@zintrust/core 0.1.21 → 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/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +1 -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/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +4 -3
- package/src/cli/scaffolding/ModelGenerator.d.ts +1 -1
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +10 -2
- 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 +2 -2
- 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 +5 -5
- package/src/config/type.d.ts +122 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/type.js +10 -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/migrations/MigrationLoader.d.ts +1 -1
- package/src/migrations/MigrationLoader.d.ts.map +1 -1
- package/src/migrations/Migrator.d.ts +3 -3
- package/src/migrations/Migrator.d.ts.map +1 -1
- package/src/migrations/Migrator.js +1 -1
- package/src/migrations/MigratorFactory.d.ts +1 -1
- package/src/migrations/MigratorFactory.d.ts.map +1 -1
- package/src/migrations/MigratorFactory.js +3 -3
- package/src/migrations/enum/index.d.ts +93 -0
- package/src/migrations/enum/index.d.ts.map +1 -0
- package/src/migrations/enum/index.js +92 -0
- package/src/migrations/schema/Blueprint.d.ts +1 -1
- package/src/migrations/schema/Blueprint.d.ts.map +1 -1
- package/src/migrations/schema/Blueprint.js +27 -25
- package/src/migrations/schema/Schema.d.ts +1 -1
- package/src/migrations/schema/Schema.d.ts.map +1 -1
- package/src/migrations/schema/Schema.js +4 -3
- package/src/migrations/schema/SchemaCompiler.d.ts +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +99 -91
- package/src/migrations/schema/index.d.ts +4 -4
- package/src/migrations/schema/index.d.ts.map +1 -1
- package/src/migrations/schema/index.js +3 -3
- package/src/migrations/schema/types.d.ts +2 -1
- package/src/migrations/schema/types.d.ts.map +1 -1
- 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 +7 -5
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +249 -93
- package/src/orm/Database.d.ts +2 -1
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/DatabaseAdapter.d.ts +3 -2
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapter.js +17 -0
- package/src/orm/Model.d.ts +8 -1
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +109 -26
- 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/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +2 -1
- package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +3 -2
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +2 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +2 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +2 -1
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +57 -18
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.js +3 -1
- 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 +15 -13
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -12
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simulate Command
|
|
3
|
-
* Internal dev tool that generates a simulated
|
|
3
|
+
* Internal dev tool that generates a simulated ZinTrust app under ./simulate/
|
|
4
4
|
* IMPORTANT: this uses the same ProjectScaffolder as `zin new`.
|
|
5
5
|
* Usage: zin -sim my-blog
|
|
6
6
|
*/
|
|
@@ -31,12 +31,12 @@ const rewriteSimulatedAppDependencyToDist = (appPath, distPath) => {
|
|
|
31
31
|
*/
|
|
32
32
|
export const SimulateCommand = {
|
|
33
33
|
name: 'simulate',
|
|
34
|
-
description: '[INTERNAL] Generate simulated
|
|
34
|
+
description: '[INTERNAL] Generate simulated ZinTrust app for testing new developer experience',
|
|
35
35
|
getCommand() {
|
|
36
36
|
const command = new Command('simulate')
|
|
37
37
|
.alias('-sim')
|
|
38
38
|
.alias('--sim')
|
|
39
|
-
.description('[INTERNAL DEV] Create a simulated
|
|
39
|
+
.description('[INTERNAL DEV] Create a simulated ZinTrust application in simulate/ folder')
|
|
40
40
|
.argument('<name>', 'Name of the simulated app')
|
|
41
41
|
.action(async (appName) => {
|
|
42
42
|
try {
|
|
@@ -51,7 +51,7 @@ export const SimulateCommand = {
|
|
|
51
51
|
template: 'basic',
|
|
52
52
|
database: 'sqlite',
|
|
53
53
|
author: 'Internal',
|
|
54
|
-
description: `Simulated
|
|
54
|
+
description: `Simulated ZinTrust app - ${appName}`,
|
|
55
55
|
});
|
|
56
56
|
if (!result.success) {
|
|
57
57
|
throw ErrorFactory.createCliError(result.message, result.error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAoavF,eAAO,MAAM,YAAY;cACb,YAAY;EAyBtB,CAAC"}
|
|
@@ -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;AAChF,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAC;AAChG,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,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,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"}
|
|
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;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,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;
|
|
1
|
+
{"version":3,"file":"ConfigSchema.d.ts","sourceRoot":"","sources":["../../../../src/cli/config/ConfigSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;IACtD,KAAK,EAAE,OAAO,CAAC;IACf,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;GAGG;AACH,eAAO,MAAM,WAAW;;;;;;;EAOtB,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgDvB,CAAC;AAEH;;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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"D1SqlMigrations.d.ts","sourceRoot":"","sources":["../../../../src/cli/d1/D1SqlMigrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"D1SqlMigrations.d.ts","sourceRoot":"","sources":["../../../../src/cli/d1/D1SqlMigrations.ts"],"names":[],"mappings":"AAYA,KAAK,6BAA6B,GAAG;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAiOF,eAAO,MAAM,eAAe;0BACE,6BAA6B,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;EAmC5F,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
2
2
|
import * as fs from '../../node-singletons/fs.js';
|
|
3
3
|
import * as path from '../../node-singletons/path.js';
|
|
4
|
+
import { AdaptersEnum } from '../../migrations/enum/index.js';
|
|
4
5
|
import { MigrationDiscovery } from '../../migrations/MigrationDiscovery.js';
|
|
5
6
|
import { MigrationLoader } from '../../migrations/MigrationLoader.js';
|
|
6
7
|
import { BaseAdapter } from '../../orm/DatabaseAdapter.js';
|
|
@@ -76,7 +77,7 @@ const createNoopAdapter = (isConnected, setConnected) => ({
|
|
|
76
77
|
return [];
|
|
77
78
|
},
|
|
78
79
|
getType() {
|
|
79
|
-
return
|
|
80
|
+
return AdaptersEnum.d1;
|
|
80
81
|
},
|
|
81
82
|
isConnected() {
|
|
82
83
|
return isConnected();
|
|
@@ -149,10 +150,10 @@ const createCaptureDb = (onSql) => {
|
|
|
149
150
|
return noopAdapter;
|
|
150
151
|
},
|
|
151
152
|
getType() {
|
|
152
|
-
return
|
|
153
|
+
return AdaptersEnum.d1;
|
|
153
154
|
},
|
|
154
155
|
getConfig() {
|
|
155
|
-
return { driver:
|
|
156
|
+
return { driver: AdaptersEnum.d1 };
|
|
156
157
|
},
|
|
157
158
|
dispose() {
|
|
158
159
|
// No resources to dispose for capture DB
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* ModelGenerator - Generate ORM model files
|
|
3
3
|
* Creates type-safe model modules with relationships and validation
|
|
4
4
|
*/
|
|
5
|
-
export type FieldType = 'string' | 'integer' | 'float' | 'boolean' | 'text' | 'datetime' | 'json' | '';
|
|
5
|
+
export type FieldType = 'string' | 'integer' | 'bigint' | 'float' | 'boolean' | 'text' | 'datetime' | 'json' | 'uuid' | '';
|
|
6
6
|
export interface ModelField {
|
|
7
7
|
name: string;
|
|
8
8
|
type: FieldType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelGenerator.d.ts","sourceRoot":"","sources":["../../../../src/cli/scaffolding/ModelGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,MAAM,SAAS,GACjB,QAAQ,GACR,S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E,MAAM,EAAE,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,CAsB3F;AAED;;GAEG;AAEH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0ClF;AAyID;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,EAAE,CAEjD;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAW5C;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,EAAE,CAU5C;AAED;;GAEG;AACH,wBAAgB,cAAc,IAAI,UAAU,EAAE,CAU7C;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;EAOzB,CAAC"}
|
|
@@ -117,13 +117,21 @@ function buildCasts(fields) {
|
|
|
117
117
|
if (fields === undefined)
|
|
118
118
|
return '';
|
|
119
119
|
const casts = fields
|
|
120
|
-
.filter((f) => f.type === 'boolean' ||
|
|
120
|
+
.filter((f) => f.type === 'boolean' ||
|
|
121
|
+
f.type === 'json' ||
|
|
122
|
+
f.type === 'datetime' ||
|
|
123
|
+
f.type === 'bigint' ||
|
|
124
|
+
f.type === 'uuid')
|
|
121
125
|
.map((f) => {
|
|
122
126
|
const castType = (() => {
|
|
123
127
|
if (f.type === 'boolean')
|
|
124
128
|
return "'boolean'";
|
|
125
129
|
if (f.type === 'json')
|
|
126
130
|
return "'json'";
|
|
131
|
+
if (f.type === 'bigint')
|
|
132
|
+
return "'bigint'";
|
|
133
|
+
if (f.type === 'uuid')
|
|
134
|
+
return "'uuid'";
|
|
127
135
|
return "'datetime'";
|
|
128
136
|
})();
|
|
129
137
|
return ` ${f.name}: ${castType},`;
|
|
@@ -193,7 +201,7 @@ function buildSoftDelete(softDelete) {
|
|
|
193
201
|
* Get common field types
|
|
194
202
|
*/
|
|
195
203
|
export function getCommonFieldTypes() {
|
|
196
|
-
return ['string', 'integer', 'float', 'boolean', 'text', 'datetime', 'json'];
|
|
204
|
+
return ['string', 'integer', 'bigint', 'float', 'boolean', 'text', 'datetime', 'json', 'uuid'];
|
|
197
205
|
}
|
|
198
206
|
/**
|
|
199
207
|
* Generate common model fields (User example)
|
|
@@ -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,CAAC;AAEnF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;
|
|
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,GA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