@no-witness-labs/midday-sdk 0.1.2 → 0.2.0
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/devnet/Cluster.d.ts +282 -0
- package/dist/devnet/Cluster.d.ts.map +1 -0
- package/dist/devnet/Cluster.js +487 -0
- package/dist/devnet/Cluster.js.map +1 -0
- package/dist/devnet/Config.d.ts +119 -0
- package/dist/devnet/Config.d.ts.map +1 -0
- package/dist/devnet/Config.js +75 -0
- package/dist/devnet/Config.js.map +1 -0
- package/dist/devnet/Container.d.ts +180 -0
- package/dist/devnet/Container.d.ts.map +1 -0
- package/dist/devnet/Container.js +390 -0
- package/dist/devnet/Container.js.map +1 -0
- package/dist/devnet/Health.d.ts +129 -0
- package/dist/devnet/Health.d.ts.map +1 -0
- package/dist/devnet/Health.js +304 -0
- package/dist/devnet/Health.js.map +1 -0
- package/dist/devnet/Images.d.ts +43 -0
- package/dist/devnet/Images.d.ts.map +1 -0
- package/dist/devnet/Images.js +96 -0
- package/dist/devnet/Images.js.map +1 -0
- package/dist/devnet/errors.d.ts +65 -0
- package/dist/devnet/errors.d.ts.map +1 -0
- package/dist/devnet/errors.js +40 -0
- package/dist/devnet/errors.js.map +1 -0
- package/dist/devnet/index.d.ts +72 -0
- package/dist/devnet/index.d.ts.map +1 -0
- package/dist/devnet/index.js +73 -0
- package/dist/devnet/index.js.map +1 -0
- package/package.json +14 -4
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DevNet cluster orchestration.
|
|
3
|
+
*
|
|
4
|
+
* Manages the lifecycle of a complete Midnight development environment
|
|
5
|
+
* consisting of a node, indexer, and proof server.
|
|
6
|
+
*
|
|
7
|
+
* ## API Design
|
|
8
|
+
*
|
|
9
|
+
* This module uses an **instance-based pattern**:
|
|
10
|
+
*
|
|
11
|
+
* - **Stateful**: A Cluster holds references to Docker containers
|
|
12
|
+
* - **Instance methods**: `cluster.start()`, `cluster.stop()`, etc.
|
|
13
|
+
* - **Effect-first**: Internal implementation uses Effect
|
|
14
|
+
* - **Promise wrapper**: `.effect` namespace exposes raw Effects
|
|
15
|
+
*
|
|
16
|
+
* ### Usage Patterns
|
|
17
|
+
*
|
|
18
|
+
* ```typescript
|
|
19
|
+
* // Promise user (majority)
|
|
20
|
+
* const cluster = await Cluster.make();
|
|
21
|
+
* await cluster.start(); // instance method
|
|
22
|
+
* const config = cluster.networkConfig; // accessor
|
|
23
|
+
* await cluster.stop();
|
|
24
|
+
*
|
|
25
|
+
* // Effect user (composable)
|
|
26
|
+
* const cluster = yield* Cluster.effect.make();
|
|
27
|
+
* yield* cluster.effect.start(); // raw Effect access
|
|
28
|
+
*
|
|
29
|
+
* // Effect DI user (dependency injection)
|
|
30
|
+
* const cluster = yield* ClusterService;
|
|
31
|
+
* yield* cluster.effect.start();
|
|
32
|
+
* // provide with: Effect.provide(Cluster.Live) or Cluster.layer({ ... })
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @since 0.2.0
|
|
36
|
+
* @module
|
|
37
|
+
*/
|
|
38
|
+
import { Context, Effect, Layer } from 'effect';
|
|
39
|
+
import type { NetworkConfig } from '../Config.js';
|
|
40
|
+
import type { DevNetConfig, ResolvedDevNetConfig } from './Config.js';
|
|
41
|
+
import * as Container from './Container.js';
|
|
42
|
+
import { ClusterError } from './errors.js';
|
|
43
|
+
/**
|
|
44
|
+
* Raw cluster data (containers and config).
|
|
45
|
+
*
|
|
46
|
+
* @since 0.2.0
|
|
47
|
+
* @category model
|
|
48
|
+
*/
|
|
49
|
+
export interface ClusterData {
|
|
50
|
+
/** The Midnight node container */
|
|
51
|
+
readonly node: Container.Container;
|
|
52
|
+
/** The indexer container */
|
|
53
|
+
readonly indexer: Container.Container;
|
|
54
|
+
/** The proof server container */
|
|
55
|
+
readonly proofServer: Container.Container;
|
|
56
|
+
/** The resolved configuration */
|
|
57
|
+
readonly config: ResolvedDevNetConfig;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A DevNet cluster instance with lifecycle methods.
|
|
61
|
+
*
|
|
62
|
+
* @since 0.2.0
|
|
63
|
+
* @category model
|
|
64
|
+
*/
|
|
65
|
+
export interface Cluster {
|
|
66
|
+
/** The Midnight node container */
|
|
67
|
+
readonly node: Container.Container;
|
|
68
|
+
/** The indexer container */
|
|
69
|
+
readonly indexer: Container.Container;
|
|
70
|
+
/** The proof server container */
|
|
71
|
+
readonly proofServer: Container.Container;
|
|
72
|
+
/** The resolved configuration */
|
|
73
|
+
readonly config: ResolvedDevNetConfig;
|
|
74
|
+
/** Network configuration for use with midday-sdk client */
|
|
75
|
+
readonly networkConfig: NetworkConfig;
|
|
76
|
+
/** Start the cluster */
|
|
77
|
+
readonly start: () => Promise<void>;
|
|
78
|
+
/** Stop the cluster */
|
|
79
|
+
readonly stop: () => Promise<void>;
|
|
80
|
+
/** Remove the cluster */
|
|
81
|
+
readonly remove: () => Promise<void>;
|
|
82
|
+
/** Check if the cluster is running */
|
|
83
|
+
readonly isRunning: () => Promise<boolean>;
|
|
84
|
+
readonly effect: {
|
|
85
|
+
/** Start the cluster (raw Effect) */
|
|
86
|
+
readonly start: () => Effect.Effect<void, ClusterError>;
|
|
87
|
+
/** Stop the cluster (raw Effect) */
|
|
88
|
+
readonly stop: () => Effect.Effect<void, ClusterError>;
|
|
89
|
+
/** Remove the cluster (raw Effect) */
|
|
90
|
+
readonly remove: () => Effect.Effect<void, ClusterError>;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
declare const ClusterService_base: Context.TagClass<ClusterService, "ClusterService", Cluster>;
|
|
94
|
+
/**
|
|
95
|
+
* Context.Tag for ClusterService dependency injection.
|
|
96
|
+
*
|
|
97
|
+
* Yields a Cluster instance directly. Use `Cluster.layer()` to provide
|
|
98
|
+
* with custom configuration.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* import { Effect } from 'effect';
|
|
103
|
+
* import { Cluster, ClusterService } from '@no-witness-labs/midday-sdk/devnet';
|
|
104
|
+
*
|
|
105
|
+
* const program = Effect.gen(function* () {
|
|
106
|
+
* const cluster = yield* ClusterService;
|
|
107
|
+
* yield* cluster.effect.start();
|
|
108
|
+
* return cluster.networkConfig;
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* // With default config
|
|
112
|
+
* await Effect.runPromise(program.pipe(Effect.provide(Cluster.Live)));
|
|
113
|
+
*
|
|
114
|
+
* // With custom config
|
|
115
|
+
* await Effect.runPromise(program.pipe(
|
|
116
|
+
* Effect.provide(Cluster.layer({ clusterName: 'my-devnet' }))
|
|
117
|
+
* ));
|
|
118
|
+
* ```
|
|
119
|
+
*
|
|
120
|
+
* @since 0.2.0
|
|
121
|
+
* @category service
|
|
122
|
+
*/
|
|
123
|
+
export declare class ClusterService extends ClusterService_base {
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create a new DevNet cluster instance.
|
|
127
|
+
*
|
|
128
|
+
* Returns a cluster with bound lifecycle methods.
|
|
129
|
+
* This creates the containers but does not start them.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* import { Cluster } from '@no-witness-labs/midday-sdk/devnet';
|
|
134
|
+
*
|
|
135
|
+
* const cluster = await Cluster.make();
|
|
136
|
+
* await cluster.start();
|
|
137
|
+
*
|
|
138
|
+
* // Access network config directly
|
|
139
|
+
* const client = await Midday.Client.create({
|
|
140
|
+
* networkConfig: cluster.networkConfig,
|
|
141
|
+
* seed: 'your-wallet-seed',
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // ... run tests ...
|
|
145
|
+
*
|
|
146
|
+
* await cluster.remove();
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* @since 0.2.0
|
|
150
|
+
* @category constructors
|
|
151
|
+
*/
|
|
152
|
+
export declare const make: (config?: DevNetConfig) => Promise<Cluster>;
|
|
153
|
+
/**
|
|
154
|
+
* Get the network configuration for use with midday-sdk client.
|
|
155
|
+
*
|
|
156
|
+
* @deprecated Prefer using `cluster.networkConfig` property instead.
|
|
157
|
+
*
|
|
158
|
+
* @since 0.2.0
|
|
159
|
+
* @category utilities
|
|
160
|
+
*/
|
|
161
|
+
export declare const toNetworkConfig: (cluster: Cluster | ClusterData) => NetworkConfig;
|
|
162
|
+
/**
|
|
163
|
+
* Helper function to run code with an automatically managed cluster.
|
|
164
|
+
* The cluster is created, started, and cleaned up automatically.
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* import { Cluster } from '@no-witness-labs/midday-sdk/devnet';
|
|
169
|
+
*
|
|
170
|
+
* await Cluster.withCluster(async (cluster) => {
|
|
171
|
+
* // Use cluster.networkConfig directly
|
|
172
|
+
* const config = cluster.networkConfig;
|
|
173
|
+
* // Your code here - cluster will be cleaned up automatically
|
|
174
|
+
* return config;
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*
|
|
178
|
+
* @since 0.2.0
|
|
179
|
+
* @category utilities
|
|
180
|
+
*/
|
|
181
|
+
export declare const withCluster: <T>(fn: (cluster: Cluster) => Promise<T>, config?: DevNetConfig) => Promise<T>;
|
|
182
|
+
/**
|
|
183
|
+
* Effect API for advanced users who want full composability,
|
|
184
|
+
* type-safe errors, retries, and other Effect benefits.
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* import { Effect } from 'effect';
|
|
189
|
+
* import { Cluster } from '@no-witness-labs/midday-sdk/devnet';
|
|
190
|
+
*
|
|
191
|
+
* const program = Effect.gen(function* () {
|
|
192
|
+
* const cluster = yield* Cluster.effect.make();
|
|
193
|
+
* yield* cluster.effect.start(); // Use instance method
|
|
194
|
+
* return cluster;
|
|
195
|
+
* }).pipe(
|
|
196
|
+
* Effect.retry({ times: 3 }),
|
|
197
|
+
* Effect.timeout('5 minutes')
|
|
198
|
+
* );
|
|
199
|
+
*
|
|
200
|
+
* await Effect.runPromise(program);
|
|
201
|
+
* ```
|
|
202
|
+
*
|
|
203
|
+
* @since 0.2.0
|
|
204
|
+
* @category effect
|
|
205
|
+
*/
|
|
206
|
+
export declare const effect: {
|
|
207
|
+
/**
|
|
208
|
+
* Create a cluster instance (returns raw Effect).
|
|
209
|
+
*
|
|
210
|
+
* The returned cluster has an `.effect` namespace for lifecycle methods.
|
|
211
|
+
*
|
|
212
|
+
* @since 0.2.0
|
|
213
|
+
*/
|
|
214
|
+
readonly make: (config?: DevNetConfig) => Effect.Effect<Cluster, ClusterError, never>;
|
|
215
|
+
/**
|
|
216
|
+
* Run code with an automatically managed cluster (returns raw Effect).
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* import { Effect } from 'effect';
|
|
221
|
+
* import { Cluster } from '@no-witness-labs/midday-sdk/devnet';
|
|
222
|
+
*
|
|
223
|
+
* const program = Cluster.effect.withCluster((cluster) =>
|
|
224
|
+
* Effect.gen(function* () {
|
|
225
|
+
* const config = cluster.networkConfig;
|
|
226
|
+
* return config;
|
|
227
|
+
* })
|
|
228
|
+
* );
|
|
229
|
+
*
|
|
230
|
+
* await Effect.runPromise(program);
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @since 0.2.0
|
|
234
|
+
*/
|
|
235
|
+
readonly withCluster: <A, E, R>(fn: (cluster: Cluster) => Effect.Effect<A, E, R>, config?: DevNetConfig) => Effect.Effect<A, E | ClusterError, R>;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Create a Layer that provides ClusterService with custom configuration.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* import { Effect } from 'effect';
|
|
243
|
+
* import { Cluster, ClusterService } from '@no-witness-labs/midday-sdk/devnet';
|
|
244
|
+
*
|
|
245
|
+
* const program = Effect.gen(function* () {
|
|
246
|
+
* const cluster = yield* ClusterService;
|
|
247
|
+
* yield* cluster.effect.start();
|
|
248
|
+
* return cluster;
|
|
249
|
+
* });
|
|
250
|
+
*
|
|
251
|
+
* await Effect.runPromise(program.pipe(
|
|
252
|
+
* Effect.provide(Cluster.layer({ clusterName: 'my-devnet' }))
|
|
253
|
+
* ));
|
|
254
|
+
* ```
|
|
255
|
+
*
|
|
256
|
+
* @since 0.2.0
|
|
257
|
+
* @category layer
|
|
258
|
+
*/
|
|
259
|
+
export declare const layer: (config?: DevNetConfig) => Layer.Layer<ClusterService, ClusterError>;
|
|
260
|
+
/**
|
|
261
|
+
* Live Layer for ClusterService with default configuration.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* import { Effect } from 'effect';
|
|
266
|
+
* import { Cluster, ClusterService } from '@no-witness-labs/midday-sdk/devnet';
|
|
267
|
+
*
|
|
268
|
+
* const program = Effect.gen(function* () {
|
|
269
|
+
* const cluster = yield* ClusterService;
|
|
270
|
+
* yield* cluster.effect.start();
|
|
271
|
+
* return cluster;
|
|
272
|
+
* });
|
|
273
|
+
*
|
|
274
|
+
* await Effect.runPromise(program.pipe(Effect.provide(Cluster.Live)));
|
|
275
|
+
* ```
|
|
276
|
+
*
|
|
277
|
+
* @since 0.2.0
|
|
278
|
+
* @category layer
|
|
279
|
+
*/
|
|
280
|
+
export declare const Live: Layer.Layer<ClusterService, ClusterError>;
|
|
281
|
+
export {};
|
|
282
|
+
//# sourceMappingURL=Cluster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Cluster.d.ts","sourceRoot":"","sources":["../../src/devnet/Cluster.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,KAAK,E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