@superbee/core 0.2.0-pre.8 → 0.4.10-pre.11
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.
- package/LICENSE +202 -0
- package/README.md +1345 -6
- package/dist/artifact-contract.d.ts +90 -0
- package/dist/artifact-contract.d.ts.map +1 -0
- package/dist/artifact-contract.js +205 -0
- package/dist/artifact-contract.js.map +1 -0
- package/dist/backend.d.ts +50 -2
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +311 -33
- package/dist/backend.js.map +1 -1
- package/dist/blob-contract.d.ts +82 -0
- package/dist/blob-contract.d.ts.map +1 -0
- package/dist/blob-contract.js +134 -0
- package/dist/blob-contract.js.map +1 -0
- package/dist/blob-journal.d.ts +303 -0
- package/dist/blob-journal.d.ts.map +1 -0
- package/dist/blob-journal.js +541 -0
- package/dist/blob-journal.js.map +1 -0
- package/dist/body-pages.d.ts +20 -0
- package/dist/body-pages.d.ts.map +1 -0
- package/dist/body-pages.js +56 -0
- package/dist/body-pages.js.map +1 -0
- package/dist/body-replace-guards.d.ts +81 -0
- package/dist/body-replace-guards.d.ts.map +1 -0
- package/dist/body-replace-guards.js +271 -0
- package/dist/body-replace-guards.js.map +1 -0
- package/dist/bounded-yaml.d.ts +28 -0
- package/dist/bounded-yaml.d.ts.map +1 -0
- package/dist/bounded-yaml.js +182 -0
- package/dist/bounded-yaml.js.map +1 -0
- package/dist/builtin-recipes/content.d.ts +93 -0
- package/dist/builtin-recipes/content.d.ts.map +1 -0
- package/dist/builtin-recipes/content.js +288 -0
- package/dist/builtin-recipes/content.js.map +1 -0
- package/dist/builtin-recipes/site.d.ts +5 -0
- package/dist/builtin-recipes/site.d.ts.map +1 -0
- package/dist/builtin-recipes/site.js +83 -0
- package/dist/builtin-recipes/site.js.map +1 -0
- package/dist/builtin-recipes.d.ts +13 -0
- package/dist/builtin-recipes.d.ts.map +1 -0
- package/dist/builtin-recipes.js +123 -0
- package/dist/builtin-recipes.js.map +1 -0
- package/dist/bundle-health/index.d.ts +14 -0
- package/dist/bundle-health/index.d.ts.map +1 -0
- package/dist/bundle-health/index.js +12 -0
- package/dist/bundle-health/index.js.map +1 -0
- package/dist/bundle-health/kind-findings.d.ts +45 -0
- package/dist/bundle-health/kind-findings.d.ts.map +1 -0
- package/dist/bundle-health/kind-findings.js +67 -0
- package/dist/bundle-health/kind-findings.js.map +1 -0
- package/dist/bundle-health/legacy-page.d.ts +21 -0
- package/dist/bundle-health/legacy-page.d.ts.map +1 -0
- package/dist/bundle-health/legacy-page.js +25 -0
- package/dist/bundle-health/legacy-page.js.map +1 -0
- package/dist/bundle-health/report.d.ts +191 -0
- package/dist/bundle-health/report.d.ts.map +1 -0
- package/dist/bundle-health/report.js +419 -0
- package/dist/bundle-health/report.js.map +1 -0
- package/dist/bundle-ops.d.ts +10 -4
- package/dist/bundle-ops.d.ts.map +1 -1
- package/dist/bundle-ops.js +15 -8
- package/dist/bundle-ops.js.map +1 -1
- package/dist/bundle.d.ts +2 -4
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +3 -12
- package/dist/bundle.js.map +1 -1
- package/dist/code-point-order.d.ts +8 -0
- package/dist/code-point-order.d.ts.map +1 -0
- package/dist/code-point-order.js +20 -0
- package/dist/code-point-order.js.map +1 -0
- package/dist/code-unit-order.d.ts +15 -0
- package/dist/code-unit-order.d.ts.map +1 -0
- package/dist/code-unit-order.js +17 -0
- package/dist/code-unit-order.js.map +1 -0
- package/dist/connector-request.d.ts +112 -0
- package/dist/connector-request.d.ts.map +1 -0
- package/dist/connector-request.js +495 -0
- package/dist/connector-request.js.map +1 -0
- package/dist/connectors.d.ts +297 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +1233 -0
- package/dist/connectors.js.map +1 -0
- package/dist/convention-record.d.ts +9 -0
- package/dist/convention-record.d.ts.map +1 -0
- package/dist/convention-record.js +13 -0
- package/dist/convention-record.js.map +1 -0
- package/dist/cross-bundle.d.ts +135 -0
- package/dist/cross-bundle.d.ts.map +1 -0
- package/dist/cross-bundle.js +191 -0
- package/dist/cross-bundle.js.map +1 -0
- package/dist/dependencies.d.ts +208 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +367 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/document-codec.d.ts +4 -1
- package/dist/document-codec.d.ts.map +1 -1
- package/dist/document-codec.js +3 -1
- package/dist/document-codec.js.map +1 -1
- package/dist/document-field-actions.d.ts +34 -3
- package/dist/document-field-actions.d.ts.map +1 -1
- package/dist/document-field-actions.js +149 -43
- package/dist/document-field-actions.js.map +1 -1
- package/dist/document-mutation.d.ts +55 -18
- package/dist/document-mutation.d.ts.map +1 -1
- package/dist/document-mutation.js +210 -86
- package/dist/document-mutation.js.map +1 -1
- package/dist/document-persistence.d.ts +12 -0
- package/dist/document-persistence.d.ts.map +1 -0
- package/dist/document-persistence.js +44 -0
- package/dist/document-persistence.js.map +1 -0
- package/dist/document-replace-rules.d.ts +44 -0
- package/dist/document-replace-rules.d.ts.map +1 -0
- package/dist/document-replace-rules.js +41 -0
- package/dist/document-replace-rules.js.map +1 -0
- package/dist/document-scan.d.ts +26 -0
- package/dist/document-scan.d.ts.map +1 -0
- package/dist/document-scan.js +70 -0
- package/dist/document-scan.js.map +1 -0
- package/dist/document-transfer.d.ts +312 -0
- package/dist/document-transfer.d.ts.map +1 -0
- package/dist/document-transfer.js +1400 -0
- package/dist/document-transfer.js.map +1 -0
- package/dist/document-write-policy.d.ts +15 -4
- package/dist/document-write-policy.d.ts.map +1 -1
- package/dist/document-write-policy.js +41 -27
- package/dist/document-write-policy.js.map +1 -1
- package/dist/domain-model.d.ts +73 -0
- package/dist/domain-model.d.ts.map +1 -0
- package/dist/domain-model.js +169 -0
- package/dist/domain-model.js.map +1 -0
- package/dist/edge-harness/corpus.d.ts +9 -0
- package/dist/edge-harness/corpus.d.ts.map +1 -0
- package/dist/edge-harness/corpus.js +57 -0
- package/dist/edge-harness/corpus.js.map +1 -0
- package/dist/edge-harness/index.d.ts +21 -0
- package/dist/edge-harness/index.d.ts.map +1 -0
- package/dist/edge-harness/index.js +537 -0
- package/dist/edge-harness/index.js.map +1 -0
- package/dist/edges/find.d.ts +14 -0
- package/dist/edges/find.d.ts.map +1 -0
- package/dist/edges/find.js +46 -0
- package/dist/edges/find.js.map +1 -0
- package/dist/edges/index.d.ts +13 -0
- package/dist/edges/index.d.ts.map +1 -0
- package/dist/edges/index.js +5 -0
- package/dist/edges/index.js.map +1 -0
- package/dist/edges/memory-source.d.ts +8 -0
- package/dist/edges/memory-source.d.ts.map +1 -0
- package/dist/edges/memory-source.js +164 -0
- package/dist/edges/memory-source.js.map +1 -0
- package/dist/edges/read-bounds.d.ts +6 -0
- package/dist/edges/read-bounds.d.ts.map +1 -0
- package/dist/edges/read-bounds.js +13 -0
- package/dist/edges/read-bounds.js.map +1 -0
- package/dist/edges/source.d.ts +123 -0
- package/dist/edges/source.d.ts.map +1 -0
- package/dist/edges/source.js +2 -0
- package/dist/edges/source.js.map +1 -0
- package/dist/edges/walk.d.ts +7 -0
- package/dist/edges/walk.d.ts.map +1 -0
- package/dist/edges/walk.js +14 -0
- package/dist/edges/walk.js.map +1 -0
- package/dist/engine.d.ts +54 -18
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +137 -108
- package/dist/engine.js.map +1 -1
- package/dist/errors.d.ts +37 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +75 -3
- package/dist/errors.js.map +1 -1
- package/dist/file-journaled-backend-internal.d.ts +2 -0
- package/dist/file-journaled-backend-internal.d.ts.map +1 -1
- package/dist/file-journaled-backend-internal.js +2 -0
- package/dist/file-journaled-backend-internal.js.map +1 -1
- package/dist/file-journaled-backend.d.ts +38 -40
- package/dist/file-journaled-backend.d.ts.map +1 -1
- package/dist/file-journaled-backend.js +284 -52
- package/dist/file-journaled-backend.js.map +1 -1
- package/dist/filesystem-identity.d.ts +116 -17
- package/dist/filesystem-identity.d.ts.map +1 -1
- package/dist/filesystem-identity.js +532 -51
- package/dist/filesystem-identity.js.map +1 -1
- package/dist/filesystem-lock.d.ts +9 -2
- package/dist/filesystem-lock.d.ts.map +1 -1
- package/dist/filesystem-lock.js +134 -17
- package/dist/filesystem-lock.js.map +1 -1
- package/dist/filesystem-temp-name.d.ts +9 -0
- package/dist/filesystem-temp-name.d.ts.map +1 -0
- package/dist/filesystem-temp-name.js +20 -0
- package/dist/filesystem-temp-name.js.map +1 -0
- package/dist/filesystem.d.ts +6 -0
- package/dist/filesystem.d.ts.map +1 -1
- package/dist/filesystem.js +2 -1
- package/dist/filesystem.js.map +1 -1
- package/dist/freshness.d.ts +16 -1
- package/dist/freshness.d.ts.map +1 -1
- package/dist/freshness.js +47 -17
- package/dist/freshness.js.map +1 -1
- package/dist/frontmatter-contract.d.ts +14 -0
- package/dist/frontmatter-contract.d.ts.map +1 -1
- package/dist/frontmatter-contract.js +22 -0
- package/dist/frontmatter-contract.js.map +1 -1
- package/dist/frontmatter-splitter.d.ts +6 -0
- package/dist/frontmatter-splitter.d.ts.map +1 -1
- package/dist/frontmatter-splitter.js +8 -0
- package/dist/frontmatter-splitter.js.map +1 -1
- package/dist/frontmatter.d.ts +17 -7
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +52 -11
- package/dist/frontmatter.js.map +1 -1
- package/dist/governed-body-write.d.ts.map +1 -1
- package/dist/governed-body-write.js +13 -6
- package/dist/governed-body-write.js.map +1 -1
- package/dist/heads-digest.d.ts.map +1 -1
- package/dist/heads-digest.js +2 -1
- package/dist/heads-digest.js.map +1 -1
- package/dist/hosted-client/binding.d.ts +7 -0
- package/dist/hosted-client/binding.d.ts.map +1 -0
- package/dist/hosted-client/binding.js +10 -0
- package/dist/hosted-client/binding.js.map +1 -0
- package/dist/hosted-client/blob-delivery.d.ts +68 -0
- package/dist/hosted-client/blob-delivery.d.ts.map +1 -0
- package/dist/hosted-client/blob-delivery.js +170 -0
- package/dist/hosted-client/blob-delivery.js.map +1 -0
- package/dist/hosted-client/blob-write.d.ts +387 -0
- package/dist/hosted-client/blob-write.d.ts.map +1 -0
- package/dist/hosted-client/blob-write.js +770 -0
- package/dist/hosted-client/blob-write.js.map +1 -0
- package/dist/hosted-client/bundle-listing.d.ts +46 -0
- package/dist/hosted-client/bundle-listing.d.ts.map +1 -0
- package/dist/hosted-client/bundle-listing.js +36 -0
- package/dist/hosted-client/bundle-listing.js.map +1 -0
- package/dist/hosted-client/client.d.ts +249 -0
- package/dist/hosted-client/client.d.ts.map +1 -0
- package/dist/hosted-client/client.js +381 -0
- package/dist/hosted-client/client.js.map +1 -0
- package/dist/hosted-client/directory.d.ts +46 -0
- package/dist/hosted-client/directory.d.ts.map +1 -0
- package/dist/hosted-client/directory.js +74 -0
- package/dist/hosted-client/directory.js.map +1 -0
- package/dist/hosted-client/errors.d.ts +26 -0
- package/dist/hosted-client/errors.d.ts.map +1 -0
- package/dist/hosted-client/errors.js +35 -0
- package/dist/hosted-client/errors.js.map +1 -0
- package/dist/hosted-client/inbox.d.ts +320 -0
- package/dist/hosted-client/inbox.d.ts.map +1 -0
- package/dist/hosted-client/inbox.js +379 -0
- package/dist/hosted-client/inbox.js.map +1 -0
- package/dist/hosted-client/index.d.ts +31 -0
- package/dist/hosted-client/index.d.ts.map +1 -0
- package/dist/hosted-client/index.js +33 -0
- package/dist/hosted-client/index.js.map +1 -0
- package/dist/hosted-client/journal.d.ts +103 -0
- package/dist/hosted-client/journal.d.ts.map +1 -0
- package/dist/hosted-client/journal.js +464 -0
- package/dist/hosted-client/journal.js.map +1 -0
- package/dist/hosted-client/node.d.ts +74 -0
- package/dist/hosted-client/node.d.ts.map +1 -0
- package/dist/hosted-client/node.js +219 -0
- package/dist/hosted-client/node.js.map +1 -0
- package/dist/hosted-client/reference.d.ts +12 -0
- package/dist/hosted-client/reference.d.ts.map +1 -0
- package/dist/hosted-client/reference.js +29 -0
- package/dist/hosted-client/reference.js.map +1 -0
- package/dist/hosted-client/view-content.d.ts +184 -0
- package/dist/hosted-client/view-content.d.ts.map +1 -0
- package/dist/hosted-client/view-content.js +268 -0
- package/dist/hosted-client/view-content.js.map +1 -0
- package/dist/hosted-client/write.d.ts +219 -0
- package/dist/hosted-client/write.d.ts.map +1 -0
- package/dist/hosted-client/write.js +419 -0
- package/dist/hosted-client/write.js.map +1 -0
- package/dist/hosted-transport/answer-rows.d.ts +132 -4
- package/dist/hosted-transport/answer-rows.d.ts.map +1 -1
- package/dist/hosted-transport/answer-rows.js +211 -11
- package/dist/hosted-transport/answer-rows.js.map +1 -1
- package/dist/hosted-transport/attribution.d.ts +32 -0
- package/dist/hosted-transport/attribution.d.ts.map +1 -0
- package/dist/hosted-transport/attribution.js +38 -0
- package/dist/hosted-transport/attribution.js.map +1 -0
- package/dist/hosted-transport/blob-reads.d.ts +35 -0
- package/dist/hosted-transport/blob-reads.d.ts.map +1 -0
- package/dist/hosted-transport/blob-reads.js +179 -0
- package/dist/hosted-transport/blob-reads.js.map +1 -0
- package/dist/hosted-transport/blob-write.d.ts +34 -0
- package/dist/hosted-transport/blob-write.d.ts.map +1 -0
- package/dist/hosted-transport/blob-write.js +115 -0
- package/dist/hosted-transport/blob-write.js.map +1 -0
- package/dist/hosted-transport/carrier.d.ts +35 -11
- package/dist/hosted-transport/carrier.d.ts.map +1 -1
- package/dist/hosted-transport/carrier.js +101 -57
- package/dist/hosted-transport/carrier.js.map +1 -1
- package/dist/hosted-transport/document-backend.d.ts +74 -0
- package/dist/hosted-transport/document-backend.d.ts.map +1 -0
- package/dist/hosted-transport/document-backend.js +160 -0
- package/dist/hosted-transport/document-backend.js.map +1 -0
- package/dist/hosted-transport/index.d.ts +7 -4
- package/dist/hosted-transport/index.d.ts.map +1 -1
- package/dist/hosted-transport/index.js +7 -4
- package/dist/hosted-transport/index.js.map +1 -1
- package/dist/hosted-transport/operations.d.ts +6 -0
- package/dist/hosted-transport/operations.d.ts.map +1 -1
- package/dist/hosted-transport/operations.js +2 -1
- package/dist/hosted-transport/operations.js.map +1 -1
- package/dist/hosted-transport/port-run.d.ts +41 -0
- package/dist/hosted-transport/port-run.d.ts.map +1 -0
- package/dist/hosted-transport/port-run.js +92 -0
- package/dist/hosted-transport/port-run.js.map +1 -0
- package/dist/hosted-transport/read-adapter.d.ts +19 -3
- package/dist/hosted-transport/read-adapter.d.ts.map +1 -1
- package/dist/hosted-transport/read-adapter.js +18 -5
- package/dist/hosted-transport/read-adapter.js.map +1 -1
- package/dist/hosted-transport/root-write.d.ts.map +1 -1
- package/dist/hosted-transport/root-write.js +5 -2
- package/dist/hosted-transport/root-write.js.map +1 -1
- package/dist/hosted-transport/whole-document-transport.d.ts +56 -7
- package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -1
- package/dist/hosted-transport/whole-document-transport.js +120 -31
- package/dist/hosted-transport/whole-document-transport.js.map +1 -1
- package/dist/identity-fold.d.ts +16 -0
- package/dist/identity-fold.d.ts.map +1 -0
- package/dist/identity-fold.js +24 -0
- package/dist/identity-fold.js.map +1 -0
- package/dist/index-projection.d.ts +2 -1
- package/dist/index-projection.d.ts.map +1 -1
- package/dist/index-projection.js +38 -28
- package/dist/index-projection.js.map +1 -1
- package/dist/index.d.ts +61 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50 -21
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +0 -31
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +5 -2
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/inventory-guard.d.ts +58 -0
- package/dist/inventory-guard.d.ts.map +1 -0
- package/dist/inventory-guard.js +169 -0
- package/dist/inventory-guard.js.map +1 -0
- package/dist/journaled-backend.d.ts +14 -4
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +19 -78
- package/dist/journaled-backend.js.map +1 -1
- package/dist/json-data.d.ts +3 -0
- package/dist/json-data.d.ts.map +1 -0
- package/dist/json-data.js +19 -0
- package/dist/json-data.js.map +1 -0
- package/dist/kind-authoring.d.ts +188 -0
- package/dist/kind-authoring.d.ts.map +1 -0
- package/dist/kind-authoring.js +520 -0
- package/dist/kind-authoring.js.map +1 -0
- package/dist/kind-changes.d.ts +45 -0
- package/dist/kind-changes.d.ts.map +1 -0
- package/dist/kind-changes.js +96 -0
- package/dist/kind-changes.js.map +1 -0
- package/dist/kind-conformance-error.d.ts +16 -0
- package/dist/kind-conformance-error.d.ts.map +1 -0
- package/dist/kind-conformance-error.js +20 -0
- package/dist/kind-conformance-error.js.map +1 -0
- package/dist/kind-coverage.d.ts +100 -0
- package/dist/kind-coverage.d.ts.map +1 -0
- package/dist/kind-coverage.js +185 -0
- package/dist/kind-coverage.js.map +1 -0
- package/dist/kind-deprecation.d.ts +32 -0
- package/dist/kind-deprecation.d.ts.map +1 -0
- package/dist/kind-deprecation.js +141 -0
- package/dist/kind-deprecation.js.map +1 -0
- package/dist/kind-field-mutation.d.ts +7 -2
- package/dist/kind-field-mutation.d.ts.map +1 -1
- package/dist/kind-field-mutation.js +28 -3
- package/dist/kind-field-mutation.js.map +1 -1
- package/dist/kind-undeclared-fields.d.ts +72 -0
- package/dist/kind-undeclared-fields.d.ts.map +1 -0
- package/dist/kind-undeclared-fields.js +124 -0
- package/dist/kind-undeclared-fields.js.map +1 -0
- package/dist/kinds-load.d.ts.map +1 -1
- package/dist/kinds-load.js +8 -5
- package/dist/kinds-load.js.map +1 -1
- package/dist/kinds.d.ts +105 -13
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +369 -30
- package/dist/kinds.js.map +1 -1
- package/dist/link-add.d.ts +81 -0
- package/dist/link-add.d.ts.map +1 -0
- package/dist/link-add.js +94 -0
- package/dist/link-add.js.map +1 -0
- package/dist/link-emit.d.ts +29 -0
- package/dist/link-emit.d.ts.map +1 -0
- package/dist/link-emit.js +39 -0
- package/dist/link-emit.js.map +1 -0
- package/dist/link-findings.d.ts +132 -0
- package/dist/link-findings.d.ts.map +1 -0
- package/dist/link-findings.js +263 -0
- package/dist/link-findings.js.map +1 -0
- package/dist/link-types.d.ts +34 -0
- package/dist/link-types.d.ts.map +1 -0
- package/dist/link-types.js +79 -0
- package/dist/link-types.js.map +1 -0
- package/dist/links.d.ts +68 -9
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +370 -57
- package/dist/links.js.map +1 -1
- package/dist/local-search-index.d.ts +86 -0
- package/dist/local-search-index.d.ts.map +1 -0
- package/dist/local-search-index.js +1055 -0
- package/dist/local-search-index.js.map +1 -0
- package/dist/managed-document-metadata.d.ts +5 -0
- package/dist/managed-document-metadata.d.ts.map +1 -0
- package/dist/managed-document-metadata.js +10 -0
- package/dist/managed-document-metadata.js.map +1 -0
- package/dist/markdown-syntax.d.ts +39 -0
- package/dist/markdown-syntax.d.ts.map +1 -0
- package/dist/markdown-syntax.js +10170 -0
- package/dist/markdown-syntax.js.map +1 -0
- package/dist/memory-backend.d.ts +3 -0
- package/dist/memory-backend.d.ts.map +1 -1
- package/dist/memory-backend.js +40 -2
- package/dist/memory-backend.js.map +1 -1
- package/dist/mutation-attribution.d.ts +2 -1
- package/dist/mutation-attribution.d.ts.map +1 -1
- package/dist/mutation-attribution.js.map +1 -1
- package/dist/okf-actor.d.ts +14 -3
- package/dist/okf-actor.d.ts.map +1 -1
- package/dist/okf-actor.js +25 -4
- package/dist/okf-actor.js.map +1 -1
- package/dist/okf-authored-values.d.ts +2 -0
- package/dist/okf-authored-values.d.ts.map +1 -1
- package/dist/okf-authored-values.js +4 -0
- package/dist/okf-authored-values.js.map +1 -1
- package/dist/okf-authoring.d.ts +7 -0
- package/dist/okf-authoring.d.ts.map +1 -0
- package/dist/okf-authoring.js +30 -0
- package/dist/okf-authoring.js.map +1 -0
- package/dist/okf-standard-fields.d.ts +4 -0
- package/dist/okf-standard-fields.d.ts.map +1 -1
- package/dist/okf-standard-fields.js +24 -14
- package/dist/okf-standard-fields.js.map +1 -1
- package/dist/okf-timestamps.d.ts +2 -2
- package/dist/okf-timestamps.d.ts.map +1 -1
- package/dist/okf-timestamps.js +25 -15
- package/dist/okf-timestamps.js.map +1 -1
- package/dist/page.d.ts +3 -7
- package/dist/page.d.ts.map +1 -1
- package/dist/page.js +3 -7
- package/dist/page.js.map +1 -1
- package/dist/path-fold.d.ts +67 -0
- package/dist/path-fold.d.ts.map +1 -0
- package/dist/path-fold.js +107 -0
- package/dist/path-fold.js.map +1 -0
- package/dist/paths.d.ts +46 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +114 -1
- package/dist/paths.js.map +1 -1
- package/dist/platform.d.ts +13 -0
- package/dist/platform.d.ts.map +1 -1
- package/dist/platform.js +16 -0
- package/dist/platform.js.map +1 -1
- package/dist/portable-export-contract.d.ts +17 -0
- package/dist/portable-export-contract.d.ts.map +1 -0
- package/dist/portable-export-contract.js +59 -0
- package/dist/portable-export-contract.js.map +1 -0
- package/dist/portable-export.d.ts +115 -0
- package/dist/portable-export.d.ts.map +1 -0
- package/dist/portable-export.js +452 -0
- package/dist/portable-export.js.map +1 -0
- package/dist/portable-frontmatter.d.ts +17 -0
- package/dist/portable-frontmatter.d.ts.map +1 -1
- package/dist/portable-frontmatter.js +42 -5
- package/dist/portable-frontmatter.js.map +1 -1
- package/dist/publication-filesystem.d.ts +1 -1
- package/dist/publication-filesystem.d.ts.map +1 -1
- package/dist/publication-filesystem.js +1 -1
- package/dist/publication-filesystem.js.map +1 -1
- package/dist/qualified-links.d.ts +67 -0
- package/dist/qualified-links.d.ts.map +1 -0
- package/dist/qualified-links.js +121 -0
- package/dist/qualified-links.js.map +1 -0
- package/dist/query-filter.d.ts +16 -4
- package/dist/query-filter.d.ts.map +1 -1
- package/dist/query-filter.js +44 -2
- package/dist/query-filter.js.map +1 -1
- package/dist/query-order.d.ts.map +1 -1
- package/dist/query-order.js +2 -1
- package/dist/query-order.js.map +1 -1
- package/dist/recipe-lifecycle/errors.d.ts +96 -0
- package/dist/recipe-lifecycle/errors.d.ts.map +1 -0
- package/dist/recipe-lifecycle/errors.js +122 -0
- package/dist/recipe-lifecycle/errors.js.map +1 -0
- package/dist/recipe-lifecycle/evolution.d.ts +134 -0
- package/dist/recipe-lifecycle/evolution.d.ts.map +1 -0
- package/dist/recipe-lifecycle/evolution.js +1047 -0
- package/dist/recipe-lifecycle/evolution.js.map +1 -0
- package/dist/recipe-lifecycle/index.d.ts +38 -0
- package/dist/recipe-lifecycle/index.d.ts.map +1 -0
- package/dist/recipe-lifecycle/index.js +31 -0
- package/dist/recipe-lifecycle/index.js.map +1 -0
- package/dist/recipe-lifecycle/install.d.ts +172 -0
- package/dist/recipe-lifecycle/install.d.ts.map +1 -0
- package/dist/recipe-lifecycle/install.js +652 -0
- package/dist/recipe-lifecycle/install.js.map +1 -0
- package/dist/recipe-lifecycle/legacy-aliases.d.ts +4 -0
- package/dist/recipe-lifecycle/legacy-aliases.d.ts.map +1 -0
- package/dist/recipe-lifecycle/legacy-aliases.js +22 -0
- package/dist/recipe-lifecycle/legacy-aliases.js.map +1 -0
- package/dist/recipe-lifecycle/retirement-apply.d.ts +59 -0
- package/dist/recipe-lifecycle/retirement-apply.d.ts.map +1 -0
- package/dist/recipe-lifecycle/retirement-apply.js +165 -0
- package/dist/recipe-lifecycle/retirement-apply.js.map +1 -0
- package/dist/recipe-lifecycle/retirement.d.ts +89 -0
- package/dist/recipe-lifecycle/retirement.d.ts.map +1 -0
- package/dist/recipe-lifecycle/retirement.js +347 -0
- package/dist/recipe-lifecycle/retirement.js.map +1 -0
- package/dist/recipe-lifecycle/set-commit.d.ts +31 -0
- package/dist/recipe-lifecycle/set-commit.d.ts.map +1 -0
- package/dist/recipe-lifecycle/set-commit.js +37 -0
- package/dist/recipe-lifecycle/set-commit.js.map +1 -0
- package/dist/recipe-lifecycle/stamp.d.ts +146 -0
- package/dist/recipe-lifecycle/stamp.d.ts.map +1 -0
- package/dist/recipe-lifecycle/stamp.js +361 -0
- package/dist/recipe-lifecycle/stamp.js.map +1 -0
- package/dist/recipe-qualify.d.ts +80 -0
- package/dist/recipe-qualify.d.ts.map +1 -0
- package/dist/recipe-qualify.js +352 -0
- package/dist/recipe-qualify.js.map +1 -0
- package/dist/recipe-set-preflight.d.ts +139 -0
- package/dist/recipe-set-preflight.d.ts.map +1 -0
- package/dist/recipe-set-preflight.js +536 -0
- package/dist/recipe-set-preflight.js.map +1 -0
- package/dist/recipe-sources.d.ts +209 -0
- package/dist/recipe-sources.d.ts.map +1 -0
- package/dist/recipe-sources.js +607 -0
- package/dist/recipe-sources.js.map +1 -0
- package/dist/recipes.d.ts +45 -1
- package/dist/recipes.d.ts.map +1 -1
- package/dist/recipes.js +138 -1
- package/dist/recipes.js.map +1 -1
- package/dist/record-overlay/apply.d.ts +43 -0
- package/dist/record-overlay/apply.d.ts.map +1 -0
- package/dist/record-overlay/apply.js +523 -0
- package/dist/record-overlay/apply.js.map +1 -0
- package/dist/record-overlay/canonical.d.ts +22 -0
- package/dist/record-overlay/canonical.d.ts.map +1 -0
- package/dist/record-overlay/canonical.js +47 -0
- package/dist/record-overlay/canonical.js.map +1 -0
- package/dist/record-overlay/digest.d.ts +4 -0
- package/dist/record-overlay/digest.d.ts.map +1 -0
- package/dist/record-overlay/digest.js +11 -0
- package/dist/record-overlay/digest.js.map +1 -0
- package/dist/record-overlay/errors.d.ts +44 -0
- package/dist/record-overlay/errors.d.ts.map +1 -0
- package/dist/record-overlay/errors.js +55 -0
- package/dist/record-overlay/errors.js.map +1 -0
- package/dist/record-overlay/findings.d.ts +5 -0
- package/dist/record-overlay/findings.d.ts.map +1 -0
- package/dist/record-overlay/findings.js +86 -0
- package/dist/record-overlay/findings.js.map +1 -0
- package/dist/record-overlay/index.d.ts +23 -0
- package/dist/record-overlay/index.d.ts.map +1 -0
- package/dist/record-overlay/index.js +21 -0
- package/dist/record-overlay/index.js.map +1 -0
- package/dist/record-overlay/plan.d.ts +12 -0
- package/dist/record-overlay/plan.d.ts.map +1 -0
- package/dist/record-overlay/plan.js +285 -0
- package/dist/record-overlay/plan.js.map +1 -0
- package/dist/record-overlay/policy.d.ts +74 -0
- package/dist/record-overlay/policy.d.ts.map +1 -0
- package/dist/record-overlay/policy.js +235 -0
- package/dist/record-overlay/policy.js.map +1 -0
- package/dist/record-overlay/redact.d.ts +3 -0
- package/dist/record-overlay/redact.d.ts.map +1 -0
- package/dist/record-overlay/redact.js +27 -0
- package/dist/record-overlay/redact.js.map +1 -0
- package/dist/record-overlay/signal-kind.d.ts +30 -0
- package/dist/record-overlay/signal-kind.d.ts.map +1 -0
- package/dist/record-overlay/signal-kind.js +38 -0
- package/dist/record-overlay/signal-kind.js.map +1 -0
- package/dist/record-overlay/signal-text.d.ts +52 -0
- package/dist/record-overlay/signal-text.d.ts.map +1 -0
- package/dist/record-overlay/signal-text.js +126 -0
- package/dist/record-overlay/signal-text.js.map +1 -0
- package/dist/record-overlay/source-index.d.ts +19 -0
- package/dist/record-overlay/source-index.d.ts.map +1 -0
- package/dist/record-overlay/source-index.js +102 -0
- package/dist/record-overlay/source-index.js.map +1 -0
- package/dist/record-overlay/types.d.ts +291 -0
- package/dist/record-overlay/types.d.ts.map +1 -0
- package/dist/record-overlay/types.js +2 -0
- package/dist/record-overlay/types.js.map +1 -0
- package/dist/relationships.d.ts +71 -0
- package/dist/relationships.d.ts.map +1 -0
- package/dist/relationships.js +87 -0
- package/dist/relationships.js.map +1 -0
- package/dist/remote-backend.d.ts +11 -21
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +20 -15
- package/dist/remote-backend.js.map +1 -1
- package/dist/remote-document-codec.d.ts +2 -1
- package/dist/remote-document-codec.d.ts.map +1 -1
- package/dist/remote-document-codec.js +3 -2
- package/dist/remote-document-codec.js.map +1 -1
- package/dist/remote-operations.d.ts +0 -41
- package/dist/remote-operations.d.ts.map +1 -1
- package/dist/remote-operations.js +14 -2
- package/dist/remote-operations.js.map +1 -1
- package/dist/remote-parsers.d.ts +19 -0
- package/dist/remote-parsers.d.ts.map +1 -1
- package/dist/remote-parsers.js.map +1 -1
- package/dist/remote.d.ts +2 -4
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +2 -3
- package/dist/remote.js.map +1 -1
- package/dist/reserved-write.d.ts +9 -0
- package/dist/reserved-write.d.ts.map +1 -0
- package/dist/reserved-write.js +15 -0
- package/dist/reserved-write.js.map +1 -0
- package/dist/search/backend-source.d.ts +6 -0
- package/dist/search/backend-source.d.ts.map +1 -0
- package/dist/search/backend-source.js +57 -0
- package/dist/search/backend-source.js.map +1 -0
- package/dist/search/contract.d.ts +162 -0
- package/dist/search/contract.d.ts.map +1 -0
- package/dist/search/contract.js +82 -0
- package/dist/search/contract.js.map +1 -0
- package/dist/search/errors.d.ts +30 -0
- package/dist/search/errors.d.ts.map +1 -0
- package/dist/search/errors.js +50 -0
- package/dist/search/errors.js.map +1 -0
- package/dist/search/identity.d.ts +12 -0
- package/dist/search/identity.d.ts.map +1 -0
- package/dist/search/identity.js +90 -0
- package/dist/search/identity.js.map +1 -0
- package/dist/search/index.d.ts +16 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +15 -0
- package/dist/search/index.js.map +1 -0
- package/dist/search/memory-source.d.ts +36 -0
- package/dist/search/memory-source.d.ts.map +1 -0
- package/dist/search/memory-source.js +238 -0
- package/dist/search/memory-source.js.map +1 -0
- package/dist/search/rank.d.ts +29 -0
- package/dist/search/rank.d.ts.map +1 -0
- package/dist/search/rank.js +132 -0
- package/dist/search/rank.js.map +1 -0
- package/dist/search/row-text.d.ts +38 -0
- package/dist/search/row-text.d.ts.map +1 -0
- package/dist/search/row-text.js +88 -0
- package/dist/search/row-text.js.map +1 -0
- package/dist/search/search.d.ts +28 -0
- package/dist/search/search.d.ts.map +1 -0
- package/dist/search/search.js +265 -0
- package/dist/search/search.js.map +1 -0
- package/dist/search/source.d.ts +70 -0
- package/dist/search/source.d.ts.map +1 -0
- package/dist/search/source.js +2 -0
- package/dist/search/source.js.map +1 -0
- package/dist/search/text.d.ts +49 -0
- package/dist/search/text.d.ts.map +1 -0
- package/dist/search/text.js +165 -0
- package/dist/search/text.js.map +1 -0
- package/dist/search-index.d.ts +9 -0
- package/dist/search-index.d.ts.map +1 -0
- package/dist/search-index.js +9 -0
- package/dist/search-index.js.map +1 -0
- package/dist/sha256.d.ts.map +1 -1
- package/dist/sha256.js +3 -2
- package/dist/sha256.js.map +1 -1
- package/dist/site-capabilities.d.ts +345 -0
- package/dist/site-capabilities.d.ts.map +1 -0
- package/dist/site-capabilities.js +724 -0
- package/dist/site-capabilities.js.map +1 -0
- package/dist/site-manifest.d.ts +51 -0
- package/dist/site-manifest.d.ts.map +1 -0
- package/dist/site-manifest.js +115 -0
- package/dist/site-manifest.js.map +1 -0
- package/dist/skip-reasons.d.ts +12 -0
- package/dist/skip-reasons.d.ts.map +1 -0
- package/dist/skip-reasons.js +15 -0
- package/dist/skip-reasons.js.map +1 -0
- package/dist/source-engine/driver.d.ts +40 -0
- package/dist/source-engine/driver.d.ts.map +1 -0
- package/dist/source-engine/driver.js +513 -0
- package/dist/source-engine/driver.js.map +1 -0
- package/dist/source-engine/evidence.d.ts +39 -0
- package/dist/source-engine/evidence.d.ts.map +1 -0
- package/dist/source-engine/evidence.js +54 -0
- package/dist/source-engine/evidence.js.map +1 -0
- package/dist/source-engine/guard.d.ts +87 -0
- package/dist/source-engine/guard.d.ts.map +1 -0
- package/dist/source-engine/guard.js +427 -0
- package/dist/source-engine/guard.js.map +1 -0
- package/dist/source-engine/index.d.ts +35 -0
- package/dist/source-engine/index.d.ts.map +1 -0
- package/dist/source-engine/index.js +27 -0
- package/dist/source-engine/index.js.map +1 -0
- package/dist/source-engine/machine-state.d.ts +87 -0
- package/dist/source-engine/machine-state.d.ts.map +1 -0
- package/dist/source-engine/machine-state.js +94 -0
- package/dist/source-engine/machine-state.js.map +1 -0
- package/dist/source-engine/observe.d.ts +10 -0
- package/dist/source-engine/observe.d.ts.map +1 -0
- package/dist/source-engine/observe.js +276 -0
- package/dist/source-engine/observe.js.map +1 -0
- package/dist/source-engine/overlay.d.ts +50 -0
- package/dist/source-engine/overlay.d.ts.map +1 -0
- package/dist/source-engine/overlay.js +114 -0
- package/dist/source-engine/overlay.js.map +1 -0
- package/dist/source-engine/robots.d.ts +53 -0
- package/dist/source-engine/robots.d.ts.map +1 -0
- package/dist/source-engine/robots.js +158 -0
- package/dist/source-engine/robots.js.map +1 -0
- package/dist/source-engine/snapshot.d.ts +104 -0
- package/dist/source-engine/snapshot.d.ts.map +1 -0
- package/dist/source-engine/snapshot.js +240 -0
- package/dist/source-engine/snapshot.js.map +1 -0
- package/dist/source-engine/target-consumer.d.ts +12 -0
- package/dist/source-engine/target-consumer.d.ts.map +1 -0
- package/dist/source-engine/target-consumer.js +15 -0
- package/dist/source-engine/target-consumer.js.map +1 -0
- package/dist/source-engine/target-descriptor.d.ts +3 -0
- package/dist/source-engine/target-descriptor.d.ts.map +1 -0
- package/dist/source-engine/target-descriptor.js +26 -0
- package/dist/source-engine/target-descriptor.js.map +1 -0
- package/dist/source-engine/target.d.ts +82 -0
- package/dist/source-engine/target.d.ts.map +1 -0
- package/dist/source-engine/target.js +213 -0
- package/dist/source-engine/target.js.map +1 -0
- package/dist/source-engine/types.d.ts +296 -0
- package/dist/source-engine/types.d.ts.map +1 -0
- package/dist/source-engine/types.js +2 -0
- package/dist/source-engine/types.js.map +1 -0
- package/dist/source-harness/conformance.d.ts +16 -0
- package/dist/source-harness/conformance.d.ts.map +1 -0
- package/dist/source-harness/conformance.js +266 -0
- package/dist/source-harness/conformance.js.map +1 -0
- package/dist/source-harness/fixture.d.ts +97 -0
- package/dist/source-harness/fixture.d.ts.map +1 -0
- package/dist/source-harness/fixture.js +276 -0
- package/dist/source-harness/fixture.js.map +1 -0
- package/dist/source-harness/index.d.ts +22 -0
- package/dist/source-harness/index.d.ts.map +1 -0
- package/dist/source-harness/index.js +19 -0
- package/dist/source-harness/index.js.map +1 -0
- package/dist/source-harness/peer.d.ts +74 -0
- package/dist/source-harness/peer.d.ts.map +1 -0
- package/dist/source-harness/peer.js +106 -0
- package/dist/source-harness/peer.js.map +1 -0
- package/dist/source-profiles/index.d.ts +31 -0
- package/dist/source-profiles/index.d.ts.map +1 -0
- package/dist/source-profiles/index.js +206 -0
- package/dist/source-profiles/index.js.map +1 -0
- package/dist/source-profiles/link-header.d.ts +6 -0
- package/dist/source-profiles/link-header.d.ts.map +1 -0
- package/dist/source-profiles/link-header.js +131 -0
- package/dist/source-profiles/link-header.js.map +1 -0
- package/dist/storage-harness/contract.d.ts +109 -0
- package/dist/storage-harness/contract.d.ts.map +1 -0
- package/dist/storage-harness/contract.js +853 -0
- package/dist/storage-harness/contract.js.map +1 -0
- package/dist/storage-harness/index.d.ts +39 -0
- package/dist/storage-harness/index.d.ts.map +1 -0
- package/dist/storage-harness/index.js +55 -0
- package/dist/storage-harness/index.js.map +1 -0
- package/dist/storage.d.ts +10 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +10 -2
- package/dist/storage.js.map +1 -1
- package/dist/string-identity-agreement.d.ts +35 -0
- package/dist/string-identity-agreement.d.ts.map +1 -0
- package/dist/string-identity-agreement.js +78 -0
- package/dist/string-identity-agreement.js.map +1 -0
- package/dist/system-documents.d.ts +82 -0
- package/dist/system-documents.d.ts.map +1 -0
- package/dist/system-documents.js +127 -0
- package/dist/system-documents.js.map +1 -0
- package/dist/types.d.ts +45 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -10
- package/dist/types.js.map +1 -1
- package/dist/uncertain-write.d.ts +119 -6
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +67 -32
- package/dist/uncertain-write.js.map +1 -1
- package/dist/validation.d.ts +5 -0
- package/dist/validation.d.ts.map +1 -1
- package/dist/verification.d.ts +22 -10
- package/dist/verification.d.ts.map +1 -1
- package/dist/verification.js +87 -39
- package/dist/verification.js.map +1 -1
- package/dist/view-launch-contract.d.ts +14 -0
- package/dist/view-launch-contract.d.ts.map +1 -0
- package/dist/view-launch-contract.js +23 -0
- package/dist/view-launch-contract.js.map +1 -0
- package/dist/write-identity.d.ts +5 -0
- package/dist/write-identity.d.ts.map +1 -0
- package/dist/write-identity.js +9 -0
- package/dist/write-identity.js.map +1 -0
- package/package.json +188 -10
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { captureNewDocumentIntent } from "./journaled-backend.js";
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* The API is experimental (`0.2.0-pre`) and may change before a stable release. The on-disk
|
|
5
|
+
* format is a supported compatibility promise, because the hosted client's durable journal
|
|
6
|
+
* (`openHostedClientJournal`) keeps app state in it: a format bump ships a reader for the older
|
|
7
|
+
* layout, or a migration.
|
|
3
8
|
*
|
|
4
9
|
* A Node {@link JournaledBackend}: the private store behind a CLI working copy, proven by the
|
|
5
10
|
* same contract kit as the IndexedDB adapter. It is an append-only, checksummed transaction log
|
|
@@ -37,20 +42,28 @@
|
|
|
37
42
|
*/
|
|
38
43
|
import { promises as fs } from "node:fs";
|
|
39
44
|
import path from "node:path";
|
|
45
|
+
import { assertBlobKey } from "./blob-contract.js";
|
|
46
|
+
import { BLOB_JOURNAL_BOUNDS, captureBlobAdmission, captureBlobForget, captureBlobIntentRecord, captureBlobMetaWrite, captureBlobRetirement, captureBlobUpdate, decideBlobAdmission, decideBlobForget, decideBlobMetaWrite, decideBlobRetirement, decideBlobUpdate, readBlobJournal, } from "./blob-journal.js";
|
|
40
47
|
import { resolveContentType } from "./content-type.js";
|
|
41
|
-
import { OPEN_LOG, STORE_RAW } from "./file-journaled-backend-internal.js";
|
|
48
|
+
import { OPEN_LOG, STORE_RAW, STORE_BYTE_LIMIT } from "./file-journaled-backend-internal.js";
|
|
42
49
|
import { captureFilesystemHostPolicy } from "./filesystem-host.js";
|
|
43
50
|
import { acquireFilesystemMutationLock } from "./filesystem-lock.js";
|
|
44
51
|
import { MalformedDocumentError, parseMarkdown, stringifyDoc } from "./frontmatter.js";
|
|
45
52
|
import { assertDeletionIntent, assertJournalGuard, assertJournalIntentChanges, assertJournalMetaChanges, assertJournalResolutionOptions, assertJournalSnapshot, assertMetaWrite, captureIntentUpdate, captureJournalDeleteOptions, captureJournalGuardOption, captureJournalValue, captureJournalWriteOptions, captureMetaWrite, captureRetireAcknowledged, deletionIntentRecord, IntentHoldConflict, IntentStateConflict, JournalGuardConflict, JournalSnapshotConflict, } from "./journaled-backend.js";
|
|
46
53
|
import { mutationActorFromFrontmatter } from "./mutation-attribution.js";
|
|
47
54
|
import { assertSafeBlobKey, assertSafeConceptId, assertSafeReservedDir, assertSafeReservedFilename, compareStorageKeys, pathFromConceptId } from "./paths.js";
|
|
55
|
+
import { assertStorableReservedWrite } from "./reserved-write.js";
|
|
48
56
|
import { parseLeadingFrontmatter } from "./portable-frontmatter.js";
|
|
49
57
|
import { sha256HexOfBytes } from "./sha256.js";
|
|
50
58
|
import { blobVersion, defaultActor, VersionConflict, versionOfBytes } from "./versioning.js";
|
|
51
59
|
// ── on-disk format ─────────────────────────────────────────────────────────────────────────
|
|
52
|
-
/**
|
|
53
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The newest layout this adapter writes and reads; it reads every earlier one too. A store stays
|
|
62
|
+
* at format 1 until it holds a blob intent (format 2), and at 2 until a blob intent carries
|
|
63
|
+
* not-dispatched evidence (format 3); the store keeps the highest format it has written. Bumping
|
|
64
|
+
* this requires a reader for the older layouts; open refuses any newer format.
|
|
65
|
+
*/
|
|
66
|
+
export const FILE_JOURNAL_FORMAT_VERSION = 3;
|
|
54
67
|
export const FILE_JOURNAL_LOG = "store.log";
|
|
55
68
|
export const FILE_JOURNAL_SNAPSHOT = "store.snapshot";
|
|
56
69
|
const SNAPSHOT_TEMP = "store.snapshot.tmp";
|
|
@@ -62,8 +75,14 @@ const HEADER = 44;
|
|
|
62
75
|
/** A record larger than this is refused at write and read as corruption at open. */
|
|
63
76
|
const MAXIMUM_RECORD_BYTES = 256 * 1024 * 1024;
|
|
64
77
|
const DEFAULT_COMPACT_AFTER_BYTES = 8 * 1024 * 1024;
|
|
78
|
+
const isDocumentIntent = (row) => !("recordFamily" in row);
|
|
79
|
+
const documentIntents = (state) => [...state.intents.values()].filter(isDocumentIntent);
|
|
80
|
+
const documentIntent = (state, id) => {
|
|
81
|
+
const row = state.intents.get(id);
|
|
82
|
+
return row && isDocumentIntent(row) ? row : undefined;
|
|
83
|
+
};
|
|
65
84
|
function emptyState() {
|
|
66
|
-
return { documents: new Map(), reserved: new Map(), blobs: new Map(), intents: new Map(), meta: new Map(), sequence: 0 };
|
|
85
|
+
return { format: 1, documents: new Map(), reserved: new Map(), blobs: new Map(), intents: new Map(), meta: new Map(), sequence: 0 };
|
|
67
86
|
}
|
|
68
87
|
function applyChanges(state, changes) {
|
|
69
88
|
for (const change of changes) {
|
|
@@ -120,7 +139,7 @@ export class FileJournalFormatError extends FileJournalCorruptError {
|
|
|
120
139
|
name = "FileJournalFormatError";
|
|
121
140
|
format;
|
|
122
141
|
constructor(file, format, offset) {
|
|
123
|
-
super(file, `written in store format ${format}; this adapter reads
|
|
142
|
+
super(file, `written in store format ${format}; this adapter reads formats 1 to ${FILE_JOURNAL_FORMAT_VERSION}`, offset);
|
|
124
143
|
this.format = format;
|
|
125
144
|
}
|
|
126
145
|
}
|
|
@@ -297,10 +316,10 @@ const encodePayload = (value) => utf8.encode(JSON.stringify(encodeValue(value, n
|
|
|
297
316
|
const decodePayload = (bytes) => decodeValue(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes)));
|
|
298
317
|
// ── framing ────────────────────────────────────────────────────────────────────────────────
|
|
299
318
|
/** magic (4) + format version (4) + payload length (4) + SHA-256 of the payload (32), then the payload. */
|
|
300
|
-
function frame(magic, payload) {
|
|
319
|
+
function frame(magic, payload, format) {
|
|
301
320
|
const out = Buffer.alloc(HEADER + payload.byteLength);
|
|
302
321
|
out.writeUInt32BE(magic, 0);
|
|
303
|
-
out.writeUInt32BE(
|
|
322
|
+
out.writeUInt32BE(format, 4);
|
|
304
323
|
out.writeUInt32BE(payload.byteLength, 8);
|
|
305
324
|
Buffer.from(sha256HexOfBytes(payload), "hex").copy(out, 12);
|
|
306
325
|
Buffer.from(payload.buffer, payload.byteOffset, payload.byteLength).copy(out, HEADER);
|
|
@@ -347,7 +366,7 @@ function scanLog(bytes, file) {
|
|
|
347
366
|
throw new FileJournalCorruptError(file, "a damaged record is followed by a whole one", at);
|
|
348
367
|
return { records, validBytes: at, totalBytes: bytes.byteLength };
|
|
349
368
|
}
|
|
350
|
-
if (found.format
|
|
369
|
+
if (!readableFormat(found.format))
|
|
351
370
|
throw new FileJournalFormatError(file, found.format, at);
|
|
352
371
|
let record;
|
|
353
372
|
try {
|
|
@@ -358,6 +377,10 @@ function scanLog(bytes, file) {
|
|
|
358
377
|
}
|
|
359
378
|
if (!record || !Number.isSafeInteger(record.txn) || !Array.isArray(record.changes))
|
|
360
379
|
throw new FileJournalCorruptError(file, "record has no transaction number or changes", at);
|
|
380
|
+
if ((found.format >= 2 ? record.format !== found.format : record.format !== undefined && record.format !== 1))
|
|
381
|
+
throw new FileJournalCorruptError(file, "record format does not match its frame", at);
|
|
382
|
+
validateIntentChanges(record.changes, found.format, file);
|
|
383
|
+
record.format = found.format;
|
|
361
384
|
records.push(record);
|
|
362
385
|
at = found.end;
|
|
363
386
|
}
|
|
@@ -369,7 +392,7 @@ function decodeSnapshot(bytes, file) {
|
|
|
369
392
|
const found = frameAt(bytes, 0, SNAPSHOT_MAGIC);
|
|
370
393
|
if (!found || found.end !== bytes.byteLength)
|
|
371
394
|
throw new FileJournalCorruptError(file, "snapshot checksum or length does not match");
|
|
372
|
-
if (found.format
|
|
395
|
+
if (!readableFormat(found.format))
|
|
373
396
|
throw new FileJournalFormatError(file, found.format);
|
|
374
397
|
let decoded;
|
|
375
398
|
try {
|
|
@@ -378,10 +401,81 @@ function decodeSnapshot(bytes, file) {
|
|
|
378
401
|
catch {
|
|
379
402
|
throw new FileJournalCorruptError(file, "snapshot checksum matches but its payload does not decode");
|
|
380
403
|
}
|
|
381
|
-
if (!decoded || decoded.format !==
|
|
404
|
+
if (!decoded || decoded.format !== found.format || !Number.isSafeInteger(decoded.txn) || !Number.isSafeInteger(decoded.sequence))
|
|
382
405
|
throw new FileJournalCorruptError(file, "snapshot has no transaction number");
|
|
406
|
+
if (!Array.isArray(decoded.intents))
|
|
407
|
+
throw new FileJournalCorruptError(file, "snapshot has no intent records");
|
|
408
|
+
validateIntentChanges(decoded.intents.map(([key, value]) => ({ family: "intent", key, value })), found.format, file);
|
|
383
409
|
return decoded;
|
|
384
410
|
}
|
|
411
|
+
const readableFormat = (format) => Number.isSafeInteger(format) && format >= 1 && format <= FILE_JOURNAL_FORMAT_VERSION;
|
|
412
|
+
/** The layout a blob intent needs: not-dispatched evidence first appeared in format 3. */
|
|
413
|
+
const blobIntentFormat = (row) => ("notDispatched" in row ? 3 : 2);
|
|
414
|
+
function validateIntentChanges(changes, format, file) {
|
|
415
|
+
for (const change of changes) {
|
|
416
|
+
if (change.family !== "intent" || change.value === null)
|
|
417
|
+
continue;
|
|
418
|
+
const row = change.value;
|
|
419
|
+
if (!("recordFamily" in row) && row.bodyReplace !== undefined) {
|
|
420
|
+
try {
|
|
421
|
+
captureNewDocumentIntent(row);
|
|
422
|
+
}
|
|
423
|
+
catch {
|
|
424
|
+
throw new FileJournalCorruptError(file, "invalid document edit intent");
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
if ("recordFamily" in row) {
|
|
428
|
+
if (row.recordFamily !== "blob" || format < 2)
|
|
429
|
+
throw new FileJournalCorruptError(file, "blob intent is not allowed in this format");
|
|
430
|
+
if (blobIntentFormat(row) > format)
|
|
431
|
+
throw new FileJournalCorruptError(file, "blob not-dispatched evidence is not allowed in this format");
|
|
432
|
+
try {
|
|
433
|
+
captureBlobIntentRecord(row);
|
|
434
|
+
assertReceiptBound(row);
|
|
435
|
+
}
|
|
436
|
+
catch {
|
|
437
|
+
throw new FileJournalCorruptError(file, "invalid blob intent payload");
|
|
438
|
+
}
|
|
439
|
+
if (row.requestId !== change.key)
|
|
440
|
+
throw new FileJournalCorruptError(file, "blob identity index mismatch");
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
function snapshotPayload(state, txn) {
|
|
445
|
+
return { format: state.format, txn, sequence: state.sequence, documents: [...state.documents], reserved: [...state.reserved], blobs: [...state.blobs], intents: [...state.intents], meta: [...state.meta] };
|
|
446
|
+
}
|
|
447
|
+
/** Terminal evidence must fit the space protected when its pending record was admitted. */
|
|
448
|
+
function assertReceiptBound(row) {
|
|
449
|
+
if (row.receipt !== undefined)
|
|
450
|
+
assertByteBound(encodePayload(row.receipt), BLOB_JOURNAL_BOUNDS.terminalReceiptBytes, "blob terminal receipt");
|
|
451
|
+
}
|
|
452
|
+
/** Derived from existing records only: no persisted reservation map or quota ledger. The
|
|
453
|
+
* mutable projection (including transaction-number width) is subtracted so claiming an
|
|
454
|
+
* attempt/state cannot consume its own reserve.
|
|
455
|
+
* The 4 KiB structural allowance covers the terminal record envelope/tagging and counter/time
|
|
456
|
+
* changes; the additional 16 KiB is aggregate encoded growth of ordinary baseline metadata.
|
|
457
|
+
* Arbitrary extra metadata growth still requires unreserved store capacity. */
|
|
458
|
+
function settlementReserve(state, txn) {
|
|
459
|
+
let reserved = 0;
|
|
460
|
+
for (const row of state.intents.values()) {
|
|
461
|
+
if (isDocumentIntent(row))
|
|
462
|
+
continue;
|
|
463
|
+
// All stored blob rows passed captureBlobIntentRecord and assertReceiptBound, including
|
|
464
|
+
// replay. Unknown/nonterminal evidence can never release this allocation.
|
|
465
|
+
if (row.receipt !== undefined && ["acknowledged", "refused", "conflict"].includes(row.state))
|
|
466
|
+
continue;
|
|
467
|
+
const mutableBytes = encodePayload({ state: row.state, attempts: row.attempts, updatedAt: row.updatedAt, transaction: txn, ...(row.notAppliedThrough === undefined ? {} : { notAppliedThrough: row.notAppliedThrough }), ...(row.deletionHold === undefined ? {} : { deletionHold: row.deletionHold }), ...(row.notDispatched === undefined ? {} : { notDispatched: row.notDispatched }) }).byteLength;
|
|
468
|
+
const remaining = BLOB_JOURNAL_BOUNDS.terminalReceiptBytes + BLOB_JOURNAL_BOUNDS.settlementStructureBytes + BLOB_JOURNAL_BOUNDS.baselineBytes - mutableBytes;
|
|
469
|
+
if (!Number.isSafeInteger(remaining) || remaining < 0 || !Number.isSafeInteger(reserved + remaining))
|
|
470
|
+
throw new RangeError("blob settlement reserve is not representable");
|
|
471
|
+
reserved += remaining;
|
|
472
|
+
}
|
|
473
|
+
return reserved;
|
|
474
|
+
}
|
|
475
|
+
function assertByteBound(payload, maximum, family) {
|
|
476
|
+
if (payload.byteLength > maximum)
|
|
477
|
+
throw new RangeError(`a ${family} of ${payload.byteLength} bytes exceeds the store's ${maximum} byte bound`);
|
|
478
|
+
}
|
|
385
479
|
// ── helpers shared with the other adapters' record handling ────────────────────────────────
|
|
386
480
|
function notFound(id) {
|
|
387
481
|
const err = new Error(`no concept document '${id}'`);
|
|
@@ -506,8 +600,12 @@ export class FileJournaledBackend {
|
|
|
506
600
|
#release;
|
|
507
601
|
#policy;
|
|
508
602
|
#txn;
|
|
603
|
+
#maximumBytes = MAXIMUM_RECORD_BYTES;
|
|
509
604
|
#logBytes;
|
|
510
605
|
#queue = Promise.resolve();
|
|
606
|
+
/** Blob claims this handle made, by request id, at their attempt count. The exclusive lock means
|
|
607
|
+
* any `in_flight` row found at open was claimed by a process that has since died. */
|
|
608
|
+
#claims = new Map();
|
|
511
609
|
#unavailable = null;
|
|
512
610
|
#closing = null;
|
|
513
611
|
#readOnly = false;
|
|
@@ -526,11 +624,11 @@ export class FileJournaledBackend {
|
|
|
526
624
|
* file. Compacts when the log is larger than `compactAfterBytes`.
|
|
527
625
|
*/
|
|
528
626
|
static open(options) {
|
|
529
|
-
return
|
|
627
|
+
return _a.#open(options, (file) => fs.open(file, "r+"));
|
|
530
628
|
}
|
|
531
629
|
/** @internal The test seam: open with a substitute log handle. Reachable only through {@link OPEN_LOG}. */
|
|
532
630
|
static [OPEN_LOG](options, openLog) {
|
|
533
|
-
return
|
|
631
|
+
return _a.#open(options, openLog);
|
|
534
632
|
}
|
|
535
633
|
static async #open(options, openLog) {
|
|
536
634
|
if (typeof options.directory !== "string" || options.directory.trim() === "")
|
|
@@ -565,9 +663,13 @@ export class FileJournaledBackend {
|
|
|
565
663
|
const logRead = await readIfPresent(logFile);
|
|
566
664
|
const logBytes = logRead ?? Buffer.alloc(0);
|
|
567
665
|
const scanned = scanLog(logBytes, logFile);
|
|
666
|
+
const maximumBytes = options[STORE_BYTE_LIMIT] ?? MAXIMUM_RECORD_BYTES;
|
|
667
|
+
if (!Number.isSafeInteger(maximumBytes) || maximumBytes < 1 || maximumBytes > MAXIMUM_RECORD_BYTES)
|
|
668
|
+
throw new TypeError("invalid store byte bound");
|
|
568
669
|
const state = emptyState();
|
|
569
670
|
let txn = 0;
|
|
570
671
|
if (snapshot) {
|
|
672
|
+
state.format = snapshot.format;
|
|
571
673
|
state.documents = new Map(snapshot.documents);
|
|
572
674
|
state.reserved = new Map(snapshot.reserved);
|
|
573
675
|
state.blobs = new Map(snapshot.blobs);
|
|
@@ -582,11 +684,15 @@ export class FileJournaledBackend {
|
|
|
582
684
|
continue;
|
|
583
685
|
if (record.txn !== txn + 1)
|
|
584
686
|
throw new FileJournalCorruptError(logFile, `transaction ${record.txn} follows ${txn}`);
|
|
687
|
+
if (record.format < state.format)
|
|
688
|
+
throw new FileJournalCorruptError(logFile, "store format regressed");
|
|
689
|
+
state.format = record.format;
|
|
585
690
|
applyChanges(state, record.changes);
|
|
586
691
|
txn = record.txn;
|
|
587
692
|
}
|
|
588
693
|
if (options.readOnly) {
|
|
589
|
-
const backend = new
|
|
694
|
+
const backend = new _a(directory, state, READ_ONLY_LOG, release, txn, scanned.validBytes, policy);
|
|
695
|
+
backend.#maximumBytes = maximumBytes;
|
|
590
696
|
backend.#readOnly = true;
|
|
591
697
|
return backend;
|
|
592
698
|
}
|
|
@@ -600,7 +706,8 @@ export class FileJournaledBackend {
|
|
|
600
706
|
await log.truncate(scanned.validBytes);
|
|
601
707
|
await log.sync();
|
|
602
708
|
}
|
|
603
|
-
const backend = new
|
|
709
|
+
const backend = new _a(directory, state, log, release, txn, scanned.validBytes, policy);
|
|
710
|
+
backend.#maximumBytes = maximumBytes;
|
|
604
711
|
if (scanned.validBytes > compactAfter)
|
|
605
712
|
await backend.compact();
|
|
606
713
|
return backend;
|
|
@@ -639,17 +746,9 @@ export class FileJournaledBackend {
|
|
|
639
746
|
compact() {
|
|
640
747
|
return this.#serial(async () => {
|
|
641
748
|
const state = this.#state;
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
sequence: state.sequence,
|
|
646
|
-
documents: [...state.documents],
|
|
647
|
-
reserved: [...state.reserved],
|
|
648
|
-
blobs: [...state.blobs],
|
|
649
|
-
intents: [...state.intents],
|
|
650
|
-
meta: [...state.meta],
|
|
651
|
-
};
|
|
652
|
-
const bytes = frame(SNAPSHOT_MAGIC, encodePayload(payload));
|
|
749
|
+
const encoded = encodePayload(snapshotPayload(state, this.#txn));
|
|
750
|
+
assertByteBound(encoded, this.#maximumBytes, "snapshot");
|
|
751
|
+
const bytes = frame(SNAPSHOT_MAGIC, encoded, state.format);
|
|
653
752
|
const temp = path.join(this.directory, SNAPSHOT_TEMP);
|
|
654
753
|
const handle = await fs.open(temp, "w", 0o600);
|
|
655
754
|
try {
|
|
@@ -697,14 +796,25 @@ export class FileJournaledBackend {
|
|
|
697
796
|
*/
|
|
698
797
|
#mutate(decide) {
|
|
699
798
|
return this.#serial(async () => {
|
|
700
|
-
const { changes, result } = decide(this.#state);
|
|
701
|
-
if (changes.length === 0)
|
|
799
|
+
const { changes, result, format, afterCommit } = decide(this.#state);
|
|
800
|
+
if (changes.length === 0) {
|
|
801
|
+
afterCommit?.();
|
|
702
802
|
return result;
|
|
703
|
-
|
|
803
|
+
}
|
|
804
|
+
const nextFormat = Math.max(this.#state.format, format ?? 1);
|
|
805
|
+
const record = { ...(nextFormat >= 2 ? { format: nextFormat } : {}), txn: this.#txn + 1, changes };
|
|
704
806
|
const payload = encodePayload(record);
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
807
|
+
assertByteBound(payload, this.#maximumBytes, "transaction");
|
|
808
|
+
const projected = { ...this.#state, format: nextFormat, documents: new Map(this.#state.documents), reserved: new Map(this.#state.reserved), blobs: new Map(this.#state.blobs), intents: new Map(this.#state.intents), meta: new Map(this.#state.meta) };
|
|
809
|
+
applyChanges(projected, changes);
|
|
810
|
+
const snapshotBytes = encodePayload(snapshotPayload(projected, record.txn));
|
|
811
|
+
assertByteBound(snapshotBytes, this.#maximumBytes, "projected snapshot");
|
|
812
|
+
if (nextFormat >= 2) {
|
|
813
|
+
const reserved = settlementReserve(projected, record.txn);
|
|
814
|
+
if (snapshotBytes.byteLength + reserved > this.#maximumBytes)
|
|
815
|
+
throw new RangeError(`a projected snapshot of ${snapshotBytes.byteLength} bytes plus ${reserved} bytes of blob settlement reserve exceeds the store's ${this.#maximumBytes} byte bound`);
|
|
816
|
+
}
|
|
817
|
+
const bytes = frame(RECORD_MAGIC, payload, nextFormat);
|
|
708
818
|
const at = this.#logBytes;
|
|
709
819
|
try {
|
|
710
820
|
await writeAll(this.#log, bytes, at);
|
|
@@ -722,7 +832,9 @@ export class FileJournaledBackend {
|
|
|
722
832
|
}
|
|
723
833
|
this.#logBytes = at + bytes.byteLength;
|
|
724
834
|
this.#txn = record.txn;
|
|
835
|
+
this.#state.format = nextFormat;
|
|
725
836
|
applyChanges(this.#state, changes);
|
|
837
|
+
afterCommit?.();
|
|
726
838
|
return result;
|
|
727
839
|
});
|
|
728
840
|
}
|
|
@@ -813,8 +925,7 @@ export class FileJournaledBackend {
|
|
|
813
925
|
return record ? { content: record.content, version: record.version } : null;
|
|
814
926
|
}
|
|
815
927
|
async writeReserved(dir, name, content, options = {}) {
|
|
816
|
-
|
|
817
|
-
assertSafeReservedFilename(name);
|
|
928
|
+
assertStorableReservedWrite(dir, name, content);
|
|
818
929
|
const key = reservedKey(dir, name);
|
|
819
930
|
const version = versionOfBytes(content);
|
|
820
931
|
const expected = options.expectedVersion;
|
|
@@ -876,12 +987,12 @@ export class FileJournaledBackend {
|
|
|
876
987
|
assertJournalGuard(guard, {
|
|
877
988
|
target: guard.target,
|
|
878
989
|
document: document ? { version: document.version, raw: document.raw } : null,
|
|
879
|
-
intents:
|
|
990
|
+
intents: documentIntents(state).filter((row) => row.target === guard.target),
|
|
880
991
|
meta: guard.meta.map((row) => ({ key: row.key, expected: state.meta.has(row.key) ? { present: true, value: state.meta.get(row.key) } : { present: false } })),
|
|
881
992
|
});
|
|
882
993
|
}
|
|
883
994
|
static #holder(state, id) {
|
|
884
|
-
return
|
|
995
|
+
return documentIntents(state).sort(bySequence).find((row) => row.target === id && row.state !== "acknowledged");
|
|
885
996
|
}
|
|
886
997
|
static #metaChanges(puts, removals = []) {
|
|
887
998
|
return [
|
|
@@ -899,6 +1010,8 @@ export class FileJournaledBackend {
|
|
|
899
1010
|
}
|
|
900
1011
|
assertSafeConceptId(id);
|
|
901
1012
|
assertJournalResolutionOptions(id, options);
|
|
1013
|
+
if (options.intent)
|
|
1014
|
+
options = { ...options, intent: captureNewDocumentIntent(options.intent) };
|
|
902
1015
|
if (snapshotGuard && (doc.id !== id || (options.intent && options.intent.target !== id)))
|
|
903
1016
|
throw new JournalGuardConflict(id);
|
|
904
1017
|
const raw = stringifyDoc(doc.frontmatter, doc.body ?? "");
|
|
@@ -908,6 +1021,8 @@ export class FileJournaledBackend {
|
|
|
908
1021
|
const meta = structuredClone(producedMeta);
|
|
909
1022
|
const removeMeta = options.removeMeta ? [...options.removeMeta] : [];
|
|
910
1023
|
const intent = options.intent ? structuredClone(options.intent) : undefined;
|
|
1024
|
+
if (intent && "recordFamily" in intent)
|
|
1025
|
+
throw new JournalGuardConflict(id);
|
|
911
1026
|
const supersede = options.supersede ? { ...options.supersede } : undefined;
|
|
912
1027
|
const resolveIntents = options.resolveIntents ? structuredClone(options.resolveIntents) : undefined;
|
|
913
1028
|
const { requireSettled } = options;
|
|
@@ -917,10 +1032,12 @@ export class FileJournaledBackend {
|
|
|
917
1032
|
return this.#mutate((state) => {
|
|
918
1033
|
this.#checkGuard(state, snapshotGuard);
|
|
919
1034
|
assertJournalIntentChanges(snapshotGuard, intent ? state.intents.get(intent.requestId) : undefined, supersede ? state.intents.get(supersede.requestId) : undefined);
|
|
1035
|
+
if (intent && state.intents.has(intent.requestId))
|
|
1036
|
+
throw new JournalSnapshotConflict(id);
|
|
920
1037
|
if (resolveIntents)
|
|
921
|
-
assertJournalSnapshot(id, resolveIntents.expected,
|
|
1038
|
+
assertJournalSnapshot(id, resolveIntents.expected, documentIntents(state), intent?.requestId);
|
|
922
1039
|
if (requireSettled) {
|
|
923
|
-
const holder =
|
|
1040
|
+
const holder = _a.#holder(state, id);
|
|
924
1041
|
if (holder)
|
|
925
1042
|
throw new IntentHoldConflict(id, holder.requestId, holder.state);
|
|
926
1043
|
}
|
|
@@ -928,7 +1045,7 @@ export class FileJournaledBackend {
|
|
|
928
1045
|
if (expected !== undefined && expected !== current)
|
|
929
1046
|
throw new VersionConflict(id, expected, current);
|
|
930
1047
|
if (supersede) {
|
|
931
|
-
const existing = state
|
|
1048
|
+
const existing = documentIntent(state, supersede.requestId);
|
|
932
1049
|
if (!existing || existing.state !== supersede.expectedState || existing.attempts !== supersede.expectedAttempts)
|
|
933
1050
|
throw new IntentStateConflict(supersede.requestId, supersede.expectedState, existing?.state ?? null);
|
|
934
1051
|
}
|
|
@@ -943,7 +1060,7 @@ export class FileJournaledBackend {
|
|
|
943
1060
|
record = { ...intent, local: version, content: raw, sequence, attempts: 0, state: "pending", updatedAt: now };
|
|
944
1061
|
changes.push({ family: "sequence", value: sequence }, { family: "intent", key: record.requestId, value: structuredClone(record) });
|
|
945
1062
|
}
|
|
946
|
-
changes.push(...
|
|
1063
|
+
changes.push(..._a.#metaChanges(meta, removeMeta));
|
|
947
1064
|
return { changes, result: { version, raw, intent: record } };
|
|
948
1065
|
});
|
|
949
1066
|
}
|
|
@@ -954,20 +1071,22 @@ export class FileJournaledBackend {
|
|
|
954
1071
|
assertDeletionIntent(id, options);
|
|
955
1072
|
const captured = structuredClone({ meta: options.meta ?? [], removeMeta: [...(options.removeMeta ?? [])], onHeld: options.onHeld, resolveIntents: options.resolveIntents, intent: options.intent, supersede: options.supersede });
|
|
956
1073
|
const { guard, requireSettled } = options;
|
|
1074
|
+
if (captured.intent && "recordFamily" in captured.intent)
|
|
1075
|
+
throw new JournalGuardConflict(id);
|
|
957
1076
|
const expected = options.expectedVersion;
|
|
958
1077
|
const now = new Date().toISOString();
|
|
959
1078
|
return this.#mutate((state) => {
|
|
960
1079
|
this.#checkGuard(state, guard);
|
|
961
1080
|
if (captured.resolveIntents)
|
|
962
|
-
assertJournalSnapshot(id, captured.resolveIntents.expected,
|
|
1081
|
+
assertJournalSnapshot(id, captured.resolveIntents.expected, documentIntents(state), captured.intent?.requestId);
|
|
963
1082
|
if (captured.intent && state.intents.has(captured.intent.requestId))
|
|
964
1083
|
throw new JournalSnapshotConflict(id);
|
|
965
1084
|
if (requireSettled) {
|
|
966
|
-
const holder =
|
|
1085
|
+
const holder = _a.#holder(state, id);
|
|
967
1086
|
if (holder) {
|
|
968
1087
|
if (!captured.onHeld)
|
|
969
1088
|
throw new IntentHoldConflict(id, holder.requestId, holder.state);
|
|
970
|
-
return { changes:
|
|
1089
|
+
return { changes: _a.#metaChanges(captured.onHeld.meta), result: { outcome: "held", requestId: holder.requestId, state: holder.state } };
|
|
971
1090
|
}
|
|
972
1091
|
}
|
|
973
1092
|
const current = state.documents.get(id)?.version ?? null;
|
|
@@ -975,7 +1094,7 @@ export class FileJournaledBackend {
|
|
|
975
1094
|
throw new VersionConflict(id, expected, current);
|
|
976
1095
|
const { supersede } = captured;
|
|
977
1096
|
if (supersede) {
|
|
978
|
-
const existing = state
|
|
1097
|
+
const existing = documentIntent(state, supersede.requestId);
|
|
979
1098
|
if (!existing || existing.target !== id || existing.state !== supersede.expectedState || existing.attempts !== supersede.expectedAttempts)
|
|
980
1099
|
throw new IntentStateConflict(supersede.requestId, supersede.expectedState, existing?.state ?? null);
|
|
981
1100
|
}
|
|
@@ -992,7 +1111,7 @@ export class FileJournaledBackend {
|
|
|
992
1111
|
record = deletionIntentRecord(captured.intent, sequence, now);
|
|
993
1112
|
changes.push({ family: "sequence", value: sequence }, { family: "intent", key: record.requestId, value: structuredClone(record) });
|
|
994
1113
|
}
|
|
995
|
-
changes.push(...
|
|
1114
|
+
changes.push(..._a.#metaChanges(captured.meta, captured.removeMeta));
|
|
996
1115
|
return { changes, result: { outcome: current !== null ? "deleted" : "absent", ...(record ? { intent: record } : {}) } };
|
|
997
1116
|
});
|
|
998
1117
|
}
|
|
@@ -1001,7 +1120,7 @@ export class FileJournaledBackend {
|
|
|
1001
1120
|
this.#assertOpen();
|
|
1002
1121
|
const state = this.#state;
|
|
1003
1122
|
const record = state.documents.get(id);
|
|
1004
|
-
const intents =
|
|
1123
|
+
const intents = documentIntents(state).filter((row) => row.target === id).sort(bySequence).map((row) => structuredClone(row));
|
|
1005
1124
|
const meta = new Map();
|
|
1006
1125
|
for (const key of options.meta ?? []) {
|
|
1007
1126
|
if (state.meta.has(key))
|
|
@@ -1021,7 +1140,7 @@ export class FileJournaledBackend {
|
|
|
1021
1140
|
// One synchronous pass: no mutation can apply between the first row and the last.
|
|
1022
1141
|
const edition = editionOf(state.reserved.get(reservedKey("", "index.md")));
|
|
1023
1142
|
const byTarget = new Map();
|
|
1024
|
-
for (const row of state
|
|
1143
|
+
for (const row of documentIntents(state)) {
|
|
1025
1144
|
const list = byTarget.get(row.target);
|
|
1026
1145
|
if (list)
|
|
1027
1146
|
list.push(row);
|
|
@@ -1049,15 +1168,17 @@ export class FileJournaledBackend {
|
|
|
1049
1168
|
async listIntents(state) {
|
|
1050
1169
|
this.#assertOpen();
|
|
1051
1170
|
const wanted = state === undefined ? null : new Set(typeof state === "string" ? [state] : state);
|
|
1052
|
-
return
|
|
1171
|
+
return documentIntents(this.#state).filter((row) => !wanted || wanted.has(row.state)).sort(bySequence).map((row) => structuredClone(row));
|
|
1053
1172
|
}
|
|
1054
1173
|
async readIntent(requestId) {
|
|
1055
1174
|
this.#assertOpen();
|
|
1056
|
-
const row = this.#state
|
|
1175
|
+
const row = documentIntent(this.#state, requestId);
|
|
1057
1176
|
return row ? structuredClone(row) : undefined;
|
|
1058
1177
|
}
|
|
1059
1178
|
async updateIntent(requestId, expectedState, patch, options = {}) {
|
|
1060
1179
|
({ patch, options } = captureIntentUpdate(patch, options));
|
|
1180
|
+
if ("recordFamily" in patch)
|
|
1181
|
+
throw new JournalGuardConflict(requestId);
|
|
1061
1182
|
const now = new Date().toISOString();
|
|
1062
1183
|
const raw = options.document ? stringifyDoc(options.document.frontmatter, options.document.body ?? "") : undefined;
|
|
1063
1184
|
const replacement = raw === undefined ? undefined : { id: options.document.id, record: { raw, version: versionOfBytes(raw), updatedBy: defaultActor(), updatedAt: now } };
|
|
@@ -1065,7 +1186,7 @@ export class FileJournaledBackend {
|
|
|
1065
1186
|
const meta = options.meta ?? [];
|
|
1066
1187
|
return this.#mutate((state) => {
|
|
1067
1188
|
this.#checkGuard(state, guard);
|
|
1068
|
-
const current = state
|
|
1189
|
+
const current = documentIntent(state, requestId);
|
|
1069
1190
|
if (!current || current.state !== expectedState)
|
|
1070
1191
|
throw new IntentStateConflict(requestId, expectedState, current?.state ?? null);
|
|
1071
1192
|
if (guard && current.target !== guard.target)
|
|
@@ -1074,7 +1195,7 @@ export class FileJournaledBackend {
|
|
|
1074
1195
|
const changes = [];
|
|
1075
1196
|
if (replacement)
|
|
1076
1197
|
changes.push({ family: "document", key: replacement.id, value: replacement.record });
|
|
1077
|
-
changes.push({ family: "intent", key: requestId, value: structuredClone(next) }, ...
|
|
1198
|
+
changes.push({ family: "intent", key: requestId, value: structuredClone(next) }, ..._a.#metaChanges(meta));
|
|
1078
1199
|
return { changes, result: next };
|
|
1079
1200
|
});
|
|
1080
1201
|
}
|
|
@@ -1084,9 +1205,87 @@ export class FileJournaledBackend {
|
|
|
1084
1205
|
await this.#mutate((state) => {
|
|
1085
1206
|
this.#checkGuard(state, guard);
|
|
1086
1207
|
const changes = requestIds.map((key) => ({ family: "intent", key, value: null }));
|
|
1087
|
-
return { changes: [...changes, ...
|
|
1208
|
+
return { changes: [...changes, ..._a.#metaChanges([], removeMeta ?? [])], result: undefined };
|
|
1088
1209
|
});
|
|
1089
1210
|
}
|
|
1211
|
+
// ── optional ordinary-file journal (no filesystem/body mirror) ─────────────────────────
|
|
1212
|
+
/** The committed index as the pure blob transition owner reads it. */
|
|
1213
|
+
#blobView(state) {
|
|
1214
|
+
return {
|
|
1215
|
+
blobIntentsFor: key => [...state.intents.values()].filter((row) => !isDocumentIntent(row) && row.target === key),
|
|
1216
|
+
blobIntent: id => { const row = state.intents.get(id); return row && !isDocumentIntent(row) ? row : undefined; },
|
|
1217
|
+
intentState: id => state.intents.get(id)?.state ?? null,
|
|
1218
|
+
meta: key => state.meta.has(key) ? { present: true, value: state.meta.get(key) } : { present: false },
|
|
1219
|
+
sequence: state.sequence,
|
|
1220
|
+
claimedInThisSession: (id, attempts) => this.#claims.get(id) === attempts,
|
|
1221
|
+
};
|
|
1222
|
+
}
|
|
1223
|
+
/** A decided blob verb as one mutation: its changes, the format they need, and the session claims. */
|
|
1224
|
+
#blobDecision(decision) {
|
|
1225
|
+
const formats = decision.intents.flatMap(({ value }) => (value === null ? [] : [blobIntentFormat(value)]));
|
|
1226
|
+
const format = formats.length === 0 ? undefined : Math.max(...formats);
|
|
1227
|
+
return {
|
|
1228
|
+
changes: _a.#blobChanges(decision),
|
|
1229
|
+
result: decision.result,
|
|
1230
|
+
...(format === undefined ? {} : { format }),
|
|
1231
|
+
afterCommit: () => {
|
|
1232
|
+
if (decision.session) {
|
|
1233
|
+
if (decision.session.claimed === null)
|
|
1234
|
+
this.#claims.delete(decision.session.requestId);
|
|
1235
|
+
else
|
|
1236
|
+
this.#claims.set(decision.session.requestId, decision.session.claimed);
|
|
1237
|
+
}
|
|
1238
|
+
for (const { requestId, value } of decision.intents)
|
|
1239
|
+
if (value === null)
|
|
1240
|
+
this.#claims.delete(requestId);
|
|
1241
|
+
},
|
|
1242
|
+
};
|
|
1243
|
+
}
|
|
1244
|
+
/** A decided blob verb as one log record's changes. */
|
|
1245
|
+
static #blobChanges(decision) {
|
|
1246
|
+
return [
|
|
1247
|
+
...(decision.sequence === undefined ? [] : [{ family: "sequence", value: decision.sequence }]),
|
|
1248
|
+
...decision.intents.map(({ requestId, value }) => ({ family: "intent", key: requestId, value: value === null ? null : structuredClone(value) })),
|
|
1249
|
+
..._a.#metaChanges(decision.meta, decision.removeMeta),
|
|
1250
|
+
];
|
|
1251
|
+
}
|
|
1252
|
+
async readBlobWithJournal(key, options = {}) {
|
|
1253
|
+
assertBlobKey(key);
|
|
1254
|
+
this.#assertOpen();
|
|
1255
|
+
return readBlobJournal(this.#blobView(this.#state), key, options);
|
|
1256
|
+
}
|
|
1257
|
+
async writeBlobMeta(key, changes, options) {
|
|
1258
|
+
const captured = captureBlobMetaWrite(key, changes, options);
|
|
1259
|
+
await this.#mutate(state => this.#blobDecision(decideBlobMetaWrite(this.#blobView(state), captured)));
|
|
1260
|
+
}
|
|
1261
|
+
async admitPreparedBlob(prepared, options) {
|
|
1262
|
+
const captured = captureBlobAdmission(prepared, options);
|
|
1263
|
+
const now = new Date().toISOString();
|
|
1264
|
+
return this.#mutate(state => this.#blobDecision(decideBlobAdmission(this.#blobView(state), captured, now)));
|
|
1265
|
+
}
|
|
1266
|
+
async listBlobIntents(state) {
|
|
1267
|
+
this.#assertOpen();
|
|
1268
|
+
const wanted = state === undefined ? null : new Set(typeof state === "string" ? [state] : state);
|
|
1269
|
+
return [...this.#state.intents.values()].filter((row) => !isDocumentIntent(row) && (!wanted || wanted.has(row.state))).sort(bySequence).map(row => structuredClone(row));
|
|
1270
|
+
}
|
|
1271
|
+
async readBlobIntent(requestId) {
|
|
1272
|
+
this.#assertOpen();
|
|
1273
|
+
const row = this.#state.intents.get(requestId);
|
|
1274
|
+
return row && !isDocumentIntent(row) ? structuredClone(row) : undefined;
|
|
1275
|
+
}
|
|
1276
|
+
async updateBlobIntent(requestId, expectedState, patch, options) {
|
|
1277
|
+
const captured = captureBlobUpdate(requestId, expectedState, patch, options);
|
|
1278
|
+
const now = new Date().toISOString();
|
|
1279
|
+
return this.#mutate(state => this.#blobDecision(decideBlobUpdate(this.#blobView(state), captured, now, assertReceiptBound)));
|
|
1280
|
+
}
|
|
1281
|
+
async retireBlobIntents(key, requestIds, options) {
|
|
1282
|
+
const captured = captureBlobRetirement(key, requestIds, options);
|
|
1283
|
+
await this.#mutate(state => this.#blobDecision(decideBlobRetirement(this.#blobView(state), captured)));
|
|
1284
|
+
}
|
|
1285
|
+
async forgetBlobIntent(requestId, options) {
|
|
1286
|
+
const captured = captureBlobForget(requestId, options);
|
|
1287
|
+
await this.#mutate(state => this.#blobDecision(decideBlobForget(this.#blobView(state), captured)));
|
|
1288
|
+
}
|
|
1090
1289
|
async readMeta(key) {
|
|
1091
1290
|
this.#assertOpen();
|
|
1092
1291
|
return this.#state.meta.has(key) ? structuredClone(this.#state.meta.get(key)) : undefined;
|
|
@@ -1109,5 +1308,38 @@ export class FileJournaledBackend {
|
|
|
1109
1308
|
return { changes: [{ family: "meta", key, present: true, value: captured }], result: undefined };
|
|
1110
1309
|
});
|
|
1111
1310
|
}
|
|
1311
|
+
/**
|
|
1312
|
+
* Every meta row whose key starts with `prefix` (all rows when it is empty), in code-unit key
|
|
1313
|
+
* order, read in one synchronous pass over the last committed transaction. Values are copies.
|
|
1314
|
+
*/
|
|
1315
|
+
async listMeta(prefix = "") {
|
|
1316
|
+
if (typeof prefix !== "string")
|
|
1317
|
+
throw new TypeError("a meta prefix is a string");
|
|
1318
|
+
this.#assertOpen();
|
|
1319
|
+
const meta = this.#state.meta;
|
|
1320
|
+
const keys = [...meta.keys()].filter((key) => key.startsWith(prefix)).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
1321
|
+
return keys.map((key) => ({ key, value: structuredClone(meta.get(key)) }));
|
|
1322
|
+
}
|
|
1323
|
+
/**
|
|
1324
|
+
* Remove one meta row, compare-and-swap: `expected` is the row's presence and value as the
|
|
1325
|
+
* caller last read it, compared in the same transaction as the removal. A mismatch is
|
|
1326
|
+
* `JournalGuardConflict` and writes nothing. It resolves true when it removed the row and false
|
|
1327
|
+
* when the row was absent as expected, which writes nothing either.
|
|
1328
|
+
*/
|
|
1329
|
+
async removeMeta(key, options) {
|
|
1330
|
+
if (typeof key !== "string")
|
|
1331
|
+
throw new TypeError("a meta key is a string");
|
|
1332
|
+
if (!options || typeof options !== "object" || options.expected === undefined)
|
|
1333
|
+
throw new JournalGuardConflict(key);
|
|
1334
|
+
const { expected } = captureMetaWrite({ expected: options.expected });
|
|
1335
|
+
return this.#mutate((state) => {
|
|
1336
|
+
const actual = state.meta.has(key) ? { present: true, value: state.meta.get(key) } : { present: false };
|
|
1337
|
+
assertMetaWrite(key, { expected }, actual, []);
|
|
1338
|
+
if (!actual.present)
|
|
1339
|
+
return { changes: [], result: false };
|
|
1340
|
+
return { changes: [{ family: "meta", key, present: false }], result: true };
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1112
1343
|
}
|
|
1344
|
+
_a = FileJournaledBackend;
|
|
1113
1345
|
//# sourceMappingURL=file-journaled-backend.js.map
|