@powerhousedao/reactor 4.1.0-dev.11 → 4.1.0-dev.111
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/cache/buffer/ring-buffer.d.ts +37 -0
- package/dist/src/cache/buffer/ring-buffer.d.ts.map +1 -0
- package/dist/src/cache/buffer/ring-buffer.js +69 -0
- package/dist/src/cache/buffer/ring-buffer.js.map +1 -0
- package/dist/src/cache/index.d.ts +3 -0
- package/dist/src/cache/index.d.ts.map +1 -0
- package/dist/src/cache/index.js +2 -0
- package/dist/src/cache/index.js.map +1 -0
- package/dist/src/cache/kysely-operation-index.d.ts +13 -0
- package/dist/src/cache/kysely-operation-index.d.ts.map +1 -0
- package/dist/src/cache/kysely-operation-index.js +152 -0
- package/dist/src/cache/kysely-operation-index.js.map +1 -0
- package/dist/src/cache/kysely-write-cache.d.ts +134 -0
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -0
- package/dist/src/cache/kysely-write-cache.js +375 -0
- package/dist/src/cache/kysely-write-cache.js.map +1 -0
- package/dist/src/cache/lru/lru-tracker.d.ts +15 -0
- package/dist/src/cache/lru/lru-tracker.d.ts.map +1 -0
- package/dist/src/cache/lru/lru-tracker.js +96 -0
- package/dist/src/cache/lru/lru-tracker.js.map +1 -0
- package/dist/src/cache/operation-index-types.d.ts +46 -0
- package/dist/src/cache/operation-index-types.d.ts.map +1 -0
- package/dist/src/cache/operation-index-types.js +4 -0
- package/dist/src/cache/operation-index-types.js.map +1 -0
- package/dist/src/cache/write/interfaces.d.ts +83 -0
- package/dist/src/cache/write/interfaces.d.ts.map +1 -0
- package/dist/src/cache/write/interfaces.js +2 -0
- package/dist/src/cache/write/interfaces.js.map +1 -0
- package/dist/src/cache/write-cache-types.d.ts +42 -0
- package/dist/src/cache/write-cache-types.d.ts.map +1 -0
- package/dist/src/cache/write-cache-types.js +2 -0
- package/dist/src/cache/write-cache-types.js.map +1 -0
- package/dist/src/client/reactor-client.d.ts +103 -0
- package/dist/src/client/reactor-client.d.ts.map +1 -0
- package/dist/src/client/reactor-client.js +184 -0
- package/dist/src/client/reactor-client.js.map +1 -0
- package/dist/src/client/types.d.ts +213 -0
- package/dist/src/client/types.d.ts.map +1 -0
- package/dist/src/client/types.js +14 -0
- package/dist/src/client/types.js.map +1 -0
- package/dist/src/core/builder.d.ts +20 -0
- package/dist/src/core/builder.d.ts.map +1 -0
- package/dist/src/core/builder.js +47 -0
- package/dist/src/core/builder.js.map +1 -0
- package/dist/src/core/reactor-builder.d.ts +32 -0
- package/dist/src/core/reactor-builder.d.ts.map +1 -0
- package/dist/src/core/reactor-builder.js +122 -0
- package/dist/src/core/reactor-builder.js.map +1 -0
- package/dist/src/core/reactor.d.ts +107 -0
- package/dist/src/core/reactor.d.ts.map +1 -0
- package/dist/src/core/reactor.js +989 -0
- package/dist/src/core/reactor.js.map +1 -0
- package/dist/src/core/types.d.ts +178 -0
- package/dist/src/core/types.d.ts.map +1 -0
- package/dist/src/core/types.js +2 -0
- package/dist/src/core/types.js.map +1 -0
- package/dist/src/core/utils.d.ts +55 -0
- package/dist/src/core/utils.d.ts.map +1 -0
- package/dist/src/core/utils.js +150 -0
- package/dist/src/core/utils.js.map +1 -0
- package/dist/src/events/event-bus.d.ts +3 -3
- package/dist/src/events/event-bus.d.ts.map +1 -1
- package/dist/src/events/event-bus.js.map +1 -1
- package/dist/src/events/interfaces.d.ts +1 -1
- package/dist/src/events/interfaces.d.ts.map +1 -1
- package/dist/src/events/types.d.ts +15 -1
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/events/types.js +6 -0
- package/dist/src/events/types.js.map +1 -1
- package/dist/src/executor/interfaces.d.ts +31 -54
- package/dist/src/executor/interfaces.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +32 -0
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor-manager.js +214 -0
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -0
- package/dist/src/executor/simple-job-executor.d.ts +62 -0
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -0
- package/dist/src/executor/simple-job-executor.js +685 -0
- package/dist/src/executor/simple-job-executor.js.map +1 -0
- package/dist/src/executor/types.d.ts +32 -8
- package/dist/src/executor/types.d.ts.map +1 -1
- package/dist/src/executor/types.js.map +1 -1
- package/dist/src/executor/util.d.ts +65 -0
- package/dist/src/executor/util.d.ts.map +1 -0
- package/dist/src/executor/util.js +154 -0
- package/dist/src/executor/util.js.map +1 -0
- package/dist/src/index.d.ts +33 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +40 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts +16 -0
- package/dist/src/job-tracker/in-memory-job-tracker.d.ts.map +1 -0
- package/dist/src/job-tracker/in-memory-job-tracker.js +84 -0
- package/dist/src/job-tracker/in-memory-job-tracker.js.map +1 -0
- package/dist/src/job-tracker/index.d.ts +3 -0
- package/dist/src/job-tracker/index.d.ts.map +1 -0
- package/dist/src/job-tracker/index.js +2 -0
- package/dist/src/job-tracker/index.js.map +1 -0
- package/dist/src/job-tracker/interfaces.d.ts +42 -0
- package/dist/src/job-tracker/interfaces.d.ts.map +1 -0
- package/dist/src/job-tracker/interfaces.js +2 -0
- package/dist/src/job-tracker/interfaces.js.map +1 -0
- package/dist/src/queue/interfaces.d.ts +46 -5
- package/dist/src/queue/interfaces.d.ts.map +1 -1
- package/dist/src/queue/job-execution-handle.d.ts +25 -0
- package/dist/src/queue/job-execution-handle.d.ts.map +1 -0
- package/dist/src/queue/job-execution-handle.js +62 -0
- package/dist/src/queue/job-execution-handle.js.map +1 -0
- package/dist/src/queue/queue.d.ts +56 -5
- package/dist/src/queue/queue.d.ts.map +1 -1
- package/dist/src/queue/queue.js +284 -36
- package/dist/src/queue/queue.js.map +1 -1
- package/dist/src/queue/types.d.ts +38 -5
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js +12 -0
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/coordinator.d.ts +38 -0
- package/dist/src/read-models/coordinator.d.ts.map +1 -0
- package/dist/src/read-models/coordinator.js +62 -0
- package/dist/src/read-models/coordinator.js.map +1 -0
- package/dist/src/read-models/document-view.d.ts +24 -0
- package/dist/src/read-models/document-view.d.ts.map +1 -0
- package/dist/src/read-models/document-view.js +368 -0
- package/dist/src/read-models/document-view.js.map +1 -0
- package/dist/src/read-models/interfaces.d.ts +29 -0
- package/dist/src/read-models/interfaces.d.ts.map +1 -0
- package/dist/src/read-models/interfaces.js +2 -0
- package/dist/src/read-models/interfaces.js.map +1 -0
- package/dist/src/read-models/types.d.ts +46 -0
- package/dist/src/read-models/types.d.ts.map +1 -0
- package/dist/src/read-models/types.js +2 -0
- package/dist/src/read-models/types.js.map +1 -0
- package/dist/src/registry/implementation.d.ts +62 -0
- package/dist/src/registry/implementation.d.ts.map +1 -0
- package/dist/src/registry/implementation.js +96 -0
- package/dist/src/registry/implementation.js.map +1 -0
- package/dist/src/registry/index.d.ts +3 -0
- package/dist/src/registry/index.d.ts.map +1 -0
- package/dist/src/registry/index.js +2 -0
- package/dist/src/registry/index.js.map +1 -0
- package/dist/src/registry/interfaces.d.ts +39 -0
- package/dist/src/registry/interfaces.d.ts.map +1 -0
- package/dist/src/registry/interfaces.js +2 -0
- package/dist/src/registry/interfaces.js.map +1 -0
- package/dist/src/shared/awaiter.d.ts +32 -0
- package/dist/src/shared/awaiter.d.ts.map +1 -0
- package/dist/src/shared/awaiter.js +132 -0
- package/dist/src/shared/awaiter.js.map +1 -0
- package/dist/src/shared/consistency-tracker.d.ts +48 -0
- package/dist/src/shared/consistency-tracker.d.ts.map +1 -0
- package/dist/src/shared/consistency-tracker.js +123 -0
- package/dist/src/shared/consistency-tracker.js.map +1 -0
- package/dist/src/shared/errors.d.ts +17 -0
- package/dist/src/shared/errors.d.ts.map +1 -0
- package/dist/src/shared/errors.js +33 -0
- package/dist/src/shared/errors.js.map +1 -0
- package/dist/src/shared/factories.d.ts +16 -0
- package/dist/src/shared/factories.d.ts.map +1 -0
- package/dist/src/shared/factories.js +33 -0
- package/dist/src/shared/factories.js.map +1 -0
- package/dist/src/shared/types.d.ts +126 -20
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js +35 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/shared/utils.d.ts +3 -0
- package/dist/src/shared/utils.d.ts.map +1 -0
- package/dist/src/shared/utils.js +8 -0
- package/dist/src/shared/utils.js.map +1 -0
- package/dist/src/signer/passthrough-signer.d.ts +6 -0
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -0
- package/dist/src/signer/passthrough-signer.js +6 -0
- package/dist/src/signer/passthrough-signer.js.map +1 -0
- package/dist/src/signer/types.d.ts +15 -0
- package/dist/src/signer/types.d.ts.map +1 -0
- package/dist/src/signer/types.js +2 -0
- package/dist/src/signer/types.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +267 -0
- package/dist/src/storage/interfaces.d.ts.map +1 -0
- package/dist/src/storage/interfaces.js +19 -0
- package/dist/src/storage/interfaces.js.map +1 -0
- package/dist/src/storage/kysely/document-indexer.d.ts +28 -0
- package/dist/src/storage/kysely/document-indexer.d.ts.map +1 -0
- package/dist/src/storage/kysely/document-indexer.js +350 -0
- package/dist/src/storage/kysely/document-indexer.js.map +1 -0
- package/dist/src/storage/kysely/keyframe-store.d.ts +15 -0
- package/dist/src/storage/kysely/keyframe-store.d.ts.map +1 -0
- package/dist/src/storage/kysely/keyframe-store.js +64 -0
- package/dist/src/storage/kysely/keyframe-store.js.map +1 -0
- package/dist/src/storage/kysely/store.d.ts +15 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -0
- package/dist/src/storage/kysely/store.js +196 -0
- package/dist/src/storage/kysely/store.js.map +1 -0
- package/dist/src/storage/kysely/types.d.ts +98 -0
- package/dist/src/storage/kysely/types.d.ts.map +1 -0
- package/dist/src/storage/kysely/types.js +2 -0
- package/dist/src/storage/kysely/types.js.map +1 -0
- package/dist/src/storage/migrations/001_create_operation_table.d.ts +3 -0
- package/dist/src/storage/migrations/001_create_operation_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/001_create_operation_table.js +40 -0
- package/dist/src/storage/migrations/001_create_operation_table.js.map +1 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.d.ts +3 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.js +27 -0
- package/dist/src/storage/migrations/002_create_keyframe_table.js.map +1 -0
- package/dist/src/storage/migrations/003_create_document_table.d.ts +3 -0
- package/dist/src/storage/migrations/003_create_document_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/003_create_document_table.js +10 -0
- package/dist/src/storage/migrations/003_create_document_table.js.map +1 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.d.ts +3 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.js +35 -0
- package/dist/src/storage/migrations/004_create_document_relationship_table.js.map +1 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.d.ts +3 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.js +10 -0
- package/dist/src/storage/migrations/005_create_indexer_state_table.js.map +1 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.d.ts +3 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.js +49 -0
- package/dist/src/storage/migrations/006_create_document_snapshot_table.js.map +1 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.d.ts +3 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.js +24 -0
- package/dist/src/storage/migrations/007_create_slug_mapping_table.js.map +1 -0
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts +3 -0
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts.map +1 -0
- package/dist/src/storage/migrations/008_create_view_state_table.js +9 -0
- package/dist/src/storage/migrations/008_create_view_state_table.js.map +1 -0
- package/dist/src/storage/migrations/009_create_operation_index_tables.d.ts +3 -0
- package/dist/src/storage/migrations/009_create_operation_index_tables.d.ts.map +1 -0
- package/dist/src/storage/migrations/009_create_operation_index_tables.js +43 -0
- package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +1 -0
- package/dist/src/storage/migrations/index.d.ts +3 -0
- package/dist/src/storage/migrations/index.d.ts.map +1 -0
- package/dist/src/storage/migrations/index.js +3 -0
- package/dist/src/storage/migrations/index.js.map +1 -0
- package/dist/src/storage/migrations/migrator.d.ts +5 -0
- package/dist/src/storage/migrations/migrator.d.ts.map +1 -0
- package/dist/src/storage/migrations/migrator.js +53 -0
- package/dist/src/storage/migrations/migrator.js.map +1 -0
- package/dist/src/storage/migrations/run-migrations.d.ts +2 -0
- package/dist/src/storage/migrations/run-migrations.d.ts.map +1 -0
- package/dist/src/storage/migrations/run-migrations.js +58 -0
- package/dist/src/storage/migrations/run-migrations.js.map +1 -0
- package/dist/src/storage/migrations/types.d.ts +9 -0
- package/dist/src/storage/migrations/types.d.ts.map +1 -0
- package/dist/src/storage/migrations/types.js +2 -0
- package/dist/src/storage/migrations/types.js.map +1 -0
- package/dist/src/storage/txn.d.ts +15 -0
- package/dist/src/storage/txn.d.ts.map +1 -0
- package/dist/src/storage/txn.js +43 -0
- package/dist/src/storage/txn.js.map +1 -0
- package/dist/src/subs/default-error-handler.d.ts +13 -0
- package/dist/src/subs/default-error-handler.d.ts.map +1 -0
- package/dist/src/subs/default-error-handler.js +27 -0
- package/dist/src/subs/default-error-handler.js.map +1 -0
- package/dist/src/subs/react-subscription-manager.d.ts +45 -0
- package/dist/src/subs/react-subscription-manager.d.ts.map +1 -0
- package/dist/src/subs/react-subscription-manager.js +185 -0
- package/dist/src/subs/react-subscription-manager.js.map +1 -0
- package/dist/src/subs/types.d.ts +64 -0
- package/dist/src/subs/types.d.ts.map +1 -0
- package/dist/src/subs/types.js +2 -0
- package/dist/src/subs/types.js.map +1 -0
- package/dist/src/utils/reshuffle.d.ts +30 -0
- package/dist/src/utils/reshuffle.d.ts.map +1 -0
- package/dist/src/utils/reshuffle.js +47 -0
- package/dist/src/utils/reshuffle.js.map +1 -0
- package/package.json +21 -7
- package/dist/bench/end-to-end-flow.bench.d.ts +0 -2
- package/dist/bench/end-to-end-flow.bench.d.ts.map +0 -1
- package/dist/bench/end-to-end-flow.bench.js +0 -256
- package/dist/bench/end-to-end-flow.bench.js.map +0 -1
- package/dist/bench/event-bus.bench.d.ts +0 -2
- package/dist/bench/event-bus.bench.d.ts.map +0 -1
- package/dist/bench/event-bus.bench.js +0 -238
- package/dist/bench/event-bus.bench.js.map +0 -1
- package/dist/bench/queue-only.bench.d.ts +0 -2
- package/dist/bench/queue-only.bench.d.ts.map +0 -1
- package/dist/bench/queue-only.bench.js +0 -40
- package/dist/bench/queue-only.bench.js.map +0 -1
- package/dist/bench/reactor-throughput.bench.d.ts +0 -2
- package/dist/bench/reactor-throughput.bench.d.ts.map +0 -1
- package/dist/bench/reactor-throughput.bench.js +0 -137
- package/dist/bench/reactor-throughput.bench.js.map +0 -1
- package/dist/src/executor/job-executor.d.ts +0 -62
- package/dist/src/executor/job-executor.d.ts.map +0 -1
- package/dist/src/executor/job-executor.js +0 -325
- package/dist/src/executor/job-executor.js.map +0 -1
- package/dist/test/event-bus.test.d.ts +0 -2
- package/dist/test/event-bus.test.d.ts.map +0 -1
- package/dist/test/event-bus.test.js +0 -532
- package/dist/test/event-bus.test.js.map +0 -1
- package/dist/test/job-executor.test.d.ts +0 -2
- package/dist/test/job-executor.test.d.ts.map +0 -1
- package/dist/test/job-executor.test.js +0 -581
- package/dist/test/job-executor.test.js.map +0 -1
- package/dist/test/queue.test.d.ts +0 -2
- package/dist/test/queue.test.d.ts.map +0 -1
- package/dist/test/queue.test.js +0 -396
- package/dist/test/queue.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"008_create_view_state_table.d.ts","sourceRoot":"","sources":["../../../../src/storage/migrations/008_create_view_state_table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.createTable("ViewState")
|
|
5
|
+
.addColumn("lastOperationId", "integer", (col) => col.primaryKey())
|
|
6
|
+
.addColumn("lastOperationTimestamp", "timestamptz", (col) => col.notNull().defaultTo(sql `NOW()`))
|
|
7
|
+
.execute();
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=008_create_view_state_table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"008_create_view_state_table.js","sourceRoot":"","sources":["../../../../src/storage/migrations/008_create_view_state_table.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAe;IACtC,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,WAAW,CAAC;SACxB,SAAS,CAAC,iBAAiB,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SAClE,SAAS,CAAC,wBAAwB,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC1D,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,OAAO,CAAC,CACpC;SACA,OAAO,EAAE,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"009_create_operation_index_tables.d.ts","sourceRoot":"","sources":["../../../../src/storage/migrations/009_create_operation_index_tables.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGrC,wBAAsB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CA8CvD"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
export async function up(db) {
|
|
3
|
+
await db.schema
|
|
4
|
+
.createTable("document_collections")
|
|
5
|
+
.addColumn("documentId", "text", (col) => col.notNull())
|
|
6
|
+
.addColumn("collectionId", "text", (col) => col.notNull())
|
|
7
|
+
.addPrimaryKeyConstraint("document_collections_pkey", [
|
|
8
|
+
"documentId",
|
|
9
|
+
"collectionId",
|
|
10
|
+
])
|
|
11
|
+
.execute();
|
|
12
|
+
await db.schema
|
|
13
|
+
.createIndex("idx_document_collections_collectionId")
|
|
14
|
+
.on("document_collections")
|
|
15
|
+
.column("collectionId")
|
|
16
|
+
.execute();
|
|
17
|
+
await db.schema
|
|
18
|
+
.createTable("operation_index_operations")
|
|
19
|
+
.addColumn("ordinal", "serial", (col) => col.primaryKey())
|
|
20
|
+
.addColumn("opId", "text", (col) => col.notNull())
|
|
21
|
+
.addColumn("documentId", "text", (col) => col.notNull())
|
|
22
|
+
.addColumn("documentType", "text", (col) => col.notNull())
|
|
23
|
+
.addColumn("scope", "text", (col) => col.notNull())
|
|
24
|
+
.addColumn("branch", "text", (col) => col.notNull())
|
|
25
|
+
.addColumn("timestampUtcMs", "bigint", (col) => col.notNull())
|
|
26
|
+
.addColumn("writeTimestampUtcMs", "timestamptz", (col) => col.notNull().defaultTo(sql `NOW()`))
|
|
27
|
+
.addColumn("index", "integer", (col) => col.notNull())
|
|
28
|
+
.addColumn("skip", "integer", (col) => col.notNull())
|
|
29
|
+
.addColumn("hash", "text", (col) => col.notNull())
|
|
30
|
+
.addColumn("action", "jsonb", (col) => col.notNull())
|
|
31
|
+
.execute();
|
|
32
|
+
await db.schema
|
|
33
|
+
.createIndex("idx_operation_index_operations_document")
|
|
34
|
+
.on("operation_index_operations")
|
|
35
|
+
.columns(["documentId", "branch", "scope"])
|
|
36
|
+
.execute();
|
|
37
|
+
await db.schema
|
|
38
|
+
.createIndex("idx_operation_index_operations_ordinal")
|
|
39
|
+
.on("operation_index_operations")
|
|
40
|
+
.column("ordinal")
|
|
41
|
+
.execute();
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=009_create_operation_index_tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"009_create_operation_index_tables.js","sourceRoot":"","sources":["../../../../src/storage/migrations/009_create_operation_index_tables.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,CAAC,KAAK,UAAU,EAAE,CAAC,EAAe;IACtC,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,sBAAsB,CAAC;SACnC,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACvD,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACzD,uBAAuB,CAAC,2BAA2B,EAAE;QACpD,YAAY;QACZ,cAAc;KACf,CAAC;SACD,OAAO,EAAE,CAAC;IAEb,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,uCAAuC,CAAC;SACpD,EAAE,CAAC,sBAAsB,CAAC;SAC1B,MAAM,CAAC,cAAc,CAAC;SACtB,OAAO,EAAE,CAAC;IAEb,MAAM,EAAE,CA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AC,QAAQ,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;SACpD,OAAO,EAAE,CAAC;IAEb,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,yCAAyC,CAAC;SACtD,EAAE,CAAC,4BAA4B,CAAC;SAChC,OAAO,CAAC,CAAC,YAAY,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SAC1C,OAAO,EAAE,CAAC;IAEb,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,wCAAwC,CAAC;SACrD,EAAE,CAAC,4BAA4B,CAAC;SAChC,MAAM,CAAC,SAAS,CAAC;SACjB,OAAO,EAAE,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/storage/migrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/storage/migrations/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Kysely } from "kysely";
|
|
2
|
+
import type { MigrationResult } from "./types.js";
|
|
3
|
+
export declare function runMigrations(db: Kysely<any>): Promise<MigrationResult>;
|
|
4
|
+
export declare function getMigrationStatus(db: Kysely<any>): Promise<readonly import("kysely").MigrationInfo[]>;
|
|
5
|
+
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrator.d.ts","sourceRoot":"","sources":["../../../../src/storage/migrations/migrator.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAqB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA6BlD,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAwB7E;AAED,wBAAsB,kBAAkB,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,sDAOvD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Migrator } from "kysely";
|
|
2
|
+
import * as migration001 from "./001_create_operation_table.js";
|
|
3
|
+
import * as migration002 from "./002_create_keyframe_table.js";
|
|
4
|
+
import * as migration003 from "./003_create_document_table.js";
|
|
5
|
+
import * as migration004 from "./004_create_document_relationship_table.js";
|
|
6
|
+
import * as migration005 from "./005_create_indexer_state_table.js";
|
|
7
|
+
import * as migration006 from "./006_create_document_snapshot_table.js";
|
|
8
|
+
import * as migration007 from "./007_create_slug_mapping_table.js";
|
|
9
|
+
import * as migration008 from "./008_create_view_state_table.js";
|
|
10
|
+
import * as migration009 from "./009_create_operation_index_tables.js";
|
|
11
|
+
const migrations = {
|
|
12
|
+
"001_create_operation_table": migration001,
|
|
13
|
+
"002_create_keyframe_table": migration002,
|
|
14
|
+
"003_create_document_table": migration003,
|
|
15
|
+
"004_create_document_relationship_table": migration004,
|
|
16
|
+
"005_create_indexer_state_table": migration005,
|
|
17
|
+
"006_create_document_snapshot_table": migration006,
|
|
18
|
+
"007_create_slug_mapping_table": migration007,
|
|
19
|
+
"008_create_view_state_table": migration008,
|
|
20
|
+
"009_create_operation_index_tables": migration009,
|
|
21
|
+
};
|
|
22
|
+
class ProgrammaticMigrationProvider {
|
|
23
|
+
getMigrations() {
|
|
24
|
+
return Promise.resolve(migrations);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export async function runMigrations(db) {
|
|
28
|
+
const migrator = new Migrator({
|
|
29
|
+
db,
|
|
30
|
+
provider: new ProgrammaticMigrationProvider(),
|
|
31
|
+
});
|
|
32
|
+
const { error, results } = await migrator.migrateToLatest();
|
|
33
|
+
const migrationsExecuted = results?.map((result) => result.migrationName) ?? [];
|
|
34
|
+
if (error) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
migrationsExecuted,
|
|
38
|
+
error: error instanceof Error ? error : new Error("Unknown migration error"),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
migrationsExecuted,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export async function getMigrationStatus(db) {
|
|
47
|
+
const migrator = new Migrator({
|
|
48
|
+
db,
|
|
49
|
+
provider: new ProgrammaticMigrationProvider(),
|
|
50
|
+
});
|
|
51
|
+
return await migrator.getMigrations();
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=migrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrator.js","sourceRoot":"","sources":["../../../../src/storage/migrations/migrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAGlC,OAAO,KAAK,YAAY,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,YAAY,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,YAAY,MAAM,6CAA6C,CAAC;AAC5E,OAAO,KAAK,YAAY,MAAM,qCAAqC,CAAC;AACpE,OAAO,KAAK,YAAY,MAAM,yCAAyC,CAAC;AACxE,OAAO,KAAK,YAAY,MAAM,oCAAoC,CAAC;AACnE,OAAO,KAAK,YAAY,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,wCAAwC,CAAC;AAEvE,MAAM,UAAU,GAAG;IACjB,4BAA4B,EAAE,YAAY;IAC1C,2BAA2B,EAAE,YAAY;IACzC,2BAA2B,EAAE,YAAY;IACzC,wCAAwC,EAAE,YAAY;IACtD,gCAAgC,EAAE,YAAY;IAC9C,oCAAoC,EAAE,YAAY;I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|
+
import { Kysely } from "kysely";
|
|
2
|
+
import { KyselyPGlite } from "kysely-pglite";
|
|
3
|
+
import { runMigrations, getMigrationStatus } from "./migrator.js";
|
|
4
|
+
async function main() {
|
|
5
|
+
const command = process.argv[2];
|
|
6
|
+
const kyselyPGlite = await KyselyPGlite.create();
|
|
7
|
+
const db = new Kysely({
|
|
8
|
+
dialect: kyselyPGlite.dialect,
|
|
9
|
+
});
|
|
10
|
+
try {
|
|
11
|
+
if (command === "up" || !command) {
|
|
12
|
+
console.log("Running migrations...");
|
|
13
|
+
const result = await runMigrations(db);
|
|
14
|
+
if (!result.success) {
|
|
15
|
+
console.error("Migration failed:", result.error?.message);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
if (result.migrationsExecuted.length === 0) {
|
|
19
|
+
console.log("No migrations to run - database is up to date");
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.log(`Successfully executed ${result.migrationsExecuted.length} migration(s):`);
|
|
23
|
+
for (const name of result.migrationsExecuted) {
|
|
24
|
+
console.log(` - ${name}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else if (command === "status") {
|
|
29
|
+
console.log("Checking migration status...");
|
|
30
|
+
const migrations = await getMigrationStatus(db);
|
|
31
|
+
console.log("\nMigration Status:");
|
|
32
|
+
console.log("=================");
|
|
33
|
+
for (const migration of migrations) {
|
|
34
|
+
const status = migration.executedAt
|
|
35
|
+
? `✓ Executed at ${migration.executedAt.toISOString()}`
|
|
36
|
+
: "○ Pending";
|
|
37
|
+
console.log(`${status} - ${migration.name}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.error(`Unknown command: ${command}`);
|
|
42
|
+
console.log("\nUsage:");
|
|
43
|
+
console.log(" pnpm migrate - Run pending migrations");
|
|
44
|
+
console.log(" pnpm migrate up - Run pending migrations");
|
|
45
|
+
console.log(" pnpm migrate status - Show migration status");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
await db.destroy();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
void main();
|
|
58
|
+
//# sourceMappingURL=run-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-migrations.js","sourceRoot":"","sources":["../../../../src/storage/migrations/run-migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAElE,KAAK,UAAU,IAAI;IACjB,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEhC,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,CAAC;IACjD,MAAM,EAAE,GAAG,IAAI,MAAM,CAAM;QACzB,OAAO,EAAE,YAAY,CAAC,OAAO;KAC9B,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,IAAI,OAAO,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YACrC,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAE,CAAC,CAAC;YAEvC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;gBAC1D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,IAAI,MAAM,CAAC,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE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B,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CACX,QAAQ,EACR,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Migration } from "kysely";
|
|
2
|
+
export type MigrationStrategy = "auto" | "manual" | "none";
|
|
3
|
+
export interface MigrationResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
migrationsExecuted: string[];
|
|
6
|
+
error?: Error;
|
|
7
|
+
}
|
|
8
|
+
export type ReactorMigration = Migration;
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/storage/migrations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;AAE3D,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/storage/migrations/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Operation } from "document-model";
|
|
2
|
+
import { type AtomicTxn as IAtomicTxn } from "./interfaces.js";
|
|
3
|
+
import type { InsertableOperation } from "./kysely/types.js";
|
|
4
|
+
export declare class AtomicTransaction implements IAtomicTxn {
|
|
5
|
+
private documentId;
|
|
6
|
+
private documentType;
|
|
7
|
+
private scope;
|
|
8
|
+
private branch;
|
|
9
|
+
private baseRevision;
|
|
10
|
+
private operations;
|
|
11
|
+
constructor(documentId: string, documentType: string, scope: string, branch: string, baseRevision: number);
|
|
12
|
+
addOperations(...operations: Operation[]): void;
|
|
13
|
+
getOperations(): InsertableOperation[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=txn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txn.d.ts","sourceRoot":"","sources":["../../../src/storage/txn.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,KAAK,SAAS,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,qBAAa,iBAAkB,YAAW,UAAU;IAIhD,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,YAAY;IAPtB,OAAO,CAAC,UAAU,CAA6B;gBAGrC,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM;IAK9B,aAAa,CAAC,GAAG,UAAU,EAAE,SAAS,EAAE,GAAG,IAAI;IAsB/C,aAAa,IAAI,mBAAmB,EAAE;CAGvC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import {} from "./interfaces.js";
|
|
3
|
+
export class AtomicTransaction {
|
|
4
|
+
documentId;
|
|
5
|
+
documentType;
|
|
6
|
+
scope;
|
|
7
|
+
branch;
|
|
8
|
+
baseRevision;
|
|
9
|
+
operations = [];
|
|
10
|
+
constructor(documentId, documentType, scope, branch, baseRevision) {
|
|
11
|
+
this.documentId = documentId;
|
|
12
|
+
this.documentType = documentType;
|
|
13
|
+
this.scope = scope;
|
|
14
|
+
this.branch = branch;
|
|
15
|
+
this.baseRevision = baseRevision;
|
|
16
|
+
//
|
|
17
|
+
}
|
|
18
|
+
addOperations(...operations) {
|
|
19
|
+
for (const op of operations) {
|
|
20
|
+
this.operations.push({
|
|
21
|
+
// WRONG
|
|
22
|
+
jobId: uuidv4(),
|
|
23
|
+
// WRONG
|
|
24
|
+
opId: op.id || uuidv4(),
|
|
25
|
+
prevOpId: "", // Will be set during apply
|
|
26
|
+
documentId: this.documentId,
|
|
27
|
+
documentType: this.documentType,
|
|
28
|
+
scope: this.scope,
|
|
29
|
+
branch: this.branch,
|
|
30
|
+
timestampUtcMs: new Date(op.timestampUtcMs),
|
|
31
|
+
index: op.index,
|
|
32
|
+
action: JSON.stringify(op.action),
|
|
33
|
+
skip: op.skip,
|
|
34
|
+
error: op.error || null,
|
|
35
|
+
hash: op.hash,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
getOperations() {
|
|
40
|
+
return this.operations;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=txn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"txn.js","sourceRoot":"","sources":["../../../src/storage/txn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAgC,MAAM,iBAAiB,CAAC;AAG/D,MAAM,OAAO,iBAAiB;IAIlB;IACA;IACA;IACA;IACA;IAPF,UAAU,GAA0B,EAAE,CAAC;IAE/C,YACU,UAAkB,EAClB,YAAoB,EACpB,KAAa,EACb,MAAc,EACd,YAAoB;QAJpB,eAAU,GAAV,UAAU,CAAQ;QAClB,iBAAY,GAAZ,YAAY,CAAQ;QACpB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAQ;QACd,iBAAY,GAAZ,YAAY,CAAQ;QAE5B,EAAE;IACJ,CAAC;IAED,aAAa,CAAC,GAAG,UAAuB;QACtC,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;YAC5B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACnB,QAAQ;gBACR,KAAK,EAAE,MAAM,EAAE;gBACf,QAAQ;gBACR,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,MAAM,EAAE;gBACvB,QAAQ,EAAE,EAAE,EAAE,2BAA2B;gBACzC,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,cAAc,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC;gBAC3C,KAAK,EAAE,EAAE,CAAC,KAAK;gBACf,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,CAAC;gBACjC,IAAI,EAAE,EAAE,CAAC,IAAI;gBACb,KAAK,EAAE,EAAE,CAAC,KAAK,IAAI,IAAI;gBACvB,IAAI,EAAE,EAAE,CAAC,IAAI;aACd,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ISubscriptionErrorHandler, SubscriptionErrorContext } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default error handler that re-throws subscription errors.
|
|
4
|
+
* This ensures that errors are not silently swallowed.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultSubscriptionErrorHandler implements ISubscriptionErrorHandler {
|
|
7
|
+
handleError(error: unknown, context: SubscriptionErrorContext): void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a default subscription error handler instance
|
|
11
|
+
*/
|
|
12
|
+
export declare function createDefaultSubscriptionErrorHandler(): ISubscriptionErrorHandler;
|
|
13
|
+
//# sourceMappingURL=default-error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-error-handler.d.ts","sourceRoot":"","sources":["../../../src/subs/default-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,yBAAyB,EACzB,wBAAwB,EACzB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,+BACX,YAAW,yBAAyB;IAEpC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,wBAAwB,GAAG,IAAI;CAcrE;AAED;;GAEG;AACH,wBAAgB,qCAAqC,IAAI,yBAAyB,CAEjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default error handler that re-throws subscription errors.
|
|
3
|
+
* This ensures that errors are not silently swallowed.
|
|
4
|
+
*/
|
|
5
|
+
export class DefaultSubscriptionErrorHandler {
|
|
6
|
+
handleError(error, context) {
|
|
7
|
+
const errorMessage = `Subscription error in ${context.eventType} (${context.subscriptionId})`;
|
|
8
|
+
if (error instanceof Error) {
|
|
9
|
+
// Preserve the original error with additional context
|
|
10
|
+
const enhancedError = new Error(`${errorMessage}: ${error.message}`);
|
|
11
|
+
enhancedError.cause = error;
|
|
12
|
+
enhancedError.stack = error.stack;
|
|
13
|
+
throw enhancedError;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
// Handle non-Error objects
|
|
17
|
+
throw new Error(`${errorMessage}: ${String(error)}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a default subscription error handler instance
|
|
23
|
+
*/
|
|
24
|
+
export function createDefaultSubscriptionErrorHandler() {
|
|
25
|
+
return new DefaultSubscriptionErrorHandler();
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=default-error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-error-handler.js","sourceRoot":"","sources":["../../../src/subs/default-error-handler.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAO,+BAA+B;IAG1C,WAAW,CAAC,KAAc,EAAE,OAAiC;QAC3D,MAAM,YAAY,GAAG,yBAAyB,OAAO,CAAC,SAAS,KAAK,OAAO,CAAC,cAAc,GAAG,CAAC;QAE9F,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,sDAAsD;YACtD,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,GAAG,YAAY,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;YAC5B,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YAClC,MAAM,aAAa,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,2BAA2B;YAC3B,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,qCAAqC;IACnD,OAAO,IAAI,+BAA+B,EAAE,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { PHDocument } from "document-model";
|
|
2
|
+
import type { PagedResults, RelationshipChangeType, SearchFilter, ViewFilter } from "../shared/types.js";
|
|
3
|
+
import type { IReactorSubscriptionManager, ISubscriptionErrorHandler } from "./types.js";
|
|
4
|
+
type DocumentCreatedCallback = (result: PagedResults<string>) => void;
|
|
5
|
+
type DocumentDeletedCallback = (documentIds: string[]) => void;
|
|
6
|
+
type DocumentStateUpdatedCallback = (result: PagedResults<PHDocument>) => void;
|
|
7
|
+
type RelationshipChangedCallback = (parentId: string, childId: string, changeType: RelationshipChangeType) => void;
|
|
8
|
+
export declare class ReactorSubscriptionManager implements IReactorSubscriptionManager {
|
|
9
|
+
private createdSubscriptions;
|
|
10
|
+
private deletedSubscriptions;
|
|
11
|
+
private updatedSubscriptions;
|
|
12
|
+
private relationshipSubscriptions;
|
|
13
|
+
private subscriptionCounter;
|
|
14
|
+
private errorHandler;
|
|
15
|
+
constructor(errorHandler: ISubscriptionErrorHandler);
|
|
16
|
+
onDocumentCreated(callback: DocumentCreatedCallback, search?: SearchFilter): () => void;
|
|
17
|
+
onDocumentDeleted(callback: DocumentDeletedCallback, search?: SearchFilter): () => void;
|
|
18
|
+
onDocumentStateUpdated(callback: DocumentStateUpdatedCallback, search?: SearchFilter, view?: ViewFilter): () => void;
|
|
19
|
+
onRelationshipChanged(callback: RelationshipChangedCallback, search?: SearchFilter): () => void;
|
|
20
|
+
/**
|
|
21
|
+
* Notify subscribers about created documents
|
|
22
|
+
*/
|
|
23
|
+
notifyDocumentsCreated(documentIds: string[], documentTypes?: Map<string, string>, parentIds?: Map<string, string | null>): void;
|
|
24
|
+
/**
|
|
25
|
+
* Notify subscribers about deleted documents
|
|
26
|
+
*/
|
|
27
|
+
notifyDocumentsDeleted(documentIds: string[], documentTypes?: Map<string, string>, parentIds?: Map<string, string | null>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Notify subscribers about updated documents
|
|
30
|
+
*/
|
|
31
|
+
notifyDocumentsUpdated(documents: PHDocument[]): void;
|
|
32
|
+
/**
|
|
33
|
+
* Notify subscribers about relationship changes
|
|
34
|
+
*/
|
|
35
|
+
notifyRelationshipChanged(parentId: string, childId: string, changeType: RelationshipChangeType, childType?: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Clear all subscriptions
|
|
38
|
+
*/
|
|
39
|
+
clearAll(): void;
|
|
40
|
+
private filterDocumentIds;
|
|
41
|
+
private filterDocuments;
|
|
42
|
+
private matchesRelationshipFilter;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=react-subscription-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-subscription-manager.d.ts","sourceRoot":"","sources":["../../../src/subs/react-subscription-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,2BAA2B,EAC3B,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,KAAK,uBAAuB,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;AACtE,KAAK,uBAAuB,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;AAC/D,KAAK,4BAA4B,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,UAAU,CAAC,KAAK,IAAI,CAAC;AAC/E,KAAK,2BAA2B,GAAG,CACjC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,sBAAsB,KAC/B,IAAI,CAAC;AASV,qBAAa,0BAA2B,YAAW,2BAA2B;IAC5E,OAAO,CAAC,oBAAoB,CAGxB;IACJ,OAAO,CAAC,oBAAoB,CAGxB;IACJ,OAAO,CAAC,oBAAoB,CAGxB;IACJ,OAAO,CAAC,yBAAyB,CAG7B;IAEJ,OAAO,CAAC,mBAAmB,CAAK;IAChC,OAAO,CAAC,YAAY,CAA4B;gBAEpC,YAAY,EAAE,yBAAyB;IAInD,iBAAiB,CACf,QAAQ,EAAE,uBAAuB,EACjC,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,IAAI;IASb,iBAAiB,CACf,QAAQ,EAAE,uBAAuB,EACjC,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,IAAI;IASb,sBAAsB,CACpB,QAAQ,EAAE,4BAA4B,EACtC,MAAM,CAAC,EAAE,YAAY,EACrB,IAAI,CAAC,EAAE,UAAU,GAChB,MAAM,IAAI;IASb,qBAAqB,CACnB,QAAQ,EAAE,2BAA2B,EACrC,MAAM,CAAC,EAAE,YAAY,GACpB,MAAM,IAAI;IASb;;OAEG;IACH,sBAAsB,CACpB,WAAW,EAAE,MAAM,EAAE,EACrB,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GACrC,IAAI;IA+BP;;OAEG;IACH,sBAAsB,CACpB,WAAW,EAAE,MAAM,EAAE,EACrB,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,SAAS,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,GACrC,IAAI;IAuBP;;OAEG;IACH,sBAAsB,CAAC,SAAS,EAAE,UAAU,EAAE,GAAG,IAAI;IA0BrD;;OAEG;IACH,yBAAyB,CACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,sBAAsB,EAClC,SAAS,CAAC,EAAE,MAAM,GACjB,IAAI;IAuBP;;OAEG;IACH,QAAQ,IAAI,IAAI;IAOhB,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,eAAe;IAevB,OAAO,CAAC,yBAAyB;CAclC"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export class ReactorSubscriptionManager {
|
|
2
|
+
createdSubscriptions = new Map();
|
|
3
|
+
deletedSubscriptions = new Map();
|
|
4
|
+
updatedSubscriptions = new Map();
|
|
5
|
+
relationshipSubscriptions = new Map();
|
|
6
|
+
subscriptionCounter = 0;
|
|
7
|
+
errorHandler;
|
|
8
|
+
constructor(errorHandler) {
|
|
9
|
+
this.errorHandler = errorHandler;
|
|
10
|
+
}
|
|
11
|
+
onDocumentCreated(callback, search) {
|
|
12
|
+
const id = `created-${++this.subscriptionCounter}`;
|
|
13
|
+
this.createdSubscriptions.set(id, { id, callback, search });
|
|
14
|
+
return () => {
|
|
15
|
+
this.createdSubscriptions.delete(id);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
onDocumentDeleted(callback, search) {
|
|
19
|
+
const id = `deleted-${++this.subscriptionCounter}`;
|
|
20
|
+
this.deletedSubscriptions.set(id, { id, callback, search });
|
|
21
|
+
return () => {
|
|
22
|
+
this.deletedSubscriptions.delete(id);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
onDocumentStateUpdated(callback, search, view) {
|
|
26
|
+
const id = `updated-${++this.subscriptionCounter}`;
|
|
27
|
+
this.updatedSubscriptions.set(id, { id, callback, search, view });
|
|
28
|
+
return () => {
|
|
29
|
+
this.updatedSubscriptions.delete(id);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
onRelationshipChanged(callback, search) {
|
|
33
|
+
const id = `relationship-${++this.subscriptionCounter}`;
|
|
34
|
+
this.relationshipSubscriptions.set(id, { id, callback, search });
|
|
35
|
+
return () => {
|
|
36
|
+
this.relationshipSubscriptions.delete(id);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Notify subscribers about created documents
|
|
41
|
+
*/
|
|
42
|
+
notifyDocumentsCreated(documentIds, documentTypes, parentIds) {
|
|
43
|
+
const result = {
|
|
44
|
+
results: documentIds,
|
|
45
|
+
options: { cursor: "", limit: documentIds.length },
|
|
46
|
+
};
|
|
47
|
+
for (const subscription of this.createdSubscriptions.values()) {
|
|
48
|
+
const filteredIds = this.filterDocumentIds(documentIds, subscription.search, documentTypes, parentIds);
|
|
49
|
+
if (filteredIds.length > 0) {
|
|
50
|
+
try {
|
|
51
|
+
subscription.callback({
|
|
52
|
+
...result,
|
|
53
|
+
results: filteredIds,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
this.errorHandler.handleError(error, {
|
|
58
|
+
eventType: "created",
|
|
59
|
+
subscriptionId: subscription.id,
|
|
60
|
+
eventData: filteredIds,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Notify subscribers about deleted documents
|
|
68
|
+
*/
|
|
69
|
+
notifyDocumentsDeleted(documentIds, documentTypes, parentIds) {
|
|
70
|
+
for (const subscription of this.deletedSubscriptions.values()) {
|
|
71
|
+
const filteredIds = this.filterDocumentIds(documentIds, subscription.search, documentTypes, parentIds);
|
|
72
|
+
if (filteredIds.length > 0) {
|
|
73
|
+
try {
|
|
74
|
+
subscription.callback(filteredIds);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.errorHandler.handleError(error, {
|
|
78
|
+
eventType: "deleted",
|
|
79
|
+
subscriptionId: subscription.id,
|
|
80
|
+
eventData: filteredIds,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Notify subscribers about updated documents
|
|
88
|
+
*/
|
|
89
|
+
notifyDocumentsUpdated(documents) {
|
|
90
|
+
const result = {
|
|
91
|
+
results: documents,
|
|
92
|
+
options: { cursor: "", limit: documents.length },
|
|
93
|
+
};
|
|
94
|
+
for (const subscription of this.updatedSubscriptions.values()) {
|
|
95
|
+
const filteredDocs = this.filterDocuments(documents, subscription.search);
|
|
96
|
+
if (filteredDocs.length > 0) {
|
|
97
|
+
try {
|
|
98
|
+
subscription.callback({
|
|
99
|
+
...result,
|
|
100
|
+
results: filteredDocs,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
this.errorHandler.handleError(error, {
|
|
105
|
+
eventType: "updated",
|
|
106
|
+
subscriptionId: subscription.id,
|
|
107
|
+
eventData: filteredDocs,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Notify subscribers about relationship changes
|
|
115
|
+
*/
|
|
116
|
+
notifyRelationshipChanged(parentId, childId, changeType, childType) {
|
|
117
|
+
for (const subscription of this.relationshipSubscriptions.values()) {
|
|
118
|
+
if (this.matchesRelationshipFilter(parentId, childId, childType, subscription.search)) {
|
|
119
|
+
try {
|
|
120
|
+
subscription.callback(parentId, childId, changeType);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
this.errorHandler.handleError(error, {
|
|
124
|
+
eventType: "relationshipChanged",
|
|
125
|
+
subscriptionId: subscription.id,
|
|
126
|
+
eventData: { parentId, childId, changeType },
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Clear all subscriptions
|
|
134
|
+
*/
|
|
135
|
+
clearAll() {
|
|
136
|
+
this.createdSubscriptions.clear();
|
|
137
|
+
this.deletedSubscriptions.clear();
|
|
138
|
+
this.updatedSubscriptions.clear();
|
|
139
|
+
this.relationshipSubscriptions.clear();
|
|
140
|
+
}
|
|
141
|
+
filterDocumentIds(documentIds, search, documentTypes, parentIds) {
|
|
142
|
+
if (!search)
|
|
143
|
+
return documentIds;
|
|
144
|
+
return documentIds.filter((id) => {
|
|
145
|
+
if (search.ids && !search.ids.includes(id))
|
|
146
|
+
return false;
|
|
147
|
+
if (search.type && documentTypes) {
|
|
148
|
+
const docType = documentTypes.get(id);
|
|
149
|
+
if (docType !== search.type)
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
if (search.parentId && parentIds) {
|
|
153
|
+
const parentId = parentIds.get(id);
|
|
154
|
+
if (parentId !== search.parentId)
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
return true;
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
filterDocuments(documents, search) {
|
|
161
|
+
if (!search)
|
|
162
|
+
return documents;
|
|
163
|
+
return documents.filter((doc) => {
|
|
164
|
+
if (search.ids && !search.ids.includes(doc.header.id))
|
|
165
|
+
return false;
|
|
166
|
+
if (search.type && doc.header.documentType !== search.type)
|
|
167
|
+
return false;
|
|
168
|
+
if (search.slugs && !search.slugs.includes(doc.header.slug))
|
|
169
|
+
return false;
|
|
170
|
+
return true;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
matchesRelationshipFilter(parentId, childId, childType, search) {
|
|
174
|
+
if (!search)
|
|
175
|
+
return true;
|
|
176
|
+
if (search.parentId && parentId !== search.parentId)
|
|
177
|
+
return false;
|
|
178
|
+
if (search.ids && !search.ids.includes(childId))
|
|
179
|
+
return false;
|
|
180
|
+
if (search.type && childType && childType !== search.type)
|
|
181
|
+
return false;
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=react-subscription-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-subscription-manager.js","sourceRoot":"","sources":["../../../src/subs/react-subscription-manager.ts"],"names":[],"mappings":"AA4BA,MAAM,OAAO,0BAA0B;IAC7B,oBAAoB,GAAG,IAAI,GAAG,EAGnC,CAAC;IACI,oBAAoB,GAAG,IAAI,GAAG,EAGnC,CAAC;IACI,oBAAoB,GAAG,IAAI,GAAG,EAGnC,CAAC;IACI,yBAAyB,GAAG,IAAI,GAAG,EAGxC,CAAC;IAEI,mBAAmB,GAAG,CAAC,CAAC;IACxB,YAAY,CAA4B;IAEhD,YAAY,YAAuC;QACjD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED,iBAAiB,CACf,QAAiC,EACjC,MAAqB;QAErB,MAAM,EAAE,GAAG,WAAW,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC;QACnD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