@workflow/nest 0.0.0-beta.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/LICENSE.md ADDED
@@ -0,0 +1 @@
1
+ Apache-2.0
package/README.md ADDED
@@ -0,0 +1,185 @@
1
+ # @workflow/nest
2
+
3
+ NestJS integration for Workflow DevKit.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @workflow/nest
9
+ # or
10
+ pnpm add @workflow/nest
11
+ ```
12
+
13
+ You also need to install the SWC packages required by NestJS's SWC builder:
14
+
15
+ ```bash
16
+ npm install -D @swc/cli @swc/core
17
+ # or
18
+ pnpm add -D @swc/cli @swc/core
19
+ ```
20
+
21
+ ## Quick Start
22
+
23
+ ### 1. Initialize SWC Configuration
24
+
25
+ After installing the package, run the init command to generate the SWC configuration:
26
+
27
+ ```bash
28
+ npx @workflow/nest init
29
+ ```
30
+
31
+ This creates a `.swcrc` file configured with the Workflow SWC plugin for client-mode transformations.
32
+
33
+ **Important:** Add `.swcrc` to your `.gitignore` as it contains machine-specific absolute paths:
34
+
35
+ ```bash
36
+ echo '/.swcrc' >> .gitignore
37
+ ```
38
+
39
+ ### 2. Configure NestJS to use SWC
40
+
41
+ Ensure your `nest-cli.json` has SWC as the builder:
42
+
43
+ {/*@skip-typecheck: Shows nest-cli.json configuration*/}
44
+
45
+ ```json
46
+ {
47
+ "compilerOptions": {
48
+ "builder": "swc"
49
+ }
50
+ }
51
+ ```
52
+
53
+ ### 3. Import the WorkflowModule
54
+
55
+ In your `app.module.ts`:
56
+
57
+ {/*@skip-typecheck: Shows WorkflowModule import*/}
58
+
59
+ ```typescript
60
+ import { Module } from '@nestjs/common';
61
+ import { WorkflowModule } from '@workflow/nest';
62
+
63
+ @Module({
64
+ imports: [WorkflowModule.forRoot()],
65
+ })
66
+ export class AppModule {}
67
+ ```
68
+
69
+ ### 4. Create Workflow Files
70
+
71
+ Create workflow files in your `src/` directory with `"use workflow"` and `"use step"` directives:
72
+
73
+ {/*@skip-typecheck: Shows workflow file*/}
74
+
75
+ ```typescript
76
+ // src/workflows/example.ts
77
+ export async function myStep(data: string) {
78
+ 'use step';
79
+ return data.toUpperCase();
80
+ }
81
+
82
+ export async function myWorkflow(input: string) {
83
+ 'use workflow';
84
+ const result = await myStep(input);
85
+ return result;
86
+ }
87
+ ```
88
+
89
+ ### 5. Add Pre-build Scripts
90
+
91
+ Add scripts to regenerate configuration before builds:
92
+
93
+ ```json
94
+ {
95
+ "scripts": {
96
+ "prebuild": "npx @workflow/nest init --force",
97
+ "build": "nest build"
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## Configuration Options
103
+
104
+ {/*@skip-typecheck: Shows WorkflowModule.forRoot options*/}
105
+
106
+ ```typescript
107
+ WorkflowModule.forRoot({
108
+ // Directory to scan for workflow files (default: ['src'])
109
+ dirs: ['src'],
110
+
111
+ // Output directory for generated bundles (default: '.nestjs/workflow')
112
+ outDir: '.nestjs/workflow',
113
+
114
+ // Skip building in production when bundles are pre-built
115
+ skipBuild: false,
116
+ });
117
+ ```
118
+
119
+ ## How It Works
120
+
121
+ The `@workflow/nest` package provides:
122
+
123
+ 1. **WorkflowModule** - A NestJS module that handles workflow bundle building and HTTP routing
124
+ 2. **WorkflowController** - Handles workflow and step execution requests at `.well-known/workflow/v1/`
125
+ 3. **NestLocalBuilder** - Builds workflow bundles (steps.mjs, workflows.mjs) from your source files
126
+ 4. **CLI** - Generates `.swcrc` configuration with the SWC plugin properly resolved
127
+
128
+ ## Why the CLI?
129
+
130
+ NestJS uses its own SWC builder that reads configuration from `.swcrc`. The Workflow SWC plugin needs to be referenced by path in this file. The CLI resolves the plugin path from `@workflow/nest`'s dependencies, eliminating the need for manual configuration or pnpm hoisting.
131
+
132
+ ### Technical Details
133
+
134
+ When you run `npx @workflow/nest init`, it:
135
+
136
+ 1. Resolves the path to `@workflow/swc-plugin` (bundled as a dependency of `@workflow/nest`)
137
+ 2. Generates `.swcrc` with the absolute path to the plugin
138
+ 3. Configures client-mode transformation for workflow files
139
+
140
+ This approach ensures:
141
+
142
+ - No manual SWC plugin configuration required
143
+ - No pnpm hoisting configuration required in `.npmrc`
144
+ - The plugin is always resolved from the correct location
145
+
146
+ ### Why Workflows Must Be in `src/`
147
+
148
+ NestJS's SWC builder only compiles files within the `sourceRoot` directory (typically `src/`). For the workflow client-mode transform to work, workflow files must be in `src/` so they get compiled with the SWC plugin that attaches `workflowId` properties needed by `start()`.
149
+
150
+ ## API Reference
151
+
152
+ ### WorkflowModule
153
+
154
+ {/*@skip-typecheck: Shows WorkflowModule usage*/}
155
+
156
+ ```typescript
157
+ import { WorkflowModule } from '@workflow/nest';
158
+
159
+ // Basic usage
160
+ WorkflowModule.forRoot()
161
+
162
+ // With options
163
+ WorkflowModule.forRoot({
164
+ dirs: ['src/workflows'],
165
+ outDir: '.nestjs/workflow',
166
+ skipBuild: process.env.NODE_ENV === 'production',
167
+ })
168
+ ```
169
+
170
+ ### CLI Commands
171
+
172
+ ```bash
173
+ # Generate .swcrc configuration
174
+ npx @workflow/nest init
175
+
176
+ # Force regenerate (overwrites existing)
177
+ npx @workflow/nest init --force
178
+
179
+ # Show help
180
+ npx @workflow/nest --help
181
+ ```
182
+
183
+ ## License
184
+
185
+ Apache-2.0
@@ -0,0 +1,30 @@
1
+ import { BaseBuilder } from '@workflow/builders';
2
+ export interface NestBuilderOptions {
3
+ /**
4
+ * Working directory for the NestJS application
5
+ * @default process.cwd()
6
+ */
7
+ workingDir?: string;
8
+ /**
9
+ * Directories to scan for workflow files
10
+ * @default ['src']
11
+ */
12
+ dirs?: string[];
13
+ /**
14
+ * Output directory for generated workflow bundles
15
+ * @default '.nestjs/workflow'
16
+ */
17
+ outDir?: string;
18
+ /**
19
+ * Enable watch mode for development
20
+ * @default false
21
+ */
22
+ watch?: boolean;
23
+ }
24
+ export declare class NestLocalBuilder extends BaseBuilder {
25
+ #private;
26
+ constructor(options?: NestBuilderOptions);
27
+ get outDir(): string;
28
+ build(): Promise<void>;
29
+ }
30
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAA2B,MAAM,oBAAoB,CAAC;AAG1E,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,gBAAiB,SAAQ,WAAW;;gBAGnC,OAAO,GAAE,kBAAuB;IAkB5C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAEc,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAmCtC"}
@@ -0,0 +1,57 @@
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { BaseBuilder, createBaseBuilderConfig } from '@workflow/builders';
3
+ import { join } from 'pathe';
4
+ export class NestLocalBuilder extends BaseBuilder {
5
+ #outDir;
6
+ constructor(options = {}) {
7
+ const workingDir = options.workingDir ?? process.cwd();
8
+ const outDir = options.outDir ?? join(workingDir, '.nestjs/workflow');
9
+ super({
10
+ ...createBaseBuilderConfig({
11
+ workingDir,
12
+ watch: options.watch ?? false,
13
+ dirs: options.dirs ?? ['src'],
14
+ }),
15
+ // Use 'standalone' as base target - we handle the specific bundling ourselves
16
+ buildTarget: 'standalone',
17
+ stepsBundlePath: join(outDir, 'steps.mjs'),
18
+ workflowsBundlePath: join(outDir, 'workflows.mjs'),
19
+ webhookBundlePath: join(outDir, 'webhook.mjs'),
20
+ });
21
+ this.#outDir = outDir;
22
+ }
23
+ get outDir() {
24
+ return this.#outDir;
25
+ }
26
+ async build() {
27
+ const inputFiles = await this.getInputFiles();
28
+ await mkdir(this.#outDir, { recursive: true });
29
+ await this.createWorkflowsBundle({
30
+ outfile: join(this.#outDir, 'workflows.mjs'),
31
+ bundleFinalOutput: false,
32
+ format: 'esm',
33
+ inputFiles,
34
+ });
35
+ const { manifest } = await this.createStepsBundle({
36
+ outfile: join(this.#outDir, 'steps.mjs'),
37
+ externalizeNonSteps: true,
38
+ format: 'esm',
39
+ inputFiles,
40
+ });
41
+ await this.createWebhookBundle({
42
+ outfile: join(this.#outDir, 'webhook.mjs'),
43
+ bundle: false,
44
+ });
45
+ // Generate manifest
46
+ await this.createManifest({
47
+ workflowBundlePath: join(this.#outDir, 'workflows.mjs'),
48
+ manifestDir: this.#outDir,
49
+ manifest,
50
+ });
51
+ // Create .gitignore to exclude generated files
52
+ if (!process.env.VERCEL_DEPLOYMENT_ID) {
53
+ await writeFile(join(this.#outDir, '.gitignore'), '*\n');
54
+ }
55
+ }
56
+ }
57
+ //# sourceMappingURL=builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAyB7B,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,OAAO,CAAS;IAEhB,YAAY,UAA8B,EAAE;QAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QACtE,KAAK,CAAC;YACJ,GAAG,uBAAuB,CAAC;gBACzB,UAAU;gBACV,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;gBAC7B,IAAI,EAAE,OAAO,CAAC,IAAI,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AAW,EAAE,IAAI,CAAC,OAAO;YACzB,QAAQ;SACT,CAAC,CAAC;QAEH,+CAA+C;QAC/C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;YACtC,MAAM,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF"}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
package/dist/cli.js ADDED
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+ import { dirname, resolve } from 'node:path';
5
+ import { fileURLToPath } from 'node:url';
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const require = createRequire(import.meta.url);
8
+ /**
9
+ * Resolve the path to the SWC workflow plugin.
10
+ * This works because @workflow/nest has @workflow/swc-plugin as a dependency.
11
+ */
12
+ function resolveSwcPluginPath() {
13
+ return require.resolve('@workflow/swc-plugin', {
14
+ paths: [__dirname],
15
+ });
16
+ }
17
+ /**
18
+ * Generate .swcrc configuration for NestJS with the workflow plugin.
19
+ */
20
+ function generateSwcrc(pluginPath) {
21
+ return {
22
+ $schema: 'https://swc.rs/schema.json',
23
+ jsc: {
24
+ parser: {
25
+ syntax: 'typescript',
26
+ decorators: true,
27
+ },
28
+ transform: {
29
+ legacyDecorator: true,
30
+ decoratorMetadata: true,
31
+ },
32
+ experimental: {
33
+ plugins: [[pluginPath, { mode: 'client' }]],
34
+ },
35
+ },
36
+ module: {
37
+ type: 'es6',
38
+ },
39
+ sourceMaps: true,
40
+ };
41
+ }
42
+ function showHelp() {
43
+ console.log(`
44
+ @workflow/nest CLI
45
+
46
+ Commands:
47
+ init Generate .swcrc configuration with the workflow plugin
48
+ help Show this help message
49
+
50
+ Usage:
51
+ npx @workflow/nest init
52
+
53
+ This command generates a .swcrc file configured with the Workflow SWC plugin
54
+ for client-mode transformations. The plugin path is resolved from the
55
+ @workflow/nest package, so no additional hoisting configuration is needed.
56
+ `);
57
+ }
58
+ function hasWorkflowPlugin(swcrcContent) {
59
+ try {
60
+ const parsed = JSON.parse(swcrcContent);
61
+ const plugins = parsed?.jsc?.experimental?.plugins;
62
+ return (Array.isArray(plugins) &&
63
+ plugins.some((p) => Array.isArray(p) &&
64
+ typeof p[0] === 'string' &&
65
+ p[0].includes('workflow')));
66
+ }
67
+ catch {
68
+ return false;
69
+ }
70
+ }
71
+ function handleInit(args) {
72
+ const swcrcPath = resolve(process.cwd(), '.swcrc');
73
+ const forceMode = args.includes('--force');
74
+ if (existsSync(swcrcPath)) {
75
+ const existing = readFileSync(swcrcPath, 'utf-8');
76
+ if (hasWorkflowPlugin(existing)) {
77
+ console.log('✓ .swcrc already configured with workflow plugin');
78
+ if (!forceMode) {
79
+ console.log(' Run with --force to regenerate');
80
+ process.exit(0);
81
+ }
82
+ }
83
+ else if (!forceMode) {
84
+ console.log('⚠ .swcrc already exists. Run with --force to overwrite.');
85
+ process.exit(1);
86
+ }
87
+ }
88
+ const pluginPath = resolveSwcPluginPath();
89
+ const swcrc = generateSwcrc(pluginPath);
90
+ writeFileSync(swcrcPath, `${JSON.stringify(swcrc, null, 2)}\n`);
91
+ console.log('✓ Created .swcrc with workflow plugin configuration');
92
+ console.log(` Plugin path: ${pluginPath}`);
93
+ console.log('\nNext steps:');
94
+ console.log('1. Ensure nest-cli.json has: "compilerOptions": { "builder": "swc" }');
95
+ console.log('2. Add .swcrc to .gitignore (it contains absolute paths)');
96
+ console.log('3. Run: nest build');
97
+ }
98
+ /**
99
+ * Main CLI entry point.
100
+ */
101
+ function main() {
102
+ const args = process.argv.slice(2);
103
+ const command = args[0];
104
+ if (!command ||
105
+ command === 'help' ||
106
+ command === '--help' ||
107
+ command === '-h') {
108
+ showHelp();
109
+ process.exit(0);
110
+ }
111
+ if (command === 'init') {
112
+ handleInit(args);
113
+ process.exit(0);
114
+ }
115
+ console.error(`Unknown command: ${command}`);
116
+ console.error('Run with --help for usage information.');
117
+ process.exit(1);
118
+ }
119
+ main();
120
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC1D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;GAGG;AACH,SAAS,oBAAoB;IAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,sBAAsB,EAAE;QAC7C,KAAK,EAAE,CAAC,SAAS,CAAC;KACnB,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,aAAa,CAAC,UAAkB;IACvC,OAAO;QACL,OAAO,EAAE,4BAA4B;QACrC,GAAG,EAAE;YACH,MAAM,EAAE;gBACN,MAAM,EAAE,YAAY;gBACpB,UAAU,EAAE,IAAI;aACjB;YACD,SAAS,EAAE;gBACT,eAAe,EAAE,IAAI;gBACrB,iBAAiB,EAAE,IAAI;aACxB;YACD,YAAY,EAAE;gBACZ,OAAO,EAAE,CAAC,CAAC,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,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AC,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,oBAAoB,OAAO,EAAE,CAAC,CAAC;IAC7C,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;IACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { type NestBuilderOptions, NestLocalBuilder } from './builder.js';
2
+ export { configureWorkflowController, WorkflowController, } from './workflow.controller.js';
3
+ export { WorkflowModule, type WorkflowModuleOptions, } from './workflow.module.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,GAC3B,MAAM,sBAAsB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { NestLocalBuilder } from './builder.js';
2
+ export { configureWorkflowController, WorkflowController, } from './workflow.controller.js';
3
+ export { WorkflowModule, } from './workflow.module.js';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,GAEf,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Configure the workflow controller with the output directory
3
+ */
4
+ export declare function configureWorkflowController(outDir: string): void;
5
+ /**
6
+ * Controller that handles the well-known workflow endpoints.
7
+ * Dynamically imports the generated bundles and handles request/response conversion.
8
+ */
9
+ export declare class WorkflowController {
10
+ handleStep(req: any, res: any): Promise<void>;
11
+ handleFlow(req: any, res: any): Promise<void>;
12
+ handleWebhook(req: any, res: any): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=workflow.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.controller.d.ts","sourceRoot":"","sources":["../src/workflow.controller.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAEhE;AAqED;;;GAGG;AACH,qBACa,kBAAkB;IAEvB,UAAU,CAAQ,GAAG,EAAE,GAAG,EAAS,GAAG,EAAE,GAAG;IAS3C,UAAU,CAAQ,GAAG,EAAE,GAAG,EAAS,GAAG,EAAE,GAAG;IAS3C,aAAa,CAAQ,GAAG,EAAE,GAAG,EAAS,GAAG,EAAE,GAAG;CAOrD"}
@@ -0,0 +1,133 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { All, Controller, Post, Req, Res } from '@nestjs/common';
14
+ import { join } from 'pathe';
15
+ // Module-level state for configuration
16
+ let configuredOutDir = null;
17
+ /**
18
+ * Configure the workflow controller with the output directory
19
+ */
20
+ export function configureWorkflowController(outDir) {
21
+ configuredOutDir = outDir;
22
+ }
23
+ /**
24
+ * Convert Express/Fastify request to Web API Request
25
+ */
26
+ function toWebRequest(req) {
27
+ // Works for both Express and Fastify
28
+ const protocol = req.protocol ?? (req.raw?.socket?.encrypted ? 'https' : 'http');
29
+ const host = req.headers.host ?? req.hostname;
30
+ const url = req.originalUrl ?? req.url;
31
+ const fullUrl = `${protocol}://${host}${url}`;
32
+ const headers = req.headers;
33
+ const method = req.method;
34
+ const body = req.body;
35
+ return new globalThis.Request(fullUrl, {
36
+ method,
37
+ headers,
38
+ body: method !== 'GET' && method !== 'HEAD'
39
+ ? body === undefined
40
+ ? undefined
41
+ : typeof body === 'string'
42
+ ? body
43
+ : JSON.stringify(body)
44
+ : undefined,
45
+ });
46
+ }
47
+ /**
48
+ * Send Web API Response back via Express/Fastify response
49
+ */
50
+ async function sendWebResponse(res, webResponse) {
51
+ const status = webResponse.status;
52
+ const headers = {};
53
+ webResponse.headers.forEach((value, key) => {
54
+ headers[key] = value;
55
+ });
56
+ const body = await webResponse.text();
57
+ // Works for both Express and Fastify
58
+ if (typeof res.code === 'function') {
59
+ // Fastify
60
+ res.code(status).headers(headers).send(body);
61
+ }
62
+ else {
63
+ // Express - use res.end() instead of res.send() to avoid automatic charset addition
64
+ res.status(status);
65
+ for (const [key, value] of Object.entries(headers)) {
66
+ res.setHeader(key, value);
67
+ }
68
+ // Use res.end() to send the body without Express modifying headers
69
+ res.end(body);
70
+ }
71
+ }
72
+ function getOutDir() {
73
+ if (!configuredOutDir) {
74
+ throw new Error('WorkflowController not configured. Call configureWorkflowController first.');
75
+ }
76
+ return configuredOutDir;
77
+ }
78
+ /**
79
+ * Controller that handles the well-known workflow endpoints.
80
+ * Dynamically imports the generated bundles and handles request/response conversion.
81
+ */
82
+ let WorkflowController = class WorkflowController {
83
+ async handleStep(req, res) {
84
+ const outDir = getOutDir();
85
+ const { POST } = await import(join(outDir, 'steps.mjs'));
86
+ const webRequest = toWebRequest(req);
87
+ const webResponse = await POST(webRequest);
88
+ await sendWebResponse(res, webResponse);
89
+ }
90
+ async handleFlow(req, res) {
91
+ const outDir = getOutDir();
92
+ const { POST } = await import(join(outDir, 'workflows.mjs'));
93
+ const webRequest = toWebRequest(req);
94
+ const webResponse = await POST(webRequest);
95
+ await sendWebResponse(res, webResponse);
96
+ }
97
+ async handleWebhook(req, res) {
98
+ const outDir = getOutDir();
99
+ const { POST } = await import(join(outDir, 'webhook.mjs'));
100
+ const webRequest = toWebRequest(req);
101
+ const webResponse = await POST(webRequest);
102
+ await sendWebResponse(res, webResponse);
103
+ }
104
+ };
105
+ __decorate([
106
+ Post('step'),
107
+ __param(0, Req()),
108
+ __param(1, Res()),
109
+ __metadata("design:type", Function),
110
+ __metadata("design:paramtypes", [Object, Object]),
111
+ __metadata("design:returntype", Promise)
112
+ ], WorkflowController.prototype, "handleStep", null);
113
+ __decorate([
114
+ Post('flow'),
115
+ __param(0, Req()),
116
+ __param(1, Res()),
117
+ __metadata("design:type", Function),
118
+ __metadata("design:paramtypes", [Object, Object]),
119
+ __metadata("design:returntype", Promise)
120
+ ], WorkflowController.prototype, "handleFlow", null);
121
+ __decorate([
122
+ All('webhook/:token'),
123
+ __param(0, Req()),
124
+ __param(1, Res()),
125
+ __metadata("design:type", Function),
126
+ __metadata("design:paramtypes", [Object, Object]),
127
+ __metadata("design:returntype", Promise)
128
+ ], WorkflowController.prototype, "handleWebhook", null);
129
+ WorkflowController = __decorate([
130
+ Controller('.well-known/workflow/v1')
131
+ ], WorkflowController);
132
+ export { WorkflowController };
133
+ //# sourceMappingURL=workflow.controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.controller.js","sourceRoot":"","sources":["../src/workflow.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAA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G,CAAC,gBAAgB,CAAC;IACD,WAAA,GAAG,EAAE,CAAA;IAAY,WAAA,GAAG,EAAE,CAAA;;;;uDAM1C;AA1BU,kBAAkB;IAD9B,UAAU,CAAC,yBAAyB,CAAC;GACzB,kBAAkB,CA2B9B"}
@@ -0,0 +1,33 @@
1
+ import { type DynamicModule, type OnModuleDestroy, type OnModuleInit } from '@nestjs/common';
2
+ import { type NestBuilderOptions } from './builder.js';
3
+ export interface WorkflowModuleOptions extends NestBuilderOptions {
4
+ /**
5
+ * Skip building workflow bundles (useful in production when bundles are pre-built)
6
+ * @default false
7
+ */
8
+ skipBuild?: boolean;
9
+ }
10
+ /**
11
+ * NestJS module that provides workflow functionality.
12
+ * Builds workflow bundles on module initialization and registers the workflow controller.
13
+ */
14
+ export declare class WorkflowModule implements OnModuleInit, OnModuleDestroy {
15
+ private static builder;
16
+ private static buildQueue;
17
+ /**
18
+ * Configure the WorkflowModule with options.
19
+ * Call this in your AppModule imports.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * @Module({
24
+ * imports: [WorkflowModule.forRoot()],
25
+ * })
26
+ * export class AppModule {}
27
+ * ```
28
+ */
29
+ static forRoot(options?: WorkflowModuleOptions): DynamicModule;
30
+ onModuleInit(): Promise<void>;
31
+ onModuleDestroy(): Promise<void>;
32
+ }
33
+ //# sourceMappingURL=workflow.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.module.d.ts","sourceRoot":"","sources":["../src/workflow.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,eAAe,EACpB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EAAE,KAAK,kBAAkB,EAAoB,MAAM,cAAc,CAAC;AAMzE,MAAM,WAAW,qBAAsB,SAAQ,kBAAkB;IAC/D;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAID;;;GAGG;AACH,qBACa,cAAe,YAAW,YAAY,EAAE,eAAe;IAClE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiC;IACvD,OAAO,CAAC,MAAM,CAAC,UAAU,CAAsB;IAE/C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,qBAA0B,GAAG,aAAa;IA4B5D,YAAY;IAOZ,eAAe;CAItB"}
@@ -0,0 +1,73 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var WorkflowModule_1;
8
+ import { Module, } from '@nestjs/common';
9
+ import { createBuildQueue } from '@workflow/builders';
10
+ import { join } from 'pathe';
11
+ import { NestLocalBuilder } from './builder.js';
12
+ import { configureWorkflowController, WorkflowController, } from './workflow.controller.js';
13
+ const DEFAULT_OUT_DIR = '.nestjs/workflow';
14
+ /**
15
+ * NestJS module that provides workflow functionality.
16
+ * Builds workflow bundles on module initialization and registers the workflow controller.
17
+ */
18
+ let WorkflowModule = class WorkflowModule {
19
+ static { WorkflowModule_1 = this; }
20
+ static builder = null;
21
+ static buildQueue = createBuildQueue();
22
+ /**
23
+ * Configure the WorkflowModule with options.
24
+ * Call this in your AppModule imports.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * @Module({
29
+ * imports: [WorkflowModule.forRoot()],
30
+ * })
31
+ * export class AppModule {}
32
+ * ```
33
+ */
34
+ static forRoot(options = {}) {
35
+ const workingDir = options.workingDir ?? process.cwd();
36
+ const outDir = options.outDir ?? join(workingDir, DEFAULT_OUT_DIR);
37
+ // Configure the controller with the output directory
38
+ configureWorkflowController(outDir);
39
+ // Create builder if we're not skipping builds
40
+ if (!options.skipBuild) {
41
+ WorkflowModule_1.builder = new NestLocalBuilder({
42
+ ...options,
43
+ outDir,
44
+ });
45
+ }
46
+ return {
47
+ module: WorkflowModule_1,
48
+ controllers: [WorkflowController],
49
+ providers: [
50
+ {
51
+ provide: 'WORKFLOW_OPTIONS',
52
+ useValue: options,
53
+ },
54
+ ],
55
+ global: true,
56
+ };
57
+ }
58
+ async onModuleInit() {
59
+ const builder = WorkflowModule_1.builder;
60
+ if (builder) {
61
+ await WorkflowModule_1.buildQueue(() => builder.build());
62
+ }
63
+ }
64
+ async onModuleDestroy() {
65
+ // Cleanup if needed
66
+ WorkflowModule_1.builder = null;
67
+ }
68
+ };
69
+ WorkflowModule = WorkflowModule_1 = __decorate([
70
+ Module({})
71
+ ], WorkflowModule);
72
+ export { WorkflowModule };
73
+ //# sourceMappingURL=workflow.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow.module.js","sourceRoot":"","sources":["../src/workflow.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAEL,MAAM,GAGP,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAC7B,OAAO,EAA2B,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,2BAA2B,EAC3B,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAUlC,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAE3C;;;GAGG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAc;;IACjB,MAAM,CAAC,OAAO,GAA4B,IAAI,CAAC;IAC/C,MAAM,CAAC,UAAU,GAAG,gBAAgB,EAAE,CAAC;IAE/C;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,OAAO,CAAC,UAAiC,EAAE;QAChD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QACvD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAEnE,qDAAqD;QACrD,2BAA2B,CAAC,MAAM,CAAC,CAAC;QAEpC,8CAA8C;QAC9C,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YACvB,gBAAc,CAAC,OAAO,GAAG,IAAI,gBAAgB,CAAC;gBAC5C,GAAG,OAAO;gBACV,MAAM;aACP,CAAC,CAAC;QACL,CAAC;QAED,OAAO;YACL,MAAM,EAAE,gBAAc;YACtB,WAAW,EAAE,CAAC,kBAAkB,CAAC;YACjC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,kBAAkB;oBAC3B,QAAQ,EAAE,OAAO;iBAClB;aACF;YACD,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,OAAO,GAAG,gBAAc,CAAC,OAAO,CAAC;QACvC,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,gBAAc,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,oBAAoB;QACpB,gBAAc,CAAC,OAAO,GAAG,IAAI,CAAC;IAChC,CAAC;;AAtDU,cAAc;IAD1B,MAAM,CAAC,EAAE,CAAC;GACE,cAAc,CAuD1B"}
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@workflow/nest",
3
+ "version": "0.0.0-beta.0",
4
+ "description": "NestJS integration for Workflow DevKit",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "workflow-nest": "./dist/cli.js"
9
+ },
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./builder": {
16
+ "types": "./dist/builder.d.ts",
17
+ "import": "./dist/builder.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "dependencies": {
27
+ "@swc/core": "1.15.3",
28
+ "pathe": "2.0.3",
29
+ "@workflow/builders": "4.0.1-beta.42",
30
+ "@workflow/swc-plugin": "4.1.0-beta.15"
31
+ },
32
+ "peerDependencies": {
33
+ "@nestjs/common": ">=10.0.0",
34
+ "@nestjs/core": ">=10.0.0",
35
+ "@swc/cli": ">=0.4.0",
36
+ "@swc/core": ">=1.5.0"
37
+ },
38
+ "peerDependenciesMeta": {
39
+ "@nestjs/common": {
40
+ "optional": false
41
+ },
42
+ "@nestjs/core": {
43
+ "optional": false
44
+ },
45
+ "@swc/cli": {
46
+ "optional": false
47
+ },
48
+ "@swc/core": {
49
+ "optional": false
50
+ }
51
+ },
52
+ "devDependencies": {
53
+ "@nestjs/common": "^11.0.17",
54
+ "@nestjs/core": "^11.0.1",
55
+ "@types/node": "22.19.0",
56
+ "typescript": "^5.9.3",
57
+ "@workflow/tsconfig": "4.0.1-beta.0"
58
+ },
59
+ "license": "Apache-2.0",
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/vercel/workflow.git",
63
+ "directory": "packages/nest"
64
+ },
65
+ "scripts": {
66
+ "build": "tsc",
67
+ "dev": "tsc --watch",
68
+ "clean": "tsc --build --clean && rm -rf dist"
69
+ }
70
+ }