@powerhousedao/reactor 6.0.0-dev.9 → 6.0.0-dev.90
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/dist/src/admin/document-integrity-service.d.ts +17 -0
- package/dist/src/admin/document-integrity-service.d.ts.map +1 -0
- package/dist/src/admin/types.d.ts +30 -0
- package/dist/src/admin/types.d.ts.map +1 -0
- package/dist/src/cache/collection-membership-cache.d.ts +14 -0
- package/dist/src/cache/collection-membership-cache.d.ts.map +1 -0
- package/dist/src/cache/document-meta-cache.d.ts +1 -0
- package/dist/src/cache/document-meta-cache.d.ts.map +1 -1
- package/dist/src/cache/kysely-operation-index.d.ts +11 -2
- package/dist/src/cache/kysely-operation-index.d.ts.map +1 -1
- package/dist/src/cache/kysely-write-cache.d.ts +10 -2
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -1
- package/dist/src/cache/operation-index-types.d.ts +16 -2
- package/dist/src/cache/operation-index-types.d.ts.map +1 -1
- package/dist/src/cache/write/interfaces.d.ts +7 -2
- package/dist/src/cache/write/interfaces.d.ts.map +1 -1
- package/dist/src/client/reactor-client.d.ts +13 -10
- package/dist/src/client/reactor-client.d.ts.map +1 -1
- package/dist/src/client/types.d.ts +25 -6
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.d.ts +23 -10
- package/dist/src/core/reactor-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-client-builder.d.ts +8 -4
- package/dist/src/core/reactor-client-builder.d.ts.map +1 -1
- package/dist/src/core/reactor.d.ts +20 -80
- package/dist/src/core/reactor.d.ts.map +1 -1
- package/dist/src/core/types.d.ts +64 -28
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/utils.d.ts +39 -3
- package/dist/src/core/utils.d.ts.map +1 -1
- package/dist/src/events/types.d.ts +35 -10
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/executor/document-action-handler.d.ts +30 -0
- package/dist/src/executor/document-action-handler.d.ts.map +1 -0
- package/dist/src/executor/execution-scope.d.ts +44 -0
- package/dist/src/executor/execution-scope.d.ts.map +1 -0
- package/dist/src/executor/signature-verifier.d.ts +9 -0
- package/dist/src/executor/signature-verifier.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor-manager.d.ts +6 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor.d.ts +8 -46
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
- package/dist/src/executor/types.d.ts +1 -3
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/util.d.ts +12 -2
- package/dist/src/executor/util.d.ts.map +1 -1
- package/dist/src/index.d.ts +13 -9
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +20501 -61
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts +4 -3
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts.map +1 -1
- package/dist/src/job-tracker/interfaces.d.ts +3 -1
- package/dist/src/job-tracker/interfaces.d.ts.map +1 -1
- package/dist/src/logging/console.d.ts +1 -22
- package/dist/src/logging/console.d.ts.map +1 -1
- package/dist/src/logging/types.d.ts +1 -11
- package/dist/src/logging/types.d.ts.map +1 -1
- package/dist/src/processors/index.d.ts +0 -1
- package/dist/src/processors/index.d.ts.map +1 -1
- package/dist/src/processors/processor-manager.d.ts +19 -6
- package/dist/src/processors/processor-manager.d.ts.map +1 -1
- package/dist/src/processors/utils.d.ts +3 -2
- package/dist/src/processors/utils.d.ts.map +1 -1
- package/dist/src/queue/job-execution-handle.d.ts +3 -0
- package/dist/src/queue/job-execution-handle.d.ts.map +1 -1
- package/dist/src/queue/queue.d.ts +30 -1
- package/dist/src/queue/queue.d.ts.map +1 -1
- package/dist/src/queue/types.d.ts +4 -3
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/read-models/base-read-model.d.ts +11 -9
- package/dist/src/read-models/base-read-model.d.ts.map +1 -1
- package/dist/src/read-models/coordinator.d.ts +2 -2
- package/dist/src/read-models/coordinator.d.ts.map +1 -1
- package/dist/src/read-models/document-view.d.ts +7 -4
- package/dist/src/read-models/document-view.d.ts.map +1 -1
- package/dist/src/read-models/interfaces.d.ts +1 -1
- package/dist/src/read-models/interfaces.d.ts.map +1 -1
- package/dist/src/read-models/types.d.ts +16 -0
- package/dist/src/read-models/types.d.ts.map +1 -1
- package/dist/src/registry/document-model-resolver.d.ts +29 -0
- package/dist/src/registry/document-model-resolver.d.ts.map +1 -0
- package/dist/src/registry/implementation.d.ts +4 -0
- package/dist/src/registry/implementation.d.ts.map +1 -1
- package/dist/src/registry/index.d.ts +3 -1
- package/dist/src/registry/index.d.ts.map +1 -1
- package/dist/src/registry/interfaces.d.ts +8 -0
- package/dist/src/registry/interfaces.d.ts.map +1 -1
- package/dist/src/shared/awaiter.d.ts +2 -2
- package/dist/src/shared/awaiter.d.ts.map +1 -1
- package/dist/src/shared/collect-all-pages.d.ts +7 -0
- package/dist/src/shared/collect-all-pages.d.ts.map +1 -0
- package/dist/src/shared/drive-url.d.ts +15 -0
- package/dist/src/shared/drive-url.d.ts.map +1 -0
- package/dist/src/shared/errors.d.ts +9 -0
- package/dist/src/shared/errors.d.ts.map +1 -1
- package/dist/src/shared/factories.d.ts +6 -2
- package/dist/src/shared/factories.d.ts.map +1 -1
- package/dist/src/shared/types.d.ts +32 -6
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/signer/passthrough-signer.d.ts +1 -1
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -1
- package/dist/src/storage/interfaces.d.ts +252 -124
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/kysely/document-indexer.d.ts +17 -18
- package/dist/src/storage/kysely/document-indexer.d.ts.map +1 -1
- package/dist/src/storage/kysely/keyframe-store.d.ts +10 -1
- package/dist/src/storage/kysely/keyframe-store.d.ts.map +1 -1
- package/dist/src/storage/kysely/store.d.ts +9 -4
- package/dist/src/storage/kysely/store.d.ts.map +1 -1
- package/dist/src/storage/kysely/sync-cursor-storage.d.ts +1 -1
- package/dist/src/storage/kysely/sync-cursor-storage.d.ts.map +1 -1
- package/dist/src/storage/kysely/sync-dead-letter-storage.d.ts +17 -0
- package/dist/src/storage/kysely/sync-dead-letter-storage.d.ts.map +1 -0
- package/dist/src/storage/kysely/types.d.ts +22 -0
- package/dist/src/storage/kysely/types.d.ts.map +1 -1
- package/dist/src/storage/migrations/011_add_cursor_type_column.d.ts +3 -0
- package/dist/src/storage/migrations/011_add_cursor_type_column.d.ts.map +1 -0
- package/dist/src/storage/migrations/012_add_source_remote_column.d.ts +3 -0
- package/dist/src/storage/migrations/012_add_source_remote_column.d.ts.map +1 -0
- package/dist/src/storage/migrations/013_create_sync_dead_letters_table.d.ts +3 -0
- package/dist/src/storage/migrations/013_create_sync_dead_letters_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/014_create_processor_cursor_table.d.ts +3 -0
- package/dist/src/storage/migrations/014_create_processor_cursor_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/migrator.d.ts.map +1 -1
- package/dist/src/subs/default-error-handler.d.ts.map +1 -1
- package/dist/src/subs/subscription-notification-read-model.d.ts +3 -2
- package/dist/src/subs/subscription-notification-read-model.d.ts.map +1 -1
- package/dist/src/sync/batch-aggregator.d.ts +25 -0
- package/dist/src/sync/batch-aggregator.d.ts.map +1 -0
- package/dist/src/sync/buffered-mailbox.d.ts +36 -0
- package/dist/src/sync/buffered-mailbox.d.ts.map +1 -0
- package/dist/src/sync/channels/gql-req-channel.d.ts +121 -0
- package/dist/src/sync/channels/gql-req-channel.d.ts.map +1 -0
- package/dist/src/sync/channels/gql-request-channel-factory.d.ts +32 -0
- package/dist/src/sync/channels/gql-request-channel-factory.d.ts.map +1 -0
- package/dist/src/sync/channels/gql-res-channel.d.ts +31 -0
- package/dist/src/sync/channels/gql-res-channel.d.ts.map +1 -0
- package/dist/src/sync/channels/gql-response-channel-factory.d.ts +13 -0
- package/dist/src/sync/channels/gql-response-channel-factory.d.ts.map +1 -0
- package/dist/src/sync/channels/index.d.ts +6 -4
- package/dist/src/sync/channels/index.d.ts.map +1 -1
- package/dist/src/sync/channels/interval-poll-timer.d.ts +40 -0
- package/dist/src/sync/channels/interval-poll-timer.d.ts.map +1 -0
- package/dist/src/sync/channels/poll-timer.d.ts +14 -0
- package/dist/src/sync/channels/poll-timer.d.ts.map +1 -0
- package/dist/src/sync/channels/utils.d.ts +15 -1
- package/dist/src/sync/channels/utils.d.ts.map +1 -1
- package/dist/src/sync/index.d.ts +11 -7
- package/dist/src/sync/index.d.ts.map +1 -1
- package/dist/src/sync/interfaces.d.ts +42 -19
- package/dist/src/sync/interfaces.d.ts.map +1 -1
- package/dist/src/sync/mailbox.d.ts +51 -12
- package/dist/src/sync/mailbox.d.ts.map +1 -1
- package/dist/src/sync/sync-awaiter.d.ts +34 -0
- package/dist/src/sync/sync-awaiter.d.ts.map +1 -0
- package/dist/src/sync/sync-builder.d.ts +5 -1
- package/dist/src/sync/sync-builder.d.ts.map +1 -1
- package/dist/src/sync/sync-manager.d.ts +22 -8
- package/dist/src/sync/sync-manager.d.ts.map +1 -1
- package/dist/src/sync/sync-operation.d.ts +4 -2
- package/dist/src/sync/sync-operation.d.ts.map +1 -1
- package/dist/src/sync/sync-status-tracker.d.ts +31 -0
- package/dist/src/sync/sync-status-tracker.d.ts.map +1 -0
- package/dist/src/sync/types.d.ts +107 -2
- package/dist/src/sync/types.d.ts.map +1 -1
- package/dist/src/sync/utils.d.ts +37 -2
- package/dist/src/sync/utils.d.ts.map +1 -1
- package/dist/src/utils/reshuffle.d.ts +22 -5
- package/dist/src/utils/reshuffle.d.ts.map +1 -1
- package/package.json +24 -20
- package/dist/src/actions/index.js +0 -76
- package/dist/src/actions/index.js.map +0 -1
- package/dist/src/cache/buffer/ring-buffer.js +0 -69
- package/dist/src/cache/buffer/ring-buffer.js.map +0 -1
- package/dist/src/cache/document-meta-cache-types.js +0 -2
- package/dist/src/cache/document-meta-cache-types.js.map +0 -1
- package/dist/src/cache/document-meta-cache.js +0 -128
- package/dist/src/cache/document-meta-cache.js.map +0 -1
- package/dist/src/cache/index.js +0 -2
- package/dist/src/cache/index.js.map +0 -1
- package/dist/src/cache/kysely-operation-index.js +0 -250
- package/dist/src/cache/kysely-operation-index.js.map +0 -1
- package/dist/src/cache/kysely-write-cache.js +0 -388
- package/dist/src/cache/kysely-write-cache.js.map +0 -1
- package/dist/src/cache/lru/lru-tracker.js +0 -96
- package/dist/src/cache/lru/lru-tracker.js.map +0 -1
- package/dist/src/cache/operation-index-types.js +0 -4
- package/dist/src/cache/operation-index-types.js.map +0 -1
- package/dist/src/cache/write/interfaces.js +0 -2
- package/dist/src/cache/write/interfaces.js.map +0 -1
- package/dist/src/cache/write-cache-types.js +0 -2
- package/dist/src/cache/write-cache-types.js.map +0 -1
- package/dist/src/client/reactor-client.js +0 -406
- package/dist/src/client/reactor-client.js.map +0 -1
- package/dist/src/client/types.js +0 -14
- package/dist/src/client/types.js.map +0 -1
- package/dist/src/core/reactor-builder.js +0 -231
- package/dist/src/core/reactor-builder.js.map +0 -1
- package/dist/src/core/reactor-client-builder.js +0 -123
- package/dist/src/core/reactor-client-builder.js.map +0 -1
- package/dist/src/core/reactor.js +0 -981
- package/dist/src/core/reactor.js.map +0 -1
- package/dist/src/core/types.js +0 -2
- package/dist/src/core/types.js.map +0 -1
- package/dist/src/core/utils.js +0 -171
- package/dist/src/core/utils.js.map +0 -1
- package/dist/src/events/event-bus.js +0 -53
- package/dist/src/events/event-bus.js.map +0 -1
- package/dist/src/events/interfaces.js +0 -2
- package/dist/src/events/interfaces.js.map +0 -1
- package/dist/src/events/types.js +0 -28
- package/dist/src/events/types.js.map +0 -1
- package/dist/src/executor/interfaces.js +0 -2
- package/dist/src/executor/interfaces.js.map +0 -1
- package/dist/src/executor/simple-job-executor-manager.js +0 -233
- package/dist/src/executor/simple-job-executor-manager.js.map +0 -1
- package/dist/src/executor/simple-job-executor.js +0 -898
- package/dist/src/executor/simple-job-executor.js.map +0 -1
- package/dist/src/executor/types.js +0 -11
- package/dist/src/executor/types.js.map +0 -1
- package/dist/src/executor/util.js +0 -184
- package/dist/src/executor/util.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/job-tracker/in-memory-job-tracker.js +0 -112
- package/dist/src/job-tracker/in-memory-job-tracker.js.map +0 -1
- package/dist/src/job-tracker/index.js +0 -2
- package/dist/src/job-tracker/index.js.map +0 -1
- package/dist/src/job-tracker/interfaces.js +0 -2
- package/dist/src/job-tracker/interfaces.js.map +0 -1
- package/dist/src/logging/console.js +0 -108
- package/dist/src/logging/console.js.map +0 -1
- package/dist/src/logging/types.js +0 -2
- package/dist/src/logging/types.js.map +0 -1
- package/dist/src/processors/index.js +0 -2
- package/dist/src/processors/index.js.map +0 -1
- package/dist/src/processors/processor-manager.js +0 -165
- package/dist/src/processors/processor-manager.js.map +0 -1
- package/dist/src/processors/types.d.ts +0 -63
- package/dist/src/processors/types.d.ts.map +0 -1
- package/dist/src/processors/types.js +0 -2
- package/dist/src/processors/types.js.map +0 -1
- package/dist/src/processors/utils.js +0 -58
- package/dist/src/processors/utils.js.map +0 -1
- package/dist/src/queue/interfaces.js +0 -2
- package/dist/src/queue/interfaces.js.map +0 -1
- package/dist/src/queue/job-execution-handle.js +0 -62
- package/dist/src/queue/job-execution-handle.js.map +0 -1
- package/dist/src/queue/queue.js +0 -384
- package/dist/src/queue/queue.js.map +0 -1
- package/dist/src/queue/types.js +0 -19
- package/dist/src/queue/types.js.map +0 -1
- package/dist/src/read-models/base-read-model.js +0 -143
- package/dist/src/read-models/base-read-model.js.map +0 -1
- package/dist/src/read-models/coordinator.js +0 -72
- package/dist/src/read-models/coordinator.js.map +0 -1
- package/dist/src/read-models/document-view.js +0 -375
- package/dist/src/read-models/document-view.js.map +0 -1
- package/dist/src/read-models/interfaces.js +0 -2
- package/dist/src/read-models/interfaces.js.map +0 -1
- package/dist/src/read-models/types.js +0 -2
- package/dist/src/read-models/types.js.map +0 -1
- package/dist/src/registry/implementation.js +0 -216
- package/dist/src/registry/implementation.js.map +0 -1
- package/dist/src/registry/index.js +0 -2
- package/dist/src/registry/index.js.map +0 -1
- package/dist/src/registry/interfaces.js +0 -2
- package/dist/src/registry/interfaces.js.map +0 -1
- package/dist/src/shared/awaiter.js +0 -123
- package/dist/src/shared/awaiter.js.map +0 -1
- package/dist/src/shared/consistency-tracker.js +0 -123
- package/dist/src/shared/consistency-tracker.js.map +0 -1
- package/dist/src/shared/errors.js +0 -75
- package/dist/src/shared/errors.js.map +0 -1
- package/dist/src/shared/factories.js +0 -33
- package/dist/src/shared/factories.js.map +0 -1
- package/dist/src/shared/types.js +0 -38
- package/dist/src/shared/types.js.map +0 -1
- package/dist/src/shared/utils.js +0 -8
- package/dist/src/shared/utils.js.map +0 -1
- package/dist/src/signer/passthrough-signer.js +0 -19
- package/dist/src/signer/passthrough-signer.js.map +0 -1
- package/dist/src/signer/types.js +0 -2
- package/dist/src/signer/types.js.map +0 -1
- package/dist/src/storage/consistency-aware-legacy-storage.d.ts +0 -33
- package/dist/src/storage/consistency-aware-legacy-storage.d.ts.map +0 -1
- package/dist/src/storage/consistency-aware-legacy-storage.js +0 -65
- package/dist/src/storage/consistency-aware-legacy-storage.js.map +0 -1
- package/dist/src/storage/index.js +0 -3
- package/dist/src/storage/index.js.map +0 -1
- package/dist/src/storage/interfaces.js +0 -19
- package/dist/src/storage/interfaces.js.map +0 -1
- package/dist/src/storage/kysely/document-indexer.js +0 -350
- package/dist/src/storage/kysely/document-indexer.js.map +0 -1
- package/dist/src/storage/kysely/keyframe-store.js +0 -64
- package/dist/src/storage/kysely/keyframe-store.js.map +0 -1
- package/dist/src/storage/kysely/store.js +0 -233
- package/dist/src/storage/kysely/store.js.map +0 -1
- package/dist/src/storage/kysely/sync-cursor-storage.js +0 -93
- package/dist/src/storage/kysely/sync-cursor-storage.js.map +0 -1
- package/dist/src/storage/kysely/sync-remote-storage.js +0 -133
- package/dist/src/storage/kysely/sync-remote-storage.js.map +0 -1
- package/dist/src/storage/kysely/types.js +0 -2
- package/dist/src/storage/kysely/types.js.map +0 -1
- package/dist/src/storage/migrations/001_create_operation_table.js +0 -41
- package/dist/src/storage/migrations/001_create_operation_table.js.map +0 -1
- package/dist/src/storage/migrations/002_create_keyframe_table.js +0 -27
- package/dist/src/storage/migrations/002_create_keyframe_table.js.map +0 -1
- package/dist/src/storage/migrations/003_create_document_table.js +0 -10
- package/dist/src/storage/migrations/003_create_document_table.js.map +0 -1
- package/dist/src/storage/migrations/004_create_document_relationship_table.js +0 -35
- package/dist/src/storage/migrations/004_create_document_relationship_table.js.map +0 -1
- package/dist/src/storage/migrations/005_create_indexer_state_table.js +0 -10
- package/dist/src/storage/migrations/005_create_indexer_state_table.js.map +0 -1
- package/dist/src/storage/migrations/006_create_document_snapshot_table.js +0 -49
- package/dist/src/storage/migrations/006_create_document_snapshot_table.js.map +0 -1
- package/dist/src/storage/migrations/007_create_slug_mapping_table.js +0 -24
- package/dist/src/storage/migrations/007_create_slug_mapping_table.js.map +0 -1
- package/dist/src/storage/migrations/008_create_view_state_table.js +0 -10
- package/dist/src/storage/migrations/008_create_view_state_table.js.map +0 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js +0 -50
- package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +0 -1
- package/dist/src/storage/migrations/010_create_sync_tables.js +0 -43
- package/dist/src/storage/migrations/010_create_sync_tables.js.map +0 -1
- package/dist/src/storage/migrations/index.js +0 -3
- package/dist/src/storage/migrations/index.js.map +0 -1
- package/dist/src/storage/migrations/migrator.js +0 -78
- package/dist/src/storage/migrations/migrator.js.map +0 -1
- package/dist/src/storage/migrations/run-migrations.js +0 -58
- package/dist/src/storage/migrations/run-migrations.js.map +0 -1
- package/dist/src/storage/migrations/types.js +0 -2
- package/dist/src/storage/migrations/types.js.map +0 -1
- package/dist/src/storage/txn.js +0 -42
- package/dist/src/storage/txn.js.map +0 -1
- package/dist/src/subs/default-error-handler.js +0 -27
- package/dist/src/subs/default-error-handler.js.map +0 -1
- package/dist/src/subs/react-subscription-manager.js +0 -185
- package/dist/src/subs/react-subscription-manager.js.map +0 -1
- package/dist/src/subs/subscription-notification-read-model.js +0 -62
- package/dist/src/subs/subscription-notification-read-model.js.map +0 -1
- package/dist/src/subs/types.js +0 -2
- package/dist/src/subs/types.js.map +0 -1
- package/dist/src/sync/channels/composite-channel-factory.d.ts +0 -30
- package/dist/src/sync/channels/composite-channel-factory.d.ts.map +0 -1
- package/dist/src/sync/channels/composite-channel-factory.js +0 -87
- package/dist/src/sync/channels/composite-channel-factory.js.map +0 -1
- package/dist/src/sync/channels/gql-channel-factory.d.ts +0 -25
- package/dist/src/sync/channels/gql-channel-factory.d.ts.map +0 -1
- package/dist/src/sync/channels/gql-channel-factory.js +0 -76
- package/dist/src/sync/channels/gql-channel-factory.js.map +0 -1
- package/dist/src/sync/channels/gql-channel.d.ts +0 -118
- package/dist/src/sync/channels/gql-channel.d.ts.map +0 -1
- package/dist/src/sync/channels/gql-channel.js +0 -423
- package/dist/src/sync/channels/gql-channel.js.map +0 -1
- package/dist/src/sync/channels/index.js +0 -6
- package/dist/src/sync/channels/index.js.map +0 -1
- package/dist/src/sync/channels/polling-channel.d.ts +0 -39
- package/dist/src/sync/channels/polling-channel.d.ts.map +0 -1
- package/dist/src/sync/channels/polling-channel.js +0 -72
- package/dist/src/sync/channels/polling-channel.js.map +0 -1
- package/dist/src/sync/channels/utils.js +0 -96
- package/dist/src/sync/channels/utils.js.map +0 -1
- package/dist/src/sync/errors.js +0 -17
- package/dist/src/sync/errors.js.map +0 -1
- package/dist/src/sync/index.js +0 -9
- package/dist/src/sync/index.js.map +0 -1
- package/dist/src/sync/interfaces.js +0 -2
- package/dist/src/sync/interfaces.js.map +0 -1
- package/dist/src/sync/mailbox.js +0 -59
- package/dist/src/sync/mailbox.js.map +0 -1
- package/dist/src/sync/sync-builder.js +0 -39
- package/dist/src/sync/sync-builder.js.map +0 -1
- package/dist/src/sync/sync-manager.js +0 -266
- package/dist/src/sync/sync-manager.js.map +0 -1
- package/dist/src/sync/sync-operation.js +0 -63
- package/dist/src/sync/sync-operation.js.map +0 -1
- package/dist/src/sync/types.js +0 -16
- package/dist/src/sync/types.js.map +0 -1
- package/dist/src/sync/utils.js +0 -78
- package/dist/src/sync/utils.js.map +0 -1
- package/dist/src/utils/reshuffle.js +0 -47
- package/dist/src/utils/reshuffle.js.map +0 -1
|
@@ -1,5 +1,18 @@
|
|
|
1
|
+
import type { Action } from "document-model";
|
|
1
2
|
import { SyncOperation } from "../sync-operation.js";
|
|
2
|
-
import type
|
|
3
|
+
import { type SyncEnvelope } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Serializes an action for GraphQL transport, converting signature tuples to strings.
|
|
6
|
+
*/
|
|
7
|
+
export declare function serializeAction(action: Action): unknown;
|
|
8
|
+
/**
|
|
9
|
+
* Serializes a SyncEnvelope for GraphQL transport.
|
|
10
|
+
*
|
|
11
|
+
* Signatures are serialized as comma-separated strings since GraphQL schema
|
|
12
|
+
* defines them as [String!]!. The resultingState context field is stripped
|
|
13
|
+
* since it is not defined in OperationContextInput.
|
|
14
|
+
*/
|
|
15
|
+
export declare function serializeEnvelope(envelope: SyncEnvelope): unknown;
|
|
3
16
|
/**
|
|
4
17
|
* Converts a SyncEnvelope containing operations into a SyncOperation.
|
|
5
18
|
*
|
|
@@ -27,4 +40,5 @@ export declare function envelopeToSyncOperation(envelope: SyncEnvelope, remoteNa
|
|
|
27
40
|
* causality across documents.
|
|
28
41
|
*/
|
|
29
42
|
export declare function envelopesToSyncOperations(envelope: SyncEnvelope, remoteName: string): SyncOperation[];
|
|
43
|
+
export declare const getLatestAppliedOrdinal: (syncOps: SyncOperation[]) => number;
|
|
30
44
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAwB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAuB,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAKrE;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAkBvD;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CA0BjE;AAmDD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,MAAM,GACjB,aAAa,CA6Bf;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,MAAM,GACjB,aAAa,EAAE,CAuBjB;AAED,eAAO,MAAM,uBAAuB,GAAI,SAAS,aAAa,EAAE,KAAG,MAUlE,CAAC"}
|
package/dist/src/sync/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
export type { IChannel, IChannelFactory, ISyncManager, Remote, } from "./interfaces.js";
|
|
1
|
+
export type { ConnectionStateChangeCallback, IChannel, IChannelFactory, ISyncManager, Remote, } from "./interfaces.js";
|
|
2
2
|
export type { ShutdownStatus } from "../shared/types.js";
|
|
3
|
-
export type { ChannelConfig, ChannelHealth,
|
|
4
|
-
export { ChannelErrorSource, SyncOperationStatus } from "./types.js";
|
|
3
|
+
export type { ChannelConfig, ChannelHealth, ChannelMeta, ConnectionState, ConnectionStateChangedEvent, ConnectionStateSnapshot, DeadLetterAddedEvent, JwtHandler, RemoteCursor, RemoteFilter, RemoteOptions, RemoteRecord, RemoteStatus, SyncEnvelope, SyncEnvelopeType, SyncFailedEvent, SyncOperationErrorType, SyncPendingEvent, SyncResult, SyncResultError, SyncResultStatus, SyncSucceededEvent, } from "./types.js";
|
|
4
|
+
export { ChannelErrorSource, ChannelScheme, SyncEventTypes, SyncOperationStatus, } from "./types.js";
|
|
5
|
+
export { BufferedMailbox } from "./buffered-mailbox.js";
|
|
6
|
+
export { Mailbox, type IMailbox } from "./mailbox.js";
|
|
5
7
|
export { SyncOperation, SyncOperationAggregateError, } from "./sync-operation.js";
|
|
6
|
-
export { Mailbox, type MailboxItem } from "./mailbox.js";
|
|
7
8
|
export { ChannelError, PollingChannelError } from "./errors.js";
|
|
8
|
-
export {
|
|
9
|
-
export { SyncManager } from "./sync-manager.js";
|
|
9
|
+
export { GqlRequestChannel, GqlRequestChannelFactory, GqlResponseChannel, GqlResponseChannelFactory, IntervalPollTimer, type GqlChannelConfig, type IPollTimer, } from "./channels/index.js";
|
|
10
10
|
export { SyncBuilder } from "./sync-builder.js";
|
|
11
|
-
export {
|
|
11
|
+
export { SyncManager } from "./sync-manager.js";
|
|
12
|
+
export { SyncStatus, SyncStatusTracker } from "./sync-status-tracker.js";
|
|
13
|
+
export type { ISyncStatusTracker, SyncStatusChangeCallback, } from "./sync-status-tracker.js";
|
|
14
|
+
export { batchOperationsByDocument, consolidateSyncOperations, createIdleHealth, filterOperations, sortEnvelopesByFirstOperationTimestamp, trimMailboxFromAckOrdinal, } from "./utils.js";
|
|
15
|
+
export type { OperationBatch } from "./utils.js";
|
|
12
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sync/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,MAAM,GACP,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,YAAY,EACV,aAAa,EACb,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"index.d.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AAO,EACL,yBAAyB,EACzB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,sCAAsC,EACtC,yBAAyB,GAC1B,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { IOperationIndex } from "../cache/operation-index-types.js";
|
|
1
2
|
import type { ShutdownStatus } from "../shared/types.js";
|
|
2
3
|
import type { ISyncCursorStorage } from "../storage/interfaces.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { ChannelConfig, RemoteFilter, RemoteOptions } from "./types.js";
|
|
4
|
+
import type { IMailbox } from "./mailbox.js";
|
|
5
|
+
import type { SyncStatus, SyncStatusChangeCallback } from "./sync-status-tracker.js";
|
|
6
|
+
import type { ChannelConfig, ConnectionStateSnapshot, RemoteFilter, RemoteOptions, SyncResult } from "./types.js";
|
|
6
7
|
/**
|
|
7
8
|
* Represents a bidirectional synchronization channel between two reactor instances.
|
|
8
9
|
*
|
|
@@ -10,29 +11,24 @@ import type { ChannelConfig, RemoteFilter, RemoteOptions } from "./types.js";
|
|
|
10
11
|
* - inbox: Sync operations received from the remote that need to be applied locally
|
|
11
12
|
* - outbox: Sync operations to be sent to the remote
|
|
12
13
|
* - deadLetter: Sync operations that failed and cannot be retried
|
|
13
|
-
*
|
|
14
|
-
* Channels are responsible for:
|
|
15
|
-
* - Transporting sync envelopes between reactor instances
|
|
16
|
-
* - Managing sync operation lifecycle through status transitions
|
|
17
|
-
* - Handling errors and moving failed sync operations to dead letter queue
|
|
18
|
-
* - Updating cursors as operations are applied
|
|
19
14
|
*/
|
|
15
|
+
export type ConnectionStateChangeCallback = (snapshot: ConnectionStateSnapshot) => void;
|
|
20
16
|
export interface IChannel {
|
|
21
17
|
/**
|
|
22
18
|
* Mailbox containing sync operations received from the remote that need to be applied locally.
|
|
23
19
|
* Consumers should register callbacks via onAdded to process incoming sync operations.
|
|
24
20
|
*/
|
|
25
|
-
inbox:
|
|
21
|
+
inbox: IMailbox;
|
|
26
22
|
/**
|
|
27
23
|
* Mailbox containing sync operations that need to be sent to the remote.
|
|
28
24
|
* The channel is responsible for transporting these sync operations and handling ACKs.
|
|
29
25
|
*/
|
|
30
|
-
outbox:
|
|
26
|
+
outbox: IMailbox;
|
|
31
27
|
/**
|
|
32
28
|
* Mailbox containing sync operations that failed and cannot be retried.
|
|
33
29
|
* These sync operations require manual intervention or should be logged for debugging.
|
|
34
30
|
*/
|
|
35
|
-
deadLetter:
|
|
31
|
+
deadLetter: IMailbox;
|
|
36
32
|
/**
|
|
37
33
|
* Initializes the channel asynchronously.
|
|
38
34
|
* For remote channels, this typically involves registering the channel on the remote server.
|
|
@@ -42,14 +38,16 @@ export interface IChannel {
|
|
|
42
38
|
/**
|
|
43
39
|
* Shuts down the channel and prevents further operations.
|
|
44
40
|
*/
|
|
45
|
-
shutdown(): void
|
|
41
|
+
shutdown(): Promise<void>;
|
|
46
42
|
/**
|
|
47
|
-
*
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
* Returns the current connection state snapshot.
|
|
44
|
+
*/
|
|
45
|
+
getConnectionState(): ConnectionStateSnapshot;
|
|
46
|
+
/**
|
|
47
|
+
* Registers a callback that fires when the connection state changes.
|
|
48
|
+
* Returns an unsubscribe function.
|
|
51
49
|
*/
|
|
52
|
-
|
|
50
|
+
onConnectionStateChange(callback: ConnectionStateChangeCallback): () => void;
|
|
53
51
|
}
|
|
54
52
|
/**
|
|
55
53
|
* Factory for creating channel instances.
|
|
@@ -67,9 +65,10 @@ export interface IChannelFactory {
|
|
|
67
65
|
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
68
66
|
* @param collectionId - Collection ID to synchronize
|
|
69
67
|
* @param filter - Filter to apply to operations
|
|
68
|
+
* @param operationIndex - Operation index for querying timestamps
|
|
70
69
|
* @returns A new channel instance
|
|
71
70
|
*/
|
|
72
|
-
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage, collectionId: string, filter: RemoteFilter): IChannel;
|
|
71
|
+
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage, collectionId: string, filter: RemoteFilter, operationIndex: IOperationIndex): IChannel;
|
|
73
72
|
}
|
|
74
73
|
/**
|
|
75
74
|
* Represents a configured remote with an active channel.
|
|
@@ -176,5 +175,29 @@ export interface ISyncManager {
|
|
|
176
175
|
* @returns Array of all remotes
|
|
177
176
|
*/
|
|
178
177
|
list(): Remote[];
|
|
178
|
+
/**
|
|
179
|
+
* Waits for sync operations for a job to complete.
|
|
180
|
+
* Resolves when SYNC_SUCCEEDED is emitted.
|
|
181
|
+
* Rejects when SYNC_FAILED is emitted.
|
|
182
|
+
*
|
|
183
|
+
* @param jobId - The job id to wait for
|
|
184
|
+
* @param signal - Optional abort signal
|
|
185
|
+
* @returns The sync result
|
|
186
|
+
*/
|
|
187
|
+
waitForSync(jobId: string, signal?: AbortSignal): Promise<SyncResult>;
|
|
188
|
+
/**
|
|
189
|
+
* Gets the current sync status for a document.
|
|
190
|
+
*
|
|
191
|
+
* @param documentId - The document ID to check
|
|
192
|
+
* @returns The sync status, or undefined if the document has never been tracked
|
|
193
|
+
*/
|
|
194
|
+
getSyncStatus(documentId: string): SyncStatus | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* Registers a callback that fires when a document's sync status changes.
|
|
197
|
+
*
|
|
198
|
+
* @param callback - Called with (documentId, newStatus) on each transition
|
|
199
|
+
* @returns Unsubscribe function
|
|
200
|
+
*/
|
|
201
|
+
onSyncStatusChange(callback: SyncStatusChangeCallback): () => void;
|
|
179
202
|
}
|
|
180
203
|
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/sync/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oB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O,CAAC,UAAU,CAAC,CAAC;IAEtE;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAE1D;;;;;OAKG;IACH,kBAAkB,CAAC,QAAQ,EAAE,wBAAwB,GAAG,MAAM,IAAI,CAAC;CACpE"}
|
|
@@ -1,21 +1,60 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { SyncOperation } from "./sync-operation.js";
|
|
2
|
+
export type MailboxCallback = (items: SyncOperation[]) => void;
|
|
3
|
+
/**
|
|
4
|
+
* The Mailbox interface is not intended to use any persistence. Instead, the
|
|
5
|
+
* IChannel implementation is responsible for persisting cursors or other data.
|
|
6
|
+
*
|
|
7
|
+
* This means that ackOrdinal and latestOrdinal are in memory only.
|
|
8
|
+
*/
|
|
9
|
+
export interface IMailbox {
|
|
10
|
+
get items(): ReadonlyArray<SyncOperation>;
|
|
11
|
+
/**
|
|
12
|
+
* The latest ordinal that has been acknowledged. Because acknowledged items
|
|
13
|
+
* are removed from the mailbox, this is the last ordinal that has been removed.
|
|
14
|
+
*/
|
|
15
|
+
get ackOrdinal(): number;
|
|
16
|
+
/**
|
|
17
|
+
* The latest ordinal of the items that are or have been added to the mailbox.
|
|
18
|
+
* This may be greater than the ack ordinal if items have been added but not
|
|
19
|
+
* yet acknowledged.
|
|
20
|
+
*/
|
|
21
|
+
get latestOrdinal(): number;
|
|
22
|
+
init(ackOrdinal: number): void;
|
|
23
|
+
get(id: string): SyncOperation | undefined;
|
|
24
|
+
add(...items: SyncOperation[]): void;
|
|
25
|
+
remove(...items: SyncOperation[]): void;
|
|
26
|
+
onAdded(callback: MailboxCallback): void;
|
|
27
|
+
onRemoved(callback: MailboxCallback): void;
|
|
28
|
+
pause(): void;
|
|
29
|
+
resume(): void;
|
|
30
|
+
flush(): void;
|
|
31
|
+
isPaused(): boolean;
|
|
32
|
+
}
|
|
5
33
|
export declare class MailboxAggregateError extends Error {
|
|
6
34
|
errors: Error[];
|
|
7
35
|
constructor(errors: Error[]);
|
|
8
36
|
}
|
|
9
|
-
export declare class Mailbox
|
|
37
|
+
export declare class Mailbox implements IMailbox {
|
|
10
38
|
private itemsMap;
|
|
11
39
|
private addedCallbacks;
|
|
12
40
|
private removedCallbacks;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
41
|
+
private paused;
|
|
42
|
+
private addedBuffer;
|
|
43
|
+
private removedBuffer;
|
|
44
|
+
private _ack;
|
|
45
|
+
private _latestOrdinal;
|
|
46
|
+
init(ackOrdinal: number): void;
|
|
47
|
+
get items(): ReadonlyArray<SyncOperation>;
|
|
48
|
+
get ackOrdinal(): number;
|
|
49
|
+
get latestOrdinal(): number;
|
|
50
|
+
get(id: string): SyncOperation | undefined;
|
|
51
|
+
add(...items: SyncOperation[]): void;
|
|
52
|
+
remove(...items: SyncOperation[]): void;
|
|
53
|
+
onAdded(callback: MailboxCallback): void;
|
|
54
|
+
onRemoved(callback: MailboxCallback): void;
|
|
55
|
+
pause(): void;
|
|
56
|
+
resume(): void;
|
|
57
|
+
flush(): void;
|
|
58
|
+
isPaused(): boolean;
|
|
19
59
|
}
|
|
20
|
-
export {};
|
|
21
60
|
//# sourceMappingURL=mailbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mailbox.d.ts","sourceRoot":"","sources":["../../../src/sync/mailbox.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"mailbox.d.ts","sourceRoot":"","sources":["../../../src/sync/mailbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGzD,MAAM,MAAM,eAAe,GAAG,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,QAAQ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EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAI1C,GAAG,CAAC,GAAG,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI;IAsCpC,MAAM,CAAC,GAAG,KAAK,EAAE,aAAa,EAAE,GAAG,IAAI;IAwBvC,OAAO,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAIxC,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAI1C,KAAK,IAAI,IAAI;IAIb,MAAM,IAAI,IAAI;IAKd,KAAK,IAAI,IAAI;IAsCb,QAAQ,IAAI,OAAO;CAGpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { IEventBus } from "../events/interfaces.js";
|
|
2
|
+
import { type SyncResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Provides a promise-based interface for waiting on sync completion.
|
|
5
|
+
* Subscribes to sync events at construction and tracks completed sync results
|
|
6
|
+
* to provide a fast path for jobs that have already synced.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SyncAwaiter {
|
|
9
|
+
private readonly eventBus;
|
|
10
|
+
private readonly completedResults;
|
|
11
|
+
private readonly pendingWaiters;
|
|
12
|
+
private readonly unsubscribers;
|
|
13
|
+
private isShutdown;
|
|
14
|
+
constructor(eventBus: IEventBus);
|
|
15
|
+
/**
|
|
16
|
+
* Waits for sync operations for a job to complete.
|
|
17
|
+
* Resolves when SYNC_SUCCEEDED is emitted.
|
|
18
|
+
* Rejects when SYNC_FAILED is emitted.
|
|
19
|
+
*
|
|
20
|
+
* @param jobId - The job id to wait for
|
|
21
|
+
* @param signal - Optional abort signal
|
|
22
|
+
* @returns The sync result
|
|
23
|
+
*/
|
|
24
|
+
waitForSync(jobId: string, signal?: AbortSignal): Promise<SyncResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Shuts down the sync awaiter. This will synchronously reject all pending waiters.
|
|
27
|
+
*/
|
|
28
|
+
shutdown(): void;
|
|
29
|
+
private subscribeToEvents;
|
|
30
|
+
private handleSyncSucceeded;
|
|
31
|
+
private handleSyncFailed;
|
|
32
|
+
private resolveWaiters;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=sync-awaiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-awaiter.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-awaiter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAGL,KAAK,UAAU,EAEhB,MAAM,YAAY,CAAC;AAQpB;;;;GAIG;AACH,qBAAa,WAAW;IAMV,OAAO,CAAC,QAAQ,CAAC,QAAQ;IALrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAiC;IAClE,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAmC;IAClE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqB;IACnD,OAAO,CAAC,UAAU,CAAS;gBAEE,QAAQ,EAAE,SAAS;IAIhD;;;;;;;;OAQG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAyCrE;;OAEG;IACH,QAAQ,IAAI,IAAI;IAgBhB,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,gBAAgB;IAcxB,OAAO,CAAC,cAAc;CAgBvB"}
|
|
@@ -3,16 +3,20 @@ import type { IOperationIndex } from "../cache/operation-index-types.js";
|
|
|
3
3
|
import type { IReactor, SyncModule } from "../core/types.js";
|
|
4
4
|
import type { IEventBus } from "../events/interfaces.js";
|
|
5
5
|
import type { ILogger } from "../logging/types.js";
|
|
6
|
-
import type { ISyncCursorStorage, ISyncRemoteStorage } from "../storage/interfaces.js";
|
|
6
|
+
import type { ISyncCursorStorage, ISyncDeadLetterStorage, ISyncRemoteStorage } from "../storage/interfaces.js";
|
|
7
7
|
import type { Database } from "../storage/kysely/types.js";
|
|
8
8
|
import type { IChannelFactory, ISyncManager } from "./interfaces.js";
|
|
9
9
|
export declare class SyncBuilder {
|
|
10
10
|
private channelFactory?;
|
|
11
11
|
private remoteStorage?;
|
|
12
12
|
private cursorStorage?;
|
|
13
|
+
private deadLetterStorage?;
|
|
14
|
+
private maxDeadLettersPerRemote;
|
|
13
15
|
withChannelFactory(factory: IChannelFactory): this;
|
|
14
16
|
withRemoteStorage(storage: ISyncRemoteStorage): this;
|
|
15
17
|
withCursorStorage(storage: ISyncCursorStorage): this;
|
|
18
|
+
withDeadLetterStorage(storage: ISyncDeadLetterStorage): this;
|
|
19
|
+
withMaxDeadLettersPerRemote(limit: number): this;
|
|
16
20
|
build(reactor: IReactor, logger: ILogger, operationIndex: IOperationIndex, eventBus: IEventBus, db: Kysely<Database>): ISyncManager;
|
|
17
21
|
buildModule(reactor: IReactor, logger: ILogger, operationIndex: IOperationIndex, eventBus: IEventBus, db: Kysely<Database>): SyncModule;
|
|
18
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-builder.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"sync-builder.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,M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E,EAAE,MAAM,CAAC,QAAQ,CAAC,GACnB,UAAU;CA8Bd"}
|
|
@@ -3,35 +3,49 @@ import type { IReactor } from "../core/types.js";
|
|
|
3
3
|
import type { IEventBus } from "../events/interfaces.js";
|
|
4
4
|
import type { ILogger } from "../logging/types.js";
|
|
5
5
|
import { type JobInfo, type ShutdownStatus } from "../shared/types.js";
|
|
6
|
-
import type { ISyncCursorStorage, ISyncRemoteStorage } from "../storage/interfaces.js";
|
|
6
|
+
import type { ISyncCursorStorage, ISyncDeadLetterStorage, ISyncRemoteStorage } from "../storage/interfaces.js";
|
|
7
7
|
import type { IChannelFactory, ISyncManager, Remote } from "./interfaces.js";
|
|
8
|
-
import
|
|
8
|
+
import { type SyncStatus, type SyncStatusChangeCallback } from "./sync-status-tracker.js";
|
|
9
|
+
import type { ChannelConfig, RemoteFilter, RemoteOptions, SyncResult } from "./types.js";
|
|
9
10
|
export declare class SyncManager implements ISyncManager {
|
|
10
11
|
private readonly logger;
|
|
11
12
|
private readonly remoteStorage;
|
|
12
13
|
private readonly cursorStorage;
|
|
14
|
+
private readonly deadLetterStorage;
|
|
13
15
|
private readonly channelFactory;
|
|
14
|
-
private readonly
|
|
16
|
+
private readonly operationIndex;
|
|
15
17
|
private readonly reactor;
|
|
16
18
|
private readonly eventBus;
|
|
17
19
|
private readonly remotes;
|
|
18
20
|
private readonly awaiter;
|
|
21
|
+
private readonly syncAwaiter;
|
|
19
22
|
private isShutdown;
|
|
20
23
|
private eventUnsubscribe?;
|
|
24
|
+
private failedEventUnsubscribe?;
|
|
25
|
+
private readonly batchAggregator;
|
|
26
|
+
private readonly syncStatusTracker;
|
|
27
|
+
private readonly maxDeadLettersPerRemote;
|
|
28
|
+
private readonly connectionStateUnsubscribes;
|
|
21
29
|
loadJobs: Map<string, JobInfo>;
|
|
22
|
-
constructor(logger: ILogger, remoteStorage: ISyncRemoteStorage, cursorStorage: ISyncCursorStorage, channelFactory: IChannelFactory, operationIndex: IOperationIndex, reactor: IReactor, eventBus: IEventBus);
|
|
30
|
+
constructor(logger: ILogger, remoteStorage: ISyncRemoteStorage, cursorStorage: ISyncCursorStorage, deadLetterStorage: ISyncDeadLetterStorage, channelFactory: IChannelFactory, operationIndex: IOperationIndex, reactor: IReactor, eventBus: IEventBus, maxDeadLettersPerRemote?: number);
|
|
23
31
|
startup(): Promise<void>;
|
|
24
32
|
shutdown(): ShutdownStatus;
|
|
25
33
|
getByName(name: string): Remote;
|
|
26
34
|
getById(id: string): Remote;
|
|
27
35
|
add(name: string, collectionId: string, channelConfig: ChannelConfig, filter?: RemoteFilter, options?: RemoteOptions, id?: string): Promise<Remote>;
|
|
28
|
-
private backfillOutbox;
|
|
29
36
|
remove(name: string): Promise<void>;
|
|
30
37
|
list(): Remote[];
|
|
38
|
+
waitForSync(jobId: string, signal?: AbortSignal): Promise<SyncResult>;
|
|
39
|
+
getSyncStatus(documentId: string): SyncStatus | undefined;
|
|
40
|
+
onSyncStatusChange(callback: SyncStatusChangeCallback): () => void;
|
|
31
41
|
private wireChannelCallbacks;
|
|
32
|
-
private
|
|
33
|
-
private
|
|
34
|
-
private
|
|
42
|
+
private loadDeadLetters;
|
|
43
|
+
private getRemotesForCollection;
|
|
44
|
+
private processCompleteBatch;
|
|
45
|
+
private handleInboxAdded;
|
|
35
46
|
private applyInboxJob;
|
|
47
|
+
private applyInboxBatch;
|
|
48
|
+
private updateOutbox;
|
|
49
|
+
private getOperationsForRemote;
|
|
36
50
|
}
|
|
37
51
|
//# sourceMappingURL=sync-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-manager.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-manager.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,KAAK,EAGV,QAAQ,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gB;YAyBV,aAAa;YA0Eb,eAAe;YAgFf,YAAY;YAiDZ,sBAAsB;CAyBrC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OperationWithContext } from "
|
|
1
|
+
import type { OperationWithContext } from "@powerhousedao/shared/document-model";
|
|
2
2
|
import type { ChannelError } from "./errors.js";
|
|
3
3
|
import { SyncOperationStatus } from "./types.js";
|
|
4
4
|
type SyncOperationStatusCallback = (syncOp: SyncOperation, prev: SyncOperationStatus, next: SyncOperationStatus) => void;
|
|
@@ -8,6 +8,8 @@ export declare class SyncOperationAggregateError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
export declare class SyncOperation {
|
|
10
10
|
readonly id: string;
|
|
11
|
+
readonly jobId: string;
|
|
12
|
+
jobDependencies: string[];
|
|
11
13
|
readonly remoteName: string;
|
|
12
14
|
readonly documentId: string;
|
|
13
15
|
readonly scopes: string[];
|
|
@@ -16,7 +18,7 @@ export declare class SyncOperation {
|
|
|
16
18
|
status: SyncOperationStatus;
|
|
17
19
|
error?: ChannelError;
|
|
18
20
|
private callbacks;
|
|
19
|
-
constructor(id: string, remoteName: string, documentId: string, scopes: string[], branch: string, operations: OperationWithContext[]);
|
|
21
|
+
constructor(id: string, jobId: string, jobDependencies: string[], remoteName: string, documentId: string, scopes: string[], branch: string, operations: OperationWithContext[]);
|
|
20
22
|
on(callback: SyncOperationStatusCallback): void;
|
|
21
23
|
started(): void;
|
|
22
24
|
transported(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-operation.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"sync-operation.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAA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0 +1,31 @@
|
|
|
1
|
+
import type { IChannel } from "./interfaces.js";
|
|
2
|
+
export declare enum SyncStatus {
|
|
3
|
+
Synced = "SYNCED",
|
|
4
|
+
Outgoing = "OUTGOING",
|
|
5
|
+
Incoming = "INCOMING",
|
|
6
|
+
OutgoingAndIncoming = "OUTGOING_AND_INCOMING",
|
|
7
|
+
Error = "ERROR"
|
|
8
|
+
}
|
|
9
|
+
export type SyncStatusChangeCallback = (documentId: string, status: SyncStatus) => void;
|
|
10
|
+
export interface ISyncStatusTracker {
|
|
11
|
+
getStatus(documentId: string): SyncStatus | undefined;
|
|
12
|
+
onChange(callback: SyncStatusChangeCallback): () => void;
|
|
13
|
+
trackRemote(remoteName: string, channel: IChannel): void;
|
|
14
|
+
untrackRemote(remoteName: string): void;
|
|
15
|
+
clear(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class SyncStatusTracker implements ISyncStatusTracker {
|
|
18
|
+
private readonly remotes;
|
|
19
|
+
private readonly seen;
|
|
20
|
+
private readonly callbacks;
|
|
21
|
+
getStatus(documentId: string): SyncStatus | undefined;
|
|
22
|
+
onChange(callback: SyncStatusChangeCallback): () => void;
|
|
23
|
+
trackRemote(remoteName: string, channel: IChannel): void;
|
|
24
|
+
untrackRemote(remoteName: string): void;
|
|
25
|
+
clear(): void;
|
|
26
|
+
private handleAdded;
|
|
27
|
+
private handleRemoved;
|
|
28
|
+
private getOrCreateCounts;
|
|
29
|
+
private notifyChange;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=sync-status-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync-status-tracker.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-status-tracker.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,oBAAY,UAAU;IACpB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,QAAQ,aAAa;IACrB,mBAAmB,0BAA0B;IAC7C,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,wBAAwB,GAAG,CACrC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,UAAU,KACf,IAAI,CAAC;AAEV,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,GAAG,MAAM,IAAI,CAAC;IACzD,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;IACzD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,KAAK,IAAI,IAAI,CAAC;CACf;AAUD,qBAAa,iBAAkB,YAAW,kBAAkB;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CACZ;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA0B;IAC/C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA4C;IAEtE,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAqBrD,QAAQ,CAAC,QAAQ,EAAE,wBAAwB,GAAG,MAAM,IAAI;IAOxD,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,GAAG,IAAI;IAoBxD,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAcvC,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,WAAW;IA+BnB,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,iBAAiB;IAmBzB,OAAO,CAAC,YAAY;CAUrB"}
|
package/dist/src/sync/types.d.ts
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type { OperationWithContext } from "
|
|
2
|
-
export
|
|
1
|
+
import type { OperationWithContext } from "@powerhousedao/shared/document-model";
|
|
2
|
+
export declare enum ChannelScheme {
|
|
3
|
+
CONNECT = "connect",
|
|
4
|
+
SWITCHBOARD = "switchboard"
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Dynamic JWT token handler for generating authentication tokens per-request.
|
|
8
|
+
* Called with the target URL to enable audience-specific tokens (aud claim).
|
|
9
|
+
* Returns undefined if no authentication is available (e.g., user not logged in).
|
|
10
|
+
*/
|
|
11
|
+
export type JwtHandler = (url: string) => Promise<string | undefined>;
|
|
12
|
+
export type RemoteOptions = {
|
|
13
|
+
sinceTimestampUtcMs: string;
|
|
14
|
+
};
|
|
3
15
|
export type RemoteFilter = {
|
|
4
16
|
documentId: string[];
|
|
5
17
|
scope: string[];
|
|
@@ -7,6 +19,7 @@ export type RemoteFilter = {
|
|
|
7
19
|
};
|
|
8
20
|
export type RemoteCursor = {
|
|
9
21
|
remoteName: string;
|
|
22
|
+
cursorType: string;
|
|
10
23
|
cursorOrdinal: number;
|
|
11
24
|
lastSyncedAtUtcMs?: number;
|
|
12
25
|
};
|
|
@@ -19,6 +32,8 @@ export type SyncEnvelope = {
|
|
|
19
32
|
channelMeta: ChannelMeta;
|
|
20
33
|
operations?: OperationWithContext[];
|
|
21
34
|
cursor?: RemoteCursor;
|
|
35
|
+
key?: string;
|
|
36
|
+
dependsOn?: string[];
|
|
22
37
|
};
|
|
23
38
|
export declare enum SyncOperationStatus {
|
|
24
39
|
Unknown = -1,
|
|
@@ -40,6 +55,22 @@ export type ChannelHealth = {
|
|
|
40
55
|
lastFailureUtcMs?: number;
|
|
41
56
|
failureCount: number;
|
|
42
57
|
};
|
|
58
|
+
export type ConnectionState = "connecting" | "connected" | "disconnected" | "reconnecting" | "error";
|
|
59
|
+
export type ConnectionStateSnapshot = {
|
|
60
|
+
state: ConnectionState;
|
|
61
|
+
failureCount: number;
|
|
62
|
+
lastSuccessUtcMs: number;
|
|
63
|
+
lastFailureUtcMs: number;
|
|
64
|
+
pushBlocked: boolean;
|
|
65
|
+
pushFailureCount: number;
|
|
66
|
+
};
|
|
67
|
+
export type ConnectionStateChangedEvent = {
|
|
68
|
+
remoteName: string;
|
|
69
|
+
remoteId: string;
|
|
70
|
+
previous: ConnectionState;
|
|
71
|
+
current: ConnectionState;
|
|
72
|
+
snapshot: ConnectionStateSnapshot;
|
|
73
|
+
};
|
|
43
74
|
export type RemoteStatus = {
|
|
44
75
|
push: ChannelHealth;
|
|
45
76
|
pull: ChannelHealth;
|
|
@@ -57,4 +88,78 @@ export type RemoteRecord = {
|
|
|
57
88
|
options: RemoteOptions;
|
|
58
89
|
status: RemoteStatus;
|
|
59
90
|
};
|
|
91
|
+
/**
|
|
92
|
+
* Event types for sync lifecycle events.
|
|
93
|
+
* These events track the sync progress of a job's operations to remotes.
|
|
94
|
+
* Uses a separate namespace (20000 range) from ReactorEventTypes (10000 range).
|
|
95
|
+
*/
|
|
96
|
+
export declare const SyncEventTypes: {
|
|
97
|
+
readonly SYNC_PENDING: 20001;
|
|
98
|
+
readonly SYNC_SUCCEEDED: 20002;
|
|
99
|
+
readonly SYNC_FAILED: 20003;
|
|
100
|
+
readonly DEAD_LETTER_ADDED: 20004;
|
|
101
|
+
readonly CONNECTION_STATE_CHANGED: 20005;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Event emitted when all SyncOperations for a job are queued in outboxes.
|
|
105
|
+
*/
|
|
106
|
+
export type SyncPendingEvent = {
|
|
107
|
+
jobId: string;
|
|
108
|
+
syncOperationCount: number;
|
|
109
|
+
remoteNames: string[];
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Event emitted when all sync operations for a job succeed.
|
|
113
|
+
*/
|
|
114
|
+
export type SyncSucceededEvent = {
|
|
115
|
+
jobId: string;
|
|
116
|
+
syncOperationCount: number;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Event emitted when at least one sync operation for a job fails.
|
|
120
|
+
*/
|
|
121
|
+
export type SyncFailedEvent = {
|
|
122
|
+
jobId: string;
|
|
123
|
+
successCount: number;
|
|
124
|
+
failureCount: number;
|
|
125
|
+
errors: Array<{
|
|
126
|
+
remoteName: string;
|
|
127
|
+
documentId: string;
|
|
128
|
+
error: string;
|
|
129
|
+
}>;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Event emitted when a sync operation is moved to dead letter storage.
|
|
133
|
+
*/
|
|
134
|
+
export type DeadLetterAddedEvent = {
|
|
135
|
+
id: string;
|
|
136
|
+
jobId: string;
|
|
137
|
+
remoteName: string;
|
|
138
|
+
documentId: string;
|
|
139
|
+
errorSource: ChannelErrorSource;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Status of a sync operation result.
|
|
143
|
+
*/
|
|
144
|
+
export type SyncResultStatus = "succeeded" | "failed";
|
|
145
|
+
/**
|
|
146
|
+
* Error information for a failed sync operation to a specific remote.
|
|
147
|
+
*/
|
|
148
|
+
export type SyncResultError = {
|
|
149
|
+
remoteName: string;
|
|
150
|
+
documentId: string;
|
|
151
|
+
error: string;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Result of waiting for sync operations to complete for a job.
|
|
155
|
+
* Returned by ISyncManager.waitForSync().
|
|
156
|
+
*/
|
|
157
|
+
export type SyncResult = {
|
|
158
|
+
jobId: string;
|
|
159
|
+
status: SyncResultStatus;
|
|
160
|
+
syncOperationCount: number;
|
|
161
|
+
successCount: number;
|
|
162
|
+
failureCount: number;
|
|
163
|
+
errors: SyncResultError[];
|
|
164
|
+
};
|
|
60
165
|
//# sourceMappingURL=types.d.ts.map
|