@workflow/sveltekit 5.0.0-beta.4 → 5.0.0-beta.6
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/builder.d.ts +0 -2
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +27 -59
- package/dist/builder.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -28
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +10 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +2 -2
- package/dist/plugin.js.map +1 -1
- package/dist/vc-config.d.ts +3 -0
- package/dist/vc-config.d.ts.map +1 -0
- package/dist/vc-config.js +40 -0
- package/dist/vc-config.js.map +1 -0
- package/package.json +5 -5
package/dist/builder.d.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { BaseBuilder, type SvelteKitConfig } from '@workflow/builders';
|
|
|
2
2
|
export declare class SvelteKitBuilder extends BaseBuilder {
|
|
3
3
|
constructor(config?: Partial<SvelteKitConfig>);
|
|
4
4
|
build(): Promise<void>;
|
|
5
|
-
private buildStepsRoute;
|
|
6
|
-
private buildWorkflowsRoute;
|
|
7
5
|
private buildWebhookRoute;
|
|
8
6
|
private findRoutesDirectory;
|
|
9
7
|
}
|
package/dist/builder.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,WAAW,EAEX,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAS5B,qBAAa,gBAAiB,SAAQ,WAAW;gBACnC,MAAM,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC;IAgB9B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YA6EvB,iBAAiB;YAqDjB,mBAAmB;CA8BlC"}
|
package/dist/builder.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { constants } from 'node:fs';
|
|
2
|
-
import { access, copyFile, mkdir, readFile, stat, writeFile, } from 'node:fs/promises';
|
|
2
|
+
import { access, copyFile, mkdir, readFile, rm, stat, writeFile, } from 'node:fs/promises';
|
|
3
3
|
import { join, resolve } from 'node:path';
|
|
4
4
|
import { BaseBuilder, NORMALIZE_REQUEST_CODE, } from '@workflow/builders';
|
|
5
5
|
const SVELTEKIT_VIRTUAL_MODULES = [
|
|
@@ -20,6 +20,7 @@ export class SvelteKitBuilder extends BaseBuilder {
|
|
|
20
20
|
webhookBundlePath: '', // unused in base
|
|
21
21
|
workingDir,
|
|
22
22
|
externalPackages: [...SVELTEKIT_VIRTUAL_MODULES],
|
|
23
|
+
sourcemap: config?.sourcemap,
|
|
23
24
|
});
|
|
24
25
|
}
|
|
25
26
|
async build() {
|
|
@@ -32,24 +33,37 @@ export class SvelteKitBuilder extends BaseBuilder {
|
|
|
32
33
|
if (process.env.VERCEL_DEPLOYMENT_ID === undefined) {
|
|
33
34
|
await writeFile(join(workflowGeneratedDir, '.gitignore'), '*');
|
|
34
35
|
}
|
|
36
|
+
// Clean up stale V1 step route directory (may persist via Vercel build cache)
|
|
37
|
+
await rm(join(workflowGeneratedDir, 'step'), {
|
|
38
|
+
recursive: true,
|
|
39
|
+
force: true,
|
|
40
|
+
});
|
|
35
41
|
// Get workflow and step files to bundle
|
|
36
42
|
const inputFiles = await this.getInputFiles();
|
|
37
43
|
const tsconfigPath = await this.findTsConfigPath();
|
|
38
|
-
|
|
44
|
+
// Create combined bundle for flow route
|
|
45
|
+
const flowRouteDir = join(workflowGeneratedDir, 'flow');
|
|
46
|
+
await mkdir(flowRouteDir, { recursive: true });
|
|
47
|
+
const { manifest } = await this.createCombinedBundle({
|
|
39
48
|
inputFiles,
|
|
40
|
-
|
|
49
|
+
stepsOutfile: join(flowRouteDir, '__step_registrations.js'),
|
|
50
|
+
flowOutfile: join(flowRouteDir, '+server.js'),
|
|
51
|
+
format: 'esm',
|
|
52
|
+
bundleFinalOutput: false,
|
|
53
|
+
externalizeNonSteps: true,
|
|
41
54
|
tsconfigPath,
|
|
42
|
-
};
|
|
43
|
-
//
|
|
44
|
-
const
|
|
45
|
-
|
|
55
|
+
});
|
|
56
|
+
// Post-process the generated file to wrap with SvelteKit request converter
|
|
57
|
+
const workflowsRouteFile = join(flowRouteDir, '+server.js');
|
|
58
|
+
let workflowsRouteContent = await readFile(workflowsRouteFile, 'utf-8');
|
|
59
|
+
// Replace the default export with SvelteKit-compatible handler
|
|
60
|
+
workflowsRouteContent = workflowsRouteContent.replace(/export const POST = workflowEntrypoint\(workflowCode\);?$/m, `${NORMALIZE_REQUEST_CODE}
|
|
61
|
+
export const POST = async ({request}) => {
|
|
62
|
+
const normalRequest = await normalizeRequest(request);
|
|
63
|
+
return workflowEntrypoint(workflowCode)(normalRequest);
|
|
64
|
+
}`);
|
|
65
|
+
await writeFile(workflowsRouteFile, workflowsRouteContent);
|
|
46
66
|
await this.buildWebhookRoute({ workflowGeneratedDir });
|
|
47
|
-
// Merge manifests from both bundles
|
|
48
|
-
const manifest = {
|
|
49
|
-
steps: { ...stepsManifest.steps, ...workflowsManifest.steps },
|
|
50
|
-
workflows: { ...stepsManifest.workflows, ...workflowsManifest.workflows },
|
|
51
|
-
classes: { ...stepsManifest.classes, ...workflowsManifest.classes },
|
|
52
|
-
};
|
|
53
67
|
// Generate unified manifest
|
|
54
68
|
const workflowBundlePath = join(workflowGeneratedDir, 'flow/+server.js');
|
|
55
69
|
const manifestJson = await this.createManifest({
|
|
@@ -65,52 +79,6 @@ export class SvelteKitBuilder extends BaseBuilder {
|
|
|
65
79
|
await copyFile(join(workflowGeneratedDir, 'manifest.json'), join(staticManifestDir, 'manifest.json'));
|
|
66
80
|
}
|
|
67
81
|
}
|
|
68
|
-
async buildStepsRoute({ inputFiles, workflowGeneratedDir, tsconfigPath, }) {
|
|
69
|
-
// Create steps route: .well-known/workflow/v1/step/+server.js
|
|
70
|
-
const stepsRouteDir = join(workflowGeneratedDir, 'step');
|
|
71
|
-
await mkdir(stepsRouteDir, { recursive: true });
|
|
72
|
-
const { manifest } = await this.createStepsBundle({
|
|
73
|
-
format: 'esm',
|
|
74
|
-
inputFiles,
|
|
75
|
-
outfile: join(stepsRouteDir, '+server.js'),
|
|
76
|
-
externalizeNonSteps: true,
|
|
77
|
-
tsconfigPath,
|
|
78
|
-
});
|
|
79
|
-
// Post-process the generated file to wrap with SvelteKit request converter
|
|
80
|
-
const stepsRouteFile = join(stepsRouteDir, '+server.js');
|
|
81
|
-
let stepsRouteContent = await readFile(stepsRouteFile, 'utf-8');
|
|
82
|
-
// Replace the default export with SvelteKit-compatible handler
|
|
83
|
-
stepsRouteContent = stepsRouteContent.replace(/export\s*\{\s*stepEntrypoint\s+as\s+POST\s*\}\s*;?$/m, `${NORMALIZE_REQUEST_CODE}
|
|
84
|
-
export const POST = async ({request}) => {
|
|
85
|
-
const normalRequest = await normalizeRequest(request);
|
|
86
|
-
return stepEntrypoint(normalRequest);
|
|
87
|
-
}`);
|
|
88
|
-
await writeFile(stepsRouteFile, stepsRouteContent);
|
|
89
|
-
return manifest;
|
|
90
|
-
}
|
|
91
|
-
async buildWorkflowsRoute({ inputFiles, workflowGeneratedDir, tsconfigPath, }) {
|
|
92
|
-
// Create workflows route: .well-known/workflow/v1/flow/+server.js
|
|
93
|
-
const workflowsRouteDir = join(workflowGeneratedDir, 'flow');
|
|
94
|
-
await mkdir(workflowsRouteDir, { recursive: true });
|
|
95
|
-
const { manifest } = await this.createWorkflowsBundle({
|
|
96
|
-
format: 'esm',
|
|
97
|
-
outfile: join(workflowsRouteDir, '+server.js'),
|
|
98
|
-
bundleFinalOutput: false,
|
|
99
|
-
inputFiles,
|
|
100
|
-
tsconfigPath,
|
|
101
|
-
});
|
|
102
|
-
// Post-process the generated file to wrap with SvelteKit request converter
|
|
103
|
-
const workflowsRouteFile = join(workflowsRouteDir, '+server.js');
|
|
104
|
-
let workflowsRouteContent = await readFile(workflowsRouteFile, 'utf-8');
|
|
105
|
-
// Replace the default export with SvelteKit-compatible handler
|
|
106
|
-
workflowsRouteContent = workflowsRouteContent.replace(/export const POST = workflowEntrypoint\(workflowCode\);?$/m, `${NORMALIZE_REQUEST_CODE}
|
|
107
|
-
export const POST = async ({request}) => {
|
|
108
|
-
const normalRequest = await normalizeRequest(request);
|
|
109
|
-
return workflowEntrypoint(workflowCode)(normalRequest);
|
|
110
|
-
}`);
|
|
111
|
-
await writeFile(workflowsRouteFile, workflowsRouteContent);
|
|
112
|
-
return manifest;
|
|
113
|
-
}
|
|
114
82
|
async buildWebhookRoute({ workflowGeneratedDir, }) {
|
|
115
83
|
// Create webhook route: .well-known/workflow/v1/webhook/[token]/+server.js
|
|
116
84
|
const webhookRouteFile = join(workflowGeneratedDir, 'webhook/[token]/+server.js');
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,EACJ,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,WAAW,EACX,sBAAsB,GAEvB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,yBAAyB,GAAG;IAChC,QAAQ,EAAE,oBAAoB;IAC9B,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,oBAAoB;IAC9B,QAAQ,EAAE,oBAAoB;CAC/B,CAAC;AAEF,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,MAAiC;QAC3C,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,OAAO,CAAC,GAAG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MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;YAC1C,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,uCAAuC,SAAS,EAAE,CAAC,CAAC;YACtE,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;YACzB,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CACb,uCAAuC,aAAa,EAAE,CACvD,CAAC;gBACJ,CAAC;gBACD,OAAO,aAAa,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { constants } from 'node:fs';\nimport {\n access,\n copyFile,\n mkdir,\n readFile,\n stat,\n writeFile,\n} from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport {\n BaseBuilder,\n NORMALIZE_REQUEST_CODE,\n type SvelteKitConfig,\n} from '@workflow/builders';\n\nconst SVELTEKIT_VIRTUAL_MODULES = [\n '$env/*', // All $env subpaths\n '$lib', // Exact $lib import\n '$lib/*', // All $lib subpaths\n '$app/*', // All $app subpaths\n];\n\nexport class SvelteKitBuilder extends BaseBuilder {\n constructor(config?: Partial<SvelteKitConfig>) {\n const workingDir = config?.workingDir || process.cwd();\n\n super({\n ...config,\n dirs: ['workflows', 'src/workflows', 'routes', 'src/routes'],\n buildTarget: 'sveltekit' as const,\n stepsBundlePath: '', // unused in base\n workflowsBundlePath: '', // unused in base\n webhookBundlePath: '', // unused in base\n workingDir,\n externalPackages: [...SVELTEKIT_VIRTUAL_MODULES],\n });\n }\n\n override async build(): Promise<void> {\n // Find SvelteKit routes directory (src/routes or routes)\n const routesDir = await this.findRoutesDirectory();\n const workflowGeneratedDir = join(routesDir, '.well-known/workflow/v1');\n\n // Ensure output directories exist\n await mkdir(workflowGeneratedDir, { recursive: true });\n\n // Add .gitignore to exclude generated files from version control\n if (process.env.VERCEL_DEPLOYMENT_ID === undefined) {\n await writeFile(join(workflowGeneratedDir, '.gitignore'), '*');\n }\n\n // Get workflow and step files to bundle\n const inputFiles = await this.getInputFiles();\n const tsconfigPath = await this.findTsConfigPath();\n\n const options = {\n inputFiles,\n workflowGeneratedDir,\n tsconfigPath,\n };\n\n // Generate the three SvelteKit route handlers\n const stepsManifest = await this.buildStepsRoute(options);\n const workflowsManifest = await this.buildWorkflowsRoute(options);\n await this.buildWebhookRoute({ workflowGeneratedDir });\n\n // Merge manifests from both bundles\n const manifest = {\n steps: { ...stepsManifest.steps, ...workflowsManifest.steps },\n workflows: { ...stepsManifest.workflows, ...workflowsManifest.workflows },\n classes: { ...stepsManifest.classes, ...workflowsManifest.classes },\n };\n\n // Generate unified manifest\n const workflowBundlePath = join(workflowGeneratedDir, 'flow/+server.js');\n const manifestJson = await this.createManifest({\n workflowBundlePath,\n manifestDir: workflowGeneratedDir,\n manifest,\n });\n\n // Expose manifest as a static file when WORKFLOW_PUBLIC_MANIFEST=1.\n // SvelteKit serves files from static/ at the root URL.\n if (this.shouldExposePublicManifest && manifestJson) {\n const staticManifestDir = join(\n this.config.workingDir,\n 'static/.well-known/workflow/v1'\n );\n await mkdir(staticManifestDir, { recursive: true });\n await copyFile(\n join(workflowGeneratedDir, 'manifest.json'),\n join(staticManifestDir, 'manifest.json')\n );\n }\n }\n\n private async buildStepsRoute({\n inputFiles,\n workflowGeneratedDir,\n tsconfigPath,\n }: {\n inputFiles: string[];\n workflowGeneratedDir: string;\n tsconfigPath?: string;\n }) {\n // Create steps route: .well-known/workflow/v1/step/+server.js\n const stepsRouteDir = join(workflowGeneratedDir, 'step');\n await mkdir(stepsRouteDir, { recursive: true });\n\n const { manifest } = await this.createStepsBundle({\n format: 'esm',\n inputFiles,\n outfile: join(stepsRouteDir, '+server.js'),\n externalizeNonSteps: true,\n tsconfigPath,\n });\n\n // Post-process the generated file to wrap with SvelteKit request converter\n const stepsRouteFile = join(stepsRouteDir, '+server.js');\n let stepsRouteContent = await readFile(stepsRouteFile, 'utf-8');\n\n // Replace the default export with SvelteKit-compatible handler\n stepsRouteContent = stepsRouteContent.replace(\n /export\\s*\\{\\s*stepEntrypoint\\s+as\\s+POST\\s*\\}\\s*;?$/m,\n `${NORMALIZE_REQUEST_CODE}\nexport const POST = async ({request}) => {\n const normalRequest = await normalizeRequest(request);\n return stepEntrypoint(normalRequest);\n}`\n );\n\n await writeFile(stepsRouteFile, stepsRouteContent);\n return manifest;\n }\n\n private async buildWorkflowsRoute({\n inputFiles,\n workflowGeneratedDir,\n tsconfigPath,\n }: {\n inputFiles: string[];\n workflowGeneratedDir: string;\n tsconfigPath?: string;\n }) {\n // Create workflows route: .well-known/workflow/v1/flow/+server.js\n const workflowsRouteDir = join(workflowGeneratedDir, 'flow');\n await mkdir(workflowsRouteDir, { recursive: true });\n\n const { manifest } = await this.createWorkflowsBundle({\n format: 'esm',\n outfile: join(workflowsRouteDir, '+server.js'),\n bundleFinalOutput: false,\n inputFiles,\n tsconfigPath,\n });\n\n // Post-process the generated file to wrap with SvelteKit request converter\n const workflowsRouteFile = join(workflowsRouteDir, '+server.js');\n let workflowsRouteContent = await readFile(workflowsRouteFile, 'utf-8');\n\n // Replace the default export with SvelteKit-compatible handler\n workflowsRouteContent = workflowsRouteContent.replace(\n /export const POST = workflowEntrypoint\\(workflowCode\\);?$/m,\n `${NORMALIZE_REQUEST_CODE}\nexport const POST = async ({request}) => {\n const normalRequest = await normalizeRequest(request);\n return workflowEntrypoint(workflowCode)(normalRequest);\n}`\n );\n await writeFile(workflowsRouteFile, workflowsRouteContent);\n\n return manifest;\n }\n\n private async buildWebhookRoute({\n workflowGeneratedDir,\n }: {\n workflowGeneratedDir: string;\n }) {\n // Create webhook route: .well-known/workflow/v1/webhook/[token]/+server.js\n const webhookRouteFile = join(\n workflowGeneratedDir,\n 'webhook/[token]/+server.js'\n );\n\n await this.createWebhookBundle({\n outfile: webhookRouteFile,\n bundle: false, // SvelteKit will handle bundling\n });\n\n // Post-process the generated file to wrap with SvelteKit request converter\n let webhookRouteContent = await readFile(webhookRouteFile, 'utf-8');\n\n // Update handler signature to accept token as parameter\n webhookRouteContent = webhookRouteContent.replace(\n /async function handler\\(request\\) \\{[\\s\\S]*?const token = decodeURIComponent\\(pathParts\\[pathParts\\.length - 1\\]\\);/,\n `async function handler(request, token) {`\n );\n\n // Remove the URL parsing code since we get token from params\n webhookRouteContent = webhookRouteContent.replace(\n /const url = new URL\\(request\\.url\\);[\\s\\S]*?const pathParts = url\\.pathname\\.split\\('\\/'\\);[\\s\\S]*?\\n/,\n ''\n );\n\n // Replace all HTTP method exports with SvelteKit-compatible handlers\n webhookRouteContent = webhookRouteContent.replace(\n /export const GET = handler;\\nexport const POST = handler;\\nexport const PUT = handler;\\nexport const PATCH = handler;\\nexport const DELETE = handler;\\nexport const HEAD = handler;\\nexport const OPTIONS = handler;/,\n `${NORMALIZE_REQUEST_CODE}\nconst createSvelteKitHandler = (method) => async ({ request, params, platform }) => {\n const normalRequest = await normalizeRequest(request);\n const response = await handler(normalRequest, params.token);\n return response;\n};\n\nexport const GET = createSvelteKitHandler('GET');\nexport const POST = createSvelteKitHandler('POST');\nexport const PUT = createSvelteKitHandler('PUT');\nexport const PATCH = createSvelteKitHandler('PATCH');\nexport const DELETE = createSvelteKitHandler('DELETE');\nexport const HEAD = createSvelteKitHandler('HEAD');\nexport const OPTIONS = createSvelteKitHandler('OPTIONS');`\n );\n\n await writeFile(webhookRouteFile, webhookRouteContent);\n }\n\n private async findRoutesDirectory(): Promise<string> {\n const routesDir = resolve(this.config.workingDir, 'src/routes');\n const rootRoutesDir = resolve(this.config.workingDir, 'routes');\n\n // Try src/routes first (standard SvelteKit convention)\n try {\n await access(routesDir, constants.F_OK);\n const routesStats = await stat(routesDir);\n if (!routesStats.isDirectory()) {\n throw new Error(`Path exists but is not a directory: ${routesDir}`);\n }\n return routesDir;\n } catch {\n // Try routes as fallback\n try {\n await access(rootRoutesDir, constants.F_OK);\n const rootRoutesStats = await stat(rootRoutesDir);\n if (!rootRoutesStats.isDirectory()) {\n throw new Error(\n `Path exists but is not a directory: ${rootRoutesDir}`\n );\n }\n return rootRoutesDir;\n } catch {\n throw new Error(\n 'Could not find SvelteKit routes directory. Expected either \"src/routes\" or \"routes\" to exist.'\n );\n }\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,EAAE,EACF,IAAI,EACJ,SAAS,GACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EACL,WAAW,EACX,sBAAsB,GAEvB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,yBAAyB,GAAG;IAChC,QAAQ,EAAE,oBAAoB;IAC9B,MAAM,EAAE,oBAAoB;IAC5B,QAAQ,EAAE,oBAAoB;IAC9B,QAAQ,EAAE,oBAAoB;CAC/B,CAAC;AAEF,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IAC/C,YAAY,MAAiC;QAC3C,MAAM,UAAU,GAAG,MAAM,EAAE,UAAU,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAEvD,KAAK,CAAC;YACJ,GAAG,MAAM;YACT,IAAI,EAAE,CAAC,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC;YAC5D,WAAW,EAAE,WAAoB;YACjC,eAAe,EAAE,EAAE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YACtE,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,yBAAyB;YACzB,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,aAAa,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;gBAC5C,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC;gBAClD,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC;oBACnC,MAAM,IAAI,KAAK,CACb,uCAAuC,aAAa,EAAE,CACvD,CAAC;gBACJ,CAAC;gBACD,OAAO,aAAa,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CACb,+FAA+F,CAChG,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { constants } from 'node:fs';\nimport {\n access,\n copyFile,\n mkdir,\n readFile,\n rm,\n stat,\n writeFile,\n} from 'node:fs/promises';\nimport { join, resolve } from 'node:path';\nimport {\n BaseBuilder,\n NORMALIZE_REQUEST_CODE,\n type SvelteKitConfig,\n} from '@workflow/builders';\n\nconst SVELTEKIT_VIRTUAL_MODULES = [\n '$env/*', // All $env subpaths\n '$lib', // Exact $lib import\n '$lib/*', // All $lib subpaths\n '$app/*', // All $app subpaths\n];\n\nexport class SvelteKitBuilder extends BaseBuilder {\n constructor(config?: Partial<SvelteKitConfig>) {\n const workingDir = config?.workingDir || process.cwd();\n\n super({\n ...config,\n dirs: ['workflows', 'src/workflows', 'routes', 'src/routes'],\n buildTarget: 'sveltekit' as const,\n stepsBundlePath: '', // unused in base\n workflowsBundlePath: '', // unused in base\n webhookBundlePath: '', // unused in base\n workingDir,\n externalPackages: [...SVELTEKIT_VIRTUAL_MODULES],\n sourcemap: config?.sourcemap,\n });\n }\n\n override async build(): Promise<void> {\n // Find SvelteKit routes directory (src/routes or routes)\n const routesDir = await this.findRoutesDirectory();\n const workflowGeneratedDir = join(routesDir, '.well-known/workflow/v1');\n\n // Ensure output directories exist\n await mkdir(workflowGeneratedDir, { recursive: true });\n\n // Add .gitignore to exclude generated files from version control\n if (process.env.VERCEL_DEPLOYMENT_ID === undefined) {\n await writeFile(join(workflowGeneratedDir, '.gitignore'), '*');\n }\n\n // Clean up stale V1 step route directory (may persist via Vercel build cache)\n await rm(join(workflowGeneratedDir, 'step'), {\n recursive: true,\n force: true,\n });\n\n // Get workflow and step files to bundle\n const inputFiles = await this.getInputFiles();\n const tsconfigPath = await this.findTsConfigPath();\n\n // Create combined bundle for flow route\n const flowRouteDir = join(workflowGeneratedDir, 'flow');\n await mkdir(flowRouteDir, { recursive: true });\n\n const { manifest } = await this.createCombinedBundle({\n inputFiles,\n stepsOutfile: join(flowRouteDir, '__step_registrations.js'),\n flowOutfile: join(flowRouteDir, '+server.js'),\n format: 'esm',\n bundleFinalOutput: false,\n externalizeNonSteps: true,\n tsconfigPath,\n });\n\n // Post-process the generated file to wrap with SvelteKit request converter\n const workflowsRouteFile = join(flowRouteDir, '+server.js');\n let workflowsRouteContent = await readFile(workflowsRouteFile, 'utf-8');\n\n // Replace the default export with SvelteKit-compatible handler\n workflowsRouteContent = workflowsRouteContent.replace(\n /export const POST = workflowEntrypoint\\(workflowCode\\);?$/m,\n `${NORMALIZE_REQUEST_CODE}\nexport const POST = async ({request}) => {\n const normalRequest = await normalizeRequest(request);\n return workflowEntrypoint(workflowCode)(normalRequest);\n}`\n );\n await writeFile(workflowsRouteFile, workflowsRouteContent);\n\n await this.buildWebhookRoute({ workflowGeneratedDir });\n\n // Generate unified manifest\n const workflowBundlePath = join(workflowGeneratedDir, 'flow/+server.js');\n const manifestJson = await this.createManifest({\n workflowBundlePath,\n manifestDir: workflowGeneratedDir,\n manifest,\n });\n\n // Expose manifest as a static file when WORKFLOW_PUBLIC_MANIFEST=1.\n // SvelteKit serves files from static/ at the root URL.\n if (this.shouldExposePublicManifest && manifestJson) {\n const staticManifestDir = join(\n this.config.workingDir,\n 'static/.well-known/workflow/v1'\n );\n await mkdir(staticManifestDir, { recursive: true });\n await copyFile(\n join(workflowGeneratedDir, 'manifest.json'),\n join(staticManifestDir, 'manifest.json')\n );\n }\n }\n\n private async buildWebhookRoute({\n workflowGeneratedDir,\n }: {\n workflowGeneratedDir: string;\n }) {\n // Create webhook route: .well-known/workflow/v1/webhook/[token]/+server.js\n const webhookRouteFile = join(\n workflowGeneratedDir,\n 'webhook/[token]/+server.js'\n );\n\n await this.createWebhookBundle({\n outfile: webhookRouteFile,\n bundle: false, // SvelteKit will handle bundling\n });\n\n // Post-process the generated file to wrap with SvelteKit request converter\n let webhookRouteContent = await readFile(webhookRouteFile, 'utf-8');\n\n // Update handler signature to accept token as parameter\n webhookRouteContent = webhookRouteContent.replace(\n /async function handler\\(request\\) \\{[\\s\\S]*?const token = decodeURIComponent\\(pathParts\\[pathParts\\.length - 1\\]\\);/,\n `async function handler(request, token) {`\n );\n\n // Remove the URL parsing code since we get token from params\n webhookRouteContent = webhookRouteContent.replace(\n /const url = new URL\\(request\\.url\\);[\\s\\S]*?const pathParts = url\\.pathname\\.split\\('\\/'\\);[\\s\\S]*?\\n/,\n ''\n );\n\n // Replace all HTTP method exports with SvelteKit-compatible handlers\n webhookRouteContent = webhookRouteContent.replace(\n /export const GET = handler;\\nexport const POST = handler;\\nexport const PUT = handler;\\nexport const PATCH = handler;\\nexport const DELETE = handler;\\nexport const HEAD = handler;\\nexport const OPTIONS = handler;/,\n `${NORMALIZE_REQUEST_CODE}\nconst createSvelteKitHandler = (method) => async ({ request, params, platform }) => {\n const normalRequest = await normalizeRequest(request);\n const response = await handler(normalRequest, params.token);\n return response;\n};\n\nexport const GET = createSvelteKitHandler('GET');\nexport const POST = createSvelteKitHandler('POST');\nexport const PUT = createSvelteKitHandler('PUT');\nexport const PATCH = createSvelteKitHandler('PATCH');\nexport const DELETE = createSvelteKitHandler('DELETE');\nexport const HEAD = createSvelteKitHandler('HEAD');\nexport const OPTIONS = createSvelteKitHandler('OPTIONS');`\n );\n\n await writeFile(webhookRouteFile, webhookRouteContent);\n }\n\n private async findRoutesDirectory(): Promise<string> {\n const routesDir = resolve(this.config.workingDir, 'src/routes');\n const rootRoutesDir = resolve(this.config.workingDir, 'routes');\n\n // Try src/routes first (standard SvelteKit convention)\n try {\n await access(routesDir, constants.F_OK);\n const routesStats = await stat(routesDir);\n if (!routesStats.isDirectory()) {\n throw new Error(`Path exists but is not a directory: ${routesDir}`);\n }\n return routesDir;\n } catch {\n // Try routes as fallback\n try {\n await access(rootRoutesDir, constants.F_OK);\n const rootRoutesStats = await stat(rootRoutesDir);\n if (!rootRoutesStats.isDirectory()) {\n throw new Error(\n `Path exists but is not a directory: ${rootRoutesDir}`\n );\n }\n return rootRoutesDir;\n } catch {\n throw new Error(\n 'Could not find SvelteKit routes directory. Expected either \"src/routes\" or \"routes\" to exist.'\n );\n }\n }\n }\n}\n"]}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAgEA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { WORKFLOW_QUEUE_TRIGGER } from '@workflow/builders';
|
|
2
3
|
import fs from 'fs-extra';
|
|
3
4
|
import { SvelteKitBuilder } from './builder.js';
|
|
5
|
+
import { stripWorkflowQueueTriggers } from './vc-config.js';
|
|
4
6
|
const builder = new SvelteKitBuilder();
|
|
5
7
|
// This needs to be in the top-level as we need to create these
|
|
6
8
|
// entries before svelte plugin is started or the entries are
|
|
@@ -11,45 +13,29 @@ process.on('beforeExit', () => {
|
|
|
11
13
|
if (!process.env.VERCEL_DEPLOYMENT_ID) {
|
|
12
14
|
return;
|
|
13
15
|
}
|
|
16
|
+
// V2: Only the combined flow handler needs queue triggers.
|
|
17
|
+
// The separate step route was removed.
|
|
14
18
|
for (const { file, config } of [
|
|
15
19
|
{
|
|
16
20
|
file: '.vercel/output/functions/.well-known/workflow/v1/flow.func/.vc-config.json',
|
|
17
21
|
config: {
|
|
18
22
|
maxDuration: 'max',
|
|
19
|
-
experimentalTriggers: [
|
|
20
|
-
{
|
|
21
|
-
type: 'queue/v2beta',
|
|
22
|
-
topic: '__wkf_workflow_*',
|
|
23
|
-
consumer: 'default',
|
|
24
|
-
retryAfterSeconds: 5,
|
|
25
|
-
initialDelaySeconds: 0,
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
file: '.vercel/output/functions/.well-known/workflow/v1/step.func/.vc-config.json',
|
|
32
|
-
config: {
|
|
33
|
-
maxDuration: 'max',
|
|
34
|
-
experimentalTriggers: [
|
|
35
|
-
{
|
|
36
|
-
type: 'queue/v2beta',
|
|
37
|
-
topic: '__wkf_step_*',
|
|
38
|
-
consumer: 'default',
|
|
39
|
-
retryAfterSeconds: 5,
|
|
40
|
-
initialDelaySeconds: 0,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
23
|
+
experimentalTriggers: [WORKFLOW_QUEUE_TRIGGER],
|
|
43
24
|
},
|
|
44
25
|
},
|
|
45
26
|
]) {
|
|
27
|
+
const funcDir = path.dirname(file);
|
|
28
|
+
if (!fs.existsSync(funcDir)) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
46
31
|
// Un-symlink these as they can't be shared due to different
|
|
47
32
|
// experimental triggers config
|
|
48
|
-
const
|
|
49
|
-
fs.
|
|
50
|
-
fs.
|
|
33
|
+
const sourceFuncDir = path.join(funcDir.replace(/\.func$/, ''), '__data.json.func');
|
|
34
|
+
const toCopy = fs.readdirSync(funcDir);
|
|
35
|
+
fs.removeSync(funcDir);
|
|
36
|
+
fs.mkdirSync(funcDir, { recursive: true });
|
|
51
37
|
for (const item of toCopy) {
|
|
52
|
-
fs.copySync(path.join(
|
|
38
|
+
fs.copySync(path.join(sourceFuncDir, item), path.join(funcDir, item));
|
|
53
39
|
}
|
|
54
40
|
// Update .vc-config.json with the new experimental triggers config
|
|
55
41
|
const existingConfig = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
@@ -57,6 +43,9 @@ process.on('beforeExit', () => {
|
|
|
57
43
|
...existingConfig,
|
|
58
44
|
...config,
|
|
59
45
|
}));
|
|
46
|
+
// The source function may be a shared catchall. It must not keep stale
|
|
47
|
+
// workflow queue triggers after the dedicated function is copied out.
|
|
48
|
+
stripWorkflowQueueTriggers(path.join(sourceFuncDir, '.vc-config.json'));
|
|
60
49
|
}
|
|
61
50
|
});
|
|
62
51
|
export { workflowPlugin } from './plugin.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAE5D,MAAM,OAAO,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAEvC,+DAA+D;AAC/D,6DAA6D;AAC7D,uDAAuD;AACvD,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;AAEtB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;IAC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,GAAG,cAAc;YACjB,GAAG,MAAM;SACV,CAAC,CACH,CAAC;QAEF,uEAAuE;QACvE,sEAAsE;QACtE,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import path from 'node:path';\nimport { WORKFLOW_QUEUE_TRIGGER } from '@workflow/builders';\nimport fs from 'fs-extra';\n\nimport { SvelteKitBuilder } from './builder.js';\nimport { stripWorkflowQueueTriggers } from './vc-config.js';\n\nconst builder = new SvelteKitBuilder();\n\n// This needs to be in the top-level as we need to create these\n// entries before svelte plugin is started or the entries are\n// a race to be created before svelte discovers entries\nawait builder.build();\n\nprocess.on('beforeExit', () => {\n // Don't patch functions output if not in Vercel adapter\n if (!process.env.VERCEL_DEPLOYMENT_ID) {\n return;\n }\n // V2: Only the combined flow handler needs queue triggers.\n // The separate step route was removed.\n for (const { file, config } of [\n {\n file: '.vercel/output/functions/.well-known/workflow/v1/flow.func/.vc-config.json',\n config: {\n maxDuration: 'max',\n experimentalTriggers: [WORKFLOW_QUEUE_TRIGGER],\n },\n },\n ]) {\n const funcDir = path.dirname(file);\n if (!fs.existsSync(funcDir)) {\n continue;\n }\n // Un-symlink these as they can't be shared due to different\n // experimental triggers config\n const sourceFuncDir = path.join(\n funcDir.replace(/\\.func$/, ''),\n '__data.json.func'\n );\n const toCopy = fs.readdirSync(funcDir);\n fs.removeSync(funcDir);\n fs.mkdirSync(funcDir, { recursive: true });\n\n for (const item of toCopy) {\n fs.copySync(path.join(sourceFuncDir, item), path.join(funcDir, item));\n }\n\n // Update .vc-config.json with the new experimental triggers config\n const existingConfig = JSON.parse(fs.readFileSync(file, 'utf8'));\n fs.writeFileSync(\n file,\n JSON.stringify({\n ...existingConfig,\n ...config,\n })\n );\n\n // The source function may be a shared catchall. It must not keep stale\n // workflow queue triggers after the dedicated function is copied out.\n stripWorkflowQueueTriggers(path.join(sourceFuncDir, '.vc-config.json'));\n }\n});\n\nexport { workflowPlugin } from './plugin.js';\n"]}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'vite';
|
|
2
|
-
export
|
|
2
|
+
export interface WorkflowPluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Controls how source maps are emitted for workflow bundles. Accepts the
|
|
5
|
+
* same values as esbuild's `sourcemap` option: `true`/`'inline'` (default),
|
|
6
|
+
* `'linked'`, `'external'`, `'both'`, or `false` to omit source maps. Can
|
|
7
|
+
* also be set via the `WORKFLOW_SOURCEMAP` environment variable.
|
|
8
|
+
*/
|
|
9
|
+
sourcemap?: boolean | 'inline' | 'linked' | 'external' | 'both';
|
|
10
|
+
}
|
|
11
|
+
export declare function workflowPlugin(options?: WorkflowPluginOptions): Plugin[];
|
|
3
12
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGnC,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,GAAG,MAAM,CAAC;CACjE;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,qBAA0B,GAAG,MAAM,EAAE,CAc5E"}
|
package/dist/plugin.js
CHANGED
|
@@ -2,8 +2,8 @@ import { createBuildQueue } from '@workflow/builders';
|
|
|
2
2
|
import { workflowTransformPlugin } from '@workflow/rollup';
|
|
3
3
|
import { workflowHotUpdatePlugin } from '@workflow/vite';
|
|
4
4
|
import { SvelteKitBuilder } from './builder.js';
|
|
5
|
-
export function workflowPlugin() {
|
|
6
|
-
const builder = new SvelteKitBuilder();
|
|
5
|
+
export function workflowPlugin(options = {}) {
|
|
6
|
+
const builder = new SvelteKitBuilder({ sourcemap: options.sourcemap });
|
|
7
7
|
const enqueue = createBuildQueue();
|
|
8
8
|
return [
|
|
9
9
|
workflowTransformPlugin(),
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAYhD,MAAM,UAAU,cAAc,CAAC,UAAiC,EAAE;IAChE,MAAM,OAAO,GAAG,IAAI,gBAAgB,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,gBAAgB,EAAE,CAAC;IAEnC,OAAO;QACL,uBAAuB,EAAY;QACnC;YACE,IAAI,EAAE,oBAAoB;SAC3B;QACD,uBAAuB,CAAC;YACtB,OAAO;YACP,OAAO;SACR,CAAC;KACH,CAAC;AACJ,CAAC","sourcesContent":["import { createBuildQueue } from '@workflow/builders';\nimport { workflowTransformPlugin } from '@workflow/rollup';\nimport { workflowHotUpdatePlugin } from '@workflow/vite';\nimport type { Plugin } from 'vite';\nimport { SvelteKitBuilder } from './builder.js';\n\nexport interface WorkflowPluginOptions {\n /**\n * Controls how source maps are emitted for workflow bundles. Accepts the\n * same values as esbuild's `sourcemap` option: `true`/`'inline'` (default),\n * `'linked'`, `'external'`, `'both'`, or `false` to omit source maps. Can\n * also be set via the `WORKFLOW_SOURCEMAP` environment variable.\n */\n sourcemap?: boolean | 'inline' | 'linked' | 'external' | 'both';\n}\n\nexport function workflowPlugin(options: WorkflowPluginOptions = {}): Plugin[] {\n const builder = new SvelteKitBuilder({ sourcemap: options.sourcemap });\n const enqueue = createBuildQueue();\n\n return [\n workflowTransformPlugin() as Plugin,\n {\n name: 'workflow:sveltekit',\n },\n workflowHotUpdatePlugin({\n builder,\n enqueue,\n }),\n ];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vc-config.d.ts","sourceRoot":"","sources":["../src/vc-config.ts"],"names":[],"mappings":"AAcA,wBAAgB,oCAAoC,CAClD,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,cAAc,EAAE,OAAO,GAAG,OAAO,CAqBlC;AAED,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,MAAM,QAYtD"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { WORKFLOW_QUEUE_TRIGGER } from '@workflow/builders';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
const WORKFLOW_QUEUE_TOPICS = new Set([WORKFLOW_QUEUE_TRIGGER.topic]);
|
|
4
|
+
function isWorkflowQueueTrigger(trigger) {
|
|
5
|
+
if (typeof trigger !== 'object' || trigger === null) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const topic = trigger.topic;
|
|
9
|
+
return typeof topic === 'string' && WORKFLOW_QUEUE_TOPICS.has(topic);
|
|
10
|
+
}
|
|
11
|
+
export function stripWorkflowQueueTriggersFromConfig(existingConfig) {
|
|
12
|
+
const experimentalTriggers = existingConfig.experimentalTriggers;
|
|
13
|
+
if (!Array.isArray(experimentalTriggers)) {
|
|
14
|
+
return existingConfig;
|
|
15
|
+
}
|
|
16
|
+
const filteredTriggers = experimentalTriggers.filter((trigger) => !isWorkflowQueueTrigger(trigger));
|
|
17
|
+
if (filteredTriggers.length === experimentalTriggers.length) {
|
|
18
|
+
return existingConfig;
|
|
19
|
+
}
|
|
20
|
+
const nextConfig = { ...existingConfig };
|
|
21
|
+
if (filteredTriggers.length > 0) {
|
|
22
|
+
nextConfig.experimentalTriggers = filteredTriggers;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
delete nextConfig.experimentalTriggers;
|
|
26
|
+
}
|
|
27
|
+
return nextConfig;
|
|
28
|
+
}
|
|
29
|
+
export function stripWorkflowQueueTriggers(file) {
|
|
30
|
+
if (!fs.existsSync(file)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const existingConfig = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
34
|
+
const nextConfig = stripWorkflowQueueTriggersFromConfig(existingConfig);
|
|
35
|
+
if (nextConfig === existingConfig) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
fs.writeFileSync(file, JSON.stringify(nextConfig));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=vc-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vc-config.js","sourceRoot":"","sources":["../src/vc-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,MAAM,UAAU,CAAC;AAE1B,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,CAAC,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AAC,CAAC,CAAC;IACjE,MAAM,UAAU,GAAG,oCAAoC,CAAC,cAAc,CAAC,CAAC;IACxE,IAAI,UAAU,KAAK,cAAc,EAAE,CAAC;QAClC,OAAO;IACT,CAAC;IAED,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { WORKFLOW_QUEUE_TRIGGER } from '@workflow/builders';\nimport fs from 'fs-extra';\n\nconst WORKFLOW_QUEUE_TOPICS = new Set([WORKFLOW_QUEUE_TRIGGER.topic]);\n\nfunction isWorkflowQueueTrigger(trigger: unknown) {\n if (typeof trigger !== 'object' || trigger === null) {\n return false;\n }\n\n const topic = (trigger as { topic?: unknown }).topic;\n return typeof topic === 'string' && WORKFLOW_QUEUE_TOPICS.has(topic);\n}\n\nexport function stripWorkflowQueueTriggersFromConfig<\n TConfig extends Record<string, unknown>,\n>(existingConfig: TConfig): TConfig {\n const experimentalTriggers = existingConfig.experimentalTriggers;\n if (!Array.isArray(experimentalTriggers)) {\n return existingConfig;\n }\n\n const filteredTriggers = experimentalTriggers.filter(\n (trigger) => !isWorkflowQueueTrigger(trigger)\n );\n if (filteredTriggers.length === experimentalTriggers.length) {\n return existingConfig;\n }\n\n const nextConfig: Record<string, unknown> = { ...existingConfig };\n if (filteredTriggers.length > 0) {\n nextConfig.experimentalTriggers = filteredTriggers;\n } else {\n delete nextConfig.experimentalTriggers;\n }\n\n return nextConfig as TConfig;\n}\n\nexport function stripWorkflowQueueTriggers(file: string) {\n if (!fs.existsSync(file)) {\n return;\n }\n\n const existingConfig = JSON.parse(fs.readFileSync(file, 'utf8'));\n const nextConfig = stripWorkflowQueueTriggersFromConfig(existingConfig);\n if (nextConfig === existingConfig) {\n return;\n }\n\n fs.writeFileSync(file, JSON.stringify(nextConfig));\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/sveltekit",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.6",
|
|
4
4
|
"description": "SvelteKit integration for Workflow SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"exsolve": "^1.0.8",
|
|
25
25
|
"fs-extra": "^11.3.2",
|
|
26
26
|
"pathe": "^2.0.3",
|
|
27
|
-
"@workflow/builders": "5.0.0-beta.
|
|
28
|
-
"@workflow/
|
|
29
|
-
"@workflow/
|
|
30
|
-
"@workflow/
|
|
27
|
+
"@workflow/builders": "5.0.0-beta.6",
|
|
28
|
+
"@workflow/rollup": "5.0.0-beta.6",
|
|
29
|
+
"@workflow/vite": "5.0.0-beta.6",
|
|
30
|
+
"@workflow/swc-plugin": "5.0.0-beta.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/fs-extra": "11.0.4",
|