@solidactions/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/.claude/settings.local.json +7 -0
  2. package/.clavix/outputs/dbos-http-sdk/full-prd.md +142 -0
  3. package/.clavix/outputs/dbos-http-sdk/quick-prd.md +12 -0
  4. package/.clavix/outputs/dbos-http-sdk/tasks.md +630 -0
  5. package/.clavix/outputs/prompts/dbos-http-api-20260110-033219.md +91 -0
  6. package/.husky/pre-commit +1 -0
  7. package/.prettierignore +3 -0
  8. package/.prettierrc +9 -0
  9. package/CODE_OF_CONDUCT.md +49 -0
  10. package/CONTRIBUTING.md +47 -0
  11. package/LICENSE +21 -0
  12. package/README.md +172 -0
  13. package/dist/dbos-config.schema.json +132 -0
  14. package/dist/schemas/system_db_schema.d.ts +73 -0
  15. package/dist/schemas/system_db_schema.d.ts.map +1 -0
  16. package/dist/schemas/system_db_schema.js +3 -0
  17. package/dist/schemas/system_db_schema.js.map +1 -0
  18. package/dist/src/adminserver.d.ts +79 -0
  19. package/dist/src/adminserver.d.ts.map +1 -0
  20. package/dist/src/adminserver.js +495 -0
  21. package/dist/src/adminserver.js.map +1 -0
  22. package/dist/src/authdecorators.d.ts +2 -0
  23. package/dist/src/authdecorators.d.ts.map +1 -0
  24. package/dist/src/authdecorators.js +48 -0
  25. package/dist/src/authdecorators.js.map +1 -0
  26. package/dist/src/cli/cli.d.ts +9 -0
  27. package/dist/src/cli/cli.d.ts.map +1 -0
  28. package/dist/src/cli/cli.js +116 -0
  29. package/dist/src/cli/cli.js.map +1 -0
  30. package/dist/src/cli/commands.d.ts +3 -0
  31. package/dist/src/cli/commands.d.ts.map +1 -0
  32. package/dist/src/cli/commands.js +46 -0
  33. package/dist/src/cli/commands.js.map +1 -0
  34. package/dist/src/client.d.ts +85 -0
  35. package/dist/src/client.d.ts.map +1 -0
  36. package/dist/src/client.js +186 -0
  37. package/dist/src/client.js.map +1 -0
  38. package/dist/src/conductor/conductor.d.ts +28 -0
  39. package/dist/src/conductor/conductor.d.ts.map +1 -0
  40. package/dist/src/conductor/conductor.js +376 -0
  41. package/dist/src/conductor/conductor.js.map +1 -0
  42. package/dist/src/conductor/protocol.d.ts +238 -0
  43. package/dist/src/conductor/protocol.d.ts.map +1 -0
  44. package/dist/src/conductor/protocol.js +353 -0
  45. package/dist/src/conductor/protocol.js.map +1 -0
  46. package/dist/src/config.d.ts +91 -0
  47. package/dist/src/config.d.ts.map +1 -0
  48. package/dist/src/config.js +199 -0
  49. package/dist/src/config.js.map +1 -0
  50. package/dist/src/context.d.ts +62 -0
  51. package/dist/src/context.d.ts.map +1 -0
  52. package/dist/src/context.js +118 -0
  53. package/dist/src/context.js.map +1 -0
  54. package/dist/src/database_utils.d.ts +17 -0
  55. package/dist/src/database_utils.d.ts.map +1 -0
  56. package/dist/src/database_utils.js +53 -0
  57. package/dist/src/database_utils.js.map +1 -0
  58. package/dist/src/datasource.d.ts +109 -0
  59. package/dist/src/datasource.d.ts.map +1 -0
  60. package/dist/src/datasource.js +204 -0
  61. package/dist/src/datasource.js.map +1 -0
  62. package/dist/src/dbos-executor.d.ts +189 -0
  63. package/dist/src/dbos-executor.d.ts.map +1 -0
  64. package/dist/src/dbos-executor.js +817 -0
  65. package/dist/src/dbos-executor.js.map +1 -0
  66. package/dist/src/dbos.d.ts +519 -0
  67. package/dist/src/dbos.d.ts.map +1 -0
  68. package/dist/src/dbos.js +1282 -0
  69. package/dist/src/dbos.js.map +1 -0
  70. package/dist/src/debouncer.d.ts +33 -0
  71. package/dist/src/debouncer.d.ts.map +1 -0
  72. package/dist/src/debouncer.js +170 -0
  73. package/dist/src/debouncer.js.map +1 -0
  74. package/dist/src/debugpoint.d.ts +26 -0
  75. package/dist/src/debugpoint.d.ts.map +1 -0
  76. package/dist/src/debugpoint.js +65 -0
  77. package/dist/src/debugpoint.js.map +1 -0
  78. package/dist/src/decorators.d.ts +219 -0
  79. package/dist/src/decorators.d.ts.map +1 -0
  80. package/dist/src/decorators.js +873 -0
  81. package/dist/src/decorators.js.map +1 -0
  82. package/dist/src/error.d.ts +130 -0
  83. package/dist/src/error.d.ts.map +1 -0
  84. package/dist/src/error.js +290 -0
  85. package/dist/src/error.js.map +1 -0
  86. package/dist/src/http_client.d.ts +82 -0
  87. package/dist/src/http_client.d.ts.map +1 -0
  88. package/dist/src/http_client.js +286 -0
  89. package/dist/src/http_client.js.map +1 -0
  90. package/dist/src/http_system_database.d.ts +84 -0
  91. package/dist/src/http_system_database.d.ts.map +1 -0
  92. package/dist/src/http_system_database.js +429 -0
  93. package/dist/src/http_system_database.js.map +1 -0
  94. package/dist/src/index.d.ts +14 -0
  95. package/dist/src/index.d.ts.map +1 -0
  96. package/dist/src/index.js +53 -0
  97. package/dist/src/index.js.map +1 -0
  98. package/dist/src/scheduler/crontab.d.ts +14 -0
  99. package/dist/src/scheduler/crontab.d.ts.map +1 -0
  100. package/dist/src/scheduler/crontab.js +308 -0
  101. package/dist/src/scheduler/crontab.js.map +1 -0
  102. package/dist/src/scheduler/scheduler.d.ts +41 -0
  103. package/dist/src/scheduler/scheduler.d.ts.map +1 -0
  104. package/dist/src/scheduler/scheduler.js +165 -0
  105. package/dist/src/scheduler/scheduler.js.map +1 -0
  106. package/dist/src/serialization.d.ts +57 -0
  107. package/dist/src/serialization.d.ts.map +1 -0
  108. package/dist/src/serialization.js +306 -0
  109. package/dist/src/serialization.js.map +1 -0
  110. package/dist/src/solidactions-executor.d.ts +177 -0
  111. package/dist/src/solidactions-executor.d.ts.map +1 -0
  112. package/dist/src/solidactions-executor.js +817 -0
  113. package/dist/src/solidactions-executor.js.map +1 -0
  114. package/dist/src/solidactions.d.ts +519 -0
  115. package/dist/src/solidactions.d.ts.map +1 -0
  116. package/dist/src/solidactions.js +1284 -0
  117. package/dist/src/solidactions.js.map +1 -0
  118. package/dist/src/step.d.ts +16 -0
  119. package/dist/src/step.d.ts.map +1 -0
  120. package/dist/src/step.js +3 -0
  121. package/dist/src/step.js.map +1 -0
  122. package/dist/src/system_database.d.ts +141 -0
  123. package/dist/src/system_database.d.ts.map +1 -0
  124. package/dist/src/system_database.js +25 -0
  125. package/dist/src/system_database.js.map +1 -0
  126. package/dist/src/telemetry/collector.d.ts +13 -0
  127. package/dist/src/telemetry/collector.d.ts.map +1 -0
  128. package/dist/src/telemetry/collector.js +63 -0
  129. package/dist/src/telemetry/collector.js.map +1 -0
  130. package/dist/src/telemetry/exporters.d.ts +13 -0
  131. package/dist/src/telemetry/exporters.d.ts.map +1 -0
  132. package/dist/src/telemetry/exporters.js +101 -0
  133. package/dist/src/telemetry/exporters.js.map +1 -0
  134. package/dist/src/telemetry/logs.d.ts +52 -0
  135. package/dist/src/telemetry/logs.d.ts.map +1 -0
  136. package/dist/src/telemetry/logs.js +287 -0
  137. package/dist/src/telemetry/logs.js.map +1 -0
  138. package/dist/src/telemetry/traces.d.ts +52 -0
  139. package/dist/src/telemetry/traces.d.ts.map +1 -0
  140. package/dist/src/telemetry/traces.js +150 -0
  141. package/dist/src/telemetry/traces.js.map +1 -0
  142. package/dist/src/utils.d.ts +26 -0
  143. package/dist/src/utils.d.ts.map +1 -0
  144. package/dist/src/utils.js +136 -0
  145. package/dist/src/utils.js.map +1 -0
  146. package/dist/src/wfqueue.d.ts +64 -0
  147. package/dist/src/wfqueue.d.ts.map +1 -0
  148. package/dist/src/wfqueue.js +147 -0
  149. package/dist/src/wfqueue.js.map +1 -0
  150. package/dist/src/workflow.d.ts +154 -0
  151. package/dist/src/workflow.d.ts.map +1 -0
  152. package/dist/src/workflow.js +99 -0
  153. package/dist/src/workflow.js.map +1 -0
  154. package/dist/src/workflow_management.d.ts +15 -0
  155. package/dist/src/workflow_management.d.ts.map +1 -0
  156. package/dist/src/workflow_management.js +87 -0
  157. package/dist/src/workflow_management.js.map +1 -0
  158. package/dist/tsconfig.tsbuildinfo +1 -0
  159. package/docs/api-schema.md +1441 -0
  160. package/docs/migration-guide.md +460 -0
  161. package/docs/phase-14-changes.md +156 -0
  162. package/docs/solidsteps-ai-prompt.md +534 -0
  163. package/eslint.config.cjs +50 -0
  164. package/package.json +84 -0
  165. package/solidactions-ai-prompt.md +1504 -0
  166. package/solidactions-config.schema.json +132 -0
  167. package/solidactions-test-config.yaml +15 -0
@@ -0,0 +1,79 @@
1
+ /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ import * as http from 'http';
4
+ import { SolidActionsExecutor } from './solidactions-executor';
5
+ import { GlobalLogger } from './telemetry/logs';
6
+ export declare const WorkflowUUIDHeader = "dbos-idempotency-key";
7
+ export declare const WorkflowRecoveryUrl = "/dbos-workflow-recovery";
8
+ export declare const HealthUrl = "/dbos-healthz";
9
+ export declare const PerfUrl = "/dbos-perf";
10
+ export declare const DeactivateUrl = "/deactivate";
11
+ interface Route {
12
+ method: string;
13
+ path: string;
14
+ handler: (req: http.IncomingMessage, res: http.ServerResponse, params?: Record<string, string>) => Promise<void>;
15
+ }
16
+ export declare class SolidActionsAdminServer {
17
+ static setupAdminApp(solidActionsExec: SolidActionsExecutor): http.Server;
18
+ static checkPortAvailabilityIPv4Ipv6(port: number, logger: GlobalLogger): Promise<void>;
19
+ static checkPortAvailability(port: number, host: string): Promise<void>;
20
+ /**
21
+ * Health check endpoint.
22
+ */
23
+ static registerHealthEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
24
+ /**
25
+ * Register workflow recovery endpoint.
26
+ * Receives a list of executor IDs and returns a list of workflowUUIDs.
27
+ */
28
+ static registerRecoveryEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
29
+ /**
30
+ * Register performance endpoint.
31
+ * Returns information on VM performance since last call.
32
+ */
33
+ static lastELU: import("perf_hooks").EventLoopUtilization;
34
+ static registerPerfEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
35
+ /**
36
+ * Register Deactivate endpoint.
37
+ * Deactivate consumers so that they don't start new workflows.
38
+ */
39
+ static isDeactivated: boolean;
40
+ static registerDeactivateEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
41
+ static registerGarbageCollectEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
42
+ static registerGlobalTimeoutEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
43
+ /**
44
+ * Register Cancel Workflow endpoint.
45
+ * Cancels a workflow by setting its status to CANCELLED.
46
+ */
47
+ static registerCancelWorkflowEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
48
+ /**
49
+ * Register Resume Workflow endpoint.
50
+ * Resume a workflow.
51
+ */
52
+ static registerResumeWorkflowEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
53
+ /**
54
+ * Register Restart Workflow endpoint.
55
+ * Restart a workflow.
56
+ */
57
+ static registerRestartWorkflowEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
58
+ /**
59
+ * Register Fork Workflow endpoint.
60
+ */
61
+ static registerForkWorkflowEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
62
+ /**
63
+ * Register List Workflow Steps endpoint.
64
+ * List steps for a given workflow.
65
+ */
66
+ static registerListWorkflowStepsEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
67
+ /**
68
+ * Register List Workflows endpoint.
69
+ * List workflows with optional filtering via request body.
70
+ */
71
+ static registerListWorkflowsEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
72
+ /**
73
+ * Register Get Workflow endpoint.
74
+ * Get detailed information about a specific workflow by ID.
75
+ */
76
+ static registerGetWorkflowEndpoint(solidActionsExec: SolidActionsExecutor, routes: Route[]): void;
77
+ }
78
+ export {};
79
+ //# sourceMappingURL=adminserver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminserver.d.ts","sourceRoot":"","sources":["../../src/adminserver.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAI7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBA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EAAE,KAAK,EAAE;IAkBzF,MAAM,CAAC,8BAA8B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IAgB7F,MAAM,CAAC,6BAA6B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IAe5F;;;OAGG;IACH,MAAM,CAAC,8BAA8B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IAc7F;;;OAGG;IACH,MAAM,CAAC,8BAA8B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IA4B7F;;;OAGG;IACH,MAAM,CAAC,+BAA+B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IAiB9F;;OAEG;IACH,MAAM,CAAC,4BAA4B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IA8C3F;;;OAGG;IACH,MAAM,CAAC,iCAAiC,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IAehG;;;OAGG;IACH,MAAM,CAAC,6BAA6B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;IAmD5F;;;OAGG;IACH,MAAM,CAAC,2BAA2B,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,KAAK,EAAE;CAkB3F"}
@@ -0,0 +1,495 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SolidActionsAdminServer = exports.DeactivateUrl = exports.PerfUrl = exports.HealthUrl = exports.WorkflowRecoveryUrl = exports.WorkflowUUIDHeader = void 0;
27
+ const http = __importStar(require("http"));
28
+ const url = __importStar(require("url"));
29
+ const error_1 = require("./error");
30
+ const net = __importStar(require("net"));
31
+ const perf_hooks_1 = require("perf_hooks");
32
+ const utils_1 = require("./utils");
33
+ const workflow_management_1 = require("./workflow_management");
34
+ const protocol = __importStar(require("./conductor/protocol"));
35
+ exports.WorkflowUUIDHeader = 'dbos-idempotency-key';
36
+ exports.WorkflowRecoveryUrl = '/dbos-workflow-recovery';
37
+ exports.HealthUrl = '/dbos-healthz';
38
+ exports.PerfUrl = '/dbos-perf';
39
+ exports.DeactivateUrl = '/deactivate';
40
+ // Helper to parse JSON body
41
+ async function parseJsonBody(req) {
42
+ return new Promise((resolve, reject) => {
43
+ let body = '';
44
+ req.on('data', (chunk) => {
45
+ body += String(chunk);
46
+ });
47
+ req.on('end', () => {
48
+ try {
49
+ resolve(body ? JSON.parse(body) : {});
50
+ }
51
+ catch (e) {
52
+ reject(new Error('Invalid JSON'));
53
+ }
54
+ });
55
+ req.on('error', reject);
56
+ });
57
+ }
58
+ // Helper to send JSON response
59
+ function sendJson(res, statusCode, data) {
60
+ res.writeHead(statusCode, {
61
+ 'Content-Type': 'application/json',
62
+ 'Access-Control-Allow-Origin': '*',
63
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
64
+ 'Access-Control-Allow-Headers': 'Content-Type',
65
+ });
66
+ res.end(JSON.stringify(data));
67
+ }
68
+ // Helper to send text response
69
+ function sendText(res, statusCode, text) {
70
+ res.writeHead(statusCode, {
71
+ 'Content-Type': 'text/plain',
72
+ 'Access-Control-Allow-Origin': '*',
73
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
74
+ 'Access-Control-Allow-Headers': 'Content-Type',
75
+ });
76
+ res.end(text);
77
+ }
78
+ // Helper to send no content response
79
+ function sendNoContent(res) {
80
+ res.writeHead(204, {
81
+ 'Access-Control-Allow-Origin': '*',
82
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
83
+ 'Access-Control-Allow-Headers': 'Content-Type',
84
+ });
85
+ res.end();
86
+ }
87
+ // Helper to extract path params
88
+ function matchPath(pattern, pathname) {
89
+ const patternParts = pattern.split('/');
90
+ const pathParts = pathname.split('/');
91
+ if (patternParts.length !== pathParts.length)
92
+ return null;
93
+ const params = {};
94
+ for (let i = 0; i < patternParts.length; i++) {
95
+ const patternPart = patternParts[i];
96
+ const pathPart = pathParts[i];
97
+ if (patternPart.startsWith(':')) {
98
+ const paramName = patternPart.substring(1);
99
+ params[paramName] = pathPart;
100
+ }
101
+ else if (patternPart !== pathPart) {
102
+ return null;
103
+ }
104
+ }
105
+ return params;
106
+ }
107
+ class SolidActionsAdminServer {
108
+ static setupAdminApp(solidActionsExec) {
109
+ const routes = [];
110
+ // Register HTTP endpoints.
111
+ SolidActionsAdminServer.registerHealthEndpoint(solidActionsExec, routes);
112
+ SolidActionsAdminServer.registerRecoveryEndpoint(solidActionsExec, routes);
113
+ SolidActionsAdminServer.registerPerfEndpoint(solidActionsExec, routes);
114
+ SolidActionsAdminServer.registerDeactivateEndpoint(solidActionsExec, routes);
115
+ SolidActionsAdminServer.registerCancelWorkflowEndpoint(solidActionsExec, routes);
116
+ SolidActionsAdminServer.registerResumeWorkflowEndpoint(solidActionsExec, routes);
117
+ SolidActionsAdminServer.registerRestartWorkflowEndpoint(solidActionsExec, routes);
118
+ SolidActionsAdminServer.registerListWorkflowStepsEndpoint(solidActionsExec, routes);
119
+ SolidActionsAdminServer.registerListWorkflowsEndpoint(solidActionsExec, routes);
120
+ SolidActionsAdminServer.registerGetWorkflowEndpoint(solidActionsExec, routes);
121
+ SolidActionsAdminServer.registerForkWorkflowEndpoint(solidActionsExec, routes);
122
+ SolidActionsAdminServer.registerGarbageCollectEndpoint(solidActionsExec, routes);
123
+ SolidActionsAdminServer.registerGlobalTimeoutEndpoint(solidActionsExec, routes);
124
+ // Create the HTTP server
125
+ const server = http.createServer(async (req, res) => {
126
+ // Handle CORS preflight requests
127
+ if (req.method === 'OPTIONS') {
128
+ res.writeHead(200, {
129
+ 'Access-Control-Allow-Origin': '*',
130
+ 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
131
+ 'Access-Control-Allow-Headers': 'Content-Type',
132
+ 'Access-Control-Max-Age': '86400',
133
+ });
134
+ res.end();
135
+ return;
136
+ }
137
+ const parsedUrl = url.parse(req.url || '', true);
138
+ const pathname = parsedUrl.pathname || '';
139
+ // Find matching route
140
+ let routeFound = false;
141
+ for (const route of routes) {
142
+ if (req.method === route.method) {
143
+ const params = matchPath(route.path, pathname);
144
+ if (params !== null) {
145
+ routeFound = true;
146
+ try {
147
+ await route.handler(req, res, params);
148
+ }
149
+ catch (error) {
150
+ solidActionsExec.logger.error(`Request handler error: ${String(error)}`);
151
+ sendJson(res, 500, { error: 'Internal server error' });
152
+ }
153
+ break;
154
+ }
155
+ }
156
+ }
157
+ if (!routeFound) {
158
+ res.writeHead(404, { 'Content-Type': 'text/plain' });
159
+ res.end('Not Found');
160
+ }
161
+ });
162
+ return server;
163
+ }
164
+ static async checkPortAvailabilityIPv4Ipv6(port, logger) {
165
+ try {
166
+ await this.checkPortAvailability(port, '127.0.0.1');
167
+ }
168
+ catch (error) {
169
+ const err = error;
170
+ if (err.code === 'EADDRINUSE') {
171
+ logger.warn(`Port ${port} is already used for IPv4 address "127.0.0.1". Please use the -p option to choose another port.\n${err.message}`);
172
+ throw error;
173
+ }
174
+ else {
175
+ logger.warn(`Error occurred while checking port availability for IPv4 address "127.0.0.1" : ${err.code}\n${err.message}`);
176
+ }
177
+ }
178
+ try {
179
+ await this.checkPortAvailability(port, '::1');
180
+ }
181
+ catch (error) {
182
+ const err = error;
183
+ if (err.code === 'EADDRINUSE') {
184
+ logger.warn(`Port ${port} is already used for IPv6 address "::1". Please use the -p option to choose another port.\n${err.message}`);
185
+ throw error;
186
+ }
187
+ else {
188
+ logger.warn(`Error occurred while checking port availability for IPv6 address "::1" : ${err.code}\n${err.message}`);
189
+ }
190
+ }
191
+ }
192
+ static async checkPortAvailability(port, host) {
193
+ return new Promise((resolve, reject) => {
194
+ const server = new net.Server();
195
+ server.on('error', (error) => {
196
+ reject(error);
197
+ });
198
+ server.on('listening', () => {
199
+ server.close();
200
+ resolve();
201
+ });
202
+ server.listen({ port: port, host: host }, () => {
203
+ resolve();
204
+ });
205
+ });
206
+ }
207
+ /**
208
+ * Health check endpoint.
209
+ */
210
+ static registerHealthEndpoint(solidActionsExec, routes) {
211
+ routes.push({
212
+ method: 'GET',
213
+ path: exports.HealthUrl,
214
+ handler: async (req, res) => {
215
+ sendText(res, 200, 'healthy');
216
+ return Promise.resolve();
217
+ },
218
+ });
219
+ solidActionsExec.logger.debug(`SolidActions Server Registered Healthz GET ${exports.HealthUrl}`);
220
+ }
221
+ /**
222
+ * Register workflow recovery endpoint.
223
+ * Receives a list of executor IDs and returns a list of workflowUUIDs.
224
+ */
225
+ static registerRecoveryEndpoint(solidActionsExec, routes) {
226
+ routes.push({
227
+ method: 'POST',
228
+ path: exports.WorkflowRecoveryUrl,
229
+ handler: async (req, res) => {
230
+ const executorIDs = (await parseJsonBody(req));
231
+ solidActionsExec.logger.info('Recovering workflows for executors: ' + executorIDs.toString());
232
+ const recoverHandles = await solidActionsExec.recoverPendingWorkflows(executorIDs);
233
+ // Return a list of workflowUUIDs being recovered.
234
+ const result = await Promise.allSettled(recoverHandles.map((i) => i.workflowID)).then((results) => results.filter((i) => i.status === 'fulfilled').map((i) => i.value));
235
+ sendJson(res, 200, result);
236
+ },
237
+ });
238
+ solidActionsExec.logger.debug(`SolidActions Server Registered Recovery POST ${exports.WorkflowRecoveryUrl}`);
239
+ }
240
+ /**
241
+ * Register performance endpoint.
242
+ * Returns information on VM performance since last call.
243
+ */
244
+ static lastELU = perf_hooks_1.performance.eventLoopUtilization();
245
+ static registerPerfEndpoint(solidActionsExec, routes) {
246
+ routes.push({
247
+ method: 'GET',
248
+ path: exports.PerfUrl,
249
+ handler: async (req, res) => {
250
+ const currELU = perf_hooks_1.performance.eventLoopUtilization();
251
+ const elu = perf_hooks_1.performance.eventLoopUtilization(currELU, SolidActionsAdminServer.lastELU);
252
+ sendJson(res, 200, elu);
253
+ SolidActionsAdminServer.lastELU = currELU;
254
+ return Promise.resolve();
255
+ },
256
+ });
257
+ solidActionsExec.logger.debug(`SolidActions Server Registered Perf GET ${exports.PerfUrl}`);
258
+ }
259
+ /**
260
+ * Register Deactivate endpoint.
261
+ * Deactivate consumers so that they don't start new workflows.
262
+ */
263
+ static isDeactivated = false;
264
+ static registerDeactivateEndpoint(solidActionsExec, routes) {
265
+ routes.push({
266
+ method: 'GET',
267
+ path: exports.DeactivateUrl,
268
+ handler: async (req, res) => {
269
+ if (!SolidActionsAdminServer.isDeactivated) {
270
+ solidActionsExec.logger.info(`Deactivating SolidActions executor ${utils_1.globalParams.executorID} with version ${utils_1.globalParams.appVersion}. This executor will complete existing workflows but will not create new workflows.`);
271
+ SolidActionsAdminServer.isDeactivated = true;
272
+ }
273
+ await solidActionsExec.deactivateEventReceivers();
274
+ sendText(res, 200, 'Deactivated');
275
+ },
276
+ });
277
+ solidActionsExec.logger.debug(`SolidActions Server Registered Deactivate GET ${exports.DeactivateUrl}`);
278
+ }
279
+ static registerGarbageCollectEndpoint(solidActionsExec, routes) {
280
+ const url = '/dbos-garbage-collect';
281
+ routes.push({
282
+ method: 'POST',
283
+ path: url,
284
+ handler: async (req, res) => {
285
+ const body = (await parseJsonBody(req));
286
+ await solidActionsExec.systemDatabase.garbageCollect(body.cutoff_epoch_timestamp_ms, body.rows_threshold);
287
+ sendNoContent(res);
288
+ },
289
+ });
290
+ }
291
+ static registerGlobalTimeoutEndpoint(solidActionsExec, routes) {
292
+ const url = '/dbos-global-timeout';
293
+ routes.push({
294
+ method: 'POST',
295
+ path: url,
296
+ handler: async (req, res) => {
297
+ const body = (await parseJsonBody(req));
298
+ await (0, workflow_management_1.globalTimeout)(solidActionsExec.systemDatabase, body.cutoff_epoch_timestamp_ms);
299
+ sendNoContent(res);
300
+ },
301
+ });
302
+ }
303
+ /**
304
+ * Register Cancel Workflow endpoint.
305
+ * Cancels a workflow by setting its status to CANCELLED.
306
+ */
307
+ static registerCancelWorkflowEndpoint(solidActionsExec, routes) {
308
+ const workflowCancelUrl = '/workflows/:workflow_id/cancel';
309
+ routes.push({
310
+ method: 'POST',
311
+ path: workflowCancelUrl,
312
+ handler: async (req, res, params) => {
313
+ const workflowId = params.workflow_id;
314
+ await solidActionsExec.cancelWorkflow(workflowId);
315
+ sendNoContent(res);
316
+ },
317
+ });
318
+ solidActionsExec.logger.debug(`SolidActions Server Registered Cancel Workflow POST ${workflowCancelUrl}`);
319
+ }
320
+ /**
321
+ * Register Resume Workflow endpoint.
322
+ * Resume a workflow.
323
+ */
324
+ static registerResumeWorkflowEndpoint(solidActionsExec, routes) {
325
+ const workflowResumeUrl = '/workflows/:workflow_id/resume';
326
+ routes.push({
327
+ method: 'POST',
328
+ path: workflowResumeUrl,
329
+ handler: async (req, res, params) => {
330
+ const workflowId = params.workflow_id;
331
+ solidActionsExec.logger.info(`Resuming workflow with ID: ${workflowId}`);
332
+ try {
333
+ await solidActionsExec.resumeWorkflow(workflowId);
334
+ sendNoContent(res);
335
+ }
336
+ catch (e) {
337
+ let errorMessage = '';
338
+ if (e instanceof error_1.SolidActionsError) {
339
+ errorMessage = e.message;
340
+ }
341
+ else {
342
+ errorMessage = `Unknown error`;
343
+ }
344
+ solidActionsExec.logger.error(`Error resuming workflow ${workflowId}: ${errorMessage}`);
345
+ sendJson(res, 500, {
346
+ error: `Error resuming workflow ${workflowId}: ${errorMessage}`,
347
+ });
348
+ }
349
+ },
350
+ });
351
+ solidActionsExec.logger.debug(`SolidActions Server Registered Resume Workflow POST ${workflowResumeUrl}`);
352
+ }
353
+ /**
354
+ * Register Restart Workflow endpoint.
355
+ * Restart a workflow.
356
+ */
357
+ static registerRestartWorkflowEndpoint(solidActionsExec, routes) {
358
+ const workflowRestartUrl = '/workflows/:workflow_id/restart';
359
+ routes.push({
360
+ method: 'POST',
361
+ path: workflowRestartUrl,
362
+ handler: async (req, res, params) => {
363
+ const workflowId = params.workflow_id;
364
+ solidActionsExec.logger.info(`Restarting workflow: ${workflowId} with a new id`);
365
+ const workflowID = await solidActionsExec.forkWorkflow(workflowId, 0);
366
+ sendJson(res, 200, {
367
+ workflow_id: workflowID,
368
+ });
369
+ },
370
+ });
371
+ solidActionsExec.logger.debug(`SolidActions Server Registered Restart Workflow POST ${workflowRestartUrl}`);
372
+ }
373
+ /**
374
+ * Register Fork Workflow endpoint.
375
+ */
376
+ static registerForkWorkflowEndpoint(solidActionsExec, routes) {
377
+ const workflowForkUrl = '/workflows/:workflow_id/fork';
378
+ routes.push({
379
+ method: 'POST',
380
+ path: workflowForkUrl,
381
+ handler: async (req, res, params) => {
382
+ const workflowId = params.workflow_id;
383
+ const body = (await parseJsonBody(req));
384
+ if (body.start_step === undefined) {
385
+ sendJson(res, 400, { error: 'Missing start_step in request body' });
386
+ return;
387
+ }
388
+ solidActionsExec.logger.info(`Forking workflow: ${workflowId} from step ${body.start_step} with a new id`);
389
+ try {
390
+ const workflowID = await solidActionsExec.forkWorkflow(workflowId, body.start_step, {
391
+ newWorkflowID: body.new_workflow_id,
392
+ applicationVersion: body.application_version,
393
+ timeoutMS: body.timeout_ms,
394
+ });
395
+ sendJson(res, 200, {
396
+ workflow_id: workflowID,
397
+ });
398
+ }
399
+ catch (e) {
400
+ let errorMessage = '';
401
+ if (e instanceof error_1.SolidActionsError) {
402
+ errorMessage = e.message;
403
+ }
404
+ else {
405
+ errorMessage = `Unknown error`;
406
+ }
407
+ solidActionsExec.logger.error(`Error forking workflow ${workflowId}: ${errorMessage}`);
408
+ sendJson(res, 500, {
409
+ error: `Error forking workflow ${workflowId}: ${errorMessage}`,
410
+ });
411
+ }
412
+ },
413
+ });
414
+ solidActionsExec.logger.debug(`SolidActions Server Registered Fork Workflow POST ${workflowForkUrl}`);
415
+ }
416
+ /**
417
+ * Register List Workflow Steps endpoint.
418
+ * List steps for a given workflow.
419
+ */
420
+ static registerListWorkflowStepsEndpoint(solidActionsExec, routes) {
421
+ const workflowStepsUrl = '/workflows/:workflow_id/steps';
422
+ routes.push({
423
+ method: 'GET',
424
+ path: workflowStepsUrl,
425
+ handler: async (req, res, params) => {
426
+ const workflowId = params.workflow_id;
427
+ const steps = await solidActionsExec.listWorkflowSteps(workflowId);
428
+ const result = steps?.map((step) => new protocol.WorkflowSteps(step));
429
+ sendJson(res, 200, result);
430
+ },
431
+ });
432
+ solidActionsExec.logger.debug(`SolidActions Server Registered List Workflow steps Get ${workflowStepsUrl}`);
433
+ }
434
+ /**
435
+ * Register List Workflows endpoint.
436
+ * List workflows with optional filtering via request body.
437
+ */
438
+ static registerListWorkflowsEndpoint(solidActionsExec, routes) {
439
+ const listWorkflowsUrl = '/workflows';
440
+ routes.push({
441
+ method: 'POST',
442
+ path: listWorkflowsUrl,
443
+ handler: async (req, res) => {
444
+ const body = (await parseJsonBody(req));
445
+ // Map request body keys to GetWorkflowsInput properties
446
+ const input = {
447
+ workflowIDs: body.workflow_uuids,
448
+ workflowName: body.workflow_name,
449
+ authenticatedUser: body.authenticated_user,
450
+ startTime: body.start_time,
451
+ endTime: body.end_time,
452
+ status: body.status,
453
+ applicationVersion: body.application_version,
454
+ forkedFrom: body.fork_from,
455
+ limit: body.limit,
456
+ offset: body.offset,
457
+ sortDesc: body.sort_desc,
458
+ workflow_id_prefix: body.workflow_id_prefix,
459
+ loadInput: body.load_input ?? false,
460
+ loadOutput: body.load_output ?? false,
461
+ };
462
+ const workflows = await solidActionsExec.listWorkflows(input);
463
+ // Map result to the underscore format.
464
+ const result = workflows.map((wf) => new protocol.WorkflowsOutput(wf));
465
+ sendJson(res, 200, result);
466
+ },
467
+ });
468
+ solidActionsExec.logger.debug(`SolidActions Server Registered List Workflows POST ${listWorkflowsUrl}`);
469
+ }
470
+ /**
471
+ * Register Get Workflow endpoint.
472
+ * Get detailed information about a specific workflow by ID.
473
+ */
474
+ static registerGetWorkflowEndpoint(solidActionsExec, routes) {
475
+ const getWorkflowUrl = '/workflows/:workflow_id';
476
+ routes.push({
477
+ method: 'GET',
478
+ path: getWorkflowUrl,
479
+ handler: async (req, res, params) => {
480
+ const workflowId = params.workflow_id;
481
+ const workflow = await solidActionsExec.getWorkflowStatus(workflowId);
482
+ if (workflow) {
483
+ const result = new protocol.WorkflowsOutput(workflow);
484
+ sendJson(res, 200, result);
485
+ }
486
+ else {
487
+ sendJson(res, 404, { error: `Workflow ${workflowId} not found` });
488
+ }
489
+ },
490
+ });
491
+ solidActionsExec.logger.debug(`SolidActions Server Registered Get Workflow GET ${getWorkflowUrl}`);
492
+ }
493
+ }
494
+ exports.SolidActionsAdminServer = SolidActionsAdminServer;
495
+ //# sourceMappingURL=adminserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adminserver.js","sourceRoot":"","sources":["../../src/adminserver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6B;AAC7B,yCAA2B;AAE3B,mCAA4C;AAG5C,yCAA2B;AAC3B,2CAAyC;AACzC,mCAAuC;AACvC,+DAAsD;AACtD,+DAAiD;AAEpC,QAAA,kBAAkB,GAAG,sBAAsB,CAAC;AAC5C,QAA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ACrG,CAAC;;AAzbH,0DA0bC"}
@@ -0,0 +1,2 @@
1
+ export declare function registerAuthChecker(): void;
2
+ //# sourceMappingURL=authdecorators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authdecorators.d.ts","sourceRoot":"","sources":["../../src/authdecorators.ts"],"names":[],"mappings":"AAyDA,wBAAgB,mBAAmB,SAElC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerAuthChecker = void 0;
4
+ const context_1 = require("./context");
5
+ const solidactions_1 = require("./solidactions");
6
+ const decorators_1 = require("./decorators");
7
+ const error_1 = require("./error");
8
+ function checkMethodAuth(methReg, args) {
9
+ // Validate the user authentication and populate the role field
10
+ const requiredRoles = methReg.getRequiredRoles();
11
+ if (requiredRoles.length > 0) {
12
+ solidactions_1.SolidActions.span?.setAttribute('requiredRoles', requiredRoles);
13
+ const curRoles = solidactions_1.SolidActions.authenticatedRoles;
14
+ let authorized = false;
15
+ const set = new Set(curRoles);
16
+ for (const role of requiredRoles) {
17
+ if (set.has(role)) {
18
+ authorized = true;
19
+ if ((0, context_1.getCurrentContextStore)()) {
20
+ (0, context_1.getCurrentContextStore)().assumedRole = role;
21
+ }
22
+ break;
23
+ }
24
+ }
25
+ if (!authorized) {
26
+ const err = new error_1.SolidActionsNotAuthorizedError(`User does not have a role with permission to call ${methReg.name}`, 403);
27
+ solidactions_1.SolidActions.span?.addEvent('SolidActionsNotAuthorizedError', { message: err.message });
28
+ throw err;
29
+ }
30
+ }
31
+ return args;
32
+ }
33
+ class AuthChecker {
34
+ installMiddleware(methReg) {
35
+ const classAuth = methReg?.defaults?.getRegisteredInfo(decorators_1.SOLIDACTIONS_AUTH);
36
+ const methodAuth = methReg?.getRegisteredInfo(decorators_1.SOLIDACTIONS_AUTH);
37
+ const shouldCheck = classAuth?.requiredRole !== undefined || methodAuth?.requiredRole !== undefined;
38
+ if (shouldCheck) {
39
+ methReg.addEntryInterceptor(checkMethodAuth, 10);
40
+ }
41
+ }
42
+ }
43
+ const authChecker = new AuthChecker();
44
+ function registerAuthChecker() {
45
+ (0, decorators_1.registerMiddlewareInstaller)(authChecker);
46
+ }
47
+ exports.registerAuthChecker = registerAuthChecker;
48
+ //# sourceMappingURL=authdecorators.js.map