@delali/sirannon-db 0.3.4-next.62 → 0.3.4

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 (108) hide show
  1. package/README.md +79 -56
  2. package/dist/backup/index.d.ts +44 -45
  3. package/dist/backup/index.mjs +7 -7
  4. package/dist/backup-scheduler/index.d.ts +42 -41
  5. package/dist/backup-scheduler/index.mjs +4 -4
  6. package/dist/baseline-Co3iIsN_.d.ts +19 -0
  7. package/dist/change-tracker-DqCdeEyx.d.ts +128 -0
  8. package/dist/{chunk-VOSJBZ6Q.mjs → chunk-2ES3DT4A.mjs} +71 -33
  9. package/dist/{chunk-6CMCO7S4.mjs → chunk-2O3PP4CF.mjs} +1 -1
  10. package/dist/{chunk-E7Q7HE46.mjs → chunk-3BZLZ47R.mjs} +26 -26
  11. package/dist/chunk-4KASJKKK.mjs +2501 -0
  12. package/dist/{chunk-MYNI2WFS.mjs → chunk-52XW3Z76.mjs} +40 -8
  13. package/dist/chunk-55YRLSM2.mjs +57 -0
  14. package/dist/{chunk-KDAHYFW7.mjs → chunk-6AOJCNRU.mjs} +5 -5
  15. package/dist/{chunk-KXTYR2OQ.mjs → chunk-A3PHCO6W.mjs} +39 -111
  16. package/dist/chunk-ADNWEHGZ.mjs +299 -0
  17. package/dist/{chunk-2QLXDHAP.mjs → chunk-BLMRNSUG.mjs} +11 -2
  18. package/dist/chunk-BVMZJOVM.mjs +5 -0
  19. package/dist/{chunk-IWGIYDMZ.mjs → chunk-BZWDPF4G.mjs} +1 -1
  20. package/dist/{chunk-YVF2ZJTE.mjs → chunk-CZL4D3BM.mjs} +1 -1
  21. package/dist/{chunk-7SC2TZAS.mjs → chunk-DX4WGJL7.mjs} +2 -2
  22. package/dist/{chunk-45MKELYA.mjs → chunk-ESTZZPT5.mjs} +132 -13
  23. package/dist/{chunk-QP5L5DFJ.mjs → chunk-FJPR2CJX.mjs} +3 -3
  24. package/dist/chunk-HR7K3GZW.mjs +36 -0
  25. package/dist/{chunk-LXCGPZPA.mjs → chunk-IEKIYO4V.mjs} +1 -1
  26. package/dist/{chunk-TUD5CJ76.mjs → chunk-KB4OLJAD.mjs} +26 -19
  27. package/dist/{chunk-PBRXXISQ.mjs → chunk-KINDFBQP.mjs} +3 -2
  28. package/dist/{chunk-E6IMX7RS.mjs → chunk-KJLNYOOL.mjs} +2 -2
  29. package/dist/{chunk-BTTFW4Z4.mjs → chunk-KU32OT4H.mjs} +2 -10
  30. package/dist/{chunk-JQWGHSEH.mjs → chunk-NVSQ2T5Q.mjs} +71 -70
  31. package/dist/{chunk-W4EUTJNT.mjs → chunk-NZGSDALX.mjs} +94 -96
  32. package/dist/{chunk-U445A3C4.mjs → chunk-QGVRRKB2.mjs} +1 -1
  33. package/dist/{chunk-GYCEJNU4.mjs → chunk-R7GBXNTO.mjs} +1 -1
  34. package/dist/{chunk-7C36BCSN.mjs → chunk-VDN6FHU4.mjs} +1 -1
  35. package/dist/{chunk-6IYS4WLH.mjs → chunk-VO3ZWA2G.mjs} +142 -115
  36. package/dist/chunk-WOMADPM4.mjs +12 -0
  37. package/dist/{chunk-OUSWVNWT.mjs → chunk-YCMB6GR4.mjs} +1 -1
  38. package/dist/{chunk-YNTDOFTN.mjs → chunk-YW7IKQ7T.mjs} +1 -1
  39. package/dist/{chunk-M2BEAH5I.mjs → chunk-ZN4HI5FK.mjs} +126 -72
  40. package/dist/{chunk-SBL6GN43.mjs → chunk-ZYWI45EN.mjs} +1 -1
  41. package/dist/client/index.d.ts +135 -137
  42. package/dist/client/index.mjs +177 -82
  43. package/dist/client/topology.d.ts +31 -31
  44. package/dist/client/topology.mjs +42 -23
  45. package/dist/client-base-BxTocU1x.d.ts +398 -0
  46. package/dist/client-streams-YKANXMWO.mjs +112 -0
  47. package/dist/codegen/cli.mjs +4 -4
  48. package/dist/codegen/index.d.ts +36 -29
  49. package/dist/codegen/index.mjs +4 -4
  50. package/dist/core/index.d.ts +130 -115
  51. package/dist/core/index.mjs +387 -297
  52. package/dist/core/writer-worker.mjs +3 -3
  53. package/dist/database-CGDsXW1K.d.ts +959 -0
  54. package/dist/database-backup-DcLhxoa1.d.ts +143 -0
  55. package/dist/driver/better-sqlite3.d.ts +11 -10
  56. package/dist/driver/better-sqlite3.mjs +11 -11
  57. package/dist/driver/bun.d.ts +9 -8
  58. package/dist/driver/expo.d.ts +6 -7
  59. package/dist/driver/node.d.ts +11 -10
  60. package/dist/driver/node.mjs +13 -11
  61. package/dist/driver/wa-sqlite.d.ts +6 -6
  62. package/dist/errors-CJUkQ-KL.d.ts +199 -0
  63. package/dist/file-migrations/index.d.ts +20 -18
  64. package/dist/file-migrations/index.mjs +3 -3
  65. package/dist/forward-rpc-VRWFZXHN.mjs +44 -0
  66. package/dist/operation-registry-CGhNT-Sn.d.ts +96 -0
  67. package/dist/primary-wins-CHNOYuN7.d.ts +81 -0
  68. package/dist/protocol-DFpNNsIT.d.ts +153 -0
  69. package/dist/query-types-5B02ixH0.d.ts +129 -0
  70. package/dist/react/index.d.ts +22 -22
  71. package/dist/replication/coordinator/etcd.d.ts +37 -31
  72. package/dist/replication/coordinator/etcd.mjs +296 -131
  73. package/dist/replication/index.d.ts +201 -161
  74. package/dist/replication/index.mjs +630 -529
  75. package/dist/restore-options-CH8mE-Tb.d.ts +84 -0
  76. package/dist/server/index.d.ts +201 -191
  77. package/dist/server/index.mjs +736 -619
  78. package/dist/server-options-aYtCkefX.d.ts +317 -0
  79. package/dist/server-streams-24XL4T43.mjs +254 -0
  80. package/dist/sirannon-J3EgPVD7.d.ts +179 -0
  81. package/dist/transport/grpc.d.ts +37 -24
  82. package/dist/transport/grpc.mjs +83 -3199
  83. package/dist/transport/memory.d.ts +25 -26
  84. package/dist/transport/memory.mjs +18 -9
  85. package/dist/types-BrAiDGOb.d.ts +505 -0
  86. package/dist/types-CEJG0eFS.d.ts +88 -0
  87. package/dist/types-Dc8oWlxj.d.ts +1580 -0
  88. package/dist/types-DqODKeOq.d.ts +123 -0
  89. package/dist/types-guEKSzMr.d.ts +367 -0
  90. package/package.json +7 -7
  91. package/dist/baseline-D93hcIEE.d.ts +0 -17
  92. package/dist/change-tracker-CjRFuZdB.d.ts +0 -144
  93. package/dist/client-base-Cmd9EVme.d.ts +0 -397
  94. package/dist/database-BLQvqjsw.d.ts +0 -917
  95. package/dist/database-backup-B7oszQ2n.d.ts +0 -141
  96. package/dist/errors-Dei4GdBb.d.ts +0 -196
  97. package/dist/operation-registry-oiPuSYI6.d.ts +0 -94
  98. package/dist/primary-wins-B0np8JS3.d.ts +0 -85
  99. package/dist/protocol-HI-nY8DD.d.ts +0 -152
  100. package/dist/query-types-p1liOP-b.d.ts +0 -127
  101. package/dist/restore-options-CksYsH1l.d.ts +0 -83
  102. package/dist/server-options-Bj5iJnjx.d.ts +0 -292
  103. package/dist/sirannon-BPxC5tC2.d.ts +0 -178
  104. package/dist/types-B0EhgDbr.d.ts +0 -340
  105. package/dist/types-CbjfRwrK.d.ts +0 -499
  106. package/dist/types-CjhxcjhA.d.ts +0 -123
  107. package/dist/types-DPSmjU54.d.ts +0 -1518
  108. package/dist/types-DTO4CYhW.d.ts +0 -88
@@ -1,10 +1,10 @@
1
- import { L as LiveQueryOptions, a as LiveQuery, b as LiveQueryState } from '../types-DTO4CYhW.js';
2
- import { O as OperationRef } from '../operation-registry-oiPuSYI6.js';
3
- import { P as Params } from '../query-types-p1liOP-b.js';
1
+ import { L as LiveQueryOptions, a as LiveQuery, b as LiveQueryState } from '../types-CEJG0eFS.js';
2
+ import { O as OperationRef } from '../operation-registry-CGhNT-Sn.js';
3
+ import { P as Params } from '../query-types-5B02ixH0.js';
4
4
 
5
5
  /**
6
- * The one method these hooks need from a database, so both a local
7
- * `Database` and a `RemoteDatabase` satisfy it.
6
+ * The one database method that `useLiveQuery` calls, which both a local
7
+ * `Database` and a `RemoteDatabase` provide.
8
8
  *
9
9
  * @public
10
10
  */
@@ -18,31 +18,31 @@ interface LiveDatabase {
18
18
  * @public
19
19
  */
20
20
  interface UseLiveQueryOptions extends LiveQueryOptions {
21
- /** Set false to hold the query closed, which suits a query that depends on data you do not have yet. */
21
+ /** Set it to `false` to keep the query closed, for example while the query's arguments depend on data that the component is still loading. */
22
22
  enabled?: boolean;
23
23
  }
24
24
  /**
25
- * Subscribes a component to a registered read and re-renders it as the rows change.
25
+ * Returns the state of a live query for a registered read, and re-renders the component each time the rows change.
26
26
  *
27
- * The query closes when the component unmounts.
27
+ * The hook closes the query when the component unmounts.
28
28
  *
29
- * @param database - Database the read runs against.
30
- * @param operation - Name of the registered read.
31
- * @param args - Arguments the read takes.
32
- * @param options - Whether the query runs, plus the live-query settings.
33
- * @returns Whether the query is pending, ready with rows, or failed.
29
+ * @param database - The database on which Sirannon runs the read.
30
+ * @param operation - The name of the registered read.
31
+ * @param args - The arguments for the read.
32
+ * @param options - The `enabled` flag and the live-query settings.
33
+ * @returns The query state, which is pending, ready with rows, or an error.
34
34
  *
35
35
  * @public
36
36
  */
37
37
  declare function useLiveQuery<Row = Record<string, unknown>>(database: LiveDatabase, operation: string, args?: Params, options?: UseLiveQueryOptions): LiveQueryState<Row>;
38
38
  /**
39
- * Subscribes a component to a registered read and re-renders it as the rows change.
39
+ * Returns the state of a live query for a registered read, and re-renders the component each time the rows change.
40
40
  *
41
- * @param database - Database the read runs against.
42
- * @param operation - Reference to the registered read, which carries its argument and row types.
43
- * @param args - Arguments the read takes.
44
- * @param options - Whether the query runs, plus the live-query settings.
45
- * @returns Whether the query is pending, ready with rows, or failed.
41
+ * @param database - The database on which Sirannon runs the read.
42
+ * @param operation - A reference to the registered read, with its argument and row types.
43
+ * @param args - The arguments for the read.
44
+ * @param options - The `enabled` flag and the live-query settings.
45
+ * @returns The query state, which is pending, ready with rows, or an error.
46
46
  *
47
47
  * @public
48
48
  */
@@ -50,8 +50,8 @@ declare function useLiveQuery<Args, Row>(database: LiveDatabase, operation: Oper
50
50
  /**
51
51
  * Returns a stable callback that runs a registered write.
52
52
  *
53
- * @param database - Database the write runs against.
54
- * @param command - Reference to the registered write, which carries its argument type.
53
+ * @param database - The database on which Sirannon runs the write.
54
+ * @param command - A reference to the registered write, with its argument type.
55
55
  * @returns A callback that takes the write's arguments and resolves with its result.
56
56
  *
57
57
  * @public
@@ -62,7 +62,7 @@ declare function useCommand<Args, Result>(database: {
62
62
  /**
63
63
  * Returns a stable callback that runs a statement or a registered write by name.
64
64
  *
65
- * @param database - Database the write runs against.
65
+ * @param database - The database on which Sirannon runs the write.
66
66
  * @param command - The statement to run, or the name of a registered write.
67
67
  * @returns A callback that takes the parameters and resolves with the result.
68
68
  *
@@ -1,46 +1,49 @@
1
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-B0EhgDbr.js';
2
+ import { C as ClusterCoordinator, A as AcquireControllerLeaseInput, a as AcquireControllerLeaseResult, b as ControllerLeaseWatcher, c as CoordinatorWatchDisposer, R as RegisterNodeSessionInput, d as CoordinatorNodeSession, N as NodeSessionWatcher, S as SetReplicationGroupStateInput, e as ReplicationGroupState, f as ReplicationGroupWatcher, g as CompareAndAdvancePrimaryTermInput, h as CompareAndAdvancePrimaryTermResult, U as UpdateInSyncSetInput, i as AdmitNodeToInSyncSetInput, j as UpdateNodeMaintenanceInput, P as PromoteEligibleReplicaInput } from '../../types-guEKSzMr.js';
3
3
 
4
4
  /**
5
- * Where the etcd coordinator connects, under which key prefix it stores group state, and how it authenticates.
5
+ * Sets the etcd endpoints that the etcd coordinator connects to, the key prefix that it stores group state under, and
6
+ * how it authenticates.
6
7
  *
7
8
  * @public
8
9
  */
9
10
  interface EtcdClusterCoordinatorOptions {
10
11
  /**
11
- * etcd endpoints to connect to. Production access requires https addresses.
12
+ * Lists the etcd endpoints to connect to. The coordinator accepts only https endpoints unless `allowInsecure` is true.
12
13
  */
13
14
  hosts: string | string[];
14
15
  /**
15
- * Prefix applied to every key this coordinator writes, which keeps clusters apart in one etcd.
16
+ * Sets the prefix that this coordinator puts in front of every key that it writes, so that several deployments can
17
+ * share one etcd.
16
18
  */
17
19
  keyPrefix: string;
18
20
  /**
19
- * TLS material, which production access requires.
21
+ * Holds the TLS material, which the coordinator requires unless `allowInsecure` is true.
20
22
  */
21
23
  credentials?: IOptions['credentials'];
22
24
  /**
23
- * Username and password, as an alternative to a client certificate.
25
+ * Holds a username and password, which the coordinator accepts in place of a client certificate.
24
26
  */
25
27
  auth?: IOptions['auth'];
26
28
  /**
27
- * Options passed straight through to the underlying gRPC channel.
29
+ * Holds options that the coordinator passes unchanged to the underlying gRPC channel.
28
30
  */
29
31
  grpcOptions?: IOptions['grpcOptions'];
30
32
  /**
31
- * Milliseconds to wait for a connection to etcd.
33
+ * Sets how many milliseconds the client waits to connect to etcd.
32
34
  */
33
35
  dialTimeoutMs?: number;
34
36
  /**
35
- * Milliseconds any single etcd call may take.
37
+ * Sets how many milliseconds a single etcd call can take before its deadline expires.
36
38
  */
37
39
  defaultCallTimeoutMs?: number;
38
40
  /**
39
- * Accepts plain http endpoints without credentials, which suits tests only.
41
+ * Lets the coordinator connect to plain http endpoints without credentials. Use it only in tests.
40
42
  */
41
43
  allowInsecure?: boolean;
42
44
  /**
43
- * Called when a group watch fails so that a caller can log it or raise an alert.
45
+ * Receives each error that an etcd watch reports or that a watch callback throws, and each lost lease, so that you
46
+ * can log it or raise an alert.
44
47
  */
45
48
  onWatcherError?: (error: Error) => void;
46
49
  }
@@ -48,55 +51,58 @@ interface EtcdClusterCoordinatorOptions {
48
51
  /**
49
52
  * Stores primary authority, node sessions, group state, and the in-sync set in etcd.
50
53
  *
51
- * Build one with {@link createEtcdCoordinator}.
54
+ * Build one with {@link createEtcdCoordinator}. The coordinator loads the `etcd3` package the first time that one of its methods connects to etcd. When this process cannot load that package, the call fails with a `SirannonError` whose code is `COORDINATOR_DEPENDENCY_MISSING`.
52
55
  *
53
56
  * @public
54
57
  */
55
58
  declare class EtcdClusterCoordinator implements ClusterCoordinator {
56
- private readonly client;
57
- private readonly namespace;
59
+ private readonly options;
60
+ private connection;
58
61
  private readonly onWatcherError;
59
62
  private readonly leases;
60
63
  private readonly grantedNodeSessionLeaseIds;
61
64
  private readonly watchers;
62
- private readonly groups;
63
65
  constructor(options: EtcdClusterCoordinatorOptions);
64
- /** Bids for the controller lease, and reports who holds it. */
66
+ /** Tries to acquire the controller lease, and returns whether it succeeded along with the current lease. */
65
67
  tryAcquireControllerLease(input: AcquireControllerLeaseInput): Promise<AcquireControllerLeaseResult>;
66
- /** Extends a lease, and reports false once it has already lapsed. */
68
+ /** Calls `watcher` with the current controller lease when the watch starts and after each change, and returns a function that stops the watch. */
69
+ watchControllerLease(clusterId: string, watcher: ControllerLeaseWatcher): Promise<CoordinatorWatchDisposer>;
70
+ /** Extends a lease, and returns false for a lease that is expired or unknown to this coordinator. */
67
71
  renewLease(leaseId: string, ttlMs: number): Promise<boolean>;
68
- /** Gives up a lease at once instead of waiting for it to lapse. */
72
+ /** Deletes a lease's key if the key still refers to that lease, then revokes the lease, and returns whether the delete succeeded. */
69
73
  releaseLease(leaseId: string): Promise<boolean>;
70
74
  /** Records one node as a live member of the cluster. */
71
75
  registerNodeSession(input: RegisterNodeSessionInput): Promise<CoordinatorNodeSession>;
72
- /** Reads one node's session, and returns null once its lease has lapsed. */
76
+ /** Returns one node's session, or null once its lease expires. */
73
77
  getLiveNodeSession(clusterId: string, nodeId: string): Promise<CoordinatorNodeSession | null>;
74
- /** Ends one node's membership at once. */
78
+ /** Calls `watcher` with the IDs of every node that holds a live session, and returns a function that stops the watch. */
79
+ watchNodeSessions(clusterId: string, watcher: NodeSessionWatcher): Promise<CoordinatorWatchDisposer>;
80
+ /** Ends one node's session at once by releasing its leases. */
75
81
  deregisterNodeSession(clusterId: string, nodeId: string): Promise<void>;
76
- /** Writes the group's state, which seeds a new group or replaces an existing one. */
82
+ /** Writes the group's state, which creates a new group or replaces an existing one. */
77
83
  setReplicationGroupState(input: SetReplicationGroupStateInput): Promise<ReplicationGroupState>;
78
- /** Reads the group's state, and returns null when the group is absent. */
84
+ /** Returns the group's state, or null when etcd has no state for the group. */
79
85
  getReplicationGroupState(clusterId: string, groupId: string): Promise<ReplicationGroupState | null>;
80
- /** Calls back on each change to the group's state, and returns a function that stops the watch. */
86
+ /** Calls `watcher` with the new state after each change to the group, and returns a function that stops the watch. */
81
87
  watchReplicationGroup(clusterId: string, groupId: string, watcher: ReplicationGroupWatcher): Promise<CoordinatorWatchDisposer>;
82
- /** Promotes a node only while the group is still at the term the caller read. */
88
+ /** Makes a node primary and advances the term, but only while the group is still at the term that the caller expects. */
83
89
  compareAndAdvancePrimaryTerm(input: CompareAndAdvancePrimaryTermInput): Promise<CompareAndAdvancePrimaryTermResult>;
84
- /** Replaces the group's in-sync set, and optionally moves its durability point. */
90
+ /** Replaces the group's in-sync set with a subset of it, and can advance the durability point. */
85
91
  updateInSyncSet(input: UpdateInSyncSetInput): Promise<ReplicationGroupState | null>;
86
92
  /** Adds one caught-up node to the in-sync set. */
87
93
  admitNodeToInSyncSet(input: AdmitNodeToInSyncSetInput): Promise<ReplicationGroupState | null>;
88
- /** Marks one node as being taken out of service, rebuilt, or quarantined. */
94
+ /** Sets or clears one node's draining, repairing, and faulted flags. */
89
95
  updateNodeMaintenance(input: UpdateNodeMaintenanceInput): Promise<ReplicationGroupState | null>;
90
- /** Promotes whichever in-sync replica is safe to write. */
96
+ /** Promotes an eligible in-sync replica, and throws a `NoSafePrimaryError` when no replica qualifies. */
91
97
  promoteEligibleReplica(input: PromoteEligibleReplicaInput): Promise<ReplicationGroupState>;
92
- /** Closes the etcd client and stops every watch. */
98
+ /** Stops every watch, revokes every lease that this coordinator granted, and closes the etcd client. */
93
99
  close(): Promise<void>;
94
- private getLeaseFromKey;
100
+ private connect;
95
101
  }
96
102
  /**
97
- * Builds a coordinator backed by etcd.
103
+ * Returns a new coordinator that stores its state in etcd.
98
104
  *
99
- * @param options - etcd endpoints, key prefix, credentials, and timeouts.
105
+ * @param options - The etcd endpoints, key prefix, credentials, and timeouts.
100
106
  * @returns The coordinator, ready to pass to a replication engine.
101
107
  *
102
108
  * @public