@superbee/core 0.1.6 → 0.2.0-pre.10

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 (248) hide show
  1. package/README.md +127 -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 +16 -1
  7. package/dist/backend.d.ts.map +1 -1
  8. package/dist/backend.js +112 -47
  9. package/dist/backend.js.map +1 -1
  10. package/dist/bundle-ops.d.ts +42 -0
  11. package/dist/bundle-ops.d.ts.map +1 -0
  12. package/dist/bundle-ops.js +88 -0
  13. package/dist/bundle-ops.js.map +1 -0
  14. package/dist/bundle.d.ts +10 -28
  15. package/dist/bundle.d.ts.map +1 -1
  16. package/dist/bundle.js +12 -69
  17. package/dist/bundle.js.map +1 -1
  18. package/dist/document-codec.d.ts +6 -1
  19. package/dist/document-codec.d.ts.map +1 -1
  20. package/dist/document-codec.js +8 -4
  21. package/dist/document-codec.js.map +1 -1
  22. package/dist/document-field-actions.d.ts +107 -0
  23. package/dist/document-field-actions.d.ts.map +1 -0
  24. package/dist/document-field-actions.js +302 -0
  25. package/dist/document-field-actions.js.map +1 -0
  26. package/dist/document-mutation.d.ts +61 -3
  27. package/dist/document-mutation.d.ts.map +1 -1
  28. package/dist/document-mutation.js +116 -25
  29. package/dist/document-mutation.js.map +1 -1
  30. package/dist/document-write-policy.d.ts +0 -1
  31. package/dist/document-write-policy.d.ts.map +1 -1
  32. package/dist/document-write-policy.js +7 -4
  33. package/dist/document-write-policy.js.map +1 -1
  34. package/dist/engine.d.ts +3 -1
  35. package/dist/engine.d.ts.map +1 -1
  36. package/dist/engine.js +6 -4
  37. package/dist/engine.js.map +1 -1
  38. package/dist/file-journaled-backend-internal.d.ts +19 -0
  39. package/dist/file-journaled-backend-internal.d.ts.map +1 -0
  40. package/dist/file-journaled-backend-internal.js +10 -0
  41. package/dist/file-journaled-backend-internal.js.map +1 -0
  42. package/dist/file-journaled-backend.d.ts +162 -0
  43. package/dist/file-journaled-backend.d.ts.map +1 -0
  44. package/dist/file-journaled-backend.js +1113 -0
  45. package/dist/file-journaled-backend.js.map +1 -0
  46. package/dist/filesystem-host.d.ts +15 -0
  47. package/dist/filesystem-host.d.ts.map +1 -0
  48. package/dist/filesystem-host.js +20 -0
  49. package/dist/filesystem-host.js.map +1 -0
  50. package/dist/filesystem-identity.d.ts +86 -4
  51. package/dist/filesystem-identity.d.ts.map +1 -1
  52. package/dist/filesystem-identity.js +338 -102
  53. package/dist/filesystem-identity.js.map +1 -1
  54. package/dist/filesystem-lock.d.ts +16 -3
  55. package/dist/filesystem-lock.d.ts.map +1 -1
  56. package/dist/filesystem-lock.js +323 -77
  57. package/dist/filesystem-lock.js.map +1 -1
  58. package/dist/filesystem-push-role.d.ts +77 -0
  59. package/dist/filesystem-push-role.d.ts.map +1 -0
  60. package/dist/filesystem-push-role.js +165 -0
  61. package/dist/filesystem-push-role.js.map +1 -0
  62. package/dist/filesystem.d.ts +17 -0
  63. package/dist/filesystem.d.ts.map +1 -0
  64. package/dist/filesystem.js +18 -0
  65. package/dist/filesystem.js.map +1 -0
  66. package/dist/freshness.d.ts +10 -7
  67. package/dist/freshness.d.ts.map +1 -1
  68. package/dist/freshness.js +14 -11
  69. package/dist/freshness.js.map +1 -1
  70. package/dist/frontmatter-contract.d.ts +2 -2
  71. package/dist/frontmatter-contract.js +2 -2
  72. package/dist/frontmatter.d.ts +11 -1
  73. package/dist/frontmatter.d.ts.map +1 -1
  74. package/dist/frontmatter.js +20 -7
  75. package/dist/frontmatter.js.map +1 -1
  76. package/dist/governed-body-write.d.ts +106 -0
  77. package/dist/governed-body-write.d.ts.map +1 -0
  78. package/dist/governed-body-write.js +251 -0
  79. package/dist/governed-body-write.js.map +1 -0
  80. package/dist/heads-digest.d.ts +32 -0
  81. package/dist/heads-digest.d.ts.map +1 -0
  82. package/dist/heads-digest.js +37 -0
  83. package/dist/heads-digest.js.map +1 -0
  84. package/dist/host-policy-snapshot.d.ts +9 -0
  85. package/dist/host-policy-snapshot.d.ts.map +1 -0
  86. package/dist/host-policy-snapshot.js +33 -0
  87. package/dist/host-policy-snapshot.js.map +1 -0
  88. package/dist/host-text.d.ts +31 -0
  89. package/dist/host-text.d.ts.map +1 -0
  90. package/dist/host-text.js +77 -0
  91. package/dist/host-text.js.map +1 -0
  92. package/dist/hosted-transport/answer-rows.d.ts +216 -0
  93. package/dist/hosted-transport/answer-rows.d.ts.map +1 -0
  94. package/dist/hosted-transport/answer-rows.js +396 -0
  95. package/dist/hosted-transport/answer-rows.js.map +1 -0
  96. package/dist/hosted-transport/carrier.d.ts +142 -0
  97. package/dist/hosted-transport/carrier.d.ts.map +1 -0
  98. package/dist/hosted-transport/carrier.js +241 -0
  99. package/dist/hosted-transport/carrier.js.map +1 -0
  100. package/dist/hosted-transport/history-pages.d.ts +55 -0
  101. package/dist/hosted-transport/history-pages.d.ts.map +1 -0
  102. package/dist/hosted-transport/history-pages.js +69 -0
  103. package/dist/hosted-transport/history-pages.js.map +1 -0
  104. package/dist/hosted-transport/index.d.ts +18 -0
  105. package/dist/hosted-transport/index.d.ts.map +1 -0
  106. package/dist/hosted-transport/index.js +18 -0
  107. package/dist/hosted-transport/index.js.map +1 -0
  108. package/dist/hosted-transport/operations.d.ts +85 -0
  109. package/dist/hosted-transport/operations.d.ts.map +1 -0
  110. package/dist/hosted-transport/operations.js +128 -0
  111. package/dist/hosted-transport/operations.js.map +1 -0
  112. package/dist/hosted-transport/paged-reads.d.ts +87 -0
  113. package/dist/hosted-transport/paged-reads.d.ts.map +1 -0
  114. package/dist/hosted-transport/paged-reads.js +238 -0
  115. package/dist/hosted-transport/paged-reads.js.map +1 -0
  116. package/dist/hosted-transport/read-adapter.d.ts +250 -0
  117. package/dist/hosted-transport/read-adapter.d.ts.map +1 -0
  118. package/dist/hosted-transport/read-adapter.js +557 -0
  119. package/dist/hosted-transport/read-adapter.js.map +1 -0
  120. package/dist/hosted-transport/root-write.d.ts +114 -0
  121. package/dist/hosted-transport/root-write.d.ts.map +1 -0
  122. package/dist/hosted-transport/root-write.js +171 -0
  123. package/dist/hosted-transport/root-write.js.map +1 -0
  124. package/dist/hosted-transport/whole-document-transport.d.ts +174 -0
  125. package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -0
  126. package/dist/hosted-transport/whole-document-transport.js +411 -0
  127. package/dist/hosted-transport/whole-document-transport.js.map +1 -0
  128. package/dist/index.d.ts +29 -8
  129. package/dist/index.d.ts.map +1 -1
  130. package/dist/index.js +26 -6
  131. package/dist/index.js.map +1 -1
  132. package/dist/indexeddb-backend.d.ts +197 -0
  133. package/dist/indexeddb-backend.d.ts.map +1 -0
  134. package/dist/indexeddb-backend.js +1183 -0
  135. package/dist/indexeddb-backend.js.map +1 -0
  136. package/dist/journaled-backend.d.ts +467 -0
  137. package/dist/journaled-backend.d.ts.map +1 -0
  138. package/dist/journaled-backend.js +389 -0
  139. package/dist/journaled-backend.js.map +1 -0
  140. package/dist/kind-coverage.d.ts +99 -0
  141. package/dist/kind-coverage.d.ts.map +1 -0
  142. package/dist/kind-coverage.js +186 -0
  143. package/dist/kind-coverage.js.map +1 -0
  144. package/dist/kind-field-mutation.d.ts +15 -0
  145. package/dist/kind-field-mutation.d.ts.map +1 -0
  146. package/dist/kind-field-mutation.js +160 -0
  147. package/dist/kind-field-mutation.js.map +1 -0
  148. package/dist/kinds.d.ts +31 -1
  149. package/dist/kinds.d.ts.map +1 -1
  150. package/dist/kinds.js +86 -17
  151. package/dist/kinds.js.map +1 -1
  152. package/dist/links.d.ts +1 -1
  153. package/dist/links.d.ts.map +1 -1
  154. package/dist/links.js +5 -10
  155. package/dist/links.js.map +1 -1
  156. package/dist/managed-document-metadata.d.ts +2 -0
  157. package/dist/managed-document-metadata.d.ts.map +1 -0
  158. package/dist/managed-document-metadata.js +9 -0
  159. package/dist/managed-document-metadata.js.map +1 -0
  160. package/dist/meaningful-change-time.d.ts +6 -6
  161. package/dist/meaningful-change-time.d.ts.map +1 -1
  162. package/dist/meaningful-change-time.js +12 -13
  163. package/dist/meaningful-change-time.js.map +1 -1
  164. package/dist/memory-backend.d.ts +2 -2
  165. package/dist/memory-backend.d.ts.map +1 -1
  166. package/dist/memory-backend.js +32 -16
  167. package/dist/memory-backend.js.map +1 -1
  168. package/dist/mutation.d.ts.map +1 -1
  169. package/dist/mutation.js +2 -2
  170. package/dist/mutation.js.map +1 -1
  171. package/dist/page.d.ts.map +1 -1
  172. package/dist/page.js +2 -1
  173. package/dist/page.js.map +1 -1
  174. package/dist/paths.d.ts +6 -2
  175. package/dist/paths.d.ts.map +1 -1
  176. package/dist/paths.js +35 -33
  177. package/dist/paths.js.map +1 -1
  178. package/dist/platform.d.ts +239 -0
  179. package/dist/platform.d.ts.map +1 -0
  180. package/dist/platform.js +82 -0
  181. package/dist/platform.js.map +1 -0
  182. package/dist/portable-export.d.ts +119 -0
  183. package/dist/portable-export.d.ts.map +1 -0
  184. package/dist/portable-export.js +501 -0
  185. package/dist/portable-export.js.map +1 -0
  186. package/dist/publication-filesystem.d.ts +1 -1
  187. package/dist/publication-filesystem.d.ts.map +1 -1
  188. package/dist/publication-filesystem.js +1 -1
  189. package/dist/publication-filesystem.js.map +1 -1
  190. package/dist/query-filter.d.ts +7 -2
  191. package/dist/query-filter.d.ts.map +1 -1
  192. package/dist/query-filter.js +24 -1
  193. package/dist/query-filter.js.map +1 -1
  194. package/dist/query-order.d.ts +22 -0
  195. package/dist/query-order.d.ts.map +1 -0
  196. package/dist/query-order.js +42 -0
  197. package/dist/query-order.js.map +1 -0
  198. package/dist/recipes.d.ts +3 -1
  199. package/dist/recipes.d.ts.map +1 -1
  200. package/dist/recipes.js +4 -4
  201. package/dist/recipes.js.map +1 -1
  202. package/dist/remote-backend.d.ts +114 -22
  203. package/dist/remote-backend.d.ts.map +1 -1
  204. package/dist/remote-backend.js +285 -44
  205. package/dist/remote-backend.js.map +1 -1
  206. package/dist/remote-document-codec.d.ts +15 -0
  207. package/dist/remote-document-codec.d.ts.map +1 -0
  208. package/dist/remote-document-codec.js +103 -0
  209. package/dist/remote-document-codec.js.map +1 -0
  210. package/dist/remote-error.d.ts +38 -0
  211. package/dist/remote-error.d.ts.map +1 -0
  212. package/dist/remote-error.js +59 -0
  213. package/dist/remote-error.js.map +1 -0
  214. package/dist/remote-operations.d.ts +63 -0
  215. package/dist/remote-operations.d.ts.map +1 -0
  216. package/dist/remote-operations.js +125 -0
  217. package/dist/remote-operations.js.map +1 -0
  218. package/dist/remote-parsers.d.ts +86 -0
  219. package/dist/remote-parsers.d.ts.map +1 -0
  220. package/dist/remote-parsers.js +181 -0
  221. package/dist/remote-parsers.js.map +1 -0
  222. package/dist/remote.d.ts +7 -2
  223. package/dist/remote.d.ts.map +1 -1
  224. package/dist/remote.js +6 -1
  225. package/dist/remote.js.map +1 -1
  226. package/dist/sha256.d.ts +21 -0
  227. package/dist/sha256.d.ts.map +1 -0
  228. package/dist/sha256.js +114 -0
  229. package/dist/sha256.js.map +1 -0
  230. package/dist/storage.d.ts +8 -2
  231. package/dist/storage.d.ts.map +1 -1
  232. package/dist/storage.js +11 -2
  233. package/dist/storage.js.map +1 -1
  234. package/dist/types.d.ts +40 -5
  235. package/dist/types.d.ts.map +1 -1
  236. package/dist/uncertain-write.d.ts +178 -0
  237. package/dist/uncertain-write.d.ts.map +1 -0
  238. package/dist/uncertain-write.js +198 -0
  239. package/dist/uncertain-write.js.map +1 -0
  240. package/dist/version-transport.d.ts +7 -0
  241. package/dist/version-transport.d.ts.map +1 -1
  242. package/dist/version-transport.js +9 -0
  243. package/dist/version-transport.js.map +1 -1
  244. package/dist/versioning.d.ts +18 -7
  245. package/dist/versioning.d.ts.map +1 -1
  246. package/dist/versioning.js +23 -14
  247. package/dist/versioning.js.map +1 -1
  248. package/package.json +75 -4
package/dist/index.js CHANGED
@@ -41,6 +41,9 @@ export { deleteDoc, deleteBlob } from "./bundle.js";
41
41
  // `pull`) route through ONLY these, never a backend directly.
42
42
  export { readBlob, writeBlob, existsBlob, listBlobs } from "./bundle.js";
43
43
  export { freshness, staleAfterInstant } from "./freshness.js";
44
+ export { escapeHostJson, stripHostControls, stripHostData, stripHostText } from "./host-text.js";
45
+ // The one equality for OKF frontmatter values: what the write policy treats as unchanged.
46
+ export { okfValuesEqual } from "./okf-authored-values.js";
44
47
  // OKF v0.2 trust: the one actor grammar and the one `verified` read/append policy every surface
45
48
  // (CLI receipts, status counts, list projection, the UI header) derives the trust tier through.
46
49
  export { OKF_ACTOR_FORMS, isOkfActor, isHumanActor, suggestOkfActor } from "./okf-actor.js";
@@ -50,7 +53,12 @@ export { TRUST_TIERS, TRUST_TIER_FIELD, appendVerificationEvent, latestVerifiedA
50
53
  // `MemoryBackend` implements the SAME contract for the hard case (real version chain,
51
54
  // enforced compare-and-swap, per-write actor) and proves the engine is backend-neutral.
52
55
  export { FilesystemBackend } from "./backend.js";
56
+ export { createFilesystemRuntime } from "./filesystem.js";
53
57
  export { MemoryBackend } from "./memory-backend.js";
58
+ // The journaled-backend seam (`journaled-backend.ts`): what an adapter adds to `StorageBackend`
59
+ // so a browser-local working copy's sync runtime can journal intents through it. The IndexedDB
60
+ // adapter implements it behind the `indexeddb-backend` subpath.
61
+ export { IntentHoldConflict, IntentStateConflict, JournalGuardConflict, captureJournalGuard } from "./journaled-backend.js";
54
62
  // Internal-workspace filesystem arbitration authority. CLI create-only policy reuses this
55
63
  // external same-user lock rather than defining a second lock protocol or writing claims into a
56
64
  // portable bundle tree.
@@ -59,12 +67,18 @@ export { withFilesystemMutationLock, FilesystemMutationLockError, filesystemMuta
59
67
  // (docs/WIRE-PROTOCOL.md) — a FUTURE plug-in adapter, proven here against the
60
68
  // in-repo reference server (`@superbee/server`) by the tri-backend contract
61
69
  // tests. No CF/D1/production deployment is implied by its presence.
62
- export { RemoteBackend, RemoteError } from "./remote-backend.js";
70
+ export { RemoteBackend } from "./remote-backend.js";
71
+ export { RemoteError, MalformedAnswer, MALFORMED_ANSWER, isMalformedAnswer } from "./remote-error.js";
72
+ export { SNAPSHOT_DIGEST_MISMATCH, SNAPSHOT_TRUNCATED, parseHeadsAnswer, readSnapshotStream } from "./remote-parsers.js";
73
+ export { headsDigest, isHeadsDigest, sortHeads } from "./heads-digest.js";
74
+ // The uncertain-write transport over `RemoteBackend`: identified document writes plus outcome
75
+ // lookup, the client side of the wire's request identity.
76
+ export { createRemoteOperationTransport, openRemoteOperationTransport, OperationsUnsupportedError } from "./remote-operations.js";
63
77
  // Versioning / attribution primitives shared by every adapter: the content-addressed
64
78
  // version token, a default actor, and the typed compare-and-swap conflict error.
65
79
  // `blobVersion` is the raw-bytes sibling of `contentVersion`/`versionOfBytes` (blobs
66
80
  // are hashed directly, never routed through a string/UTF-8 step).
67
- export { contentVersion, versionOfBytes, blobVersion, defaultActor, VersionConflict, stripETagWrapper, } from "./versioning.js";
81
+ export { contentVersion, versionOfBytes, blobVersion, defaultActor, VersionConflict, isContentVersion, stripETagWrapper, } from "./versioning.js";
68
82
  // The ONE versioned-mutation boundary: a shared read-decide-CAS-retry
69
83
  // primitive consumed by document, link, and index mutation policies instead of
70
84
  // independently hand-rolled loops.
@@ -84,14 +98,14 @@ export { list } from "./bundle.js";
84
98
  // (`readManyExisting`) is internal: its one-time export for the reference router was
85
99
  // withdrawn when the router switched to consuming `queryHeads` wholesale.
86
100
  export { queryHeads } from "./bundle.js";
87
- export { matchesFilter } from "./query-filter.js";
101
+ export { matchesFilter, matchesSourceIdentity, hasSourceIdentity } from "./query-filter.js";
88
102
  export { applyQuerySelectionFilters } from "./query-selection.js";
89
103
  // Portable, ownership-governed `index.md` projection. Raw reserved-file interop stays on the backend seam.
90
104
  export { GENERATED_INDEX_MARKER, IndexProjectionWriteError, planIndexProjection, prepareIndexProjection, applyIndexProjection, } from "./index-projection.js";
91
105
  // Pure, unit-testable path / link / note / freshness helpers.
92
- export { RESERVED_FILENAMES, isReservedFile, conceptIdFromPath, pathFromConceptId, assertSafeConceptId, assertSafeReservedDir, assertSafeBlobKey, toPosix, } from "./paths.js";
106
+ export { RESERVED_FILENAMES, isReservedFile, conceptIdFromPath, pathFromConceptId, assertSafeConceptId, assertSafeReservedDir, assertSafeReservedFilename, compareStorageKeys, assertSafeBlobKey, toPosix, } from "./paths.js";
93
107
  export { extractMarkdownLinks, resolveConceptId, relativeHref, parseLinksFromDoc, isExternalHref, } from "./links.js";
94
- export { parseTimestamp } from "./freshness.js";
108
+ export { parseTimestamp, invalidLegacyTimestamp } from "./freshness.js";
95
109
  export { SUPERBEE_UPDATED_BY_FIELD, mutationActorFromFrontmatter, persistMutationActor, } from "./mutation-attribution.js";
96
110
  export { parseMarkdown, stringifyDoc, stringifyWithData, normalizeDocumentBodyForStorage, isUsableTimestamp, MalformedDocumentError, } from "./frontmatter.js";
97
111
  // Typed input-validation rejection — consumer boundaries branch on the TYPE (CLI: USAGE/exit 2),
@@ -104,7 +118,7 @@ export { applyV02MutationMetadata } from "./document-write-policy.js";
104
118
  // registry — validation + per-kind freshness horizons, read from `Convention` docs under
105
119
  // `conventions/`. THE mechanism is core (one implementation, consumed by CLI/server/future
106
120
  // MCP); usage is opt-in per bundle. A conventions-free bundle is byte-for-byte unaffected.
107
- export { CONVENTIONS_PREFIX, CONVENTION_TYPE, PROGRESS_STATUS_FIELD, SUPERBEE_PROGRESS_STATUS_FIELD, RESERVED_KIND_FIELD_NAMES, progressStatusStorageField, progressStatusCoordinate, resolveKindFieldCoordinate, claimCoordinates, kindInputFieldNames, readKindField, projectLogicalKindFields, projectKindForAuthoring, projectKindValidationWarnings, validateAgainstKind, isPresent, defaultTimestampAndValidateAgainstRegistry, freshnessHorizonMs, kindConventionDoc, parseConventionDoc, buildKindRegistry, splitSections, isTerminal, } from "./kinds.js";
121
+ export { CONVENTIONS_PREFIX, CONVENTION_TYPE, isConventionId, PROGRESS_STATUS_FIELD, SUPERBEE_PROGRESS_STATUS_FIELD, RESERVED_KIND_FIELD_NAMES, progressStatusStorageField, progressStatusCoordinate, resolveKindFieldCoordinate, claimCoordinates, kindInputFieldNames, readKindField, projectLogicalKindFields, projectKindForAuthoring, projectKindValidationWarnings, isKindFieldValidationWarning, validateAgainstKind, isPresent, defaultTimestampAndValidateAgainstRegistry, freshnessHorizonMs, kindConventionDoc, parseConventionDoc, buildKindRegistry, compareReadingOrder, splitSections, isTerminal, } from "./kinds.js";
108
122
  export { loadKinds } from "./kinds-load.js";
109
123
  // Ported MIME utilities (holaxis-agentstate `packages/schemas/src/content-type.ts`).
110
124
  // `resolveContentType` is the ONE place a blob's content-type is resolved (explicit
@@ -113,4 +127,10 @@ export { loadKinds } from "./kinds-load.js";
113
127
  export { EXTENSION_CONTENT_TYPES, extensionOfDocKey, inferContentTypeFromDocKey, inferContentTypeForNewBlob, resolveContentType, DEFAULT_BLOB_CONTENT_TYPE, } from "./content-type.js";
114
128
  export { invalidOkfTimestamps, assertAuthoredOkfTimestamps } from "./okf-timestamps.js";
115
129
  export { isOkfLifecycleStatus, OKF_LIFECYCLE_STATUSES } from "./okf-lifecycle.js";
130
+ export { prepareDocumentFieldAction, isStandardDocumentSetField, FieldActionError } from "./document-field-actions.js";
131
+ export { prepareDocumentMutationCandidate } from "./document-mutation.js";
132
+ export { KindFieldMutationConflict, prepareKindFieldMutation } from "./kind-field-mutation.js";
133
+ export { BODY_DELIVERY_LIMITS, prepareBodyDelivery, validatePreparedBodyDelivery, assertSameBodyDelivery, validateBodyReceipt, performBodyDelivery, reconcileBodyReceipt, } from "./governed-body-write.js";
134
+ export { isManagedDocumentMetadataField } from "./managed-document-metadata.js";
135
+ export { kindCoverage } from "./kind-coverage.js";
116
136
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA0BH,iFAAiF;AACjF,OAAO,EACL,UAA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BAAwB,CAAC;AAC3I,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAA0B,MAAM,0BAA0B,CAAC;AACvH,OAAO,EACL,oBAAoB,EAAE,mBAAmB,EAAE,4BAA4B,EAAE,sBAAsB,EAC/F,mBAAmB,EAAE,mBAAmB,EAAE,oBAAoB,GAC/D,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAEhF,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,197 @@
1
+ /**
2
+ * IndexedDB-backed {@link JournaledBackend}: the browser-local working copy's first persistent
3
+ * store candidate, sitting behind the same core seam as {@link FilesystemBackend} and
4
+ * {@link MemoryBackend} and proven by the same adapter contract kit, plus the journal seam the
5
+ * sync runtime needs (`journaled-backend.ts`), proven by that kit's journal rows.
6
+ *
7
+ * Storage shape mirrors the filesystem adapter, not the memory adapter: a concept document is
8
+ * stored as its exact OKF-serialized string and parsed on every read, so the read body carries
9
+ * the serializer's normalization (the trailing newline) and the version token is
10
+ * `versionOfBytes(raw)` over the same bytes the disk copy would hold. Reserved files are stored
11
+ * as raw strings and blobs as raw bytes, both content-addressed with the shared primitives, so a
12
+ * document, reserved file, or blob carries one token on disk, in memory, and in the browser.
13
+ *
14
+ * Compare-and-swap is one IndexedDB readwrite transaction per mutation: the current record is
15
+ * read, compared, and replaced (or the transaction aborted with a {@link VersionConflict}) before
16
+ * the transaction commits. IndexedDB serializes readwrite transactions that overlap on a store,
17
+ * so two adapter instances (two tabs, two workers) over the same database cannot both win a
18
+ * conditional write. A write resolves only after the transaction's `complete` event, which is
19
+ * the point a local-save indicator may follow. That is a commit promise, not a power-loss
20
+ * promise: the browser decides when committed pages reach stable storage.
21
+ *
22
+ * Two further stores serve the working copy's synchronization: `intents` journals every local
23
+ * write as a pending-change intent committed in the same transaction as the document record
24
+ * ({@link IndexedDbBackend.writeJournaled}), and `meta` holds opaque key-value rows such as the
25
+ * bootstrap marker and per-document shared bases. The adapter owns the transaction mechanics;
26
+ * what the rows mean belongs to the sync component that writes them, and what the verbs
27
+ * promise is stated once on the seam.
28
+ *
29
+ * This module imports no Node builtin so it bundles for the browser; the IndexedDB factory is
30
+ * injectable so a Node test can supply an in-memory implementation without touching globals.
31
+ */
32
+ import { type IntentPatch, type IntentRecord, type IntentUpdateOptions, type MetaWriteOptions, type JournaledBackend, type JournaledDeleteOptions, type JournaledDeleteResult, type JournaledHead, type JournaledHeadsOptions, type JournaledReadResult, type JournaledWriteOptions, type RetireAcknowledgedOptions } from "./journaled-backend.js";
33
+ import type { OperationState } from "./uncertain-write.js";
34
+ import type { BlobKey, ConceptId, DeleteOptions, OkfDocument, ReadBlobResult, ReadResult, ReservedFilename, ReservedReadResult, StorageCapabilities, Version, VersionInfo, WriteOptions } from "./types.js";
35
+ export { IntentHoldConflict, IntentStateConflict } from "./journaled-backend.js";
36
+ export type { IntentPatch, IntentRecord, JournaledDeleteOptions, JournaledDeleteResult, JournaledHead, JournaledHeadsOptions, JournaledReadResult, JournaledWriteOptions, MetaRecord, NewIntentRecord } from "./journaled-backend.js";
37
+ type Handler = ((this: any, event: any) => any) | null;
38
+ export interface IdbRequestLike<T = unknown> {
39
+ readonly result: T;
40
+ readonly error: unknown;
41
+ onsuccess: Handler;
42
+ onerror: Handler;
43
+ }
44
+ export interface IdbOpenRequestLike extends IdbRequestLike<IdbDatabaseLike> {
45
+ onupgradeneeded: Handler;
46
+ onblocked: Handler;
47
+ readonly transaction: IdbTransactionLike | null;
48
+ }
49
+ /** A value cursor over a store, in key order; `continue` re-fires the opening request's `onsuccess`, with `null` once the store is walked. */
50
+ export interface IdbCursorLike {
51
+ readonly value: unknown;
52
+ continue(): void;
53
+ }
54
+ export interface IdbObjectStoreLike {
55
+ get(key: string): IdbRequestLike;
56
+ getAll(): IdbRequestLike<unknown[]>;
57
+ getAllKeys(): IdbRequestLike<unknown[]>;
58
+ count(key: string): IdbRequestLike<number>;
59
+ put(value: unknown): IdbRequestLike;
60
+ delete(key: string): IdbRequestLike;
61
+ openCursor(): IdbRequestLike<IdbCursorLike | null>;
62
+ }
63
+ export interface IdbTransactionLike {
64
+ objectStore(name: string): IdbObjectStoreLike;
65
+ abort(): void;
66
+ readonly error: unknown;
67
+ oncomplete: Handler;
68
+ onerror: Handler;
69
+ onabort: Handler;
70
+ }
71
+ export interface IdbDatabaseLike {
72
+ readonly version: number;
73
+ readonly objectStoreNames: {
74
+ contains(name: string): boolean;
75
+ readonly length: number;
76
+ };
77
+ createObjectStore(name: string, options?: {
78
+ keyPath?: string;
79
+ }): unknown;
80
+ transaction(storeNames: string | string[], mode?: "readonly" | "readwrite"): IdbTransactionLike;
81
+ close(): void;
82
+ onversionchange: Handler;
83
+ }
84
+ export interface IdbFactoryLike {
85
+ open(name: string, version?: number): IdbOpenRequestLike;
86
+ }
87
+ export interface IndexedDbBackendOptions {
88
+ /** The IndexedDB database holding this working copy; one bundle per database. */
89
+ databaseName: string;
90
+ /** The factory to open it with. Defaults to the host's global `indexedDB`. */
91
+ indexedDB?: IdbFactoryLike;
92
+ }
93
+ /** The database does not carry this adapter's schema and the adapter refuses to touch it. */
94
+ export declare class IndexedDbSchemaError extends Error {
95
+ readonly name = "IndexedDbSchemaError";
96
+ }
97
+ /** Bumping this requires a migration in `upgrade`; the handler refuses any other older layout. */
98
+ export declare const INDEXEDDB_SCHEMA_VERSION = 1;
99
+ /**
100
+ * A persistent browser-local OKF store implementing the {@link JournaledBackend} contract over
101
+ * IndexedDB. One instance per bundle per JavaScript realm; several instances over the same
102
+ * database name are peers whose conditional writes are serialized by the database.
103
+ */
104
+ export declare class IndexedDbBackend implements JournaledBackend {
105
+ #private;
106
+ readonly journalSnapshotCas: true;
107
+ /**
108
+ * What a resolved write promises: the IndexedDB transaction reported `complete`. Whether the
109
+ * committed pages survive power loss is the browser's and the operating system's decision.
110
+ */
111
+ readonly durability: "transaction-committed";
112
+ constructor(options: IndexedDbBackendOptions);
113
+ /** Whether an IndexedDB factory is reachable, so a caller can fall back to another store. */
114
+ static available(indexedDB?: IdbFactoryLike): boolean;
115
+ /** The database name this adapter opens. */
116
+ get databaseName(): string;
117
+ capabilities(): StorageCapabilities;
118
+ /** Release the database handle. The next operation reopens it lazily. */
119
+ close(): void;
120
+ read(id: ConceptId): Promise<ReadResult>;
121
+ readMany(ids: ConceptId[]): Promise<ReadResult[]>;
122
+ write(id: ConceptId, doc: OkfDocument, options?: WriteOptions): Promise<Version>;
123
+ delete(id: ConceptId, options?: DeleteOptions): Promise<boolean>;
124
+ exists(id: ConceptId): Promise<boolean>;
125
+ list(prefix?: string): Promise<ConceptId[]>;
126
+ versions(id: ConceptId): Promise<VersionInfo[]>;
127
+ readReserved(dir: string, name: ReservedFilename): Promise<ReservedReadResult | null>;
128
+ writeReserved(dir: string, name: ReservedFilename, content: string, options?: WriteOptions): Promise<Version>;
129
+ /**
130
+ * Remove acknowledged intents of one target and named meta rows in one transaction, after
131
+ * comparing the target's full guard in that same transaction.
132
+ */
133
+ retireAcknowledged(target: ConceptId, options: RetireAcknowledgedOptions): Promise<void>;
134
+ /**
135
+ * One transaction over documents, intents, and meta: the document compare-and-swap of
136
+ * {@link write}, plus (optionally) deleting a superseded intent, recording a new intent for
137
+ * the written bytes, and putting meta rows. Every step is conditional on every other: a
138
+ * failed document CAS records no intent, and a superseded intent whose state moved fails the
139
+ * whole write with {@link IntentStateConflict} so the caller composes against fresh state.
140
+ * With `requireSettled`, an unsettled intent on the target fails it with
141
+ * {@link IntentHoldConflict} before the document is touched.
142
+ */
143
+ writeJournaled(id: ConceptId, doc: OkfDocument, options?: JournaledWriteOptions): Promise<{
144
+ version: Version;
145
+ raw: string;
146
+ intent: IntentRecord | null;
147
+ }>;
148
+ /**
149
+ * One transaction over documents, intents, and meta: the document compare-and-swap of
150
+ * {@link delete}, plus putting and removing meta rows. With `requireSettled`, an unsettled
151
+ * intent on the target refuses it before anything is touched: a rejection with
152
+ * {@link IntentHoldConflict}, or with `onHeld` the `held` outcome whose meta rows are put in
153
+ * this same transaction, so the hold the caller acts on is the one that refused it. An absent
154
+ * target resolves `absent` with the meta changes applied, as {@link delete} answers absence
155
+ * with `false` even under a compare-and-swap.
156
+ */
157
+ deleteJournaled(id: ConceptId, options?: JournaledDeleteOptions): Promise<JournaledDeleteResult>;
158
+ /**
159
+ * The document, every intent targeting it, and the named meta rows, from ONE readonly
160
+ * transaction over documents, reserved, intents, and meta. A caller deriving where a document
161
+ * stands (its bytes against its shared base and its journal) reads them here so a write in
162
+ * another realm between separate reads can never show it a document of one moment beside a
163
+ * journal of another; with this snapshot a mismatch is a genuine working-copy defect.
164
+ */
165
+ readWithJournal(id: ConceptId, options?: {
166
+ meta?: readonly string[];
167
+ }): Promise<JournaledReadResult>;
168
+ /**
169
+ * Every document's head with its intents and the meta rows named for it, from ONE readonly
170
+ * transaction over documents, reserved, intents, and meta: {@link readWithJournal} over the
171
+ * whole store. The root index, the journal (grouped by target, since it has no index by
172
+ * target) and the `shared` keys are read once, then the documents are walked by cursor, each
173
+ * row's own keys read with it, so a caller's `project` sees one record at a time and the
174
+ * listing holds only what it keeps plus the journal it read up front, intents' content
175
+ * included. The frontmatter is the one `readWithJournal` would parse
176
+ * for the record, under the edition the root index declared at this moment; the body is
177
+ * never parsed. Rows come back in `list` order.
178
+ */
179
+ readHeads<T = JournaledHead>(options?: JournaledHeadsOptions<T>): Promise<T[]>;
180
+ /** Intents in local commit order, optionally restricted to one or more states. */
181
+ listIntents(state?: OperationState | readonly OperationState[]): Promise<IntentRecord[]>;
182
+ readIntent(requestId: string): Promise<IntentRecord | undefined>;
183
+ /**
184
+ * Compare-and-swap on an intent's `state`: the patch applies only while the record is in
185
+ * `expectedState`, together with any meta rows, in one transaction. A different state or a
186
+ * missing record rejects with {@link IntentStateConflict} and writes nothing.
187
+ */
188
+ updateIntent(requestId: string, expectedState: OperationState, patch: IntentPatch, options?: IntentUpdateOptions): Promise<IntentRecord>;
189
+ readMeta<T = unknown>(key: string): Promise<T | undefined>;
190
+ writeMeta(key: string, value: unknown, options?: MetaWriteOptions): Promise<void>;
191
+ readBlob(key: BlobKey): Promise<ReadBlobResult | null>;
192
+ writeBlob(key: BlobKey, bytes: Uint8Array, contentType?: string, options?: WriteOptions): Promise<Version>;
193
+ deleteBlob(key: BlobKey, options?: DeleteOptions): Promise<boolean>;
194
+ existsBlob(key: BlobKey): Promise<boolean>;
195
+ listBlobs(prefix?: string): Promise<BlobKey[]>;
196
+ }
197
+ //# sourceMappingURL=indexeddb-backend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexeddb-backend.d.ts","sourceRoot":"","sources":["../src/indexeddb-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAKH,OAAO,EAoBL,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EAClB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAE1B,KAAK,yBAAyB,EAC/B,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,KAAK,EACV,OAAO,EACP,SAAS,EACT,aAAa,EAEb,WAAW,EACX,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,OAAO,EACP,WAAW,EACX,YAAY,EACb,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACjF,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,aAAa,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,w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