@superbee/core 0.2.0-pre.2 → 0.2.0-pre.21

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 (517) hide show
  1. package/README.md +1000 -0
  2. package/dist/artifact-contract.d.ts +90 -0
  3. package/dist/artifact-contract.d.ts.map +1 -0
  4. package/dist/artifact-contract.js +205 -0
  5. package/dist/artifact-contract.js.map +1 -0
  6. package/dist/backend.d.ts +19 -1
  7. package/dist/backend.d.ts.map +1 -1
  8. package/dist/backend.js +83 -36
  9. package/dist/backend.js.map +1 -1
  10. package/dist/blob-contract.d.ts +80 -0
  11. package/dist/blob-contract.d.ts.map +1 -0
  12. package/dist/blob-contract.js +131 -0
  13. package/dist/blob-contract.js.map +1 -0
  14. package/dist/blob-journal.d.ts +302 -0
  15. package/dist/blob-journal.d.ts.map +1 -0
  16. package/dist/blob-journal.js +540 -0
  17. package/dist/blob-journal.js.map +1 -0
  18. package/dist/body-replace-guards.d.ts +50 -0
  19. package/dist/body-replace-guards.d.ts.map +1 -0
  20. package/dist/body-replace-guards.js +158 -0
  21. package/dist/body-replace-guards.js.map +1 -0
  22. package/dist/builtin-recipes/content.d.ts +93 -0
  23. package/dist/builtin-recipes/content.d.ts.map +1 -0
  24. package/dist/builtin-recipes/content.js +288 -0
  25. package/dist/builtin-recipes/content.js.map +1 -0
  26. package/dist/builtin-recipes.d.ts +10 -0
  27. package/dist/builtin-recipes.d.ts.map +1 -0
  28. package/dist/builtin-recipes.js +97 -0
  29. package/dist/builtin-recipes.js.map +1 -0
  30. package/dist/bundle-health/index.d.ts +14 -0
  31. package/dist/bundle-health/index.d.ts.map +1 -0
  32. package/dist/bundle-health/index.js +12 -0
  33. package/dist/bundle-health/index.js.map +1 -0
  34. package/dist/bundle-health/kind-findings.d.ts +44 -0
  35. package/dist/bundle-health/kind-findings.d.ts.map +1 -0
  36. package/dist/bundle-health/kind-findings.js +68 -0
  37. package/dist/bundle-health/kind-findings.js.map +1 -0
  38. package/dist/bundle-health/legacy-page.d.ts +39 -0
  39. package/dist/bundle-health/legacy-page.d.ts.map +1 -0
  40. package/dist/bundle-health/legacy-page.js +50 -0
  41. package/dist/bundle-health/legacy-page.js.map +1 -0
  42. package/dist/bundle-health/report.d.ts +202 -0
  43. package/dist/bundle-health/report.d.ts.map +1 -0
  44. package/dist/bundle-health/report.js +438 -0
  45. package/dist/bundle-health/report.js.map +1 -0
  46. package/dist/bundle-ops.d.ts +1 -1
  47. package/dist/bundle-ops.d.ts.map +1 -1
  48. package/dist/bundle-ops.js +2 -2
  49. package/dist/bundle-ops.js.map +1 -1
  50. package/dist/bundle.d.ts +2 -1
  51. package/dist/bundle.d.ts.map +1 -1
  52. package/dist/bundle.js +3 -3
  53. package/dist/bundle.js.map +1 -1
  54. package/dist/code-point-order.d.ts +8 -0
  55. package/dist/code-point-order.d.ts.map +1 -0
  56. package/dist/code-point-order.js +20 -0
  57. package/dist/code-point-order.js.map +1 -0
  58. package/dist/connectors.d.ts +230 -0
  59. package/dist/connectors.d.ts.map +1 -0
  60. package/dist/connectors.js +1150 -0
  61. package/dist/connectors.js.map +1 -0
  62. package/dist/cross-bundle.d.ts +135 -0
  63. package/dist/cross-bundle.d.ts.map +1 -0
  64. package/dist/cross-bundle.js +186 -0
  65. package/dist/cross-bundle.js.map +1 -0
  66. package/dist/dependencies.d.ts +94 -0
  67. package/dist/dependencies.d.ts.map +1 -0
  68. package/dist/dependencies.js +180 -0
  69. package/dist/dependencies.js.map +1 -0
  70. package/dist/document-codec.d.ts +6 -1
  71. package/dist/document-codec.d.ts.map +1 -1
  72. package/dist/document-codec.js +8 -4
  73. package/dist/document-codec.js.map +1 -1
  74. package/dist/document-field-actions.d.ts +31 -1
  75. package/dist/document-field-actions.d.ts.map +1 -1
  76. package/dist/document-field-actions.js +137 -34
  77. package/dist/document-field-actions.js.map +1 -1
  78. package/dist/document-mutation.d.ts +22 -10
  79. package/dist/document-mutation.d.ts.map +1 -1
  80. package/dist/document-mutation.js +58 -27
  81. package/dist/document-mutation.js.map +1 -1
  82. package/dist/document-write-policy.d.ts.map +1 -1
  83. package/dist/document-write-policy.js +4 -2
  84. package/dist/document-write-policy.js.map +1 -1
  85. package/dist/engine.d.ts +9 -2
  86. package/dist/engine.d.ts.map +1 -1
  87. package/dist/engine.js +11 -4
  88. package/dist/engine.js.map +1 -1
  89. package/dist/file-journaled-backend-internal.d.ts +21 -0
  90. package/dist/file-journaled-backend-internal.d.ts.map +1 -0
  91. package/dist/file-journaled-backend-internal.js +12 -0
  92. package/dist/file-journaled-backend-internal.js.map +1 -0
  93. package/dist/file-journaled-backend.d.ts +200 -0
  94. package/dist/file-journaled-backend.d.ts.map +1 -0
  95. package/dist/file-journaled-backend.js +1334 -0
  96. package/dist/file-journaled-backend.js.map +1 -0
  97. package/dist/filesystem-host.d.ts +15 -0
  98. package/dist/filesystem-host.d.ts.map +1 -0
  99. package/dist/filesystem-host.js +20 -0
  100. package/dist/filesystem-host.js.map +1 -0
  101. package/dist/filesystem-identity.d.ts +86 -4
  102. package/dist/filesystem-identity.d.ts.map +1 -1
  103. package/dist/filesystem-identity.js +338 -102
  104. package/dist/filesystem-identity.js.map +1 -1
  105. package/dist/filesystem-lock.d.ts +16 -3
  106. package/dist/filesystem-lock.d.ts.map +1 -1
  107. package/dist/filesystem-lock.js +323 -77
  108. package/dist/filesystem-lock.js.map +1 -1
  109. package/dist/filesystem-push-role.d.ts +77 -0
  110. package/dist/filesystem-push-role.d.ts.map +1 -0
  111. package/dist/filesystem-push-role.js +165 -0
  112. package/dist/filesystem-push-role.js.map +1 -0
  113. package/dist/filesystem.d.ts +17 -0
  114. package/dist/filesystem.d.ts.map +1 -0
  115. package/dist/filesystem.js +18 -0
  116. package/dist/filesystem.js.map +1 -0
  117. package/dist/frontmatter.d.ts +8 -0
  118. package/dist/frontmatter.d.ts.map +1 -1
  119. package/dist/frontmatter.js +14 -4
  120. package/dist/frontmatter.js.map +1 -1
  121. package/dist/governed-body-write.d.ts +106 -0
  122. package/dist/governed-body-write.d.ts.map +1 -0
  123. package/dist/governed-body-write.js +251 -0
  124. package/dist/governed-body-write.js.map +1 -0
  125. package/dist/host-policy-snapshot.d.ts +9 -0
  126. package/dist/host-policy-snapshot.d.ts.map +1 -0
  127. package/dist/host-policy-snapshot.js +33 -0
  128. package/dist/host-policy-snapshot.js.map +1 -0
  129. package/dist/host-text.d.ts +31 -0
  130. package/dist/host-text.d.ts.map +1 -0
  131. package/dist/host-text.js +77 -0
  132. package/dist/host-text.js.map +1 -0
  133. package/dist/hosted-client/binding.d.ts +7 -0
  134. package/dist/hosted-client/binding.d.ts.map +1 -0
  135. package/dist/hosted-client/binding.js +10 -0
  136. package/dist/hosted-client/binding.js.map +1 -0
  137. package/dist/hosted-client/blob-delivery.d.ts +67 -0
  138. package/dist/hosted-client/blob-delivery.d.ts.map +1 -0
  139. package/dist/hosted-client/blob-delivery.js +169 -0
  140. package/dist/hosted-client/blob-delivery.js.map +1 -0
  141. package/dist/hosted-client/blob-write.d.ts +386 -0
  142. package/dist/hosted-client/blob-write.d.ts.map +1 -0
  143. package/dist/hosted-client/blob-write.js +770 -0
  144. package/dist/hosted-client/blob-write.js.map +1 -0
  145. package/dist/hosted-client/bundle-listing.d.ts +46 -0
  146. package/dist/hosted-client/bundle-listing.d.ts.map +1 -0
  147. package/dist/hosted-client/bundle-listing.js +36 -0
  148. package/dist/hosted-client/bundle-listing.js.map +1 -0
  149. package/dist/hosted-client/client.d.ts +219 -0
  150. package/dist/hosted-client/client.d.ts.map +1 -0
  151. package/dist/hosted-client/client.js +309 -0
  152. package/dist/hosted-client/client.js.map +1 -0
  153. package/dist/hosted-client/directory.d.ts +46 -0
  154. package/dist/hosted-client/directory.d.ts.map +1 -0
  155. package/dist/hosted-client/directory.js +74 -0
  156. package/dist/hosted-client/directory.js.map +1 -0
  157. package/dist/hosted-client/errors.d.ts +26 -0
  158. package/dist/hosted-client/errors.d.ts.map +1 -0
  159. package/dist/hosted-client/errors.js +35 -0
  160. package/dist/hosted-client/errors.js.map +1 -0
  161. package/dist/hosted-client/inbox.d.ts +320 -0
  162. package/dist/hosted-client/inbox.d.ts.map +1 -0
  163. package/dist/hosted-client/inbox.js +379 -0
  164. package/dist/hosted-client/inbox.js.map +1 -0
  165. package/dist/hosted-client/index.d.ts +30 -0
  166. package/dist/hosted-client/index.d.ts.map +1 -0
  167. package/dist/hosted-client/index.js +32 -0
  168. package/dist/hosted-client/index.js.map +1 -0
  169. package/dist/hosted-client/journal.d.ts +103 -0
  170. package/dist/hosted-client/journal.d.ts.map +1 -0
  171. package/dist/hosted-client/journal.js +464 -0
  172. package/dist/hosted-client/journal.js.map +1 -0
  173. package/dist/hosted-client/node.d.ts +74 -0
  174. package/dist/hosted-client/node.d.ts.map +1 -0
  175. package/dist/hosted-client/node.js +219 -0
  176. package/dist/hosted-client/node.js.map +1 -0
  177. package/dist/hosted-client/reference.d.ts +12 -0
  178. package/dist/hosted-client/reference.d.ts.map +1 -0
  179. package/dist/hosted-client/reference.js +29 -0
  180. package/dist/hosted-client/reference.js.map +1 -0
  181. package/dist/hosted-client/write.d.ts +217 -0
  182. package/dist/hosted-client/write.d.ts.map +1 -0
  183. package/dist/hosted-client/write.js +418 -0
  184. package/dist/hosted-client/write.js.map +1 -0
  185. package/dist/hosted-transport/answer-rows.d.ts +243 -0
  186. package/dist/hosted-transport/answer-rows.d.ts.map +1 -0
  187. package/dist/hosted-transport/answer-rows.js +454 -0
  188. package/dist/hosted-transport/answer-rows.js.map +1 -0
  189. package/dist/hosted-transport/blob-reads.d.ts +35 -0
  190. package/dist/hosted-transport/blob-reads.d.ts.map +1 -0
  191. package/dist/hosted-transport/blob-reads.js +179 -0
  192. package/dist/hosted-transport/blob-reads.js.map +1 -0
  193. package/dist/hosted-transport/blob-write.d.ts +34 -0
  194. package/dist/hosted-transport/blob-write.d.ts.map +1 -0
  195. package/dist/hosted-transport/blob-write.js +115 -0
  196. package/dist/hosted-transport/blob-write.js.map +1 -0
  197. package/dist/hosted-transport/carrier.d.ts +151 -0
  198. package/dist/hosted-transport/carrier.d.ts.map +1 -0
  199. package/dist/hosted-transport/carrier.js +260 -0
  200. package/dist/hosted-transport/carrier.js.map +1 -0
  201. package/dist/hosted-transport/history-pages.d.ts +55 -0
  202. package/dist/hosted-transport/history-pages.d.ts.map +1 -0
  203. package/dist/hosted-transport/history-pages.js +69 -0
  204. package/dist/hosted-transport/history-pages.js.map +1 -0
  205. package/dist/hosted-transport/index.d.ts +18 -0
  206. package/dist/hosted-transport/index.d.ts.map +1 -0
  207. package/dist/hosted-transport/index.js +18 -0
  208. package/dist/hosted-transport/index.js.map +1 -0
  209. package/dist/hosted-transport/operations.d.ts +85 -0
  210. package/dist/hosted-transport/operations.d.ts.map +1 -0
  211. package/dist/hosted-transport/operations.js +128 -0
  212. package/dist/hosted-transport/operations.js.map +1 -0
  213. package/dist/hosted-transport/paged-reads.d.ts +87 -0
  214. package/dist/hosted-transport/paged-reads.d.ts.map +1 -0
  215. package/dist/hosted-transport/paged-reads.js +238 -0
  216. package/dist/hosted-transport/paged-reads.js.map +1 -0
  217. package/dist/hosted-transport/read-adapter.d.ts +256 -0
  218. package/dist/hosted-transport/read-adapter.d.ts.map +1 -0
  219. package/dist/hosted-transport/read-adapter.js +568 -0
  220. package/dist/hosted-transport/read-adapter.js.map +1 -0
  221. package/dist/hosted-transport/root-write.d.ts +114 -0
  222. package/dist/hosted-transport/root-write.d.ts.map +1 -0
  223. package/dist/hosted-transport/root-write.js +171 -0
  224. package/dist/hosted-transport/root-write.js.map +1 -0
  225. package/dist/hosted-transport/whole-document-transport.d.ts +204 -0
  226. package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -0
  227. package/dist/hosted-transport/whole-document-transport.js +447 -0
  228. package/dist/hosted-transport/whole-document-transport.js.map +1 -0
  229. package/dist/index.d.ts +34 -10
  230. package/dist/index.d.ts.map +1 -1
  231. package/dist/index.js +26 -8
  232. package/dist/index.js.map +1 -1
  233. package/dist/indexeddb-backend.d.ts +28 -6
  234. package/dist/indexeddb-backend.d.ts.map +1 -1
  235. package/dist/indexeddb-backend.js +471 -92
  236. package/dist/indexeddb-backend.js.map +1 -1
  237. package/dist/journaled-backend.d.ts +247 -10
  238. package/dist/journaled-backend.d.ts.map +1 -1
  239. package/dist/journaled-backend.js +302 -1
  240. package/dist/journaled-backend.js.map +1 -1
  241. package/dist/kind-authoring.d.ts +170 -0
  242. package/dist/kind-authoring.d.ts.map +1 -0
  243. package/dist/kind-authoring.js +451 -0
  244. package/dist/kind-authoring.js.map +1 -0
  245. package/dist/kind-conformance-error.d.ts +15 -0
  246. package/dist/kind-conformance-error.d.ts.map +1 -0
  247. package/dist/kind-conformance-error.js +20 -0
  248. package/dist/kind-conformance-error.js.map +1 -0
  249. package/dist/kind-coverage.d.ts +99 -0
  250. package/dist/kind-coverage.d.ts.map +1 -0
  251. package/dist/kind-coverage.js +186 -0
  252. package/dist/kind-coverage.js.map +1 -0
  253. package/dist/kind-field-mutation.d.ts +4 -0
  254. package/dist/kind-field-mutation.d.ts.map +1 -1
  255. package/dist/kind-field-mutation.js +28 -3
  256. package/dist/kind-field-mutation.js.map +1 -1
  257. package/dist/kinds-load.js +4 -4
  258. package/dist/kinds-load.js.map +1 -1
  259. package/dist/kinds.d.ts +65 -2
  260. package/dist/kinds.d.ts.map +1 -1
  261. package/dist/kinds.js +341 -21
  262. package/dist/kinds.js.map +1 -1
  263. package/dist/link-types.d.ts +26 -0
  264. package/dist/link-types.d.ts.map +1 -0
  265. package/dist/link-types.js +57 -0
  266. package/dist/link-types.js.map +1 -0
  267. package/dist/links.d.ts +21 -3
  268. package/dist/links.d.ts.map +1 -1
  269. package/dist/links.js +213 -14
  270. package/dist/links.js.map +1 -1
  271. package/dist/managed-document-metadata.d.ts +2 -0
  272. package/dist/managed-document-metadata.d.ts.map +1 -0
  273. package/dist/managed-document-metadata.js +9 -0
  274. package/dist/managed-document-metadata.js.map +1 -0
  275. package/dist/memory-backend.d.ts +2 -2
  276. package/dist/memory-backend.d.ts.map +1 -1
  277. package/dist/memory-backend.js +26 -11
  278. package/dist/memory-backend.js.map +1 -1
  279. package/dist/paths.d.ts +16 -0
  280. package/dist/paths.d.ts.map +1 -1
  281. package/dist/paths.js +25 -0
  282. package/dist/paths.js.map +1 -1
  283. package/dist/platform.d.ts +13 -2
  284. package/dist/platform.d.ts.map +1 -1
  285. package/dist/platform.js +16 -0
  286. package/dist/platform.js.map +1 -1
  287. package/dist/portable-export.d.ts +119 -0
  288. package/dist/portable-export.d.ts.map +1 -0
  289. package/dist/portable-export.js +501 -0
  290. package/dist/portable-export.js.map +1 -0
  291. package/dist/publication-filesystem.d.ts +1 -1
  292. package/dist/publication-filesystem.d.ts.map +1 -1
  293. package/dist/publication-filesystem.js +1 -1
  294. package/dist/publication-filesystem.js.map +1 -1
  295. package/dist/qualified-links.d.ts +67 -0
  296. package/dist/qualified-links.d.ts.map +1 -0
  297. package/dist/qualified-links.js +117 -0
  298. package/dist/qualified-links.js.map +1 -0
  299. package/dist/query-filter.d.ts +16 -2
  300. package/dist/query-filter.d.ts.map +1 -1
  301. package/dist/query-filter.js +40 -1
  302. package/dist/query-filter.js.map +1 -1
  303. package/dist/query-order.d.ts +22 -0
  304. package/dist/query-order.d.ts.map +1 -0
  305. package/dist/query-order.js +42 -0
  306. package/dist/query-order.js.map +1 -0
  307. package/dist/recipe-lifecycle/errors.d.ts +96 -0
  308. package/dist/recipe-lifecycle/errors.d.ts.map +1 -0
  309. package/dist/recipe-lifecycle/errors.js +122 -0
  310. package/dist/recipe-lifecycle/errors.js.map +1 -0
  311. package/dist/recipe-lifecycle/evolution.d.ts +108 -0
  312. package/dist/recipe-lifecycle/evolution.d.ts.map +1 -0
  313. package/dist/recipe-lifecycle/evolution.js +884 -0
  314. package/dist/recipe-lifecycle/evolution.js.map +1 -0
  315. package/dist/recipe-lifecycle/index.d.ts +26 -0
  316. package/dist/recipe-lifecycle/index.d.ts.map +1 -0
  317. package/dist/recipe-lifecycle/index.js +22 -0
  318. package/dist/recipe-lifecycle/index.js.map +1 -0
  319. package/dist/recipe-lifecycle/install.d.ts +127 -0
  320. package/dist/recipe-lifecycle/install.d.ts.map +1 -0
  321. package/dist/recipe-lifecycle/install.js +526 -0
  322. package/dist/recipe-lifecycle/install.js.map +1 -0
  323. package/dist/recipe-lifecycle/legacy-aliases.d.ts +16 -0
  324. package/dist/recipe-lifecycle/legacy-aliases.d.ts.map +1 -0
  325. package/dist/recipe-lifecycle/legacy-aliases.js +51 -0
  326. package/dist/recipe-lifecycle/legacy-aliases.js.map +1 -0
  327. package/dist/recipe-lifecycle/stamp.d.ts +136 -0
  328. package/dist/recipe-lifecycle/stamp.d.ts.map +1 -0
  329. package/dist/recipe-lifecycle/stamp.js +326 -0
  330. package/dist/recipe-lifecycle/stamp.js.map +1 -0
  331. package/dist/recipes.d.ts +29 -1
  332. package/dist/recipes.d.ts.map +1 -1
  333. package/dist/recipes.js +137 -1
  334. package/dist/recipes.js.map +1 -1
  335. package/dist/record-overlay/apply.d.ts +43 -0
  336. package/dist/record-overlay/apply.d.ts.map +1 -0
  337. package/dist/record-overlay/apply.js +527 -0
  338. package/dist/record-overlay/apply.js.map +1 -0
  339. package/dist/record-overlay/canonical.d.ts +22 -0
  340. package/dist/record-overlay/canonical.d.ts.map +1 -0
  341. package/dist/record-overlay/canonical.js +47 -0
  342. package/dist/record-overlay/canonical.js.map +1 -0
  343. package/dist/record-overlay/digest.d.ts +4 -0
  344. package/dist/record-overlay/digest.d.ts.map +1 -0
  345. package/dist/record-overlay/digest.js +11 -0
  346. package/dist/record-overlay/digest.js.map +1 -0
  347. package/dist/record-overlay/errors.d.ts +44 -0
  348. package/dist/record-overlay/errors.d.ts.map +1 -0
  349. package/dist/record-overlay/errors.js +55 -0
  350. package/dist/record-overlay/errors.js.map +1 -0
  351. package/dist/record-overlay/findings.d.ts +5 -0
  352. package/dist/record-overlay/findings.d.ts.map +1 -0
  353. package/dist/record-overlay/findings.js +83 -0
  354. package/dist/record-overlay/findings.js.map +1 -0
  355. package/dist/record-overlay/index.d.ts +23 -0
  356. package/dist/record-overlay/index.d.ts.map +1 -0
  357. package/dist/record-overlay/index.js +21 -0
  358. package/dist/record-overlay/index.js.map +1 -0
  359. package/dist/record-overlay/plan.d.ts +12 -0
  360. package/dist/record-overlay/plan.d.ts.map +1 -0
  361. package/dist/record-overlay/plan.js +285 -0
  362. package/dist/record-overlay/plan.js.map +1 -0
  363. package/dist/record-overlay/policy.d.ts +69 -0
  364. package/dist/record-overlay/policy.d.ts.map +1 -0
  365. package/dist/record-overlay/policy.js +228 -0
  366. package/dist/record-overlay/policy.js.map +1 -0
  367. package/dist/record-overlay/redact.d.ts +3 -0
  368. package/dist/record-overlay/redact.d.ts.map +1 -0
  369. package/dist/record-overlay/redact.js +27 -0
  370. package/dist/record-overlay/redact.js.map +1 -0
  371. package/dist/record-overlay/signal-kind.d.ts +30 -0
  372. package/dist/record-overlay/signal-kind.d.ts.map +1 -0
  373. package/dist/record-overlay/signal-kind.js +38 -0
  374. package/dist/record-overlay/signal-kind.js.map +1 -0
  375. package/dist/record-overlay/signal-text.d.ts +45 -0
  376. package/dist/record-overlay/signal-text.d.ts.map +1 -0
  377. package/dist/record-overlay/signal-text.js +116 -0
  378. package/dist/record-overlay/signal-text.js.map +1 -0
  379. package/dist/record-overlay/source-index.d.ts +19 -0
  380. package/dist/record-overlay/source-index.d.ts.map +1 -0
  381. package/dist/record-overlay/source-index.js +102 -0
  382. package/dist/record-overlay/source-index.js.map +1 -0
  383. package/dist/record-overlay/types.d.ts +291 -0
  384. package/dist/record-overlay/types.d.ts.map +1 -0
  385. package/dist/record-overlay/types.js +2 -0
  386. package/dist/record-overlay/types.js.map +1 -0
  387. package/dist/remote-backend.d.ts +67 -67
  388. package/dist/remote-backend.d.ts.map +1 -1
  389. package/dist/remote-backend.js +169 -201
  390. package/dist/remote-backend.js.map +1 -1
  391. package/dist/remote-document-codec.d.ts +15 -0
  392. package/dist/remote-document-codec.d.ts.map +1 -0
  393. package/dist/remote-document-codec.js +103 -0
  394. package/dist/remote-document-codec.js.map +1 -0
  395. package/dist/remote-error.d.ts +38 -0
  396. package/dist/remote-error.d.ts.map +1 -0
  397. package/dist/remote-error.js +59 -0
  398. package/dist/remote-error.js.map +1 -0
  399. package/dist/remote-operations.d.ts +6 -3
  400. package/dist/remote-operations.d.ts.map +1 -1
  401. package/dist/remote-operations.js +23 -5
  402. package/dist/remote-operations.js.map +1 -1
  403. package/dist/remote-parsers.d.ts +86 -0
  404. package/dist/remote-parsers.d.ts.map +1 -0
  405. package/dist/remote-parsers.js +181 -0
  406. package/dist/remote-parsers.js.map +1 -0
  407. package/dist/remote.d.ts +5 -2
  408. package/dist/remote.d.ts.map +1 -1
  409. package/dist/remote.js +5 -1
  410. package/dist/remote.js.map +1 -1
  411. package/dist/search/backend-source.d.ts +6 -0
  412. package/dist/search/backend-source.d.ts.map +1 -0
  413. package/dist/search/backend-source.js +33 -0
  414. package/dist/search/backend-source.js.map +1 -0
  415. package/dist/search/contract.d.ts +151 -0
  416. package/dist/search/contract.d.ts.map +1 -0
  417. package/dist/search/contract.js +78 -0
  418. package/dist/search/contract.js.map +1 -0
  419. package/dist/search/errors.d.ts +30 -0
  420. package/dist/search/errors.d.ts.map +1 -0
  421. package/dist/search/errors.js +50 -0
  422. package/dist/search/errors.js.map +1 -0
  423. package/dist/search/identity.d.ts +12 -0
  424. package/dist/search/identity.d.ts.map +1 -0
  425. package/dist/search/identity.js +90 -0
  426. package/dist/search/identity.js.map +1 -0
  427. package/dist/search/index.d.ts +16 -0
  428. package/dist/search/index.d.ts.map +1 -0
  429. package/dist/search/index.js +15 -0
  430. package/dist/search/index.js.map +1 -0
  431. package/dist/search/memory-source.d.ts +36 -0
  432. package/dist/search/memory-source.d.ts.map +1 -0
  433. package/dist/search/memory-source.js +235 -0
  434. package/dist/search/memory-source.js.map +1 -0
  435. package/dist/search/rank.d.ts +34 -0
  436. package/dist/search/rank.d.ts.map +1 -0
  437. package/dist/search/rank.js +129 -0
  438. package/dist/search/rank.js.map +1 -0
  439. package/dist/search/row-text.d.ts +38 -0
  440. package/dist/search/row-text.d.ts.map +1 -0
  441. package/dist/search/row-text.js +88 -0
  442. package/dist/search/row-text.js.map +1 -0
  443. package/dist/search/search.d.ts +28 -0
  444. package/dist/search/search.d.ts.map +1 -0
  445. package/dist/search/search.js +257 -0
  446. package/dist/search/search.js.map +1 -0
  447. package/dist/search/source.d.ts +67 -0
  448. package/dist/search/source.d.ts.map +1 -0
  449. package/dist/search/source.js +2 -0
  450. package/dist/search/source.js.map +1 -0
  451. package/dist/search/text.d.ts +47 -0
  452. package/dist/search/text.d.ts.map +1 -0
  453. package/dist/search/text.js +148 -0
  454. package/dist/search/text.js.map +1 -0
  455. package/dist/site-capabilities.d.ts +339 -0
  456. package/dist/site-capabilities.d.ts.map +1 -0
  457. package/dist/site-capabilities.js +717 -0
  458. package/dist/site-capabilities.js.map +1 -0
  459. package/dist/source-engine/guard.d.ts +82 -0
  460. package/dist/source-engine/guard.d.ts.map +1 -0
  461. package/dist/source-engine/guard.js +396 -0
  462. package/dist/source-engine/guard.js.map +1 -0
  463. package/dist/source-engine/index.d.ts +24 -0
  464. package/dist/source-engine/index.d.ts.map +1 -0
  465. package/dist/source-engine/index.js +20 -0
  466. package/dist/source-engine/index.js.map +1 -0
  467. package/dist/source-engine/machine-state.d.ts +74 -0
  468. package/dist/source-engine/machine-state.d.ts.map +1 -0
  469. package/dist/source-engine/machine-state.js +48 -0
  470. package/dist/source-engine/machine-state.js.map +1 -0
  471. package/dist/source-engine/observe.d.ts +18 -0
  472. package/dist/source-engine/observe.d.ts.map +1 -0
  473. package/dist/source-engine/observe.js +598 -0
  474. package/dist/source-engine/observe.js.map +1 -0
  475. package/dist/source-engine/robots.d.ts +53 -0
  476. package/dist/source-engine/robots.d.ts.map +1 -0
  477. package/dist/source-engine/robots.js +158 -0
  478. package/dist/source-engine/robots.js.map +1 -0
  479. package/dist/source-engine/types.d.ts +285 -0
  480. package/dist/source-engine/types.d.ts.map +1 -0
  481. package/dist/source-engine/types.js +2 -0
  482. package/dist/source-engine/types.js.map +1 -0
  483. package/dist/source-harness/conformance.d.ts +16 -0
  484. package/dist/source-harness/conformance.d.ts.map +1 -0
  485. package/dist/source-harness/conformance.js +265 -0
  486. package/dist/source-harness/conformance.js.map +1 -0
  487. package/dist/source-harness/fixture.d.ts +95 -0
  488. package/dist/source-harness/fixture.d.ts.map +1 -0
  489. package/dist/source-harness/fixture.js +261 -0
  490. package/dist/source-harness/fixture.js.map +1 -0
  491. package/dist/source-harness/index.d.ts +22 -0
  492. package/dist/source-harness/index.d.ts.map +1 -0
  493. package/dist/source-harness/index.js +19 -0
  494. package/dist/source-harness/index.js.map +1 -0
  495. package/dist/source-harness/peer.d.ts +74 -0
  496. package/dist/source-harness/peer.d.ts.map +1 -0
  497. package/dist/source-harness/peer.js +106 -0
  498. package/dist/source-harness/peer.js.map +1 -0
  499. package/dist/storage.d.ts +6 -2
  500. package/dist/storage.d.ts.map +1 -1
  501. package/dist/storage.js +4 -1
  502. package/dist/storage.js.map +1 -1
  503. package/dist/types.d.ts +33 -5
  504. package/dist/types.d.ts.map +1 -1
  505. package/dist/uncertain-write.d.ts +156 -19
  506. package/dist/uncertain-write.d.ts.map +1 -1
  507. package/dist/uncertain-write.js +90 -31
  508. package/dist/uncertain-write.js.map +1 -1
  509. package/dist/versioning.d.ts +9 -4
  510. package/dist/versioning.d.ts.map +1 -1
  511. package/dist/versioning.js +9 -4
  512. package/dist/versioning.js.map +1 -1
  513. package/dist/write-identity.d.ts +5 -0
  514. package/dist/write-identity.d.ts.map +1 -0
  515. package/dist/write-identity.js +9 -0
  516. package/dist/write-identity.js.map +1 -0
  517. package/package.json +94 -2
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Bundle identity and the `docs/dependencies` declaration.
3
+ *
4
+ * A bundle names the other bundles it links into in ONE committed document, `docs/dependencies`
5
+ * (type `Bundle Dependencies`). Each entry maps a local alias (the `<alias>` in
6
+ * `okf://<alias>/<path>.md`) to the target's portable `bundle_id`, plus optional `source`, `pin`
7
+ * and `path`. A target confirms its own identity with `bundle_id` in its `docs/bundle` document.
8
+ *
9
+ * Pure and browser-safe: no `node:*` import, no I/O. Consumers read the documents through their
10
+ * own backend and hand them here.
11
+ */
12
+ // ── Bundle identity ─────────────────────────────────────────────────────────
13
+ // A portable bundle id: lower-case letters and digits joined by `.`, `_` or `-`, starting with a
14
+ // letter, at most 128 characters. The one rule hosted `checkout`, `export` and `publish` accept an
15
+ // id by, and the one a printed `checkout <id>` command is emitted for: an id it rejects (one
16
+ // starting with `-` would read as an option) never appears in a command.
17
+ const BUNDLE_ID = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/;
18
+ const BUNDLE_ID_MAX_LENGTH = 128;
19
+ /** True when `id` is a portable bundle id (the hosted bundle-id grammar). */
20
+ export function isHostedBundleId(id) {
21
+ return id.length <= BUNDLE_ID_MAX_LENGTH && BUNDLE_ID.test(id);
22
+ }
23
+ /**
24
+ * The well-known concept id carrying a bundle's explicit display name and portable id. NOT the
25
+ * bundle-root `index.md` — OKF §3.1 reserves that file's frontmatter solely for `okf_version`, so
26
+ * the name needs its own small doc.
27
+ */
28
+ export const BUNDLE_NAME_DOC_ID = "docs/bundle";
29
+ /**
30
+ * The ownership marker: `docs/bundle` speaks for the bundle ONLY when it carries exactly this
31
+ * `type`. A `docs/bundle` doc of any other type is an ordinary document and is ignored, so an
32
+ * unrelated pre-existing doc is never appropriated as the bundle's name or id.
33
+ */
34
+ export const BUNDLE_NAME_DOC_TYPE = "Bundle Name";
35
+ /**
36
+ * The bundle's self-declared portable id: `bundle_id` in `docs/bundle` under the marker type, when
37
+ * it satisfies {@link isHostedBundleId}. Anything else (absent doc, other type, missing or
38
+ * malformed id) is `undefined`; the caller decides what a bundle without a declared id means.
39
+ */
40
+ export function declaredBundleId(doc) {
41
+ if (!doc || doc.id !== BUNDLE_NAME_DOC_ID)
42
+ return undefined;
43
+ const type = doc.frontmatter.type;
44
+ if (typeof type !== "string" || type.trim() !== BUNDLE_NAME_DOC_TYPE)
45
+ return undefined;
46
+ const id = doc.frontmatter.bundle_id;
47
+ return typeof id === "string" && isHostedBundleId(id) ? id : undefined;
48
+ }
49
+ // ── docs/dependencies ───────────────────────────────────────────────────────
50
+ export const DEPENDENCIES_DOC_ID = "docs/dependencies";
51
+ export const DEPENDENCIES_DOC_TYPE = "Bundle Dependencies";
52
+ /** The alias grammar shared by `okf://<alias>/…` hrefs, dependency keys and qualified Kind targets. */
53
+ export const BUNDLE_ALIAS = /^[a-z][a-z0-9-]{0,62}$/;
54
+ export function isBundleAlias(alias) {
55
+ return BUNDLE_ALIAS.test(alias);
56
+ }
57
+ const KNOWN_KEYS = new Set(["bundle_id", "source", "pin", "path"]);
58
+ /** Reserved for recipe dependencies, which will reuse this declaration. */
59
+ const RESERVED_KEYS = new Set(["use", "version", "channel"]);
60
+ const COMMIT_PIN = /^[0-9a-f]{7,40}$/;
61
+ const DIGEST_PIN = /^sha256:[0-9a-f]{64}$/;
62
+ function isRecord(value) {
63
+ return typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date);
64
+ }
65
+ /**
66
+ * Absolute under POSIX or win32 rules, or carrying a backslash. Pure string checks (no
67
+ * `node:path`) so the verdict is the same on every host: `/x`, `\x`, `\\server\share`, `C:\x`,
68
+ * `C:/x` and the drive-relative `C:x` are all refused.
69
+ */
70
+ export function isNonPortableDependencyPath(value) {
71
+ return value.startsWith("/") || value.includes("\\") || /^[A-Za-z]:/.test(value);
72
+ }
73
+ function parsePin(value) {
74
+ if (typeof value !== "string")
75
+ return null;
76
+ if (COMMIT_PIN.test(value))
77
+ return { kind: "commit", value };
78
+ if (DIGEST_PIN.test(value))
79
+ return { kind: "digest", value };
80
+ return null;
81
+ }
82
+ /**
83
+ * Parse `docs/dependencies`. Never throws: every defect is a problem, and an entry whose alias,
84
+ * `bundle_id` or `pin` is unusable is dropped (fail closed: a link under it reads as
85
+ * `unknown_alias`, never as resolved against the wrong copy). An unusable `source` or `path` drops
86
+ * only that field. Unknown and reserved keys are reported and the entry is kept.
87
+ */
88
+ export function parseDependencies(doc, options = {}) {
89
+ const dependencies = new Map();
90
+ const problems = [];
91
+ const rejected = new Map();
92
+ const result = () => ({ dependencies, problems, rejected });
93
+ const reject = (alias, code, detail) => {
94
+ problems.push({ code, alias, detail });
95
+ rejected.set(alias, code);
96
+ };
97
+ if (!doc)
98
+ return result();
99
+ const type = doc.frontmatter.type;
100
+ if (typeof type !== "string" || type.trim() !== DEPENDENCIES_DOC_TYPE) {
101
+ problems.push({ code: "DEP_TYPE", detail: `type must be '${DEPENDENCIES_DOC_TYPE}'` });
102
+ return result();
103
+ }
104
+ const declared = doc.frontmatter.dependencies;
105
+ if (declared === undefined || declared === null)
106
+ return result();
107
+ if (!isRecord(declared)) {
108
+ problems.push({ code: "DEP_SHAPE", detail: "dependencies must be a mapping of alias to entry" });
109
+ return result();
110
+ }
111
+ const aliasByBundle = new Map();
112
+ for (const [alias, raw] of Object.entries(declared)) {
113
+ if (!isBundleAlias(alias)) {
114
+ problems.push({ code: "DEP_ALIAS", alias, detail: "alias must match ^[a-z][a-z0-9-]{0,62}$" });
115
+ continue;
116
+ }
117
+ if (!isRecord(raw)) {
118
+ reject(alias, "DEP_SHAPE", "entry must be a mapping");
119
+ continue;
120
+ }
121
+ const bundleId = raw.bundle_id;
122
+ if (typeof bundleId !== "string" || !isHostedBundleId(bundleId)) {
123
+ reject(alias, "DEP_BUNDLE_ID", "bundle_id is required and must be a portable bundle id");
124
+ continue;
125
+ }
126
+ let pin;
127
+ if (raw.pin !== undefined) {
128
+ const parsed = parsePin(raw.pin);
129
+ if (parsed === null) {
130
+ // A YAML scalar such as 1234567 or 3e45678 arrives as a number, so the hint says to quote.
131
+ reject(alias, "DEP_PIN", "pin must be a quoted commit (7-40 lower-case hex) or sha256:<64 lower-case hex>");
132
+ continue;
133
+ }
134
+ pin = parsed;
135
+ }
136
+ if (options.selfBundleId !== undefined && bundleId === options.selfBundleId) {
137
+ reject(alias, "DEP_SELF", `bundle_id '${bundleId}' is this bundle`);
138
+ continue;
139
+ }
140
+ const earlier = aliasByBundle.get(bundleId);
141
+ if (earlier !== undefined) {
142
+ reject(alias, "DEP_DUPLICATE_BUNDLE", `bundle_id '${bundleId}' is already declared as '${earlier}'`);
143
+ continue;
144
+ }
145
+ const entry = { alias, bundle_id: bundleId };
146
+ if (raw.source !== undefined) {
147
+ if (typeof raw.source === "string" && raw.source.trim() !== "")
148
+ entry.source = raw.source;
149
+ else
150
+ problems.push({ code: "DEP_SHAPE", alias, detail: "source must be a non-empty string" });
151
+ }
152
+ if (pin)
153
+ entry.pin = pin;
154
+ if (raw.path !== undefined) {
155
+ if (typeof raw.path !== "string" || raw.path.trim() === "") {
156
+ problems.push({ code: "DEP_SHAPE", alias, detail: "path must be a non-empty string" });
157
+ }
158
+ else if (isNonPortableDependencyPath(raw.path)) {
159
+ problems.push({ code: "DEP_PATH_ABSOLUTE", alias, detail: "path must be relative to this bundle's root, with '/' separators" });
160
+ }
161
+ else {
162
+ entry.path = raw.path;
163
+ }
164
+ }
165
+ for (const key of Object.keys(raw)) {
166
+ if (KNOWN_KEYS.has(key))
167
+ continue;
168
+ if (RESERVED_KEYS.has(key)) {
169
+ problems.push({ code: "DEP_RESERVED_KEY", alias, detail: `'${key}' is reserved for recipe dependencies` });
170
+ }
171
+ else {
172
+ problems.push({ code: "DEP_UNKNOWN_KEY", alias, detail: `unknown key '${key}'` });
173
+ }
174
+ }
175
+ aliasByBundle.set(bundleId, alias);
176
+ dependencies.set(alias, entry);
177
+ }
178
+ return result();
179
+ }
180
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,+EAA+E;AAE/E,iGAAiG;AACjG,mGAAmG;AACnG,6FAA6F;AAC7F,y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Aa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC3B,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAG,uCAAuC,EAAE,CAAC,CAAC;YAC7G,CAAC;iBAAM,CAAC;gBACN,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,EAAE,gBAAgB,GAAG,GAAG,EAAE,CAAC,CAAC;YACpF,CAAC;QACH,CAAC;QAED,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QACnC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,MAAM,EAAE,CAAC;AAClB,CAAC"}
@@ -5,8 +5,13 @@
5
5
  */
6
6
  export { parseMarkdown, stringifyDoc, stringifyWithData, normalizeDocumentBodyForStorage, MalformedDocumentError, } from "./frontmatter.js";
7
7
  export { resolveContentType } from "./content-type.js";
8
+ export { captureRemoteFrontmatter, RemoteDocumentValueError } from "./remote-document-codec.js";
8
9
  export type { Frontmatter, OkfDocument, Version } from "./types.js";
9
10
  import type { Version } from "./types.js";
10
- /** SHA-256 version of exact bytes, including binary data, using Web Crypto. */
11
+ /**
12
+ * SHA-256 version of exact bytes, including binary data. Minted by the same pure
13
+ * implementation as every other version token, so one digest owner serves Node and
14
+ * browser runtimes; the async signature is kept for the codec's existing callers.
15
+ */
11
16
  export declare function versionFromBytes(bytes: Uint8Array): Promise<Version>;
12
17
  //# sourceMappingURL=document-codec.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-codec.d.ts","sourceRoot":"","sources":["../src/document-codec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,+EAA+E;AAC/E,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAI1E"}
1
+ {"version":3,"file":"document-codec.d.ts","sourceRoot":"","sources":["../src/document-codec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAChG,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,CAE1E"}
@@ -5,10 +5,14 @@
5
5
  */
6
6
  export { parseMarkdown, stringifyDoc, stringifyWithData, normalizeDocumentBodyForStorage, MalformedDocumentError, } from "./frontmatter.js";
7
7
  export { resolveContentType } from "./content-type.js";
8
- /** SHA-256 version of exact bytes, including binary data, using Web Crypto. */
8
+ export { captureRemoteFrontmatter, RemoteDocumentValueError } from "./remote-document-codec.js";
9
+ import { sha256HexOfBytes } from "./sha256.js";
10
+ /**
11
+ * SHA-256 version of exact bytes, including binary data. Minted by the same pure
12
+ * implementation as every other version token, so one digest owner serves Node and
13
+ * browser runtimes; the async signature is kept for the codec's existing callers.
14
+ */
9
15
  export async function versionFromBytes(bytes) {
10
- const digest = await globalThis.crypto.subtle.digest("SHA-256", new Uint8Array(bytes).buffer);
11
- const hex = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
12
- return `sha256:${hex}`;
16
+ return `sha256:${sha256HexOfBytes(bytes)}`;
13
17
  }
14
18
  //# sourceMappingURL=document-codec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"document-codec.js","sourceRoot":"","sources":["../src/document-codec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAKvD,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAiB;IACtD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;IAC9F,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtG,OAAO,UAAU,GAAG,EAAE,CAAC;AACzB,CAAC"}
1
+ {"version":3,"file":"document-codec.js","sourceRoot":"","sources":["../src/document-codec.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,+BAA+B,EAC/B,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAGhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/C;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAiB;IACtD,OAAO,UAAU,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;AAC7C,CAAC"}
@@ -1,4 +1,3 @@
1
- /** Explicit frontmatter intent. Collection construction is owned here, before CAS metadata. */
2
1
  import { InvalidInputError } from "./errors.js";
3
2
  import { type KindRegistry } from "./kinds.js";
4
3
  import type { Frontmatter, OkfDocument } from "./types.js";
@@ -38,6 +37,14 @@ export type FieldAction = {
38
37
  action: "set";
39
38
  field: string;
40
39
  value: unknown;
40
+ }
41
+ /**
42
+ * Remove one field: any field `set` admits apart from `type` and the fields the document's Kind
43
+ * requires (refused with that Kind's `KIND_FIELD_MISSING`). A no-op when the field is absent.
44
+ */
45
+ | {
46
+ action: "unset";
47
+ field: string;
41
48
  } | {
42
49
  action: "add";
43
50
  field: "tags";
@@ -59,6 +66,19 @@ export type FieldAction = {
59
66
  field: "sources";
60
67
  selector: SourceSelector;
61
68
  patch: Record<string, unknown>;
69
+ }
70
+ /**
71
+ * Select the one entry whose (`resource`, `id`) pair equals the value's, by the shared
72
+ * `sources[]` identity rule, and merge the value's properties into it; append the value when
73
+ * no entry carries the pair. The ID must be nonempty because an upsert may mint it, and it
74
+ * may not already name an entry under another resource.
75
+ */
76
+ | {
77
+ action: "upsert";
78
+ field: "sources";
79
+ value: SourceEntry & {
80
+ id: string;
81
+ };
62
82
  } | {
63
83
  action: "replace-all";
64
84
  field: "tags";
@@ -67,6 +87,16 @@ export type FieldAction = {
67
87
  action: "replace-all";
68
88
  field: "sources";
69
89
  value: SourceEntry[];
90
+ }
91
+ /**
92
+ * The complete list of a field the document's Kind declares as `string-list` or `https-url-list`,
93
+ * kept in the given order: a Kind cannot say whether its list is a set, so ordering and
94
+ * deduplication belong to the caller (the Kind's type check refuses repeats on a strict write).
95
+ */
96
+ | {
97
+ action: "replace-all";
98
+ field: string;
99
+ value: string[];
70
100
  };
71
101
  export interface FieldActionScope {
72
102
  field: string;
@@ -1 +1 @@
1
- {"version":3,"file":"document-field-actions.d.ts","sourceRoot":"","sources":["../src/document-field-actions.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAmD,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAExE,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AACjG,MAAM,WAAW,uBAAuB;IAAG,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE;AAC3F,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,kBAAkB,GAAG,eAAe,GAAG,kBAAkB,GAAG,oBAAoB,GAAG,mBAAmB,GAAG,uBAAuB,CAAC;IACzI,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,mBAAmB,CAAC,EAAE,cAAc,CAAC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AA2B,CAwJ/I"}
@@ -1,7 +1,11 @@
1
+ import { assertTypedListPatch } from "./body-replace-guards.js";
1
2
  /** Explicit frontmatter intent. Collection construction is owned here, before CAS metadata. */
3
+ import { isManagedDocumentMetadataField } from "./managed-document-metadata.js";
2
4
  import { InvalidInputError } from "./errors.js";
3
5
  import { okfValuesEqual } from "./okf-authored-values.js";
4
- import { kindInputFieldNames, resolveKindFieldCoordinate } from "./kinds.js";
6
+ import { KindConformanceError } from "./kind-conformance-error.js";
7
+ import { isKindListField, kindInputFieldNames, resolveKindFieldCoordinate, validateAgainstKind } from "./kinds.js";
8
+ import { matchesSourceIdentity } from "./query-filter.js";
5
9
  /** Adapters can render corrective commands without parsing prose or repeating selection. */
6
10
  export class FieldActionError extends InvalidInputError {
7
11
  details;
@@ -11,7 +15,6 @@ export class FieldActionError extends InvalidInputError {
11
15
  this.details = details;
12
16
  }
13
17
  }
14
- const managed = new Set(["generated", "verified", "superbee_updated_by", "actor", "timestamp"]);
15
18
  const standard = new Set(["title", "description", "type", "resource"]);
16
19
  const v02 = new Set(["status", "stale_after", "usage_window"]);
17
20
  export function isStandardDocumentSetField(field, okfVersion) {
@@ -52,7 +55,7 @@ export function assertOrdinaryPatch(existing, proposed) {
52
55
  }
53
56
  }
54
57
  function assertAssignmentName(field) {
55
- if (managed.has(field))
58
+ if (isManagedDocumentMetadataField(field))
56
59
  throw new InvalidInputError(`'${field}' is managed metadata and cannot be assigned by a field action.`);
57
60
  if (field === "tags" || field === "sources")
58
61
  throw new InvalidInputError(`'${field}' requires an explicit collection add/remove/replace-all action.`);
@@ -106,54 +109,114 @@ function selectorIndex(rows, selector, edit) {
106
109
  }
107
110
  return index;
108
111
  }
112
+ /**
113
+ * The field `set` (and `unset`) may name on this document, resolved to its storage name: a standard
114
+ * set field of the edition or a field the document's Kind declares. Anything else is
115
+ * `unsupported-set-field`, listing what the action would accept.
116
+ */
117
+ function admittedField(existing, field, context, action) {
118
+ const kind = context.registry.kinds.get(String(existing.frontmatter.type)) ?? undefined;
119
+ const coordinate = kind && resolveKindFieldCoordinate(context.okfVersion, kind, field);
120
+ if (context.okfVersion === "0.1" && (field === "stale_after" || field === "usage_window"))
121
+ throw new InvalidInputError(`'${field}' requires OKF v0.2.`);
122
+ if (!isStandardDocumentSetField(field, context.okfVersion) && !coordinate) {
123
+ const supportedFields = [...new Set([
124
+ ...standard,
125
+ ...(context.okfVersion === "0.2" ? v02 : []),
126
+ ...(kind ? kindInputFieldNames(context.okfVersion, kind) : []),
127
+ ])].filter(name => {
128
+ if (isManagedDocumentMetadataField(name) || name === "tags" || name === "sources")
129
+ return false;
130
+ if (context.okfVersion === "0.1" && (name === "stale_after" || name === "usage_window"))
131
+ return false;
132
+ const storage = kind && resolveKindFieldCoordinate(context.okfVersion, kind, name);
133
+ if (action === "unset")
134
+ return name !== "type" && !(kind && kind.fields.required.includes(storage?.storageField ?? name));
135
+ return !containsCollection(existing.frontmatter[storage?.storageField ?? name]);
136
+ }).sort();
137
+ throw new FieldActionError(`Unsupported ${action} field '${field}'; supported fields: ${supportedFields.join(", ")}.`, {
138
+ reason: "unsupported-set-field", field, supportedFields,
139
+ });
140
+ }
141
+ return { kind, storageField: coordinate?.storageField ?? field };
142
+ }
143
+ const timestampFor = (context) => (context.now ?? (() => new Date().toISOString()))();
109
144
  export function prepareDocumentFieldAction(existing, action, context) {
110
145
  if (!record(action) || typeof action.field !== "string")
111
146
  throw new InvalidInputError("A field action requires a field name.");
112
- if (action.action === "set")
147
+ if (action.action === "set" || action.action === "unset")
113
148
  assertAssignmentName(action.field);
114
149
  const keys = action.action === "edit" ? ["action", "field", "selector", "patch"]
115
150
  : action.action === "remove" && action.field === "sources" ? ["action", "field", "selector"]
116
- : ["action", "field", "value"];
151
+ : action.action === "unset" ? ["action", "field"]
152
+ : ["action", "field", "value"];
117
153
  if (Object.keys(action).some(key => !keys.includes(key)) || keys.some(key => !has(action, key)))
118
154
  throw new InvalidInputError("Field action has missing or incompatible input properties.");
119
155
  if ("value" in action && action.value === undefined)
120
- throw new InvalidInputError("A field action value must be supplied; removing a field is not supported.");
156
+ throw new InvalidInputError("A field action value must be supplied; remove a field with unset.");
121
157
  let storageField = action.field;
122
158
  let candidate = { frontmatter: structuredClone(existing.frontmatter), body: existing.body };
123
159
  const scope = { field: action.field, action: action.action, outcome: "unchanged" };
124
160
  if (action.action === "set") {
125
- const kind = context.registry.kinds.get(String(existing.frontmatter.type));
126
- const coordinate = kind && resolveKindFieldCoordinate(context.okfVersion, kind, action.field);
127
- if (context.okfVersion === "0.1" && (action.field === "stale_after" || action.field === "usage_window"))
128
- throw new InvalidInputError(`'${action.field}' requires OKF v0.2.`);
129
- if (!isStandardDocumentSetField(action.field, context.okfVersion) && !coordinate) {
130
- const supportedFields = [...new Set([
131
- ...standard,
132
- ...(context.okfVersion === "0.2" ? v02 : []),
133
- ...(kind ? kindInputFieldNames(context.okfVersion, kind) : []),
134
- ])].filter(field => {
135
- if (managed.has(field) || field === "tags" || field === "sources")
136
- return false;
137
- if (context.okfVersion === "0.1" && (field === "stale_after" || field === "usage_window"))
138
- return false;
139
- const storage = kind && resolveKindFieldCoordinate(context.okfVersion, kind, field);
140
- return !containsCollection(existing.frontmatter[storage?.storageField ?? field]);
141
- }).sort();
142
- throw new FieldActionError(`Unsupported set field '${action.field}'; supported fields: ${supportedFields.join(", ")}.`, {
143
- reason: "unsupported-set-field", field: action.field, supportedFields,
144
- });
145
- }
146
- storageField = coordinate?.storageField ?? action.field;
161
+ const admitted = admittedField(existing, action.field, context, "set");
162
+ storageField = admitted.storageField;
163
+ if (admitted.kind)
164
+ assertTypedListPatch(admitted.kind, storageField);
147
165
  candidate = prepareDocumentAssignments(existing, { [storageField]: action.value });
148
166
  if (!okfValuesEqual(existing.frontmatter[storageField], action.value))
149
167
  scope.outcome = "edited";
150
168
  if (scope.outcome !== "unchanged" && context.okfVersion === "0.1")
151
- candidate.frontmatter.timestamp = (context.now ?? (() => new Date().toISOString()))();
169
+ candidate.frontmatter.timestamp = timestampFor(context);
170
+ return { candidate, scope, storageField };
171
+ }
172
+ const prototypeName = () => { throw new InvalidInputError("'__proto__' is not a writable frontmatter field."); };
173
+ if (action.action === "unset") {
174
+ if (action.field === "__proto__")
175
+ prototypeName();
176
+ if (action.field === "type")
177
+ throw new InvalidInputError("'type' cannot be removed; a document keeps its type.");
178
+ const admitted = admittedField(existing, action.field, context, "unset");
179
+ storageField = admitted.storageField;
180
+ const fields = candidate.frontmatter;
181
+ if (has(fields, storageField)) {
182
+ delete fields[storageField];
183
+ scope.outcome = "removed";
184
+ }
185
+ const kind = admitted.kind;
186
+ if (kind && kind.fields.required.includes(storageField)) {
187
+ // The Kind's own finding for the candidate, so every consumer reads the code it already maps.
188
+ const missing = validateAgainstKind({ id: existing.id, ...candidate }, kind).filter(warning => warning.code === "KIND_FIELD_MISSING" && warning.field === storageField);
189
+ throw new KindConformanceError(existing.id, kind.governs, missing, context.okfVersion);
190
+ }
191
+ if (scope.outcome !== "unchanged" && context.okfVersion === "0.1")
192
+ candidate.frontmatter.timestamp = timestampFor(context);
193
+ return { candidate, scope, storageField };
194
+ }
195
+ if (action.action === "replace-all" && action.field !== "tags" && action.field !== "sources") {
196
+ if (action.field === "__proto__")
197
+ prototypeName();
198
+ const kind = context.registry.kinds.get(String(existing.frontmatter.type)) ?? undefined;
199
+ const coordinate = kind && resolveKindFieldCoordinate(context.okfVersion, kind, action.field);
200
+ if (isManagedDocumentMetadataField(action.field) || isStandardDocumentSetField(action.field, context.okfVersion) || !coordinate || !isKindListField(kind, coordinate.storageField)) {
201
+ throw new InvalidInputError(`replace-all supports tags, sources, and fields the document's Kind declares as string-list or https-url-list; '${action.field}' is none of these.`);
202
+ }
203
+ storageField = coordinate.storageField;
204
+ if (!Array.isArray(action.value))
205
+ throw new InvalidInputError("replace-all requires a complete list (including [] to empty it).");
206
+ if (action.value.some(member => typeof member !== "string"))
207
+ throw new InvalidInputError(`'${action.field}' must be a list of strings.`);
208
+ const rows = structuredClone(action.value);
209
+ if (!okfValuesEqual(existing.frontmatter[storageField], rows)) {
210
+ candidate.frontmatter[storageField] = rows;
211
+ scope.outcome = "replaced";
212
+ if (context.okfVersion === "0.1")
213
+ candidate.frontmatter.timestamp = timestampFor(context);
214
+ }
152
215
  return { candidate, scope, storageField };
153
216
  }
154
217
  if (action.field !== "tags" && action.field !== "sources")
155
- throw new InvalidInputError("Collection actions support only tags and sources.");
156
- if (!["add", "remove", "edit", "replace-all"].includes(action.action))
218
+ throw new InvalidInputError("add, remove and edit support only tags and sources; replace a Kind-declared list field whole with replace-all.");
219
+ if (!["add", "remove", "edit", "replace-all", "upsert"].includes(action.action))
157
220
  throw new InvalidInputError("Unknown field action.");
158
221
  if (action.field === "sources" && context.okfVersion !== "0.2")
159
222
  throw new InvalidInputError("sources actions require OKF v0.2.");
@@ -173,8 +236,8 @@ export function prepareDocumentFieldAction(existing, action, context) {
173
236
  throw new InvalidInputError(`'${action.field}' is not a list; repair it with version-guarded replace-all.`);
174
237
  rows = structuredClone(previous ?? []);
175
238
  if (action.field === "tags") {
176
- if (action.action === "edit")
177
- throw new InvalidInputError("tags supports add/remove/replace-all, not edit.");
239
+ if (["edit", "upsert"].includes(action.action))
240
+ throw new InvalidInputError(`tags supports add/remove/replace-all, not ${action.action}.`);
178
241
  if (typeof action.value !== "string")
179
242
  throw new InvalidInputError("A tag must be a string.");
180
243
  if (action.action === "add" && !rows.includes(action.value)) {
@@ -186,6 +249,46 @@ export function prepareDocumentFieldAction(existing, action, context) {
186
249
  scope.outcome = "removed";
187
250
  }
188
251
  }
252
+ else if (action.action === "upsert") {
253
+ sourceRow(action.value);
254
+ const value = action.value;
255
+ if (typeof value.id !== "string" || value.id.trim() === "")
256
+ throw new InvalidInputError("A source upsert requires a nonempty id.");
257
+ for (const [property, entry] of Object.entries(value)) {
258
+ if (entry === undefined)
259
+ throw new InvalidInputError("Source upsert properties must have values.");
260
+ if (containsCollection(entry))
261
+ throw new InvalidInputError(`Cannot assign source property '${property}': the new subtree contains a list. Use sources replace-all with an observed version.`);
262
+ }
263
+ const identity = { resource: value.resource, id: value.id };
264
+ const matches = rows.flatMap((row, index) => matchesSourceIdentity(row, identity) ? [index] : []);
265
+ if (matches.length > 1)
266
+ throw new FieldActionError(`Source identity is ambiguous (${matches.length} matches); repair duplicates with version-guarded replace-all.`, {
267
+ reason: "ambiguous-source", field: "sources", selector: { id: value.id }, ...sourceCandidates(matches.map(index => rows[index])),
268
+ });
269
+ scope.affectedSourceIds = [value.id];
270
+ if (matches.length === 1) {
271
+ const old = rows[matches[0]];
272
+ for (const property of Object.keys(value)) {
273
+ if (containsCollection(old[property]))
274
+ throw new InvalidInputError(`Cannot assign source property '${property}': the old subtree contains a list. Use sources replace-all with an observed version.`);
275
+ }
276
+ const next = { ...old, ...structuredClone(value) };
277
+ if (!okfValuesEqual(old, next)) {
278
+ rows[matches[0]] = next;
279
+ scope.outcome = "edited";
280
+ }
281
+ }
282
+ else {
283
+ const sameId = rows.filter(row => record(row) && row.id === value.id);
284
+ if (sameId.length > 0)
285
+ throw new FieldActionError(`Source ID '${value.id}' already names an entry under another resource; a document-local ID is never minted twice.`, {
286
+ reason: "source-id-conflict", field: "sources", selector: { id: value.id }, recommendedSelector: { id: value.id }, ...sourceCandidates(sameId),
287
+ });
288
+ rows.push(structuredClone(value));
289
+ scope.outcome = "added";
290
+ }
291
+ }
189
292
  else if (action.action === "add") {
190
293
  sourceRow(action.value);
191
294
  if (has(action.value, "id")) {
@@ -255,7 +358,7 @@ export function prepareDocumentFieldAction(existing, action, context) {
255
358
  scope.affectedSourceIds = [...new Set([...(Array.isArray(previous) ? previous : []), ...rows].flatMap(row => record(row) && typeof row.id === "string" ? [row.id] : []))];
256
359
  }
257
360
  if (scope.outcome !== "unchanged" && context.okfVersion === "0.1")
258
- candidate.frontmatter.timestamp = (context.now ?? (() => new Date().toISOString()))();
361
+ candidate.frontmatter.timestamp = timestampFor(context);
259
362
  return { candidate, scope, storageField };
260
363
  }
261
364
  //# sourceMappingURL=document-field-actions.js.map