@contentchef/contentchef-types 11.0.0-alpha.5 → 11.0.0-alpha.7
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/Audience.d.ts +185 -196
- package/dist/api/Audience.js +21 -11
- package/dist/api/Content.d.ts +9 -12
- package/dist/api/Content.js +5 -8
- package/dist/api/ContentDefinition.d.ts +1 -19
- package/dist/api/ContentDefinition.js +1 -5
- package/dist/api/ContentDefinitionSchema.d.ts +6 -24
- package/dist/api/Dimension.d.ts +254 -0
- package/dist/api/Dimension.js +18 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/lib/api/Audience.ts +191 -205
- package/lib/api/Content.ts +9 -12
- package/lib/api/ContentDefinition.ts +1 -20
- package/lib/api/ContentDefinitionSchema.ts +6 -24
- package/lib/api/Dimension.ts +274 -0
- package/lib/api/index.ts +1 -0
- package/package.json +2 -2
package/lib/api/Audience.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthorResponse } from './Author';
|
|
2
2
|
import { PagedListResponse } from './common';
|
|
3
|
-
import {
|
|
3
|
+
import { DimensionAssignment } from './Dimension';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The audience unique id
|
|
@@ -8,34 +8,82 @@ import { ContentDefinitionId } from './ContentDefinition';
|
|
|
8
8
|
export type AudienceId = number;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* An audience's mnemonicId
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* An audience's mnemonicId must match this pattern, and is at least 2 characters long. Lowercase like
|
|
12
|
+
* a dimension's, and immutable once created: contents, CSV files, the publishing snapshot and delivery
|
|
13
|
+
* all reference an audience by it
|
|
14
14
|
*/
|
|
15
15
|
export const AUDIENCE_NAME_PATTERN = /^[a-z0-9_-]+$/;
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* This type represent
|
|
18
|
+
* This type represent the condition of an audience rule on a single dimension: the visitor's value for
|
|
19
|
+
* [[dimension]] has to be one of [[in]]
|
|
19
20
|
*/
|
|
20
|
-
export type
|
|
21
|
+
export type DimensionPredicate = {
|
|
21
22
|
/**
|
|
22
|
-
* The
|
|
23
|
+
* The mnemonic id of the dimension this predicate constrains
|
|
23
24
|
*/
|
|
24
|
-
|
|
25
|
+
dimension: string;
|
|
25
26
|
/**
|
|
26
|
-
*
|
|
27
|
-
* keeps resolving. The flag toggles both ways
|
|
27
|
+
* The keys of the dimension that satisfy this predicate, at least one
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
in: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Set this value to also satisfy the predicate when the dimension was not provided at all
|
|
32
|
+
*
|
|
33
|
+
* Not-provided is not a key, so no list of keys can express it, and an enumeration would silently
|
|
34
|
+
* narrow the moment a key is added to the dimension. A key that was provided but is not listed does
|
|
35
|
+
* not satisfy this flag: the audience simply does not match
|
|
36
|
+
*/
|
|
37
|
+
orUnset?: boolean;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This type represent a condition satisfied when every child condition is satisfied
|
|
42
|
+
*/
|
|
43
|
+
export type AllDimensionPredicate = {
|
|
44
|
+
all: AudienceRule[];
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This type represent a condition satisfied when at least one child condition is satisfied
|
|
49
|
+
*/
|
|
50
|
+
export type AnyDimensionPredicate = {
|
|
51
|
+
any: AudienceRule[];
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* This type represent the rule of an audience: or within a dimension, and between dimensions
|
|
56
|
+
*
|
|
57
|
+
* The stored form is a tree so that new kinds of condition stay additive, but an editor only needs to
|
|
58
|
+
* build an [[AllDimensionPredicate]] of one [[DimensionPredicate]] per dimension. A dimension the rule
|
|
59
|
+
* does not mention is unconstrained, which is a different thing from one listed with
|
|
60
|
+
* [[DimensionPredicate.orUnset]]. `{ all: [] }` matches everyone
|
|
61
|
+
*/
|
|
62
|
+
export type AudienceRule = DimensionPredicate | AllDimensionPredicate | AnyDimensionPredicate;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* This type represent one dimension key an audience rule references. `key` is absent for a rule that
|
|
66
|
+
* constrains the dimension without naming a key
|
|
67
|
+
*/
|
|
68
|
+
export type DimensionKeyReference = {
|
|
69
|
+
/**
|
|
70
|
+
* The dimension mnemonic id
|
|
71
|
+
*/
|
|
72
|
+
dimension: string;
|
|
73
|
+
/**
|
|
74
|
+
* The key, absent when the rule names none
|
|
75
|
+
*/
|
|
76
|
+
key?: string;
|
|
30
77
|
};
|
|
31
78
|
|
|
32
79
|
/**
|
|
33
|
-
* This type represent the model of an audience, that is a
|
|
34
|
-
*
|
|
80
|
+
* This type represent the model of an audience, that is a named rule over dimensions -
|
|
81
|
+
* "authenticated users with a silver card" - written once and referenced by mnemonicId from every
|
|
82
|
+
* content that wants it
|
|
35
83
|
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
84
|
+
* Nothing to evaluate lives in a content: a personalized field lists audiences, and the rules stay
|
|
85
|
+
* here. Audiences are archived and never deleted, and archiving is refused while a content still
|
|
86
|
+
* references one
|
|
39
87
|
*/
|
|
40
88
|
export type AudienceResponse = {
|
|
41
89
|
/**
|
|
@@ -51,9 +99,14 @@ export type AudienceResponse = {
|
|
|
51
99
|
*/
|
|
52
100
|
mnemonicId: string;
|
|
53
101
|
/**
|
|
54
|
-
* The
|
|
102
|
+
* The rule that decides whether a visitor belongs to this audience
|
|
103
|
+
*/
|
|
104
|
+
rule: AudienceRule;
|
|
105
|
+
/**
|
|
106
|
+
* The dimension keys the rule references, derived from it on every save. This is what makes a
|
|
107
|
+
* dimension key removable or not
|
|
55
108
|
*/
|
|
56
|
-
|
|
109
|
+
usedDimensionKeys: DimensionKeyReference[];
|
|
57
110
|
/**
|
|
58
111
|
* The archived status of the audience
|
|
59
112
|
*/
|
|
@@ -88,6 +141,11 @@ export type ListAudiencesFilters = {
|
|
|
88
141
|
* This filter is used to retrieve archived or not archived audiences. Defaults to not archived
|
|
89
142
|
*/
|
|
90
143
|
archived?: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* This filter is used to search audiences whose name or mnemonic id contain the value inserted,
|
|
146
|
+
* case insensitively. At most 100 characters
|
|
147
|
+
*/
|
|
148
|
+
name?: string;
|
|
91
149
|
};
|
|
92
150
|
|
|
93
151
|
/**
|
|
@@ -109,48 +167,25 @@ export type ListAudiencesRequest = {
|
|
|
109
167
|
};
|
|
110
168
|
|
|
111
169
|
/**
|
|
112
|
-
* This type represent the item of a list audiences API request
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* This type represent the response of a list audiences API request
|
|
170
|
+
* This type represent the item of a list audiences API request: the audience with its rule read back
|
|
171
|
+
* in words, which is what a picker shows. No usage count, that is one query per audience and belongs
|
|
172
|
+
* to [[GetAudienceResponse]]
|
|
118
173
|
*/
|
|
119
|
-
export type
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* This type represent the usage of one key of an audience. A key with no entry is used by no content,
|
|
123
|
-
* and is therefore the only kind of key that can be removed or renamed
|
|
124
|
-
*/
|
|
125
|
-
export type AudienceKeyUsage = {
|
|
174
|
+
export type ListAudiencesItem = AudienceResponse & {
|
|
126
175
|
/**
|
|
127
|
-
* The
|
|
128
|
-
* ones that only fire when the audience is unknown
|
|
176
|
+
* The rule in words, so it reads without decoding a predicate
|
|
129
177
|
*/
|
|
130
|
-
|
|
178
|
+
description: string;
|
|
131
179
|
/**
|
|
132
|
-
*
|
|
180
|
+
* The mnemonic ids of the dimensions the rule depends on
|
|
133
181
|
*/
|
|
134
|
-
|
|
182
|
+
dimensions: string[];
|
|
135
183
|
};
|
|
136
184
|
|
|
137
185
|
/**
|
|
138
|
-
* This type represent
|
|
186
|
+
* This type represent the response of a list audiences API request
|
|
139
187
|
*/
|
|
140
|
-
export type
|
|
141
|
-
/**
|
|
142
|
-
* The content definition unique id
|
|
143
|
-
*/
|
|
144
|
-
id: ContentDefinitionId;
|
|
145
|
-
/**
|
|
146
|
-
* The content definition mnemonic id
|
|
147
|
-
*/
|
|
148
|
-
mnemonicId: string;
|
|
149
|
-
/**
|
|
150
|
-
* The content definition name
|
|
151
|
-
*/
|
|
152
|
-
name: string;
|
|
153
|
-
};
|
|
188
|
+
export type ListAudiencesResponse = PagedListResponse<ListAudiencesItem>;
|
|
154
189
|
|
|
155
190
|
/**
|
|
156
191
|
* This type represent the data needed to make a get audience API request
|
|
@@ -163,18 +198,20 @@ export type GetAudienceRequest = {
|
|
|
163
198
|
};
|
|
164
199
|
|
|
165
200
|
/**
|
|
166
|
-
* This type represent the response of a get audience API request: the audience, plus the
|
|
167
|
-
*
|
|
201
|
+
* This type represent the response of a get audience API request: the audience, plus what the editor
|
|
202
|
+
* cannot derive on its own - the rule in words, the dimensions it depends on, and how many contents
|
|
203
|
+
* reference it, which is exactly the guard archiving enforces
|
|
168
204
|
*/
|
|
169
|
-
export type GetAudienceResponse =
|
|
170
|
-
/**
|
|
171
|
-
* One entry per key at least one content references. A key absent from this list is unused
|
|
172
|
-
*/
|
|
173
|
-
keyUsage: AudienceKeyUsage[];
|
|
205
|
+
export type GetAudienceResponse = ListAudiencesItem & {
|
|
174
206
|
/**
|
|
175
|
-
*
|
|
207
|
+
* How much of the space depends on this audience
|
|
176
208
|
*/
|
|
177
|
-
|
|
209
|
+
usage: {
|
|
210
|
+
/**
|
|
211
|
+
* How many contents reference this audience. Archiving is refused while this is not zero
|
|
212
|
+
*/
|
|
213
|
+
contents: number;
|
|
214
|
+
};
|
|
178
215
|
};
|
|
179
216
|
|
|
180
217
|
/**
|
|
@@ -186,13 +223,14 @@ export type CreateAudienceRequest = {
|
|
|
186
223
|
*/
|
|
187
224
|
name: string;
|
|
188
225
|
/**
|
|
189
|
-
* The audience mnemonic id, matching [[AUDIENCE_NAME_PATTERN]]
|
|
226
|
+
* The audience mnemonic id, matching [[AUDIENCE_NAME_PATTERN]]. It cannot be changed afterwards
|
|
190
227
|
*/
|
|
191
228
|
mnemonicId: string;
|
|
192
229
|
/**
|
|
193
|
-
* The
|
|
230
|
+
* The rule over dimensions. Every dimension it names has to exist in the space and not be
|
|
231
|
+
* archived, and every key has to exist on its dimension and not be deprecated
|
|
194
232
|
*/
|
|
195
|
-
|
|
233
|
+
rule: AudienceRule;
|
|
196
234
|
};
|
|
197
235
|
|
|
198
236
|
/**
|
|
@@ -203,9 +241,8 @@ export type CreateAudienceResponse = AudienceResponse;
|
|
|
203
241
|
/**
|
|
204
242
|
* This type represent the data needed to make an update audience API request
|
|
205
243
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* references it. `mnemonicId` cannot be changed
|
|
244
|
+
* The rule may change freely even while contents reference the audience: the change reaching delivery
|
|
245
|
+
* on the next publish of any content that uses it is the point of naming an audience once
|
|
209
246
|
*/
|
|
210
247
|
export type UpdateAudienceRequest = {
|
|
211
248
|
/**
|
|
@@ -221,9 +258,9 @@ export type UpdateAudienceRequest = {
|
|
|
221
258
|
*/
|
|
222
259
|
mnemonicId: string;
|
|
223
260
|
/**
|
|
224
|
-
* The
|
|
261
|
+
* The rule, replacing what is stored
|
|
225
262
|
*/
|
|
226
|
-
|
|
263
|
+
rule: AudienceRule;
|
|
227
264
|
};
|
|
228
265
|
|
|
229
266
|
/**
|
|
@@ -240,7 +277,8 @@ export type ToggleArchivedAudienceRequest = {
|
|
|
240
277
|
*/
|
|
241
278
|
id: AudienceId;
|
|
242
279
|
/**
|
|
243
|
-
* This value represent the archive status to set in the specified audience
|
|
280
|
+
* This value represent the archive status to set in the specified audience. Archiving is refused
|
|
281
|
+
* with an `AudienceInUse` error while any content references the audience
|
|
244
282
|
*/
|
|
245
283
|
archived: boolean;
|
|
246
284
|
};
|
|
@@ -251,137 +289,74 @@ export type ToggleArchivedAudienceRequest = {
|
|
|
251
289
|
export type ToggleArchivedAudienceResponse = AudienceResponse;
|
|
252
290
|
|
|
253
291
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
292
|
+
* Thin enum represent all audience rule violations error codes, reported by the create and update
|
|
293
|
+
* audience API requests through the `violations` of an `InvalidAudienceRule` error
|
|
256
294
|
*/
|
|
257
|
-
export
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* not satisfy this flag: it falls through to the field's fallback
|
|
272
|
-
*/
|
|
273
|
-
orUnset?: boolean;
|
|
274
|
-
};
|
|
295
|
+
export enum AudienceRuleViolationCodes {
|
|
296
|
+
ruleMissing = 'audienceRule.ruleMissing',
|
|
297
|
+
unknownShape = 'audienceRule.unknownShape',
|
|
298
|
+
groupIsNotAnArray = 'audienceRule.groupIsNotAnArray',
|
|
299
|
+
dimensionIsNotAString = 'audienceRule.dimensionIsNotAString',
|
|
300
|
+
inIsNotAnArray = 'audienceRule.inIsNotAnArray',
|
|
301
|
+
inIsEmpty = 'audienceRule.inIsEmpty',
|
|
302
|
+
keyIsNotAString = 'audienceRule.keyIsNotAString',
|
|
303
|
+
orUnsetIsNotABoolean = 'audienceRule.orUnsetIsNotABoolean',
|
|
304
|
+
dimensionNotFound = 'audienceRule.dimensionNotFound',
|
|
305
|
+
dimensionArchived = 'audienceRule.dimensionArchived',
|
|
306
|
+
dimensionKeyNotFound = 'audienceRule.dimensionKeyNotFound',
|
|
307
|
+
dimensionKeyDeprecated = 'audienceRule.dimensionKeyDeprecated'
|
|
308
|
+
}
|
|
275
309
|
|
|
276
310
|
/**
|
|
277
|
-
* This type represent
|
|
311
|
+
* This type represent one problem found in an audience rule, carrying the path of the offending node
|
|
278
312
|
*/
|
|
279
|
-
export type
|
|
280
|
-
all: AudienceRuleCondition[];
|
|
281
|
-
};
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* This type represent a condition satisfied when at least one child condition is satisfied
|
|
285
|
-
*/
|
|
286
|
-
export type AnyAudiencePredicate = {
|
|
287
|
-
any: AudienceRuleCondition[];
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* This type represent the condition of a rule
|
|
292
|
-
*
|
|
293
|
-
* The stored form is a tree so that new kinds of condition stay additive, but an editor only needs to
|
|
294
|
-
* build an [[AllAudiencePredicate]] of one [[AudiencePredicate]] per audience: or within an audience, and
|
|
295
|
-
* between audiences. An audience the condition does not mention is unconstrained, which is a different
|
|
296
|
-
* thing from one listed with [[AudiencePredicate.orUnset]]
|
|
297
|
-
*/
|
|
298
|
-
export type AudienceRuleCondition = AudiencePredicate | AllAudiencePredicate | AnyAudiencePredicate;
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* This type represent one rule of a personalized field: the condition, and the value to serve when it wins
|
|
302
|
-
* @template T The type of the value served by the rule, which conforms to the field's `variantType`
|
|
303
|
-
*/
|
|
304
|
-
export type PersonalizedRule<T = any> = {
|
|
305
|
-
/**
|
|
306
|
-
* The rule id, unique in the field. Used for diagnostics only, matching never reads it
|
|
307
|
-
*/
|
|
308
|
-
id?: string;
|
|
313
|
+
export type AudienceRuleViolation = {
|
|
309
314
|
/**
|
|
310
|
-
* The
|
|
315
|
+
* The error code discriminator, one of [[AudienceRuleViolationCodes]]
|
|
311
316
|
*/
|
|
312
|
-
|
|
317
|
+
code: string;
|
|
313
318
|
/**
|
|
314
|
-
* The
|
|
319
|
+
* The path of the rejected node inside the rule, for instance `rule.all.0.in.1`
|
|
315
320
|
*/
|
|
316
|
-
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* This type represent the value a personalized field holds in a content payload: an ordered list of
|
|
321
|
-
* rules, first match wins, and the fallback served when no rule matches
|
|
322
|
-
*
|
|
323
|
-
* The fallback is mandatory exactly when the field is required, which keeps the delivery contract of a
|
|
324
|
-
* personalized field the same as any other field. Zero rules is legal: the field is then just its fallback
|
|
325
|
-
* @template T The type of the served values, which conform to the field's `variantType`
|
|
326
|
-
*/
|
|
327
|
-
export type PersonalizedFieldPayload<T = any> = {
|
|
321
|
+
path: string;
|
|
328
322
|
/**
|
|
329
|
-
* The
|
|
323
|
+
* The dimension the node names, when the violation is about one
|
|
330
324
|
*/
|
|
331
|
-
|
|
325
|
+
dimension?: string;
|
|
332
326
|
/**
|
|
333
|
-
* The
|
|
327
|
+
* The key the node names, when the violation is about one
|
|
334
328
|
*/
|
|
335
|
-
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
/**
|
|
339
|
-
* This type represent the visitor's value per audience, as the rule engine reads it. An audience missing
|
|
340
|
-
* from the map, or set to `undefined`, means "not provided" - which is what
|
|
341
|
-
* [[AudiencePredicate.orUnset]] answers
|
|
342
|
-
*/
|
|
343
|
-
export type AudienceAssignment = {
|
|
344
|
-
[audienceMnemonicId: string]: string | undefined;
|
|
329
|
+
key?: string;
|
|
345
330
|
};
|
|
346
331
|
|
|
347
332
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* Not a real key - it cannot be one, since keys match [[AUDIENCE_NAME_PATTERN]]. A rule only ever tests
|
|
351
|
-
* membership in its own list, so every unmentioned key behaves identically and one case covers them
|
|
352
|
-
* all, which is what keeps the analysis exact and small. [[CoverageReport.otherKeys]] says which real
|
|
353
|
-
* keys it stood for
|
|
354
|
-
*/
|
|
355
|
-
export const OTHER_KEY = '<any other key>';
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* This type represent how much of a rule list one rule actually serves
|
|
333
|
+
* This type represent how much of an analysed audience list one audience actually serves
|
|
359
334
|
*/
|
|
360
335
|
export type RuleCoverage = {
|
|
361
336
|
/**
|
|
362
|
-
* The position of the
|
|
337
|
+
* The position of the audience in the analysed list
|
|
363
338
|
*/
|
|
364
339
|
index: number;
|
|
365
340
|
/**
|
|
366
|
-
* The
|
|
341
|
+
* The audience mnemonic id
|
|
367
342
|
*/
|
|
368
343
|
id?: string;
|
|
369
344
|
/**
|
|
370
|
-
* The
|
|
345
|
+
* The rule in words, so a finding reads without decoding a predicate
|
|
371
346
|
*/
|
|
372
347
|
condition: string;
|
|
373
348
|
/**
|
|
374
|
-
* How many of the analysed assignments this
|
|
349
|
+
* How many of the analysed assignments this audience wins. Zero means it can never serve anyone
|
|
375
350
|
*/
|
|
376
351
|
wins: number;
|
|
377
352
|
};
|
|
378
353
|
|
|
379
354
|
/**
|
|
380
|
-
* This type represent what an ordered
|
|
381
|
-
* keys alone - no request traffic is involved
|
|
355
|
+
* This type represent what an ordered list of audiences covers, worked out from their rules and the
|
|
356
|
+
* dimensions' keys alone - no request traffic is involved
|
|
382
357
|
*
|
|
383
358
|
* The findings are advisory and never validation violations: a gap is usually deliberate, that being
|
|
384
|
-
* what a fallback is for, while an unreachable
|
|
359
|
+
* what a fallback is for, while an unreachable audience is almost always a mistake
|
|
385
360
|
*/
|
|
386
361
|
export type CoverageReport = {
|
|
387
362
|
/**
|
|
@@ -389,78 +364,89 @@ export type CoverageReport = {
|
|
|
389
364
|
*/
|
|
390
365
|
combinations: number;
|
|
391
366
|
/**
|
|
392
|
-
* One entry per analysed
|
|
367
|
+
* One entry per analysed audience, in the order they were sent, its `id` being the mnemonic id. An
|
|
368
|
+
* audience the space does not have has no rule to analyse and contributes no entry, so this can be
|
|
369
|
+
* shorter than the request
|
|
393
370
|
*/
|
|
394
371
|
rules: RuleCoverage[];
|
|
395
372
|
/**
|
|
396
|
-
* The
|
|
373
|
+
* The audiences that win nothing: shadowed by an earlier one, or self-contradictory
|
|
397
374
|
*/
|
|
398
375
|
unreachableRules: RuleCoverage[];
|
|
399
376
|
/**
|
|
400
|
-
* The assignments no
|
|
377
|
+
* The assignments no audience claims, so they reach the fallback. Capped at 25 entries, while
|
|
401
378
|
* [[fallbackCount]] is the real total
|
|
402
379
|
*/
|
|
403
|
-
fallbackAssignments:
|
|
380
|
+
fallbackAssignments: DimensionAssignment[];
|
|
404
381
|
/**
|
|
405
382
|
* How many assignments reach the fallback, of [[combinations]]
|
|
406
383
|
*/
|
|
407
384
|
fallbackCount: number;
|
|
408
385
|
/**
|
|
409
|
-
*
|
|
410
|
-
*
|
|
386
|
+
* What [[OTHER_KEY]] stood for, per dimension: the real unmentioned keys, capped at 10, with their
|
|
387
|
+
* total. Only the dimensions that needed the stand-in appear
|
|
411
388
|
*/
|
|
412
|
-
|
|
389
|
+
otherKeys: { [dimension: string]: { keys: string[]; total: number } };
|
|
413
390
|
/**
|
|
414
|
-
*
|
|
415
|
-
* total. Only the audiences that needed the stand-in appear
|
|
416
|
-
*/
|
|
417
|
-
otherKeys: { [audience: string]: { keys: string[]; total: number } };
|
|
418
|
-
/**
|
|
419
|
-
* Set when the rules and their audiences were too large to enumerate. Everything else is then
|
|
391
|
+
* Set when the rules and their dimensions were too large to enumerate. Everything else is then
|
|
420
392
|
* unpopulated rather than guessed, because a sampled "no gaps" is not a fact
|
|
421
393
|
*/
|
|
422
394
|
notAnalysed?: { reason: 'tooManyCombinations'; combinations: number };
|
|
423
395
|
};
|
|
424
396
|
|
|
425
397
|
/**
|
|
426
|
-
* This type represent
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
398
|
+
* This type represent the data needed to make an analyse rules API request, which is what a
|
|
399
|
+
* personalized field's editor asks about the variants on screen, before anything is saved
|
|
400
|
+
*
|
|
401
|
+
* The rules and the dimensions' keys are read from the space, so a client sends the audiences and
|
|
402
|
+
* nothing else
|
|
430
403
|
*/
|
|
431
|
-
export type
|
|
432
|
-
/**
|
|
433
|
-
* The rule id, when it carries one. Reported back on the finding, so a client can match a finding
|
|
434
|
-
* to the rule on screen without relying on the index
|
|
435
|
-
*/
|
|
436
|
-
id?: string;
|
|
404
|
+
export type AnalyseAudienceRulesRequest = {
|
|
437
405
|
/**
|
|
438
|
-
* The
|
|
406
|
+
* The audience mnemonic ids in the order the variants list them, at most 20. The order is the
|
|
407
|
+
* whole point: the first listed audience that matches wins, so one being unreachable is a
|
|
408
|
+
* consequence of what precedes it
|
|
439
409
|
*/
|
|
440
|
-
|
|
410
|
+
audiences: string[];
|
|
441
411
|
};
|
|
442
412
|
|
|
443
413
|
/**
|
|
444
|
-
* This type represent the
|
|
445
|
-
* rule editor asks about the rules on screen, before anything is saved
|
|
446
|
-
*
|
|
447
|
-
* The keys of every audience are read from the space rather than taken from the request, so a client
|
|
448
|
-
* never has to hold them or keep them current
|
|
414
|
+
* This type represent the response of an analyse rules API request
|
|
449
415
|
*/
|
|
450
|
-
export type
|
|
416
|
+
export type AnalyseAudienceRulesResponse = CoverageReport;
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* This type represent one variant of a personalized field: the audience served, and the value to
|
|
420
|
+
* serve it
|
|
421
|
+
* @template T The type of the served value, which conforms to the field's `variantType`
|
|
422
|
+
*/
|
|
423
|
+
export type PersonalizedVariant<T = any> = {
|
|
451
424
|
/**
|
|
452
|
-
* The mnemonic
|
|
453
|
-
* these, as the field's rules are
|
|
425
|
+
* The mnemonic id of the audience this variant serves
|
|
454
426
|
*/
|
|
455
|
-
|
|
427
|
+
audience: string;
|
|
456
428
|
/**
|
|
457
|
-
* The
|
|
458
|
-
* being unreachable is a consequence of what precedes it
|
|
429
|
+
* The value served when this variant wins
|
|
459
430
|
*/
|
|
460
|
-
|
|
431
|
+
value: T;
|
|
461
432
|
};
|
|
462
433
|
|
|
463
434
|
/**
|
|
464
|
-
* This type represent the
|
|
435
|
+
* This type represent the value a personalized field holds in a content payload: an ordered list of
|
|
436
|
+
* variants, the first whose audience matches the visitor wins, and the fallback served when none does
|
|
437
|
+
*
|
|
438
|
+
* The fallback is mandatory exactly when the field is required, which keeps the delivery contract of a
|
|
439
|
+
* personalized field the same as any other field. Zero variants is legal: the field is then just its
|
|
440
|
+
* fallback
|
|
441
|
+
* @template T The type of the served values, which conform to the field's `variantType`
|
|
465
442
|
*/
|
|
466
|
-
export type
|
|
443
|
+
export type PersonalizedFieldPayload<T = any> = {
|
|
444
|
+
/**
|
|
445
|
+
* The variants, in the order they are evaluated in
|
|
446
|
+
*/
|
|
447
|
+
variants?: PersonalizedVariant<T>[];
|
|
448
|
+
/**
|
|
449
|
+
* The value served when no variant's audience matches
|
|
450
|
+
*/
|
|
451
|
+
fallback?: T;
|
|
452
|
+
};
|
package/lib/api/Content.ts
CHANGED
|
@@ -404,9 +404,8 @@ export type ListContentsFilters = {
|
|
|
404
404
|
translationStatus?: ContentTranslationStatus;
|
|
405
405
|
|
|
406
406
|
/**
|
|
407
|
-
* This filter is used to search contents whose personalized fields have
|
|
408
|
-
*
|
|
409
|
-
* uses it with, and several tokens narrow the result like `tags` do
|
|
407
|
+
* This filter is used to search contents whose personalized fields have a variant serving one of the
|
|
408
|
+
* audience mnemonic ids inserted. Several of them narrow the result like `tags` do
|
|
410
409
|
*/
|
|
411
410
|
audiences?: string[];
|
|
412
411
|
};
|
|
@@ -847,16 +846,13 @@ export enum ContentFieldViolationCodes {
|
|
|
847
846
|
textFieldValueIsNotAString = "textField.valueIsNotAString",
|
|
848
847
|
textFieldBlankValueNotAllowed = "textField.blankValueNotAllowed",
|
|
849
848
|
personalizedFieldValueIsNotPersonalized = "personalizedField.valueIsNotPersonalized",
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
personalizedFieldDuplicateRuleId = "personalizedField.duplicateRuleId",
|
|
854
|
-
personalizedFieldAudienceNotDeclared = "personalizedField.audienceNotDeclared",
|
|
855
|
-
personalizedFieldFallbackRequired = "personalizedField.fallbackRequired",
|
|
849
|
+
personalizedFieldVariantsIsNotAnArray = "personalizedField.variantsIsNotAnArray",
|
|
850
|
+
personalizedFieldVariantIsNotAnObject = "personalizedField.variantIsNotAnObject",
|
|
851
|
+
personalizedFieldAudienceMissing = "personalizedField.audienceMissing",
|
|
856
852
|
personalizedFieldAudienceNotFound = "personalizedField.audienceNotFound",
|
|
857
853
|
personalizedFieldAudienceArchived = "personalizedField.audienceArchived",
|
|
858
|
-
|
|
859
|
-
|
|
854
|
+
personalizedFieldDuplicateAudience = "personalizedField.duplicateAudience",
|
|
855
|
+
personalizedFieldFallbackRequired = "personalizedField.fallbackRequired",
|
|
860
856
|
}
|
|
861
857
|
|
|
862
858
|
/**
|
|
@@ -913,7 +909,8 @@ export type AnalysePersonalizedRulesRequest = {
|
|
|
913
909
|
};
|
|
914
910
|
|
|
915
911
|
/**
|
|
916
|
-
* This type represent the coverage of one personalized field of a content
|
|
912
|
+
* This type represent the coverage of one personalized field of a content, that is what the audiences
|
|
913
|
+
* of its variants cover
|
|
917
914
|
*/
|
|
918
915
|
export type PersonalizedFieldCoverage = CoverageReport & {
|
|
919
916
|
/**
|
|
@@ -189,12 +189,6 @@ export type ContentDefinitionResponse = {
|
|
|
189
189
|
* Valued with paths to each array or null if definition is legacy
|
|
190
190
|
*/
|
|
191
191
|
trackableArrayFields?: ArrayField[] | null;
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* The mnemonic ids of the audiences this definition's personalized fields vary by
|
|
195
|
-
* Derived from the schema on every save, never assigned by the client
|
|
196
|
-
*/
|
|
197
|
-
audiences?: string[];
|
|
198
192
|
};
|
|
199
193
|
|
|
200
194
|
/**
|
|
@@ -287,15 +281,6 @@ export type ContentDefinitionSchemaErrors = {
|
|
|
287
281
|
* This attribute represents an error if the language of the schema is not a valid string
|
|
288
282
|
*/
|
|
289
283
|
lang?: string;
|
|
290
|
-
/**
|
|
291
|
-
* This attribute represents all the error that occurs inside the audiences declaration of the
|
|
292
|
-
* definition schema object
|
|
293
|
-
*
|
|
294
|
-
* - The value is a string if the audiences value is not in the expected format
|
|
295
|
-
* - The value is a list of AttributeViolation, one per declared audience that does not exist in the
|
|
296
|
-
* space or is archived
|
|
297
|
-
*/
|
|
298
|
-
audiences?: string | AttributeViolation[];
|
|
299
284
|
};
|
|
300
285
|
|
|
301
286
|
/**
|
|
@@ -431,9 +416,5 @@ export enum SchemaFieldViolationCodes {
|
|
|
431
416
|
translatableNotAllowed = 'translatableNotAllowed',
|
|
432
417
|
invalidEnumValue = 'invalidEnumValue',
|
|
433
418
|
compactCannotBeNested = 'compactCannotBeNested',
|
|
434
|
-
|
|
435
|
-
audienceNameNotFound = 'audienceNameNotFound',
|
|
436
|
-
audienceArchived = 'audienceArchived',
|
|
437
|
-
audienceNotDeclaredByDefinition = 'audienceNotDeclaredByDefinition',
|
|
438
|
-
duplicateAudienceName = 'duplicateAudienceName'
|
|
419
|
+
variantTypeNotAllowed = 'variantTypeNotAllowed'
|
|
439
420
|
}
|