@delali/sirannon-db 0.1.4 → 0.1.5
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/README.md +415 -39
- package/dist/backup-scheduler/index.d.ts +2 -2
- package/dist/change-tracker-CFTQ9TSn.d.ts +89 -0
- package/dist/chunk-3MCMONVP.mjs +115 -0
- package/dist/chunk-ER7ODTDA.mjs +23 -0
- package/dist/chunk-GS7T5YMI.mjs +51 -0
- package/dist/{chunk-AX66KWBR.mjs → chunk-UTO3ZAFS.mjs} +226 -64
- package/dist/chunk-UVMVN3OT.mjs +111 -0
- package/dist/client/index.d.ts +99 -42
- package/dist/client/index.mjs +726 -26
- package/dist/core/index.d.ts +11 -108
- package/dist/core/index.mjs +134 -168
- package/dist/{sirannon-B1oTfebD.d.ts → database-BVY1GqE7.d.ts} +8 -33
- package/dist/errors-C00ed08Q.d.ts +101 -0
- package/dist/file-migrations/index.d.ts +2 -2
- package/dist/{index-hXiis3N-.d.ts → index-CLdNrcPz.d.ts} +1 -1
- package/dist/replication/coordinator/etcd.d.ts +44 -0
- package/dist/replication/coordinator/etcd.mjs +650 -0
- package/dist/replication/index.d.ts +491 -0
- package/dist/replication/index.mjs +3784 -0
- package/dist/server/index.d.ts +14 -3
- package/dist/server/index.mjs +262 -44
- package/dist/sirannon-Cd-lK6T0.d.ts +31 -0
- package/dist/transport/grpc.d.ts +316 -0
- package/dist/transport/grpc.mjs +3341 -0
- package/dist/transport/memory.d.ts +221 -0
- package/dist/transport/memory.mjs +337 -0
- package/dist/types-B2byqt0B.d.ts +273 -0
- package/dist/types-BEu1I_9_.d.ts +139 -0
- package/dist/types-BeozgNPr.d.ts +26 -0
- package/dist/{types-DtDutWRU.d.ts → types-D-74JiXb.d.ts} +78 -2
- package/package.json +54 -10
- package/dist/types-DRkJlqex.d.ts +0 -38
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base class for all sirannon-db errors. Extend this class to create
|
|
3
|
+
* domain-specific errors that carry a machine-readable {@link code}.
|
|
4
|
+
*/
|
|
5
|
+
declare class SirannonError extends Error {
|
|
6
|
+
readonly code: string;
|
|
7
|
+
constructor(message: string, code: string);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Thrown when a database ID cannot be resolved in the registry.
|
|
11
|
+
* This typically means the database was never opened or has already been closed.
|
|
12
|
+
*/
|
|
13
|
+
declare class DatabaseNotFoundError extends SirannonError {
|
|
14
|
+
constructor(id: string);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Thrown when attempting to register a database with an ID that is already
|
|
18
|
+
* in use. Each database ID must be unique within the registry.
|
|
19
|
+
*/
|
|
20
|
+
declare class DatabaseAlreadyExistsError extends SirannonError {
|
|
21
|
+
constructor(id: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Thrown when a write operation is attempted on a database that was opened
|
|
25
|
+
* in read-only mode.
|
|
26
|
+
*/
|
|
27
|
+
declare class ReadOnlyError extends SirannonError {
|
|
28
|
+
constructor(id: string);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Thrown when SQLite fails to execute a statement. The {@link sql} property
|
|
32
|
+
* holds the original SQL string that caused the failure, which is useful for
|
|
33
|
+
* debugging and logging.
|
|
34
|
+
*/
|
|
35
|
+
declare class QueryError extends SirannonError {
|
|
36
|
+
readonly sql: string;
|
|
37
|
+
constructor(message: string, sql: string);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Thrown when a transaction cannot be committed or is forcibly rolled back.
|
|
41
|
+
* Check the message for the underlying cause.
|
|
42
|
+
*/
|
|
43
|
+
declare class TransactionError extends SirannonError {
|
|
44
|
+
constructor(message: string);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Thrown when a migration step fails. The {@link version} property identifies
|
|
48
|
+
* which schema version triggered the error so the failure can be pinpointed
|
|
49
|
+
* in the migration history.
|
|
50
|
+
*/
|
|
51
|
+
declare class MigrationError extends SirannonError {
|
|
52
|
+
readonly version: number;
|
|
53
|
+
constructor(message: string, version: number, code?: string);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Thrown when a before-hook explicitly rejects an operation. The optional
|
|
57
|
+
* `reason` string is surfaced in the message so callers can distinguish
|
|
58
|
+
* between different hook policies.
|
|
59
|
+
*/
|
|
60
|
+
declare class HookDeniedError extends SirannonError {
|
|
61
|
+
constructor(hookName: string, reason?: string);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Thrown when the change-data-capture pipeline encounters an unrecoverable
|
|
65
|
+
* error, such as a failed event dispatch or a corrupt change record.
|
|
66
|
+
*/
|
|
67
|
+
declare class CDCError extends SirannonError {
|
|
68
|
+
constructor(message: string);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Thrown when a backup operation fails, whether that is an online backup via
|
|
72
|
+
* the SQLite backup API or a file-level copy.
|
|
73
|
+
*/
|
|
74
|
+
declare class BackupError extends SirannonError {
|
|
75
|
+
constructor(message: string);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Thrown when the connection pool reaches its limit or is configured with
|
|
79
|
+
* invalid parameters such as a minimum size greater than the maximum.
|
|
80
|
+
*/
|
|
81
|
+
declare class ConnectionPoolError extends SirannonError {
|
|
82
|
+
constructor(message: string);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Thrown when opening a new database would exceed the configured cap on
|
|
86
|
+
* concurrently open databases. Close an existing database before opening
|
|
87
|
+
* another one.
|
|
88
|
+
*/
|
|
89
|
+
declare class MaxDatabasesError extends SirannonError {
|
|
90
|
+
constructor(max: number);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Thrown when a native SQLite extension cannot be loaded. The `path` argument
|
|
94
|
+
* is the filesystem path passed to `load_extension`, and the optional `cause`
|
|
95
|
+
* string carries the error detail reported by SQLite.
|
|
96
|
+
*/
|
|
97
|
+
declare class ExtensionError extends SirannonError {
|
|
98
|
+
constructor(path: string, cause?: string);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { BackupError as B, CDCError as C, DatabaseAlreadyExistsError as D, ExtensionError as E, HookDeniedError as H, MaxDatabasesError as M, QueryError as Q, ReadOnlyError as R, SirannonError as S, TransactionError as T, ConnectionPoolError as a, DatabaseNotFoundError as b, MigrationError as c };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as SQLiteConnection } from './types-BFSsG77t.js';
|
|
2
|
-
import {
|
|
2
|
+
import { m as BackupScheduleOptions } from './types-D-74JiXb.js';
|
|
3
3
|
|
|
4
4
|
declare class BackupManager {
|
|
5
5
|
backup(conn: SQLiteConnection, destPath: string): Promise<void>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IOptions } from 'etcd3';
|
|
2
|
+
import { C as ClusterCoordinator, A as AcquireControllerLeaseInput, a as AcquireControllerLeaseResult, R as RegisterNodeSessionInput, b as CoordinatorNodeSession, S as SetReplicationGroupStateInput, c as ReplicationGroupState, d as ReplicationGroupWatcher, e as CoordinatorWatchDisposer, f as CompareAndAdvancePrimaryTermInput, g as CompareAndAdvancePrimaryTermResult, U as UpdateInSyncSetInput, h as AdmitNodeToInSyncSetInput, i as UpdateNodeMaintenanceInput, P as PromoteEligibleReplicaInput } from '../../types-BEu1I_9_.js';
|
|
3
|
+
|
|
4
|
+
interface EtcdClusterCoordinatorOptions {
|
|
5
|
+
hosts: string | string[];
|
|
6
|
+
keyPrefix: string;
|
|
7
|
+
credentials?: IOptions['credentials'];
|
|
8
|
+
auth?: IOptions['auth'];
|
|
9
|
+
grpcOptions?: IOptions['grpcOptions'];
|
|
10
|
+
dialTimeoutMs?: number;
|
|
11
|
+
defaultCallTimeoutMs?: number;
|
|
12
|
+
allowInsecure?: boolean;
|
|
13
|
+
onWatcherError?: (error: Error) => void;
|
|
14
|
+
}
|
|
15
|
+
declare class EtcdClusterCoordinator implements ClusterCoordinator {
|
|
16
|
+
private readonly client;
|
|
17
|
+
private readonly namespace;
|
|
18
|
+
private readonly onWatcherError;
|
|
19
|
+
private readonly leases;
|
|
20
|
+
private readonly watchers;
|
|
21
|
+
constructor(options: EtcdClusterCoordinatorOptions);
|
|
22
|
+
tryAcquireControllerLease(input: AcquireControllerLeaseInput): Promise<AcquireControllerLeaseResult>;
|
|
23
|
+
renewLease(leaseId: string, ttlMs: number): Promise<boolean>;
|
|
24
|
+
releaseLease(leaseId: string): Promise<boolean>;
|
|
25
|
+
registerNodeSession(input: RegisterNodeSessionInput): Promise<CoordinatorNodeSession>;
|
|
26
|
+
getLiveNodeSession(clusterId: string, nodeId: string): Promise<CoordinatorNodeSession | null>;
|
|
27
|
+
deregisterNodeSession(clusterId: string, nodeId: string): Promise<void>;
|
|
28
|
+
setReplicationGroupState(input: SetReplicationGroupStateInput): Promise<ReplicationGroupState>;
|
|
29
|
+
getReplicationGroupState(clusterId: string, groupId: string): Promise<ReplicationGroupState | null>;
|
|
30
|
+
watchReplicationGroup(clusterId: string, groupId: string, watcher: ReplicationGroupWatcher): Promise<CoordinatorWatchDisposer>;
|
|
31
|
+
compareAndAdvancePrimaryTerm(input: CompareAndAdvancePrimaryTermInput): Promise<CompareAndAdvancePrimaryTermResult>;
|
|
32
|
+
updateInSyncSet(input: UpdateInSyncSetInput): Promise<ReplicationGroupState | null>;
|
|
33
|
+
admitNodeToInSyncSet(input: AdmitNodeToInSyncSetInput): Promise<ReplicationGroupState | null>;
|
|
34
|
+
updateNodeMaintenance(input: UpdateNodeMaintenanceInput): Promise<ReplicationGroupState | null>;
|
|
35
|
+
promoteEligibleReplica(input: PromoteEligibleReplicaInput): Promise<ReplicationGroupState>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
private getLeaseFromKey;
|
|
38
|
+
private trackLease;
|
|
39
|
+
private updateGroupStateWithRetry;
|
|
40
|
+
private casGroupState;
|
|
41
|
+
}
|
|
42
|
+
declare function createEtcdCoordinator(options: EtcdClusterCoordinatorOptions): EtcdClusterCoordinator;
|
|
43
|
+
|
|
44
|
+
export { EtcdClusterCoordinator, type EtcdClusterCoordinatorOptions, createEtcdCoordinator };
|