@uniformdev/context 20.3.1 → 20.4.1-alpha.15
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/dist/api/api.d.mts +1 -1
- package/dist/api/api.d.ts +1 -1
- package/dist/index.d.mts +20 -4
- package/dist/index.d.ts +20 -4
- package/dist/index.esm.js +120 -25
- package/dist/index.js +122 -26
- package/dist/index.mjs +120 -25
- package/dist/{types-EJl31yuP.d.mts → types-BPchcX4k.d.mts} +91 -24
- package/dist/{types-EJl31yuP.d.ts → types-BPchcX4k.d.ts} +91 -24
- package/package.json +2 -2
| @@ -859,6 +859,10 @@ type LogMessages = { | |
| 859 859 | 
             
                }>;
         | 
| 860 860 | 
             
                /** Final result for a personalized variation */
         | 
| 861 861 | 
             
                303: MessageFunc<boolean>;
         | 
| 862 | 
            +
                /** Personalization algorithm not found */
         | 
| 863 | 
            +
                304: MessageFunc<{
         | 
| 864 | 
            +
                    algorithm: string;
         | 
| 865 | 
            +
                }>;
         | 
| 862 866 | 
             
                /** A/B test placement executing */
         | 
| 863 867 | 
             
                400: MessageFunc<string>;
         | 
| 864 868 | 
             
                /** A/B Test definition did not exist */
         | 
| @@ -898,23 +902,29 @@ type LogMessageSingle<TID extends keyof LogMessages = keyof LogMessages> = [ | |
| 898 902 | 
             
            type LogMessageGroup<TID extends keyof LogMessages = keyof LogMessages> = [severity: Severity, id: TID, group: 'GROUP', ...args: Parameters<LogMessages[TID]>] | [severity: Severity, id: TID, group: 'ENDGROUP'];
         | 
| 899 903 | 
             
            type LogDrain = (message: LogMessage) => void;
         | 
| 900 904 |  | 
| 901 | 
            -
             | 
| 905 | 
            +
            /** Data for a personalization variation using the top-down criteria selection algorithm */
         | 
| 906 | 
            +
            interface VariantMatchCriteria extends VariantMatchMetadata {
         | 
| 902 907 | 
             
                /**
         | 
| 903 908 | 
             
                 * Operation for match criteria
         | 
| 904 909 | 
             
                 *
         | 
| 905 910 | 
             
                 * @defaultValue `&`
         | 
| 906 911 | 
             
                 */
         | 
| 907 912 | 
             
                op?: '&' | '|';
         | 
| 908 | 
            -
                crit: DimensionMatch | 
| 909 | 
            -
                /**
         | 
| 910 | 
            -
                 * Name of the variant for analytics tracking.
         | 
| 911 | 
            -
                 */
         | 
| 912 | 
            -
                name?: string;
         | 
| 913 | 
            +
                crit: Array<DimensionMatch | QuirkMatch>;
         | 
| 913 914 | 
             
                /**
         | 
| 914 915 | 
             
                 * Control group percentage for the variant.
         | 
| 915 916 | 
             
                 */
         | 
| 916 917 | 
             
                control?: number;
         | 
| 917 | 
            -
            } | 
| 918 | 
            +
            }
         | 
| 919 | 
            +
            /** Data that must exist on a personalization variation regardless of selection algorithm */
         | 
| 920 | 
            +
            interface VariantMatchMetadata {
         | 
| 921 | 
            +
                /**
         | 
| 922 | 
            +
                 * Name of the variation for analytics tracking.
         | 
| 923 | 
            +
                 * NOTE: name is optional for backwards compatibility, but it is HIGHLY recommended to specify a name
         | 
| 924 | 
            +
                 * as the default fallback is not helpfully named and is reliant on the order of the variations array.
         | 
| 925 | 
            +
                 */
         | 
| 926 | 
            +
                name?: string;
         | 
| 927 | 
            +
            }
         | 
| 918 928 | 
             
            type DimensionMatch = {
         | 
| 919 929 | 
             
                /**
         | 
| 920 930 | 
             
                 * Left hand side of the match expression (name of dimension in score vector)
         | 
| @@ -953,17 +963,48 @@ type DimensionMatch = { | |
| 953 963 | 
             
                 */
         | 
| 954 964 | 
             
                rDim?: string;
         | 
| 955 965 | 
             
            };
         | 
| 966 | 
            +
            type QuirkMatch = {
         | 
| 967 | 
            +
                /**
         | 
| 968 | 
            +
                 * Type of match expression; 'q' discriminates quirk matches from dimension matches
         | 
| 969 | 
            +
                 */
         | 
| 970 | 
            +
                t: 'q';
         | 
| 971 | 
            +
                /**
         | 
| 972 | 
            +
                 * Left hand side of the match expression (name of quirk)
         | 
| 973 | 
            +
                 * NOTE: if the quirk is not present
         | 
| 974 | 
            +
                 */
         | 
| 975 | 
            +
                l: string;
         | 
| 976 | 
            +
                /**
         | 
| 977 | 
            +
                 * Operator of the match expression
         | 
| 978 | 
            +
                 * Comparison operators:
         | 
| 979 | 
            +
                 * =: `l` is equal to the right hand side expression
         | 
| 980 | 
            +
                 * !=: `l` is not equal to the right hand side expression
         | 
| 981 | 
            +
                 */
         | 
| 982 | 
            +
                op: '=' | '!=';
         | 
| 983 | 
            +
                /**
         | 
| 984 | 
            +
                 * Right hand side of the match expression
         | 
| 985 | 
            +
                 * This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
         | 
| 986 | 
            +
                 * To reference another score dimension as the RHS, use the `rDim` property instead.
         | 
| 987 | 
            +
                 * `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
         | 
| 988 | 
            +
                 */
         | 
| 989 | 
            +
                r: string;
         | 
| 990 | 
            +
                /**
         | 
| 991 | 
            +
                 * Only here to maintain object compatibility with DimensionMatch.
         | 
| 992 | 
            +
                 * Completely ignored.
         | 
| 993 | 
            +
                 * @deprecated this is not used with QuirkMatch.
         | 
| 994 | 
            +
                 */
         | 
| 995 | 
            +
                rDim?: string;
         | 
| 996 | 
            +
            };
         | 
| 956 997 |  | 
| 957 998 | 
             
            /** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
         | 
| 958 999 | 
             
            type BehaviorTag = {
         | 
| 959 1000 | 
             
                beh?: EnrichmentData[];
         | 
| 960 1001 | 
             
            };
         | 
| 961 1002 | 
             
            /** Defines the shape of a personalized content variant */
         | 
| 962 | 
            -
            type PersonalizedVariant = {
         | 
| 1003 | 
            +
            type PersonalizedVariant<TCriteria = VariantMatchCriteria> = {
         | 
| 963 1004 | 
             
                /** A unique identifier for this variation */
         | 
| 964 1005 | 
             
                id: string;
         | 
| 965 1006 | 
             
                /** Match criteria for this variation */
         | 
| 966 | 
            -
                pz?:  | 
| 1007 | 
            +
                pz?: TCriteria;
         | 
| 967 1008 | 
             
            };
         | 
| 968 1009 | 
             
            /** The result of computing personalized content from variations */
         | 
| 969 1010 | 
             
            type PersonalizedResult<TVariant> = {
         | 
| @@ -971,6 +1012,7 @@ type PersonalizedResult<TVariant> = { | |
| 971 1012 | 
             
                personalized: boolean;
         | 
| 972 1013 | 
             
                /** Matching variations */
         | 
| 973 1014 | 
             
                variations: Array<TVariant & {
         | 
| 1015 | 
            +
                    /** Whether the visitor is part of this variation's local control group (also true if part of global control group) */
         | 
| 974 1016 | 
             
                    control: boolean;
         | 
| 975 1017 | 
             
                }>;
         | 
| 976 1018 | 
             
            };
         | 
| @@ -995,19 +1037,28 @@ type TestResult<TVariant> = { | |
| 995 1037 | 
             
                 */
         | 
| 996 1038 | 
             
                variantAssigned: boolean;
         | 
| 997 1039 | 
             
            };
         | 
| 998 | 
            -
             | 
| 999 | 
            -
             | 
| 1040 | 
            +
            interface PersonalizeOptions<TVariant> {
         | 
| 1041 | 
            +
                /** Name of placement (sent to analytics) */
         | 
| 1042 | 
            +
                name: string;
         | 
| 1043 | 
            +
                /** Possible variations to place  */
         | 
| 1044 | 
            +
                variations: Iterable<TVariant>;
         | 
| 1045 | 
            +
                /** Maximum number of variants to place (default: 1) */
         | 
| 1046 | 
            +
                take?: number;
         | 
| 1047 | 
            +
                /** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
         | 
| 1048 | 
            +
                algorithm?: string;
         | 
| 1049 | 
            +
            }
         | 
| 1050 | 
            +
            interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
         | 
| 1000 1051 | 
             
                /** Name of placement (sent to analytics) */
         | 
| 1001 1052 | 
             
                name: string;
         | 
| 1002 | 
            -
                /** Possible  | 
| 1053 | 
            +
                /** Possible variations to place  */
         | 
| 1003 1054 | 
             
                variations: Iterable<TVariant>;
         | 
| 1004 1055 | 
             
                /** Maximum number of variants to place (default: 1) */
         | 
| 1005 1056 | 
             
                take?: number;
         | 
| 1057 | 
            +
                /** Callback for logging messages */
         | 
| 1006 1058 | 
             
                onLogMessage?: (message: LogMessage) => void;
         | 
| 1007 | 
            -
             | 
| 1008 | 
            -
            declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
         | 
| 1059 | 
            +
                /** Context instance */
         | 
| 1009 1060 | 
             
                context: Context;
         | 
| 1010 | 
            -
            } | 
| 1061 | 
            +
            }
         | 
| 1011 1062 |  | 
| 1012 1063 | 
             
            type TestOptions<TVariant extends TestVariant> = {
         | 
| 1013 1064 | 
             
                /** The name of the test that is being run, must be included in the manifest. */
         | 
| @@ -1022,18 +1073,31 @@ declare const testVariations: <TVariant extends TestVariant>({ name, context, va | |
| 1022 1073 |  | 
| 1023 1074 | 
             
            declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
         | 
| 1024 1075 | 
             
            declare const CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
         | 
| 1076 | 
            +
            type PersonalizationSelectionAlgorithm<TCriteria = unknown> = (options: PersonalizationSelectionAlgorithmOptions<TCriteria>) => PersonalizedResult<PersonalizedVariant<TCriteria>>;
         | 
| 1077 | 
            +
            type PersonalizationSelectionAlgorithms<TCriteria = unknown> = Record<string, PersonalizationSelectionAlgorithm<TCriteria>>;
         | 
| 1025 1078 | 
             
            /**
         | 
| 1026 1079 | 
             
             * Defines a plugin for Uniform Context.
         | 
| 1027 1080 | 
             
             * The plugin should attach event handlers in its creation function.
         | 
| 1028 1081 | 
             
             * @returns A function that detaches any event handlers when called
         | 
| 1029 1082 | 
             
             */
         | 
| 1030 1083 | 
             
            type ContextPlugin = {
         | 
| 1084 | 
            +
                /** Defines a log drain for the plugin, which all log messages are sent to */
         | 
| 1031 1085 | 
             
                logDrain?: LogDrain;
         | 
| 1086 | 
            +
                /** Initializes the plugin (attach event handlers here if needed) */
         | 
| 1032 1087 | 
             
                init?: (context: Context) => () => void;
         | 
| 1088 | 
            +
                /** Plugin-specific actions to perform when a user is forgotten */
         | 
| 1033 1089 | 
             
                forget?: () => Promise<void> | void;
         | 
| 1090 | 
            +
                /** Plugin-specific actions to perform when the visitor context is updated */
         | 
| 1034 1091 | 
             
                update?: (newData: Partial<ContextState>) => Promise<void> | void;
         | 
| 1092 | 
            +
                /**
         | 
| 1093 | 
            +
                 * Allows the plugin to register named personalization selection algorithms
         | 
| 1094 | 
            +
                 *
         | 
| 1095 | 
            +
                 * Important: the `default` and `strongestMatch` algorithms are automatically registered.
         | 
| 1096 | 
            +
                 * We strongly advise against replacing these.
         | 
| 1097 | 
            +
                 */
         | 
| 1098 | 
            +
                personalizationSelectionAlgorithms?: PersonalizationSelectionAlgorithms<any>;
         | 
| 1035 1099 | 
             
            };
         | 
| 1036 | 
            -
             | 
| 1100 | 
            +
            interface ContextOptions extends Omit<VisitorDataStoreOptions, 'manifest' | 'onServerTransitionScoresReceived'> {
         | 
| 1037 1101 | 
             
                /** The Context Manifest to load (from the Context API) */
         | 
| 1038 1102 | 
             
                manifest: ManifestV2;
         | 
| 1039 1103 | 
             
                /**
         | 
| @@ -1050,16 +1114,19 @@ type ContextOptions = { | |
| 1050 1114 | 
             
                 * `true`: personalization is not run at all unless storage consent is given
         | 
| 1051 1115 | 
             
                 */
         | 
| 1052 1116 | 
             
                requireConsentForPersonalization?: boolean;
         | 
| 1053 | 
            -
            } | 
| 1117 | 
            +
            }
         | 
| 1118 | 
            +
            type PersonalizationEventVariantId = {
         | 
| 1119 | 
            +
                /** The variant ID that was selected */
         | 
| 1120 | 
            +
                id: string;
         | 
| 1121 | 
            +
                /** Whether the visitor is part of this variant's local control group (also true if part of global control group) */
         | 
| 1122 | 
            +
                control: boolean;
         | 
| 1123 | 
            +
            };
         | 
| 1054 1124 | 
             
            /** Emitted when a personalization runs */
         | 
| 1055 1125 | 
             
            type PersonalizationEvent = {
         | 
| 1056 1126 | 
             
                /** Name of the personalized placement */
         | 
| 1057 1127 | 
             
                name: string;
         | 
| 1058 1128 | 
             
                /** Selected variant ID(s) */
         | 
| 1059 | 
            -
                variantIds:  | 
| 1060 | 
            -
                    id: string;
         | 
| 1061 | 
            -
                    control: boolean;
         | 
| 1062 | 
            -
                }[];
         | 
| 1129 | 
            +
                variantIds: PersonalizationEventVariantId[];
         | 
| 1063 1130 | 
             
                /** Whether the user was part of the control group (and did not receive any personalization) */
         | 
| 1064 1131 | 
             
                control: boolean | undefined;
         | 
| 1065 1132 | 
             
                /**
         | 
| @@ -1113,7 +1180,7 @@ interface ContextInstance { | |
| 1113 1180 | 
             
                setTestVariantId(testName: string, variantId: string): void;
         | 
| 1114 1181 | 
             
                log(...message: LogMessage): void;
         | 
| 1115 1182 | 
             
                test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
         | 
| 1116 | 
            -
                personalize<TVariant extends PersonalizedVariant | 
| 1183 | 
            +
                personalize<TVariant extends PersonalizedVariant<any>>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
         | 
| 1117 1184 | 
             
                forget(fromAllDevices: boolean): Promise<void>;
         | 
| 1118 1185 | 
             
                getServerToClientTransitionState(): ServerToClientTransitionState;
         | 
| 1119 1186 | 
             
                readonly manifest: ManifestInstance;
         | 
| @@ -1178,7 +1245,7 @@ declare class Context implements ContextInstance { | |
| 1178 1245 | 
             
                /** Executes an A/B test with a given set of variants, showing the visitor's assigned variant (or selecting one to assign, if none is set yet) */
         | 
| 1179 1246 | 
             
                test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
         | 
| 1180 1247 | 
             
                /** Executes a personalized placement with a given set of variants */
         | 
| 1181 | 
            -
                personalize<TVariant extends PersonalizedVariant | 
| 1248 | 
            +
                personalize<TVariant extends PersonalizedVariant<any>>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
         | 
| 1182 1249 | 
             
                /**
         | 
| 1183 1250 | 
             
                 * Forgets the visitor's data and resets the Context to its initial state.
         | 
| 1184 1251 | 
             
                 * @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
         | 
| @@ -1265,4 +1332,4 @@ declare global { | |
| 1265 1332 | 
             
                }
         | 
| 1266 1333 | 
             
            }
         | 
| 1267 1334 |  | 
| 1268 | 
            -
            export { type  | 
| 1335 | 
            +
            export { type PersonalizationManifest as $, type AggregateDimension as A, type DevToolsDataEvent as B, type ContextPlugin as C, type DecayFunction as D, type DevToolsHelloEvent as E, type DevToolsUpdateEvent as F, type DevToolsRawCommandsEvent as G, type DevToolsForgetEvent as H, type LogMessages as I, type Severity as J, type MessageFunc as K, type LogDrain as L, type MessageCategory as M, type LogMessageSingle as N, type OutputSeverity as O, type PersonalizedVariant as P, type Quirks as Q, type LogMessageGroup as R, type ScoreVector as S, TransitionDataStore as T, ManifestInstance as U, type VisitorData as V, GroupCriteriaEvaluator as W, type CriteriaEvaluatorResult as X, type CriteriaEvaluatorParameters as Y, type SignalData as Z, type ManifestV2 as _, type StorageCommands as a, type Signal as a0, type SignalCriteriaGroup as a1, type SignalCriteria as a2, type EnrichmentCategory as a3, type NumberMatch as a4, type TestDefinition as a5, type AggregateDimensionInput as a6, type TestOptions as a7, testVariations as a8, type VariantMatchMetadata as a9, type PersonalizeControlVariant as aA, type PersonalizeVariants as aB, type EventData as aC, emptyVisitorData as aD, type ContextState as aE, type ContextStateUpdate as aF, type GoalStateUpdate as aG, type paths as aH, type DimensionMatch as aa, type QuirkMatch as ab, type BehaviorTag as ac, type TestVariant as ad, type TestResult as ae, type StorageCommand as af, type SetGoalCommand as ag, type ModifyScoreCommand as ah, type ModifySessionScoreCommand as ai, type SetConsentCommand as aj, type SetQuirkCommand as ak, type SetTestCommand as al, type IdentifyCommand as am, type SetControlGroupCommand as an, type SetPersonalizeVariantControlCommand as ao, areCommandsEqual as ap, type ServerToClientTransitionState as aq, SERVER_STATE_ID as ar, type TransitionDataStoreEvents as as, type DecayOptions as at, type VisitorDataStoreOptions as au, type VisitorDataStoreEvents as av, VisitorDataStore as aw, type Tests as ax, type Goals as ay, type EnrichmentData as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type PersonalizeOptions as g, Context as h, type PersonalizedResult as i, type PersonalizationSelectionAlgorithmOptions as j, type DevToolsEvents as k, CONTEXTUAL_EDITING_TEST_NAME as l, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as m, type PersonalizationSelectionAlgorithm as n, type PersonalizationSelectionAlgorithms as o, type ContextOptions as p, type PersonalizationEventVariantId as q, type PersonalizationEvent as r, type TestEvent as s, type ContextEvents as t, type ContextInstance as u, type DevToolsUiVersion as v, type DevToolsState as w, type DevToolsActions as x, type DevToolsEvent as y, type DevToolsLogEvent as z };
         | 
| @@ -859,6 +859,10 @@ type LogMessages = { | |
| 859 859 | 
             
                }>;
         | 
| 860 860 | 
             
                /** Final result for a personalized variation */
         | 
| 861 861 | 
             
                303: MessageFunc<boolean>;
         | 
| 862 | 
            +
                /** Personalization algorithm not found */
         | 
| 863 | 
            +
                304: MessageFunc<{
         | 
| 864 | 
            +
                    algorithm: string;
         | 
| 865 | 
            +
                }>;
         | 
| 862 866 | 
             
                /** A/B test placement executing */
         | 
| 863 867 | 
             
                400: MessageFunc<string>;
         | 
| 864 868 | 
             
                /** A/B Test definition did not exist */
         | 
| @@ -898,23 +902,29 @@ type LogMessageSingle<TID extends keyof LogMessages = keyof LogMessages> = [ | |
| 898 902 | 
             
            type LogMessageGroup<TID extends keyof LogMessages = keyof LogMessages> = [severity: Severity, id: TID, group: 'GROUP', ...args: Parameters<LogMessages[TID]>] | [severity: Severity, id: TID, group: 'ENDGROUP'];
         | 
| 899 903 | 
             
            type LogDrain = (message: LogMessage) => void;
         | 
| 900 904 |  | 
| 901 | 
            -
             | 
| 905 | 
            +
            /** Data for a personalization variation using the top-down criteria selection algorithm */
         | 
| 906 | 
            +
            interface VariantMatchCriteria extends VariantMatchMetadata {
         | 
| 902 907 | 
             
                /**
         | 
| 903 908 | 
             
                 * Operation for match criteria
         | 
| 904 909 | 
             
                 *
         | 
| 905 910 | 
             
                 * @defaultValue `&`
         | 
| 906 911 | 
             
                 */
         | 
| 907 912 | 
             
                op?: '&' | '|';
         | 
| 908 | 
            -
                crit: DimensionMatch | 
| 909 | 
            -
                /**
         | 
| 910 | 
            -
                 * Name of the variant for analytics tracking.
         | 
| 911 | 
            -
                 */
         | 
| 912 | 
            -
                name?: string;
         | 
| 913 | 
            +
                crit: Array<DimensionMatch | QuirkMatch>;
         | 
| 913 914 | 
             
                /**
         | 
| 914 915 | 
             
                 * Control group percentage for the variant.
         | 
| 915 916 | 
             
                 */
         | 
| 916 917 | 
             
                control?: number;
         | 
| 917 | 
            -
            } | 
| 918 | 
            +
            }
         | 
| 919 | 
            +
            /** Data that must exist on a personalization variation regardless of selection algorithm */
         | 
| 920 | 
            +
            interface VariantMatchMetadata {
         | 
| 921 | 
            +
                /**
         | 
| 922 | 
            +
                 * Name of the variation for analytics tracking.
         | 
| 923 | 
            +
                 * NOTE: name is optional for backwards compatibility, but it is HIGHLY recommended to specify a name
         | 
| 924 | 
            +
                 * as the default fallback is not helpfully named and is reliant on the order of the variations array.
         | 
| 925 | 
            +
                 */
         | 
| 926 | 
            +
                name?: string;
         | 
| 927 | 
            +
            }
         | 
| 918 928 | 
             
            type DimensionMatch = {
         | 
| 919 929 | 
             
                /**
         | 
| 920 930 | 
             
                 * Left hand side of the match expression (name of dimension in score vector)
         | 
| @@ -953,17 +963,48 @@ type DimensionMatch = { | |
| 953 963 | 
             
                 */
         | 
| 954 964 | 
             
                rDim?: string;
         | 
| 955 965 | 
             
            };
         | 
| 966 | 
            +
            type QuirkMatch = {
         | 
| 967 | 
            +
                /**
         | 
| 968 | 
            +
                 * Type of match expression; 'q' discriminates quirk matches from dimension matches
         | 
| 969 | 
            +
                 */
         | 
| 970 | 
            +
                t: 'q';
         | 
| 971 | 
            +
                /**
         | 
| 972 | 
            +
                 * Left hand side of the match expression (name of quirk)
         | 
| 973 | 
            +
                 * NOTE: if the quirk is not present
         | 
| 974 | 
            +
                 */
         | 
| 975 | 
            +
                l: string;
         | 
| 976 | 
            +
                /**
         | 
| 977 | 
            +
                 * Operator of the match expression
         | 
| 978 | 
            +
                 * Comparison operators:
         | 
| 979 | 
            +
                 * =: `l` is equal to the right hand side expression
         | 
| 980 | 
            +
                 * !=: `l` is not equal to the right hand side expression
         | 
| 981 | 
            +
                 */
         | 
| 982 | 
            +
                op: '=' | '!=';
         | 
| 983 | 
            +
                /**
         | 
| 984 | 
            +
                 * Right hand side of the match expression
         | 
| 985 | 
            +
                 * This value is treated as a constant value, if it is present. If it's a string, it is parsed to an integer.
         | 
| 986 | 
            +
                 * To reference another score dimension as the RHS, use the `rDim` property instead.
         | 
| 987 | 
            +
                 * `r` and `rDim` are mutually exclusive; if both are specified, then `rDim` wins.
         | 
| 988 | 
            +
                 */
         | 
| 989 | 
            +
                r: string;
         | 
| 990 | 
            +
                /**
         | 
| 991 | 
            +
                 * Only here to maintain object compatibility with DimensionMatch.
         | 
| 992 | 
            +
                 * Completely ignored.
         | 
| 993 | 
            +
                 * @deprecated this is not used with QuirkMatch.
         | 
| 994 | 
            +
                 */
         | 
| 995 | 
            +
                rDim?: string;
         | 
| 996 | 
            +
            };
         | 
| 956 997 |  | 
| 957 998 | 
             
            /** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
         | 
| 958 999 | 
             
            type BehaviorTag = {
         | 
| 959 1000 | 
             
                beh?: EnrichmentData[];
         | 
| 960 1001 | 
             
            };
         | 
| 961 1002 | 
             
            /** Defines the shape of a personalized content variant */
         | 
| 962 | 
            -
            type PersonalizedVariant = {
         | 
| 1003 | 
            +
            type PersonalizedVariant<TCriteria = VariantMatchCriteria> = {
         | 
| 963 1004 | 
             
                /** A unique identifier for this variation */
         | 
| 964 1005 | 
             
                id: string;
         | 
| 965 1006 | 
             
                /** Match criteria for this variation */
         | 
| 966 | 
            -
                pz?:  | 
| 1007 | 
            +
                pz?: TCriteria;
         | 
| 967 1008 | 
             
            };
         | 
| 968 1009 | 
             
            /** The result of computing personalized content from variations */
         | 
| 969 1010 | 
             
            type PersonalizedResult<TVariant> = {
         | 
| @@ -971,6 +1012,7 @@ type PersonalizedResult<TVariant> = { | |
| 971 1012 | 
             
                personalized: boolean;
         | 
| 972 1013 | 
             
                /** Matching variations */
         | 
| 973 1014 | 
             
                variations: Array<TVariant & {
         | 
| 1015 | 
            +
                    /** Whether the visitor is part of this variation's local control group (also true if part of global control group) */
         | 
| 974 1016 | 
             
                    control: boolean;
         | 
| 975 1017 | 
             
                }>;
         | 
| 976 1018 | 
             
            };
         | 
| @@ -995,19 +1037,28 @@ type TestResult<TVariant> = { | |
| 995 1037 | 
             
                 */
         | 
| 996 1038 | 
             
                variantAssigned: boolean;
         | 
| 997 1039 | 
             
            };
         | 
| 998 | 
            -
             | 
| 999 | 
            -
             | 
| 1040 | 
            +
            interface PersonalizeOptions<TVariant> {
         | 
| 1041 | 
            +
                /** Name of placement (sent to analytics) */
         | 
| 1042 | 
            +
                name: string;
         | 
| 1043 | 
            +
                /** Possible variations to place  */
         | 
| 1044 | 
            +
                variations: Iterable<TVariant>;
         | 
| 1045 | 
            +
                /** Maximum number of variants to place (default: 1) */
         | 
| 1046 | 
            +
                take?: number;
         | 
| 1047 | 
            +
                /** Name of the personalization selection algorithm to use. Defaults to top-down criteria when not specified. */
         | 
| 1048 | 
            +
                algorithm?: string;
         | 
| 1049 | 
            +
            }
         | 
| 1050 | 
            +
            interface PersonalizationSelectionAlgorithmOptions<TCriteria, TVariant extends PersonalizedVariant<TCriteria> = PersonalizedVariant<TCriteria>> {
         | 
| 1000 1051 | 
             
                /** Name of placement (sent to analytics) */
         | 
| 1001 1052 | 
             
                name: string;
         | 
| 1002 | 
            -
                /** Possible  | 
| 1053 | 
            +
                /** Possible variations to place  */
         | 
| 1003 1054 | 
             
                variations: Iterable<TVariant>;
         | 
| 1004 1055 | 
             
                /** Maximum number of variants to place (default: 1) */
         | 
| 1005 1056 | 
             
                take?: number;
         | 
| 1057 | 
            +
                /** Callback for logging messages */
         | 
| 1006 1058 | 
             
                onLogMessage?: (message: LogMessage) => void;
         | 
| 1007 | 
            -
             | 
| 1008 | 
            -
            declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
         | 
| 1059 | 
            +
                /** Context instance */
         | 
| 1009 1060 | 
             
                context: Context;
         | 
| 1010 | 
            -
            } | 
| 1061 | 
            +
            }
         | 
| 1011 1062 |  | 
| 1012 1063 | 
             
            type TestOptions<TVariant extends TestVariant> = {
         | 
| 1013 1064 | 
             
                /** The name of the test that is being run, must be included in the manifest. */
         | 
| @@ -1022,18 +1073,31 @@ declare const testVariations: <TVariant extends TestVariant>({ name, context, va | |
| 1022 1073 |  | 
| 1023 1074 | 
             
            declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
         | 
| 1024 1075 | 
             
            declare const CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_test_selected_variant";
         | 
| 1076 | 
            +
            type PersonalizationSelectionAlgorithm<TCriteria = unknown> = (options: PersonalizationSelectionAlgorithmOptions<TCriteria>) => PersonalizedResult<PersonalizedVariant<TCriteria>>;
         | 
| 1077 | 
            +
            type PersonalizationSelectionAlgorithms<TCriteria = unknown> = Record<string, PersonalizationSelectionAlgorithm<TCriteria>>;
         | 
| 1025 1078 | 
             
            /**
         | 
| 1026 1079 | 
             
             * Defines a plugin for Uniform Context.
         | 
| 1027 1080 | 
             
             * The plugin should attach event handlers in its creation function.
         | 
| 1028 1081 | 
             
             * @returns A function that detaches any event handlers when called
         | 
| 1029 1082 | 
             
             */
         | 
| 1030 1083 | 
             
            type ContextPlugin = {
         | 
| 1084 | 
            +
                /** Defines a log drain for the plugin, which all log messages are sent to */
         | 
| 1031 1085 | 
             
                logDrain?: LogDrain;
         | 
| 1086 | 
            +
                /** Initializes the plugin (attach event handlers here if needed) */
         | 
| 1032 1087 | 
             
                init?: (context: Context) => () => void;
         | 
| 1088 | 
            +
                /** Plugin-specific actions to perform when a user is forgotten */
         | 
| 1033 1089 | 
             
                forget?: () => Promise<void> | void;
         | 
| 1090 | 
            +
                /** Plugin-specific actions to perform when the visitor context is updated */
         | 
| 1034 1091 | 
             
                update?: (newData: Partial<ContextState>) => Promise<void> | void;
         | 
| 1092 | 
            +
                /**
         | 
| 1093 | 
            +
                 * Allows the plugin to register named personalization selection algorithms
         | 
| 1094 | 
            +
                 *
         | 
| 1095 | 
            +
                 * Important: the `default` and `strongestMatch` algorithms are automatically registered.
         | 
| 1096 | 
            +
                 * We strongly advise against replacing these.
         | 
| 1097 | 
            +
                 */
         | 
| 1098 | 
            +
                personalizationSelectionAlgorithms?: PersonalizationSelectionAlgorithms<any>;
         | 
| 1035 1099 | 
             
            };
         | 
| 1036 | 
            -
             | 
| 1100 | 
            +
            interface ContextOptions extends Omit<VisitorDataStoreOptions, 'manifest' | 'onServerTransitionScoresReceived'> {
         | 
| 1037 1101 | 
             
                /** The Context Manifest to load (from the Context API) */
         | 
| 1038 1102 | 
             
                manifest: ManifestV2;
         | 
| 1039 1103 | 
             
                /**
         | 
| @@ -1050,16 +1114,19 @@ type ContextOptions = { | |
| 1050 1114 | 
             
                 * `true`: personalization is not run at all unless storage consent is given
         | 
| 1051 1115 | 
             
                 */
         | 
| 1052 1116 | 
             
                requireConsentForPersonalization?: boolean;
         | 
| 1053 | 
            -
            } | 
| 1117 | 
            +
            }
         | 
| 1118 | 
            +
            type PersonalizationEventVariantId = {
         | 
| 1119 | 
            +
                /** The variant ID that was selected */
         | 
| 1120 | 
            +
                id: string;
         | 
| 1121 | 
            +
                /** Whether the visitor is part of this variant's local control group (also true if part of global control group) */
         | 
| 1122 | 
            +
                control: boolean;
         | 
| 1123 | 
            +
            };
         | 
| 1054 1124 | 
             
            /** Emitted when a personalization runs */
         | 
| 1055 1125 | 
             
            type PersonalizationEvent = {
         | 
| 1056 1126 | 
             
                /** Name of the personalized placement */
         | 
| 1057 1127 | 
             
                name: string;
         | 
| 1058 1128 | 
             
                /** Selected variant ID(s) */
         | 
| 1059 | 
            -
                variantIds:  | 
| 1060 | 
            -
                    id: string;
         | 
| 1061 | 
            -
                    control: boolean;
         | 
| 1062 | 
            -
                }[];
         | 
| 1129 | 
            +
                variantIds: PersonalizationEventVariantId[];
         | 
| 1063 1130 | 
             
                /** Whether the user was part of the control group (and did not receive any personalization) */
         | 
| 1064 1131 | 
             
                control: boolean | undefined;
         | 
| 1065 1132 | 
             
                /**
         | 
| @@ -1113,7 +1180,7 @@ interface ContextInstance { | |
| 1113 1180 | 
             
                setTestVariantId(testName: string, variantId: string): void;
         | 
| 1114 1181 | 
             
                log(...message: LogMessage): void;
         | 
| 1115 1182 | 
             
                test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
         | 
| 1116 | 
            -
                personalize<TVariant extends PersonalizedVariant | 
| 1183 | 
            +
                personalize<TVariant extends PersonalizedVariant<any>>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
         | 
| 1117 1184 | 
             
                forget(fromAllDevices: boolean): Promise<void>;
         | 
| 1118 1185 | 
             
                getServerToClientTransitionState(): ServerToClientTransitionState;
         | 
| 1119 1186 | 
             
                readonly manifest: ManifestInstance;
         | 
| @@ -1178,7 +1245,7 @@ declare class Context implements ContextInstance { | |
| 1178 1245 | 
             
                /** Executes an A/B test with a given set of variants, showing the visitor's assigned variant (or selecting one to assign, if none is set yet) */
         | 
| 1179 1246 | 
             
                test<TVariant extends TestVariant>(options: TestOptions<TVariant>): TestResult<TVariant>;
         | 
| 1180 1247 | 
             
                /** Executes a personalized placement with a given set of variants */
         | 
| 1181 | 
            -
                personalize<TVariant extends PersonalizedVariant | 
| 1248 | 
            +
                personalize<TVariant extends PersonalizedVariant<any>>(options: PersonalizeOptions<TVariant>): PersonalizedResult<TVariant>;
         | 
| 1182 1249 | 
             
                /**
         | 
| 1183 1250 | 
             
                 * Forgets the visitor's data and resets the Context to its initial state.
         | 
| 1184 1251 | 
             
                 * @param fromAllDevices for an identified user, whether to delete all their data (for the entire account) - true, or data for this device (sign out) - false
         | 
| @@ -1265,4 +1332,4 @@ declare global { | |
| 1265 1332 | 
             
                }
         | 
| 1266 1333 | 
             
            }
         | 
| 1267 1334 |  | 
| 1268 | 
            -
            export { type  | 
| 1335 | 
            +
            export { type PersonalizationManifest as $, type AggregateDimension as A, type DevToolsDataEvent as B, type ContextPlugin as C, type DecayFunction as D, type DevToolsHelloEvent as E, type DevToolsUpdateEvent as F, type DevToolsRawCommandsEvent as G, type DevToolsForgetEvent as H, type LogMessages as I, type Severity as J, type MessageFunc as K, type LogDrain as L, type MessageCategory as M, type LogMessageSingle as N, type OutputSeverity as O, type PersonalizedVariant as P, type Quirks as Q, type LogMessageGroup as R, type ScoreVector as S, TransitionDataStore as T, ManifestInstance as U, type VisitorData as V, GroupCriteriaEvaluator as W, type CriteriaEvaluatorResult as X, type CriteriaEvaluatorParameters as Y, type SignalData as Z, type ManifestV2 as _, type StorageCommands as a, type Signal as a0, type SignalCriteriaGroup as a1, type SignalCriteria as a2, type EnrichmentCategory as a3, type NumberMatch as a4, type TestDefinition as a5, type AggregateDimensionInput as a6, type TestOptions as a7, testVariations as a8, type VariantMatchMetadata as a9, type PersonalizeControlVariant as aA, type PersonalizeVariants as aB, type EventData as aC, emptyVisitorData as aD, type ContextState as aE, type ContextStateUpdate as aF, type GoalStateUpdate as aG, type paths as aH, type DimensionMatch as aa, type QuirkMatch as ab, type BehaviorTag as ac, type TestVariant as ad, type TestResult as ae, type StorageCommand as af, type SetGoalCommand as ag, type ModifyScoreCommand as ah, type ModifySessionScoreCommand as ai, type SetConsentCommand as aj, type SetQuirkCommand as ak, type SetTestCommand as al, type IdentifyCommand as am, type SetControlGroupCommand as an, type SetPersonalizeVariantControlCommand as ao, areCommandsEqual as ap, type ServerToClientTransitionState as aq, SERVER_STATE_ID as ar, type TransitionDataStoreEvents as as, type DecayOptions as at, type VisitorDataStoreOptions as au, type VisitorDataStoreEvents as av, VisitorDataStore as aw, type Tests as ax, type Goals as ay, type EnrichmentData as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type PersonalizeOptions as g, Context as h, type PersonalizedResult as i, type PersonalizationSelectionAlgorithmOptions as j, type DevToolsEvents as k, CONTEXTUAL_EDITING_TEST_NAME as l, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as m, type PersonalizationSelectionAlgorithm as n, type PersonalizationSelectionAlgorithms as o, type ContextOptions as p, type PersonalizationEventVariantId as q, type PersonalizationEvent as r, type TestEvent as s, type ContextEvents as t, type ContextInstance as u, type DevToolsUiVersion as v, type DevToolsState as w, type DevToolsActions as x, type DevToolsEvent as y, type DevToolsLogEvent as z };
         | 
    
        package/package.json
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            {
         | 
| 2 2 | 
             
              "name": "@uniformdev/context",
         | 
| 3 | 
            -
              "version": "20. | 
| 3 | 
            +
              "version": "20.4.1-alpha.15+73b27bfcce",
         | 
| 4 4 | 
             
              "description": "Uniform Context core package",
         | 
| 5 5 | 
             
              "license": "SEE LICENSE IN LICENSE.txt",
         | 
| 6 6 | 
             
              "main": "./dist/index.js",
         | 
| @@ -68,5 +68,5 @@ | |
| 68 68 | 
             
              "publishConfig": {
         | 
| 69 69 | 
             
                "access": "public"
         | 
| 70 70 | 
             
              },
         | 
| 71 | 
            -
              "gitHead": " | 
| 71 | 
            +
              "gitHead": "73b27bfcce749c31e7ab50bdc9bb86ac1294903d"
         | 
| 72 72 | 
             
            }
         |