@superbee/core 0.2.0-pre.6 → 0.2.0-pre.60
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/README.md +1425 -0
- 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 +11 -5
- package/dist/bundle-ops.d.ts.map +1 -1
- package/dist/bundle-ops.js +17 -10
- 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 +55 -19
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +141 -111
- 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 +21 -0
- package/dist/file-journaled-backend-internal.d.ts.map +1 -0
- package/dist/file-journaled-backend-internal.js +12 -0
- package/dist/file-journaled-backend-internal.js.map +1 -0
- package/dist/file-journaled-backend.d.ts +160 -0
- package/dist/file-journaled-backend.d.ts.map +1 -0
- package/dist/file-journaled-backend.js +1345 -0
- package/dist/file-journaled-backend.js.map +1 -0
- 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 +19 -2
- package/dist/filesystem-lock.d.ts.map +1 -1
- package/dist/filesystem-lock.js +259 -17
- package/dist/filesystem-lock.js.map +1 -1
- package/dist/filesystem-push-role.d.ts +77 -0
- package/dist/filesystem-push-role.d.ts.map +1 -0
- package/dist/filesystem-push-role.js +165 -0
- package/dist/filesystem-push-role.js.map +1 -0
- 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 +8 -1
- package/dist/governed-body-write.d.ts.map +1 -1
- package/dist/governed-body-write.js +22 -8
- 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/host-text.d.ts +31 -0
- package/dist/host-text.d.ts.map +1 -0
- package/dist/host-text.js +77 -0
- package/dist/host-text.js.map +1 -0
- 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 +344 -0
- package/dist/hosted-transport/answer-rows.d.ts.map +1 -0
- package/dist/hosted-transport/answer-rows.js +596 -0
- package/dist/hosted-transport/answer-rows.js.map +1 -0
- 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 +166 -0
- package/dist/hosted-transport/carrier.d.ts.map +1 -0
- package/dist/hosted-transport/carrier.js +285 -0
- package/dist/hosted-transport/carrier.js.map +1 -0
- 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/history-pages.d.ts +55 -0
- package/dist/hosted-transport/history-pages.d.ts.map +1 -0
- package/dist/hosted-transport/history-pages.js +69 -0
- package/dist/hosted-transport/history-pages.js.map +1 -0
- package/dist/hosted-transport/index.d.ts +21 -0
- package/dist/hosted-transport/index.d.ts.map +1 -0
- package/dist/hosted-transport/index.js +21 -0
- package/dist/hosted-transport/index.js.map +1 -0
- package/dist/hosted-transport/operations.d.ts +91 -0
- package/dist/hosted-transport/operations.d.ts.map +1 -0
- package/dist/hosted-transport/operations.js +129 -0
- package/dist/hosted-transport/operations.js.map +1 -0
- package/dist/hosted-transport/paged-reads.d.ts +87 -0
- package/dist/hosted-transport/paged-reads.d.ts.map +1 -0
- package/dist/hosted-transport/paged-reads.js +238 -0
- package/dist/hosted-transport/paged-reads.js.map +1 -0
- 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 +266 -0
- package/dist/hosted-transport/read-adapter.d.ts.map +1 -0
- package/dist/hosted-transport/read-adapter.js +570 -0
- package/dist/hosted-transport/read-adapter.js.map +1 -0
- package/dist/hosted-transport/root-write.d.ts +114 -0
- package/dist/hosted-transport/root-write.d.ts.map +1 -0
- package/dist/hosted-transport/root-write.js +174 -0
- package/dist/hosted-transport/root-write.js.map +1 -0
- package/dist/hosted-transport/whole-document-transport.d.ts +223 -0
- package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -0
- package/dist/hosted-transport/whole-document-transport.js +500 -0
- package/dist/hosted-transport/whole-document-transport.js.map +1 -0
- 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 +65 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +54 -22
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +6 -32
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +82 -8
- 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 +86 -8
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +64 -69
- 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 +200 -0
- package/dist/kind-authoring.d.ts.map +1 -0
- package/dist/kind-authoring.js +539 -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 +117 -6
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +416 -29
- 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 +373 -65
- 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 +22 -2
- 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 +111 -0
- package/dist/portable-export.d.ts.map +1 -0
- package/dist/portable-export.js +448 -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 +22 -0
- package/dist/query-order.d.ts.map +1 -0
- package/dist/query-order.js +43 -0
- package/dist/query-order.js.map +1 -0
- 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 +67 -32
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +171 -39
- 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-error.d.ts +17 -1
- package/dist/remote-error.d.ts.map +1 -1
- package/dist/remote-error.js +32 -2
- package/dist/remote-error.js.map +1 -1
- package/dist/remote-operations.d.ts +0 -40
- package/dist/remote-operations.d.ts.map +1 -1
- package/dist/remote-operations.js +28 -6
- package/dist/remote-operations.js.map +1 -1
- package/dist/remote-parsers.d.ts +20 -1
- package/dist/remote-parsers.d.ts.map +1 -1
- package/dist/remote-parsers.js +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 +54 -8
- 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 +164 -17
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +86 -30
- 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 +202 -8
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { InvalidInputError } from "./errors.js";
|
|
2
|
+
import { okfVersionOfRootIndex } from "./portable-frontmatter.js";
|
|
3
|
+
import { assertSafeConceptId, compareStorageKeys, isReservedFile, pathFromConceptId } from "./paths.js";
|
|
4
|
+
import { sha256HexOfUtf8 } from "./sha256.js";
|
|
5
|
+
/** Current writers using this exact store/root and namespace; excludes independently rooted overlap. */
|
|
6
|
+
export const INVENTORY_GUARD_DOMAIN = "cooperating-local-writers-v1";
|
|
7
|
+
export class InventoryGuardUnsupported extends Error {
|
|
8
|
+
written = false;
|
|
9
|
+
reason;
|
|
10
|
+
constructor(reason) { super(`Inventory guard unsupported: ${reason}`); this.name = "InventoryGuardUnsupported"; this.reason = reason; }
|
|
11
|
+
}
|
|
12
|
+
export class InventoryGuardConflict extends Error {
|
|
13
|
+
written = false;
|
|
14
|
+
reason;
|
|
15
|
+
constructor(reason) {
|
|
16
|
+
super(`Inventory guard premise changed: ${reason}`);
|
|
17
|
+
this.name = "InventoryGuardConflict";
|
|
18
|
+
this.reason = reason;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const capabilityOwners = new WeakMap();
|
|
22
|
+
/** Internal adapter binding, deliberately absent from public entrypoint exports. */
|
|
23
|
+
export function bindInventoryGuard(owner, guard) {
|
|
24
|
+
capabilityOwners.set(guard, owner);
|
|
25
|
+
return guard;
|
|
26
|
+
}
|
|
27
|
+
export function inventoryGuardFor(backend) {
|
|
28
|
+
let guard;
|
|
29
|
+
try {
|
|
30
|
+
guard = backend.inventoryGuard;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error instanceof InventoryGuardUnsupported)
|
|
34
|
+
throw error;
|
|
35
|
+
throw new InventoryGuardUnsupported("adapter_guard_unavailable");
|
|
36
|
+
}
|
|
37
|
+
if (!guard)
|
|
38
|
+
throw new InventoryGuardUnsupported("adapter_has_no_inventory_guard");
|
|
39
|
+
if (capabilityOwners.get(guard) !== backend)
|
|
40
|
+
throw new InventoryGuardUnsupported("unqualified_wrapper");
|
|
41
|
+
return guard;
|
|
42
|
+
}
|
|
43
|
+
export function assertInventoryGuardBound(count) {
|
|
44
|
+
if (count > 10_000)
|
|
45
|
+
throw new InventoryGuardUnsupported("inventory_document_bound");
|
|
46
|
+
}
|
|
47
|
+
/** Snapshot data without invoking caller accessors, toJSON, or transaction callbacks. */
|
|
48
|
+
function copyData(value, active = new Set(), budget = { nodes: 100_000 }) {
|
|
49
|
+
if (--budget.nodes < 0)
|
|
50
|
+
throw new InvalidInputError("Inventory guard input exceeds its data bound.");
|
|
51
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
52
|
+
return value;
|
|
53
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
54
|
+
return value;
|
|
55
|
+
if (typeof value !== "object")
|
|
56
|
+
throw new InvalidInputError("Inventory guard accepts finite plain data only.");
|
|
57
|
+
if (active.has(value))
|
|
58
|
+
throw new InvalidInputError("Inventory guard input is cyclic.");
|
|
59
|
+
const array = Array.isArray(value);
|
|
60
|
+
if (Object.getPrototypeOf(value) !== (array ? Array.prototype : Object.prototype) && Object.getPrototypeOf(value) !== null) {
|
|
61
|
+
throw new InvalidInputError("Inventory guard accepts plain objects and arrays only.");
|
|
62
|
+
}
|
|
63
|
+
active.add(value);
|
|
64
|
+
const result = array ? [] : Object.create(null);
|
|
65
|
+
if (array && Object.keys(value).length !== value.length)
|
|
66
|
+
throw new InvalidInputError("Inventory guard input cannot carry sparse arrays or extra keys.");
|
|
67
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
68
|
+
if (array && key === "length")
|
|
69
|
+
continue;
|
|
70
|
+
if (array && (typeof key !== "string" || !/^(0|[1-9][0-9]*)$/.test(key)))
|
|
71
|
+
throw new InvalidInputError("Inventory guard arrays require indexed data only.");
|
|
72
|
+
if (typeof key !== "string")
|
|
73
|
+
throw new InvalidInputError("Inventory guard input cannot carry symbol keys.");
|
|
74
|
+
const property = Object.getOwnPropertyDescriptor(value, key);
|
|
75
|
+
if (!property.enumerable || !("value" in property))
|
|
76
|
+
throw new InvalidInputError("Inventory guard input cannot carry accessors or hidden data.");
|
|
77
|
+
Object.defineProperty(result, key, { value: copyData(property.value, active, budget), enumerable: true, configurable: true, writable: true });
|
|
78
|
+
}
|
|
79
|
+
if (array && result.length !== value.length)
|
|
80
|
+
throw new InvalidInputError("Inventory guard input cannot carry sparse arrays.");
|
|
81
|
+
active.delete(value);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
function record(value) {
|
|
85
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
86
|
+
throw new InvalidInputError("Inventory guard expected an object.");
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
function keys(value, allowed) {
|
|
90
|
+
if (Object.keys(value).some(key => !allowed.includes(key)))
|
|
91
|
+
throw new InvalidInputError("Inventory guard input has unsupported fields.");
|
|
92
|
+
}
|
|
93
|
+
function version(value) {
|
|
94
|
+
if (typeof value !== "string" || !/^sha256:[0-9a-f]{64}$/.test(value))
|
|
95
|
+
throw new InvalidInputError("Inventory guard requires exact content versions.");
|
|
96
|
+
}
|
|
97
|
+
export function captureInventoryGuardRequest(input) {
|
|
98
|
+
const data = record(copyData(input));
|
|
99
|
+
keys(data, ["target", "domain", "inventory", "id", "expectedVersion", "doc", "options"]);
|
|
100
|
+
const target = record(data.target);
|
|
101
|
+
keys(target, ["contract", "domain", "adapter", "store", "root_version", "edition"]);
|
|
102
|
+
if (target.contract !== "inventory-guard/v1" || target.domain !== INVENTORY_GUARD_DOMAIN || data.domain !== INVENTORY_GUARD_DOMAIN) {
|
|
103
|
+
throw new InventoryGuardUnsupported("domain_or_contract");
|
|
104
|
+
}
|
|
105
|
+
if (!["memory", "filesystem"].includes(String(target.adapter)) || typeof target.store !== "string" || target.store.length === 0 || !["0.1", "0.2"].includes(String(target.edition)))
|
|
106
|
+
throw new InvalidInputError("Invalid inventory guard target.");
|
|
107
|
+
version(target.root_version);
|
|
108
|
+
if (typeof data.id !== "string")
|
|
109
|
+
throw new InvalidInputError("Inventory guard requires a target id.");
|
|
110
|
+
assertSafeConceptId(data.id);
|
|
111
|
+
if (isReservedFile(pathFromConceptId(data.id)))
|
|
112
|
+
throw new InvalidInputError("Inventory guard target must be a concept.");
|
|
113
|
+
version(data.expectedVersion);
|
|
114
|
+
if (!Array.isArray(data.inventory))
|
|
115
|
+
throw new InvalidInputError("Inventory guard requires a complete inventory.");
|
|
116
|
+
assertInventoryGuardBound(data.inventory.length);
|
|
117
|
+
let previous;
|
|
118
|
+
for (const raw of data.inventory) {
|
|
119
|
+
const row = record(raw);
|
|
120
|
+
keys(row, ["id", "version"]);
|
|
121
|
+
if (typeof row.id !== "string")
|
|
122
|
+
throw new InvalidInputError("Inventory guard inventory id is invalid.");
|
|
123
|
+
assertSafeConceptId(row.id);
|
|
124
|
+
if (isReservedFile(pathFromConceptId(row.id)) || (previous !== undefined && compareStorageKeys(previous, row.id) >= 0))
|
|
125
|
+
throw new InvalidInputError("Inventory guard inventory must be sorted, unique concepts.");
|
|
126
|
+
version(row.version);
|
|
127
|
+
previous = row.id;
|
|
128
|
+
}
|
|
129
|
+
if (!data.inventory.some(row => row.id === data.id && row.version === data.expectedVersion))
|
|
130
|
+
throw new InvalidInputError("Inventory guard target/version is missing from inventory.");
|
|
131
|
+
const doc = record(data.doc);
|
|
132
|
+
keys(doc, ["id", "frontmatter", "body"]);
|
|
133
|
+
if (doc.id !== data.id || typeof doc.body !== "string")
|
|
134
|
+
throw new InvalidInputError("Inventory guard candidate identity/body is invalid.");
|
|
135
|
+
record(doc.frontmatter);
|
|
136
|
+
if (data.options !== undefined) {
|
|
137
|
+
const options = record(data.options);
|
|
138
|
+
keys(options, ["actor", "agent"]);
|
|
139
|
+
if (Object.values(options).some(value => typeof value !== "string"))
|
|
140
|
+
throw new InvalidInputError("Inventory guard attribution must be strings.");
|
|
141
|
+
}
|
|
142
|
+
return data;
|
|
143
|
+
}
|
|
144
|
+
export function guardEdition(content) {
|
|
145
|
+
if (content === null)
|
|
146
|
+
throw new InventoryGuardUnsupported("root_metadata_absent");
|
|
147
|
+
const edition = okfVersionOfRootIndex(content);
|
|
148
|
+
if (edition !== "0.1" && edition !== "0.2")
|
|
149
|
+
throw new InventoryGuardUnsupported("root_edition_unestablished");
|
|
150
|
+
return edition;
|
|
151
|
+
}
|
|
152
|
+
export function compareInventoryPremises(expected, current, inventory) {
|
|
153
|
+
if (expected.target.adapter !== current.adapter || expected.target.store !== current.store)
|
|
154
|
+
throw new InventoryGuardConflict("identity");
|
|
155
|
+
if (expected.target.edition !== current.edition)
|
|
156
|
+
throw new InventoryGuardConflict("edition");
|
|
157
|
+
if (expected.target.root_version !== current.root_version)
|
|
158
|
+
throw new InventoryGuardConflict("root_metadata");
|
|
159
|
+
if (expected.inventory.length !== inventory.length || expected.inventory.some((row, index) => row.id !== inventory[index]?.id))
|
|
160
|
+
throw new InventoryGuardConflict("membership");
|
|
161
|
+
if (expected.inventory.some((row, index) => row.version !== inventory[index].version))
|
|
162
|
+
throw new InventoryGuardConflict("version");
|
|
163
|
+
if (!inventory.some(row => row.id === expected.id && row.version === expected.expectedVersion))
|
|
164
|
+
throw new InventoryGuardConflict("target_version");
|
|
165
|
+
}
|
|
166
|
+
export function inventoryDigest(inventory) {
|
|
167
|
+
return `sha256:${sha256HexOfUtf8(JSON.stringify(inventory.map(row => [row.id, row.version])))}`;
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=inventory-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inventory-guard.js","sourceRoot":"","sources":["../src/inventory-guard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACxG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,wGAAwG;AACxG,MAAM,CAAC,MAAM,sBAAsB,GAAG,8BAAuC,CAAC;AAkC9E,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IACzC,OAAO,GAAG,KAAK,CAAC;IAChB,MAAM,CAAS;IACxB,YAAY,MAAc,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;CAChJ;AACD,MAAM,OAAO,sBA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C,CAAC;IACpI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,QAAQ,CAAC,EAAE,IAAI,GAAG,CAAC,OAAO,KAAK,QAAQ,CAAC,eAAe,CAAC;QAAE,MAAM,IAAI,sBAAsB,CAAC,gBAAgB,CAAC,CAAC;AACrJ,CAAC;AACD,MAAM,UAAU,eAAe,CAAC,SAA2B;IACzD,OAAO,UAAU,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAClG,CAAC"}
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
* that commits.
|
|
22
22
|
* - {@link JournaledBackend.deleteJournaled} is the deletion counterpart: ONE transaction that
|
|
23
23
|
* removes the document record under the same compare-and-swap, puts and removes meta rows
|
|
24
|
-
* with it,
|
|
24
|
+
* with it, optionally supersedes an intent and records a deletion intent
|
|
25
|
+
* ({@link DOCUMENT_DELETE_KIND}) exactly as `writeJournaled` does for a write, and honours
|
|
26
|
+
* `requireSettled` the same way, so a document the authority deleted
|
|
25
27
|
* leaves the working copy together with its shared base and never while a local edit holds
|
|
26
28
|
* it. An absent target is not a conflict: the meta changes still apply and the result says
|
|
27
29
|
* `absent`, as the plain `delete` answers absence with `false`. With `onHeld`, a hold is not a
|
|
@@ -36,6 +38,12 @@
|
|
|
36
38
|
* chain whose head is a recorded conflict or refusal, with conflicted, refused, and
|
|
37
39
|
* never-attempted pending successors behind it, never uncertain delivery. The caller
|
|
38
40
|
* preserves recovery evidence in meta; retirement does not assert remote acceptance.
|
|
41
|
+
* - {@link JournaledBackend.retireAcknowledged}, when an adapter offers it, is ONE transaction
|
|
42
|
+
* that removes named acknowledged intents of one target, and named meta rows, under the full
|
|
43
|
+
* guard of that target. Every named intent must be acknowledged in the guard, and the guard is
|
|
44
|
+
* compared in the same transaction, so an intent another realm moved since the caller's read is
|
|
45
|
+
* never removed. Unsettled work is never retired this way. What a retained successor may
|
|
46
|
+
* still need from a retired row is the caller's rule; the adapter only enforces the premise.
|
|
39
47
|
* - {@link JournaledBackend.readWithJournal} is ONE snapshot: the document, every intent
|
|
40
48
|
* targeting it, and the named meta rows, read in one readonly transaction, so a write in
|
|
41
49
|
* another realm between separate reads can never show a caller a document of one moment
|
|
@@ -68,6 +76,16 @@
|
|
|
68
76
|
import type { MalformedDocumentError } from "./frontmatter-contract.js";
|
|
69
77
|
import type { OperationIntent, OperationState } from "./uncertain-write.js";
|
|
70
78
|
import type { ConceptId, DeleteOptions, Frontmatter, OkfDocument, ReadResult, StorageBackend, Version, WriteOptions } from "./types.js";
|
|
79
|
+
/**
|
|
80
|
+
* The intent kind of a journaled local deletion: the document leaves at exactly the intent's
|
|
81
|
+
* base. A deletion carries no bytes, so its `content` is {@link DELETION_CONTENT} and its `local`
|
|
82
|
+
* is {@link DELETION_VERSION}, the version of empty bytes, which no document can have (every
|
|
83
|
+
* document has frontmatter). A conflict can therefore never name a deletion's own `local` and
|
|
84
|
+
* read as its commit.
|
|
85
|
+
*/
|
|
86
|
+
export declare const DOCUMENT_DELETE_KIND = "document.delete";
|
|
87
|
+
export declare const DELETION_CONTENT = "";
|
|
88
|
+
export declare const DELETION_VERSION: Version;
|
|
71
89
|
/** Presence is independent of value: a stored undefined is not an absent row. */
|
|
72
90
|
export type MetaExpectation = {
|
|
73
91
|
present: false;
|
|
@@ -100,6 +118,8 @@ export declare class JournalGuardConflict extends Error {
|
|
|
100
118
|
* applies only to guarded operations; the unguarded metadata store remains opaque.
|
|
101
119
|
*/
|
|
102
120
|
export declare function captureJournalValue<T>(value: T): T;
|
|
121
|
+
export declare function equalJournalValue(a: unknown, b: unknown): boolean;
|
|
122
|
+
export declare function assertMetaExpectation(value: MetaExpectation): void;
|
|
103
123
|
export declare function captureJournalGuard(value: JournalGuard, target?: ConceptId): JournalGuard;
|
|
104
124
|
/** Only omission or undefined selects the unguarded compatibility path. */
|
|
105
125
|
export declare function captureJournalGuardOption(options: {
|
|
@@ -124,11 +144,31 @@ export declare function captureIntentUpdate(patch: IntentPatch, options: IntentU
|
|
|
124
144
|
options: IntentUpdateOptions;
|
|
125
145
|
};
|
|
126
146
|
export declare function captureMetaWrite(options: MetaWriteOptions): MetaWriteOptions;
|
|
127
|
-
export declare function assertMetaWrite(key: string, options: MetaWriteOptions, actual: MetaExpectation, intents: readonly
|
|
147
|
+
export declare function assertMetaWrite(key: string, options: MetaWriteOptions, actual: MetaExpectation, intents: readonly {
|
|
148
|
+
requestId: string;
|
|
149
|
+
}[]): void;
|
|
128
150
|
/** Metadata removal is admitted only with an explicit full-snapshot premise. */
|
|
129
151
|
export declare function assertJournalMetaChanges(guard: JournalGuard | undefined, puts: readonly MetaRecord[], removals: readonly string[] | undefined): void;
|
|
130
152
|
/** A guarded write owns one target and creates a globally fresh journal identity. */
|
|
131
|
-
export declare function assertJournalIntentChanges(guard: JournalGuard | undefined, existingIdentity:
|
|
153
|
+
export declare function assertJournalIntentChanges(guard: JournalGuard | undefined, existingIdentity: {
|
|
154
|
+
target: string;
|
|
155
|
+
} | undefined, superseded: {
|
|
156
|
+
target: string;
|
|
157
|
+
} | undefined): void;
|
|
158
|
+
/** Options for {@link JournaledBackend.retireAcknowledged}. */
|
|
159
|
+
export interface RetireAcknowledgedOptions {
|
|
160
|
+
/** The full target snapshot the retirement was composed against, compared in its transaction. */
|
|
161
|
+
guard: JournalGuard;
|
|
162
|
+
/** Acknowledged intents of the guard's target to remove; at least one, each named once. */
|
|
163
|
+
requestIds: readonly string[];
|
|
164
|
+
/** Meta rows the guard names, removed in the same transaction. */
|
|
165
|
+
removeMeta?: readonly string[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Capture a retirement before any adapter work: the guard is required and complete, every
|
|
169
|
+
* named intent is in it and acknowledged, and every removed meta row is one the guard names.
|
|
170
|
+
*/
|
|
171
|
+
export declare function captureRetireAcknowledged(target: ConceptId, options: RetireAcknowledgedOptions): RetireAcknowledgedOptions;
|
|
132
172
|
/** Capture write options while retaining the existing synchronous metadata producer. */
|
|
133
173
|
export declare function captureJournalWriteOptions(options: JournaledWriteOptions): JournaledWriteOptions;
|
|
134
174
|
/** Capture every guarded deletion branch before evaluating held or absent state. */
|
|
@@ -171,10 +211,15 @@ export interface IntentRecord extends OperationIntent {
|
|
|
171
211
|
after?: string;
|
|
172
212
|
/** Set when the authority committed the intent; equals `local` for a content-addressed token. */
|
|
173
213
|
acknowledgedVersion?: Version;
|
|
174
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* The shared head observed when the intent entered conflict. With `version: null` (deleted
|
|
216
|
+
* remotely), `tombstone` is the deletion the authority named, when it named one: what a
|
|
217
|
+
* deliberate re-create acknowledges. It is never a version a read serves.
|
|
218
|
+
*/
|
|
175
219
|
remote?: {
|
|
176
220
|
version: Version | null;
|
|
177
221
|
content: string | null;
|
|
222
|
+
tombstone?: Version;
|
|
178
223
|
};
|
|
179
224
|
refusal?: {
|
|
180
225
|
code: string;
|
|
@@ -184,7 +229,9 @@ export interface IntentRecord extends OperationIntent {
|
|
|
184
229
|
finding?: string;
|
|
185
230
|
}
|
|
186
231
|
/** The caller-supplied part of a new intent; the adapter fills content, version, sequence, and state. */
|
|
187
|
-
export type NewIntentRecord = Pick<IntentRecord, "requestId" | "kind" | "target" | "base" | "baseContent" | "createdAt"> & Partial<Pick<IntentRecord, "after">>;
|
|
232
|
+
export type NewIntentRecord = Pick<IntentRecord, "requestId" | "kind" | "target" | "base" | "baseContent" | "createdAt"> & Partial<Pick<IntentRecord, "after" | "recreates" | "producer" | "bodyReplace">>;
|
|
233
|
+
/** Capture durable per-request edit intent before an adapter queues asynchronous work. */
|
|
234
|
+
export declare function captureNewDocumentIntent(intent: NewIntentRecord): NewIntentRecord;
|
|
188
235
|
/** An opaque key-value row in the meta store (bootstrap marker, per-document base, pause flag). */
|
|
189
236
|
export interface MetaRecord {
|
|
190
237
|
key: string;
|
|
@@ -196,6 +243,14 @@ export declare class JournalSnapshotConflict extends Error {
|
|
|
196
243
|
readonly target: ConceptId;
|
|
197
244
|
constructor(target: ConceptId);
|
|
198
245
|
}
|
|
246
|
+
/**
|
|
247
|
+
* The deletion intent a journaled deletion records, refused before any adapter work when it is
|
|
248
|
+
* not one: another kind, another target, or combined with a guard (a guarded deletion journals
|
|
249
|
+
* nothing). The adapter fills content, local version, sequence and state.
|
|
250
|
+
*/
|
|
251
|
+
export declare function assertDeletionIntent(target: ConceptId, options: JournaledDeleteOptions): void;
|
|
252
|
+
/** The record a journaled deletion adds for `intent`. */
|
|
253
|
+
export declare function deletionIntentRecord(intent: NewIntentRecord, sequence: number, now: string): IntentRecord;
|
|
199
254
|
export declare function assertJournalResolutionOptions(target: ConceptId, options: JournaledWriteOptions | JournaledDeleteOptions): void;
|
|
200
255
|
/**
|
|
201
256
|
* Compare full records, not only state: a changed outcome or retry is new recovery evidence.
|
|
@@ -247,6 +302,20 @@ export interface JournaledDeleteOptions extends DeleteOptions {
|
|
|
247
302
|
meta?: MetaRecord[];
|
|
248
303
|
/** Meta keys to remove in the same transaction; a key with no row is not an error. Applied as `meta` is. */
|
|
249
304
|
removeMeta?: readonly string[];
|
|
305
|
+
/**
|
|
306
|
+
* Record this deletion intent in the same transaction, as `writeJournaled` records a write's:
|
|
307
|
+
* `pending`, zero attempts, the next sequence, with {@link DELETION_CONTENT} and
|
|
308
|
+
* {@link DELETION_VERSION}. Its kind must be {@link DOCUMENT_DELETE_KIND}. It is recorded when
|
|
309
|
+
* the deletion applies, including over an absent record (a resolution re-deleting a document
|
|
310
|
+
* the working copy no longer holds), and never when the deletion is held.
|
|
311
|
+
*/
|
|
312
|
+
intent?: NewIntentRecord;
|
|
313
|
+
/** An unsettled intent this deletion composes over; removed only while its state and attempts still match, as for `writeJournaled`. */
|
|
314
|
+
supersede?: {
|
|
315
|
+
requestId: string;
|
|
316
|
+
expectedState: OperationState;
|
|
317
|
+
expectedAttempts: number;
|
|
318
|
+
};
|
|
250
319
|
/**
|
|
251
320
|
* Refuse the deletion when any intent targeting `id` is in a state other than `acknowledged`,
|
|
252
321
|
* read in the same transaction as the deletion. A pull that reconciles a remote deletion uses
|
|
@@ -265,13 +334,15 @@ export interface JournaledDeleteOptions extends DeleteOptions {
|
|
|
265
334
|
}
|
|
266
335
|
/** What {@link JournaledBackend.deleteJournaled} did, in one transaction. */
|
|
267
336
|
export type JournaledDeleteResult =
|
|
268
|
-
/** A record was removed; `meta` and `removeMeta` applied. */
|
|
337
|
+
/** A record was removed; `meta` and `removeMeta` applied, and `intent` recorded when one was given. */
|
|
269
338
|
{
|
|
270
339
|
outcome: "deleted";
|
|
340
|
+
intent?: IntentRecord;
|
|
271
341
|
}
|
|
272
|
-
/** No record to remove; `meta` and `removeMeta` still applied. */
|
|
342
|
+
/** No record to remove; `meta` and `removeMeta` still applied, and `intent` recorded when one was given. */
|
|
273
343
|
| {
|
|
274
344
|
outcome: "absent";
|
|
345
|
+
intent?: IntentRecord;
|
|
275
346
|
}
|
|
276
347
|
/** An unsettled intent holds the target and `onHeld` was given: its meta rows applied, nothing else did. */
|
|
277
348
|
| {
|
|
@@ -333,7 +404,7 @@ export interface JournaledHeadsOptions<T> {
|
|
|
333
404
|
project?: (head: JournaledHead) => T;
|
|
334
405
|
}
|
|
335
406
|
/** Fields a caller may change when settling or reclaiming an intent. */
|
|
336
|
-
export type IntentPatch = Partial<Omit<IntentRecord, "requestId" | "sequence" | "createdAt" | "kind" | "target">>;
|
|
407
|
+
export type IntentPatch = Partial<Omit<IntentRecord, "requestId" | "sequence" | "createdAt" | "kind" | "target" | "bodyReplace">>;
|
|
337
408
|
/**
|
|
338
409
|
* A {@link StorageBackend} that also journals local writes as intents and keeps opaque meta
|
|
339
410
|
* rows, with the transaction and compare-and-swap guarantees stated in this module's header.
|
|
@@ -387,6 +458,13 @@ export interface JournaledBackend extends StorageBackend {
|
|
|
387
458
|
/** Intents in local commit order, optionally restricted to one or more states. */
|
|
388
459
|
listIntents(state?: OperationState | readonly OperationState[]): Promise<IntentRecord[]>;
|
|
389
460
|
readIntent(requestId: string): Promise<IntentRecord | undefined>;
|
|
461
|
+
/**
|
|
462
|
+
* Remove acknowledged intents of one target, and named meta rows, in ONE transaction under
|
|
463
|
+
* the target's full guard ({@link RetireAcknowledgedOptions}). A guard that no longer matches
|
|
464
|
+
* rejects with {@link JournalGuardConflict} and removes nothing. Optional: a caller that finds
|
|
465
|
+
* no such method keeps acknowledged history, as every adapter did before it existed.
|
|
466
|
+
*/
|
|
467
|
+
retireAcknowledged?(target: ConceptId, options: RetireAcknowledgedOptions): Promise<void>;
|
|
390
468
|
/**
|
|
391
469
|
* Compare-and-swap on an intent's `state`: the patch applies only while the record is in
|
|
392
470
|
* `expectedState`, together with any meta rows, in one transaction. A different state or a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journaled-backend.d.ts","sourceRoot":"","sources":["../src/journaled-backend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"journaled-backend.d.ts","sourceRoot":"","sources":["../src/journaled-backend.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0EG;AAEH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAIxI;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AACtD,eAAO,MAAM,gBAAgB,KAAK,CAAC;AACnC,eAAO,M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ace-guards.js";
|
|
2
|
+
import { assertSafeConceptId } from "./paths.js";
|
|
3
|
+
import { versionOfBytes } from "./versioning.js";
|
|
1
4
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* The contract a second adapter must meet:
|
|
9
|
-
*
|
|
10
|
-
* - {@link JournaledBackend.writeJournaled} is ONE transaction over documents, intents, and
|
|
11
|
-
* meta: the document compare-and-swap of `write`, plus (optionally) deleting a superseded
|
|
12
|
-
* intent, recording a new intent for the written bytes, and putting meta rows. Every step is
|
|
13
|
-
* conditional on every other: a failed document CAS records no intent, and a superseded
|
|
14
|
-
* intent whose state or attempts moved fails the whole write with {@link IntentStateConflict}
|
|
15
|
-
* so the caller composes against fresh state. With `requireSettled`, an unsettled intent on
|
|
16
|
-
* the target fails it with {@link IntentHoldConflict} before the document is touched; the
|
|
17
|
-
* check runs inside the write's own transaction, so an intent committed while the caller was
|
|
18
|
-
* awaiting the network still holds the target. A recorded intent starts `pending` with zero
|
|
19
|
-
* attempts, carries the written bytes as `content` and their version as `local`, and takes
|
|
20
|
-
* the next value of a monotonic per-store sequence. The sequence advances only for a write
|
|
21
|
-
* that commits.
|
|
22
|
-
* - {@link JournaledBackend.deleteJournaled} is the deletion counterpart: ONE transaction that
|
|
23
|
-
* removes the document record under the same compare-and-swap, puts and removes meta rows
|
|
24
|
-
* with it, and honours `requireSettled` the same way, so a document the authority deleted
|
|
25
|
-
* leaves the working copy together with its shared base and never while a local edit holds
|
|
26
|
-
* it. An absent target is not a conflict: the meta changes still apply and the result says
|
|
27
|
-
* `absent`, as the plain `delete` answers absence with `false`. With `onHeld`, a hold is not a
|
|
28
|
-
* rejection but the third outcome: the deletion and its own meta changes do not apply, the
|
|
29
|
-
* `onHeld` meta rows apply instead, in the same transaction as the hold check, and the result
|
|
30
|
-
* says `held` and names the holder. A caller that must rewrite a held document's shared base
|
|
31
|
-
* (a pull reconciling a remote deletion) does it there, so no other realm can settle the
|
|
32
|
-
* holding intent between the refusal and the rewrite.
|
|
33
|
-
* - `resolveIntents` on either journaled mutation requires document CAS and the exact complete
|
|
34
|
-
* unsettled target journal. It retires those records atomically with the document, meta, and
|
|
35
|
-
* optional replacement intent, leaving acknowledged history untouched. Recovery may retire a
|
|
36
|
-
* chain whose head is a recorded conflict or refusal, with conflicted, refused, and
|
|
37
|
-
* never-attempted pending successors behind it, never uncertain delivery. The caller
|
|
38
|
-
* preserves recovery evidence in meta; retirement does not assert remote acceptance.
|
|
39
|
-
* - {@link JournaledBackend.readWithJournal} is ONE snapshot: the document, every intent
|
|
40
|
-
* targeting it, and the named meta rows, read in one readonly transaction, so a write in
|
|
41
|
-
* another realm between separate reads can never show a caller a document of one moment
|
|
42
|
-
* beside a journal of another. Intents come back in local commit order (by `sequence`).
|
|
43
|
-
* - {@link JournaledBackend.readHeads} is that snapshot over every document at once: each
|
|
44
|
-
* record's head (id, version, writer, time), its leading frontmatter parsed as `read` parses
|
|
45
|
-
* it, its exact bytes, every intent targeting it, and the meta rows the caller names for it,
|
|
46
|
-
* all from ONE readonly transaction, so every row describes the same moment. Bodies are
|
|
47
|
-
* never parsed. A record whose leading block does not parse is a row with `frontmatter`
|
|
48
|
-
* null and the parser's error, never a dropped row and never a failed listing. A caller that
|
|
49
|
-
* keeps less than the row (a version and a provenance, say) passes `project`, which maps
|
|
50
|
-
* each row as it is read so the listing over a large store never holds every document's
|
|
51
|
-
* stored bytes at once; the journal is read whole before the walk, so intents and the
|
|
52
|
-
* content they carry are held for its duration, as a single read holds them. Keys every row
|
|
53
|
-
* needs go in `shared`, read once. Rows come back in the order `list` orders ids.
|
|
54
|
-
* - {@link JournaledBackend.updateIntent} is a compare-and-swap on the intent's `state`: the
|
|
55
|
-
* patch applies only while the record is in `expectedState`, together with any meta rows, in
|
|
56
|
-
* one transaction. A different state or a missing record rejects with
|
|
57
|
-
* {@link IntentStateConflict} and writes nothing, so two realms (a stale tab, a worker) cannot
|
|
58
|
-
* both settle or both replace one intent.
|
|
59
|
-
* - {@link JournaledBackend.listIntents} returns intents in local commit order (ascending
|
|
60
|
-
* `sequence`), optionally restricted to one or more states.
|
|
61
|
-
* - {@link JournaledBackend.readMeta} and {@link JournaledBackend.writeMeta} are an opaque
|
|
62
|
-
* key-value store; what the rows mean belongs to the sync component that writes them.
|
|
63
|
-
*
|
|
64
|
-
* This module imports no Node builtin so it bundles for the browser. The IndexedDB adapter is
|
|
65
|
-
* the shipping implementation; a test-only in-memory adapter proves the seam is not a
|
|
66
|
-
* description of that one class.
|
|
5
|
+
* The intent kind of a journaled local deletion: the document leaves at exactly the intent's
|
|
6
|
+
* base. A deletion carries no bytes, so its `content` is {@link DELETION_CONTENT} and its `local`
|
|
7
|
+
* is {@link DELETION_VERSION}, the version of empty bytes, which no document can have (every
|
|
8
|
+
* document has frontmatter). A conflict can therefore never name a deletion's own `local` and
|
|
9
|
+
* read as its commit.
|
|
67
10
|
*/
|
|
68
|
-
|
|
11
|
+
export const DOCUMENT_DELETE_KIND = "document.delete";
|
|
12
|
+
export const DELETION_CONTENT = "";
|
|
13
|
+
export const DELETION_VERSION = versionOfBytes(DELETION_CONTENT);
|
|
69
14
|
/** A full snapshot or metadata admission premise changed; nothing was written. */
|
|
70
15
|
export class JournalGuardConflict extends Error {
|
|
71
16
|
name = "JournalGuardConflict";
|
|
@@ -103,7 +48,7 @@ export function captureJournalValue(value) {
|
|
|
103
48
|
check(value);
|
|
104
49
|
return structuredClone(value);
|
|
105
50
|
}
|
|
106
|
-
function equalJournalValue(a, b) {
|
|
51
|
+
export function equalJournalValue(a, b) {
|
|
107
52
|
if (Object.is(a, b))
|
|
108
53
|
return true;
|
|
109
54
|
if (!a || !b || typeof a !== "object" || typeof b !== "object" || Array.isArray(a) !== Array.isArray(b))
|
|
@@ -113,7 +58,7 @@ function equalJournalValue(a, b) {
|
|
|
113
58
|
const keys = Object.keys(a);
|
|
114
59
|
return keys.length === Object.keys(b).length && keys.every(key => Object.hasOwn(b, key) && equalJournalValue(a[key], b[key]));
|
|
115
60
|
}
|
|
116
|
-
function assertMetaExpectation(value) {
|
|
61
|
+
export function assertMetaExpectation(value) {
|
|
117
62
|
if (!value || typeof value !== "object" || typeof value.present !== "boolean" ||
|
|
118
63
|
!equalJournalValue(Object.keys(value).sort(), (value.present ? ["present", "value"] : ["present"]).sort()))
|
|
119
64
|
throw new JournalGuardConflict("meta");
|
|
@@ -131,7 +76,7 @@ export function captureJournalGuard(value, target) {
|
|
|
131
76
|
throw new JournalGuardConflict(target);
|
|
132
77
|
const requests = new Set(), sequences = new Set(), keys = new Set();
|
|
133
78
|
for (const row of guard.intents) {
|
|
134
|
-
if (!row || row.target !== target || typeof row.requestId !== "string" || requests.has(row.requestId) || !Number.isSafeInteger(row.sequence) || sequences.has(row.sequence))
|
|
79
|
+
if (!row || "recordFamily" in row || row.target !== target || typeof row.requestId !== "string" || requests.has(row.requestId) || !Number.isSafeInteger(row.sequence) || sequences.has(row.sequence))
|
|
135
80
|
throw new JournalGuardConflict(target);
|
|
136
81
|
requests.add(row.requestId);
|
|
137
82
|
sequences.add(row.sequence);
|
|
@@ -168,6 +113,8 @@ export function assertJournalGuard(expected, current) {
|
|
|
168
113
|
}
|
|
169
114
|
/** Capture guarded updates before any asynchronous adapter work and protect original history. */
|
|
170
115
|
export function captureIntentUpdate(patch, options) {
|
|
116
|
+
if (Object.hasOwn(patch, "bodyReplace"))
|
|
117
|
+
throw new JournalGuardConflict("bodyReplace");
|
|
171
118
|
const guard = captureJournalGuardOption(options);
|
|
172
119
|
if (guard !== undefined)
|
|
173
120
|
captureJournalValue({ patch, options });
|
|
@@ -215,6 +162,25 @@ export function assertJournalIntentChanges(guard, existingIdentity, superseded)
|
|
|
215
162
|
if (guard && (existingIdentity !== undefined || (superseded !== undefined && superseded.target !== guard.target)))
|
|
216
163
|
throw new JournalGuardConflict(guard.target);
|
|
217
164
|
}
|
|
165
|
+
/**
|
|
166
|
+
* Capture a retirement before any adapter work: the guard is required and complete, every
|
|
167
|
+
* named intent is in it and acknowledged, and every removed meta row is one the guard names.
|
|
168
|
+
*/
|
|
169
|
+
export function captureRetireAcknowledged(target, options) {
|
|
170
|
+
if (!options || typeof options !== "object" || Array.isArray(options))
|
|
171
|
+
throw new JournalGuardConflict(target);
|
|
172
|
+
const guard = captureJournalGuardOption(options, target);
|
|
173
|
+
if (guard === undefined)
|
|
174
|
+
throw new JournalGuardConflict(target);
|
|
175
|
+
const captured = captureJournalValue({ requestIds: options.requestIds, removeMeta: options.removeMeta });
|
|
176
|
+
const ids = captured.requestIds;
|
|
177
|
+
if (!Array.isArray(ids) || ids.length === 0 || ids.some(id => typeof id !== "string") || new Set(ids).size !== ids.length ||
|
|
178
|
+
Object.keys(options).some(key => !["guard", "requestIds", "removeMeta"].includes(key)) ||
|
|
179
|
+
ids.some(id => guard.intents.find(row => row.requestId === id)?.state !== "acknowledged"))
|
|
180
|
+
throw new JournalGuardConflict(target);
|
|
181
|
+
assertJournalMetaChanges(guard, [], captured.removeMeta);
|
|
182
|
+
return { guard, requestIds: ids, ...(captured.removeMeta === undefined ? {} : { removeMeta: captured.removeMeta }) };
|
|
183
|
+
}
|
|
218
184
|
/** Capture write options while retaining the existing synchronous metadata producer. */
|
|
219
185
|
export function captureJournalWriteOptions(options) {
|
|
220
186
|
const descriptors = Object.getOwnPropertyDescriptors(options);
|
|
@@ -288,6 +254,17 @@ export class IntentHoldConflict extends Error {
|
|
|
288
254
|
this.state = state;
|
|
289
255
|
}
|
|
290
256
|
}
|
|
257
|
+
/** Capture durable per-request edit intent before an adapter queues asynchronous work. */
|
|
258
|
+
export function captureNewDocumentIntent(intent) {
|
|
259
|
+
const captured = captureJournalValue(intent);
|
|
260
|
+
const posture = captureBodyReplacePosture(captured.bodyReplace);
|
|
261
|
+
if (posture !== undefined) {
|
|
262
|
+
if (captured.kind !== "document.write")
|
|
263
|
+
throw new JournalGuardConflict(captured.target);
|
|
264
|
+
return { ...captured, bodyReplace: posture };
|
|
265
|
+
}
|
|
266
|
+
return captured;
|
|
267
|
+
}
|
|
291
268
|
/** Recovery was composed against a different or unsafe unsettled journal snapshot. */
|
|
292
269
|
export class JournalSnapshotConflict extends Error {
|
|
293
270
|
name = "JournalSnapshotConflict";
|
|
@@ -297,6 +274,24 @@ export class JournalSnapshotConflict extends Error {
|
|
|
297
274
|
this.target = target;
|
|
298
275
|
}
|
|
299
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* The deletion intent a journaled deletion records, refused before any adapter work when it is
|
|
279
|
+
* not one: another kind, another target, or combined with a guard (a guarded deletion journals
|
|
280
|
+
* nothing). The adapter fills content, local version, sequence and state.
|
|
281
|
+
*/
|
|
282
|
+
export function assertDeletionIntent(target, options) {
|
|
283
|
+
if (options.intent && Object.hasOwn(options.intent, "bodyReplace"))
|
|
284
|
+
throw new JournalSnapshotConflict(target);
|
|
285
|
+
if (options.intent === undefined && options.supersede === undefined)
|
|
286
|
+
return;
|
|
287
|
+
if (options.guard !== undefined || (options.intent !== undefined && (options.intent.kind !== DOCUMENT_DELETE_KIND || options.intent.target !== target))) {
|
|
288
|
+
throw new JournalSnapshotConflict(target);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/** The record a journaled deletion adds for `intent`. */
|
|
292
|
+
export function deletionIntentRecord(intent, sequence, now) {
|
|
293
|
+
return { ...intent, local: DELETION_VERSION, content: DELETION_CONTENT, sequence, attempts: 0, state: "pending", updatedAt: now };
|
|
294
|
+
}
|
|
300
295
|
export function assertJournalResolutionOptions(target, options) {
|
|
301
296
|
if (!options.resolveIntents)
|
|
302
297
|
return;
|