@uniformdev/context 19.135.0 → 19.135.1-alpha.11

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,4 +1,5 @@
1
1
  import * as mitt from 'mitt';
2
+ import { Emitter } from 'mitt';
2
3
 
3
4
  type Quirks = {
4
5
  [key: string]: string;
@@ -9,6 +10,9 @@ type Tests = {
9
10
  type ScoreVector = {
10
11
  [key: string]: number;
11
12
  };
13
+ type Goals = {
14
+ [key: string]: boolean;
15
+ };
12
16
  type EnrichmentData = {
13
17
  /** Enrichment category name */
14
18
  cat: string;
@@ -47,6 +51,10 @@ type VisitorData = {
47
51
  * NOTE: Context.scores is more commonly correct to read scores instead of this value.
48
52
  */
49
53
  scores: ScoreVector;
54
+ /**
55
+ * Goals that this user has triggered.
56
+ */
57
+ goals?: Goals;
50
58
  /**
51
59
  * Whether consent has been given to store the visitor data
52
60
  * If false or not set: visitor data is stored in memory and is lost if the browser refreshes
@@ -84,13 +92,23 @@ type ContextStateUpdate = {
84
92
  visitor: VisitorData;
85
93
  scores: ScoreVector;
86
94
  };
95
+ type GoalStateUpdate = {
96
+ scores: ScoreVector | undefined;
97
+ quirks: Quirks | undefined;
98
+ };
87
99
 
88
100
  type StorageCommand<TID extends string = string, TData = unknown> = {
89
101
  type: TID;
90
102
  data: TData;
91
103
  };
92
104
  /** Commands that can be issued to alter the storage of Uniform Context data */
93
- type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand | SetPersonalizeVariantControlCommand;
105
+ type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand | SetPersonalizeVariantControlCommand | SetGoalCommand;
106
+ /**
107
+ * Converts the goal specified.
108
+ */
109
+ type SetGoalCommand = StorageCommand<'setgoal', {
110
+ goal: string;
111
+ }>;
94
112
  /**
95
113
  * Changes the visitor's permanent score for a given dimension
96
114
  */
@@ -141,6 +159,7 @@ type SetPersonalizeVariantControlCommand = StorageCommand<'setpersonalizecontrol
141
159
  index: number;
142
160
  control: boolean;
143
161
  }>;
162
+ declare const areCommandsEqual: (a: StorageCommands, b: StorageCommands) => boolean;
144
163
 
145
164
  type TransitionDataStoreOptions = {
146
165
  initialData?: Partial<VisitorData>;
@@ -152,6 +171,10 @@ type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'test
152
171
  * recomputation.
153
172
  */
154
173
  ssv?: ScoreVector;
174
+ /**
175
+ * Storage commands that the server
176
+ */
177
+ commands?: StorageCommands[];
155
178
  };
156
179
  declare const SERVER_STATE_ID = "__UNIFORM_DATA__";
157
180
  type TransitionDataStoreEvents = {
@@ -178,7 +201,7 @@ declare abstract class TransitionDataStore {
178
201
  (type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
179
202
  };
180
203
  off: {
181
- <Key_1 extends "dataUpdatedAsync">(type: Key_1, handler?: mitt.Handler<TransitionDataStoreEvents[Key_1]> | undefined): void;
204
+ <Key extends "dataUpdatedAsync">(type: Key, handler?: mitt.Handler<TransitionDataStoreEvents[Key]> | undefined): void;
182
205
  (type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
183
206
  };
184
207
  };
@@ -260,6 +283,11 @@ type VisitorDataStoreOptions = {
260
283
  onServerTransitionReceived?: (state: ServerToClientTransitionState) => void;
261
284
  /** Called when a log message is emitted from the data store */
262
285
  onLogMessage?: (message: LogMessage) => void;
286
+ /**
287
+ * Optionally specify a prefix for all storage keys.
288
+ * Only required if using multiple Context instances on the same domain and need to separate them.
289
+ */
290
+ partitionKey?: string;
263
291
  };
264
292
  type VisitorDataStoreEvents = {
265
293
  /**
@@ -286,6 +314,14 @@ type VisitorDataStoreEvents = {
286
314
  * Fired when visitor control group membership is changed
287
315
  */
288
316
  controlGroupUpdated: Pick<VisitorData, 'controlGroup'>;
317
+ /**
318
+ * Fired when a goal is converted
319
+ */
320
+ goalConverted: {
321
+ goalId: string;
322
+ };
323
+ /** Fired when storage update commands are done executing */
324
+ commandsExecuted: StorageCommands[];
289
325
  };
290
326
  declare class VisitorDataStore {
291
327
  #private;
@@ -303,7 +339,7 @@ declare class VisitorDataStore {
303
339
  (type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
304
340
  };
305
341
  off: {
306
- <Key_1 extends keyof VisitorDataStoreEvents>(type: Key_1, handler?: mitt.Handler<VisitorDataStoreEvents[Key_1]> | undefined): void;
342
+ <Key extends keyof VisitorDataStoreEvents>(type: Key, handler?: mitt.Handler<VisitorDataStoreEvents[Key]> | undefined): void;
307
343
  (type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
308
344
  };
309
345
  };
@@ -328,6 +364,7 @@ declare class ManifestInstance {
328
364
  rollForControlGroup(): boolean;
329
365
  getTest(name: string): TestDefinition | undefined;
330
366
  computeSignals(update: ContextStateUpdate): StorageCommands[];
367
+ computeGoals(data: GoalStateUpdate): StorageCommands[];
331
368
  /**
332
369
  * Computes aggregated scores based on other dimensions
333
370
  */
@@ -491,6 +528,7 @@ interface external {
491
528
  */
492
529
  dur: "s" | "p" | "t";
493
530
  crit: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["RootSignalCriteriaGroup"];
531
+ conversion?: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Conversion"] | null;
494
532
  };
495
533
  RootSignalCriteriaGroup: {
496
534
  /**
@@ -503,7 +541,7 @@ interface external {
503
541
  * & = AND
504
542
  * | = OR
505
543
  *
506
- * Default is `&` if unspecified.
544
+ * Default is `&` if unspecified
507
545
  *
508
546
  * @default &
509
547
  * @enum {string}
@@ -512,6 +550,13 @@ interface external {
512
550
  /** @description The criteria clauses that make up this grouping of criteria */
513
551
  clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
514
552
  };
553
+ Conversion: {
554
+ /**
555
+ * @description The frequency of the conversion event
556
+ * @enum {string}
557
+ */
558
+ freq: "O";
559
+ };
515
560
  SignalCriteriaGroup: {
516
561
  /**
517
562
  * @description Criteria type (Group of other criteria)
@@ -523,7 +568,7 @@ interface external {
523
568
  * & = AND
524
569
  * | = OR
525
570
  *
526
- * Default is `&` if unspecified.
571
+ * Default is `&` if unspecified
527
572
  *
528
573
  * @enum {string}
529
574
  */
@@ -584,7 +629,7 @@ interface external {
584
629
  };
585
630
  /** @description Describes a match expression on a string */
586
631
  StringMatch: {
587
- /** @description The right hand side of the match expression */
632
+ /** @description The right-hand side of the match expression */
588
633
  rhs: string;
589
634
  /**
590
635
  * @description The match operator
@@ -597,7 +642,7 @@ interface external {
597
642
  * @enum {string}
598
643
  */
599
644
  op: "=" | "~" | "//" | "!=" | "!~" | "!//";
600
- /** @description The case sensitivity of the match. Defaults to false if unspecified. */
645
+ /** @description The case sensitivity of the match. Defaults to false if unspecified */
601
646
  cs?: boolean;
602
647
  } | {
603
648
  /**
@@ -611,7 +656,7 @@ interface external {
611
656
  };
612
657
  /** @description Describes a match expression on a number */
613
658
  NumberMatch: {
614
- /** @description The right hand side of the match expression */
659
+ /** @description The right-hand side of the match expression */
615
660
  rhs: number;
616
661
  /**
617
662
  * @description The type of match to perform
@@ -624,7 +669,7 @@ interface external {
624
669
  */
625
670
  op: "=" | "<" | ">" | "!=";
626
671
  };
627
- /** @description Defines an aggregate dimension that is a grouping of other dimensions' scores; an intent or audience. */
672
+ /** @description Defines an aggregate dimension that is a grouping of other dimensions' scores; an intent or audience */
628
673
  AggregateDimension: {
629
674
  /** @description Input dimensions to the aggregate dimension */
630
675
  inputs: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["AggregateDimensionInput"][];
@@ -638,7 +683,7 @@ interface external {
638
683
  *
639
684
  * Note that creating a cycle of aggregate dimensions is allowed, however
640
685
  * the final score will _ignore_ the cycled aggregate dimension in the result.
641
- * This can be used to create mutually exclusive aggregates.
686
+ * This can be used to create mutually exclusive aggregates
642
687
  */
643
688
  dim: string;
644
689
  /**
@@ -646,7 +691,7 @@ interface external {
646
691
  *
647
692
  * '+' = add to the final score
648
693
  * '-' = subtract from the final score
649
- * 'c' = clear the final score (if the input dimension has any score at all, this aggreate will have no score regardless of other inputs)
694
+ * 'c' = clear the final score (if the input dimension has any score at all, this aggregate will have no score regardless of other inputs)
650
695
  *
651
696
  * Default if unspecified: '+'
652
697
  *
@@ -949,7 +994,7 @@ type TestOptions<TVariant extends TestVariant> = {
949
994
  };
950
995
  declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
951
996
  context: Context;
952
- onLogMessage?: ((message: LogMessage) => void) | undefined;
997
+ onLogMessage?: (message: LogMessage) => void;
953
998
  }) => TestResult<TVariant>;
954
999
 
955
1000
  declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
@@ -962,6 +1007,8 @@ declare const CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_
962
1007
  type ContextPlugin = {
963
1008
  logDrain?: LogDrain;
964
1009
  init?: (context: Context) => () => void;
1010
+ forget?: () => Promise<void> | void;
1011
+ update?: (newData: Partial<ContextState>) => Promise<void> | void;
965
1012
  };
966
1013
  type ContextOptions = {
967
1014
  /** The Context Manifest to load (from the Context API) */
@@ -1041,6 +1088,10 @@ interface ContextInstance {
1041
1088
  forget(fromAllDevices: boolean): Promise<void>;
1042
1089
  getServerToClientTransitionState(): ServerToClientTransitionState;
1043
1090
  readonly manifest: ManifestInstance;
1091
+ events: {
1092
+ on: Emitter<ContextEvents>['on'];
1093
+ off: Emitter<ContextEvents>['off'];
1094
+ };
1044
1095
  /** @deprecated */
1045
1096
  internal_processTestEvent(event: TestEvent): void;
1046
1097
  /** @deprecated */
@@ -1063,7 +1114,7 @@ declare class Context implements ContextInstance {
1063
1114
  (type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
1064
1115
  };
1065
1116
  off: {
1066
- <Key_1 extends keyof ContextEvents>(type: Key_1, handler?: mitt.Handler<ContextEvents[Key_1]> | undefined): void;
1117
+ <Key extends keyof ContextEvents>(type: Key, handler?: mitt.Handler<ContextEvents[Key]> | undefined): void;
1067
1118
  (type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
1068
1119
  };
1069
1120
  };
@@ -1078,6 +1129,10 @@ declare class Context implements ContextInstance {
1078
1129
  * will NOT result in a recomputation of signal state.
1079
1130
  */
1080
1131
  update(newData: Partial<ContextState>): Promise<void>;
1132
+ processServerCommands({ serverCommands, commands, }: {
1133
+ serverCommands: StorageCommands[] | undefined;
1134
+ commands: StorageCommands[];
1135
+ }): Promise<void>;
1081
1136
  /** use test() instead */
1082
1137
  getTestVariantId(testName: string): string | null | undefined;
1083
1138
  /** use test() instead */
@@ -1170,7 +1225,12 @@ declare global {
1170
1225
  interface Window {
1171
1226
  /** Window var set by enableContextDevTools() to enable embedded devtools to receive Context instance and attach events to it. */
1172
1227
  __UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__?: Context;
1228
+ /**
1229
+ * Window var set automatically that Uniform's contextual editing uses to respond to changes in the Context within its preview pane,
1230
+ * for example quirks being set from within the preview.
1231
+ */
1232
+ __UNIFORM_CONTEXTUAL_EDITING_CONTEXT__?: Context;
1173
1233
  }
1174
1234
  }
1175
1235
 
1176
- export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ModifyScoreCommand as aa, type ModifySessionScoreCommand as ab, type SetConsentCommand as ac, type SetQuirkCommand as ad, type SetTestCommand as ae, type IdentifyCommand as af, type SetControlGroupCommand as ag, type SetPersonalizeVariantControlCommand as ah, type ServerToClientTransitionState as ai, SERVER_STATE_ID as aj, type TransitionDataStoreEvents as ak, type DecayOptions as al, type VisitorDataStoreOptions as am, type VisitorDataStoreEvents as an, VisitorDataStore as ao, type Quirks as ap, type Tests as aq, type EnrichmentData as ar, type PersonalizeControlVariant as as, type PersonalizeVariants as at, type EventData as au, emptyVisitorData as av, type ContextState as aw, type ContextStateUpdate as ax, type paths as ay, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
1236
+ export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type SetGoalCommand as aa, type ModifyScoreCommand as ab, type ModifySessionScoreCommand as ac, type SetConsentCommand as ad, type SetQuirkCommand as ae, type SetTestCommand as af, type IdentifyCommand as ag, type SetControlGroupCommand as ah, type SetPersonalizeVariantControlCommand as ai, areCommandsEqual as aj, type ServerToClientTransitionState as ak, SERVER_STATE_ID as al, type TransitionDataStoreEvents as am, type DecayOptions as an, type VisitorDataStoreOptions as ao, type VisitorDataStoreEvents as ap, VisitorDataStore as aq, type Quirks as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
@@ -1,4 +1,5 @@
1
1
  import * as mitt from 'mitt';
2
+ import { Emitter } from 'mitt';
2
3
 
3
4
  type Quirks = {
4
5
  [key: string]: string;
@@ -9,6 +10,9 @@ type Tests = {
9
10
  type ScoreVector = {
10
11
  [key: string]: number;
11
12
  };
13
+ type Goals = {
14
+ [key: string]: boolean;
15
+ };
12
16
  type EnrichmentData = {
13
17
  /** Enrichment category name */
14
18
  cat: string;
@@ -47,6 +51,10 @@ type VisitorData = {
47
51
  * NOTE: Context.scores is more commonly correct to read scores instead of this value.
48
52
  */
49
53
  scores: ScoreVector;
54
+ /**
55
+ * Goals that this user has triggered.
56
+ */
57
+ goals?: Goals;
50
58
  /**
51
59
  * Whether consent has been given to store the visitor data
52
60
  * If false or not set: visitor data is stored in memory and is lost if the browser refreshes
@@ -84,13 +92,23 @@ type ContextStateUpdate = {
84
92
  visitor: VisitorData;
85
93
  scores: ScoreVector;
86
94
  };
95
+ type GoalStateUpdate = {
96
+ scores: ScoreVector | undefined;
97
+ quirks: Quirks | undefined;
98
+ };
87
99
 
88
100
  type StorageCommand<TID extends string = string, TData = unknown> = {
89
101
  type: TID;
90
102
  data: TData;
91
103
  };
92
104
  /** Commands that can be issued to alter the storage of Uniform Context data */
93
- type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand | SetPersonalizeVariantControlCommand;
105
+ type StorageCommands = ModifyScoreCommand | ModifySessionScoreCommand | SetConsentCommand | SetQuirkCommand | SetTestCommand | IdentifyCommand | SetControlGroupCommand | SetPersonalizeVariantControlCommand | SetGoalCommand;
106
+ /**
107
+ * Converts the goal specified.
108
+ */
109
+ type SetGoalCommand = StorageCommand<'setgoal', {
110
+ goal: string;
111
+ }>;
94
112
  /**
95
113
  * Changes the visitor's permanent score for a given dimension
96
114
  */
@@ -141,6 +159,7 @@ type SetPersonalizeVariantControlCommand = StorageCommand<'setpersonalizecontrol
141
159
  index: number;
142
160
  control: boolean;
143
161
  }>;
162
+ declare const areCommandsEqual: (a: StorageCommands, b: StorageCommands) => boolean;
144
163
 
145
164
  type TransitionDataStoreOptions = {
146
165
  initialData?: Partial<VisitorData>;
@@ -152,6 +171,10 @@ type ServerToClientTransitionState = Pick<Partial<VisitorData>, 'quirks' | 'test
152
171
  * recomputation.
153
172
  */
154
173
  ssv?: ScoreVector;
174
+ /**
175
+ * Storage commands that the server
176
+ */
177
+ commands?: StorageCommands[];
155
178
  };
156
179
  declare const SERVER_STATE_ID = "__UNIFORM_DATA__";
157
180
  type TransitionDataStoreEvents = {
@@ -178,7 +201,7 @@ declare abstract class TransitionDataStore {
178
201
  (type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
179
202
  };
180
203
  off: {
181
- <Key_1 extends "dataUpdatedAsync">(type: Key_1, handler?: mitt.Handler<TransitionDataStoreEvents[Key_1]> | undefined): void;
204
+ <Key extends "dataUpdatedAsync">(type: Key, handler?: mitt.Handler<TransitionDataStoreEvents[Key]> | undefined): void;
182
205
  (type: "*", handler: mitt.WildcardHandler<TransitionDataStoreEvents>): void;
183
206
  };
184
207
  };
@@ -260,6 +283,11 @@ type VisitorDataStoreOptions = {
260
283
  onServerTransitionReceived?: (state: ServerToClientTransitionState) => void;
261
284
  /** Called when a log message is emitted from the data store */
262
285
  onLogMessage?: (message: LogMessage) => void;
286
+ /**
287
+ * Optionally specify a prefix for all storage keys.
288
+ * Only required if using multiple Context instances on the same domain and need to separate them.
289
+ */
290
+ partitionKey?: string;
263
291
  };
264
292
  type VisitorDataStoreEvents = {
265
293
  /**
@@ -286,6 +314,14 @@ type VisitorDataStoreEvents = {
286
314
  * Fired when visitor control group membership is changed
287
315
  */
288
316
  controlGroupUpdated: Pick<VisitorData, 'controlGroup'>;
317
+ /**
318
+ * Fired when a goal is converted
319
+ */
320
+ goalConverted: {
321
+ goalId: string;
322
+ };
323
+ /** Fired when storage update commands are done executing */
324
+ commandsExecuted: StorageCommands[];
289
325
  };
290
326
  declare class VisitorDataStore {
291
327
  #private;
@@ -303,7 +339,7 @@ declare class VisitorDataStore {
303
339
  (type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
304
340
  };
305
341
  off: {
306
- <Key_1 extends keyof VisitorDataStoreEvents>(type: Key_1, handler?: mitt.Handler<VisitorDataStoreEvents[Key_1]> | undefined): void;
342
+ <Key extends keyof VisitorDataStoreEvents>(type: Key, handler?: mitt.Handler<VisitorDataStoreEvents[Key]> | undefined): void;
307
343
  (type: "*", handler: mitt.WildcardHandler<VisitorDataStoreEvents>): void;
308
344
  };
309
345
  };
@@ -328,6 +364,7 @@ declare class ManifestInstance {
328
364
  rollForControlGroup(): boolean;
329
365
  getTest(name: string): TestDefinition | undefined;
330
366
  computeSignals(update: ContextStateUpdate): StorageCommands[];
367
+ computeGoals(data: GoalStateUpdate): StorageCommands[];
331
368
  /**
332
369
  * Computes aggregated scores based on other dimensions
333
370
  */
@@ -491,6 +528,7 @@ interface external {
491
528
  */
492
529
  dur: "s" | "p" | "t";
493
530
  crit: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["RootSignalCriteriaGroup"];
531
+ conversion?: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Conversion"] | null;
494
532
  };
495
533
  RootSignalCriteriaGroup: {
496
534
  /**
@@ -503,7 +541,7 @@ interface external {
503
541
  * & = AND
504
542
  * | = OR
505
543
  *
506
- * Default is `&` if unspecified.
544
+ * Default is `&` if unspecified
507
545
  *
508
546
  * @default &
509
547
  * @enum {string}
@@ -512,6 +550,13 @@ interface external {
512
550
  /** @description The criteria clauses that make up this grouping of criteria */
513
551
  clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
514
552
  };
553
+ Conversion: {
554
+ /**
555
+ * @description The frequency of the conversion event
556
+ * @enum {string}
557
+ */
558
+ freq: "O";
559
+ };
515
560
  SignalCriteriaGroup: {
516
561
  /**
517
562
  * @description Criteria type (Group of other criteria)
@@ -523,7 +568,7 @@ interface external {
523
568
  * & = AND
524
569
  * | = OR
525
570
  *
526
- * Default is `&` if unspecified.
571
+ * Default is `&` if unspecified
527
572
  *
528
573
  * @enum {string}
529
574
  */
@@ -584,7 +629,7 @@ interface external {
584
629
  };
585
630
  /** @description Describes a match expression on a string */
586
631
  StringMatch: {
587
- /** @description The right hand side of the match expression */
632
+ /** @description The right-hand side of the match expression */
588
633
  rhs: string;
589
634
  /**
590
635
  * @description The match operator
@@ -597,7 +642,7 @@ interface external {
597
642
  * @enum {string}
598
643
  */
599
644
  op: "=" | "~" | "//" | "!=" | "!~" | "!//";
600
- /** @description The case sensitivity of the match. Defaults to false if unspecified. */
645
+ /** @description The case sensitivity of the match. Defaults to false if unspecified */
601
646
  cs?: boolean;
602
647
  } | {
603
648
  /**
@@ -611,7 +656,7 @@ interface external {
611
656
  };
612
657
  /** @description Describes a match expression on a number */
613
658
  NumberMatch: {
614
- /** @description The right hand side of the match expression */
659
+ /** @description The right-hand side of the match expression */
615
660
  rhs: number;
616
661
  /**
617
662
  * @description The type of match to perform
@@ -624,7 +669,7 @@ interface external {
624
669
  */
625
670
  op: "=" | "<" | ">" | "!=";
626
671
  };
627
- /** @description Defines an aggregate dimension that is a grouping of other dimensions' scores; an intent or audience. */
672
+ /** @description Defines an aggregate dimension that is a grouping of other dimensions' scores; an intent or audience */
628
673
  AggregateDimension: {
629
674
  /** @description Input dimensions to the aggregate dimension */
630
675
  inputs: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["AggregateDimensionInput"][];
@@ -638,7 +683,7 @@ interface external {
638
683
  *
639
684
  * Note that creating a cycle of aggregate dimensions is allowed, however
640
685
  * the final score will _ignore_ the cycled aggregate dimension in the result.
641
- * This can be used to create mutually exclusive aggregates.
686
+ * This can be used to create mutually exclusive aggregates
642
687
  */
643
688
  dim: string;
644
689
  /**
@@ -646,7 +691,7 @@ interface external {
646
691
  *
647
692
  * '+' = add to the final score
648
693
  * '-' = subtract from the final score
649
- * 'c' = clear the final score (if the input dimension has any score at all, this aggreate will have no score regardless of other inputs)
694
+ * 'c' = clear the final score (if the input dimension has any score at all, this aggregate will have no score regardless of other inputs)
650
695
  *
651
696
  * Default if unspecified: '+'
652
697
  *
@@ -949,7 +994,7 @@ type TestOptions<TVariant extends TestVariant> = {
949
994
  };
950
995
  declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
951
996
  context: Context;
952
- onLogMessage?: ((message: LogMessage) => void) | undefined;
997
+ onLogMessage?: (message: LogMessage) => void;
953
998
  }) => TestResult<TVariant>;
954
999
 
955
1000
  declare const CONTEXTUAL_EDITING_TEST_NAME = "contextual_editing_test";
@@ -962,6 +1007,8 @@ declare const CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID = "contextual_editing_
962
1007
  type ContextPlugin = {
963
1008
  logDrain?: LogDrain;
964
1009
  init?: (context: Context) => () => void;
1010
+ forget?: () => Promise<void> | void;
1011
+ update?: (newData: Partial<ContextState>) => Promise<void> | void;
965
1012
  };
966
1013
  type ContextOptions = {
967
1014
  /** The Context Manifest to load (from the Context API) */
@@ -1041,6 +1088,10 @@ interface ContextInstance {
1041
1088
  forget(fromAllDevices: boolean): Promise<void>;
1042
1089
  getServerToClientTransitionState(): ServerToClientTransitionState;
1043
1090
  readonly manifest: ManifestInstance;
1091
+ events: {
1092
+ on: Emitter<ContextEvents>['on'];
1093
+ off: Emitter<ContextEvents>['off'];
1094
+ };
1044
1095
  /** @deprecated */
1045
1096
  internal_processTestEvent(event: TestEvent): void;
1046
1097
  /** @deprecated */
@@ -1063,7 +1114,7 @@ declare class Context implements ContextInstance {
1063
1114
  (type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
1064
1115
  };
1065
1116
  off: {
1066
- <Key_1 extends keyof ContextEvents>(type: Key_1, handler?: mitt.Handler<ContextEvents[Key_1]> | undefined): void;
1117
+ <Key extends keyof ContextEvents>(type: Key, handler?: mitt.Handler<ContextEvents[Key]> | undefined): void;
1067
1118
  (type: "*", handler: mitt.WildcardHandler<ContextEvents>): void;
1068
1119
  };
1069
1120
  };
@@ -1078,6 +1129,10 @@ declare class Context implements ContextInstance {
1078
1129
  * will NOT result in a recomputation of signal state.
1079
1130
  */
1080
1131
  update(newData: Partial<ContextState>): Promise<void>;
1132
+ processServerCommands({ serverCommands, commands, }: {
1133
+ serverCommands: StorageCommands[] | undefined;
1134
+ commands: StorageCommands[];
1135
+ }): Promise<void>;
1081
1136
  /** use test() instead */
1082
1137
  getTestVariantId(testName: string): string | null | undefined;
1083
1138
  /** use test() instead */
@@ -1170,7 +1225,12 @@ declare global {
1170
1225
  interface Window {
1171
1226
  /** Window var set by enableContextDevTools() to enable embedded devtools to receive Context instance and attach events to it. */
1172
1227
  __UNIFORM_DEVTOOLS_CONTEXT_INSTANCE__?: Context;
1228
+ /**
1229
+ * Window var set automatically that Uniform's contextual editing uses to respond to changes in the Context within its preview pane,
1230
+ * for example quirks being set from within the preview.
1231
+ */
1232
+ __UNIFORM_CONTEXTUAL_EDITING_CONTEXT__?: Context;
1173
1233
  }
1174
1234
  }
1175
1235
 
1176
- export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ModifyScoreCommand as aa, type ModifySessionScoreCommand as ab, type SetConsentCommand as ac, type SetQuirkCommand as ad, type SetTestCommand as ae, type IdentifyCommand as af, type SetControlGroupCommand as ag, type SetPersonalizeVariantControlCommand as ah, type ServerToClientTransitionState as ai, SERVER_STATE_ID as aj, type TransitionDataStoreEvents as ak, type DecayOptions as al, type VisitorDataStoreOptions as am, type VisitorDataStoreEvents as an, VisitorDataStore as ao, type Quirks as ap, type Tests as aq, type EnrichmentData as ar, type PersonalizeControlVariant as as, type PersonalizeVariants as at, type EventData as au, emptyVisitorData as av, type ContextState as aw, type ContextStateUpdate as ax, type paths as ay, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
1236
+ export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type ContextStateUpdate as aA, type GoalStateUpdate as aB, type paths as aC, type SetGoalCommand as aa, type ModifyScoreCommand as ab, type ModifySessionScoreCommand as ac, type SetConsentCommand as ad, type SetQuirkCommand as ae, type SetTestCommand as af, type IdentifyCommand as ag, type SetControlGroupCommand as ah, type SetPersonalizeVariantControlCommand as ai, areCommandsEqual as aj, type ServerToClientTransitionState as ak, SERVER_STATE_ID as al, type TransitionDataStoreEvents as am, type DecayOptions as an, type VisitorDataStoreOptions as ao, type VisitorDataStoreEvents as ap, VisitorDataStore as aq, type Quirks as ar, type Tests as as, type Goals as at, type EnrichmentData as au, type PersonalizeControlVariant as av, type PersonalizeVariants as aw, type EventData as ax, emptyVisitorData as ay, type ContextState as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/context",
3
- "version": "19.135.0",
3
+ "version": "19.135.1-alpha.11+9f52e6cfd6",
4
4
  "description": "Uniform Context core package",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./dist/index.js",
@@ -51,14 +51,16 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/js-cookie": "3.0.6",
54
+ "@types/uuid": "9.0.4",
54
55
  "benny": "3.7.1"
55
56
  },
56
57
  "dependencies": {
57
58
  "dequal": "^2.0.2",
58
59
  "js-cookie": "3.0.5",
59
- "mitt": "^3.0.0",
60
+ "mitt": "^3.0.1",
60
61
  "p-limit": "^3.1.0",
61
- "rfdc": "^1.3.0"
62
+ "rfdc": "^1.3.0",
63
+ "uuid": "9.0.1"
62
64
  },
63
65
  "files": [
64
66
  "/dist"
@@ -66,5 +68,5 @@
66
68
  "publishConfig": {
67
69
  "access": "public"
68
70
  },
69
- "gitHead": "741cd50843c92d550dbff2daffb3a6106a7a3f94"
71
+ "gitHead": "9f52e6cfd6e562e9c759735ba2a44378388a2a82"
70
72
  }