@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.
- package/.claude/settings.local.json +7 -0
- package/.clavix/outputs/dbos-http-sdk/full-prd.md +142 -0
- package/.clavix/outputs/dbos-http-sdk/quick-prd.md +12 -0
- package/.clavix/outputs/dbos-http-sdk/tasks.md +630 -0
- package/.clavix/outputs/prompts/dbos-http-api-20260110-033219.md +91 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +3 -0
- package/.prettierrc +9 -0
- package/CODE_OF_CONDUCT.md +49 -0
- package/CONTRIBUTING.md +47 -0
- package/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/dbos-config.schema.json +132 -0
- package/dist/schemas/system_db_schema.d.ts +73 -0
- package/dist/schemas/system_db_schema.d.ts.map +1 -0
- package/dist/schemas/system_db_schema.js +3 -0
- package/dist/schemas/system_db_schema.js.map +1 -0
- package/dist/src/adminserver.d.ts +79 -0
- package/dist/src/adminserver.d.ts.map +1 -0
- package/dist/src/adminserver.js +495 -0
- package/dist/src/adminserver.js.map +1 -0
- package/dist/src/authdecorators.d.ts +2 -0
- package/dist/src/authdecorators.d.ts.map +1 -0
- package/dist/src/authdecorators.js +48 -0
- package/dist/src/authdecorators.js.map +1 -0
- package/dist/src/cli/cli.d.ts +9 -0
- package/dist/src/cli/cli.d.ts.map +1 -0
- package/dist/src/cli/cli.js +116 -0
- package/dist/src/cli/cli.js.map +1 -0
- package/dist/src/cli/commands.d.ts +3 -0
- package/dist/src/cli/commands.d.ts.map +1 -0
- package/dist/src/cli/commands.js +46 -0
- package/dist/src/cli/commands.js.map +1 -0
- package/dist/src/client.d.ts +85 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +186 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/conductor/conductor.d.ts +28 -0
- package/dist/src/conductor/conductor.d.ts.map +1 -0
- package/dist/src/conductor/conductor.js +376 -0
- package/dist/src/conductor/conductor.js.map +1 -0
- package/dist/src/conductor/protocol.d.ts +238 -0
- package/dist/src/conductor/protocol.d.ts.map +1 -0
- package/dist/src/conductor/protocol.js +353 -0
- package/dist/src/conductor/protocol.js.map +1 -0
- package/dist/src/config.d.ts +91 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +199 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/context.d.ts +62 -0
- package/dist/src/context.d.ts.map +1 -0
- package/dist/src/context.js +118 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/database_utils.d.ts +17 -0
- package/dist/src/database_utils.d.ts.map +1 -0
- package/dist/src/database_utils.js +53 -0
- package/dist/src/database_utils.js.map +1 -0
- package/dist/src/datasource.d.ts +109 -0
- package/dist/src/datasource.d.ts.map +1 -0
- package/dist/src/datasource.js +204 -0
- package/dist/src/datasource.js.map +1 -0
- package/dist/src/dbos-executor.d.ts +189 -0
- package/dist/src/dbos-executor.d.ts.map +1 -0
- package/dist/src/dbos-executor.js +817 -0
- package/dist/src/dbos-executor.js.map +1 -0
- package/dist/src/dbos.d.ts +519 -0
- package/dist/src/dbos.d.ts.map +1 -0
- package/dist/src/dbos.js +1282 -0
- package/dist/src/dbos.js.map +1 -0
- package/dist/src/debouncer.d.ts +33 -0
- package/dist/src/debouncer.d.ts.map +1 -0
- package/dist/src/debouncer.js +170 -0
- package/dist/src/debouncer.js.map +1 -0
- package/dist/src/debugpoint.d.ts +26 -0
- package/dist/src/debugpoint.d.ts.map +1 -0
- package/dist/src/debugpoint.js +65 -0
- package/dist/src/debugpoint.js.map +1 -0
- package/dist/src/decorators.d.ts +219 -0
- package/dist/src/decorators.d.ts.map +1 -0
- package/dist/src/decorators.js +873 -0
- package/dist/src/decorators.js.map +1 -0
- package/dist/src/error.d.ts +130 -0
- package/dist/src/error.d.ts.map +1 -0
- package/dist/src/error.js +290 -0
- package/dist/src/error.js.map +1 -0
- package/dist/src/http_client.d.ts +82 -0
- package/dist/src/http_client.d.ts.map +1 -0
- package/dist/src/http_client.js +286 -0
- package/dist/src/http_client.js.map +1 -0
- package/dist/src/http_system_database.d.ts +84 -0
- package/dist/src/http_system_database.d.ts.map +1 -0
- package/dist/src/http_system_database.js +429 -0
- package/dist/src/http_system_database.js.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +53 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/scheduler/crontab.d.ts +14 -0
- package/dist/src/scheduler/crontab.d.ts.map +1 -0
- package/dist/src/scheduler/crontab.js +308 -0
- package/dist/src/scheduler/crontab.js.map +1 -0
- package/dist/src/scheduler/scheduler.d.ts +41 -0
- package/dist/src/scheduler/scheduler.d.ts.map +1 -0
- package/dist/src/scheduler/scheduler.js +165 -0
- package/dist/src/scheduler/scheduler.js.map +1 -0
- package/dist/src/serialization.d.ts +57 -0
- package/dist/src/serialization.d.ts.map +1 -0
- package/dist/src/serialization.js +306 -0
- package/dist/src/serialization.js.map +1 -0
- package/dist/src/solidactions-executor.d.ts +177 -0
- package/dist/src/solidactions-executor.d.ts.map +1 -0
- package/dist/src/solidactions-executor.js +817 -0
- package/dist/src/solidactions-executor.js.map +1 -0
- package/dist/src/solidactions.d.ts +519 -0
- package/dist/src/solidactions.d.ts.map +1 -0
- package/dist/src/solidactions.js +1284 -0
- package/dist/src/solidactions.js.map +1 -0
- package/dist/src/step.d.ts +16 -0
- package/dist/src/step.d.ts.map +1 -0
- package/dist/src/step.js +3 -0
- package/dist/src/step.js.map +1 -0
- package/dist/src/system_database.d.ts +141 -0
- package/dist/src/system_database.d.ts.map +1 -0
- package/dist/src/system_database.js +25 -0
- package/dist/src/system_database.js.map +1 -0
- package/dist/src/telemetry/collector.d.ts +13 -0
- package/dist/src/telemetry/collector.d.ts.map +1 -0
- package/dist/src/telemetry/collector.js +63 -0
- package/dist/src/telemetry/collector.js.map +1 -0
- package/dist/src/telemetry/exporters.d.ts +13 -0
- package/dist/src/telemetry/exporters.d.ts.map +1 -0
- package/dist/src/telemetry/exporters.js +101 -0
- package/dist/src/telemetry/exporters.js.map +1 -0
- package/dist/src/telemetry/logs.d.ts +52 -0
- package/dist/src/telemetry/logs.d.ts.map +1 -0
- package/dist/src/telemetry/logs.js +287 -0
- package/dist/src/telemetry/logs.js.map +1 -0
- package/dist/src/telemetry/traces.d.ts +52 -0
- package/dist/src/telemetry/traces.d.ts.map +1 -0
- package/dist/src/telemetry/traces.js +150 -0
- package/dist/src/telemetry/traces.js.map +1 -0
- package/dist/src/utils.d.ts +26 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +136 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/wfqueue.d.ts +64 -0
- package/dist/src/wfqueue.d.ts.map +1 -0
- package/dist/src/wfqueue.js +147 -0
- package/dist/src/wfqueue.js.map +1 -0
- package/dist/src/workflow.d.ts +154 -0
- package/dist/src/workflow.d.ts.map +1 -0
- package/dist/src/workflow.js +99 -0
- package/dist/src/workflow.js.map +1 -0
- package/dist/src/workflow_management.d.ts +15 -0
- package/dist/src/workflow_management.d.ts.map +1 -0
- package/dist/src/workflow_management.js +87 -0
- package/dist/src/workflow_management.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/docs/api-schema.md +1441 -0
- package/docs/migration-guide.md +460 -0
- package/docs/phase-14-changes.md +156 -0
- package/docs/solidsteps-ai-prompt.md +534 -0
- package/eslint.config.cjs +50 -0
- package/package.json +84 -0
- package/solidactions-ai-prompt.md +1504 -0
- package/solidactions-config.schema.json +132 -0
- package/solidactions-test-config.yaml +15 -0
|
@@ -0,0 +1,630 @@
|
|
|
1
|
+
# Implementation Plan
|
|
2
|
+
|
|
3
|
+
**Project**: dbos-http-sdk
|
|
4
|
+
**Generated**: 2026-01-10T03:45:00Z
|
|
5
|
+
|
|
6
|
+
## Technical Context & Standards
|
|
7
|
+
|
|
8
|
+
_Detected Stack & Patterns_
|
|
9
|
+
|
|
10
|
+
- **Language**: TypeScript (Node.js >=20)
|
|
11
|
+
- **Current DB**: PostgreSQL via `pg@8.11.3`
|
|
12
|
+
- **Architecture**: `SystemDatabase` interface with `PostgresSystemDatabase` implementation
|
|
13
|
+
- **Serialization**: `superjson` for complex types, JSON for simple types
|
|
14
|
+
- **Entry Point**: `src/index.ts` exports main SDK
|
|
15
|
+
- **Key Interface**: `SystemDatabase` (lines 64-200 in `src/system_database.ts`)
|
|
16
|
+
|
|
17
|
+
_Files to Modify/Create_
|
|
18
|
+
|
|
19
|
+
- `src/system_database.ts` → Create `HttpSystemDatabase` class
|
|
20
|
+
- `src/http_client.ts` → New HTTP client with retry logic
|
|
21
|
+
- `src/config.ts` → Update configuration for HTTP
|
|
22
|
+
- `src/client.ts` → Replace Pool with HTTP client
|
|
23
|
+
- `src/dbos-executor.ts` → Update to use HTTP
|
|
24
|
+
- `package.json` → Remove `pg`, add HTTP client
|
|
25
|
+
- `docs/api-schema.md` → New API documentation
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Phase 1: SDK Infrastructure
|
|
30
|
+
|
|
31
|
+
**Goal**: Create HTTP client infrastructure with retry logic, error handling, and configuration.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
- [x] **Create HTTP Client with Retry Logic** (ref: PRD Section 4)
|
|
36
|
+
Task ID: `phase-1-infra-01`
|
|
37
|
+
> **Implementation**: Create `src/http_client.ts` > **Details**: Create HTTP client class with:
|
|
38
|
+
>
|
|
39
|
+
> ```typescript
|
|
40
|
+
> export interface HttpClientConfig {
|
|
41
|
+
> baseUrl: string;
|
|
42
|
+
> apiKey: string;
|
|
43
|
+
> timeout?: number; // Default: 30000ms
|
|
44
|
+
> maxRetries?: number; // Default: 3
|
|
45
|
+
> retryDelay?: number; // Default: 1000ms (base for exponential)
|
|
46
|
+
> }
|
|
47
|
+
>
|
|
48
|
+
> export class HttpClient {
|
|
49
|
+
> constructor(config: HttpClientConfig);
|
|
50
|
+
> async request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
51
|
+
> // Internal: exponential backoff with jitter
|
|
52
|
+
> // Internal: respect Retry-After header
|
|
53
|
+
> }
|
|
54
|
+
> ```
|
|
55
|
+
>
|
|
56
|
+
> Use native `fetch` (Node.js 18+). Implement:
|
|
57
|
+
>
|
|
58
|
+
> - Exponential backoff: `delay * 2^attempt + random(0, delay * 0.5)`
|
|
59
|
+
> - Only retry on 5xx and network errors
|
|
60
|
+
> - Throw immediately on 4xx
|
|
61
|
+
> - Log retry attempts using `GlobalLogger` from `src/telemetry/logs.ts`
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
- [x] **Create HTTP Error Types** (ref: PRD Section 3)
|
|
66
|
+
Task ID: `phase-1-infra-02`
|
|
67
|
+
> **Implementation**: Add to `src/error.ts` > **Details**: Add new error types that map to HTTP errors:
|
|
68
|
+
>
|
|
69
|
+
> ```typescript
|
|
70
|
+
> export class DBOSHttpError extends DBOSError {
|
|
71
|
+
> constructor(message: string, public statusCode: number, public responseBody?: unknown);
|
|
72
|
+
> }
|
|
73
|
+
> export class DBOSUnauthorizedError extends DBOSHttpError { /* 401 */ }
|
|
74
|
+
> export class DBOSForbiddenError extends DBOSHttpError { /* 403 */ }
|
|
75
|
+
> export class DBOSNotFoundError extends DBOSHttpError { /* 404 */ }
|
|
76
|
+
> export class DBOSRateLimitedError extends DBOSHttpError { /* 429 */ }
|
|
77
|
+
> export class DBOSServerError extends DBOSHttpError { /* 5xx */ }
|
|
78
|
+
> export class DBOSNetworkError extends DBOSError { /* Network failures */ }
|
|
79
|
+
> ```
|
|
80
|
+
>
|
|
81
|
+
> Existing errors like `DBOSWorkflowConflictError` (line 4) can be thrown for 409.
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
- [x] **Create Error Mapper Function** (ref: PRD Section 3)
|
|
86
|
+
Task ID: `phase-1-infra-03`
|
|
87
|
+
> **Implementation**: Add to `src/http_client.ts` > **Details**: Create function to map HTTP responses to SDK errors:
|
|
88
|
+
>
|
|
89
|
+
> ```typescript
|
|
90
|
+
> export function mapHttpError(response: Response, body?: unknown): never {
|
|
91
|
+
> switch (response.status) {
|
|
92
|
+
> case 400: throw new DBOSValidationError(body?.message);
|
|
93
|
+
> case 401: throw new DBOSUnauthorizedError(...);
|
|
94
|
+
> case 404: throw new DBOSNonExistentWorkflowError(...); // Reuse existing
|
|
95
|
+
> case 409: throw new DBOSWorkflowConflictError(...); // Reuse existing
|
|
96
|
+
> case 429: throw new DBOSRateLimitedError(...);
|
|
97
|
+
> default: throw new DBOSServerError(...);
|
|
98
|
+
> }
|
|
99
|
+
> }
|
|
100
|
+
> ```
|
|
101
|
+
>
|
|
102
|
+
> Map to existing errors where appropriate (lines 4-11 in `src/system_database.ts`).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
- [x] **Update Configuration for HTTP** (ref: PRD Section 5)
|
|
107
|
+
Task ID: `phase-1-infra-04`
|
|
108
|
+
> **Implementation**: Modify `src/config.ts` > **Details**: Replace database URL config with HTTP config. Update `getSystemDatabaseUrl()` (lines 94-150):
|
|
109
|
+
>
|
|
110
|
+
> ```typescript
|
|
111
|
+
> export interface DBOSHttpConfig {
|
|
112
|
+
> apiUrl: string; // Required: Base API URL
|
|
113
|
+
> apiKey: string; // Required: Bearer token
|
|
114
|
+
> timeout?: number; // Optional: Request timeout
|
|
115
|
+
> maxRetries?: number; // Optional: Retry count
|
|
116
|
+
> }
|
|
117
|
+
>
|
|
118
|
+
> export function getHttpConfig(configFile?: DBOSConfig): DBOSHttpConfig {
|
|
119
|
+
> // Read from config or environment variables:
|
|
120
|
+
> // DBOS_API_URL, DBOS_API_KEY
|
|
121
|
+
> }
|
|
122
|
+
> ```
|
|
123
|
+
>
|
|
124
|
+
> Remove: `getSystemDatabaseUrl()`, `getPGClientConfig()` functions.
|
|
125
|
+
> Keep: Other config functions not related to database.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
- [x] **Update DBOSConfig Interface** (ref: PRD Section 5)
|
|
130
|
+
Task ID: `phase-1-infra-05`
|
|
131
|
+
> **Implementation**: Modify `src/config.ts` > **Details**: Update the `DBOSConfig` interface to use HTTP config instead of database config:
|
|
132
|
+
>
|
|
133
|
+
> - Remove: `system_database` property with PostgreSQL URL
|
|
134
|
+
> - Add: `api` property with `{ url: string, key: string, timeout?: number }`
|
|
135
|
+
> - Update validation to require `api.url` and `api.key`
|
|
136
|
+
> - Update `loadDBOSConfig()` function to parse new format
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Phase 2: Implement HttpSystemDatabase
|
|
141
|
+
|
|
142
|
+
**Goal**: Create new `HttpSystemDatabase` class implementing the `SystemDatabase` interface using HTTP calls.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
- [x] **Create HttpSystemDatabase Class Shell** (ref: PRD Section 1)
|
|
147
|
+
Task ID: `phase-2-http-db-01`
|
|
148
|
+
> **Implementation**: Create new class in `src/system_database.ts` (after line 200)
|
|
149
|
+
> **Details**: Create class that implements `SystemDatabase` interface:
|
|
150
|
+
>
|
|
151
|
+
> ```typescript
|
|
152
|
+
> export class HttpSystemDatabase implements SystemDatabase {
|
|
153
|
+
> private client: HttpClient;
|
|
154
|
+
> private executorID: string;
|
|
155
|
+
> private appVersion: string;
|
|
156
|
+
> private runningWorkflows: Map<string, Promise<unknown>> = new Map();
|
|
157
|
+
>
|
|
158
|
+
> constructor(config: DBOSHttpConfig, executorID: string, appVersion: string) {
|
|
159
|
+
> this.client = new HttpClient({
|
|
160
|
+
> baseUrl: config.apiUrl,
|
|
161
|
+
> apiKey: config.apiKey,
|
|
162
|
+
> timeout: config.timeout,
|
|
163
|
+
> maxRetries: config.maxRetries,
|
|
164
|
+
> });
|
|
165
|
+
> this.executorID = executorID;
|
|
166
|
+
> this.appVersion = appVersion;
|
|
167
|
+
> }
|
|
168
|
+
> }
|
|
169
|
+
> ```
|
|
170
|
+
>
|
|
171
|
+
> Keep `PostgresSystemDatabase` temporarily for reference, remove in Phase 4.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
- [x] **Implement init() and destroy()** (ref: PRD Section 1)
|
|
176
|
+
Task ID: `phase-2-http-db-02`
|
|
177
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
178
|
+
> **Details**:
|
|
179
|
+
>
|
|
180
|
+
> ```typescript
|
|
181
|
+
> async init(debugMode?: boolean): Promise<void> {
|
|
182
|
+
> // HTTP version: Just verify connectivity
|
|
183
|
+
> await this.client.request('GET', '/health');
|
|
184
|
+
> // Note: Migrations are Laravel's responsibility
|
|
185
|
+
> }
|
|
186
|
+
>
|
|
187
|
+
> async destroy(): Promise<void> {
|
|
188
|
+
> // HTTP version: No persistent connections to close
|
|
189
|
+
> // Just await running workflows
|
|
190
|
+
> await this.awaitRunningWorkflows();
|
|
191
|
+
> }
|
|
192
|
+
> ```
|
|
193
|
+
>
|
|
194
|
+
> Original PostgresSystemDatabase.init() is at lines 899-911, destroy() at 913-925.
|
|
195
|
+
|
|
196
|
+
---
|
|
197
|
+
|
|
198
|
+
- [x] **Implement Workflow Status Methods** (ref: PRD Section 1)
|
|
199
|
+
Task ID: `phase-2-http-db-03`
|
|
200
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
201
|
+
> **Details**: Implement these methods using HTTP calls:
|
|
202
|
+
>
|
|
203
|
+
> - `initWorkflowStatus()` → `POST /workflows`
|
|
204
|
+
> - `recordWorkflowOutput()` → `PUT /workflows/{id}/output`
|
|
205
|
+
> - `recordWorkflowError()` → `PUT /workflows/{id}/error`
|
|
206
|
+
> - `getWorkflowStatus()` → `GET /workflows/{id}`
|
|
207
|
+
> - `getPendingWorkflows()` → `GET /workflows/pending?executorId=X&appVersion=Y`
|
|
208
|
+
> - `listWorkflows()` → `GET /workflows?{filters}`
|
|
209
|
+
>
|
|
210
|
+
> Match request/response types to `WorkflowStatusInternal` interface.
|
|
211
|
+
> Original implementations: lines 928-1055 in PostgresSystemDatabase.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
- [x] **Implement Operation Result Methods** (ref: PRD Section 1)
|
|
216
|
+
Task ID: `phase-2-http-db-04`
|
|
217
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
218
|
+
> **Details**: Implement these methods:
|
|
219
|
+
>
|
|
220
|
+
> - `getOperationResultAndThrowIfCancelled()` → `GET /workflows/{id}/operations/{functionId}`
|
|
221
|
+
> - `getAllOperationResults()` → `GET /workflows/{id}/operations`
|
|
222
|
+
> - `recordOperationResult()` → `POST /workflows/{id}/operations`
|
|
223
|
+
>
|
|
224
|
+
> Handle cancelled status: If response indicates cancelled, throw `DBOSWorkflowCancelledError`.
|
|
225
|
+
> Original implementations: lines 1083-1135 in PostgresSystemDatabase.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
- [x] **Implement awaitWorkflowResult() with Polling** (ref: PRD Section 1)
|
|
230
|
+
Task ID: `phase-2-http-db-05`
|
|
231
|
+
> **Implementation**: Add method to `HttpSystemDatabase` class
|
|
232
|
+
> **Details**: Implement polling-based wait for workflow result:
|
|
233
|
+
>
|
|
234
|
+
> ```typescript
|
|
235
|
+
> async awaitWorkflowResult(
|
|
236
|
+
> workflowID: string,
|
|
237
|
+
> timeoutSeconds?: number,
|
|
238
|
+
> callerID?: string,
|
|
239
|
+
> timerFuncID?: number,
|
|
240
|
+
> ): Promise<SystemDatabaseStoredResult | undefined> {
|
|
241
|
+
> const deadline = timeoutSeconds ? Date.now() + timeoutSeconds * 1000 : undefined;
|
|
242
|
+
> const pollInterval = 1000; // 1 second
|
|
243
|
+
>
|
|
244
|
+
> while (!deadline || Date.now() < deadline) {
|
|
245
|
+
> const result = await this.client.request('GET', `/workflows/${workflowID}/result`);
|
|
246
|
+
> if (result.status !== 'PENDING') return result;
|
|
247
|
+
> await sleepms(pollInterval);
|
|
248
|
+
> }
|
|
249
|
+
> return undefined; // Timeout
|
|
250
|
+
> }
|
|
251
|
+
> ```
|
|
252
|
+
>
|
|
253
|
+
> Original PostgreSQL version uses LISTEN/NOTIFY (lines 1817-1905). HTTP version uses polling.
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
- [x] **Implement Workflow Control Methods** (ref: PRD Section 1)
|
|
258
|
+
Task ID: `phase-2-http-db-06`
|
|
259
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
260
|
+
> **Details**: Implement these methods:
|
|
261
|
+
>
|
|
262
|
+
> - `setWorkflowStatus()` → `PUT /workflows/{id}/status`
|
|
263
|
+
> - `cancelWorkflow()` → `POST /workflows/{id}/cancel`
|
|
264
|
+
> - `resumeWorkflow()` → `POST /workflows/{id}/resume`
|
|
265
|
+
> - `forkWorkflow()` → `POST /workflows/{id}/fork`
|
|
266
|
+
> - `checkIfCanceled()` → `GET /workflows/{id}/cancelled`
|
|
267
|
+
>
|
|
268
|
+
> Original implementations: lines 1657-1769 in PostgresSystemDatabase.
|
|
269
|
+
|
|
270
|
+
---
|
|
271
|
+
|
|
272
|
+
- [x] **Implement Running Workflow Tracking** (ref: PRD Section 1)
|
|
273
|
+
Task ID: `phase-2-http-db-07`
|
|
274
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
275
|
+
> **Details**: These are in-memory operations (no HTTP needed):
|
|
276
|
+
>
|
|
277
|
+
> ```typescript
|
|
278
|
+
> registerRunningWorkflow(workflowID: string, workflowPromise: Promise<unknown>): void {
|
|
279
|
+
> this.runningWorkflows.set(workflowID, workflowPromise);
|
|
280
|
+
> workflowPromise.finally(() => this.runningWorkflows.delete(workflowID));
|
|
281
|
+
> }
|
|
282
|
+
>
|
|
283
|
+
> checkForRunningWorkflow(workflowID: string): boolean {
|
|
284
|
+
> return this.runningWorkflows.has(workflowID);
|
|
285
|
+
> }
|
|
286
|
+
>
|
|
287
|
+
> async awaitRunningWorkflows(): Promise<void> {
|
|
288
|
+
> await Promise.allSettled(this.runningWorkflows.values());
|
|
289
|
+
> }
|
|
290
|
+
> ```
|
|
291
|
+
>
|
|
292
|
+
> Same logic as PostgresSystemDatabase (in-memory tracking).
|
|
293
|
+
|
|
294
|
+
---
|
|
295
|
+
|
|
296
|
+
- [x] **Implement Queue Methods** (ref: PRD Section 1)
|
|
297
|
+
Task ID: `phase-2-http-db-08`
|
|
298
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
299
|
+
> **Details**: Implement these methods:
|
|
300
|
+
>
|
|
301
|
+
> - `clearQueueAssignment()` → `DELETE /workflows/{id}/queue-assignment`
|
|
302
|
+
> - `getDeduplicatedWorkflow()` → `GET /queues/{name}/deduplicated/{dedupId}`
|
|
303
|
+
> - `getQueuePartitions()` → `GET /queues/{name}/partitions`
|
|
304
|
+
> - `findAndMarkStartableWorkflows()` → `POST /queues/{name}/start-workflows`
|
|
305
|
+
>
|
|
306
|
+
> Original implementations: lines 2134-2320 in PostgresSystemDatabase.
|
|
307
|
+
> Note: `findAndMarkStartableWorkflows` is complex with REPEATABLE READ - Laravel handles atomicity.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
- [x] **Implement Messaging Methods (send/recv/sleep)** (ref: PRD Section 1)
|
|
312
|
+
Task ID: `phase-2-http-db-09`
|
|
313
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
314
|
+
> **Details**: Implement these methods:
|
|
315
|
+
>
|
|
316
|
+
> - `send()` → `POST /workflows/{id}/messages`
|
|
317
|
+
> - `recv()` → `GET /workflows/{id}/messages?topic=X` (with polling loop)
|
|
318
|
+
> - `durableSleepms()` → `POST /workflows/{id}/sleep`
|
|
319
|
+
>
|
|
320
|
+
> For `recv()`, implement polling similar to `awaitWorkflowResult()`:
|
|
321
|
+
>
|
|
322
|
+
> ```typescript
|
|
323
|
+
> async recv(workflowID, functionID, timeoutFunctionID, topic?, timeoutSeconds?): Promise<string | null> {
|
|
324
|
+
> const deadline = timeoutSeconds ? Date.now() + timeoutSeconds * 1000 : undefined;
|
|
325
|
+
> while (!deadline || Date.now() < deadline) {
|
|
326
|
+
> // Check if cancelled first
|
|
327
|
+
> await this.checkIfCanceled(workflowID);
|
|
328
|
+
> const result = await this.client.request('GET', `/workflows/${workflowID}/messages?topic=${topic}`);
|
|
329
|
+
> if (result.message !== null) return result.message;
|
|
330
|
+
> await sleepms(1000);
|
|
331
|
+
> }
|
|
332
|
+
> return null;
|
|
333
|
+
> }
|
|
334
|
+
> ```
|
|
335
|
+
>
|
|
336
|
+
> Original implementations: lines 1242-1480 in PostgresSystemDatabase.
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
- [x] **Implement Event Methods** (ref: PRD Section 1)
|
|
341
|
+
Task ID: `phase-2-http-db-10`
|
|
342
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
343
|
+
> **Details**: Implement these methods:
|
|
344
|
+
>
|
|
345
|
+
> - `setEvent()` → `PUT /workflows/{id}/events/{key}`
|
|
346
|
+
> - `getEvent()` → `GET /workflows/{id}/events/{key}` (with polling loop)
|
|
347
|
+
>
|
|
348
|
+
> For `getEvent()`, implement polling similar to `recv()`.
|
|
349
|
+
> Original implementations: lines 1501-1656 in PostgresSystemDatabase.
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
- [x] **Implement Event Dispatch State Methods** (ref: PRD Section 1)
|
|
354
|
+
Task ID: `phase-2-http-db-11`
|
|
355
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
356
|
+
> **Details**: Implement these methods:
|
|
357
|
+
>
|
|
358
|
+
> - `getEventDispatchState()` → `GET /event-dispatch/{service}/{workflowFnName}/{key}`
|
|
359
|
+
> - `upsertEventDispatchState()` → `PUT /event-dispatch`
|
|
360
|
+
>
|
|
361
|
+
> Preserve versioning semantics (update_time, update_seq) in request/response.
|
|
362
|
+
> Original implementations: lines 1959-2014 in PostgresSystemDatabase.
|
|
363
|
+
|
|
364
|
+
---
|
|
365
|
+
|
|
366
|
+
- [x] **Implement Streaming Methods** (ref: PRD Section 1)
|
|
367
|
+
Task ID: `phase-2-http-db-12`
|
|
368
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
369
|
+
> **Details**: Implement these methods:
|
|
370
|
+
>
|
|
371
|
+
> - `writeStreamFromWorkflow()` → `POST /workflows/{id}/streams/{key}` with `{fromWorkflow: true, functionId}`
|
|
372
|
+
> - `writeStreamFromStep()` → `POST /workflows/{id}/streams/{key}` with `{fromWorkflow: false}`
|
|
373
|
+
> - `closeStream()` → `POST /workflows/{id}/streams/{key}/close`
|
|
374
|
+
> - `readStream()` → `GET /workflows/{id}/streams/{key}/{offset}`
|
|
375
|
+
>
|
|
376
|
+
> Handle `DBOS_STREAM_CLOSED_SENTINEL` in responses.
|
|
377
|
+
> Original implementations: lines 2321-2425 in PostgresSystemDatabase.
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
- [x] **Implement Admin Methods** (ref: PRD Section 1)
|
|
382
|
+
Task ID: `phase-2-http-db-13`
|
|
383
|
+
> **Implementation**: Add methods to `HttpSystemDatabase` class
|
|
384
|
+
> **Details**: Implement these methods:
|
|
385
|
+
>
|
|
386
|
+
> - `garbageCollect()` → `POST /admin/garbage-collect`
|
|
387
|
+
> - `getMetrics()` → `GET /admin/metrics?startTime=X&endTime=Y`
|
|
388
|
+
> - `checkPatch()` → `GET /workflows/{id}/patch/{functionId}?patchName=X&deprecated=Y`
|
|
389
|
+
>
|
|
390
|
+
> Original implementations: lines 2427-2543 in PostgresSystemDatabase.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Phase 3: Integration & Cleanup
|
|
395
|
+
|
|
396
|
+
**Goal**: Wire up new HttpSystemDatabase, remove PostgreSQL dependencies.
|
|
397
|
+
|
|
398
|
+
---
|
|
399
|
+
|
|
400
|
+
- [x] **Update DBOSExecutor to use HttpSystemDatabase** (ref: PRD Section 1)
|
|
401
|
+
Task ID: `phase-3-integration-01`
|
|
402
|
+
> **Implementation**: Modify `src/dbos-executor.ts` > **Details**: Update DBOSExecutor class:
|
|
403
|
+
>
|
|
404
|
+
> - Line 80: Remove `import { Pool } from 'pg';`
|
|
405
|
+
> - Update constructor to accept `DBOSHttpConfig` instead of database URL
|
|
406
|
+
> - Create `HttpSystemDatabase` instead of `PostgresSystemDatabase`
|
|
407
|
+
> - Remove any direct Pool usage
|
|
408
|
+
>
|
|
409
|
+
> Look for all `Pool` references and replace with HTTP client usage.
|
|
410
|
+
|
|
411
|
+
---
|
|
412
|
+
|
|
413
|
+
- [x] **Update DBOSClient to use HTTP** (ref: PRD Section 1)
|
|
414
|
+
Task ID: `phase-3-integration-02`
|
|
415
|
+
> **Implementation**: Modify `src/client.ts` > **Details**: Update DBOSClient class:
|
|
416
|
+
>
|
|
417
|
+
> - Line 31: Remove `import { Pool } from 'pg';`
|
|
418
|
+
> - Update constructor to use `HttpSystemDatabase` or `HttpClient` directly
|
|
419
|
+
> - Update all methods that query workflow status to use HTTP
|
|
420
|
+
> - Remove Pool member variable and initialization
|
|
421
|
+
>
|
|
422
|
+
> The client uses Pool for `listWorkflows()`, `getWorkflow()`, etc.
|
|
423
|
+
|
|
424
|
+
---
|
|
425
|
+
|
|
426
|
+
- [x] **Remove database_utils.ts PostgreSQL Functions** (ref: PRD Section 1)
|
|
427
|
+
Task ID: `phase-3-integration-03`
|
|
428
|
+
> **Implementation**: Modify `src/database_utils.ts` > **Details**:
|
|
429
|
+
>
|
|
430
|
+
> - Remove or deprecate functions that are PostgreSQL-specific:
|
|
431
|
+
> - `dropPGDatabase()` (lines 40-177)
|
|
432
|
+
> - `ensurePGDatabase()` (lines 207-326)
|
|
433
|
+
> - `connectToPGDatabase()` (lines 377-394)
|
|
434
|
+
> - `connectToPGAndReportOutcome()` (lines 396-416)
|
|
435
|
+
> - `currentDBUserIdentity()` (lines 423-430)
|
|
436
|
+
> - `getPGDatabaseOwner()` (lines 432-440)
|
|
437
|
+
> - `grantDbosSchemaPermissions()` (lines 253-303)
|
|
438
|
+
> - Keep utility functions not tied to PostgreSQL if any exist
|
|
439
|
+
> - Consider renaming file to `http_utils.ts` if it has remaining content
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
- [x] **Update CLI to use HTTP** (ref: PRD Section 1)
|
|
444
|
+
Task ID: `phase-3-integration-04`
|
|
445
|
+
> **Implementation**: Modify `src/cli/cli.ts` > **Details**: Update CLI commands that interact with database:
|
|
446
|
+
>
|
|
447
|
+
> - Commands that list/query workflows should use HTTP client
|
|
448
|
+
> - Remove direct database connection logic
|
|
449
|
+
> - Update `docker_pg_helper.ts` - either remove entirely or keep for local development with note that it's for Laravel's database, not SDK's
|
|
450
|
+
|
|
451
|
+
---
|
|
452
|
+
|
|
453
|
+
- [x] **Remove PostgresSystemDatabase Class** (ref: PRD Section 1)
|
|
454
|
+
Task ID: `phase-3-integration-05`
|
|
455
|
+
> **Implementation**: Modify `src/system_database.ts` > **Details**:
|
|
456
|
+
>
|
|
457
|
+
> - Remove the entire `PostgresSystemDatabase` class (lines 830-2554)
|
|
458
|
+
> - Remove helper functions that were only used by PostgresSystemDatabase:
|
|
459
|
+
> - `insertWorkflowStatus()` (lines 400-517)
|
|
460
|
+
> - `updateWorkflowStatus()` (lines 512-596)
|
|
461
|
+
> - `recordOperationResult()` helper (lines 598-767)
|
|
462
|
+
> - Keep the `SystemDatabase` interface (lines 64-200)
|
|
463
|
+
> - Keep `HttpSystemDatabase` as the only implementation
|
|
464
|
+
> - Remove `import { ... } from 'pg';` at line 2
|
|
465
|
+
|
|
466
|
+
---
|
|
467
|
+
|
|
468
|
+
- [x] **Remove Migration Runner** (ref: PRD Section 1)
|
|
469
|
+
Task ID: `phase-3-integration-06`
|
|
470
|
+
> **Implementation**: Remove/deprecate `src/sysdb_migrations/` > **Details**:
|
|
471
|
+
>
|
|
472
|
+
> - Remove or deprecate `src/sysdb_migrations/migration_runner.ts`
|
|
473
|
+
> - Remove or deprecate `src/sysdb_migrations/internal/migrations.ts`
|
|
474
|
+
> - Migrations are now Laravel's responsibility
|
|
475
|
+
> - Document in API schema that Laravel must set up the database schema
|
|
476
|
+
|
|
477
|
+
---
|
|
478
|
+
|
|
479
|
+
- [x] **Update package.json Dependencies** (ref: PRD Section 4)
|
|
480
|
+
Task ID: `phase-3-integration-07`
|
|
481
|
+
> **Implementation**: Modify `package.json` > **Details**:
|
|
482
|
+
> Remove from `dependencies`:
|
|
483
|
+
>
|
|
484
|
+
> ```json
|
|
485
|
+
> - "pg": "8.11.3"
|
|
486
|
+
> ```
|
|
487
|
+
>
|
|
488
|
+
> Remove from `devDependencies`:
|
|
489
|
+
>
|
|
490
|
+
> ```json
|
|
491
|
+
> - "@types/pg": "^8.11.2"
|
|
492
|
+
> - "@testcontainers/postgresql": "^11.6.0"
|
|
493
|
+
> ```
|
|
494
|
+
>
|
|
495
|
+
> Note: No new HTTP client dependency needed if using native `fetch` (Node.js 18+).
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
- [x] **Update Index Exports** (ref: PRD Section 1)
|
|
500
|
+
Task ID: `phase-3-integration-08`
|
|
501
|
+
> **Implementation**: Modify `src/index.ts` > **Details**:
|
|
502
|
+
>
|
|
503
|
+
> - Export `HttpSystemDatabase` instead of `PostgresSystemDatabase`
|
|
504
|
+
> - Export new error types (`DBOSHttpError`, etc.)
|
|
505
|
+
> - Export `HttpClient` and `HttpClientConfig` for advanced usage
|
|
506
|
+
> - Remove any PostgreSQL-specific exports
|
|
507
|
+
|
|
508
|
+
---
|
|
509
|
+
|
|
510
|
+
## Phase 4: API Schema Documentation
|
|
511
|
+
|
|
512
|
+
**Goal**: Document all HTTP endpoints based on the implemented HttpSystemDatabase for Laravel to implement.
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
- [x] **Create API Schema Documentation** (ref: PRD Section 2)
|
|
517
|
+
Task ID: `phase-4-api-docs-01`
|
|
518
|
+
> **Implementation**: Create `docs/api-schema.md` > **Details**: Document all HTTP endpoints based on actual implementation:
|
|
519
|
+
>
|
|
520
|
+
> - Base URL and authentication header format
|
|
521
|
+
> - All endpoints organized by category (workflows, operations, queues, messaging, events, streams, admin)
|
|
522
|
+
> - Request/response JSON schemas derived from TypeScript interfaces
|
|
523
|
+
> - HTTP status codes and their meanings
|
|
524
|
+
> - Atomicity requirements (mark which endpoints must be transactional)
|
|
525
|
+
> - Polling endpoints (recv, getEvent, awaitWorkflowResult) with recommended intervals
|
|
526
|
+
|
|
527
|
+
---
|
|
528
|
+
|
|
529
|
+
- [x] **Document Database Schema for Laravel** (ref: PRD Section 2)
|
|
530
|
+
Task ID: `phase-4-api-docs-02`
|
|
531
|
+
> **Implementation**: Add to `docs/api-schema.md` > **Details**: Include database schema documentation for Laravel:
|
|
532
|
+
>
|
|
533
|
+
> - All tables from `schemas/system_db_schema.ts`
|
|
534
|
+
> - Indexes required for performance
|
|
535
|
+
> - Foreign key relationships
|
|
536
|
+
> - Note: Laravel owns migrations, but needs to know the schema
|
|
537
|
+
|
|
538
|
+
---
|
|
539
|
+
|
|
540
|
+
## Phase 5: Validation & Documentation
|
|
541
|
+
|
|
542
|
+
**Goal**: Ensure everything works, update tests, create documentation.
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
- [x] **Update Unit Tests for HTTP** (ref: PRD Section 4)
|
|
547
|
+
Task ID: `phase-5-validation-01`
|
|
548
|
+
> **Implementation**: Modify test files in `tests/` > **Details**:
|
|
549
|
+
>
|
|
550
|
+
> - Replace PostgreSQL test containers with HTTP mocking
|
|
551
|
+
> - Use `jest.mock()` or similar to mock `fetch` calls
|
|
552
|
+
> - Create mock HTTP responses for all endpoints
|
|
553
|
+
> - Ensure all existing test cases pass with HTTP mocks
|
|
554
|
+
> - Test retry logic with simulated 5xx errors
|
|
555
|
+
> - Test error mapping with simulated 4xx errors
|
|
556
|
+
|
|
557
|
+
---
|
|
558
|
+
|
|
559
|
+
- [x] **Create HTTP Integration Tests** (ref: PRD Section 4)
|
|
560
|
+
Task ID: `phase-5-validation-02`
|
|
561
|
+
> **Implementation**: Create `tests/http_integration.test.ts` > **Details**:
|
|
562
|
+
>
|
|
563
|
+
> - Create integration tests that test against a real HTTP server
|
|
564
|
+
> - Can use a mock server or wait for Laravel implementation
|
|
565
|
+
> - Test full workflow lifecycle over HTTP
|
|
566
|
+
> - Test error scenarios
|
|
567
|
+
|
|
568
|
+
---
|
|
569
|
+
|
|
570
|
+
- [x] **Create Migration Guide Document** (ref: PRD Deliverables)
|
|
571
|
+
Task ID: `phase-5-validation-03`
|
|
572
|
+
> **Implementation**: Create `docs/migration-guide.md` > **Details**: Document for users:
|
|
573
|
+
>
|
|
574
|
+
> - Configuration changes (database URL → API URL + key)
|
|
575
|
+
> - Environment variable changes (`PGHOST` → `DBOS_API_URL`)
|
|
576
|
+
> - Breaking changes list
|
|
577
|
+
> - Example new configuration
|
|
578
|
+
> - Step-by-step migration instructions
|
|
579
|
+
|
|
580
|
+
---
|
|
581
|
+
|
|
582
|
+
- [x] **Document Removed Dependencies** (ref: PRD Deliverables)
|
|
583
|
+
Task ID: `phase-5-validation-04`
|
|
584
|
+
> **Implementation**: Add section to `docs/migration-guide.md` > **Details**: List all removed packages:
|
|
585
|
+
>
|
|
586
|
+
> - `pg@8.11.3`
|
|
587
|
+
> - `@types/pg@^8.11.2`
|
|
588
|
+
> - `@testcontainers/postgresql@^11.6.0`
|
|
589
|
+
>
|
|
590
|
+
> Explain implications for users who may have been using these.
|
|
591
|
+
|
|
592
|
+
---
|
|
593
|
+
|
|
594
|
+
- [x] **Update README** (ref: PRD Deliverables)
|
|
595
|
+
Task ID: `phase-5-validation-05`
|
|
596
|
+
> **Implementation**: Modify `README.md` > **Details**:
|
|
597
|
+
>
|
|
598
|
+
> - Update installation instructions
|
|
599
|
+
> - Update configuration examples to show API URL + key
|
|
600
|
+
> - Remove PostgreSQL setup instructions
|
|
601
|
+
> - Add link to Laravel API requirements
|
|
602
|
+
> - Update architecture diagram if present
|
|
603
|
+
|
|
604
|
+
---
|
|
605
|
+
|
|
606
|
+
- [x] **Final Verification: Run All Tests** (ref: PRD Success Criteria)
|
|
607
|
+
Task ID: `phase-5-validation-06`
|
|
608
|
+
> **Implementation**: Run `npm test` > **Details**:
|
|
609
|
+
>
|
|
610
|
+
> - Ensure all unit tests pass
|
|
611
|
+
> - Ensure no TypeScript errors (`npm run build`)
|
|
612
|
+
> - Ensure no lint errors (`npm run lint`)
|
|
613
|
+
> - Verify package can be published (`npm pack --dry-run`)
|
|
614
|
+
|
|
615
|
+
---
|
|
616
|
+
|
|
617
|
+
## Summary
|
|
618
|
+
|
|
619
|
+
| Phase | Tasks | Focus |
|
|
620
|
+
| --------- | ------ | -------------------------------------------------- |
|
|
621
|
+
| Phase 1 | 5 | SDK Infrastructure (HTTP client, errors, config) |
|
|
622
|
+
| Phase 2 | 13 | Implement HttpSystemDatabase |
|
|
623
|
+
| Phase 3 | 8 | Integration & Cleanup |
|
|
624
|
+
| Phase 4 | 2 | API Schema Documentation (based on implementation) |
|
|
625
|
+
| Phase 5 | 6 | Validation & Documentation |
|
|
626
|
+
| **Total** | **34** | |
|
|
627
|
+
|
|
628
|
+
---
|
|
629
|
+
|
|
630
|
+
_Generated by Clavix /clavix:plan_
|