@decocms/blocks 8.1.0-next.1 → 8.1.0-next.3

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 (392) hide show
  1. package/bin/deco.js +5 -12
  2. package/dist/index.d.ts +2 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +4 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/protocol/assets.d.ts +46 -0
  7. package/dist/protocol/assets.d.ts.map +1 -0
  8. package/dist/protocol/assets.js +105 -0
  9. package/dist/protocol/assets.js.map +1 -0
  10. package/dist/protocol/canonical.d.ts +8 -0
  11. package/dist/protocol/canonical.d.ts.map +1 -0
  12. package/dist/protocol/canonical.js +8 -0
  13. package/dist/protocol/canonical.js.map +1 -0
  14. package/dist/protocol/ciphertext.d.ts +7 -0
  15. package/dist/protocol/ciphertext.d.ts.map +1 -0
  16. package/dist/protocol/ciphertext.js +7 -0
  17. package/dist/protocol/ciphertext.js.map +1 -0
  18. package/dist/protocol/client.d.ts +54 -0
  19. package/dist/protocol/client.d.ts.map +1 -0
  20. package/dist/protocol/client.js +104 -0
  21. package/dist/protocol/client.js.map +1 -0
  22. package/dist/protocol/conformance/cases/assets.d.ts +3 -0
  23. package/dist/protocol/conformance/cases/assets.d.ts.map +1 -0
  24. package/dist/protocol/conformance/cases/assets.js +71 -0
  25. package/dist/protocol/conformance/cases/assets.js.map +1 -0
  26. package/dist/protocol/conformance/cases/guards.d.ts +3 -0
  27. package/dist/protocol/conformance/cases/guards.d.ts.map +1 -0
  28. package/dist/protocol/conformance/cases/guards.js +265 -0
  29. package/dist/protocol/conformance/cases/guards.js.map +1 -0
  30. package/dist/protocol/conformance/cases/reads.d.ts +3 -0
  31. package/dist/protocol/conformance/cases/reads.d.ts.map +1 -0
  32. package/dist/protocol/conformance/cases/reads.js +140 -0
  33. package/dist/protocol/conformance/cases/reads.js.map +1 -0
  34. package/dist/protocol/conformance/cases/types.d.ts +9 -0
  35. package/dist/protocol/conformance/cases/types.d.ts.map +1 -0
  36. package/dist/protocol/conformance/cases/types.js +2 -0
  37. package/dist/protocol/conformance/cases/types.js.map +1 -0
  38. package/dist/protocol/conformance/cases/wire.d.ts +3 -0
  39. package/dist/protocol/conformance/cases/wire.d.ts.map +1 -0
  40. package/dist/protocol/conformance/cases/wire.js +130 -0
  41. package/dist/protocol/conformance/cases/wire.js.map +1 -0
  42. package/dist/protocol/conformance/cases/writes.d.ts +3 -0
  43. package/dist/protocol/conformance/cases/writes.d.ts.map +1 -0
  44. package/dist/protocol/conformance/cases/writes.js +278 -0
  45. package/dist/protocol/conformance/cases/writes.js.map +1 -0
  46. package/dist/protocol/conformance/contentHashFixtures.d.ts +51 -0
  47. package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -0
  48. package/dist/protocol/conformance/contentHashFixtures.js +94 -0
  49. package/dist/protocol/conformance/contentHashFixtures.js.map +1 -0
  50. package/dist/protocol/conformance/context.d.ts +100 -0
  51. package/dist/protocol/conformance/context.d.ts.map +1 -0
  52. package/dist/protocol/conformance/context.js +155 -0
  53. package/dist/protocol/conformance/context.js.map +1 -0
  54. package/dist/protocol/conformance/index.d.ts +32 -0
  55. package/dist/protocol/conformance/index.d.ts.map +1 -0
  56. package/dist/protocol/conformance/index.js +90 -0
  57. package/dist/protocol/conformance/index.js.map +1 -0
  58. package/dist/protocol/errors.d.ts +85 -0
  59. package/dist/protocol/errors.d.ts.map +1 -0
  60. package/dist/protocol/errors.js +62 -0
  61. package/dist/protocol/errors.js.map +1 -0
  62. package/dist/protocol/index.d.ts +28 -0
  63. package/dist/protocol/index.d.ts.map +1 -0
  64. package/dist/protocol/index.js +28 -0
  65. package/dist/protocol/index.js.map +1 -0
  66. package/dist/protocol/keys.d.ts +101 -0
  67. package/dist/protocol/keys.d.ts.map +1 -0
  68. package/dist/protocol/keys.js +223 -0
  69. package/dist/protocol/keys.js.map +1 -0
  70. package/dist/protocol/params.d.ts +10 -0
  71. package/dist/protocol/params.d.ts.map +1 -0
  72. package/dist/protocol/params.js +54 -0
  73. package/dist/protocol/params.js.map +1 -0
  74. package/dist/protocol/secrets.d.ts +22 -0
  75. package/dist/protocol/secrets.d.ts.map +1 -0
  76. package/dist/protocol/secrets.js +200 -0
  77. package/dist/protocol/secrets.js.map +1 -0
  78. package/dist/protocol/server/assets.d.ts +20 -0
  79. package/dist/protocol/server/assets.d.ts.map +1 -0
  80. package/dist/protocol/server/assets.js +77 -0
  81. package/dist/protocol/server/assets.js.map +1 -0
  82. package/dist/protocol/server/auth.d.ts +31 -0
  83. package/dist/protocol/server/auth.d.ts.map +1 -0
  84. package/dist/protocol/server/auth.js +32 -0
  85. package/dist/protocol/server/auth.js.map +1 -0
  86. package/dist/protocol/server/bodyCache.d.ts +28 -0
  87. package/dist/protocol/server/bodyCache.d.ts.map +1 -0
  88. package/dist/protocol/server/bodyCache.js +75 -0
  89. package/dist/protocol/server/bodyCache.js.map +1 -0
  90. package/dist/protocol/server/content.d.ts +44 -0
  91. package/dist/protocol/server/content.d.ts.map +1 -0
  92. package/dist/protocol/server/content.js +132 -0
  93. package/dist/protocol/server/content.js.map +1 -0
  94. package/dist/protocol/server/core.d.ts +63 -0
  95. package/dist/protocol/server/core.d.ts.map +1 -0
  96. package/dist/protocol/server/core.js +77 -0
  97. package/dist/protocol/server/core.js.map +1 -0
  98. package/dist/protocol/server/handler.d.ts +5 -0
  99. package/dist/protocol/server/handler.d.ts.map +1 -0
  100. package/dist/protocol/server/handler.js +70 -0
  101. package/dist/protocol/server/handler.js.map +1 -0
  102. package/dist/protocol/server/http.d.ts +24 -0
  103. package/dist/protocol/server/http.d.ts.map +1 -0
  104. package/dist/protocol/server/http.js +133 -0
  105. package/dist/protocol/server/http.js.map +1 -0
  106. package/dist/protocol/server/index.d.ts +11 -0
  107. package/dist/protocol/server/index.d.ts.map +1 -0
  108. package/dist/protocol/server/index.js +9 -0
  109. package/dist/protocol/server/index.js.map +1 -0
  110. package/dist/protocol/server/methods/apply.d.ts +4 -0
  111. package/dist/protocol/server/methods/apply.d.ts.map +1 -0
  112. package/dist/protocol/server/methods/apply.js +275 -0
  113. package/dist/protocol/server/methods/apply.js.map +1 -0
  114. package/dist/protocol/server/methods/read.d.ts +14 -0
  115. package/dist/protocol/server/methods/read.d.ts.map +1 -0
  116. package/dist/protocol/server/methods/read.js +132 -0
  117. package/dist/protocol/server/methods/read.js.map +1 -0
  118. package/dist/protocol/server/rpc.d.ts +7 -0
  119. package/dist/protocol/server/rpc.d.ts.map +1 -0
  120. package/dist/protocol/server/rpc.js +115 -0
  121. package/dist/protocol/server/rpc.js.map +1 -0
  122. package/dist/protocol/storage/fs/hash.d.ts +8 -0
  123. package/dist/protocol/storage/fs/hash.d.ts.map +1 -0
  124. package/dist/protocol/storage/fs/hash.js +20 -0
  125. package/dist/protocol/storage/fs/hash.js.map +1 -0
  126. package/dist/protocol/storage/fs/index.d.ts +30 -0
  127. package/dist/protocol/storage/fs/index.d.ts.map +1 -0
  128. package/dist/protocol/storage/fs/index.js +301 -0
  129. package/dist/protocol/storage/fs/index.js.map +1 -0
  130. package/dist/protocol/storage/fs/lock.d.ts +8 -0
  131. package/dist/protocol/storage/fs/lock.d.ts.map +1 -0
  132. package/dist/protocol/storage/fs/lock.js +61 -0
  133. package/dist/protocol/storage/fs/lock.js.map +1 -0
  134. package/dist/protocol/storage/fs/transaction.d.ts +19 -0
  135. package/dist/protocol/storage/fs/transaction.d.ts.map +1 -0
  136. package/dist/protocol/storage/fs/transaction.js +174 -0
  137. package/dist/protocol/storage/fs/transaction.js.map +1 -0
  138. package/dist/protocol/storage/fs/unsupported.d.ts +10 -0
  139. package/dist/protocol/storage/fs/unsupported.d.ts.map +1 -0
  140. package/dist/protocol/storage/fs/unsupported.js +4 -0
  141. package/dist/protocol/storage/fs/unsupported.js.map +1 -0
  142. package/dist/protocol/storage/memory.d.ts +40 -0
  143. package/dist/protocol/storage/memory.d.ts.map +1 -0
  144. package/dist/protocol/storage/memory.js +179 -0
  145. package/dist/protocol/storage/memory.js.map +1 -0
  146. package/dist/protocol/storage.d.ts +178 -0
  147. package/dist/protocol/storage.d.ts.map +1 -0
  148. package/dist/protocol/storage.js +29 -0
  149. package/dist/protocol/storage.js.map +1 -0
  150. package/dist/protocol/types.d.ts +194 -0
  151. package/dist/protocol/types.d.ts.map +1 -0
  152. package/dist/protocol/types.js +31 -0
  153. package/dist/protocol/types.js.map +1 -0
  154. package/dist/v8/analytics.d.ts +31 -0
  155. package/dist/v8/analytics.d.ts.map +1 -0
  156. package/dist/v8/analytics.js +46 -0
  157. package/dist/v8/analytics.js.map +1 -0
  158. package/dist/v8/background.d.ts +26 -0
  159. package/dist/v8/background.d.ts.map +1 -0
  160. package/dist/v8/background.js +95 -0
  161. package/dist/v8/background.js.map +1 -0
  162. package/dist/v8/builtins/data.d.ts +15 -0
  163. package/dist/v8/builtins/data.d.ts.map +1 -0
  164. package/dist/v8/builtins/data.js +18 -0
  165. package/dist/v8/builtins/data.js.map +1 -0
  166. package/dist/v8/builtins/index.d.ts +9 -0
  167. package/dist/v8/builtins/index.d.ts.map +1 -0
  168. package/dist/v8/builtins/index.js +24 -0
  169. package/dist/v8/builtins/index.js.map +1 -0
  170. package/dist/v8/builtins/lazy.d.ts +17 -0
  171. package/dist/v8/builtins/lazy.d.ts.map +1 -0
  172. package/dist/v8/builtins/lazy.js +13 -0
  173. package/dist/v8/builtins/lazy.js.map +1 -0
  174. package/dist/v8/builtins/legacy.d.ts +41 -0
  175. package/dist/v8/builtins/legacy.d.ts.map +1 -0
  176. package/dist/v8/builtins/legacy.js +62 -0
  177. package/dist/v8/builtins/legacy.js.map +1 -0
  178. package/dist/v8/builtins/matchers.d.ts +19 -0
  179. package/dist/v8/builtins/matchers.d.ts.map +1 -0
  180. package/dist/v8/builtins/matchers.js +24 -0
  181. package/dist/v8/builtins/matchers.js.map +1 -0
  182. package/dist/v8/builtins/multivariate.d.ts +15 -0
  183. package/dist/v8/builtins/multivariate.d.ts.map +1 -0
  184. package/dist/v8/builtins/multivariate.js +18 -0
  185. package/dist/v8/builtins/multivariate.js.map +1 -0
  186. package/dist/v8/builtins/secret.d.ts +7 -0
  187. package/dist/v8/builtins/secret.d.ts.map +1 -0
  188. package/dist/v8/builtins/secret.js +68 -0
  189. package/dist/v8/builtins/secret.js.map +1 -0
  190. package/dist/v8/canonical.d.ts +70 -0
  191. package/dist/v8/canonical.d.ts.map +1 -0
  192. package/dist/v8/canonical.js +130 -0
  193. package/dist/v8/canonical.js.map +1 -0
  194. package/dist/v8/ciphertext.d.ts +58 -0
  195. package/dist/v8/ciphertext.d.ts.map +1 -0
  196. package/dist/v8/ciphertext.js +134 -0
  197. package/dist/v8/ciphertext.js.map +1 -0
  198. package/dist/v8/cli/builtins.d.ts +11 -0
  199. package/dist/v8/cli/builtins.d.ts.map +1 -0
  200. package/dist/v8/cli/builtins.js +18 -0
  201. package/dist/v8/cli/builtins.js.map +1 -0
  202. package/dist/v8/cli/check/index.d.ts +41 -0
  203. package/dist/v8/cli/check/index.d.ts.map +1 -0
  204. package/dist/v8/cli/check/index.js +713 -0
  205. package/dist/v8/cli/check/index.js.map +1 -0
  206. package/dist/v8/cli/check/messages.d.ts +24 -0
  207. package/dist/v8/cli/check/messages.d.ts.map +1 -0
  208. package/dist/v8/cli/check/messages.js +150 -0
  209. package/dist/v8/cli/check/messages.js.map +1 -0
  210. package/dist/v8/cli/content.d.ts +60 -0
  211. package/dist/v8/cli/content.d.ts.map +1 -0
  212. package/dist/v8/cli/content.js +231 -0
  213. package/dist/v8/cli/content.js.map +1 -0
  214. package/dist/v8/cli/index.d.ts +18 -0
  215. package/dist/v8/cli/index.d.ts.map +1 -0
  216. package/dist/v8/cli/index.js +18 -0
  217. package/dist/v8/cli/index.js.map +1 -0
  218. package/dist/v8/cli/log.d.ts +9 -0
  219. package/dist/v8/cli/log.d.ts.map +1 -0
  220. package/dist/v8/cli/log.js +11 -0
  221. package/dist/v8/cli/log.js.map +1 -0
  222. package/dist/v8/cli/main.d.ts +2 -0
  223. package/dist/v8/cli/main.d.ts.map +1 -0
  224. package/dist/v8/cli/main.js +9 -0
  225. package/dist/v8/cli/main.js.map +1 -0
  226. package/dist/v8/cli/root.d.ts +28 -0
  227. package/dist/v8/cli/root.d.ts.map +1 -0
  228. package/dist/v8/cli/root.js +64 -0
  229. package/dist/v8/cli/root.js.map +1 -0
  230. package/dist/v8/cli/run.d.ts +13 -0
  231. package/dist/v8/cli/run.d.ts.map +1 -0
  232. package/dist/v8/cli/run.js +210 -0
  233. package/dist/v8/cli/run.js.map +1 -0
  234. package/dist/v8/cli/schema/builtinSchemas.d.ts +22 -0
  235. package/dist/v8/cli/schema/builtinSchemas.d.ts.map +1 -0
  236. package/dist/v8/cli/schema/builtinSchemas.js +213 -0
  237. package/dist/v8/cli/schema/builtinSchemas.js.map +1 -0
  238. package/dist/v8/cli/schema/generate.d.ts +50 -0
  239. package/dist/v8/cli/schema/generate.d.ts.map +1 -0
  240. package/dist/v8/cli/schema/generate.js +415 -0
  241. package/dist/v8/cli/schema/generate.js.map +1 -0
  242. package/dist/v8/cli/schema/index.d.ts +21 -0
  243. package/dist/v8/cli/schema/index.d.ts.map +1 -0
  244. package/dist/v8/cli/schema/index.js +51 -0
  245. package/dist/v8/cli/schema/index.js.map +1 -0
  246. package/dist/v8/cli/schema/tsProgram.d.ts +126 -0
  247. package/dist/v8/cli/schema/tsProgram.d.ts.map +1 -0
  248. package/dist/v8/cli/schema/tsProgram.js +435 -0
  249. package/dist/v8/cli/schema/tsProgram.js.map +1 -0
  250. package/dist/v8/cli/schema/typeToSchema.d.ts +94 -0
  251. package/dist/v8/cli/schema/typeToSchema.d.ts.map +1 -0
  252. package/dist/v8/cli/schema/typeToSchema.js +752 -0
  253. package/dist/v8/cli/schema/typeToSchema.js.map +1 -0
  254. package/dist/v8/cli/serve/server.d.ts +31 -0
  255. package/dist/v8/cli/serve/server.d.ts.map +1 -0
  256. package/dist/v8/cli/serve/server.js +247 -0
  257. package/dist/v8/cli/serve/server.js.map +1 -0
  258. package/dist/v8/cli/watch.d.ts +20 -0
  259. package/dist/v8/cli/watch.d.ts.map +1 -0
  260. package/dist/v8/cli/watch.js +79 -0
  261. package/dist/v8/cli/watch.js.map +1 -0
  262. package/dist/v8/client.d.ts +20 -0
  263. package/dist/v8/client.d.ts.map +1 -0
  264. package/dist/v8/client.js +115 -0
  265. package/dist/v8/client.js.map +1 -0
  266. package/dist/v8/cms.d.ts +9 -0
  267. package/dist/v8/cms.d.ts.map +1 -0
  268. package/dist/v8/cms.js +217 -0
  269. package/dist/v8/cms.js.map +1 -0
  270. package/dist/v8/content.d.ts +51 -0
  271. package/dist/v8/content.d.ts.map +1 -0
  272. package/dist/v8/content.js +218 -0
  273. package/dist/v8/content.js.map +1 -0
  274. package/dist/v8/draft.d.ts +48 -0
  275. package/dist/v8/draft.d.ts.map +1 -0
  276. package/dist/v8/draft.js +195 -0
  277. package/dist/v8/draft.js.map +1 -0
  278. package/dist/v8/errors.d.ts +21 -0
  279. package/dist/v8/errors.d.ts.map +1 -0
  280. package/dist/v8/errors.js +39 -0
  281. package/dist/v8/errors.js.map +1 -0
  282. package/dist/v8/fetch.d.ts +26 -0
  283. package/dist/v8/fetch.d.ts.map +1 -0
  284. package/dist/v8/fetch.js +98 -0
  285. package/dist/v8/fetch.js.map +1 -0
  286. package/dist/v8/identity.d.ts +19 -0
  287. package/dist/v8/identity.d.ts.map +1 -0
  288. package/dist/v8/identity.js +54 -0
  289. package/dist/v8/identity.js.map +1 -0
  290. package/dist/v8/index.d.ts +11 -0
  291. package/dist/v8/index.d.ts.map +1 -0
  292. package/dist/v8/index.js +10 -0
  293. package/dist/v8/index.js.map +1 -0
  294. package/dist/v8/json.d.ts +19 -0
  295. package/dist/v8/json.d.ts.map +1 -0
  296. package/dist/v8/json.js +65 -0
  297. package/dist/v8/json.js.map +1 -0
  298. package/dist/v8/matchRoute.d.ts +30 -0
  299. package/dist/v8/matchRoute.d.ts.map +1 -0
  300. package/dist/v8/matchRoute.js +175 -0
  301. package/dist/v8/matchRoute.js.map +1 -0
  302. package/dist/v8/remoteLoader.d.ts +16 -0
  303. package/dist/v8/remoteLoader.d.ts.map +1 -0
  304. package/dist/v8/remoteLoader.js +427 -0
  305. package/dist/v8/remoteLoader.js.map +1 -0
  306. package/dist/v8/resolver.d.ts +34 -0
  307. package/dist/v8/resolver.d.ts.map +1 -0
  308. package/dist/v8/resolver.js +219 -0
  309. package/dist/v8/resolver.js.map +1 -0
  310. package/dist/v8/secrets.d.ts +9 -0
  311. package/dist/v8/secrets.d.ts.map +1 -0
  312. package/dist/v8/secrets.js +14 -0
  313. package/dist/v8/secrets.js.map +1 -0
  314. package/dist/v8/telemetry.d.ts +61 -0
  315. package/dist/v8/telemetry.d.ts.map +1 -0
  316. package/dist/v8/telemetry.js +460 -0
  317. package/dist/v8/telemetry.js.map +1 -0
  318. package/dist/v8/types.d.ts +226 -0
  319. package/dist/v8/types.d.ts.map +1 -0
  320. package/dist/v8/types.js +2 -0
  321. package/dist/v8/types.js.map +1 -0
  322. package/dist/v8/variants.d.ts +3 -0
  323. package/dist/v8/variants.d.ts.map +1 -0
  324. package/dist/v8/variants.js +65 -0
  325. package/dist/v8/variants.js.map +1 -0
  326. package/package.json +64 -18
  327. package/src/index.ts +1 -1
  328. package/src/protocol/canonical.ts +1 -1
  329. package/src/protocol/ciphertext.ts +1 -1
  330. package/src/protocol/client.ts +2 -2
  331. package/src/protocol/conformance/cases/assets.ts +3 -3
  332. package/src/protocol/conformance/cases/guards.ts +4 -4
  333. package/src/protocol/conformance/cases/reads.ts +4 -4
  334. package/src/protocol/conformance/cases/types.ts +1 -1
  335. package/src/protocol/conformance/cases/wire.ts +4 -4
  336. package/src/protocol/conformance/cases/writes.ts +4 -4
  337. package/src/protocol/conformance/contentHashFixtures.ts +57 -0
  338. package/src/protocol/conformance/context.ts +4 -4
  339. package/src/protocol/conformance/index.ts +15 -10
  340. package/src/protocol/index.ts +14 -7
  341. package/src/protocol/params.ts +2 -2
  342. package/src/protocol/secrets.ts +3 -3
  343. package/src/protocol/server/assets.ts +6 -6
  344. package/src/protocol/server/auth.ts +1 -1
  345. package/src/protocol/server/content.ts +5 -5
  346. package/src/protocol/server/core.ts +12 -6
  347. package/src/protocol/server/handler.ts +6 -6
  348. package/src/protocol/server/http.ts +1 -1
  349. package/src/protocol/server/index.ts +3 -3
  350. package/src/protocol/server/methods/apply.ts +9 -9
  351. package/src/protocol/server/methods/read.ts +5 -5
  352. package/src/protocol/server/rpc.ts +6 -6
  353. package/src/protocol/storage/fs/index.ts +7 -7
  354. package/src/protocol/storage/fs/lock.ts +1 -1
  355. package/src/protocol/storage/fs/unsupported.ts +2 -2
  356. package/src/protocol/storage/memory.ts +4 -4
  357. package/src/protocol/storage.ts +1 -1
  358. package/src/v8/analytics.ts +2 -2
  359. package/src/v8/builtins/data.ts +1 -1
  360. package/src/v8/builtins/index.ts +6 -6
  361. package/src/v8/builtins/lazy.ts +1 -1
  362. package/src/v8/builtins/legacy.ts +1 -1
  363. package/src/v8/builtins/multivariate.ts +1 -1
  364. package/src/v8/builtins/secret.ts +2 -2
  365. package/src/v8/canonical.ts +36 -0
  366. package/src/v8/cli/builtins.ts +2 -2
  367. package/src/v8/cli/check/index.ts +11 -11
  368. package/src/v8/cli/content.ts +6 -6
  369. package/src/v8/cli/index.ts +7 -7
  370. package/src/v8/cli/main.ts +1 -1
  371. package/src/v8/cli/run.ts +7 -7
  372. package/src/v8/cli/schema/builtinSchemas.ts +1 -1
  373. package/src/v8/cli/schema/generate.ts +8 -7
  374. package/src/v8/cli/schema/index.ts +4 -4
  375. package/src/v8/cli/schema/tsProgram.ts +18 -1
  376. package/src/v8/cli/schema/typeToSchema.ts +100 -4
  377. package/src/v8/cli/serve/server.ts +9 -9
  378. package/src/v8/client.ts +5 -5
  379. package/src/v8/cms.ts +23 -11
  380. package/src/v8/content.ts +58 -22
  381. package/src/v8/draft.ts +75 -6
  382. package/src/v8/errors.ts +1 -1
  383. package/src/v8/fetch.ts +1 -1
  384. package/src/v8/identity.ts +1 -1
  385. package/src/v8/index.ts +5 -5
  386. package/src/v8/matchRoute.ts +1 -1
  387. package/src/v8/remoteLoader.ts +246 -26
  388. package/src/v8/resolver.ts +6 -6
  389. package/src/v8/secrets.ts +1 -1
  390. package/src/v8/telemetry.ts +5 -5
  391. package/src/v8/types.ts +14 -1
  392. package/src/v8/variants.ts +61 -0
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Public types of the next-major (v8) core SDK. See the API reference
3
+ * (`/next/api-reference#types`) — every type here is documented there.
4
+ */
5
+ import type { ReactNode } from "react";
6
+ /**
7
+ * A block as stored: the JSON in `.deco/blocks`, and what `client.list` and
8
+ * `{ run: false }` return. Props never use it: a field's type is the value the
9
+ * function receives.
10
+ */
11
+ export type Block = {
12
+ __resolveType: string;
13
+ [input: string]: unknown;
14
+ };
15
+ /** A function a block can call. */
16
+ export type BlockFunction = (inputs: any) => unknown | Promise<unknown>;
17
+ /** A block map: what `.deco/index.ts` exports and the CLI reads. */
18
+ export type Blocks = Record<string, BlockFunction>;
19
+ /** One fixed copy of the content: what the content module exports and `load()` returns. */
20
+ export type Snapshot = {
21
+ revision: string;
22
+ /** The content map: entry name → saved JSON. */
23
+ blocks: Record<string, unknown>;
24
+ /** The alias table `deco content` writes: old type name → your type. */
25
+ aliases?: Record<string, string>;
26
+ };
27
+ /**
28
+ * The content module `deco content` writes: a snapshot plus `root`, the
29
+ * `.deco` folder it was generated from, which `createCMS` keys its instance
30
+ * on (see /next/api-reference#one-instance-per-process). Not exported.
31
+ */
32
+ export type ContentModule = Snapshot & {
33
+ root?: string;
34
+ };
35
+ /** A source of content. `load()` is the release; `load(pointer)` is a draft. */
36
+ export interface Loader {
37
+ load(pointer?: string | null): Promise<Snapshot>;
38
+ update?(): Promise<{
39
+ updated: boolean;
40
+ }>;
41
+ }
42
+ /** The parts of a draft pointer, `<host[:port]><path[?query]>@<version>`. */
43
+ export interface DraftPointer {
44
+ /** `host[:port]` of the content source that holds the draft. */
45
+ host: string;
46
+ /** Starts with `/`; opaque to the app. Never carries the `__variant` parameters. */
47
+ path: string;
48
+ /** Opaque and immutable: the branch head or ETag. */
49
+ version: string;
50
+ /** The variants this preview forces (the query's `__variant` parameters); absent when none. */
51
+ variants?: ForcedVariant[];
52
+ }
53
+ /**
54
+ * A variant a preview forces: the multivariate block at `path` (dot-separated
55
+ * keys and indexes, `""` for the saved block itself) inside the saved block
56
+ * `block` shows its variant `index` instead of evaluating rules.
57
+ */
58
+ export interface ForcedVariant {
59
+ block: string;
60
+ path: string;
61
+ index: number;
62
+ }
63
+ /** An entry that lives at a URL. Extend it to make a type routable. */
64
+ export interface Route {
65
+ /** @title Name */
66
+ name: string;
67
+ /** @title Path */
68
+ path: string;
69
+ }
70
+ export interface Seo {
71
+ title: string;
72
+ description: string;
73
+ }
74
+ /** The built-in `page` block, resolved: without `seo`, the site's defaults apply. */
75
+ export interface Page extends Route {
76
+ seo?: Seo;
77
+ sections: ReactNode[];
78
+ }
79
+ /** The built-in `redirect` block. */
80
+ export interface Redirect {
81
+ /** Literal path or template (`:name` segments, an optional trailing `/*`). */
82
+ from: string;
83
+ to: string;
84
+ /** `true` for a 301, `false` for a 302. */
85
+ permanent: boolean;
86
+ /** Wins over `permanent`. */
87
+ status?: RedirectStatus;
88
+ /** Drop the request's query string instead of carrying it over. */
89
+ discardQueryParameters?: boolean;
90
+ }
91
+ export type RedirectStatus = 301 | 302 | 307 | 308;
92
+ /**
93
+ * The nested redirect shape v7 content stores (`website/loaders/redirect.ts`).
94
+ * `matchRoute` accepts it next to {@link Redirect}: `permanent` is a 301 and
95
+ * anything else a 307, the status the site editor has always written for it.
96
+ */
97
+ export interface LegacyRedirect {
98
+ redirect: {
99
+ from: string;
100
+ to: string;
101
+ type?: "permanent" | "temporary";
102
+ discardQueryParameters?: boolean;
103
+ };
104
+ }
105
+ /** A field the site editor saves encrypted, as a `secret` block. */
106
+ export type Secret = string & {
107
+ readonly __secret: true;
108
+ };
109
+ /** A prop the built-in `lazy` block fills; resolves its value when called, at most once. */
110
+ export type Lazy<T> = () => Promise<T>;
111
+ /** One entry of `variants`: a rule and the variant it shows. */
112
+ export interface Variant<T> {
113
+ rule: boolean;
114
+ value: Lazy<T>;
115
+ }
116
+ /** The `Telemetry` saved block's type (built-in `telemetry`). */
117
+ export interface Telemetry {
118
+ /** Default `true`; `false` switches telemetry off. */
119
+ enabled?: boolean;
120
+ /** Default `true`. */
121
+ metrics?: boolean;
122
+ /** Default 0.05, capped by `telemetry.limits`. */
123
+ errorSampleRate?: number;
124
+ /** Default 0, capped by `telemetry.limits`. */
125
+ traceSampleRate?: number;
126
+ }
127
+ /** The built-in `analytics` block's props. Separate from telemetry. */
128
+ export interface Analytics {
129
+ /** An endpoint that accepts the One Dollar Stats format; default: the hosted Deco CMS collector. */
130
+ collector?: string;
131
+ /** Default `true`; `false` makes `AnalyticsScript` render nothing. */
132
+ enabled?: boolean;
133
+ }
134
+ export type CMSErrorCode = "NOT_FOUND" | "UNKNOWN_BLOCK" | "CYCLE" | "BLOCK_FAILED" | "LOADER_FAILED";
135
+ export interface CMSError {
136
+ code: CMSErrorCode;
137
+ message: string;
138
+ /** Where in the tree it happened, such as `["sections", 2, "product"]`. */
139
+ path: (string | number)[];
140
+ /** The original error, for `BLOCK_FAILED` and `LOADER_FAILED`. */
141
+ cause?: unknown;
142
+ }
143
+ export type Result<T> = [T, null] | [null, CMSError];
144
+ export type Match<T> = {
145
+ kind: "match";
146
+ entry: T;
147
+ params: Record<string, string>;
148
+ } | {
149
+ kind: "redirect";
150
+ location: string;
151
+ status: RedirectStatus;
152
+ } | {
153
+ kind: "not-found";
154
+ };
155
+ export type TelemetryConfig = ({
156
+ site: string;
157
+ token: string;
158
+ } | {
159
+ endpoint: string;
160
+ headers?: Record<string, string>;
161
+ }) & {
162
+ limits?: {
163
+ errorSampleRate?: number;
164
+ traceSampleRate?: number;
165
+ };
166
+ };
167
+ export interface CMSConfig {
168
+ /** Your block functions; the CMS uses `{ ...builtIns, ...blocks }`. */
169
+ blocks: Blocks;
170
+ /** The content module (`.deco/blocks.gen.ts`), or any {@link Loader}. */
171
+ content: ContentModule | Loader;
172
+ /** ms between `update()` checks of a content source that has one; minimum 60 000. */
173
+ interval?: number;
174
+ /** Where telemetry goes; see /next/telemetry. */
175
+ telemetry?: false | TelemetryConfig;
176
+ /** The private key that decrypts `secret` blocks. */
177
+ secrets?: {
178
+ key?: string;
179
+ };
180
+ /** Your site's ID, for hosted releases and drafts. */
181
+ site?: string;
182
+ /** Your site token (secret), for hosted releases and drafts. */
183
+ token?: string;
184
+ }
185
+ export interface ResolveOptions {
186
+ /** `false` reads without running: saved blocks expand, no function runs. */
187
+ run?: boolean;
188
+ }
189
+ export interface ListOptions<T> {
190
+ where?: (entry: T) => boolean;
191
+ sort?: (a: T, b: T) => number;
192
+ limit?: number;
193
+ run?: boolean;
194
+ }
195
+ /**
196
+ * Reads one revision for one request.
197
+ *
198
+ * Results are read-only. A client runs each block function once per distinct
199
+ * input, so the same block at two places in a request hands both places the
200
+ * same object; mutating it in place changes the other occurrence too. Copy a
201
+ * result before changing it. (The memo belongs to one client, so nothing is
202
+ * shared across requests.)
203
+ */
204
+ export interface Client {
205
+ resolve<T = unknown>(target: unknown, options?: ResolveOptions): Promise<Result<T>>;
206
+ list<T = Block>(type: string, options?: ListOptions<T>): Promise<Result<T[]>>;
207
+ /**
208
+ * The revision this client reads (loads it on first use). Unlike `resolve`
209
+ * and `list`, it rejects with the `LOADER_FAILED` error when the content
210
+ * can't load, since there is no revision to report.
211
+ */
212
+ revision(): Promise<string>;
213
+ }
214
+ export interface CMS {
215
+ /** A client reading the current release. */
216
+ forRelease(): Client;
217
+ /** A client reading the draft a pointer names. */
218
+ forDraft(pointer: string): Client;
219
+ /** A client pinned to a revision this CMS has served; an unknown revision behaves like the release. */
220
+ forRevision(revision: string): Client;
221
+ /** Ask the content source for newer content now; never throws. */
222
+ update(): Promise<{
223
+ updated: boolean;
224
+ }>;
225
+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,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,MAAM;IACrB,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IACpF,IAAI,CAAC,CAAC,GAAG,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E;;;;OAIG;IACH,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,GAAG;IAClB,4CAA4C;IAC5C,UAAU,IAAI,MAAM,CAAC;IACrB,kDAAkD;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,uGAAuG;IACvG,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IACtC,kEAAkE;IAClE,MAAM,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACzC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/v8/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import type { ForcedVariant, Snapshot } from "./types.ts";
2
+ export declare function forceVariants(snapshot: Snapshot, variants: readonly ForcedVariant[] | undefined): Snapshot;
3
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../src/v8/variants.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE1D,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,GAC7C,QAAQ,CAaV"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Forced variants (see /next/releases-and-drafts#preview-a-variant): the
3
+ * variants a draft pointer's `__variant` parameters name, applied to a
4
+ * snapshot for one preview. Each addressed multivariate keeps only the forced
5
+ * variant, with the rule `true`, so it shows that variant's value and no other
6
+ * rule runs. The snapshot is copied along the addressed paths only; the shared
7
+ * one is never touched.
8
+ *
9
+ * An address that doesn't reach a multivariate block with that variant (a
10
+ * renamed block, a moved section, an index past the end) is ignored, so a
11
+ * stale preview link renders the content as saved.
12
+ */
13
+ import { LEGACY_ALIASES } from "./builtins/legacy.js";
14
+ import { isPlainObject, own } from "./json.js";
15
+ export function forceVariants(snapshot, variants) {
16
+ if (variants === undefined || variants.length === 0)
17
+ return snapshot;
18
+ let blocks;
19
+ for (const { block, path, index } of variants) {
20
+ const entry = own(blocks ?? snapshot.blocks, block);
21
+ if (entry === undefined)
22
+ continue;
23
+ const keys = path === "" ? [] : path.split(".");
24
+ const next = forceAt(entry, keys, index, snapshot);
25
+ if (next === entry)
26
+ continue;
27
+ blocks ??= { ...snapshot.blocks };
28
+ blocks[block] = next;
29
+ }
30
+ return blocks === undefined ? snapshot : { ...snapshot, blocks };
31
+ }
32
+ function forceAt(node, keys, index, snapshot) {
33
+ if (keys.length === 0)
34
+ return forceNode(node, index, snapshot);
35
+ const [key, ...rest] = keys;
36
+ if (Array.isArray(node)) {
37
+ const i = Number(key);
38
+ if (!Number.isInteger(i) || String(i) !== key || i < 0 || i >= node.length)
39
+ return node;
40
+ const child = forceAt(node[i], rest, index, snapshot);
41
+ if (child === node[i])
42
+ return node;
43
+ const copy = node.slice();
44
+ copy[i] = child;
45
+ return copy;
46
+ }
47
+ if (!isPlainObject(node) || !Object.hasOwn(node, key))
48
+ return node;
49
+ const child = forceAt(node[key], rest, index, snapshot);
50
+ return child === node[key] ? node : { ...node, [key]: child };
51
+ }
52
+ /** A multivariate block (by its own name or an alias) with only `variants[index]`, ruled `true`. */
53
+ function forceNode(node, index, snapshot) {
54
+ if (!isPlainObject(node) || typeof node.__resolveType !== "string")
55
+ return node;
56
+ const type = node.__resolveType;
57
+ const canonical = own(snapshot.aliases, type) ?? own(LEGACY_ALIASES, type) ?? type;
58
+ if (canonical !== "multivariate" || !Array.isArray(node.variants))
59
+ return node;
60
+ const variant = node.variants[index];
61
+ if (!isPlainObject(variant))
62
+ return node;
63
+ return { ...node, variants: [{ ...variant, rule: true }] };
64
+ }
65
+ //# sourceMappingURL=variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.js","sourceRoot":"","sources":["../../src/v8/variants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/C,MAAM,UAAU,aAAa,CAC3B,QAAkB,EAClB,QAA8C;IAE9C,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IACrE,IAAI,MAA2C,CAAC;IAChD,KAAK,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,MAAM,IAAI,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS;YAAE,SAAS;QAClC,MAAM,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE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  "node": ">=24"
@@ -11,9 +11,11 @@
11
11
  "url": "https://github.com/decocms/blocks.git",
12
12
  "directory": "packages/blocks"
13
13
  },
14
- "main": "./src/index.ts",
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
15
16
  "files": [
16
17
  "bin",
18
+ "dist",
17
19
  "src",
18
20
  "!src/**/*.test.ts",
19
21
  "!src/**/*.test.tsx",
@@ -26,28 +28,72 @@
26
28
  "deco": "./bin/deco.js"
27
29
  },
28
30
  "exports": {
29
- ".": "./src/index.ts",
30
- "./analytics": "./src/v8/analytics.ts",
31
- "./cli": "./src/v8/cli/index.ts",
32
- "./fetch": "./src/v8/fetch.ts",
33
- "./secrets": "./src/v8/secrets.ts",
34
- "./protocol": "./src/protocol/index.ts",
35
- "./protocol/keys": "./src/protocol/keys.ts",
36
- "./protocol/server": "./src/protocol/server/index.ts",
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "source": "./src/index.ts",
34
+ "default": "./dist/index.js"
35
+ },
36
+ "./analytics": {
37
+ "types": "./dist/v8/analytics.d.ts",
38
+ "source": "./src/v8/analytics.ts",
39
+ "default": "./dist/v8/analytics.js"
40
+ },
41
+ "./cli": {
42
+ "types": "./dist/v8/cli/index.d.ts",
43
+ "source": "./src/v8/cli/index.ts",
44
+ "default": "./dist/v8/cli/index.js"
45
+ },
46
+ "./fetch": {
47
+ "types": "./dist/v8/fetch.d.ts",
48
+ "source": "./src/v8/fetch.ts",
49
+ "default": "./dist/v8/fetch.js"
50
+ },
51
+ "./secrets": {
52
+ "types": "./dist/v8/secrets.d.ts",
53
+ "source": "./src/v8/secrets.ts",
54
+ "default": "./dist/v8/secrets.js"
55
+ },
56
+ "./protocol": {
57
+ "types": "./dist/protocol/index.d.ts",
58
+ "source": "./src/protocol/index.ts",
59
+ "default": "./dist/protocol/index.js"
60
+ },
61
+ "./protocol/keys": {
62
+ "types": "./dist/protocol/keys.d.ts",
63
+ "source": "./src/protocol/keys.ts",
64
+ "default": "./dist/protocol/keys.js"
65
+ },
66
+ "./protocol/server": {
67
+ "types": "./dist/protocol/server/index.d.ts",
68
+ "source": "./src/protocol/server/index.ts",
69
+ "default": "./dist/protocol/server/index.js"
70
+ },
37
71
  "./protocol/storage/fs": {
38
- "node": "./src/protocol/storage/fs/index.ts",
39
- "default": "./src/protocol/storage/fs/unsupported.ts"
72
+ "node": {
73
+ "types": "./dist/protocol/storage/fs/index.d.ts",
74
+ "source": "./src/protocol/storage/fs/index.ts",
75
+ "default": "./dist/protocol/storage/fs/index.js"
76
+ },
77
+ "default": {
78
+ "types": "./dist/protocol/storage/fs/unsupported.d.ts",
79
+ "source": "./src/protocol/storage/fs/unsupported.ts",
80
+ "default": "./dist/protocol/storage/fs/unsupported.js"
81
+ }
40
82
  },
41
- "./protocol/conformance": "./src/protocol/conformance/index.ts"
83
+ "./protocol/conformance": {
84
+ "types": "./dist/protocol/conformance/index.d.ts",
85
+ "source": "./src/protocol/conformance/index.ts",
86
+ "default": "./dist/protocol/conformance/index.js"
87
+ }
42
88
  },
43
89
  "scripts": {
44
- "build": "tsc",
90
+ "build": "node ../../scripts/tsc.mjs --clean dist -p tsconfig.build.json",
91
+ "prepack": "npm run build",
45
92
  "test": "vitest run --root ../.. packages/blocks/",
46
- "typecheck": "tsc --noEmit"
93
+ "typecheck": "node ../../scripts/tsc.mjs -p tsconfig.json"
47
94
  },
48
95
  "dependencies": {
49
96
  "ajv": "^8.20.0",
50
- "tsx": "^4.22.5",
51
97
  "zod": "^4.4.3"
52
98
  },
53
99
  "peerDependencies": {
@@ -55,11 +101,11 @@
55
101
  "typescript": "^5.0.0"
56
102
  },
57
103
  "devDependencies": {
104
+ "@opentelemetry/api": "^1.9.1",
58
105
  "@types/react": "^19.0.0",
59
106
  "@types/react-dom": "^19.0.0",
60
107
  "esbuild": "^0.27.3",
61
- "react-dom": "^19.0.0",
62
- "typescript": "^5.9.0"
108
+ "react-dom": "^19.0.0"
63
109
  },
64
110
  "publishConfig": {
65
111
  "registry": "https://registry.npmjs.org",
package/src/index.ts CHANGED
@@ -32,4 +32,4 @@ export {
32
32
  type Telemetry,
33
33
  type TelemetryConfig,
34
34
  type Variant,
35
- } from "./v8/index";
35
+ } from "./v8/index.ts";
@@ -4,4 +4,4 @@
4
4
  * content revisions too; the protocol re-exports it so the CLI, the server
5
5
  * and the site editor share one definition.
6
6
  */
7
- export * from "../v8/canonical";
7
+ export * from "../v8/canonical.ts";
@@ -3,4 +3,4 @@
3
3
  * module of the SDK (`src/v8/ciphertext.ts`), where the `secret` built-in
4
4
  * decrypts it; the protocol re-exports it for its secret guard.
5
5
  */
6
- export * from "../v8/ciphertext";
6
+ export * from "../v8/ciphertext.ts";
@@ -2,7 +2,7 @@
2
2
  * A small content-protocol client: one method per protocol method, plus
3
3
  * batches. Uses `fetch`, so it runs in browsers, on Workers and on Node.
4
4
  */
5
- import { ContentProtocolError, ErrorCode, type RpcErrorObject } from "./errors";
5
+ import { ContentProtocolError, ErrorCode, type RpcErrorObject } from "./errors.ts";
6
6
  import {
7
7
  type DescribeResult,
8
8
  type MethodName,
@@ -10,7 +10,7 @@ import {
10
10
  PROTOCOL_NAME,
11
11
  PROTOCOL_VERSION,
12
12
  type RpcId,
13
- } from "./types";
13
+ } from "./types.ts";
14
14
 
15
15
  export interface ContentClientOptions {
16
16
  /** The endpoint URL, such as `http://127.0.0.1:4545/rpc`. */
@@ -2,9 +2,9 @@
2
2
  * Uploads beside the protocol: `PUT /assets/<name>`. These cases run only
3
3
  * when the harness passes `assetsEndpoint`.
4
4
  */
5
- import { ErrorCode } from "../../errors";
6
- import { assert, assertEqual, type ConformanceContext, rawErrorCode } from "../context";
7
- import type { ConformanceCase } from "./types";
5
+ import { ErrorCode } from "../../errors.ts";
6
+ import { assert, assertEqual, type ConformanceContext, rawErrorCode } from "../context.ts";
7
+ import type { ConformanceCase } from "./types.ts";
8
8
 
9
9
  /** The smallest PNG header: enough bytes for an upload, never executed. */
10
10
  const PNG = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
@@ -1,16 +1,16 @@
1
1
  /**
2
2
  * Limits, the secret guard and request-key idempotency.
3
3
  */
4
- import { encryptToCiphertext, publicKeyPemFromDer } from "../../ciphertext";
5
- import { ErrorCode, type InvalidBlockData } from "../../errors";
4
+ import { encryptToCiphertext, publicKeyPemFromDer } from "../../ciphertext.ts";
5
+ import { ErrorCode, type InvalidBlockData } from "../../errors.ts";
6
6
  import {
7
7
  assert,
8
8
  assertEqual,
9
9
  type ConformanceContext,
10
10
  expectError,
11
11
  rawErrorCode,
12
- } from "../context";
13
- import type { ConformanceCase } from "./types";
12
+ } from "../context.ts";
13
+ import type { ConformanceCase } from "./types.ts";
14
14
 
15
15
  async function writable(ctx: ConformanceContext) {
16
16
  const d = await ctx.describe();
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * `describe`, `schema.get` and `blocks.list`, including conditional reads.
3
3
  */
4
- import { ErrorCode } from "../../errors";
5
- import { PROTOCOL_NAME, SCHEMA_FORMAT } from "../../types";
6
- import { assert, assertEqual, expectError } from "../context";
7
- import type { ConformanceCase } from "./types";
4
+ import { ErrorCode } from "../../errors.ts";
5
+ import { PROTOCOL_NAME, SCHEMA_FORMAT } from "../../types.ts";
6
+ import { assert, assertEqual, expectError } from "../context.ts";
7
+ import type { ConformanceCase } from "./types.ts";
8
8
 
9
9
  const LIMIT_KEYS = [
10
10
  "maxOpsPerApply",
@@ -1,4 +1,4 @@
1
- import type { ConformanceContext } from "../context";
1
+ import type { ConformanceContext } from "../context.ts";
2
2
 
3
3
  /** One black-box check of a content-protocol endpoint. */
4
4
  export interface ConformanceCase {
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * The wire format: JSON-RPC 2.0 envelopes, batches, HTTP status codes, gzip.
3
3
  */
4
- import { ErrorCode } from "../../errors";
5
- import { MAX_BATCH_CALLS } from "../../types";
6
- import { assert, assertEqual, rawErrorCode } from "../context";
7
- import type { ConformanceCase } from "./types";
4
+ import { ErrorCode } from "../../errors.ts";
5
+ import { MAX_BATCH_CALLS } from "../../types.ts";
6
+ import { assert, assertEqual, rawErrorCode } from "../context.ts";
7
+ import type { ConformanceCase } from "./types.ts";
8
8
 
9
9
  const req = (id: unknown, method: string, params?: unknown) =>
10
10
  params === undefined ? { jsonrpc: "2.0", id, method } : { jsonrpc: "2.0", id, method, params };
@@ -2,10 +2,10 @@
2
2
  * `blocks.apply`: atomic set and delete, set precedence, validation, the
3
3
  * file-name rule and preconditions.
4
4
  */
5
- import { ErrorCode, type InvalidBlockData } from "../../errors";
6
- import type { BlocksListResult } from "../../types";
7
- import { assert, assertEqual, type ConformanceContext, expectError } from "../context";
8
- import type { ConformanceCase } from "./types";
5
+ import { ErrorCode, type InvalidBlockData } from "../../errors.ts";
6
+ import type { BlocksListResult } from "../../types.ts";
7
+ import { assert, assertEqual, type ConformanceContext, expectError } from "../context.ts";
8
+ import type { ConformanceCase } from "./types.ts";
9
9
 
10
10
  type FullList = Extract<BlocksListResult, { notModified: false }>;
11
11
 
@@ -77,3 +77,60 @@ export const contentHashFixtures: readonly ContentHashFixture[] = [
77
77
  revision: "6913c5e6aa28f441d3b0102177b372e4fb7c08bc09bdd8698df85e597282ac96",
78
78
  },
79
79
  ];
80
+
81
+ /**
82
+ * Golden fixtures for draft overlays (see /next/content-delivery#exact-draft-previews):
83
+ * whatever prepares draft assets must produce these block hashes and overlay
84
+ * versions, which the SDK checks on every asset it downloads.
85
+ *
86
+ * ```ts
87
+ * import { draftOverlayFixtures } from "@decocms/blocks/protocol/conformance";
88
+ * for (const f of draftOverlayFixtures) expect(await myOverlayVersion(f.overlay)).toBe(f.version);
89
+ * ```
90
+ */
91
+ export interface DraftOverlayFixture {
92
+ id: string;
93
+ title: string;
94
+ /** The changed entries, by name: each is stored under its block hash. */
95
+ blocks: Record<string, unknown>;
96
+ /** Each changed entry's block hash: SHA-256 of its canonical JSON. */
97
+ hashes: Record<string, string>;
98
+ /** The manifest. */
99
+ overlay: { format: 1; set: Record<string, string>; delete: string[] };
100
+ /** Its canonical JSON. */
101
+ canonical: string;
102
+ /** The overlay version: SHA-256 of the canonical manifest. */
103
+ version: string;
104
+ }
105
+
106
+ export const draftOverlayFixtures: readonly DraftOverlayFixture[] = [
107
+ {
108
+ id: "empty",
109
+ title: "a draft with no changes",
110
+ blocks: {},
111
+ hashes: {},
112
+ overlay: { format: 1, set: {}, delete: [] },
113
+ canonical: '{"delete":[],"format":1,"set":{}}',
114
+ version: "8e740552419ba3858a3be4a30165178ab034372f8718e34d076518325bab75e4",
115
+ },
116
+ {
117
+ id: "set-and-delete",
118
+ title: "one replacement and one tombstone (the docs' example)",
119
+ blocks: {
120
+ HomeHero: {
121
+ __resolveType: "hero",
122
+ title: "Summer sale",
123
+ image: { src: "/s.png", width: 1200 },
124
+ },
125
+ },
126
+ hashes: { HomeHero: "81213bc231ca93365b7c45d26265c21814fc0a359b1c44078e36ecdcf895fd80" },
127
+ overlay: {
128
+ format: 1,
129
+ set: { HomeHero: "81213bc231ca93365b7c45d26265c21814fc0a359b1c44078e36ecdcf895fd80" },
130
+ delete: ["OldPromotion"],
131
+ },
132
+ canonical:
133
+ '{"delete":["OldPromotion"],"format":1,"set":{"HomeHero":"81213bc231ca93365b7c45d26265c21814fc0a359b1c44078e36ecdcf895fd80"}}',
134
+ version: "91a60f71f78b5cc373c2995b479fbc2c8932970d4f3ff2bec0404a573d1c440f",
135
+ },
136
+ ];
@@ -2,10 +2,10 @@
2
2
  * What every conformance case gets: a client, raw HTTP access, the endpoint's
3
3
  * `describe`, unique names and assertion helpers.
4
4
  */
5
- import { canonicalJson } from "../canonical";
6
- import { type ContentClient, createContentClient, readResponseJson } from "../client";
7
- import { ContentProtocolError } from "../errors";
8
- import type { DescribeResult } from "../types";
5
+ import { canonicalJson } from "../canonical.ts";
6
+ import { type ContentClient, createContentClient, readResponseJson } from "../client.ts";
7
+ import { ContentProtocolError } from "../errors.ts";
8
+ import type { DescribeResult } from "../types.ts";
9
9
 
10
10
  export interface ConformanceOptions {
11
11
  /** The endpoint URL, such as `http://127.0.0.1:4545/rpc`. */