@decocms/blocks 8.9.1 → 8.11.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 (409) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/protocol/channel.d.ts +98 -0
  6. package/dist/protocol/channel.d.ts.map +1 -0
  7. package/dist/protocol/channel.js +58 -0
  8. package/dist/protocol/channel.js.map +1 -0
  9. package/dist/protocol/client.js +2 -2
  10. package/dist/protocol/client.js.map +1 -1
  11. package/dist/protocol/conformance/blockMetaVectors.json +214 -0
  12. package/dist/protocol/conformance/contentHashFixtures.d.ts +22 -0
  13. package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -1
  14. package/dist/protocol/conformance/contentHashFixtures.js +55 -0
  15. package/dist/protocol/conformance/contentHashFixtures.js.map +1 -1
  16. package/dist/protocol/conformance/index.d.ts +2 -1
  17. package/dist/protocol/conformance/index.d.ts.map +1 -1
  18. package/dist/protocol/conformance/index.js +2 -1
  19. package/dist/protocol/conformance/index.js.map +1 -1
  20. package/dist/protocol/conformance/vectors.d.ts +33 -0
  21. package/dist/protocol/conformance/vectors.d.ts.map +1 -0
  22. package/dist/protocol/conformance/vectors.js +3 -0
  23. package/dist/protocol/conformance/vectors.js.map +1 -0
  24. package/dist/protocol/index.d.ts +11 -1
  25. package/dist/protocol/index.d.ts.map +1 -1
  26. package/dist/protocol/index.js +11 -1
  27. package/dist/protocol/index.js.map +1 -1
  28. package/dist/protocol/keys.d.ts +1 -1
  29. package/dist/protocol/keys.js +1 -1
  30. package/dist/v8/background.d.ts +13 -0
  31. package/dist/v8/background.d.ts.map +1 -1
  32. package/dist/v8/background.js +41 -0
  33. package/dist/v8/background.js.map +1 -1
  34. package/dist/v8/blockMeta.d.ts +27 -0
  35. package/dist/v8/blockMeta.d.ts.map +1 -0
  36. package/dist/v8/blockMeta.js +75 -0
  37. package/dist/v8/blockMeta.js.map +1 -0
  38. package/dist/v8/blockStore.d.ts +43 -0
  39. package/dist/v8/blockStore.d.ts.map +1 -0
  40. package/dist/v8/blockStore.js +95 -0
  41. package/dist/v8/blockStore.js.map +1 -0
  42. package/dist/v8/boundedJson.d.ts +5 -0
  43. package/dist/v8/boundedJson.d.ts.map +1 -1
  44. package/dist/v8/boundedJson.js +10 -2
  45. package/dist/v8/boundedJson.js.map +1 -1
  46. package/dist/v8/boundedMap.d.ts +19 -0
  47. package/dist/v8/boundedMap.d.ts.map +1 -0
  48. package/dist/v8/boundedMap.js +52 -0
  49. package/dist/v8/boundedMap.js.map +1 -0
  50. package/dist/v8/builtins/data.d.ts +18 -2
  51. package/dist/v8/builtins/data.d.ts.map +1 -1
  52. package/dist/v8/builtins/data.js +17 -1
  53. package/dist/v8/builtins/data.js.map +1 -1
  54. package/dist/v8/builtins/index.d.ts.map +1 -1
  55. package/dist/v8/builtins/index.js +2 -1
  56. package/dist/v8/builtins/index.js.map +1 -1
  57. package/dist/v8/builtins/legacy.d.ts +6 -3
  58. package/dist/v8/builtins/legacy.d.ts.map +1 -1
  59. package/dist/v8/builtins/legacy.js +6 -3
  60. package/dist/v8/builtins/legacy.js.map +1 -1
  61. package/dist/v8/canonical.d.ts +8 -0
  62. package/dist/v8/canonical.d.ts.map +1 -1
  63. package/dist/v8/canonical.js +15 -0
  64. package/dist/v8/canonical.js.map +1 -1
  65. package/dist/v8/cli/builtins.d.ts.map +1 -1
  66. package/dist/v8/cli/builtins.js +1 -0
  67. package/dist/v8/cli/builtins.js.map +1 -1
  68. package/dist/v8/cli/check/index.d.ts +10 -0
  69. package/dist/v8/cli/check/index.d.ts.map +1 -1
  70. package/dist/v8/cli/check/index.js +91 -7
  71. package/dist/v8/cli/check/index.js.map +1 -1
  72. package/dist/v8/cli/content.d.ts +12 -25
  73. package/dist/v8/cli/content.d.ts.map +1 -1
  74. package/dist/v8/cli/content.js +46 -75
  75. package/dist/v8/cli/content.js.map +1 -1
  76. package/dist/v8/cli/index.d.ts +2 -2
  77. package/dist/v8/cli/index.d.ts.map +1 -1
  78. package/dist/v8/cli/index.js +2 -2
  79. package/dist/v8/cli/index.js.map +1 -1
  80. package/dist/v8/cli/remote/commands.d.ts +71 -0
  81. package/dist/v8/cli/remote/commands.d.ts.map +1 -0
  82. package/dist/v8/cli/remote/commands.js +644 -0
  83. package/dist/v8/cli/remote/commands.js.map +1 -0
  84. package/dist/v8/cli/remote/diff.d.ts +15 -0
  85. package/dist/v8/cli/remote/diff.d.ts.map +1 -0
  86. package/dist/v8/cli/remote/diff.js +102 -0
  87. package/dist/v8/cli/remote/diff.js.map +1 -0
  88. package/dist/v8/cli/remote/env.d.ts +35 -0
  89. package/dist/v8/cli/remote/env.d.ts.map +1 -0
  90. package/dist/v8/cli/remote/env.js +84 -0
  91. package/dist/v8/cli/remote/env.js.map +1 -0
  92. package/dist/v8/cli/remote/http.d.ts +149 -0
  93. package/dist/v8/cli/remote/http.d.ts.map +1 -0
  94. package/dist/v8/cli/remote/http.js +381 -0
  95. package/dist/v8/cli/remote/http.js.map +1 -0
  96. package/dist/v8/cli/remote/local.d.ts +90 -0
  97. package/dist/v8/cli/remote/local.d.ts.map +1 -0
  98. package/dist/v8/cli/remote/local.js +309 -0
  99. package/dist/v8/cli/remote/local.js.map +1 -0
  100. package/dist/v8/cli/root.d.ts +29 -0
  101. package/dist/v8/cli/root.d.ts.map +1 -1
  102. package/dist/v8/cli/root.js +28 -0
  103. package/dist/v8/cli/root.js.map +1 -1
  104. package/dist/v8/cli/run.d.ts +13 -1
  105. package/dist/v8/cli/run.d.ts.map +1 -1
  106. package/dist/v8/cli/run.js +310 -124
  107. package/dist/v8/cli/run.js.map +1 -1
  108. package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -1
  109. package/dist/v8/cli/schema/builtinSchemas.js +28 -10
  110. package/dist/v8/cli/schema/builtinSchemas.js.map +1 -1
  111. package/dist/v8/cli/schema/generate.js +1 -1
  112. package/dist/v8/cli/schema/generate.js.map +1 -1
  113. package/dist/v8/cli/skills.d.ts +25 -0
  114. package/dist/v8/cli/skills.d.ts.map +1 -0
  115. package/dist/v8/cli/skills.js +70 -0
  116. package/dist/v8/cli/skills.js.map +1 -0
  117. package/dist/v8/client.d.ts +9 -9
  118. package/dist/v8/client.d.ts.map +1 -1
  119. package/dist/v8/client.js +138 -50
  120. package/dist/v8/client.js.map +1 -1
  121. package/dist/v8/cms.d.ts +2 -1
  122. package/dist/v8/cms.d.ts.map +1 -1
  123. package/dist/v8/cms.js +55 -46
  124. package/dist/v8/cms.js.map +1 -1
  125. package/dist/v8/content.d.ts +39 -78
  126. package/dist/v8/content.d.ts.map +1 -1
  127. package/dist/v8/content.js +155 -195
  128. package/dist/v8/content.js.map +1 -1
  129. package/dist/v8/contentIndex.d.ts +71 -0
  130. package/dist/v8/contentIndex.d.ts.map +1 -0
  131. package/dist/v8/contentIndex.js +137 -0
  132. package/dist/v8/contentIndex.js.map +1 -0
  133. package/dist/v8/draft.d.ts +7 -7
  134. package/dist/v8/draft.d.ts.map +1 -1
  135. package/dist/v8/draft.js +10 -9
  136. package/dist/v8/draft.js.map +1 -1
  137. package/dist/v8/draftChanges.d.ts +59 -32
  138. package/dist/v8/draftChanges.d.ts.map +1 -1
  139. package/dist/v8/draftChanges.js +139 -75
  140. package/dist/v8/draftChanges.js.map +1 -1
  141. package/dist/v8/errors.d.ts +21 -0
  142. package/dist/v8/errors.d.ts.map +1 -1
  143. package/dist/v8/errors.js +22 -0
  144. package/dist/v8/errors.js.map +1 -1
  145. package/dist/v8/hostedSource.d.ts +57 -0
  146. package/dist/v8/hostedSource.d.ts.map +1 -0
  147. package/dist/v8/hostedSource.js +18 -0
  148. package/dist/v8/hostedSource.js.map +1 -0
  149. package/dist/v8/identity.d.ts +1 -1
  150. package/dist/v8/identity.js +1 -1
  151. package/dist/v8/index.d.ts +1 -0
  152. package/dist/v8/index.d.ts.map +1 -1
  153. package/dist/v8/index.js +1 -0
  154. package/dist/v8/index.js.map +1 -1
  155. package/dist/v8/matchRoute.js +7 -4
  156. package/dist/v8/matchRoute.js.map +1 -1
  157. package/dist/v8/pin.d.ts +34 -0
  158. package/dist/v8/pin.d.ts.map +1 -0
  159. package/dist/v8/pin.js +156 -0
  160. package/dist/v8/pin.js.map +1 -0
  161. package/dist/v8/preview/StudioBridge.d.ts +8 -8
  162. package/dist/v8/preview/StudioBridge.d.ts.map +1 -1
  163. package/dist/v8/preview/StudioBridge.js +8 -10
  164. package/dist/v8/preview/StudioBridge.js.map +1 -1
  165. package/dist/v8/preview/StudioChannel.d.ts +51 -0
  166. package/dist/v8/preview/StudioChannel.d.ts.map +1 -0
  167. package/dist/v8/preview/StudioChannel.js +104 -0
  168. package/dist/v8/preview/StudioChannel.js.map +1 -0
  169. package/dist/v8/preview/index.d.ts +3 -0
  170. package/dist/v8/preview/index.d.ts.map +1 -1
  171. package/dist/v8/preview/index.js +3 -0
  172. package/dist/v8/preview/index.js.map +1 -1
  173. package/dist/v8/remoteLoader.d.ts +42 -5
  174. package/dist/v8/remoteLoader.d.ts.map +1 -1
  175. package/dist/v8/remoteLoader.js +317 -259
  176. package/dist/v8/remoteLoader.js.map +1 -1
  177. package/dist/v8/resolver.d.ts +22 -8
  178. package/dist/v8/resolver.d.ts.map +1 -1
  179. package/dist/v8/resolver.js +37 -32
  180. package/dist/v8/resolver.js.map +1 -1
  181. package/dist/v8/revisionId.d.ts +11 -0
  182. package/dist/v8/revisionId.d.ts.map +1 -0
  183. package/dist/v8/revisionId.js +13 -0
  184. package/dist/v8/revisionId.js.map +1 -0
  185. package/dist/v8/settings.d.ts +6 -6
  186. package/dist/v8/settings.d.ts.map +1 -1
  187. package/dist/v8/settings.js +8 -7
  188. package/dist/v8/settings.js.map +1 -1
  189. package/dist/v8/telemetry.d.ts +4 -2
  190. package/dist/v8/telemetry.d.ts.map +1 -1
  191. package/dist/v8/telemetry.js +2 -2
  192. package/dist/v8/telemetry.js.map +1 -1
  193. package/dist/v8/types.d.ts +52 -40
  194. package/dist/v8/types.d.ts.map +1 -1
  195. package/dist/v8/variants.d.ts +7 -2
  196. package/dist/v8/variants.d.ts.map +1 -1
  197. package/dist/v8/variants.js +21 -24
  198. package/dist/v8/variants.js.map +1 -1
  199. package/dist/v8/vite/index.d.ts +2 -2
  200. package/dist/v8/vite/index.js +1 -1
  201. package/dist/v8/vite/index.js.map +1 -1
  202. package/package.json +3 -2
  203. package/skills/deco-apps/SKILL.md +82 -0
  204. package/skills/deco-apps/references/algolia.md +51 -0
  205. package/skills/deco-apps/references/commerce-types.md +132 -0
  206. package/skills/deco-apps/references/instrumented-fetch.md +144 -0
  207. package/skills/deco-apps/references/magento.md +55 -0
  208. package/skills/deco-apps/references/messaging.md +76 -0
  209. package/skills/deco-apps/references/shopify.md +69 -0
  210. package/skills/deco-apps/references/vendored-loaders.md +135 -0
  211. package/skills/deco-apps/references/vtex-cookies-auth.md +146 -0
  212. package/skills/deco-apps/references/vtex.md +150 -0
  213. package/skills/deco-apps/references/wake.md +75 -0
  214. package/skills/deco-cms-schema/SKILL.md +80 -0
  215. package/skills/deco-cms-schema/references/annotations.md +147 -0
  216. package/skills/deco-cms-schema/references/content-hygiene.md +91 -0
  217. package/skills/deco-cms-schema/references/formats-and-widgets.md +112 -0
  218. package/skills/deco-cms-schema/references/shapes-that-break-the-form.md +165 -0
  219. package/skills/deco-cms-schema/references/types-to-fields.md +112 -0
  220. package/skills/deco-go-live/SKILL.md +127 -0
  221. package/skills/deco-go-live/references/content-releases.md +90 -0
  222. package/skills/deco-go-live/references/process.md +106 -0
  223. package/skills/deco-go-live/references/proxy-headers-checkout.md +139 -0
  224. package/skills/deco-go-live/references/qa-checklist-template.md +150 -0
  225. package/skills/deco-go-live/references/qa-inventory.md +120 -0
  226. package/skills/deco-go-live/references/react-spa.md +183 -0
  227. package/skills/deco-go-live/references/seo-analytics.md +114 -0
  228. package/skills/deco-go-live/references/traffic-ramp.md +87 -0
  229. package/skills/deco-go-live/references/worker-runtime.md +93 -0
  230. package/skills/deco-go-live/scripts/preflight.sh +221 -0
  231. package/skills/deco-images-media/SKILL.md +64 -0
  232. package/skills/deco-images-media/references/asset-upload.md +191 -0
  233. package/skills/deco-images-media/references/components-per-binding.md +167 -0
  234. package/skills/deco-images-media/references/providers-and-cdn.md +145 -0
  235. package/skills/deco-images-media/references/quality-and-lcp.md +93 -0
  236. package/skills/deco-images-media/references/troubleshooting.md +147 -0
  237. package/skills/deco-images-media/references/video.md +122 -0
  238. package/skills/deco-make-editable/SKILL.md +94 -0
  239. package/skills/deco-make-editable/references/a11y-and-e2e.md +104 -0
  240. package/skills/deco-make-editable/references/content-shapes.md +198 -0
  241. package/skills/deco-make-editable/references/from-figma.md +110 -0
  242. package/skills/deco-make-editable/references/i18n-fields.md +112 -0
  243. package/skills/deco-make-editable/references/inventory.md +79 -0
  244. package/skills/deco-make-editable/references/pixel-parity.md +175 -0
  245. package/skills/deco-make-editable/references/seeding-content.md +119 -0
  246. package/skills/deco-nextjs-site/SKILL.md +74 -0
  247. package/skills/deco-nextjs-site/references/caching.md +116 -0
  248. package/skills/deco-nextjs-site/references/metadata-seo.md +100 -0
  249. package/skills/deco-nextjs-site/references/proxy-and-drafts.md +177 -0
  250. package/skills/deco-nextjs-site/references/rendering.md +171 -0
  251. package/skills/deco-nextjs-site/references/setup.md +190 -0
  252. package/skills/deco-nextjs-site/references/studio-bridge.md +130 -0
  253. package/skills/deco-site-authoring/SKILL.md +75 -0
  254. package/skills/deco-site-authoring/references/lazy-blocks.md +155 -0
  255. package/skills/deco-site-authoring/references/loaders.md +192 -0
  256. package/skills/deco-site-authoring/references/pages.md +156 -0
  257. package/skills/deco-site-authoring/references/review-before-publish.md +95 -0
  258. package/skills/deco-site-authoring/references/sections.md +158 -0
  259. package/skills/deco-site-authoring/references/seo.md +116 -0
  260. package/skills/deco-site-workflow/SKILL.md +92 -0
  261. package/skills/deco-site-workflow/references/check.md +116 -0
  262. package/skills/deco-site-workflow/references/cli-reference.md +104 -0
  263. package/skills/deco-site-workflow/references/content-layout.md +93 -0
  264. package/skills/deco-site-workflow/references/content-sync.md +146 -0
  265. package/skills/deco-site-workflow/references/delivery.md +51 -0
  266. package/skills/deco-site-workflow/references/deploy.md +87 -0
  267. package/skills/deco-site-workflow/references/schema.md +173 -0
  268. package/skills/deco-site-workflow/references/serve-and-studio.md +138 -0
  269. package/skills/deco-storefront-caching/SKILL.md +67 -0
  270. package/skills/deco-storefront-caching/references/cache-keys.md +129 -0
  271. package/skills/deco-storefront-caching/references/case-study.md +82 -0
  272. package/skills/deco-storefront-caching/references/egress-traps.md +153 -0
  273. package/skills/deco-storefront-caching/references/nextjs.md +60 -0
  274. package/skills/deco-storefront-caching/references/perf-guardrails-e2e.md +123 -0
  275. package/skills/deco-storefront-caching/references/verification.md +136 -0
  276. package/skills/deco-storefront-caching/references/worker-page-cache.md +160 -0
  277. package/skills/deco-storefront-caching/scripts/html-anatomy.mjs +97 -0
  278. package/skills/deco-storefront-performance/SKILL.md +81 -0
  279. package/skills/deco-storefront-performance/references/cls-third-party.md +90 -0
  280. package/skills/deco-storefront-performance/references/hydration.md +116 -0
  281. package/skills/deco-storefront-performance/references/loaders-n-plus-1.md +107 -0
  282. package/skills/deco-storefront-performance/references/navigation-ux.md +130 -0
  283. package/skills/deco-storefront-performance/references/payload-trim.md +163 -0
  284. package/skills/deco-storefront-performance/references/render-location.md +152 -0
  285. package/skills/deco-storefront-performance/references/request-dedupe.md +147 -0
  286. package/skills/deco-storefront-performance/references/trace-reading.md +79 -0
  287. package/skills/deco-storefront-performance/references/worker-memory.md +176 -0
  288. package/skills/deco-tanstack-site/SKILL.md +68 -0
  289. package/skills/deco-tanstack-site/references/document-and-security.md +155 -0
  290. package/skills/deco-tanstack-site/references/router-and-navigation.md +137 -0
  291. package/skills/deco-tanstack-site/references/routes-and-pages.md +183 -0
  292. package/skills/deco-tanstack-site/references/server-functions.md +123 -0
  293. package/skills/deco-tanstack-site/references/setup.md +153 -0
  294. package/skills/deco-tanstack-site/references/worker-entry.md +152 -0
  295. package/skills/deco-v7-to-v8-migration/SKILL.md +122 -0
  296. package/skills/deco-v7-to-v8-migration/references/caching-and-privacy.md +10 -0
  297. package/skills/deco-v7-to-v8-migration/references/content.md +25 -0
  298. package/skills/deco-v7-to-v8-migration/references/editor-forms.md +27 -0
  299. package/skills/deco-v7-to-v8-migration/references/faststore.md +40 -0
  300. package/skills/deco-v7-to-v8-migration/references/framework-code.md +53 -0
  301. package/skills/deco-v7-to-v8-migration/references/hosted-releases.md +16 -0
  302. package/skills/deco-v7-to-v8-migration/references/import-map.md +81 -0
  303. package/skills/deco-v7-to-v8-migration/references/legacy-names.md +33 -0
  304. package/skills/deco-v7-to-v8-migration/references/manual-steps.md +10 -0
  305. package/skills/deco-v7-to-v8-migration/references/native-apps.md +43 -0
  306. package/skills/deco-v7-to-v8-migration/references/nextjs.md +19 -0
  307. package/skills/deco-v7-to-v8-migration/references/parity.md +66 -0
  308. package/skills/deco-v7-to-v8-migration/references/rendering.md +13 -0
  309. package/skills/deco-v7-to-v8-migration/references/running-the-script.md +29 -0
  310. package/skills/deco-v7-to-v8-migration/references/script-steps.md +13 -0
  311. package/skills/deco-v7-to-v8-migration/references/server-functions.md +15 -0
  312. package/skills/deco-v7-to-v8-migration/references/sibling-port.md +11 -0
  313. package/skills/deco-v7-to-v8-migration/references/site-code.md +15 -0
  314. package/skills/deco-v7-to-v8-migration/references/telemetry.md +10 -0
  315. package/skills/deco-v7-to-v8-migration/references/verify.md +20 -0
  316. package/skills/deco-v7-to-v8-migration/scripts/apps.ts +297 -0
  317. package/skills/deco-v7-to-v8-migration/scripts/asyncRendering.ts +73 -0
  318. package/skills/deco-v7-to-v8-migration/scripts/blockMap.ts +584 -0
  319. package/skills/deco-v7-to-v8-migration/scripts/ciSchemaCheck.ts +145 -0
  320. package/skills/deco-v7-to-v8-migration/scripts/compat.ts +357 -0
  321. package/skills/deco-v7-to-v8-migration/scripts/content.ts +121 -0
  322. package/skills/deco-v7-to-v8-migration/scripts/experiments.ts +81 -0
  323. package/skills/deco-v7-to-v8-migration/scripts/framework.ts +61 -0
  324. package/skills/deco-v7-to-v8-migration/scripts/imageCopy.ts +276 -0
  325. package/skills/deco-v7-to-v8-migration/scripts/imageModule.ts +285 -0
  326. package/skills/deco-v7-to-v8-migration/scripts/imports.ts +942 -0
  327. package/skills/deco-v7-to-v8-migration/scripts/invoke.ts +624 -0
  328. package/skills/deco-v7-to-v8-migration/scripts/legacyNames.ts +45 -0
  329. package/skills/deco-v7-to-v8-migration/scripts/main.ts +59 -0
  330. package/skills/deco-v7-to-v8-migration/scripts/matchers.ts +41 -0
  331. package/skills/deco-v7-to-v8-migration/scripts/migrate.ts +176 -0
  332. package/skills/deco-v7-to-v8-migration/scripts/redirects.ts +455 -0
  333. package/skills/deco-v7-to-v8-migration/scripts/report.ts +50 -0
  334. package/skills/deco-v7-to-v8-migration/scripts/scaffold.ts +1119 -0
  335. package/skills/deco-v7-to-v8-migration/scripts/secrets.ts +35 -0
  336. package/skills/deco-v7-to-v8-migration/scripts/sectionLoaders.ts +216 -0
  337. package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +261 -0
  338. package/skills/deco-v7-to-v8-migration/scripts/stubs.ts +388 -0
  339. package/skills/deco-v7-to-v8-migration/scripts/tsconfig.json +7 -0
  340. package/skills/deco-v7-to-v8-migration/scripts/vendor.ts +249 -0
  341. package/skills/deco-v7-to-v8-migration/scripts/vtexInvoke.ts +240 -0
  342. package/skills/deco-v7-to-v8-migration/scripts/walk.ts +30 -0
  343. package/skills/deco-variants/SKILL.md +57 -0
  344. package/skills/deco-variants/references/caching-variants.md +63 -0
  345. package/skills/deco-variants/references/custom-matchers.md +83 -0
  346. package/skills/deco-variants/references/draft-preview.md +59 -0
  347. package/skills/deco-variants/references/experiments-and-campaigns.md +104 -0
  348. package/skills/deco-variants/references/multivariate.md +85 -0
  349. package/skills/deco-variants/references/v7-matchers.md +71 -0
  350. package/src/index.ts +2 -0
  351. package/src/protocol/channel.ts +127 -0
  352. package/src/protocol/client.ts +2 -2
  353. package/src/protocol/conformance/blockMetaVectors.json +214 -0
  354. package/src/protocol/conformance/contentHashFixtures.ts +74 -0
  355. package/src/protocol/conformance/index.ts +9 -1
  356. package/src/protocol/conformance/vectors.ts +36 -0
  357. package/src/protocol/index.ts +32 -0
  358. package/src/protocol/keys.ts +1 -1
  359. package/src/v8/background.ts +42 -0
  360. package/src/v8/blockMeta.ts +100 -0
  361. package/src/v8/blockStore.ts +124 -0
  362. package/src/v8/boundedJson.ts +20 -2
  363. package/src/v8/boundedMap.ts +53 -0
  364. package/src/v8/builtins/data.ts +26 -2
  365. package/src/v8/builtins/index.ts +2 -1
  366. package/src/v8/builtins/legacy.ts +6 -3
  367. package/src/v8/canonical.ts +15 -0
  368. package/src/v8/cli/builtins.ts +1 -0
  369. package/src/v8/cli/check/index.ts +97 -7
  370. package/src/v8/cli/content.ts +49 -91
  371. package/src/v8/cli/index.ts +2 -2
  372. package/src/v8/cli/remote/commands.ts +834 -0
  373. package/src/v8/cli/remote/diff.ts +100 -0
  374. package/src/v8/cli/remote/env.ts +107 -0
  375. package/src/v8/cli/remote/http.ts +484 -0
  376. package/src/v8/cli/remote/local.ts +343 -0
  377. package/src/v8/cli/root.ts +40 -0
  378. package/src/v8/cli/run.ts +366 -135
  379. package/src/v8/cli/schema/builtinSchemas.ts +29 -10
  380. package/src/v8/cli/schema/generate.ts +1 -1
  381. package/src/v8/cli/skills.ts +91 -0
  382. package/src/v8/client.ts +162 -60
  383. package/src/v8/cms.ts +62 -53
  384. package/src/v8/content.ts +179 -229
  385. package/src/v8/contentIndex.ts +183 -0
  386. package/src/v8/draft.ts +15 -14
  387. package/src/v8/draftChanges.ts +151 -85
  388. package/src/v8/errors.ts +37 -0
  389. package/src/v8/hostedSource.ts +67 -0
  390. package/src/v8/identity.ts +1 -1
  391. package/src/v8/index.ts +1 -0
  392. package/src/v8/matchRoute.ts +7 -4
  393. package/src/v8/pin.ts +176 -0
  394. package/src/v8/preview/StudioBridge.ts +8 -10
  395. package/src/v8/preview/StudioChannel.ts +116 -0
  396. package/src/v8/preview/index.ts +3 -0
  397. package/src/v8/remoteLoader.ts +350 -286
  398. package/src/v8/resolver.ts +56 -33
  399. package/src/v8/revisionId.ts +14 -0
  400. package/src/v8/settings.ts +10 -9
  401. package/src/v8/telemetry.ts +3 -3
  402. package/src/v8/types.ts +52 -40
  403. package/src/v8/variants.ts +30 -26
  404. package/src/v8/vite/index.ts +3 -3
  405. package/dist/v8/cli/serve/server.d.ts +0 -29
  406. package/dist/v8/cli/serve/server.d.ts.map +0 -1
  407. package/dist/v8/cli/serve/server.js +0 -296
  408. package/dist/v8/cli/serve/server.js.map +0 -1
  409. package/src/v8/cli/serve/server.ts +0 -348
@@ -0,0 +1,455 @@
1
+ /**
2
+ * Redirects (spec: routing › Redirects): v8 routes the rules of one saved
3
+ * block, `Redirects`, of the built-in type `redirects`; it routes no v7
4
+ * redirect block. This step folds every v7 one into `Redirects`:
5
+ *
6
+ * - a per-rule `website/loaders/redirect.ts` block,
7
+ * `{ redirect: { from, to, type?, discardQueryParameters? } }`;
8
+ * - a list `website/loaders/redirects.ts` block,
9
+ * `{ redirects: [{ from, to, type?, discardQueryParameters? }] }`;
10
+ * - a list `deco-sites/std/loaders/x/redirects.ts` block, the same shape;
11
+ * - a `website/loaders/redirectsFromCsv.ts` loader, saved or inline in another
12
+ * block (`site.routes`), `{ from: "static/redirects.csv",
13
+ * forcePermanentRedirects? }`: the rows of its CSV file.
14
+ *
15
+ * These are what 7.x routed: `loadRedirects` in 7.x's `sdk/redirects.ts`
16
+ * reads `redirects` or `redirect` from any saved block of the first three
17
+ * types (and of the CSV type), and 7.x's build (`buildCsvRedirectBlocks`)
18
+ * read every CSV loader, saved or nested anywhere, from the site's `public/`
19
+ * (`static/x.csv`, `public/x.csv`, `/x.csv` or `x.csv` all name
20
+ * `public/x.csv`, and `../x.csv` the site's `x.csv`). A CSV is parsed as 7.x's `parseRedirectsCsv` did: one rule
21
+ * a line, `from,to` then `type` (`permanent`, `301` or `temporary`) and
22
+ * `discardQueryParameters` (`true` or `false`) recognized by value in any
23
+ * later column; fields split on `,` (and on `;` outside quotes); blank lines,
24
+ * `#` comments and a `from,to` header row skipped; a row with no type is
25
+ * temporary, or permanent under the loader's `forcePermanentRedirects` (any
26
+ * loader of the same file setting it). 7.x loaded the CSV rows before the
27
+ * saved blocks.
28
+ *
29
+ * Each rule becomes `{ from, to, permanent }` (v7's `type: "permanent"` or
30
+ * `"301"` is `permanent: true`, a 301; anything else, `temporary` or none, is
31
+ * `permanent: false`, a 307 in v8), `from` and `to` trimmed as v7 read them
32
+ * (an absolute `from`, `https://store.com/x`, is its path, as 7.x matched
33
+ * it), with `discardQueryParameters` kept. Rules are deduped by `from`, in
34
+ * 7.x's load order: the CSV rows, file by file in the order the loaders are
35
+ * found, then the v7 blocks in code-unit name order, each in its own order.
36
+ * For one exact `from` the last rule wins, as in 7.x's exact map (a later
37
+ * block, a later row; so a saved block's rule wins over a CSV row); for a
38
+ * glob (a `*` in `from`) the first wins, as 7.x scanned its patterns in
39
+ * order. An existing `Redirects` block's rules come first and always win
40
+ * (they are v8's already). Every rule that loses to one sending its route
41
+ * somewhere else is reported. The v7 blocks and
42
+ * the CSV loaders are deleted once folded (the CSV files are kept, and
43
+ * reported); a second run changes nothing.
44
+ *
45
+ * A v7 redirect written inline in another block (not a saved block of its
46
+ * own) is reported, not folded: v7 routed only saved blocks. A CSV loader
47
+ * whose file 7.x couldn't read (a URL, a path outside the site, a missing
48
+ * file) is left as it is and reported: 7.x routed none of its rows (a saved
49
+ * one's own `redirects`, which 7.x routed, are named in the report).
50
+ */
51
+ import fs from "node:fs";
52
+ import path from "node:path";
53
+ import { blockFileName, serializeBlock } from "@decocms/blocks/protocol/keys";
54
+ import type { Report } from "./report";
55
+ import { forEachBlock, isPlainObject, type JsonObject, readContent } from "./walk";
56
+
57
+ export const REDIRECTS_BLOCK = "Redirects";
58
+ export const REDIRECTS_TYPE = "redirects";
59
+ /** v7's per-rule redirect block type. */
60
+ export const V7_REDIRECT_TYPE = "website/loaders/redirect.ts";
61
+ /** v7's list-of-rules redirect block type. */
62
+ export const V7_REDIRECTS_TYPE = "website/loaders/redirects.ts";
63
+ /** The std app's list-of-rules redirect block type, which v7 routed too. */
64
+ export const V7_STD_REDIRECTS_TYPE = "deco-sites/std/loaders/x/redirects.ts";
65
+ const V7_TYPES = new Set([V7_REDIRECT_TYPE, V7_REDIRECTS_TYPE, V7_STD_REDIRECTS_TYPE]);
66
+ /** v7's CSV redirects loader: its rules live in a CSV file under `public/`. */
67
+ export const V7_CSV_REDIRECTS_TYPE = "website/loaders/redirectsFromCsv.ts";
68
+ const ROUTING_DOC = "/next/routing#redirects";
69
+
70
+ /** A v8 rule, as the `redirects` built-in stores it. */
71
+ interface Rule {
72
+ from: string;
73
+ to: string;
74
+ permanent: boolean;
75
+ discardQueryParameters?: boolean;
76
+ }
77
+
78
+ /** An absolute source as the path 7.x matched (`sourcePath`): origin dropped, query kept. */
79
+ function sourcePath(from: string): string {
80
+ if (!from.startsWith("http://") && !from.startsWith("https://")) return from;
81
+ try {
82
+ const url = new URL(from);
83
+ return url.pathname + url.search;
84
+ } catch {
85
+ const slash = from.indexOf("/", from.indexOf("//") + 2);
86
+ return slash >= 0 ? from.slice(slash) : from;
87
+ }
88
+ }
89
+
90
+ /** A v7 rule (`{ from, to, type? }`) as a v8 rule; null when it has no string `from`/`to`. */
91
+ function fromV7(rule: unknown): Rule | null {
92
+ if (!isPlainObject(rule)) return null;
93
+ // A list rule saved in the per-rule shape, `{ redirect: { … } }`, reads the same.
94
+ const flat = isPlainObject(rule.redirect) ? rule.redirect : rule;
95
+ const { type, discardQueryParameters } = flat;
96
+ // Trimmed, as v7 read them; v7's `isPermanent` takes "301" too.
97
+ const from = typeof flat.from === "string" ? sourcePath(flat.from.trim()) : "";
98
+ const to = typeof flat.to === "string" ? flat.to.trim() : "";
99
+ if (from === "" || to === "") return null;
100
+ const out: Rule = { from, to, permanent: type === "permanent" || type === "301" };
101
+ if (typeof discardQueryParameters === "boolean") {
102
+ out.discardQueryParameters = discardQueryParameters;
103
+ }
104
+ return out;
105
+ }
106
+
107
+ /** The v7 rules a saved v7 redirect block holds, in order: `redirects ?? redirect`, as v7 read them. */
108
+ function v7Rules(block: JsonObject): unknown[] {
109
+ const entries = block.redirects ?? block.redirect;
110
+ if (entries === undefined || entries === null) return [];
111
+ return Array.isArray(entries) ? entries : [entries];
112
+ }
113
+
114
+ /** Where a rule sends its route: what makes two rules for one `from` the same rule. */
115
+ function target(rule: unknown): string {
116
+ if (!isPlainObject(rule)) return JSON.stringify(rule);
117
+ return JSON.stringify([rule.to, rule.permanent === true, rule.discardQueryParameters === true]);
118
+ }
119
+
120
+ const byCodeUnit = (a: string, b: string) => (a < b ? -1 : a > b ? 1 : 0);
121
+
122
+ // ---------------------------------------------------------------------------
123
+ // CSV files, read as 7.x read them
124
+ // ---------------------------------------------------------------------------
125
+
126
+ const TYPE_VALUES = ["temporary", "permanent", "301"];
127
+ const DISCARD_VALUES = ["true", "false"];
128
+ /** 7.x's (and Fresh's) field split: a comma always splits; a semicolon only outside quotes. */
129
+ const FIELD_SPLIT = /,|;(?=(?:(?:[^"]*"){2})*[^"]*$)/;
130
+
131
+ /** Removes and returns the first field that is one of `values`. */
132
+ function takeValue(fields: string[], values: string[]): string | null {
133
+ const index = fields.findIndex((field) => values.includes(field));
134
+ return index === -1 ? null : fields.splice(index, 1)[0]!;
135
+ }
136
+
137
+ /**
138
+ * The rows of a CSV as v7 rules, `{ from, to, type, discardQueryParameters? }`,
139
+ * and how many lines have no `from` and `to` (7.x skipped them). Blank lines,
140
+ * `#` comments and a `from,to` header row aren't rows.
141
+ */
142
+ function parseRedirectsCsv(
143
+ csv: string,
144
+ forcePermanentRedirects: boolean,
145
+ ): { rows: JsonObject[]; skipped: number } {
146
+ const rows: JsonObject[] = [];
147
+ let skipped = 0;
148
+ for (const raw of csv.split(/\r\n|\r|\n/)) {
149
+ const line = raw.trim();
150
+ if (!line || line.startsWith("#")) continue;
151
+ const fields = line.split(FIELD_SPLIT).map((field) => field.trim());
152
+ const type =
153
+ takeValue(fields, TYPE_VALUES) ?? (forcePermanentRedirects ? "permanent" : "temporary");
154
+ const discard = takeValue(fields, DISCARD_VALUES) === "true";
155
+ const [from, to] = fields;
156
+ if (!from || !to) {
157
+ skipped += 1;
158
+ continue;
159
+ }
160
+ // A header row, once or repeated where files were concatenated.
161
+ if (from.toLowerCase() === "from" && to.toLowerCase() === "to") continue;
162
+ rows.push({ from, to, type, ...(discard ? { discardQueryParameters: true } : {}) });
163
+ }
164
+ return { rows, skipped };
165
+ }
166
+
167
+ /**
168
+ * A CSV loader's file, as 7.x resolved it (`path.resolve(public, from)` once
169
+ * a leading `static/`, `public/` or `/` is dropped, so `../x.csv` is the
170
+ * site's `x.csv`), or why 7.x couldn't read it.
171
+ */
172
+ function csvFile(root: string, from: unknown): { file: string } | { problem: string } {
173
+ if (typeof from !== "string" || from.trim() === "") return { problem: "it names no file" };
174
+ const written = from.trim();
175
+ if (/^[a-z][a-z\d+.-]*:/i.test(written)) {
176
+ return { problem: `${written} is a URL, which 7.x never fetched (it read only files)` };
177
+ }
178
+ const relative = written.replace(/^\/?(?:static|public)\//i, "").replace(/^\//, "");
179
+ const full = path.resolve(root, "public", relative);
180
+ const inside = path.relative(root, full);
181
+ if (inside === "" || inside.startsWith("..") || path.isAbsolute(inside)) {
182
+ return { problem: `${written} names ${full}, outside the site` };
183
+ }
184
+ const file = inside.split(path.sep).join("/");
185
+ if (!fs.existsSync(full) || !fs.statSync(full).isFile()) {
186
+ return { problem: `${file} (from ${written}) doesn't exist` };
187
+ }
188
+ return { file };
189
+ }
190
+
191
+ /** A CSV loader found in the content: in a saved block, or the saved block itself. */
192
+ interface CsvLoader {
193
+ /** The saved block holding it. */
194
+ block: string;
195
+ /** The loader is the saved block itself, not inline in it. */
196
+ saved: boolean;
197
+ node: JsonObject;
198
+ /** The CSV file it reads (`public/…`), or why it can't be read. */
199
+ file?: string;
200
+ problem?: string;
201
+ }
202
+
203
+ /** Removes every object in `value` that `drop` picks, from its array or its key; true when one was. */
204
+ function removeNodes(value: unknown, drop: (node: JsonObject) => boolean): boolean {
205
+ let removed = false;
206
+ if (Array.isArray(value)) {
207
+ for (let i = value.length - 1; i >= 0; i--) {
208
+ if (isPlainObject(value[i]) && drop(value[i] as JsonObject)) {
209
+ value.splice(i, 1);
210
+ removed = true;
211
+ } else if (removeNodes(value[i], drop)) removed = true;
212
+ }
213
+ return removed;
214
+ }
215
+ if (!isPlainObject(value)) return false;
216
+ for (const [key, child] of Object.entries(value)) {
217
+ if (isPlainObject(child) && drop(child)) {
218
+ delete value[key];
219
+ removed = true;
220
+ } else if (removeNodes(child, drop)) removed = true;
221
+ }
222
+ return removed;
223
+ }
224
+
225
+ export function foldRedirects(root: string, report: Report): void {
226
+ const blocksDir = path.join(root, ".deco", "blocks");
227
+ const { blocks, files } = readContent(root);
228
+ const subject = (name: string) => `.deco/blocks/${files[name]}`;
229
+ const names = Object.keys(blocks).sort(byCodeUnit);
230
+
231
+ // Every CSV loader, saved or inline, in block name order, outermost first.
232
+ const loaders: CsvLoader[] = [];
233
+ for (const name of names) {
234
+ forEachBlock(blocks[name], (node) => {
235
+ if (node.__resolveType !== V7_CSV_REDIRECTS_TYPE) return;
236
+ loaders.push({
237
+ block: name,
238
+ saved: node === blocks[name],
239
+ node,
240
+ ...csvFile(root, node.from),
241
+ });
242
+ });
243
+ }
244
+ for (const loader of loaders) {
245
+ if (loader.problem === undefined) continue;
246
+ // 7.x routed a saved loader's own `redirects` even when its file was missing.
247
+ const own = loader.saved ? v7Rules(loader.node).length : 0;
248
+ const routed =
249
+ own > 0
250
+ ? `, and the ${own === 1 ? "rule" : `${own} rules`} in its own "redirects", which 7.x routed`
251
+ : "";
252
+ report.manual.push({
253
+ step: "content",
254
+ subject: subject(loader.block),
255
+ message: `holds a v7 CSV redirects loader (${V7_CSV_REDIRECTS_TYPE}) whose file wasn't read: ${loader.problem}. 7.x routed none of its rows; if the site needs them, add each row to the "${REDIRECTS_BLOCK}" block (type "${REDIRECTS_TYPE}"; a row typed permanent or 301, or one with no type under forcePermanentRedirects, is permanent: true)${routed}, then remove the loader (${ROUTING_DOC})`,
256
+ });
257
+ }
258
+ const readable = loaders.filter((loader) => loader.file !== undefined);
259
+
260
+ // v7 redirects inline in another block: reported, never folded.
261
+ for (const name of names) {
262
+ let inline = 0;
263
+ for (const value of Object.values(blocks[name]!)) {
264
+ forEachBlock(value, (node) => {
265
+ if (V7_TYPES.has(node.__resolveType)) inline += 1;
266
+ });
267
+ }
268
+ if (inline === 0) continue;
269
+ report.manual.push({
270
+ step: "content",
271
+ subject: subject(name),
272
+ message: `holds ${inline === 1 ? "a v7 redirect" : `${inline} v7 redirects`} inline (${[...V7_TYPES].join(" or ")}), which v8 doesn't route: if v7 routed them, add their rules to the "${REDIRECTS_BLOCK}" block (type "${REDIRECTS_TYPE}") and remove them here (${ROUTING_DOC})`,
273
+ });
274
+ }
275
+
276
+ // The saved blocks folded and deleted: the v7 redirect blocks, and each
277
+ // saved CSV loader whose file is read (7.x routed its own `redirects` too).
278
+ const sources = names.filter((name) => {
279
+ const type = blocks[name]!.__resolveType as string;
280
+ if (V7_TYPES.has(type)) return true;
281
+ return readable.some((loader) => loader.saved && loader.block === name);
282
+ });
283
+ if (sources.length === 0 && readable.length === 0) return;
284
+
285
+ const current = blocks[REDIRECTS_BLOCK];
286
+ const currentIsV7 = current !== undefined && sources.includes(REDIRECTS_BLOCK);
287
+ if (current !== undefined && !currentIsV7 && current.__resolveType !== REDIRECTS_TYPE) {
288
+ const csvs = [...new Set(readable.map((loader) => loader.file!))];
289
+ const waiting = [
290
+ ...sources.map(subject),
291
+ ...(csvs.length ? [`the CSV files ${csvs.join(", ")}`] : []),
292
+ ];
293
+ report.manual.push({
294
+ step: "content",
295
+ subject: subject(REDIRECTS_BLOCK),
296
+ message: `"${REDIRECTS_BLOCK}" is the name of the redirects block (type "${REDIRECTS_TYPE}"); rename this "${String(current.__resolveType)}" block, then run the migration again to fold the v7 redirects (${waiting.join(", ")}) into it (${ROUTING_DOC})`,
297
+ });
298
+ return;
299
+ }
300
+
301
+ // An existing v8 Redirects block keeps its rules, first, and they win:
302
+ // they are v8's already, which no v7 rule overrides.
303
+ const existing: unknown[] =
304
+ current !== undefined && !currentIsV7 && Array.isArray(current.redirects)
305
+ ? [...current.redirects]
306
+ : [];
307
+ const pinned = new Map<string, unknown>();
308
+ for (const rule of existing) {
309
+ if (isPlainObject(rule) && typeof rule.from === "string" && !pinned.has(rule.from)) {
310
+ pinned.set(rule.from, rule);
311
+ }
312
+ }
313
+
314
+ /** The v7 rule kept for each `from`, where 7.x's route table put it. */
315
+ const chosen = new Map<string, { rule: Rule; source: string; subject: string }>();
316
+ const describe = (rule: Rule) => `to ${rule.to}, ${rule.permanent ? "permanent" : "temporary"}`;
317
+ /**
318
+ * Adds the v7 rules of one source, in 7.x's load order; returns how many
319
+ * had no `from` and `to`. For one exact `from` the LAST rule wins, as
320
+ * 7.x's exact map (`map.exact.set`) kept it; for a glob (a `*` in `from`)
321
+ * the FIRST, as 7.x scanned its patterns in order. Each conflict is reported
322
+ * on the rule that lost.
323
+ */
324
+ function fold(rules: unknown[], source: string, noteSubject: string): number {
325
+ let skipped = 0;
326
+ for (const v7 of rules) {
327
+ const rule = fromV7(v7);
328
+ if (rule === null) {
329
+ skipped += 1;
330
+ continue;
331
+ }
332
+ const v8 = pinned.get(rule.from);
333
+ if (v8 !== undefined) {
334
+ if (target(v8) !== target(rule)) {
335
+ report.manual.push({
336
+ step: "content",
337
+ subject: noteSubject,
338
+ message: `its rule for ${rule.from} (${describe(rule)}) conflicts with the one already in "${REDIRECTS_BLOCK}" (to ${String((v8 as JsonObject).to)}), which was kept: change it there if this one should win`,
339
+ });
340
+ }
341
+ continue;
342
+ }
343
+ const earlier = chosen.get(rule.from);
344
+ if (earlier === undefined) {
345
+ chosen.set(rule.from, { rule, source, subject: noteSubject });
346
+ continue;
347
+ }
348
+ if (target(earlier.rule) === target(rule)) continue;
349
+ if (rule.from.includes("*")) {
350
+ report.manual.push({
351
+ step: "content",
352
+ subject: noteSubject,
353
+ message: `its rule for ${rule.from} (${describe(rule)}) conflicts with the earlier one from "${earlier.source}" (to ${earlier.rule.to}), which was kept in "${REDIRECTS_BLOCK}" as 7.x matched the first glob rule: change it there if this one should win`,
354
+ });
355
+ continue;
356
+ }
357
+ report.manual.push({
358
+ step: "content",
359
+ subject: earlier.subject,
360
+ message: `its rule for ${rule.from} (${describe(earlier.rule)}) conflicts with the later one from "${source}" (to ${rule.to}), which was kept in "${REDIRECTS_BLOCK}" as 7.x routed the last rule for a path: change it there if this one should win`,
361
+ });
362
+ // The later rule takes the earlier one's place.
363
+ chosen.set(rule.from, { rule, source, subject: noteSubject });
364
+ }
365
+ return skipped;
366
+ }
367
+
368
+ // 7.x's load order: the CSV files first, each once, in the order the
369
+ // loaders are found (7.x spread them before the saved blocks, so a saved
370
+ // block's exact rule wins over a CSV row), then the saved blocks in name order.
371
+ const csvs = new Map<string, boolean>();
372
+ for (const loader of readable) {
373
+ const force = loader.node.forcePermanentRedirects === true;
374
+ csvs.set(loader.file!, (csvs.get(loader.file!) ?? false) || force);
375
+ }
376
+ const csvRows = new Map<string, number>();
377
+ for (const [file, force] of csvs) {
378
+ const csv = fs.readFileSync(path.join(root, file), "utf8");
379
+ const { rows, skipped } = parseRedirectsCsv(csv, force);
380
+ csvRows.set(file, rows.length);
381
+ const malformed = skipped + fold(rows, file, file);
382
+ if (malformed > 0) {
383
+ report.manual.push({
384
+ step: "content",
385
+ subject: file,
386
+ message: `${malformed === 1 ? "a row" : `${malformed} rows`} without a from and a to, left out of "${REDIRECTS_BLOCK}", as 7.x skipped them`,
387
+ });
388
+ }
389
+ }
390
+
391
+ const folded: string[] = [];
392
+ for (const name of sources) {
393
+ const skipped = fold(v7Rules(blocks[name]!), name, subject(name));
394
+ if (skipped > 0) {
395
+ report.manual.push({
396
+ step: "content",
397
+ subject: subject(name),
398
+ message: `${skipped === 1 ? "a rule" : `${skipped} rules`} without a from and a to, left out of "${REDIRECTS_BLOCK}" (the block was deleted; git has it)`,
399
+ });
400
+ }
401
+ folded.push(files[name]!);
402
+ }
403
+
404
+ const rules = [...chosen.values()].map((entry) => entry.rule);
405
+ const kept: unknown[] = [...existing, ...rules];
406
+ const added = rules.length;
407
+ const temporary = rules.filter((rule) => !rule.permanent).length;
408
+
409
+ fs.mkdirSync(blocksDir, { recursive: true });
410
+ const file = files[REDIRECTS_BLOCK] ?? blockFileName(REDIRECTS_BLOCK);
411
+ const next = serializeBlock({
412
+ ...(currentIsV7 ? {} : current),
413
+ __resolveType: REDIRECTS_TYPE,
414
+ redirects: kept,
415
+ });
416
+ // Deleted first: on a case-insensitive disk, redirects.json is Redirects.json.
417
+ for (const old of folded) {
418
+ if (old !== file) fs.rmSync(path.join(blocksDir, old), { force: true });
419
+ }
420
+ const full = path.join(blocksDir, file);
421
+ if (!fs.existsSync(full) || fs.readFileSync(full, "utf8") !== next) fs.writeFileSync(full, next);
422
+
423
+ // Inline CSV loaders whose file was folded come out of the blocks holding them.
424
+ const inline = new Set(readable.filter((loader) => !loader.saved).map((loader) => loader.node));
425
+ for (const name of [...new Set(readable.filter((l) => !l.saved).map((l) => l.block))]) {
426
+ if (sources.includes(name)) continue;
427
+ const block = blocks[name]!;
428
+ if (!removeNodes(block, (node) => inline.has(node))) continue;
429
+ fs.writeFileSync(path.join(blocksDir, files[name]!), serializeBlock(block));
430
+ const read = readable.filter((loader) => !loader.saved && loader.block === name);
431
+ report.done.push({
432
+ step: "content",
433
+ subject: subject(name),
434
+ message: `removed ${read.length === 1 ? "its v7 CSV redirects loader" : `its ${read.length} v7 CSV redirects loaders`} (${V7_CSV_REDIRECTS_TYPE}: ${[...new Set(read.map((l) => l.file))].join(", ")}): the rows are in "${REDIRECTS_BLOCK}"`,
435
+ });
436
+ }
437
+
438
+ const from = [
439
+ ...(folded.length ? [`the v7 redirect blocks ${folded.join(", ")}`] : []),
440
+ ...(csvs.size ? [`the CSV files ${[...csvs.keys()].join(", ")}`] : []),
441
+ ];
442
+ const statuses = `v7's type permanent is permanent: true, a 301, and temporary permanent: false, a 307${temporary > 0 ? "; under 7.x's default (legacy) redirect semantics a temporary rule answered 302" : ""}`;
443
+ report.done.push({
444
+ step: "content",
445
+ subject: `.deco/blocks/${file}`,
446
+ message: `folded ${added === 1 ? "1 rule" : `${added} rules`} from ${from.join(" and ")}, then deleted ${folded.length ? "them" : "the loaders"}: v8 routes only this block (type "${REDIRECTS_TYPE}"; ${statuses}) (${ROUTING_DOC})`,
447
+ });
448
+ for (const [csv, rows] of csvRows) {
449
+ report.manual.push({
450
+ step: "content",
451
+ subject: csv,
452
+ message: `kept: v8 reads no CSV, and its ${rows === 1 ? "row is" : `${rows} rows are`} in the "${REDIRECTS_BLOCK}" block now. Delete the file once you've checked them there`,
453
+ });
454
+ }
455
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * What a migration did and what it left for a person: every step adds to one
3
+ * report, which the command prints at the end.
4
+ */
5
+ type Step =
6
+ | "content"
7
+ | "settings"
8
+ | "apps"
9
+ | "secrets"
10
+ | "block map"
11
+ | "vendor"
12
+ | "invoke"
13
+ | "scaffold"
14
+ | "imports"
15
+ | "scripts";
16
+
17
+ export interface Note {
18
+ step: Step;
19
+ /** What the note is about: a type name, a file, an import specifier. */
20
+ subject: string;
21
+ message: string;
22
+ }
23
+
24
+ export interface Report {
25
+ /** Changes the migration made. */
26
+ done: Note[];
27
+ /** Work left for a person: nothing was changed for these. */
28
+ manual: Note[];
29
+ }
30
+
31
+ export function createReport(): Report {
32
+ return { done: [], manual: [] };
33
+ }
34
+
35
+ function section(title: string, notes: Note[]): string[] {
36
+ if (notes.length === 0) return [];
37
+ const lines = [`${title} (${notes.length})`];
38
+ for (const step of new Set(notes.map((n) => n.step))) {
39
+ lines.push(` ${step}`);
40
+ for (const n of notes.filter((n) => n.step === step)) {
41
+ lines.push(` ${n.subject}: ${n.message}`);
42
+ }
43
+ }
44
+ return lines;
45
+ }
46
+
47
+ export function formatReport(report: Report): string {
48
+ const lines = [...section("Done", report.done), ...section("Left to do", report.manual)];
49
+ return lines.length > 0 ? lines.join("\n") : "Nothing to migrate.";
50
+ }