@uniformdev/context 12.2.1-alpha.183 → 14.2.1-alpha.128
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 +17 -1401
- package/dist/api/api.js +2 -2
- package/dist/api/api.mjs +1 -1
- package/dist/chunk-5UOAJNMX.mjs +2 -0
- package/dist/{chunk-KZPEO35A.mjs → chunk-AFJ7PNM5.mjs} +0 -0
- package/dist/chunk-CEKV2MHL.mjs +1 -0
- package/dist/cli/cli.d.ts +14 -1
- package/dist/cli/cli.js +63 -53
- package/dist/cli/cli.mjs +62 -52
- package/dist/contextTypes-7f24fc7c.d.ts +1534 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{types-1ad8439c.d.ts → types-d77228a6.d.ts} +35 -290
- package/dist/v2-manifest.swagger-d0899723.d.ts +285 -0
- package/package.json +6 -19
- package/dist/chunk-GU2YFM6V.mjs +0 -1
- package/dist/chunk-JKQJOIRC.mjs +0 -2
@@ -1,3 +1,4 @@
|
|
1
|
+
import { c as components, e as external } from './v2-manifest.swagger-d0899723';
|
1
2
|
import * as mitt from 'mitt';
|
2
3
|
|
3
4
|
declare type StorageCommand<TID extends string = string, TData = unknown> = {
|
@@ -99,9 +100,12 @@ declare type VisitorData = {
|
|
99
100
|
controlGroup?: boolean;
|
100
101
|
};
|
101
102
|
declare const emptyVisitorData: () => VisitorData;
|
103
|
+
/**
|
104
|
+
* Expresses a 'patch' to the Uniform Context state
|
105
|
+
*/
|
102
106
|
declare type ContextState = {
|
103
107
|
cookies: Record<string, string>;
|
104
|
-
url
|
108
|
+
url?: URL;
|
105
109
|
quirks: Quirks;
|
106
110
|
enrichments: EnrichmentData[];
|
107
111
|
events: EventData[];
|
@@ -220,6 +224,8 @@ declare type LogMessages = {
|
|
220
224
|
3: MessageFunc<ScoreVector>;
|
221
225
|
/** Context emitted updated quirks */
|
222
226
|
4: MessageFunc<Quirks>;
|
227
|
+
/** Tried to set enrichment category that did not exist */
|
228
|
+
5: MessageFunc<EnrichmentData>;
|
223
229
|
/** Storage received update commands */
|
224
230
|
101: MessageFunc<StorageCommands[]>;
|
225
231
|
/** Storage data was updated */
|
@@ -236,6 +242,8 @@ declare type LogMessages = {
|
|
236
242
|
120: MessageFunc;
|
237
243
|
/** Server to client transition score data was loaded */
|
238
244
|
130: MessageFunc<ScoreVector>;
|
245
|
+
/** Server to client transition data was discarded */
|
246
|
+
131: MessageFunc;
|
239
247
|
/** Test did not exist */
|
240
248
|
401: MessageFunc<string>;
|
241
249
|
/** Previously shown test variant no longer in variant data */
|
@@ -358,290 +366,6 @@ declare class ManifestInstance {
|
|
358
366
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
359
367
|
}
|
360
368
|
|
361
|
-
/**
|
362
|
-
* This file was auto-generated by openapi-typescript.
|
363
|
-
* Do not make direct changes to the file.
|
364
|
-
*/
|
365
|
-
interface paths {
|
366
|
-
"/api/v2/manifest": {
|
367
|
-
/**
|
368
|
-
* Fetches the Intent Manifest for a given project.
|
369
|
-
* If no manifest has ever been published, and an API key is used that has preview manifest permissions then the current preview manifest will be returned (in delivery format).
|
370
|
-
*/
|
371
|
-
get: {
|
372
|
-
parameters: {
|
373
|
-
query: {
|
374
|
-
preview?: boolean;
|
375
|
-
projectId: string;
|
376
|
-
};
|
377
|
-
};
|
378
|
-
responses: {
|
379
|
-
/** OK */
|
380
|
-
200: {
|
381
|
-
content: {
|
382
|
-
"application/json": components["schemas"]["ManifestV2"];
|
383
|
-
};
|
384
|
-
};
|
385
|
-
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
386
|
-
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
387
|
-
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
388
|
-
/** No manifest has ever been published, and the API key does not have preview permissions */
|
389
|
-
404: {
|
390
|
-
content: {
|
391
|
-
"text/plain": string;
|
392
|
-
};
|
393
|
-
};
|
394
|
-
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
395
|
-
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
396
|
-
};
|
397
|
-
};
|
398
|
-
};
|
399
|
-
}
|
400
|
-
interface components {
|
401
|
-
schemas: {
|
402
|
-
ManifestV2: {
|
403
|
-
project: {
|
404
|
-
pz?: components["schemas"]["PersonalizationManifest"];
|
405
|
-
/** @description A/B test settings */
|
406
|
-
test?: {
|
407
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Test"];
|
408
|
-
};
|
409
|
-
};
|
410
|
-
};
|
411
|
-
PersonalizationManifest: {
|
412
|
-
/** @description Map of all signals defined for personalization criteria */
|
413
|
-
sig?: {
|
414
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Signal"];
|
415
|
-
};
|
416
|
-
/** @description Map of all enrichment categories defined for personalization criteria */
|
417
|
-
enr?: {
|
418
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["EnrichmentCategory"];
|
419
|
-
};
|
420
|
-
/** @description Map of all aggregate dimensions (intents or audiences) defined for personalization criteria */
|
421
|
-
agg?: {
|
422
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["AggregateDimension"];
|
423
|
-
};
|
424
|
-
/** @description Percentage of visitors that will be used as a personalization control group (not shown any personalization) */
|
425
|
-
control?: number;
|
426
|
-
};
|
427
|
-
};
|
428
|
-
}
|
429
|
-
interface external {
|
430
|
-
"swagger.yml": {
|
431
|
-
paths: {};
|
432
|
-
components: {
|
433
|
-
schemas: {
|
434
|
-
Error: {
|
435
|
-
/** @description Error message(s) that occurred while processing the request */
|
436
|
-
errorMessage?: string[] | string;
|
437
|
-
};
|
438
|
-
};
|
439
|
-
responses: {
|
440
|
-
/** Request input validation failed */
|
441
|
-
BadRequestError: {
|
442
|
-
content: {
|
443
|
-
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
444
|
-
};
|
445
|
-
};
|
446
|
-
/** API key or token was not valid */
|
447
|
-
UnauthorizedError: {
|
448
|
-
content: {
|
449
|
-
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
450
|
-
};
|
451
|
-
};
|
452
|
-
/** Permission was denied */
|
453
|
-
ForbiddenError: {
|
454
|
-
content: {
|
455
|
-
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
456
|
-
};
|
457
|
-
};
|
458
|
-
/** Too many requests in allowed time period */
|
459
|
-
RateLimitError: unknown;
|
460
|
-
/** Execution error occurred */
|
461
|
-
InternalServerError: unknown;
|
462
|
-
};
|
463
|
-
};
|
464
|
-
operations: {};
|
465
|
-
};
|
466
|
-
"uniform-context-types.swagger.yml": {
|
467
|
-
paths: {};
|
468
|
-
components: {
|
469
|
-
schemas: {
|
470
|
-
EnrichmentCategory: {
|
471
|
-
/** @description The maximum visitor score allowed for enrichment keys in this category */
|
472
|
-
cap: number;
|
473
|
-
};
|
474
|
-
PreviewSignal: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Signal"] & {
|
475
|
-
/** @description Friendly name of the signal */
|
476
|
-
name: string;
|
477
|
-
/** @description Description of the signal */
|
478
|
-
description?: string;
|
479
|
-
};
|
480
|
-
Signal: {
|
481
|
-
/** @description The signal strength per activation (each time its criteria are true, this score is added) */
|
482
|
-
str: number;
|
483
|
-
/** @description The maximum visitor score allowed for this signal */
|
484
|
-
cap: number;
|
485
|
-
/**
|
486
|
-
* @description How long the signal's score should persist
|
487
|
-
* 's' = current session (expires after a period of inactivity)
|
488
|
-
* 'p' = permanent (expires as far in the future as possible, may be limited by browser security settings)
|
489
|
-
* 't' = transient (score tracks the current state of the criteria every time scores are updated)
|
490
|
-
*/
|
491
|
-
dur: "s" | "p" | "t";
|
492
|
-
crit: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["RootSignalCriteriaGroup"];
|
493
|
-
};
|
494
|
-
RootSignalCriteriaGroup: {
|
495
|
-
/** @description Criteria type (Group of other criteria) */
|
496
|
-
type: "G";
|
497
|
-
/**
|
498
|
-
* @description The logical operator to apply to the criteria groups
|
499
|
-
* & = AND
|
500
|
-
* | = OR
|
501
|
-
*
|
502
|
-
* Default is `&` if unspecified.
|
503
|
-
*
|
504
|
-
* @default &
|
505
|
-
*/
|
506
|
-
op?: "&" | "|";
|
507
|
-
/** @description The criteria clauses that make up this grouping of criteria */
|
508
|
-
clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
|
509
|
-
};
|
510
|
-
SignalCriteriaGroup: {
|
511
|
-
/** @description Criteria type (Group of other criteria) */
|
512
|
-
type: "G";
|
513
|
-
/**
|
514
|
-
* @description The logical operator to apply to the criteria groups
|
515
|
-
* & = AND
|
516
|
-
* | = OR
|
517
|
-
*
|
518
|
-
* Default is `&` if unspecified.
|
519
|
-
*/
|
520
|
-
op?: "&" | "|";
|
521
|
-
/** @description The criteria clauses that make up this grouping of criteria */
|
522
|
-
clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
|
523
|
-
};
|
524
|
-
SignalCriteria: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["CookieCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QueryStringCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QuirkCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["EventCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["CurrentPageCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["PageViewCountCriteria"];
|
525
|
-
/** @description Matches a URL query string parameter value */
|
526
|
-
QueryStringCriteria: {
|
527
|
-
type: "QS";
|
528
|
-
/** @description The name of the query string parameter to match */
|
529
|
-
queryName: string;
|
530
|
-
/** @description The value to match the query string parameter against */
|
531
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
532
|
-
};
|
533
|
-
/** @description Matches a web cookie value */
|
534
|
-
CookieCriteria: {
|
535
|
-
type: "CK";
|
536
|
-
/** @description The name of the cookie to match */
|
537
|
-
cookieName: string;
|
538
|
-
/** @description The value to match the cookie against */
|
539
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
540
|
-
};
|
541
|
-
/** @description Matches a visitor quirk key and value */
|
542
|
-
QuirkCriteria: {
|
543
|
-
type: "QK";
|
544
|
-
/** @description The name of the quirk key to match */
|
545
|
-
key: string;
|
546
|
-
/** @description The quirk value to match against */
|
547
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
548
|
-
};
|
549
|
-
/** @description Matches an analytics event name being fired */
|
550
|
-
EventCriteria: {
|
551
|
-
type: "EVT";
|
552
|
-
/** @description How to match the event name */
|
553
|
-
event: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
554
|
-
};
|
555
|
-
/**
|
556
|
-
* @description Matches the current page's absolute path (i.e. /path/to/page.html)
|
557
|
-
* Does not include the query string or protocol and hostname (i.e. NOT https://foo.com/path/to/page.html?query=something)
|
558
|
-
*/
|
559
|
-
CurrentPageCriteria: {
|
560
|
-
type: "PV";
|
561
|
-
/** @description The page/route path to match as a page that has been visited */
|
562
|
-
path: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
563
|
-
};
|
564
|
-
PageViewCountCriteria: {
|
565
|
-
type: "PVC";
|
566
|
-
/** @description The expression to match the page view count against */
|
567
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["NumberMatch"];
|
568
|
-
};
|
569
|
-
/** @description Describes a match expression on a string */
|
570
|
-
StringMatch: {
|
571
|
-
/** @description The right hand side of the match expression */
|
572
|
-
rhs: string;
|
573
|
-
/**
|
574
|
-
* @description The match operator
|
575
|
-
* '=' = exact match
|
576
|
-
* '~' = contains match
|
577
|
-
* '//' = regular expression match
|
578
|
-
*
|
579
|
-
* Any of the above can be prefixed with '!' to invert the match (i.e. != for 'not an exact match')
|
580
|
-
*/
|
581
|
-
op: "=" | "~" | "//" | "!=" | "!~" | "!//";
|
582
|
-
/** @description The case sensitivity of the match. Defaults to false if unspecified. */
|
583
|
-
cs?: boolean;
|
584
|
-
} | {
|
585
|
-
/**
|
586
|
-
* @description The type of match to perform
|
587
|
-
* '*' = exists with any value
|
588
|
-
* '!*' = does not exist
|
589
|
-
*/
|
590
|
-
op: "*" | "!*";
|
591
|
-
};
|
592
|
-
/** @description Describes a match expression on a number */
|
593
|
-
NumberMatch: {
|
594
|
-
/** @description The right hand side of the match expression */
|
595
|
-
rhs: number;
|
596
|
-
/**
|
597
|
-
* @description The type of match to perform
|
598
|
-
* '=' = exact match
|
599
|
-
* '!=' = not an exact match
|
600
|
-
* '<' = less than match expression
|
601
|
-
* '>' = greater than match expression
|
602
|
-
*/
|
603
|
-
op: "=" | "<" | ">" | "!=";
|
604
|
-
};
|
605
|
-
/** @description Defines an aggregate dimension that is a grouping of other dimensions' scores; an intent or audience. */
|
606
|
-
AggregateDimension: {
|
607
|
-
/** @description Input dimensions to the aggregate dimension */
|
608
|
-
inputs: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["AggregateDimensionInput"][];
|
609
|
-
};
|
610
|
-
/** @description Defines an input dimension to an aggregate dimension */
|
611
|
-
AggregateDimensionInput: {
|
612
|
-
/**
|
613
|
-
* @description Dimension name to reference as an input.
|
614
|
-
* For enrichment inputs, use CATEGORY_KEY as the dimension.
|
615
|
-
* Enrichments, signals, and other aggregate dimensions may be referenced.
|
616
|
-
*
|
617
|
-
* Note that creating a cycle of aggregate dimensions is allowed, however
|
618
|
-
* the final score will _ignore_ the cycled aggregate dimension in the result.
|
619
|
-
* This can be used to create mutually exclusive aggregates.
|
620
|
-
*/
|
621
|
-
dim: string;
|
622
|
-
/**
|
623
|
-
* @description The sign of the input dimension controls how it affects the aggregate dimension's final score.
|
624
|
-
*
|
625
|
-
* '+' = add to the final score
|
626
|
-
* '-' = subtract from the final score
|
627
|
-
* 'c' = clear the final score (if the input dimension has any score at all, this aggreate will have no score regardless of other inputs)
|
628
|
-
*
|
629
|
-
* Default if unspecified: '+'
|
630
|
-
*
|
631
|
-
* @default +
|
632
|
-
*/
|
633
|
-
sign?: "+" | "-" | "c";
|
634
|
-
};
|
635
|
-
Test: {
|
636
|
-
/** @description Winning variation ID - if set, the test will not run and this variation is shown to all visitors (the test is closed) */
|
637
|
-
wv?: string;
|
638
|
-
};
|
639
|
-
};
|
640
|
-
};
|
641
|
-
operations: {};
|
642
|
-
};
|
643
|
-
}
|
644
|
-
|
645
369
|
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
646
370
|
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
647
371
|
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
@@ -655,17 +379,29 @@ declare type TestDefinition = SharedTypes['Test'];
|
|
655
379
|
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
656
380
|
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
657
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
|
+
};
|
658
395
|
/**
|
659
396
|
* A type that evaluates a signal criteria type and
|
660
397
|
* decides if it matches the current Context state or not.
|
661
|
-
|
662
|
-
|
663
|
-
declare type CriteriaEvaluator = (update: ContextStateUpdate, criteria: SignalCriteria, commands: StorageCommands[], signal: Signal, dimension: string) => boolean;
|
398
|
+
*/
|
399
|
+
declare type CriteriaEvaluator = (update: ContextStateUpdate, criteria: SignalCriteria, commands: StorageCommands[], signal: Signal, dimension: string) => CriteriaEvaluatorResult;
|
664
400
|
|
665
401
|
declare class GroupCriteriaEvaluator {
|
666
402
|
#private;
|
667
403
|
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
668
|
-
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: Signal, dimension: string):
|
404
|
+
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: Signal, dimension: string): CriteriaEvaluatorResult;
|
669
405
|
}
|
670
406
|
|
671
407
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
@@ -901,6 +637,15 @@ declare class Context implements Context {
|
|
901
637
|
};
|
902
638
|
};
|
903
639
|
readonly storage: VisitorDataStore;
|
640
|
+
/**
|
641
|
+
* Updates the Context with new data of any sort, such as
|
642
|
+
* new URLs, cookies, quirks, and enrichments.
|
643
|
+
*
|
644
|
+
* Only properties that are set in the data parameter will be updated.
|
645
|
+
* Properties that do not result in a changed state,
|
646
|
+
* i.e. pushing the same URL or cookies as before,
|
647
|
+
* will NOT result in a recomputation of signal state.
|
648
|
+
*/
|
904
649
|
update(newData: Partial<ContextState>): Promise<void>;
|
905
650
|
getTestVariantId(testName: string): string | null | undefined;
|
906
651
|
setTestVariantId(testName: string, variantId: string): void;
|
@@ -984,4 +729,4 @@ declare global {
|
|
984
729
|
}
|
985
730
|
}
|
986
731
|
|
987
|
-
export {
|
732
|
+
export { LogMessages as $, AggregateDimension as A, DecayOptions as B, CookieAdapter as C, DecayFunction as D, EnrichmentCategory as E, VisitorDataStoreOptions as F, GroupCriteriaEvaluator as G, VisitorDataStoreEvents as H, IdentifyCommand as I, VisitorDataStore as J, ServerToClientTransitionState as K, LogDrain as L, ManifestInstance as M, NumberMatch as N, OutputSeverity as O, PersonalizationManifest as P, Quirks as Q, SERVER_STATE_ID as R, StorageCommands as S, TransitionDataStore as T, TransitionDataStoreEvents as U, VisitorData as V, ContextOptions as W, PersonalizationEvent as X, TestEvent as Y, ContextEvents as Z, Context as _, TransitionDataStoreOptions as a, Severity as a0, MessageFunc as a1, LogMessage as a2, testVariations as a3, TestOptions as a4, PersonalizeOptions as a5, personalizeVariations as a6, DimensionMatch as a7, BehaviorTag as a8, PersonalizedVariant as a9, PersonalizedResult as aa, TestVariant as ab, TestResult as ac, TaggedContent as ad, DevToolsUiVersion as ae, DevToolsState as af, DevToolsActions as ag, DevToolsEvent as ah, DevToolsEvents as ai, DevToolsLogEvent as aj, DevToolsDataEvent as ak, DevToolsHelloEvent as al, DevToolsUpdateEvent as am, DevToolsRawCommandsEvent as an, DevToolsForgetEvent as ao, ContextPlugin as b, CriteriaEvaluator as c, StringMatch as d, ScoreVector as e, VariantMatchCriteria as f, ManifestV2 as g, Signal as h, SignalCriteriaGroup as i, SignalCriteria as j, TestDefinition as k, AggregateDimensionInput as l, CriteriaEvaluatorResult as m, Tests as n, EnrichmentData as o, EventData as p, emptyVisitorData as q, ContextState as r, ContextStateUpdate as s, StorageCommand as t, ModifyScoreCommand as u, ModifySessionScoreCommand as v, SetConsentCommand as w, SetQuirkCommand as x, SetTestCommand as y, SetControlGroupCommand as z };
|