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