@revturbine/sdk 0.11.19 → 0.11.20
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 +42 -0
- package/dist/growthbook.d.ts +16 -1
- package/dist/headless.d.ts +140 -19
- package/dist/headless.js +2 -2
- package/dist/headless.js.map +1 -1
- package/dist/index.d.ts +140 -19
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/optimizely.d.ts +16 -1
- package/dist/types/server-node/local-server.d.ts +13 -1
- package/dist/types/server-node/local-server.d.ts.map +1 -1
- package/dist/types/web-sdk/customer-side.d.ts +51 -16
- package/dist/types/web-sdk/customer-side.d.ts.map +1 -1
- package/dist/types/web-sdk/placements/AccessGateSurfaceSlot.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -27720,6 +27720,52 @@ type PlaybookOption = {
|
|
|
27720
27720
|
exportedConfig: RevTurbineConfig;
|
|
27721
27721
|
};
|
|
27722
27722
|
|
|
27723
|
+
/**
|
|
27724
|
+
* Effective entitlements — the ONE answer every SDK runtime uses (D-61,
|
|
27725
|
+
* Kent 2026-10-06).
|
|
27726
|
+
*
|
|
27727
|
+
* The shared evaluator (`deriveLocalEntitlementFromConfiguredRules`) decides
|
|
27728
|
+
* each entitlement from the Playbook + user context. An app may then enrich
|
|
27729
|
+
* that answer with its own data ("Entitlement Mirroring"): grants on
|
|
27730
|
+
* `UserContext.entitlements` and/or an app-registered entitlement provider.
|
|
27731
|
+
* The two are merged with a configurable precedence — provider level
|
|
27732
|
+
* (`precedence`, default `'app'`) with optional per-field overrides.
|
|
27733
|
+
*
|
|
27734
|
+
* Browser and server SDKs run this same function on the same inputs: the
|
|
27735
|
+
* browser result shapes interaction, the server result verifies it.
|
|
27736
|
+
*
|
|
27737
|
+
* An entitlement handle neither the Playbook nor the app knows is DENIED
|
|
27738
|
+
* (`entitlement_not_in_playbook`) and flagged `unknownHandle`, so the runtime
|
|
27739
|
+
* can warn and report it.
|
|
27740
|
+
*/
|
|
27741
|
+
|
|
27742
|
+
/** Which side wins a merge: the app's own data, or the Playbook evaluation. */
|
|
27743
|
+
type EntitlementSource = 'app' | 'playbook';
|
|
27744
|
+
/** Fields that can be given their own precedence. `status` carries `allowed` and `reason` with it. */
|
|
27745
|
+
type EntitlementMergeField = 'status' | 'limit' | 'used' | 'remaining';
|
|
27746
|
+
interface EntitlementMergeOptions {
|
|
27747
|
+
/** Provider-level precedence. Default `'app'`: app-supplied data wins. */
|
|
27748
|
+
precedence?: EntitlementSource;
|
|
27749
|
+
/** Per-field overrides of `precedence`. */
|
|
27750
|
+
fields?: Partial<Record<EntitlementMergeField, EntitlementSource>>;
|
|
27751
|
+
}
|
|
27752
|
+
/** A mirrored grant on `UserContext.entitlements`: a boolean, or a grant-shaped record. */
|
|
27753
|
+
type MirroredEntitlement = boolean | {
|
|
27754
|
+
status?: string;
|
|
27755
|
+
allowed?: boolean;
|
|
27756
|
+
limit?: number;
|
|
27757
|
+
used?: number;
|
|
27758
|
+
remaining?: number;
|
|
27759
|
+
reason?: string;
|
|
27760
|
+
};
|
|
27761
|
+
/** The trial facts reverse-trial grants depend on (`UserTrialStatus` subset). */
|
|
27762
|
+
interface ReverseTrialView {
|
|
27763
|
+
in_trial?: boolean;
|
|
27764
|
+
trial_type?: string;
|
|
27765
|
+
/** The user's BASE plan while on a reverse trial. */
|
|
27766
|
+
plan_handle?: string;
|
|
27767
|
+
}
|
|
27768
|
+
|
|
27723
27769
|
/**
|
|
27724
27770
|
* User context lifecycle — pure functions for building, merging,
|
|
27725
27771
|
* and deriving targeting state from user context + RevTurbineConfig.
|
|
@@ -27742,7 +27788,12 @@ interface UserContextSnapshot {
|
|
|
27742
27788
|
*/
|
|
27743
27789
|
plan?: string | UserPlanContext;
|
|
27744
27790
|
custom?: Record<string, JsonValue>;
|
|
27745
|
-
|
|
27791
|
+
/**
|
|
27792
|
+
* App-supplied entitlement data keyed by handle — a boolean or a grant
|
|
27793
|
+
* (D-61 Entitlement Mirroring). Merged with the Playbook evaluation by the
|
|
27794
|
+
* effective-entitlement core; flattened into segment traits as a boolean.
|
|
27795
|
+
*/
|
|
27796
|
+
entitlements?: Record<string, MirroredEntitlement>;
|
|
27746
27797
|
usage?: Record<string, UserUsageEntry>;
|
|
27747
27798
|
personalization?: Record<string, JsonValue>;
|
|
27748
27799
|
/** Canonical experiment-handle to variant-handle assignments. */
|
|
@@ -28023,6 +28074,13 @@ interface EntitlementUsageEntry {
|
|
|
28023
28074
|
reset_date?: string;
|
|
28024
28075
|
}
|
|
28025
28076
|
interface EntitlementProviderState {
|
|
28077
|
+
/**
|
|
28078
|
+
* D-61: `'playbook_default'` marks entries the static adapter fills with a
|
|
28079
|
+
* blanket default policy. Those are NOT app data and never override the
|
|
28080
|
+
* Playbook evaluation; entries from any other provider are app-mirrored
|
|
28081
|
+
* data and merge with it per the runtime's precedence.
|
|
28082
|
+
*/
|
|
28083
|
+
origin?: 'playbook_default';
|
|
28026
28084
|
/**
|
|
28027
28085
|
* All entitlement results keyed by entitlement handle.
|
|
28028
28086
|
* Each entry carries status ('allowed' | 'limited' | 'denied') so the
|
|
@@ -28496,7 +28554,7 @@ interface DecisionEngineOptions {
|
|
|
28496
28554
|
enableCapsEnforcement?: boolean;
|
|
28497
28555
|
/** Enable category pipeline for local-mode priority ordering. Default: false. */
|
|
28498
28556
|
enableCategoryPipelineLocalMode?: boolean;
|
|
28499
|
-
/** Default entitlement policy when no provider or entry found. Default: '
|
|
28557
|
+
/** Default entitlement policy when no provider or entry found. Default: 'deny' (fail closed, D-61). */
|
|
28500
28558
|
defaultEntitlementPolicy?: 'allow' | 'deny';
|
|
28501
28559
|
}
|
|
28502
28560
|
interface EntitlementCheckResult {
|
|
@@ -29391,6 +29449,20 @@ interface LocalRuntimeOptionsBase {
|
|
|
29391
29449
|
impressionStore?: ImpressionHistoryStore;
|
|
29392
29450
|
/** Decision engine behavior flags. */
|
|
29393
29451
|
engineOptions?: DecisionEngineOptions;
|
|
29452
|
+
/**
|
|
29453
|
+
* D-61 Entitlement Mirroring: the user context's own entitlement data
|
|
29454
|
+
* (`UserContext.entitlements`), merged with the Playbook evaluation.
|
|
29455
|
+
*/
|
|
29456
|
+
userEntitlements?: Record<string, MirroredEntitlement>;
|
|
29457
|
+
/** D-61: the user's trial status, so reverse-trial grants evaluate exactly as in the browser. */
|
|
29458
|
+
trialStatus?: ReverseTrialView;
|
|
29459
|
+
/** D-61: how app-supplied entitlement data merges with the Playbook result. Default: app wins. */
|
|
29460
|
+
entitlementMerge?: EntitlementMergeOptions;
|
|
29461
|
+
/**
|
|
29462
|
+
* Called once per entitlement handle that neither the Playbook nor the app
|
|
29463
|
+
* knows (it is denied). The runtime also logs a warning. Wire telemetry here.
|
|
29464
|
+
*/
|
|
29465
|
+
onUnknownEntitlement?: (handle: string) => void;
|
|
29394
29466
|
/** Interaction tracker options. */
|
|
29395
29467
|
interactionOptions?: Partial<Pick<InteractionTrackerOptions, 'defaultDismissCooldownMs' | 'defaultRemindLaterMs'>>;
|
|
29396
29468
|
}
|
|
@@ -29411,6 +29483,11 @@ declare class LocalRuntime {
|
|
|
29411
29483
|
readonly impressionHistory: ImpressionHistory;
|
|
29412
29484
|
private readonly playbook;
|
|
29413
29485
|
private readonly registeredPlacements;
|
|
29486
|
+
private readonly userEntitlements;
|
|
29487
|
+
private readonly trialStatus;
|
|
29488
|
+
private readonly entitlementMerge;
|
|
29489
|
+
private readonly onUnknownEntitlement;
|
|
29490
|
+
private readonly reportedUnknownEntitlements;
|
|
29414
29491
|
private userId;
|
|
29415
29492
|
constructor(options: LocalRuntimeOptions);
|
|
29416
29493
|
/**
|
|
@@ -29448,7 +29525,12 @@ declare class LocalRuntime {
|
|
|
29448
29525
|
*/
|
|
29449
29526
|
getPlacement(config: RevTurbinePlacementRequestConfig$1): Promise<RevTurbinePlacementDecision | null>;
|
|
29450
29527
|
/**
|
|
29451
|
-
* Check entitlement access locally
|
|
29528
|
+
* Check entitlement access locally (D-61): the shared evaluator decides
|
|
29529
|
+
* from the Playbook + user context, then app-mirrored data (user-context
|
|
29530
|
+
* grants and any app entitlement provider) merges per the runtime's
|
|
29531
|
+
* precedence (default: app wins). The browser SDK runs the same function on
|
|
29532
|
+
* the same inputs, so the server verifies exactly what the browser showed.
|
|
29533
|
+
* An entitlement nobody knows is denied, warned and reported.
|
|
29452
29534
|
*/
|
|
29453
29535
|
checkEntitlement(handle: string, context?: RevTurbineEntitlementContext): Promise<EntitlementResult>;
|
|
29454
29536
|
/**
|
|
@@ -29511,7 +29593,11 @@ declare class LocalRuntime {
|
|
|
29511
29593
|
*/
|
|
29512
29594
|
private slotRecordForConfig;
|
|
29513
29595
|
private buildPlacementResolver;
|
|
29514
|
-
|
|
29596
|
+
/** Evaluator inputs from the resolved providers — the same facts the browser SDK uses. */
|
|
29597
|
+
private effectiveBase;
|
|
29598
|
+
/** App-mirrored data per handle: user-context grants plus non-default provider entries. */
|
|
29599
|
+
private appInputsByHandle;
|
|
29600
|
+
private reportUnknownEntitlement;
|
|
29515
29601
|
}
|
|
29516
29602
|
|
|
29517
29603
|
/**
|
|
@@ -31009,8 +31095,14 @@ interface RevTurbineUserContext extends Omit<UserContextInput, 'custom' | 'entit
|
|
|
31009
31095
|
context_hash?: UserContextInput['context_hash'];
|
|
31010
31096
|
/** Customer-defined fields for segmentation and personalization. */
|
|
31011
31097
|
custom?: SdkTraits;
|
|
31012
|
-
/**
|
|
31013
|
-
|
|
31098
|
+
/**
|
|
31099
|
+
* App-supplied entitlement data, keyed by handle — a boolean or a grant
|
|
31100
|
+
* (`status`, `limit`, `used`). This is Entitlement Mirroring (D-61): it
|
|
31101
|
+
* merges with the Playbook evaluation, and by default the app's data wins.
|
|
31102
|
+
* Browser-supplied data shapes the UI only; the server re-check on the
|
|
31103
|
+
* same inputs stays authoritative for paid actions.
|
|
31104
|
+
*/
|
|
31105
|
+
entitlements?: UserContextInput['entitlements'];
|
|
31014
31106
|
/** Usage entries derived from credits / usage_limit entitlements, keyed by handle. */
|
|
31015
31107
|
usage?: UserContextInput['usage'];
|
|
31016
31108
|
/**
|
|
@@ -31493,6 +31585,14 @@ interface RevTurbineInitOptions {
|
|
|
31493
31585
|
* Playbook.
|
|
31494
31586
|
*/
|
|
31495
31587
|
placementBehavior?: Partial<RevTurbinePlacementBehaviorFlags>;
|
|
31588
|
+
/**
|
|
31589
|
+
* How app-supplied entitlement data (`userContext.entitlements`, an app
|
|
31590
|
+
* entitlement provider) merges with the Playbook evaluation (D-61).
|
|
31591
|
+
* Provider-level `precedence` defaults to `'app'`; `fields` overrides it
|
|
31592
|
+
* per field (`status`, `limit`, `used`, `remaining`). Use the same value
|
|
31593
|
+
* on your server SDK so verification matches.
|
|
31594
|
+
*/
|
|
31595
|
+
entitlementMerge?: EntitlementMergeOptions;
|
|
31496
31596
|
extension?: {
|
|
31497
31597
|
enabled?: boolean;
|
|
31498
31598
|
};
|
|
@@ -32267,6 +32367,16 @@ declare class RevTurbineCustomerSdk {
|
|
|
32267
32367
|
private readonly policy;
|
|
32268
32368
|
private readonly extensionEnabled;
|
|
32269
32369
|
private readonly placementBehaviorOverrides;
|
|
32370
|
+
private readonly entitlementMerge;
|
|
32371
|
+
/** Entries from an app-registered entitlement provider (D-61 mirroring), from the last provider resolution. */
|
|
32372
|
+
private appProviderEntitlements;
|
|
32373
|
+
/** Plan from an app-registered plan provider (D-61) — wins over the user-context plan, as on the server. */
|
|
32374
|
+
private appProviderPlanHandle;
|
|
32375
|
+
/** Usage from an app entitlement provider (D-61), fed into the evaluation as on the server. */
|
|
32376
|
+
private appProviderUsage;
|
|
32377
|
+
/** Segment membership from an app segment provider (D-61), as a server runtime sees it. */
|
|
32378
|
+
private appProviderSegments;
|
|
32379
|
+
private readonly reportedUnknownEntitlements;
|
|
32270
32380
|
private derivedPlacementBehaviorMemo;
|
|
32271
32381
|
private readonly providerFailureSlotBehavior;
|
|
32272
32382
|
private readonly uiPathResolvers;
|
|
@@ -32765,6 +32875,14 @@ declare class RevTurbineCustomerSdk {
|
|
|
32765
32875
|
*/
|
|
32766
32876
|
private candidateCapGate;
|
|
32767
32877
|
private recordPresentationCapRules;
|
|
32878
|
+
/**
|
|
32879
|
+
* D-60 + D-61: the resolver's gates read the SAME effective entitlements
|
|
32880
|
+
* `checkEntitlement` returns — the shared evaluation merged with
|
|
32881
|
+
* app-mirrored data — for every handle the Playbook, the user context or an
|
|
32882
|
+
* app provider knows. A gate slot's reported `entitlement_status` still
|
|
32883
|
+
* wins inside the resolver.
|
|
32884
|
+
*/
|
|
32885
|
+
private withSlotEntitlementStatus;
|
|
32768
32886
|
private slotIdForRecord;
|
|
32769
32887
|
private hydratePresentationCaps;
|
|
32770
32888
|
private persistPresentationCaps;
|
|
@@ -32941,22 +33059,25 @@ declare class RevTurbineCustomerSdk {
|
|
|
32941
33059
|
* @public
|
|
32942
33060
|
*/
|
|
32943
33061
|
setApiBranding(branding: BrandingConfig | undefined): void;
|
|
33062
|
+
/**
|
|
33063
|
+
* The effective entitlement (D-61): the shared core evaluator decides from
|
|
33064
|
+
* the Playbook + user context, then app-mirrored data merges per
|
|
33065
|
+
* `entitlementMerge` (default: app wins). The server SDKs run the same
|
|
33066
|
+
* function on the same inputs, so a server re-check verifies exactly this.
|
|
33067
|
+
* An entitlement nobody knows is denied, warned once and reported.
|
|
33068
|
+
*/
|
|
32944
33069
|
private deriveLocalEntitlementFromConfiguredRules;
|
|
32945
33070
|
/**
|
|
32946
|
-
*
|
|
32947
|
-
*
|
|
32948
|
-
*
|
|
32949
|
-
*
|
|
32950
|
-
* the rule has no entitlements_during_trial[].
|
|
32951
|
-
*
|
|
32952
|
-
* Why inline (not calling scaffold's deriveReverseTrialGrants):
|
|
32953
|
-
* the scaffold helper takes a `TrialInstance` (DB-side state) and
|
|
32954
|
-
* matches by `rule_id`. The SDK only holds `UserTrialStatus` (the
|
|
32955
|
-
* transient runtime shape) and doesn't see the rule_id. We match
|
|
32956
|
-
* by `fallback_plan_id === plan_handle` instead — that's the
|
|
32957
|
-
* single configured rule the user can be on per spec §2.4.2.
|
|
33071
|
+
* D-61: snapshot what the app's own providers say — plan, entitlement
|
|
33072
|
+
* entries, usage — so the browser evaluates on exactly the inputs a server
|
|
33073
|
+
* runtime with the same providers would. A static adapter's blanket
|
|
33074
|
+
* defaults are not app data.
|
|
32958
33075
|
*/
|
|
32959
|
-
private
|
|
33076
|
+
private captureAppProviderState;
|
|
33077
|
+
/** D-61: resolve the app's providers before an entitlement check (cached per provider TTL). */
|
|
33078
|
+
private refreshAppProviderState;
|
|
33079
|
+
/** D-61: an unknown entitlement handle is denied; say so once, locally and in telemetry. */
|
|
33080
|
+
private reportUnknownEntitlement;
|
|
32960
33081
|
/**
|
|
32961
33082
|
* Return the SDK-resolved targeting snapshot for the active user.
|
|
32962
33083
|
*
|