@diffra-ai/chord 0.0.0-stage → 0.2.3
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/CHANGELOG.md +237 -0
- package/README.md +227 -2
- package/dist/context/index.d.ts +43 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +112 -0
- package/dist/context/index.js.map +1 -0
- package/dist/contracts/accepts.d.ts +91 -0
- package/dist/contracts/accepts.d.ts.map +1 -0
- package/dist/contracts/accepts.js +145 -0
- package/dist/contracts/accepts.js.map +1 -0
- package/dist/contracts/contract.d.ts +238 -0
- package/dist/contracts/contract.d.ts.map +1 -0
- package/dist/contracts/contract.js +69 -0
- package/dist/contracts/contract.js.map +1 -0
- package/dist/contracts/declare.d.ts +144 -0
- package/dist/contracts/declare.d.ts.map +1 -0
- package/dist/contracts/declare.js +207 -0
- package/dist/contracts/declare.js.map +1 -0
- package/dist/contracts/evolve.d.ts +142 -0
- package/dist/contracts/evolve.d.ts.map +1 -0
- package/dist/contracts/evolve.js +216 -0
- package/dist/contracts/evolve.js.map +1 -0
- package/dist/contracts/fingerprint.d.ts +16 -0
- package/dist/contracts/fingerprint.d.ts.map +1 -0
- package/dist/contracts/fingerprint.js +61 -0
- package/dist/contracts/fingerprint.js.map +1 -0
- package/dist/contracts/history.d.ts +79 -0
- package/dist/contracts/history.d.ts.map +1 -0
- package/dist/contracts/history.js +3 -0
- package/dist/contracts/history.js.map +1 -0
- package/dist/contracts/host-kind.d.ts +58 -0
- package/dist/contracts/host-kind.d.ts.map +1 -0
- package/dist/contracts/host-kind.js +122 -0
- package/dist/contracts/host-kind.js.map +1 -0
- package/dist/contracts/index.d.ts +8 -0
- package/dist/contracts/index.d.ts.map +1 -0
- package/dist/contracts/index.js +7 -0
- package/dist/contracts/index.js.map +1 -0
- package/dist/contracts/internal.d.ts +12 -0
- package/dist/contracts/internal.d.ts.map +1 -0
- package/dist/contracts/internal.js +11 -0
- package/dist/contracts/internal.js.map +1 -0
- package/dist/contracts/names.d.ts +3 -0
- package/dist/contracts/names.d.ts.map +1 -0
- package/dist/contracts/names.js +13 -0
- package/dist/contracts/names.js.map +1 -0
- package/dist/contracts/params.d.ts +28 -0
- package/dist/contracts/params.d.ts.map +1 -0
- package/dist/contracts/params.js +55 -0
- package/dist/contracts/params.js.map +1 -0
- package/dist/contracts/schema.d.ts +144 -0
- package/dist/contracts/schema.d.ts.map +1 -0
- package/dist/contracts/schema.js +144 -0
- package/dist/contracts/schema.js.map +1 -0
- package/dist/contracts/snapshot.d.ts +16 -0
- package/dist/contracts/snapshot.d.ts.map +1 -0
- package/dist/contracts/snapshot.js +167 -0
- package/dist/contracts/snapshot.js.map +1 -0
- package/dist/data/args.d.ts +50 -0
- package/dist/data/args.d.ts.map +1 -0
- package/dist/data/args.js +83 -0
- package/dist/data/args.js.map +1 -0
- package/dist/data/errors.d.ts +80 -0
- package/dist/data/errors.d.ts.map +1 -0
- package/dist/data/errors.js +116 -0
- package/dist/data/errors.js.map +1 -0
- package/dist/data/failure.d.ts +31 -0
- package/dist/data/failure.d.ts.map +1 -0
- package/dist/data/failure.js +78 -0
- package/dist/data/failure.js.map +1 -0
- package/dist/data/index.d.ts +4 -0
- package/dist/data/index.d.ts.map +1 -0
- package/dist/data/index.js +5 -0
- package/dist/data/index.js.map +1 -0
- package/dist/data/internal.d.ts +7 -0
- package/dist/data/internal.d.ts.map +1 -0
- package/dist/data/internal.js +8 -0
- package/dist/data/internal.js.map +1 -0
- package/dist/data/params.d.ts +20 -0
- package/dist/data/params.d.ts.map +1 -0
- package/dist/data/params.js +31 -0
- package/dist/data/params.js.map +1 -0
- package/dist/data/principal.d.ts +28 -0
- package/dist/data/principal.d.ts.map +1 -0
- package/dist/data/principal.js +64 -0
- package/dist/data/principal.js.map +1 -0
- package/dist/data/validator.d.ts +12 -0
- package/dist/data/validator.d.ts.map +1 -0
- package/dist/data/validator.js +35 -0
- package/dist/data/validator.js.map +1 -0
- package/dist/delta/apply-immutable-trusted.d.ts +4 -0
- package/dist/delta/apply-immutable-trusted.d.ts.map +1 -0
- package/dist/delta/apply-immutable-trusted.js +126 -0
- package/dist/delta/apply-immutable-trusted.js.map +1 -0
- package/dist/delta/diff.d.ts +5 -0
- package/dist/delta/diff.d.ts.map +1 -0
- package/dist/delta/diff.js +435 -0
- package/dist/delta/diff.js.map +1 -0
- package/dist/delta/draft.d.ts +5 -0
- package/dist/delta/draft.d.ts.map +1 -0
- package/dist/delta/draft.js +2 -0
- package/dist/delta/draft.js.map +1 -0
- package/dist/delta/index.d.ts +120 -0
- package/dist/delta/index.d.ts.map +1 -0
- package/dist/delta/index.js +697 -0
- package/dist/delta/index.js.map +1 -0
- package/dist/delta/pending.d.ts +36 -0
- package/dist/delta/pending.d.ts.map +1 -0
- package/dist/delta/pending.js +143 -0
- package/dist/delta/pending.js.map +1 -0
- package/dist/delta/revision-validator.d.ts +7 -0
- package/dist/delta/revision-validator.d.ts.map +1 -0
- package/dist/delta/revision-validator.js +71 -0
- package/dist/delta/revision-validator.js.map +1 -0
- package/dist/delta/tracker.d.ts +38 -0
- package/dist/delta/tracker.d.ts.map +1 -0
- package/dist/delta/tracker.js +2175 -0
- package/dist/delta/tracker.js.map +1 -0
- package/dist/documents/address-source.d.ts +20 -0
- package/dist/documents/address-source.d.ts.map +1 -0
- package/dist/documents/address-source.js +44 -0
- package/dist/documents/address-source.js.map +1 -0
- package/dist/documents/definition.d.ts +92 -0
- package/dist/documents/definition.d.ts.map +1 -0
- package/dist/documents/definition.js +81 -0
- package/dist/documents/definition.js.map +1 -0
- package/dist/documents/documents.d.ts +129 -0
- package/dist/documents/documents.d.ts.map +1 -0
- package/dist/documents/documents.js +258 -0
- package/dist/documents/documents.js.map +1 -0
- package/dist/documents/fence.d.ts +9 -0
- package/dist/documents/fence.d.ts.map +1 -0
- package/dist/documents/fence.js +15 -0
- package/dist/documents/fence.js.map +1 -0
- package/dist/documents/handles.d.ts +81 -0
- package/dist/documents/handles.d.ts.map +1 -0
- package/dist/documents/handles.js +74 -0
- package/dist/documents/handles.js.map +1 -0
- package/dist/documents/index.d.ts +4 -0
- package/dist/documents/index.d.ts.map +1 -0
- package/dist/documents/index.js +3 -0
- package/dist/documents/index.js.map +1 -0
- package/dist/documents/internal.d.ts +9 -0
- package/dist/documents/internal.d.ts.map +1 -0
- package/dist/documents/internal.js +9 -0
- package/dist/documents/internal.js.map +1 -0
- package/dist/documents/keyed-slot.d.ts +139 -0
- package/dist/documents/keyed-slot.d.ts.map +1 -0
- package/dist/documents/keyed-slot.js +478 -0
- package/dist/documents/keyed-slot.js.map +1 -0
- package/dist/documents/line.d.ts +7 -0
- package/dist/documents/line.d.ts.map +1 -0
- package/dist/documents/line.js +14 -0
- package/dist/documents/line.js.map +1 -0
- package/dist/documents/persistence.d.ts +120 -0
- package/dist/documents/persistence.d.ts.map +1 -0
- package/dist/documents/persistence.js +156 -0
- package/dist/documents/persistence.js.map +1 -0
- package/dist/documents/residency.d.ts +31 -0
- package/dist/documents/residency.d.ts.map +1 -0
- package/dist/documents/residency.js +93 -0
- package/dist/documents/residency.js.map +1 -0
- package/dist/documents/slot.d.ts +112 -0
- package/dist/documents/slot.d.ts.map +1 -0
- package/dist/documents/slot.js +190 -0
- package/dist/documents/slot.js.map +1 -0
- package/dist/documents/transaction.d.ts +143 -0
- package/dist/documents/transaction.d.ts.map +1 -0
- package/dist/documents/transaction.js +445 -0
- package/dist/documents/transaction.js.map +1 -0
- package/dist/host/activity.d.ts +31 -0
- package/dist/host/activity.d.ts.map +1 -0
- package/dist/host/activity.js +40 -0
- package/dist/host/activity.js.map +1 -0
- package/dist/host/adapted.d.ts +63 -0
- package/dist/host/adapted.d.ts.map +1 -0
- package/dist/host/adapted.js +298 -0
- package/dist/host/adapted.js.map +1 -0
- package/dist/host/admission.d.ts +137 -0
- package/dist/host/admission.d.ts.map +1 -0
- package/dist/host/admission.js +290 -0
- package/dist/host/admission.js.map +1 -0
- package/dist/host/attempt.d.ts +417 -0
- package/dist/host/attempt.d.ts.map +1 -0
- package/dist/host/attempt.js +1490 -0
- package/dist/host/attempt.js.map +1 -0
- package/dist/host/backoff.d.ts +29 -0
- package/dist/host/backoff.d.ts.map +1 -0
- package/dist/host/backoff.js +69 -0
- package/dist/host/backoff.js.map +1 -0
- package/dist/host/ctx.d.ts +94 -0
- package/dist/host/ctx.d.ts.map +1 -0
- package/dist/host/ctx.js +200 -0
- package/dist/host/ctx.js.map +1 -0
- package/dist/host/deadline.d.ts +12 -0
- package/dist/host/deadline.d.ts.map +1 -0
- package/dist/host/deadline.js +40 -0
- package/dist/host/deadline.js.map +1 -0
- package/dist/host/dependencies.d.ts +97 -0
- package/dist/host/dependencies.d.ts.map +1 -0
- package/dist/host/dependencies.js +148 -0
- package/dist/host/dependencies.js.map +1 -0
- package/dist/host/destination.d.ts +48 -0
- package/dist/host/destination.d.ts.map +1 -0
- package/dist/host/destination.js +101 -0
- package/dist/host/destination.js.map +1 -0
- package/dist/host/events.d.ts +114 -0
- package/dist/host/events.d.ts.map +1 -0
- package/dist/host/events.js +191 -0
- package/dist/host/events.js.map +1 -0
- package/dist/host/facet.d.ts +106 -0
- package/dist/host/facet.d.ts.map +1 -0
- package/dist/host/facet.js +55 -0
- package/dist/host/facet.js.map +1 -0
- package/dist/host/follow.d.ts +52 -0
- package/dist/host/follow.d.ts.map +1 -0
- package/dist/host/follow.js +207 -0
- package/dist/host/follow.js.map +1 -0
- package/dist/host/host-data.d.ts +62 -0
- package/dist/host/host-data.d.ts.map +1 -0
- package/dist/host/host-data.js +229 -0
- package/dist/host/host-data.js.map +1 -0
- package/dist/host/host.d.ts +641 -0
- package/dist/host/host.d.ts.map +1 -0
- package/dist/host/host.js +1449 -0
- package/dist/host/host.js.map +1 -0
- package/dist/host/index.d.ts +20 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +7 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/internal.d.ts +13 -0
- package/dist/host/internal.d.ts.map +1 -0
- package/dist/host/internal.js +11 -0
- package/dist/host/internal.js.map +1 -0
- package/dist/host/list.d.ts +52 -0
- package/dist/host/list.d.ts.map +1 -0
- package/dist/host/list.js +149 -0
- package/dist/host/list.js.map +1 -0
- package/dist/host/members.d.ts +58 -0
- package/dist/host/members.d.ts.map +1 -0
- package/dist/host/members.js +178 -0
- package/dist/host/members.js.map +1 -0
- package/dist/host/named-query.d.ts +67 -0
- package/dist/host/named-query.d.ts.map +1 -0
- package/dist/host/named-query.js +166 -0
- package/dist/host/named-query.js.map +1 -0
- package/dist/host/native.d.ts +64 -0
- package/dist/host/native.d.ts.map +1 -0
- package/dist/host/native.js +126 -0
- package/dist/host/native.js.map +1 -0
- package/dist/host/object.d.ts +388 -0
- package/dist/host/object.d.ts.map +1 -0
- package/dist/host/object.js +1527 -0
- package/dist/host/object.js.map +1 -0
- package/dist/host/old-work.d.ts +34 -0
- package/dist/host/old-work.d.ts.map +1 -0
- package/dist/host/old-work.js +52 -0
- package/dist/host/old-work.js.map +1 -0
- package/dist/host/parked.d.ts +23 -0
- package/dist/host/parked.d.ts.map +1 -0
- package/dist/host/parked.js +79 -0
- package/dist/host/parked.js.map +1 -0
- package/dist/host/presence.d.ts +34 -0
- package/dist/host/presence.d.ts.map +1 -0
- package/dist/host/presence.js +117 -0
- package/dist/host/presence.js.map +1 -0
- package/dist/host/query-reader.d.ts +80 -0
- package/dist/host/query-reader.d.ts.map +1 -0
- package/dist/host/query-reader.js +182 -0
- package/dist/host/query-reader.js.map +1 -0
- package/dist/host/read-declarations.d.ts +75 -0
- package/dist/host/read-declarations.d.ts.map +1 -0
- package/dist/host/read-declarations.js +152 -0
- package/dist/host/read-declarations.js.map +1 -0
- package/dist/host/readiness.d.ts +27 -0
- package/dist/host/readiness.d.ts.map +1 -0
- package/dist/host/readiness.js +134 -0
- package/dist/host/readiness.js.map +1 -0
- package/dist/host/ref-state.d.ts +53 -0
- package/dist/host/ref-state.d.ts.map +1 -0
- package/dist/host/ref-state.js +83 -0
- package/dist/host/ref-state.js.map +1 -0
- package/dist/host/reference-events.d.ts +51 -0
- package/dist/host/reference-events.d.ts.map +1 -0
- package/dist/host/reference-events.js +133 -0
- package/dist/host/reference-events.js.map +1 -0
- package/dist/host/reference-keys.d.ts +36 -0
- package/dist/host/reference-keys.d.ts.map +1 -0
- package/dist/host/reference-keys.js +168 -0
- package/dist/host/reference-keys.js.map +1 -0
- package/dist/host/reference-source.d.ts +77 -0
- package/dist/host/reference-source.d.ts.map +1 -0
- package/dist/host/reference-source.js +326 -0
- package/dist/host/reference-source.js.map +1 -0
- package/dist/host/reference.d.ts +377 -0
- package/dist/host/reference.d.ts.map +1 -0
- package/dist/host/reference.js +986 -0
- package/dist/host/reference.js.map +1 -0
- package/dist/host/reload-cycle.d.ts +16 -0
- package/dist/host/reload-cycle.d.ts.map +1 -0
- package/dist/host/reload-cycle.js +81 -0
- package/dist/host/reload-cycle.js.map +1 -0
- package/dist/host/retry-on.d.ts +28 -0
- package/dist/host/retry-on.d.ts.map +1 -0
- package/dist/host/retry-on.js +52 -0
- package/dist/host/retry-on.js.map +1 -0
- package/dist/host/revocation.d.ts +16 -0
- package/dist/host/revocation.d.ts.map +1 -0
- package/dist/host/revocation.js +27 -0
- package/dist/host/revocation.js.map +1 -0
- package/dist/host/root.d.ts +37 -0
- package/dist/host/root.d.ts.map +1 -0
- package/dist/host/root.js +68 -0
- package/dist/host/root.js.map +1 -0
- package/dist/host/route-admission.d.ts +24 -0
- package/dist/host/route-admission.d.ts.map +1 -0
- package/dist/host/route-admission.js +238 -0
- package/dist/host/route-admission.js.map +1 -0
- package/dist/host/route.d.ts +88 -0
- package/dist/host/route.d.ts.map +1 -0
- package/dist/host/route.js +247 -0
- package/dist/host/route.js.map +1 -0
- package/dist/host/routines.d.ts +78 -0
- package/dist/host/routines.d.ts.map +1 -0
- package/dist/host/routines.js +398 -0
- package/dist/host/routines.js.map +1 -0
- package/dist/host/sleep.d.ts +9 -0
- package/dist/host/sleep.d.ts.map +1 -0
- package/dist/host/sleep.js +40 -0
- package/dist/host/sleep.js.map +1 -0
- package/dist/host/staging.d.ts +100 -0
- package/dist/host/staging.d.ts.map +1 -0
- package/dist/host/staging.js +413 -0
- package/dist/host/staging.js.map +1 -0
- package/dist/host/tiling.d.ts +57 -0
- package/dist/host/tiling.d.ts.map +1 -0
- package/dist/host/tiling.js +269 -0
- package/dist/host/tiling.js.map +1 -0
- package/dist/host/unbound-clock.d.ts +23 -0
- package/dist/host/unbound-clock.d.ts.map +1 -0
- package/dist/host/unbound-clock.js +58 -0
- package/dist/host/unbound-clock.js.map +1 -0
- package/dist/host/unbound.d.ts +37 -0
- package/dist/host/unbound.d.ts.map +1 -0
- package/dist/host/unbound.js +88 -0
- package/dist/host/unbound.js.map +1 -0
- package/dist/host/uuid.d.ts +3 -0
- package/dist/host/uuid.d.ts.map +1 -0
- package/dist/host/uuid.js +38 -0
- package/dist/host/uuid.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/jobs/definition.d.ts +96 -0
- package/dist/jobs/definition.d.ts.map +1 -0
- package/dist/jobs/definition.js +83 -0
- package/dist/jobs/definition.js.map +1 -0
- package/dist/jobs/index.d.ts +5 -0
- package/dist/jobs/index.d.ts.map +1 -0
- package/dist/jobs/index.js +3 -0
- package/dist/jobs/index.js.map +1 -0
- package/dist/jobs/internal.d.ts +3 -0
- package/dist/jobs/internal.d.ts.map +1 -0
- package/dist/jobs/internal.js +4 -0
- package/dist/jobs/internal.js.map +1 -0
- package/dist/jobs/job.d.ts +149 -0
- package/dist/jobs/job.d.ts.map +1 -0
- package/dist/jobs/job.js +387 -0
- package/dist/jobs/job.js.map +1 -0
- package/dist/jobs/persisted.d.ts +38 -0
- package/dist/jobs/persisted.d.ts.map +1 -0
- package/dist/jobs/persisted.js +95 -0
- package/dist/jobs/persisted.js.map +1 -0
- package/dist/jobs/records.d.ts +231 -0
- package/dist/jobs/records.d.ts.map +1 -0
- package/dist/jobs/records.js +871 -0
- package/dist/jobs/records.js.map +1 -0
- package/dist/jobs/run-states.d.ts +69 -0
- package/dist/jobs/run-states.d.ts.map +1 -0
- package/dist/jobs/run-states.js +228 -0
- package/dist/jobs/run-states.js.map +1 -0
- package/dist/jobs/run.d.ts +117 -0
- package/dist/jobs/run.d.ts.map +1 -0
- package/dist/jobs/run.js +204 -0
- package/dist/jobs/run.js.map +1 -0
- package/dist/jobs/running.d.ts +44 -0
- package/dist/jobs/running.d.ts.map +1 -0
- package/dist/jobs/running.js +117 -0
- package/dist/jobs/running.js.map +1 -0
- package/dist/jobs/stored.d.ts +63 -0
- package/dist/jobs/stored.d.ts.map +1 -0
- package/dist/jobs/stored.js +55 -0
- package/dist/jobs/stored.js.map +1 -0
- package/dist/json.d.ts +18 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +124 -0
- package/dist/json.js.map +1 -0
- package/dist/link/binary.d.ts +4 -0
- package/dist/link/binary.d.ts.map +1 -0
- package/dist/link/binary.js +574 -0
- package/dist/link/binary.js.map +1 -0
- package/dist/link/channel.d.ts +78 -0
- package/dist/link/channel.d.ts.map +1 -0
- package/dist/link/channel.js +252 -0
- package/dist/link/channel.js.map +1 -0
- package/dist/link/errors.d.ts +7 -0
- package/dist/link/errors.d.ts.map +1 -0
- package/dist/link/errors.js +21 -0
- package/dist/link/errors.js.map +1 -0
- package/dist/link/index.d.ts +8 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +8 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/internal.d.ts +9 -0
- package/dist/link/internal.d.ts.map +1 -0
- package/dist/link/internal.js +10 -0
- package/dist/link/internal.js.map +1 -0
- package/dist/link/ipc.d.ts +22 -0
- package/dist/link/ipc.d.ts.map +1 -0
- package/dist/link/ipc.js +64 -0
- package/dist/link/ipc.js.map +1 -0
- package/dist/link/link.d.ts +34 -0
- package/dist/link/link.d.ts.map +1 -0
- package/dist/link/link.js +87 -0
- package/dist/link/link.js.map +1 -0
- package/dist/link/message.d.ts +278 -0
- package/dist/link/message.d.ts.map +1 -0
- package/dist/link/message.js +179 -0
- package/dist/link/message.js.map +1 -0
- package/dist/link/part.d.ts +80 -0
- package/dist/link/part.d.ts.map +1 -0
- package/dist/link/part.js +165 -0
- package/dist/link/part.js.map +1 -0
- package/dist/link/text.d.ts +6 -0
- package/dist/link/text.d.ts.map +1 -0
- package/dist/link/text.js +383 -0
- package/dist/link/text.js.map +1 -0
- package/dist/link/values.d.ts +40 -0
- package/dist/link/values.d.ts.map +1 -0
- package/dist/link/values.js +121 -0
- package/dist/link/values.js.map +1 -0
- package/dist/link/websocket.d.ts +26 -0
- package/dist/link/websocket.d.ts.map +1 -0
- package/dist/link/websocket.js +91 -0
- package/dist/link/websocket.js.map +1 -0
- package/dist/node/app/app.d.ts +283 -0
- package/dist/node/app/app.d.ts.map +1 -0
- package/dist/node/app/app.js +598 -0
- package/dist/node/app/app.js.map +1 -0
- package/dist/node/app/archive.d.ts +44 -0
- package/dist/node/app/archive.d.ts.map +1 -0
- package/dist/node/app/archive.js +212 -0
- package/dist/node/app/archive.js.map +1 -0
- package/dist/node/app/blobs.d.ts +23 -0
- package/dist/node/app/blobs.d.ts.map +1 -0
- package/dist/node/app/blobs.js +64 -0
- package/dist/node/app/blobs.js.map +1 -0
- package/dist/node/app/data.d.ts +40 -0
- package/dist/node/app/data.d.ts.map +1 -0
- package/dist/node/app/data.js +47 -0
- package/dist/node/app/data.js.map +1 -0
- package/dist/node/app/ephemeral-sign-ins.d.ts +20 -0
- package/dist/node/app/ephemeral-sign-ins.d.ts.map +1 -0
- package/dist/node/app/ephemeral-sign-ins.js +69 -0
- package/dist/node/app/ephemeral-sign-ins.js.map +1 -0
- package/dist/node/app/ephemeral.d.ts +11 -0
- package/dist/node/app/ephemeral.d.ts.map +1 -0
- package/dist/node/app/ephemeral.js +34 -0
- package/dist/node/app/ephemeral.js.map +1 -0
- package/dist/node/app/files-copy.d.ts +13 -0
- package/dist/node/app/files-copy.d.ts.map +1 -0
- package/dist/node/app/files-copy.js +86 -0
- package/dist/node/app/files-copy.js.map +1 -0
- package/dist/node/app/files-entry.d.ts +4 -0
- package/dist/node/app/files-entry.d.ts.map +1 -0
- package/dist/node/app/files-entry.js +7 -0
- package/dist/node/app/files-entry.js.map +1 -0
- package/dist/node/app/files-index.d.ts +180 -0
- package/dist/node/app/files-index.d.ts.map +1 -0
- package/dist/node/app/files-index.js +535 -0
- package/dist/node/app/files-index.js.map +1 -0
- package/dist/node/app/files.d.ts +388 -0
- package/dist/node/app/files.d.ts.map +1 -0
- package/dist/node/app/files.js +368 -0
- package/dist/node/app/files.js.map +1 -0
- package/dist/node/app/folder-views.d.ts +21 -0
- package/dist/node/app/folder-views.d.ts.map +1 -0
- package/dist/node/app/folder-views.js +55 -0
- package/dist/node/app/folder-views.js.map +1 -0
- package/dist/node/app/index.d.ts +12 -0
- package/dist/node/app/index.d.ts.map +1 -0
- package/dist/node/app/index.js +15 -0
- package/dist/node/app/index.js.map +1 -0
- package/dist/node/app/info.d.ts +70 -0
- package/dist/node/app/info.d.ts.map +1 -0
- package/dist/node/app/info.js +37 -0
- package/dist/node/app/info.js.map +1 -0
- package/dist/node/app/invite.d.ts +5 -0
- package/dist/node/app/invite.d.ts.map +1 -0
- package/dist/node/app/invite.js +64 -0
- package/dist/node/app/invite.js.map +1 -0
- package/dist/node/app/layout.d.ts +36 -0
- package/dist/node/app/layout.d.ts.map +1 -0
- package/dist/node/app/layout.js +87 -0
- package/dist/node/app/layout.js.map +1 -0
- package/dist/node/app/owner.d.ts +31 -0
- package/dist/node/app/owner.d.ts.map +1 -0
- package/dist/node/app/owner.js +104 -0
- package/dist/node/app/owner.js.map +1 -0
- package/dist/node/app/pairing.d.ts +55 -0
- package/dist/node/app/pairing.d.ts.map +1 -0
- package/dist/node/app/pairing.js +183 -0
- package/dist/node/app/pairing.js.map +1 -0
- package/dist/node/app/secrets.d.ts +16 -0
- package/dist/node/app/secrets.d.ts.map +1 -0
- package/dist/node/app/secrets.js +72 -0
- package/dist/node/app/secrets.js.map +1 -0
- package/dist/node/app/sign-ins.d.ts +74 -0
- package/dist/node/app/sign-ins.d.ts.map +1 -0
- package/dist/node/app/sign-ins.js +222 -0
- package/dist/node/app/sign-ins.js.map +1 -0
- package/dist/node/app/tar.d.ts +24 -0
- package/dist/node/app/tar.d.ts.map +1 -0
- package/dist/node/app/tar.js +167 -0
- package/dist/node/app/tar.js.map +1 -0
- package/dist/node/app/uploads.d.ts +37 -0
- package/dist/node/app/uploads.d.ts.map +1 -0
- package/dist/node/app/uploads.js +157 -0
- package/dist/node/app/uploads.js.map +1 -0
- package/dist/node/app/users.d.ts +39 -0
- package/dist/node/app/users.d.ts.map +1 -0
- package/dist/node/app/users.js +62 -0
- package/dist/node/app/users.js.map +1 -0
- package/dist/node/app/worker.d.ts +18 -0
- package/dist/node/app/worker.d.ts.map +1 -0
- package/dist/node/app/worker.js +84 -0
- package/dist/node/app/worker.js.map +1 -0
- package/dist/node/compression.d.ts +7 -0
- package/dist/node/compression.d.ts.map +1 -0
- package/dist/node/compression.js +25 -0
- package/dist/node/compression.js.map +1 -0
- package/dist/node/http/admission.d.ts +64 -0
- package/dist/node/http/admission.d.ts.map +1 -0
- package/dist/node/http/admission.js +137 -0
- package/dist/node/http/admission.js.map +1 -0
- package/dist/node/http/authenticate.d.ts +21 -0
- package/dist/node/http/authenticate.d.ts.map +1 -0
- package/dist/node/http/authenticate.js +34 -0
- package/dist/node/http/authenticate.js.map +1 -0
- package/dist/node/http/cookies.d.ts +32 -0
- package/dist/node/http/cookies.d.ts.map +1 -0
- package/dist/node/http/cookies.js +70 -0
- package/dist/node/http/cookies.js.map +1 -0
- package/dist/node/http/file.d.ts +23 -0
- package/dist/node/http/file.d.ts.map +1 -0
- package/dist/node/http/file.js +94 -0
- package/dist/node/http/file.js.map +1 -0
- package/dist/node/http/headers.d.ts +37 -0
- package/dist/node/http/headers.d.ts.map +1 -0
- package/dist/node/http/headers.js +136 -0
- package/dist/node/http/headers.js.map +1 -0
- package/dist/node/http/http.d.ts +114 -0
- package/dist/node/http/http.d.ts.map +1 -0
- package/dist/node/http/http.js +524 -0
- package/dist/node/http/http.js.map +1 -0
- package/dist/node/http/incoming.d.ts +19 -0
- package/dist/node/http/incoming.d.ts.map +1 -0
- package/dist/node/http/incoming.js +31 -0
- package/dist/node/http/incoming.js.map +1 -0
- package/dist/node/http/index.d.ts +11 -0
- package/dist/node/http/index.d.ts.map +1 -0
- package/dist/node/http/index.js +12 -0
- package/dist/node/http/index.js.map +1 -0
- package/dist/node/http/node.d.ts +78 -0
- package/dist/node/http/node.d.ts.map +1 -0
- package/dist/node/http/node.js +291 -0
- package/dist/node/http/node.js.map +1 -0
- package/dist/node/http/request.d.ts +60 -0
- package/dist/node/http/request.d.ts.map +1 -0
- package/dist/node/http/request.js +118 -0
- package/dist/node/http/request.js.map +1 -0
- package/dist/node/http/response.d.ts +63 -0
- package/dist/node/http/response.d.ts.map +1 -0
- package/dist/node/http/response.js +202 -0
- package/dist/node/http/response.js.map +1 -0
- package/dist/node/http/router.d.ts +132 -0
- package/dist/node/http/router.d.ts.map +1 -0
- package/dist/node/http/router.js +267 -0
- package/dist/node/http/router.js.map +1 -0
- package/dist/node/http/upgrades.d.ts +62 -0
- package/dist/node/http/upgrades.d.ts.map +1 -0
- package/dist/node/http/upgrades.js +194 -0
- package/dist/node/http/upgrades.js.map +1 -0
- package/dist/node/plugins/base-inputs.d.ts +14 -0
- package/dist/node/plugins/base-inputs.d.ts.map +1 -0
- package/dist/node/plugins/base-inputs.js +33 -0
- package/dist/node/plugins/base-inputs.js.map +1 -0
- package/dist/node/plugins/build.d.ts +77 -0
- package/dist/node/plugins/build.d.ts.map +1 -0
- package/dist/node/plugins/build.js +577 -0
- package/dist/node/plugins/build.js.map +1 -0
- package/dist/node/plugins/css-modules.d.ts +13 -0
- package/dist/node/plugins/css-modules.d.ts.map +1 -0
- package/dist/node/plugins/css-modules.js +58 -0
- package/dist/node/plugins/css-modules.js.map +1 -0
- package/dist/node/plugins/discover.d.ts +67 -0
- package/dist/node/plugins/discover.d.ts.map +1 -0
- package/dist/node/plugins/discover.js +369 -0
- package/dist/node/plugins/discover.js.map +1 -0
- package/dist/node/plugins/evaluate.d.ts +33 -0
- package/dist/node/plugins/evaluate.d.ts.map +1 -0
- package/dist/node/plugins/evaluate.js +121 -0
- package/dist/node/plugins/evaluate.js.map +1 -0
- package/dist/node/plugins/index.d.ts +11 -0
- package/dist/node/plugins/index.d.ts.map +1 -0
- package/dist/node/plugins/index.js +13 -0
- package/dist/node/plugins/index.js.map +1 -0
- package/dist/node/plugins/install.d.ts +40 -0
- package/dist/node/plugins/install.d.ts.map +1 -0
- package/dist/node/plugins/install.js +215 -0
- package/dist/node/plugins/install.js.map +1 -0
- package/dist/node/plugins/plugins.d.ts +165 -0
- package/dist/node/plugins/plugins.d.ts.map +1 -0
- package/dist/node/plugins/plugins.js +268 -0
- package/dist/node/plugins/plugins.js.map +1 -0
- package/dist/node/plugins/runtime.d.ts +57 -0
- package/dist/node/plugins/runtime.d.ts.map +1 -0
- package/dist/node/plugins/runtime.js +92 -0
- package/dist/node/plugins/runtime.js.map +1 -0
- package/dist/node/plugins/stack.d.ts +16 -0
- package/dist/node/plugins/stack.d.ts.map +1 -0
- package/dist/node/plugins/stack.js +70 -0
- package/dist/node/plugins/stack.js.map +1 -0
- package/dist/node/plugins/testing.d.ts +58 -0
- package/dist/node/plugins/testing.d.ts.map +1 -0
- package/dist/node/plugins/testing.js +210 -0
- package/dist/node/plugins/testing.js.map +1 -0
- package/dist/node/plugins/watcher.d.ts +69 -0
- package/dist/node/plugins/watcher.d.ts.map +1 -0
- package/dist/node/plugins/watcher.js +622 -0
- package/dist/node/plugins/watcher.js.map +1 -0
- package/dist/node/surfaces/bundle.d.ts +40 -0
- package/dist/node/surfaces/bundle.d.ts.map +1 -0
- package/dist/node/surfaces/bundle.js +121 -0
- package/dist/node/surfaces/bundle.js.map +1 -0
- package/dist/node/surfaces/current.d.ts +17 -0
- package/dist/node/surfaces/current.d.ts.map +1 -0
- package/dist/node/surfaces/current.js +54 -0
- package/dist/node/surfaces/current.js.map +1 -0
- package/dist/node/surfaces/index.d.ts +6 -0
- package/dist/node/surfaces/index.d.ts.map +1 -0
- package/dist/node/surfaces/index.js +6 -0
- package/dist/node/surfaces/index.js.map +1 -0
- package/dist/node/surfaces/published.d.ts +27 -0
- package/dist/node/surfaces/published.d.ts.map +1 -0
- package/dist/node/surfaces/published.js +142 -0
- package/dist/node/surfaces/published.js.map +1 -0
- package/dist/node/surfaces/served.d.ts +17 -0
- package/dist/node/surfaces/served.d.ts.map +1 -0
- package/dist/node/surfaces/served.js +44 -0
- package/dist/node/surfaces/served.js.map +1 -0
- package/dist/node/surfaces/surface-build.d.ts +53 -0
- package/dist/node/surfaces/surface-build.d.ts.map +1 -0
- package/dist/node/surfaces/surface-build.js +105 -0
- package/dist/node/surfaces/surface-build.js.map +1 -0
- package/dist/node/surfaces/tui.d.ts +42 -0
- package/dist/node/surfaces/tui.d.ts.map +1 -0
- package/dist/node/surfaces/tui.js +59 -0
- package/dist/node/surfaces/tui.js.map +1 -0
- package/dist/node/surfaces/web.d.ts +82 -0
- package/dist/node/surfaces/web.d.ts.map +1 -0
- package/dist/node/surfaces/web.js +122 -0
- package/dist/node/surfaces/web.js.map +1 -0
- package/dist/node/tui/actions.d.ts +49 -0
- package/dist/node/tui/actions.d.ts.map +1 -0
- package/dist/node/tui/actions.js +195 -0
- package/dist/node/tui/actions.js.map +1 -0
- package/dist/node/tui/credentials.d.ts +17 -0
- package/dist/node/tui/credentials.d.ts.map +1 -0
- package/dist/node/tui/credentials.js +54 -0
- package/dist/node/tui/credentials.js.map +1 -0
- package/dist/node/tui/filter.d.ts +5 -0
- package/dist/node/tui/filter.d.ts.map +1 -0
- package/dist/node/tui/filter.js +79 -0
- package/dist/node/tui/filter.js.map +1 -0
- package/dist/node/tui/index.d.ts +6 -0
- package/dist/node/tui/index.d.ts.map +1 -0
- package/dist/node/tui/index.js +6 -0
- package/dist/node/tui/index.js.map +1 -0
- package/dist/node/tui/launcher.d.ts +40 -0
- package/dist/node/tui/launcher.d.ts.map +1 -0
- package/dist/node/tui/launcher.js +439 -0
- package/dist/node/tui/launcher.js.map +1 -0
- package/dist/node/tui/pipe.d.ts +18 -0
- package/dist/node/tui/pipe.d.ts.map +1 -0
- package/dist/node/tui/pipe.js +134 -0
- package/dist/node/tui/pipe.js.map +1 -0
- package/dist/node/tui/sandbox.d.ts +54 -0
- package/dist/node/tui/sandbox.d.ts.map +1 -0
- package/dist/node/tui/sandbox.js +431 -0
- package/dist/node/tui/sandbox.js.map +1 -0
- package/dist/node/workers/base.d.ts +30 -0
- package/dist/node/workers/base.d.ts.map +1 -0
- package/dist/node/workers/base.js +260 -0
- package/dist/node/workers/base.js.map +1 -0
- package/dist/node/workers/child.d.ts +4 -0
- package/dist/node/workers/child.d.ts.map +1 -0
- package/dist/node/workers/child.js +6 -0
- package/dist/node/workers/child.js.map +1 -0
- package/dist/node/workers/control.d.ts +83 -0
- package/dist/node/workers/control.d.ts.map +1 -0
- package/dist/node/workers/control.js +77 -0
- package/dist/node/workers/control.js.map +1 -0
- package/dist/node/workers/index.d.ts +4 -0
- package/dist/node/workers/index.d.ts.map +1 -0
- package/dist/node/workers/index.js +7 -0
- package/dist/node/workers/index.js.map +1 -0
- package/dist/node/workers/lock.d.ts +30 -0
- package/dist/node/workers/lock.d.ts.map +1 -0
- package/dist/node/workers/lock.js +180 -0
- package/dist/node/workers/lock.js.map +1 -0
- package/dist/node/workers/main.d.ts +46 -0
- package/dist/node/workers/main.d.ts.map +1 -0
- package/dist/node/workers/main.js +230 -0
- package/dist/node/workers/main.js.map +1 -0
- package/dist/node/workers/process.d.ts +43 -0
- package/dist/node/workers/process.d.ts.map +1 -0
- package/dist/node/workers/process.js +137 -0
- package/dist/node/workers/process.js.map +1 -0
- package/dist/node/workers/workers.d.ts +144 -0
- package/dist/node/workers/workers.d.ts.map +1 -0
- package/dist/node/workers/workers.js +723 -0
- package/dist/node/workers/workers.js.map +1 -0
- package/dist/output.d.ts +91 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +362 -0
- package/dist/output.js.map +1 -0
- package/dist/react/hooks.d.ts +61 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +119 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +4 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/stores.d.ts +9 -0
- package/dist/react/stores.d.ts.map +1 -0
- package/dist/react/stores.js +37 -0
- package/dist/react/stores.js.map +1 -0
- package/dist/registries/contribution.d.ts +50 -0
- package/dist/registries/contribution.d.ts.map +1 -0
- package/dist/registries/contribution.js +129 -0
- package/dist/registries/contribution.js.map +1 -0
- package/dist/registries/entries.d.ts +18 -0
- package/dist/registries/entries.d.ts.map +1 -0
- package/dist/registries/entries.js +42 -0
- package/dist/registries/entries.js.map +1 -0
- package/dist/registries/index.d.ts +3 -0
- package/dist/registries/index.d.ts.map +1 -0
- package/dist/registries/index.js +5 -0
- package/dist/registries/index.js.map +1 -0
- package/dist/registries/internal.d.ts +4 -0
- package/dist/registries/internal.d.ts.map +1 -0
- package/dist/registries/internal.js +5 -0
- package/dist/registries/internal.js.map +1 -0
- package/dist/registries/record.d.ts +115 -0
- package/dist/registries/record.d.ts.map +1 -0
- package/dist/registries/record.js +283 -0
- package/dist/registries/record.js.map +1 -0
- package/dist/registries/registry.d.ts +74 -0
- package/dist/registries/registry.d.ts.map +1 -0
- package/dist/registries/registry.js +14 -0
- package/dist/registries/registry.js.map +1 -0
- package/dist/registries/value.d.ts +48 -0
- package/dist/registries/value.d.ts.map +1 -0
- package/dist/registries/value.js +224 -0
- package/dist/registries/value.js.map +1 -0
- package/dist/remote/calls.d.ts +34 -0
- package/dist/remote/calls.d.ts.map +1 -0
- package/dist/remote/calls.js +75 -0
- package/dist/remote/calls.js.map +1 -0
- package/dist/remote/consumer.d.ts +59 -0
- package/dist/remote/consumer.d.ts.map +1 -0
- package/dist/remote/consumer.js +468 -0
- package/dist/remote/consumer.js.map +1 -0
- package/dist/remote/hold.d.ts +147 -0
- package/dist/remote/hold.d.ts.map +1 -0
- package/dist/remote/hold.js +653 -0
- package/dist/remote/hold.js.map +1 -0
- package/dist/remote/host-link.d.ts +81 -0
- package/dist/remote/host-link.d.ts.map +1 -0
- package/dist/remote/host-link.js +198 -0
- package/dist/remote/host-link.js.map +1 -0
- package/dist/remote/internal.d.ts +6 -0
- package/dist/remote/internal.d.ts.map +1 -0
- package/dist/remote/internal.js +6 -0
- package/dist/remote/internal.js.map +1 -0
- package/dist/remote/path.d.ts +105 -0
- package/dist/remote/path.d.ts.map +1 -0
- package/dist/remote/path.js +197 -0
- package/dist/remote/path.js.map +1 -0
- package/dist/remote/provider.d.ts +113 -0
- package/dist/remote/provider.d.ts.map +1 -0
- package/dist/remote/provider.js +787 -0
- package/dist/remote/provider.js.map +1 -0
- package/dist/remote/relay.d.ts +126 -0
- package/dist/remote/relay.d.ts.map +1 -0
- package/dist/remote/relay.js +334 -0
- package/dist/remote/relay.js.map +1 -0
- package/dist/remote/remote-object.d.ts +181 -0
- package/dist/remote/remote-object.d.ts.map +1 -0
- package/dist/remote/remote-object.js +683 -0
- package/dist/remote/remote-object.js.map +1 -0
- package/dist/remote/replica.d.ts +66 -0
- package/dist/remote/replica.d.ts.map +1 -0
- package/dist/remote/replica.js +148 -0
- package/dist/remote/replica.js.map +1 -0
- package/dist/sqlite/cloudflare.d.ts +54 -0
- package/dist/sqlite/cloudflare.d.ts.map +1 -0
- package/dist/sqlite/cloudflare.js +144 -0
- package/dist/sqlite/cloudflare.js.map +1 -0
- package/dist/sqlite/database.d.ts +40 -0
- package/dist/sqlite/database.d.ts.map +1 -0
- package/dist/sqlite/database.js +2 -0
- package/dist/sqlite/database.js.map +1 -0
- package/dist/sqlite/index.d.ts +4 -0
- package/dist/sqlite/index.d.ts.map +1 -0
- package/dist/sqlite/index.js +3 -0
- package/dist/sqlite/index.js.map +1 -0
- package/dist/sqlite/migrations.d.ts +10 -0
- package/dist/sqlite/migrations.d.ts.map +1 -0
- package/dist/sqlite/migrations.js +33 -0
- package/dist/sqlite/migrations.js.map +1 -0
- package/dist/sqlite/node.d.ts +49 -0
- package/dist/sqlite/node.d.ts.map +1 -0
- package/dist/sqlite/node.js +197 -0
- package/dist/sqlite/node.js.map +1 -0
- package/dist/sqlite/schema.d.ts +3 -0
- package/dist/sqlite/schema.d.ts.map +1 -0
- package/dist/sqlite/schema.js +10 -0
- package/dist/sqlite/schema.js.map +1 -0
- package/dist/state/batch.d.ts +64 -0
- package/dist/state/batch.d.ts.map +1 -0
- package/dist/state/batch.js +164 -0
- package/dist/state/batch.js.map +1 -0
- package/dist/state/derive.d.ts +56 -0
- package/dist/state/derive.d.ts.map +1 -0
- package/dist/state/derive.js +192 -0
- package/dist/state/derive.js.map +1 -0
- package/dist/state/framed.d.ts +43 -0
- package/dist/state/framed.d.ts.map +1 -0
- package/dist/state/framed.js +121 -0
- package/dist/state/framed.js.map +1 -0
- package/dist/state/index.d.ts +6 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/internal.d.ts +7 -0
- package/dist/state/internal.d.ts.map +1 -0
- package/dist/state/internal.js +9 -0
- package/dist/state/internal.js.map +1 -0
- package/dist/state/native-source.d.ts +106 -0
- package/dist/state/native-source.d.ts.map +1 -0
- package/dist/state/native-source.js +240 -0
- package/dist/state/native-source.js.map +1 -0
- package/dist/state/watchable.d.ts +114 -0
- package/dist/state/watchable.d.ts.map +1 -0
- package/dist/state/watchable.js +156 -0
- package/dist/state/watchable.js.map +1 -0
- package/dist/state/writable.d.ts +32 -0
- package/dist/state/writable.d.ts.map +1 -0
- package/dist/state/writable.js +49 -0
- package/dist/state/writable.js.map +1 -0
- package/dist/store/adapter.d.ts +67 -0
- package/dist/store/adapter.d.ts.map +1 -0
- package/dist/store/adapter.js +118 -0
- package/dist/store/adapter.js.map +1 -0
- package/dist/store/allocator.d.ts +17 -0
- package/dist/store/allocator.d.ts.map +1 -0
- package/dist/store/allocator.js +30 -0
- package/dist/store/allocator.js.map +1 -0
- package/dist/store/applier.d.ts +8 -0
- package/dist/store/applier.d.ts.map +1 -0
- package/dist/store/applier.js +390 -0
- package/dist/store/applier.js.map +1 -0
- package/dist/store/apply-batch.d.ts +12 -0
- package/dist/store/apply-batch.d.ts.map +1 -0
- package/dist/store/apply-batch.js +83 -0
- package/dist/store/apply-batch.js.map +1 -0
- package/dist/store/archive.d.ts +36 -0
- package/dist/store/archive.d.ts.map +1 -0
- package/dist/store/archive.js +140 -0
- package/dist/store/archive.js.map +1 -0
- package/dist/store/backend.d.ts +10 -0
- package/dist/store/backend.d.ts.map +1 -0
- package/dist/store/backend.js +15 -0
- package/dist/store/backend.js.map +1 -0
- package/dist/store/catalog.d.ts +24 -0
- package/dist/store/catalog.d.ts.map +1 -0
- package/dist/store/catalog.js +17 -0
- package/dist/store/catalog.js.map +1 -0
- package/dist/store/claims.d.ts +23 -0
- package/dist/store/claims.d.ts.map +1 -0
- package/dist/store/claims.js +65 -0
- package/dist/store/claims.js.map +1 -0
- package/dist/store/column-set.d.ts +64 -0
- package/dist/store/column-set.d.ts.map +1 -0
- package/dist/store/column-set.js +96 -0
- package/dist/store/column-set.js.map +1 -0
- package/dist/store/columns.d.ts +93 -0
- package/dist/store/columns.d.ts.map +1 -0
- package/dist/store/columns.js +87 -0
- package/dist/store/columns.js.map +1 -0
- package/dist/store/engine.d.ts +182 -0
- package/dist/store/engine.d.ts.map +1 -0
- package/dist/store/engine.js +290 -0
- package/dist/store/engine.js.map +1 -0
- package/dist/store/evaluate.d.ts +17 -0
- package/dist/store/evaluate.d.ts.map +1 -0
- package/dist/store/evaluate.js +131 -0
- package/dist/store/evaluate.js.map +1 -0
- package/dist/store/export.d.ts +30 -0
- package/dist/store/export.d.ts.map +1 -0
- package/dist/store/export.js +221 -0
- package/dist/store/export.js.map +1 -0
- package/dist/store/expression.d.ts +254 -0
- package/dist/store/expression.d.ts.map +1 -0
- package/dist/store/expression.js +577 -0
- package/dist/store/expression.js.map +1 -0
- package/dist/store/host-column.d.ts +22 -0
- package/dist/store/host-column.d.ts.map +1 -0
- package/dist/store/host-column.js +36 -0
- package/dist/store/host-column.js.map +1 -0
- package/dist/store/host-data.d.ts +100 -0
- package/dist/store/host-data.d.ts.map +1 -0
- package/dist/store/host-data.js +397 -0
- package/dist/store/host-data.js.map +1 -0
- package/dist/store/import-migration.d.ts +19 -0
- package/dist/store/import-migration.d.ts.map +1 -0
- package/dist/store/import-migration.js +124 -0
- package/dist/store/import-migration.js.map +1 -0
- package/dist/store/import.d.ts +12 -0
- package/dist/store/import.d.ts.map +1 -0
- package/dist/store/import.js +279 -0
- package/dist/store/import.js.map +1 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +16 -0
- package/dist/store/index.js.map +1 -0
- package/dist/store/json-column.d.ts +33 -0
- package/dist/store/json-column.d.ts.map +1 -0
- package/dist/store/json-column.js +62 -0
- package/dist/store/json-column.js.map +1 -0
- package/dist/store/jsonl.d.ts +9 -0
- package/dist/store/jsonl.d.ts.map +1 -0
- package/dist/store/jsonl.js +61 -0
- package/dist/store/jsonl.js.map +1 -0
- package/dist/store/live-query.d.ts +72 -0
- package/dist/store/live-query.d.ts.map +1 -0
- package/dist/store/live-query.js +162 -0
- package/dist/store/live-query.js.map +1 -0
- package/dist/store/open-query.d.ts +90 -0
- package/dist/store/open-query.d.ts.map +1 -0
- package/dist/store/open-query.js +201 -0
- package/dist/store/open-query.js.map +1 -0
- package/dist/store/outbox.d.ts +26 -0
- package/dist/store/outbox.d.ts.map +1 -0
- package/dist/store/outbox.js +80 -0
- package/dist/store/outbox.js.map +1 -0
- package/dist/store/page.d.ts +14 -0
- package/dist/store/page.d.ts.map +1 -0
- package/dist/store/page.js +26 -0
- package/dist/store/page.js.map +1 -0
- package/dist/store/query.d.ts +65 -0
- package/dist/store/query.d.ts.map +1 -0
- package/dist/store/query.js +193 -0
- package/dist/store/query.js.map +1 -0
- package/dist/store/read-plan.d.ts +74 -0
- package/dist/store/read-plan.d.ts.map +1 -0
- package/dist/store/read-plan.js +324 -0
- package/dist/store/read-plan.js.map +1 -0
- package/dist/store/read.d.ts +81 -0
- package/dist/store/read.d.ts.map +1 -0
- package/dist/store/read.js +113 -0
- package/dist/store/read.js.map +1 -0
- package/dist/store/reads.d.ts +79 -0
- package/dist/store/reads.d.ts.map +1 -0
- package/dist/store/reads.js +255 -0
- package/dist/store/reads.js.map +1 -0
- package/dist/store/refusal.d.ts +15 -0
- package/dist/store/refusal.d.ts.map +1 -0
- package/dist/store/refusal.js +36 -0
- package/dist/store/refusal.js.map +1 -0
- package/dist/store/rows.d.ts +96 -0
- package/dist/store/rows.d.ts.map +1 -0
- package/dist/store/rows.js +222 -0
- package/dist/store/rows.js.map +1 -0
- package/dist/store/schema.d.ts +25 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +123 -0
- package/dist/store/schema.js.map +1 -0
- package/dist/store/skip.d.ts +26 -0
- package/dist/store/skip.d.ts.map +1 -0
- package/dist/store/skip.js +66 -0
- package/dist/store/skip.js.map +1 -0
- package/dist/store/sql.d.ts +78 -0
- package/dist/store/sql.d.ts.map +1 -0
- package/dist/store/sql.js +244 -0
- package/dist/store/sql.js.map +1 -0
- package/dist/store/step.d.ts +52 -0
- package/dist/store/step.d.ts.map +1 -0
- package/dist/store/step.js +59 -0
- package/dist/store/step.js.map +1 -0
- package/dist/store/store.d.ts +192 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +863 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/table-changes.d.ts +35 -0
- package/dist/store/table-changes.d.ts.map +1 -0
- package/dist/store/table-changes.js +127 -0
- package/dist/store/table-changes.js.map +1 -0
- package/dist/store/table-evolve.d.ts +82 -0
- package/dist/store/table-evolve.d.ts.map +1 -0
- package/dist/store/table-evolve.js +208 -0
- package/dist/store/table-evolve.js.map +1 -0
- package/dist/store/table-handle.d.ts +69 -0
- package/dist/store/table-handle.d.ts.map +1 -0
- package/dist/store/table-handle.js +92 -0
- package/dist/store/table-handle.js.map +1 -0
- package/dist/store/table-history.d.ts +78 -0
- package/dist/store/table-history.d.ts.map +1 -0
- package/dist/store/table-history.js +43 -0
- package/dist/store/table-history.js.map +1 -0
- package/dist/store/table-migration.d.ts +28 -0
- package/dist/store/table-migration.d.ts.map +1 -0
- package/dist/store/table-migration.js +212 -0
- package/dist/store/table-migration.js.map +1 -0
- package/dist/store/table-writes.d.ts +125 -0
- package/dist/store/table-writes.d.ts.map +1 -0
- package/dist/store/table-writes.js +170 -0
- package/dist/store/table-writes.js.map +1 -0
- package/dist/store/table.d.ts +91 -0
- package/dist/store/table.d.ts.map +1 -0
- package/dist/store/table.js +133 -0
- package/dist/store/table.js.map +1 -0
- package/dist/store/text.d.ts +14 -0
- package/dist/store/text.d.ts.map +1 -0
- package/dist/store/text.js +51 -0
- package/dist/store/text.js.map +1 -0
- package/dist/store/writes.d.ts +5 -0
- package/dist/store/writes.d.ts.map +1 -0
- package/dist/store/writes.js +4 -0
- package/dist/store/writes.js.map +1 -0
- package/dist/surfaces/active-language.d.ts +20 -0
- package/dist/surfaces/active-language.d.ts.map +1 -0
- package/dist/surfaces/active-language.js +78 -0
- package/dist/surfaces/active-language.js.map +1 -0
- package/dist/surfaces/active-theme.d.ts +16 -0
- package/dist/surfaces/active-theme.d.ts.map +1 -0
- package/dist/surfaces/active-theme.js +47 -0
- package/dist/surfaces/active-theme.js.map +1 -0
- package/dist/surfaces/client.d.ts +106 -0
- package/dist/surfaces/client.d.ts.map +1 -0
- package/dist/surfaces/client.js +280 -0
- package/dist/surfaces/client.js.map +1 -0
- package/dist/surfaces/connection.d.ts +53 -0
- package/dist/surfaces/connection.d.ts.map +1 -0
- package/dist/surfaces/connection.js +161 -0
- package/dist/surfaces/connection.js.map +1 -0
- package/dist/surfaces/format.d.ts +5 -0
- package/dist/surfaces/format.d.ts.map +1 -0
- package/dist/surfaces/format.js +37 -0
- package/dist/surfaces/format.js.map +1 -0
- package/dist/surfaces/index.d.ts +15 -0
- package/dist/surfaces/index.d.ts.map +1 -0
- package/dist/surfaces/index.js +18 -0
- package/dist/surfaces/index.js.map +1 -0
- package/dist/surfaces/language.d.ts +53 -0
- package/dist/surfaces/language.d.ts.map +1 -0
- package/dist/surfaces/language.js +74 -0
- package/dist/surfaces/language.js.map +1 -0
- package/dist/surfaces/loaded.d.ts +42 -0
- package/dist/surfaces/loaded.d.ts.map +1 -0
- package/dist/surfaces/loaded.js +116 -0
- package/dist/surfaces/loaded.js.map +1 -0
- package/dist/surfaces/locale-choice.d.ts +26 -0
- package/dist/surfaces/locale-choice.d.ts.map +1 -0
- package/dist/surfaces/locale-choice.js +14 -0
- package/dist/surfaces/locale-choice.js.map +1 -0
- package/dist/surfaces/messages.d.ts +67 -0
- package/dist/surfaces/messages.d.ts.map +1 -0
- package/dist/surfaces/messages.js +112 -0
- package/dist/surfaces/messages.js.map +1 -0
- package/dist/surfaces/page-state.d.ts +14 -0
- package/dist/surfaces/page-state.d.ts.map +1 -0
- package/dist/surfaces/page-state.js +43 -0
- package/dist/surfaces/page-state.js.map +1 -0
- package/dist/surfaces/preference.d.ts +33 -0
- package/dist/surfaces/preference.d.ts.map +1 -0
- package/dist/surfaces/preference.js +72 -0
- package/dist/surfaces/preference.js.map +1 -0
- package/dist/surfaces/registered.d.ts +33 -0
- package/dist/surfaces/registered.d.ts.map +1 -0
- package/dist/surfaces/registered.js +51 -0
- package/dist/surfaces/registered.js.map +1 -0
- package/dist/surfaces/scripts.d.ts +86 -0
- package/dist/surfaces/scripts.d.ts.map +1 -0
- package/dist/surfaces/scripts.js +28 -0
- package/dist/surfaces/scripts.js.map +1 -0
- package/dist/surfaces/theme-choice.d.ts +32 -0
- package/dist/surfaces/theme-choice.d.ts.map +1 -0
- package/dist/surfaces/theme-choice.js +18 -0
- package/dist/surfaces/theme-choice.js.map +1 -0
- package/dist/surfaces/themes.d.ts +43 -0
- package/dist/surfaces/themes.d.ts.map +1 -0
- package/dist/surfaces/themes.js +110 -0
- package/dist/surfaces/themes.js.map +1 -0
- package/dist/surfaces/translations.d.ts +29 -0
- package/dist/surfaces/translations.d.ts.map +1 -0
- package/dist/surfaces/translations.js +57 -0
- package/dist/surfaces/translations.js.map +1 -0
- package/dist/surfaces/variant.d.ts +23 -0
- package/dist/surfaces/variant.d.ts.map +1 -0
- package/dist/surfaces/variant.js +18 -0
- package/dist/surfaces/variant.js.map +1 -0
- package/dist/sync/batch.d.ts +18 -0
- package/dist/sync/batch.d.ts.map +1 -0
- package/dist/sync/batch.js +125 -0
- package/dist/sync/batch.js.map +1 -0
- package/dist/sync/client.d.ts +169 -0
- package/dist/sync/client.d.ts.map +1 -0
- package/dist/sync/client.js +459 -0
- package/dist/sync/client.js.map +1 -0
- package/dist/sync/files.d.ts +46 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +13 -0
- package/dist/sync/files.js.map +1 -0
- package/dist/sync/filesystem.d.ts +37 -0
- package/dist/sync/filesystem.d.ts.map +1 -0
- package/dist/sync/filesystem.js +205 -0
- package/dist/sync/filesystem.js.map +1 -0
- package/dist/sync/index.d.ts +8 -0
- package/dist/sync/index.d.ts.map +1 -0
- package/dist/sync/index.js +9 -0
- package/dist/sync/index.js.map +1 -0
- package/dist/sync/lines.d.ts +18 -0
- package/dist/sync/lines.d.ts.map +1 -0
- package/dist/sync/lines.js +46 -0
- package/dist/sync/lines.js.map +1 -0
- package/dist/sync/remote.d.ts +145 -0
- package/dist/sync/remote.d.ts.map +1 -0
- package/dist/sync/remote.js +59 -0
- package/dist/sync/remote.js.map +1 -0
- package/dist/sync/state.d.ts +17 -0
- package/dist/sync/state.d.ts.map +1 -0
- package/dist/sync/state.js +40 -0
- package/dist/sync/state.js.map +1 -0
- package/dist/telemetry-ingest/batch.d.ts +73 -0
- package/dist/telemetry-ingest/batch.d.ts.map +1 -0
- package/dist/telemetry-ingest/batch.js +110 -0
- package/dist/telemetry-ingest/batch.js.map +1 -0
- package/dist/telemetry-ingest/facet.d.ts +26 -0
- package/dist/telemetry-ingest/facet.d.ts.map +1 -0
- package/dist/telemetry-ingest/facet.js +100 -0
- package/dist/telemetry-ingest/facet.js.map +1 -0
- package/dist/telemetry-ingest/index.d.ts +5 -0
- package/dist/telemetry-ingest/index.d.ts.map +1 -0
- package/dist/telemetry-ingest/index.js +8 -0
- package/dist/telemetry-ingest/index.js.map +1 -0
- package/dist/telemetry-ingest/recorder.d.ts +50 -0
- package/dist/telemetry-ingest/recorder.d.ts.map +1 -0
- package/dist/telemetry-ingest/recorder.js +298 -0
- package/dist/telemetry-ingest/recorder.js.map +1 -0
- package/dist/telemetry-ingest/sender.d.ts +14 -0
- package/dist/telemetry-ingest/sender.d.ts.map +1 -0
- package/dist/telemetry-ingest/sender.js +64 -0
- package/dist/telemetry-ingest/sender.js.map +1 -0
- package/dist/telemetry-sqlite/index.d.ts +33 -0
- package/dist/telemetry-sqlite/index.d.ts.map +1 -0
- package/dist/telemetry-sqlite/index.js +113 -0
- package/dist/telemetry-sqlite/index.js.map +1 -0
- package/dist/telemetry-sqlite/node.d.ts +13 -0
- package/dist/telemetry-sqlite/node.d.ts.map +1 -0
- package/dist/telemetry-sqlite/node.js +27 -0
- package/dist/telemetry-sqlite/node.js.map +1 -0
- package/dist/telemetry-sqlite/schema.d.ts +9 -0
- package/dist/telemetry-sqlite/schema.d.ts.map +1 -0
- package/dist/telemetry-sqlite/schema.js +61 -0
- package/dist/telemetry-sqlite/schema.js.map +1 -0
- package/dist/telemetry-sqlite/store.d.ts +12 -0
- package/dist/telemetry-sqlite/store.d.ts.map +1 -0
- package/dist/telemetry-sqlite/store.js +121 -0
- package/dist/telemetry-sqlite/store.js.map +1 -0
- package/dist/telemetry.d.ts +1013 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +518 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tui/bridge.d.ts +112 -0
- package/dist/tui/bridge.d.ts.map +1 -0
- package/dist/tui/bridge.js +9 -0
- package/dist/tui/bridge.js.map +1 -0
- package/dist/tui/channel.d.ts +44 -0
- package/dist/tui/channel.d.ts.map +1 -0
- package/dist/tui/channel.js +150 -0
- package/dist/tui/channel.js.map +1 -0
- package/dist/tui/frames.d.ts +5 -0
- package/dist/tui/frames.d.ts.map +1 -0
- package/dist/tui/frames.js +52 -0
- package/dist/tui/frames.js.map +1 -0
- package/dist/tui/index.d.ts +8 -0
- package/dist/tui/index.d.ts.map +1 -0
- package/dist/tui/index.js +8 -0
- package/dist/tui/index.js.map +1 -0
- package/dist/tui/runtime.d.ts +46 -0
- package/dist/tui/runtime.d.ts.map +1 -0
- package/dist/tui/runtime.js +101 -0
- package/dist/tui/runtime.js.map +1 -0
- package/dist/tui/scope.d.ts +62 -0
- package/dist/tui/scope.d.ts.map +1 -0
- package/dist/tui/scope.js +173 -0
- package/dist/tui/scope.js.map +1 -0
- package/dist/tui/terminal.d.ts +15 -0
- package/dist/tui/terminal.d.ts.map +1 -0
- package/dist/tui/terminal.js +37 -0
- package/dist/tui/terminal.js.map +1 -0
- package/dist/tui/theme.d.ts +17 -0
- package/dist/tui/theme.d.ts.map +1 -0
- package/dist/tui/theme.js +38 -0
- package/dist/tui/theme.js.map +1 -0
- package/dist/watch.d.ts +194 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.js +383 -0
- package/dist/watch.js.map +1 -0
- package/dist/web/environment.d.ts +4 -0
- package/dist/web/environment.d.ts.map +1 -0
- package/dist/web/environment.js +37 -0
- package/dist/web/environment.js.map +1 -0
- package/dist/web/index.d.ts +5 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +7 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/language.d.ts +7 -0
- package/dist/web/language.d.ts.map +1 -0
- package/dist/web/language.js +21 -0
- package/dist/web/language.js.map +1 -0
- package/dist/web/page.d.ts +42 -0
- package/dist/web/page.d.ts.map +1 -0
- package/dist/web/page.js +96 -0
- package/dist/web/page.js.map +1 -0
- package/dist/web/scripts.d.ts +23 -0
- package/dist/web/scripts.d.ts.map +1 -0
- package/dist/web/scripts.js +50 -0
- package/dist/web/scripts.js.map +1 -0
- package/dist/web/styles.d.ts +17 -0
- package/dist/web/styles.d.ts.map +1 -0
- package/dist/web/styles.js +218 -0
- package/dist/web/styles.js.map +1 -0
- package/dist/web/themes.d.ts +6 -0
- package/dist/web/themes.d.ts.map +1 -0
- package/dist/web/themes.js +31 -0
- package/dist/web/themes.js.map +1 -0
- package/docs/admission/design.md +178 -0
- package/docs/benchmarks.md +1182 -0
- package/docs/decisions.md +3760 -0
- package/docs/dependencies/book.md +1671 -0
- package/docs/dependencies/index.html +2641 -0
- package/docs/dependencies/model.md +330 -0
- package/docs/design.md +3691 -0
- package/docs/durable-observers/book.md +432 -0
- package/docs/durable-observers/index.html +517 -0
- package/docs/events/spec.md +438 -0
- package/docs/flow-control/book.md +333 -0
- package/docs/flow-control/fold/index.html +265 -0
- package/docs/flow-control/index.html +548 -0
- package/docs/flow-control/window/index.html +228 -0
- package/docs/guide-plugins-hosts/book.md +958 -0
- package/docs/guide-plugins-hosts/index.html +952 -0
- package/docs/host-keyed/spec.md +343 -0
- package/docs/http-workers/book.md +378 -0
- package/docs/http-workers/index.html +515 -0
- package/docs/i18n/book.md +217 -0
- package/docs/i18n/index.html +344 -0
- package/docs/layer-1.md +311 -0
- package/docs/layer-2.md +216 -0
- package/docs/p3-features/README.md +6 -0
- package/docs/p3-features/book.md +478 -0
- package/docs/plugin-authoring.md +389 -0
- package/docs/plugin-model/book.md +186 -0
- package/docs/plugin-model/index.html +310 -0
- package/docs/plugin-primer/book.md +273 -0
- package/docs/plugin-primer/index.html +430 -0
- package/docs/shared-holds/design.md +339 -0
- package/docs/slice-1.md +236 -0
- package/docs/slice-10.md +288 -0
- package/docs/slice-11.md +114 -0
- package/docs/slice-12.md +132 -0
- package/docs/slice-13.md +121 -0
- package/docs/slice-14-design.md +213 -0
- package/docs/slice-14.md +861 -0
- package/docs/slice-2.md +174 -0
- package/docs/slice-3a.md +296 -0
- package/docs/slice-3b.md +197 -0
- package/docs/slice-4.md +146 -0
- package/docs/slice-4a.md +418 -0
- package/docs/slice-4b.md +208 -0
- package/docs/slice-5.md +281 -0
- package/docs/slice-6a.md +676 -0
- package/docs/slice-6b.md +332 -0
- package/docs/slice-7a.md +130 -0
- package/docs/slice-7b/book.md +608 -0
- package/docs/slice-7b/index.html +842 -0
- package/docs/slice-7b.md +255 -0
- package/docs/slice-7c.md +165 -0
- package/docs/slice-8.md +194 -0
- package/docs/slice-9.md +110 -0
- package/docs/slices.md +380 -0
- package/docs/store/book.md +670 -0
- package/docs/store/index.html +861 -0
- package/docs/store/walkthrough.md +193 -0
- package/docs/theming/book.md +223 -0
- package/docs/theming/index.html +371 -0
- package/docs/tutorial/book.md +2170 -0
- package/docs/tutorial/index.html +2112 -0
- package/docs/tutorial/screens/click-after.png +0 -0
- package/docs/tutorial/screens/click-before.png +0 -0
- package/docs/tutorial/screens/edited.png +0 -0
- package/docs/tutorial/screens/french.png +0 -0
- package/docs/tutorial/screens/harbor.png +0 -0
- package/docs/tutorial/screens/page.png +0 -0
- package/docs/tutorial/screens/traces-ada.png +0 -0
- package/docs/tutorial/screens/traces.png +0 -0
- package/package.json +200 -5
- package/src/delta/README.md +262 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import type { SyncBody } from "./batch.ts";
|
|
3
|
+
import { type SyncFileSystem } from "./files.ts";
|
|
4
|
+
import { type JsonObject, type PutBatchResult, type RemoteListing, type Seq, type SessionChanges, type SessionSyncMaintenance } from "./remote.ts";
|
|
5
|
+
/** A session ID names a file or directory: refuse anything that could leave the root. */
|
|
6
|
+
export declare function checkSessionId(sessionId: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* A remote store in a directory, laid out as the real remote is: per session, one slot per batch start, holding where
|
|
9
|
+
* the batch ends and which device created it, and snapshots named by their end. As the real remote, it creates a slot
|
|
10
|
+
* only where the history ends. Creating a slot is check-then-write,
|
|
11
|
+
* without the atomicity of the real remote across processes: for development and tests, with one process writing.
|
|
12
|
+
*
|
|
13
|
+
* ```text
|
|
14
|
+
* {root}/{session}/slots/{after}.json { after, to, device, archive?, folded? }, written once
|
|
15
|
+
* {root}/{session}/batches/{after}.batch the commits (or an archive), until folded
|
|
16
|
+
* {root}/{session}/snapshots/{to}.batch a store archive
|
|
17
|
+
* {root}/{session}/meta.json the host's description, last write wins
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class FileSystemSyncRemote implements SessionSyncMaintenance {
|
|
21
|
+
#private;
|
|
22
|
+
constructor(fs: SyncFileSystem, root: string);
|
|
23
|
+
putBatch(sessionId: string, after: Seq, to: Seq, device: string, body: SyncBody, context: Context, options?: {
|
|
24
|
+
readonly archive?: boolean;
|
|
25
|
+
}): Promise<PutBatchResult>;
|
|
26
|
+
getBatch(sessionId: string, after: Seq, context: Context): Promise<SyncBody | undefined>;
|
|
27
|
+
getSnapshot(sessionId: string, to: Seq, context: Context): Promise<SyncBody | undefined>;
|
|
28
|
+
putSnapshot(sessionId: string, to: Seq, body: SyncBody, context: Context): Promise<void>;
|
|
29
|
+
foldBatches(sessionId: string, afters: readonly Seq[], context: Context): Promise<void>;
|
|
30
|
+
deleteSnapshots(sessionId: string, snapshots: readonly Seq[], context: Context): Promise<void>;
|
|
31
|
+
list(sessionId: string, context: Context): Promise<RemoteListing>;
|
|
32
|
+
/** Every session, every time: a directory keeps no change order. */
|
|
33
|
+
sessions(_cursor: string | undefined, context: Context): Promise<SessionChanges>;
|
|
34
|
+
putMeta(sessionId: string, meta: JsonObject, context: Context): Promise<void>;
|
|
35
|
+
getMeta(sessionId: string, context: Context): Promise<JsonObject | undefined>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../src/sync/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAmC,KAAK,cAAc,EAAU,MAAM,YAAY,CAAC;AAC1F,OAAO,EAEN,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAElB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,MAAM,aAAa,CAAC;AAcrB,yFAAyF;AACzF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxD;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,oBAAqB,YAAW,sBAAsB;;IAIlE,YAAY,EAAE,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAG3C;IAEK,QAAQ,CACb,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,GAAG,EACV,EAAE,EAAE,GAAG,EACP,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAO,GAC1C,OAAO,CAAC,cAAc,CAAC,CAgBzB;IAEK,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAI7F;IAED,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC,CAEvF;IAEK,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;IAEK,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5F;IAEK,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnG;IAEK,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CActE;IAED,oEAAoE;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC,CAiBrF;IAEK,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAElF;IAEK,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAGlF;CA2DD"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { isNotFound, unwrap } from "./files.js";
|
|
2
|
+
import { remoteHead, } from "./remote.js";
|
|
3
|
+
const pad = (value) => String(value).padStart(16, "0");
|
|
4
|
+
/** How much of a body is read from its file at a time. */
|
|
5
|
+
const READ_CHUNK = 256 * 1024;
|
|
6
|
+
/** One buffer as a body. */
|
|
7
|
+
async function* once(bytes) {
|
|
8
|
+
yield bytes;
|
|
9
|
+
}
|
|
10
|
+
const SLOT_NAME = /^(\d{16})\.json$/;
|
|
11
|
+
const SNAPSHOT_NAME = /^(\d{16})\.batch$/;
|
|
12
|
+
const SESSION_ID = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;
|
|
13
|
+
/** A session ID names a file or directory: refuse anything that could leave the root. */
|
|
14
|
+
export function checkSessionId(sessionId) {
|
|
15
|
+
if (!SESSION_ID.test(sessionId))
|
|
16
|
+
throw new Error(`Invalid session ID for a sync directory: ${sessionId}`);
|
|
17
|
+
return sessionId;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A remote store in a directory, laid out as the real remote is: per session, one slot per batch start, holding where
|
|
21
|
+
* the batch ends and which device created it, and snapshots named by their end. As the real remote, it creates a slot
|
|
22
|
+
* only where the history ends. Creating a slot is check-then-write,
|
|
23
|
+
* without the atomicity of the real remote across processes: for development and tests, with one process writing.
|
|
24
|
+
*
|
|
25
|
+
* ```text
|
|
26
|
+
* {root}/{session}/slots/{after}.json { after, to, device, archive?, folded? }, written once
|
|
27
|
+
* {root}/{session}/batches/{after}.batch the commits (or an archive), until folded
|
|
28
|
+
* {root}/{session}/snapshots/{to}.batch a store archive
|
|
29
|
+
* {root}/{session}/meta.json the host's description, last write wins
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export class FileSystemSyncRemote {
|
|
33
|
+
#fs;
|
|
34
|
+
#root;
|
|
35
|
+
constructor(fs, root) {
|
|
36
|
+
this.#fs = fs;
|
|
37
|
+
this.#root = root;
|
|
38
|
+
}
|
|
39
|
+
async putBatch(sessionId, after, to, device, body, context, options = {}) {
|
|
40
|
+
const existing = await this.#slot(sessionId, after, context);
|
|
41
|
+
if (existing !== undefined)
|
|
42
|
+
return { type: "exists", to: existing.to, device: existing.device };
|
|
43
|
+
const head = remoteHead(await this.list(sessionId, context));
|
|
44
|
+
if (after !== head)
|
|
45
|
+
return { type: "not_head", head };
|
|
46
|
+
await this.#write(sessionId, ["batches"], `${pad(after)}.batch`, body, context);
|
|
47
|
+
// The slot is written last: it is what makes the batch exist.
|
|
48
|
+
const slot = { after, to, device, ...(options.archive === true ? { archive: true } : {}) };
|
|
49
|
+
await this.#write(sessionId, ["slots"], `${pad(after)}.json`, once(new TextEncoder().encode(JSON.stringify(slot))), context);
|
|
50
|
+
return { type: "created" };
|
|
51
|
+
}
|
|
52
|
+
async getBatch(sessionId, after, context) {
|
|
53
|
+
const slot = await this.#slot(sessionId, after, context);
|
|
54
|
+
if (slot === undefined || slot.folded)
|
|
55
|
+
return undefined;
|
|
56
|
+
return this.#stream(context, sessionId, "batches", `${pad(after)}.batch`);
|
|
57
|
+
}
|
|
58
|
+
getSnapshot(sessionId, to, context) {
|
|
59
|
+
return this.#stream(context, sessionId, "snapshots", `${pad(to)}.batch`);
|
|
60
|
+
}
|
|
61
|
+
async putSnapshot(sessionId, to, body, context) {
|
|
62
|
+
await this.#write(sessionId, ["snapshots"], `${pad(to)}.batch`, body, context);
|
|
63
|
+
}
|
|
64
|
+
async foldBatches(sessionId, afters, context) {
|
|
65
|
+
for (const after of afters) {
|
|
66
|
+
const slot = await this.#slot(sessionId, after, context);
|
|
67
|
+
if (slot === undefined || slot.folded)
|
|
68
|
+
continue;
|
|
69
|
+
const folded = { ...slot, folded: true };
|
|
70
|
+
await this.#write(sessionId, ["slots"], `${pad(after)}.json`, once(new TextEncoder().encode(JSON.stringify(folded))), context);
|
|
71
|
+
const body = await this.#path(context, sessionId, "batches", `${pad(after)}.batch`);
|
|
72
|
+
unwrap(await this.#fs.remove(body, { force: true }, context));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async deleteSnapshots(sessionId, snapshots, context) {
|
|
76
|
+
for (const to of snapshots) {
|
|
77
|
+
const path = await this.#path(context, sessionId, "snapshots", `${pad(to)}.batch`);
|
|
78
|
+
unwrap(await this.#fs.remove(path, { force: true }, context));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async list(sessionId, context) {
|
|
82
|
+
const batches = [];
|
|
83
|
+
for (const name of await this.#names(context, sessionId, "slots")) {
|
|
84
|
+
const match = SLOT_NAME.exec(name);
|
|
85
|
+
if (match === null)
|
|
86
|
+
continue;
|
|
87
|
+
const slot = await this.#slot(sessionId, Number(match[1]), context);
|
|
88
|
+
if (slot !== undefined)
|
|
89
|
+
batches.push(slot);
|
|
90
|
+
}
|
|
91
|
+
const snapshots = [];
|
|
92
|
+
for (const name of await this.#names(context, sessionId, "snapshots")) {
|
|
93
|
+
const match = SNAPSHOT_NAME.exec(name);
|
|
94
|
+
if (match !== null)
|
|
95
|
+
snapshots.push(Number(match[1]));
|
|
96
|
+
}
|
|
97
|
+
return { batches, snapshots };
|
|
98
|
+
}
|
|
99
|
+
/** Every session, every time: a directory keeps no change order. */
|
|
100
|
+
async sessions(_cursor, context) {
|
|
101
|
+
const result = await this.#fs.listDir(this.#root, context);
|
|
102
|
+
const names = isNotFound(result)
|
|
103
|
+
? []
|
|
104
|
+
: unwrap(result)
|
|
105
|
+
.filter((info) => info.kind === "directory" && SESSION_ID.test(info.name))
|
|
106
|
+
.map((info) => info.name)
|
|
107
|
+
.sort();
|
|
108
|
+
const sessions = [];
|
|
109
|
+
for (const id of names) {
|
|
110
|
+
sessions.push({
|
|
111
|
+
id,
|
|
112
|
+
head: remoteHead(await this.list(id, context)),
|
|
113
|
+
meta: await this.getMeta(id, context),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return { sessions, cursor: "", more: false };
|
|
117
|
+
}
|
|
118
|
+
async putMeta(sessionId, meta, context) {
|
|
119
|
+
await this.#write(sessionId, [], "meta.json", once(new TextEncoder().encode(JSON.stringify(meta))), context);
|
|
120
|
+
}
|
|
121
|
+
async getMeta(sessionId, context) {
|
|
122
|
+
const bytes = await this.#read(context, sessionId, "meta.json");
|
|
123
|
+
return bytes === undefined ? undefined : JSON.parse(new TextDecoder().decode(bytes));
|
|
124
|
+
}
|
|
125
|
+
async #slot(sessionId, after, context) {
|
|
126
|
+
const bytes = await this.#read(context, sessionId, "slots", `${pad(after)}.json`);
|
|
127
|
+
return bytes === undefined ? undefined : JSON.parse(new TextDecoder().decode(bytes));
|
|
128
|
+
}
|
|
129
|
+
async #names(context, sessionId, ...parts) {
|
|
130
|
+
const result = await this.#fs.listDir(await this.#path(context, sessionId, ...parts), context);
|
|
131
|
+
if (isNotFound(result))
|
|
132
|
+
return [];
|
|
133
|
+
return unwrap(result).map((info) => info.name);
|
|
134
|
+
}
|
|
135
|
+
async #read(context, sessionId, ...parts) {
|
|
136
|
+
const result = await this.#fs.readBinaryFile(await this.#path(context, sessionId, ...parts), context);
|
|
137
|
+
if (isNotFound(result))
|
|
138
|
+
return undefined;
|
|
139
|
+
return unwrap(result);
|
|
140
|
+
}
|
|
141
|
+
/** A body streamed back from its file, a chunk at a time; undefined when the file is missing. */
|
|
142
|
+
async #stream(context, sessionId, ...parts) {
|
|
143
|
+
const opened = await this.#fs.openBinaryReader(await this.#path(context, sessionId, ...parts), undefined, context);
|
|
144
|
+
if (isNotFound(opened))
|
|
145
|
+
return undefined;
|
|
146
|
+
return readerBody(unwrap(opened), context);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Write a body through a temporary file and a rename, so a reader never sees half a file; the body is appended chunk
|
|
150
|
+
* by chunk as it streams.
|
|
151
|
+
*/
|
|
152
|
+
async #write(sessionId, directory, name, body, context) {
|
|
153
|
+
unwrap(await this.#fs.createDir(await this.#path(context, sessionId, ...directory), { recursive: true }, context));
|
|
154
|
+
const path = await this.#path(context, sessionId, ...directory, name);
|
|
155
|
+
const temporary = await this.#path(context, sessionId, ...directory, `${name}.tmp`);
|
|
156
|
+
unwrap(await this.#fs.writeFile(temporary, new Uint8Array(), context));
|
|
157
|
+
try {
|
|
158
|
+
for await (const chunk of body)
|
|
159
|
+
unwrap(await this.#fs.appendFile(temporary, chunk, context));
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
await this.#fs.remove(temporary, { force: true }, context);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
unwrap(await this.#fs.renameFile(temporary, path, context));
|
|
166
|
+
}
|
|
167
|
+
async #path(context, sessionId, ...parts) {
|
|
168
|
+
return unwrap(await this.#fs.joinPath([this.#root, checkSessionId(sessionId), ...parts], context));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* An open file as a body, a chunk at a time, closed at its end, on a failed read, or on `return()`. Not an async
|
|
173
|
+
* generator: its `finally` runs only once started, and a file left to garbage collection is an uncaught error on Node 26.
|
|
174
|
+
*/
|
|
175
|
+
function readerBody(reader, context) {
|
|
176
|
+
let offset = 0;
|
|
177
|
+
let closing;
|
|
178
|
+
const close = async () => {
|
|
179
|
+
closing ??= reader.close(context);
|
|
180
|
+
await closing;
|
|
181
|
+
return { done: true, value: undefined };
|
|
182
|
+
};
|
|
183
|
+
const body = {
|
|
184
|
+
async next() {
|
|
185
|
+
if (closing !== undefined)
|
|
186
|
+
return close();
|
|
187
|
+
let chunk;
|
|
188
|
+
try {
|
|
189
|
+
chunk = unwrap(await reader.read(offset, READ_CHUNK, context));
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
await close();
|
|
193
|
+
throw error;
|
|
194
|
+
}
|
|
195
|
+
if (chunk.length === 0)
|
|
196
|
+
return close();
|
|
197
|
+
offset += chunk.length;
|
|
198
|
+
return { done: false, value: chunk };
|
|
199
|
+
},
|
|
200
|
+
return: close,
|
|
201
|
+
[Symbol.asyncIterator]: () => body,
|
|
202
|
+
};
|
|
203
|
+
return body;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=filesystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.js","sourceRoot":"","sources":["../../src/sync/filesystem.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAA4C,MAAM,EAAE,MAAM,YAAY,CAAC;AAC1F,OAAO,EAKN,UAAU,GAIV,MAAM,aAAa,CAAC;AAEr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CAAC;IACF,MAAM,IAAI,GAAiD;QAC1D,KAAK,CAAC,IAAI;YACT,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAO,KAAK,EAAE,CAAC;YAC1C,IAAI,KAAiB,CAAC;YACtB,IAAI,CAAC;gBACJ,KAAK,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,MAAM,KAAK,EAAE,CAAC;gBACd,MAAM,KAAK,CAAC;YACb,CAAC;YACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,KAAK,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC;YACvB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;QACtC,CAAC;QACD,MAAM,EAAE,KAAK;QACb,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC,IAAI;KAClC,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["import type { Context } from \"../context/index.ts\";\nimport type { SyncBody } from \"./batch.ts\";\nimport { isNotFound, type SyncFileReader, type SyncFileSystem, unwrap } from \"./files.ts\";\nimport {\n\ttype BatchInfo,\n\ttype JsonObject,\n\ttype PutBatchResult,\n\ttype RemoteListing,\n\tremoteHead,\n\ttype Seq,\n\ttype SessionChanges,\n\ttype SessionSyncMaintenance,\n} from \"./remote.ts\";\n\nconst pad = (value: number): string => String(value).padStart(16, \"0\");\n/** How much of a body is read from its file at a time. */\nconst READ_CHUNK = 256 * 1024;\n\n/** One buffer as a body. */\nasync function* once(bytes: Uint8Array): SyncBody {\n\tyield bytes;\n}\nconst SLOT_NAME = /^(\\d{16})\\.json$/;\nconst SNAPSHOT_NAME = /^(\\d{16})\\.batch$/;\nconst SESSION_ID = /^[A-Za-z0-9_-][A-Za-z0-9._-]*$/;\n\n/** A session ID names a file or directory: refuse anything that could leave the root. */\nexport function checkSessionId(sessionId: string): string {\n\tif (!SESSION_ID.test(sessionId)) throw new Error(`Invalid session ID for a sync directory: ${sessionId}`);\n\treturn sessionId;\n}\n\n/**\n * A remote store in a directory, laid out as the real remote is: per session, one slot per batch start, holding where\n * the batch ends and which device created it, and snapshots named by their end. As the real remote, it creates a slot\n * only where the history ends. Creating a slot is check-then-write,\n * without the atomicity of the real remote across processes: for development and tests, with one process writing.\n *\n * ```text\n * {root}/{session}/slots/{after}.json { after, to, device, archive?, folded? }, written once\n * {root}/{session}/batches/{after}.batch the commits (or an archive), until folded\n * {root}/{session}/snapshots/{to}.batch a store archive\n * {root}/{session}/meta.json the host's description, last write wins\n * ```\n */\nexport class FileSystemSyncRemote implements SessionSyncMaintenance {\n\treadonly #fs: SyncFileSystem;\n\treadonly #root: string;\n\n\tconstructor(fs: SyncFileSystem, root: string) {\n\t\tthis.#fs = fs;\n\t\tthis.#root = root;\n\t}\n\n\tasync putBatch(\n\t\tsessionId: string,\n\t\tafter: Seq,\n\t\tto: Seq,\n\t\tdevice: string,\n\t\tbody: SyncBody,\n\t\tcontext: Context,\n\t\toptions: { readonly archive?: boolean } = {},\n\t): Promise<PutBatchResult> {\n\t\tconst existing = await this.#slot(sessionId, after, context);\n\t\tif (existing !== undefined) return { type: \"exists\", to: existing.to, device: existing.device };\n\t\tconst head = remoteHead(await this.list(sessionId, context));\n\t\tif (after !== head) return { type: \"not_head\", head };\n\t\tawait this.#write(sessionId, [\"batches\"], `${pad(after)}.batch`, body, context);\n\t\t// The slot is written last: it is what makes the batch exist.\n\t\tconst slot: BatchInfo = { after, to, device, ...(options.archive === true ? { archive: true as const } : {}) };\n\t\tawait this.#write(\n\t\t\tsessionId,\n\t\t\t[\"slots\"],\n\t\t\t`${pad(after)}.json`,\n\t\t\tonce(new TextEncoder().encode(JSON.stringify(slot))),\n\t\t\tcontext,\n\t\t);\n\t\treturn { type: \"created\" };\n\t}\n\n\tasync getBatch(sessionId: string, after: Seq, context: Context): Promise<SyncBody | undefined> {\n\t\tconst slot = await this.#slot(sessionId, after, context);\n\t\tif (slot === undefined || slot.folded) return undefined;\n\t\treturn this.#stream(context, sessionId, \"batches\", `${pad(after)}.batch`);\n\t}\n\n\tgetSnapshot(sessionId: string, to: Seq, context: Context): Promise<SyncBody | undefined> {\n\t\treturn this.#stream(context, sessionId, \"snapshots\", `${pad(to)}.batch`);\n\t}\n\n\tasync putSnapshot(sessionId: string, to: Seq, body: SyncBody, context: Context): Promise<void> {\n\t\tawait this.#write(sessionId, [\"snapshots\"], `${pad(to)}.batch`, body, context);\n\t}\n\n\tasync foldBatches(sessionId: string, afters: readonly Seq[], context: Context): Promise<void> {\n\t\tfor (const after of afters) {\n\t\t\tconst slot = await this.#slot(sessionId, after, context);\n\t\t\tif (slot === undefined || slot.folded) continue;\n\t\t\tconst folded: BatchInfo = { ...slot, folded: true };\n\t\t\tawait this.#write(\n\t\t\t\tsessionId,\n\t\t\t\t[\"slots\"],\n\t\t\t\t`${pad(after)}.json`,\n\t\t\t\tonce(new TextEncoder().encode(JSON.stringify(folded))),\n\t\t\t\tcontext,\n\t\t\t);\n\t\t\tconst body = await this.#path(context, sessionId, \"batches\", `${pad(after)}.batch`);\n\t\t\tunwrap(await this.#fs.remove(body, { force: true }, context));\n\t\t}\n\t}\n\n\tasync deleteSnapshots(sessionId: string, snapshots: readonly Seq[], context: Context): Promise<void> {\n\t\tfor (const to of snapshots) {\n\t\t\tconst path = await this.#path(context, sessionId, \"snapshots\", `${pad(to)}.batch`);\n\t\t\tunwrap(await this.#fs.remove(path, { force: true }, context));\n\t\t}\n\t}\n\n\tasync list(sessionId: string, context: Context): Promise<RemoteListing> {\n\t\tconst batches: BatchInfo[] = [];\n\t\tfor (const name of await this.#names(context, sessionId, \"slots\")) {\n\t\t\tconst match = SLOT_NAME.exec(name);\n\t\t\tif (match === null) continue;\n\t\t\tconst slot = await this.#slot(sessionId, Number(match[1]), context);\n\t\t\tif (slot !== undefined) batches.push(slot);\n\t\t}\n\t\tconst snapshots: Seq[] = [];\n\t\tfor (const name of await this.#names(context, sessionId, \"snapshots\")) {\n\t\t\tconst match = SNAPSHOT_NAME.exec(name);\n\t\t\tif (match !== null) snapshots.push(Number(match[1]));\n\t\t}\n\t\treturn { batches, snapshots };\n\t}\n\n\t/** Every session, every time: a directory keeps no change order. */\n\tasync sessions(_cursor: string | undefined, context: Context): Promise<SessionChanges> {\n\t\tconst result = await this.#fs.listDir(this.#root, context);\n\t\tconst names = isNotFound(result)\n\t\t\t? []\n\t\t\t: unwrap(result)\n\t\t\t\t\t.filter((info) => info.kind === \"directory\" && SESSION_ID.test(info.name))\n\t\t\t\t\t.map((info) => info.name)\n\t\t\t\t\t.sort();\n\t\tconst sessions = [];\n\t\tfor (const id of names) {\n\t\t\tsessions.push({\n\t\t\t\tid,\n\t\t\t\thead: remoteHead(await this.list(id, context)),\n\t\t\t\tmeta: await this.getMeta(id, context),\n\t\t\t});\n\t\t}\n\t\treturn { sessions, cursor: \"\", more: false };\n\t}\n\n\tasync putMeta(sessionId: string, meta: JsonObject, context: Context): Promise<void> {\n\t\tawait this.#write(sessionId, [], \"meta.json\", once(new TextEncoder().encode(JSON.stringify(meta))), context);\n\t}\n\n\tasync getMeta(sessionId: string, context: Context): Promise<JsonObject | undefined> {\n\t\tconst bytes = await this.#read(context, sessionId, \"meta.json\");\n\t\treturn bytes === undefined ? undefined : (JSON.parse(new TextDecoder().decode(bytes)) as JsonObject);\n\t}\n\n\tasync #slot(sessionId: string, after: Seq, context: Context): Promise<BatchInfo | undefined> {\n\t\tconst bytes = await this.#read(context, sessionId, \"slots\", `${pad(after)}.json`);\n\t\treturn bytes === undefined ? undefined : (JSON.parse(new TextDecoder().decode(bytes)) as BatchInfo);\n\t}\n\n\tasync #names(context: Context, sessionId: string, ...parts: string[]): Promise<string[]> {\n\t\tconst result = await this.#fs.listDir(await this.#path(context, sessionId, ...parts), context);\n\t\tif (isNotFound(result)) return [];\n\t\treturn unwrap(result).map((info) => info.name);\n\t}\n\n\tasync #read(context: Context, sessionId: string, ...parts: string[]): Promise<Uint8Array | undefined> {\n\t\tconst result = await this.#fs.readBinaryFile(await this.#path(context, sessionId, ...parts), context);\n\t\tif (isNotFound(result)) return undefined;\n\t\treturn unwrap(result);\n\t}\n\n\t/** A body streamed back from its file, a chunk at a time; undefined when the file is missing. */\n\tasync #stream(context: Context, sessionId: string, ...parts: string[]): Promise<SyncBody | undefined> {\n\t\tconst opened = await this.#fs.openBinaryReader(\n\t\t\tawait this.#path(context, sessionId, ...parts),\n\t\t\tundefined,\n\t\t\tcontext,\n\t\t);\n\t\tif (isNotFound(opened)) return undefined;\n\t\treturn readerBody(unwrap(opened), context);\n\t}\n\n\t/**\n\t * Write a body through a temporary file and a rename, so a reader never sees half a file; the body is appended chunk\n\t * by chunk as it streams.\n\t */\n\tasync #write(\n\t\tsessionId: string,\n\t\tdirectory: readonly string[],\n\t\tname: string,\n\t\tbody: SyncBody,\n\t\tcontext: Context,\n\t): Promise<void> {\n\t\tunwrap(\n\t\t\tawait this.#fs.createDir(await this.#path(context, sessionId, ...directory), { recursive: true }, context),\n\t\t);\n\t\tconst path = await this.#path(context, sessionId, ...directory, name);\n\t\tconst temporary = await this.#path(context, sessionId, ...directory, `${name}.tmp`);\n\t\tunwrap(await this.#fs.writeFile(temporary, new Uint8Array(), context));\n\t\ttry {\n\t\t\tfor await (const chunk of body) unwrap(await this.#fs.appendFile(temporary, chunk, context));\n\t\t} catch (error) {\n\t\t\tawait this.#fs.remove(temporary, { force: true }, context);\n\t\t\tthrow error;\n\t\t}\n\t\tunwrap(await this.#fs.renameFile(temporary, path, context));\n\t}\n\n\tasync #path(context: Context, sessionId: string, ...parts: string[]): Promise<string> {\n\t\treturn unwrap(await this.#fs.joinPath([this.#root, checkSessionId(sessionId), ...parts], context));\n\t}\n}\n\n/**\n * An open file as a body, a chunk at a time, closed at its end, on a failed read, or on `return()`. Not an async\n * generator: its `finally` runs only once started, and a file left to garbage collection is an uncaught error on Node 26.\n */\nfunction readerBody(reader: SyncFileReader, context: Context): SyncBody {\n\tlet offset = 0;\n\tlet closing: Promise<void> | undefined;\n\tconst close = async (): Promise<IteratorReturnResult<undefined>> => {\n\t\tclosing ??= reader.close(context);\n\t\tawait closing;\n\t\treturn { done: true, value: undefined };\n\t};\n\tconst body: AsyncIterableIterator<Uint8Array, undefined> = {\n\t\tasync next() {\n\t\t\tif (closing !== undefined) return close();\n\t\t\tlet chunk: Uint8Array;\n\t\t\ttry {\n\t\t\t\tchunk = unwrap(await reader.read(offset, READ_CHUNK, context));\n\t\t\t} catch (error) {\n\t\t\t\tawait close();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (chunk.length === 0) return close();\n\t\t\toffset += chunk.length;\n\t\t\treturn { done: false, value: chunk };\n\t\t},\n\t\treturn: close,\n\t\t[Symbol.asyncIterator]: () => body,\n\t};\n\treturn body;\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { decodeBatch, decodeBatchLines, decodeSnapshot, encodeBatch, encodeSnapshot, type SyncBody, } from "./batch.ts";
|
|
2
|
+
export { APPLY_BYTES, BATCH_BYTES, FlushScheduler, type FlushSchedulerOptions, foldSession, type LocalCopy, OutboxUnavailableError, pullSession, readOutbox, type SyncState, type SyncStateStore, storeHead, UnsyncedCommitsError, type UploadResult, uploadSession, } from "./client.ts";
|
|
3
|
+
export type { FileResult, SyncFileInfo, SyncFileReader, SyncFileSystem } from "./files.ts";
|
|
4
|
+
export { checkSessionId, FileSystemSyncRemote } from "./filesystem.ts";
|
|
5
|
+
export { decodeLogLine, encodeLogLine, LOG_VERSION, LogFormatError } from "./lines.ts";
|
|
6
|
+
export { type BatchInfo, HistoryUnavailableError, type JsonObject, LOG_START, type PutBatchResult, type RemoteHistory, type RemoteListing, remoteHead, remoteHistory, type Seq, type SessionChanges, type SessionSummary, type SessionSyncMaintenance, type SessionSyncStore, type SessionSyncUploader, SYNC_PROTOCOL, } from "./remote.ts";
|
|
7
|
+
export { FileSyncStateStore } from "./state.ts";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACN,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,cAAc,EACd,KAAK,QAAQ,GACb,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,WAAW,EACX,WAAW,EACX,cAAc,EACd,KAAK,qBAAqB,EAC1B,WAAW,EACX,KAAK,SAAS,EACd,sBAAsB,EACtB,WAAW,EACX,UAAU,EACV,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,SAAS,EACT,oBAAoB,EACpB,KAAK,YAAY,EACjB,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EACN,KAAK,SAAS,EACd,uBAAuB,EACvB,KAAK,UAAU,EACf,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,UAAU,EACV,aAAa,EACb,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Session sync over a store's outbox (`@diffra-ai/chord/sync`, experimental). Portable: the remote and the host's
|
|
2
|
+
// sync state are interfaces, and the directory-backed ones take their file operations (`SyncFileSystem`).
|
|
3
|
+
export { decodeBatch, decodeBatchLines, decodeSnapshot, encodeBatch, encodeSnapshot, } from "./batch.js";
|
|
4
|
+
export { APPLY_BYTES, BATCH_BYTES, FlushScheduler, foldSession, OutboxUnavailableError, pullSession, readOutbox, storeHead, UnsyncedCommitsError, uploadSession, } from "./client.js";
|
|
5
|
+
export { checkSessionId, FileSystemSyncRemote } from "./filesystem.js";
|
|
6
|
+
export { decodeLogLine, encodeLogLine, LOG_VERSION, LogFormatError } from "./lines.js";
|
|
7
|
+
export { HistoryUnavailableError, LOG_START, remoteHead, remoteHistory, SYNC_PROTOCOL, } from "./remote.js";
|
|
8
|
+
export { FileSyncStateStore } from "./state.js";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/sync/index.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,0GAA0G;AAE1G,OAAO,EACN,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,WAAW,EACX,cAAc,GAEd,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,WAAW,EACX,WAAW,EACX,cAAc,EAEd,WAAW,EAEX,sBAAsB,EACtB,WAAW,EACX,UAAU,EAGV,SAAS,EACT,oBAAoB,EAEpB,aAAa,GACb,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAEN,uBAAuB,EAEvB,SAAS,EAIT,UAAU,EACV,aAAa,EAOb,aAAa,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// Session sync over a store's outbox (`@diffra-ai/chord/sync`, experimental). Portable: the remote and the host's\n// sync state are interfaces, and the directory-backed ones take their file operations (`SyncFileSystem`).\n\nexport {\n\tdecodeBatch,\n\tdecodeBatchLines,\n\tdecodeSnapshot,\n\tencodeBatch,\n\tencodeSnapshot,\n\ttype SyncBody,\n} from \"./batch.ts\";\nexport {\n\tAPPLY_BYTES,\n\tBATCH_BYTES,\n\tFlushScheduler,\n\ttype FlushSchedulerOptions,\n\tfoldSession,\n\ttype LocalCopy,\n\tOutboxUnavailableError,\n\tpullSession,\n\treadOutbox,\n\ttype SyncState,\n\ttype SyncStateStore,\n\tstoreHead,\n\tUnsyncedCommitsError,\n\ttype UploadResult,\n\tuploadSession,\n} from \"./client.ts\";\nexport type { FileResult, SyncFileInfo, SyncFileReader, SyncFileSystem } from \"./files.ts\";\nexport { checkSessionId, FileSystemSyncRemote } from \"./filesystem.ts\";\nexport { decodeLogLine, encodeLogLine, LOG_VERSION, LogFormatError } from \"./lines.ts\";\nexport {\n\ttype BatchInfo,\n\tHistoryUnavailableError,\n\ttype JsonObject,\n\tLOG_START,\n\ttype PutBatchResult,\n\ttype RemoteHistory,\n\ttype RemoteListing,\n\tremoteHead,\n\tremoteHistory,\n\ttype Seq,\n\ttype SessionChanges,\n\ttype SessionSummary,\n\ttype SessionSyncMaintenance,\n\ttype SessionSyncStore,\n\ttype SessionSyncUploader,\n\tSYNC_PROTOCOL,\n} from \"./remote.ts\";\nexport { FileSyncStateStore } from \"./state.ts\";\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OutboxCommit } from "../store/outbox.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Version of the line envelope. It changes when the envelope changes; the writes inside carry the store outbox's own
|
|
4
|
+
* `format`, which `applyBatch()` checks.
|
|
5
|
+
*/
|
|
6
|
+
export declare const LOG_VERSION = 2;
|
|
7
|
+
export declare class LogFormatError extends Error {
|
|
8
|
+
constructor(message: string, options?: ErrorOptions);
|
|
9
|
+
}
|
|
10
|
+
/** One outbox commit as a JSON line, terminated by a newline. */
|
|
11
|
+
export declare function encodeLogLine(commit: OutboxCommit): string;
|
|
12
|
+
/**
|
|
13
|
+
* One line (without its newline) as an outbox commit; `number` names the line in errors. A line of an unknown version
|
|
14
|
+
* is an error: an older diffra must not apply writes it does not understand. The writes themselves are checked by
|
|
15
|
+
* `applyBatch()`, a trust boundary.
|
|
16
|
+
*/
|
|
17
|
+
export declare function decodeLogLine(text: string, number: number): OutboxCommit;
|
|
18
|
+
//# sourceMappingURL=lines.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.d.ts","sourceRoot":"","sources":["../../src/sync/lines.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,eAAO,MAAM,WAAW,IAAI,CAAC;AAS7B,qBAAa,cAAe,SAAQ,KAAK;IACxC,YAAY,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,EAGlD;CACD;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAG1D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,YAAY,CAoBxE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version of the line envelope. It changes when the envelope changes; the writes inside carry the store outbox's own
|
|
3
|
+
* `format`, which `applyBatch()` checks.
|
|
4
|
+
*/
|
|
5
|
+
export const LOG_VERSION = 2;
|
|
6
|
+
export class LogFormatError extends Error {
|
|
7
|
+
constructor(message, options) {
|
|
8
|
+
super(message, options);
|
|
9
|
+
this.name = "LogFormatError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** One outbox commit as a JSON line, terminated by a newline. */
|
|
13
|
+
export function encodeLogLine(commit) {
|
|
14
|
+
const line = { v: LOG_VERSION, seq: commit.seq, nextId: commit.nextId, writes: commit.writes };
|
|
15
|
+
return `${JSON.stringify(line)}\n`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One line (without its newline) as an outbox commit; `number` names the line in errors. A line of an unknown version
|
|
19
|
+
* is an error: an older diffra must not apply writes it does not understand. The writes themselves are checked by
|
|
20
|
+
* `applyBatch()`, a trust boundary.
|
|
21
|
+
*/
|
|
22
|
+
export function decodeLogLine(text, number) {
|
|
23
|
+
let value;
|
|
24
|
+
try {
|
|
25
|
+
value = JSON.parse(text);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
throw new LogFormatError(`Log line ${number} is not JSON`, { cause: error });
|
|
29
|
+
}
|
|
30
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
31
|
+
throw new LogFormatError(`Log line ${number} is not an object`);
|
|
32
|
+
}
|
|
33
|
+
const line = value;
|
|
34
|
+
if (line.v !== LOG_VERSION)
|
|
35
|
+
throw new LogFormatError(`Log line ${number} has unknown version ${String(line.v)}`);
|
|
36
|
+
if (typeof line.seq !== "number" || !Number.isSafeInteger(line.seq) || line.seq < 1) {
|
|
37
|
+
throw new LogFormatError(`Log line ${number} has no valid sequence`);
|
|
38
|
+
}
|
|
39
|
+
if (typeof line.nextId !== "number" || !Number.isSafeInteger(line.nextId)) {
|
|
40
|
+
throw new LogFormatError(`Log line ${number} has no valid next id`);
|
|
41
|
+
}
|
|
42
|
+
if (!Array.isArray(line.writes))
|
|
43
|
+
throw new LogFormatError(`Log line ${number} has no writes`);
|
|
44
|
+
return { seq: line.seq, nextId: line.nextId, writes: line.writes };
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lines.js","sourceRoot":"","sources":["../../src/sync/lines.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC;AAS7B,MA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Aa,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,CAAC,EAAE,CAAC;QACrF,MAAM,IAAI,cAAc,CAAC,YAAY,MAAM,wBAAwB,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3E,MAAM,IAAI,cAAc,CAAC,YAAY,MAAM,uBAAuB,CAAC,CAAC;IACrE,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,cAAc,CAAC,YAAY,MAAM,gBAAgB,CAAC,CAAC;IAC9F,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { OutboxCommit } from \"../store/outbox.ts\";\n\n/**\n * Version of the line envelope. It changes when the envelope changes; the writes inside carry the store outbox's own\n * `format`, which `applyBatch()` checks.\n */\nexport const LOG_VERSION = 2;\n\ntype LogLine = {\n\treadonly v: typeof LOG_VERSION;\n\treadonly seq: number;\n\treadonly nextId: number;\n\treadonly writes: OutboxCommit[\"writes\"];\n};\n\nexport class LogFormatError extends Error {\n\tconstructor(message: string, options?: ErrorOptions) {\n\t\tsuper(message, options);\n\t\tthis.name = \"LogFormatError\";\n\t}\n}\n\n/** One outbox commit as a JSON line, terminated by a newline. */\nexport function encodeLogLine(commit: OutboxCommit): string {\n\tconst line: LogLine = { v: LOG_VERSION, seq: commit.seq, nextId: commit.nextId, writes: commit.writes };\n\treturn `${JSON.stringify(line)}\\n`;\n}\n\n/**\n * One line (without its newline) as an outbox commit; `number` names the line in errors. A line of an unknown version\n * is an error: an older diffra must not apply writes it does not understand. The writes themselves are checked by\n * `applyBatch()`, a trust boundary.\n */\nexport function decodeLogLine(text: string, number: number): OutboxCommit {\n\tlet value: unknown;\n\ttry {\n\t\tvalue = JSON.parse(text);\n\t} catch (error) {\n\t\tthrow new LogFormatError(`Log line ${number} is not JSON`, { cause: error });\n\t}\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n\t\tthrow new LogFormatError(`Log line ${number} is not an object`);\n\t}\n\tconst line = value as Partial<LogLine> & { readonly v?: unknown };\n\tif (line.v !== LOG_VERSION) throw new LogFormatError(`Log line ${number} has unknown version ${String(line.v)}`);\n\tif (typeof line.seq !== \"number\" || !Number.isSafeInteger(line.seq) || line.seq < 1) {\n\t\tthrow new LogFormatError(`Log line ${number} has no valid sequence`);\n\t}\n\tif (typeof line.nextId !== \"number\" || !Number.isSafeInteger(line.nextId)) {\n\t\tthrow new LogFormatError(`Log line ${number} has no valid next id`);\n\t}\n\tif (!Array.isArray(line.writes)) throw new LogFormatError(`Log line ${number} has no writes`);\n\treturn { seq: line.seq, nextId: line.nextId, writes: line.writes };\n}\n"]}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Context } from "../context/index.ts";
|
|
2
|
+
import type { SyncBody } from "./batch.ts";
|
|
3
|
+
/** A store's commit sequence (`store.lastSeq`, an outbox commit's `seq`); 0 is before every commit. */
|
|
4
|
+
export type Seq = number;
|
|
5
|
+
/** A JSON object: a session's description on the remote. */
|
|
6
|
+
export type JsonObject = {
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
};
|
|
9
|
+
/** The sequence before every commit: a store without commits is at it. */
|
|
10
|
+
export declare const LOG_START: Seq;
|
|
11
|
+
/**
|
|
12
|
+
* The version of the sync rules this client follows: slots created once at the head, each recording its device, and
|
|
13
|
+
* archive slots. A remote adapter sends it with every request, so a remote that later changes the rules for a session
|
|
14
|
+
* (a handoff to another device) can refuse writers that do not know them. Raised when the rules change, not when a
|
|
15
|
+
* body's encoding does (`LOG_VERSION`).
|
|
16
|
+
*/
|
|
17
|
+
export declare const SYNC_PROTOCOL = 1;
|
|
18
|
+
/**
|
|
19
|
+
* A slot of a session's remote history: the batch of outbox commits after `after`, up to `to`, uploaded by `device`. A
|
|
20
|
+
* store creates each slot once and never replaces it, so the device whose upload creates it continues the session from
|
|
21
|
+
* `after`, and a device that finds it taken by another one holds a different history.
|
|
22
|
+
*/
|
|
23
|
+
export type BatchInfo = {
|
|
24
|
+
readonly after: Seq;
|
|
25
|
+
readonly to: Seq;
|
|
26
|
+
readonly device: string;
|
|
27
|
+
/** Folding dropped its commits into a snapshot; the slot stays taken. */
|
|
28
|
+
readonly folded?: true;
|
|
29
|
+
/**
|
|
30
|
+
* The body is a store archive at `to` instead of commits: an upload whose outbox does not reach back to `after` (a
|
|
31
|
+
* session's first upload with its outbox turned on late, or one after its outbox was turned off and on again). A
|
|
32
|
+
* restore starts from the newest one along the chain; a copy behind it restores fresh.
|
|
33
|
+
*/
|
|
34
|
+
readonly archive?: true;
|
|
35
|
+
};
|
|
36
|
+
/** What a remote store holds for one session. A snapshot is a store archive at its sequence, folded from batches. */
|
|
37
|
+
export type RemoteListing = {
|
|
38
|
+
readonly batches: readonly BatchInfo[];
|
|
39
|
+
readonly snapshots: readonly Seq[];
|
|
40
|
+
};
|
|
41
|
+
export type PutBatchResult = {
|
|
42
|
+
readonly type: "created";
|
|
43
|
+
}
|
|
44
|
+
/** The slot is taken; by this device, after an upload whose response was lost, or by another one. */
|
|
45
|
+
| {
|
|
46
|
+
readonly type: "exists";
|
|
47
|
+
readonly to: Seq;
|
|
48
|
+
readonly device: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* No slot starts at `after`, and the history does not end there: a slot there would branch the chain inside a batch
|
|
52
|
+
* or leave a gap. The uploader's history is not the remote's from `after` on.
|
|
53
|
+
*/
|
|
54
|
+
| {
|
|
55
|
+
readonly type: "not_head";
|
|
56
|
+
readonly head: Seq;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The upload's `epoch` is not the session's current one: another device was given the right to write the session
|
|
60
|
+
* since this one was. Who grants it, and when, is the remote's (RFC 0074's single writer); Chord only reports it.
|
|
61
|
+
*/
|
|
62
|
+
| {
|
|
63
|
+
readonly type: "stale_epoch";
|
|
64
|
+
readonly epoch: number;
|
|
65
|
+
};
|
|
66
|
+
/** A session as the remote's listing describes it. */
|
|
67
|
+
export type SessionSummary = {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
/** Where its history ends; `LOG_START` for a session with a description and no history. */
|
|
70
|
+
readonly head: Seq;
|
|
71
|
+
readonly meta: JsonObject | undefined;
|
|
72
|
+
};
|
|
73
|
+
/** Sessions changed after a cursor, and the cursor to continue from. */
|
|
74
|
+
export type SessionChanges = {
|
|
75
|
+
readonly sessions: readonly SessionSummary[];
|
|
76
|
+
/** Pass it to the next call; opaque. */
|
|
77
|
+
readonly cursor: string;
|
|
78
|
+
/** More changes follow right away: call again with `cursor`. */
|
|
79
|
+
readonly more: boolean;
|
|
80
|
+
};
|
|
81
|
+
/** The client's view of a remote store. Clients never delete or fold. */
|
|
82
|
+
export interface SessionSyncStore {
|
|
83
|
+
/**
|
|
84
|
+
* Create the slot after `after` unless it exists or the history does not end at `after`. `body` is a stream read once;
|
|
85
|
+
* a remote that answers without reading it (`exists`, `not_head`) leaves it unread.
|
|
86
|
+
*/
|
|
87
|
+
putBatch(sessionId: string, after: Seq, to: Seq, device: string, body: SyncBody, context: Context, options?: {
|
|
88
|
+
readonly archive?: boolean;
|
|
89
|
+
/** The writer's epoch: a remote that issues epochs refuses a stale one (`stale_epoch`); others ignore it. */
|
|
90
|
+
readonly epoch?: number;
|
|
91
|
+
}): Promise<PutBatchResult>;
|
|
92
|
+
/**
|
|
93
|
+
* A batch's body; `undefined` when its slot is folded or absent. The body may hold a file or a connection until it is
|
|
94
|
+
* read to the end or its iterator's `return()` is called, which releases it also before the first read.
|
|
95
|
+
*/
|
|
96
|
+
getBatch(sessionId: string, after: Seq, context: Context): Promise<SyncBody | undefined>;
|
|
97
|
+
/** A snapshot's body, released as `getBatch()`'s; `undefined` when it is absent. */
|
|
98
|
+
getSnapshot(sessionId: string, to: Seq, context: Context): Promise<SyncBody | undefined>;
|
|
99
|
+
list(sessionId: string, context: Context): Promise<RemoteListing>;
|
|
100
|
+
/**
|
|
101
|
+
* The sessions changed after `cursor` (all of them without one). A remote may also list sessions that did not change,
|
|
102
|
+
* so a caller compares what it gets with what it has.
|
|
103
|
+
*/
|
|
104
|
+
sessions(cursor: string | undefined, context: Context): Promise<SessionChanges>;
|
|
105
|
+
/**
|
|
106
|
+
* The host's description of a session (title, location, which device started it), outside its history: the last
|
|
107
|
+
* write wins, and it may be ahead of or behind the batches.
|
|
108
|
+
*/
|
|
109
|
+
putMeta(sessionId: string, meta: JsonObject, context: Context): Promise<void>;
|
|
110
|
+
getMeta(sessionId: string, context: Context): Promise<JsonObject | undefined>;
|
|
111
|
+
}
|
|
112
|
+
/** What an upload needs of a remote: creating slots (`uploadSession`). */
|
|
113
|
+
export type SessionSyncUploader = Pick<SessionSyncStore, "putBatch">;
|
|
114
|
+
/** The remote's own side: folding history into snapshots, which clients never do. */
|
|
115
|
+
export interface SessionSyncMaintenance extends SessionSyncStore {
|
|
116
|
+
putSnapshot(sessionId: string, to: Seq, body: SyncBody, context: Context): Promise<void>;
|
|
117
|
+
/** Drop the bodies of these slots, keeping the slots taken so nobody can create them again. */
|
|
118
|
+
foldBatches(sessionId: string, afters: readonly Seq[], context: Context): Promise<void>;
|
|
119
|
+
deleteSnapshots(sessionId: string, snapshots: readonly Seq[], context: Context): Promise<void>;
|
|
120
|
+
}
|
|
121
|
+
/** What a copy applies to reach the remote's head. */
|
|
122
|
+
export type RemoteHistory = {
|
|
123
|
+
/** The snapshot a restore starts from. */
|
|
124
|
+
readonly snapshot?: Seq;
|
|
125
|
+
/**
|
|
126
|
+
* The batches to apply in order. The first may start before the copy's head, when a pull stopped inside it; its
|
|
127
|
+
* commits at or below the head are skipped.
|
|
128
|
+
*/
|
|
129
|
+
readonly batches: readonly BatchInfo[];
|
|
130
|
+
/** Where applying them ends. */
|
|
131
|
+
readonly head: Seq;
|
|
132
|
+
};
|
|
133
|
+
/** The remote's history no longer continues from a copy's head, after folding: restore into a fresh store. */
|
|
134
|
+
export declare class HistoryUnavailableError extends Error {
|
|
135
|
+
constructor(head: Seq);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The history a copy at `from` applies, or a restore without `from`. Slots are created once, so at most one batch
|
|
139
|
+
* starts at each sequence and the history is a single chain. A restore starts from the newest full state along it: the
|
|
140
|
+
* newest snapshot or archive slot, whichever ends later.
|
|
141
|
+
*/
|
|
142
|
+
export declare function remoteHistory(listing: RemoteListing, from?: Seq): RemoteHistory;
|
|
143
|
+
/** The furthest head the remote's history reaches. */
|
|
144
|
+
export declare function remoteHead(listing: RemoteListing): Seq;
|
|
145
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/sync/remote.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,uGAAuG;AACvG,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC;AAEzB,4DAA4D;AAC5D,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAEpD,0EAA0E;AAC1E,eAAO,MAAM,SAAS,EAAE,GAAO,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,aAAa,IAAI,CAAC;AAE/B;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG;IACvB,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC;IACpB,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC;IACjB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;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AC;AAErE,qFAAqF;AACrF,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;IAC/D,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzF,+FAA+F;IAC/F,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/F;AAED,sDAAsD;AACtD,MAAM,MAAM,aAAa,GAAG;IAC3B,0CAA0C;IAC1C,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,SAAS,EAAE,CAAC;IACvC,gCAAgC;IAChC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC;CACnB,CAAC;AAEF,8GAA8G;AAC9G,qBAAa,uBAAwB,SAAQ,KAAK;IACjD,YAAY,IAAI,EAAE,GAAG,EAGpB;CACD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,aAAa,CA2B/E;AAED,sDAAsD;AACtD,wBAAgB,UAAU,CAAC,OAAO,EAAE,aAAa,GAAG,GAAG,CAKtD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** The sequence before every commit: a store without commits is at it. */
|
|
2
|
+
export const LOG_START = 0;
|
|
3
|
+
/**
|
|
4
|
+
* The version of the sync rules this client follows: slots created once at the head, each recording its device, and
|
|
5
|
+
* archive slots. A remote adapter sends it with every request, so a remote that later changes the rules for a session
|
|
6
|
+
* (a handoff to another device) can refuse writers that do not know them. Raised when the rules change, not when a
|
|
7
|
+
* body's encoding does (`LOG_VERSION`).
|
|
8
|
+
*/
|
|
9
|
+
export const SYNC_PROTOCOL = 1;
|
|
10
|
+
/** The remote's history no longer continues from a copy's head, after folding: restore into a fresh store. */
|
|
11
|
+
export class HistoryUnavailableError extends Error {
|
|
12
|
+
constructor(head) {
|
|
13
|
+
super(`The remote history does not continue from ${head}`);
|
|
14
|
+
this.name = "HistoryUnavailableError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The history a copy at `from` applies, or a restore without `from`. Slots are created once, so at most one batch
|
|
19
|
+
* starts at each sequence and the history is a single chain. A restore starts from the newest full state along it: the
|
|
20
|
+
* newest snapshot or archive slot, whichever ends later.
|
|
21
|
+
*/
|
|
22
|
+
export function remoteHistory(listing, from) {
|
|
23
|
+
const chain = new Map(listing.batches.map((batch) => [batch.after, batch]));
|
|
24
|
+
let snapshot;
|
|
25
|
+
let at;
|
|
26
|
+
const batches = [];
|
|
27
|
+
if (from === undefined || from === LOG_START) {
|
|
28
|
+
snapshot = listing.snapshots.length === 0 ? undefined : Math.max(...listing.snapshots);
|
|
29
|
+
at = snapshot ?? LOG_START;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
at = from;
|
|
33
|
+
// A pull that stopped inside a batch finishes it; only one batch can contain the head.
|
|
34
|
+
const inside = listing.batches.find((batch) => batch.after < from && from < batch.to);
|
|
35
|
+
if (inside !== undefined) {
|
|
36
|
+
batches.push(inside);
|
|
37
|
+
at = inside.to;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (let next = chain.get(at); next !== undefined; next = chain.get(at)) {
|
|
41
|
+
batches.push(next);
|
|
42
|
+
at = next.to;
|
|
43
|
+
}
|
|
44
|
+
// An archive slot is a full state: a restore starts at the newest one. A copy at `from` gets the chain as it is: an
|
|
45
|
+
// archive slot in it does not apply on top of its store, and `pullSession` refuses it (the host restores fresh).
|
|
46
|
+
const archive = from === undefined || from === LOG_START ? batches.findLastIndex((batch) => batch.archive === true) : -1;
|
|
47
|
+
if (archive >= 0)
|
|
48
|
+
return { batches: batches.slice(archive), head: at };
|
|
49
|
+
return { ...(snapshot === undefined ? {} : { snapshot }), batches, head: at };
|
|
50
|
+
}
|
|
51
|
+
/** The furthest head the remote's history reaches. */
|
|
52
|
+
export function remoteHead(listing) {
|
|
53
|
+
const chain = new Map(listing.batches.map((batch) => [batch.after, batch]));
|
|
54
|
+
let at = LOG_START;
|
|
55
|
+
for (let next = chain.get(at); next !== undefined; next = chain.get(at))
|
|
56
|
+
at = next.to;
|
|
57
|
+
return at;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=remote.js.map
|