@workflow/builders 4.0.1-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/LICENSE.md +201 -0
  2. package/README.md +43 -0
  3. package/dist/apply-swc-transform.d.ts +24 -0
  4. package/dist/apply-swc-transform.d.ts.map +1 -0
  5. package/dist/apply-swc-transform.js +38 -0
  6. package/dist/apply-swc-transform.js.map +1 -0
  7. package/dist/base-builder.d.ts +135 -0
  8. package/dist/base-builder.d.ts.map +1 -0
  9. package/dist/base-builder.js +598 -0
  10. package/dist/base-builder.js.map +1 -0
  11. package/dist/config-helpers.d.ts +12 -0
  12. package/dist/config-helpers.d.ts.map +1 -0
  13. package/dist/config-helpers.js +16 -0
  14. package/dist/config-helpers.js.map +1 -0
  15. package/dist/constants.d.ts +25 -0
  16. package/dist/constants.d.ts.map +1 -0
  17. package/dist/constants.js +25 -0
  18. package/dist/constants.js.map +1 -0
  19. package/dist/discover-entries-esbuild-plugin.d.ts +11 -0
  20. package/dist/discover-entries-esbuild-plugin.d.ts.map +1 -0
  21. package/dist/discover-entries-esbuild-plugin.js +87 -0
  22. package/dist/discover-entries-esbuild-plugin.js.map +1 -0
  23. package/dist/index.d.ts +13 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +11 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/node-module-esbuild-plugin.d.ts +3 -0
  28. package/dist/node-module-esbuild-plugin.d.ts.map +1 -0
  29. package/dist/node-module-esbuild-plugin.js +25 -0
  30. package/dist/node-module-esbuild-plugin.js.map +1 -0
  31. package/dist/node-module-esbuild-plugin.test.d.ts +2 -0
  32. package/dist/node-module-esbuild-plugin.test.d.ts.map +1 -0
  33. package/dist/node-module-esbuild-plugin.test.js +198 -0
  34. package/dist/node-module-esbuild-plugin.test.js.map +1 -0
  35. package/dist/standalone.d.ts +8 -0
  36. package/dist/standalone.d.ts.map +1 -0
  37. package/dist/standalone.js +47 -0
  38. package/dist/standalone.js.map +1 -0
  39. package/dist/swc-esbuild-plugin.d.ts +12 -0
  40. package/dist/swc-esbuild-plugin.d.ts.map +1 -0
  41. package/dist/swc-esbuild-plugin.js +179 -0
  42. package/dist/swc-esbuild-plugin.js.map +1 -0
  43. package/dist/types.d.ts +56 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +10 -0
  46. package/dist/types.js.map +1 -0
  47. package/dist/vercel-build-output-api.d.ts +9 -0
  48. package/dist/vercel-build-output-api.d.ts.map +1 -0
  49. package/dist/vercel-build-output-api.js +92 -0
  50. package/dist/vercel-build-output-api.js.map +1 -0
  51. package/package.json +54 -0
@@ -0,0 +1,598 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { dirname, join, relative, resolve } from 'node:path';
3
+ import { promisify } from 'node:util';
4
+ import chalk from 'chalk';
5
+ import { parse } from 'comment-json';
6
+ import enhancedResolveOriginal from 'enhanced-resolve';
7
+ import * as esbuild from 'esbuild';
8
+ import { findUp } from 'find-up';
9
+ import { glob } from 'tinyglobby';
10
+ import { createDiscoverEntriesPlugin } from './discover-entries-esbuild-plugin.js';
11
+ import { createNodeModuleErrorPlugin } from './node-module-esbuild-plugin.js';
12
+ import { createSwcPlugin } from './swc-esbuild-plugin.js';
13
+ const enhancedResolve = promisify(enhancedResolveOriginal);
14
+ const EMIT_SOURCEMAPS_FOR_DEBUGGING = process.env.WORKFLOW_EMIT_SOURCEMAPS_FOR_DEBUGGING === '1';
15
+ /**
16
+ * Base class for workflow builders. Provides common build logic for transforming
17
+ * workflow source files into deployable bundles using esbuild and SWC.
18
+ *
19
+ * Subclasses must implement the build() method to define builder-specific logic.
20
+ */
21
+ export class BaseBuilder {
22
+ config;
23
+ constructor(config) {
24
+ this.config = config;
25
+ }
26
+ /**
27
+ * Extracts TypeScript path mappings and baseUrl from tsconfig.json/jsconfig.json.
28
+ * Used to properly resolve module imports during bundling.
29
+ */
30
+ async getTsConfigOptions() {
31
+ const options = {};
32
+ const cwd = this.config.workingDir || process.cwd();
33
+ const tsJsConfig = await findUp(['tsconfig.json', 'jsconfig.json'], {
34
+ cwd,
35
+ });
36
+ if (tsJsConfig) {
37
+ try {
38
+ const rawJson = await readFile(tsJsConfig, 'utf8');
39
+ const parsed = parse(rawJson);
40
+ if (parsed) {
41
+ options.paths = parsed.compilerOptions?.paths;
42
+ if (parsed.compilerOptions?.baseUrl) {
43
+ options.baseUrl = resolve(cwd, parsed.compilerOptions.baseUrl);
44
+ }
45
+ else {
46
+ options.baseUrl = cwd;
47
+ }
48
+ }
49
+ }
50
+ catch (err) {
51
+ console.error(`Failed to parse ${tsJsConfig} aliases might not apply properly`, err);
52
+ }
53
+ }
54
+ return options;
55
+ }
56
+ /**
57
+ * Discovers all source files in the configured directories.
58
+ * Searches for TypeScript and JavaScript files while excluding common build
59
+ * and dependency directories.
60
+ */
61
+ async getInputFiles() {
62
+ const patterns = this.config.dirs.map((dir) => {
63
+ const resolvedDir = resolve(this.config.workingDir, dir);
64
+ // Normalize path separators to forward slashes for glob compatibility
65
+ const normalizedDir = resolvedDir.replace(/\\/g, '/');
66
+ return `${normalizedDir}/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}`;
67
+ });
68
+ const result = await glob(patterns, {
69
+ ignore: [
70
+ '**/node_modules/**',
71
+ '**/.git/**',
72
+ '**/.next/**',
73
+ '**/.vercel/**',
74
+ '**/.workflow-data/**',
75
+ '**/.well-known/workflow/**',
76
+ '**/.svelte-kit/**',
77
+ ],
78
+ absolute: true,
79
+ });
80
+ return result;
81
+ }
82
+ /**
83
+ * Caches discovered workflow entries by input array reference.
84
+ * Uses WeakMap to allow garbage collection when input arrays are no longer referenced.
85
+ * This cache is invalidated automatically when the inputs array reference changes
86
+ * (e.g., when files are added/removed during watch mode).
87
+ */
88
+ discoveredEntries = new WeakMap();
89
+ async discoverEntries(inputs, outdir) {
90
+ const previousResult = this.discoveredEntries.get(inputs);
91
+ if (previousResult) {
92
+ return previousResult;
93
+ }
94
+ const state = {
95
+ discoveredSteps: [],
96
+ discoveredWorkflows: [],
97
+ };
98
+ const discoverStart = Date.now();
99
+ try {
100
+ await esbuild.build({
101
+ treeShaking: true,
102
+ entryPoints: inputs,
103
+ plugins: [createDiscoverEntriesPlugin(state)],
104
+ platform: 'node',
105
+ write: false,
106
+ outdir,
107
+ bundle: true,
108
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
109
+ absWorkingDir: this.config.workingDir,
110
+ logLevel: 'silent',
111
+ });
112
+ }
113
+ catch (_) { }
114
+ console.log(`Discovering workflow directives`, `${Date.now() - discoverStart}ms`);
115
+ this.discoveredEntries.set(inputs, state);
116
+ return state;
117
+ }
118
+ /**
119
+ * Writes debug information to a JSON file for troubleshooting build issues.
120
+ * Executes whenever called, regardless of environment variables.
121
+ */
122
+ async writeDebugFile(outfile, debugData, merge) {
123
+ try {
124
+ let existing = {};
125
+ if (merge) {
126
+ existing = JSON.parse(await readFile(`${outfile}.debug.json`, 'utf8').catch(() => '{}'));
127
+ }
128
+ await writeFile(`${outfile}.debug.json`, JSON.stringify({
129
+ ...existing,
130
+ ...debugData,
131
+ }, null, 2));
132
+ }
133
+ catch (error) {
134
+ console.warn('Failed to write debug file:', error);
135
+ }
136
+ }
137
+ /**
138
+ * Logs and optionally throws on esbuild errors and warnings.
139
+ * @param throwOnError - If true, throws an error when esbuild errors are present
140
+ */
141
+ logEsbuildMessages(result, phase, throwOnError = true) {
142
+ if (result.errors && result.errors.length > 0) {
143
+ console.error(`❌ esbuild errors in ${phase}:`);
144
+ const errorMessages = [];
145
+ for (const error of result.errors) {
146
+ console.error(` ${error.text}`);
147
+ errorMessages.push(error.text);
148
+ if (error.location) {
149
+ const location = ` at ${error.location.file}:${error.location.line}:${error.location.column}`;
150
+ console.error(location);
151
+ errorMessages.push(location);
152
+ }
153
+ }
154
+ if (throwOnError) {
155
+ throw new Error(`Build failed during ${phase}:\n${errorMessages.join('\n')}`);
156
+ }
157
+ }
158
+ if (result.warnings && result.warnings.length > 0) {
159
+ console.warn(`! esbuild warnings in ${phase}:`);
160
+ for (const warning of result.warnings) {
161
+ console.warn(` ${warning.text}`);
162
+ if (warning.location) {
163
+ console.warn(` at ${warning.location.file}:${warning.location.line}:${warning.location.column}`);
164
+ }
165
+ }
166
+ }
167
+ }
168
+ /**
169
+ * Creates a bundle for workflow step functions.
170
+ * Steps have full Node.js runtime access and handle side effects, API calls, etc.
171
+ *
172
+ * @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code
173
+ */
174
+ async createStepsBundle({ inputFiles, format = 'cjs', outfile, externalizeNonSteps, tsBaseUrl, tsPaths, }) {
175
+ // These need to handle watching for dev to scan for
176
+ // new entries and changes to existing ones
177
+ const { discoveredSteps: stepFiles } = await this.discoverEntries(inputFiles, dirname(outfile));
178
+ // log the step files for debugging
179
+ await this.writeDebugFile(outfile, { stepFiles });
180
+ const stepsBundleStart = Date.now();
181
+ const workflowManifest = {};
182
+ const builtInSteps = 'workflow/internal/builtins';
183
+ const resolvedBuiltInSteps = await enhancedResolve(dirname(outfile), 'workflow/internal/builtins').catch((err) => {
184
+ throw new Error([
185
+ chalk.red('Failed to resolve built-in steps sources.'),
186
+ `${chalk.yellow.bold('hint:')} run \`${chalk.cyan.italic('npm install workflow')}\` to resolve this issue.`,
187
+ '',
188
+ `Caused by: ${chalk.red(String(err))}`,
189
+ ].join('\n'));
190
+ });
191
+ // Create a virtual entry that imports all files. All step definitions
192
+ // will get registered thanks to the swc transform.
193
+ const imports = stepFiles
194
+ .map((file) => {
195
+ // Normalize both paths to forward slashes before calling relative()
196
+ // This is critical on Windows where relative() can produce unexpected results with mixed path formats
197
+ const normalizedWorkingDir = this.config.workingDir.replace(/\\/g, '/');
198
+ const normalizedFile = file.replace(/\\/g, '/');
199
+ // Calculate relative path from working directory to the file
200
+ let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(/\\/g, '/');
201
+ // Ensure relative paths start with ./ so esbuild resolves them correctly
202
+ if (!relativePath.startsWith('.')) {
203
+ relativePath = `./${relativePath}`;
204
+ }
205
+ return `import '${relativePath}';`;
206
+ })
207
+ .join('\n');
208
+ const entryContent = `
209
+ // Built in steps
210
+ import '${builtInSteps}';
211
+ // User steps
212
+ ${imports}
213
+ // API entrypoint
214
+ export { stepEntrypoint as POST } from 'workflow/runtime';`;
215
+ // Bundle with esbuild and our custom SWC plugin
216
+ const esbuildCtx = await esbuild.context({
217
+ banner: {
218
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
219
+ },
220
+ stdin: {
221
+ contents: entryContent,
222
+ resolveDir: this.config.workingDir,
223
+ sourcefile: 'virtual-entry.js',
224
+ loader: 'js',
225
+ },
226
+ outfile,
227
+ absWorkingDir: this.config.workingDir,
228
+ bundle: true,
229
+ format,
230
+ platform: 'node',
231
+ conditions: ['node'],
232
+ target: 'es2022',
233
+ write: true,
234
+ treeShaking: true,
235
+ keepNames: true,
236
+ minify: false,
237
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
238
+ // TODO: investigate proper source map support
239
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
240
+ plugins: [
241
+ createSwcPlugin({
242
+ mode: 'step',
243
+ entriesToBundle: externalizeNonSteps
244
+ ? [
245
+ ...stepFiles,
246
+ ...(resolvedBuiltInSteps ? [resolvedBuiltInSteps] : []),
247
+ ]
248
+ : undefined,
249
+ outdir: outfile ? dirname(outfile) : undefined,
250
+ tsBaseUrl,
251
+ tsPaths,
252
+ workflowManifest,
253
+ }),
254
+ ],
255
+ // Plugin should catch most things, but this lets users hard override
256
+ // if the plugin misses anything that should be externalized
257
+ external: this.config.externalPackages || [],
258
+ });
259
+ const stepsResult = await esbuildCtx.rebuild();
260
+ this.logEsbuildMessages(stepsResult, 'steps bundle creation');
261
+ console.log('Created steps bundle', `${Date.now() - stepsBundleStart}ms`);
262
+ const partialWorkflowManifest = {
263
+ steps: workflowManifest.steps,
264
+ };
265
+ // always write to debug file
266
+ await this.writeDebugFile(join(dirname(outfile), 'manifest'), partialWorkflowManifest, true);
267
+ // Create .gitignore in .swc directory
268
+ await this.createSwcGitignore();
269
+ if (this.config.watch) {
270
+ return esbuildCtx;
271
+ }
272
+ await esbuildCtx.dispose();
273
+ }
274
+ /**
275
+ * Creates a bundle for workflow orchestration functions.
276
+ * Workflows run in a sandboxed VM and coordinate step execution.
277
+ *
278
+ * @param bundleFinalOutput - If false, skips the final bundling step (used by Next.js)
279
+ */
280
+ async createWorkflowsBundle({ inputFiles, format = 'cjs', outfile, bundleFinalOutput = true, tsBaseUrl, tsPaths, }) {
281
+ const { discoveredWorkflows: workflowFiles } = await this.discoverEntries(inputFiles, dirname(outfile));
282
+ // log the workflow files for debugging
283
+ await this.writeDebugFile(outfile, { workflowFiles });
284
+ // Create a virtual entry that imports all files
285
+ const imports = `globalThis.__private_workflows = new Map();\n` +
286
+ workflowFiles
287
+ .map((file, workflowFileIdx) => {
288
+ // Normalize both paths to forward slashes before calling relative()
289
+ // This is critical on Windows where relative() can produce unexpected results with mixed path formats
290
+ const normalizedWorkingDir = this.config.workingDir.replace(/\\/g, '/');
291
+ const normalizedFile = file.replace(/\\/g, '/');
292
+ // Calculate relative path from working directory to the file
293
+ let relativePath = relative(normalizedWorkingDir, normalizedFile).replace(/\\/g, '/');
294
+ // Ensure relative paths start with ./ so esbuild resolves them correctly
295
+ if (!relativePath.startsWith('.')) {
296
+ relativePath = `./${relativePath}`;
297
+ }
298
+ return `import * as workflowFile${workflowFileIdx} from '${relativePath}';
299
+ Object.values(workflowFile${workflowFileIdx}).map(item => item?.workflowId && globalThis.__private_workflows.set(item.workflowId, item))`;
300
+ })
301
+ .join('\n');
302
+ const bundleStartTime = Date.now();
303
+ const workflowManifest = {};
304
+ // Bundle with esbuild and our custom SWC plugin in workflow mode.
305
+ // this bundle will be run inside a vm isolate
306
+ const interimBundleCtx = await esbuild.context({
307
+ stdin: {
308
+ contents: imports,
309
+ resolveDir: this.config.workingDir,
310
+ sourcefile: 'virtual-entry.js',
311
+ loader: 'js',
312
+ },
313
+ bundle: true,
314
+ absWorkingDir: this.config.workingDir,
315
+ format: 'cjs', // Runs inside the VM which expects cjs
316
+ platform: 'neutral', // The platform is neither node nor browser
317
+ mainFields: ['module', 'main'], // To support npm style imports
318
+ conditions: ['workflow'], // Allow packages to export 'workflow' compliant versions
319
+ target: 'es2022',
320
+ write: false,
321
+ treeShaking: true,
322
+ keepNames: true,
323
+ minify: false,
324
+ // Inline source maps for better stack traces in workflow VM execution.
325
+ // This intermediate bundle is executed via runInContext() in a VM, so we need
326
+ // inline source maps to get meaningful stack traces instead of "evalmachine.<anonymous>".
327
+ sourcemap: 'inline',
328
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
329
+ plugins: [
330
+ createSwcPlugin({
331
+ mode: 'workflow',
332
+ tsBaseUrl,
333
+ tsPaths,
334
+ workflowManifest,
335
+ }),
336
+ // This plugin must run after the swc plugin to ensure dead code elimination
337
+ // happens first, preventing false positives on Node.js imports in unused code paths
338
+ createNodeModuleErrorPlugin(),
339
+ ],
340
+ });
341
+ const interimBundle = await interimBundleCtx.rebuild();
342
+ this.logEsbuildMessages(interimBundle, 'intermediate workflow bundle');
343
+ console.log('Created intermediate workflow bundle', `${Date.now() - bundleStartTime}ms`);
344
+ const partialWorkflowManifest = {
345
+ workflows: workflowManifest.workflows,
346
+ };
347
+ await this.writeDebugFile(join(dirname(outfile), 'manifest'), partialWorkflowManifest, true);
348
+ if (this.config.workflowManifestPath) {
349
+ const resolvedPath = resolve(process.cwd(), this.config.workflowManifestPath);
350
+ let prefix = '';
351
+ if (resolvedPath.endsWith('.cjs')) {
352
+ prefix = 'module.exports = ';
353
+ }
354
+ else if (resolvedPath.endsWith('.js') ||
355
+ resolvedPath.endsWith('.mjs')) {
356
+ prefix = 'export default ';
357
+ }
358
+ await mkdir(dirname(resolvedPath), { recursive: true });
359
+ await writeFile(resolvedPath, prefix + JSON.stringify(workflowManifest.workflows, null, 2));
360
+ }
361
+ // Create .gitignore in .swc directory
362
+ await this.createSwcGitignore();
363
+ if (!interimBundle.outputFiles || interimBundle.outputFiles.length === 0) {
364
+ throw new Error('No output files generated from esbuild');
365
+ }
366
+ const bundleFinal = async (interimBundle) => {
367
+ const workflowBundleCode = interimBundle;
368
+ const workflowFunctionCode = `// biome-ignore-all lint: generated file
369
+ /* eslint-disable */
370
+ import { workflowEntrypoint } from 'workflow/runtime';
371
+
372
+ const workflowCode = \`${workflowBundleCode.replace(/[\\`$]/g, '\\$&')}\`;
373
+
374
+ export const POST = workflowEntrypoint(workflowCode);`;
375
+ // we skip the final bundling step for Next.js so it can bundle itself
376
+ if (!bundleFinalOutput) {
377
+ if (!outfile) {
378
+ throw new Error(`Invariant: missing outfile for workflow bundle`);
379
+ }
380
+ // Ensure the output directory exists
381
+ const outputDir = dirname(outfile);
382
+ await mkdir(outputDir, { recursive: true });
383
+ await writeFile(outfile, workflowFunctionCode);
384
+ return;
385
+ }
386
+ const bundleStartTime = Date.now();
387
+ // Now bundle this so we can resolve the @workflow/core dependency
388
+ // we could remove this if we do nft tracing or similar instead
389
+ const finalWorkflowResult = await esbuild.build({
390
+ banner: {
391
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
392
+ },
393
+ stdin: {
394
+ contents: workflowFunctionCode,
395
+ resolveDir: this.config.workingDir,
396
+ sourcefile: 'virtual-entry.js',
397
+ loader: 'js',
398
+ },
399
+ outfile,
400
+ // Source maps for the final workflow bundle wrapper (not important since this code
401
+ // doesn't run in the VM - only the intermediate bundle sourcemap is relevant)
402
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
403
+ absWorkingDir: this.config.workingDir,
404
+ bundle: true,
405
+ format,
406
+ platform: 'node',
407
+ target: 'es2022',
408
+ write: true,
409
+ keepNames: true,
410
+ minify: false,
411
+ external: ['@aws-sdk/credential-provider-web-identity'],
412
+ });
413
+ this.logEsbuildMessages(finalWorkflowResult, 'final workflow bundle');
414
+ console.log('Created final workflow bundle', `${Date.now() - bundleStartTime}ms`);
415
+ };
416
+ await bundleFinal(interimBundle.outputFiles[0].text);
417
+ if (this.config.watch) {
418
+ return {
419
+ interimBundleCtx,
420
+ bundleFinal,
421
+ };
422
+ }
423
+ await interimBundleCtx.dispose();
424
+ }
425
+ /**
426
+ * Creates a client library bundle for workflow execution.
427
+ * The client library allows importing and calling workflows from application code.
428
+ * Only generated if clientBundlePath is specified in config.
429
+ */
430
+ async createClientLibrary() {
431
+ if (!this.config.clientBundlePath) {
432
+ // Silently exit since no client bundle was requested
433
+ return;
434
+ }
435
+ console.log('Generating a client library at', this.config.clientBundlePath);
436
+ console.log('NOTE: The recommended way to use workflow with a framework like NextJS is using the loader/plugin with webpack/turbobpack/rollup');
437
+ // Ensure we have the directory for the client bundle
438
+ const outputDir = dirname(this.config.clientBundlePath);
439
+ await mkdir(outputDir, { recursive: true });
440
+ const inputFiles = await this.getInputFiles();
441
+ // Create a virtual entry that imports all files
442
+ const imports = inputFiles
443
+ .map((file) => `export * from '${file}';`)
444
+ .join('\n');
445
+ // Bundle with esbuild and our custom SWC plugin
446
+ const clientResult = await esbuild.build({
447
+ banner: {
448
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
449
+ },
450
+ stdin: {
451
+ contents: imports,
452
+ resolveDir: this.config.workingDir,
453
+ sourcefile: 'virtual-entry.js',
454
+ loader: 'js',
455
+ },
456
+ outfile: this.config.clientBundlePath,
457
+ bundle: true,
458
+ format: 'esm',
459
+ platform: 'node',
460
+ target: 'es2022',
461
+ write: true,
462
+ treeShaking: true,
463
+ external: ['@workflow/core'],
464
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
465
+ plugins: [createSwcPlugin({ mode: 'client' })],
466
+ });
467
+ this.logEsbuildMessages(clientResult, 'client library bundle');
468
+ // Create .gitignore in .swc directory
469
+ await this.createSwcGitignore();
470
+ }
471
+ /**
472
+ * Creates a webhook handler bundle for resuming workflows via HTTP callbacks.
473
+ *
474
+ * @param bundle - If true, bundles dependencies (needed for Build Output API)
475
+ * @param suppressUndefinedRejections - If true, suppresses undefined rejections.
476
+ * This is a workaround to avoid crashing in local
477
+ * dev when context isn't set for waitUntil()
478
+ */
479
+ async createWebhookBundle({ outfile, bundle = false, suppressUndefinedRejections = false, }) {
480
+ console.log('Creating webhook route');
481
+ await mkdir(dirname(outfile), { recursive: true });
482
+ // Create a static route that calls resumeWebhook
483
+ // This route works for both Next.js and Vercel Build Output API
484
+ const routeContent = `${suppressUndefinedRejections ? 'process.on("unhandledRejection", (reason) => { if (reason !== undefined) console.error("Unhandled rejection detected", reason); });\n' : ''}
485
+ import { resumeWebhook } from 'workflow/api';
486
+
487
+ async function handler(request) {
488
+ const url = new URL(request.url);
489
+ // Extract token from pathname: /.well-known/workflow/v1/webhook/{token}
490
+ const pathParts = url.pathname.split('/');
491
+ const token = decodeURIComponent(pathParts[pathParts.length - 1]);
492
+
493
+ if (!token) {
494
+ return new Response('Missing token', { status: 400 });
495
+ }
496
+
497
+ try {
498
+ const response = await resumeWebhook(token, request);
499
+ return response;
500
+ } catch (error) {
501
+ // TODO: differentiate between invalid token and other errors
502
+ console.error('Error during resumeWebhook', error);
503
+ return new Response(null, { status: 404 });
504
+ }
505
+ }
506
+
507
+ export const GET = handler;
508
+ export const POST = handler;
509
+ export const PUT = handler;
510
+ export const PATCH = handler;
511
+ export const DELETE = handler;
512
+ export const HEAD = handler;
513
+ export const OPTIONS = handler;`;
514
+ if (!bundle) {
515
+ // For Next.js, just write the unbundled file
516
+ await writeFile(outfile, routeContent);
517
+ return;
518
+ }
519
+ // For Build Output API, bundle with esbuild to resolve imports
520
+ const webhookBundleStart = Date.now();
521
+ const result = await esbuild.build({
522
+ banner: {
523
+ js: `// biome-ignore-all lint: generated file\n/* eslint-disable */`,
524
+ },
525
+ stdin: {
526
+ contents: routeContent,
527
+ resolveDir: this.config.workingDir,
528
+ sourcefile: 'webhook-route.js',
529
+ loader: 'js',
530
+ },
531
+ outfile,
532
+ absWorkingDir: this.config.workingDir,
533
+ bundle: true,
534
+ format: 'cjs',
535
+ platform: 'node',
536
+ conditions: ['import', 'module', 'node', 'default'],
537
+ target: 'es2022',
538
+ write: true,
539
+ treeShaking: true,
540
+ keepNames: true,
541
+ minify: false,
542
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
543
+ sourcemap: false,
544
+ mainFields: ['module', 'main'],
545
+ // Don't externalize anything - bundle everything including workflow packages
546
+ external: [],
547
+ });
548
+ this.logEsbuildMessages(result, 'webhook bundle creation');
549
+ console.log('Created webhook bundle', `${Date.now() - webhookBundleStart}ms`);
550
+ }
551
+ /**
552
+ * Creates a package.json file with the specified module type.
553
+ */
554
+ async createPackageJson(dir, type) {
555
+ const packageJson = { type };
556
+ await writeFile(join(dir, 'package.json'), JSON.stringify(packageJson, null, 2));
557
+ }
558
+ /**
559
+ * Creates a .vc-config.json file for Vercel Build Output API functions.
560
+ */
561
+ async createVcConfig(dir, config) {
562
+ const vcConfig = {
563
+ runtime: config.runtime ?? 'nodejs22.x',
564
+ handler: config.handler ?? 'index.js',
565
+ launcherType: config.launcherType ?? 'Nodejs',
566
+ architecture: config.architecture ?? 'arm64',
567
+ shouldAddHelpers: config.shouldAddHelpers ?? true,
568
+ ...(config.shouldAddSourcemapSupport !== undefined && {
569
+ shouldAddSourcemapSupport: config.shouldAddSourcemapSupport,
570
+ }),
571
+ ...(config.experimentalTriggers && {
572
+ experimentalTriggers: config.experimentalTriggers,
573
+ }),
574
+ };
575
+ await writeFile(join(dir, '.vc-config.json'), JSON.stringify(vcConfig, null, 2));
576
+ }
577
+ /**
578
+ * Resolves a path relative to the working directory.
579
+ */
580
+ resolvePath(path) {
581
+ return resolve(this.config.workingDir, path);
582
+ }
583
+ /**
584
+ * Ensures the directory for a file path exists, creating it if necessary.
585
+ */
586
+ async ensureDirectory(filePath) {
587
+ await mkdir(dirname(filePath), { recursive: true });
588
+ }
589
+ async createSwcGitignore() {
590
+ try {
591
+ await writeFile(join(this.config.workingDir, '.swc', '.gitignore'), '*\n');
592
+ }
593
+ catch {
594
+ // We're intentionally silently ignoring this error - creating .gitignore isn't critical
595
+ }
596
+ }
597
+ }
598
+ //# sourceMappingURL=base-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-builder.js","sourceRoot":"","sources":["../src/base-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,uBAAuB,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AACnF,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG1D,MAAM,eAAe,GAAG,SAAS,CAAC,uBAAuB,CAAC,CAAC;AAE3D,MAAM,6BAA6B,GACjC,OAAO,CAAC,GAAG,CAAC,sCAAsC,KAAK,GAAG,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,OAAgB,WAAW;IACrB,MAAM,CAAiB;IAEjC,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAQD;;;OAGG;IACO,KAAK,CAAC,kBAAkB;Q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AAC,gBAAgB,IAAI,IAAI;YACjD,GAAG,CAAC,MAAM,CAAC,yBAAyB,KAAK,SAAS,IAAI;gBACpD,yBAAyB,EAAE,MAAM,CAAC,yBAAyB;aAC5D,CAAC;YACF,GAAG,CAAC,MAAM,CAAC,oBAAoB,IAAI;gBACjC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;aAClD,CAAC;SACH,CAAC;QAEF,MAAM,SAAS,CACb,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,EAC5B,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,WAAW,CAAC,IAAY;QAChC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACO,KAAK,CAAC,eAAe,CAAC,QAAgB;QAC9C,MAAM,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAEO,KAAK,CAAC,kBAAkB;QAC9B,IAAI,CAAC;YACH,MAAM,SAAS,CACb,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,CAAC,EAClD,KAAK,CACN,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC;YACP,wFAAwF;QAC1F,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import type { WorkflowConfig } from './types.js';
2
+ /**
3
+ * Creates a partial configuration for builders that don't use bundle paths directly.
4
+ * Used by framework integrations like Nitro where the builder computes paths internally.
5
+ */
6
+ export declare function createBaseBuilderConfig(options: {
7
+ workingDir: string;
8
+ dirs?: string[];
9
+ watch?: boolean;
10
+ externalPackages?: string[];
11
+ }): Omit<WorkflowConfig, 'buildTarget'>;
12
+ //# sourceMappingURL=config-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-helpers.d.ts","sourceRoot":"","sources":["../src/config-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAC/C,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC7B,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,CAAC,CAUtC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Creates a partial configuration for builders that don't use bundle paths directly.
3
+ * Used by framework integrations like Nitro where the builder computes paths internally.
4
+ */
5
+ export function createBaseBuilderConfig(options) {
6
+ return {
7
+ dirs: options.dirs ?? ['workflows'],
8
+ workingDir: options.workingDir,
9
+ watch: options.watch,
10
+ stepsBundlePath: '', // Not used by base builder methods
11
+ workflowsBundlePath: '', // Not used by base builder methods
12
+ webhookBundlePath: '', // Not used by base builder methods
13
+ externalPackages: options.externalPackages,
14
+ };
15
+ }
16
+ //# sourceMappingURL=config-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-helpers.js","sourceRoot":"","sources":["../src/config-helpers.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAKvC;IACC,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC;QACnC,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,eAAe,EAAE,EAAE,EAAE,mCAAmC;QACxD,mBAAmB,EAAE,EAAE,EAAE,mCAAmC;QAC5D,iBAAiB,EAAE,EAAE,EAAE,mCAAmC;QAC1D,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;KAC3C,CAAC;AACJ,CAAC"}