devflare 1.0.0-next.39 → 1.0.0-next.40

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 (277) hide show
  1. package/dist/_chunks/account-BtWcv3X9.js +462 -0
  2. package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
  3. package/dist/_chunks/ai-CBEuLdoP.js +322 -0
  4. package/dist/_chunks/api-TzdliH-6.js +568 -0
  5. package/dist/_chunks/build-3T6O4uIg.js +24 -0
  6. package/dist/_chunks/build-artifacts-8TqBSQkG.js +483 -0
  7. package/dist/_chunks/cli-BTF1X4SG.js +1128 -0
  8. package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
  9. package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
  10. package/dist/_chunks/command-utils-BsfkmTqh.js +45 -0
  11. package/dist/_chunks/compiler-uoyAQ8zW.js +424 -0
  12. package/dist/_chunks/config-D5u-bEkn.js +78 -0
  13. package/dist/_chunks/config-path-DCPto4XB.js +42 -0
  14. package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
  15. package/dist/_chunks/decorators-QmV57ixr.js +19 -0
  16. package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
  17. package/dist/_chunks/deploy-DMTr6JeR.js +915 -0
  18. package/dist/_chunks/dev-CvRHmRFZ.js +3456 -0
  19. package/dist/_chunks/doctor-DIG8DoFU.js +219 -0
  20. package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
  21. package/dist/_chunks/env-S0_nMVz1.js +125 -0
  22. package/dist/_chunks/family-DXC5SdFK.js +143 -0
  23. package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
  24. package/dist/_chunks/glob-CmQOvunB.js +56 -0
  25. package/dist/_chunks/init-3moXTgpb.js +165 -0
  26. package/dist/_chunks/loader-DLXO60RO.js +1153 -0
  27. package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
  28. package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
  29. package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
  30. package/dist/_chunks/local-secrets-DMmEOygL.js +123 -0
  31. package/dist/_chunks/local-workflow-entrypoints-Wip3o1u8.js +90 -0
  32. package/dist/_chunks/login-BmnDzDlH.js +51 -0
  33. package/dist/_chunks/package-metadata-DAuCkyvK.js +39 -0
  34. package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
  35. package/dist/_chunks/preview-BhqDmq8I.js +456 -0
  36. package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
  37. package/dist/_chunks/preview-resources-DdXj8LMM.js +358 -0
  38. package/dist/_chunks/previews-Dlr13x5M.js +1134 -0
  39. package/dist/_chunks/productions-D3AnOHac.js +411 -0
  40. package/dist/_chunks/ref-CYJNAAe_.js +178 -0
  41. package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
  42. package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
  43. package/dist/_chunks/resolve-package-Y84HB3Nt.js +133 -0
  44. package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
  45. package/dist/_chunks/routes-C3FqES2W.js +796 -0
  46. package/dist/_chunks/runtime-FvXvfuZ2.js +550 -0
  47. package/dist/_chunks/schema-normalization-DWVleVxo.js +477 -0
  48. package/dist/_chunks/secrets-70eN0Q6C.js +95 -0
  49. package/dist/_chunks/token-kguIDmej.js +333 -0
  50. package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
  51. package/dist/_chunks/types-OrLbzv4I.js +476 -0
  52. package/dist/_chunks/ui-BUoZApvE.js +103 -0
  53. package/dist/_chunks/usage-BBTGzjon.js +272 -0
  54. package/dist/_chunks/vite-CsI0E-uV.js +1235 -0
  55. package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
  56. package/dist/_chunks/worker-CS1jgNFE.js +410 -0
  57. package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
  58. package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
  59. package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
  60. package/dist/bridge/index.d.ts +6 -6
  61. package/dist/bridge/miniflare.d.ts +2 -2
  62. package/dist/bridge/proxy.d.ts +1 -1
  63. package/dist/bridge/v2/body-streams.d.ts +1 -1
  64. package/dist/bridge/v2/codec.d.ts +4 -4
  65. package/dist/bridge/v2/index.d.ts +10 -10
  66. package/dist/bridge/v2/serialization.d.ts +1 -1
  67. package/dist/bridge/v2/value-codec.d.ts +1 -1
  68. package/dist/bridge/v2/value-serialization.d.ts.map +1 -1
  69. package/dist/bridge/v2/ws-relay.d.ts +3 -3
  70. package/dist/browser-shim/index.d.ts +2 -2
  71. package/dist/browser.d.ts +70 -70
  72. package/dist/browser.js +74 -2462
  73. package/dist/bundler/do-bundler.d.ts +1 -1
  74. package/dist/bundler/index.d.ts +3 -3
  75. package/dist/bundler/rolldown-shared.d.ts +1 -1
  76. package/dist/bundler/worker-bundler.d.ts +1 -1
  77. package/dist/cli/build-manifest.d.ts +1 -1
  78. package/dist/cli/command-utils.d.ts +1 -1
  79. package/dist/cli/commands/account.d.ts +1 -1
  80. package/dist/cli/commands/ai.d.ts +1 -1
  81. package/dist/cli/commands/build-artifacts.d.ts +5 -5
  82. package/dist/cli/commands/build.d.ts +1 -1
  83. package/dist/cli/commands/config.d.ts +1 -1
  84. package/dist/cli/commands/deploy/prepare.d.ts +2 -2
  85. package/dist/cli/commands/deploy/runtime.d.ts +1 -1
  86. package/dist/cli/commands/deploy/verification.d.ts +1 -1
  87. package/dist/cli/commands/deploy.d.ts +1 -1
  88. package/dist/cli/commands/dev.d.ts +1 -1
  89. package/dist/cli/commands/doctor.d.ts +1 -1
  90. package/dist/cli/commands/init.d.ts +1 -1
  91. package/dist/cli/commands/login.d.ts +1 -1
  92. package/dist/cli/commands/previews-support/cleanup.d.ts +1 -1
  93. package/dist/cli/commands/previews-support/family.d.ts +3 -3
  94. package/dist/cli/commands/previews-support/render.d.ts +3 -3
  95. package/dist/cli/commands/previews-support/theme.d.ts +2 -2
  96. package/dist/cli/commands/previews-support/types.d.ts +2 -2
  97. package/dist/cli/commands/previews.d.ts +1 -1
  98. package/dist/cli/commands/productions.d.ts +1 -1
  99. package/dist/cli/commands/remote.d.ts +1 -1
  100. package/dist/cli/commands/secrets.d.ts +1 -1
  101. package/dist/cli/commands/token.d.ts +1 -1
  102. package/dist/cli/commands/type-generation/discovery.d.ts +2 -2
  103. package/dist/cli/commands/type-generation/generator.d.ts +3 -3
  104. package/dist/cli/commands/type-generation/models.d.ts +1 -1
  105. package/dist/cli/commands/types.d.ts +1 -1
  106. package/dist/cli/commands/worker.d.ts +1 -1
  107. package/dist/cli/deploy-strategy.d.ts +1 -1
  108. package/dist/cli/deploy-target.d.ts +1 -1
  109. package/dist/cli/help-pages/pages/account.d.ts +1 -1
  110. package/dist/cli/help-pages/pages/core.d.ts +1 -1
  111. package/dist/cli/help-pages/pages/index.d.ts +1 -1
  112. package/dist/cli/help-pages/pages/misc.d.ts +1 -1
  113. package/dist/cli/help-pages/pages/previews.d.ts +1 -1
  114. package/dist/cli/help-pages/pages/productions.d.ts +1 -1
  115. package/dist/cli/help-pages/render.d.ts +2 -2
  116. package/dist/cli/help-pages/shared.d.ts +1 -1
  117. package/dist/cli/help.d.ts +2 -2
  118. package/dist/cli/index.js +2 -1383
  119. package/dist/cli/preview-bindings.d.ts +3 -3
  120. package/dist/cli/preview.d.ts +1 -1
  121. package/dist/cli/wrangler-auth.d.ts +1 -1
  122. package/dist/cloudflare/account-core.d.ts +2 -2
  123. package/dist/cloudflare/account-resources.d.ts +2 -2
  124. package/dist/cloudflare/account-status.d.ts +1 -1
  125. package/dist/cloudflare/account-workers.d.ts +2 -2
  126. package/dist/cloudflare/account.d.ts +7 -7
  127. package/dist/cloudflare/auth.d.ts +1 -1
  128. package/dist/cloudflare/index.d.ts +13 -13
  129. package/dist/cloudflare/index.js +4 -59
  130. package/dist/cloudflare/kv-namespace.d.ts +1 -1
  131. package/dist/cloudflare/preview-registry-cache.d.ts +1 -1
  132. package/dist/cloudflare/preview-registry-inference.d.ts +2 -2
  133. package/dist/cloudflare/preview-registry-records.d.ts +3 -3
  134. package/dist/cloudflare/preview-registry-shape.d.ts +2 -2
  135. package/dist/cloudflare/preview-registry-store.d.ts +3 -3
  136. package/dist/cloudflare/preview-registry-transport.d.ts +2 -2
  137. package/dist/cloudflare/preview-registry-types.d.ts +2 -2
  138. package/dist/cloudflare/preview-registry.d.ts +5 -5
  139. package/dist/cloudflare/tokens.d.ts +2 -2
  140. package/dist/cloudflare/usage.d.ts +2 -2
  141. package/dist/config/binding-resolution-helpers.d.ts +1 -1
  142. package/dist/config/compiler/bindings.d.ts +2 -2
  143. package/dist/config/compiler/core-helpers.d.ts +2 -2
  144. package/dist/config/compiler/do-workers.d.ts +2 -2
  145. package/dist/config/compiler/paths.d.ts +1 -1
  146. package/dist/config/compiler.d.ts +6 -6
  147. package/dist/config/define.d.ts +2 -2
  148. package/dist/config/deploy-resources.d.ts +5 -5
  149. package/dist/config/env-vars.d.ts +1 -1
  150. package/dist/config/framework-providers.d.ts +1 -1
  151. package/dist/config/index.d.ts +12 -12
  152. package/dist/config/loader.d.ts +2 -2
  153. package/dist/config/local-dev-vars.d.ts +1 -1
  154. package/dist/config/preview-resources.d.ts +4 -4
  155. package/dist/config/preview.d.ts +1 -1
  156. package/dist/config/ref.d.ts +2 -2
  157. package/dist/config/resolve-phased.d.ts +4 -4
  158. package/dist/config/resolve.d.ts +1 -1
  159. package/dist/config/resource-resolution.d.ts +6 -6
  160. package/dist/config/schema-env.d.ts +20 -20
  161. package/dist/config/schema-normalization.d.ts +1 -1
  162. package/dist/config/schema-types-bindings.d.ts +4 -4
  163. package/dist/config/schema-types-build.d.ts +1 -1
  164. package/dist/config/schema-types.d.ts +7 -7
  165. package/dist/config/schema.d.ts +46 -46
  166. package/dist/config/service-bindings-validation.d.ts +1 -1
  167. package/dist/config-entry.d.ts +6 -6
  168. package/dist/config-entry.js +3 -8
  169. package/dist/decorators/index.d.ts +2 -2
  170. package/dist/decorators/index.js +2 -9
  171. package/dist/dev-server/d1-migrations.d.ts +1 -1
  172. package/dist/dev-server/dev-server-state.d.ts +6 -6
  173. package/dist/dev-server/gateway-script.d.ts +1 -1
  174. package/dist/dev-server/index.d.ts +1 -1
  175. package/dist/dev-server/miniflare-bindings.d.ts +1 -1
  176. package/dist/dev-server/miniflare-dev-config.d.ts +5 -5
  177. package/dist/dev-server/miniflare-worker-config.d.ts +3 -3
  178. package/dist/dev-server/server-startup-helpers.d.ts +6 -6
  179. package/dist/dev-server/worker-surface-paths.d.ts +2 -2
  180. package/dist/index.d.ts +8 -8
  181. package/dist/index.js +9 -22
  182. package/dist/runtime/context-events.d.ts +1 -1
  183. package/dist/runtime/context.d.ts +3 -3
  184. package/dist/runtime/exports.d.ts +2 -2
  185. package/dist/runtime/index.d.ts +10 -10
  186. package/dist/runtime/index.js +5 -57
  187. package/dist/runtime/middleware.d.ts +1 -1
  188. package/dist/runtime/router/index.d.ts +3 -3
  189. package/dist/runtime/validation.d.ts +1 -1
  190. package/dist/secrets/local-secrets.d.ts +1 -1
  191. package/dist/shims/local-media-bindings.d.ts +1 -1
  192. package/dist/sveltekit/index.d.ts +1 -1
  193. package/dist/sveltekit/index.js +327 -9
  194. package/dist/sveltekit/local-bindings.d.ts +1 -1
  195. package/dist/sveltekit/platform.d.ts +1 -1
  196. package/dist/test/binding-hints.d.ts +2 -2
  197. package/dist/test/cf.d.ts +19 -19
  198. package/dist/test/index.d.ts +18 -18
  199. package/dist/test/index.js +4495 -46
  200. package/dist/test/offline-bindings.d.ts +3 -3
  201. package/dist/test/resolve-service-bindings.d.ts +1 -1
  202. package/dist/test/simple-context-bindings.d.ts +1 -1
  203. package/dist/test/simple-context-durable-objects.d.ts +1 -1
  204. package/dist/test/simple-context-env.d.ts +2 -2
  205. package/dist/test/simple-context-handlers.d.ts +2 -2
  206. package/dist/test/simple-context-lifecycle.d.ts +2 -2
  207. package/dist/test/simple-context-mfconfig.d.ts +1 -1
  208. package/dist/test/simple-context-multi-worker.d.ts +2 -2
  209. package/dist/test/simple-context-runtime.d.ts +1 -1
  210. package/dist/test/simple-context-startup.d.ts +1 -1
  211. package/dist/test/simple-context.d.ts +1 -1
  212. package/dist/test/utilities/env.d.ts +3 -3
  213. package/dist/test/utilities.d.ts +10 -10
  214. package/dist/test/worker.d.ts +1 -1
  215. package/dist/transform/index.d.ts +2 -2
  216. package/dist/utils/send-email.js +163 -19
  217. package/dist/vite/config-file.d.ts +2 -2
  218. package/dist/vite/index.d.ts +3 -3
  219. package/dist/vite/index.js +2 -31
  220. package/dist/vite/plugin-config-hook.d.ts +1 -1
  221. package/dist/vite/plugin-context.d.ts +3 -3
  222. package/dist/vite/plugin-durable-objects.d.ts +2 -2
  223. package/dist/vite/plugin-programmatic.d.ts +1 -1
  224. package/dist/vite/plugin-service-bindings.d.ts +2 -2
  225. package/dist/vite/plugin.d.ts +3 -3
  226. package/dist/worker-entry/composed-worker.d.ts +1 -1
  227. package/dist/worker-entry/routes.d.ts +2 -2
  228. package/dist/worker-entry/surface-paths.d.ts +1 -1
  229. package/dist/workflows/local-workflow-entrypoints.d.ts +1 -1
  230. package/package.json +5 -3
  231. package/dist/account-4tgh03a8.js +0 -484
  232. package/dist/ai-r3zqmxan.js +0 -261
  233. package/dist/api-6z01z734.js +0 -33
  234. package/dist/build-kw625v84.js +0 -51
  235. package/dist/config-ghk2bxj3.js +0 -102
  236. package/dist/deploy-9kee65n9.js +0 -1062
  237. package/dist/dev-x8zr249a.js +0 -3569
  238. package/dist/doctor-0ng5qrr1.js +0 -258
  239. package/dist/durable-object-0ybmg08a.js +0 -13
  240. package/dist/index-04wh9bxx.js +0 -514
  241. package/dist/index-0cc05hzv.js +0 -74
  242. package/dist/index-2yv7w548.js +0 -185
  243. package/dist/index-37x76zdn.js +0 -4
  244. package/dist/index-3cpzsr47.js +0 -125
  245. package/dist/index-3t6rypgc.js +0 -13
  246. package/dist/index-4mmpccrb.js +0 -309
  247. package/dist/index-5dkjffqz.js +0 -25
  248. package/dist/index-5hy7jmv3.js +0 -890
  249. package/dist/index-627srx16.js +0 -45
  250. package/dist/index-7m557715.js +0 -283
  251. package/dist/index-a8pnvg3r.js +0 -52
  252. package/dist/index-aabgympv.js +0 -39
  253. package/dist/index-atwc3csp.js +0 -256
  254. package/dist/index-cv4cvrxe.js +0 -2046
  255. package/dist/index-h7r11y4a.js +0 -539
  256. package/dist/index-hvtd936d.js +0 -1229
  257. package/dist/index-kcp7y951.js +0 -136
  258. package/dist/index-maw0jjnn.js +0 -147
  259. package/dist/index-mek9msfv.js +0 -705
  260. package/dist/index-n4xkaymm.js +0 -236
  261. package/dist/index-nkk59p3y.js +0 -579
  262. package/dist/index-phcrvs6d.js +0 -342
  263. package/dist/index-se4kw8tm.js +0 -460
  264. package/dist/index-x8s9rwfh.js +0 -2020
  265. package/dist/index-y7w3x9p1.js +0 -18
  266. package/dist/index-z9gy8w6b.js +0 -57
  267. package/dist/index-zdd0d9qa.js +0 -199
  268. package/dist/init-tb8jqgvr.js +0 -180
  269. package/dist/login-4h1sfsed.js +0 -75
  270. package/dist/previews-qr7c5j8h.js +0 -1336
  271. package/dist/productions-xpmd6bw8.js +0 -505
  272. package/dist/remote-kqcvhnfx.js +0 -192
  273. package/dist/secrets-6wbdsdek.js +0 -89
  274. package/dist/token-yp1qa70y.js +0 -419
  275. package/dist/types-15yv4cj3.js +0 -701
  276. package/dist/worker-1yg72jxg.js +0 -510
  277. package/dist/worker-entrypoint-y8s9kdcx.js +0 -15
@@ -1,701 +0,0 @@
1
- import {
2
- resolveConfigCandidatePath
3
- } from "./index-a8pnvg3r.js";
4
- import {
5
- getDependencies
6
- } from "./index-z9gy8w6b.js";
7
- import {
8
- bold,
9
- createCliTheme,
10
- dim
11
- } from "./index-maw0jjnn.js";
12
- import"./index-3t6rypgc.js";
13
- import {
14
- discoverEntrypointsAsync,
15
- resolvePackageSpecifier
16
- } from "./index-3cpzsr47.js";
17
- import {
18
- DEFAULT_DO_PATTERN,
19
- DEFAULT_ENTRYPOINT_PATTERN,
20
- findFiles
21
- } from "./index-5dkjffqz.js";
22
- import"./index-mek9msfv.js";
23
- import {
24
- loadConfig,
25
- normalizeDOBinding
26
- } from "./index-x8s9rwfh.js";
27
- import"./index-h7r11y4a.js";
28
- import"./index-04wh9bxx.js";
29
- import {
30
- findDurableObjectClasses
31
- } from "./index-4mmpccrb.js";
32
- import"./index-37x76zdn.js";
33
-
34
- // src/cli/commands/types.ts
35
- import { resolve } from "pathe";
36
-
37
- // src/cli/commands/type-generation/discovery.ts
38
- import { readFile } from "node:fs/promises";
39
- import { dirname, relative } from "pathe";
40
- var DEFAULT_INTERFACE_LOOKUP_KEYS = new Set(["Worker", "Default", "MathService"]);
41
- var interfaceTypeCache = new Map;
42
- async function readFileIfAvailable(filePath) {
43
- try {
44
- return await readFile(filePath, "utf-8");
45
- } catch {
46
- return null;
47
- }
48
- }
49
- function getInterfaceSearchKey(searchDirs) {
50
- return [...new Set(searchDirs)].sort((left, right) => left.localeCompare(right)).join("\x00");
51
- }
52
- function getPatternMatches(pattern, code) {
53
- const matches = [];
54
- pattern.lastIndex = 0;
55
- let nextMatch = pattern.exec(code);
56
- while (nextMatch !== null) {
57
- matches.push(nextMatch);
58
- nextMatch = pattern.exec(code);
59
- }
60
- return matches;
61
- }
62
- function getInterfaceBaseName(interfaceName) {
63
- if (interfaceName.endsWith("Interface")) {
64
- return interfaceName.slice(0, -9);
65
- }
66
- if (interfaceName.endsWith("Rpc")) {
67
- return interfaceName.slice(0, -3);
68
- }
69
- return null;
70
- }
71
- function registerInterfaceType(interfaces, baseName, interfaceInfo) {
72
- if (!interfaces.has(baseName)) {
73
- interfaces.set(baseName, interfaceInfo);
74
- }
75
- if (!interfaces.has("__default__") && DEFAULT_INTERFACE_LOOKUP_KEYS.has(baseName)) {
76
- interfaces.set("__default__", interfaceInfo);
77
- }
78
- }
79
- async function collectInterfaceTypesFromFile(interfaces, filePath) {
80
- const code = await readFileIfAvailable(filePath);
81
- if (!code) {
82
- return;
83
- }
84
- const interfacePattern = /export\s+interface\s+(\w+(?:Interface|Rpc))\s*\{/g;
85
- for (const match of getPatternMatches(interfacePattern, code)) {
86
- const interfaceName = match[1];
87
- const baseName = getInterfaceBaseName(interfaceName);
88
- if (!baseName) {
89
- continue;
90
- }
91
- registerInterfaceType(interfaces, baseName, {
92
- filePath,
93
- interfaceName
94
- });
95
- }
96
- }
97
- async function parseConfigForRefs(configPath) {
98
- const refs = [];
99
- const serviceBindings = [];
100
- const doBindings = [];
101
- const code = await readFileIfAvailable(configPath);
102
- if (!code) {
103
- return {
104
- refs,
105
- serviceBindings,
106
- doBindings
107
- };
108
- }
109
- const refPattern = /const\s+(\w+)\s*=\s*ref\s*\(\s*(?:'[^']*'\s*,\s*)?(?:\(\s*\)\s*=>\s*)?import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
110
- for (const match of getPatternMatches(refPattern, code)) {
111
- refs.push({
112
- varName: match[1],
113
- importPath: match[2]
114
- });
115
- }
116
- const servicePattern = /(\w+)\s*:\s*(\w+)\.worker(?:\s*\(\s*['"](\w+)['"]\s*\))?/g;
117
- for (const match of getPatternMatches(servicePattern, code)) {
118
- serviceBindings.push({
119
- bindingName: match[1],
120
- varName: match[2],
121
- entrypoint: match[3]
122
- });
123
- }
124
- const doPattern = /(\w+)\s*:\s*(\w+)\.([A-Z][A-Z0-9_]*)\s*[,\n\r}]/g;
125
- for (const match of getPatternMatches(doPattern, code)) {
126
- if (match[3] === "worker") {
127
- continue;
128
- }
129
- doBindings.push({
130
- bindingName: match[1],
131
- varName: match[2],
132
- doName: match[3]
133
- });
134
- }
135
- return {
136
- refs,
137
- serviceBindings,
138
- doBindings
139
- };
140
- }
141
- async function findInterfaceTypes(searchDirs) {
142
- const interfaces = new Map;
143
- for (const dir of [...new Set(searchDirs)]) {
144
- const typeFiles = await findFiles("**/*.types.ts", { cwd: dir });
145
- const srcFiles = await findFiles("src/**/*.ts", { cwd: dir });
146
- const allFiles = [...new Set([...typeFiles, ...srcFiles])];
147
- for (const filePath of allFiles) {
148
- await collectInterfaceTypesFromFile(interfaces, filePath);
149
- }
150
- }
151
- return interfaces;
152
- }
153
- async function getCachedInterfaceTypes(searchDirs) {
154
- const cacheKey = getInterfaceSearchKey(searchDirs);
155
- const cached = interfaceTypeCache.get(cacheKey);
156
- if (cached) {
157
- return cached;
158
- }
159
- const pending = findInterfaceTypes(searchDirs);
160
- interfaceTypeCache.set(cacheKey, pending);
161
- try {
162
- return await pending;
163
- } catch (error) {
164
- interfaceTypeCache.delete(cacheKey);
165
- throw error;
166
- }
167
- }
168
- async function discoverDurableObjects(cwd, pattern = DEFAULT_DO_PATTERN) {
169
- const discovered = [];
170
- const files = await findFiles(pattern, { cwd });
171
- for (const filePath of files) {
172
- const code = await readFileIfAvailable(filePath);
173
- if (!code) {
174
- continue;
175
- }
176
- const classNames = findDurableObjectClasses(code);
177
- for (const className of classNames) {
178
- const bindingName = className.replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").toUpperCase();
179
- discovered.push({
180
- className,
181
- filePath,
182
- bindingName
183
- });
184
- }
185
- }
186
- return discovered;
187
- }
188
- function generateImportPath(cwd, filePath) {
189
- let relativePath = relative(cwd, filePath);
190
- relativePath = relativePath.replace(/\.(ts|tsx|js|jsx)$/, "");
191
- if (!relativePath.startsWith(".") && !relativePath.startsWith("/")) {
192
- relativePath = `./${relativePath}`;
193
- }
194
- return relativePath;
195
- }
196
- async function resolveReferencedConfigs(configPath, cwd) {
197
- const referenced = [];
198
- const { refs, serviceBindings, doBindings } = await parseConfigForRefs(configPath);
199
- if (refs.length === 0) {
200
- return referenced;
201
- }
202
- const configDir = dirname(configPath);
203
- const referencedConfigDetailsByPath = new Map;
204
- for (const ref of refs) {
205
- const refImportPath = resolvePackageSpecifier(ref.importPath, configDir);
206
- const refConfigPath = await resolveConfigCandidatePath(refImportPath);
207
- if (!refConfigPath) {
208
- continue;
209
- }
210
- try {
211
- let referencedConfigDetails = referencedConfigDetailsByPath.get(refConfigPath);
212
- if (!referencedConfigDetails) {
213
- referencedConfigDetails = (async () => {
214
- const refDir2 = dirname(refConfigPath);
215
- return {
216
- refDir: refDir2,
217
- entrypoints: await discoverEntrypointsAsync(refDir2, DEFAULT_ENTRYPOINT_PATTERN),
218
- refDOs: await discoverDurableObjects(refDir2, DEFAULT_DO_PATTERN),
219
- interfaceMap: await getCachedInterfaceTypes([configDir, refDir2])
220
- };
221
- })();
222
- referencedConfigDetailsByPath.set(refConfigPath, referencedConfigDetails);
223
- }
224
- const { refDir, entrypoints, refDOs, interfaceMap } = await referencedConfigDetails;
225
- const bindings = serviceBindings.filter((serviceBinding) => serviceBinding.varName === ref.varName).map((serviceBinding) => {
226
- const info = {
227
- bindingName: serviceBinding.bindingName,
228
- entrypoint: serviceBinding.entrypoint
229
- };
230
- const lookupKey = serviceBinding.entrypoint || "__default__";
231
- const interfaceInfo = interfaceMap.get(lookupKey) || (serviceBinding.entrypoint ? interfaceMap.get(serviceBinding.entrypoint) : undefined);
232
- if (interfaceInfo) {
233
- info.interfaceImport = generateImportPath(cwd, interfaceInfo.filePath);
234
- info.interfaceType = interfaceInfo.interfaceName;
235
- }
236
- return info;
237
- });
238
- const crossWorkerDOs = doBindings.filter((doBinding) => doBinding.varName === ref.varName).map((doBinding) => {
239
- const matchingDO = refDOs.find((doInfo) => doInfo.bindingName === doBinding.doName);
240
- if (!matchingDO) {
241
- return null;
242
- }
243
- const crossWorkerDO = {
244
- bindingName: doBinding.bindingName,
245
- doName: doBinding.doName,
246
- className: matchingDO.className,
247
- filePath: matchingDO.filePath
248
- };
249
- return crossWorkerDO;
250
- }).filter((item) => item !== null);
251
- referenced.push({
252
- varName: ref.varName,
253
- importPath: ref.importPath,
254
- refDir,
255
- entrypoints,
256
- serviceBindings: bindings,
257
- durableObjects: crossWorkerDOs
258
- });
259
- } catch {}
260
- }
261
- return referenced;
262
- }
263
-
264
- // src/cli/commands/type-generation/generator.ts
265
- function generateBindingMembers(config, doClassMap, crossWorkerDOMap, serviceBindingMap, cwd, indent, options = {}) {
266
- const lines = [];
267
- const imports = [];
268
- if (config.bindings) {
269
- if (config.bindings.kv) {
270
- for (const binding of Object.keys(config.bindings.kv)) {
271
- lines.push(`${indent}${binding}: KVNamespace`);
272
- }
273
- }
274
- if (config.bindings.d1) {
275
- for (const binding of Object.keys(config.bindings.d1)) {
276
- lines.push(`${indent}${binding}: D1Database`);
277
- }
278
- }
279
- if (config.bindings.r2) {
280
- for (const binding of Object.keys(config.bindings.r2)) {
281
- lines.push(`${indent}${binding}: R2Bucket`);
282
- }
283
- }
284
- if (config.bindings.durableObjects) {
285
- for (const [binding, doConfig] of Object.entries(config.bindings.durableObjects)) {
286
- const crossWorkerDO = crossWorkerDOMap.get(binding);
287
- if (crossWorkerDO) {
288
- const importPath = generateImportPath(cwd, crossWorkerDO.filePath);
289
- lines.push(`${indent}${binding}: DurableObjectNamespace<Rpc.DurableObjectBranded & import('${importPath}').${crossWorkerDO.className}>`);
290
- continue;
291
- }
292
- const className = doConfig.className;
293
- if (className) {
294
- const classInfo = doClassMap.get(className);
295
- if (classInfo) {
296
- lines.push(`${indent}${binding}: DurableObjectNamespace<Rpc.DurableObjectBranded & import('${classInfo.importPath}').${classInfo.className}>`);
297
- continue;
298
- }
299
- }
300
- lines.push(`${indent}${binding}: DurableObjectNamespace`);
301
- }
302
- }
303
- if (config.bindings.queues?.producers) {
304
- for (const binding of Object.keys(config.bindings.queues.producers)) {
305
- lines.push(`${indent}${binding}: Queue`);
306
- }
307
- }
308
- if (config.bindings.rateLimits) {
309
- for (const binding of Object.keys(config.bindings.rateLimits)) {
310
- lines.push(`${indent}${binding}: RateLimit`);
311
- }
312
- }
313
- if (config.bindings.versionMetadata?.binding) {
314
- lines.push(`${indent}${config.bindings.versionMetadata.binding}: WorkerVersionMetadata`);
315
- }
316
- if (config.bindings.workerLoaders) {
317
- for (const binding of Object.keys(config.bindings.workerLoaders)) {
318
- lines.push(`${indent}${binding}: WorkerLoader`);
319
- }
320
- }
321
- if (config.bindings.mtlsCertificates) {
322
- for (const binding of Object.keys(config.bindings.mtlsCertificates)) {
323
- lines.push(`${indent}${binding}: Fetcher`);
324
- }
325
- }
326
- if (config.bindings.dispatchNamespaces) {
327
- for (const binding of Object.keys(config.bindings.dispatchNamespaces)) {
328
- lines.push(`${indent}${binding}: DispatchNamespace`);
329
- }
330
- }
331
- if (config.bindings.workflows) {
332
- for (const binding of Object.keys(config.bindings.workflows)) {
333
- lines.push(`${indent}${binding}: Workflow`);
334
- }
335
- }
336
- if (config.bindings.pipelines) {
337
- imports.push("import type { Pipeline } from 'cloudflare:pipelines'");
338
- for (const binding of Object.keys(config.bindings.pipelines)) {
339
- lines.push(`${indent}${binding}: Pipeline`);
340
- }
341
- }
342
- if (config.bindings.images) {
343
- for (const binding of Object.keys(config.bindings.images)) {
344
- lines.push(`${indent}${binding}: ImagesBinding`);
345
- }
346
- }
347
- if (config.bindings.media) {
348
- for (const binding of Object.keys(config.bindings.media)) {
349
- lines.push(`${indent}${binding}: MediaBinding`);
350
- }
351
- }
352
- if (config.bindings.artifacts) {
353
- for (const binding of Object.keys(config.bindings.artifacts)) {
354
- lines.push(`${indent}${binding}: Artifacts`);
355
- }
356
- }
357
- if (config.bindings.secretsStore) {
358
- for (const binding of Object.keys(config.bindings.secretsStore)) {
359
- lines.push(`${indent}${binding}: SecretsStoreSecret`);
360
- }
361
- }
362
- if (config.bindings.services) {
363
- for (const binding of Object.keys(config.bindings.services)) {
364
- const serviceInfo = serviceBindingMap.get(binding);
365
- if (serviceInfo?.interfaceType && serviceInfo.interfaceImport) {
366
- imports.push(`import type { ${serviceInfo.interfaceType} } from '${serviceInfo.interfaceImport}'`);
367
- lines.push(`${indent}${binding}: ${serviceInfo.interfaceType}`);
368
- continue;
369
- }
370
- lines.push(`${indent}${binding}: Fetcher`);
371
- }
372
- }
373
- if (config.bindings.ai) {
374
- lines.push(`${indent}${config.bindings.ai.binding}: Ai`);
375
- }
376
- if (config.bindings.aiSearchNamespaces) {
377
- for (const binding of Object.keys(config.bindings.aiSearchNamespaces)) {
378
- lines.push(`${indent}${binding}: AiSearchNamespace`);
379
- }
380
- }
381
- if (config.bindings.aiSearch) {
382
- for (const binding of Object.keys(config.bindings.aiSearch)) {
383
- lines.push(`${indent}${binding}: AiSearchInstance`);
384
- }
385
- }
386
- if (config.bindings.vectorize) {
387
- for (const binding of Object.keys(config.bindings.vectorize)) {
388
- lines.push(`${indent}${binding}: VectorizeIndex`);
389
- }
390
- }
391
- if (config.bindings.hyperdrive) {
392
- for (const binding of Object.keys(config.bindings.hyperdrive)) {
393
- lines.push(`${indent}${binding}: Hyperdrive`);
394
- }
395
- }
396
- if (config.bindings.browser) {
397
- for (const binding of Object.keys(config.bindings.browser)) {
398
- lines.push(`${indent}${binding}: Fetcher`);
399
- }
400
- }
401
- if (config.bindings.analyticsEngine) {
402
- for (const binding of Object.keys(config.bindings.analyticsEngine)) {
403
- lines.push(`${indent}${binding}: AnalyticsEngineDataset`);
404
- }
405
- }
406
- if (config.bindings.sendEmail) {
407
- for (const binding of Object.keys(config.bindings.sendEmail)) {
408
- lines.push(`${indent}${binding}: SendEmail`);
409
- }
410
- }
411
- }
412
- if (options.includeVarsAsMembers !== false && config.vars) {
413
- for (const key of Object.keys(config.vars)) {
414
- lines.push(`${indent}${key}: string`);
415
- }
416
- }
417
- if (config.secrets) {
418
- for (const secret of Object.keys(config.secrets)) {
419
- lines.push(`${indent}${secret}: string`);
420
- }
421
- }
422
- return { lines, imports };
423
- }
424
- function normalizeModuleDeclarationGlob(glob) {
425
- return glob.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\*\*\//, "");
426
- }
427
- function generateModuleRuleDeclarations(config) {
428
- const declarations = [];
429
- const seen = new Set;
430
- const typeByRuleType = {
431
- Text: "string",
432
- Data: "ArrayBuffer",
433
- CompiledWasm: "WebAssembly.Module"
434
- };
435
- for (const rule of config.rules ?? []) {
436
- const valueType = rule.type ? typeByRuleType[rule.type] : undefined;
437
- if (!valueType) {
438
- continue;
439
- }
440
- for (const glob of rule.globs ?? []) {
441
- const specifier = normalizeModuleDeclarationGlob(glob);
442
- const key = `${specifier}:${valueType}`;
443
- if (seen.has(key)) {
444
- continue;
445
- }
446
- seen.add(key);
447
- declarations.push(`declare module '${specifier}' {`);
448
- declarations.push(` const value: ${valueType}`);
449
- declarations.push("\texport default value");
450
- declarations.push("}");
451
- declarations.push("");
452
- }
453
- }
454
- return declarations;
455
- }
456
- function generateBindingTypes(config, discoveredDOs, discoveredEntrypoints, referencedConfigs, cwd, options = {}) {
457
- const doClassMap = new Map;
458
- for (const doInfo of discoveredDOs) {
459
- doClassMap.set(doInfo.className, {
460
- importPath: generateImportPath(cwd, doInfo.filePath),
461
- className: doInfo.className
462
- });
463
- }
464
- const crossWorkerDOMap = new Map;
465
- for (const ref of referencedConfigs) {
466
- for (const doInfo of ref.durableObjects) {
467
- crossWorkerDOMap.set(doInfo.bindingName, doInfo);
468
- }
469
- }
470
- const serviceBindingMap = new Map;
471
- for (const ref of referencedConfigs) {
472
- for (const serviceBinding of ref.serviceBindings) {
473
- serviceBindingMap.set(serviceBinding.bindingName, serviceBinding);
474
- }
475
- }
476
- const usedTypes = new Set;
477
- if (config.bindings) {
478
- if (config.bindings.kv && Object.keys(config.bindings.kv).length > 0)
479
- usedTypes.add("KVNamespace");
480
- if (config.bindings.d1 && Object.keys(config.bindings.d1).length > 0)
481
- usedTypes.add("D1Database");
482
- if (config.bindings.r2 && Object.keys(config.bindings.r2).length > 0)
483
- usedTypes.add("R2Bucket");
484
- if (config.bindings.durableObjects && Object.keys(config.bindings.durableObjects).length > 0)
485
- usedTypes.add("DurableObjectNamespace");
486
- if (config.bindings.queues?.producers && Object.keys(config.bindings.queues.producers).length > 0)
487
- usedTypes.add("Queue");
488
- if (config.bindings.rateLimits && Object.keys(config.bindings.rateLimits).length > 0)
489
- usedTypes.add("RateLimit");
490
- if (config.bindings.versionMetadata?.binding)
491
- usedTypes.add("WorkerVersionMetadata");
492
- if (config.bindings.workerLoaders && Object.keys(config.bindings.workerLoaders).length > 0)
493
- usedTypes.add("WorkerLoader");
494
- if (config.bindings.mtlsCertificates && Object.keys(config.bindings.mtlsCertificates).length > 0)
495
- usedTypes.add("Fetcher");
496
- if (config.bindings.dispatchNamespaces && Object.keys(config.bindings.dispatchNamespaces).length > 0)
497
- usedTypes.add("DispatchNamespace");
498
- if (config.bindings.workflows && Object.keys(config.bindings.workflows).length > 0)
499
- usedTypes.add("Workflow");
500
- if (config.bindings.images && Object.keys(config.bindings.images).length > 0)
501
- usedTypes.add("ImagesBinding");
502
- if (config.bindings.media && Object.keys(config.bindings.media).length > 0)
503
- usedTypes.add("MediaBinding");
504
- if (config.bindings.artifacts && Object.keys(config.bindings.artifacts).length > 0)
505
- usedTypes.add("Artifacts");
506
- if (config.bindings.secretsStore && Object.keys(config.bindings.secretsStore).length > 0)
507
- usedTypes.add("SecretsStoreSecret");
508
- if (config.bindings.services) {
509
- const hasUntypedServices = Object.keys(config.bindings.services).some((name) => !serviceBindingMap.get(name)?.interfaceType);
510
- if (hasUntypedServices)
511
- usedTypes.add("Fetcher");
512
- }
513
- if (config.bindings.ai)
514
- usedTypes.add("Ai");
515
- if (config.bindings.aiSearchNamespaces && Object.keys(config.bindings.aiSearchNamespaces).length > 0) {
516
- usedTypes.add("AiSearchNamespace");
517
- }
518
- if (config.bindings.aiSearch && Object.keys(config.bindings.aiSearch).length > 0) {
519
- usedTypes.add("AiSearchInstance");
520
- }
521
- if (config.bindings.vectorize && Object.keys(config.bindings.vectorize).length > 0)
522
- usedTypes.add("VectorizeIndex");
523
- if (config.bindings.hyperdrive && Object.keys(config.bindings.hyperdrive).length > 0)
524
- usedTypes.add("Hyperdrive");
525
- if (config.bindings.browser && Object.keys(config.bindings.browser).length > 0)
526
- usedTypes.add("Fetcher");
527
- if (config.bindings.analyticsEngine && Object.keys(config.bindings.analyticsEngine).length > 0)
528
- usedTypes.add("AnalyticsEngineDataset");
529
- if (config.bindings.sendEmail && Object.keys(config.bindings.sendEmail).length > 0)
530
- usedTypes.add("SendEmail");
531
- }
532
- const lines = [
533
- "// Generated by devflare - DO NOT EDIT",
534
- "// Run `devflare types` to regenerate",
535
- ""
536
- ];
537
- const hasConfigVars = Boolean(config.vars && Object.keys(config.vars).length > 0);
538
- const hasLocalDOsWithClasses = Boolean(config.bindings?.durableObjects && Object.values(config.bindings.durableObjects).some((doConfig) => doConfig.className && doClassMap.has(doConfig.className)));
539
- const hasCrossWorkerDOs = crossWorkerDOMap.size > 0;
540
- const hasDOsWithClasses = hasLocalDOsWithClasses || hasCrossWorkerDOs;
541
- if (usedTypes.size > 0) {
542
- const sortedTypes = [...usedTypes].sort();
543
- if (hasDOsWithClasses) {
544
- lines.push(`import type { ${sortedTypes.join(", ")}, Rpc } from '@cloudflare/workers-types'`);
545
- } else {
546
- lines.push(`import type { ${sortedTypes.join(", ")} } from '@cloudflare/workers-types'`);
547
- }
548
- lines.push("");
549
- }
550
- if (hasConfigVars) {
551
- const configImportPath = options.configImportPath ?? "./devflare.config";
552
- lines.push("import type { InferConfigVars } from 'devflare/config'");
553
- lines.push(`type __DevflareConfigVars = InferConfigVars<Awaited<typeof import('${configImportPath}').default>>`);
554
- lines.push("");
555
- }
556
- const { lines: bindingMembers, imports: serviceImports } = generateBindingMembers(config, doClassMap, crossWorkerDOMap, serviceBindingMap, cwd, "\t\t", { includeVarsAsMembers: !hasConfigVars });
557
- const uniqueImports = [...new Set(serviceImports)];
558
- if (uniqueImports.length > 0) {
559
- lines.push(...uniqueImports);
560
- lines.push("");
561
- }
562
- lines.push("declare global {");
563
- if (hasConfigVars) {
564
- lines.push("\tinterface DevflareVars extends __DevflareConfigVars {}");
565
- lines.push("\tinterface DevflareEnv extends __DevflareConfigVars {");
566
- } else {
567
- lines.push("\tinterface DevflareEnv {");
568
- }
569
- lines.push(...bindingMembers);
570
- lines.push("\t}");
571
- lines.push("}");
572
- lines.push("");
573
- lines.push(...generateModuleRuleDeclarations(config));
574
- if (discoveredEntrypoints.length > 0) {
575
- const entrypointNames = discoveredEntrypoints.map((entrypoint) => `'${entrypoint.className}'`).join(" | ");
576
- lines.push("/**");
577
- lines.push(" * Named entrypoints discovered from ep.*.ts files.");
578
- lines.push(" * Use with defineConfig<Entrypoints>() for type-safe cross-worker references.");
579
- lines.push(" */");
580
- lines.push(`export type Entrypoints = ${entrypointNames}`);
581
- } else {
582
- lines.push("/**");
583
- lines.push(" * Named entrypoints (none discovered - add ep.*.ts files to enable).");
584
- lines.push(" * Use with defineConfig<Entrypoints>() for type-safe cross-worker references.");
585
- lines.push(" */");
586
- lines.push("export type Entrypoints = string");
587
- }
588
- lines.push("");
589
- return lines.join(`
590
- `);
591
- }
592
-
593
- // src/cli/commands/types.ts
594
- function logTypesLine(logger, message = "") {
595
- if (typeof logger.log === "function") {
596
- logger.log(message);
597
- return;
598
- }
599
- if (typeof logger.info === "function") {
600
- logger.info(message);
601
- }
602
- }
603
- async function runTypesCommand(parsed, logger, options) {
604
- const cwd = options.cwd || process.cwd();
605
- const configPath = parsed.options.config;
606
- const outputPath = parsed.options.output || "env.d.ts";
607
- const theme = createCliTheme(parsed.options);
608
- logTypesLine(logger);
609
- logTypesLine(logger, `${bold("types", theme)} ${dim("Generating TypeScript bindings", theme)}`);
610
- try {
611
- const config = await loadConfig({ cwd, configFile: configPath });
612
- const requestedConfigPath = configPath ? resolve(cwd, configPath) : cwd;
613
- const actualConfigPath = await resolveConfigCandidatePath(requestedConfigPath);
614
- if (!actualConfigPath) {
615
- throw new Error("Could not resolve the loaded devflare config file path");
616
- }
617
- const doPattern = typeof config.files?.durableObjects === "string" ? config.files.durableObjects : DEFAULT_DO_PATTERN;
618
- let discoveredDOs = [];
619
- if (config.files?.durableObjects !== false) {
620
- discoveredDOs = await discoverDurableObjects(cwd, doPattern);
621
- if (discoveredDOs.length > 0) {
622
- logTypesLine(logger, `Discovered ${discoveredDOs.length} Durable Object class(es):`);
623
- for (const doInfo of discoveredDOs) {
624
- logTypesLine(logger, ` • ${doInfo.className} → ${doInfo.bindingName}`);
625
- }
626
- }
627
- }
628
- if (config.bindings?.durableObjects) {
629
- for (const [bindingName, doConfig] of Object.entries(config.bindings.durableObjects)) {
630
- const normalized = normalizeDOBinding(doConfig);
631
- const className = normalized.className;
632
- if (!className) {
633
- continue;
634
- }
635
- const existing = discoveredDOs.find((doInfo) => doInfo.className === className);
636
- if (existing) {
637
- continue;
638
- }
639
- if (normalized.scriptName && (normalized.scriptName.endsWith(".ts") || normalized.scriptName.endsWith(".js"))) {
640
- const filePath = resolve(cwd, "src", normalized.scriptName);
641
- discoveredDOs.push({
642
- className,
643
- filePath,
644
- bindingName
645
- });
646
- }
647
- }
648
- }
649
- const entrypointPattern = typeof config.files?.entrypoints === "string" ? config.files.entrypoints : DEFAULT_ENTRYPOINT_PATTERN;
650
- let discoveredEntrypoints = [];
651
- if (config.files?.entrypoints !== false) {
652
- discoveredEntrypoints = await discoverEntrypointsAsync(cwd, entrypointPattern);
653
- if (discoveredEntrypoints.length > 0) {
654
- logTypesLine(logger, `Discovered ${discoveredEntrypoints.length} entrypoint class(es):`);
655
- for (const entrypoint of discoveredEntrypoints) {
656
- logTypesLine(logger, ` • ${entrypoint.className}`);
657
- }
658
- }
659
- }
660
- const referencedConfigs = await resolveReferencedConfigs(actualConfigPath, cwd);
661
- if (referencedConfigs.length > 0) {
662
- logTypesLine(logger, `Found ${referencedConfigs.length} referenced worker(s):`);
663
- for (const ref of referencedConfigs) {
664
- const typedBindings = ref.serviceBindings.filter((serviceBinding) => serviceBinding.interfaceType);
665
- if (typedBindings.length > 0) {
666
- logTypesLine(logger, ` • ${ref.varName}: ${typedBindings.map((serviceBinding) => `${serviceBinding.bindingName} → ${serviceBinding.interfaceType}`).join(", ")}`);
667
- }
668
- }
669
- }
670
- const normalizedConfig = {
671
- ...config,
672
- bindings: config.bindings ? {
673
- ...config.bindings,
674
- durableObjects: config.bindings.durableObjects ? Object.fromEntries(Object.entries(config.bindings.durableObjects).map(([name, doConfig]) => {
675
- const normalized = normalizeDOBinding(doConfig);
676
- return [
677
- name,
678
- { className: normalized.className, scriptName: normalized.scriptName }
679
- ];
680
- })) : undefined
681
- } : undefined
682
- };
683
- const types = generateBindingTypes(normalizedConfig, discoveredDOs, discoveredEntrypoints, referencedConfigs, cwd, { configImportPath: generateImportPath(cwd, actualConfigPath) });
684
- const { fs } = await getDependencies();
685
- const fullPath = resolve(cwd, outputPath);
686
- await fs.writeFile(fullPath, types, "utf-8");
687
- logger.success(`Generated types: ${outputPath}`);
688
- return { exitCode: 0 };
689
- } catch (error) {
690
- if (error instanceof Error) {
691
- logger.error("Type generation failed:", error.message);
692
- if (parsed.options.debug) {
693
- logger.error(error.stack);
694
- }
695
- }
696
- return { exitCode: 1 };
697
- }
698
- }
699
- export {
700
- runTypesCommand
701
- };