@vite-hub/workflow 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +187 -56
  3. package/dist/{_app-DgwN4ulW.d.ts → app-BojnC_yf.d.ts} +1 -4
  4. package/dist/{app-BZpq2cwC.js → app-CzPoP84f.js} +2 -1
  5. package/dist/client-DsGM3M4U.js +389 -0
  6. package/dist/cloudflare-env-BNrYo29x.js +113 -0
  7. package/dist/cloudflare-nF4abPd4.js +59 -0
  8. package/dist/cloudflare-shared-CaxrMD1A.d.ts +1 -0
  9. package/dist/{cloudflare-vite-B0zel2Do.js → cloudflare-vite-B3IabBsv.js} +18 -10
  10. package/dist/{config-BDqB6I4E.js → config-IJMb0eeZ.js} +39 -25
  11. package/dist/error-diagnostics-A_8Kp-48.js +116 -0
  12. package/dist/error-diagnostics-pwNFvAHP.js +67 -0
  13. package/dist/index.d.ts +24 -20
  14. package/dist/index.js +25 -334
  15. package/dist/inspect-B72iFyj-.js +70 -0
  16. package/dist/operations-B_rYG71W.js +230 -0
  17. package/dist/operations-tNUdj3G4.d.ts +212 -0
  18. package/dist/operations.d.ts +37 -0
  19. package/dist/operations.js +887 -0
  20. package/dist/out-CsaJxg8m.js +21755 -0
  21. package/dist/{provider-operation-CWIV4k42.js → provider-operation-CW2cYfVy.js} +13 -10
  22. package/dist/rolldown-runtime-CMFfr-1z.js +26 -0
  23. package/dist/runtime/cloudflare-runner.d.ts +8 -14
  24. package/dist/runtime/cloudflare-runner.js +77 -14
  25. package/dist/runtime/cloudflare-shared.d.ts +1 -0
  26. package/dist/runtime/cloudflare-shared.js +1 -1
  27. package/dist/runtime/cloudflare-vite.d.ts +8 -9
  28. package/dist/runtime/cloudflare-vite.js +2 -2
  29. package/dist/runtime/execute.d.ts +8 -7
  30. package/dist/runtime/execute.js +28 -5
  31. package/dist/runtime/openworkflow-worker.d.ts +6 -8
  32. package/dist/runtime/openworkflow-worker.js +43 -6
  33. package/dist/runtime/openworkflow.d.ts +8 -10
  34. package/dist/runtime/openworkflow.js +50 -32
  35. package/dist/runtime/state.d.ts +20 -21
  36. package/dist/runtime/state.js +90 -20
  37. package/dist/runtime/vercel-vite.d.ts +10 -11
  38. package/dist/runtime/vercel-vite.js +11 -8
  39. package/dist/runtime-type-DBCvIh5x.js +7 -0
  40. package/dist/{types-BUlYBZwH.d.ts → types-D82WmfZa.d.ts} +35 -18
  41. package/dist/{vercel-D2_J5D_Y.js → vercel-D-ZNtB_u.js} +59 -26
  42. package/dist/vite.d.ts +365 -6
  43. package/dist/vite.js +4667 -910
  44. package/package.json +78 -28
  45. package/dist/cloudflare-Cds1VIWa.js +0 -42
  46. package/dist/cloudflare-env-mFp2Uj6Z.js +0 -53
  47. package/dist/cloudflare-shared-BVVgDSdq.d.ts +0 -1
package/package.json CHANGED
@@ -1,17 +1,20 @@
1
1
  {
2
2
  "name": "@vite-hub/workflow",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Workflow primitives and Vite integration for ViteHub.",
5
5
  "keywords": [
6
+ "background-jobs",
6
7
  "cloudflare",
7
8
  "docker",
9
+ "durable-execution",
8
10
  "openworkflow",
11
+ "typescript",
9
12
  "vercel",
10
13
  "vite",
11
14
  "vitehub",
12
15
  "workflow"
13
16
  ],
14
- "homepage": "https://github.com/vite-hub/vitehub#readme",
17
+ "homepage": "https://vitehub.dev",
15
18
  "bugs": "https://github.com/vite-hub/vitehub/issues",
16
19
  "license": "Apache-2.0",
17
20
  "author": "onmax <maximogarciamtnez@gmail.com>",
@@ -28,42 +31,89 @@
28
31
  "sideEffects": false,
29
32
  "types": "./dist/index.d.ts",
30
33
  "exports": {
31
- ".": "./dist/index.js",
32
- "./runtime/cloudflare-runner": "./dist/runtime/cloudflare-runner.js",
33
- "./runtime/cloudflare-shared": "./dist/runtime/cloudflare-shared.js",
34
- "./runtime/cloudflare-vite": "./dist/runtime/cloudflare-vite.js",
35
- "./runtime/execute": "./dist/runtime/execute.js",
36
- "./runtime/openworkflow": "./dist/runtime/openworkflow.js",
37
- "./runtime/openworkflow-worker": "./dist/runtime/openworkflow-worker.js",
38
- "./runtime/state": "./dist/runtime/state.js",
39
- "./runtime/vercel-vite": "./dist/runtime/vercel-vite.js",
40
- "./vite": "./dist/vite.js",
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js",
37
+ "default": "./dist/index.js"
38
+ },
39
+ "./operations": {
40
+ "types": "./dist/operations.d.ts",
41
+ "import": "./dist/operations.js",
42
+ "default": "./dist/operations.js"
43
+ },
44
+ "./runtime/cloudflare-runner": {
45
+ "types": "./dist/runtime/cloudflare-runner.d.ts",
46
+ "import": "./dist/runtime/cloudflare-runner.js",
47
+ "default": "./dist/runtime/cloudflare-runner.js"
48
+ },
49
+ "./runtime/cloudflare-shared": {
50
+ "types": "./dist/runtime/cloudflare-shared.d.ts",
51
+ "import": "./dist/runtime/cloudflare-shared.js",
52
+ "default": "./dist/runtime/cloudflare-shared.js"
53
+ },
54
+ "./runtime/cloudflare-vite": {
55
+ "types": "./dist/runtime/cloudflare-vite.d.ts",
56
+ "import": "./dist/runtime/cloudflare-vite.js",
57
+ "default": "./dist/runtime/cloudflare-vite.js"
58
+ },
59
+ "./runtime/execute": {
60
+ "types": "./dist/runtime/execute.d.ts",
61
+ "import": "./dist/runtime/execute.js",
62
+ "default": "./dist/runtime/execute.js"
63
+ },
64
+ "./runtime/openworkflow": {
65
+ "types": "./dist/runtime/openworkflow.d.ts",
66
+ "import": "./dist/runtime/openworkflow.js",
67
+ "default": "./dist/runtime/openworkflow.js"
68
+ },
69
+ "./runtime/openworkflow-worker": {
70
+ "types": "./dist/runtime/openworkflow-worker.d.ts",
71
+ "import": "./dist/runtime/openworkflow-worker.js",
72
+ "default": "./dist/runtime/openworkflow-worker.js"
73
+ },
74
+ "./runtime/state": {
75
+ "types": "./dist/runtime/state.d.ts",
76
+ "import": "./dist/runtime/state.js",
77
+ "default": "./dist/runtime/state.js"
78
+ },
79
+ "./runtime/vercel-vite": {
80
+ "types": "./dist/runtime/vercel-vite.d.ts",
81
+ "import": "./dist/runtime/vercel-vite.js",
82
+ "default": "./dist/runtime/vercel-vite.js"
83
+ },
84
+ "./vite": {
85
+ "types": "./dist/vite.d.ts",
86
+ "import": "./dist/vite.js",
87
+ "default": "./dist/vite.js"
88
+ },
41
89
  "./package.json": "./package.json"
42
90
  },
43
91
  "dependencies": {
44
- "@vercel/functions": "^3.7.5",
92
+ "@vercel/functions": "^3.9.11",
93
+ "@vite-hub/runtime": "0.1.0",
45
94
  "defu": "^6.1.7",
46
- "esbuild": "^0.28.1",
47
- "h3": "2.0.1-rc.25",
95
+ "esbuild": "^0.28.2",
96
+ "h3": "2.0.1-rc.33",
97
+ "nostics": "1.3.0",
48
98
  "pathe": "^2.0.3",
49
- "@vite-hub/runtime": "0.0.3"
99
+ "valibot": "^1.5.0"
50
100
  },
51
101
  "devDependencies": {
52
- "@types/node": "^24.13.3",
53
- "openworkflow": "^0.9.0",
54
- "publint": "^0.3.21",
102
+ "@types/node": "^24.19.1",
103
+ "openworkflow": "^0.9.2",
104
+ "publint": "^0.3.25",
55
105
  "typescript": "^6.0.3",
56
- "vite": "^8.0.8",
57
- "vite-plus": "^0.1.24",
58
- "vitest": "^4.1.4",
106
+ "vite": "^8.2.2",
107
+ "vite-plus": "^0.3.3",
108
+ "vitest": "^4.1.11",
59
109
  "@vite-hub/internal": "0.0.1"
60
110
  },
61
111
  "peerDependencies": {
62
- "@workflow/builders": "5.0.0-beta.35",
63
- "openworkflow": "^0.9.0",
112
+ "@vite-hub/database": "0.1.0",
113
+ "@workflow/builders": "5.0.1",
114
+ "openworkflow": "^0.9.2",
64
115
  "vite": ">=8.0.0",
65
- "workflow": "5.0.0-beta.35",
66
- "@vite-hub/database": "0.0.3"
116
+ "workflow": "5.0.1"
67
117
  },
68
118
  "peerDependenciesMeta": {
69
119
  "@vite-hub/database": {
@@ -88,7 +138,7 @@
88
138
  "scripts": {
89
139
  "build": "vp pack",
90
140
  "dev": "vp pack --watch",
91
- "typecheck": "tsc --noEmit -p ./tsconfig.json",
92
- "test": "vp run -t @vite-hub/workflow#build && vp test"
141
+ "typecheck": "vp run --cache -t @vite-hub/workflow#build && node ../../test/package-typecheck.mjs --noEmit -p ./tsconfig.json",
142
+ "test": "vp run -t @vite-hub/workflow#build && vp run -t @vite-hub/agent#build && vp test"
93
143
  }
94
144
  }
@@ -1,42 +0,0 @@
1
- //#region ../internal/src/integrations/hex.ts
2
- const textEncoder = new TextEncoder();
3
- new TextDecoder();
4
- function encodeNameHex(name) {
5
- return [...textEncoder.encode(name)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
6
- }
7
- //#endregion
8
- //#region src/integrations/cloudflare.ts
9
- const cloudflareWorkflowNameMaxLength = 64;
10
- function shortHash(value) {
11
- let hash = 2166136261;
12
- for (const char of value) {
13
- hash ^= char.codePointAt(0) || 0;
14
- hash = Math.imul(hash, 16777619);
15
- }
16
- return (hash >>> 0).toString(16).padStart(8, "0");
17
- }
18
- function getCloudflareWorkflowBindingName(name) {
19
- return `WORKFLOW_${encodeNameHex(name).toUpperCase()}`;
20
- }
21
- function getCloudflareWorkflowName(name) {
22
- const encoded = encodeNameHex(name);
23
- const fullName = `workflow--${encoded}`;
24
- if (fullName.length <= cloudflareWorkflowNameMaxLength) return fullName;
25
- const hash = shortHash(name);
26
- const prefixLength = cloudflareWorkflowNameMaxLength - 10 - 1 - hash.length;
27
- return `workflow--${encoded.slice(0, prefixLength)}-${hash}`;
28
- }
29
- function getCloudflareWorkflowClassName(name) {
30
- return `ViteHub${name.split(/[^a-z0-9]+/i).filter(Boolean).map((segment) => `${segment.charAt(0).toUpperCase()}${segment.slice(1)}`).join("") || "Default"}${shortHash(name)}Workflow`;
31
- }
32
- function createCloudflareWorkflowBindings(definitions, options) {
33
- if (!definitions.length) return;
34
- if (definitions.length > 1 && options && (options.binding || options.name)) throw new TypeError("Cloudflare workflow binding and name overrides are only supported when one workflow is discovered.");
35
- return definitions.map((definition) => ({
36
- binding: definitions.length === 1 && options ? options.binding || getCloudflareWorkflowBindingName(definition.name) : getCloudflareWorkflowBindingName(definition.name),
37
- class_name: getCloudflareWorkflowClassName(definition.name),
38
- name: definitions.length === 1 && options ? options.name || getCloudflareWorkflowName(definition.name) : getCloudflareWorkflowName(definition.name)
39
- }));
40
- }
41
- //#endregion
42
- export { encodeNameHex as a, getCloudflareWorkflowName as i, getCloudflareWorkflowBindingName as n, getCloudflareWorkflowClassName as r, createCloudflareWorkflowBindings as t };
@@ -1,53 +0,0 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
- //#region ../internal/src/runtime/cloudflare-env.ts
3
- let activeEnv;
4
- const activeEnvStorage = new AsyncLocalStorage();
5
- function setActiveCloudflareEnv(env) {
6
- activeEnv = env;
7
- globalThis.__env__ = env;
8
- try {
9
- activeEnvStorage.enterWith({ env });
10
- } catch {}
11
- }
12
- function runWithActiveCloudflareEnv(env, callback) {
13
- return activeEnvStorage.run({ env }, callback);
14
- }
15
- function getActiveCloudflareEnv() {
16
- const scoped = activeEnvStorage.getStore();
17
- return scoped ? scoped.env : activeEnv ?? globalThis.__env__;
18
- }
19
- function getCloudflareEnv(event) {
20
- const target = event;
21
- return target?.env || target?.context?.cloudflare?.env || target?.context?._platform?.cloudflare?.env || target?.req?.runtime?.cloudflare?.env || getActiveCloudflareEnv();
22
- }
23
- function resolveWaitUntil(event) {
24
- const target = event;
25
- const owners = [
26
- target,
27
- target?.context,
28
- target?.context?.cloudflare,
29
- target?.context?.cloudflare?.context,
30
- target?.context?._platform?.cloudflare,
31
- target?.context?._platform?.cloudflare?.context,
32
- target?.req,
33
- target?.req?.runtime?.cloudflare,
34
- target?.req?.runtime?.cloudflare?.context
35
- ];
36
- for (const owner of owners) if (typeof owner?.waitUntil === "function") return owner.waitUntil.bind(owner);
37
- }
38
- function createCloudflareRuntimeEvent(env, context) {
39
- const waitUntil = typeof context?.waitUntil === "function" ? context.waitUntil.bind(context) : void 0;
40
- return {
41
- context: {
42
- cloudflare: {
43
- env,
44
- context
45
- },
46
- waitUntil
47
- },
48
- env,
49
- waitUntil
50
- };
51
- }
52
- //#endregion
53
- export { setActiveCloudflareEnv as a, runWithActiveCloudflareEnv as i, getCloudflareEnv as n, resolveWaitUntil as r, createCloudflareRuntimeEvent as t };
@@ -1 +0,0 @@
1
- export { };