@toggld/node 0.2.0 → 0.4.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/README.md +109 -10
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +235 -0
- package/dist/{core-Bx0PVoEm.mjs → core-CezJWPV4.mjs} +280 -512
- package/dist/effect.d.mts +6 -7
- package/dist/effect.mjs +1 -2
- package/dist/index.d.mts +5 -6
- package/dist/index.mjs +8 -7
- package/dist/src-B_M-Oix8.mjs +638 -0
- package/dist/{types-DItF1mIU.d.mts → types-hdTQWEM5.d.mts} +41 -12
- package/package.json +7 -4
package/dist/effect.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { a as ErrorCode, c as FlagValue, i as ToggldClientOptions, l as Reason, n as EvaluationMode, o as EvaluationContext, r as SyncOptions, s as FlagMetadata, t as EvaluationDetails } from "./types-
|
|
1
|
+
import { a as ErrorCode, c as FlagValue, i as ToggldClientOptions, l as Reason, n as EvaluationMode, o as EvaluationContext, r as SyncOptions, s as FlagMetadata, t as EvaluationDetails } from "./types-hdTQWEM5.mjs";
|
|
2
2
|
import { Context, Effect, Layer } from "effect";
|
|
3
|
-
|
|
4
|
-
//#region src/internal/core.d.ts
|
|
5
3
|
/** The evaluation surface of a Toggld client. Every method is non-failing. */
|
|
6
4
|
interface ToggldClientShape {
|
|
7
5
|
/**
|
|
@@ -10,6 +8,8 @@ interface ToggldClientShape {
|
|
|
10
8
|
* resolve to the caller's default with `PROVIDER_NOT_READY`.
|
|
11
9
|
*/
|
|
12
10
|
readonly ready: Effect.Effect<void>;
|
|
11
|
+
/** Send buffered telemetry. Failed windows remain queued for retry. */
|
|
12
|
+
readonly flushTelemetry: Effect.Effect<void>;
|
|
13
13
|
/** Resolve a flag, returning full details with an untyped (JSON) value. */
|
|
14
14
|
readonly evaluate: (key: string, defaultValue: FlagValue, context?: EvaluationContext) => Effect.Effect<EvaluationDetails<FlagValue>>;
|
|
15
15
|
/** Resolve every flag for the environment (one request in remote mode; in-process in local mode). */
|
|
@@ -28,13 +28,12 @@ declare const ToggldClient_base: Context.ServiceClass<ToggldClient, "@toggld/nod
|
|
|
28
28
|
* The Toggld client as an Effect service. Build a {@link layer} from options and
|
|
29
29
|
* compose it into your runtime, then `yield* ToggldClient` to evaluate flags.
|
|
30
30
|
*/
|
|
31
|
-
declare class ToggldClient extends ToggldClient_base {}
|
|
31
|
+
export declare class ToggldClient extends ToggldClient_base {}
|
|
32
32
|
/**
|
|
33
33
|
* A self-contained `Layer` providing {@link ToggldClient} — it wires its own
|
|
34
34
|
* HTTP and WebSocket backends, so Effect users need only provide this one
|
|
35
35
|
* layer. In local mode the background sync fibers live in the layer's scope:
|
|
36
36
|
* closing it (e.g. `ManagedRuntime.dispose`) stops sync and closes the stream.
|
|
37
37
|
*/
|
|
38
|
-
declare const layer: (options: ToggldClientOptions) => Layer.Layer<ToggldClient>;
|
|
39
|
-
|
|
40
|
-
export { type ErrorCode, type EvaluationContext, type EvaluationDetails, type EvaluationMode, type FlagMetadata, type FlagValue, type Reason, type SyncOptions, ToggldClient, type ToggldClientOptions, type ToggldClientShape, layer };
|
|
38
|
+
export declare const layer: (options: ToggldClientOptions) => Layer.Layer<ToggldClient>;
|
|
39
|
+
export type { ErrorCode, EvaluationContext, EvaluationDetails, EvaluationMode, FlagMetadata, FlagValue, Reason, SyncOptions, ToggldClientOptions, ToggldClientShape };
|
package/dist/effect.mjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { ToggldClient, layer };
|
|
1
|
+
export { t as ToggldClient, n as layer } from "./core-CezJWPV4.mjs";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { a as ErrorCode, c as FlagValue, i as ToggldClientOptions, l as Reason, n as EvaluationMode, o as EvaluationContext, r as SyncOptions, s as FlagMetadata, t as EvaluationDetails } from "./types-
|
|
2
|
-
|
|
3
|
-
//#region src/index.d.ts
|
|
1
|
+
import { a as ErrorCode, c as FlagValue, i as ToggldClientOptions, l as Reason, n as EvaluationMode, o as EvaluationContext, r as SyncOptions, s as FlagMetadata, t as EvaluationDetails } from "./types-hdTQWEM5.mjs";
|
|
4
2
|
/**
|
|
5
3
|
* A Toggld client backed by a private Effect runtime. Create one with {@link
|
|
6
4
|
* ToggldClient.create} and {@link ToggldClient.close} it on shutdown to release
|
|
7
5
|
* the runtime.
|
|
8
6
|
*/
|
|
9
|
-
declare class ToggldClient {
|
|
7
|
+
export declare class ToggldClient {
|
|
10
8
|
#private;
|
|
11
9
|
private constructor();
|
|
12
10
|
/**
|
|
@@ -22,6 +20,8 @@ declare class ToggldClient {
|
|
|
22
20
|
* want to await sync explicitly.
|
|
23
21
|
*/
|
|
24
22
|
ready(): Promise<void>;
|
|
23
|
+
/** Send buffered counts without failing evaluations. Failed windows remain queued. */
|
|
24
|
+
flushTelemetry(): Promise<void>;
|
|
25
25
|
/** Resolve a flag, returning full details with an untyped (JSON) value. */
|
|
26
26
|
evaluate(key: string, defaultValue: FlagValue, context?: EvaluationContext): Promise<EvaluationDetails<FlagValue>>;
|
|
27
27
|
/** Resolve every flag for the environment in one request (OFREP bulk). */
|
|
@@ -37,5 +37,4 @@ declare class ToggldClient {
|
|
|
37
37
|
/** Dispose the underlying runtime. The client is unusable afterwards. */
|
|
38
38
|
close(): Promise<void>;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
export { type ErrorCode, type EvaluationContext, type EvaluationDetails, type EvaluationMode, type FlagMetadata, type FlagValue, type Reason, type SyncOptions, ToggldClient, type ToggldClientOptions };
|
|
40
|
+
export type { ErrorCode, EvaluationContext, EvaluationDetails, EvaluationMode, FlagMetadata, FlagValue, Reason, SyncOptions, ToggldClientOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as layer, t as ToggldClient$1 } from "./core-
|
|
1
|
+
import { n as layer, t as ToggldClient$1 } from "./core-CezJWPV4.mjs";
|
|
2
2
|
import { Duration, Effect, ManagedRuntime } from "effect";
|
|
3
|
-
|
|
3
|
+
// src/index.ts
|
|
4
4
|
/**
|
|
5
5
|
* `@toggld/node` — the default entry: a plain Promise API.
|
|
6
6
|
*
|
|
@@ -44,10 +44,8 @@ var ToggldClient = class ToggldClient {
|
|
|
44
44
|
static async create(options) {
|
|
45
45
|
const runtime = ManagedRuntime.make(layer(options));
|
|
46
46
|
const client = await runtime.runPromise(ToggldClient$1);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
await runtime.runPromise(client.ready.pipe(Effect.timeout(Duration.millis(readyTimeoutMs)), Effect.ignore));
|
|
50
|
-
}
|
|
47
|
+
const readyTimeoutMs = options.sync?.readyTimeoutMs ?? 5e3;
|
|
48
|
+
await runtime.runPromise(client.ready.pipe(Effect.timeout(Duration.millis(readyTimeoutMs)), Effect.ignore));
|
|
51
49
|
return new ToggldClient(runtime, client);
|
|
52
50
|
}
|
|
53
51
|
/**
|
|
@@ -58,6 +56,10 @@ var ToggldClient = class ToggldClient {
|
|
|
58
56
|
ready() {
|
|
59
57
|
return this.#runtime.runPromise(this.#client.ready);
|
|
60
58
|
}
|
|
59
|
+
/** Send buffered counts without failing evaluations. Failed windows remain queued. */
|
|
60
|
+
flushTelemetry() {
|
|
61
|
+
return this.#runtime.runPromise(this.#client.flushTelemetry);
|
|
62
|
+
}
|
|
61
63
|
/** Resolve a flag, returning full details with an untyped (JSON) value. */
|
|
62
64
|
evaluate(key, defaultValue, context) {
|
|
63
65
|
return this.#runtime.runPromise(this.#client.evaluate(key, defaultValue, context));
|
|
@@ -95,5 +97,4 @@ var ToggldClient = class ToggldClient {
|
|
|
95
97
|
return this.#runtime.dispose();
|
|
96
98
|
}
|
|
97
99
|
};
|
|
98
|
-
//#endregion
|
|
99
100
|
export { ToggldClient };
|