@contentful/optimization-api-schemas 0.1.0-alpha
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/LICENSE +21 -0
- package/README.md +127 -0
- package/dist/contentful/AudienceEntry.d.ts +73 -0
- package/dist/contentful/AudienceEntry.d.ts.map +1 -0
- package/dist/contentful/AudienceEntry.js +41 -0
- package/dist/contentful/AudienceEntry.js.map +1 -0
- package/dist/contentful/CtflEntry.d.ts +206 -0
- package/dist/contentful/CtflEntry.d.ts.map +1 -0
- package/dist/contentful/CtflEntry.js +122 -0
- package/dist/contentful/CtflEntry.js.map +1 -0
- package/dist/contentful/MergeTagEntry.d.ts +68 -0
- package/dist/contentful/MergeTagEntry.d.ts.map +1 -0
- package/dist/contentful/MergeTagEntry.js +38 -0
- package/dist/contentful/MergeTagEntry.js.map +1 -0
- package/dist/contentful/PersonalizationConfig.d.ts +437 -0
- package/dist/contentful/PersonalizationConfig.d.ts.map +1 -0
- package/dist/contentful/PersonalizationConfig.js +164 -0
- package/dist/contentful/PersonalizationConfig.js.map +1 -0
- package/dist/contentful/PersonalizationEntry.d.ts +541 -0
- package/dist/contentful/PersonalizationEntry.d.ts.map +1 -0
- package/dist/contentful/PersonalizationEntry.js +95 -0
- package/dist/contentful/PersonalizationEntry.js.map +1 -0
- package/dist/contentful/PersonalizedEntry.d.ts +244 -0
- package/dist/contentful/PersonalizedEntry.d.ts.map +1 -0
- package/dist/contentful/PersonalizedEntry.js +27 -0
- package/dist/contentful/PersonalizedEntry.js.map +1 -0
- package/dist/contentful/index.d.ts +7 -0
- package/dist/contentful/index.d.ts.map +1 -0
- package/dist/contentful/index.js +7 -0
- package/dist/contentful/index.js.map +1 -0
- package/dist/experience/BatchExperienceResponse.d.ts +110 -0
- package/dist/experience/BatchExperienceResponse.d.ts.map +1 -0
- package/dist/experience/BatchExperienceResponse.js +25 -0
- package/dist/experience/BatchExperienceResponse.js.map +1 -0
- package/dist/experience/ExperienceRequest.d.ts +440 -0
- package/dist/experience/ExperienceRequest.d.ts.map +1 -0
- package/dist/experience/ExperienceRequest.js +36 -0
- package/dist/experience/ExperienceRequest.js.map +1 -0
- package/dist/experience/ExperienceResponse.d.ts +173 -0
- package/dist/experience/ExperienceResponse.d.ts.map +1 -0
- package/dist/experience/ExperienceResponse.js +38 -0
- package/dist/experience/ExperienceResponse.js.map +1 -0
- package/dist/experience/ResponseEnvelope.d.ts +35 -0
- package/dist/experience/ResponseEnvelope.d.ts.map +1 -0
- package/dist/experience/ResponseEnvelope.js +31 -0
- package/dist/experience/ResponseEnvelope.js.map +1 -0
- package/dist/experience/change/Change.d.ts +138 -0
- package/dist/experience/change/Change.d.ts.map +1 -0
- package/dist/experience/change/Change.js +102 -0
- package/dist/experience/change/Change.js.map +1 -0
- package/dist/experience/change/index.d.ts +2 -0
- package/dist/experience/change/index.d.ts.map +1 -0
- package/dist/experience/change/index.js +2 -0
- package/dist/experience/change/index.js.map +1 -0
- package/dist/experience/event/AliasEvent.d.ts +73 -0
- package/dist/experience/event/AliasEvent.d.ts.map +1 -0
- package/dist/experience/event/AliasEvent.js +20 -0
- package/dist/experience/event/AliasEvent.js.map +1 -0
- package/dist/experience/event/BatchExperienceEvent.d.ts +820 -0
- package/dist/experience/event/BatchExperienceEvent.d.ts.map +1 -0
- package/dist/experience/event/BatchExperienceEvent.js +37 -0
- package/dist/experience/event/BatchExperienceEvent.js.map +1 -0
- package/dist/experience/event/ComponentViewEvent.d.ts +75 -0
- package/dist/experience/event/ComponentViewEvent.d.ts.map +1 -0
- package/dist/experience/event/ComponentViewEvent.js +43 -0
- package/dist/experience/event/ComponentViewEvent.js.map +1 -0
- package/dist/experience/event/ExperienceEvent.d.ts +810 -0
- package/dist/experience/event/ExperienceEvent.d.ts.map +1 -0
- package/dist/experience/event/ExperienceEvent.js +29 -0
- package/dist/experience/event/ExperienceEvent.js.map +1 -0
- package/dist/experience/event/GroupEvent.d.ts +73 -0
- package/dist/experience/event/GroupEvent.d.ts.map +1 -0
- package/dist/experience/event/GroupEvent.js +20 -0
- package/dist/experience/event/GroupEvent.js.map +1 -0
- package/dist/experience/event/IdentifyEvent.d.ts +71 -0
- package/dist/experience/event/IdentifyEvent.d.ts.map +1 -0
- package/dist/experience/event/IdentifyEvent.js +24 -0
- package/dist/experience/event/IdentifyEvent.js.map +1 -0
- package/dist/experience/event/PageViewEvent.d.ts +128 -0
- package/dist/experience/event/PageViewEvent.d.ts.map +1 -0
- package/dist/experience/event/PageViewEvent.js +44 -0
- package/dist/experience/event/PageViewEvent.js.map +1 -0
- package/dist/experience/event/ScreenViewEvent.d.ts +111 -0
- package/dist/experience/event/ScreenViewEvent.d.ts.map +1 -0
- package/dist/experience/event/ScreenViewEvent.js +43 -0
- package/dist/experience/event/ScreenViewEvent.js.map +1 -0
- package/dist/experience/event/TrackEvent.d.ts +73 -0
- package/dist/experience/event/TrackEvent.d.ts.map +1 -0
- package/dist/experience/event/TrackEvent.js +27 -0
- package/dist/experience/event/TrackEvent.js.map +1 -0
- package/dist/experience/event/UniversalEventProperties.d.ts +175 -0
- package/dist/experience/event/UniversalEventProperties.d.ts.map +1 -0
- package/dist/experience/event/UniversalEventProperties.js +100 -0
- package/dist/experience/event/UniversalEventProperties.js.map +1 -0
- package/dist/experience/event/index.d.ts +12 -0
- package/dist/experience/event/index.d.ts.map +1 -0
- package/dist/experience/event/index.js +12 -0
- package/dist/experience/event/index.js.map +1 -0
- package/dist/experience/event/properties/App.d.ts +25 -0
- package/dist/experience/event/properties/App.d.ts.map +1 -0
- package/dist/experience/event/properties/App.js +21 -0
- package/dist/experience/event/properties/App.js.map +1 -0
- package/dist/experience/event/properties/Campaign.d.ts +34 -0
- package/dist/experience/event/properties/Campaign.d.ts.map +1 -0
- package/dist/experience/event/properties/Campaign.js +30 -0
- package/dist/experience/event/properties/Campaign.js.map +1 -0
- package/dist/experience/event/properties/Channel.d.ts +17 -0
- package/dist/experience/event/properties/Channel.d.ts.map +1 -0
- package/dist/experience/event/properties/Channel.js +13 -0
- package/dist/experience/event/properties/Channel.js.map +1 -0
- package/dist/experience/event/properties/Dictionary.d.ts +13 -0
- package/dist/experience/event/properties/Dictionary.d.ts.map +1 -0
- package/dist/experience/event/properties/Dictionary.js +9 -0
- package/dist/experience/event/properties/Dictionary.js.map +1 -0
- package/dist/experience/event/properties/GeoLocation.d.ts +66 -0
- package/dist/experience/event/properties/GeoLocation.d.ts.map +1 -0
- package/dist/experience/event/properties/GeoLocation.js +76 -0
- package/dist/experience/event/properties/GeoLocation.js.map +1 -0
- package/dist/experience/event/properties/Library.d.ts +22 -0
- package/dist/experience/event/properties/Library.d.ts.map +1 -0
- package/dist/experience/event/properties/Library.js +18 -0
- package/dist/experience/event/properties/Library.js.map +1 -0
- package/dist/experience/event/properties/Page.d.ts +39 -0
- package/dist/experience/event/properties/Page.d.ts.map +1 -0
- package/dist/experience/event/properties/Page.js +36 -0
- package/dist/experience/event/properties/Page.js.map +1 -0
- package/dist/experience/event/properties/Properties.d.ts +13 -0
- package/dist/experience/event/properties/Properties.d.ts.map +1 -0
- package/dist/experience/event/properties/Properties.js +9 -0
- package/dist/experience/event/properties/Properties.js.map +1 -0
- package/dist/experience/event/properties/Screen.d.ts +19 -0
- package/dist/experience/event/properties/Screen.d.ts.map +1 -0
- package/dist/experience/event/properties/Screen.js +15 -0
- package/dist/experience/event/properties/Screen.js.map +1 -0
- package/dist/experience/event/properties/Traits.d.ts +14 -0
- package/dist/experience/event/properties/Traits.d.ts.map +1 -0
- package/dist/experience/event/properties/Traits.js +10 -0
- package/dist/experience/event/properties/Traits.js.map +1 -0
- package/dist/experience/event/properties/index.d.ts +11 -0
- package/dist/experience/event/properties/index.d.ts.map +1 -0
- package/dist/experience/event/properties/index.js +11 -0
- package/dist/experience/event/properties/index.js.map +1 -0
- package/dist/experience/index.d.ts +8 -0
- package/dist/experience/index.d.ts.map +1 -0
- package/dist/experience/index.js +8 -0
- package/dist/experience/index.js.map +1 -0
- package/dist/experience/personalization/SelectedPersonalization.d.ts +86 -0
- package/dist/experience/personalization/SelectedPersonalization.d.ts.map +1 -0
- package/dist/experience/personalization/SelectedPersonalization.js +48 -0
- package/dist/experience/personalization/SelectedPersonalization.js.map +1 -0
- package/dist/experience/personalization/index.d.ts +2 -0
- package/dist/experience/personalization/index.d.ts.map +1 -0
- package/dist/experience/personalization/index.js +2 -0
- package/dist/experience/personalization/index.js.map +1 -0
- package/dist/experience/profile/Profile.d.ts +104 -0
- package/dist/experience/profile/Profile.d.ts.map +1 -0
- package/dist/experience/profile/Profile.js +72 -0
- package/dist/experience/profile/Profile.js.map +1 -0
- package/dist/experience/profile/index.d.ts +3 -0
- package/dist/experience/profile/index.d.ts.map +1 -0
- package/dist/experience/profile/index.js +3 -0
- package/dist/experience/profile/index.js.map +1 -0
- package/dist/experience/profile/properties/SessionStatistics.d.ts +60 -0
- package/dist/experience/profile/properties/SessionStatistics.d.ts.map +1 -0
- package/dist/experience/profile/properties/SessionStatistics.js +50 -0
- package/dist/experience/profile/properties/SessionStatistics.js.map +1 -0
- package/dist/experience/profile/properties/index.d.ts +2 -0
- package/dist/experience/profile/properties/index.d.ts.map +1 -0
- package/dist/experience/profile/properties/index.js +2 -0
- package/dist/experience/profile/properties/index.js.map +1 -0
- package/dist/index.cjs +684 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +425 -0
- package/dist/index.mjs.map +1 -0
- package/dist/insights/event/BatchInsightsEvent.d.ts +173 -0
- package/dist/insights/event/BatchInsightsEvent.d.ts.map +1 -0
- package/dist/insights/event/BatchInsightsEvent.js +32 -0
- package/dist/insights/event/BatchInsightsEvent.js.map +1 -0
- package/dist/insights/event/InsightsEvent.d.ts +145 -0
- package/dist/insights/event/InsightsEvent.d.ts.map +1 -0
- package/dist/insights/event/InsightsEvent.js +16 -0
- package/dist/insights/event/InsightsEvent.js.map +1 -0
- package/dist/insights/event/index.d.ts +3 -0
- package/dist/insights/event/index.d.ts.map +1 -0
- package/dist/insights/event/index.js +3 -0
- package/dist/insights/event/index.js.map +1 -0
- package/dist/insights/index.d.ts +2 -0
- package/dist/insights/index.d.ts.map +1 -0
- package/dist/insights/index.js +2 -0
- package/dist/insights/index.js.map +1 -0
- package/package.json +25 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MergeTagEntry.d.ts","sourceRoot":"","sources":["../../src/contentful/MergeTagEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAG7B;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;QAEtB;;WAEG;;QAGH;;WAEG;;QAGH;;WAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgBL,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
import { CtflEntry, EntrySys } from './CtflEntry';
|
|
3
|
+
/**
|
|
4
|
+
* Zod schema for a Merge Tag Contentful entry.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Extends {@link CtflEntry} with merge-tag-specific fields and constrains the
|
|
8
|
+
* `contentType` to the `nt_mergetag` content type.
|
|
9
|
+
*/
|
|
10
|
+
export const MergeTagEntry = z.extend(CtflEntry, {
|
|
11
|
+
fields: z.object({
|
|
12
|
+
/**
|
|
13
|
+
* Human-readable name of the merge tag.
|
|
14
|
+
*/
|
|
15
|
+
nt_name: z.string(),
|
|
16
|
+
/**
|
|
17
|
+
* Fallback value to use when the merge tag cannot be resolved.
|
|
18
|
+
*/
|
|
19
|
+
nt_fallback: z.optional(z.string()),
|
|
20
|
+
/**
|
|
21
|
+
* Internal identifier of the merge tag.
|
|
22
|
+
*/
|
|
23
|
+
nt_mergetag_id: z.string(),
|
|
24
|
+
}),
|
|
25
|
+
/**
|
|
26
|
+
* System fields extended to constrain the content type to `nt_mergetag`.
|
|
27
|
+
*/
|
|
28
|
+
sys: z.extend(EntrySys, {
|
|
29
|
+
contentType: z.object({
|
|
30
|
+
sys: z.object({
|
|
31
|
+
type: z.literal('Link'),
|
|
32
|
+
linkType: z.literal('ContentType'),
|
|
33
|
+
id: z.literal('nt_mergetag'),
|
|
34
|
+
}),
|
|
35
|
+
}),
|
|
36
|
+
}),
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=MergeTagEntry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MergeTagEntry.js","sourceRoot":"","sources":["../../src/contentful/MergeTagEntry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAC7B,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEjD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,EAAE;IAC/C,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf;;WAEG;QACH,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QAEnB;;WAEG;QACH,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAEnC;;WAEG;QACH,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;KAC3B,CAAC;IAEF;;OAEG;IACH,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE;QACtB,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC;gBACZ,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;gBACvB,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;gBAClC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC;aAC7B,CAAC;SACH,CAAC;KACH,CAAC;CACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema describing a single entry replacement variant.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Each variant is identified by an `id` and may be marked as `hidden`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EntryReplacementVariant: z.ZodMiniObject<{
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for the variant.
|
|
11
|
+
*/
|
|
12
|
+
id: z.ZodMiniString<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue false
|
|
17
|
+
*/
|
|
18
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
/**
|
|
21
|
+
* TypeScript type inferred from {@link EntryReplacementVariant}.
|
|
22
|
+
*/
|
|
23
|
+
export type EntryReplacementVariant = z.infer<typeof EntryReplacementVariant>;
|
|
24
|
+
/**
|
|
25
|
+
* Type guard for {@link EntryReplacementVariant}.
|
|
26
|
+
*
|
|
27
|
+
* @param variant - Value to test.
|
|
28
|
+
* @returns `true` if `variant` conforms to {@link EntryReplacementVariant}, otherwise `false`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isEntryReplacementVariant(variant: unknown): variant is EntryReplacementVariant;
|
|
31
|
+
/**
|
|
32
|
+
* Zod schema describing an entry replacement personalization component.
|
|
33
|
+
*
|
|
34
|
+
* @remarks
|
|
35
|
+
* This component replaces a baseline entry with one of several variants.
|
|
36
|
+
*/
|
|
37
|
+
export declare const EntryReplacementComponent: z.ZodMiniObject<{
|
|
38
|
+
/**
|
|
39
|
+
* Discriminator for the component type.
|
|
40
|
+
*
|
|
41
|
+
* @remarks
|
|
42
|
+
* May be omitted, in which case the component is treated as an EntryReplacement.
|
|
43
|
+
*/
|
|
44
|
+
type: z.ZodMiniOptional<z.ZodMiniLiteral<"EntryReplacement">>;
|
|
45
|
+
/**
|
|
46
|
+
* Baseline variant used when no targeting or allocation selects another variant.
|
|
47
|
+
*/
|
|
48
|
+
baseline: z.ZodMiniObject<{
|
|
49
|
+
/**
|
|
50
|
+
* Unique identifier for the variant.
|
|
51
|
+
*/
|
|
52
|
+
id: z.ZodMiniString<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
55
|
+
*
|
|
56
|
+
* @defaultValue false
|
|
57
|
+
*/
|
|
58
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
/**
|
|
61
|
+
* Additional variants that may be served.
|
|
62
|
+
*/
|
|
63
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
64
|
+
/**
|
|
65
|
+
* Unique identifier for the variant.
|
|
66
|
+
*/
|
|
67
|
+
id: z.ZodMiniString<string>;
|
|
68
|
+
/**
|
|
69
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
70
|
+
*
|
|
71
|
+
* @defaultValue false
|
|
72
|
+
*/
|
|
73
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
74
|
+
}, z.core.$strip>>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
/**
|
|
77
|
+
* TypeScript type inferred from {@link EntryReplacementComponent}.
|
|
78
|
+
*/
|
|
79
|
+
export type EntryReplacementComponent = z.infer<typeof EntryReplacementComponent>;
|
|
80
|
+
/**
|
|
81
|
+
* Type guard for {@link EntryReplacementComponent}.
|
|
82
|
+
*
|
|
83
|
+
* @param component - Personalization component to test.
|
|
84
|
+
* @returns `true` if the component is an EntryReplacement component, otherwise `false`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function isEntryReplacementComponent(component: PersonalizationComponent): component is EntryReplacementComponent;
|
|
87
|
+
/**
|
|
88
|
+
* Zod schema describing a variant for inline variables.
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* The value may be a primitive or a JSON object.
|
|
92
|
+
*/
|
|
93
|
+
export declare const InlineVariableVariant: z.ZodMiniObject<{
|
|
94
|
+
/**
|
|
95
|
+
* Variant value for the inline variable.
|
|
96
|
+
*/
|
|
97
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
/**
|
|
100
|
+
* Enumeration of supported inline variable value types.
|
|
101
|
+
*/
|
|
102
|
+
export declare const InlineVariableComponentValueType: z.ZodMiniEnum<{
|
|
103
|
+
Boolean: "Boolean";
|
|
104
|
+
Number: "Number";
|
|
105
|
+
Object: "Object";
|
|
106
|
+
String: "String";
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Zod schema describing an inline variable personalization component.
|
|
110
|
+
*
|
|
111
|
+
* @remarks
|
|
112
|
+
* Used to vary scalar or object values in templates.
|
|
113
|
+
*/
|
|
114
|
+
export declare const InlineVariableComponent: z.ZodMiniObject<{
|
|
115
|
+
/**
|
|
116
|
+
* Discriminator for the inline variable component.
|
|
117
|
+
*/
|
|
118
|
+
type: z.ZodMiniLiteral<"InlineVariable">;
|
|
119
|
+
/**
|
|
120
|
+
* Key under which this variable is exposed to the template.
|
|
121
|
+
*/
|
|
122
|
+
key: z.ZodMiniString<string>;
|
|
123
|
+
/**
|
|
124
|
+
* Describes the runtime type of the values for this variable.
|
|
125
|
+
*/
|
|
126
|
+
valueType: z.ZodMiniEnum<{
|
|
127
|
+
Boolean: "Boolean";
|
|
128
|
+
Number: "Number";
|
|
129
|
+
Object: "Object";
|
|
130
|
+
String: "String";
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Baseline value used when no targeting or allocation selects another variant.
|
|
134
|
+
*/
|
|
135
|
+
baseline: z.ZodMiniObject<{
|
|
136
|
+
/**
|
|
137
|
+
* Variant value for the inline variable.
|
|
138
|
+
*/
|
|
139
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
140
|
+
}, z.core.$strip>;
|
|
141
|
+
/**
|
|
142
|
+
* Additional variable variants for experimentation or personalization.
|
|
143
|
+
*/
|
|
144
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
145
|
+
/**
|
|
146
|
+
* Variant value for the inline variable.
|
|
147
|
+
*/
|
|
148
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
149
|
+
}, z.core.$strip>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
/**
|
|
152
|
+
* TypeScript type inferred from {@link InlineVariableComponent}.
|
|
153
|
+
*/
|
|
154
|
+
export type InlineVariableComponent = z.infer<typeof InlineVariableComponent>;
|
|
155
|
+
/**
|
|
156
|
+
* Type guard for {@link InlineVariableComponent}.
|
|
157
|
+
*
|
|
158
|
+
* @param component - Personalization component to test.
|
|
159
|
+
* @returns `true` if the component is an InlineVariable component, otherwise `false`.
|
|
160
|
+
*/
|
|
161
|
+
export declare function isInlineVariableComponent(component: PersonalizationComponent): component is InlineVariableComponent;
|
|
162
|
+
/**
|
|
163
|
+
* Discriminated union of all supported personalization components.
|
|
164
|
+
*/
|
|
165
|
+
export declare const PersonalizationComponent: z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
166
|
+
/**
|
|
167
|
+
* Discriminator for the component type.
|
|
168
|
+
*
|
|
169
|
+
* @remarks
|
|
170
|
+
* May be omitted, in which case the component is treated as an EntryReplacement.
|
|
171
|
+
*/
|
|
172
|
+
type: z.ZodMiniOptional<z.ZodMiniLiteral<"EntryReplacement">>;
|
|
173
|
+
/**
|
|
174
|
+
* Baseline variant used when no targeting or allocation selects another variant.
|
|
175
|
+
*/
|
|
176
|
+
baseline: z.ZodMiniObject<{
|
|
177
|
+
/**
|
|
178
|
+
* Unique identifier for the variant.
|
|
179
|
+
*/
|
|
180
|
+
id: z.ZodMiniString<string>;
|
|
181
|
+
/**
|
|
182
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
183
|
+
*
|
|
184
|
+
* @defaultValue false
|
|
185
|
+
*/
|
|
186
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
187
|
+
}, z.core.$strip>;
|
|
188
|
+
/**
|
|
189
|
+
* Additional variants that may be served.
|
|
190
|
+
*/
|
|
191
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
192
|
+
/**
|
|
193
|
+
* Unique identifier for the variant.
|
|
194
|
+
*/
|
|
195
|
+
id: z.ZodMiniString<string>;
|
|
196
|
+
/**
|
|
197
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
198
|
+
*
|
|
199
|
+
* @defaultValue false
|
|
200
|
+
*/
|
|
201
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
202
|
+
}, z.core.$strip>>;
|
|
203
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
204
|
+
/**
|
|
205
|
+
* Discriminator for the inline variable component.
|
|
206
|
+
*/
|
|
207
|
+
type: z.ZodMiniLiteral<"InlineVariable">;
|
|
208
|
+
/**
|
|
209
|
+
* Key under which this variable is exposed to the template.
|
|
210
|
+
*/
|
|
211
|
+
key: z.ZodMiniString<string>;
|
|
212
|
+
/**
|
|
213
|
+
* Describes the runtime type of the values for this variable.
|
|
214
|
+
*/
|
|
215
|
+
valueType: z.ZodMiniEnum<{
|
|
216
|
+
Boolean: "Boolean";
|
|
217
|
+
Number: "Number";
|
|
218
|
+
Object: "Object";
|
|
219
|
+
String: "String";
|
|
220
|
+
}>;
|
|
221
|
+
/**
|
|
222
|
+
* Baseline value used when no targeting or allocation selects another variant.
|
|
223
|
+
*/
|
|
224
|
+
baseline: z.ZodMiniObject<{
|
|
225
|
+
/**
|
|
226
|
+
* Variant value for the inline variable.
|
|
227
|
+
*/
|
|
228
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
229
|
+
}, z.core.$strip>;
|
|
230
|
+
/**
|
|
231
|
+
* Additional variable variants for experimentation or personalization.
|
|
232
|
+
*/
|
|
233
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
234
|
+
/**
|
|
235
|
+
* Variant value for the inline variable.
|
|
236
|
+
*/
|
|
237
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
238
|
+
}, z.core.$strip>>;
|
|
239
|
+
}, z.core.$strip>], "type">;
|
|
240
|
+
/**
|
|
241
|
+
* TypeScript type inferred from {@link PersonalizationComponent}.
|
|
242
|
+
*/
|
|
243
|
+
export type PersonalizationComponent = z.infer<typeof PersonalizationComponent>;
|
|
244
|
+
/**
|
|
245
|
+
* Zod schema representing an array of {@link PersonalizationComponent} items.
|
|
246
|
+
*/
|
|
247
|
+
export declare const PersonalizationComponentArray: z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
248
|
+
/**
|
|
249
|
+
* Discriminator for the component type.
|
|
250
|
+
*
|
|
251
|
+
* @remarks
|
|
252
|
+
* May be omitted, in which case the component is treated as an EntryReplacement.
|
|
253
|
+
*/
|
|
254
|
+
type: z.ZodMiniOptional<z.ZodMiniLiteral<"EntryReplacement">>;
|
|
255
|
+
/**
|
|
256
|
+
* Baseline variant used when no targeting or allocation selects another variant.
|
|
257
|
+
*/
|
|
258
|
+
baseline: z.ZodMiniObject<{
|
|
259
|
+
/**
|
|
260
|
+
* Unique identifier for the variant.
|
|
261
|
+
*/
|
|
262
|
+
id: z.ZodMiniString<string>;
|
|
263
|
+
/**
|
|
264
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
265
|
+
*
|
|
266
|
+
* @defaultValue false
|
|
267
|
+
*/
|
|
268
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
/**
|
|
271
|
+
* Additional variants that may be served.
|
|
272
|
+
*/
|
|
273
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
274
|
+
/**
|
|
275
|
+
* Unique identifier for the variant.
|
|
276
|
+
*/
|
|
277
|
+
id: z.ZodMiniString<string>;
|
|
278
|
+
/**
|
|
279
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
280
|
+
*
|
|
281
|
+
* @defaultValue false
|
|
282
|
+
*/
|
|
283
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
284
|
+
}, z.core.$strip>>;
|
|
285
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
286
|
+
/**
|
|
287
|
+
* Discriminator for the inline variable component.
|
|
288
|
+
*/
|
|
289
|
+
type: z.ZodMiniLiteral<"InlineVariable">;
|
|
290
|
+
/**
|
|
291
|
+
* Key under which this variable is exposed to the template.
|
|
292
|
+
*/
|
|
293
|
+
key: z.ZodMiniString<string>;
|
|
294
|
+
/**
|
|
295
|
+
* Describes the runtime type of the values for this variable.
|
|
296
|
+
*/
|
|
297
|
+
valueType: z.ZodMiniEnum<{
|
|
298
|
+
Boolean: "Boolean";
|
|
299
|
+
Number: "Number";
|
|
300
|
+
Object: "Object";
|
|
301
|
+
String: "String";
|
|
302
|
+
}>;
|
|
303
|
+
/**
|
|
304
|
+
* Baseline value used when no targeting or allocation selects another variant.
|
|
305
|
+
*/
|
|
306
|
+
baseline: z.ZodMiniObject<{
|
|
307
|
+
/**
|
|
308
|
+
* Variant value for the inline variable.
|
|
309
|
+
*/
|
|
310
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
311
|
+
}, z.core.$strip>;
|
|
312
|
+
/**
|
|
313
|
+
* Additional variable variants for experimentation or personalization.
|
|
314
|
+
*/
|
|
315
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
316
|
+
/**
|
|
317
|
+
* Variant value for the inline variable.
|
|
318
|
+
*/
|
|
319
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
320
|
+
}, z.core.$strip>>;
|
|
321
|
+
}, z.core.$strip>], "type">>;
|
|
322
|
+
/**
|
|
323
|
+
* TypeScript type inferred from {@link PersonalizationComponentArray}.
|
|
324
|
+
*/
|
|
325
|
+
export type PersonalizationComponentArray = z.infer<typeof PersonalizationComponentArray>;
|
|
326
|
+
/**
|
|
327
|
+
* Zod schema describing the full configuration for a personalization.
|
|
328
|
+
*
|
|
329
|
+
* @remarks
|
|
330
|
+
* Provides distribution, traffic allocation, component definitions, and sticky behavior.
|
|
331
|
+
*/
|
|
332
|
+
export declare const PersonalizationConfig: z.ZodMiniObject<{
|
|
333
|
+
/**
|
|
334
|
+
* Variant distribution used for traffic allocation.
|
|
335
|
+
*
|
|
336
|
+
* @defaultValue [0.5, 0.5]
|
|
337
|
+
*/
|
|
338
|
+
distribution: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniArray<z.ZodMiniNumber<number>>>>;
|
|
339
|
+
/**
|
|
340
|
+
* Percentage of total traffic that should enter the personalization.
|
|
341
|
+
*
|
|
342
|
+
* @defaultValue 0
|
|
343
|
+
*/
|
|
344
|
+
traffic: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniNumber<number>>>;
|
|
345
|
+
/**
|
|
346
|
+
* Personalization components that define how content is varied.
|
|
347
|
+
*
|
|
348
|
+
* @defaultValue
|
|
349
|
+
* A single {@link EntryReplacementComponent} with an empty `baseline` and `variants` ID.
|
|
350
|
+
*/
|
|
351
|
+
components: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniArray<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
352
|
+
/**
|
|
353
|
+
* Discriminator for the component type.
|
|
354
|
+
*
|
|
355
|
+
* @remarks
|
|
356
|
+
* May be omitted, in which case the component is treated as an EntryReplacement.
|
|
357
|
+
*/
|
|
358
|
+
type: z.ZodMiniOptional<z.ZodMiniLiteral<"EntryReplacement">>;
|
|
359
|
+
/**
|
|
360
|
+
* Baseline variant used when no targeting or allocation selects another variant.
|
|
361
|
+
*/
|
|
362
|
+
baseline: z.ZodMiniObject<{
|
|
363
|
+
/**
|
|
364
|
+
* Unique identifier for the variant.
|
|
365
|
+
*/
|
|
366
|
+
id: z.ZodMiniString<string>;
|
|
367
|
+
/**
|
|
368
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
369
|
+
*
|
|
370
|
+
* @defaultValue false
|
|
371
|
+
*/
|
|
372
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
373
|
+
}, z.core.$strip>;
|
|
374
|
+
/**
|
|
375
|
+
* Additional variants that may be served.
|
|
376
|
+
*/
|
|
377
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
378
|
+
/**
|
|
379
|
+
* Unique identifier for the variant.
|
|
380
|
+
*/
|
|
381
|
+
id: z.ZodMiniString<string>;
|
|
382
|
+
/**
|
|
383
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
384
|
+
*
|
|
385
|
+
* @defaultValue false
|
|
386
|
+
*/
|
|
387
|
+
hidden: z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>;
|
|
388
|
+
}, z.core.$strip>>;
|
|
389
|
+
}, z.core.$strip>, z.ZodMiniObject<{
|
|
390
|
+
/**
|
|
391
|
+
* Discriminator for the inline variable component.
|
|
392
|
+
*/
|
|
393
|
+
type: z.ZodMiniLiteral<"InlineVariable">;
|
|
394
|
+
/**
|
|
395
|
+
* Key under which this variable is exposed to the template.
|
|
396
|
+
*/
|
|
397
|
+
key: z.ZodMiniString<string>;
|
|
398
|
+
/**
|
|
399
|
+
* Describes the runtime type of the values for this variable.
|
|
400
|
+
*/
|
|
401
|
+
valueType: z.ZodMiniEnum<{
|
|
402
|
+
Boolean: "Boolean";
|
|
403
|
+
Number: "Number";
|
|
404
|
+
Object: "Object";
|
|
405
|
+
String: "String";
|
|
406
|
+
}>;
|
|
407
|
+
/**
|
|
408
|
+
* Baseline value used when no targeting or allocation selects another variant.
|
|
409
|
+
*/
|
|
410
|
+
baseline: z.ZodMiniObject<{
|
|
411
|
+
/**
|
|
412
|
+
* Variant value for the inline variable.
|
|
413
|
+
*/
|
|
414
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
415
|
+
}, z.core.$strip>;
|
|
416
|
+
/**
|
|
417
|
+
* Additional variable variants for experimentation or personalization.
|
|
418
|
+
*/
|
|
419
|
+
variants: z.ZodMiniArray<z.ZodMiniObject<{
|
|
420
|
+
/**
|
|
421
|
+
* Variant value for the inline variable.
|
|
422
|
+
*/
|
|
423
|
+
value: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniBoolean<boolean>, z.ZodMiniNull, z.ZodMiniNumber<number>, z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>]>;
|
|
424
|
+
}, z.core.$strip>>;
|
|
425
|
+
}, z.core.$strip>], "type">>>>;
|
|
426
|
+
/**
|
|
427
|
+
* Controls whether the assignment should be sticky for a given user.
|
|
428
|
+
*
|
|
429
|
+
* @defaultValue false
|
|
430
|
+
*/
|
|
431
|
+
sticky: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniBoolean<boolean>>>;
|
|
432
|
+
}, z.core.$strip>;
|
|
433
|
+
/**
|
|
434
|
+
* TypeScript type inferred from {@link PersonalizationConfig}.
|
|
435
|
+
*/
|
|
436
|
+
export type PersonalizationConfig = z.infer<typeof PersonalizationConfig>;
|
|
437
|
+
//# sourceMappingURL=PersonalizationConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersonalizationConfig.d.ts","sourceRoot":"","sources":["../../src/contentful/PersonalizationConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAA;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;OAEG;;IAGH;;;;OAIG;;iBAEH,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE7E;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,uBAAuB,CAE9F;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB;IACpC;;;;;OAKG;;IAGH;;OAEG;;QA7CH;;WAEG;;QAGH;;;;WAIG;;;IAuCH;;OAEG;;QAlDH;;WAEG;;QAGH;;;;WAIG;;;iBA2CH,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uFH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;;;;;;IAGH;;OAEG;;QAnCH;;WAEG;;;IAoCH;;OAEG;;QAxCH;;WAEG;;;4BA2EyE,CAAA;AAE9E;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEzF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;IAChC;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;;QAzJH;;;;;WAKG;;QAGH;;WAEG;;YA7CH;;eAEG;;YAGH;;;;eAIG;;;QAuCH;;WAEG;;YAlDH;;eAEG;;YAGH;;;;eAIG;;;;QAuFH;;WAEG;;QAGH;;WAEG;;QAGH;;WAEG;;;;;;;QAGH;;WAEG;;YAnCH;;eAEG;;;QAoCH;;WAEG;;YAxCH;;eAEG;;;;IAuHH;;;;OAIG;;iBAEH,CAAA;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* Zod schema describing a single entry replacement variant.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Each variant is identified by an `id` and may be marked as `hidden`.
|
|
7
|
+
*/
|
|
8
|
+
export const EntryReplacementVariant = z.object({
|
|
9
|
+
/**
|
|
10
|
+
* Unique identifier for the variant.
|
|
11
|
+
*/
|
|
12
|
+
id: z.string(),
|
|
13
|
+
/**
|
|
14
|
+
* Indicates whether this variant is hidden from allocation/traffic.
|
|
15
|
+
*
|
|
16
|
+
* @defaultValue false
|
|
17
|
+
*/
|
|
18
|
+
hidden: z.prefault(z.boolean(), false),
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Type guard for {@link EntryReplacementVariant}.
|
|
22
|
+
*
|
|
23
|
+
* @param variant - Value to test.
|
|
24
|
+
* @returns `true` if `variant` conforms to {@link EntryReplacementVariant}, otherwise `false`.
|
|
25
|
+
*/
|
|
26
|
+
export function isEntryReplacementVariant(variant) {
|
|
27
|
+
return EntryReplacementVariant.safeParse(variant).success;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Zod schema describing an entry replacement personalization component.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* This component replaces a baseline entry with one of several variants.
|
|
34
|
+
*/
|
|
35
|
+
export const EntryReplacementComponent = z.object({
|
|
36
|
+
/**
|
|
37
|
+
* Discriminator for the component type.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* May be omitted, in which case the component is treated as an EntryReplacement.
|
|
41
|
+
*/
|
|
42
|
+
type: z.optional(z.literal('EntryReplacement')),
|
|
43
|
+
/**
|
|
44
|
+
* Baseline variant used when no targeting or allocation selects another variant.
|
|
45
|
+
*/
|
|
46
|
+
baseline: EntryReplacementVariant,
|
|
47
|
+
/**
|
|
48
|
+
* Additional variants that may be served.
|
|
49
|
+
*/
|
|
50
|
+
variants: z.array(EntryReplacementVariant),
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Type guard for {@link EntryReplacementComponent}.
|
|
54
|
+
*
|
|
55
|
+
* @param component - Personalization component to test.
|
|
56
|
+
* @returns `true` if the component is an EntryReplacement component, otherwise `false`.
|
|
57
|
+
*/
|
|
58
|
+
export function isEntryReplacementComponent(component) {
|
|
59
|
+
return component.type === 'EntryReplacement' || component.type === undefined;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Zod schema describing a variant for inline variables.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* The value may be a primitive or a JSON object.
|
|
66
|
+
*/
|
|
67
|
+
export const InlineVariableVariant = z.object({
|
|
68
|
+
/**
|
|
69
|
+
* Variant value for the inline variable.
|
|
70
|
+
*/
|
|
71
|
+
value: z.union([z.string(), z.boolean(), z.null(), z.number(), z.record(z.string(), z.json())]),
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Enumeration of supported inline variable value types.
|
|
75
|
+
*/
|
|
76
|
+
export const InlineVariableComponentValueType = z.enum(['Boolean', 'Number', 'Object', 'String']);
|
|
77
|
+
/**
|
|
78
|
+
* Zod schema describing an inline variable personalization component.
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* Used to vary scalar or object values in templates.
|
|
82
|
+
*/
|
|
83
|
+
export const InlineVariableComponent = z.object({
|
|
84
|
+
/**
|
|
85
|
+
* Discriminator for the inline variable component.
|
|
86
|
+
*/
|
|
87
|
+
type: z.literal('InlineVariable'),
|
|
88
|
+
/**
|
|
89
|
+
* Key under which this variable is exposed to the template.
|
|
90
|
+
*/
|
|
91
|
+
key: z.string(),
|
|
92
|
+
/**
|
|
93
|
+
* Describes the runtime type of the values for this variable.
|
|
94
|
+
*/
|
|
95
|
+
valueType: InlineVariableComponentValueType,
|
|
96
|
+
/**
|
|
97
|
+
* Baseline value used when no targeting or allocation selects another variant.
|
|
98
|
+
*/
|
|
99
|
+
baseline: InlineVariableVariant,
|
|
100
|
+
/**
|
|
101
|
+
* Additional variable variants for experimentation or personalization.
|
|
102
|
+
*/
|
|
103
|
+
variants: z.array(InlineVariableVariant),
|
|
104
|
+
});
|
|
105
|
+
/**
|
|
106
|
+
* Type guard for {@link InlineVariableComponent}.
|
|
107
|
+
*
|
|
108
|
+
* @param component - Personalization component to test.
|
|
109
|
+
* @returns `true` if the component is an InlineVariable component, otherwise `false`.
|
|
110
|
+
*/
|
|
111
|
+
export function isInlineVariableComponent(component) {
|
|
112
|
+
return component.type === 'InlineVariable';
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Discriminated union of all supported personalization components.
|
|
116
|
+
*/
|
|
117
|
+
export const PersonalizationComponent = z.discriminatedUnion('type', [
|
|
118
|
+
EntryReplacementComponent,
|
|
119
|
+
InlineVariableComponent,
|
|
120
|
+
]);
|
|
121
|
+
/**
|
|
122
|
+
* Zod schema representing an array of {@link PersonalizationComponent} items.
|
|
123
|
+
*/
|
|
124
|
+
export const PersonalizationComponentArray = z.array(PersonalizationComponent);
|
|
125
|
+
/**
|
|
126
|
+
* Zod schema describing the full configuration for a personalization.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* Provides distribution, traffic allocation, component definitions, and sticky behavior.
|
|
130
|
+
*/
|
|
131
|
+
export const PersonalizationConfig = z.object({
|
|
132
|
+
/**
|
|
133
|
+
* Variant distribution used for traffic allocation.
|
|
134
|
+
*
|
|
135
|
+
* @defaultValue [0.5, 0.5]
|
|
136
|
+
*/
|
|
137
|
+
distribution: z.optional(z.prefault(z.array(z.number()), [0.5, 0.5])),
|
|
138
|
+
/**
|
|
139
|
+
* Percentage of total traffic that should enter the personalization.
|
|
140
|
+
*
|
|
141
|
+
* @defaultValue 0
|
|
142
|
+
*/
|
|
143
|
+
traffic: z.optional(z.prefault(z.number(), 0)),
|
|
144
|
+
/**
|
|
145
|
+
* Personalization components that define how content is varied.
|
|
146
|
+
*
|
|
147
|
+
* @defaultValue
|
|
148
|
+
* A single {@link EntryReplacementComponent} with an empty `baseline` and `variants` ID.
|
|
149
|
+
*/
|
|
150
|
+
components: z.optional(z.prefault(PersonalizationComponentArray, [
|
|
151
|
+
{
|
|
152
|
+
type: 'EntryReplacement',
|
|
153
|
+
baseline: { id: '' },
|
|
154
|
+
variants: [{ id: '' }],
|
|
155
|
+
},
|
|
156
|
+
])),
|
|
157
|
+
/**
|
|
158
|
+
* Controls whether the assignment should be sticky for a given user.
|
|
159
|
+
*
|
|
160
|
+
* @defaultValue false
|
|
161
|
+
*/
|
|
162
|
+
sticky: z.optional(z.prefault(z.boolean(), false)),
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=PersonalizationConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PersonalizationConfig.js","source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