@delali/sirannon-db 0.1.8 → 0.2.1-next.18

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.
Files changed (79) hide show
  1. package/README.md +117 -989
  2. package/dist/backup-scheduler/index.d.ts +15 -1
  3. package/dist/backup-scheduler/index.mjs +2 -2
  4. package/dist/baseline-D93hcIEE.d.ts +17 -0
  5. package/dist/{change-tracker-CbmaMO-N.d.ts → change-tracker-DDmXB754.d.ts} +59 -14
  6. package/dist/chunk-2QLXDHAP.mjs +18 -0
  7. package/dist/chunk-7C36BCSN.mjs +18 -0
  8. package/dist/chunk-7FQRQH5Z.mjs +654 -0
  9. package/dist/{chunk-GEZUUIKV.mjs → chunk-7R4ER4FB.mjs} +5 -2
  10. package/dist/{chunk-BNUTBHHH.mjs → chunk-BQFQ65OL.mjs} +1 -1
  11. package/dist/{chunk-H5AB6NIR.mjs → chunk-BTTFW4Z4.mjs} +2 -15
  12. package/dist/{chunk-HHRMRFFR.mjs → chunk-CCZK6LCB.mjs} +374 -150
  13. package/dist/chunk-GVCNMPOS.mjs +130 -0
  14. package/dist/{chunk-CW6S3WL5.mjs → chunk-HCCGEIZ2.mjs} +7 -5
  15. package/dist/chunk-IWGIYDMZ.mjs +90 -0
  16. package/dist/{chunk-CJLYFDP5.mjs → chunk-OUSWVNWT.mjs} +1 -1
  17. package/dist/chunk-P2VJYRVY.mjs +714 -0
  18. package/dist/{chunk-YPYVQJ4C.mjs → chunk-PBRXXISQ.mjs} +12 -1
  19. package/dist/chunk-SBL6GN43.mjs +299 -0
  20. package/dist/chunk-TUD5CJ76.mjs +126 -0
  21. package/dist/{chunk-UXLAO6ZH.mjs → chunk-UPKKSUPA.mjs} +8 -3
  22. package/dist/chunk-VOSJBZ6Q.mjs +187 -0
  23. package/dist/{chunk-VLTICJOD.mjs → chunk-VOYGMAU7.mjs} +9 -1
  24. package/dist/chunk-WJ67DTD6.mjs +1449 -0
  25. package/dist/chunk-XF2HH5E6.mjs +226 -0
  26. package/dist/client/index.d.ts +393 -299
  27. package/dist/client/index.mjs +1265 -1327
  28. package/dist/client/topology.d.ts +109 -0
  29. package/dist/client/topology.mjs +701 -0
  30. package/dist/client-base-CmZO0v3m.d.ts +343 -0
  31. package/dist/codegen/cli.d.ts +2 -0
  32. package/dist/codegen/cli.mjs +11 -0
  33. package/dist/codegen/index.d.ts +120 -0
  34. package/dist/codegen/index.mjs +5 -0
  35. package/dist/core/index.d.ts +201 -18
  36. package/dist/core/index.mjs +2783 -504
  37. package/dist/core/writer-worker.mjs +3 -3
  38. package/dist/database-B5Qv1-cU.d.ts +380 -0
  39. package/dist/driver/better-sqlite3.d.ts +18 -1
  40. package/dist/driver/better-sqlite3.mjs +5 -5
  41. package/dist/driver/bun.d.ts +28 -0
  42. package/dist/driver/expo.d.ts +17 -0
  43. package/dist/driver/node.d.ts +18 -1
  44. package/dist/driver/node.mjs +5 -5
  45. package/dist/driver/wa-sqlite.d.ts +14 -132
  46. package/dist/{errors-5Nf5ZAEC.d.ts → errors-Dei4GdBb.d.ts} +85 -8
  47. package/dist/file-migrations/index.d.ts +59 -5
  48. package/dist/file-migrations/index.mjs +42 -37
  49. package/dist/operation-registry-hlbhqu7q.d.ts +94 -0
  50. package/dist/primary-wins-B0np8JS3.d.ts +85 -0
  51. package/dist/protocol-rqANt-9Q.d.ts +152 -0
  52. package/dist/query-types-DL3LtPvY.d.ts +95 -0
  53. package/dist/react/index.d.ts +75 -0
  54. package/dist/react/index.mjs +137 -0
  55. package/dist/replication/coordinator/etcd.d.ts +66 -4
  56. package/dist/replication/coordinator/etcd.mjs +593 -465
  57. package/dist/replication/index.d.ts +355 -175
  58. package/dist/replication/index.mjs +1515 -2046
  59. package/dist/server/index.d.ts +330 -88
  60. package/dist/server/index.mjs +1895 -454
  61. package/dist/server-options-Dab_Jvd_.d.ts +275 -0
  62. package/dist/sirannon-CMhiJa5Y.d.ts +111 -0
  63. package/dist/transport/grpc.d.ts +95 -8
  64. package/dist/transport/grpc.mjs +251 -114
  65. package/dist/transport/memory.d.ts +50 -149
  66. package/dist/transport/memory.mjs +28 -1
  67. package/dist/types-BCejqzNA.d.ts +63 -0
  68. package/dist/types-CMBcFPhb.d.ts +336 -0
  69. package/dist/types-CjhxcjhA.d.ts +123 -0
  70. package/dist/types-DyrCiWuc.d.ts +499 -0
  71. package/dist/types-rVZKnKN-.d.ts +591 -0
  72. package/package.json +65 -21
  73. package/dist/chunk-TKGHYWQ6.mjs +0 -35
  74. package/dist/database-DuGp0Rtr.d.ts +0 -127
  75. package/dist/sirannon-4SspRvP5.d.ts +0 -31
  76. package/dist/types-BEu1I_9_.d.ts +0 -139
  77. package/dist/types-BsjobKbl.d.ts +0 -274
  78. package/dist/types-D4p4UyDK.d.ts +0 -26
  79. package/dist/types-D_hQW1hr.d.ts +0 -494
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@delali/sirannon-db",
3
3
  "type": "module",
4
- "version": "0.1.8",
4
+ "version": "0.2.1-next.18",
5
5
  "description": "A production-grade library that turns SQLite databases into a networked data layer with real-time subscriptions.",
6
6
  "author": "Delali (https://sondelali.com)",
7
7
  "license": "Apache-2.0",
@@ -27,6 +27,23 @@
27
27
  "expo-sqlite",
28
28
  "pluggable"
29
29
  ],
30
+ "scripts": {
31
+ "build": "rm -rf dist && tsup",
32
+ "check:bundle": "node scripts/assert-browser-bundle.mjs",
33
+ "check:types": "node scripts/assert-consumer-types.mjs",
34
+ "check:api": "node scripts/assert-api-reports.mjs",
35
+ "api:update": "node scripts/assert-api-reports.mjs --update",
36
+ "test": "vitest run",
37
+ "test:coverage": "vitest run --coverage",
38
+ "test:e2e": "vitest run --config vitest.e2e.config.ts",
39
+ "test:failover": "vitest run --config vitest.failover.config.ts",
40
+ "test:soak": "vitest run --config vitest.soak.config.ts",
41
+ "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
42
+ "lint": "biome check --error-on-warnings .",
43
+ "lint:fix": "biome check --write .",
44
+ "format": "biome format --write .",
45
+ "proto:gen": "grpc_tools_node_protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/transport/grpc/generated --ts_proto_opt=forceLong=bigint --ts_proto_opt=esModuleInterop=true --ts_proto_opt=outputServices=grpc-js --ts_proto_opt=env=node -I src/transport/grpc/proto src/transport/grpc/proto/replication.proto"
46
+ },
30
47
  "exports": {
31
48
  ".": {
32
49
  "types": "./dist/core/index.d.ts",
@@ -41,6 +58,7 @@
41
58
  "import": "./dist/driver/node.mjs"
42
59
  },
43
60
  "./driver/bun": {
61
+ "types": "./dist/driver/bun.d.ts",
44
62
  "import": "./dist/driver/bun.mjs"
45
63
  },
46
64
  "./driver/wa-sqlite": {
@@ -48,6 +66,7 @@
48
66
  "import": "./dist/driver/wa-sqlite.mjs"
49
67
  },
50
68
  "./driver/expo": {
69
+ "types": "./dist/driver/expo.d.ts",
51
70
  "import": "./dist/driver/expo.mjs"
52
71
  },
53
72
  "./file-migrations": {
@@ -66,6 +85,18 @@
66
85
  "types": "./dist/client/index.d.ts",
67
86
  "import": "./dist/client/index.mjs"
68
87
  },
88
+ "./client/topology": {
89
+ "types": "./dist/client/topology.d.ts",
90
+ "import": "./dist/client/topology.mjs"
91
+ },
92
+ "./react": {
93
+ "types": "./dist/react/index.d.ts",
94
+ "import": "./dist/react/index.mjs"
95
+ },
96
+ "./codegen": {
97
+ "types": "./dist/codegen/index.d.ts",
98
+ "import": "./dist/codegen/index.mjs"
99
+ },
69
100
  "./replication": {
70
101
  "types": "./dist/replication/index.d.ts",
71
102
  "import": "./dist/replication/index.mjs"
@@ -83,6 +114,22 @@
83
114
  "import": "./dist/transport/grpc.mjs"
84
115
  }
85
116
  },
117
+ "typesVersions": {
118
+ "*": {
119
+ "react": [
120
+ "./dist/react/index.d.ts"
121
+ ],
122
+ "codegen": [
123
+ "./dist/codegen/index.d.ts"
124
+ ],
125
+ "client/topology": [
126
+ "./dist/client/topology.d.ts"
127
+ ]
128
+ }
129
+ },
130
+ "bin": {
131
+ "sirannon-codegen": "./dist/codegen/cli.mjs"
132
+ },
86
133
  "files": [
87
134
  "dist",
88
135
  "LICENSE",
@@ -95,9 +142,10 @@
95
142
  "@bufbuild/protobuf": ">=2.0.0",
96
143
  "@grpc/grpc-js": ">=1.10.0",
97
144
  "better-sqlite3": ">=12.0.0",
98
- "expo-sqlite": ">=14.0.0",
99
145
  "etcd3": ">=1.1.2",
146
+ "expo-sqlite": ">=14.0.0",
100
147
  "grpc-health-check": ">=2.0.0",
148
+ "react": ">=19.0.0",
101
149
  "uWebSockets.js": ">=20.0.0",
102
150
  "wa-sqlite": ">=1.0.0"
103
151
  },
@@ -125,38 +173,34 @@
125
173
  },
126
174
  "wa-sqlite": {
127
175
  "optional": true
176
+ },
177
+ "react": {
178
+ "optional": true
128
179
  }
129
180
  },
130
181
  "devDependencies": {
131
182
  "@bufbuild/protobuf": "2.11.0",
132
- "@grpc/grpc-js": "1.14.3",
183
+ "@grpc/grpc-js": "1.14.4",
184
+ "@microsoft/api-extractor": "7.58.12",
133
185
  "@types/better-sqlite3": "7.6.13",
134
- "@types/node": "25.3.3",
186
+ "@types/node": "26.1.2",
187
+ "@types/react": "19.2.15",
188
+ "@types/react-dom": "19.2.3",
135
189
  "@vitest/coverage-v8": "4.0.18",
136
- "better-sqlite3": "12.6.2",
190
+ "better-sqlite3": "13.0.2",
137
191
  "etcd3": "1.1.2",
192
+ "expo-sqlite": "55.0.10",
138
193
  "grpc-health-check": "2.1.0",
139
194
  "grpc-tools": "1.13.1",
195
+ "jsdom": "29.1.1",
196
+ "react": "19.2.6",
197
+ "react-dom": "19.2.6",
140
198
  "selfsigned": "5.5.0",
141
199
  "ts-proto": "2.11.6",
142
200
  "tsup": "8.5.1",
143
201
  "tsx": "4.21.0",
144
202
  "typescript": "5.9.3",
145
- "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.58.0",
203
+ "uWebSockets.js": "github:uNetworking/uWebSockets.js#v20.69.0",
146
204
  "vitest": "4.0.18"
147
- },
148
- "scripts": {
149
- "build": "rm -rf dist && tsup",
150
- "check:bundle": "node scripts/assert-browser-bundle.mjs",
151
- "test": "vitest run",
152
- "test:coverage": "vitest run --coverage",
153
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
154
- "test:failover": "vitest run --config vitest.failover.config.ts",
155
- "test:soak": "vitest run --config vitest.soak.config.ts",
156
- "typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
157
- "lint": "biome check --error-on-warnings .",
158
- "lint:fix": "biome check --write .",
159
- "format": "biome format --write .",
160
- "proto:gen": "grpc_tools_node_protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=src/transport/grpc/generated --ts_proto_opt=forceLong=bigint --ts_proto_opt=esModuleInterop=true --ts_proto_opt=outputServices=grpc-js --ts_proto_opt=env=node -I src/transport/grpc/proto src/transport/grpc/proto/replication.proto"
161
205
  }
162
- }
206
+ }
@@ -1,35 +0,0 @@
1
- import { query, execute, executeBatch } from './chunk-CW6S3WL5.mjs';
2
-
3
- // src/core/transaction.ts
4
- var Transaction = class _Transaction {
5
- constructor(conn) {
6
- this.conn = conn;
7
- }
8
- _lastInsertRowId = 0;
9
- async query(sql, params) {
10
- return query(this.conn, sql, params);
11
- }
12
- async execute(sql, params) {
13
- const result = await execute(this.conn, sql, params);
14
- this._lastInsertRowId = result.lastInsertRowId;
15
- return result;
16
- }
17
- async executeBatch(sql, paramsBatch) {
18
- const results = await executeBatch(this.conn, sql, paramsBatch);
19
- if (results.length > 0) {
20
- this._lastInsertRowId = results[results.length - 1].lastInsertRowId;
21
- }
22
- return results;
23
- }
24
- get lastInsertRowId() {
25
- return this._lastInsertRowId;
26
- }
27
- static async run(conn, fn) {
28
- return conn.transaction(async (txConn) => {
29
- const tx = new _Transaction(txConn);
30
- return fn(tx);
31
- });
32
- }
33
- };
34
-
35
- export { Transaction };
@@ -1,127 +0,0 @@
1
- import { Q as QueryHookContext, k as ConnectionHookContext, l as BeforeSubscribeHook, H as HookConfig, M as MetricsConfig, m as QueryMetrics, n as ConnectionMetrics, o as CDCMetrics, a as SQLiteDriver, D as DatabaseOptions, P as Params, p as QueryOptions, E as ExecuteResult, q as BulkLoadOptions, h as BulkLoadResult, T as Transaction, e as SQLiteConnection, r as SubscriptionBuilder, f as BackupScheduleOptions, B as BeforeQueryHook, A as AfterQueryHook } from './types-D_hQW1hr.js';
2
- import { M as Migration, a as MigrationResult, R as RollbackResult } from './types-D4p4UyDK.js';
3
-
4
- type HookEvent = 'beforeQuery' | 'afterQuery' | 'beforeConnect' | 'databaseOpen' | 'databaseClose' | 'beforeSubscribe';
5
- type SubscribeHookContext = Parameters<BeforeSubscribeHook>[0];
6
- interface HookEventContextMap {
7
- beforeQuery: QueryHookContext;
8
- afterQuery: QueryHookContext & {
9
- durationMs: number;
10
- };
11
- beforeConnect: ConnectionHookContext;
12
- databaseOpen: ConnectionHookContext;
13
- databaseClose: ConnectionHookContext;
14
- beforeSubscribe: SubscribeHookContext;
15
- }
16
- type HookHandler<E extends HookEvent> = (ctx: HookEventContextMap[E]) => void | Promise<void>;
17
- type HookDispose = () => void;
18
-
19
- declare class HookRegistry {
20
- private hooks;
21
- constructor(config?: HookConfig);
22
- register<E extends HookEvent>(event: E, hook: HookHandler<E>): HookDispose;
23
- invoke<E extends HookEvent>(event: E, ctx: HookEventContextMap[E]): Promise<void>;
24
- invokeSync<E extends HookEvent>(event: E, ctx: HookEventContextMap[E]): void;
25
- has(event: HookEvent): boolean;
26
- count(event: HookEvent): number;
27
- clear(event?: HookEvent): void;
28
- private addHook;
29
- private loadConfig;
30
- }
31
-
32
- declare class MetricsCollector {
33
- private config;
34
- constructor(config?: MetricsConfig);
35
- trackQuery<T>(fn: () => Promise<T>, context: Omit<QueryMetrics, 'durationMs' | 'error'>): Promise<T>;
36
- trackConnection(metrics: ConnectionMetrics): void;
37
- trackCDCEvent(metrics: CDCMetrics): void;
38
- get active(): boolean;
39
- }
40
-
41
- interface DatabaseInternals {
42
- parentHooks?: HookRegistry;
43
- metrics?: MetricsCollector;
44
- }
45
- declare class Database {
46
- readonly id: string;
47
- readonly path: string;
48
- readonly readOnly: boolean;
49
- private readonly pool;
50
- private readonly driver;
51
- private readonly synchronous;
52
- private readonly walMode;
53
- private readonly writerLock;
54
- private readonly writeGate;
55
- private readonly groupCommitter;
56
- private readonly closeListeners;
57
- private _closed;
58
- private readonly cdc;
59
- private readonly hookRegistry;
60
- private readonly observer;
61
- private readonly backups;
62
- private constructor();
63
- static create(id: string, path: string, driver: SQLiteDriver, options?: DatabaseOptions, internals?: DatabaseInternals): Promise<Database>;
64
- query<T = Record<string, unknown>>(sql: string, params?: Params, options?: QueryOptions): Promise<T[]>;
65
- /**
66
- * Returns query rows already encoded for the wire (safe-range integers as
67
- * plain numbers, larger integers and BLOBs as tagged envelopes) in a single
68
- * pass. The server response path uses this so a read walks its values once
69
- * rather than narrowing on the driver and re-scanning to tag.
70
- */
71
- queryForWire(sql: string, params?: Params, options?: QueryOptions): Promise<unknown[]>;
72
- queryOne<T = Record<string, unknown>>(sql: string, params?: Params, options?: QueryOptions): Promise<T | undefined>;
73
- /**
74
- * On a single-connection driver the reader is the writer, so serialise the
75
- * read through the writer lock to avoid a bulk load's uncommitted rows.
76
- */
77
- private runRead;
78
- execute(sql: string, params?: Params, options?: QueryOptions): Promise<ExecuteResult>;
79
- executeBatch(sql: string, paramsBatch: Params[], options?: QueryOptions): Promise<ExecuteResult[]>;
80
- private runInTransaction;
81
- /**
82
- * Load rows with relaxed writer durability. The load holds the writer lock
83
- * for its whole duration, so no other write commits under the relaxed level
84
- * and no two loads race on the shared `synchronous` setting; the configured
85
- * level is restored before this resolves, whether the load succeeds or
86
- * fails. The load runs in one transaction, so one commit and one durability
87
- * barrier cover the whole batch. Rows are summed rather than returned
88
- * per-row to bound memory on large loads. Like `execute` and `transaction`,
89
- * this writes only to the local database; under replication the server routes
90
- * loads through the engine, not through this method.
91
- */
92
- bulkLoad(sql: string, paramsBatch: Params[], options?: BulkLoadOptions): Promise<BulkLoadResult>;
93
- /**
94
- * Takes the statements up front rather than a callback, since a group cannot wait on an
95
- * arbitrary caller-supplied callback without delaying every transaction beside it.
96
- */
97
- executeTransaction(statements: readonly {
98
- sql: string;
99
- params?: Params;
100
- }[]): Promise<ExecuteResult[]>;
101
- private runStatementsAlone;
102
- transaction<T>(fn: (tx: Transaction) => Promise<T>): Promise<T>;
103
- watch(table: string): Promise<void>;
104
- /**
105
- * Runs a CDC maintenance write (change-log pruning) on the shared writer
106
- * under the writer lock. Serialising it with application writes keeps it
107
- * from becoming a second writer that contends for SQLite's single write
108
- * lock and stalls the event loop on `busy_timeout`.
109
- */
110
- runCdcMaintenance(op: (writer: SQLiteConnection) => Promise<unknown>): Promise<void>;
111
- unwatch(table: string): Promise<void>;
112
- on(table: string): SubscriptionBuilder;
113
- migrate(migrations: Migration[]): Promise<MigrationResult>;
114
- rollback(migrations: Migration[], version?: number): Promise<RollbackResult>;
115
- backup(destPath: string): Promise<void>;
116
- scheduleBackup(options: BackupScheduleOptions): void;
117
- loadExtension(extensionPath: string): Promise<void>;
118
- onBeforeQuery(hook: BeforeQueryHook): void;
119
- onAfterQuery(hook: AfterQueryHook): void;
120
- addCloseListener(fn: () => void | Promise<void>): void;
121
- close(): Promise<void>;
122
- get closed(): boolean;
123
- get readerCount(): number;
124
- private ensureOpen;
125
- }
126
-
127
- export { Database as D, type HookDispose as H, MetricsCollector as M, type SubscribeHookContext as S, type HookEvent as a, type HookEventContextMap as b, type HookHandler as c, HookRegistry as d };
@@ -1,31 +0,0 @@
1
- import { D as Database } from './database-DuGp0Rtr.js';
2
- import { S as SirannonOptions, a as SQLiteDriver, D as DatabaseOptions, B as BeforeQueryHook, A as AfterQueryHook, b as BeforeConnectHook, c as DatabaseOpenHook, d as DatabaseCloseHook } from './types-D_hQW1hr.js';
3
-
4
- declare class Sirannon {
5
- readonly options: SirannonOptions;
6
- private readonly dbs;
7
- private readonly opening;
8
- private _shutdown;
9
- private readonly _driver;
10
- private readonly hookRegistry;
11
- private readonly metricsCollector;
12
- private readonly lifecycleManager;
13
- constructor(options: SirannonOptions);
14
- get driver(): SQLiteDriver;
15
- open(id: string, path: string, options?: DatabaseOptions): Promise<Database>;
16
- private withRegistryDefaults;
17
- close(id: string): Promise<void>;
18
- get(id: string): Database | undefined;
19
- resolve(id: string): Promise<Database | undefined>;
20
- has(id: string): boolean;
21
- databases(): Map<string, Database>;
22
- shutdown(): Promise<void>;
23
- onBeforeQuery(hook: BeforeQueryHook): void;
24
- onAfterQuery(hook: AfterQueryHook): void;
25
- onBeforeConnect(hook: BeforeConnectHook): void;
26
- onDatabaseOpen(hook: DatabaseOpenHook): void;
27
- onDatabaseClose(hook: DatabaseCloseHook): void;
28
- private ensureRunning;
29
- }
30
-
31
- export { Sirannon as S };
@@ -1,139 +0,0 @@
1
- type CoordinatorLeaseKind = 'controller' | 'node-session';
2
- type CoordinatorWatchDisposer = () => void | Promise<void>;
3
- interface CoordinatorLease {
4
- id: string;
5
- kind: CoordinatorLeaseKind;
6
- clusterId: string;
7
- holderId: string;
8
- ttlMs: number;
9
- grantedAtMs: number;
10
- expiresAtMs: number;
11
- metadata?: Record<string, unknown>;
12
- }
13
- interface AcquireControllerLeaseInput {
14
- clusterId: string;
15
- holderId: string;
16
- ttlMs: number;
17
- metadata?: Record<string, unknown>;
18
- }
19
- type AcquireControllerLeaseResult = {
20
- acquired: true;
21
- lease: CoordinatorLease;
22
- } | {
23
- acquired: false;
24
- lease: CoordinatorLease | null;
25
- };
26
- interface CoordinatorCompatibilityMetadata {
27
- packageVersion?: string;
28
- specVersion?: string;
29
- protocolVersion?: string;
30
- }
31
- interface RegisterNodeSessionInput {
32
- clusterId: string;
33
- nodeId: string;
34
- ttlMs: number;
35
- endpoint?: string;
36
- groupIds?: string[];
37
- dataBearing?: boolean;
38
- voting?: boolean;
39
- compatibility?: CoordinatorCompatibilityMetadata;
40
- metadata?: Record<string, unknown>;
41
- }
42
- interface CoordinatorNodeSession {
43
- clusterId: string;
44
- nodeId: string;
45
- lease: CoordinatorLease;
46
- endpoint?: string;
47
- groupIds: string[];
48
- dataBearing: boolean;
49
- voting: boolean;
50
- compatibility?: CoordinatorCompatibilityMetadata;
51
- metadata?: Record<string, unknown>;
52
- }
53
- interface CoordinatorPrimary {
54
- nodeId: string;
55
- endpoint?: string;
56
- }
57
- interface ReplicationGroupState {
58
- clusterId: string;
59
- groupId: string;
60
- votingDataBearingNodeIds: string[];
61
- currentPrimary: CoordinatorPrimary | null;
62
- primaryTerm: bigint;
63
- durabilityPointSeq: bigint;
64
- inSyncNodeIds: string[];
65
- drainingNodeIds: string[];
66
- repairingNodeIds: string[];
67
- faultedNodeIds: string[];
68
- compatibility?: CoordinatorCompatibilityMetadata;
69
- updatedAtMs: number;
70
- }
71
- interface SetReplicationGroupStateInput {
72
- clusterId: string;
73
- groupId: string;
74
- votingDataBearingNodeIds: string[];
75
- currentPrimary?: CoordinatorPrimary | null;
76
- primaryTerm?: bigint;
77
- durabilityPointSeq?: bigint;
78
- inSyncNodeIds?: string[];
79
- drainingNodeIds?: string[];
80
- repairingNodeIds?: string[];
81
- faultedNodeIds?: string[];
82
- compatibility?: CoordinatorCompatibilityMetadata;
83
- }
84
- interface CompareAndAdvancePrimaryTermInput {
85
- clusterId: string;
86
- groupId: string;
87
- expectedPrimaryTerm: bigint;
88
- nextPrimary: CoordinatorPrimary;
89
- }
90
- interface CompareAndAdvancePrimaryTermResult {
91
- advanced: boolean;
92
- state: ReplicationGroupState | null;
93
- }
94
- interface UpdateInSyncSetInput {
95
- clusterId: string;
96
- groupId: string;
97
- inSyncNodeIds: string[];
98
- durabilityPointSeq?: bigint;
99
- }
100
- interface AdmitNodeToInSyncSetInput {
101
- clusterId: string;
102
- groupId: string;
103
- nodeId: string;
104
- sourceNodeId: string;
105
- appliedSeq: bigint;
106
- }
107
- interface UpdateNodeMaintenanceInput {
108
- clusterId: string;
109
- groupId: string;
110
- nodeId: string;
111
- draining?: boolean;
112
- repairing?: boolean;
113
- faulted?: boolean;
114
- }
115
- interface PromoteEligibleReplicaInput {
116
- clusterId: string;
117
- groupId: string;
118
- excludeNodeIds?: string[];
119
- }
120
- type ReplicationGroupWatcher = (state: ReplicationGroupState) => void;
121
- interface ClusterCoordinator {
122
- tryAcquireControllerLease(input: AcquireControllerLeaseInput): Promise<AcquireControllerLeaseResult>;
123
- renewLease(leaseId: string, ttlMs: number): Promise<boolean>;
124
- releaseLease(leaseId: string): Promise<boolean>;
125
- registerNodeSession(input: RegisterNodeSessionInput): Promise<CoordinatorNodeSession>;
126
- getLiveNodeSession(clusterId: string, nodeId: string): Promise<CoordinatorNodeSession | null>;
127
- deregisterNodeSession(clusterId: string, nodeId: string): Promise<void>;
128
- setReplicationGroupState(input: SetReplicationGroupStateInput): Promise<ReplicationGroupState>;
129
- getReplicationGroupState(clusterId: string, groupId: string): Promise<ReplicationGroupState | null>;
130
- watchReplicationGroup(clusterId: string, groupId: string, watcher: ReplicationGroupWatcher): CoordinatorWatchDisposer | Promise<CoordinatorWatchDisposer>;
131
- compareAndAdvancePrimaryTerm(input: CompareAndAdvancePrimaryTermInput): Promise<CompareAndAdvancePrimaryTermResult>;
132
- updateInSyncSet(input: UpdateInSyncSetInput): Promise<ReplicationGroupState | null>;
133
- admitNodeToInSyncSet(input: AdmitNodeToInSyncSetInput): Promise<ReplicationGroupState | null>;
134
- updateNodeMaintenance(input: UpdateNodeMaintenanceInput): Promise<ReplicationGroupState | null>;
135
- promoteEligibleReplica(input: PromoteEligibleReplicaInput): Promise<ReplicationGroupState>;
136
- close?(): Promise<void>;
137
- }
138
-
139
- export type { AcquireControllerLeaseInput as A, ClusterCoordinator as C, PromoteEligibleReplicaInput as P, RegisterNodeSessionInput as R, SetReplicationGroupStateInput as S, UpdateInSyncSetInput as U, AcquireControllerLeaseResult as a, CoordinatorNodeSession as b, ReplicationGroupState as c, ReplicationGroupWatcher as d, CoordinatorWatchDisposer as e, CompareAndAdvancePrimaryTermInput as f, CompareAndAdvancePrimaryTermResult as g, AdmitNodeToInSyncSetInput as h, UpdateNodeMaintenanceInput as i, CoordinatorCompatibilityMetadata as j, CoordinatorLease as k, CoordinatorPrimary as l };