@workflow/core 4.2.0-beta.76 → 4.2.0-beta.78
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/flushable-stream.d.ts.map +1 -1
- package/dist/flushable-stream.js +14 -2
- package/dist/private.d.ts.map +1 -1
- package/dist/private.js +7 -4
- package/dist/runtime/helpers.d.ts +4 -0
- package/dist/runtime/helpers.d.ts.map +1 -1
- package/dist/runtime/helpers.js +31 -8
- package/dist/runtime/resume-hook.d.ts.map +1 -1
- package/dist/runtime/resume-hook.js +3 -2
- package/dist/runtime/run.d.ts +11 -1
- package/dist/runtime/run.d.ts.map +1 -1
- package/dist/runtime/run.js +26 -2
- package/dist/runtime/runs.d.ts.map +1 -1
- package/dist/runtime/runs.js +3 -1
- package/dist/runtime/start.d.ts +27 -13
- package/dist/runtime/start.d.ts.map +1 -1
- package/dist/runtime/start.js +91 -27
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +31 -8
- package/dist/schemas.d.ts +1 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/serialization.d.ts +12 -0
- package/dist/serialization.d.ts.map +1 -1
- package/dist/serialization.js +37 -3
- package/dist/step/context-storage.d.ts +3 -2
- package/dist/step/context-storage.d.ts.map +1 -1
- package/dist/step/context-storage.js +21 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/vm/index.d.ts.map +1 -1
- package/dist/vm/index.js +2 -1
- package/docs/foundations/starting-workflows.mdx +1 -1
- package/docs/foundations/streaming.mdx +1 -1
- package/docs/how-it-works/encryption.mdx +39 -2
- package/docs/how-it-works/event-sourcing.mdx +19 -2
- package/docs/how-it-works/framework-integrations.mdx +68 -11
- package/package.json +4 -4
|
@@ -261,6 +261,35 @@ class MyFrameworkBuilder extends BaseBuilder {
|
|
|
261
261
|
|
|
262
262
|
If your framework supports virtual server routes and dev mode watching, make sure to adapt accordingly. Please open a PR to the Workflow SDK if the base builder class is missing necessary functionality.
|
|
263
263
|
|
|
264
|
+
### Monorepos and Workspace Imports
|
|
265
|
+
|
|
266
|
+
If your framework integration lives in a subdirectory and your workflows import code from sibling workspace packages, pass `projectRoot` to `BaseBuilder`. Use the smallest directory that contains every workspace package imported by your workflows.
|
|
267
|
+
|
|
268
|
+
{/* @skip-typecheck: @workflow/cli internal module */}
|
|
269
|
+
```typescript title="my-framework-builder.ts" lineNumbers
|
|
270
|
+
import { BaseBuilder } from "@workflow/cli/dist/lib/builders/base-builder";
|
|
271
|
+
|
|
272
|
+
class MyFrameworkBuilder extends BaseBuilder {
|
|
273
|
+
constructor(options: {
|
|
274
|
+
rootDir: string;
|
|
275
|
+
workspaceRoot?: string;
|
|
276
|
+
dev: boolean;
|
|
277
|
+
}) {
|
|
278
|
+
super({
|
|
279
|
+
dirs: ["workflows"],
|
|
280
|
+
workingDir: options.rootDir,
|
|
281
|
+
projectRoot: options.workspaceRoot ?? options.rootDir, // [!code highlight]
|
|
282
|
+
watch: options.dev,
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
override async build(): Promise<void> {
|
|
287
|
+
const inputFiles = await this.getInputFiles();
|
|
288
|
+
// ...
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
264
293
|
Hook into your framework's build:
|
|
265
294
|
|
|
266
295
|
{/* @skip-typecheck: incomplete code sample */}
|
|
@@ -346,22 +375,50 @@ In the future, the Workflow SDK will emit more routes under the `.well-known/wor
|
|
|
346
375
|
|
|
347
376
|
## Security
|
|
348
377
|
|
|
349
|
-
|
|
378
|
+
The workflow and step handler endpoints are invoked by the world's queuing infrastructure, not by end users. How they're secured depends on which world you're deploying to.
|
|
379
|
+
|
|
380
|
+
### Vercel (`@workflow/world-vercel`)
|
|
381
|
+
|
|
382
|
+
On Vercel, workflow handler functions are not accessible through public endpoints. Handlers use the same [consumer function security](https://vercel.com/docs/queues/concepts#consumer-function-security) mechanism that secures [Vercel Queues](https://vercel.com/docs/queues) consumers.
|
|
383
|
+
|
|
384
|
+
During the build step, the Workflow SDK automatically configures each handler as a queue consumer by writing `experimentalTriggers` to the function's `.vc-config.json`:
|
|
385
|
+
|
|
386
|
+
```json title=".vc-config.json (generated by Workflow SDK)"
|
|
387
|
+
{
|
|
388
|
+
"experimentalTriggers": [
|
|
389
|
+
{
|
|
390
|
+
"type": "queue/v2beta",
|
|
391
|
+
"topic": "__wkf_step_*",
|
|
392
|
+
"consumer": "default",
|
|
393
|
+
"retryAfterSeconds": 5,
|
|
394
|
+
"initialDelaySeconds": 0
|
|
395
|
+
}
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
Two queue topics are created per deployment:
|
|
350
402
|
|
|
351
|
-
|
|
403
|
+
| Handler | Topic | Description |
|
|
404
|
+
| --- | --- | --- |
|
|
405
|
+
| `step.func` | `__wkf_step_*` | Step execution (long-running, `maxDuration: max`) |
|
|
406
|
+
| `flow.func` | `__wkf_workflow_*` | Workflow orchestration (`maxDuration: 60`) |
|
|
407
|
+
|
|
408
|
+
If you're building a framework integration that targets Vercel, you should write these triggers into the `.vc-config.json` for each generated function. The `STEP_QUEUE_TRIGGER` and `WORKFLOW_QUEUE_TRIGGER` constants are exported from `@workflow/builders` for this purpose:
|
|
409
|
+
|
|
410
|
+
```typescript
|
|
411
|
+
import { STEP_QUEUE_TRIGGER, WORKFLOW_QUEUE_TRIGGER } from "@workflow/builders";
|
|
412
|
+
```
|
|
352
413
|
|
|
353
|
-
**Vercel (`@workflow/world-vercel`):**
|
|
354
414
|
|
|
355
|
-
|
|
356
|
-
- Handlers receive only a message ID that must be retrieved from Vercel's backend
|
|
357
|
-
- Impossible to craft custom payloads without valid queue-issued message IDs
|
|
415
|
+
### Custom implementations
|
|
358
416
|
|
|
359
|
-
|
|
417
|
+
For self-hosted or non-Vercel deployments, you are responsible for securing the handler endpoints:
|
|
360
418
|
|
|
361
|
-
-
|
|
362
|
-
-
|
|
363
|
-
-
|
|
364
|
-
- Rate limiting and request validation
|
|
419
|
+
- **Framework middleware** — Add authentication (API keys, JWT, OIDC) in front of the `/.well-known/workflow/v1/*` routes
|
|
420
|
+
- **Network-level security** — Deploy handlers behind a VPC, private network, or firewall rules so only your queue infrastructure can reach them
|
|
421
|
+
- **Rate limiting** — Add request validation and rate limiting to prevent abuse
|
|
365
422
|
|
|
366
423
|
Learn more about [building custom Worlds](/docs/deploying/building-a-world).
|
|
367
424
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/core",
|
|
3
|
-
"version": "4.2.0-beta.
|
|
3
|
+
"version": "4.2.0-beta.78",
|
|
4
4
|
"description": "Core runtime and engine for Workflow SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
"@workflow/errors": "4.1.0-beta.20",
|
|
84
84
|
"@workflow/serde": "4.1.0-beta.2",
|
|
85
85
|
"@workflow/utils": "4.1.0-beta.13",
|
|
86
|
-
"@workflow/world": "4.1.0-beta.
|
|
87
|
-
"@workflow/world-local": "4.1.0-beta.
|
|
88
|
-
"@workflow/world-vercel": "4.1.0-beta.
|
|
86
|
+
"@workflow/world": "4.1.0-beta.17",
|
|
87
|
+
"@workflow/world-local": "4.1.0-beta.51",
|
|
88
|
+
"@workflow/world-vercel": "4.1.0-beta.49"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@opentelemetry/api": "1.9.0",
|