@contentchef/contentchef-types 11.0.0-alpha.5 → 11.0.0-alpha.6
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 +180 -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 +249 -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 +186 -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 +269 -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
|
*/
|
|
@@ -109,48 +162,25 @@ export type ListAudiencesRequest = {
|
|
|
109
162
|
};
|
|
110
163
|
|
|
111
164
|
/**
|
|
112
|
-
* This type represent the item of a list audiences API request
|
|
165
|
+
* This type represent the item of a list audiences API request: the audience with its rule read back
|
|
166
|
+
* in words, which is what a picker shows. No usage count, that is one query per audience and belongs
|
|
167
|
+
* to [[GetAudienceResponse]]
|
|
113
168
|
*/
|
|
114
|
-
export type ListAudiencesItem = AudienceResponse
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* This type represent the response of a list audiences API request
|
|
118
|
-
*/
|
|
119
|
-
export type ListAudiencesResponse = PagedListResponse<ListAudiencesItem>;
|
|
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 = {
|
|
169
|
+
export type ListAudiencesItem = AudienceResponse & {
|
|
126
170
|
/**
|
|
127
|
-
* The
|
|
128
|
-
* ones that only fire when the audience is unknown
|
|
171
|
+
* The rule in words, so it reads without decoding a predicate
|
|
129
172
|
*/
|
|
130
|
-
|
|
173
|
+
description: string;
|
|
131
174
|
/**
|
|
132
|
-
*
|
|
175
|
+
* The mnemonic ids of the dimensions the rule depends on
|
|
133
176
|
*/
|
|
134
|
-
|
|
177
|
+
dimensions: string[];
|
|
135
178
|
};
|
|
136
179
|
|
|
137
180
|
/**
|
|
138
|
-
* This type represent
|
|
181
|
+
* This type represent the response of a list audiences API request
|
|
139
182
|
*/
|
|
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
|
-
};
|
|
183
|
+
export type ListAudiencesResponse = PagedListResponse<ListAudiencesItem>;
|
|
154
184
|
|
|
155
185
|
/**
|
|
156
186
|
* This type represent the data needed to make a get audience API request
|
|
@@ -163,18 +193,20 @@ export type GetAudienceRequest = {
|
|
|
163
193
|
};
|
|
164
194
|
|
|
165
195
|
/**
|
|
166
|
-
* This type represent the response of a get audience API request: the audience, plus the
|
|
167
|
-
*
|
|
196
|
+
* This type represent the response of a get audience API request: the audience, plus what the editor
|
|
197
|
+
* cannot derive on its own - the rule in words, the dimensions it depends on, and how many contents
|
|
198
|
+
* reference it, which is exactly the guard archiving enforces
|
|
168
199
|
*/
|
|
169
|
-
export type GetAudienceResponse =
|
|
200
|
+
export type GetAudienceResponse = ListAudiencesItem & {
|
|
170
201
|
/**
|
|
171
|
-
*
|
|
202
|
+
* How much of the space depends on this audience
|
|
172
203
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
204
|
+
usage: {
|
|
205
|
+
/**
|
|
206
|
+
* How many contents reference this audience. Archiving is refused while this is not zero
|
|
207
|
+
*/
|
|
208
|
+
contents: number;
|
|
209
|
+
};
|
|
178
210
|
};
|
|
179
211
|
|
|
180
212
|
/**
|
|
@@ -186,13 +218,14 @@ export type CreateAudienceRequest = {
|
|
|
186
218
|
*/
|
|
187
219
|
name: string;
|
|
188
220
|
/**
|
|
189
|
-
* The audience mnemonic id, matching [[AUDIENCE_NAME_PATTERN]]
|
|
221
|
+
* The audience mnemonic id, matching [[AUDIENCE_NAME_PATTERN]]. It cannot be changed afterwards
|
|
190
222
|
*/
|
|
191
223
|
mnemonicId: string;
|
|
192
224
|
/**
|
|
193
|
-
* The
|
|
225
|
+
* The rule over dimensions. Every dimension it names has to exist in the space and not be
|
|
226
|
+
* archived, and every key has to exist on its dimension and not be deprecated
|
|
194
227
|
*/
|
|
195
|
-
|
|
228
|
+
rule: AudienceRule;
|
|
196
229
|
};
|
|
197
230
|
|
|
198
231
|
/**
|
|
@@ -203,9 +236,8 @@ export type CreateAudienceResponse = AudienceResponse;
|
|
|
203
236
|
/**
|
|
204
237
|
* This type represent the data needed to make an update audience API request
|
|
205
238
|
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
* references it. `mnemonicId` cannot be changed
|
|
239
|
+
* The rule may change freely even while contents reference the audience: the change reaching delivery
|
|
240
|
+
* on the next publish of any content that uses it is the point of naming an audience once
|
|
209
241
|
*/
|
|
210
242
|
export type UpdateAudienceRequest = {
|
|
211
243
|
/**
|
|
@@ -221,9 +253,9 @@ export type UpdateAudienceRequest = {
|
|
|
221
253
|
*/
|
|
222
254
|
mnemonicId: string;
|
|
223
255
|
/**
|
|
224
|
-
* The
|
|
256
|
+
* The rule, replacing what is stored
|
|
225
257
|
*/
|
|
226
|
-
|
|
258
|
+
rule: AudienceRule;
|
|
227
259
|
};
|
|
228
260
|
|
|
229
261
|
/**
|
|
@@ -240,7 +272,8 @@ export type ToggleArchivedAudienceRequest = {
|
|
|
240
272
|
*/
|
|
241
273
|
id: AudienceId;
|
|
242
274
|
/**
|
|
243
|
-
* This value represent the archive status to set in the specified audience
|
|
275
|
+
* This value represent the archive status to set in the specified audience. Archiving is refused
|
|
276
|
+
* with an `AudienceInUse` error while any content references the audience
|
|
244
277
|
*/
|
|
245
278
|
archived: boolean;
|
|
246
279
|
};
|
|
@@ -251,137 +284,74 @@ export type ToggleArchivedAudienceRequest = {
|
|
|
251
284
|
export type ToggleArchivedAudienceResponse = AudienceResponse;
|
|
252
285
|
|
|
253
286
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
287
|
+
* Thin enum represent all audience rule violations error codes, reported by the create and update
|
|
288
|
+
* audience API requests through the `violations` of an `InvalidAudienceRule` error
|
|
256
289
|
*/
|
|
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
|
-
};
|
|
290
|
+
export enum AudienceRuleViolationCodes {
|
|
291
|
+
ruleMissing = 'audienceRule.ruleMissing',
|
|
292
|
+
unknownShape = 'audienceRule.unknownShape',
|
|
293
|
+
groupIsNotAnArray = 'audienceRule.groupIsNotAnArray',
|
|
294
|
+
dimensionIsNotAString = 'audienceRule.dimensionIsNotAString',
|
|
295
|
+
inIsNotAnArray = 'audienceRule.inIsNotAnArray',
|
|
296
|
+
inIsEmpty = 'audienceRule.inIsEmpty',
|
|
297
|
+
keyIsNotAString = 'audienceRule.keyIsNotAString',
|
|
298
|
+
orUnsetIsNotABoolean = 'audienceRule.orUnsetIsNotABoolean',
|
|
299
|
+
dimensionNotFound = 'audienceRule.dimensionNotFound',
|
|
300
|
+
dimensionArchived = 'audienceRule.dimensionArchived',
|
|
301
|
+
dimensionKeyNotFound = 'audienceRule.dimensionKeyNotFound',
|
|
302
|
+
dimensionKeyDeprecated = 'audienceRule.dimensionKeyDeprecated'
|
|
303
|
+
}
|
|
275
304
|
|
|
276
305
|
/**
|
|
277
|
-
* This type represent
|
|
306
|
+
* This type represent one problem found in an audience rule, carrying the path of the offending node
|
|
278
307
|
*/
|
|
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> = {
|
|
308
|
+
export type AudienceRuleViolation = {
|
|
305
309
|
/**
|
|
306
|
-
* The
|
|
310
|
+
* The error code discriminator, one of [[AudienceRuleViolationCodes]]
|
|
307
311
|
*/
|
|
308
|
-
|
|
312
|
+
code: string;
|
|
309
313
|
/**
|
|
310
|
-
* The
|
|
314
|
+
* The path of the rejected node inside the rule, for instance `rule.all.0.in.1`
|
|
311
315
|
*/
|
|
312
|
-
|
|
316
|
+
path: string;
|
|
313
317
|
/**
|
|
314
|
-
* The
|
|
318
|
+
* The dimension the node names, when the violation is about one
|
|
315
319
|
*/
|
|
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> = {
|
|
328
|
-
/**
|
|
329
|
-
* The rules, in the order they are evaluated in
|
|
330
|
-
*/
|
|
331
|
-
rules?: PersonalizedRule<T>[];
|
|
320
|
+
dimension?: string;
|
|
332
321
|
/**
|
|
333
|
-
* The
|
|
322
|
+
* The key the node names, when the violation is about one
|
|
334
323
|
*/
|
|
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;
|
|
324
|
+
key?: string;
|
|
345
325
|
};
|
|
346
326
|
|
|
347
327
|
/**
|
|
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
|
|
328
|
+
* This type represent how much of an analysed audience list one audience actually serves
|
|
359
329
|
*/
|
|
360
330
|
export type RuleCoverage = {
|
|
361
331
|
/**
|
|
362
|
-
* The position of the
|
|
332
|
+
* The position of the audience in the analysed list
|
|
363
333
|
*/
|
|
364
334
|
index: number;
|
|
365
335
|
/**
|
|
366
|
-
* The
|
|
336
|
+
* The audience mnemonic id
|
|
367
337
|
*/
|
|
368
338
|
id?: string;
|
|
369
339
|
/**
|
|
370
|
-
* The
|
|
340
|
+
* The rule in words, so a finding reads without decoding a predicate
|
|
371
341
|
*/
|
|
372
342
|
condition: string;
|
|
373
343
|
/**
|
|
374
|
-
* How many of the analysed assignments this
|
|
344
|
+
* How many of the analysed assignments this audience wins. Zero means it can never serve anyone
|
|
375
345
|
*/
|
|
376
346
|
wins: number;
|
|
377
347
|
};
|
|
378
348
|
|
|
379
349
|
/**
|
|
380
|
-
* This type represent what an ordered
|
|
381
|
-
* keys alone - no request traffic is involved
|
|
350
|
+
* This type represent what an ordered list of audiences covers, worked out from their rules and the
|
|
351
|
+
* dimensions' keys alone - no request traffic is involved
|
|
382
352
|
*
|
|
383
353
|
* The findings are advisory and never validation violations: a gap is usually deliberate, that being
|
|
384
|
-
* what a fallback is for, while an unreachable
|
|
354
|
+
* what a fallback is for, while an unreachable audience is almost always a mistake
|
|
385
355
|
*/
|
|
386
356
|
export type CoverageReport = {
|
|
387
357
|
/**
|
|
@@ -389,78 +359,89 @@ export type CoverageReport = {
|
|
|
389
359
|
*/
|
|
390
360
|
combinations: number;
|
|
391
361
|
/**
|
|
392
|
-
* One entry per analysed
|
|
362
|
+
* One entry per analysed audience, in the order they were sent, its `id` being the mnemonic id. An
|
|
363
|
+
* audience the space does not have has no rule to analyse and contributes no entry, so this can be
|
|
364
|
+
* shorter than the request
|
|
393
365
|
*/
|
|
394
366
|
rules: RuleCoverage[];
|
|
395
367
|
/**
|
|
396
|
-
* The
|
|
368
|
+
* The audiences that win nothing: shadowed by an earlier one, or self-contradictory
|
|
397
369
|
*/
|
|
398
370
|
unreachableRules: RuleCoverage[];
|
|
399
371
|
/**
|
|
400
|
-
* The assignments no
|
|
372
|
+
* The assignments no audience claims, so they reach the fallback. Capped at 25 entries, while
|
|
401
373
|
* [[fallbackCount]] is the real total
|
|
402
374
|
*/
|
|
403
|
-
fallbackAssignments:
|
|
375
|
+
fallbackAssignments: DimensionAssignment[];
|
|
404
376
|
/**
|
|
405
377
|
* How many assignments reach the fallback, of [[combinations]]
|
|
406
378
|
*/
|
|
407
379
|
fallbackCount: number;
|
|
408
380
|
/**
|
|
409
|
-
*
|
|
410
|
-
*
|
|
381
|
+
* What [[OTHER_KEY]] stood for, per dimension: the real unmentioned keys, capped at 10, with their
|
|
382
|
+
* total. Only the dimensions that needed the stand-in appear
|
|
411
383
|
*/
|
|
412
|
-
|
|
384
|
+
otherKeys: { [dimension: string]: { keys: string[]; total: number } };
|
|
413
385
|
/**
|
|
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
|
|
386
|
+
* Set when the rules and their dimensions were too large to enumerate. Everything else is then
|
|
420
387
|
* unpopulated rather than guessed, because a sampled "no gaps" is not a fact
|
|
421
388
|
*/
|
|
422
389
|
notAnalysed?: { reason: 'tooManyCombinations'; combinations: number };
|
|
423
390
|
};
|
|
424
391
|
|
|
425
392
|
/**
|
|
426
|
-
* This type represent
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
393
|
+
* This type represent the data needed to make an analyse rules API request, which is what a
|
|
394
|
+
* personalized field's editor asks about the variants on screen, before anything is saved
|
|
395
|
+
*
|
|
396
|
+
* The rules and the dimensions' keys are read from the space, so a client sends the audiences and
|
|
397
|
+
* nothing else
|
|
430
398
|
*/
|
|
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;
|
|
399
|
+
export type AnalyseAudienceRulesRequest = {
|
|
437
400
|
/**
|
|
438
|
-
* The
|
|
401
|
+
* The audience mnemonic ids in the order the variants list them, at most 20. The order is the
|
|
402
|
+
* whole point: the first listed audience that matches wins, so one being unreachable is a
|
|
403
|
+
* consequence of what precedes it
|
|
439
404
|
*/
|
|
440
|
-
|
|
405
|
+
audiences: string[];
|
|
441
406
|
};
|
|
442
407
|
|
|
443
408
|
/**
|
|
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
|
|
409
|
+
* This type represent the response of an analyse rules API request
|
|
449
410
|
*/
|
|
450
|
-
export type
|
|
411
|
+
export type AnalyseAudienceRulesResponse = CoverageReport;
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* This type represent one variant of a personalized field: the audience served, and the value to
|
|
415
|
+
* serve it
|
|
416
|
+
* @template T The type of the served value, which conforms to the field's `variantType`
|
|
417
|
+
*/
|
|
418
|
+
export type PersonalizedVariant<T = any> = {
|
|
451
419
|
/**
|
|
452
|
-
* The mnemonic
|
|
453
|
-
* these, as the field's rules are
|
|
420
|
+
* The mnemonic id of the audience this variant serves
|
|
454
421
|
*/
|
|
455
|
-
|
|
422
|
+
audience: string;
|
|
456
423
|
/**
|
|
457
|
-
* The
|
|
458
|
-
* being unreachable is a consequence of what precedes it
|
|
424
|
+
* The value served when this variant wins
|
|
459
425
|
*/
|
|
460
|
-
|
|
426
|
+
value: T;
|
|
461
427
|
};
|
|
462
428
|
|
|
463
429
|
/**
|
|
464
|
-
* This type represent the
|
|
430
|
+
* This type represent the value a personalized field holds in a content payload: an ordered list of
|
|
431
|
+
* variants, the first whose audience matches the visitor wins, and the fallback served when none does
|
|
432
|
+
*
|
|
433
|
+
* The fallback is mandatory exactly when the field is required, which keeps the delivery contract of a
|
|
434
|
+
* personalized field the same as any other field. Zero variants is legal: the field is then just its
|
|
435
|
+
* fallback
|
|
436
|
+
* @template T The type of the served values, which conform to the field's `variantType`
|
|
465
437
|
*/
|
|
466
|
-
export type
|
|
438
|
+
export type PersonalizedFieldPayload<T = any> = {
|
|
439
|
+
/**
|
|
440
|
+
* The variants, in the order they are evaluated in
|
|
441
|
+
*/
|
|
442
|
+
variants?: PersonalizedVariant<T>[];
|
|
443
|
+
/**
|
|
444
|
+
* The value served when no variant's audience matches
|
|
445
|
+
*/
|
|
446
|
+
fallback?: T;
|
|
447
|
+
};
|
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
|
}
|