@workflow/builders 4.0.1-beta.4

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 +131 -0
  8. package/dist/base-builder.d.ts.map +1 -0
  9. package/dist/base-builder.js +558 -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 +84 -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 +24 -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 +128 -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 +134 -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,558 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { dirname, join, 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 result = await glob(this.config.dirs.map((dir) => `${resolve(this.config.workingDir, dir)}/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}`), {
63
+ ignore: [
64
+ '**/node_modules/**',
65
+ '**/.git/**',
66
+ '**/.next/**',
67
+ '**/.vercel/**',
68
+ '**/.workflow-data/**',
69
+ '**/.well-known/workflow/**',
70
+ ],
71
+ absolute: true,
72
+ });
73
+ return result;
74
+ }
75
+ /**
76
+ * Caches discovered workflow entries by input array reference.
77
+ * Uses WeakMap to allow garbage collection when input arrays are no longer referenced.
78
+ * This cache is invalidated automatically when the inputs array reference changes
79
+ * (e.g., when files are added/removed during watch mode).
80
+ */
81
+ discoveredEntries = new WeakMap();
82
+ async discoverEntries(inputs, outdir) {
83
+ const previousResult = this.discoveredEntries.get(inputs);
84
+ if (previousResult) {
85
+ return previousResult;
86
+ }
87
+ const state = {
88
+ discoveredSteps: [],
89
+ discoveredWorkflows: [],
90
+ };
91
+ const discoverStart = Date.now();
92
+ try {
93
+ await esbuild.build({
94
+ treeShaking: true,
95
+ entryPoints: inputs,
96
+ plugins: [createDiscoverEntriesPlugin(state)],
97
+ platform: 'node',
98
+ write: false,
99
+ outdir,
100
+ bundle: true,
101
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
102
+ absWorkingDir: this.config.workingDir,
103
+ logLevel: 'silent',
104
+ });
105
+ }
106
+ catch (_) { }
107
+ console.log(`Discovering workflow directives`, `${Date.now() - discoverStart}ms`);
108
+ this.discoveredEntries.set(inputs, state);
109
+ return state;
110
+ }
111
+ /**
112
+ * Writes debug information to a JSON file for troubleshooting build issues.
113
+ * Executes whenever called, regardless of environment variables.
114
+ */
115
+ async writeDebugFile(outfile, debugData, merge) {
116
+ try {
117
+ let existing = {};
118
+ if (merge) {
119
+ existing = JSON.parse(await readFile(`${outfile}.debug.json`, 'utf8').catch(() => '{}'));
120
+ }
121
+ await writeFile(`${outfile}.debug.json`, JSON.stringify({
122
+ ...existing,
123
+ ...debugData,
124
+ }, null, 2));
125
+ }
126
+ catch (error) {
127
+ console.warn('Failed to write debug file:', error);
128
+ }
129
+ }
130
+ /**
131
+ * Logs and optionally throws on esbuild errors and warnings.
132
+ * @param throwOnError - If true, throws an error when esbuild errors are present
133
+ */
134
+ logEsbuildMessages(result, phase, throwOnError = true) {
135
+ if (result.errors && result.errors.length > 0) {
136
+ console.error(`❌ esbuild errors in ${phase}:`);
137
+ const errorMessages = [];
138
+ for (const error of result.errors) {
139
+ console.error(` ${error.text}`);
140
+ errorMessages.push(error.text);
141
+ if (error.location) {
142
+ const location = ` at ${error.location.file}:${error.location.line}:${error.location.column}`;
143
+ console.error(location);
144
+ errorMessages.push(location);
145
+ }
146
+ }
147
+ if (throwOnError) {
148
+ throw new Error(`Build failed during ${phase}:\n${errorMessages.join('\n')}`);
149
+ }
150
+ }
151
+ if (result.warnings && result.warnings.length > 0) {
152
+ console.warn(`! esbuild warnings in ${phase}:`);
153
+ for (const warning of result.warnings) {
154
+ console.warn(` ${warning.text}`);
155
+ if (warning.location) {
156
+ console.warn(` at ${warning.location.file}:${warning.location.line}:${warning.location.column}`);
157
+ }
158
+ }
159
+ }
160
+ }
161
+ /**
162
+ * Creates a bundle for workflow step functions.
163
+ * Steps have full Node.js runtime access and handle side effects, API calls, etc.
164
+ *
165
+ * @param externalizeNonSteps - If true, only bundles step entry points and externalizes other code
166
+ */
167
+ async createStepsBundle({ inputFiles, format = 'cjs', outfile, externalizeNonSteps, tsBaseUrl, tsPaths, }) {
168
+ // These need to handle watching for dev to scan for
169
+ // new entries and changes to existing ones
170
+ const { discoveredSteps: stepFiles } = await this.discoverEntries(inputFiles, dirname(outfile));
171
+ // log the step files for debugging
172
+ await this.writeDebugFile(outfile, { stepFiles });
173
+ const stepsBundleStart = Date.now();
174
+ const workflowManifest = {};
175
+ const builtInSteps = 'workflow/internal/builtins';
176
+ const resolvedBuiltInSteps = await enhancedResolve(dirname(outfile), 'workflow/internal/builtins').catch((err) => {
177
+ throw new Error([
178
+ chalk.red('Failed to resolve built-in steps sources.'),
179
+ `${chalk.yellow.bold('hint:')} run \`${chalk.cyan.italic('npm install workflow')}\` to resolve this issue.`,
180
+ '',
181
+ `Caused by: ${chalk.red(String(err))}`,
182
+ ].join('\n'));
183
+ });
184
+ // Create a virtual entry that imports all files. All step definitions
185
+ // will get registered thanks to the swc transform.
186
+ const imports = stepFiles.map((file) => `import '${file}';`).join('\n');
187
+ const entryContent = `
188
+ // Built in steps
189
+ import '${builtInSteps}';
190
+ // User steps
191
+ ${imports}
192
+ // API entrypoint
193
+ export { stepEntrypoint as POST } from 'workflow/runtime';`;
194
+ // Bundle with esbuild and our custom SWC plugin
195
+ const esbuildCtx = await esbuild.context({
196
+ banner: {
197
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
198
+ },
199
+ stdin: {
200
+ contents: entryContent,
201
+ resolveDir: this.config.workingDir,
202
+ sourcefile: 'virtual-entry.js',
203
+ loader: 'js',
204
+ },
205
+ outfile,
206
+ absWorkingDir: this.config.workingDir,
207
+ bundle: true,
208
+ format,
209
+ platform: 'node',
210
+ conditions: ['node'],
211
+ target: 'es2022',
212
+ write: true,
213
+ treeShaking: true,
214
+ keepNames: true,
215
+ minify: false,
216
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
217
+ // TODO: investigate proper source map support
218
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
219
+ plugins: [
220
+ createSwcPlugin({
221
+ mode: 'step',
222
+ entriesToBundle: externalizeNonSteps
223
+ ? [
224
+ ...stepFiles,
225
+ ...(resolvedBuiltInSteps ? [resolvedBuiltInSteps] : []),
226
+ ]
227
+ : undefined,
228
+ outdir: outfile ? dirname(outfile) : undefined,
229
+ tsBaseUrl,
230
+ tsPaths,
231
+ workflowManifest,
232
+ }),
233
+ ],
234
+ // Plugin should catch most things, but this lets users hard override
235
+ // if the plugin misses anything that should be externalized
236
+ external: this.config.externalPackages || [],
237
+ });
238
+ const stepsResult = await esbuildCtx.rebuild();
239
+ this.logEsbuildMessages(stepsResult, 'steps bundle creation');
240
+ console.log('Created steps bundle', `${Date.now() - stepsBundleStart}ms`);
241
+ const partialWorkflowManifest = {
242
+ steps: workflowManifest.steps,
243
+ };
244
+ // always write to debug file
245
+ await this.writeDebugFile(join(dirname(outfile), 'manifest'), partialWorkflowManifest, true);
246
+ // Create .gitignore in .swc directory
247
+ await this.createSwcGitignore();
248
+ if (this.config.watch) {
249
+ return esbuildCtx;
250
+ }
251
+ await esbuildCtx.dispose();
252
+ }
253
+ /**
254
+ * Creates a bundle for workflow orchestration functions.
255
+ * Workflows run in a sandboxed VM and coordinate step execution.
256
+ *
257
+ * @param bundleFinalOutput - If false, skips the final bundling step (used by Next.js)
258
+ */
259
+ async createWorkflowsBundle({ inputFiles, format = 'cjs', outfile, bundleFinalOutput = true, tsBaseUrl, tsPaths, }) {
260
+ const { discoveredWorkflows: workflowFiles } = await this.discoverEntries(inputFiles, dirname(outfile));
261
+ // log the workflow files for debugging
262
+ await this.writeDebugFile(outfile, { workflowFiles });
263
+ // Create a virtual entry that imports all files
264
+ const imports = `globalThis.__private_workflows = new Map();\n` +
265
+ workflowFiles
266
+ .map((file, workflowFileIdx) => `import * as workflowFile${workflowFileIdx} from '${file}';
267
+ Object.values(workflowFile${workflowFileIdx}).map(item => item?.workflowId && globalThis.__private_workflows.set(item.workflowId, item))`)
268
+ .join('\n');
269
+ const bundleStartTime = Date.now();
270
+ const workflowManifest = {};
271
+ // Bundle with esbuild and our custom SWC plugin in workflow mode.
272
+ // this bundle will be run inside a vm isolate
273
+ const interimBundleCtx = await esbuild.context({
274
+ stdin: {
275
+ contents: imports,
276
+ resolveDir: this.config.workingDir,
277
+ sourcefile: 'virtual-entry.js',
278
+ loader: 'js',
279
+ },
280
+ bundle: true,
281
+ absWorkingDir: this.config.workingDir,
282
+ format: 'cjs', // Runs inside the VM which expects cjs
283
+ platform: 'neutral', // The platform is neither node nor browser
284
+ mainFields: ['module', 'main'], // To support npm style imports
285
+ conditions: ['workflow'], // Allow packages to export 'workflow' compliant versions
286
+ target: 'es2022',
287
+ write: false,
288
+ treeShaking: true,
289
+ keepNames: true,
290
+ minify: false,
291
+ // TODO: investigate proper source map support
292
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
293
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
294
+ plugins: [
295
+ createSwcPlugin({
296
+ mode: 'workflow',
297
+ tsBaseUrl,
298
+ tsPaths,
299
+ workflowManifest,
300
+ }),
301
+ // This plugin must run after the swc plugin to ensure dead code elimination
302
+ // happens first, preventing false positives on Node.js imports in unused code paths
303
+ createNodeModuleErrorPlugin(),
304
+ ],
305
+ });
306
+ const interimBundle = await interimBundleCtx.rebuild();
307
+ this.logEsbuildMessages(interimBundle, 'intermediate workflow bundle');
308
+ console.log('Created intermediate workflow bundle', `${Date.now() - bundleStartTime}ms`);
309
+ const partialWorkflowManifest = {
310
+ workflows: workflowManifest.workflows,
311
+ };
312
+ await this.writeDebugFile(join(dirname(outfile), 'manifest'), partialWorkflowManifest, true);
313
+ if (this.config.workflowManifestPath) {
314
+ const resolvedPath = resolve(process.cwd(), this.config.workflowManifestPath);
315
+ let prefix = '';
316
+ if (resolvedPath.endsWith('.cjs')) {
317
+ prefix = 'module.exports = ';
318
+ }
319
+ else if (resolvedPath.endsWith('.js') ||
320
+ resolvedPath.endsWith('.mjs')) {
321
+ prefix = 'export default ';
322
+ }
323
+ await mkdir(dirname(resolvedPath), { recursive: true });
324
+ await writeFile(resolvedPath, prefix + JSON.stringify(workflowManifest.workflows, null, 2));
325
+ }
326
+ // Create .gitignore in .swc directory
327
+ await this.createSwcGitignore();
328
+ if (!interimBundle.outputFiles || interimBundle.outputFiles.length === 0) {
329
+ throw new Error('No output files generated from esbuild');
330
+ }
331
+ const bundleFinal = async (interimBundle) => {
332
+ const workflowBundleCode = interimBundle;
333
+ const workflowFunctionCode = `// biome-ignore-all lint: generated file
334
+ /* eslint-disable */
335
+ import { workflowEntrypoint } from 'workflow/runtime';
336
+
337
+ const workflowCode = \`${workflowBundleCode.replace(/[\\`$]/g, '\\$&')}\`;
338
+
339
+ export const POST = workflowEntrypoint(workflowCode);`;
340
+ // we skip the final bundling step for Next.js so it can bundle itself
341
+ if (!bundleFinalOutput) {
342
+ if (!outfile) {
343
+ throw new Error(`Invariant: missing outfile for workflow bundle`);
344
+ }
345
+ // Ensure the output directory exists
346
+ const outputDir = dirname(outfile);
347
+ await mkdir(outputDir, { recursive: true });
348
+ await writeFile(outfile, workflowFunctionCode);
349
+ return;
350
+ }
351
+ const bundleStartTime = Date.now();
352
+ // Now bundle this so we can resolve the @workflow/core dependency
353
+ // we could remove this if we do nft tracing or similar instead
354
+ const finalWorkflowResult = await esbuild.build({
355
+ banner: {
356
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
357
+ },
358
+ stdin: {
359
+ contents: workflowFunctionCode,
360
+ resolveDir: this.config.workingDir,
361
+ sourcefile: 'virtual-entry.js',
362
+ loader: 'js',
363
+ },
364
+ outfile,
365
+ // TODO: investigate proper source map support
366
+ sourcemap: EMIT_SOURCEMAPS_FOR_DEBUGGING,
367
+ absWorkingDir: this.config.workingDir,
368
+ bundle: true,
369
+ format,
370
+ platform: 'node',
371
+ target: 'es2022',
372
+ write: true,
373
+ keepNames: true,
374
+ minify: false,
375
+ external: ['@aws-sdk/credential-provider-web-identity'],
376
+ });
377
+ this.logEsbuildMessages(finalWorkflowResult, 'final workflow bundle');
378
+ console.log('Created final workflow bundle', `${Date.now() - bundleStartTime}ms`);
379
+ };
380
+ await bundleFinal(interimBundle.outputFiles[0].text);
381
+ if (this.config.watch) {
382
+ return {
383
+ interimBundleCtx,
384
+ bundleFinal,
385
+ };
386
+ }
387
+ await interimBundleCtx.dispose();
388
+ }
389
+ /**
390
+ * Creates a client library bundle for workflow execution.
391
+ * The client library allows importing and calling workflows from application code.
392
+ * Only generated if clientBundlePath is specified in config.
393
+ */
394
+ async createClientLibrary() {
395
+ if (!this.config.clientBundlePath) {
396
+ // Silently exit since no client bundle was requested
397
+ return;
398
+ }
399
+ console.log('Generating a client library at', this.config.clientBundlePath);
400
+ console.log('NOTE: The recommended way to use workflow with a framework like NextJS is using the loader/plugin with webpack/turbobpack/rollup');
401
+ // Ensure we have the directory for the client bundle
402
+ const outputDir = dirname(this.config.clientBundlePath);
403
+ await mkdir(outputDir, { recursive: true });
404
+ const inputFiles = await this.getInputFiles();
405
+ // Create a virtual entry that imports all files
406
+ const imports = inputFiles
407
+ .map((file) => `export * from '${file}';`)
408
+ .join('\n');
409
+ // Bundle with esbuild and our custom SWC plugin
410
+ const clientResult = await esbuild.build({
411
+ banner: {
412
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
413
+ },
414
+ stdin: {
415
+ contents: imports,
416
+ resolveDir: this.config.workingDir,
417
+ sourcefile: 'virtual-entry.js',
418
+ loader: 'js',
419
+ },
420
+ outfile: this.config.clientBundlePath,
421
+ bundle: true,
422
+ format: 'esm',
423
+ platform: 'node',
424
+ target: 'es2022',
425
+ write: true,
426
+ treeShaking: true,
427
+ external: ['@workflow/core'],
428
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
429
+ plugins: [createSwcPlugin({ mode: 'client' })],
430
+ });
431
+ this.logEsbuildMessages(clientResult, 'client library bundle');
432
+ // Create .gitignore in .swc directory
433
+ await this.createSwcGitignore();
434
+ }
435
+ /**
436
+ * Creates a webhook handler bundle for resuming workflows via HTTP callbacks.
437
+ *
438
+ * @param bundle - If true, bundles dependencies (needed for Build Output API)
439
+ */
440
+ async createWebhookBundle({ outfile, bundle = false, }) {
441
+ console.log('Creating webhook route');
442
+ await mkdir(dirname(outfile), { recursive: true });
443
+ // Create a static route that calls resumeWebhook
444
+ // This route works for both Next.js and Vercel Build Output API
445
+ const routeContent = `import { resumeWebhook } from 'workflow/api';
446
+
447
+ async function handler(request) {
448
+ const url = new URL(request.url);
449
+ // Extract token from pathname: /.well-known/workflow/v1/webhook/{token}
450
+ const pathParts = url.pathname.split('/');
451
+ const token = decodeURIComponent(pathParts[pathParts.length - 1]);
452
+
453
+ if (!token) {
454
+ return new Response('Missing token', { status: 400 });
455
+ }
456
+
457
+ try {
458
+ const response = await resumeWebhook(token, request);
459
+ return response;
460
+ } catch (error) {
461
+ // TODO: differentiate between invalid token and other errors
462
+ console.error('Error during resumeWebhook', error);
463
+ return new Response(null, { status: 404 });
464
+ }
465
+ }
466
+
467
+ export const GET = handler;
468
+ export const POST = handler;
469
+ export const PUT = handler;
470
+ export const PATCH = handler;
471
+ export const DELETE = handler;
472
+ export const HEAD = handler;
473
+ export const OPTIONS = handler;`;
474
+ if (!bundle) {
475
+ // For Next.js, just write the unbundled file
476
+ await writeFile(outfile, routeContent);
477
+ return;
478
+ }
479
+ // For Build Output API, bundle with esbuild to resolve imports
480
+ const webhookBundleStart = Date.now();
481
+ const result = await esbuild.build({
482
+ banner: {
483
+ js: '// biome-ignore-all lint: generated file\n/* eslint-disable */\n',
484
+ },
485
+ stdin: {
486
+ contents: routeContent,
487
+ resolveDir: this.config.workingDir,
488
+ sourcefile: 'webhook-route.js',
489
+ loader: 'js',
490
+ },
491
+ outfile,
492
+ absWorkingDir: this.config.workingDir,
493
+ bundle: true,
494
+ format: 'cjs',
495
+ platform: 'node',
496
+ conditions: ['import', 'module', 'node', 'default'],
497
+ target: 'es2022',
498
+ write: true,
499
+ treeShaking: true,
500
+ keepNames: true,
501
+ minify: false,
502
+ resolveExtensions: ['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs'],
503
+ sourcemap: false,
504
+ mainFields: ['module', 'main'],
505
+ // Don't externalize anything - bundle everything including workflow packages
506
+ external: [],
507
+ });
508
+ this.logEsbuildMessages(result, 'webhook bundle creation');
509
+ console.log('Created webhook bundle', `${Date.now() - webhookBundleStart}ms`);
510
+ }
511
+ /**
512
+ * Creates a package.json file with the specified module type.
513
+ */
514
+ async createPackageJson(dir, type) {
515
+ const packageJson = { type };
516
+ await writeFile(join(dir, 'package.json'), JSON.stringify(packageJson, null, 2));
517
+ }
518
+ /**
519
+ * Creates a .vc-config.json file for Vercel Build Output API functions.
520
+ */
521
+ async createVcConfig(dir, config) {
522
+ const vcConfig = {
523
+ runtime: config.runtime ?? 'nodejs22.x',
524
+ handler: config.handler ?? 'index.js',
525
+ launcherType: config.launcherType ?? 'Nodejs',
526
+ architecture: config.architecture ?? 'arm64',
527
+ shouldAddHelpers: config.shouldAddHelpers ?? true,
528
+ ...(config.shouldAddSourcemapSupport !== undefined && {
529
+ shouldAddSourcemapSupport: config.shouldAddSourcemapSupport,
530
+ }),
531
+ ...(config.experimentalTriggers && {
532
+ experimentalTriggers: config.experimentalTriggers,
533
+ }),
534
+ };
535
+ await writeFile(join(dir, '.vc-config.json'), JSON.stringify(vcConfig, null, 2));
536
+ }
537
+ /**
538
+ * Resolves a path relative to the working directory.
539
+ */
540
+ resolvePath(path) {
541
+ return resolve(this.config.workingDir, path);
542
+ }
543
+ /**
544
+ * Ensures the directory for a file path exists, creating it if necessary.
545
+ */
546
+ async ensureDirectory(filePath) {
547
+ await mkdir(dirname(filePath), { recursive: true });
548
+ }
549
+ async createSwcGitignore() {
550
+ try {
551
+ await writeFile(join(this.config.workingDir, '.swc', '.gitignore'), '*\n');
552
+ }
553
+ catch {
554
+ // We're intentionally silently ignoring this error - creating .gitignore isn't critical
555
+ }
556
+ }
557
+ }
558
+ //# 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,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,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,CAA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,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"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Queue trigger configuration for workflow step execution.
3
+ * Steps are queued to the __wkf_step_* topic.
4
+ */
5
+ export declare const STEP_QUEUE_TRIGGER: {
6
+ type: "queue/v1beta";
7
+ topic: string;
8
+ consumer: string;
9
+ maxDeliveries: number;
10
+ retryAfterSeconds: number;
11
+ initialDelaySeconds: number;
12
+ };
13
+ /**
14
+ * Queue trigger configuration for workflow orchestration.
15
+ * Workflows are queued to the __wkf_workflow_* topic.
16
+ */
17
+ export declare const WORKFLOW_QUEUE_TRIGGER: {
18
+ type: "queue/v1beta";
19
+ topic: string;
20
+ consumer: string;
21
+ maxDeliveries: number;
22
+ retryAfterSeconds: number;
23
+ initialDelaySeconds: number;
24
+ };
25
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;CAO9B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC"}