@uniformdev/context 14.2.1-alpha.128 → 14.2.1-alpha.181
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.ts +4 -4
- package/dist/chunk-A5FZYSIL.mjs +76 -0
- package/dist/chunk-FJWWKKCL.mjs +307 -0
- package/dist/chunk-YGARAHYJ.mjs +11 -0
- package/dist/cli/cli.d.ts +2 -2
- package/dist/{contextTypes-7f24fc7c.d.ts → contextTypes-572b0d33.d.ts} +1 -1
- package/dist/index.d.ts +48 -22
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/types-5f88cc63.d.ts +772 -0
- package/dist/{types-d77228a6.d.ts → types-ef0eef65.d.ts} +137 -64
- package/dist/{v2-manifest.swagger-d0899723.d.ts → v2-manifest.swagger-ff2af13e.d.ts} +9 -0
- package/package.json +5 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
import { c as components, e as external } from './v2-manifest.swagger-
|
1
|
+
import { c as components, e as external } from './v2-manifest.swagger-ff2af13e';
|
2
2
|
import * as mitt from 'mitt';
|
3
3
|
|
4
4
|
declare type StorageCommand<TID extends string = string, TData = unknown> = {
|
@@ -192,25 +192,65 @@ declare abstract class TransitionDataStore {
|
|
192
192
|
getClientTransitionState(): ServerToClientTransitionState | undefined;
|
193
193
|
}
|
194
194
|
|
195
|
-
declare type
|
196
|
-
|
197
|
-
|
198
|
-
|
195
|
+
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
196
|
+
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
197
|
+
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
198
|
+
declare type Signal = SharedTypes['Signal'];
|
199
|
+
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
|
200
|
+
declare type SignalCriteria = SharedTypes['SignalCriteria'];
|
201
|
+
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
|
202
|
+
declare type StringMatch = SharedTypes['StringMatch'];
|
203
|
+
declare type NumberMatch = SharedTypes['NumberMatch'];
|
204
|
+
declare type TestDefinition = SharedTypes['Test'];
|
205
|
+
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
206
|
+
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
207
|
+
|
208
|
+
/**
|
209
|
+
* The result of evaluating a signal criteria.
|
210
|
+
*/
|
211
|
+
declare type CriteriaEvaluatorResult = {
|
212
|
+
/** Whether the criteria evaluated to true or not */
|
213
|
+
result: boolean;
|
214
|
+
/**
|
215
|
+
* Whether the value of the criteria changed from the previous state
|
216
|
+
* If ALL criteria on a signal have NOT changed, the signal is skipped
|
217
|
+
* and its score is left alone.
|
218
|
+
*/
|
219
|
+
changed: boolean;
|
199
220
|
};
|
200
|
-
declare type
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
221
|
+
declare type CriteriaEvaluatorParameters = {
|
222
|
+
/** The update being made to the Context state */
|
223
|
+
update: ContextStateUpdate;
|
224
|
+
/** Current criteria to evaluate the update against */
|
225
|
+
criteria: SignalCriteria;
|
226
|
+
/**
|
227
|
+
* The storage commands that will be executed by this update.
|
228
|
+
* If the evaluation requires custom commands, push them into this parameter.
|
229
|
+
* NOTE: needing to use this is very rare and should be avoided if possible.
|
230
|
+
*/
|
231
|
+
commands: StorageCommands[];
|
232
|
+
/** The parent signal containing the criteria we are evaluating */
|
233
|
+
signal: SignalData;
|
234
|
+
/** Function to emit log notices to the Context log */
|
235
|
+
onLogMessage?: (message: LogMessage) => void;
|
236
|
+
};
|
237
|
+
declare type SignalData = Signal & {
|
238
|
+
id: string;
|
205
239
|
};
|
206
240
|
/**
|
207
|
-
*
|
208
|
-
*
|
209
|
-
* if it needs to apply score decay. The data store ensures immutability already.
|
210
|
-
*
|
211
|
-
* @returns true if any decay was applied, false otherwise
|
241
|
+
* A type that evaluates a signal criteria type and
|
242
|
+
* decides if it matches the current Context state or not.
|
212
243
|
*/
|
213
|
-
declare type
|
244
|
+
declare type CriteriaEvaluator = ((parameters: CriteriaEvaluatorParameters) => CriteriaEvaluatorResult) & {
|
245
|
+
/** If true the criteria will always execute even if a short-circuit would normally skip it */
|
246
|
+
alwaysExecute?: boolean;
|
247
|
+
};
|
248
|
+
|
249
|
+
declare class GroupCriteriaEvaluator {
|
250
|
+
#private;
|
251
|
+
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
252
|
+
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: SignalData, onLogMessage?: (message: LogMessage) => void): CriteriaEvaluatorResult;
|
253
|
+
}
|
214
254
|
|
215
255
|
/** Defines all error codes and their parameter(s) */
|
216
256
|
declare type LogMessages = {
|
@@ -232,6 +272,8 @@ declare type LogMessages = {
|
|
232
272
|
102: MessageFunc<VisitorData>;
|
233
273
|
/** Storage data was deleted bool: fromAllDevices */
|
234
274
|
103: MessageFunc<boolean>;
|
275
|
+
/** Visitor was assigned or removed from control group */
|
276
|
+
104: MessageFunc<boolean>;
|
235
277
|
/** Storage score was truncated to its cap */
|
236
278
|
110: MessageFunc<{
|
237
279
|
dim: string;
|
@@ -244,13 +286,51 @@ declare type LogMessages = {
|
|
244
286
|
130: MessageFunc<ScoreVector>;
|
245
287
|
/** Server to client transition data was discarded */
|
246
288
|
131: MessageFunc;
|
247
|
-
/**
|
289
|
+
/** Decay function executed */
|
290
|
+
140: MessageFunc<string>;
|
291
|
+
/** Signals evaluation beginning */
|
292
|
+
200: MessageFunc;
|
293
|
+
/** Evaluation of a specific signal beginning */
|
294
|
+
201: MessageFunc<SignalData>;
|
295
|
+
/** Evaluation of a group beginning */
|
296
|
+
202: MessageFunc<SignalCriteriaGroup>;
|
297
|
+
203: MessageFunc<{
|
298
|
+
criteria: SignalCriteria;
|
299
|
+
result: CriteriaEvaluatorResult;
|
300
|
+
explanation: string;
|
301
|
+
}>;
|
302
|
+
/** Result of evaluating a criteria group */
|
303
|
+
204: MessageFunc<CriteriaEvaluatorResult>;
|
304
|
+
/** Personalization placement executing */
|
305
|
+
300: MessageFunc<{
|
306
|
+
name: string;
|
307
|
+
take?: number;
|
308
|
+
}>;
|
309
|
+
/** Personalization placement testing variation */
|
310
|
+
301: MessageFunc<{
|
311
|
+
id: string;
|
312
|
+
op?: string;
|
313
|
+
}>;
|
314
|
+
/** Processed a personalization criteria */
|
315
|
+
302: MessageFunc<{
|
316
|
+
matched: boolean;
|
317
|
+
description: string;
|
318
|
+
}>;
|
319
|
+
/** Final result for a personalized variation */
|
320
|
+
303: MessageFunc<boolean>;
|
321
|
+
/** A/B test placement executing */
|
322
|
+
400: MessageFunc<string>;
|
323
|
+
/** A/B Test definition did not exist */
|
248
324
|
401: MessageFunc<string>;
|
249
325
|
/** Previously shown test variant no longer in variant data */
|
250
326
|
402: MessageFunc<{
|
251
|
-
|
252
|
-
|
327
|
+
missingVariant: string;
|
328
|
+
variants: string[];
|
253
329
|
}>;
|
330
|
+
/** Selected a new A/B test variation */
|
331
|
+
403: MessageFunc<string>;
|
332
|
+
/** Displaying A/B test variation */
|
333
|
+
404: MessageFunc<string>;
|
254
334
|
/** gtag was not present on the page to emit events to */
|
255
335
|
700: MessageFunc;
|
256
336
|
/** Enabled gtag event signal redirection */
|
@@ -258,15 +338,41 @@ declare type LogMessages = {
|
|
258
338
|
};
|
259
339
|
|
260
340
|
declare type Severity = 'debug' | 'info' | 'warn' | 'error';
|
341
|
+
declare type MessageCategory = 'context' | 'storage' | 'testing' | 'personalization' | 'gtag' | 'signals';
|
261
342
|
declare type OutputSeverity = Severity | 'none';
|
262
|
-
declare type MessageFunc<TArg = void> = (arg: TArg) => [
|
263
|
-
|
343
|
+
declare type MessageFunc<TArg = void> = (arg: TArg) => [
|
344
|
+
/** Category of the message */
|
345
|
+
MessageCategory,
|
346
|
+
/** Log message text */
|
347
|
+
string,
|
348
|
+
/** Log message */
|
349
|
+
...unknown[]
|
350
|
+
];
|
351
|
+
declare type LogMessage = LogMessageSingle | LogMessageGroup;
|
352
|
+
declare type LogMessageSingle<TID extends keyof LogMessages = keyof LogMessages> = [
|
264
353
|
severity: Severity,
|
265
354
|
id: TID,
|
266
355
|
...args: Parameters<LogMessages[TID]>
|
267
356
|
];
|
357
|
+
declare type LogMessageGroup<TID extends keyof LogMessages = keyof LogMessages> = [severity: Severity, id: TID, group: 'GROUP', ...args: Parameters<LogMessages[TID]>] | [severity: Severity, id: TID, group: 'ENDGROUP'];
|
268
358
|
declare type LogDrain = (message: LogMessage) => void;
|
269
359
|
|
360
|
+
declare type DecayOptions = {
|
361
|
+
now: number;
|
362
|
+
lastUpd: number | undefined;
|
363
|
+
scores: ScoreVector;
|
364
|
+
sessionScores: ScoreVector;
|
365
|
+
onLogMessage?: (message: LogMessage) => void;
|
366
|
+
};
|
367
|
+
/**
|
368
|
+
* Computes decay of visitor scores over time.
|
369
|
+
* NOTE: it is expected that this function mutates the incoming score vectors,
|
370
|
+
* if it needs to apply score decay. The data store ensures immutability already.
|
371
|
+
*
|
372
|
+
* @returns true if any decay was applied, false otherwise
|
373
|
+
*/
|
374
|
+
declare type DecayFunction = (options: DecayOptions) => boolean;
|
375
|
+
|
270
376
|
declare type VisitorDataStoreOptions = {
|
271
377
|
/** Transition storage used to transfer server or edge side execution state to the client. Unused for client side only. */
|
272
378
|
transitionStore?: TransitionDataStore;
|
@@ -352,9 +458,10 @@ declare class VisitorDataStore {
|
|
352
458
|
declare class ManifestInstance {
|
353
459
|
#private;
|
354
460
|
readonly data: ManifestV2;
|
355
|
-
constructor({ manifest, evaluator, }: {
|
461
|
+
constructor({ manifest, evaluator, onLogMessage, }: {
|
356
462
|
manifest: ManifestV2;
|
357
463
|
evaluator?: GroupCriteriaEvaluator;
|
464
|
+
onLogMessage?: (message: LogMessage) => void;
|
358
465
|
});
|
359
466
|
rollForControlGroup(): boolean;
|
360
467
|
getTest(name: string): TestDefinition | undefined;
|
@@ -366,44 +473,6 @@ declare class ManifestInstance {
|
|
366
473
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
367
474
|
}
|
368
475
|
|
369
|
-
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
370
|
-
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
371
|
-
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
372
|
-
declare type Signal = SharedTypes['Signal'];
|
373
|
-
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
|
374
|
-
declare type SignalCriteria = SharedTypes['SignalCriteria'];
|
375
|
-
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
|
376
|
-
declare type StringMatch = SharedTypes['StringMatch'];
|
377
|
-
declare type NumberMatch = SharedTypes['NumberMatch'];
|
378
|
-
declare type TestDefinition = SharedTypes['Test'];
|
379
|
-
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
380
|
-
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
381
|
-
|
382
|
-
/**
|
383
|
-
* The result of evaluating a signal criteria.
|
384
|
-
*/
|
385
|
-
declare type CriteriaEvaluatorResult = {
|
386
|
-
/** Whether the criteria evaluated to true or not */
|
387
|
-
result: boolean;
|
388
|
-
/**
|
389
|
-
* Whether the value of the criteria changed from the previous state
|
390
|
-
* If ALL criteria on a signal have NOT changed, the signal is skipped
|
391
|
-
* and its score is left alone.
|
392
|
-
*/
|
393
|
-
changed: boolean;
|
394
|
-
};
|
395
|
-
/**
|
396
|
-
* A type that evaluates a signal criteria type and
|
397
|
-
* decides if it matches the current Context state or not.
|
398
|
-
*/
|
399
|
-
declare type CriteriaEvaluator = (update: ContextStateUpdate, criteria: SignalCriteria, commands: StorageCommands[], signal: Signal, dimension: string) => CriteriaEvaluatorResult;
|
400
|
-
|
401
|
-
declare class GroupCriteriaEvaluator {
|
402
|
-
#private;
|
403
|
-
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
404
|
-
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: Signal, dimension: string): CriteriaEvaluatorResult;
|
405
|
-
}
|
406
|
-
|
407
476
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
408
477
|
declare type BehaviorTag = {
|
409
478
|
beh?: EnrichmentData[];
|
@@ -484,8 +553,9 @@ declare type PersonalizeOptions<TVariant> = {
|
|
484
553
|
variations: Iterable<TVariant>;
|
485
554
|
/** Maximum number of variants to place (default: 1) */
|
486
555
|
take?: number;
|
556
|
+
onLogMessage?: (message: LogMessage) => void;
|
487
557
|
};
|
488
|
-
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ context, variations, take, }: PersonalizeOptions<TVariant> & {
|
558
|
+
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
|
489
559
|
context: Context;
|
490
560
|
}): PersonalizedResult<TVariant>;
|
491
561
|
|
@@ -542,8 +612,9 @@ declare type TestOptions<TVariant extends TestVariant> = {
|
|
542
612
|
/** Variations that are being tested. */
|
543
613
|
variations: TVariant[];
|
544
614
|
};
|
545
|
-
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, }: TestOptions<TVariant> & {
|
615
|
+
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
546
616
|
context: Context;
|
617
|
+
onLogMessage?: ((message: LogMessage) => void) | undefined;
|
547
618
|
}) => TestResult<TVariant>;
|
548
619
|
|
549
620
|
/**
|
@@ -612,7 +683,7 @@ declare type ContextEvents = {
|
|
612
683
|
* Note that event handlers attached to this event will not catch events
|
613
684
|
* logged during initialisation of the Context unless they are attached as plugins to the constructor.
|
614
685
|
*/
|
615
|
-
log: LogMessage;
|
686
|
+
log: LogMessage | LogMessageGroup;
|
616
687
|
/** Test variant has been selected */
|
617
688
|
testResult: TestEvent;
|
618
689
|
/** Personalization variants have been selected */
|
@@ -647,7 +718,9 @@ declare class Context implements Context {
|
|
647
718
|
* will NOT result in a recomputation of signal state.
|
648
719
|
*/
|
649
720
|
update(newData: Partial<ContextState>): Promise<void>;
|
721
|
+
/** use test() instead */
|
650
722
|
getTestVariantId(testName: string): string | null | undefined;
|
723
|
+
/** use test() instead */
|
651
724
|
setTestVariantId(testName: string, variantId: string): void;
|
652
725
|
/**
|
653
726
|
* Writes a message to the Context log sink.
|
@@ -729,4 +802,4 @@ declare global {
|
|
729
802
|
}
|
730
803
|
}
|
731
804
|
|
732
|
-
export {
|
805
|
+
export { ContextEvents as $, AggregateDimension as A, SetTestCommand as B, ContextPlugin as C, DecayFunction as D, EnrichmentCategory as E, SetControlGroupCommand as F, GroupCriteriaEvaluator as G, DecayOptions as H, IdentifyCommand as I, VisitorDataStoreOptions as J, VisitorDataStoreEvents as K, LogDrain as L, ManifestInstance as M, NumberMatch as N, OutputSeverity as O, PersonalizationManifest as P, Quirks as Q, VisitorDataStore as R, StorageCommands as S, TransitionDataStore as T, ServerToClientTransitionState as U, VisitorData as V, SERVER_STATE_ID as W, TransitionDataStoreEvents as X, ContextOptions as Y, PersonalizationEvent as Z, TestEvent as _, TransitionDataStoreOptions as a, Context as a0, LogMessages as a1, Severity as a2, MessageCategory as a3, MessageFunc as a4, LogMessageSingle as a5, LogMessageGroup as a6, testVariations as a7, TestOptions as a8, PersonalizeOptions as a9, personalizeVariations as aa, DimensionMatch as ab, BehaviorTag as ac, PersonalizedVariant as ad, PersonalizedResult as ae, TestVariant as af, TestResult as ag, TaggedContent as ah, DevToolsUiVersion as ai, DevToolsState as aj, DevToolsActions as ak, DevToolsEvent as al, DevToolsEvents as am, DevToolsLogEvent as an, DevToolsDataEvent as ao, DevToolsHelloEvent as ap, DevToolsUpdateEvent as aq, DevToolsRawCommandsEvent as ar, DevToolsForgetEvent as as, CriteriaEvaluator as b, StringMatch as c, ScoreVector as d, VariantMatchCriteria as e, LogMessage as f, ManifestV2 as g, Signal as h, SignalCriteriaGroup as i, SignalCriteria as j, TestDefinition as k, AggregateDimensionInput as l, CriteriaEvaluatorResult as m, CriteriaEvaluatorParameters as n, SignalData as o, Tests as p, EnrichmentData as q, EventData as r, emptyVisitorData as s, ContextState as t, ContextStateUpdate as u, StorageCommand as v, ModifyScoreCommand as w, ModifySessionScoreCommand as x, SetConsentCommand as y, SetQuirkCommand as z };
|
@@ -41,6 +41,15 @@ interface components {
|
|
41
41
|
schemas: {
|
42
42
|
ManifestV2: {
|
43
43
|
project: {
|
44
|
+
/**
|
45
|
+
* Format: uuid
|
46
|
+
* @description is not present unless getting a preview manifest
|
47
|
+
*/
|
48
|
+
id?: string;
|
49
|
+
/** @description is not present unless getting a preview manifest */
|
50
|
+
name?: string;
|
51
|
+
/** @description is not present unless getting a preview manifest */
|
52
|
+
ui_version?: number;
|
44
53
|
pz?: components["schemas"]["PersonalizationManifest"];
|
45
54
|
/** @description A/B test settings */
|
46
55
|
test?: {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/context",
|
3
|
-
"version": "14.2.1-alpha.
|
3
|
+
"version": "14.2.1-alpha.181+5f7721b60",
|
4
4
|
"description": "Uniform Context core package",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -49,14 +49,16 @@
|
|
49
49
|
"benchmark:run": "node ./dist/storage.benchmark.js"
|
50
50
|
},
|
51
51
|
"devDependencies": {
|
52
|
+
"@types/js-cookie": "3.0.1",
|
52
53
|
"@types/yargs": "17.0.9",
|
53
|
-
"@uniformdev/cli": "^14.2.1-alpha.
|
54
|
+
"@uniformdev/cli": "^14.2.1-alpha.181+5f7721b60",
|
54
55
|
"benny": "3.7.1",
|
55
56
|
"yargs": "17.3.1"
|
56
57
|
},
|
57
58
|
"dependencies": {
|
58
59
|
"dequal": "^2.0.2",
|
59
60
|
"isomorphic-unfetch": "^3.1.0",
|
61
|
+
"js-cookie": "3.0.1",
|
60
62
|
"mitt": "^3.0.0",
|
61
63
|
"p-limit": "^3.1.0",
|
62
64
|
"rfdc": "^1.3.0"
|
@@ -64,5 +66,5 @@
|
|
64
66
|
"files": [
|
65
67
|
"/dist"
|
66
68
|
],
|
67
|
-
"gitHead": "
|
69
|
+
"gitHead": "5f7721b601b0ce2ed15f2369ca87c2e2b1bd3c88"
|
68
70
|
}
|