@avsbhq/node 1.8.0 → 1.9.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 +11 -0
- package/dist/index.cjs +893 -889
- package/dist/index.d.cts +8 -107
- package/dist/index.d.ts +8 -107
- package/dist/index.js +882 -878
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -351,40 +351,14 @@ interface InternalGetFlagOptions extends ServerGetFlagOptions {
|
|
|
351
351
|
/** Runtime type check to apply, from a typed getter. */
|
|
352
352
|
expectedType?: 'boolean' | 'string' | 'number' | 'json';
|
|
353
353
|
}
|
|
354
|
+
|
|
354
355
|
declare class AvsbServer {
|
|
355
|
-
|
|
356
|
-
private readonly
|
|
357
|
-
private
|
|
358
|
-
private
|
|
359
|
-
private
|
|
360
|
-
private
|
|
361
|
-
private readonly eventOptions;
|
|
362
|
-
private readonly streamingEnabled;
|
|
363
|
-
private readonly streamingEndpointOption;
|
|
364
|
-
private readonly overrides;
|
|
365
|
-
private readonly resolveDecideOptions;
|
|
366
|
-
private datafile;
|
|
367
|
-
private datafileEtag;
|
|
368
|
-
private ready;
|
|
369
|
-
private destroyed;
|
|
370
|
-
private tracker;
|
|
371
|
-
private streamingClient;
|
|
372
|
-
private pollingTimer;
|
|
373
|
-
private abortController;
|
|
374
|
-
private listeners;
|
|
375
|
-
private readyPromise;
|
|
376
|
-
private pendingEvents;
|
|
377
|
-
private pendingPurchases;
|
|
378
|
-
/**
|
|
379
|
-
* Exposures produced before the tracker existed. Third member of the
|
|
380
|
-
* pre-ready family alongside `pendingEvents` and `pendingPurchases`; it used
|
|
381
|
-
* to be missing, and exposures were dropped on the floor instead.
|
|
382
|
-
*/
|
|
383
|
-
private pendingExposures;
|
|
384
|
-
/** ms-epoch of the last liveness heartbeat, for the throttle. */
|
|
385
|
-
private lastHeartbeatAt;
|
|
386
|
-
/** Keys of one-time warnings, so a request loop cannot flood a log. */
|
|
387
|
-
private readonly warnedOnce;
|
|
356
|
+
/** Everything mutable about this client. See ./serverState. */
|
|
357
|
+
private readonly s;
|
|
358
|
+
private get tracker();
|
|
359
|
+
private set tracker(value);
|
|
360
|
+
private deliverExposure;
|
|
361
|
+
private initTracker;
|
|
388
362
|
/**
|
|
389
363
|
* `client.utils.*` surface, constructed lazily on first access so the utils
|
|
390
364
|
* package is only imported when actually consumed.
|
|
@@ -413,9 +387,6 @@ declare class AvsbServer {
|
|
|
413
387
|
onReady(): Promise<InitResult>;
|
|
414
388
|
/** True when a datafile is loaded and flags are answerable right now. */
|
|
415
389
|
isReady(): boolean;
|
|
416
|
-
private initializeAndReady;
|
|
417
|
-
/** Wiring that runs once a datafile is readable, however it arrived. */
|
|
418
|
-
private onDatafileReadable;
|
|
419
390
|
close(): Promise<void>;
|
|
420
391
|
flush(): Promise<void>;
|
|
421
392
|
/**
|
|
@@ -448,8 +419,6 @@ declare class AvsbServer {
|
|
|
448
419
|
* published API: its options bag carries package-internal fields.
|
|
449
420
|
*/
|
|
450
421
|
evaluateInternal<T>(flagKey: string, defaultValue: NoInfer<T> | T, context?: EvalContext, options?: InternalGetFlagOptions): Flag<T>;
|
|
451
|
-
private evaluateAndBuild;
|
|
452
|
-
private checkType;
|
|
453
422
|
/**
|
|
454
423
|
* Every flag in the environment, evaluated against one context.
|
|
455
424
|
*
|
|
@@ -515,74 +484,6 @@ declare class AvsbServer {
|
|
|
515
484
|
createDecisionLog(): DecisionLog;
|
|
516
485
|
on<E extends ServerEventName>(event: E, cb: ServerEventMap[E]): () => void;
|
|
517
486
|
off<E extends ServerEventName>(event: E, cb: ServerEventMap[E]): void;
|
|
518
|
-
/**
|
|
519
|
-
* `on` for the shared `ClientEventMap` names the utils layer speaks. The
|
|
520
|
-
* server emits every one of them except `flagChange`, which needs per-flag
|
|
521
|
-
* diffing the server does not do; subscribing to it warns and hands back a
|
|
522
|
-
* no-op disposer instead of pretending.
|
|
523
|
-
*/
|
|
524
|
-
private onSharedEvent;
|
|
525
|
-
private emit;
|
|
526
|
-
private warnOnce;
|
|
527
|
-
private evaluate;
|
|
528
|
-
/**
|
|
529
|
-
* One exposure, delivered everywhere: queued for ingestion AND emitted on
|
|
530
|
-
* the event bus with the SAME `eventId`, so a customer forwarding decisions
|
|
531
|
-
* to their own analytics can reconcile rows with A vs B results.
|
|
532
|
-
*/
|
|
533
|
-
private deliverExposure;
|
|
534
|
-
private toFlag;
|
|
535
|
-
/** Build a Flag from a forced variation key (per-request forced decision). */
|
|
536
|
-
private buildForcedFlag;
|
|
537
|
-
/** Emit the evaluation event and append to a decision log if one was passed. */
|
|
538
|
-
private recordDecision;
|
|
539
|
-
private buildLegacyContext;
|
|
540
|
-
private resolveStickyBucket;
|
|
541
|
-
private findVariation;
|
|
542
|
-
private fireExposureForStickyAssignment;
|
|
543
|
-
private initTracker;
|
|
544
|
-
private enqueuePendingExposure;
|
|
545
|
-
private enqueuePending;
|
|
546
|
-
/**
|
|
547
|
-
* Fetch and apply the datafile.
|
|
548
|
-
*
|
|
549
|
-
* Three outcomes, not two, because a conditional request has three:
|
|
550
|
-
* 'applied' a datafile came back and is now in memory
|
|
551
|
-
* 'unchanged' the CDN answered 304: what we hold IS current
|
|
552
|
-
* 'failed' nothing usable came back; the error is already logged
|
|
553
|
-
*
|
|
554
|
-
* 'unchanged' is a success. Collapsing it into 'failed' made
|
|
555
|
-
* `refreshDatafile()` warn that a refresh "did not apply a new datafile"
|
|
556
|
-
* every time the datafile was simply up to date.
|
|
557
|
-
*/
|
|
558
|
-
private loadDatafile;
|
|
559
|
-
/**
|
|
560
|
-
* Poll on a JITTERED interval. Without the jitter every process that
|
|
561
|
-
* deployed together polls the CDN on the same tick forever.
|
|
562
|
-
*/
|
|
563
|
-
private startPolling;
|
|
564
|
-
/**
|
|
565
|
-
* Open the SSE stream when one is available, and fall back to polling in
|
|
566
|
-
* silence when it is not (B12). The endpoint comes from the datafile's
|
|
567
|
-
* `streamEndpoint` field, or an explicit option; it is never guessed from
|
|
568
|
-
* another host, which is what gave one port an infinite reconnect loop
|
|
569
|
-
* against DNS that does not resolve.
|
|
570
|
-
*/
|
|
571
|
-
private startStreamingIfEnabled;
|
|
572
|
-
/**
|
|
573
|
-
* Report liveness, throttled.
|
|
574
|
-
*
|
|
575
|
-
* Called on every successful datafile load, not just at init: the dashboard
|
|
576
|
-
* marks an environment Stale after five minutes without a heartbeat, so an
|
|
577
|
-
* init-only heartbeat made every long-running process look dead a few
|
|
578
|
-
* minutes after it started. The throttle keeps a fast polling interval (or a
|
|
579
|
-
* burst of stream-triggered refreshes) from turning liveness into traffic.
|
|
580
|
-
*
|
|
581
|
-
* Fire and forget: a failed heartbeat never affects evaluation, and the
|
|
582
|
-
* throttle clock is stamped by the synchronous send below, so a hanging
|
|
583
|
-
* request cannot queue a second one.
|
|
584
|
-
*/
|
|
585
|
-
private sendHeartbeat;
|
|
586
487
|
}
|
|
587
488
|
|
|
588
489
|
declare class InMemoryStickyBucketService implements StickyBucketService {
|
|
@@ -677,6 +578,6 @@ type WebhookVerifyResult = {
|
|
|
677
578
|
declare function verifyWebhookSignature(payload: string | Buffer, headers: WebhookHeaders, secret: string, options?: VerifyWebhookOptions): WebhookVerifyResult;
|
|
678
579
|
|
|
679
580
|
/** This package's version, reported on every liveness heartbeat as `sdkVersion`. */
|
|
680
|
-
declare const SDK_VERSION = "1.
|
|
581
|
+
declare const SDK_VERSION = "1.9.0";
|
|
681
582
|
|
|
682
583
|
export { AvsbServer, type AvsbServerOptions, DEFAULT_TOLERANCE_SECONDS, type DatafileRecipe, type DatasetGetResult, type DatasetsClient, type EventOptions, type GetAllFlagsOptions, InMemoryStickyBucketService, type PurchaseOrder, type RecProduct, type RecsAttribution, type RecsClient, type RecsGetRequest, type RecsResult, type RedisLike, type RedisStickyBucketOptions, RedisStickyBucketService, SDK_VERSION, type ServerEventMap, type ServerEventName, type ServerGetFlagOptions, type ServerLogLevel, type UserBoundClient, type VerifyWebhookOptions, type WebhookHeaders, type WebhookVerifyFailure, type WebhookVerifyResult, createDecisionLog, defaultLogger, isDevEnvironment, resolveServerLogger, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -351,40 +351,14 @@ interface InternalGetFlagOptions extends ServerGetFlagOptions {
|
|
|
351
351
|
/** Runtime type check to apply, from a typed getter. */
|
|
352
352
|
expectedType?: 'boolean' | 'string' | 'number' | 'json';
|
|
353
353
|
}
|
|
354
|
+
|
|
354
355
|
declare class AvsbServer {
|
|
355
|
-
|
|
356
|
-
private readonly
|
|
357
|
-
private
|
|
358
|
-
private
|
|
359
|
-
private
|
|
360
|
-
private
|
|
361
|
-
private readonly eventOptions;
|
|
362
|
-
private readonly streamingEnabled;
|
|
363
|
-
private readonly streamingEndpointOption;
|
|
364
|
-
private readonly overrides;
|
|
365
|
-
private readonly resolveDecideOptions;
|
|
366
|
-
private datafile;
|
|
367
|
-
private datafileEtag;
|
|
368
|
-
private ready;
|
|
369
|
-
private destroyed;
|
|
370
|
-
private tracker;
|
|
371
|
-
private streamingClient;
|
|
372
|
-
private pollingTimer;
|
|
373
|
-
private abortController;
|
|
374
|
-
private listeners;
|
|
375
|
-
private readyPromise;
|
|
376
|
-
private pendingEvents;
|
|
377
|
-
private pendingPurchases;
|
|
378
|
-
/**
|
|
379
|
-
* Exposures produced before the tracker existed. Third member of the
|
|
380
|
-
* pre-ready family alongside `pendingEvents` and `pendingPurchases`; it used
|
|
381
|
-
* to be missing, and exposures were dropped on the floor instead.
|
|
382
|
-
*/
|
|
383
|
-
private pendingExposures;
|
|
384
|
-
/** ms-epoch of the last liveness heartbeat, for the throttle. */
|
|
385
|
-
private lastHeartbeatAt;
|
|
386
|
-
/** Keys of one-time warnings, so a request loop cannot flood a log. */
|
|
387
|
-
private readonly warnedOnce;
|
|
356
|
+
/** Everything mutable about this client. See ./serverState. */
|
|
357
|
+
private readonly s;
|
|
358
|
+
private get tracker();
|
|
359
|
+
private set tracker(value);
|
|
360
|
+
private deliverExposure;
|
|
361
|
+
private initTracker;
|
|
388
362
|
/**
|
|
389
363
|
* `client.utils.*` surface, constructed lazily on first access so the utils
|
|
390
364
|
* package is only imported when actually consumed.
|
|
@@ -413,9 +387,6 @@ declare class AvsbServer {
|
|
|
413
387
|
onReady(): Promise<InitResult>;
|
|
414
388
|
/** True when a datafile is loaded and flags are answerable right now. */
|
|
415
389
|
isReady(): boolean;
|
|
416
|
-
private initializeAndReady;
|
|
417
|
-
/** Wiring that runs once a datafile is readable, however it arrived. */
|
|
418
|
-
private onDatafileReadable;
|
|
419
390
|
close(): Promise<void>;
|
|
420
391
|
flush(): Promise<void>;
|
|
421
392
|
/**
|
|
@@ -448,8 +419,6 @@ declare class AvsbServer {
|
|
|
448
419
|
* published API: its options bag carries package-internal fields.
|
|
449
420
|
*/
|
|
450
421
|
evaluateInternal<T>(flagKey: string, defaultValue: NoInfer<T> | T, context?: EvalContext, options?: InternalGetFlagOptions): Flag<T>;
|
|
451
|
-
private evaluateAndBuild;
|
|
452
|
-
private checkType;
|
|
453
422
|
/**
|
|
454
423
|
* Every flag in the environment, evaluated against one context.
|
|
455
424
|
*
|
|
@@ -515,74 +484,6 @@ declare class AvsbServer {
|
|
|
515
484
|
createDecisionLog(): DecisionLog;
|
|
516
485
|
on<E extends ServerEventName>(event: E, cb: ServerEventMap[E]): () => void;
|
|
517
486
|
off<E extends ServerEventName>(event: E, cb: ServerEventMap[E]): void;
|
|
518
|
-
/**
|
|
519
|
-
* `on` for the shared `ClientEventMap` names the utils layer speaks. The
|
|
520
|
-
* server emits every one of them except `flagChange`, which needs per-flag
|
|
521
|
-
* diffing the server does not do; subscribing to it warns and hands back a
|
|
522
|
-
* no-op disposer instead of pretending.
|
|
523
|
-
*/
|
|
524
|
-
private onSharedEvent;
|
|
525
|
-
private emit;
|
|
526
|
-
private warnOnce;
|
|
527
|
-
private evaluate;
|
|
528
|
-
/**
|
|
529
|
-
* One exposure, delivered everywhere: queued for ingestion AND emitted on
|
|
530
|
-
* the event bus with the SAME `eventId`, so a customer forwarding decisions
|
|
531
|
-
* to their own analytics can reconcile rows with A vs B results.
|
|
532
|
-
*/
|
|
533
|
-
private deliverExposure;
|
|
534
|
-
private toFlag;
|
|
535
|
-
/** Build a Flag from a forced variation key (per-request forced decision). */
|
|
536
|
-
private buildForcedFlag;
|
|
537
|
-
/** Emit the evaluation event and append to a decision log if one was passed. */
|
|
538
|
-
private recordDecision;
|
|
539
|
-
private buildLegacyContext;
|
|
540
|
-
private resolveStickyBucket;
|
|
541
|
-
private findVariation;
|
|
542
|
-
private fireExposureForStickyAssignment;
|
|
543
|
-
private initTracker;
|
|
544
|
-
private enqueuePendingExposure;
|
|
545
|
-
private enqueuePending;
|
|
546
|
-
/**
|
|
547
|
-
* Fetch and apply the datafile.
|
|
548
|
-
*
|
|
549
|
-
* Three outcomes, not two, because a conditional request has three:
|
|
550
|
-
* 'applied' a datafile came back and is now in memory
|
|
551
|
-
* 'unchanged' the CDN answered 304: what we hold IS current
|
|
552
|
-
* 'failed' nothing usable came back; the error is already logged
|
|
553
|
-
*
|
|
554
|
-
* 'unchanged' is a success. Collapsing it into 'failed' made
|
|
555
|
-
* `refreshDatafile()` warn that a refresh "did not apply a new datafile"
|
|
556
|
-
* every time the datafile was simply up to date.
|
|
557
|
-
*/
|
|
558
|
-
private loadDatafile;
|
|
559
|
-
/**
|
|
560
|
-
* Poll on a JITTERED interval. Without the jitter every process that
|
|
561
|
-
* deployed together polls the CDN on the same tick forever.
|
|
562
|
-
*/
|
|
563
|
-
private startPolling;
|
|
564
|
-
/**
|
|
565
|
-
* Open the SSE stream when one is available, and fall back to polling in
|
|
566
|
-
* silence when it is not (B12). The endpoint comes from the datafile's
|
|
567
|
-
* `streamEndpoint` field, or an explicit option; it is never guessed from
|
|
568
|
-
* another host, which is what gave one port an infinite reconnect loop
|
|
569
|
-
* against DNS that does not resolve.
|
|
570
|
-
*/
|
|
571
|
-
private startStreamingIfEnabled;
|
|
572
|
-
/**
|
|
573
|
-
* Report liveness, throttled.
|
|
574
|
-
*
|
|
575
|
-
* Called on every successful datafile load, not just at init: the dashboard
|
|
576
|
-
* marks an environment Stale after five minutes without a heartbeat, so an
|
|
577
|
-
* init-only heartbeat made every long-running process look dead a few
|
|
578
|
-
* minutes after it started. The throttle keeps a fast polling interval (or a
|
|
579
|
-
* burst of stream-triggered refreshes) from turning liveness into traffic.
|
|
580
|
-
*
|
|
581
|
-
* Fire and forget: a failed heartbeat never affects evaluation, and the
|
|
582
|
-
* throttle clock is stamped by the synchronous send below, so a hanging
|
|
583
|
-
* request cannot queue a second one.
|
|
584
|
-
*/
|
|
585
|
-
private sendHeartbeat;
|
|
586
487
|
}
|
|
587
488
|
|
|
588
489
|
declare class InMemoryStickyBucketService implements StickyBucketService {
|
|
@@ -677,6 +578,6 @@ type WebhookVerifyResult = {
|
|
|
677
578
|
declare function verifyWebhookSignature(payload: string | Buffer, headers: WebhookHeaders, secret: string, options?: VerifyWebhookOptions): WebhookVerifyResult;
|
|
678
579
|
|
|
679
580
|
/** This package's version, reported on every liveness heartbeat as `sdkVersion`. */
|
|
680
|
-
declare const SDK_VERSION = "1.
|
|
581
|
+
declare const SDK_VERSION = "1.9.0";
|
|
681
582
|
|
|
682
583
|
export { AvsbServer, type AvsbServerOptions, DEFAULT_TOLERANCE_SECONDS, type DatafileRecipe, type DatasetGetResult, type DatasetsClient, type EventOptions, type GetAllFlagsOptions, InMemoryStickyBucketService, type PurchaseOrder, type RecProduct, type RecsAttribution, type RecsClient, type RecsGetRequest, type RecsResult, type RedisLike, type RedisStickyBucketOptions, RedisStickyBucketService, SDK_VERSION, type ServerEventMap, type ServerEventName, type ServerGetFlagOptions, type ServerLogLevel, type UserBoundClient, type VerifyWebhookOptions, type WebhookHeaders, type WebhookVerifyFailure, type WebhookVerifyResult, createDecisionLog, defaultLogger, isDevEnvironment, resolveServerLogger, verifyWebhookSignature };
|