@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.
Files changed (229) hide show
  1. package/bin/z.d.ts +1 -1
  2. package/bin/z.js +1 -1
  3. package/bin/zin.d.ts +1 -1
  4. package/bin/zin.js +1 -1
  5. package/bin/zintrust-main.d.ts +1 -1
  6. package/bin/zintrust-main.js +2 -2
  7. package/bin/zintrust-microservices.d.ts +1 -1
  8. package/bin/zintrust-microservices.js +1 -1
  9. package/bin/zintrust.d.ts +1 -1
  10. package/bin/zintrust.js +1 -1
  11. package/bin/zt.d.ts +1 -1
  12. package/bin/zt.js +1 -1
  13. package/package.json +2 -3
  14. package/public/index.html +3 -3
  15. package/routes/api.js +1 -1
  16. package/routes/health.d.ts +3 -4
  17. package/routes/health.d.ts.map +1 -1
  18. package/routes/health.js +3 -125
  19. package/src/boot/Application.d.ts.map +1 -1
  20. package/src/boot/Application.js +11 -22
  21. package/src/boot/bootstrap.d.ts +1 -1
  22. package/src/boot/bootstrap.js +48 -7
  23. package/src/builder/BundleOptimizer.d.ts +1 -1
  24. package/src/builder/BundleOptimizer.js +1 -1
  25. package/src/cache/drivers/KVRemoteDriver.d.ts +1 -1
  26. package/src/cache/drivers/KVRemoteDriver.js +1 -1
  27. package/src/cli/CLI.d.ts.map +1 -1
  28. package/src/cli/CLI.js +15 -1
  29. package/src/cli/ErrorHandler.js +3 -3
  30. package/src/cli/commands/AddCommand.d.ts +1 -1
  31. package/src/cli/commands/AddCommand.d.ts.map +1 -1
  32. package/src/cli/commands/AddCommand.js +1 -1
  33. package/src/cli/commands/DbSeedCommand.js +1 -1
  34. package/src/cli/commands/MakeMailTemplateCommand.js +2 -1
  35. package/src/cli/commands/MakeNotificationTemplateCommand.js +2 -1
  36. package/src/cli/commands/MigrateWorkerCommand.d.ts +9 -0
  37. package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -0
  38. package/src/cli/commands/MigrateWorkerCommand.js +182 -0
  39. package/src/cli/commands/NewCommand.d.ts +1 -1
  40. package/src/cli/commands/NewCommand.d.ts.map +1 -1
  41. package/src/cli/commands/NewCommand.js +21 -7
  42. package/src/cli/commands/PublishCommand.d.ts +5 -0
  43. package/src/cli/commands/PublishCommand.d.ts.map +1 -0
  44. package/src/cli/commands/PublishCommand.js +54 -0
  45. package/src/cli/commands/QACommand.js +4 -4
  46. package/src/cli/commands/ResourceControlCommand.d.ts +6 -0
  47. package/src/cli/commands/ResourceControlCommand.d.ts.map +1 -0
  48. package/src/cli/commands/ResourceControlCommand.js +43 -0
  49. package/src/cli/commands/SimulateCommand.d.ts +1 -1
  50. package/src/cli/commands/SimulateCommand.js +4 -4
  51. package/src/cli/commands/StartCommand.d.ts.map +1 -1
  52. package/src/cli/commands/StartCommand.js +19 -7
  53. package/src/cli/commands/UpgradeCommand.d.ts +1 -1
  54. package/src/cli/commands/UpgradeCommand.js +2 -2
  55. package/src/cli/commands/WorkerCommands.d.ts +17 -0
  56. package/src/cli/commands/WorkerCommands.d.ts.map +1 -0
  57. package/src/cli/commands/WorkerCommands.js +264 -0
  58. package/src/cli/commands/index.d.ts +2 -0
  59. package/src/cli/commands/index.d.ts.map +1 -1
  60. package/src/cli/commands/index.js +2 -0
  61. package/src/cli/config/ConfigSchema.d.ts +1 -1
  62. package/src/cli/config/ConfigSchema.d.ts.map +1 -1
  63. package/src/cli/config/ConfigSchema.js +4 -3
  64. package/src/cli/scaffolding/ProjectScaffolder.js +5 -5
  65. package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
  66. package/src/cli/scaffolding/RouteGenerator.js +21 -2
  67. package/src/cli/scaffolding/TemplateEngine.js +1 -1
  68. package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
  69. package/src/common/ExternalServiceUtils.d.ts +63 -0
  70. package/src/common/ExternalServiceUtils.d.ts.map +1 -0
  71. package/src/common/ExternalServiceUtils.js +116 -0
  72. package/src/common/HealthRoutes.d.ts +10 -0
  73. package/src/common/HealthRoutes.d.ts.map +1 -0
  74. package/src/common/HealthRoutes.js +114 -0
  75. package/src/config/SecretsManager.d.ts.map +1 -1
  76. package/src/config/SecretsManager.js +2 -1
  77. package/src/config/app.d.ts +2 -1
  78. package/src/config/app.d.ts.map +1 -1
  79. package/src/config/app.js +98 -52
  80. package/src/config/broadcast.d.ts.map +1 -1
  81. package/src/config/broadcast.js +1 -1
  82. package/src/config/cache.d.ts.map +1 -1
  83. package/src/config/cache.js +2 -2
  84. package/src/config/database.d.ts.map +1 -1
  85. package/src/config/database.js +24 -5
  86. package/src/config/env.d.ts +43 -1
  87. package/src/config/env.d.ts.map +1 -1
  88. package/src/config/env.js +68 -21
  89. package/src/config/index.d.ts +10 -1
  90. package/src/config/index.d.ts.map +1 -1
  91. package/src/config/index.js +1 -0
  92. package/src/config/mail.d.ts.map +1 -1
  93. package/src/config/mail.js +3 -3
  94. package/src/config/middleware.d.ts.map +1 -1
  95. package/src/config/middleware.js +1 -1
  96. package/src/config/notification.d.ts.map +1 -1
  97. package/src/config/notification.js +2 -2
  98. package/src/config/queue.d.ts +14 -0
  99. package/src/config/queue.d.ts.map +1 -1
  100. package/src/config/queue.js +61 -36
  101. package/src/config/security.js +2 -2
  102. package/src/config/storage.d.ts.map +1 -1
  103. package/src/config/storage.js +1 -1
  104. package/src/config/type.d.ts +111 -0
  105. package/src/config/type.d.ts.map +1 -1
  106. package/src/config/workers.d.ts +13 -0
  107. package/src/config/workers.d.ts.map +1 -0
  108. package/src/config/workers.js +173 -0
  109. package/src/database/Paginator.d.ts +37 -0
  110. package/src/database/Paginator.d.ts.map +1 -0
  111. package/src/database/Paginator.js +81 -0
  112. package/src/exceptions/ZintrustError.d.ts +5 -2
  113. package/src/exceptions/ZintrustError.d.ts.map +1 -1
  114. package/src/exceptions/ZintrustError.js +6 -2
  115. package/src/features/Auth.d.ts +1 -1
  116. package/src/features/Auth.d.ts.map +1 -1
  117. package/src/features/Auth.js +3 -2
  118. package/src/features/Queue.d.ts.map +1 -1
  119. package/src/features/Queue.js +0 -2
  120. package/src/index.d.ts +15 -5
  121. package/src/index.d.ts.map +1 -1
  122. package/src/index.js +24 -3
  123. package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
  124. package/src/microservices/MicroserviceBootstrap.js +3 -1
  125. package/src/microservices/MicroserviceGenerator.js +4 -4
  126. package/src/microservices/MicroserviceManager.d.ts +1 -1
  127. package/src/microservices/MicroserviceManager.js +1 -1
  128. package/src/middleware/RateLimiter.d.ts.map +1 -1
  129. package/src/middleware/RateLimiter.js +4 -3
  130. package/src/node-singletons/crypto.d.ts +1 -1
  131. package/src/node-singletons/crypto.d.ts.map +1 -1
  132. package/src/node-singletons/crypto.js +1 -1
  133. package/src/node-singletons/os.d.ts +10 -1
  134. package/src/node-singletons/os.d.ts.map +1 -1
  135. package/src/node-singletons/os.js +10 -1
  136. package/src/openapi/OpenApiGenerator.js +2 -2
  137. package/src/orm/ConnectionManager.d.ts +1 -1
  138. package/src/orm/ConnectionManager.d.ts.map +1 -1
  139. package/src/orm/ConnectionManager.js +37 -19
  140. package/src/orm/Model.d.ts +8 -1
  141. package/src/orm/Model.d.ts.map +1 -1
  142. package/src/orm/Model.js +85 -24
  143. package/src/orm/QueryBuilder.d.ts +12 -2
  144. package/src/orm/QueryBuilder.d.ts.map +1 -1
  145. package/src/orm/QueryBuilder.js +438 -38
  146. package/src/orm/Relationships.d.ts +61 -1
  147. package/src/orm/Relationships.d.ts.map +1 -1
  148. package/src/orm/Relationships.js +190 -0
  149. package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
  150. package/src/orm/adapters/D1RemoteAdapter.js +1 -1
  151. package/src/performance/Optimizer.d.ts.map +1 -1
  152. package/src/performance/Optimizer.js +2 -4
  153. package/src/routing/CoreRoutes.d.ts +1 -1
  154. package/src/routing/CoreRoutes.d.ts.map +1 -1
  155. package/src/routing/CoreRoutes.js +2 -116
  156. package/src/routing/error.d.ts.map +1 -1
  157. package/src/routing/error.js +3 -2
  158. package/src/routing/publicRoot.d.ts.map +1 -1
  159. package/src/routing/publicRoot.js +4 -2
  160. package/src/runtime/PluginAutoImports.d.ts.map +1 -1
  161. package/src/runtime/PluginAutoImports.js +20 -4
  162. package/src/runtime/PluginManager.d.ts.map +1 -1
  163. package/src/runtime/PluginManager.js +23 -6
  164. package/src/runtime/RuntimeAdapter.d.ts +3 -3
  165. package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
  166. package/src/runtime/StartupConfigFileRegistry.d.ts +2 -1
  167. package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
  168. package/src/runtime/StartupConfigFileRegistry.js +2 -1
  169. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
  170. package/src/runtime/adapters/CloudflareAdapter.js +1 -1
  171. package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
  172. package/src/runtime/adapters/DenoAdapter.js +1 -1
  173. package/src/runtime/adapters/FargateAdapter.d.ts +2 -2
  174. package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
  175. package/src/runtime/adapters/FargateAdapter.js +1 -1
  176. package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
  177. package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
  178. package/src/runtime/adapters/LambdaAdapter.js +6 -4
  179. package/src/runtime/adapters/NodeServerAdapter.js +1 -1
  180. package/src/scripts/GenerateEnvArtifacts.js +1 -1
  181. package/src/security/SignedRequest.js +1 -1
  182. package/src/security/StartupSecretValidation.d.ts.map +1 -1
  183. package/src/security/StartupSecretValidation.js +7 -1
  184. package/src/start.d.ts.map +1 -1
  185. package/src/start.js +0 -2
  186. package/src/templates/features/Auth.ts.tpl +4 -4
  187. package/src/templates/project/basic/README.md.tpl +1 -1
  188. package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
  189. package/src/templates/project/basic/config/notification.ts.tpl +1 -1
  190. package/src/templates/project/basic/routes/api.ts.tpl +1 -3
  191. package/src/templates/project/basic/src/index.ts.tpl +1 -1
  192. package/src/templates/project/basic/src/zintrust.plugins.ts.tpl +1 -1
  193. package/src/templates/project/basic/template.json +1 -1
  194. package/src/toolkit/Secrets/index.d.ts.map +1 -1
  195. package/src/toolkit/Secrets/index.js +13 -9
  196. package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
  197. package/src/toolkit/Secrets/providers/AwsSecretsManager.js +20 -7
  198. package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
  199. package/src/toolkit/Secrets/providers/CloudflareKv.js +19 -6
  200. package/src/tools/http/Http.js +1 -1
  201. package/src/tools/mail/drivers/Ses.d.ts.map +1 -1
  202. package/src/tools/mail/drivers/Ses.js +5 -4
  203. package/src/tools/mail/templates/index.js +2 -2
  204. package/src/tools/notification/drivers/Termii.d.ts.map +1 -1
  205. package/src/tools/notification/drivers/Termii.js +6 -17
  206. package/src/tools/notification/testingHelpers.d.ts.map +1 -1
  207. package/src/tools/queue/Queue.d.ts.map +1 -1
  208. package/src/tools/queue/Queue.js +3 -5
  209. package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
  210. package/src/tools/queue/drivers/Redis.js +7 -1
  211. package/src/tools/storage/drivers/S3.d.ts.map +1 -1
  212. package/src/tools/storage/drivers/S3.js +16 -3
  213. package/src/routes/health.d.ts +0 -2
  214. package/src/routes/health.d.ts.map +0 -1
  215. package/src/routes/health.js +0 -1
  216. package/src/runtime/RuntimeDetector.d.ts +0 -15
  217. package/src/runtime/RuntimeDetector.d.ts.map +0 -1
  218. package/src/runtime/RuntimeDetector.js +0 -271
  219. package/src/templates/project/basic/routes/health.ts.tpl +0 -143
  220. package/src/templates/project/basic/routes/metrics.ts.tpl +0 -22
  221. package/src/workers/BroadcastWorker.d.ts +0 -22
  222. package/src/workers/BroadcastWorker.d.ts.map +0 -1
  223. package/src/workers/BroadcastWorker.js +0 -24
  224. package/src/workers/NotificationWorker.d.ts +0 -22
  225. package/src/workers/NotificationWorker.d.ts.map +0 -1
  226. package/src/workers/NotificationWorker.js +0 -23
  227. package/src/workers/createQueueWorker.d.ts +0 -24
  228. package/src/workers/createQueueWorker.d.ts.map +0 -1
  229. 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 = typeof process.env['APP_MODE'] === 'string' ? process.env['APP_MODE'].trim() : '';
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
- // .env is primary (loaded by EnvFileLoader with overrideExisting=true)
50
- const envPort = process.env['APP_PORT'] ?? process.env['PORT'] ?? '';
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(envPort, 10);
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 '${envPort}'. Expected 1-65535.`);
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 Zintrust app found. Run 'zin new <project>' or ensure package.json exists.");
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 Zintrust projects adopt new safe defaults without forcing
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):
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Upgrade Command
3
3
  *
4
- * Goal: help existing Zintrust projects adopt new safe defaults without forcing
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 Zintrust project in-place (safe, non-destructive)',
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,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
@@ -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,6 +1,6 @@
1
1
  /**
2
2
  * Configuration Schema
3
- * Defines the structure and types for Zintrust configuration
3
+ * Defines the structure and types for ZinTrust configuration
4
4
  */
5
5
  export interface DatabaseConfig {
6
6
  connection: 'sqlite' | 'postgres' | 'mysql' | 'mariadb';
@@ -1 +1 @@
1
- {"version":3,"file":"ConfigSchema.d.ts","sourceRoot":"","sources":["../../../../src/cli/config/ConfigSchema.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,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,CAA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,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 Zintrust configuration
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 Zintrust application',
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 = process.env['HOME'] ?? process.env['USERPROFILE'] ?? '';
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 Zintrust project structure',
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 Zintrust project structure',
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 Zintrust project structure',
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 Zintrust project structure',
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 Zintrust.
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;AAED,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAA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E,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,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,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,
@@ -62,7 +62,7 @@ export const TemplateEngine = Object.freeze({
62
62
  export const BUILT_IN_TEMPLATES = {
63
63
  basic: {
64
64
  name: 'basic',
65
- description: 'Basic Zintrust application',
65
+ description: 'Basic ZinTrust application',
66
66
  directories: [
67
67
  'src',
68
68
  'app/Models',
@@ -1 +1 @@
1
- {"version":3,"file":"EnvFileLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/EnvFileLoader.ts"],"names":[],"mappings":"AA2GA,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"}
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"}