@superbee/core 0.2.0-pre.2 → 0.2.0-pre.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1000 -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 +19 -1
- package/dist/backend.d.ts.map +1 -1
- package/dist/backend.js +83 -36
- package/dist/backend.js.map +1 -1
- package/dist/blob-contract.d.ts +80 -0
- package/dist/blob-contract.d.ts.map +1 -0
- package/dist/blob-contract.js +131 -0
- package/dist/blob-contract.js.map +1 -0
- package/dist/blob-journal.d.ts +302 -0
- package/dist/blob-journal.d.ts.map +1 -0
- package/dist/blob-journal.js +540 -0
- package/dist/blob-journal.js.map +1 -0
- package/dist/body-replace-guards.d.ts +50 -0
- package/dist/body-replace-guards.d.ts.map +1 -0
- package/dist/body-replace-guards.js +158 -0
- package/dist/body-replace-guards.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.d.ts +10 -0
- package/dist/builtin-recipes.d.ts.map +1 -0
- package/dist/builtin-recipes.js +97 -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 +44 -0
- package/dist/bundle-health/kind-findings.d.ts.map +1 -0
- package/dist/bundle-health/kind-findings.js +68 -0
- package/dist/bundle-health/kind-findings.js.map +1 -0
- package/dist/bundle-health/legacy-page.d.ts +39 -0
- package/dist/bundle-health/legacy-page.d.ts.map +1 -0
- package/dist/bundle-health/legacy-page.js +50 -0
- package/dist/bundle-health/legacy-page.js.map +1 -0
- package/dist/bundle-health/report.d.ts +202 -0
- package/dist/bundle-health/report.d.ts.map +1 -0
- package/dist/bundle-health/report.js +438 -0
- package/dist/bundle-health/report.js.map +1 -0
- package/dist/bundle-ops.d.ts +1 -1
- package/dist/bundle-ops.d.ts.map +1 -1
- package/dist/bundle-ops.js +2 -2
- package/dist/bundle-ops.js.map +1 -1
- package/dist/bundle.d.ts +2 -1
- package/dist/bundle.d.ts.map +1 -1
- package/dist/bundle.js +3 -3
- 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/connectors.d.ts +230 -0
- package/dist/connectors.d.ts.map +1 -0
- package/dist/connectors.js +1150 -0
- package/dist/connectors.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 +186 -0
- package/dist/cross-bundle.js.map +1 -0
- package/dist/dependencies.d.ts +94 -0
- package/dist/dependencies.d.ts.map +1 -0
- package/dist/dependencies.js +180 -0
- package/dist/dependencies.js.map +1 -0
- package/dist/document-codec.d.ts +6 -1
- package/dist/document-codec.d.ts.map +1 -1
- package/dist/document-codec.js +8 -4
- package/dist/document-codec.js.map +1 -1
- package/dist/document-field-actions.d.ts +31 -1
- package/dist/document-field-actions.d.ts.map +1 -1
- package/dist/document-field-actions.js +137 -34
- package/dist/document-field-actions.js.map +1 -1
- package/dist/document-mutation.d.ts +22 -10
- package/dist/document-mutation.d.ts.map +1 -1
- package/dist/document-mutation.js +58 -27
- package/dist/document-mutation.js.map +1 -1
- package/dist/document-write-policy.d.ts.map +1 -1
- package/dist/document-write-policy.js +4 -2
- package/dist/document-write-policy.js.map +1 -1
- package/dist/engine.d.ts +9 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +11 -4
- package/dist/engine.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 +200 -0
- package/dist/file-journaled-backend.d.ts.map +1 -0
- package/dist/file-journaled-backend.js +1334 -0
- package/dist/file-journaled-backend.js.map +1 -0
- package/dist/filesystem-host.d.ts +15 -0
- package/dist/filesystem-host.d.ts.map +1 -0
- package/dist/filesystem-host.js +20 -0
- package/dist/filesystem-host.js.map +1 -0
- package/dist/filesystem-identity.d.ts +86 -4
- package/dist/filesystem-identity.d.ts.map +1 -1
- package/dist/filesystem-identity.js +338 -102
- package/dist/filesystem-identity.js.map +1 -1
- package/dist/filesystem-lock.d.ts +16 -3
- package/dist/filesystem-lock.d.ts.map +1 -1
- package/dist/filesystem-lock.js +323 -77
- 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.d.ts +17 -0
- package/dist/filesystem.d.ts.map +1 -0
- package/dist/filesystem.js +18 -0
- package/dist/filesystem.js.map +1 -0
- package/dist/frontmatter.d.ts +8 -0
- package/dist/frontmatter.d.ts.map +1 -1
- package/dist/frontmatter.js +14 -4
- package/dist/frontmatter.js.map +1 -1
- package/dist/governed-body-write.d.ts +106 -0
- package/dist/governed-body-write.d.ts.map +1 -0
- package/dist/governed-body-write.js +251 -0
- package/dist/governed-body-write.js.map +1 -0
- package/dist/host-policy-snapshot.d.ts +9 -0
- package/dist/host-policy-snapshot.d.ts.map +1 -0
- package/dist/host-policy-snapshot.js +33 -0
- package/dist/host-policy-snapshot.js.map +1 -0
- 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 +67 -0
- package/dist/hosted-client/blob-delivery.d.ts.map +1 -0
- package/dist/hosted-client/blob-delivery.js +169 -0
- package/dist/hosted-client/blob-delivery.js.map +1 -0
- package/dist/hosted-client/blob-write.d.ts +386 -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 +219 -0
- package/dist/hosted-client/client.d.ts.map +1 -0
- package/dist/hosted-client/client.js +309 -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 +30 -0
- package/dist/hosted-client/index.d.ts.map +1 -0
- package/dist/hosted-client/index.js +32 -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/write.d.ts +217 -0
- package/dist/hosted-client/write.d.ts.map +1 -0
- package/dist/hosted-client/write.js +418 -0
- package/dist/hosted-client/write.js.map +1 -0
- package/dist/hosted-transport/answer-rows.d.ts +243 -0
- package/dist/hosted-transport/answer-rows.d.ts.map +1 -0
- package/dist/hosted-transport/answer-rows.js +454 -0
- package/dist/hosted-transport/answer-rows.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 +151 -0
- package/dist/hosted-transport/carrier.d.ts.map +1 -0
- package/dist/hosted-transport/carrier.js +260 -0
- package/dist/hosted-transport/carrier.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 +18 -0
- package/dist/hosted-transport/index.d.ts.map +1 -0
- package/dist/hosted-transport/index.js +18 -0
- package/dist/hosted-transport/index.js.map +1 -0
- package/dist/hosted-transport/operations.d.ts +85 -0
- package/dist/hosted-transport/operations.d.ts.map +1 -0
- package/dist/hosted-transport/operations.js +128 -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/read-adapter.d.ts +256 -0
- package/dist/hosted-transport/read-adapter.d.ts.map +1 -0
- package/dist/hosted-transport/read-adapter.js +568 -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 +171 -0
- package/dist/hosted-transport/root-write.js.map +1 -0
- package/dist/hosted-transport/whole-document-transport.d.ts +204 -0
- package/dist/hosted-transport/whole-document-transport.d.ts.map +1 -0
- package/dist/hosted-transport/whole-document-transport.js +447 -0
- package/dist/hosted-transport/whole-document-transport.js.map +1 -0
- package/dist/index.d.ts +34 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -8
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-backend.d.ts +28 -6
- package/dist/indexeddb-backend.d.ts.map +1 -1
- package/dist/indexeddb-backend.js +471 -92
- package/dist/indexeddb-backend.js.map +1 -1
- package/dist/journaled-backend.d.ts +247 -10
- package/dist/journaled-backend.d.ts.map +1 -1
- package/dist/journaled-backend.js +302 -1
- package/dist/journaled-backend.js.map +1 -1
- package/dist/kind-authoring.d.ts +170 -0
- package/dist/kind-authoring.d.ts.map +1 -0
- package/dist/kind-authoring.js +451 -0
- package/dist/kind-authoring.js.map +1 -0
- package/dist/kind-conformance-error.d.ts +15 -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 +99 -0
- package/dist/kind-coverage.d.ts.map +1 -0
- package/dist/kind-coverage.js +186 -0
- package/dist/kind-coverage.js.map +1 -0
- package/dist/kind-field-mutation.d.ts +4 -0
- 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/kinds-load.js +4 -4
- package/dist/kinds-load.js.map +1 -1
- package/dist/kinds.d.ts +65 -2
- package/dist/kinds.d.ts.map +1 -1
- package/dist/kinds.js +341 -21
- package/dist/kinds.js.map +1 -1
- package/dist/link-types.d.ts +26 -0
- package/dist/link-types.d.ts.map +1 -0
- package/dist/link-types.js +57 -0
- package/dist/link-types.js.map +1 -0
- package/dist/links.d.ts +21 -3
- package/dist/links.d.ts.map +1 -1
- package/dist/links.js +213 -14
- package/dist/links.js.map +1 -1
- package/dist/managed-document-metadata.d.ts +2 -0
- package/dist/managed-document-metadata.d.ts.map +1 -0
- package/dist/managed-document-metadata.js +9 -0
- package/dist/managed-document-metadata.js.map +1 -0
- package/dist/memory-backend.d.ts +2 -2
- package/dist/memory-backend.d.ts.map +1 -1
- package/dist/memory-backend.js +26 -11
- package/dist/memory-backend.js.map +1 -1
- package/dist/paths.d.ts +16 -0
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +25 -0
- package/dist/paths.js.map +1 -1
- package/dist/platform.d.ts +13 -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.d.ts +119 -0
- package/dist/portable-export.d.ts.map +1 -0
- package/dist/portable-export.js +501 -0
- package/dist/portable-export.js.map +1 -0
- 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 +117 -0
- package/dist/qualified-links.js.map +1 -0
- package/dist/query-filter.d.ts +16 -2
- package/dist/query-filter.d.ts.map +1 -1
- package/dist/query-filter.js +40 -1
- 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 +42 -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 +108 -0
- package/dist/recipe-lifecycle/evolution.d.ts.map +1 -0
- package/dist/recipe-lifecycle/evolution.js +884 -0
- package/dist/recipe-lifecycle/evolution.js.map +1 -0
- package/dist/recipe-lifecycle/index.d.ts +26 -0
- package/dist/recipe-lifecycle/index.d.ts.map +1 -0
- package/dist/recipe-lifecycle/index.js +22 -0
- package/dist/recipe-lifecycle/index.js.map +1 -0
- package/dist/recipe-lifecycle/install.d.ts +127 -0
- package/dist/recipe-lifecycle/install.d.ts.map +1 -0
- package/dist/recipe-lifecycle/install.js +526 -0
- package/dist/recipe-lifecycle/install.js.map +1 -0
- package/dist/recipe-lifecycle/legacy-aliases.d.ts +16 -0
- package/dist/recipe-lifecycle/legacy-aliases.d.ts.map +1 -0
- package/dist/recipe-lifecycle/legacy-aliases.js +51 -0
- package/dist/recipe-lifecycle/legacy-aliases.js.map +1 -0
- package/dist/recipe-lifecycle/stamp.d.ts +136 -0
- package/dist/recipe-lifecycle/stamp.d.ts.map +1 -0
- package/dist/recipe-lifecycle/stamp.js +326 -0
- package/dist/recipe-lifecycle/stamp.js.map +1 -0
- package/dist/recipes.d.ts +29 -1
- package/dist/recipes.d.ts.map +1 -1
- package/dist/recipes.js +137 -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 +527 -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 +83 -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 +69 -0
- package/dist/record-overlay/policy.d.ts.map +1 -0
- package/dist/record-overlay/policy.js +228 -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 +45 -0
- package/dist/record-overlay/signal-text.d.ts.map +1 -0
- package/dist/record-overlay/signal-text.js +116 -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/remote-backend.d.ts +67 -67
- package/dist/remote-backend.d.ts.map +1 -1
- package/dist/remote-backend.js +169 -201
- package/dist/remote-backend.js.map +1 -1
- package/dist/remote-document-codec.d.ts +15 -0
- package/dist/remote-document-codec.d.ts.map +1 -0
- package/dist/remote-document-codec.js +103 -0
- package/dist/remote-document-codec.js.map +1 -0
- package/dist/remote-error.d.ts +38 -0
- package/dist/remote-error.d.ts.map +1 -0
- package/dist/remote-error.js +59 -0
- package/dist/remote-error.js.map +1 -0
- package/dist/remote-operations.d.ts +6 -3
- package/dist/remote-operations.d.ts.map +1 -1
- package/dist/remote-operations.js +23 -5
- package/dist/remote-operations.js.map +1 -1
- package/dist/remote-parsers.d.ts +86 -0
- package/dist/remote-parsers.d.ts.map +1 -0
- package/dist/remote-parsers.js +181 -0
- package/dist/remote-parsers.js.map +1 -0
- package/dist/remote.d.ts +5 -2
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +5 -1
- package/dist/remote.js.map +1 -1
- 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 +33 -0
- package/dist/search/backend-source.js.map +1 -0
- package/dist/search/contract.d.ts +151 -0
- package/dist/search/contract.d.ts.map +1 -0
- package/dist/search/contract.js +78 -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 +235 -0
- package/dist/search/memory-source.js.map +1 -0
- package/dist/search/rank.d.ts +34 -0
- package/dist/search/rank.d.ts.map +1 -0
- package/dist/search/rank.js +129 -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 +257 -0
- package/dist/search/search.js.map +1 -0
- package/dist/search/source.d.ts +67 -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 +47 -0
- package/dist/search/text.d.ts.map +1 -0
- package/dist/search/text.js +148 -0
- package/dist/search/text.js.map +1 -0
- package/dist/site-capabilities.d.ts +339 -0
- package/dist/site-capabilities.d.ts.map +1 -0
- package/dist/site-capabilities.js +717 -0
- package/dist/site-capabilities.js.map +1 -0
- package/dist/source-engine/guard.d.ts +82 -0
- package/dist/source-engine/guard.d.ts.map +1 -0
- package/dist/source-engine/guard.js +396 -0
- package/dist/source-engine/guard.js.map +1 -0
- package/dist/source-engine/index.d.ts +24 -0
- package/dist/source-engine/index.d.ts.map +1 -0
- package/dist/source-engine/index.js +20 -0
- package/dist/source-engine/index.js.map +1 -0
- package/dist/source-engine/machine-state.d.ts +74 -0
- package/dist/source-engine/machine-state.d.ts.map +1 -0
- package/dist/source-engine/machine-state.js +48 -0
- package/dist/source-engine/machine-state.js.map +1 -0
- package/dist/source-engine/observe.d.ts +18 -0
- package/dist/source-engine/observe.d.ts.map +1 -0
- package/dist/source-engine/observe.js +598 -0
- package/dist/source-engine/observe.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/types.d.ts +285 -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 +265 -0
- package/dist/source-harness/conformance.js.map +1 -0
- package/dist/source-harness/fixture.d.ts +95 -0
- package/dist/source-harness/fixture.d.ts.map +1 -0
- package/dist/source-harness/fixture.js +261 -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/storage.d.ts +6 -2
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -1
- package/dist/storage.js.map +1 -1
- package/dist/types.d.ts +33 -5
- package/dist/types.d.ts.map +1 -1
- package/dist/uncertain-write.d.ts +156 -19
- package/dist/uncertain-write.d.ts.map +1 -1
- package/dist/uncertain-write.js +90 -31
- package/dist/uncertain-write.js.map +1 -1
- package/dist/versioning.d.ts +9 -4
- package/dist/versioning.d.ts.map +1 -1
- package/dist/versioning.js +9 -4
- package/dist/versioning.js.map +1 -1
- 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 +94 -2
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundle's front page: one write that replaces the root `index.md` (`bundles.root.replace.v1`,
|
|
3
|
+
* `POST <sync prefix>/root`), compare-and-swap on the root's version or on its absence.
|
|
4
|
+
*
|
|
5
|
+
* It is not an identified write. It carries no `X-Superbee-Write-Request`, the host keeps no
|
|
6
|
+
* receipt of it, and there is no outcome lookup. A root version is the SHA-256 of its exact UTF-8
|
|
7
|
+
* bytes, so a client that lost the answer re-reads the root's version from the capabilities answer
|
|
8
|
+
* instead ({@link rootLanding}): the digest of what it sent means the write landed, its base means
|
|
9
|
+
* it did not, and anything else is a conflict. The window this leaves (the root returning to the
|
|
10
|
+
* same old bytes in between) is accepted for a front page.
|
|
11
|
+
*
|
|
12
|
+
* The refusal envelope is the write schema's, read by the same parser as a document write's; only
|
|
13
|
+
* the success differs, since it names the bundle and no document.
|
|
14
|
+
*/
|
|
15
|
+
import { type AuthorizationCode } from "./answer-rows.js";
|
|
16
|
+
import { type HostedAnswer, type HostedCarrier } from "./carrier.js";
|
|
17
|
+
export declare const ROOT_OPERATION_ID = "bundles.root.replace.v1";
|
|
18
|
+
/** What a capabilities answer says about replacing the bundle's root `index.md`; absent reads as `"refused"`. */
|
|
19
|
+
export type HostedRootWrites = "allowed" | "refused";
|
|
20
|
+
export declare const ROOT_WRITE_BOUNDS: Readonly<{
|
|
21
|
+
/** The request ceiling, measured on the encoded JSON body: the same bound as every sync write. */
|
|
22
|
+
payloadBytes: 65536;
|
|
23
|
+
/** The answer is a bounded result envelope. */
|
|
24
|
+
answerBytes: 65536;
|
|
25
|
+
}>;
|
|
26
|
+
/** The root's version as the host computes it: `sha256:` and the hex SHA-256 of the UTF-8 bytes. */
|
|
27
|
+
export declare function rootVersionOf(content: string): string;
|
|
28
|
+
/** The body one root write sends: against `expectedVersion`, or creating a root that is absent. */
|
|
29
|
+
export type RootWritePayload = {
|
|
30
|
+
readonly bundleId: string;
|
|
31
|
+
readonly content: string;
|
|
32
|
+
readonly expectedVersion: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly bundleId: string;
|
|
35
|
+
readonly content: string;
|
|
36
|
+
readonly expectAbsent: true;
|
|
37
|
+
};
|
|
38
|
+
/** A root the transport will not send, and why: over the request bound, or content the host refuses outright. */
|
|
39
|
+
export declare class RootWriteInputError extends Error {
|
|
40
|
+
readonly name = "RootWriteInputError";
|
|
41
|
+
readonly code: "too_large" | "invalid_input";
|
|
42
|
+
constructor(code: "too_large" | "invalid_input", message: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The request a root write sends, and its encoded body, refused before anything leaves when the
|
|
46
|
+
* host could only refuse it: a leading byte-order mark or text that is not well formed (the host's
|
|
47
|
+
* version and the client's digest of it could then differ), or a body over the request bound.
|
|
48
|
+
*/
|
|
49
|
+
export declare function rootWriteRequest(bundleId: string, content: string, base: string | null): {
|
|
50
|
+
payload: RootWritePayload;
|
|
51
|
+
body: string;
|
|
52
|
+
bytes: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* One root write's outcome. `committed` names the version stored (the digest of the bytes sent).
|
|
56
|
+
* `conflict` is a stale base (`version_conflict`, or `document_exists` for a create that found a
|
|
57
|
+
* root), with the host's version when it said. `refused` applied nothing and is final;
|
|
58
|
+
* `authorization` is set when the refusal is about the caller, not the content. `unknown` may
|
|
59
|
+
* have landed: resolve it with {@link rootLanding}.
|
|
60
|
+
*/
|
|
61
|
+
export type RootWriteOutcome = {
|
|
62
|
+
readonly kind: "committed";
|
|
63
|
+
readonly version: string;
|
|
64
|
+
readonly changed: boolean;
|
|
65
|
+
} | {
|
|
66
|
+
readonly kind: "conflict";
|
|
67
|
+
readonly current?: string;
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: "refused";
|
|
70
|
+
readonly code: string;
|
|
71
|
+
readonly message: string;
|
|
72
|
+
readonly authorization?: AuthorizationCode;
|
|
73
|
+
/** The host refused the request itself as malformed (`400`): nothing about the content. */
|
|
74
|
+
readonly malformed?: true;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: "unknown";
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* The outcome one root write's answer stands for. The refusal rows are the identified writes'
|
|
80
|
+
* ({@link updateRow}), read without an identity: a refusal that says `not_applied` is final, and
|
|
81
|
+
* anything the host may have applied without saying so is unknown.
|
|
82
|
+
*/
|
|
83
|
+
export declare function classifyRootAnswer(answer: Pick<HostedAnswer, "status" | "body">, expected: {
|
|
84
|
+
bundleId: string;
|
|
85
|
+
sent: string;
|
|
86
|
+
}): RootWriteOutcome;
|
|
87
|
+
/** The refusal codes of a root write that say only that the host was busy: the next sync sends it again. */
|
|
88
|
+
export declare const ROOT_BUSY_CODES: ReadonlySet<string>;
|
|
89
|
+
export interface RootWriteOptions {
|
|
90
|
+
carrier: HostedCarrier;
|
|
91
|
+
/** The root route, e.g. `/sync/v1/root`. */
|
|
92
|
+
route: string;
|
|
93
|
+
bundleId: string;
|
|
94
|
+
/** The checkout's binding (`X-Superbee-Checkout`). */
|
|
95
|
+
binding: string;
|
|
96
|
+
/** The agent the client runs under (`X-Superbee-Via`); a token {@link isAgentLabelVia} admits. */
|
|
97
|
+
via?: string;
|
|
98
|
+
content: string;
|
|
99
|
+
/** The root version the content replaces, or null to create a root the bundle lacks. */
|
|
100
|
+
base: string | null;
|
|
101
|
+
signal?: AbortSignal;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Send one root write and classify its answer. Content the host would refuse outright is refused
|
|
105
|
+
* here without sending ({@link rootWriteRequest}). Never sends a request identity.
|
|
106
|
+
*/
|
|
107
|
+
export declare function sendRootWrite(options: RootWriteOptions): Promise<RootWriteOutcome>;
|
|
108
|
+
/**
|
|
109
|
+
* Whether a root write whose answer was lost landed, from the root version the host serves now
|
|
110
|
+
* (`null`: no root): the digest of the bytes sent means it landed, its base means it did not, and
|
|
111
|
+
* anything else is a conflict (another write moved the root).
|
|
112
|
+
*/
|
|
113
|
+
export declare function rootLanding(current: string | null, sent: string, base: string | null): "landed" | "not_landed" | "conflict";
|
|
114
|
+
//# sourceMappingURL=root-write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-write.d.ts","sourceRoot":"","sources":["../../src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AAE,WAAW,CAAC;CACtB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAsBxF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAI3H"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundle's front page: one write that replaces the root `index.md` (`bundles.root.replace.v1`,
|
|
3
|
+
* `POST <sync prefix>/root`), compare-and-swap on the root's version or on its absence.
|
|
4
|
+
*
|
|
5
|
+
* It is not an identified write. It carries no `X-Superbee-Write-Request`, the host keeps no
|
|
6
|
+
* receipt of it, and there is no outcome lookup. A root version is the SHA-256 of its exact UTF-8
|
|
7
|
+
* bytes, so a client that lost the answer re-reads the root's version from the capabilities answer
|
|
8
|
+
* instead ({@link rootLanding}): the digest of what it sent means the write landed, its base means
|
|
9
|
+
* it did not, and anything else is a conflict. The window this leaves (the root returning to the
|
|
10
|
+
* same old bytes in between) is accepted for a front page.
|
|
11
|
+
*
|
|
12
|
+
* The refusal envelope is the write schema's, read by the same parser as a document write's; only
|
|
13
|
+
* the success differs, since it names the bundle and no document.
|
|
14
|
+
*/
|
|
15
|
+
import { sha256HexOfUtf8 } from "../sha256.js";
|
|
16
|
+
import { isContentVersion } from "../version-transport.js";
|
|
17
|
+
import { parseWriteResult, updateRow } from "./answer-rows.js";
|
|
18
|
+
import { HostedCarrierError, isAgentLabelVia } from "./carrier.js";
|
|
19
|
+
import { WHOLE_DOCUMENT_BOUNDS } from "./whole-document-transport.js";
|
|
20
|
+
export const ROOT_OPERATION_ID = "bundles.root.replace.v1";
|
|
21
|
+
export const ROOT_WRITE_BOUNDS = Object.freeze({
|
|
22
|
+
/** The request ceiling, measured on the encoded JSON body: the same bound as every sync write. */
|
|
23
|
+
payloadBytes: WHOLE_DOCUMENT_BOUNDS.payloadBytes,
|
|
24
|
+
/** The answer is a bounded result envelope. */
|
|
25
|
+
answerBytes: WHOLE_DOCUMENT_BOUNDS.answerBytes,
|
|
26
|
+
});
|
|
27
|
+
/** The root's version as the host computes it: `sha256:` and the hex SHA-256 of the UTF-8 bytes. */
|
|
28
|
+
export function rootVersionOf(content) {
|
|
29
|
+
return `sha256:${sha256HexOfUtf8(content)}`;
|
|
30
|
+
}
|
|
31
|
+
/** A root the transport will not send, and why: over the request bound, or content the host refuses outright. */
|
|
32
|
+
export class RootWriteInputError extends Error {
|
|
33
|
+
name = "RootWriteInputError";
|
|
34
|
+
code;
|
|
35
|
+
constructor(code, message) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.code = code;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
|
|
41
|
+
const encoder = new TextEncoder();
|
|
42
|
+
/**
|
|
43
|
+
* The request a root write sends, and its encoded body, refused before anything leaves when the
|
|
44
|
+
* host could only refuse it: a leading byte-order mark or text that is not well formed (the host's
|
|
45
|
+
* version and the client's digest of it could then differ), or a body over the request bound.
|
|
46
|
+
*/
|
|
47
|
+
export function rootWriteRequest(bundleId, content, base) {
|
|
48
|
+
if (base !== null && !isContentVersion(base))
|
|
49
|
+
throw new RootWriteInputError("invalid_input", "the root's base is not a version");
|
|
50
|
+
if (content.startsWith(""))
|
|
51
|
+
throw new RootWriteInputError("invalid_input", "the root index starts with a byte-order mark, which the host refuses");
|
|
52
|
+
if (LONE_SURROGATE.test(content))
|
|
53
|
+
throw new RootWriteInputError("invalid_input", "the root index is not well-formed text");
|
|
54
|
+
const payload = base === null ? { bundleId, content, expectAbsent: true } : { bundleId, content, expectedVersion: base };
|
|
55
|
+
const body = JSON.stringify(payload);
|
|
56
|
+
const bytes = encoder.encode(body).byteLength;
|
|
57
|
+
if (bytes > ROOT_WRITE_BOUNDS.payloadBytes)
|
|
58
|
+
throw new RootWriteInputError("too_large", `the root index is over the ${ROOT_WRITE_BOUNDS.payloadBytes / 1024} KiB a sync write carries (${bytes} bytes as a request)`);
|
|
59
|
+
return { payload, body, bytes };
|
|
60
|
+
}
|
|
61
|
+
const UNKNOWN = Object.freeze({ kind: "unknown" });
|
|
62
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
63
|
+
/** A root write's `200` success, admitted only for this bundle, a content version and a boolean `changed`. */
|
|
64
|
+
function rootSuccess(body, bundleId) {
|
|
65
|
+
if (!isRecord(body) || body.ok !== true || body.operationId !== ROOT_OPERATION_ID || body.error !== undefined)
|
|
66
|
+
return null;
|
|
67
|
+
const data = body.data;
|
|
68
|
+
if (!isRecord(data) || !Object.keys(data).every((key) => key === "bundleId" || key === "version" || key === "changed"))
|
|
69
|
+
return null;
|
|
70
|
+
if (data.bundleId !== bundleId || !isContentVersion(data.version) || typeof data.changed !== "boolean")
|
|
71
|
+
return null;
|
|
72
|
+
return { version: data.version, changed: data.changed };
|
|
73
|
+
}
|
|
74
|
+
/** The authorization code the identified writes' row for a `200` refusal carries, if any. */
|
|
75
|
+
function authorizationOf(code) {
|
|
76
|
+
try {
|
|
77
|
+
return updateRow(`200 ${code}`).code;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The outcome one root write's answer stands for. The refusal rows are the identified writes'
|
|
85
|
+
* ({@link updateRow}), read without an identity: a refusal that says `not_applied` is final, and
|
|
86
|
+
* anything the host may have applied without saying so is unknown.
|
|
87
|
+
*/
|
|
88
|
+
export function classifyRootAnswer(answer, expected) {
|
|
89
|
+
const { status, body } = answer;
|
|
90
|
+
const error = isRecord(body) && isRecord(body.error) ? body.error : undefined;
|
|
91
|
+
const notApplied = error?.writeState === "not_applied";
|
|
92
|
+
if (status === 200) {
|
|
93
|
+
if (isRecord(body) && body.ok === true) {
|
|
94
|
+
const success = rootSuccess(body, expected.bundleId);
|
|
95
|
+
// A success naming other bytes than those sent is not evidence about this request.
|
|
96
|
+
return success && success.version === expected.sent ? { kind: "committed", ...success } : UNKNOWN;
|
|
97
|
+
}
|
|
98
|
+
let failure;
|
|
99
|
+
try {
|
|
100
|
+
failure = parseWriteResult(body, { operationIds: [ROOT_OPERATION_ID], documentId: "index.md", bundleId: expected.bundleId });
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return UNKNOWN;
|
|
104
|
+
}
|
|
105
|
+
if (failure.ok || failure.error.writeState !== "not_applied")
|
|
106
|
+
return UNKNOWN;
|
|
107
|
+
const { code, message, currentVersion } = failure.error;
|
|
108
|
+
if (code === "version_conflict" || code === "document_exists")
|
|
109
|
+
return { kind: "conflict", ...(currentVersion !== undefined ? { current: currentVersion } : {}) };
|
|
110
|
+
const authorization = authorizationOf(code);
|
|
111
|
+
return { kind: "refused", code, message, ...(authorization ? { authorization } : {}) };
|
|
112
|
+
}
|
|
113
|
+
// A malformed binding or body: the host read nothing, and the same request can only repeat it.
|
|
114
|
+
if (status === 400)
|
|
115
|
+
return { kind: "refused", code: typeof error?.code === "string" ? error.code : "invalid_input", message: typeof error?.message === "string" ? error.message : "The host refused the request as malformed; nothing was written.", malformed: true };
|
|
116
|
+
if (status === 401)
|
|
117
|
+
return notApplied ? { kind: "refused", code: "AUTH_REQUIRED", message: "The hosted session ended; the front page was not sent.", authorization: "AUTH_REQUIRED" } : UNKNOWN;
|
|
118
|
+
// As the identified writes' `403` row: access withdrawn, which signing in again cannot fix.
|
|
119
|
+
if (status === 403)
|
|
120
|
+
return { kind: "refused", code: "access_withdrawn", message: "The host denied access to this bundle.", authorization: "AUTH_REQUIRED" };
|
|
121
|
+
if (status === 503 && notApplied)
|
|
122
|
+
return { kind: "refused", code: typeof error?.code === "string" ? error.code : "backend_unavailable", message: typeof error?.message === "string" ? error.message : "The host was unavailable; nothing was written." };
|
|
123
|
+
return UNKNOWN;
|
|
124
|
+
}
|
|
125
|
+
/** The refusal codes of a root write that say only that the host was busy: the next sync sends it again. */
|
|
126
|
+
export const ROOT_BUSY_CODES = new Set(["backend_unavailable", "concurrent_change", "internal_error", "deadline_exceeded", "cancelled"]);
|
|
127
|
+
/**
|
|
128
|
+
* Send one root write and classify its answer. Content the host would refuse outright is refused
|
|
129
|
+
* here without sending ({@link rootWriteRequest}). Never sends a request identity.
|
|
130
|
+
*/
|
|
131
|
+
export async function sendRootWrite(options) {
|
|
132
|
+
if (options.via !== undefined && !isAgentLabelVia(options.via))
|
|
133
|
+
throw new TypeError("the via token is not one the host admits");
|
|
134
|
+
let request;
|
|
135
|
+
try {
|
|
136
|
+
request = rootWriteRequest(options.bundleId, options.content, options.base);
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if (error instanceof RootWriteInputError)
|
|
140
|
+
return { kind: "refused", code: error.code, message: `${error.message}; it was not sent.` };
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
let answer;
|
|
144
|
+
try {
|
|
145
|
+
answer = await options.carrier.json(options.route, request.payload, options.signal ?? new AbortController().signal, {
|
|
146
|
+
maximum: ROOT_WRITE_BOUNDS.answerBytes,
|
|
147
|
+
binding: options.binding,
|
|
148
|
+
...(options.via !== undefined ? { via: options.via } : {}),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
// A credential that was already gone sent nothing; anything else may have left.
|
|
153
|
+
if (error instanceof HostedCarrierError && error.code === "denied")
|
|
154
|
+
return { kind: "refused", code: "AUTH_REQUIRED", message: "No credential was available; the front page was not sent.", authorization: "AUTH_REQUIRED" };
|
|
155
|
+
return UNKNOWN;
|
|
156
|
+
}
|
|
157
|
+
return classifyRootAnswer(answer, { bundleId: options.bundleId, sent: rootVersionOf(options.content) });
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Whether a root write whose answer was lost landed, from the root version the host serves now
|
|
161
|
+
* (`null`: no root): the digest of the bytes sent means it landed, its base means it did not, and
|
|
162
|
+
* anything else is a conflict (another write moved the root).
|
|
163
|
+
*/
|
|
164
|
+
export function rootLanding(current, sent, base) {
|
|
165
|
+
if (current === sent)
|
|
166
|
+
return "landed";
|
|
167
|
+
if (current === base)
|
|
168
|
+
return "not_landed";
|
|
169
|
+
return "conflict";
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=root-write.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-write.js","sourceRoot":"","sources":["../../src/hosted-transport/root-write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAA0B,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAyC,MAAM,cAAc,CAAC;AAC1G,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AAK3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,kGAAkG;IAClG,YAAY,EAAE,qBAAqB,CAAC,YAAY;IAChD,+CAA+C;IAC/C,WAAW,EAAE,qBAAqB,CAAC,WAAW;CAC/C,CAAC,CAAC;AAEH,oGAAoG;AACpG,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO,UAAU,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;AAC9C,CAAC;AAOD,iHAAiH;AACjH,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IAC1B,IAAI,GAAG,qBAAqB,CAAC;IACtC,IAAI,CAAgC;IA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AI,eAAe,EAAE,CAAC,MAAM,EAAE;YAClH,OAAO,EAAE,iBAAiB,CAAC,WAAW;YACtC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,CAAC,OAAO,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC3D,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,gFAAgF;QAChF,IAAI,KAAK,YAAY,kBAAkB,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,2DAA2D,EAAE,aAAa,EAAE,eAAe,EAAE,CAAC;QAC5N,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,OAAO,kBAAkB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC1G,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,OAAsB,EAAE,IAAY,EAAE,IAAmB;IACnF,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,QAAQ,CAAC;IACtC,IAAI,OAAO,KAAK,IAAI;QAAE,OAAO,YAAY,CAAC;IAC1C,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The sync delivery side: an {@link OperationTransport} that pushes one whole document per
|
|
3
|
+
* request. The intent's kind names the operation and its base must agree with it
|
|
4
|
+
* ({@link WHOLE_DOCUMENT_INTENT_KINDS}): a create (`documents.create.v1`, create-only) has no
|
|
5
|
+
* base, a replace (`documents.replace.v1`) is against exactly the intent's base, and a delete
|
|
6
|
+
* (`documents.delete.v1`) removes the document at exactly the intent's base, so the host's
|
|
7
|
+
* compare-and-swap decides every concurrent change to one document and never merges it. Any other
|
|
8
|
+
* kind (a body update) or a kind its base contradicts is refused before anything is sent, and
|
|
9
|
+
* never mapped to another operation. The managed fields the host owns are stripped before
|
|
10
|
+
* sending; the host carries them from the stored document. The one exception is a bundle's
|
|
11
|
+
* creation ({@link WholeDocumentRequestOptions.mode} `import`), where nothing is stored yet.
|
|
12
|
+
*
|
|
13
|
+
* A deleted document leaves a tombstone on the host. A create of that id is refused as a
|
|
14
|
+
* `version_conflict` naming the tombstone unless it acknowledges exactly the id's latest one
|
|
15
|
+
* (`X-Superbee-Recreate`), and the refusal comes back as the "deleted remotely" conflict carrying
|
|
16
|
+
* the tombstone (`{ kind: "conflict", actual: null, tombstone }`). The acknowledgement is sent
|
|
17
|
+
* only when the intent says so ({@link OperationIntent.recreates}); a stale one is refused again
|
|
18
|
+
* and comes back as a fresh conflict naming the newer tombstone, never as last-writer-wins.
|
|
19
|
+
*
|
|
20
|
+
* Every answer is mapped by the shared rows in `answer-rows.ts`, with one difference a
|
|
21
|
+
* create-only write needs: `document_exists` is a conflict against the served head, because a
|
|
22
|
+
* create that finds the document is exactly a compare-and-swap mismatch on absence.
|
|
23
|
+
*
|
|
24
|
+
* The committed version comes from the host's recorded result, and the host stores its own
|
|
25
|
+
* serialization (with managed fields), so a committed version is not the intent's `local`
|
|
26
|
+
* version. Deliver with `settlement: "recorded-only"` ({@link WHOLE_DOCUMENT_SETTLEMENT}) so a
|
|
27
|
+
* conflict is never read as a commit by comparing versions.
|
|
28
|
+
*
|
|
29
|
+
* `OperationTransport.lookup` names only a request identity, and the host's outcome route takes
|
|
30
|
+
* the same body as the write it identifies, so the transport reads the intent back from the
|
|
31
|
+
* journal (`intentFor`) to rebuild it.
|
|
32
|
+
*/
|
|
33
|
+
import type { Frontmatter, Version } from "../types.js";
|
|
34
|
+
import { type OperationIntent, type OperationTransport, type UncertainWriteOptions } from "../uncertain-write.js";
|
|
35
|
+
import { DELETE_OPERATION_ID } from "./answer-rows.js";
|
|
36
|
+
import { type HostedCarrier } from "./carrier.js";
|
|
37
|
+
import { type HostedReadAdapter } from "./read-adapter.js";
|
|
38
|
+
/** Frontmatter the host owns; no caller may set it, and the host carries it from the stored document. */
|
|
39
|
+
export declare const HOSTED_MANAGED_FIELDS: ReadonlySet<string>;
|
|
40
|
+
/**
|
|
41
|
+
* The managed fields a bundle's creation carries as the folder states them: provenance a local
|
|
42
|
+
* engine stored, which nothing on the host could restore later, so a bundle moved to the host
|
|
43
|
+
* reads as it did. Each is the folder's claim, not authority: `generated` and
|
|
44
|
+
* `superbee_updated_by` say who produced and last wrote the content (the host shows either as
|
|
45
|
+
* attribution, never as an authorization input), and `verified` events are the checks the folder
|
|
46
|
+
* records, which the host has no path to write again. The host's own record of the creation is its
|
|
47
|
+
* history row, which names the person who published; every later write through the host stamps
|
|
48
|
+
* `superbee_updated_by` itself and carries `verified` from the stored document. A field outside
|
|
49
|
+
* this list ({@link IMPORT_DROPPED_FIELDS}) never leaves.
|
|
50
|
+
*/
|
|
51
|
+
export declare const IMPORT_CARRIED_FIELDS: readonly string[];
|
|
52
|
+
/** The managed fields a creation drops: none today; a managed field added later stays behind until it is named above. */
|
|
53
|
+
export declare const IMPORT_DROPPED_FIELDS: readonly string[];
|
|
54
|
+
/** The most frontmatter fields the kernel accepts on a create or replace. */
|
|
55
|
+
export declare const FRONTMATTER_KEY_LIMIT = 32;
|
|
56
|
+
/** The settlement mode a whole-document delivery must use. */
|
|
57
|
+
export declare const WHOLE_DOCUMENT_SETTLEMENT: NonNullable<UncertainWriteOptions["settlement"]>;
|
|
58
|
+
export declare const WHOLE_DOCUMENT_BOUNDS: Readonly<{
|
|
59
|
+
/**
|
|
60
|
+
* The write routes' request ceiling on a host that states none (`limits.documentInputBytes`); a
|
|
61
|
+
* larger payload is refused here before it leaves. A host that states its bound is held to that.
|
|
62
|
+
*/
|
|
63
|
+
payloadBytes: 65536;
|
|
64
|
+
/** A write answer is a bounded result envelope. */
|
|
65
|
+
answerBytes: 65536;
|
|
66
|
+
/** An outcome answer carries the committed document as base64 under this envelope ceiling. */
|
|
67
|
+
outcomeAnswerBytes: number;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* The whole-document write bound current hosts state (`limits.documentInputBytes`, 983,040 bytes:
|
|
71
|
+
* 1 MiB less a 64 KiB margin). A client plans against it only before it has asked the host, and
|
|
72
|
+
* holds a request to what the host actually states.
|
|
73
|
+
*/
|
|
74
|
+
export declare const CURRENT_HOST_DOCUMENT_INPUT_BYTES = 983040;
|
|
75
|
+
export interface WholeDocumentRoutes {
|
|
76
|
+
create: string;
|
|
77
|
+
replace: string;
|
|
78
|
+
delete: string;
|
|
79
|
+
outcome: string;
|
|
80
|
+
}
|
|
81
|
+
export declare const SYNC_WRITE_ROUTES: WholeDocumentRoutes;
|
|
82
|
+
/**
|
|
83
|
+
* The exact kernel input one intent becomes, and the route and operation it goes to. A create
|
|
84
|
+
* that re-creates a deleted document carries the tombstone it acknowledges in `recreates`, which
|
|
85
|
+
* rides the `X-Superbee-Recreate` header, never the body.
|
|
86
|
+
*/
|
|
87
|
+
export type WholeDocumentRequest = {
|
|
88
|
+
kind: "create";
|
|
89
|
+
operationId: "documents.create.v1";
|
|
90
|
+
payload: {
|
|
91
|
+
bundleId: string;
|
|
92
|
+
documentId: string;
|
|
93
|
+
expectAbsent: true;
|
|
94
|
+
frontmatter: Frontmatter;
|
|
95
|
+
body: string;
|
|
96
|
+
};
|
|
97
|
+
recreates?: Version;
|
|
98
|
+
/** An `import` request only: the managed fields the document held, carried and dropped. */
|
|
99
|
+
provenance?: {
|
|
100
|
+
carried: string[];
|
|
101
|
+
dropped: string[];
|
|
102
|
+
};
|
|
103
|
+
} | {
|
|
104
|
+
kind: "replace";
|
|
105
|
+
operationId: "documents.replace.v1";
|
|
106
|
+
payload: {
|
|
107
|
+
bundleId: string;
|
|
108
|
+
documentId: string;
|
|
109
|
+
expectedVersion: Version;
|
|
110
|
+
frontmatter: Frontmatter;
|
|
111
|
+
body: string;
|
|
112
|
+
};
|
|
113
|
+
} | {
|
|
114
|
+
kind: "delete";
|
|
115
|
+
operationId: typeof DELETE_OPERATION_ID;
|
|
116
|
+
payload: {
|
|
117
|
+
bundleId: string;
|
|
118
|
+
documentId: string;
|
|
119
|
+
expectedVersion: Version;
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* The intent kinds this transport sends, each with the base it requires. `document.write` is the
|
|
124
|
+
* working-copy engine's whole-document write, a create exactly when it has no base.
|
|
125
|
+
* `document.delete` removes the document at exactly its base, so it requires one. Every other
|
|
126
|
+
* kind is unsupported: it is refused without sending, never routed by its base.
|
|
127
|
+
*/
|
|
128
|
+
export declare const WHOLE_DOCUMENT_INTENT_KINDS: Readonly<Record<string, "create" | "replace" | "delete" | "by-base">>;
|
|
129
|
+
/**
|
|
130
|
+
* An intent the transport will not send, and why: the answer a `refused` outcome carries.
|
|
131
|
+
* `unsupported_operation` is an intent kind this transport does not send, or one its base
|
|
132
|
+
* contradicts; `invalid_input` is a document the host would refuse.
|
|
133
|
+
*/
|
|
134
|
+
export declare class WholeDocumentInputError extends Error {
|
|
135
|
+
readonly name = "WholeDocumentInputError";
|
|
136
|
+
readonly code: "invalid_input" | "unsupported_operation";
|
|
137
|
+
constructor(message: string, code?: "invalid_input" | "unsupported_operation");
|
|
138
|
+
}
|
|
139
|
+
export interface WholeDocumentRequestOptions {
|
|
140
|
+
/**
|
|
141
|
+
* `write` (the default): every managed field is removed, as every write to an existing bundle
|
|
142
|
+
* needs. `import`: the document is part of a bundle's creation, where the host stores what it
|
|
143
|
+
* is sent and holds nothing to carry managed fields from, so {@link IMPORT_CARRIED_FIELDS}
|
|
144
|
+
* travel as the folder states them and {@link IMPORT_DROPPED_FIELDS} are removed. Only a create
|
|
145
|
+
* may be an import; any other operation is refused.
|
|
146
|
+
*/
|
|
147
|
+
mode?: "write" | "import";
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The request an intent becomes: the serialized document parsed under the bundle's edition,
|
|
151
|
+
* managed fields removed (for an `import`, the dropped ones), a create or a replace against
|
|
152
|
+
* `base` as its kind names. The kind is checked first, so an unsupported kind is refused before
|
|
153
|
+
* its content is read. A document whose frontmatter is not plain JSON (a date object, say) is
|
|
154
|
+
* refused here, because sending it would change what it says.
|
|
155
|
+
*/
|
|
156
|
+
export declare function wholeDocumentRequest(bundleId: string, intent: Pick<OperationIntent, "kind" | "target" | "base" | "content" | "recreates">, okfVersion?: string, options?: WholeDocumentRequestOptions): WholeDocumentRequest;
|
|
157
|
+
export interface WholeDocumentTransportOptions {
|
|
158
|
+
carrier: HostedCarrier;
|
|
159
|
+
bundleId: string;
|
|
160
|
+
/** The checkout's binding, pinned on every write and lookup; the outcome answer must name it. */
|
|
161
|
+
binding: string;
|
|
162
|
+
/** The intent a request identity names, from the journal; the lookup rebuilds its request from it. */
|
|
163
|
+
intentFor(requestId: string): Promise<OperationIntent | undefined>;
|
|
164
|
+
/** The served head after a conflict without a current version, and the retention window. */
|
|
165
|
+
remote: Pick<HostedReadAdapter, "read" | "operationsRetentionMs">;
|
|
166
|
+
routes?: WholeDocumentRoutes;
|
|
167
|
+
/** The bundle's edition, for parsing an intent's serialized frontmatter. */
|
|
168
|
+
okfVersion?: string;
|
|
169
|
+
/** Ends every request in flight. */
|
|
170
|
+
signal?: AbortSignal;
|
|
171
|
+
now?: () => number;
|
|
172
|
+
/**
|
|
173
|
+
* The agent the client runs under (`X-Superbee-Via`), sent on every write and its lookup. It
|
|
174
|
+
* must be a token {@link isAgentLabelVia} admits: the transport refuses to be built otherwise.
|
|
175
|
+
*/
|
|
176
|
+
via?: string;
|
|
177
|
+
/**
|
|
178
|
+
* The person's typed acknowledgment of the host's mass-delete hold (`X-Superbee-Accept-Deletes`),
|
|
179
|
+
* sent on every delete write of this transport and on nothing else. Set it only after the person
|
|
180
|
+
* confirmed that many deletions in their own terminal; never from an agent's decision.
|
|
181
|
+
*/
|
|
182
|
+
acceptDeletes?: number;
|
|
183
|
+
/**
|
|
184
|
+
* The host's whole-document write bound as its capabilities answer states it
|
|
185
|
+
* (`documentInputBytes`), in bytes of the request's JSON. Absent or null: the host states none,
|
|
186
|
+
* and {@link WHOLE_DOCUMENT_BOUNDS}`.payloadBytes` applies.
|
|
187
|
+
*/
|
|
188
|
+
documentInputBytes?: number | null;
|
|
189
|
+
/**
|
|
190
|
+
* Told of each delete the host's mass-delete hold refused (`428 deletions_held`), with the
|
|
191
|
+
* bundle's counts. The intent is settled `refused` with {@link DELETIONS_HELD_REFUSAL_CODE},
|
|
192
|
+
* which never pauses the store: it stays until a person accepts or restores it.
|
|
193
|
+
*/
|
|
194
|
+
onDeletionsHeld?: (held: {
|
|
195
|
+
requestId: string;
|
|
196
|
+
target: string;
|
|
197
|
+
deletions: number;
|
|
198
|
+
baseline: number;
|
|
199
|
+
}) => void;
|
|
200
|
+
}
|
|
201
|
+
export declare function createWholeDocumentTransport(options: WholeDocumentTransportOptions): OperationTransport & {
|
|
202
|
+
readonly settlement: typeof WHOLE_DOCUMENT_SETTLEMENT;
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=whole-document-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whole-document-transport.d.ts","sourceRoot":"","sources":["../../src/hosted-transport/whole-document-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAsC,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAgB,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAapK,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAmF,KAAK,aAAa,EAA6B,MAAM,cAAc,CAAC;AAE9J,OAAO,EAAgC,KAAK,iBAAiB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