@powerhousedao/reactor 5.1.0-staging.0 → 5.2.0-dev.1
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/actions/index.d.ts +24 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/src/actions/index.js +76 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/cache/document-meta-cache-types.d.ts +114 -0
- package/dist/src/cache/document-meta-cache-types.d.ts.map +1 -0
- package/dist/src/cache/document-meta-cache-types.js +2 -0
- package/dist/src/cache/document-meta-cache-types.js.map +1 -0
- package/dist/src/cache/document-meta-cache.d.ts +30 -0
- package/dist/src/cache/document-meta-cache.d.ts.map +1 -0
- package/dist/src/cache/document-meta-cache.js +128 -0
- package/dist/src/cache/document-meta-cache.js.map +1 -0
- package/dist/src/cache/kysely-operation-index.d.ts +4 -2
- package/dist/src/cache/kysely-operation-index.d.ts.map +1 -1
- package/dist/src/cache/kysely-operation-index.js +67 -24
- package/dist/src/cache/kysely-operation-index.js.map +1 -1
- package/dist/src/cache/kysely-write-cache.d.ts.map +1 -1
- package/dist/src/cache/kysely-write-cache.js +3 -2
- package/dist/src/cache/kysely-write-cache.js.map +1 -1
- package/dist/src/cache/operation-index-types.d.ts +4 -3
- package/dist/src/cache/operation-index-types.d.ts.map +1 -1
- package/dist/src/cache/operation-index-types.js.map +1 -1
- package/dist/src/client/reactor-client.d.ts +16 -4
- package/dist/src/client/reactor-client.d.ts.map +1 -1
- package/dist/src/client/reactor-client.js +122 -5
- package/dist/src/client/reactor-client.js.map +1 -1
- package/dist/src/client/types.d.ts +22 -3
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.d.ts +10 -9
- package/dist/src/core/reactor-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-builder.js +73 -17
- package/dist/src/core/reactor-builder.js.map +1 -1
- package/dist/src/core/reactor-client-builder.d.ts +10 -1
- package/dist/src/core/reactor-client-builder.d.ts.map +1 -1
- package/dist/src/core/reactor-client-builder.js +16 -1
- package/dist/src/core/reactor-client-builder.js.map +1 -1
- package/dist/src/core/reactor.d.ts +11 -10
- package/dist/src/core/reactor.d.ts.map +1 -1
- package/dist/src/core/reactor.js +78 -91
- package/dist/src/core/reactor.js.map +1 -1
- package/dist/src/core/types.d.ts +22 -7
- package/dist/src/core/types.d.ts.map +1 -1
- package/dist/src/core/utils.d.ts +1 -2
- package/dist/src/core/utils.d.ts.map +1 -1
- package/dist/src/core/utils.js +2 -2
- package/dist/src/core/utils.js.map +1 -1
- package/dist/src/events/types.d.ts +1 -0
- package/dist/src/events/types.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts +3 -1
- package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor-manager.js +10 -7
- package/dist/src/executor/simple-job-executor-manager.js.map +1 -1
- package/dist/src/executor/simple-job-executor.d.ts +17 -3
- package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
- package/dist/src/executor/simple-job-executor.js +329 -221
- package/dist/src/executor/simple-job-executor.js.map +1 -1
- package/dist/src/executor/types.d.ts +2 -0
- 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 +14 -5
- package/dist/src/executor/util.d.ts.map +1 -1
- package/dist/src/executor/util.js +36 -9
- package/dist/src/executor/util.js.map +1 -1
- package/dist/src/index.d.ts +12 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/logging/console.d.ts +11 -1
- package/dist/src/logging/console.d.ts.map +1 -1
- package/dist/src/logging/console.js +45 -14
- package/dist/src/logging/console.js.map +1 -1
- package/dist/src/logging/types.d.ts +1 -0
- package/dist/src/logging/types.d.ts.map +1 -1
- package/dist/src/processors/index.d.ts +3 -0
- package/dist/src/processors/index.d.ts.map +1 -0
- package/dist/src/processors/index.js +2 -0
- package/dist/src/processors/index.js.map +1 -0
- package/dist/src/processors/processor-manager.d.ts +38 -0
- package/dist/src/processors/processor-manager.d.ts.map +1 -0
- package/dist/src/processors/processor-manager.js +165 -0
- package/dist/src/processors/processor-manager.js.map +1 -0
- package/dist/src/processors/types.d.ts +63 -0
- package/dist/src/processors/types.d.ts.map +1 -0
- package/dist/src/processors/types.js +2 -0
- package/dist/src/processors/types.js.map +1 -0
- package/dist/src/processors/utils.d.ts +10 -0
- package/dist/src/processors/utils.d.ts.map +1 -0
- package/dist/src/processors/utils.js +58 -0
- package/dist/src/processors/utils.js.map +1 -0
- package/dist/src/queue/types.d.ts +2 -0
- package/dist/src/queue/types.d.ts.map +1 -1
- package/dist/src/queue/types.js.map +1 -1
- package/dist/src/read-models/base-read-model.d.ts +60 -0
- package/dist/src/read-models/base-read-model.d.ts.map +1 -0
- package/dist/src/read-models/base-read-model.js +143 -0
- package/dist/src/read-models/base-read-model.js.map +1 -0
- package/dist/src/read-models/coordinator.d.ts +3 -2
- package/dist/src/read-models/coordinator.d.ts.map +1 -1
- package/dist/src/read-models/coordinator.js +12 -13
- package/dist/src/read-models/coordinator.js.map +1 -1
- package/dist/src/read-models/document-view.d.ts +6 -7
- package/dist/src/read-models/document-view.d.ts.map +1 -1
- package/dist/src/read-models/document-view.js +18 -81
- package/dist/src/read-models/document-view.js.map +1 -1
- package/dist/src/read-models/types.d.ts +2 -1
- package/dist/src/read-models/types.d.ts.map +1 -1
- package/dist/src/registry/implementation.d.ts +42 -34
- package/dist/src/registry/implementation.d.ts.map +1 -1
- package/dist/src/registry/implementation.js +168 -48
- package/dist/src/registry/implementation.js.map +1 -1
- package/dist/src/registry/interfaces.d.ts +69 -8
- package/dist/src/registry/interfaces.d.ts.map +1 -1
- package/dist/src/shared/errors.d.ts +16 -0
- package/dist/src/shared/errors.d.ts.map +1 -1
- package/dist/src/shared/errors.js +28 -0
- package/dist/src/shared/errors.js.map +1 -1
- package/dist/src/shared/types.d.ts +4 -0
- package/dist/src/shared/types.d.ts.map +1 -1
- package/dist/src/shared/types.js.map +1 -1
- package/dist/src/signer/passthrough-signer.d.ts +9 -3
- package/dist/src/signer/passthrough-signer.d.ts.map +1 -1
- package/dist/src/signer/passthrough-signer.js +13 -0
- package/dist/src/signer/passthrough-signer.js.map +1 -1
- package/dist/src/signer/types.d.ts +2 -22
- package/dist/src/signer/types.d.ts.map +1 -1
- package/dist/src/storage/consistency-aware-legacy-storage.d.ts +33 -0
- package/dist/src/storage/consistency-aware-legacy-storage.d.ts.map +1 -0
- package/dist/src/storage/consistency-aware-legacy-storage.js +65 -0
- package/dist/src/storage/consistency-aware-legacy-storage.js.map +1 -0
- package/dist/src/storage/interfaces.d.ts +94 -1
- package/dist/src/storage/interfaces.d.ts.map +1 -1
- package/dist/src/storage/interfaces.js +2 -2
- package/dist/src/storage/interfaces.js.map +1 -1
- package/dist/src/storage/kysely/store.d.ts +1 -0
- package/dist/src/storage/kysely/store.d.ts.map +1 -1
- package/dist/src/storage/kysely/store.js +41 -4
- package/dist/src/storage/kysely/store.js.map +1 -1
- package/dist/src/storage/kysely/sync-cursor-storage.js +2 -2
- package/dist/src/storage/kysely/sync-cursor-storage.js.map +1 -1
- package/dist/src/storage/kysely/sync-remote-storage.js +8 -8
- package/dist/src/storage/kysely/sync-remote-storage.js.map +1 -1
- package/dist/src/storage/kysely/types.d.ts +6 -6
- package/dist/src/storage/migrations/001_create_operation_table.d.ts.map +1 -1
- package/dist/src/storage/migrations/001_create_operation_table.js +2 -1
- package/dist/src/storage/migrations/001_create_operation_table.js.map +1 -1
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts +1 -1
- package/dist/src/storage/migrations/008_create_view_state_table.d.ts.map +1 -1
- package/dist/src/storage/migrations/008_create_view_state_table.js +2 -1
- package/dist/src/storage/migrations/008_create_view_state_table.js.map +1 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js +1 -1
- package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +1 -1
- package/dist/src/storage/migrations/010_create_sync_tables.js +5 -5
- package/dist/src/storage/migrations/010_create_sync_tables.js.map +1 -1
- package/dist/src/storage/migrations/migrator.d.ts +3 -2
- package/dist/src/storage/migrations/migrator.d.ts.map +1 -1
- package/dist/src/storage/migrations/migrator.js +29 -6
- package/dist/src/storage/migrations/migrator.js.map +1 -1
- package/dist/src/storage/txn.d.ts.map +1 -1
- package/dist/src/storage/txn.js +2 -3
- package/dist/src/storage/txn.js.map +1 -1
- package/dist/src/subs/subscription-notification-read-model.d.ts +17 -0
- package/dist/src/subs/subscription-notification-read-model.d.ts.map +1 -0
- package/dist/src/subs/subscription-notification-read-model.js +62 -0
- package/dist/src/subs/subscription-notification-read-model.js.map +1 -0
- package/dist/src/sync/channels/composite-channel-factory.d.ts +30 -0
- package/dist/src/sync/channels/composite-channel-factory.d.ts.map +1 -0
- package/dist/src/sync/channels/composite-channel-factory.js +87 -0
- package/dist/src/sync/channels/composite-channel-factory.js.map +1 -0
- package/dist/src/sync/channels/gql-channel-factory.d.ts +5 -2
- package/dist/src/sync/channels/gql-channel-factory.d.ts.map +1 -1
- package/dist/src/sync/channels/gql-channel-factory.js +8 -2
- package/dist/src/sync/channels/gql-channel-factory.js.map +1 -1
- package/dist/src/sync/channels/gql-channel.d.ts +28 -1
- package/dist/src/sync/channels/gql-channel.d.ts.map +1 -1
- package/dist/src/sync/channels/gql-channel.js +150 -22
- package/dist/src/sync/channels/gql-channel.js.map +1 -1
- package/dist/src/sync/channels/index.d.ts +2 -1
- package/dist/src/sync/channels/index.d.ts.map +1 -1
- package/dist/src/sync/channels/index.js +2 -1
- package/dist/src/sync/channels/index.js.map +1 -1
- package/dist/src/sync/channels/polling-channel.d.ts +39 -0
- package/dist/src/sync/channels/polling-channel.d.ts.map +1 -0
- package/dist/src/sync/channels/polling-channel.js +72 -0
- package/dist/src/sync/channels/polling-channel.js.map +1 -0
- package/dist/src/sync/channels/utils.d.ts +17 -2
- package/dist/src/sync/channels/utils.d.ts.map +1 -1
- package/dist/src/sync/channels/utils.js +76 -6
- package/dist/src/sync/channels/utils.js.map +1 -1
- package/dist/src/sync/errors.d.ts +1 -1
- package/dist/src/sync/errors.d.ts.map +1 -1
- package/dist/src/sync/errors.js +2 -2
- package/dist/src/sync/errors.js.map +1 -1
- package/dist/src/sync/index.d.ts +2 -2
- package/dist/src/sync/index.d.ts.map +1 -1
- package/dist/src/sync/index.js +2 -2
- package/dist/src/sync/index.js.map +1 -1
- package/dist/src/sync/interfaces.d.ts +16 -1
- package/dist/src/sync/interfaces.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.d.ts +3 -2
- package/dist/src/sync/sync-builder.d.ts.map +1 -1
- package/dist/src/sync/sync-builder.js +4 -4
- package/dist/src/sync/sync-builder.js.map +1 -1
- package/dist/src/sync/sync-manager.d.ts +4 -1
- package/dist/src/sync/sync-manager.d.ts.map +1 -1
- package/dist/src/sync/sync-manager.js +65 -8
- package/dist/src/sync/sync-manager.js.map +1 -1
- package/dist/src/sync/utils.d.ts +19 -0
- package/dist/src/sync/utils.d.ts.map +1 -1
- package/dist/src/sync/utils.js +44 -0
- package/dist/src/sync/utils.js.map +1 -1
- package/package.json +3 -3
- package/dist/src/sync/channels/internal-channel.d.ts +0 -57
- package/dist/src/sync/channels/internal-channel.d.ts.map +0 -1
- package/dist/src/sync/channels/internal-channel.js +0 -106
- package/dist/src/sync/channels/internal-channel.js.map +0 -1
|
@@ -12,12 +12,12 @@ export async function up(db) {
|
|
|
12
12
|
.addColumn("filter_scopes", "jsonb")
|
|
13
13
|
.addColumn("filter_branch", "text", (col) => col.notNull().defaultTo("main"))
|
|
14
14
|
.addColumn("push_state", "text", (col) => col.notNull().defaultTo("idle"))
|
|
15
|
-
.addColumn("push_last_success_utc_ms", "
|
|
16
|
-
.addColumn("push_last_failure_utc_ms", "
|
|
15
|
+
.addColumn("push_last_success_utc_ms", "text")
|
|
16
|
+
.addColumn("push_last_failure_utc_ms", "text")
|
|
17
17
|
.addColumn("push_failure_count", "integer", (col) => col.notNull().defaultTo(0))
|
|
18
18
|
.addColumn("pull_state", "text", (col) => col.notNull().defaultTo("idle"))
|
|
19
|
-
.addColumn("pull_last_success_utc_ms", "
|
|
20
|
-
.addColumn("pull_last_failure_utc_ms", "
|
|
19
|
+
.addColumn("pull_last_success_utc_ms", "text")
|
|
20
|
+
.addColumn("pull_last_failure_utc_ms", "text")
|
|
21
21
|
.addColumn("pull_failure_count", "integer", (col) => col.notNull().defaultTo(0))
|
|
22
22
|
.addColumn("created_at", "timestamptz", (col) => col.notNull().defaultTo(sql `NOW()`))
|
|
23
23
|
.addColumn("updated_at", "timestamptz", (col) => col.notNull().defaultTo(sql `NOW()`))
|
|
@@ -31,7 +31,7 @@ export async function up(db) {
|
|
|
31
31
|
.createTable("sync_cursors")
|
|
32
32
|
.addColumn("remote_name", "text", (col) => col.primaryKey().references("sync_remotes.name").onDelete("cascade"))
|
|
33
33
|
.addColumn("cursor_ordinal", "bigint", (col) => col.notNull().defaultTo(0))
|
|
34
|
-
.addColumn("last_synced_at_utc_ms", "
|
|
34
|
+
.addColumn("last_synced_at_utc_ms", "text")
|
|
35
35
|
.addColumn("updated_at", "timestamptz", (col) => col.notNull().defaultTo(sql `NOW()`))
|
|
36
36
|
.execute();
|
|
37
37
|
await db.schema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"010_create_sync_tables.js","sourceRoot":"","sources":["../../../../src/storage/migrations/010_create_sync_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,cAAc,CAAC;SAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;SACpD,SAAS,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC,GAAG,EAA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AAC,uBAAuB,EAAE,MAAM,CAAC;SAC1C,SAAS,CAAC,YAAY,EAAE,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAC9C,GAAG,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,GAAG,CAAA,OAAO,CAAC,CACpC;SACA,OAAO,EAAE,CAAC;IAEb,MAAM,EAAE,CAAC,MAAM;SACZ,WAAW,CAAC,0BAA0B,CAAC;SACvC,EAAE,CAAC,cAAc,CAAC;SAClB,MAAM,CAAC,gBAAgB,CAAC;SACxB,OAAO,EAAE,CAAC;AACf,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Kysely } from "kysely";
|
|
2
2
|
import type { MigrationResult } from "./types.js";
|
|
3
|
-
export declare
|
|
4
|
-
export declare function
|
|
3
|
+
export declare const REACTOR_SCHEMA = "reactor";
|
|
4
|
+
export declare function runMigrations(db: Kysely<any>, schema?: string): Promise<MigrationResult>;
|
|
5
|
+
export declare function getMigrationStatus(db: Kysely<any>, schema?: string): Promise<readonly import("kysely").MigrationInfo[]>;
|
|
5
6
|
//# sourceMappingURL=migrator.d.ts.map
|
|
@@ -1 +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;AA+
|
|
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;AAElD,eAAO,MAAM,cAAc,YAAY,CAAC;AA+BxC,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EACf,MAAM,GAAE,MAAuB,GAC9B,OAAO,CAAC,eAAe,CAAC,CA6C1B;AAED,wBAAsB,kBAAkB,CACtC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,EACf,MAAM,GAAE,MAAuB,sDAShC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Migrator } from "kysely";
|
|
1
|
+
import { Migrator, sql } from "kysely";
|
|
2
|
+
export const REACTOR_SCHEMA = "reactor";
|
|
2
3
|
import * as migration001 from "./001_create_operation_table.js";
|
|
3
4
|
import * as migration002 from "./002_create_keyframe_table.js";
|
|
4
5
|
import * as migration003 from "./003_create_document_table.js";
|
|
@@ -26,12 +27,33 @@ class ProgrammaticMigrationProvider {
|
|
|
26
27
|
return Promise.resolve(migrations);
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
export async function runMigrations(db) {
|
|
30
|
+
export async function runMigrations(db, schema = REACTOR_SCHEMA) {
|
|
31
|
+
try {
|
|
32
|
+
await sql `CREATE SCHEMA IF NOT EXISTS ${sql.id(schema)}`.execute(db);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
success: false,
|
|
37
|
+
migrationsExecuted: [],
|
|
38
|
+
error: error instanceof Error ? error : new Error("Failed to create schema"),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
30
41
|
const migrator = new Migrator({
|
|
31
|
-
db,
|
|
42
|
+
db: db.withSchema(schema),
|
|
32
43
|
provider: new ProgrammaticMigrationProvider(),
|
|
44
|
+
migrationTableSchema: schema,
|
|
33
45
|
});
|
|
34
|
-
|
|
46
|
+
let error;
|
|
47
|
+
let results;
|
|
48
|
+
try {
|
|
49
|
+
const result = await migrator.migrateToLatest();
|
|
50
|
+
error = result.error;
|
|
51
|
+
results = result.results;
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
error = e;
|
|
55
|
+
results = [];
|
|
56
|
+
}
|
|
35
57
|
const migrationsExecuted = results?.map((result) => result.migrationName) ?? [];
|
|
36
58
|
if (error) {
|
|
37
59
|
return {
|
|
@@ -45,10 +67,11 @@ export async function runMigrations(db) {
|
|
|
45
67
|
migrationsExecuted,
|
|
46
68
|
};
|
|
47
69
|
}
|
|
48
|
-
export async function getMigrationStatus(db) {
|
|
70
|
+
export async function getMigrationStatus(db, schema = REACTOR_SCHEMA) {
|
|
49
71
|
const migrator = new Migrator({
|
|
50
|
-
db,
|
|
72
|
+
db: db.withSchema(schema),
|
|
51
73
|
provider: new ProgrammaticMigrationProvider(),
|
|
74
|
+
migrationTableSchema: schema,
|
|
52
75
|
});
|
|
53
76
|
return await migrator.getMigrations();
|
|
54
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrator.js","sourceRoot":"","sources":["../../../../src/storage/migrations/migrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"migrator.js","sourceRoot":"","sources":["../../../../src/storage/migrations/migrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAIvC,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,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;AACvE,OAAO,KAAK,YAAY,MAAM,6BAA6B,CAAC;AAE5D,MAAM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O,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;
|
|
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;IAqB/C,aAAa,IAAI,mBAAmB,EAAE;CAGvC"}
|
package/dist/src/storage/txn.js
CHANGED
|
@@ -18,10 +18,9 @@ export class AtomicTransaction {
|
|
|
18
18
|
addOperations(...operations) {
|
|
19
19
|
for (const op of operations) {
|
|
20
20
|
this.operations.push({
|
|
21
|
-
// WRONG
|
|
21
|
+
// WRONG -- we should be using the jobId
|
|
22
22
|
jobId: uuidv4(),
|
|
23
|
-
|
|
24
|
-
opId: op.id || uuidv4(),
|
|
23
|
+
opId: op.id,
|
|
25
24
|
prevOpId: "", // Will be set during apply
|
|
26
25
|
documentId: this.documentId,
|
|
27
26
|
documentType: this.documentType,
|
|
@@ -1 +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,
|
|
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,wCAAwC;gBACxC,KAAK,EAAE,MAAM,EAAE;gBACf,IAAI,EAAE,EAAE,CAAC,EAAE;gBACX,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,17 @@
|
|
|
1
|
+
import type { IReadModel } from "../read-models/interfaces.js";
|
|
2
|
+
import type { IDocumentView, OperationWithContext } from "../storage/interfaces.js";
|
|
3
|
+
import type { ReactorSubscriptionManager } from "./react-subscription-manager.js";
|
|
4
|
+
/**
|
|
5
|
+
* A read model that notifies the subscription manager when operations are processed.
|
|
6
|
+
* This bridges the gap between operation processing and subscription callbacks.
|
|
7
|
+
*
|
|
8
|
+
* Must be processed AFTER other read models have completed and AFTER OPERATIONS_READY
|
|
9
|
+
* is emitted, so that reactor.get() returns fresh data when callbacks fire.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SubscriptionNotificationReadModel implements IReadModel {
|
|
12
|
+
private subscriptionManager;
|
|
13
|
+
private documentView?;
|
|
14
|
+
constructor(subscriptionManager: ReactorSubscriptionManager, documentView?: IDocumentView | undefined);
|
|
15
|
+
indexOperations(operations: OperationWithContext[]): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=subscription-notification-read-model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-notification-read-model.d.ts","sourceRoot":"","sources":["../../../src/subs/subscription-notification-read-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE/D,OAAO,KAAK,EACV,aAAa,EACb,oBAAoB,EACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF;;;;;;GAMG;AACH,qBAAa,iCAAkC,YAAW,UAAU;IAEhE,OAAO,CAAC,mBAAmB;IAC3B,OAAO,CAAC,YAAY,CAAC;gBADb,mBAAmB,EAAE,0BAA0B,EAC/C,YAAY,CAAC,EAAE,aAAa,YAAA;IAGhC,eAAe,CAAC,UAAU,EAAE,oBAAoB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CA2EzE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { RelationshipChangeType } from "../shared/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A read model that notifies the subscription manager when operations are processed.
|
|
4
|
+
* This bridges the gap between operation processing and subscription callbacks.
|
|
5
|
+
*
|
|
6
|
+
* Must be processed AFTER other read models have completed and AFTER OPERATIONS_READY
|
|
7
|
+
* is emitted, so that reactor.get() returns fresh data when callbacks fire.
|
|
8
|
+
*/
|
|
9
|
+
export class SubscriptionNotificationReadModel {
|
|
10
|
+
subscriptionManager;
|
|
11
|
+
documentView;
|
|
12
|
+
constructor(subscriptionManager, documentView) {
|
|
13
|
+
this.subscriptionManager = subscriptionManager;
|
|
14
|
+
this.documentView = documentView;
|
|
15
|
+
}
|
|
16
|
+
async indexOperations(operations) {
|
|
17
|
+
if (operations.length === 0)
|
|
18
|
+
return;
|
|
19
|
+
const created = [];
|
|
20
|
+
const deleted = [];
|
|
21
|
+
const updatedIds = new Set();
|
|
22
|
+
const documentTypes = new Map();
|
|
23
|
+
const parentIds = new Map();
|
|
24
|
+
for (const item of operations) {
|
|
25
|
+
const { operation, context } = item;
|
|
26
|
+
const actionType = operation.action.type;
|
|
27
|
+
documentTypes.set(context.documentId, context.documentType);
|
|
28
|
+
if (actionType === "CREATE_DOCUMENT") {
|
|
29
|
+
created.push(context.documentId);
|
|
30
|
+
}
|
|
31
|
+
else if (actionType === "DELETE_DOCUMENT") {
|
|
32
|
+
const input = operation.action.input;
|
|
33
|
+
const deletedId = input.documentId ?? context.documentId;
|
|
34
|
+
deleted.push(deletedId);
|
|
35
|
+
}
|
|
36
|
+
else if (actionType === "ADD_RELATIONSHIP") {
|
|
37
|
+
const input = operation.action.input;
|
|
38
|
+
this.subscriptionManager.notifyRelationshipChanged(input.sourceId, input.targetId, RelationshipChangeType.Added, input.childType);
|
|
39
|
+
}
|
|
40
|
+
else if (actionType === "REMOVE_RELATIONSHIP") {
|
|
41
|
+
const input = operation.action.input;
|
|
42
|
+
this.subscriptionManager.notifyRelationshipChanged(input.sourceId, input.targetId, RelationshipChangeType.Removed, input.childType);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
if (!created.includes(context.documentId)) {
|
|
46
|
+
updatedIds.add(context.documentId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (created.length > 0) {
|
|
51
|
+
this.subscriptionManager.notifyDocumentsCreated(created, documentTypes, parentIds);
|
|
52
|
+
}
|
|
53
|
+
if (deleted.length > 0) {
|
|
54
|
+
this.subscriptionManager.notifyDocumentsDeleted(deleted, documentTypes, parentIds);
|
|
55
|
+
}
|
|
56
|
+
if (updatedIds.size > 0 && this.documentView) {
|
|
57
|
+
const documents = await Promise.all(Array.from(updatedIds).map((id) => this.documentView.get(id)));
|
|
58
|
+
this.subscriptionManager.notifyDocumentsUpdated(documents);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=subscription-notification-read-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subscription-notification-read-model.js","sourceRoot":"","sources":["../../../src/subs/subscription-notification-read-model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAO5D;;;;;;GAMG;AACH,MAAM,OAAO,iCAAiC;IAElC;IACA;IAFV,YACU,mBAA+C,EAC/C,YAA4B;QAD5B,wBAAmB,GAAnB,mBAAmB,CAA4B;QAC/C,iBAAY,GAAZ,YAAY,CAAgB;IACnC,CAAC;IAEJ,KAAK,CAAC,eAAe,CAAC,UAAkC;QACtD,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QAEpC,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;QACrC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QAChD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;QAEnD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;YAC9B,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;YACpC,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC;YAEzC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;YAE5D,IAAI,UAAU,KAAK,iBAAiB,EAAE,CAAC;gBACrC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACnC,CAAC;iBAAM,IAAI,UAAU,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,EACb,SAAS,CACV,CAAC;QACJ,CAAC;QAED,IAAI,UAAU,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7C,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CACjC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,YAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAC/D,CAAC;YACF,IAAI,CAAC,mBAAmB,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ILogger } from "../../logging/types.js";
|
|
2
|
+
import type { ISyncCursorStorage } from "../../storage/interfaces.js";
|
|
3
|
+
import type { IChannel, IChannelFactory } from "../interfaces.js";
|
|
4
|
+
import type { ChannelConfig, RemoteFilter } from "../types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Factory for creating channel instances of multiple types.
|
|
7
|
+
*
|
|
8
|
+
* Supports both "gql" channels for network-based synchronization and
|
|
9
|
+
* "internal" channels for in-process communication.
|
|
10
|
+
*/
|
|
11
|
+
export declare class CompositeChannelFactory implements IChannelFactory {
|
|
12
|
+
private readonly logger;
|
|
13
|
+
constructor(logger: ILogger);
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new channel instance based on the configuration type.
|
|
16
|
+
*
|
|
17
|
+
* @param remoteId - Unique identifier for the remote
|
|
18
|
+
* @param remoteName - Human-readable name for the remote
|
|
19
|
+
* @param config - Channel configuration including type and parameters
|
|
20
|
+
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
21
|
+
* @param collectionId - Collection ID for filtering
|
|
22
|
+
* @param filter - Remote filter configuration
|
|
23
|
+
* @returns A new channel instance
|
|
24
|
+
* @throws Error if config.type is not supported or required parameters are missing
|
|
25
|
+
*/
|
|
26
|
+
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage, collectionId: string, filter: RemoteFilter): IChannel;
|
|
27
|
+
private createGqlChannel;
|
|
28
|
+
private createPollingChannel;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=composite-channel-factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-channel-factory.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/composite-channel-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI/D;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,eAAe;IAC7D,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,MAAM,EAAE,OAAO;IAI3B;;;;;;;;;;;OAWG;IACH,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,kBAAkB,EACjC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,GACnB,QAAQ;IAqBX,OAAO,CAAC,gBAAgB;IAwExB,OAAO,CAAC,oBAAoB;CAO7B"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { GqlChannel } from "./gql-channel.js";
|
|
2
|
+
import { PollingChannel } from "./polling-channel.js";
|
|
3
|
+
/**
|
|
4
|
+
* Factory for creating channel instances of multiple types.
|
|
5
|
+
*
|
|
6
|
+
* Supports both "gql" channels for network-based synchronization and
|
|
7
|
+
* "internal" channels for in-process communication.
|
|
8
|
+
*/
|
|
9
|
+
export class CompositeChannelFactory {
|
|
10
|
+
logger;
|
|
11
|
+
constructor(logger) {
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new channel instance based on the configuration type.
|
|
16
|
+
*
|
|
17
|
+
* @param remoteId - Unique identifier for the remote
|
|
18
|
+
* @param remoteName - Human-readable name for the remote
|
|
19
|
+
* @param config - Channel configuration including type and parameters
|
|
20
|
+
* @param cursorStorage - Storage for persisting synchronization cursors
|
|
21
|
+
* @param collectionId - Collection ID for filtering
|
|
22
|
+
* @param filter - Remote filter configuration
|
|
23
|
+
* @returns A new channel instance
|
|
24
|
+
* @throws Error if config.type is not supported or required parameters are missing
|
|
25
|
+
*/
|
|
26
|
+
instance(remoteId, remoteName, config, cursorStorage, collectionId, filter) {
|
|
27
|
+
if (config.type === "gql") {
|
|
28
|
+
return this.createGqlChannel(remoteId, remoteName, config, cursorStorage, collectionId, filter);
|
|
29
|
+
}
|
|
30
|
+
if (config.type === "polling") {
|
|
31
|
+
return this.createPollingChannel(remoteId, remoteName, cursorStorage);
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`CompositeChannelFactory does not support channel type "${config.type}"`);
|
|
34
|
+
}
|
|
35
|
+
createGqlChannel(remoteId, remoteName, config, cursorStorage, collectionId, filter) {
|
|
36
|
+
const url = config.parameters.url;
|
|
37
|
+
if (typeof url !== "string" || !url) {
|
|
38
|
+
throw new Error('CompositeChannelFactory requires "url" parameter for gql channels');
|
|
39
|
+
}
|
|
40
|
+
const gqlConfig = {
|
|
41
|
+
url,
|
|
42
|
+
collectionId,
|
|
43
|
+
filter,
|
|
44
|
+
};
|
|
45
|
+
if (config.parameters.authToken !== undefined) {
|
|
46
|
+
if (typeof config.parameters.authToken !== "string") {
|
|
47
|
+
throw new Error('"authToken" parameter must be a string');
|
|
48
|
+
}
|
|
49
|
+
gqlConfig.authToken = config.parameters.authToken;
|
|
50
|
+
}
|
|
51
|
+
if (config.parameters.pollIntervalMs !== undefined) {
|
|
52
|
+
if (typeof config.parameters.pollIntervalMs !== "number") {
|
|
53
|
+
throw new Error('"pollIntervalMs" parameter must be a number');
|
|
54
|
+
}
|
|
55
|
+
gqlConfig.pollIntervalMs = config.parameters.pollIntervalMs;
|
|
56
|
+
}
|
|
57
|
+
if (config.parameters.retryBaseDelayMs !== undefined) {
|
|
58
|
+
if (typeof config.parameters.retryBaseDelayMs !== "number") {
|
|
59
|
+
throw new Error('"retryBaseDelayMs" parameter must be a number');
|
|
60
|
+
}
|
|
61
|
+
gqlConfig.retryBaseDelayMs = config.parameters.retryBaseDelayMs;
|
|
62
|
+
}
|
|
63
|
+
if (config.parameters.retryMaxDelayMs !== undefined) {
|
|
64
|
+
if (typeof config.parameters.retryMaxDelayMs !== "number") {
|
|
65
|
+
throw new Error('"retryMaxDelayMs" parameter must be a number');
|
|
66
|
+
}
|
|
67
|
+
gqlConfig.retryMaxDelayMs = config.parameters.retryMaxDelayMs;
|
|
68
|
+
}
|
|
69
|
+
if (config.parameters.maxFailures !== undefined) {
|
|
70
|
+
if (typeof config.parameters.maxFailures !== "number") {
|
|
71
|
+
throw new Error('"maxFailures" parameter must be a number');
|
|
72
|
+
}
|
|
73
|
+
gqlConfig.maxFailures = config.parameters.maxFailures;
|
|
74
|
+
}
|
|
75
|
+
if (config.parameters.fetchFn !== undefined) {
|
|
76
|
+
if (typeof config.parameters.fetchFn !== "function") {
|
|
77
|
+
throw new Error('"fetchFn" parameter must be a function');
|
|
78
|
+
}
|
|
79
|
+
gqlConfig.fetchFn = config.parameters.fetchFn;
|
|
80
|
+
}
|
|
81
|
+
return new GqlChannel(this.logger, remoteId, remoteName, cursorStorage, gqlConfig);
|
|
82
|
+
}
|
|
83
|
+
createPollingChannel(remoteId, remoteName, cursorStorage) {
|
|
84
|
+
return new PollingChannel(remoteId, remoteName, cursorStorage);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=composite-channel-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-channel-factory.js","sourceRoot":"","sources":["../../../../src/sync/channels/composite-channel-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IACjB,MAAM,CAAU;IAEjC,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,QAAQ,CACN,QAAgB,EAChB,UAAkB,EAClB,MAAqB,EACrB,aAAiC,EACjC,YAAoB,EACpB,MAAoB;QAEpB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,gBAAgB,CAC1B,QAAQ,EACR,UAAU,EACV,MAAM,EACN,aAAa,EACb,YAAY,EACZ,MAAM,CACP,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,IAAI,KAAK,CACb,0DAA0D,MAAM,CAAC,IAAI,GAAG,CACzE,CAAC;IACJ,CAAC;IAEO,gBAAgB,CACtB,QAAgB,EAChB,UAAkB,EAClB,MAAqB,EACrB,aAAiC,EACjC,YAAoB,EACpB,MAAoB;QAEpB,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;QAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;QACJ,CAAC;QAED,MAAM,SAAS,GAAqB;YAClC,GAAG;YACH,YAAY;YACZ,MAAM;SACP,CAAC;QAEF,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,S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AM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;YAC9D,CAAC;YACD,SAAS,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC;QACxD,CAAC;QAED,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC5C,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBACpD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;YACD,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAuB,CAAC;QAChE,CAAC;QAED,OAAO,IAAI,UAAU,CACnB,IAAI,CAAC,MAAM,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EACb,SAAS,CACV,CAAC;IACJ,CAAC;IAEO,oBAAoB,CAC1B,QAAgB,EAChB,UAAkB,EAClB,aAAiC;QAEjC,OAAO,IAAI,cAAc,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,CAAC,CAAC;IACjE,CAAC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { ILogger } from "../../logging/types.js";
|
|
1
2
|
import type { ISyncCursorStorage } from "../../storage/interfaces.js";
|
|
2
3
|
import type { IChannel, IChannelFactory } from "../interfaces.js";
|
|
3
|
-
import type { ChannelConfig } from "../types.js";
|
|
4
|
+
import type { ChannelConfig, RemoteFilter } from "../types.js";
|
|
4
5
|
/**
|
|
5
6
|
* Factory for creating GqlChannel instances.
|
|
6
7
|
*
|
|
@@ -8,6 +9,8 @@ import type { ChannelConfig } from "../types.js";
|
|
|
8
9
|
* instantiates GqlChannel instances for network-based synchronization.
|
|
9
10
|
*/
|
|
10
11
|
export declare class GqlChannelFactory implements IChannelFactory {
|
|
12
|
+
private readonly logger;
|
|
13
|
+
constructor(logger: ILogger);
|
|
11
14
|
/**
|
|
12
15
|
* Creates a new GqlChannel instance with the given configuration.
|
|
13
16
|
* See GqlChannelConfig for the expected parameters.
|
|
@@ -17,6 +20,6 @@ export declare class GqlChannelFactory implements IChannelFactory {
|
|
|
17
20
|
* @returns A new GqlChannel instance
|
|
18
21
|
* @throws Error if config.type is not "gql" or required parameters are missing
|
|
19
22
|
*/
|
|
20
|
-
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage): IChannel;
|
|
23
|
+
instance(remoteId: string, remoteName: string, config: ChannelConfig, cursorStorage: ISyncCursorStorage, collectionId: string, filter: RemoteFilter): IChannel;
|
|
21
24
|
}
|
|
22
25
|
//# sourceMappingURL=gql-channel-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql-channel-factory.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"gql-channel-factory.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel-factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG/D;;;;;GAKG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;gBAErB,MAAM,EAAE,OAAO;IAI3B;;;;;;;;OAQG;IACH,QAAQ,CACN,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,kBAAkB,EACjC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,YAAY,GACnB,QAAQ;CAwEZ"}
|
|
@@ -6,6 +6,10 @@ import { GqlChannel } from "./gql-channel.js";
|
|
|
6
6
|
* instantiates GqlChannel instances for network-based synchronization.
|
|
7
7
|
*/
|
|
8
8
|
export class GqlChannelFactory {
|
|
9
|
+
logger;
|
|
10
|
+
constructor(logger) {
|
|
11
|
+
this.logger = logger;
|
|
12
|
+
}
|
|
9
13
|
/**
|
|
10
14
|
* Creates a new GqlChannel instance with the given configuration.
|
|
11
15
|
* See GqlChannelConfig for the expected parameters.
|
|
@@ -15,7 +19,7 @@ export class GqlChannelFactory {
|
|
|
15
19
|
* @returns A new GqlChannel instance
|
|
16
20
|
* @throws Error if config.type is not "gql" or required parameters are missing
|
|
17
21
|
*/
|
|
18
|
-
instance(remoteId, remoteName, config, cursorStorage) {
|
|
22
|
+
instance(remoteId, remoteName, config, cursorStorage, collectionId, filter) {
|
|
19
23
|
if (config.type !== "gql") {
|
|
20
24
|
throw new Error(`GqlChannelFactory can only create channels of type "gql", got "${config.type}"`);
|
|
21
25
|
}
|
|
@@ -27,6 +31,8 @@ export class GqlChannelFactory {
|
|
|
27
31
|
// Extract optional parameters with validation
|
|
28
32
|
const gqlConfig = {
|
|
29
33
|
url,
|
|
34
|
+
collectionId,
|
|
35
|
+
filter,
|
|
30
36
|
};
|
|
31
37
|
if (config.parameters.authToken !== undefined) {
|
|
32
38
|
if (typeof config.parameters.authToken !== "string") {
|
|
@@ -64,7 +70,7 @@ export class GqlChannelFactory {
|
|
|
64
70
|
}
|
|
65
71
|
gqlConfig.fetchFn = config.parameters.fetchFn;
|
|
66
72
|
}
|
|
67
|
-
return new GqlChannel(remoteId, remoteName, cursorStorage, gqlConfig);
|
|
73
|
+
return new GqlChannel(this.logger, remoteId, remoteName, cursorStorage, gqlConfig);
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
//# sourceMappingURL=gql-channel-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql-channel-factory.js","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gql-channel-factory.js","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel-factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AAErE;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IACX,MAAM,CAAU;IAEjC,YAAY,MAAe;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;OAQG;IACH,QAAQ,CACN,QAAgB,EAChB,UAAkB,EAClB,MAAqB,EACrB,aAAiC,EACjC,YAAoB,EACpB,MAAoB;QAEpB,IAAI,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CACb,kEAAkE,MAAM,CAAC,IAAI,GAAG,CACjF,CAAC;QACJ,CAAC;QAED,2CAA2C;QAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC;QAClC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,GAAG,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QACJ,CAAC;QAED,8CAA8C;QAC9C,MAAM,SAAS,GAAqB;YAClC,GAAG;YACH,YAAY;YACZ,MAAM;SACP,CAAC;QAEF,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,SAAS,EAAE,CAAC;YAC9C,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;gBACpD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;YACD,SAAS,CAAC,SAAS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,SAAS,EAAE,CAAC;YAC5C,IAAI,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,KAAK,UAAU,EAAE,CAAC;gBACpD,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;YAC5D,CAAC;YACD,SAAS,CAAC,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,OAAuB,CAAC;QAChE,CAAC;QAED,OAAO,IAAI,UAAU,CACnB,IAAI,CAAC,MAAM,EACX,QAAQ,EACR,UAAU,EACV,aAAa,EACb,SAAS,CACV,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { ILogger } from "../../logging/types.js";
|
|
1
2
|
import type { ISyncCursorStorage } from "../../storage/interfaces.js";
|
|
2
3
|
import type { IChannel } from "../interfaces.js";
|
|
3
4
|
import { Mailbox } from "../mailbox.js";
|
|
4
5
|
import type { SyncOperation } from "../sync-operation.js";
|
|
6
|
+
import type { RemoteFilter } from "../types.js";
|
|
5
7
|
/**
|
|
6
8
|
* Configuration parameters for GqlChannel
|
|
7
9
|
*/
|
|
@@ -20,11 +22,16 @@ export type GqlChannelConfig = {
|
|
|
20
22
|
maxFailures?: number;
|
|
21
23
|
/** Custom fetch function for testing (default: global fetch) */
|
|
22
24
|
fetchFn?: typeof fetch;
|
|
25
|
+
/** Collection ID to synchronize */
|
|
26
|
+
collectionId: string;
|
|
27
|
+
/** Filter to apply to operations */
|
|
28
|
+
filter: RemoteFilter;
|
|
23
29
|
};
|
|
24
30
|
/**
|
|
25
31
|
* GraphQL-based synchronization channel for network communication between reactors.
|
|
26
32
|
*/
|
|
27
33
|
export declare class GqlChannel implements IChannel {
|
|
34
|
+
private readonly logger;
|
|
28
35
|
readonly inbox: Mailbox<SyncOperation>;
|
|
29
36
|
readonly outbox: Mailbox<SyncOperation>;
|
|
30
37
|
readonly deadLetter: Mailbox<SyncOperation>;
|
|
@@ -37,11 +44,15 @@ export declare class GqlChannel implements IChannel {
|
|
|
37
44
|
private failureCount;
|
|
38
45
|
private lastSuccessUtcMs?;
|
|
39
46
|
private lastFailureUtcMs?;
|
|
40
|
-
constructor(channelId: string, remoteName: string, cursorStorage: ISyncCursorStorage, config: GqlChannelConfig);
|
|
47
|
+
constructor(logger: ILogger, channelId: string, remoteName: string, cursorStorage: ISyncCursorStorage, config: GqlChannelConfig);
|
|
41
48
|
/**
|
|
42
49
|
* Shuts down the channel and prevents further operations.
|
|
43
50
|
*/
|
|
44
51
|
shutdown(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Initializes the channel by registering it on the remote server and starting polling.
|
|
54
|
+
*/
|
|
55
|
+
init(): Promise<void>;
|
|
45
56
|
/**
|
|
46
57
|
* Starts the polling loop to fetch operations from the remote.
|
|
47
58
|
*/
|
|
@@ -54,10 +65,18 @@ export declare class GqlChannel implements IChannel {
|
|
|
54
65
|
* Handles polling errors with exponential backoff.
|
|
55
66
|
*/
|
|
56
67
|
private handlePollError;
|
|
68
|
+
/**
|
|
69
|
+
* Recovers from a "Channel not found" error by re-registering and restarting polling.
|
|
70
|
+
*/
|
|
71
|
+
private recoverFromChannelNotFound;
|
|
57
72
|
/**
|
|
58
73
|
* Queries the remote GraphQL endpoint for sync envelopes.
|
|
59
74
|
*/
|
|
60
75
|
private pollSyncEnvelopes;
|
|
76
|
+
/**
|
|
77
|
+
* Registers or updates this channel on the remote server via GraphQL mutation.
|
|
78
|
+
*/
|
|
79
|
+
private touchRemoteChannel;
|
|
61
80
|
/**
|
|
62
81
|
* Handles sync operations added to the outbox by sending them to the remote.
|
|
63
82
|
*/
|
|
@@ -68,8 +87,16 @@ export declare class GqlChannel implements IChannel {
|
|
|
68
87
|
private pushSyncOperation;
|
|
69
88
|
/**
|
|
70
89
|
* Serializes a SyncEnvelope for GraphQL transport.
|
|
90
|
+
*
|
|
91
|
+
* Signatures are serialized as comma-separated strings since GraphQL schema
|
|
92
|
+
* defines them as [String!]!. Extra context fields (resultingState, ordinal)
|
|
93
|
+
* are stripped since they are not defined in OperationContextInput.
|
|
71
94
|
*/
|
|
72
95
|
private serializeEnvelope;
|
|
96
|
+
/**
|
|
97
|
+
* Serializes an action for GraphQL transport, converting signature tuples to strings.
|
|
98
|
+
*/
|
|
99
|
+
private serializeAction;
|
|
73
100
|
/**
|
|
74
101
|
* Executes a GraphQL query or mutation against the remote endpoint.
|
|
75
102
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gql-channel.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gql-channel.d.ts","sourceRoot":"","sources":["../../../../src/sync/channels/gql-channel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAEtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAgB,YAAY,EAAgB,MAAM,aAAa,CAAC;AAI5E;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iFAAiF;IACjF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,mCAAmC;IACnC,YAAY,EAAE,MAAM,CAAC;IACrB,oCAAo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