@stepflowjs/adapter-nitric 0.0.1
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/dist/index.d.ts +116 -0
- package/dist/index.js +280 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Stepflow } from '@stepflowjs/core';
|
|
2
|
+
export { Execution, NotifyResult, TriggerResult } from '@stepflowjs/core';
|
|
3
|
+
import { AuthContext, AuthConfig, EndpointOption, BaseAdapterOptions } from '@stepflowjs/adapter-shared';
|
|
4
|
+
export { AuthConfig, AuthContext, AuthHandler, AuthResult, EndpointConfig, EndpointOption, EndpointPreset, RouteName, allOf, anyOf, createApiKeyAuth, createBearerAuth, isRouteEnabled, resolveEndpoints } from '@stepflowjs/adapter-shared';
|
|
5
|
+
|
|
6
|
+
/** Nitric-specific request type for auth handlers */
|
|
7
|
+
type NitricRequest = {
|
|
8
|
+
header(name: string): string | undefined;
|
|
9
|
+
headers: Record<string, string>;
|
|
10
|
+
url: string;
|
|
11
|
+
method: string;
|
|
12
|
+
query: Record<string, string>;
|
|
13
|
+
};
|
|
14
|
+
/** Nitric-specific auth context */
|
|
15
|
+
type NitricAuthContext = AuthContext<NitricRequest, NitricHttpContext>;
|
|
16
|
+
/** Nitric-specific auth config */
|
|
17
|
+
type NitricAuthConfig = AuthConfig<NitricRequest, NitricHttpContext>;
|
|
18
|
+
interface HandlerOptions {
|
|
19
|
+
/** Base path prefix for all routes (e.g., "/api/stepflow"). */
|
|
20
|
+
basePath?: string;
|
|
21
|
+
/** Custom health check function. Defaults to stepflow.healthCheck(). */
|
|
22
|
+
healthCheck?: () => Promise<boolean>;
|
|
23
|
+
/** Endpoint configuration - preset or fine-grained */
|
|
24
|
+
endpoints?: EndpointOption;
|
|
25
|
+
/** Authorization configuration */
|
|
26
|
+
auth?: NitricAuthConfig;
|
|
27
|
+
/** Callback when authorization fails */
|
|
28
|
+
onAuthFailure?: BaseAdapterOptions<NitricRequest, NitricHttpContext>["onAuthFailure"];
|
|
29
|
+
}
|
|
30
|
+
interface TriggerRequestBody<TPayload = unknown> {
|
|
31
|
+
payload: TPayload;
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
runId?: string;
|
|
34
|
+
delay?: number;
|
|
35
|
+
idempotencyKey?: string;
|
|
36
|
+
}
|
|
37
|
+
interface NotifyRequestBody {
|
|
38
|
+
data: unknown;
|
|
39
|
+
}
|
|
40
|
+
interface ErrorResponseBody {
|
|
41
|
+
error: string;
|
|
42
|
+
message?: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Nitric HTTP context (simplified version for adapter compatibility)
|
|
46
|
+
*/
|
|
47
|
+
interface NitricHttpContext {
|
|
48
|
+
req: {
|
|
49
|
+
method: string;
|
|
50
|
+
path: string;
|
|
51
|
+
params: Record<string, string>;
|
|
52
|
+
query: Record<string, string>;
|
|
53
|
+
headers: Record<string, string>;
|
|
54
|
+
json: () => Promise<unknown>;
|
|
55
|
+
text: () => Promise<string>;
|
|
56
|
+
};
|
|
57
|
+
res: {
|
|
58
|
+
status: number;
|
|
59
|
+
headers: Record<string, string>;
|
|
60
|
+
body: string | Uint8Array;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
type NitricHandler = (ctx: NitricHttpContext) => Promise<NitricHttpContext>;
|
|
64
|
+
interface StepflowHandlers {
|
|
65
|
+
/** Handler for POST /trigger/:workflowId */
|
|
66
|
+
triggerHandler: NitricHandler;
|
|
67
|
+
/** Handler for GET /runs/:runId */
|
|
68
|
+
runHandler: NitricHandler;
|
|
69
|
+
/** Handler for GET /runs/:runId/stream */
|
|
70
|
+
streamHandler: NitricHandler;
|
|
71
|
+
/** Handler for POST /notify/:eventId */
|
|
72
|
+
notifyHandler: NitricHandler;
|
|
73
|
+
/** Handler for GET /health */
|
|
74
|
+
healthHandler: NitricHandler;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create Nitric HTTP handlers for Stepflow
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { api } from '@nitric/sdk';
|
|
83
|
+
* import { Stepflow } from '@stepflowjs/core';
|
|
84
|
+
* import { createStepflowHandlers } from '@stepflowjs/adapter-nitric';
|
|
85
|
+
*
|
|
86
|
+
* const stepflow = new Stepflow({ storage: ... });
|
|
87
|
+
* const { triggerHandler, runHandler, healthHandler } = createStepflowHandlers(stepflow);
|
|
88
|
+
*
|
|
89
|
+
* const mainApi = api('main');
|
|
90
|
+
*
|
|
91
|
+
* mainApi.post('/stepflow/trigger/:workflowId', triggerHandler);
|
|
92
|
+
* mainApi.get('/stepflow/runs/:runId', runHandler);
|
|
93
|
+
* mainApi.get('/stepflow/health', healthHandler);
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare function createStepflowHandlers(stepflow: Stepflow, options?: HandlerOptions): StepflowHandlers;
|
|
97
|
+
/**
|
|
98
|
+
* Create a combined Nitric handler that routes to the appropriate handler
|
|
99
|
+
* based on the request path and method.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* import { api } from '@nitric/sdk';
|
|
104
|
+
* import { Stepflow } from '@stepflowjs/core';
|
|
105
|
+
* import { createStepflowRouter } from '@stepflowjs/adapter-nitric';
|
|
106
|
+
*
|
|
107
|
+
* const stepflow = new Stepflow({ storage: ... });
|
|
108
|
+
* const router = createStepflowRouter(stepflow, { basePath: '/stepflow' });
|
|
109
|
+
*
|
|
110
|
+
* const mainApi = api('main');
|
|
111
|
+
* mainApi.all('/stepflow/*', router);
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
declare function createStepflowRouter(stepflow: Stepflow, options?: HandlerOptions): NitricHandler;
|
|
115
|
+
|
|
116
|
+
export { type ErrorResponseBody, type HandlerOptions, type NitricAuthConfig, type NitricAuthContext, type NitricHandler, type NitricHttpContext, type NitricRequest, type NotifyRequestBody, type StepflowHandlers, type TriggerRequestBody, createStepflowHandlers, createStepflowRouter };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import {
|
|
3
|
+
isRouteEnabled,
|
|
4
|
+
runAuth,
|
|
5
|
+
getAuthFailureResponse,
|
|
6
|
+
createErrorBody
|
|
7
|
+
} from "@stepflowjs/adapter-shared";
|
|
8
|
+
import {
|
|
9
|
+
createApiKeyAuth,
|
|
10
|
+
createBearerAuth,
|
|
11
|
+
anyOf,
|
|
12
|
+
allOf,
|
|
13
|
+
isRouteEnabled as isRouteEnabled2,
|
|
14
|
+
resolveEndpoints
|
|
15
|
+
} from "@stepflowjs/adapter-shared";
|
|
16
|
+
function getAccessToken(ctx) {
|
|
17
|
+
const queryToken = ctx.req.query["token"];
|
|
18
|
+
if (queryToken) return queryToken;
|
|
19
|
+
const authHeader = ctx.req.headers["authorization"] || ctx.req.headers["Authorization"];
|
|
20
|
+
if (!authHeader) return void 0;
|
|
21
|
+
const match = authHeader.match(/^Bearer\s+(.+)$/i);
|
|
22
|
+
return match?.[1];
|
|
23
|
+
}
|
|
24
|
+
function jsonResponse(ctx, data, status = 200) {
|
|
25
|
+
ctx.res.status = status;
|
|
26
|
+
ctx.res.headers["Content-Type"] = "application/json";
|
|
27
|
+
ctx.res.body = JSON.stringify(data);
|
|
28
|
+
return ctx;
|
|
29
|
+
}
|
|
30
|
+
function jsonError(ctx, status, error, message) {
|
|
31
|
+
const body = message ? { error, message } : { error };
|
|
32
|
+
ctx.res.status = status;
|
|
33
|
+
ctx.res.headers["Content-Type"] = "application/json";
|
|
34
|
+
ctx.res.body = JSON.stringify(body);
|
|
35
|
+
return ctx;
|
|
36
|
+
}
|
|
37
|
+
function jsonAuthError(ctx, status, code, message) {
|
|
38
|
+
const body = createErrorBody(code, message);
|
|
39
|
+
ctx.res.status = status;
|
|
40
|
+
ctx.res.headers["Content-Type"] = "application/json";
|
|
41
|
+
ctx.res.body = JSON.stringify(body);
|
|
42
|
+
return ctx;
|
|
43
|
+
}
|
|
44
|
+
async function parseJsonBody(ctx) {
|
|
45
|
+
try {
|
|
46
|
+
return await ctx.req.json();
|
|
47
|
+
} catch {
|
|
48
|
+
throw new Error("Invalid JSON body");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function createNitricRequest(ctx) {
|
|
52
|
+
return {
|
|
53
|
+
header: (name) => ctx.req.headers[name] || ctx.req.headers[name.toLowerCase()],
|
|
54
|
+
headers: ctx.req.headers,
|
|
55
|
+
url: ctx.req.path,
|
|
56
|
+
method: ctx.req.method,
|
|
57
|
+
query: ctx.req.query
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
async function checkAuth(ctx, route, options, params = {}) {
|
|
61
|
+
const authCtx = {
|
|
62
|
+
route,
|
|
63
|
+
request: createNitricRequest(ctx),
|
|
64
|
+
extra: ctx,
|
|
65
|
+
...params
|
|
66
|
+
};
|
|
67
|
+
const result = await runAuth(authCtx, options.auth);
|
|
68
|
+
if (!result.ok) {
|
|
69
|
+
const { status, code, message } = getAuthFailureResponse(result);
|
|
70
|
+
await options.onAuthFailure?.(authCtx, result);
|
|
71
|
+
return jsonAuthError(ctx, status, code, message);
|
|
72
|
+
}
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
function createStepflowHandlers(stepflow, options = {}) {
|
|
76
|
+
const triggerHandler = async (ctx) => {
|
|
77
|
+
const workflowId = ctx.req.params["workflowId"];
|
|
78
|
+
if (!workflowId) {
|
|
79
|
+
return jsonError(ctx, 400, "Bad request", "Missing workflowId parameter");
|
|
80
|
+
}
|
|
81
|
+
const authError = await checkAuth(ctx, "trigger", options, { workflowId });
|
|
82
|
+
if (authError) return authError;
|
|
83
|
+
try {
|
|
84
|
+
const body = await parseJsonBody(ctx);
|
|
85
|
+
const result = await stepflow.trigger(workflowId, body.payload, {
|
|
86
|
+
runId: body.runId,
|
|
87
|
+
metadata: body.metadata,
|
|
88
|
+
delay: body.delay,
|
|
89
|
+
idempotencyKey: body.idempotencyKey
|
|
90
|
+
});
|
|
91
|
+
const response = result;
|
|
92
|
+
return jsonResponse(ctx, response);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
const message = error.message;
|
|
95
|
+
if (message.includes("Workflow") && message.includes("not found")) {
|
|
96
|
+
return jsonError(ctx, 404, "Not found", message);
|
|
97
|
+
}
|
|
98
|
+
if (message === "Invalid JSON body") {
|
|
99
|
+
return jsonError(ctx, 400, "Bad request", message);
|
|
100
|
+
}
|
|
101
|
+
return jsonError(ctx, 500, "Internal server error", message);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const runHandler = async (ctx) => {
|
|
105
|
+
const runId = ctx.req.params["runId"];
|
|
106
|
+
if (!runId) {
|
|
107
|
+
return jsonError(ctx, 400, "Bad request", "Missing runId parameter");
|
|
108
|
+
}
|
|
109
|
+
const authError = await checkAuth(ctx, "runs", options, { runId });
|
|
110
|
+
if (authError) return authError;
|
|
111
|
+
try {
|
|
112
|
+
const accessToken = getAccessToken(ctx);
|
|
113
|
+
const run = await stepflow.getRun(runId, { accessToken });
|
|
114
|
+
if (!run) {
|
|
115
|
+
return jsonError(ctx, 404, "Not found", `Run "${runId}" not found`);
|
|
116
|
+
}
|
|
117
|
+
const response = run;
|
|
118
|
+
return jsonResponse(ctx, response);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
const message = error.message;
|
|
121
|
+
if (message === "Invalid access token") {
|
|
122
|
+
return jsonError(ctx, 401, "Unauthorized", message);
|
|
123
|
+
}
|
|
124
|
+
return jsonError(ctx, 500, "Internal server error", message);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
const streamHandler = async (ctx) => {
|
|
128
|
+
const runId = ctx.req.params["runId"];
|
|
129
|
+
if (!runId) {
|
|
130
|
+
return jsonError(ctx, 400, "Bad request", "Missing runId parameter");
|
|
131
|
+
}
|
|
132
|
+
const authError = await checkAuth(ctx, "runsStream", options, { runId });
|
|
133
|
+
if (authError) return authError;
|
|
134
|
+
const accessToken = getAccessToken(ctx);
|
|
135
|
+
if (accessToken) {
|
|
136
|
+
try {
|
|
137
|
+
await stepflow.getRun(runId, { accessToken });
|
|
138
|
+
} catch (error) {
|
|
139
|
+
const message = error.message;
|
|
140
|
+
if (message === "Invalid access token") {
|
|
141
|
+
return jsonError(ctx, 401, "Unauthorized", message);
|
|
142
|
+
}
|
|
143
|
+
return jsonError(ctx, 500, "Internal server error", message);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const run = await stepflow.getRun(runId);
|
|
148
|
+
if (!run) {
|
|
149
|
+
return jsonError(ctx, 404, "Not found", `Run "${runId}" not found`);
|
|
150
|
+
}
|
|
151
|
+
ctx.res.status = 200;
|
|
152
|
+
ctx.res.headers["Content-Type"] = "text/event-stream";
|
|
153
|
+
ctx.res.headers["Cache-Control"] = "no-cache";
|
|
154
|
+
ctx.res.headers["Connection"] = "keep-alive";
|
|
155
|
+
ctx.res.body = `event: update
|
|
156
|
+
data: ${JSON.stringify(run)}
|
|
157
|
+
|
|
158
|
+
`;
|
|
159
|
+
return ctx;
|
|
160
|
+
} catch (error) {
|
|
161
|
+
return jsonError(
|
|
162
|
+
ctx,
|
|
163
|
+
500,
|
|
164
|
+
"Internal server error",
|
|
165
|
+
error.message
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
const notifyHandler = async (ctx) => {
|
|
170
|
+
const eventId = ctx.req.params["eventId"];
|
|
171
|
+
if (!eventId) {
|
|
172
|
+
return jsonError(ctx, 400, "Bad request", "Missing eventId parameter");
|
|
173
|
+
}
|
|
174
|
+
const authError = await checkAuth(ctx, "notify", options, { eventId });
|
|
175
|
+
if (authError) return authError;
|
|
176
|
+
try {
|
|
177
|
+
const body = await parseJsonBody(ctx);
|
|
178
|
+
const result = await stepflow.notify(eventId, body.data);
|
|
179
|
+
const response = result;
|
|
180
|
+
return jsonResponse(ctx, response);
|
|
181
|
+
} catch (error) {
|
|
182
|
+
const message = error.message;
|
|
183
|
+
if (message === "Invalid JSON body") {
|
|
184
|
+
return jsonError(ctx, 400, "Bad request", message);
|
|
185
|
+
}
|
|
186
|
+
return jsonError(ctx, 500, "Internal server error", message);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
const healthHandler = async (ctx) => {
|
|
190
|
+
const authError = await checkAuth(ctx, "health", options);
|
|
191
|
+
if (authError) return authError;
|
|
192
|
+
try {
|
|
193
|
+
const ok = await (options.healthCheck?.() ?? stepflow.healthCheck());
|
|
194
|
+
return jsonResponse(ctx, { ok });
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return jsonError(
|
|
197
|
+
ctx,
|
|
198
|
+
500,
|
|
199
|
+
"Internal server error",
|
|
200
|
+
error.message
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
return {
|
|
205
|
+
triggerHandler,
|
|
206
|
+
runHandler,
|
|
207
|
+
streamHandler,
|
|
208
|
+
notifyHandler,
|
|
209
|
+
healthHandler
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function createStepflowRouter(stepflow, options = {}) {
|
|
213
|
+
const handlers = createStepflowHandlers(stepflow, options);
|
|
214
|
+
const basePath = options.basePath?.replace(/\/$/, "") || "";
|
|
215
|
+
return async (ctx) => {
|
|
216
|
+
const path = basePath ? ctx.req.path.slice(basePath.length) : ctx.req.path;
|
|
217
|
+
const method = ctx.req.method.toUpperCase();
|
|
218
|
+
if (isRouteEnabled("health", options.endpoints)) {
|
|
219
|
+
if (path === "/health" && method === "GET") {
|
|
220
|
+
return handlers.healthHandler(ctx);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (isRouteEnabled("trigger", options.endpoints)) {
|
|
224
|
+
const triggerMatch = path.match(/^\/trigger\/([^/]+)$/);
|
|
225
|
+
if (triggerMatch && method === "POST") {
|
|
226
|
+
ctx.req.params["workflowId"] = triggerMatch[1];
|
|
227
|
+
return handlers.triggerHandler(ctx);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (isRouteEnabled("runsStream", options.endpoints)) {
|
|
231
|
+
const streamMatch = path.match(/^\/runs\/([^/]+)\/stream$/);
|
|
232
|
+
if (streamMatch && method === "GET") {
|
|
233
|
+
ctx.req.params["runId"] = streamMatch[1];
|
|
234
|
+
return handlers.streamHandler(ctx);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (isRouteEnabled("runs", options.endpoints)) {
|
|
238
|
+
const runMatch = path.match(/^\/runs\/([^/]+)$/);
|
|
239
|
+
if (runMatch && method === "GET") {
|
|
240
|
+
ctx.req.params["runId"] = runMatch[1];
|
|
241
|
+
return handlers.runHandler(ctx);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (isRouteEnabled("notify", options.endpoints)) {
|
|
245
|
+
const notifyMatch = path.match(/^\/notify\/([^/]+)$/);
|
|
246
|
+
if (notifyMatch && method === "POST") {
|
|
247
|
+
ctx.req.params["eventId"] = notifyMatch[1];
|
|
248
|
+
return handlers.notifyHandler(ctx);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (isRouteEnabled("workflowsTrigger", options.endpoints)) {
|
|
252
|
+
const workflowTriggerMatch = path.match(
|
|
253
|
+
/^\/workflows\/([^/]+)\/trigger$/
|
|
254
|
+
);
|
|
255
|
+
if (workflowTriggerMatch && method === "POST") {
|
|
256
|
+
ctx.req.params["workflowId"] = workflowTriggerMatch[1];
|
|
257
|
+
return handlers.triggerHandler(ctx);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (isRouteEnabled("eventsNotify", options.endpoints)) {
|
|
261
|
+
const eventNotifyMatch = path.match(/^\/events\/([^/]+)\/notify$/);
|
|
262
|
+
if (eventNotifyMatch && method === "POST") {
|
|
263
|
+
ctx.req.params["eventId"] = eventNotifyMatch[1];
|
|
264
|
+
return handlers.notifyHandler(ctx);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return jsonError(ctx, 404, "Not found");
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
export {
|
|
271
|
+
allOf,
|
|
272
|
+
anyOf,
|
|
273
|
+
createApiKeyAuth,
|
|
274
|
+
createBearerAuth,
|
|
275
|
+
createStepflowHandlers,
|
|
276
|
+
createStepflowRouter,
|
|
277
|
+
isRouteEnabled2 as isRouteEnabled,
|
|
278
|
+
resolveEndpoints
|
|
279
|
+
};
|
|
280
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { Execution, TriggerResult, NotifyResult } from \"@stepflowjs/core\";\nimport type { Stepflow } from \"@stepflowjs/core\";\nimport {\n type AuthConfig,\n type AuthContext,\n type BaseAdapterOptions,\n type EndpointOption,\n type RouteName,\n isRouteEnabled,\n runAuth,\n getAuthFailureResponse,\n createErrorBody,\n} from \"@stepflowjs/adapter-shared\";\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/** Nitric-specific request type for auth handlers */\nexport type NitricRequest = {\n header(name: string): string | undefined;\n headers: Record<string, string>;\n url: string;\n method: string;\n query: Record<string, string>;\n};\n\n/** Nitric-specific auth context */\nexport type NitricAuthContext = AuthContext<NitricRequest, NitricHttpContext>;\n\n/** Nitric-specific auth config */\nexport type NitricAuthConfig = AuthConfig<NitricRequest, NitricHttpContext>;\n\nexport interface HandlerOptions {\n /** Base path prefix for all routes (e.g., \"/api/stepflow\"). */\n basePath?: string;\n /** Custom health check function. Defaults to stepflow.healthCheck(). */\n healthCheck?: () => Promise<boolean>;\n /** Endpoint configuration - preset or fine-grained */\n endpoints?: EndpointOption;\n /** Authorization configuration */\n auth?: NitricAuthConfig;\n /** Callback when authorization fails */\n onAuthFailure?: BaseAdapterOptions<\n NitricRequest,\n NitricHttpContext\n >[\"onAuthFailure\"];\n}\n\nexport interface TriggerRequestBody<TPayload = unknown> {\n payload: TPayload;\n metadata?: Record<string, unknown>;\n runId?: string;\n delay?: number;\n idempotencyKey?: string;\n}\n\nexport interface NotifyRequestBody {\n data: unknown;\n}\n\nexport interface ErrorResponseBody {\n error: string;\n message?: string;\n}\n\n/**\n * Nitric HTTP context (simplified version for adapter compatibility)\n */\nexport interface NitricHttpContext {\n req: {\n method: string;\n path: string;\n params: Record<string, string>;\n query: Record<string, string>;\n headers: Record<string, string>;\n json: () => Promise<unknown>;\n text: () => Promise<string>;\n };\n res: {\n status: number;\n headers: Record<string, string>;\n body: string | Uint8Array;\n };\n}\n\nexport type NitricHandler = (\n ctx: NitricHttpContext,\n) => Promise<NitricHttpContext>;\n\nexport interface StepflowHandlers {\n /** Handler for POST /trigger/:workflowId */\n triggerHandler: NitricHandler;\n /** Handler for GET /runs/:runId */\n runHandler: NitricHandler;\n /** Handler for GET /runs/:runId/stream */\n streamHandler: NitricHandler;\n /** Handler for POST /notify/:eventId */\n notifyHandler: NitricHandler;\n /** Handler for GET /health */\n healthHandler: NitricHandler;\n}\n\n// ============================================================================\n// Re-exports from shared\n// ============================================================================\n\nexport {\n type AuthContext,\n type AuthResult,\n type AuthHandler,\n type AuthConfig,\n type EndpointConfig,\n type EndpointOption,\n type EndpointPreset,\n type RouteName,\n createApiKeyAuth,\n createBearerAuth,\n anyOf,\n allOf,\n isRouteEnabled,\n resolveEndpoints,\n} from \"@stepflowjs/adapter-shared\";\n\n// ============================================================================\n// Helpers\n// ============================================================================\n\nfunction getAccessToken(ctx: NitricHttpContext): string | undefined {\n const queryToken = ctx.req.query[\"token\"];\n if (queryToken) return queryToken;\n\n const authHeader =\n ctx.req.headers[\"authorization\"] || ctx.req.headers[\"Authorization\"];\n if (!authHeader) return undefined;\n\n const match = authHeader.match(/^Bearer\\s+(.+)$/i);\n return match?.[1];\n}\n\nfunction jsonResponse<T>(\n ctx: NitricHttpContext,\n data: T,\n status = 200,\n): NitricHttpContext {\n ctx.res.status = status;\n ctx.res.headers[\"Content-Type\"] = \"application/json\";\n ctx.res.body = JSON.stringify(data);\n return ctx;\n}\n\nfunction jsonError(\n ctx: NitricHttpContext,\n status: number,\n error: string,\n message?: string,\n): NitricHttpContext {\n const body: ErrorResponseBody = message ? { error, message } : { error };\n ctx.res.status = status;\n ctx.res.headers[\"Content-Type\"] = \"application/json\";\n ctx.res.body = JSON.stringify(body);\n return ctx;\n}\n\nfunction jsonAuthError(\n ctx: NitricHttpContext,\n status: number,\n code: string,\n message: string,\n): NitricHttpContext {\n const body = createErrorBody(code, message);\n ctx.res.status = status;\n ctx.res.headers[\"Content-Type\"] = \"application/json\";\n ctx.res.body = JSON.stringify(body);\n return ctx;\n}\n\nasync function parseJsonBody<T>(ctx: NitricHttpContext): Promise<T> {\n try {\n return (await ctx.req.json()) as T;\n } catch {\n throw new Error(\"Invalid JSON body\");\n }\n}\n\n/**\n * Creates a NitricRequest object from Nitric context for auth handlers\n */\nfunction createNitricRequest(ctx: NitricHttpContext): NitricRequest {\n return {\n header: (name: string) =>\n ctx.req.headers[name] || ctx.req.headers[name.toLowerCase()],\n headers: ctx.req.headers,\n url: ctx.req.path,\n method: ctx.req.method,\n query: ctx.req.query,\n };\n}\n\n/**\n * Runs authorization check and returns error response if denied\n */\nasync function checkAuth(\n ctx: NitricHttpContext,\n route: RouteName,\n options: HandlerOptions,\n params: { workflowId?: string; eventId?: string; runId?: string } = {},\n): Promise<NitricHttpContext | null> {\n const authCtx: NitricAuthContext = {\n route,\n request: createNitricRequest(ctx),\n extra: ctx,\n ...params,\n };\n\n const result = await runAuth(authCtx, options.auth);\n\n if (!result.ok) {\n const { status, code, message } = getAuthFailureResponse(result);\n await options.onAuthFailure?.(authCtx, result);\n return jsonAuthError(ctx, status, code, message);\n }\n\n return null;\n}\n\n// ============================================================================\n// Handler Factory\n// ============================================================================\n\n/**\n * Create Nitric HTTP handlers for Stepflow\n *\n * @example\n * ```typescript\n * import { api } from '@nitric/sdk';\n * import { Stepflow } from '@stepflowjs/core';\n * import { createStepflowHandlers } from '@stepflowjs/adapter-nitric';\n *\n * const stepflow = new Stepflow({ storage: ... });\n * const { triggerHandler, runHandler, healthHandler } = createStepflowHandlers(stepflow);\n *\n * const mainApi = api('main');\n *\n * mainApi.post('/stepflow/trigger/:workflowId', triggerHandler);\n * mainApi.get('/stepflow/runs/:runId', runHandler);\n * mainApi.get('/stepflow/health', healthHandler);\n * ```\n */\nexport function createStepflowHandlers(\n stepflow: Stepflow,\n options: HandlerOptions = {},\n): StepflowHandlers {\n // -------------------------------------------------------------------------\n // Trigger Handler - POST /trigger/:workflowId\n // -------------------------------------------------------------------------\n const triggerHandler: NitricHandler = async (ctx) => {\n const workflowId = ctx.req.params[\"workflowId\"];\n\n if (!workflowId) {\n return jsonError(ctx, 400, \"Bad request\", \"Missing workflowId parameter\");\n }\n\n const authError = await checkAuth(ctx, \"trigger\", options, { workflowId });\n if (authError) return authError;\n\n try {\n const body = await parseJsonBody<TriggerRequestBody>(ctx);\n const result = await stepflow.trigger(workflowId, body.payload, {\n runId: body.runId,\n metadata: body.metadata,\n delay: body.delay,\n idempotencyKey: body.idempotencyKey,\n });\n\n const response: TriggerResult = result;\n return jsonResponse(ctx, response);\n } catch (error) {\n const message = (error as Error).message;\n if (message.includes(\"Workflow\") && message.includes(\"not found\")) {\n return jsonError(ctx, 404, \"Not found\", message);\n }\n if (message === \"Invalid JSON body\") {\n return jsonError(ctx, 400, \"Bad request\", message);\n }\n return jsonError(ctx, 500, \"Internal server error\", message);\n }\n };\n\n // -------------------------------------------------------------------------\n // Run Handler - GET /runs/:runId\n // -------------------------------------------------------------------------\n const runHandler: NitricHandler = async (ctx) => {\n const runId = ctx.req.params[\"runId\"];\n\n if (!runId) {\n return jsonError(ctx, 400, \"Bad request\", \"Missing runId parameter\");\n }\n\n const authError = await checkAuth(ctx, \"runs\", options, { runId });\n if (authError) return authError;\n\n try {\n const accessToken = getAccessToken(ctx);\n const run = await stepflow.getRun(runId, { accessToken });\n\n if (!run) {\n return jsonError(ctx, 404, \"Not found\", `Run \"${runId}\" not found`);\n }\n\n const response: Execution = run;\n return jsonResponse(ctx, response);\n } catch (error) {\n const message = (error as Error).message;\n if (message === \"Invalid access token\") {\n return jsonError(ctx, 401, \"Unauthorized\", message);\n }\n return jsonError(ctx, 500, \"Internal server error\", message);\n }\n };\n\n // -------------------------------------------------------------------------\n // Stream Handler - GET /runs/:runId/stream\n // -------------------------------------------------------------------------\n const streamHandler: NitricHandler = async (ctx) => {\n const runId = ctx.req.params[\"runId\"];\n\n if (!runId) {\n return jsonError(ctx, 400, \"Bad request\", \"Missing runId parameter\");\n }\n\n const authError = await checkAuth(ctx, \"runsStream\", options, { runId });\n if (authError) return authError;\n\n // Validate access token if provided\n const accessToken = getAccessToken(ctx);\n if (accessToken) {\n try {\n await stepflow.getRun(runId, { accessToken });\n } catch (error) {\n const message = (error as Error).message;\n if (message === \"Invalid access token\") {\n return jsonError(ctx, 401, \"Unauthorized\", message);\n }\n return jsonError(ctx, 500, \"Internal server error\", message);\n }\n }\n\n // For Nitric, SSE streaming is not directly supported in the same way\n // Instead, we return the current state as JSON\n // Real-time updates should be implemented using Nitric's websocket or pub/sub features\n try {\n const run = await stepflow.getRun(runId);\n\n if (!run) {\n return jsonError(ctx, 404, \"Not found\", `Run \"${runId}\" not found`);\n }\n\n // Return SSE-style headers but with current state as JSON\n // Note: True SSE streaming requires different Nitric patterns (websockets/pub-sub)\n ctx.res.status = 200;\n ctx.res.headers[\"Content-Type\"] = \"text/event-stream\";\n ctx.res.headers[\"Cache-Control\"] = \"no-cache\";\n ctx.res.headers[\"Connection\"] = \"keep-alive\";\n ctx.res.body = `event: update\\ndata: ${JSON.stringify(run)}\\n\\n`;\n\n return ctx;\n } catch (error) {\n return jsonError(\n ctx,\n 500,\n \"Internal server error\",\n (error as Error).message,\n );\n }\n };\n\n // -------------------------------------------------------------------------\n // Notify Handler - POST /notify/:eventId\n // -------------------------------------------------------------------------\n const notifyHandler: NitricHandler = async (ctx) => {\n const eventId = ctx.req.params[\"eventId\"];\n\n if (!eventId) {\n return jsonError(ctx, 400, \"Bad request\", \"Missing eventId parameter\");\n }\n\n const authError = await checkAuth(ctx, \"notify\", options, { eventId });\n if (authError) return authError;\n\n try {\n const body = await parseJsonBody<NotifyRequestBody>(ctx);\n const result = await stepflow.notify(eventId, body.data);\n const response: NotifyResult = result;\n return jsonResponse(ctx, response);\n } catch (error) {\n const message = (error as Error).message;\n if (message === \"Invalid JSON body\") {\n return jsonError(ctx, 400, \"Bad request\", message);\n }\n return jsonError(ctx, 500, \"Internal server error\", message);\n }\n };\n\n // -------------------------------------------------------------------------\n // Health Handler - GET /health\n // -------------------------------------------------------------------------\n const healthHandler: NitricHandler = async (ctx) => {\n const authError = await checkAuth(ctx, \"health\", options);\n if (authError) return authError;\n\n try {\n const ok = await (options.healthCheck?.() ?? stepflow.healthCheck());\n return jsonResponse(ctx, { ok });\n } catch (error) {\n return jsonError(\n ctx,\n 500,\n \"Internal server error\",\n (error as Error).message,\n );\n }\n };\n\n return {\n triggerHandler,\n runHandler,\n streamHandler,\n notifyHandler,\n healthHandler,\n };\n}\n\n/**\n * Create a combined Nitric handler that routes to the appropriate handler\n * based on the request path and method.\n *\n * @example\n * ```typescript\n * import { api } from '@nitric/sdk';\n * import { Stepflow } from '@stepflowjs/core';\n * import { createStepflowRouter } from '@stepflowjs/adapter-nitric';\n *\n * const stepflow = new Stepflow({ storage: ... });\n * const router = createStepflowRouter(stepflow, { basePath: '/stepflow' });\n *\n * const mainApi = api('main');\n * mainApi.all('/stepflow/*', router);\n * ```\n */\nexport function createStepflowRouter(\n stepflow: Stepflow,\n options: HandlerOptions = {},\n): NitricHandler {\n const handlers = createStepflowHandlers(stepflow, options);\n const basePath = options.basePath?.replace(/\\/$/, \"\") || \"\";\n\n return async (ctx) => {\n const path = basePath ? ctx.req.path.slice(basePath.length) : ctx.req.path;\n const method = ctx.req.method.toUpperCase();\n\n // Health check\n if (isRouteEnabled(\"health\", options.endpoints)) {\n if (path === \"/health\" && method === \"GET\") {\n return handlers.healthHandler(ctx);\n }\n }\n\n // Trigger workflow\n if (isRouteEnabled(\"trigger\", options.endpoints)) {\n const triggerMatch = path.match(/^\\/trigger\\/([^/]+)$/);\n if (triggerMatch && method === \"POST\") {\n ctx.req.params[\"workflowId\"] = triggerMatch[1];\n return handlers.triggerHandler(ctx);\n }\n }\n\n // Run stream\n if (isRouteEnabled(\"runsStream\", options.endpoints)) {\n const streamMatch = path.match(/^\\/runs\\/([^/]+)\\/stream$/);\n if (streamMatch && method === \"GET\") {\n ctx.req.params[\"runId\"] = streamMatch[1];\n return handlers.streamHandler(ctx);\n }\n }\n\n // Run status\n if (isRouteEnabled(\"runs\", options.endpoints)) {\n const runMatch = path.match(/^\\/runs\\/([^/]+)$/);\n if (runMatch && method === \"GET\") {\n ctx.req.params[\"runId\"] = runMatch[1];\n return handlers.runHandler(ctx);\n }\n }\n\n // Notify event\n if (isRouteEnabled(\"notify\", options.endpoints)) {\n const notifyMatch = path.match(/^\\/notify\\/([^/]+)$/);\n if (notifyMatch && method === \"POST\") {\n ctx.req.params[\"eventId\"] = notifyMatch[1];\n return handlers.notifyHandler(ctx);\n }\n }\n\n // Client SDK compatibility routes\n if (isRouteEnabled(\"workflowsTrigger\", options.endpoints)) {\n const workflowTriggerMatch = path.match(\n /^\\/workflows\\/([^/]+)\\/trigger$/,\n );\n if (workflowTriggerMatch && method === \"POST\") {\n ctx.req.params[\"workflowId\"] = workflowTriggerMatch[1];\n return handlers.triggerHandler(ctx);\n }\n }\n\n if (isRouteEnabled(\"eventsNotify\", options.endpoints)) {\n const eventNotifyMatch = path.match(/^\\/events\\/([^/]+)\\/notify$/);\n if (eventNotifyMatch && method === \"POST\") {\n ctx.req.params[\"eventId\"] = eventNotifyMatch[1];\n return handlers.notifyHandler(ctx);\n }\n }\n\n // Not found\n return jsonError(ctx, 404, \"Not found\");\n };\n}\n\n// Re-export types\nexport type { Execution, TriggerResult, NotifyResult } from \"@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0.0.1",
|
|
4
|
+
"description": "Nitric.io adapter for Stepflow workflows",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@stepflowjs/core": "0.0.1",
|
|
20
|
+
"@stepflowjs/adapter-shared": "0.0.1"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@nitric/sdk": "^1.4.2",
|
|
24
|
+
"tsup": "^8.5.1",
|
|
25
|
+
"vitest": "^4.0.17"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@nitric/sdk": "^1.0.0",
|
|
29
|
+
"typescript": "^5.0.0"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"author": "Stepflow Contributors",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://stepflow-production.up.railway.app",
|
|
36
|
+
"directory": "packages/adapters/nitric"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://stepflow-production.up.railway.app",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://stepflow-production.up.railway.app"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"stepflow",
|
|
44
|
+
"adapter",
|
|
45
|
+
"nitric",
|
|
46
|
+
"framework",
|
|
47
|
+
"workflow",
|
|
48
|
+
"orchestration"
|
|
49
|
+
],
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "tsup",
|
|
55
|
+
"dev": "tsup --watch",
|
|
56
|
+
"typecheck": "tsc --noEmit",
|
|
57
|
+
"test": "vitest",
|
|
58
|
+
"clean": "rm -rf dist"
|
|
59
|
+
}
|
|
60
|
+
}
|