@workflow/sveltekit 5.0.0-beta.5 → 5.0.0-beta.7

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiEA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
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
@@ -18,15 +20,7 @@ process.on('beforeExit', () => {
18
20
  file: '.vercel/output/functions/.well-known/workflow/v1/flow.func/.vc-config.json',
19
21
  config: {
20
22
  maxDuration: 'max',
21
- experimentalTriggers: [
22
- {
23
- type: 'queue/v2beta',
24
- topic: '__wkf_workflow_*',
25
- consumer: 'default',
26
- retryAfterSeconds: 5,
27
- initialDelaySeconds: 0,
28
- },
29
- ],
23
+ experimentalTriggers: [WORKFLOW_QUEUE_TRIGGER],
30
24
  },
31
25
  },
32
26
  ]) {
@@ -36,11 +30,12 @@ process.on('beforeExit', () => {
36
30
  }
37
31
  // Un-symlink these as they can't be shared due to different
38
32
  // experimental triggers config
33
+ const sourceFuncDir = path.join(funcDir.replace(/\.func$/, ''), '__data.json.func');
39
34
  const toCopy = fs.readdirSync(funcDir);
40
35
  fs.removeSync(funcDir);
41
36
  fs.mkdirSync(funcDir, { recursive: true });
42
37
  for (const item of toCopy) {
43
- fs.copySync(path.join(funcDir.replace(/\.func$/, ''), '__data.json.func', item), path.join(funcDir, item));
38
+ fs.copySync(path.join(sourceFuncDir, item), path.join(funcDir, item));
44
39
  }
45
40
  // Update .vc-config.json with the new experimental triggers config
46
41
  const existingConfig = JSON.parse(fs.readFileSync(file, 'utf8'));
@@ -48,6 +43,9 @@ process.on('beforeExit', () => {
48
43
  ...existingConfig,
49
44
  ...config,
50
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'));
51
49
  }
52
50
  });
53
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;AAEhD,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;IAC5B,wDAAwD;IACxD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,CAAC;QACtC,OAAO;IACT,CAAC;IACD,2DAA2D;IAC3D,uCAAuC;IACvC,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI;QAC7B;YACE,IAAI,EAAE,4EAA4E;YAClF,MAAM,EAAE;gBACN,WAAW,EAAE,KAAK;gBAClB,oBAAoB,EAAE;oBACpB;wBACE,IAAI,EAAE,cAAc;wBACpB,KAAK,EAAE,kBAAkB;wBACzB,QAAQ,EAAE,SAAS;wBACnB,iBAAiB,EAAE,CAAC;wBACpB,mBAAmB,EAAE,CAAC;qBACvB;iBACF;aACF;SACF;KACF,EAAE,CAAC;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,SAAS;QACX,CAAC;QACD,4DAA4D;QAC5D,+BAA+B;QAC/B,MAAM,MAAM,GAAG,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACvC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACvB,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE3C,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;YAC1B,EAAE,CAAC,QAAQ,CACT,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,kBAAkB,EAAE,IAAI,CAAC,EACnE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CACzB,CAAC;QACJ,CAAC;QAED,mEAAmE;QACnE,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;QACjE,EAAE,CAAC,aAAa,CACd,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC;YACb,GAAG,cAAc;YACjB,GAAG,MAAM;SACV,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC","sourcesContent":["import path from 'node:path';\nimport fs from 'fs-extra';\n\nimport { SvelteKitBuilder } from './builder.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: [\n {\n type: 'queue/v2beta',\n topic: '__wkf_workflow_*',\n consumer: 'default',\n retryAfterSeconds: 5,\n initialDelaySeconds: 0,\n },\n ],\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 toCopy = fs.readdirSync(funcDir);\n fs.removeSync(funcDir);\n fs.mkdirSync(funcDir, { recursive: true });\n\n for (const item of toCopy) {\n fs.copySync(\n path.join(funcDir.replace(/\\.func$/, ''), '__data.json.func', item),\n path.join(funcDir, item)\n );\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});\n\nexport { workflowPlugin } from './plugin.js';\n"]}
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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,CAAC;YACb,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"]}
@@ -0,0 +1,3 @@
1
+ export declare function stripWorkflowQueueTriggersFromConfig<TConfig extends Record<string, unknown>>(existingConfig: TConfig): TConfig;
2
+ export declare function stripWorkflowQueueTriggers(file: string): void;
3
+ //# sourceMappingURL=vc-config.d.ts.map
@@ -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,KAAK,CAAC,CAAC,CAAC;AAEtE,SAAS,sBAAsB,CAAC,OAAgB;IAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAI,OAA+B,CAAC,KAAK,CAAC;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACvE,CAAC;AAED,MAAM,UAAU,oCAAoC,CAElD,cAAuB;IACvB,MAAM,oBAAoB,GAAG,cAAc,CAAC,oBAAoB,CAAC;IACjE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC;QACzC,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAClD,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAC9C,CAAC;IACF,IAAI,gBAAgB,CAAC,MAAM,KAAK,oBAAoB,CAAC,MAAM,EAAE,CAAC;QAC5D,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,MAAM,UAAU,GAA4B,EAAE,GAAG,cAAc,EAAE,CAAC;IAClE,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAChC,UAAU,CAAC,oBAAoB,GAAG,gBAAgB,CAAC;IACrD,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAC,oBAAoB,CAAC;IACzC,CAAC;IAED,OAAO,UAAqB,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,0BAA0B,CAAC,IAAY;IACrD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,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.5",
3
+ "version": "5.0.0-beta.7",
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.7",
27
28
  "@workflow/swc-plugin": "5.0.0-beta.4",
28
- "@workflow/builders": "5.0.0-beta.5",
29
- "@workflow/vite": "5.0.0-beta.5",
30
- "@workflow/rollup": "5.0.0-beta.5"
29
+ "@workflow/vite": "5.0.0-beta.7",
30
+ "@workflow/rollup": "5.0.0-beta.7"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/fs-extra": "11.0.4",