@ops-ai/react-router-toggly 1.1.0 → 1.2.1
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/CHANGELOG.md +16 -0
- package/dist/client.cjs +81 -24
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +26 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.js +81 -24
- package/dist/client.js.map +1 -1
- package/dist/server.cjs +257 -109
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +49 -5
- package/dist/server.d.ts +49 -5
- package/dist/server.js +257 -109
- package/dist/server.js.map +1 -1
- package/dist/telemetry/grpc.cjs +1 -1
- package/dist/telemetry/grpc.cjs.map +1 -1
- package/dist/telemetry/grpc.js +1 -1
- package/dist/telemetry/grpc.js.map +1 -1
- package/package.json +1 -1
package/dist/server.d.cts
CHANGED
|
@@ -100,6 +100,14 @@ interface TogglyConfig {
|
|
|
100
100
|
localGates?: LocalGate[];
|
|
101
101
|
/** Optional SDK error callback for reporting fetch/evaluation failures. */
|
|
102
102
|
onError?: (message: string, error?: unknown) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Use `/evaluated-variants-signed` and expose {@link TogglyContextValue.getVariant} /
|
|
105
|
+
* `getVariantValue` (client) or the equivalent {@link TogglyServerClient} methods
|
|
106
|
+
* (server). Only applies in `remote` evaluationMode client-side; the server
|
|
107
|
+
* package forces `remote` when this is set (mirrors the Nuxt/Astro OPS-825
|
|
108
|
+
* override — server otherwise defaults to `definitions-signed` + local eval).
|
|
109
|
+
*/
|
|
110
|
+
enableVariants?: boolean;
|
|
103
111
|
/** Host-minted browser capability; takes precedence over client identity targeting. */
|
|
104
112
|
instanceId?: string;
|
|
105
113
|
/** Initial browser identity; hydrated server identity takes precedence. */
|
|
@@ -179,6 +187,13 @@ interface IdentityContext {
|
|
|
179
187
|
* Feature flags state (boolean or entity gate per flag)
|
|
180
188
|
*/
|
|
181
189
|
type FeatureFlags = EvaluatedDefinitions;
|
|
190
|
+
/**
|
|
191
|
+
* Assigned variant for a feature (aligned with @ops-ai/feature-flags-toggly).
|
|
192
|
+
*/
|
|
193
|
+
interface VariantResult {
|
|
194
|
+
name: string;
|
|
195
|
+
configurationValue?: unknown;
|
|
196
|
+
}
|
|
182
197
|
/**
|
|
183
198
|
* Feature evaluation result
|
|
184
199
|
*/
|
|
@@ -355,12 +370,19 @@ declare class TogglyServerClient {
|
|
|
355
370
|
private flags;
|
|
356
371
|
/** Raw definitions-signed models keyed by featureKey. */
|
|
357
372
|
private definitions;
|
|
373
|
+
/** Evaluated-variants-signed defs when `enableVariants`; otherwise null. */
|
|
374
|
+
private variants;
|
|
358
375
|
private hooks;
|
|
359
376
|
private initialized;
|
|
360
377
|
/** Dedupes concurrent cold-start definition fetches. */
|
|
361
378
|
private definitionsLoadPromise;
|
|
362
379
|
/** Single-flight for definition GET so concurrent joiners are not double-counted. */
|
|
363
380
|
private definitionsFetchInFlight;
|
|
381
|
+
/**
|
|
382
|
+
* Serializes variants-mode init so concurrent identities cannot interleave
|
|
383
|
+
* shared `this.variants` / `this.flags` mutations.
|
|
384
|
+
*/
|
|
385
|
+
private variantsInitChain;
|
|
364
386
|
private ws;
|
|
365
387
|
private wsConnected;
|
|
366
388
|
private wsReconnectTimer;
|
|
@@ -420,24 +442,46 @@ declare class TogglyServerClient {
|
|
|
420
442
|
*/
|
|
421
443
|
get isWsConnected(): boolean;
|
|
422
444
|
/**
|
|
423
|
-
* Initialize the client
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
445
|
+
* Initialize the client and optionally bind identity.
|
|
446
|
+
* Local mode: concurrent cold starts share one definitions fetch; each caller
|
|
447
|
+
* still receives a request-local snapshot for its identity.
|
|
448
|
+
* Variants mode: inits are serialized so concurrent identities cannot
|
|
449
|
+
* interleave remote variant assignments on the shared client.
|
|
428
450
|
*/
|
|
429
451
|
init(identity?: string): Promise<FeatureFlags>;
|
|
452
|
+
/**
|
|
453
|
+
* Variants are remote-evaluated; identity must be bound before fetch so
|
|
454
|
+
* `/evaluated-variants-signed` receives the correct `userId`.
|
|
455
|
+
*/
|
|
456
|
+
private initWithVariants;
|
|
457
|
+
private initWithLocalDefinitions;
|
|
430
458
|
/**
|
|
431
459
|
* Fetch feature definitions from the API (definitions-signed; no identity query).
|
|
432
460
|
* Counts one definition-refresh hit/miss per performed attempt; concurrent
|
|
433
461
|
* in-flight joiners await the same fetch and are not counted.
|
|
434
462
|
*/
|
|
435
463
|
fetchFlags(identity?: string): Promise<FeatureFlags>;
|
|
464
|
+
private applyNoAppKeyDefaults;
|
|
465
|
+
private applyParsedDefinitionsBody;
|
|
466
|
+
private hasLastKnownGoodDefinitions;
|
|
467
|
+
private buildDefinitionsFetchUrl;
|
|
468
|
+
private noteNotModifiedResponse;
|
|
469
|
+
private noteAppliedDefinitionsRevision;
|
|
470
|
+
private recoverDefinitionsFetchError;
|
|
436
471
|
private performDefinitionsFetch;
|
|
437
472
|
/**
|
|
438
473
|
* Get all flags
|
|
439
474
|
*/
|
|
440
475
|
getFlags(): FeatureFlags;
|
|
476
|
+
/**
|
|
477
|
+
* Current variant assignment for a feature (requires `enableVariants`).
|
|
478
|
+
* Soft-null when disabled, the feature is off/local-gated, or no variant is assigned.
|
|
479
|
+
*/
|
|
480
|
+
getVariant(featureKey: string): VariantResult | null;
|
|
481
|
+
/**
|
|
482
|
+
* Configuration payload for the assigned variant, if any.
|
|
483
|
+
*/
|
|
484
|
+
getVariantValue<T = unknown>(featureKey: string, isT?: (v: unknown) => v is T): T | null;
|
|
441
485
|
/**
|
|
442
486
|
* Check if a feature is enabled
|
|
443
487
|
*/
|
package/dist/server.d.ts
CHANGED
|
@@ -100,6 +100,14 @@ interface TogglyConfig {
|
|
|
100
100
|
localGates?: LocalGate[];
|
|
101
101
|
/** Optional SDK error callback for reporting fetch/evaluation failures. */
|
|
102
102
|
onError?: (message: string, error?: unknown) => void;
|
|
103
|
+
/**
|
|
104
|
+
* Use `/evaluated-variants-signed` and expose {@link TogglyContextValue.getVariant} /
|
|
105
|
+
* `getVariantValue` (client) or the equivalent {@link TogglyServerClient} methods
|
|
106
|
+
* (server). Only applies in `remote` evaluationMode client-side; the server
|
|
107
|
+
* package forces `remote` when this is set (mirrors the Nuxt/Astro OPS-825
|
|
108
|
+
* override — server otherwise defaults to `definitions-signed` + local eval).
|
|
109
|
+
*/
|
|
110
|
+
enableVariants?: boolean;
|
|
103
111
|
/** Host-minted browser capability; takes precedence over client identity targeting. */
|
|
104
112
|
instanceId?: string;
|
|
105
113
|
/** Initial browser identity; hydrated server identity takes precedence. */
|
|
@@ -179,6 +187,13 @@ interface IdentityContext {
|
|
|
179
187
|
* Feature flags state (boolean or entity gate per flag)
|
|
180
188
|
*/
|
|
181
189
|
type FeatureFlags = EvaluatedDefinitions;
|
|
190
|
+
/**
|
|
191
|
+
* Assigned variant for a feature (aligned with @ops-ai/feature-flags-toggly).
|
|
192
|
+
*/
|
|
193
|
+
interface VariantResult {
|
|
194
|
+
name: string;
|
|
195
|
+
configurationValue?: unknown;
|
|
196
|
+
}
|
|
182
197
|
/**
|
|
183
198
|
* Feature evaluation result
|
|
184
199
|
*/
|
|
@@ -355,12 +370,19 @@ declare class TogglyServerClient {
|
|
|
355
370
|
private flags;
|
|
356
371
|
/** Raw definitions-signed models keyed by featureKey. */
|
|
357
372
|
private definitions;
|
|
373
|
+
/** Evaluated-variants-signed defs when `enableVariants`; otherwise null. */
|
|
374
|
+
private variants;
|
|
358
375
|
private hooks;
|
|
359
376
|
private initialized;
|
|
360
377
|
/** Dedupes concurrent cold-start definition fetches. */
|
|
361
378
|
private definitionsLoadPromise;
|
|
362
379
|
/** Single-flight for definition GET so concurrent joiners are not double-counted. */
|
|
363
380
|
private definitionsFetchInFlight;
|
|
381
|
+
/**
|
|
382
|
+
* Serializes variants-mode init so concurrent identities cannot interleave
|
|
383
|
+
* shared `this.variants` / `this.flags` mutations.
|
|
384
|
+
*/
|
|
385
|
+
private variantsInitChain;
|
|
364
386
|
private ws;
|
|
365
387
|
private wsConnected;
|
|
366
388
|
private wsReconnectTimer;
|
|
@@ -420,24 +442,46 @@ declare class TogglyServerClient {
|
|
|
420
442
|
*/
|
|
421
443
|
get isWsConnected(): boolean;
|
|
422
444
|
/**
|
|
423
|
-
* Initialize the client
|
|
424
|
-
*
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
445
|
+
* Initialize the client and optionally bind identity.
|
|
446
|
+
* Local mode: concurrent cold starts share one definitions fetch; each caller
|
|
447
|
+
* still receives a request-local snapshot for its identity.
|
|
448
|
+
* Variants mode: inits are serialized so concurrent identities cannot
|
|
449
|
+
* interleave remote variant assignments on the shared client.
|
|
428
450
|
*/
|
|
429
451
|
init(identity?: string): Promise<FeatureFlags>;
|
|
452
|
+
/**
|
|
453
|
+
* Variants are remote-evaluated; identity must be bound before fetch so
|
|
454
|
+
* `/evaluated-variants-signed` receives the correct `userId`.
|
|
455
|
+
*/
|
|
456
|
+
private initWithVariants;
|
|
457
|
+
private initWithLocalDefinitions;
|
|
430
458
|
/**
|
|
431
459
|
* Fetch feature definitions from the API (definitions-signed; no identity query).
|
|
432
460
|
* Counts one definition-refresh hit/miss per performed attempt; concurrent
|
|
433
461
|
* in-flight joiners await the same fetch and are not counted.
|
|
434
462
|
*/
|
|
435
463
|
fetchFlags(identity?: string): Promise<FeatureFlags>;
|
|
464
|
+
private applyNoAppKeyDefaults;
|
|
465
|
+
private applyParsedDefinitionsBody;
|
|
466
|
+
private hasLastKnownGoodDefinitions;
|
|
467
|
+
private buildDefinitionsFetchUrl;
|
|
468
|
+
private noteNotModifiedResponse;
|
|
469
|
+
private noteAppliedDefinitionsRevision;
|
|
470
|
+
private recoverDefinitionsFetchError;
|
|
436
471
|
private performDefinitionsFetch;
|
|
437
472
|
/**
|
|
438
473
|
* Get all flags
|
|
439
474
|
*/
|
|
440
475
|
getFlags(): FeatureFlags;
|
|
476
|
+
/**
|
|
477
|
+
* Current variant assignment for a feature (requires `enableVariants`).
|
|
478
|
+
* Soft-null when disabled, the feature is off/local-gated, or no variant is assigned.
|
|
479
|
+
*/
|
|
480
|
+
getVariant(featureKey: string): VariantResult | null;
|
|
481
|
+
/**
|
|
482
|
+
* Configuration payload for the assigned variant, if any.
|
|
483
|
+
*/
|
|
484
|
+
getVariantValue<T = unknown>(featureKey: string, isT?: (v: unknown) => v is T): T | null;
|
|
441
485
|
/**
|
|
442
486
|
* Check if a feature is enabled
|
|
443
487
|
*/
|