@toggld/node 0.1.0 → 0.3.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.
@@ -1,85 +0,0 @@
1
- //#region ../spec/src/index.d.ts
2
- /**
3
- * A resolved flag value. OpenFeature permits `boolean | string | number |
4
- * structure`; we model the union as JSON, which also covers arrays and null for
5
- * "object" typed flags.
6
- */
7
- type FlagValue = null | boolean | number | string | ReadonlyArray<FlagValue> | {
8
- readonly [key: string]: FlagValue;
9
- };
10
- /**
11
- * Flag metadata: "arbitrary properties, with keys of type string, and values of
12
- * type boolean, string, or number." (Requirement 2.2.10)
13
- */
14
- type MetadataValue = string | number | boolean;
15
- type FlagMetadata = {
16
- readonly [key: string]: MetadataValue;
17
- };
18
- /**
19
- * An OpenFeature evaluation context: an optional `targetingKey` identifying the
20
- * subject (Requirement 3.1.1) plus arbitrary custom JSON-valued attributes
21
- * (Requirement 3.1.2).
22
- */
23
- type EvaluationContext = {
24
- readonly [attribute: string]: FlagValue;
25
- };
26
- /**
27
- * Resolution reasons. (Requirement 2.2.5)
28
- */
29
- type Reason = "STATIC" | "DEFAULT" | "TARGETING_MATCH" | "SPLIT" | "CACHED" | "DISABLED" | "UNKNOWN" | "STALE" | "ERROR";
30
- /**
31
- * OpenFeature error codes.
32
- * @see https://openfeature.dev/specification/types
33
- */
34
- type ErrorCode = "PROVIDER_NOT_READY" | "PROVIDER_FATAL" | "FLAG_NOT_FOUND" | "PARSE_ERROR" | "TYPE_MISMATCH" | "TARGETING_KEY_MISSING" | "INVALID_CONTEXT" | "GENERAL";
35
- //#endregion
36
- //#region src/internal/types.d.ts
37
- /** Configuration for a {@link https://toggld.io Toggld} client. */
38
- interface ToggldClientOptions {
39
- /**
40
- * An **evaluation** (or management) API key, sent as `Authorization: Bearer
41
- * <sdkKey>`. The key is scoped to one tenant + environment server-side, so a
42
- * client always evaluates against exactly that environment.
43
- */
44
- readonly sdkKey: string;
45
- /**
46
- * Base URL of the flag API, e.g. `https://toggld-api.example.workers.dev` or
47
- * `http://localhost:3000` in local development. No trailing path — the client
48
- * appends the OFREP routes (`/ofrep/v1/...`).
49
- */
50
- readonly endpoint: string;
51
- /**
52
- * Attributes merged into the evaluation context of **every** request, under
53
- * any per-call context (per-call attributes win on key collision). Handy for
54
- * process-wide dimensions such as `region` or `serviceVersion`.
55
- */
56
- readonly defaultContext?: EvaluationContext;
57
- /** Per-request timeout in milliseconds. Default `5000`. */
58
- readonly timeoutMs?: number;
59
- /**
60
- * Custom `fetch` implementation. Defaults to the global `fetch`. Useful for
61
- * tests, proxies, or injecting retries/instrumentation.
62
- */
63
- readonly fetch?: typeof globalThis.fetch;
64
- }
65
- /**
66
- * The outcome of evaluating a single flag — OpenFeature "evaluation details"
67
- * with a value typed to the requested flag type. Mirrors {@link
68
- * https://openfeature.dev/specification/sections/evaluation-details}.
69
- *
70
- * On any abnormal evaluation (network failure, unknown flag, type mismatch, a
71
- * server-reported error) the call still resolves: `value` holds the caller's
72
- * default, `reason` is `"ERROR"`, and `errorCode`/`errorMessage` describe what
73
- * went wrong. Evaluation never throws.
74
- */
75
- interface EvaluationDetails<T extends FlagValue> {
76
- readonly flagKey: string;
77
- readonly value: T;
78
- readonly variant: string | undefined;
79
- readonly reason: Reason;
80
- readonly errorCode: ErrorCode | undefined;
81
- readonly errorMessage: string | undefined;
82
- readonly flagMetadata: FlagMetadata;
83
- }
84
- //#endregion
85
- export { FlagMetadata as a, EvaluationContext as i, ToggldClientOptions as n, FlagValue as o, ErrorCode as r, Reason as s, EvaluationDetails as t };