@earendil-works/chord 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (820) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +79 -14
  3. package/dist/cell.d.ts +7 -7
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js.map +1 -1
  6. package/dist/context/index.d.ts +1 -1
  7. package/dist/context/index.d.ts.map +1 -1
  8. package/dist/context/index.js +1 -1
  9. package/dist/context/index.js.map +1 -1
  10. package/dist/contract.d.ts +51 -52
  11. package/dist/contract.d.ts.map +1 -1
  12. package/dist/contract.js +19 -24
  13. package/dist/contract.js.map +1 -1
  14. package/dist/delta/apply-immutable-trusted.js +3 -4
  15. package/dist/delta/apply-immutable-trusted.js.map +1 -1
  16. package/dist/delta/diff.d.ts.map +1 -1
  17. package/dist/delta/diff.js +5 -3
  18. package/dist/delta/diff.js.map +1 -1
  19. package/dist/delta/index.d.ts +9 -1
  20. package/dist/delta/index.d.ts.map +1 -1
  21. package/dist/delta/index.js +15 -11
  22. package/dist/delta/index.js.map +1 -1
  23. package/dist/delta/pending.d.ts +36 -0
  24. package/dist/delta/pending.d.ts.map +1 -0
  25. package/dist/delta/pending.js +143 -0
  26. package/dist/delta/pending.js.map +1 -0
  27. package/dist/delta/tracker.d.ts +12 -0
  28. package/dist/delta/tracker.d.ts.map +1 -1
  29. package/dist/delta/tracker.js +109 -39
  30. package/dist/delta/tracker.js.map +1 -1
  31. package/dist/host.d.ts.map +1 -1
  32. package/dist/host.js +9 -7
  33. package/dist/host.js.map +1 -1
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +1 -0
  37. package/dist/index.js.map +1 -1
  38. package/dist/next/contracts/accepts.d.ts +81 -0
  39. package/dist/next/contracts/accepts.d.ts.map +1 -0
  40. package/dist/next/contracts/accepts.js +123 -0
  41. package/dist/next/contracts/accepts.js.map +1 -0
  42. package/dist/next/contracts/contract.d.ts +121 -0
  43. package/dist/next/contracts/contract.d.ts.map +1 -0
  44. package/dist/next/contracts/contract.js +50 -0
  45. package/dist/next/contracts/contract.js.map +1 -0
  46. package/dist/next/contracts/declare.d.ts +107 -0
  47. package/dist/next/contracts/declare.d.ts.map +1 -0
  48. package/dist/next/contracts/declare.js +136 -0
  49. package/dist/next/contracts/declare.js.map +1 -0
  50. package/dist/next/contracts/evolve.d.ts +92 -0
  51. package/dist/next/contracts/evolve.d.ts.map +1 -0
  52. package/dist/next/contracts/evolve.js +179 -0
  53. package/dist/next/contracts/evolve.js.map +1 -0
  54. package/dist/next/contracts/fingerprint.d.ts +16 -0
  55. package/dist/next/contracts/fingerprint.d.ts.map +1 -0
  56. package/dist/next/contracts/fingerprint.js +50 -0
  57. package/dist/next/contracts/fingerprint.js.map +1 -0
  58. package/dist/next/contracts/history.d.ts +71 -0
  59. package/dist/next/contracts/history.d.ts.map +1 -0
  60. package/dist/next/contracts/history.js +3 -0
  61. package/dist/next/contracts/history.js.map +1 -0
  62. package/dist/next/contracts/host-kind.d.ts +40 -0
  63. package/dist/next/contracts/host-kind.d.ts.map +1 -0
  64. package/dist/next/contracts/host-kind.js +37 -0
  65. package/dist/next/contracts/host-kind.js.map +1 -0
  66. package/dist/next/contracts/index.d.ts +7 -0
  67. package/dist/next/contracts/index.d.ts.map +1 -0
  68. package/dist/next/contracts/index.js +6 -0
  69. package/dist/next/contracts/index.js.map +1 -0
  70. package/dist/next/contracts/internal.d.ts +10 -0
  71. package/dist/next/contracts/internal.d.ts.map +1 -0
  72. package/dist/next/contracts/internal.js +9 -0
  73. package/dist/next/contracts/internal.js.map +1 -0
  74. package/dist/next/contracts/names.d.ts +3 -0
  75. package/dist/next/contracts/names.d.ts.map +1 -0
  76. package/dist/next/contracts/names.js +13 -0
  77. package/dist/next/contracts/names.js.map +1 -0
  78. package/dist/next/contracts/params.d.ts +28 -0
  79. package/dist/next/contracts/params.d.ts.map +1 -0
  80. package/dist/next/contracts/params.js +50 -0
  81. package/dist/next/contracts/params.js.map +1 -0
  82. package/dist/next/contracts/schema.d.ts +102 -0
  83. package/dist/next/contracts/schema.d.ts.map +1 -0
  84. package/dist/next/contracts/schema.js +103 -0
  85. package/dist/next/contracts/schema.js.map +1 -0
  86. package/dist/next/contracts/snapshot.d.ts +16 -0
  87. package/dist/next/contracts/snapshot.d.ts.map +1 -0
  88. package/dist/next/contracts/snapshot.js +167 -0
  89. package/dist/next/contracts/snapshot.js.map +1 -0
  90. package/dist/next/data/args.d.ts +50 -0
  91. package/dist/next/data/args.d.ts.map +1 -0
  92. package/dist/next/data/args.js +83 -0
  93. package/dist/next/data/args.js.map +1 -0
  94. package/dist/next/data/errors.d.ts +73 -0
  95. package/dist/next/data/errors.d.ts.map +1 -0
  96. package/dist/next/data/errors.js +107 -0
  97. package/dist/next/data/errors.js.map +1 -0
  98. package/dist/next/data/failure.d.ts +26 -0
  99. package/dist/next/data/failure.d.ts.map +1 -0
  100. package/dist/next/data/failure.js +72 -0
  101. package/dist/next/data/failure.js.map +1 -0
  102. package/dist/next/data/index.d.ts +4 -0
  103. package/dist/next/data/index.d.ts.map +1 -0
  104. package/dist/next/data/index.js +4 -0
  105. package/dist/next/data/index.js.map +1 -0
  106. package/dist/next/data/internal.d.ts +7 -0
  107. package/dist/next/data/internal.d.ts.map +1 -0
  108. package/dist/next/data/internal.js +8 -0
  109. package/dist/next/data/internal.js.map +1 -0
  110. package/dist/next/data/params.d.ts +20 -0
  111. package/dist/next/data/params.d.ts.map +1 -0
  112. package/dist/next/data/params.js +31 -0
  113. package/dist/next/data/params.js.map +1 -0
  114. package/dist/next/data/principal.d.ts +17 -0
  115. package/dist/next/data/principal.d.ts.map +1 -0
  116. package/dist/next/data/principal.js +41 -0
  117. package/dist/next/data/principal.js.map +1 -0
  118. package/dist/next/data/validator.d.ts +12 -0
  119. package/dist/next/data/validator.d.ts.map +1 -0
  120. package/dist/next/data/validator.js +34 -0
  121. package/dist/next/data/validator.js.map +1 -0
  122. package/dist/next/documents/address-source.d.ts +20 -0
  123. package/dist/next/documents/address-source.d.ts.map +1 -0
  124. package/dist/next/documents/address-source.js +44 -0
  125. package/dist/next/documents/address-source.js.map +1 -0
  126. package/dist/next/documents/definition.d.ts +84 -0
  127. package/dist/next/documents/definition.d.ts.map +1 -0
  128. package/dist/next/documents/definition.js +73 -0
  129. package/dist/next/documents/definition.js.map +1 -0
  130. package/dist/next/documents/documents.d.ts +106 -0
  131. package/dist/next/documents/documents.d.ts.map +1 -0
  132. package/dist/next/documents/documents.js +224 -0
  133. package/dist/next/documents/documents.js.map +1 -0
  134. package/dist/next/documents/fence.d.ts +9 -0
  135. package/dist/next/documents/fence.d.ts.map +1 -0
  136. package/dist/next/documents/fence.js +15 -0
  137. package/dist/next/documents/fence.js.map +1 -0
  138. package/dist/next/documents/handles.d.ts +76 -0
  139. package/dist/next/documents/handles.d.ts.map +1 -0
  140. package/dist/next/documents/handles.js +66 -0
  141. package/dist/next/documents/handles.js.map +1 -0
  142. package/dist/next/documents/index.d.ts +4 -0
  143. package/dist/next/documents/index.d.ts.map +1 -0
  144. package/dist/next/documents/index.js +3 -0
  145. package/dist/next/documents/index.js.map +1 -0
  146. package/dist/next/documents/internal.d.ts +9 -0
  147. package/dist/next/documents/internal.d.ts.map +1 -0
  148. package/dist/next/documents/internal.js +9 -0
  149. package/dist/next/documents/internal.js.map +1 -0
  150. package/dist/next/documents/keyed-slot.d.ts +103 -0
  151. package/dist/next/documents/keyed-slot.d.ts.map +1 -0
  152. package/dist/next/documents/keyed-slot.js +395 -0
  153. package/dist/next/documents/keyed-slot.js.map +1 -0
  154. package/dist/next/documents/line.d.ts +7 -0
  155. package/dist/next/documents/line.d.ts.map +1 -0
  156. package/dist/next/documents/line.js +14 -0
  157. package/dist/next/documents/line.js.map +1 -0
  158. package/dist/next/documents/persistence.d.ts +104 -0
  159. package/dist/next/documents/persistence.d.ts.map +1 -0
  160. package/dist/next/documents/persistence.js +128 -0
  161. package/dist/next/documents/persistence.js.map +1 -0
  162. package/dist/next/documents/residency.d.ts +31 -0
  163. package/dist/next/documents/residency.d.ts.map +1 -0
  164. package/dist/next/documents/residency.js +93 -0
  165. package/dist/next/documents/residency.js.map +1 -0
  166. package/dist/next/documents/slot.d.ts +109 -0
  167. package/dist/next/documents/slot.d.ts.map +1 -0
  168. package/dist/next/documents/slot.js +181 -0
  169. package/dist/next/documents/slot.js.map +1 -0
  170. package/dist/next/documents/transaction.d.ts +133 -0
  171. package/dist/next/documents/transaction.d.ts.map +1 -0
  172. package/dist/next/documents/transaction.js +409 -0
  173. package/dist/next/documents/transaction.js.map +1 -0
  174. package/dist/next/host/activity.d.ts +31 -0
  175. package/dist/next/host/activity.d.ts.map +1 -0
  176. package/dist/next/host/activity.js +40 -0
  177. package/dist/next/host/activity.js.map +1 -0
  178. package/dist/next/host/adapted.d.ts +49 -0
  179. package/dist/next/host/adapted.d.ts.map +1 -0
  180. package/dist/next/host/adapted.js +214 -0
  181. package/dist/next/host/adapted.js.map +1 -0
  182. package/dist/next/host/attempt.d.ts +278 -0
  183. package/dist/next/host/attempt.d.ts.map +1 -0
  184. package/dist/next/host/attempt.js +1072 -0
  185. package/dist/next/host/attempt.js.map +1 -0
  186. package/dist/next/host/backoff.d.ts +29 -0
  187. package/dist/next/host/backoff.d.ts.map +1 -0
  188. package/dist/next/host/backoff.js +69 -0
  189. package/dist/next/host/backoff.js.map +1 -0
  190. package/dist/next/host/ctx.d.ts +47 -0
  191. package/dist/next/host/ctx.d.ts.map +1 -0
  192. package/dist/next/host/ctx.js +108 -0
  193. package/dist/next/host/ctx.js.map +1 -0
  194. package/dist/next/host/deadline.d.ts +12 -0
  195. package/dist/next/host/deadline.d.ts.map +1 -0
  196. package/dist/next/host/deadline.js +40 -0
  197. package/dist/next/host/deadline.js.map +1 -0
  198. package/dist/next/host/dependencies.d.ts +65 -0
  199. package/dist/next/host/dependencies.d.ts.map +1 -0
  200. package/dist/next/host/dependencies.js +115 -0
  201. package/dist/next/host/dependencies.js.map +1 -0
  202. package/dist/next/host/destination.d.ts +48 -0
  203. package/dist/next/host/destination.d.ts.map +1 -0
  204. package/dist/next/host/destination.js +101 -0
  205. package/dist/next/host/destination.js.map +1 -0
  206. package/dist/next/host/facet.d.ts +79 -0
  207. package/dist/next/host/facet.d.ts.map +1 -0
  208. package/dist/next/host/facet.js +55 -0
  209. package/dist/next/host/facet.js.map +1 -0
  210. package/dist/next/host/follow.d.ts +52 -0
  211. package/dist/next/host/follow.d.ts.map +1 -0
  212. package/dist/next/host/follow.js +207 -0
  213. package/dist/next/host/follow.js.map +1 -0
  214. package/dist/next/host/host.d.ts +495 -0
  215. package/dist/next/host/host.d.ts.map +1 -0
  216. package/dist/next/host/host.js +1075 -0
  217. package/dist/next/host/host.js.map +1 -0
  218. package/dist/next/host/index.d.ts +17 -0
  219. package/dist/next/host/index.d.ts.map +1 -0
  220. package/dist/next/host/index.js +6 -0
  221. package/dist/next/host/index.js.map +1 -0
  222. package/dist/next/host/internal.d.ts +10 -0
  223. package/dist/next/host/internal.d.ts.map +1 -0
  224. package/dist/next/host/internal.js +8 -0
  225. package/dist/next/host/internal.js.map +1 -0
  226. package/dist/next/host/members.d.ts +50 -0
  227. package/dist/next/host/members.d.ts.map +1 -0
  228. package/dist/next/host/members.js +107 -0
  229. package/dist/next/host/members.js.map +1 -0
  230. package/dist/next/host/native.d.ts +55 -0
  231. package/dist/next/host/native.d.ts.map +1 -0
  232. package/dist/next/host/native.js +92 -0
  233. package/dist/next/host/native.js.map +1 -0
  234. package/dist/next/host/object.d.ts +290 -0
  235. package/dist/next/host/object.d.ts.map +1 -0
  236. package/dist/next/host/object.js +1127 -0
  237. package/dist/next/host/object.js.map +1 -0
  238. package/dist/next/host/parked.d.ts +23 -0
  239. package/dist/next/host/parked.d.ts.map +1 -0
  240. package/dist/next/host/parked.js +79 -0
  241. package/dist/next/host/parked.js.map +1 -0
  242. package/dist/next/host/presence.d.ts +34 -0
  243. package/dist/next/host/presence.d.ts.map +1 -0
  244. package/dist/next/host/presence.js +117 -0
  245. package/dist/next/host/presence.js.map +1 -0
  246. package/dist/next/host/ref-state.d.ts +53 -0
  247. package/dist/next/host/ref-state.d.ts.map +1 -0
  248. package/dist/next/host/ref-state.js +83 -0
  249. package/dist/next/host/ref-state.js.map +1 -0
  250. package/dist/next/host/reference-keys.d.ts +36 -0
  251. package/dist/next/host/reference-keys.d.ts.map +1 -0
  252. package/dist/next/host/reference-keys.js +168 -0
  253. package/dist/next/host/reference-keys.js.map +1 -0
  254. package/dist/next/host/reference-source.d.ts +65 -0
  255. package/dist/next/host/reference-source.d.ts.map +1 -0
  256. package/dist/next/host/reference-source.js +285 -0
  257. package/dist/next/host/reference-source.js.map +1 -0
  258. package/dist/next/host/reference.d.ts +308 -0
  259. package/dist/next/host/reference.d.ts.map +1 -0
  260. package/dist/next/host/reference.js +775 -0
  261. package/dist/next/host/reference.js.map +1 -0
  262. package/dist/next/host/retry-on.d.ts +28 -0
  263. package/dist/next/host/retry-on.d.ts.map +1 -0
  264. package/dist/next/host/retry-on.js +52 -0
  265. package/dist/next/host/retry-on.js.map +1 -0
  266. package/dist/next/host/revocation.d.ts +16 -0
  267. package/dist/next/host/revocation.d.ts.map +1 -0
  268. package/dist/next/host/revocation.js +27 -0
  269. package/dist/next/host/revocation.js.map +1 -0
  270. package/dist/next/host/root.d.ts +27 -0
  271. package/dist/next/host/root.d.ts.map +1 -0
  272. package/dist/next/host/root.js +68 -0
  273. package/dist/next/host/root.js.map +1 -0
  274. package/dist/next/host/route.d.ts +64 -0
  275. package/dist/next/host/route.d.ts.map +1 -0
  276. package/dist/next/host/route.js +190 -0
  277. package/dist/next/host/route.js.map +1 -0
  278. package/dist/next/host/routines.d.ts +76 -0
  279. package/dist/next/host/routines.d.ts.map +1 -0
  280. package/dist/next/host/routines.js +350 -0
  281. package/dist/next/host/routines.js.map +1 -0
  282. package/dist/next/host/sleep.d.ts +9 -0
  283. package/dist/next/host/sleep.d.ts.map +1 -0
  284. package/dist/next/host/sleep.js +40 -0
  285. package/dist/next/host/sleep.js.map +1 -0
  286. package/dist/next/host/staging.d.ts +94 -0
  287. package/dist/next/host/staging.d.ts.map +1 -0
  288. package/dist/next/host/staging.js +302 -0
  289. package/dist/next/host/staging.js.map +1 -0
  290. package/dist/next/host/unbound.d.ts +30 -0
  291. package/dist/next/host/unbound.d.ts.map +1 -0
  292. package/dist/next/host/unbound.js +67 -0
  293. package/dist/next/host/unbound.js.map +1 -0
  294. package/dist/next/host/uuid.d.ts +3 -0
  295. package/dist/next/host/uuid.d.ts.map +1 -0
  296. package/dist/next/host/uuid.js +38 -0
  297. package/dist/next/host/uuid.js.map +1 -0
  298. package/dist/next/index.d.ts +28 -0
  299. package/dist/next/index.d.ts.map +1 -0
  300. package/dist/next/index.js +18 -0
  301. package/dist/next/index.js.map +1 -0
  302. package/dist/next/jobs/definition.d.ts +96 -0
  303. package/dist/next/jobs/definition.d.ts.map +1 -0
  304. package/dist/next/jobs/definition.js +83 -0
  305. package/dist/next/jobs/definition.js.map +1 -0
  306. package/dist/next/jobs/index.d.ts +5 -0
  307. package/dist/next/jobs/index.d.ts.map +1 -0
  308. package/dist/next/jobs/index.js +3 -0
  309. package/dist/next/jobs/index.js.map +1 -0
  310. package/dist/next/jobs/internal.d.ts +3 -0
  311. package/dist/next/jobs/internal.d.ts.map +1 -0
  312. package/dist/next/jobs/internal.js +4 -0
  313. package/dist/next/jobs/internal.js.map +1 -0
  314. package/dist/next/jobs/job.d.ts +152 -0
  315. package/dist/next/jobs/job.d.ts.map +1 -0
  316. package/dist/next/jobs/job.js +320 -0
  317. package/dist/next/jobs/job.js.map +1 -0
  318. package/dist/next/jobs/persisted.d.ts +38 -0
  319. package/dist/next/jobs/persisted.d.ts.map +1 -0
  320. package/dist/next/jobs/persisted.js +95 -0
  321. package/dist/next/jobs/persisted.js.map +1 -0
  322. package/dist/next/jobs/records.d.ts +231 -0
  323. package/dist/next/jobs/records.d.ts.map +1 -0
  324. package/dist/next/jobs/records.js +869 -0
  325. package/dist/next/jobs/records.js.map +1 -0
  326. package/dist/next/jobs/run-states.d.ts +69 -0
  327. package/dist/next/jobs/run-states.d.ts.map +1 -0
  328. package/dist/next/jobs/run-states.js +228 -0
  329. package/dist/next/jobs/run-states.js.map +1 -0
  330. package/dist/next/jobs/run.d.ts +113 -0
  331. package/dist/next/jobs/run.d.ts.map +1 -0
  332. package/dist/next/jobs/run.js +200 -0
  333. package/dist/next/jobs/run.js.map +1 -0
  334. package/dist/next/jobs/running.d.ts +44 -0
  335. package/dist/next/jobs/running.d.ts.map +1 -0
  336. package/dist/next/jobs/running.js +117 -0
  337. package/dist/next/jobs/running.js.map +1 -0
  338. package/dist/next/jobs/stored.d.ts +63 -0
  339. package/dist/next/jobs/stored.d.ts.map +1 -0
  340. package/dist/next/jobs/stored.js +55 -0
  341. package/dist/next/jobs/stored.js.map +1 -0
  342. package/dist/next/link/binary.d.ts +4 -0
  343. package/dist/next/link/binary.d.ts.map +1 -0
  344. package/dist/next/link/binary.js +534 -0
  345. package/dist/next/link/binary.js.map +1 -0
  346. package/dist/next/link/channel.d.ts +63 -0
  347. package/dist/next/link/channel.d.ts.map +1 -0
  348. package/dist/next/link/channel.js +202 -0
  349. package/dist/next/link/channel.js.map +1 -0
  350. package/dist/next/link/errors.d.ts +7 -0
  351. package/dist/next/link/errors.d.ts.map +1 -0
  352. package/dist/next/link/errors.js +21 -0
  353. package/dist/next/link/errors.js.map +1 -0
  354. package/dist/next/link/index.d.ts +8 -0
  355. package/dist/next/link/index.d.ts.map +1 -0
  356. package/dist/next/link/index.js +8 -0
  357. package/dist/next/link/index.js.map +1 -0
  358. package/dist/next/link/internal.d.ts +9 -0
  359. package/dist/next/link/internal.d.ts.map +1 -0
  360. package/dist/next/link/internal.js +10 -0
  361. package/dist/next/link/internal.js.map +1 -0
  362. package/dist/next/link/ipc.d.ts +22 -0
  363. package/dist/next/link/ipc.d.ts.map +1 -0
  364. package/dist/next/link/ipc.js +64 -0
  365. package/dist/next/link/ipc.js.map +1 -0
  366. package/dist/next/link/link.d.ts +34 -0
  367. package/dist/next/link/link.d.ts.map +1 -0
  368. package/dist/next/link/link.js +87 -0
  369. package/dist/next/link/link.js.map +1 -0
  370. package/dist/next/link/message.d.ts +249 -0
  371. package/dist/next/link/message.d.ts.map +1 -0
  372. package/dist/next/link/message.js +123 -0
  373. package/dist/next/link/message.js.map +1 -0
  374. package/dist/next/link/part.d.ts +80 -0
  375. package/dist/next/link/part.d.ts.map +1 -0
  376. package/dist/next/link/part.js +164 -0
  377. package/dist/next/link/part.js.map +1 -0
  378. package/dist/next/link/text.d.ts +6 -0
  379. package/dist/next/link/text.d.ts.map +1 -0
  380. package/dist/next/link/text.js +335 -0
  381. package/dist/next/link/text.js.map +1 -0
  382. package/dist/next/link/values.d.ts +40 -0
  383. package/dist/next/link/values.d.ts.map +1 -0
  384. package/dist/next/link/values.js +117 -0
  385. package/dist/next/link/values.js.map +1 -0
  386. package/dist/next/link/websocket.d.ts +26 -0
  387. package/dist/next/link/websocket.d.ts.map +1 -0
  388. package/dist/next/link/websocket.js +91 -0
  389. package/dist/next/link/websocket.js.map +1 -0
  390. package/dist/next/registries/contribution.d.ts +50 -0
  391. package/dist/next/registries/contribution.d.ts.map +1 -0
  392. package/dist/next/registries/contribution.js +129 -0
  393. package/dist/next/registries/contribution.js.map +1 -0
  394. package/dist/next/registries/entries.d.ts +18 -0
  395. package/dist/next/registries/entries.d.ts.map +1 -0
  396. package/dist/next/registries/entries.js +42 -0
  397. package/dist/next/registries/entries.js.map +1 -0
  398. package/dist/next/registries/index.d.ts +3 -0
  399. package/dist/next/registries/index.d.ts.map +1 -0
  400. package/dist/next/registries/index.js +5 -0
  401. package/dist/next/registries/index.js.map +1 -0
  402. package/dist/next/registries/internal.d.ts +4 -0
  403. package/dist/next/registries/internal.d.ts.map +1 -0
  404. package/dist/next/registries/internal.js +5 -0
  405. package/dist/next/registries/internal.js.map +1 -0
  406. package/dist/next/registries/record.d.ts +94 -0
  407. package/dist/next/registries/record.d.ts.map +1 -0
  408. package/dist/next/registries/record.js +253 -0
  409. package/dist/next/registries/record.js.map +1 -0
  410. package/dist/next/registries/registry.d.ts +74 -0
  411. package/dist/next/registries/registry.d.ts.map +1 -0
  412. package/dist/next/registries/registry.js +14 -0
  413. package/dist/next/registries/registry.js.map +1 -0
  414. package/dist/next/registries/value.d.ts +48 -0
  415. package/dist/next/registries/value.d.ts.map +1 -0
  416. package/dist/next/registries/value.js +199 -0
  417. package/dist/next/registries/value.js.map +1 -0
  418. package/dist/next/remote/calls.d.ts +25 -0
  419. package/dist/next/remote/calls.d.ts.map +1 -0
  420. package/dist/next/remote/calls.js +62 -0
  421. package/dist/next/remote/calls.js.map +1 -0
  422. package/dist/next/remote/consumer.d.ts +42 -0
  423. package/dist/next/remote/consumer.d.ts.map +1 -0
  424. package/dist/next/remote/consumer.js +343 -0
  425. package/dist/next/remote/consumer.js.map +1 -0
  426. package/dist/next/remote/hold.d.ts +130 -0
  427. package/dist/next/remote/hold.d.ts.map +1 -0
  428. package/dist/next/remote/hold.js +537 -0
  429. package/dist/next/remote/hold.js.map +1 -0
  430. package/dist/next/remote/host-link.d.ts +77 -0
  431. package/dist/next/remote/host-link.d.ts.map +1 -0
  432. package/dist/next/remote/host-link.js +182 -0
  433. package/dist/next/remote/host-link.js.map +1 -0
  434. package/dist/next/remote/internal.d.ts +6 -0
  435. package/dist/next/remote/internal.d.ts.map +1 -0
  436. package/dist/next/remote/internal.js +6 -0
  437. package/dist/next/remote/internal.js.map +1 -0
  438. package/dist/next/remote/path.d.ts +46 -0
  439. package/dist/next/remote/path.d.ts.map +1 -0
  440. package/dist/next/remote/path.js +73 -0
  441. package/dist/next/remote/path.js.map +1 -0
  442. package/dist/next/remote/provider.d.ts +76 -0
  443. package/dist/next/remote/provider.d.ts.map +1 -0
  444. package/dist/next/remote/provider.js +506 -0
  445. package/dist/next/remote/provider.js.map +1 -0
  446. package/dist/next/remote/relay.d.ts +58 -0
  447. package/dist/next/remote/relay.d.ts.map +1 -0
  448. package/dist/next/remote/relay.js +117 -0
  449. package/dist/next/remote/relay.js.map +1 -0
  450. package/dist/next/remote/remote-object.d.ts +133 -0
  451. package/dist/next/remote/remote-object.d.ts.map +1 -0
  452. package/dist/next/remote/remote-object.js +411 -0
  453. package/dist/next/remote/remote-object.js.map +1 -0
  454. package/dist/next/remote/replica.d.ts +59 -0
  455. package/dist/next/remote/replica.d.ts.map +1 -0
  456. package/dist/next/remote/replica.js +125 -0
  457. package/dist/next/remote/replica.js.map +1 -0
  458. package/dist/next/state/batch.d.ts +64 -0
  459. package/dist/next/state/batch.d.ts.map +1 -0
  460. package/dist/next/state/batch.js +163 -0
  461. package/dist/next/state/batch.js.map +1 -0
  462. package/dist/next/state/derive.d.ts +52 -0
  463. package/dist/next/state/derive.d.ts.map +1 -0
  464. package/dist/next/state/derive.js +182 -0
  465. package/dist/next/state/derive.js.map +1 -0
  466. package/dist/next/state/index.d.ts +6 -0
  467. package/dist/next/state/index.d.ts.map +1 -0
  468. package/dist/next/state/index.js +4 -0
  469. package/dist/next/state/index.js.map +1 -0
  470. package/dist/next/state/internal.d.ts +6 -0
  471. package/dist/next/state/internal.d.ts.map +1 -0
  472. package/dist/next/state/internal.js +8 -0
  473. package/dist/next/state/internal.js.map +1 -0
  474. package/dist/next/state/native-source.d.ts +106 -0
  475. package/dist/next/state/native-source.d.ts.map +1 -0
  476. package/dist/next/state/native-source.js +240 -0
  477. package/dist/next/state/native-source.js.map +1 -0
  478. package/dist/next/state/watchable.d.ts +114 -0
  479. package/dist/next/state/watchable.d.ts.map +1 -0
  480. package/dist/next/state/watchable.js +156 -0
  481. package/dist/next/state/watchable.js.map +1 -0
  482. package/dist/next/state/writable.d.ts +32 -0
  483. package/dist/next/state/writable.d.ts.map +1 -0
  484. package/dist/next/state/writable.js +49 -0
  485. package/dist/next/state/writable.js.map +1 -0
  486. package/dist/next/store/adapter.d.ts +67 -0
  487. package/dist/next/store/adapter.d.ts.map +1 -0
  488. package/dist/next/store/adapter.js +118 -0
  489. package/dist/next/store/adapter.js.map +1 -0
  490. package/dist/next/store/allocator.d.ts +17 -0
  491. package/dist/next/store/allocator.d.ts.map +1 -0
  492. package/dist/next/store/allocator.js +30 -0
  493. package/dist/next/store/allocator.js.map +1 -0
  494. package/dist/next/store/applier.d.ts +8 -0
  495. package/dist/next/store/applier.d.ts.map +1 -0
  496. package/dist/next/store/applier.js +375 -0
  497. package/dist/next/store/applier.js.map +1 -0
  498. package/dist/next/store/apply-batch.d.ts +12 -0
  499. package/dist/next/store/apply-batch.d.ts.map +1 -0
  500. package/dist/next/store/apply-batch.js +83 -0
  501. package/dist/next/store/apply-batch.js.map +1 -0
  502. package/dist/next/store/archive.d.ts +32 -0
  503. package/dist/next/store/archive.d.ts.map +1 -0
  504. package/dist/next/store/archive.js +129 -0
  505. package/dist/next/store/archive.js.map +1 -0
  506. package/dist/next/store/backend.d.ts +10 -0
  507. package/dist/next/store/backend.d.ts.map +1 -0
  508. package/dist/next/store/backend.js +15 -0
  509. package/dist/next/store/backend.js.map +1 -0
  510. package/dist/next/store/catalog.d.ts +24 -0
  511. package/dist/next/store/catalog.d.ts.map +1 -0
  512. package/dist/next/store/catalog.js +17 -0
  513. package/dist/next/store/catalog.js.map +1 -0
  514. package/dist/next/store/claims.d.ts +23 -0
  515. package/dist/next/store/claims.d.ts.map +1 -0
  516. package/dist/next/store/claims.js +65 -0
  517. package/dist/next/store/claims.js.map +1 -0
  518. package/dist/next/store/columns.d.ts +77 -0
  519. package/dist/next/store/columns.d.ts.map +1 -0
  520. package/dist/next/store/columns.js +77 -0
  521. package/dist/next/store/columns.js.map +1 -0
  522. package/dist/next/store/engine.d.ts +176 -0
  523. package/dist/next/store/engine.d.ts.map +1 -0
  524. package/dist/next/store/engine.js +283 -0
  525. package/dist/next/store/engine.js.map +1 -0
  526. package/dist/next/store/evaluate.d.ts +17 -0
  527. package/dist/next/store/evaluate.d.ts.map +1 -0
  528. package/dist/next/store/evaluate.js +128 -0
  529. package/dist/next/store/evaluate.js.map +1 -0
  530. package/dist/next/store/export.d.ts +17 -0
  531. package/dist/next/store/export.d.ts.map +1 -0
  532. package/dist/next/store/export.js +200 -0
  533. package/dist/next/store/export.js.map +1 -0
  534. package/dist/next/store/expression.d.ts +150 -0
  535. package/dist/next/store/expression.d.ts.map +1 -0
  536. package/dist/next/store/expression.js +268 -0
  537. package/dist/next/store/expression.js.map +1 -0
  538. package/dist/next/store/import.d.ts +10 -0
  539. package/dist/next/store/import.d.ts.map +1 -0
  540. package/dist/next/store/import.js +276 -0
  541. package/dist/next/store/import.js.map +1 -0
  542. package/dist/next/store/index.d.ts +16 -0
  543. package/dist/next/store/index.d.ts.map +1 -0
  544. package/dist/next/store/index.js +13 -0
  545. package/dist/next/store/index.js.map +1 -0
  546. package/dist/next/store/json-column.d.ts +33 -0
  547. package/dist/next/store/json-column.d.ts.map +1 -0
  548. package/dist/next/store/json-column.js +61 -0
  549. package/dist/next/store/json-column.js.map +1 -0
  550. package/dist/next/store/jsonl.d.ts +9 -0
  551. package/dist/next/store/jsonl.d.ts.map +1 -0
  552. package/dist/next/store/jsonl.js +61 -0
  553. package/dist/next/store/jsonl.js.map +1 -0
  554. package/dist/next/store/outbox.d.ts +26 -0
  555. package/dist/next/store/outbox.d.ts.map +1 -0
  556. package/dist/next/store/outbox.js +80 -0
  557. package/dist/next/store/outbox.js.map +1 -0
  558. package/dist/next/store/query.d.ts +39 -0
  559. package/dist/next/store/query.d.ts.map +1 -0
  560. package/dist/next/store/query.js +97 -0
  561. package/dist/next/store/query.js.map +1 -0
  562. package/dist/next/store/refusal.d.ts +15 -0
  563. package/dist/next/store/refusal.d.ts.map +1 -0
  564. package/dist/next/store/refusal.js +36 -0
  565. package/dist/next/store/refusal.js.map +1 -0
  566. package/dist/next/store/rows.d.ts +80 -0
  567. package/dist/next/store/rows.d.ts.map +1 -0
  568. package/dist/next/store/rows.js +183 -0
  569. package/dist/next/store/rows.js.map +1 -0
  570. package/dist/next/store/schema.d.ts +25 -0
  571. package/dist/next/store/schema.d.ts.map +1 -0
  572. package/dist/next/store/schema.js +115 -0
  573. package/dist/next/store/schema.js.map +1 -0
  574. package/dist/next/store/sql.d.ts +73 -0
  575. package/dist/next/store/sql.d.ts.map +1 -0
  576. package/dist/next/store/sql.js +234 -0
  577. package/dist/next/store/sql.js.map +1 -0
  578. package/dist/next/store/step.d.ts +48 -0
  579. package/dist/next/store/step.d.ts.map +1 -0
  580. package/dist/next/store/step.js +50 -0
  581. package/dist/next/store/step.js.map +1 -0
  582. package/dist/next/store/store.d.ts +161 -0
  583. package/dist/next/store/store.d.ts.map +1 -0
  584. package/dist/next/store/store.js +627 -0
  585. package/dist/next/store/store.js.map +1 -0
  586. package/dist/next/store/table-changes.d.ts +29 -0
  587. package/dist/next/store/table-changes.d.ts.map +1 -0
  588. package/dist/next/store/table-changes.js +102 -0
  589. package/dist/next/store/table-changes.js.map +1 -0
  590. package/dist/next/store/table-evolve.d.ts +74 -0
  591. package/dist/next/store/table-evolve.d.ts.map +1 -0
  592. package/dist/next/store/table-evolve.js +201 -0
  593. package/dist/next/store/table-evolve.js.map +1 -0
  594. package/dist/next/store/table-handle.d.ts +67 -0
  595. package/dist/next/store/table-handle.d.ts.map +1 -0
  596. package/dist/next/store/table-handle.js +101 -0
  597. package/dist/next/store/table-handle.js.map +1 -0
  598. package/dist/next/store/table-history.d.ts +75 -0
  599. package/dist/next/store/table-history.d.ts.map +1 -0
  600. package/dist/next/store/table-history.js +42 -0
  601. package/dist/next/store/table-history.js.map +1 -0
  602. package/dist/next/store/table-migration.d.ts +16 -0
  603. package/dist/next/store/table-migration.d.ts.map +1 -0
  604. package/dist/next/store/table-migration.js +202 -0
  605. package/dist/next/store/table-migration.js.map +1 -0
  606. package/dist/next/store/table-writes.d.ts +125 -0
  607. package/dist/next/store/table-writes.d.ts.map +1 -0
  608. package/dist/next/store/table-writes.js +165 -0
  609. package/dist/next/store/table-writes.js.map +1 -0
  610. package/dist/next/store/table.d.ts +80 -0
  611. package/dist/next/store/table.d.ts.map +1 -0
  612. package/dist/next/store/table.js +103 -0
  613. package/dist/next/store/table.js.map +1 -0
  614. package/dist/next/store/text.d.ts +14 -0
  615. package/dist/next/store/text.d.ts.map +1 -0
  616. package/dist/next/store/text.js +51 -0
  617. package/dist/next/store/text.js.map +1 -0
  618. package/dist/next/store/writes.d.ts +5 -0
  619. package/dist/next/store/writes.d.ts.map +1 -0
  620. package/dist/next/store/writes.js +4 -0
  621. package/dist/next/store/writes.js.map +1 -0
  622. package/dist/next-node/compression.d.ts +7 -0
  623. package/dist/next-node/compression.d.ts.map +1 -0
  624. package/dist/next-node/compression.js +24 -0
  625. package/dist/next-node/compression.js.map +1 -0
  626. package/dist/next-node/http/admission.d.ts +63 -0
  627. package/dist/next-node/http/admission.d.ts.map +1 -0
  628. package/dist/next-node/http/admission.js +134 -0
  629. package/dist/next-node/http/admission.js.map +1 -0
  630. package/dist/next-node/http/authenticate.d.ts +21 -0
  631. package/dist/next-node/http/authenticate.d.ts.map +1 -0
  632. package/dist/next-node/http/authenticate.js +34 -0
  633. package/dist/next-node/http/authenticate.js.map +1 -0
  634. package/dist/next-node/http/cookies.d.ts +24 -0
  635. package/dist/next-node/http/cookies.d.ts.map +1 -0
  636. package/dist/next-node/http/cookies.js +62 -0
  637. package/dist/next-node/http/cookies.js.map +1 -0
  638. package/dist/next-node/http/file.d.ts +23 -0
  639. package/dist/next-node/http/file.d.ts.map +1 -0
  640. package/dist/next-node/http/file.js +94 -0
  641. package/dist/next-node/http/file.js.map +1 -0
  642. package/dist/next-node/http/headers.d.ts +37 -0
  643. package/dist/next-node/http/headers.d.ts.map +1 -0
  644. package/dist/next-node/http/headers.js +129 -0
  645. package/dist/next-node/http/headers.js.map +1 -0
  646. package/dist/next-node/http/http.d.ts +100 -0
  647. package/dist/next-node/http/http.d.ts.map +1 -0
  648. package/dist/next-node/http/http.js +462 -0
  649. package/dist/next-node/http/http.js.map +1 -0
  650. package/dist/next-node/http/incoming.d.ts +19 -0
  651. package/dist/next-node/http/incoming.d.ts.map +1 -0
  652. package/dist/next-node/http/incoming.js +31 -0
  653. package/dist/next-node/http/incoming.js.map +1 -0
  654. package/dist/next-node/http/index.d.ts +11 -0
  655. package/dist/next-node/http/index.d.ts.map +1 -0
  656. package/dist/next-node/http/index.js +12 -0
  657. package/dist/next-node/http/index.js.map +1 -0
  658. package/dist/next-node/http/node.d.ts +78 -0
  659. package/dist/next-node/http/node.d.ts.map +1 -0
  660. package/dist/next-node/http/node.js +291 -0
  661. package/dist/next-node/http/node.js.map +1 -0
  662. package/dist/next-node/http/request.d.ts +54 -0
  663. package/dist/next-node/http/request.d.ts.map +1 -0
  664. package/dist/next-node/http/request.js +116 -0
  665. package/dist/next-node/http/request.js.map +1 -0
  666. package/dist/next-node/http/response.d.ts +63 -0
  667. package/dist/next-node/http/response.d.ts.map +1 -0
  668. package/dist/next-node/http/response.js +202 -0
  669. package/dist/next-node/http/response.js.map +1 -0
  670. package/dist/next-node/http/router.d.ts +114 -0
  671. package/dist/next-node/http/router.d.ts.map +1 -0
  672. package/dist/next-node/http/router.js +261 -0
  673. package/dist/next-node/http/router.js.map +1 -0
  674. package/dist/next-node/http/upgrades.d.ts +58 -0
  675. package/dist/next-node/http/upgrades.d.ts.map +1 -0
  676. package/dist/next-node/http/upgrades.js +184 -0
  677. package/dist/next-node/http/upgrades.js.map +1 -0
  678. package/dist/next-node/plugins/build.d.ts +57 -0
  679. package/dist/next-node/plugins/build.d.ts.map +1 -0
  680. package/dist/next-node/plugins/build.js +334 -0
  681. package/dist/next-node/plugins/build.js.map +1 -0
  682. package/dist/next-node/plugins/discover.d.ts +36 -0
  683. package/dist/next-node/plugins/discover.d.ts.map +1 -0
  684. package/dist/next-node/plugins/discover.js +91 -0
  685. package/dist/next-node/plugins/discover.js.map +1 -0
  686. package/dist/next-node/plugins/evaluate.d.ts +33 -0
  687. package/dist/next-node/plugins/evaluate.d.ts.map +1 -0
  688. package/dist/next-node/plugins/evaluate.js +98 -0
  689. package/dist/next-node/plugins/evaluate.js.map +1 -0
  690. package/dist/next-node/plugins/index.d.ts +9 -0
  691. package/dist/next-node/plugins/index.d.ts.map +1 -0
  692. package/dist/next-node/plugins/index.js +11 -0
  693. package/dist/next-node/plugins/index.js.map +1 -0
  694. package/dist/next-node/plugins/install.d.ts +13 -0
  695. package/dist/next-node/plugins/install.d.ts.map +1 -0
  696. package/dist/next-node/plugins/install.js +37 -0
  697. package/dist/next-node/plugins/install.js.map +1 -0
  698. package/dist/next-node/plugins/plugins.d.ts +135 -0
  699. package/dist/next-node/plugins/plugins.d.ts.map +1 -0
  700. package/dist/next-node/plugins/plugins.js +206 -0
  701. package/dist/next-node/plugins/plugins.js.map +1 -0
  702. package/dist/next-node/plugins/runtime.d.ts +41 -0
  703. package/dist/next-node/plugins/runtime.d.ts.map +1 -0
  704. package/dist/next-node/plugins/runtime.js +136 -0
  705. package/dist/next-node/plugins/runtime.js.map +1 -0
  706. package/dist/next-node/plugins/stack.d.ts +16 -0
  707. package/dist/next-node/plugins/stack.d.ts.map +1 -0
  708. package/dist/next-node/plugins/stack.js +61 -0
  709. package/dist/next-node/plugins/stack.js.map +1 -0
  710. package/dist/next-node/plugins/watcher.d.ts +58 -0
  711. package/dist/next-node/plugins/watcher.d.ts.map +1 -0
  712. package/dist/next-node/plugins/watcher.js +281 -0
  713. package/dist/next-node/plugins/watcher.js.map +1 -0
  714. package/dist/next-node/workers/control.d.ts +83 -0
  715. package/dist/next-node/workers/control.d.ts.map +1 -0
  716. package/dist/next-node/workers/control.js +77 -0
  717. package/dist/next-node/workers/control.js.map +1 -0
  718. package/dist/next-node/workers/index.d.ts +5 -0
  719. package/dist/next-node/workers/index.d.ts.map +1 -0
  720. package/dist/next-node/workers/index.js +7 -0
  721. package/dist/next-node/workers/index.js.map +1 -0
  722. package/dist/next-node/workers/lock.d.ts +21 -0
  723. package/dist/next-node/workers/lock.d.ts.map +1 -0
  724. package/dist/next-node/workers/lock.js +137 -0
  725. package/dist/next-node/workers/lock.js.map +1 -0
  726. package/dist/next-node/workers/main.d.ts +46 -0
  727. package/dist/next-node/workers/main.d.ts.map +1 -0
  728. package/dist/next-node/workers/main.js +230 -0
  729. package/dist/next-node/workers/main.js.map +1 -0
  730. package/dist/next-node/workers/process.d.ts +42 -0
  731. package/dist/next-node/workers/process.d.ts.map +1 -0
  732. package/dist/next-node/workers/process.js +125 -0
  733. package/dist/next-node/workers/process.js.map +1 -0
  734. package/dist/next-node/workers/workers.d.ts +80 -0
  735. package/dist/next-node/workers/workers.d.ts.map +1 -0
  736. package/dist/next-node/workers/workers.js +572 -0
  737. package/dist/next-node/workers/workers.js.map +1 -0
  738. package/dist/object.d.ts +4 -4
  739. package/dist/object.d.ts.map +1 -1
  740. package/dist/object.js +3 -4
  741. package/dist/object.js.map +1 -1
  742. package/dist/output.d.ts +1 -1
  743. package/dist/output.d.ts.map +1 -1
  744. package/dist/output.js +4 -2
  745. package/dist/output.js.map +1 -1
  746. package/dist/remote.d.ts.map +1 -1
  747. package/dist/remote.js +2 -2
  748. package/dist/remote.js.map +1 -1
  749. package/dist/schema.d.ts +8 -4
  750. package/dist/schema.d.ts.map +1 -1
  751. package/dist/schema.js +180 -5
  752. package/dist/schema.js.map +1 -1
  753. package/dist/sqlite/cloudflare.d.ts +2 -0
  754. package/dist/sqlite/cloudflare.d.ts.map +1 -1
  755. package/dist/sqlite/cloudflare.js +10 -0
  756. package/dist/sqlite/cloudflare.js.map +1 -1
  757. package/dist/sqlite/database.d.ts +5 -2
  758. package/dist/sqlite/database.d.ts.map +1 -1
  759. package/dist/sqlite/database.js.map +1 -1
  760. package/dist/sqlite/node.d.ts +4 -1
  761. package/dist/sqlite/node.d.ts.map +1 -1
  762. package/dist/sqlite/node.js +22 -5
  763. package/dist/sqlite/node.js.map +1 -1
  764. package/dist/watch.d.ts +194 -0
  765. package/dist/watch.d.ts.map +1 -0
  766. package/dist/watch.js +383 -0
  767. package/dist/watch.js.map +1 -0
  768. package/dist/wire.d.ts +174 -193
  769. package/dist/wire.d.ts.map +1 -1
  770. package/dist/wire.js +81 -80
  771. package/dist/wire.js.map +1 -1
  772. package/docs/guide.md +15 -15
  773. package/docs/next/benchmarks.md +959 -0
  774. package/docs/next/decisions.md +2957 -0
  775. package/docs/next/dependencies/book.md +1671 -0
  776. package/docs/next/dependencies/index.html +2641 -0
  777. package/docs/next/dependencies/model.md +330 -0
  778. package/docs/next/design.md +2554 -0
  779. package/docs/next/durable-observers/book.md +432 -0
  780. package/docs/next/durable-observers/index.html +517 -0
  781. package/docs/next/flow-control/book.md +333 -0
  782. package/docs/next/flow-control/fold/index.html +265 -0
  783. package/docs/next/flow-control/index.html +548 -0
  784. package/docs/next/flow-control/window/index.html +228 -0
  785. package/docs/next/guide-plugins-hosts/book.md +607 -0
  786. package/docs/next/guide-plugins-hosts/index.html +652 -0
  787. package/docs/next/http-workers/book.md +378 -0
  788. package/docs/next/http-workers/index.html +515 -0
  789. package/docs/next/layer-1.md +311 -0
  790. package/docs/next/layer-2.md +216 -0
  791. package/docs/next/plugin-model/book.md +186 -0
  792. package/docs/next/plugin-model/index.html +310 -0
  793. package/docs/next/plugin-primer/book.md +273 -0
  794. package/docs/next/plugin-primer/index.html +430 -0
  795. package/docs/next/slice-1.md +236 -0
  796. package/docs/next/slice-10.md +285 -0
  797. package/docs/next/slice-11.md +93 -0
  798. package/docs/next/slice-2.md +174 -0
  799. package/docs/next/slice-3a.md +296 -0
  800. package/docs/next/slice-3b.md +197 -0
  801. package/docs/next/slice-4.md +146 -0
  802. package/docs/next/slice-4a.md +418 -0
  803. package/docs/next/slice-4b.md +208 -0
  804. package/docs/next/slice-5.md +281 -0
  805. package/docs/next/slice-6a.md +676 -0
  806. package/docs/next/slice-6b.md +332 -0
  807. package/docs/next/slice-7a.md +130 -0
  808. package/docs/next/slice-7b/book.md +608 -0
  809. package/docs/next/slice-7b/index.html +842 -0
  810. package/docs/next/slice-7b.md +255 -0
  811. package/docs/next/slice-7c.md +165 -0
  812. package/docs/next/slice-8.md +194 -0
  813. package/docs/next/slices.md +230 -0
  814. package/docs/next/store/book.md +665 -0
  815. package/docs/next/store/index.html +861 -0
  816. package/docs/next/store/walkthrough.md +193 -0
  817. package/docs/spec.md +9 -9
  818. package/docs/tutorial.md +26 -25
  819. package/package.json +22 -6
  820. package/src/delta/README.md +69 -0
@@ -0,0 +1,71 @@
1
+ import type { Method, Schema } from "./schema.ts";
2
+ /** One variant's members at one version: state schemas and method signatures. */
3
+ export type VariantShape = {
4
+ readonly state: {
5
+ readonly [member: string]: Schema;
6
+ };
7
+ readonly methods: {
8
+ readonly [member: string]: Method;
9
+ };
10
+ /** A local contract's keyed state members (slice 6a §12). */
11
+ readonly keyed?: {
12
+ readonly [member: string]: Schema;
13
+ };
14
+ };
15
+ /** Variants by name. A local contract has the single variant `members`. */
16
+ export type Variants = {
17
+ readonly [variant: string]: VariantShape;
18
+ };
19
+ /**
20
+ * What one edit changed: one side of one member in one variant (a union of variants when it changed several); `keyed`
21
+ * for a local contract's keyed member (slice 7b).
22
+ */
23
+ export type Change = readonly [variant: string, member: string, side: "state" | "args" | "result" | "keyed"];
24
+ /** One version: its number as digits, its variants, and the changes that produced it (`never` for a base). */
25
+ type Step = {
26
+ readonly version: string;
27
+ readonly variants: Variants;
28
+ readonly changes: Change;
29
+ };
30
+ /** Every version from the base, oldest first. */
31
+ export type History = readonly Step[];
32
+ export type CurrentStep<H extends History> = H extends readonly [...Step[], infer Last extends Step] ? Last : never;
33
+ export type StepAt<H extends History, V extends string> = Extract<H[number], {
34
+ readonly version: V;
35
+ }>;
36
+ /** Versions before the current one. */
37
+ export type OlderVersions<H extends History> = H extends readonly [...infer Older extends Step[], Step] ? Older[number]["version"] : never;
38
+ /** Every change made after version `V`. */
39
+ export type ChangesAfter<H extends readonly Step[], V extends string> = H extends readonly [
40
+ infer First extends Step,
41
+ ...infer Rest extends Step[]
42
+ ] ? First["version"] extends V ? Rest[number]["changes"] : ChangesAfter<Rest, V> : never;
43
+ /** Names of the state members or methods in any variant. */
44
+ export type MemberNames<V extends Variants, Side extends keyof VariantShape> = {
45
+ [X in keyof V]: keyof V[X][Side];
46
+ }[keyof V] & string;
47
+ /** The variants that have method `M`. */
48
+ export type VariantsWith<V extends Variants, M> = {
49
+ [X in keyof V]: M extends keyof V[X]["methods"] ? X : never;
50
+ }[keyof V] & string;
51
+ /** Method `M` (one signature in every variant that has it). */
52
+ export type MethodAt<V extends Variants, M> = {
53
+ [X in keyof V]: M extends keyof V[X]["methods"] ? V[X]["methods"][M] : never;
54
+ }[keyof V];
55
+ /** `N + 1` on decimal digits, so versions beyond 9 and 99 stay literal. */
56
+ export type Increment<N extends string> = N extends `${infer Init}9` ? `${Init extends "" ? "1" : Increment<Init>}0` : {
57
+ [D in keyof NextDigit]: N extends `${infer Init}${D}` ? `${Init}${NextDigit[D]}` : never;
58
+ }[keyof NextDigit];
59
+ type NextDigit = {
60
+ "0": "1";
61
+ "1": "2";
62
+ "2": "3";
63
+ "3": "4";
64
+ "4": "5";
65
+ "5": "6";
66
+ "6": "7";
67
+ "7": "8";
68
+ "8": "9";
69
+ };
70
+ export {};
71
+ //# sourceMappingURL=history.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/history.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAElD,iFAAiF;AACjF,MAAM,MAAM,YAAY,GAAG;IAC1B,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACtD,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACxD,6DAA6D;IAC7D,QAAQ,CAAC,KAAK,CAAC,EAAE;QAAE,QAAQ,EAAE,MA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AC,GAAG,GAC7C;KAAG,CAAC,IAAI,MAAM,SAAS,GAAG,CAAC,SAAS,GAAG,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK;CAAE,CAAC,MAAM,SAAS,CAAC,CAAC;AAEjH,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ // The type-level history of a contract: every version's members and the changes that produced it.
2
+ export {};
3
+ //# sourceMappingURL=history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.js","sourceRoot":"","sources":["../../../src/next/contracts/history.ts"],"names":[],"mappings":"AAAA,kGAAkG","sourcesContent":["// The type-level history of a contract: every version's members and the changes that produced it.\n\nimport type { Method, Schema } from \"./schema.ts\";\n\n/** One variant's members at one version: state schemas and method signatures. */\nexport type VariantShape = {\n\treadonly state: { readonly [member: string]: Schema };\n\treadonly methods: { readonly [member: string]: Method };\n\t/** A local contract's keyed state members (slice 6a §12). */\n\treadonly keyed?: { readonly [member: string]: Schema };\n};\n\n/** Variants by name. A local contract has the single variant `members`. */\nexport type Variants = { readonly [variant: string]: VariantShape };\n\n/**\n * What one edit changed: one side of one member in one variant (a union of variants when it changed several); `keyed`\n * for a local contract's keyed member (slice 7b).\n */\nexport type Change = readonly [variant: string, member: string, side: \"state\" | \"args\" | \"result\" | \"keyed\"];\n\n/** One version: its number as digits, its variants, and the changes that produced it (`never` for a base). */\ntype Step = { readonly version: string; readonly variants: Variants; readonly changes: Change };\n\n/** Every version from the base, oldest first. */\nexport type History = readonly Step[];\n\nexport type CurrentStep<H extends History> = H extends readonly [...Step[], infer Last extends Step] ? Last : never;\n\nexport type StepAt<H extends History, V extends string> = Extract<H[number], { readonly version: V }>;\n\n/** Versions before the current one. */\nexport type OlderVersions<H extends History> = H extends readonly [...infer Older extends Step[], Step]\n\t? Older[number][\"version\"]\n\t: never;\n\n/** Every change made after version `V`. */\nexport type ChangesAfter<H extends readonly Step[], V extends string> = H extends readonly [\n\tinfer First extends Step,\n\t...infer Rest extends Step[],\n]\n\t? First[\"version\"] extends V\n\t\t? Rest[number][\"changes\"]\n\t\t: ChangesAfter<Rest, V>\n\t: never;\n\n/** Names of the state members or methods in any variant. */\nexport type MemberNames<V extends Variants, Side extends keyof VariantShape> = {\n\t[X in keyof V]: keyof V[X][Side];\n}[keyof V] &\n\tstring;\n\n/** The variants that have method `M`. */\nexport type VariantsWith<V extends Variants, M> = {\n\t[X in keyof V]: M extends keyof V[X][\"methods\"] ? X : never;\n}[keyof V] &\n\tstring;\n\n/** Method `M` (one signature in every variant that has it). */\nexport type MethodAt<V extends Variants, M> = {\n\t[X in keyof V]: M extends keyof V[X][\"methods\"] ? V[X][\"methods\"][M] : never;\n}[keyof V];\n\n/** `N + 1` on decimal digits, so versions beyond 9 and 99 stay literal. */\nexport type Increment<N extends string> = N extends `${infer Init}9`\n\t? `${Init extends \"\" ? \"1\" : Increment<Init>}0`\n\t: { [D in keyof NextDigit]: N extends `${infer Init}${D}` ? `${Init}${NextDigit[D]}` : never }[keyof NextDigit];\n\ntype NextDigit = { \"0\": \"1\"; \"1\": \"2\"; \"2\": \"3\"; \"3\": \"4\"; \"4\": \"5\"; \"5\": \"6\"; \"6\": \"7\"; \"7\": \"8\"; \"8\": \"9\" };\n"]}
@@ -0,0 +1,40 @@
1
+ import { type Params, type ParamsData, type RequiredFields } from "./params.ts";
2
+ import type { Static } from "./schema.ts";
3
+ /** What an address's type needs of its kind: the name and the params, type only. */
4
+ export type KindShape = {
5
+ readonly kind: string;
6
+ readonly "~params"?: Params;
7
+ };
8
+ /** One host of a kind: the kind's name, its params and its key (`session|S1`); two addresses are equal by key. */
9
+ export type Address<K extends KindShape = KindShape> = {
10
+ readonly kind: K["kind"];
11
+ readonly params: ParamsOfKind<K>;
12
+ readonly key: string;
13
+ };
14
+ /** A kind of addressable host: called with its params, it makes an address. */
15
+ export interface HostKind<N extends string = string, P extends Params = Params> {
16
+ (...params: keyof P extends never ? [params?: Record<never, never>] : [params: {
17
+ [F in keyof P]: Static<P[F]>;
18
+ }]): Address<HostKind<N, P>>;
19
+ readonly kind: N;
20
+ /** Type only: absent at runtime. */
21
+ readonly "~params"?: P;
22
+ }
23
+ /** The params object of a host kind. */
24
+ export type ParamsOfKind<K extends KindShape> = {
25
+ [F in keyof NonNullable<K["~params"]>]: Static<NonNullable<K["~params"]>[F]>;
26
+ };
27
+ /**
28
+ * Declares a host kind; `params` follow the params policy of contracts (a flat record of required `str()`, `int()`,
29
+ * `bool()` and `oneOf(...)`). Making an address computes its key only: its params are checked where it is routed.
30
+ */
31
+ export declare function hostKind<const N extends string, const P extends Params = Record<never, never>>(name: N, params?: P & NoInfer<RequiredFields<P>>): HostKind<N, P>;
32
+ /** The params of a declared host kind. */
33
+ export declare function kindParams(kind: {
34
+ readonly kind: string;
35
+ }): ParamsData;
36
+ /** An address's key: the kind's name and each field value in declared order, joined (`joinKey`). */
37
+ export declare function addressKey(kind: string, params: ParamsData, values: {
38
+ readonly [field: string]: unknown;
39
+ }): string;
40
+ //# sourceMappingURL=host-kind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-kind.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/host-kind.ts"],"names":[],"mappings":"AAIA,OAAO,EAAW,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAc,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,oFAAoF;AACp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AAE,KAAK,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC7F,IAAI,EAAE,CAAC,EACP,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,GACrC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAchB;AAID,0CAA0C;AAC1C,wBAAgB,UAAU,CAAC,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAItE;AAED,oGAAoG;AACpG,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE;IAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,MAAM,CAElH"}
@@ -0,0 +1,37 @@
1
+ // Host kinds and addresses (§3): a kind of addressable host with params like a contract's, and the address of one
2
+ // host of a kind, which a remote contract's `hostAddress` computes from its params.
3
+ import { checkName } from "./names.js";
4
+ import { joinKey, readParams } from "./params.js";
5
+ /**
6
+ * Declares a host kind; `params` follow the params policy of contracts (a flat record of required `str()`, `int()`,
7
+ * `bool()` and `oneOf(...)`). Making an address computes its key only: its params are checked where it is routed.
8
+ */
9
+ export function hostKind(name, params) {
10
+ checkName(name, "A host kind's name");
11
+ // `client` is the host kind of a host without an address in store names (owner strings, table names).
12
+ if (name === "client")
13
+ throw new Error('A host kind\'s name "client" is reserved for hosts without an address');
14
+ const data = readParams(Object.entries(params ?? {}), `${name}.params`);
15
+ const make = (values = {}) => ({
16
+ kind: name,
17
+ params: values,
18
+ key: addressKey(name, data, values),
19
+ });
20
+ Object.defineProperty(make, "kind", { value: name, enumerable: true });
21
+ kinds.set(make, data);
22
+ // The function and its `kind` are the declared shape; the params type is type-level only.
23
+ return make;
24
+ }
25
+ const kinds = new WeakMap();
26
+ /** The params of a declared host kind. */
27
+ export function kindParams(kind) {
28
+ const data = kinds.get(kind);
29
+ if (data === undefined)
30
+ throw new Error(`${kind.kind}: not a declared host kind`);
31
+ return data;
32
+ }
33
+ /** An address's key: the kind's name and each field value in declared order, joined (`joinKey`). */
34
+ export function addressKey(kind, params, values) {
35
+ return joinKey([kind, ...params.fields.map((field) => String(values[field]))]);
36
+ }
37
+ //# sourceMappingURL=host-kind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"host-kind.js","sourceRoot":"","sources":["../../../src/next/contracts/host-kind.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,oFAAoF;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAqD,UAAU,EAAE,MAAM,aAAa,CAAC;AA4BrG;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACvB,IAAO,EACP,MAAuC;IAEvC,SAAS,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;IACtC,sGAAsG;IACtG,IAAI,IAAI,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAChH,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,CAAC;IACxE,MAAM,IAAI,GAAG,CAAC,MAAM,GAA0C,EAAE,EAAE,EAAE,CAAC,CAAC;QACrE,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC;KACnC,CAAC,CAAC;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IACvE,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtB,0FAA0F;IAC1F,OAAO,IAAiC,CAAC;AAC1C,CAAC;AAED,MAAM,KAAK,GAAG,IAAI,OAAO,EAAsB,CAAC;AAEhD,0CAA0C;AAC1C,MAAM,UAAU,UAAU,CAAC,IAA+B;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7B,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,4BAA4B,CAAC,CAAC;IAClF,OAAO,IAAI,CAAC;AACb,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,MAAkB,EAAE,MAA6C;IACzG,OAAO,OAAO,CAAC,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChF,CAAC","sourcesContent":["// Host kinds and addresses (§3): a kind of addressable host with params like a contract's, and the address of one\n// host of a kind, which a remote contract's `hostAddress` computes from its params.\n\nimport { checkName } from \"./names.ts\";\nimport { joinKey, type Params, type ParamsData, type RequiredFields, readParams } from \"./params.ts\";\nimport type { Static } from \"./schema.ts\";\n\n/** What an address's type needs of its kind: the name and the params, type only. */\nexport type KindShape = { readonly kind: string; readonly \"~params\"?: Params };\n\n/** One host of a kind: the kind's name, its params and its key (`session|S1`); two addresses are equal by key. */\nexport type Address<K extends KindShape = KindShape> = {\n\treadonly kind: K[\"kind\"];\n\treadonly params: ParamsOfKind<K>;\n\treadonly key: string;\n};\n\n/** A kind of addressable host: called with its params, it makes an address. */\nexport interface HostKind<N extends string = string, P extends Params = Params> {\n\t(\n\t\t...params: keyof P extends never ? [params?: Record<never, never>] : [params: { [F in keyof P]: Static<P[F]> }]\n\t): Address<HostKind<N, P>>;\n\treadonly kind: N;\n\t/** Type only: absent at runtime. */\n\treadonly \"~params\"?: P;\n}\n\n/** The params object of a host kind. */\nexport type ParamsOfKind<K extends KindShape> = {\n\t[F in keyof NonNullable<K[\"~params\"]>]: Static<NonNullable<K[\"~params\"]>[F]>;\n};\n\n/**\n * Declares a host kind; `params` follow the params policy of contracts (a flat record of required `str()`, `int()`,\n * `bool()` and `oneOf(...)`). Making an address computes its key only: its params are checked where it is routed.\n */\nexport function hostKind<const N extends string, const P extends Params = Record<never, never>>(\n\tname: N,\n\tparams?: P & NoInfer<RequiredFields<P>>,\n): HostKind<N, P> {\n\tcheckName(name, \"A host kind's name\");\n\t// `client` is the host kind of a host without an address in store names (owner strings, table names).\n\tif (name === \"client\") throw new Error('A host kind\\'s name \"client\" is reserved for hosts without an address');\n\tconst data = readParams(Object.entries(params ?? {}), `${name}.params`);\n\tconst make = (values: { readonly [field: string]: unknown } = {}) => ({\n\t\tkind: name,\n\t\tparams: values,\n\t\tkey: addressKey(name, data, values),\n\t});\n\tObject.defineProperty(make, \"kind\", { value: name, enumerable: true });\n\tkinds.set(make, data);\n\t// The function and its `kind` are the declared shape; the params type is type-level only.\n\treturn make as unknown as HostKind<N, P>;\n}\n\nconst kinds = new WeakMap<object, ParamsData>();\n\n/** The params of a declared host kind. */\nexport function kindParams(kind: { readonly kind: string }): ParamsData {\n\tconst data = kinds.get(kind);\n\tif (data === undefined) throw new Error(`${kind.kind}: not a declared host kind`);\n\treturn data;\n}\n\n/** An address's key: the kind's name and each field value in declared order, joined (`joinKey`). */\nexport function addressKey(kind: string, params: ParamsData, values: { readonly [field: string]: unknown }): string {\n\treturn joinKey([kind, ...params.fields.map((field) => String(values[field]))]);\n}\n"]}
@@ -0,0 +1,7 @@
1
+ export type { AcceptsTable } from "./accepts.ts";
2
+ export type { Contract, Implementation, KeyedWatchable, ParamsOf } from "./contract.ts";
3
+ export { local, remote } from "./declare.ts";
4
+ export { evolve } from "./evolve.ts";
5
+ export { type Address, type HostKind, hostKind, type KindShape, type ParamsOfKind } from "./host-kind.ts";
6
+ export { arr, type BooleanSchema, type Bounds, bool, bytes, type Defaulted, type IntegerSchema, int, type KeyedMember, keyed, lit, map, method, type NullSchema, type NumberSchema, nul, num, type Optional, obj, oneOf, opt, type Schema, type Static, type StringSchema, str, union, unknown, } from "./schema.ts";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/index.ts"],"names":[],"mappings":"AAEA,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,QAAQ,EAAE,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EACN,GAAG,EACH,KAAK,aAAa,EAClB,KAAK,MAAM,EACX,IAAI,EACJ,KAAK,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,GAAG,EACH,KAAK,WAAW,EAChB,KAAK,EACL,GAAG,EACH,GAAG,EACH,MAAM,EACN,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,GAAG,EACH,GAAG,EACH,KAAK,QAAQ,EACb,GAAG,EACH,KAAK,EACL,GAAG,EACH,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,GAAG,EACH,KAAK,EACL,OAAO,GACP,MAAM,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ // Contracts for apps: declaring, evolving and implementing Chord object types.
2
+ export { local, remote } from "./declare.js";
3
+ export { evolve } from "./evolve.js";
4
+ export { hostKind } from "./host-kind.js";
5
+ export { arr, bool, bytes, int, keyed, lit, map, method, nul, num, obj, oneOf, opt, str, union, unknown, } from "./schema.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/next/contracts/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAI/E,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAA+B,QAAQ,EAAqC,MAAM,gBAAgB,CAAC;AAC1G,OAAO,EACN,GAAG,EAGH,IAAI,EACJ,KAAK,EAGL,GAAG,EAEH,KAAK,EACL,GAAG,EACH,GAAG,EACH,MAAM,EAGN,GAAG,EACH,GAAG,EAEH,GAAG,EACH,KAAK,EACL,GAAG,EAIH,GAAG,EACH,KAAK,EACL,OAAO,GACP,MAAM,aAAa,CAAC","sourcesContent":["// Contracts for apps: declaring, evolving and implementing Chord object types.\n\nexport type { AcceptsTable } from \"./accepts.ts\";\nexport type { Contract, Implementation, KeyedWatchable, ParamsOf } from \"./contract.ts\";\nexport { local, remote } from \"./declare.ts\";\nexport { evolve } from \"./evolve.ts\";\nexport { type Address, type HostKind, hostKind, type KindShape, type ParamsOfKind } from \"./host-kind.ts\";\nexport {\n\tarr,\n\ttype BooleanSchema,\n\ttype Bounds,\n\tbool,\n\tbytes,\n\ttype Defaulted,\n\ttype IntegerSchema,\n\tint,\n\ttype KeyedMember,\n\tkeyed,\n\tlit,\n\tmap,\n\tmethod,\n\ttype NullSchema,\n\ttype NumberSchema,\n\tnul,\n\tnum,\n\ttype Optional,\n\tobj,\n\toneOf,\n\topt,\n\ttype Schema,\n\ttype Static,\n\ttype StringSchema,\n\tstr,\n\tunion,\n\tunknown,\n} from \"./schema.ts\";\n"]}
@@ -0,0 +1,10 @@
1
+ export { checkAccepts } from "./accepts.ts";
2
+ export { type ContractShape, type CurrentVariants, contractData, currentVariants, LOCAL, type MethodData, type ShapeOf, takesNoArgs, type VariantData, type VariantImplementation, type VariantNames, variantNames, variantOrder, variantsAt, } from "./contract.ts";
3
+ export { editWith } from "./evolve.ts";
4
+ export { fingerprintOf, hash64, NORMAL_FORM_VERSION } from "./fingerprint.ts";
5
+ export type { Increment } from "./history.ts";
6
+ export { kindParams } from "./host-kind.ts";
7
+ export { checkName } from "./names.ts";
8
+ export type { Params, ParamsData } from "./params.ts";
9
+ export { Method } from "./schema.ts";
10
+ //# sourceMappingURL=internal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/internal.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,YAAY,EACZ,eAAe,EACf,KAAK,EACL,KAAK,UAAU,EACf,KAAK,OAAO,EACZ,WAAW,EACX,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,YAAY,EACZ,YAAY,EACZ,UAAU,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,YAAY,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,9 @@
1
+ // Contracts for Chord's layers: accepted versions, the data behind a contract handle, and the types L4 dispatches on.
2
+ export { checkAccepts } from "./accepts.js";
3
+ export { contractData, currentVariants, LOCAL, takesNoArgs, variantNames, variantOrder, variantsAt, } from "./contract.js";
4
+ export { editWith } from "./evolve.js";
5
+ export { fingerprintOf, hash64, NORMAL_FORM_VERSION } from "./fingerprint.js";
6
+ export { kindParams } from "./host-kind.js";
7
+ export { checkName } from "./names.js";
8
+ export { Method } from "./schema.js";
9
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/next/contracts/internal.ts"],"names":[],"mappings":"AAAA,sHAAsH;AAEtH,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAGN,YAAY,EACZ,eAAe,EACf,KAAK,EAGL,WAAW,EAIX,YAAY,EACZ,YAAY,EACZ,UAAU,GACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC","sourcesContent":["// Contracts for Chord's layers: accepted versions, the data behind a contract handle, and the types L4 dispatches on.\n\nexport { checkAccepts } from \"./accepts.ts\";\nexport {\n\ttype ContractShape,\n\ttype CurrentVariants,\n\tcontractData,\n\tcurrentVariants,\n\tLOCAL,\n\ttype MethodData,\n\ttype ShapeOf,\n\ttakesNoArgs,\n\ttype VariantData,\n\ttype VariantImplementation,\n\ttype VariantNames,\n\tvariantNames,\n\tvariantOrder,\n\tvariantsAt,\n} from \"./contract.ts\";\nexport { editWith } from \"./evolve.ts\";\nexport { fingerprintOf, hash64, NORMAL_FORM_VERSION } from \"./fingerprint.ts\";\nexport type { Increment } from \"./history.ts\";\nexport { kindParams } from \"./host-kind.ts\";\nexport { checkName } from \"./names.ts\";\nexport type { Params, ParamsData } from \"./params.ts\";\nexport { Method } from \"./schema.ts\";\n"]}
@@ -0,0 +1,3 @@
1
+ /** Throws unless `name` is a nonempty lowercase name of `[a-z0-9@/._~-]` (`what` names it in the error). */
2
+ export declare function checkName(name: string, what: string): void;
3
+ //# sourceMappingURL=names.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/names.ts"],"names":[],"mappings":"AAOA,4GAA4G;AAC5G,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAK1D"}
@@ -0,0 +1,13 @@
1
+ // Names that become SQL names or stored identities in the store (decision "Restricted names"): object types, host
2
+ // kinds, tables, state definitions and jobs use npm package-name characters, lowercase, so `<host kind>:<object
3
+ // type>:<table>` is injective and readable, and a document's or a job record's name is stored as declared.
4
+ /** Lowercase npm package-name characters: `:` cannot occur, so names joined with it stay apart. */
5
+ const NAME = /^[a-z0-9@/._~-]+$/;
6
+ /** Throws unless `name` is a nonempty lowercase name of `[a-z0-9@/._~-]` (`what` names it in the error). */
7
+ export function checkName(name, what) {
8
+ // Declaration policy: JavaScript callers reach this check.
9
+ if (typeof name !== "string" || !NAME.test(name)) {
10
+ throw new Error(`${what} ${JSON.stringify(name)}: expected lowercase [a-z0-9@/._~-]`);
11
+ }
12
+ }
13
+ //# sourceMappingURL=names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names.js","sourceRoot":"","sources":["../../../src/next/contracts/names.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,gHAAgH;AAChH,2GAA2G;AAE3G,mGAAmG;AACnG,MAAM,IAAI,GAAG,mBAAmB,CAAC;AAEjC,4GAA4G;AAC5G,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,IAAY;IACnD,2DAA2D;IAC3D,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAClD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;IACvF,CAAC;AACF,CAAC","sourcesContent":["// Names that become SQL names or stored identities in the store (decision \"Restricted names\"): object types, host\n// kinds, tables, state definitions and jobs use npm package-name characters, lowercase, so `<host kind>:<object\n// type>:<table>` is injective and readable, and a document's or a job record's name is stored as declared.\n\n/** Lowercase npm package-name characters: `:` cannot occur, so names joined with it stay apart. */\nconst NAME = /^[a-z0-9@/._~-]+$/;\n\n/** Throws unless `name` is a nonempty lowercase name of `[a-z0-9@/._~-]` (`what` names it in the error). */\nexport function checkName(name: string, what: string): void {\n\t// Declaration policy: JavaScript callers reach this check.\n\tif (typeof name !== \"string\" || !NAME.test(name)) {\n\t\tthrow new Error(`${what} ${JSON.stringify(name)}: expected lowercase [a-z0-9@/._~-]`);\n\t}\n}\n"]}
@@ -0,0 +1,28 @@
1
+ import type { JsonValue } from "../../json.ts";
2
+ import { type BooleanSchema, type IntegerSchema, type LiteralsSchema, type Optional, type Schema, type StringSchema } from "./schema.ts";
3
+ /** A params field: a string, an integer, a boolean or a union of string literals; constraints allowed, no default. */
4
+ type ParamSchema = (StringSchema | IntegerSchema | BooleanSchema | LiteralsSchema<string>) & {
5
+ readonly default?: never;
6
+ };
7
+ /** Params: a flat record of required fields, in identity order. */
8
+ export type Params = {
9
+ readonly [field: string]: ParamSchema;
10
+ };
11
+ /** Refuses optional params fields, which the field types alone admit. */
12
+ export type RequiredFields<P extends Params> = {
13
+ [F in keyof P]: P[F] extends Optional ? never : P[F];
14
+ };
15
+ export type ParamsData = {
16
+ /** Field names in identity order. */
17
+ readonly fields: readonly string[];
18
+ /** The closed object schema of all fields. */
19
+ readonly schema: Schema;
20
+ /** `[field, normal form]` pairs in identity order. */
21
+ readonly normal: JsonValue;
22
+ };
23
+ /** Reads declared params fields: each a required str(), int(), bool() or oneOf(...) of strings, constraints allowed. */
24
+ export declare function readParams(declared: readonly [string, unknown][], path: string): ParamsData;
25
+ /** Joins key parts with `|`, each escaped (`\\` and `|`), so two different part lists never join to one key. */
26
+ export declare function joinKey(parts: readonly string[]): string;
27
+ export {};
28
+ //# sourceMappingURL=params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/params.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,aAAa,EAElB,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,MAAM,aAAa,CAAC;AAGrB,sHAAsH;AACtH,KAAK,WAAW,GAAG,CAAC,YAAY,GAAG,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG;IAC5F,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;CACzB,CAAC;AAEF,mEAAmE;AACnE,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AAE/D,yEAAyE;AACzE,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,IAAI;KAC7C,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACxB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC3B,CAAC;AAEF,wHAAwH;AACxH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,CAoB3F;AAED,gHAAgH;AAChH,wBAAgB,OAAO,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAExD"}
@@ -0,0 +1,50 @@
1
+ // Params declarations: the policy for params fields and the closed object schema checked on every get.
2
+ import { isOptional, } from "./schema.js";
3
+ import { snapshotSchema } from "./snapshot.js";
4
+ /** Reads declared params fields: each a required str(), int(), bool() or oneOf(...) of strings, constraints allowed. */
5
+ export function readParams(declared, path) {
6
+ const fields = declared.map(([field, schema]) => {
7
+ const fieldPath = `${path}.${field}`;
8
+ const refused = new Error(`${fieldPath}: a param is a required str(), int(), bool() or oneOf(...) of strings`);
9
+ if (isOptional(schema))
10
+ throw refused;
11
+ const snapshot = snapshotSchema(schema, fieldPath);
12
+ if (!isParamSchema(snapshot.normal))
13
+ throw refused;
14
+ return [field, snapshot];
15
+ });
16
+ const schema = {
17
+ type: "object",
18
+ properties: Object.fromEntries(fields.map(([field, snapshot]) => [field, snapshot.schema])),
19
+ required: fields.map(([field]) => field),
20
+ additionalProperties: false,
21
+ };
22
+ return {
23
+ fields: fields.map(([field]) => field),
24
+ schema,
25
+ normal: fields.map(([field, snapshot]) => [field, snapshot.normal]),
26
+ };
27
+ }
28
+ /** Joins key parts with `|`, each escaped (`\\` and `|`), so two different part lists never join to one key. */
29
+ export function joinKey(parts) {
30
+ return parts.map((part) => part.replaceAll("\\", "\\\\").replaceAll("|", "\\|")).join("|");
31
+ }
32
+ function isParamSchema(normal) {
33
+ const node = normal;
34
+ if (node.anyOf !== undefined) {
35
+ return Object.keys(node).length === 1 && Array.isArray(node.anyOf) && node.anyOf.every(isStringLiteral);
36
+ }
37
+ const allowed = PARAM_KEYWORDS.get(node.type);
38
+ return allowed !== undefined && Object.keys(node).every((key) => allowed.has(key));
39
+ }
40
+ /** Keywords a params field may use, by type. */
41
+ const PARAM_KEYWORDS = new Map([
42
+ ["string", new Set(["type", "minLength", "maxLength", "pattern", "format"])],
43
+ ["integer", new Set(["type", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum", "multipleOf"])],
44
+ ["boolean", new Set(["type"])],
45
+ ]);
46
+ function isStringLiteral(branch) {
47
+ const node = branch;
48
+ return node.type === "string" && typeof node.const === "string" && Object.keys(node).length === 2;
49
+ }
50
+ //# sourceMappingURL=params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params.js","sourceRoot":"","sources":["../../../src/next/contracts/params.ts"],"names":[],"mappings":"AAAA,uGAAuG;AAGvG,OAAO,EAGN,UAAU,GAKV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAwB/C,wHAAwH;AACxH,MAAM,UAAU,UAAU,CAAC,QAAsC,EAAE,IAAY;IAC9E,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE;QAC/C,MAAM,SAAS,GAAG,GAAG,IAAI,IAAI,KAAK,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,KAAK,CAAC,GAAG,SAAS,uEAAuE,CAAC,CAAC;QAC/G,IAAI,UAAU,CAAC,MAAM,CAAC;YAAE,MAAM,OAAO,CAAC;QACtC,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACnD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,MAAM,OAAO,CAAC;QACnD,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAU,CAAC;IACnC,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG;QACd,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3F,QAAQ,EAAE,MAAM,CAAC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AAC;AAED,gDAAgD;AAChD,MAAM,cAAc,GAAG,IAAI,GAAG,CAA+B;IAC5D,CAAC,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5E,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,YAAY,CAAC,CAAC,CAAC;IAC1G,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;CAC9B,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,MAAiB;IACzC,MAAM,IAAI,GAAG,MAAoB,CAAC;IAClC,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACnG,CAAC","sourcesContent":["// Params declarations: the policy for params fields and the closed object schema checked on every get.\n\nimport type { JsonValue } from \"../../json.ts\";\nimport {\n\ttype BooleanSchema,\n\ttype IntegerSchema,\n\tisOptional,\n\ttype LiteralsSchema,\n\ttype Optional,\n\ttype Schema,\n\ttype StringSchema,\n} from \"./schema.ts\";\nimport { snapshotSchema } from \"./snapshot.ts\";\n\n/** A params field: a string, an integer, a boolean or a union of string literals; constraints allowed, no default. */\ntype ParamSchema = (StringSchema | IntegerSchema | BooleanSchema | LiteralsSchema<string>) & {\n\treadonly default?: never;\n};\n\n/** Params: a flat record of required fields, in identity order. */\nexport type Params = { readonly [field: string]: ParamSchema };\n\n/** Refuses optional params fields, which the field types alone admit. */\nexport type RequiredFields<P extends Params> = {\n\t[F in keyof P]: P[F] extends Optional ? never : P[F];\n};\n\nexport type ParamsData = {\n\t/** Field names in identity order. */\n\treadonly fields: readonly string[];\n\t/** The closed object schema of all fields. */\n\treadonly schema: Schema;\n\t/** `[field, normal form]` pairs in identity order. */\n\treadonly normal: JsonValue;\n};\n\n/** Reads declared params fields: each a required str(), int(), bool() or oneOf(...) of strings, constraints allowed. */\nexport function readParams(declared: readonly [string, unknown][], path: string): ParamsData {\n\tconst fields = declared.map(([field, schema]) => {\n\t\tconst fieldPath = `${path}.${field}`;\n\t\tconst refused = new Error(`${fieldPath}: a param is a required str(), int(), bool() or oneOf(...) of strings`);\n\t\tif (isOptional(schema)) throw refused;\n\t\tconst snapshot = snapshotSchema(schema, fieldPath);\n\t\tif (!isParamSchema(snapshot.normal)) throw refused;\n\t\treturn [field, snapshot] as const;\n\t});\n\tconst schema = {\n\t\ttype: \"object\",\n\t\tproperties: Object.fromEntries(fields.map(([field, snapshot]) => [field, snapshot.schema])),\n\t\trequired: fields.map(([field]) => field),\n\t\tadditionalProperties: false,\n\t};\n\treturn {\n\t\tfields: fields.map(([field]) => field),\n\t\tschema,\n\t\tnormal: fields.map(([field, snapshot]) => [field, snapshot.normal]),\n\t};\n}\n\n/** Joins key parts with `|`, each escaped (`\\\\` and `|`), so two different part lists never join to one key. */\nexport function joinKey(parts: readonly string[]): string {\n\treturn parts.map((part) => part.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll(\"|\", \"\\\\|\")).join(\"|\");\n}\n\ntype SchemaNode = { readonly [keyword: string]: JsonValue };\n\nfunction isParamSchema(normal: JsonValue): boolean {\n\tconst node = normal as SchemaNode;\n\tif (node.anyOf !== undefined) {\n\t\treturn Object.keys(node).length === 1 && Array.isArray(node.anyOf) && node.anyOf.every(isStringLiteral);\n\t}\n\tconst allowed = PARAM_KEYWORDS.get(node.type);\n\treturn allowed !== undefined && Object.keys(node).every((key) => allowed.has(key));\n}\n\n/** Keywords a params field may use, by type. */\nconst PARAM_KEYWORDS = new Map<unknown, ReadonlySet<string>>([\n\t[\"string\", new Set([\"type\", \"minLength\", \"maxLength\", \"pattern\", \"format\"])],\n\t[\"integer\", new Set([\"type\", \"minimum\", \"maximum\", \"exclusiveMinimum\", \"exclusiveMaximum\", \"multipleOf\"])],\n\t[\"boolean\", new Set([\"type\"])],\n]);\n\nfunction isStringLiteral(branch: JsonValue): boolean {\n\tconst node = branch as SchemaNode;\n\treturn node.type === \"string\" && typeof node.const === \"string\" && Object.keys(node).length === 2;\n}\n"]}
@@ -0,0 +1,102 @@
1
+ import { Optional, type Properties, type Schema, type Static, type StaticObject } from "@earendil-works/pi-schema";
2
+ export { Optional, opt, type Schema, type Static } from "@earendil-works/pi-schema";
3
+ /** Bounds of a string length, a number or an array length. */
4
+ export type Bounds = {
5
+ readonly min?: number;
6
+ readonly max?: number;
7
+ };
8
+ /** A declared default value: a table column with one may be left out of a `put` (slice 6a §5). */
9
+ export type Defaulted<T> = {
10
+ readonly default: T;
11
+ };
12
+ /** A string schema (`str()`), told apart from the other scalars by its `type`. */
13
+ export interface StringSchema extends Schema<string> {
14
+ readonly type: "string";
15
+ }
16
+ /** A number schema (`num()`). */
17
+ export interface NumberSchema extends Schema<number> {
18
+ readonly type: "number";
19
+ }
20
+ /** An integer schema (`int()`). */
21
+ export interface IntegerSchema extends Schema<number> {
22
+ readonly type: "integer";
23
+ }
24
+ /** A boolean schema (`bool()`). */
25
+ export interface BooleanSchema extends Schema<boolean> {
26
+ readonly type: "boolean";
27
+ }
28
+ /** The `null` schema (`nul()`): also the omitted side of a method. */
29
+ export interface NullSchema extends Schema<null> {
30
+ readonly type: "null";
31
+ }
32
+ /** A union of literals (`oneOf(...)`). */
33
+ export interface LiteralsSchema<V extends Literal> extends Schema<V> {
34
+ readonly anyOf: readonly Schema<V>[];
35
+ }
36
+ /** A string, with optional length bounds, pattern and default. */
37
+ export declare function str(options: Bounds & {
38
+ readonly pattern?: string;
39
+ readonly default: string;
40
+ }): StringSchema & Defaulted<string>;
41
+ export declare function str(options?: Bounds & {
42
+ readonly pattern?: string;
43
+ }): StringSchema;
44
+ /** A finite number within optional bounds, with an optional default. */
45
+ export declare function num(options: Bounds & {
46
+ readonly default: number;
47
+ }): NumberSchema & Defaulted<number>;
48
+ export declare function num(options?: Bounds): NumberSchema;
49
+ /** An integer within optional bounds, with an optional default. */
50
+ export declare function int(options: Bounds & {
51
+ readonly default: number;
52
+ }): IntegerSchema & Defaulted<number>;
53
+ export declare function int(options?: Bounds): IntegerSchema;
54
+ /** A boolean, with an optional default. */
55
+ export declare function bool(options: {
56
+ readonly default: boolean;
57
+ }): BooleanSchema & Defaulted<boolean>;
58
+ export declare function bool(options?: Record<never, never>): BooleanSchema;
59
+ /** `null`; also the omitted side of a method. */
60
+ export declare function nul(): NullSchema;
61
+ /** Exactly the given value, with its JSON type (`{ type: "string", const: "a" }`). */
62
+ export declare function lit<const V extends Literal>(value: V): Schema<V>;
63
+ /** A value `lit(...)` and `oneOf(...)` take. */
64
+ export type Literal = string | number | boolean;
65
+ /** One of the given literals: a union of `lit(...)` schemas, in order. */
66
+ export declare function oneOf<const V extends Literal[]>(...values: V): LiteralsSchema<V[number]>;
67
+ /** Any of the given schemas. */
68
+ export declare function union<const S extends readonly Schema[]>(schemas: S): Schema<Static<S[number]>>;
69
+ /** A closed object: unknown fields are refused; `opt(...)` marks an optional field. */
70
+ export declare function obj<const P extends Properties>(properties: P): Schema<StaticObject<P>>;
71
+ /** An array, with optional length bounds. */
72
+ export declare function arr<T>(items: Schema<T>, options?: Bounds): Schema<T[]>;
73
+ /** A string-keyed record: one pattern property matching every key. */
74
+ export declare function map<T>(value: Schema<T>): Schema<Record<string, T>>;
75
+ /** Any value. */
76
+ export declare function unknown(): Schema<unknown>;
77
+ /**
78
+ * A `Uint8Array` leaf, checked by `instanceof` and length, never enumerated: `{ type: "bytes", minLength?, maxLength? }`
79
+ * (pi-schema's extension of JSON Schema for values that never pass through JSON).
80
+ */
81
+ export declare function bytes(options?: Bounds): Schema<Uint8Array>;
82
+ /** Whether a declared object field is `opt(...)`. */
83
+ export declare function isOptional(value: unknown): value is Optional;
84
+ /** A method declaration: its argument and result schemas; an omitted side is `null` on the wire. */
85
+ export declare class Method<A extends Schema = Schema, R extends Schema = Schema> {
86
+ readonly args: A;
87
+ readonly result: R;
88
+ constructor(args: A, result: R);
89
+ }
90
+ /** A keyed state member's declaration (slice 6a §12): documents of `schema` by string key; only in `local` contracts. */
91
+ export declare class KeyedMember<S extends Schema = Schema> {
92
+ readonly schema: S;
93
+ constructor(schema: S);
94
+ }
95
+ /** Declares a keyed state member of a `local` contract: documents of `schema` by string key, each watchable. */
96
+ export declare function keyed<S extends Schema>(schema: S): KeyedMember<S>;
97
+ /** Declares a method: `method()`, `method(args)`, `method(args, result)` or `method(undefined, result)`. */
98
+ export declare function method(): Method<NullSchema, NullSchema>;
99
+ export declare function method<A extends Schema>(args: A): Method<A, NullSchema>;
100
+ export declare function method<R extends Schema>(args: undefined, result: R): Method<NullSchema, R>;
101
+ export declare function method<A extends Schema, R extends Schema>(args: A, result: R): Method<A, R>;
102
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/next/contracts/schema.ts"],"names":[],"mappings":"AAIA,OAAO,EAON,QAAQ,EAER,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EAIjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,2BAA2B,CAAC;AAEpF,8DAA8D;AAC9D,MAAM,MAAM,MAAM,GAAG;IAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,kGAAkG;AAClG,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAAE,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAKnD,kFAAkF;AAClF,MAAM,WAAW,YAAa,SAAQ,MAAM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EAAE,UAAU,CAAC,CAAC;AACzD,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;AACzE,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;AAC5F,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,103 @@
1
+ // Schema helpers: Chord's short constructors over pi-schema's builders (plain JSON Schema, typed with the values they
2
+ // accept), and method and keyed member declarations. The helpers keep the shapes contracts were fingerprinted with:
3
+ // literals carry their `type`, `oneOf` is a union of literals, `map` a pattern-property record.
4
+ import { arr as arrSchema, bool as boolSchema, bytes as bytesSchema, int as intSchema, nul as nulSchema, num as numSchema, Optional, obj as objSchema, str as strSchema, union as unionSchema, unknown as unknownSchema, } from "@earendil-works/pi-schema";
5
+ export { Optional, opt } from "@earendil-works/pi-schema";
6
+ export function str(options = {}) {
7
+ const pattern = options.pattern === undefined ? {} : { pattern: options.pattern };
8
+ return strSchema({
9
+ ...limits(options, "minLength", "maxLength"),
10
+ ...pattern,
11
+ ...defaultOf(options),
12
+ });
13
+ }
14
+ export function num(options = {}) {
15
+ return numSchema({ ...limits(options, "minimum", "maximum"), ...defaultOf(options) });
16
+ }
17
+ export function int(options = {}) {
18
+ return intSchema({ ...limits(options, "minimum", "maximum"), ...defaultOf(options) });
19
+ }
20
+ export function bool(options = {}) {
21
+ return boolSchema(defaultOf(options));
22
+ }
23
+ /** The `default` keyword of `options`, left out when absent (snapshots refuse `undefined`). */
24
+ function defaultOf(options) {
25
+ return options.default === undefined ? {} : { default: options.default };
26
+ }
27
+ /** `null`; also the omitted side of a method. */
28
+ export function nul() {
29
+ // The builder's `type: "null"`, typed as such.
30
+ return nulSchema();
31
+ }
32
+ /** Exactly the given value, with its JSON type (`{ type: "string", const: "a" }`). */
33
+ export function lit(value) {
34
+ return { type: typeof value, const: value };
35
+ }
36
+ /** One of the given literals: a union of `lit(...)` schemas, in order. */
37
+ export function oneOf(...values) {
38
+ return { anyOf: values.map((value) => lit(value)) };
39
+ }
40
+ /** Any of the given schemas. */
41
+ export function union(schemas) {
42
+ return unionSchema(schemas);
43
+ }
44
+ /** A closed object: unknown fields are refused; `opt(...)` marks an optional field. */
45
+ export function obj(properties) {
46
+ return objSchema(properties);
47
+ }
48
+ /** An array, with optional length bounds. */
49
+ export function arr(items, options = {}) {
50
+ return arrSchema(items, limits(options, "minItems", "maxItems"));
51
+ }
52
+ /** A string-keyed record: one pattern property matching every key. */
53
+ export function map(value) {
54
+ return { type: "object", patternProperties: { "^.*$": value } };
55
+ }
56
+ /** Any value. */
57
+ export function unknown() {
58
+ return unknownSchema();
59
+ }
60
+ /**
61
+ * A `Uint8Array` leaf, checked by `instanceof` and length, never enumerated: `{ type: "bytes", minLength?, maxLength? }`
62
+ * (pi-schema's extension of JSON Schema for values that never pass through JSON).
63
+ */
64
+ export function bytes(options = {}) {
65
+ return bytesSchema(limits(options, "minLength", "maxLength"));
66
+ }
67
+ /** Builder options for the given bounds; an absent bound is left out, since snapshots refuse `undefined`. */
68
+ function limits(options, min, max) {
69
+ const result = {};
70
+ if (options.min !== undefined)
71
+ result[min] = options.min;
72
+ if (options.max !== undefined)
73
+ result[max] = options.max;
74
+ return result;
75
+ }
76
+ /** Whether a declared object field is `opt(...)`. */
77
+ export function isOptional(value) {
78
+ return value instanceof Optional;
79
+ }
80
+ /** A method declaration: its argument and result schemas; an omitted side is `null` on the wire. */
81
+ export class Method {
82
+ args;
83
+ result;
84
+ constructor(args, result) {
85
+ this.args = args;
86
+ this.result = result;
87
+ }
88
+ }
89
+ /** A keyed state member's declaration (slice 6a §12): documents of `schema` by string key; only in `local` contracts. */
90
+ export class KeyedMember {
91
+ schema;
92
+ constructor(schema) {
93
+ this.schema = schema;
94
+ }
95
+ }
96
+ /** Declares a keyed state member of a `local` contract: documents of `schema` by string key, each watchable. */
97
+ export function keyed(schema) {
98
+ return new KeyedMember(schema);
99
+ }
100
+ export function method(args, result) {
101
+ return new Method(args ?? nul(), result ?? nul());
102
+ }
103
+ //# sourceMappingURL=schema.js.map