@decocms/blocks 8.1.0-next.0 → 8.1.0-next.2

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 (490) 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 +22 -0
  47. package/dist/protocol/conformance/contentHashFixtures.d.ts.map +1 -0
  48. package/dist/protocol/conformance/contentHashFixtures.js +64 -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 +25 -0
  63. package/dist/protocol/index.d.ts.map +1 -0
  64. package/dist/protocol/index.js +25 -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 +42 -0
  191. package/dist/v8/canonical.d.ts.map +1 -0
  192. package/dist/v8/canonical.js +111 -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 +120 -0
  247. package/dist/v8/cli/schema/tsProgram.d.ts.map +1 -0
  248. package/dist/v8/cli/schema/tsProgram.js +418 -0
  249. package/dist/v8/cli/schema/tsProgram.js.map +1 -0
  250. package/dist/v8/cli/schema/typeToSchema.d.ts +81 -0
  251. package/dist/v8/cli/schema/typeToSchema.d.ts.map +1 -0
  252. package/dist/v8/cli/schema/typeToSchema.js +683 -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 +206 -0
  269. package/dist/v8/cms.js.map +1 -0
  270. package/dist/v8/content.d.ts +35 -0
  271. package/dist/v8/content.d.ts.map +1 -0
  272. package/dist/v8/content.js +183 -0
  273. package/dist/v8/content.js.map +1 -0
  274. package/dist/v8/draft.d.ts +44 -0
  275. package/dist/v8/draft.d.ts.map +1 -0
  276. package/dist/v8/draft.js +133 -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 +243 -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 +214 -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/package.json +65 -105
  323. package/src/index.ts +3 -13
  324. package/src/protocol/canonical.ts +1 -1
  325. package/src/protocol/ciphertext.ts +1 -1
  326. package/src/protocol/client.ts +2 -2
  327. package/src/protocol/conformance/cases/assets.ts +3 -3
  328. package/src/protocol/conformance/cases/guards.ts +4 -4
  329. package/src/protocol/conformance/cases/reads.ts +4 -4
  330. package/src/protocol/conformance/cases/types.ts +1 -1
  331. package/src/protocol/conformance/cases/wire.ts +4 -4
  332. package/src/protocol/conformance/cases/writes.ts +4 -4
  333. package/src/protocol/conformance/context.ts +4 -4
  334. package/src/protocol/conformance/index.ts +10 -10
  335. package/src/protocol/index.ts +6 -6
  336. package/src/protocol/params.ts +2 -2
  337. package/src/protocol/secrets.ts +3 -3
  338. package/src/protocol/server/assets.ts +6 -6
  339. package/src/protocol/server/auth.ts +1 -1
  340. package/src/protocol/server/content.ts +5 -5
  341. package/src/protocol/server/core.ts +12 -6
  342. package/src/protocol/server/handler.ts +6 -6
  343. package/src/protocol/server/http.ts +1 -1
  344. package/src/protocol/server/index.ts +3 -3
  345. package/src/protocol/server/methods/apply.ts +9 -9
  346. package/src/protocol/server/methods/read.ts +5 -5
  347. package/src/protocol/server/rpc.ts +6 -6
  348. package/src/protocol/storage/fs/index.ts +7 -7
  349. package/src/protocol/storage/fs/lock.ts +1 -1
  350. package/src/protocol/storage/fs/unsupported.ts +2 -2
  351. package/src/protocol/storage/memory.ts +5 -5
  352. package/src/protocol/storage.ts +1 -1
  353. package/src/v8/analytics.ts +2 -2
  354. package/src/v8/background.ts +3 -3
  355. package/src/v8/builtins/data.ts +1 -1
  356. package/src/v8/builtins/index.ts +6 -6
  357. package/src/v8/builtins/lazy.ts +1 -1
  358. package/src/v8/builtins/legacy.ts +2 -2
  359. package/src/v8/builtins/multivariate.ts +1 -1
  360. package/src/v8/builtins/secret.ts +2 -2
  361. package/src/v8/cli/builtins.ts +2 -2
  362. package/src/v8/cli/check/index.ts +11 -11
  363. package/src/v8/cli/content.ts +6 -6
  364. package/src/v8/cli/index.ts +8 -8
  365. package/src/v8/cli/main.ts +1 -1
  366. package/src/v8/cli/run.ts +7 -7
  367. package/src/v8/cli/schema/builtinSchemas.ts +1 -1
  368. package/src/v8/cli/schema/generate.ts +6 -6
  369. package/src/v8/cli/schema/index.ts +4 -4
  370. package/src/v8/cli/schema/tsProgram.ts +1 -1
  371. package/src/v8/cli/schema/typeToSchema.ts +24 -2
  372. package/src/v8/cli/serve/server.ts +9 -9
  373. package/src/v8/client.ts +5 -5
  374. package/src/v8/cms.ts +9 -9
  375. package/src/v8/content.ts +4 -4
  376. package/src/v8/draft.ts +1 -1
  377. package/src/v8/errors.ts +1 -1
  378. package/src/v8/fetch.ts +9 -28
  379. package/src/v8/identity.ts +1 -1
  380. package/src/v8/index.ts +5 -5
  381. package/src/v8/matchRoute.ts +1 -1
  382. package/src/v8/remoteLoader.ts +7 -7
  383. package/src/v8/resolver.ts +6 -6
  384. package/src/v8/secrets.ts +1 -1
  385. package/src/v8/telemetry.ts +6 -6
  386. package/src/cms/applySectionConventions.ts +0 -148
  387. package/src/cms/blockSource.ts +0 -228
  388. package/src/cms/client.ts +0 -85
  389. package/src/cms/deferredTrigger.ts +0 -58
  390. package/src/cms/draftSource.ts +0 -476
  391. package/src/cms/index.ts +0 -180
  392. package/src/cms/loadDecofileDirectory.ts +0 -89
  393. package/src/cms/loader.ts +0 -563
  394. package/src/cms/registry.ts +0 -264
  395. package/src/cms/renderJson.ts +0 -179
  396. package/src/cms/resolve.ts +0 -2583
  397. package/src/cms/schema.ts +0 -1219
  398. package/src/cms/sectionLoaderContext.ts +0 -113
  399. package/src/cms/sectionLoaders.ts +0 -686
  400. package/src/cms/sectionMixins.ts +0 -153
  401. package/src/flags/audience.ts +0 -56
  402. package/src/flags/everyone.ts +0 -29
  403. package/src/flags/flag.ts +0 -15
  404. package/src/flags/multivariate/image.ts +0 -11
  405. package/src/flags/multivariate/message.ts +0 -11
  406. package/src/flags/multivariate/page.ts +0 -16
  407. package/src/flags/multivariate/section.ts +0 -16
  408. package/src/flags/multivariate.ts +0 -1
  409. package/src/flags/types.ts +0 -59
  410. package/src/flags/utils/multivariate.ts +0 -20
  411. package/src/hooks/Image.tsx +0 -314
  412. package/src/hooks/JsonLd.tsx +0 -353
  413. package/src/hooks/LazySection.tsx +0 -121
  414. package/src/hooks/LiveControls.tsx +0 -144
  415. package/src/hooks/Picture.tsx +0 -127
  416. package/src/hooks/RenderSection.tsx +0 -91
  417. package/src/hooks/SectionErrorFallback.tsx +0 -97
  418. package/src/hooks/Stats.tsx +0 -134
  419. package/src/hooks/index.ts +0 -35
  420. package/src/hooks/useLoadMore.ts +0 -100
  421. package/src/matchers/builtins.ts +0 -459
  422. package/src/matchers/countryNames.ts +0 -104
  423. package/src/matchers/override.ts +0 -136
  424. package/src/matchers/posthog.ts +0 -154
  425. package/src/middleware/decoState.ts +0 -55
  426. package/src/middleware/healthMetrics.ts +0 -133
  427. package/src/middleware/hydrationContext.ts +0 -79
  428. package/src/middleware/index.ts +0 -88
  429. package/src/middleware/liveness.ts +0 -21
  430. package/src/middleware/observability.ts +0 -800
  431. package/src/middleware/validateSection.ts +0 -100
  432. package/src/preview/DraftPreviewBadge.tsx +0 -306
  433. package/src/preview/decoMark.ts +0 -11
  434. package/src/preview/index.ts +0 -8
  435. package/src/sdk/abTesting.ts +0 -556
  436. package/src/sdk/analytics.ts +0 -147
  437. package/src/sdk/cacheHeaders.ts +0 -633
  438. package/src/sdk/cacheStorage.ts +0 -287
  439. package/src/sdk/cachedLoader.ts +0 -556
  440. package/src/sdk/clx.ts +0 -5
  441. package/src/sdk/cn.ts +0 -28
  442. package/src/sdk/composite.ts +0 -114
  443. package/src/sdk/cookie.ts +0 -129
  444. package/src/sdk/crypto.ts +0 -199
  445. package/src/sdk/csp.ts +0 -59
  446. package/src/sdk/deepOmit.ts +0 -52
  447. package/src/sdk/detectDevice.ts +0 -45
  448. package/src/sdk/djb2.ts +0 -20
  449. package/src/sdk/encoding.ts +0 -44
  450. package/src/sdk/env.ts +0 -54
  451. package/src/sdk/experiments.ts +0 -314
  452. package/src/sdk/fetchCache.ts +0 -269
  453. package/src/sdk/fetchTimeout.ts +0 -58
  454. package/src/sdk/flags.ts +0 -138
  455. package/src/sdk/http.ts +0 -124
  456. package/src/sdk/index.ts +0 -97
  457. package/src/sdk/inflightTimeout.ts +0 -53
  458. package/src/sdk/instrumentedFetch.ts +0 -362
  459. package/src/sdk/invoke.ts +0 -298
  460. package/src/sdk/logger.ts +0 -304
  461. package/src/sdk/mergeCacheControl.ts +0 -150
  462. package/src/sdk/nonce.ts +0 -46
  463. package/src/sdk/normalizeUrls.ts +0 -91
  464. package/src/sdk/observability.ts +0 -116
  465. package/src/sdk/otel.ts +0 -1118
  466. package/src/sdk/otelAdapters/clickhouseCollector.ts +0 -65
  467. package/src/sdk/otelAdapters.ts +0 -144
  468. package/src/sdk/otelHttpLog.ts +0 -419
  469. package/src/sdk/otelHttpMeter.ts +0 -532
  470. package/src/sdk/otelHttpTracer.ts +0 -543
  471. package/src/sdk/redirects.ts +0 -336
  472. package/src/sdk/requestContext.ts +0 -281
  473. package/src/sdk/requestContextStorage.browser.ts +0 -43
  474. package/src/sdk/requestContextStorage.ts +0 -35
  475. package/src/sdk/responseCache.ts +0 -82
  476. package/src/sdk/retry.ts +0 -45
  477. package/src/sdk/serverTimings.ts +0 -68
  478. package/src/sdk/signal.ts +0 -42
  479. package/src/sdk/sitemap.ts +0 -160
  480. package/src/sdk/urlRedaction.ts +0 -82
  481. package/src/sdk/urlUtils.ts +0 -183
  482. package/src/sdk/useDevice.ts +0 -89
  483. package/src/sdk/useDeviceContext.tsx +0 -108
  484. package/src/sdk/useId.ts +0 -7
  485. package/src/sdk/useScript.ts +0 -210
  486. package/src/sdk/useSuggestions.ts +0 -188
  487. package/src/sdk/wrapCaughtErrors.ts +0 -107
  488. package/src/setup.ts +0 -120
  489. package/src/types/index.ts +0 -53
  490. package/src/types/widgets.ts +0 -14
@@ -0,0 +1,683 @@
1
+ /**
2
+ * TypeScript types to JSON Schema, in the site editor's dialect (the
3
+ * `deco-meta@1` format, which is today's `meta.gen.json`).
4
+ *
5
+ * Ported from the v7 generator (`@decocms/blocks-cli`'s
6
+ * `scripts/generate-schema.ts`: `typeToJsonSchema`, the JSDoc tag table and
7
+ * the widget aliases), so a type produces the same field it always has. What
8
+ * changed for the next major (spec: schema › From types to forms):
9
+ *
10
+ * - `ReactNode` / `ReactNode[]` are a choice of components (the section
11
+ * picker) instead of a hidden field.
12
+ * - An object field takes a plain value or any block whose function's awaited
13
+ * return type fits it, decided by TypeScript assignability, not by type
14
+ * name (spec: schema › Interchangeable blocks).
15
+ * - `Lazy<T>` is a `lazy` block whose `value` has the form of `T`.
16
+ * - `Secret` holds a `secret` block, never a plain string.
17
+ * - `@options` with a literal list becomes an `enum`; a function-backed list
18
+ * falls back to a text field, since the site editor never runs site code.
19
+ *
20
+ * The compiler is only imported as types here; `generate.ts` loads the
21
+ * app's `typescript` when `deco schema` runs.
22
+ */
23
+ import fs from "node:fs";
24
+ import path from "node:path";
25
+ export const RESOLVABLE_KEY = "Resolvable";
26
+ export const SECTION_REF_KEY = "__SECTION_REF__";
27
+ /** Standard padded base64, matching the browser's `btoa()`. */
28
+ export function toBase64(value) {
29
+ return Buffer.from(value, "utf8").toString("base64");
30
+ }
31
+ export const resolvableRef = () => ({ $ref: `#/definitions/${RESOLVABLE_KEY}` });
32
+ export const sectionRef = () => ({ $ref: `#/definitions/${SECTION_REF_KEY}` });
33
+ // ---------------------------------------------------------------------------
34
+ // JSDoc tags (spec: schema › Widgets)
35
+ // ---------------------------------------------------------------------------
36
+ const NUMERIC_TAGS = new Set([
37
+ "maximum",
38
+ "minimum",
39
+ "exclusiveMaximum",
40
+ "exclusiveMinimum",
41
+ "multipleOf",
42
+ "maxLength",
43
+ "minLength",
44
+ "maxItems",
45
+ "minItems",
46
+ "maxProperties",
47
+ "minProperties",
48
+ ]);
49
+ const BOOLEAN_TAGS = new Set(["readOnly", "writeOnly", "deprecated", "uniqueItems"]);
50
+ export function getJsDocTags(symbol) {
51
+ const tags = {};
52
+ for (const decl of symbol.getDeclarations()) {
53
+ for (const doc of decl.getJsDocs()) {
54
+ const desc = doc.getDescription().trim();
55
+ if (desc)
56
+ tags.description = desc;
57
+ for (const tag of doc.getTags()) {
58
+ tags[tag.getTagName()] = tag.getCommentText()?.trim() || "true";
59
+ }
60
+ }
61
+ }
62
+ return tags;
63
+ }
64
+ /**
65
+ * Parse an `@options` value. A JSON list of strings, numbers, or
66
+ * `{ value, label }` objects is a static list; anything else (a loader path,
67
+ * a function name) is dynamic and can't be written into the schema.
68
+ */
69
+ function parseOptions(raw) {
70
+ let parsed;
71
+ try {
72
+ parsed = JSON.parse(raw);
73
+ }
74
+ catch {
75
+ return null;
76
+ }
77
+ if (!Array.isArray(parsed) || parsed.length === 0)
78
+ return null;
79
+ const values = [];
80
+ const labels = [];
81
+ let labelled = false;
82
+ for (const item of parsed) {
83
+ if (typeof item === "string" || typeof item === "number") {
84
+ values.push(item);
85
+ labels.push(String(item));
86
+ }
87
+ else if (item &&
88
+ typeof item === "object" &&
89
+ (typeof item.value === "string" || typeof item.value === "number")) {
90
+ values.push(item.value);
91
+ labels.push(typeof item.label === "string" ? item.label : String(item.value));
92
+ labelled ||= typeof item.label === "string";
93
+ }
94
+ else {
95
+ return null;
96
+ }
97
+ }
98
+ return labelled ? { values, labels } : { values };
99
+ }
100
+ function applyJsDocToSchema(schema, tags) {
101
+ for (const [tag, value] of Object.entries(tags)) {
102
+ if (tag === "ignore")
103
+ continue;
104
+ if (tag === "hide") {
105
+ schema.hide = "true";
106
+ continue;
107
+ }
108
+ if (tag === "default") {
109
+ if (value === "true")
110
+ schema.default = true;
111
+ else if (value === "false")
112
+ schema.default = false;
113
+ else if (value === "null")
114
+ schema.default = null;
115
+ else if (!Number.isNaN(Number(value)) && value.trim() !== "")
116
+ schema.default = Number(value);
117
+ else {
118
+ try {
119
+ schema.default = JSON.parse(value);
120
+ }
121
+ catch {
122
+ schema.default = value;
123
+ }
124
+ }
125
+ continue;
126
+ }
127
+ if (tag === "examples") {
128
+ const lines = value
129
+ .split("\n")
130
+ .map((l) => l.trim())
131
+ .filter(Boolean);
132
+ if (lines.length > 1)
133
+ schema.examples = lines;
134
+ else {
135
+ try {
136
+ schema.examples = JSON.parse(value);
137
+ }
138
+ catch {
139
+ schema.examples = [value];
140
+ }
141
+ }
142
+ continue;
143
+ }
144
+ if (tag === "options") {
145
+ const options = parseOptions(value);
146
+ // Static lists become an enum the site editor shows as a select without
147
+ // asking the site. A dynamic list falls back to a plain text field.
148
+ if (options) {
149
+ schema.enum = options.values;
150
+ if (options.labels)
151
+ schema.enumNames = options.labels;
152
+ }
153
+ continue;
154
+ }
155
+ if (NUMERIC_TAGS.has(tag)) {
156
+ schema[tag] = Number(value);
157
+ continue;
158
+ }
159
+ if (BOOLEAN_TAGS.has(tag)) {
160
+ schema[tag] = value === "true";
161
+ continue;
162
+ }
163
+ // Everything else passes through as-is, matching the v7 generator: title,
164
+ // description, format, widget, icon, titleBy, mode, label, pattern, …
165
+ schema[tag] = value;
166
+ }
167
+ }
168
+ // ---------------------------------------------------------------------------
169
+ // Widget aliases (kept from v7: `image: ImageWidget` is an image picker)
170
+ // ---------------------------------------------------------------------------
171
+ const WIDGET_TYPE_FORMATS = {
172
+ ImageWidget: "image-uri",
173
+ VideoWidget: "video-uri",
174
+ HTMLWidget: "html",
175
+ RichText: "rich-text",
176
+ Color: "color",
177
+ TextArea: "textarea",
178
+ Code: "code",
179
+ DateTimeWidget: "date-time",
180
+ };
181
+ /** Apply the format of a widget alias named in `typeHint` to the right inner schema. */
182
+ function applyWidgetFormat(schema, typeHint) {
183
+ const format = Object.entries(WIDGET_TYPE_FORMATS).find(([alias]) => typeHint === alias || new RegExp(`\\b${alias}\\b`).test(typeHint))?.[1];
184
+ if (!format)
185
+ return;
186
+ if (schema.type === "string") {
187
+ schema.format ??= format;
188
+ }
189
+ else if (schema.type === "array" && schema.items?.type === "string") {
190
+ schema.items.format ??= format;
191
+ }
192
+ else if (Array.isArray(schema.anyOf)) {
193
+ for (const variant of schema.anyOf) {
194
+ if (variant.type === "string")
195
+ variant.format ??= format;
196
+ }
197
+ }
198
+ else if (!schema.type && !schema.$ref && !schema.anyOf) {
199
+ // A widget alias the checker couldn't resolve (remote import) came through as
200
+ // `any`; every widget alias is a string, so recover the intended widget.
201
+ schema.type = "string";
202
+ schema.format = format;
203
+ }
204
+ }
205
+ // ---------------------------------------------------------------------------
206
+ // Recognizing the framework's own types
207
+ // ---------------------------------------------------------------------------
208
+ const JSX_SYMBOLS = new Set([
209
+ "ReactNode",
210
+ "ReactElement",
211
+ "ReactPortal",
212
+ "VNode",
213
+ "ComponentChildren",
214
+ ]);
215
+ function typeNames(type) {
216
+ const names = [];
217
+ const alias = type.getAliasSymbol()?.getName();
218
+ if (alias)
219
+ names.push(alias);
220
+ const sym = type.getSymbol()?.getName();
221
+ if (sym)
222
+ names.push(sym);
223
+ return names;
224
+ }
225
+ /** `ReactNode`, `ReactElement`, `JSX.Element` and friends. */
226
+ /** A render descriptor (spec: rendering): `{ component: string; props: … }`. */
227
+ export function isDescriptorType(type) {
228
+ const check = (t) => {
229
+ const component = t.getProperty("component");
230
+ return component !== undefined && t.getProperty("props") !== undefined;
231
+ };
232
+ if (type.isUnion())
233
+ return type.getUnionTypes().every((t) => check(t));
234
+ return type.isObject() && check(type);
235
+ }
236
+ /**
237
+ * What a section renders to: JSX, or a render descriptor in data mode. A field
238
+ * of either type is a section picker.
239
+ */
240
+ function isSectionType(type) {
241
+ return isJsxType(type) || isDescriptorType(type);
242
+ }
243
+ export function isJsxType(type) {
244
+ if (typeNames(type).some((n) => JSX_SYMBOLS.has(n)))
245
+ return true;
246
+ const text = type.getText();
247
+ if (/(^|\.)Element$/.test(text) && /\bJSX\b/.test(text))
248
+ return true;
249
+ // A flattened `ReactNode` (it lost its alias): a union with an element member.
250
+ return (type.isUnion() &&
251
+ type
252
+ .getUnionTypes()
253
+ .some((member) => typeNames(member).some((n) => n === "ReactElement" || n === "ReactPortal")));
254
+ }
255
+ /**
256
+ * `Lazy<T>`: the `T`, or null for any other type. Only the `Lazy` alias
257
+ * counts, so a method like `onLoad: () => Promise<void>` stays a method
258
+ * (skipped) instead of becoming a lazy field. `typeHint`, the annotation as
259
+ * written, covers a checker that printed the alias away; the type must still
260
+ * have `Lazy`'s shape, a call with no parameters returning a promise of data.
261
+ */
262
+ function lazyInner(type, typeHint = "") {
263
+ const alias = type.getAliasSymbol();
264
+ if (alias?.getName() === "Lazy") {
265
+ const [arg] = type.getAliasTypeArguments();
266
+ if (arg)
267
+ return arg;
268
+ }
269
+ if (!/^(\w+\.)?Lazy\s*</.test(typeHint.trim()))
270
+ return null;
271
+ const signatures = type.getCallSignatures();
272
+ if (signatures.length !== 1 || type.getProperties().length > 0)
273
+ return null;
274
+ const [signature] = signatures;
275
+ if (signature.getParameters().length > 0)
276
+ return null;
277
+ const inner = awaitedOf(signature.getReturnType(), true);
278
+ if (!inner || inner.isVoid() || inner.isUndefined() || inner.isNever())
279
+ return null;
280
+ return inner;
281
+ }
282
+ /** `Secret`, from `@decocms/blocks` (`string & { readonly __secret: true }`). */
283
+ function isSecretType(type, typeHint = "") {
284
+ if (type.getAliasSymbol()?.getName() === "Secret")
285
+ return true;
286
+ if (/^(\w+\.)?Secret$/.test(typeHint.trim()))
287
+ return true;
288
+ return (type.isIntersection() &&
289
+ type.getIntersectionTypes().some((t) => t.getProperty("__secret") !== undefined));
290
+ }
291
+ /**
292
+ * The awaited type: `Promise<T>` is `T`. With `strict`, anything that isn't a
293
+ * promise returns null (used to recognize `() => Promise<T>`).
294
+ */
295
+ export function awaitedOf(type, strict = false) {
296
+ if (type.getSymbol()?.getName() === "Promise" || type.getAliasSymbol()?.getName() === "Promise") {
297
+ const [arg] = type.getTypeArguments();
298
+ return arg ?? null;
299
+ }
300
+ return strict ? null : type;
301
+ }
302
+ export function nonNullable(type) {
303
+ if (!type.isUnion())
304
+ return type;
305
+ const parts = type.getUnionTypes().filter((t) => !t.isNull() && !t.isUndefined());
306
+ return parts.length === 1 ? parts[0] : type.getNonNullableType();
307
+ }
308
+ /** Types a block can fill: objects, arrays and intersections of objects, not primitives. */
309
+ function isObjectLike(type) {
310
+ const t = nonNullable(type);
311
+ if (t.isAny() || t.isUnknown() || t.isNever())
312
+ return false;
313
+ if (t.isString() || t.isNumber() || t.isBoolean() || t.isLiteral() || t.isBooleanLiteral()) {
314
+ return false;
315
+ }
316
+ if (t.isUnion()) {
317
+ // A union of objects (`A | B`) can be filled; a union with a primitive can't.
318
+ return t.getUnionTypes().every((u) => isObjectLike(u) || u.isNull() || u.isUndefined());
319
+ }
320
+ if (t.isIntersection()) {
321
+ return !t.getIntersectionTypes().some((p) => p.isString() || p.isNumber() || p.isBoolean());
322
+ }
323
+ return t.isArray() || t.isObject() || t.isInterface();
324
+ }
325
+ // ---------------------------------------------------------------------------
326
+ // The converter
327
+ // ---------------------------------------------------------------------------
328
+ const REACT_INTERNAL_PROPS = new Set([
329
+ "ref",
330
+ "then",
331
+ "catch",
332
+ "finally",
333
+ "$$typeof",
334
+ "_owner",
335
+ "_store",
336
+ ]);
337
+ // Platform types never configured in a form; collapsed to a hidden object.
338
+ const RUNTIME_INJECTED_TYPES = new Set([
339
+ "URL",
340
+ "URLSearchParams",
341
+ "Request",
342
+ "Response",
343
+ "Headers",
344
+ "AbortSignal",
345
+ "ReadableStream",
346
+ "WritableStream",
347
+ "Blob",
348
+ "File",
349
+ "FormData",
350
+ ]);
351
+ const titleCase = (name) => name.charAt(0).toUpperCase() + name.slice(1);
352
+ /** `Secret | undefined` → `Secret`: the annotation without its nullish members. */
353
+ function stripNullish(typeHint) {
354
+ return typeHint.replace(/\s*\|\s*(null|undefined)\b/g, "").trim();
355
+ }
356
+ function isNullableHint(optional, typeHint) {
357
+ return optional || /\bnull\b|\bundefined\b/.test(typeHint);
358
+ }
359
+ /** The schema of a `lazy` block whose value has the form `value`. */
360
+ export function lazySchema(value) {
361
+ return {
362
+ type: "object",
363
+ required: ["__resolveType", "value"],
364
+ properties: {
365
+ __resolveType: { type: "string", enum: ["lazy"], default: "lazy" },
366
+ value,
367
+ },
368
+ };
369
+ }
370
+ /** The schema of a `secret` block: a write-only field saved encrypted. */
371
+ function secretSchema() {
372
+ return {
373
+ type: "object",
374
+ format: "secret",
375
+ writeOnly: true,
376
+ required: ["__resolveType", "ciphertext"],
377
+ properties: {
378
+ __resolveType: { type: "string", enum: ["secret"], default: "secret" },
379
+ ciphertext: { type: "string" },
380
+ },
381
+ };
382
+ }
383
+ /**
384
+ * The schema of one field: everything a type means at a property position,
385
+ * before the property's own JSDoc and title are applied.
386
+ */
387
+ function fieldSchema(propType, typeHint, ctx, visited = new Set()) {
388
+ const lazy = lazyInner(nonNullable(propType), stripNullish(typeHint));
389
+ if (lazy)
390
+ return lazySchema(fieldSchema(lazy, lazy.getText(), ctx, visited));
391
+ if (isSecretType(nonNullable(propType), stripNullish(typeHint)))
392
+ return secretSchema();
393
+ if (ctx && isObjectLike(propType) && !isSectionType(nonNullable(propType))) {
394
+ const fits = ctx.fitting(propType);
395
+ if (fits.length > 0) {
396
+ const inner = nonNullable(propType);
397
+ const inline = inlineSchema(inner, ctx, visited);
398
+ return {
399
+ anyOf: [resolvableRef(), inline, ...fits.map((key) => ({ $ref: `#/definitions/${key}` }))],
400
+ };
401
+ }
402
+ }
403
+ const schema = typeToJsonSchema(propType, new Set(visited), ctx);
404
+ applyWidgetFormat(schema, typeHint);
405
+ return schema;
406
+ }
407
+ /** The "plain value" branch of a field that blocks can fill. */
408
+ function inlineSchema(type, ctx, visited) {
409
+ if (type.isArray()) {
410
+ const element = type.getArrayElementType();
411
+ const items = element
412
+ ? (ctx.namedDefinition(element) ?? typeToJsonSchema(element, new Set(visited), ctx))
413
+ : {};
414
+ return { type: "array", items, title: "Inline data" };
415
+ }
416
+ const named = ctx.namedDefinition(type);
417
+ return named
418
+ ? { ...named, title: "Inline data" }
419
+ : { ...typeToJsonSchema(type, new Set(visited), ctx), title: "Inline data" };
420
+ }
421
+ /**
422
+ * Whether a prop annotated `Section` / `Section[]` is v7's opaque Section type
423
+ * (`type Section = any`), a "pick any section" field, rather than a site type
424
+ * that happens to be called `Section`.
425
+ */
426
+ function isOpaqueSectionType(propType) {
427
+ let type = nonNullable(propType);
428
+ if (type.isArray())
429
+ type = type.getArrayElementType() ?? type;
430
+ return type.isAny() || type.isUnknown();
431
+ }
432
+ export function typeToJsonSchema(type, visited = new Set(), ctx) {
433
+ const typeText = type.getText();
434
+ if (visited.has(typeText))
435
+ return { type: "object" };
436
+ visited.add(typeText);
437
+ try {
438
+ if (type.isAny() || type.isUnknown())
439
+ return {};
440
+ // Structural blocks wherever the type appears, not only as a whole field:
441
+ // `Secret[]` is a list of secret blocks, `Lazy<T>[]` a list of lazy ones.
442
+ if (isSecretType(type))
443
+ return secretSchema();
444
+ const lazy = lazyInner(type);
445
+ if (lazy)
446
+ return lazySchema(fieldSchema(lazy, lazy.getText(), ctx, visited));
447
+ if (type.isArray()) {
448
+ const el = type.getArrayElementType();
449
+ return el
450
+ ? { type: "array", items: typeToJsonSchema(el, new Set(visited), ctx) }
451
+ : { type: "array" };
452
+ }
453
+ if (isSectionType(type))
454
+ return sectionRef();
455
+ if (type.isString() || type.isStringLiteral()) {
456
+ return type.isStringLiteral()
457
+ ? { type: "string", const: type.getLiteralValue() }
458
+ : { type: "string" };
459
+ }
460
+ if (type.isNumber() || type.isNumberLiteral())
461
+ return { type: "number" };
462
+ if (type.isBoolean() || type.isBooleanLiteral())
463
+ return { type: "boolean" };
464
+ if (type.isNull() || type.isUndefined())
465
+ return { type: "null" };
466
+ if (type.isUnion()) {
467
+ const parts = type.getUnionTypes();
468
+ const nonNull = parts.filter((t) => !t.isNull() && !t.isUndefined());
469
+ const isNullable = nonNull.length < parts.length;
470
+ if (nonNull.length === 1) {
471
+ const inner = typeToJsonSchema(nonNull[0], new Set(visited), ctx);
472
+ return isNullable ? { ...inner, nullable: true } : inner;
473
+ }
474
+ if (nonNull.every((t) => t.isBooleanLiteral())) {
475
+ return isNullable ? { type: "boolean", nullable: true } : { type: "boolean" };
476
+ }
477
+ // String-literal unions and string enums: a select, written into the schema.
478
+ if (nonNull.every((t) => t.isStringLiteral())) {
479
+ const result = { type: "string", enum: nonNull.map((t) => t.getLiteralValue()) };
480
+ if (isNullable)
481
+ result.nullable = true;
482
+ return result;
483
+ }
484
+ if (nonNull.every((t) => t.isNumberLiteral())) {
485
+ const result = { type: "number", enum: nonNull.map((t) => t.getLiteralValue()) };
486
+ if (isNullable)
487
+ result.nullable = true;
488
+ return result;
489
+ }
490
+ const anyOf = nonNull.map((t) => {
491
+ const schema = typeToJsonSchema(t, new Set(visited), ctx);
492
+ if (!schema.title && schema.type === "object") {
493
+ const symName = (t.getAliasSymbol() ?? t.getSymbol())?.getName();
494
+ if (symName && symName !== "__type" && symName !== "default" && symName !== "__object") {
495
+ schema.title = symName;
496
+ }
497
+ if (!schema.title && schema.properties) {
498
+ for (const v of Object.values(schema.properties)) {
499
+ if (v?.const !== undefined) {
500
+ schema.title = String(v.const);
501
+ break;
502
+ }
503
+ }
504
+ }
505
+ }
506
+ return schema;
507
+ });
508
+ const result = { anyOf };
509
+ if (isNullable)
510
+ result.nullable = true;
511
+ return result;
512
+ }
513
+ if (type.isIntersection()) {
514
+ const parts = type.getIntersectionTypes();
515
+ const primitive = parts.find((t) => t.isString() || t.isNumber() || t.isBoolean());
516
+ if (primitive)
517
+ return typeToJsonSchema(primitive, new Set(visited), ctx);
518
+ const merged = { type: "object", properties: {} };
519
+ const required = new Set();
520
+ for (const part of parts) {
521
+ const sub = typeToJsonSchema(part, new Set(visited), ctx);
522
+ if (sub?.type !== "object" || !sub.properties)
523
+ continue;
524
+ Object.assign(merged.properties, sub.properties);
525
+ for (const r of sub.required ?? [])
526
+ required.add(r);
527
+ for (const [k, v] of Object.entries(sub)) {
528
+ if (k === "type" || k === "properties" || k === "required")
529
+ continue;
530
+ if (!(k in merged))
531
+ merged[k] = v;
532
+ }
533
+ }
534
+ if (required.size > 0)
535
+ merged.required = [...required];
536
+ return merged;
537
+ }
538
+ if (type.isObject() || type.isInterface()) {
539
+ if (ctx?.shareNamed && type.compilerType !== ctx.shareNamed.rootType.compilerType) {
540
+ const shared = ctx.namedDefinition(type);
541
+ if (shared)
542
+ return shared;
543
+ }
544
+ const symName = type.getSymbol()?.getName();
545
+ if (symName && RUNTIME_INJECTED_TYPES.has(symName)) {
546
+ const declFile = type.getSymbol()?.getDeclarations()?.[0]?.getSourceFile().getFilePath();
547
+ if (declFile?.includes("typescript/lib/") || declFile?.includes("@types/")) {
548
+ return { type: "object", hide: "true" };
549
+ }
550
+ }
551
+ const stringIdx = type.getStringIndexType();
552
+ const numberIdx = type.getNumberIndexType();
553
+ if ((stringIdx || numberIdx) && type.getProperties().length === 0) {
554
+ return {
555
+ type: "object",
556
+ additionalProperties: typeToJsonSchema((stringIdx || numberIdx), new Set(visited), ctx),
557
+ };
558
+ }
559
+ const properties = {};
560
+ const required = [];
561
+ for (const prop of type.getProperties()) {
562
+ const name = prop.getName();
563
+ if (name.startsWith("_") || name.startsWith("$") || name === "@type")
564
+ continue;
565
+ if (REACT_INTERNAL_PROPS.has(name))
566
+ continue;
567
+ const decl = prop.getValueDeclaration() ?? prop.getDeclarations()[0];
568
+ if (!decl)
569
+ continue;
570
+ const propType = prop.getTypeAtLocation(decl);
571
+ const tags = getJsDocTags(prop);
572
+ if (tags.ignore)
573
+ continue;
574
+ // The annotation as written (`ImageWidget`, `Section[]`, `Secret`),
575
+ // before the checker resolves aliases away.
576
+ const typeNode = decl.getTypeNode();
577
+ const typeHint = typeNode ? typeNode.getText() : propType.getText();
578
+ const optional = prop.isOptional();
579
+ // Methods aren't data, but `Lazy<T>` (a function prop) is a field.
580
+ const callable = nonNullable(propType);
581
+ const isFunction = callable.getCallSignatures().length > 0 && callable.getProperties().length === 0;
582
+ if (isFunction && !lazyInner(nonNullable(propType), stripNullish(typeHint)))
583
+ continue;
584
+ // v7's opaque `Section` type: a section picker.
585
+ const baseHint = typeHint.replace(/\s*\|\s*(null|undefined)/g, "").trim();
586
+ if ((baseHint === "Section" || baseHint === "Section[]") && isOpaqueSectionType(propType)) {
587
+ const schema = baseHint.endsWith("[]")
588
+ ? { type: "array", items: sectionRef(), title: titleCase(name) }
589
+ : { ...sectionRef(), title: titleCase(name) };
590
+ if (isNullableHint(optional, typeHint))
591
+ schema.nullable = true;
592
+ applyJsDocToSchema(schema, tags);
593
+ properties[name] = schema;
594
+ if (!optional)
595
+ required.push(name);
596
+ continue;
597
+ }
598
+ const schema = fieldSchema(propType, typeHint, ctx, visited);
599
+ if (schema.anyOf && schema.anyOf[0]?.$ref === resolvableRef().$ref) {
600
+ // A block-ref field: nullability lives on the wrapper.
601
+ if (isNullableHint(optional, typeHint))
602
+ schema.nullable = true;
603
+ }
604
+ if (schema.$ref === sectionRef().$ref && isNullableHint(optional, typeHint)) {
605
+ schema.nullable = true;
606
+ }
607
+ applyJsDocToSchema(schema, tags);
608
+ schema.title ??= titleCase(name);
609
+ properties[name] = schema;
610
+ // A hidden prop can't be filled in by an editor; requiring it would
611
+ // deadlock the form.
612
+ if (!optional && schema.hide !== "true")
613
+ required.push(name);
614
+ }
615
+ const result = { type: "object", properties };
616
+ if (required.length > 0)
617
+ result.required = required;
618
+ const ifaceSym = type.getAliasSymbol() ?? type.getSymbol();
619
+ if (ifaceSym)
620
+ applyJsDocToSchema(result, getJsDocTags(ifaceSym));
621
+ return result;
622
+ }
623
+ return { type: "string" };
624
+ }
625
+ finally {
626
+ visited.delete(typeText);
627
+ }
628
+ }
629
+ /**
630
+ * A machine-independent id for a source file: relative to the app root, or
631
+ * `<package name>/<path in package>` for a file in a dependency (including a
632
+ * workspace package the checker reached through a symlink).
633
+ *
634
+ * A declaration file with a declaration map (`x.d.ts` + `x.d.ts.map`, as
635
+ * `tsc` emits into a package's dist/) is named after the source it was
636
+ * compiled from, so a type keeps one id whether the checker read the
637
+ * package's compiled `.d.ts` or its `.ts` source (the "source" condition).
638
+ */
639
+ export function stableFileId(filePath, root) {
640
+ const file = sourceOfDeclaration(filePath.replace(/^file:\/+/, "/"));
641
+ const nm = file.lastIndexOf("/node_modules/");
642
+ if (nm >= 0)
643
+ return file.slice(nm + "/node_modules/".length);
644
+ const rel = path.relative(root, file).split(path.sep).join("/");
645
+ if (!rel.startsWith(".."))
646
+ return rel;
647
+ let dir = path.dirname(file);
648
+ for (;;) {
649
+ const manifest = path.join(dir, "package.json");
650
+ if (fs.existsSync(manifest)) {
651
+ try {
652
+ const name = JSON.parse(fs.readFileSync(manifest, "utf8")).name;
653
+ if (typeof name === "string") {
654
+ return `${name}/${path.relative(dir, file).split(path.sep).join("/")}`;
655
+ }
656
+ }
657
+ catch {
658
+ // unreadable manifest: keep walking
659
+ }
660
+ }
661
+ const parent = path.dirname(dir);
662
+ if (parent === dir)
663
+ return path.basename(file);
664
+ dir = parent;
665
+ }
666
+ }
667
+ /** The `.ts` file a `.d.ts` was emitted from, per its declaration map; else the file itself. */
668
+ function sourceOfDeclaration(file) {
669
+ if (!/\.d\.[cm]?ts$/.test(file))
670
+ return file;
671
+ try {
672
+ const map = JSON.parse(fs.readFileSync(`${file}.map`, "utf8"));
673
+ const source = Array.isArray(map.sources) ? map.sources[0] : undefined;
674
+ if (typeof source !== "string")
675
+ return file;
676
+ const sourceRoot = typeof map.sourceRoot === "string" ? map.sourceRoot : "";
677
+ return path.resolve(path.dirname(file), sourceRoot, source);
678
+ }
679
+ catch {
680
+ return file;
681
+ }
682
+ }
683
+ //# sourceMappingURL=typeToSchema.js.map