@zintrust/core 0.1.22 → 0.1.23
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/z.d.ts +1 -1
- package/bin/z.js +1 -1
- package/bin/zin.d.ts +1 -1
- package/bin/zin.js +1 -1
- package/bin/zintrust-main.d.ts +1 -1
- package/bin/zintrust-main.js +2 -2
- package/bin/zintrust-microservices.d.ts +1 -1
- package/bin/zintrust-microservices.js +1 -1
- package/bin/zintrust.d.ts +1 -1
- package/bin/zintrust.js +1 -1
- package/bin/zt.d.ts +1 -1
- package/bin/zt.js +1 -1
- package/package.json +2 -3
- package/public/index.html +3 -3
- package/routes/api.js +1 -1
- package/routes/health.d.ts +3 -4
- package/routes/health.d.ts.map +1 -1
- package/routes/health.js +3 -125
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +11 -22
- package/src/boot/bootstrap.d.ts +1 -1
- package/src/boot/bootstrap.js +48 -7
- package/src/builder/BundleOptimizer.d.ts +1 -1
- package/src/builder/BundleOptimizer.js +1 -1
- package/src/cache/drivers/KVRemoteDriver.d.ts +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +15 -1
- package/src/cli/ErrorHandler.js +3 -3
- package/src/cli/commands/AddCommand.d.ts +1 -1
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +1 -1
- package/src/cli/commands/DbSeedCommand.js +1 -1
- package/src/cli/commands/MakeMailTemplateCommand.js +2 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.js +2 -1
- package/src/cli/commands/MigrateWorkerCommand.d.ts +9 -0
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateWorkerCommand.js +182 -0
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +21 -7
- package/src/cli/commands/PublishCommand.d.ts +5 -0
- package/src/cli/commands/PublishCommand.d.ts.map +1 -0
- package/src/cli/commands/PublishCommand.js +54 -0
- package/src/cli/commands/QACommand.js +4 -4
- package/src/cli/commands/ResourceControlCommand.d.ts +6 -0
- package/src/cli/commands/ResourceControlCommand.d.ts.map +1 -0
- package/src/cli/commands/ResourceControlCommand.js +43 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.js +4 -4
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +19 -7
- package/src/cli/commands/UpgradeCommand.d.ts +1 -1
- package/src/cli/commands/UpgradeCommand.js +2 -2
- package/src/cli/commands/WorkerCommands.d.ts +17 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -0
- package/src/cli/commands/WorkerCommands.js +264 -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/config/ConfigSchema.d.ts +1 -1
- package/src/cli/config/ConfigSchema.d.ts.map +1 -1
- package/src/cli/config/ConfigSchema.js +4 -3
- package/src/cli/scaffolding/ProjectScaffolder.js +5 -5
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +21 -2
- package/src/cli/scaffolding/TemplateEngine.js +1 -1
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/common/ExternalServiceUtils.d.ts +63 -0
- package/src/common/ExternalServiceUtils.d.ts.map +1 -0
- package/src/common/ExternalServiceUtils.js +116 -0
- package/src/common/HealthRoutes.d.ts +10 -0
- package/src/common/HealthRoutes.d.ts.map +1 -0
- package/src/common/HealthRoutes.js +114 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +2 -1
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +98 -52
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +1 -1
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +2 -2
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +24 -5
- package/src/config/env.d.ts +43 -1
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +68 -21
- package/src/config/index.d.ts +10 -1
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +1 -0
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +3 -3
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +1 -1
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +2 -2
- package/src/config/queue.d.ts +14 -0
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +61 -36
- package/src/config/security.js +2 -2
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -1
- package/src/config/type.d.ts +111 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts +13 -0
- package/src/config/workers.d.ts.map +1 -0
- package/src/config/workers.js +173 -0
- package/src/database/Paginator.d.ts +37 -0
- package/src/database/Paginator.d.ts.map +1 -0
- package/src/database/Paginator.js +81 -0
- package/src/exceptions/ZintrustError.d.ts +5 -2
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +6 -2
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -2
- package/src/features/Queue.d.ts.map +1 -1
- package/src/features/Queue.js +0 -2
- package/src/index.d.ts +15 -5
- package/src/index.d.ts.map +1 -1
- package/src/index.js +24 -3
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
- package/src/microservices/MicroserviceBootstrap.js +3 -1
- package/src/microservices/MicroserviceGenerator.js +4 -4
- package/src/microservices/MicroserviceManager.d.ts +1 -1
- package/src/microservices/MicroserviceManager.js +1 -1
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/RateLimiter.js +4 -3
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/os.d.ts +10 -1
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +10 -1
- package/src/openapi/OpenApiGenerator.js +2 -2
- package/src/orm/ConnectionManager.d.ts +1 -1
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +37 -19
- package/src/orm/Model.d.ts +8 -1
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +85 -24
- package/src/orm/QueryBuilder.d.ts +12 -2
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +438 -38
- package/src/orm/Relationships.d.ts +61 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +190 -0
- package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +2 -4
- package/src/routing/CoreRoutes.d.ts +1 -1
- package/src/routing/CoreRoutes.d.ts.map +1 -1
- package/src/routing/CoreRoutes.js +2 -116
- package/src/routing/error.d.ts.map +1 -1
- package/src/routing/error.js +3 -2
- package/src/routing/publicRoot.d.ts.map +1 -1
- package/src/routing/publicRoot.js +4 -2
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +20 -4
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +23 -6
- package/src/runtime/RuntimeAdapter.d.ts +3 -3
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +2 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +2 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/FargateAdapter.d.ts +2 -2
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +6 -4
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/scripts/GenerateEnvArtifacts.js +1 -1
- package/src/security/SignedRequest.js +1 -1
- package/src/security/StartupSecretValidation.d.ts.map +1 -1
- package/src/security/StartupSecretValidation.js +7 -1
- package/src/start.d.ts.map +1 -1
- package/src/start.js +0 -2
- package/src/templates/features/Auth.ts.tpl +4 -4
- package/src/templates/project/basic/README.md.tpl +1 -1
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
- package/src/templates/project/basic/config/notification.ts.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +1 -3
- package/src/templates/project/basic/src/index.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.ts.tpl +1 -1
- package/src/templates/project/basic/template.json +1 -1
- package/src/toolkit/Secrets/index.d.ts.map +1 -1
- package/src/toolkit/Secrets/index.js +13 -9
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +20 -7
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/CloudflareKv.js +19 -6
- package/src/tools/http/Http.js +1 -1
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -1
- package/src/tools/mail/drivers/Ses.js +5 -4
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -1
- package/src/tools/notification/drivers/Termii.js +6 -17
- package/src/tools/notification/testingHelpers.d.ts.map +1 -1
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +3 -5
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +7 -1
- package/src/tools/storage/drivers/S3.d.ts.map +1 -1
- package/src/tools/storage/drivers/S3.js +16 -3
- package/src/routes/health.d.ts +0 -2
- package/src/routes/health.d.ts.map +0 -1
- package/src/routes/health.js +0 -1
- package/src/runtime/RuntimeDetector.d.ts +0 -15
- package/src/runtime/RuntimeDetector.d.ts.map +0 -1
- package/src/runtime/RuntimeDetector.js +0 -271
- package/src/templates/project/basic/routes/health.ts.tpl +0 -143
- package/src/templates/project/basic/routes/metrics.ts.tpl +0 -22
- package/src/workers/BroadcastWorker.d.ts +0 -22
- package/src/workers/BroadcastWorker.d.ts.map +0 -1
- package/src/workers/BroadcastWorker.js +0 -24
- package/src/workers/NotificationWorker.d.ts +0 -22
- package/src/workers/NotificationWorker.d.ts.map +0 -1
- package/src/workers/NotificationWorker.js +0 -23
- package/src/workers/createQueueWorker.d.ts +0 -24
- package/src/workers/createQueueWorker.d.ts.map +0 -1
- package/src/workers/createQueueWorker.js +0 -114
|
@@ -3,6 +3,7 @@ import { DENO_RUNNER_SOURCE, LAMBDA_RUNNER_SOURCE } from '../commands/runner/ind
|
|
|
3
3
|
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
4
4
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
5
5
|
import { resolveNpmPath } from '../../common/index.js';
|
|
6
|
+
import { Env } from '../../config/env.js';
|
|
6
7
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
7
8
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from '../../node-singletons/fs.js';
|
|
8
9
|
import * as path from '../../node-singletons/path.js';
|
|
@@ -19,8 +20,20 @@ const normalizeMode = (value) => {
|
|
|
19
20
|
return 'testing';
|
|
20
21
|
return 'development';
|
|
21
22
|
};
|
|
23
|
+
const readEnvString = (key) => {
|
|
24
|
+
const anyEnv = Env;
|
|
25
|
+
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
26
|
+
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
27
|
+
return fromEnv;
|
|
28
|
+
if (typeof process !== 'undefined') {
|
|
29
|
+
const raw = process.env?.[key];
|
|
30
|
+
if (typeof raw === 'string')
|
|
31
|
+
return raw;
|
|
32
|
+
}
|
|
33
|
+
return fromEnv ?? '';
|
|
34
|
+
};
|
|
22
35
|
const resolveModeFromAppMode = () => {
|
|
23
|
-
const raw =
|
|
36
|
+
const raw = readEnvString('APP_MODE').trim();
|
|
24
37
|
const normalized = raw.toLowerCase();
|
|
25
38
|
if (normalized === 'production' || normalized === 'pro' || normalized === 'prod') {
|
|
26
39
|
return 'production';
|
|
@@ -46,13 +59,12 @@ const resolvePort = (options) => {
|
|
|
46
59
|
}
|
|
47
60
|
return parsed;
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (envPort === '')
|
|
62
|
+
const envPortRaw = process.env['APP_PORT'] ?? process.env['PORT'] ?? '';
|
|
63
|
+
if (envPortRaw === '')
|
|
52
64
|
return undefined;
|
|
53
|
-
const parsed = Number.parseInt(
|
|
65
|
+
const parsed = Number.parseInt(String(envPortRaw), 10);
|
|
54
66
|
if (!Number.isFinite(parsed) || parsed <= 0 || parsed >= 65536) {
|
|
55
|
-
throw ErrorFactory.createCliError(`Error: Invalid APP_PORT/PORT '${
|
|
67
|
+
throw ErrorFactory.createCliError(`Error: Invalid APP_PORT/PORT '${envPortRaw}'. Expected 1-65535.`);
|
|
56
68
|
}
|
|
57
69
|
return parsed;
|
|
58
70
|
};
|
|
@@ -94,7 +106,7 @@ const resolveWatchPreference = (options, mode) => {
|
|
|
94
106
|
const readPackageJson = (cwd) => {
|
|
95
107
|
const packagePath = path.join(cwd, 'package.json');
|
|
96
108
|
if (!existsSync(packagePath)) {
|
|
97
|
-
throw ErrorFactory.createCliError("Error: No
|
|
109
|
+
throw ErrorFactory.createCliError("Error: No ZinTrust app found. Run 'zin new <project>' or ensure package.json exists.");
|
|
98
110
|
}
|
|
99
111
|
try {
|
|
100
112
|
const raw = readFileSync(packagePath, 'utf-8');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Upgrade Command
|
|
3
3
|
*
|
|
4
|
-
* Goal: help existing
|
|
4
|
+
* Goal: help existing ZinTrust projects adopt new safe defaults without forcing
|
|
5
5
|
* a full re-scaffold.
|
|
6
6
|
*
|
|
7
7
|
* Current scope (minimal/safe):
|
|
@@ -81,7 +81,7 @@ export const UpgradeCommand = Object.freeze({
|
|
|
81
81
|
create() {
|
|
82
82
|
return BaseCommand.create({
|
|
83
83
|
name: 'upgrade',
|
|
84
|
-
description: 'Upgrade an existing
|
|
84
|
+
description: 'Upgrade an existing ZinTrust project in-place (safe, non-destructive)',
|
|
85
85
|
addOptions: (command) => {
|
|
86
86
|
command.option('--cwd <path>', 'Project directory (default: current working directory)');
|
|
87
87
|
command.option('--dry-run', 'Print planned changes without writing files');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Worker Management CLI Commands
|
|
3
|
+
* Command-line interface for managing workers
|
|
4
|
+
*/
|
|
5
|
+
import type { IBaseCommand } from '../BaseCommand';
|
|
6
|
+
/**
|
|
7
|
+
* Export worker command creators
|
|
8
|
+
*/
|
|
9
|
+
export declare const WorkerCommands: {
|
|
10
|
+
createWorkerListCommand: () => IBaseCommand;
|
|
11
|
+
createWorkerStatusCommand: () => IBaseCommand;
|
|
12
|
+
createWorkerStartCommand: () => IBaseCommand;
|
|
13
|
+
createWorkerStopCommand: () => IBaseCommand;
|
|
14
|
+
createWorkerRestartCommand: () => IBaseCommand;
|
|
15
|
+
createWorkerSummaryCommand: () => IBaseCommand;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=WorkerCommands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerCommands.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/WorkerCommands.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0UrD;;GAEG;AACH,eAAO,MAAM,cAAc;mCAhPS,YAAY;qCA2CV,YAAY;oCAiDb,YAAY;mCA+Bb,YAAY;sCAgCT,YAAY;sCAgCZ,YAAY;CA4DlD,CAAC"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
/**
|
|
3
|
+
* Worker Management CLI Commands
|
|
4
|
+
* Command-line interface for managing workers
|
|
5
|
+
*/
|
|
6
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
7
|
+
import { Logger } from '../../config/logger.js';
|
|
8
|
+
import { HealthMonitor as HealthMonitorAny, ResourceMonitor as ResourceMonitorAny, WorkerFactory as WorkerFactoryAny, WorkerRegistry as WorkerRegistryAny, } from '../../../packages/workers/src/index.js';
|
|
9
|
+
// Lazy initialization to prevent temporal dead zone issues
|
|
10
|
+
let WorkerFactory;
|
|
11
|
+
let WorkerRegistry;
|
|
12
|
+
let HealthMonitor;
|
|
13
|
+
let ResourceMonitor;
|
|
14
|
+
const getWorkerFactory = () => {
|
|
15
|
+
WorkerFactory ??= WorkerFactoryAny;
|
|
16
|
+
return WorkerFactory;
|
|
17
|
+
};
|
|
18
|
+
const getWorkerRegistry = () => {
|
|
19
|
+
WorkerRegistry ??= WorkerRegistryAny;
|
|
20
|
+
return WorkerRegistry;
|
|
21
|
+
};
|
|
22
|
+
const getHealthMonitor = () => {
|
|
23
|
+
HealthMonitor ??= HealthMonitorAny;
|
|
24
|
+
return HealthMonitor;
|
|
25
|
+
};
|
|
26
|
+
const getResourceMonitor = () => {
|
|
27
|
+
ResourceMonitor ??= ResourceMonitorAny;
|
|
28
|
+
return ResourceMonitor;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Helper: Format table output
|
|
32
|
+
*/
|
|
33
|
+
const formatTable = (headers, rows) => {
|
|
34
|
+
const columnWidths = headers.map((h, i) => {
|
|
35
|
+
const maxRowWidth = Math.max(...rows.map((r) => (r[i] || '').length));
|
|
36
|
+
return Math.max(h.length, maxRowWidth);
|
|
37
|
+
});
|
|
38
|
+
const headerRow = headers.map((h, i) => h.padEnd(columnWidths[i])).join(' | ');
|
|
39
|
+
const separator = columnWidths.map((w) => '-'.repeat(w)).join('-+-');
|
|
40
|
+
const dataRows = rows.map((row) => row.map((cell, i) => (cell || '').padEnd(columnWidths[i])).join(' | '));
|
|
41
|
+
return [headerRow, separator, ...dataRows].join('\n');
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Worker List Command
|
|
45
|
+
*/
|
|
46
|
+
const createWorkerListCommand = () => {
|
|
47
|
+
const ext = async () => {
|
|
48
|
+
try {
|
|
49
|
+
const workers = await getWorkerFactory().listPersisted();
|
|
50
|
+
console.log(`\nTotal Workers: ${workers.length}\n`);
|
|
51
|
+
if (workers.length === 0) {
|
|
52
|
+
console.log('No workers found.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const rows = workers.map((name) => {
|
|
56
|
+
const status = getWorkerRegistry().status(name);
|
|
57
|
+
return [
|
|
58
|
+
name,
|
|
59
|
+
status?.status ?? 'unknown',
|
|
60
|
+
status?.version ?? 'N/A',
|
|
61
|
+
status?.queueName ?? 'N/A',
|
|
62
|
+
String(status?.concurrency ?? 0),
|
|
63
|
+
];
|
|
64
|
+
});
|
|
65
|
+
console.log(formatTable(['Name', 'Status', 'Version', 'Queue', 'Concurrency'], rows));
|
|
66
|
+
console.log();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
Logger.error('worker:list command failed', error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const cmd = BaseCommand.create({
|
|
74
|
+
name: 'worker:list',
|
|
75
|
+
description: 'List all workers',
|
|
76
|
+
execute: async () => ext(),
|
|
77
|
+
});
|
|
78
|
+
return cmd;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Worker Status Command
|
|
82
|
+
*/
|
|
83
|
+
const createWorkerStatusCommand = () => {
|
|
84
|
+
const ext = async (name) => {
|
|
85
|
+
try {
|
|
86
|
+
if (!name) {
|
|
87
|
+
Logger.error('Error: Worker name is required');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
const status = getWorkerRegistry().status(name);
|
|
91
|
+
const health = await getWorkerFactory().getHealth(name);
|
|
92
|
+
const healthData = typeof health === 'object' && health !== null
|
|
93
|
+
? health
|
|
94
|
+
: {};
|
|
95
|
+
const metrics = await getWorkerFactory().getMetrics(name);
|
|
96
|
+
console.log(`\n=== Worker: ${name} ===\n`);
|
|
97
|
+
console.log(`Status: ${status?.status}`);
|
|
98
|
+
console.log(`Version: ${status?.version}`);
|
|
99
|
+
console.log(`Queue: ${status?.queueName}`);
|
|
100
|
+
console.log(`Region: ${status?.region ?? 'N/A'}`);
|
|
101
|
+
console.log(`Started: ${status?.startedAt}`);
|
|
102
|
+
console.log(`Concurrency: ${status?.concurrency}`);
|
|
103
|
+
console.log(`\nHealth Score: ${healthData.score ?? 'N/A'}`);
|
|
104
|
+
console.log(`Health Status: ${healthData.status ?? 'N/A'}`);
|
|
105
|
+
console.log(`\nMetrics:`);
|
|
106
|
+
console.log(JSON.stringify(metrics, null, 2));
|
|
107
|
+
console.log();
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
Logger.error('worker:status command failed', error);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const cmd = BaseCommand.create({
|
|
115
|
+
name: 'worker:status',
|
|
116
|
+
description: 'Get detailed status of a worker',
|
|
117
|
+
addOptions: (command) => {
|
|
118
|
+
command.argument('<name>', 'Worker name');
|
|
119
|
+
},
|
|
120
|
+
execute: async (options) => ext(options.args?.[0] ?? ''),
|
|
121
|
+
});
|
|
122
|
+
return cmd;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Worker Start Command
|
|
126
|
+
*/
|
|
127
|
+
const createWorkerStartCommand = () => {
|
|
128
|
+
const ext = async (name) => {
|
|
129
|
+
try {
|
|
130
|
+
if (!name) {
|
|
131
|
+
Logger.error('Error: Worker name is required');
|
|
132
|
+
process.exit(1);
|
|
133
|
+
}
|
|
134
|
+
await getWorkerFactory().start(name);
|
|
135
|
+
Logger.info(`✓ Worker "${name}" started successfully`);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
Logger.error('worker:start command failed', error);
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const cmd = BaseCommand.create({
|
|
143
|
+
name: 'worker:start',
|
|
144
|
+
description: 'Start a worker',
|
|
145
|
+
addOptions: (command) => {
|
|
146
|
+
command.argument('<name>', 'Worker name');
|
|
147
|
+
},
|
|
148
|
+
execute: async (options) => ext(options.args?.[0] ?? ''),
|
|
149
|
+
});
|
|
150
|
+
return cmd;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Worker Stop Command
|
|
154
|
+
*/
|
|
155
|
+
const createWorkerStopCommand = () => {
|
|
156
|
+
const ext = async (name) => {
|
|
157
|
+
try {
|
|
158
|
+
if (!name) {
|
|
159
|
+
console.error('Error: Worker name is required');
|
|
160
|
+
process.exit(1);
|
|
161
|
+
}
|
|
162
|
+
await getWorkerFactory().stop(name);
|
|
163
|
+
console.log(`✓ Worker "${name}" stopped successfully`);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
Logger.error('worker:stop command failed', error);
|
|
167
|
+
console.error(`Error: ${error.message}`);
|
|
168
|
+
process.exit(1);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
const cmd = BaseCommand.create({
|
|
172
|
+
name: 'worker:stop',
|
|
173
|
+
description: 'Stop a worker',
|
|
174
|
+
addOptions: (command) => {
|
|
175
|
+
command.argument('<name>', 'Worker name');
|
|
176
|
+
},
|
|
177
|
+
execute: async (options) => ext(options.args?.[0] ?? ''),
|
|
178
|
+
});
|
|
179
|
+
return cmd;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Worker Restart Command
|
|
183
|
+
*/
|
|
184
|
+
const createWorkerRestartCommand = () => {
|
|
185
|
+
const ext = async (name) => {
|
|
186
|
+
try {
|
|
187
|
+
if (!name) {
|
|
188
|
+
console.error('Error: Worker name is required');
|
|
189
|
+
process.exit(1);
|
|
190
|
+
}
|
|
191
|
+
await getWorkerFactory().restart(name);
|
|
192
|
+
console.log(`✓ Worker "${name}" restarted successfully`);
|
|
193
|
+
}
|
|
194
|
+
catch (error) {
|
|
195
|
+
Logger.error('worker:restart command failed', error);
|
|
196
|
+
console.error(`Error: ${error.message}`);
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const cmd = BaseCommand.create({
|
|
201
|
+
name: 'worker:restart',
|
|
202
|
+
description: 'Restart a worker',
|
|
203
|
+
addOptions: (command) => {
|
|
204
|
+
command.argument('<name>', 'Worker name');
|
|
205
|
+
},
|
|
206
|
+
execute: async (options) => ext(options.args?.[0] ?? ''),
|
|
207
|
+
});
|
|
208
|
+
return cmd;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Worker Summary Command
|
|
212
|
+
*/
|
|
213
|
+
const createWorkerSummaryCommand = () => {
|
|
214
|
+
const ext = () => {
|
|
215
|
+
try {
|
|
216
|
+
const workers = getWorkerFactory().list();
|
|
217
|
+
const monitoringSummary = getHealthMonitor().getSummary();
|
|
218
|
+
const resourceUsage = getResourceMonitor().getCurrentUsage('system');
|
|
219
|
+
console.log(`\n=== Worker System Summary ===\n`);
|
|
220
|
+
console.log(`Total Workers: ${workers.length}`);
|
|
221
|
+
console.log(`\nHealth Overview:`);
|
|
222
|
+
const healthCounts = {
|
|
223
|
+
healthy: 0,
|
|
224
|
+
degraded: 0,
|
|
225
|
+
unhealthy: 0,
|
|
226
|
+
critical: 0,
|
|
227
|
+
};
|
|
228
|
+
monitoringSummary.forEach((w) => {
|
|
229
|
+
healthCounts[w.status]++;
|
|
230
|
+
});
|
|
231
|
+
console.log(` Healthy: ${healthCounts.healthy}`);
|
|
232
|
+
console.log(` Degraded: ${healthCounts.degraded}`);
|
|
233
|
+
console.log(` Unhealthy: ${healthCounts.unhealthy}`);
|
|
234
|
+
console.log(` Critical: ${healthCounts.critical}`);
|
|
235
|
+
console.log(`\nSystem Resources:`);
|
|
236
|
+
console.log(` CPU: ${resourceUsage.cpu.toFixed(1)}%`);
|
|
237
|
+
console.log(` Memory: ${resourceUsage.memory.percent.toFixed(1)}% (${(resourceUsage.memory.used / 1024 / 1024 / 1024).toFixed(2)} GB used)`);
|
|
238
|
+
console.log(` Cost (hourly): $${resourceUsage.cost.hourly.toFixed(2)}`);
|
|
239
|
+
console.log(` Cost (daily): $${resourceUsage.cost.daily.toFixed(2)}`);
|
|
240
|
+
console.log();
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
Logger.error('worker:summary command failed', error);
|
|
244
|
+
process.exit(1);
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const cmd = BaseCommand.create({
|
|
248
|
+
name: 'worker:summary',
|
|
249
|
+
description: 'Get system-wide worker summary',
|
|
250
|
+
execute: () => ext(),
|
|
251
|
+
});
|
|
252
|
+
return cmd;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* Export worker command creators
|
|
256
|
+
*/
|
|
257
|
+
export const WorkerCommands = {
|
|
258
|
+
createWorkerListCommand,
|
|
259
|
+
createWorkerStatusCommand,
|
|
260
|
+
createWorkerStartCommand,
|
|
261
|
+
createWorkerStopCommand,
|
|
262
|
+
createWorkerRestartCommand,
|
|
263
|
+
createWorkerSummaryCommand,
|
|
264
|
+
};
|
|
@@ -11,10 +11,12 @@ export { LogsCleanupCommand } from '../commands/LogsCleanupCommand';
|
|
|
11
11
|
export { MakeMailTemplateCommand } from '../commands/MakeMailTemplateCommand';
|
|
12
12
|
export { MakeNotificationTemplateCommand } from '../commands/MakeNotificationTemplateCommand';
|
|
13
13
|
export { MigrateCommand } from '../commands/MigrateCommand';
|
|
14
|
+
export { MigrateWorkerCommand } from '../commands/MigrateWorkerCommand';
|
|
14
15
|
export { NewCommand } from '../commands/NewCommand';
|
|
15
16
|
export { NotificationWorkCommand } from '../commands/NotificationWorkCommand';
|
|
16
17
|
export { PrepareCommand } from '../commands/PrepareCommand';
|
|
17
18
|
export { QueueCommand } from '../commands/QueueCommand';
|
|
19
|
+
export { ResourceControlCommand } from '../commands/ResourceControlCommand';
|
|
18
20
|
export { RoutesCommand } from '../commands/RoutesCommand';
|
|
19
21
|
export { SecretsCommand } from '../commands/SecretsCommand';
|
|
20
22
|
export { StartCommand } from '../commands/StartCommand';
|
|
@@ -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,EACL,mBAAmB,EACnB,aAAa,EACb,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AA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AE,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,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"}
|
|
@@ -11,10 +11,12 @@ export { LogsCleanupCommand } from '../commands/LogsCleanupCommand.js';
|
|
|
11
11
|
export { MakeMailTemplateCommand } from '../commands/MakeMailTemplateCommand.js';
|
|
12
12
|
export { MakeNotificationTemplateCommand } from '../commands/MakeNotificationTemplateCommand.js';
|
|
13
13
|
export { MigrateCommand } from '../commands/MigrateCommand.js';
|
|
14
|
+
export { MigrateWorkerCommand } from '../commands/MigrateWorkerCommand.js';
|
|
14
15
|
export { NewCommand } from '../commands/NewCommand.js';
|
|
15
16
|
export { NotificationWorkCommand } from '../commands/NotificationWorkCommand.js';
|
|
16
17
|
export { PrepareCommand } from '../commands/PrepareCommand.js';
|
|
17
18
|
export { QueueCommand } from '../commands/QueueCommand.js';
|
|
19
|
+
export { ResourceControlCommand } from '../commands/ResourceControlCommand.js';
|
|
18
20
|
export { RoutesCommand } from '../commands/RoutesCommand.js';
|
|
19
21
|
export { SecretsCommand } from '../commands/SecretsCommand.js';
|
|
20
22
|
export { StartCommand } from '../commands/StartCommand.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigSchema.d.ts","sourceRoot":"","sources":["../../../../src/cli/config/ConfigSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
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AEH;;GAEG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAapD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAgB/F;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAiBlF"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration Schema
|
|
3
|
-
* Defines the structure and types for
|
|
3
|
+
* Defines the structure and types for ZinTrust configuration
|
|
4
4
|
*/
|
|
5
|
+
import { Env } from '../../config/env.js';
|
|
5
6
|
/**
|
|
6
7
|
* Default configuration values
|
|
7
8
|
*/
|
|
8
9
|
export const DEFAULT_CONFIG = Object.freeze({
|
|
9
10
|
name: 'zintrust-app',
|
|
10
11
|
version: '1.0.0',
|
|
11
|
-
description: 'A
|
|
12
|
+
description: 'A ZinTrust application',
|
|
12
13
|
author: 'Developer',
|
|
13
14
|
database: {
|
|
14
15
|
connection: 'sqlite',
|
|
@@ -50,7 +51,7 @@ export const DEFAULT_CONFIG = Object.freeze({
|
|
|
50
51
|
/**
|
|
51
52
|
* Configuration paths
|
|
52
53
|
*/
|
|
53
|
-
const HOME_DIR =
|
|
54
|
+
const HOME_DIR = Env.HOME || Env.USERPROFILE || '';
|
|
54
55
|
const GLOBAL_DIR = `${HOME_DIR}/.zintrust`;
|
|
55
56
|
/**
|
|
56
57
|
* Configuration paths
|
|
@@ -352,7 +352,7 @@ const loadTemplateFromDisk = (templateName, fallback) => {
|
|
|
352
352
|
*/
|
|
353
353
|
const BASIC_TEMPLATE = {
|
|
354
354
|
name: 'basic',
|
|
355
|
-
description: 'Basic
|
|
355
|
+
description: 'Basic ZinTrust project structure',
|
|
356
356
|
directories: [
|
|
357
357
|
'config',
|
|
358
358
|
'app/Controllers',
|
|
@@ -373,7 +373,7 @@ const BASIC_TEMPLATE = {
|
|
|
373
373
|
};
|
|
374
374
|
const API_TEMPLATE = {
|
|
375
375
|
name: 'api',
|
|
376
|
-
description: 'API-focused
|
|
376
|
+
description: 'API-focused ZinTrust project structure',
|
|
377
377
|
directories: [
|
|
378
378
|
'app/Controllers',
|
|
379
379
|
'app/Middleware',
|
|
@@ -389,7 +389,7 @@ const API_TEMPLATE = {
|
|
|
389
389
|
};
|
|
390
390
|
const MICROSERVICE_TEMPLATE = {
|
|
391
391
|
name: 'microservice',
|
|
392
|
-
description: 'Microservice-focused
|
|
392
|
+
description: 'Microservice-focused ZinTrust project structure',
|
|
393
393
|
directories: [
|
|
394
394
|
'app/Controllers',
|
|
395
395
|
'app/Middleware',
|
|
@@ -406,7 +406,7 @@ const MICROSERVICE_TEMPLATE = {
|
|
|
406
406
|
};
|
|
407
407
|
const FULLSTACK_TEMPLATE = {
|
|
408
408
|
name: 'fullstack',
|
|
409
|
-
description: 'Fullstack
|
|
409
|
+
description: 'Fullstack ZinTrust project structure',
|
|
410
410
|
directories: [
|
|
411
411
|
'app/Controllers',
|
|
412
412
|
'app/Middleware',
|
|
@@ -521,7 +521,7 @@ tmp/
|
|
|
521
521
|
if (!Object.hasOwn(files, 'README.md')) {
|
|
522
522
|
files['README.md'] = `# {{projectName}}
|
|
523
523
|
|
|
524
|
-
Starter Task API built with
|
|
524
|
+
Starter Task API built with ZinTrust.
|
|
525
525
|
|
|
526
526
|
## Run
|
|
527
527
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouteGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/RouteGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,MAAM,MAAM,WAAW,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,C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CAAA;CAAE,CAqB3F;AAED;;GAEG;AAEH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4CnF;AA+LD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,eAAe,EAAE,CAsCpD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,eAAe,EAAE,CA6BjD;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,eAAe,EAAE,CA+BlD;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,EAAE,CAEhD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;EAOzB,CAAC"}
|
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
6
6
|
import { Logger } from '../../config/logger.js';
|
|
7
7
|
import * as path from '../../node-singletons/path.js';
|
|
8
|
+
// Escape characters that can cause issues when embedding JSON.stringify output
|
|
9
|
+
// into generated JavaScript source (e.g., inside <script> tags).
|
|
10
|
+
const unsafeCharMap = {
|
|
11
|
+
'<': '\\u003C',
|
|
12
|
+
'>': '\\u003E',
|
|
13
|
+
'/': '\\u002F',
|
|
14
|
+
'\\': '\\\\',
|
|
15
|
+
'\b': '\\b',
|
|
16
|
+
'\f': '\\f',
|
|
17
|
+
'\n': '\\n',
|
|
18
|
+
'\r': '\\r',
|
|
19
|
+
'\t': '\\t',
|
|
20
|
+
'\0': '\\0',
|
|
21
|
+
'\u2028': '\\u2028',
|
|
22
|
+
'\u2029': '\\u2029',
|
|
23
|
+
};
|
|
24
|
+
function escapeUnsafeChars(str) {
|
|
25
|
+
return str.replace(/[<>/\\\b\f\n\r\t\0\u2028\u2029]/g, (ch) => unsafeCharMap[ch] ?? ch);
|
|
26
|
+
}
|
|
8
27
|
/**
|
|
9
28
|
* Validate route options
|
|
10
29
|
*/
|
|
@@ -181,7 +200,7 @@ function buildMethodRoute(route, router, groupMiddlewareList) {
|
|
|
181
200
|
.filter((v) => v.trim() !== '')
|
|
182
201
|
.join(', ')}]`
|
|
183
202
|
: '';
|
|
184
|
-
const metaProp = `meta: { summary: ${JSON.stringify(summary)}, tags: [${JSON.stringify(tag)}] }`;
|
|
203
|
+
const metaProp = `meta: { summary: ${escapeUnsafeChars(JSON.stringify(summary))}, tags: [${escapeUnsafeChars(JSON.stringify(tag))}] }`;
|
|
185
204
|
const options = `{ ${[middlewareProp, metaProp].filter((v) => v !== '').join(', ')} }`;
|
|
186
205
|
return ` Router.${method}(${router}, '${routePath}', (req, res) => ${controllerVar}.${action}(req, res), ${options});\n`;
|
|
187
206
|
}
|
|
@@ -201,7 +220,7 @@ function buildResourceRoute(route, router, groupMiddlewareList) {
|
|
|
201
220
|
.filter((v) => v.trim() !== '')
|
|
202
221
|
.join(', ')}]`
|
|
203
222
|
: '';
|
|
204
|
-
const resourceMeta = (action, routePattern) => `meta: { summary: ${JSON.stringify(action.toUpperCase() + ' ' + routePattern)}, tags: [${JSON.stringify(tag)}] }`;
|
|
223
|
+
const resourceMeta = (action, routePattern) => `meta: { summary: ${escapeUnsafeChars(JSON.stringify(action.toUpperCase() + ' ' + routePattern))}, tags: [${escapeUnsafeChars(JSON.stringify(tag))}] }`;
|
|
205
224
|
const pathId = routePath + '/:id';
|
|
206
225
|
const optsParts = [
|
|
207
226
|
middlewareProp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnvFileLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/EnvFileLoader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EnvFileLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/EnvFileLoader.ts"],"names":[],"mappings":"AAgHA,KAAK,WAAW,GAAG;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAsFF,eAAO,MAAM,aAAa;qBA7DH,WAAW,KAAQ,SAAS;wBA8B1B,SAAS;mCAEI,YAAY,KAAG,IAAI;oBA2BpC,SAAS;EAO5B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Utilities for External Service Drivers
|
|
3
|
+
* Common patterns for API calls, environment variable reading, and error handling
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Environment variable reader with fallback support
|
|
7
|
+
* Handles both Env.get() and process.env for maximum compatibility
|
|
8
|
+
*/
|
|
9
|
+
export declare const readEnvString: (key: string, fallback?: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Validate required parameters for external service calls
|
|
12
|
+
*/
|
|
13
|
+
export declare const validateRequiredParams: (params: Record<string, unknown>, required: string[]) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Create standardized API error response
|
|
16
|
+
*/
|
|
17
|
+
export declare const createApiError: (message: string, service: string) => Error;
|
|
18
|
+
/**
|
|
19
|
+
* Common fetch wrapper with error handling
|
|
20
|
+
*/
|
|
21
|
+
export declare const safeFetch: (url: string, options: RequestInit) => Promise<Response>;
|
|
22
|
+
/**
|
|
23
|
+
* Standard API response builder
|
|
24
|
+
*/
|
|
25
|
+
export declare const buildApiResponse: <T>(success: boolean, data?: T, error?: string) => {
|
|
26
|
+
success: boolean;
|
|
27
|
+
data?: T;
|
|
28
|
+
error?: string;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Health check utilities
|
|
32
|
+
*/
|
|
33
|
+
export declare const HealthUtils: {
|
|
34
|
+
/**
|
|
35
|
+
* Get process uptime safely
|
|
36
|
+
*/
|
|
37
|
+
getUptime(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Get current timestamp
|
|
40
|
+
*/
|
|
41
|
+
getTimestamp(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Check if in production
|
|
44
|
+
*/
|
|
45
|
+
isProduction(environment: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Build health response
|
|
48
|
+
*/
|
|
49
|
+
buildHealthResponse(status: "healthy" | "unhealthy" | "alive" | "ready" | "not_ready", environment: string, extra?: Record<string, unknown>): {
|
|
50
|
+
status: "unhealthy" | "ready" | "healthy" | "alive" | "not_ready";
|
|
51
|
+
timestamp: string;
|
|
52
|
+
environment: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Build error health response
|
|
56
|
+
*/
|
|
57
|
+
buildErrorResponse(status: "unhealthy" | "not_ready", environment: string, error: Error, extra?: Record<string, unknown>): {
|
|
58
|
+
status: "unhealthy" | "ready" | "healthy" | "alive" | "not_ready";
|
|
59
|
+
timestamp: string;
|
|
60
|
+
environment: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=ExternalServiceUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExternalServiceUtils.d.ts","sourceRoot":"","sources":["../../../src/common/ExternalServiceUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;;GAGG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,EAAE,iBAAa,KAAG,MAS1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GACjC,QAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,UAAU,MAAM,EAAE,KACjB,IAWF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,SAAS,MAAM,KAAG,KAEjE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,GAAU,KAAK,MAAM,EAAE,SAAS,WAAW,KAAG,OAAO,CAAC,QAAQ,CAcnF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,EAChC,SAAS,OAAO,EAChB,OAAO,CAAC,EACR,QAAQ,MAAM,KACb;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAY9C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;iBACU,MAAM;IAMnB;;OAEG;oBACa,MAAM;IAItB;;OAEG;8BACuB,MAAM,GAAG,OAAO;IAI1C;;OAEG;gCAEO,SAAS,GAAG,WAAW,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,eACpD,MAAM,UACX,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;IAYjC;;OAEG;+BAEO,WAAW,GAAG,WAAW,eACpB,MAAM,SACZ,KAAK,UACJ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;CASlC,CAAC"}
|