@contentchef/contentchef-types 11.0.0-alpha.3 → 11.0.0-alpha.5

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.
@@ -191,10 +191,10 @@ export type ContentDefinitionResponse = {
191
191
  trackableArrayFields?: ArrayField[] | null;
192
192
 
193
193
  /**
194
- * The mnemonic ids of the segments this definition's segmented fields vary by
194
+ * The mnemonic ids of the audiences this definition's personalized fields vary by
195
195
  * Derived from the schema on every save, never assigned by the client
196
196
  */
197
- segments?: string[];
197
+ audiences?: string[];
198
198
  };
199
199
 
200
200
  /**
@@ -288,14 +288,14 @@ export type ContentDefinitionSchemaErrors = {
288
288
  */
289
289
  lang?: string;
290
290
  /**
291
- * This attribute represents all the error that occurs inside the segments declaration of the
291
+ * This attribute represents all the error that occurs inside the audiences declaration of the
292
292
  * definition schema object
293
293
  *
294
- * - The value is a string if the segments value is not in the expected format
295
- * - The value is a list of AttributeViolation, one per declared segment that does not exist in the
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
296
  * space or is archived
297
297
  */
298
- segments?: string | AttributeViolation[];
298
+ audiences?: string | AttributeViolation[];
299
299
  };
300
300
 
301
301
  /**
@@ -431,9 +431,9 @@ export enum SchemaFieldViolationCodes {
431
431
  translatableNotAllowed = 'translatableNotAllowed',
432
432
  invalidEnumValue = 'invalidEnumValue',
433
433
  compactCannotBeNested = 'compactCannotBeNested',
434
- segmentTypeNotAllowed = 'segmentTypeNotAllowed',
435
- segmentNameNotFound = 'segmentNameNotFound',
436
- segmentArchived = 'segmentArchived',
437
- segmentNotDeclaredByDefinition = 'segmentNotDeclaredByDefinition',
438
- duplicateSegmentName = 'duplicateSegmentName'
434
+ audienceTypeNotAllowed = 'audienceTypeNotAllowed',
435
+ audienceNameNotFound = 'audienceNameNotFound',
436
+ audienceArchived = 'audienceArchived',
437
+ audienceNotDeclaredByDefinition = 'audienceNotDeclaredByDefinition',
438
+ duplicateAudienceName = 'duplicateAudienceName'
439
439
  }
@@ -21,7 +21,7 @@ export enum SchemaTypeIds {
21
21
  ARRAY = 'array',
22
22
  SLUG = 'slug',
23
23
  MEDIA = 'media',
24
- SEGMENTED = 'segmented',
24
+ PERSONALIZED = 'personalized',
25
25
  }
26
26
 
27
27
  /**
@@ -52,13 +52,13 @@ export type ContentDefinitionSchema = {
52
52
  */
53
53
  fragments: FragmentsTable;
54
54
  /**
55
- * The segments this definition depends on, chosen by the author. Every one has to exist in the
56
- * space and not be archived, and a segmented field may only vary by segments named here, so this
55
+ * The audiences this definition depends on, chosen by the author. Every one has to exist in the
56
+ * space and not be archived, and a personalized field may only vary by audiences named here, so this
57
57
  * is what scopes a definition and gives the field editor a short list to offer
58
58
  *
59
- * Optional: a definition that declares none simply cannot hold a segmented field
59
+ * Optional: a definition that declares none simply cannot hold a personalized field
60
60
  */
61
- segments?: string[];
61
+ audiences?: string[];
62
62
  };
63
63
 
64
64
  /**
@@ -329,39 +329,39 @@ export type OneLinkedContentOfConstraints = {
329
329
  };
330
330
 
331
331
  /**
332
- * This type represent what every value of a segmented field holds: one descriptor for the whole field,
332
+ * This type represent what every value of a personalized field holds: one descriptor for the whole field,
333
333
  * so the rules and the fallback cannot differ in type
334
334
  *
335
335
  * Only the two `one...Of` forms are admitted: `fragment` and `linked-content` are each the
336
336
  * single-target special case of one of them, carrying an identical payload value
337
337
  */
338
- export type SegmentVariantType =
338
+ export type PersonalizedVariantType =
339
339
  | { type: SchemaTypeIds.ONE_FRAGMENT_OF; constraints: OneFragmentOfConstraints; }
340
340
  | { type: SchemaTypeIds.ONE_LINKED_CONTENT_OF; constraints: OneLinkedContentOfConstraints; };
341
341
 
342
342
  /**
343
- * This type represent the model of a segmented field constraints
343
+ * This type represent the model of a personalized field constraints
344
344
  *
345
- * A segmented field declares only *what varies* and *what shape the values have*. Which conditions
345
+ * A personalized field declares only *what varies* and *what shape the values have*. Which conditions
346
346
  * exist and what each of them serves is authored per content, as an ordered list of rules plus a
347
- * fallback - see [[SegmentedFieldPayload]] - so no combination has to be pre-declared here and two
347
+ * fallback - see [[PersonalizedFieldPayload]] - so no combination has to be pre-declared here and two
348
348
  * contents of the same definition may carry entirely different rule sets
349
349
  */
350
- export type SegmentedFieldConstraints = {
350
+ export type PersonalizedFieldConstraints = {
351
351
  /**
352
- * The mnemonic ids of the segments this field varies by, which must be among the ones the
353
- * definition declares in [[ContentDefinitionSchema.segments]]. Only the declaration is checked
354
- * against the space, so a segment that does not exist is one error on the definition rather than
352
+ * The mnemonic ids of the audiences this field varies by, which must be among the ones the
353
+ * definition declares in [[ContentDefinitionSchema.audiences]]. Only the declaration is checked
354
+ * against the space, so an audience that does not exist is one error on the definition rather than
355
355
  * one on every field that reached for it
356
356
  *
357
357
  * Declaration order carries no meaning: a rule wins by being first in the content, not by which
358
- * segment it constrains
358
+ * audience it constrains
359
359
  */
360
- segments: string[];
360
+ audiences: string[];
361
361
  /**
362
362
  * The shape every rule value and the fallback conform to
363
363
  */
364
- variantType: SegmentVariantType;
364
+ variantType: PersonalizedVariantType;
365
365
  };
366
366
 
367
367
  /**
@@ -529,9 +529,9 @@ export type OneFragmentOfSchemaType = SchemaType<SchemaTypeIds.ONE_FRAGMENT_OF,
529
529
  export type OneLinkedContentOfSchemaType = IndexableSchemaType<SchemaTypeIds.ONE_LINKED_CONTENT_OF, OneLinkedContentOfConstraints>;
530
530
 
531
531
  /**
532
- * This type represent a segmented field schema type
532
+ * This type represent a personalized field schema type
533
533
  */
534
- export type SegmentedSchemaType = SchemaType<SchemaTypeIds.SEGMENTED, SegmentedFieldConstraints>;
534
+ export type PersonalizedSchemaType = SchemaType<SchemaTypeIds.PERSONALIZED, PersonalizedFieldConstraints>;
535
535
 
536
536
  /**
537
537
  * Slug schema type
@@ -565,7 +565,7 @@ export type TranslatableSchemaTypes = NumberSchemaType | TextSchemaType | LongTe
565
565
  /**
566
566
  * This type group all the schema types of a content definition that are not indexable
567
567
  */
568
- export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType | SegmentedSchemaType;
568
+ export type PlainSchemaTypes = DateSchemaType | FragmentSchemaType | OneFragmentOfSchemaType | SlugSchemaType | PersonalizedSchemaType;
569
569
 
570
570
  /**
571
571
  * This type group all schema types of a content definition
package/lib/api/index.ts CHANGED
@@ -12,7 +12,7 @@ export * from './Invites';
12
12
  export * from './MediaGallery';
13
13
  export * from './PublishedContent';
14
14
  export * from './PublishingRequest';
15
- export * from './Segment';
15
+ export * from './Audience';
16
16
  export * from './Space';
17
17
  export * from './Subscription';
18
18
  export * from './UnpublishRequest';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentchef/contentchef-types",
3
- "version": "11.0.0-alpha.3",
3
+ "version": "11.0.0-alpha.5",
4
4
  "description": "ContentChef types",
5
5
  "author": "PierpaoloIannone <piannone@byte-code.com>",
6
6
  "homepage": "https://github.com/ContentChef/contentchef-management-js-client#readme",
@@ -34,5 +34,5 @@
34
34
  "devDependencies": {
35
35
  "typescript": "^5.9.3"
36
36
  },
37
- "gitHead": "778b33af62f27ed0f992fc1d50025f2cf8c90836"
37
+ "gitHead": "9aec2cdbb2d04b788dec73666e71eb36f867944a"
38
38
  }
@@ -1,312 +0,0 @@
1
- import { AuthorResponse } from './Author';
2
- import { PagedListResponse } from './common';
3
- import { ContentDefinitionId } from './ContentDefinition';
4
- /**
5
- * The segment unique id
6
- */
7
- export type SegmentId = number;
8
- /**
9
- * A segment's mnemonicId and every one of its keys must match this pattern: lowercase, digits,
10
- * underscore and hyphen. Stricter than the other authoring mnemonicIds on purpose, because both halves
11
- * travel in the delivery `segments` query param and are compared against strings a client supplies
12
- */
13
- export declare const SEGMENT_NAME_PATTERN: RegExp;
14
- /**
15
- * This type represent one key of a segment, that is one of the values a visitor can have for it
16
- */
17
- export type SegmentKey = {
18
- /**
19
- * The key, matching [[SEGMENT_NAME_PATTERN]]
20
- */
21
- key: string;
22
- /**
23
- * A deprecated key cannot be referenced by new content rules, while every rule already written
24
- * keeps resolving. The flag toggles both ways
25
- */
26
- deprecated?: boolean;
27
- };
28
- /**
29
- * This type represent the model of a segment, that is a dimension a content can vary by - `gender`,
30
- * `loyalty`, `auth_status` - holding the fixed set of keys a visitor can have for it
31
- *
32
- * Contents reference a segment by mnemonicId and key inside their rules, and definitions by
33
- * mnemonicId, so segments are archived and never deleted, and a key can only be removed or renamed
34
- * while no content references it
35
- */
36
- export type SegmentResponse = {
37
- /**
38
- * The segment unique id
39
- */
40
- id: SegmentId;
41
- /**
42
- * The segment name
43
- */
44
- name: string;
45
- /**
46
- * The segment mnemonic id, matching [[SEGMENT_NAME_PATTERN]]
47
- */
48
- mnemonicId: string;
49
- /**
50
- * The keys a visitor can hold for this segment, each carrying its own deprecation state
51
- */
52
- keys: SegmentKey[];
53
- /**
54
- * The archived status of the segment
55
- */
56
- archived: boolean;
57
- /**
58
- * The archive date of the segment
59
- */
60
- archivedDate: Date | null;
61
- /**
62
- * The segment creation date
63
- */
64
- createdDate: Date;
65
- /**
66
- * The segment last modified date
67
- */
68
- lastModifiedDate: Date;
69
- /**
70
- * The segment author, resolved by `list` only
71
- */
72
- author?: AuthorResponse;
73
- /**
74
- * The segment last modified author, resolved by every endpoint but `get`
75
- */
76
- latestContributor?: AuthorResponse;
77
- };
78
- /**
79
- * This type represent all possible filters used to retrieve a list of segment
80
- */
81
- export type ListSegmentsFilters = {
82
- /**
83
- * This filter is used to retrieve archived or not archived segments. Defaults to not archived
84
- */
85
- archived?: boolean;
86
- };
87
- /**
88
- * This type represent the data needed to make a list segments API request
89
- */
90
- export type ListSegmentsRequest = {
91
- /**
92
- * The number of segments to skip (this value is used for pagination)
93
- */
94
- skip?: number;
95
- /**
96
- * The number of segments to take (this value is used for pagination), at most 100
97
- */
98
- take?: number;
99
- /**
100
- * The data used to filter the list of segments
101
- */
102
- filters?: ListSegmentsFilters;
103
- };
104
- /**
105
- * This type represent the item of a list segments API request
106
- */
107
- export type ListSegmentsItem = SegmentResponse;
108
- /**
109
- * This type represent the response of a list segments API request
110
- */
111
- export type ListSegmentsResponse = PagedListResponse<ListSegmentsItem>;
112
- /**
113
- * This type represent the usage of one key of a segment. 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
115
- */
116
- export type SegmentKeyUsage = {
117
- /**
118
- * The key, or null for the rules that constrain the segment without naming any key - that is the
119
- * ones that only fire when the segment is unknown
120
- */
121
- key: string | null;
122
- /**
123
- * How many contents reference this key
124
- */
125
- contents: number;
126
- };
127
- /**
128
- * This type represent a content definition that declares a segment
129
- */
130
- export type DefinitionUsingSegment = {
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
- };
144
- /**
145
- * This type represent the data needed to make a get segment API request
146
- */
147
- export type GetSegmentRequest = {
148
- /**
149
- * The unique segment id to retrieve
150
- */
151
- id: SegmentId;
152
- };
153
- /**
154
- * This type represent the response of a get segment API request: the segment, plus the two things the
155
- * editor cannot decide without, which keys are in use and which definitions vary by this segment
156
- */
157
- export type GetSegmentResponse = SegmentResponse & {
158
- /**
159
- * One entry per key at least one content references. A key absent from this list is unused
160
- */
161
- keyUsage: SegmentKeyUsage[];
162
- /**
163
- * The content definitions declaring this segment
164
- */
165
- definitions: DefinitionUsingSegment[];
166
- };
167
- /**
168
- * This type represent the data needed to make a create segment API request
169
- */
170
- export type CreateSegmentRequest = {
171
- /**
172
- * The segment name
173
- */
174
- name: string;
175
- /**
176
- * The segment mnemonic id, matching [[SEGMENT_NAME_PATTERN]]
177
- */
178
- mnemonicId: string;
179
- /**
180
- * The keys a visitor can hold for this segment, at least one, each key unique
181
- */
182
- keys: SegmentKey[];
183
- };
184
- /**
185
- * This type represent the response of a create segment API request
186
- */
187
- export type CreateSegmentResponse = SegmentResponse;
188
- /**
189
- * This type represent the data needed to make an update segment API request
190
- *
191
- * `keys` replaces the whole stored list, deprecation flags included. Adding keys and toggling
192
- * deprecation are always allowed, while removing or renaming a key is refused while a content still
193
- * references it. `mnemonicId` cannot be changed
194
- */
195
- export type UpdateSegmentRequest = {
196
- /**
197
- * The segment unique id
198
- */
199
- id: SegmentId;
200
- /**
201
- * The segment name to update
202
- */
203
- name: string;
204
- /**
205
- * The segment mnemonic id, which must be the stored one
206
- */
207
- mnemonicId: string;
208
- /**
209
- * The whole key list, replacing what is stored
210
- */
211
- keys: SegmentKey[];
212
- };
213
- /**
214
- * This type represent the response of an update segment API request
215
- */
216
- export type UpdateSegmentResponse = SegmentResponse;
217
- /**
218
- * This type represent the data needed to make a toggle archived segment API request
219
- */
220
- export type ToggleArchivedSegmentRequest = {
221
- /**
222
- * The segment unique id
223
- */
224
- id: SegmentId;
225
- /**
226
- * This value represent the archive status to set in the specified segment
227
- */
228
- archived: boolean;
229
- };
230
- /**
231
- * This type represent the response of a toggle archived segment API request
232
- */
233
- export type ToggleArchivedSegmentResponse = SegmentResponse;
234
- /**
235
- * This type represent the condition of one rule on a single segment: the visitor's value for
236
- * [[segment]] has to be one of [[in]]
237
- */
238
- export type SegmentPredicate = {
239
- /**
240
- * The mnemonic id of the segment this predicate constrains, which the field must declare
241
- */
242
- segment: string;
243
- /**
244
- * The keys of the segment that satisfy this predicate
245
- */
246
- in: string[];
247
- /**
248
- * Set this value to also satisfy the predicate when the segment was not provided at all
249
- *
250
- * Not-provided is not a key, so no list of keys can express it, and an enumeration would silently
251
- * narrow the moment a key is added to the segment. A key that was provided but is not listed does
252
- * not satisfy this flag: it falls through to the field's fallback
253
- */
254
- orUnset?: boolean;
255
- };
256
- /**
257
- * This type represent a condition satisfied when every child condition is satisfied
258
- */
259
- export type AllSegmentPredicate = {
260
- all: SegmentRuleCondition[];
261
- };
262
- /**
263
- * This type represent a condition satisfied when at least one child condition is satisfied
264
- */
265
- export type AnySegmentPredicate = {
266
- any: SegmentRuleCondition[];
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 [[AllSegmentPredicate]] of one [[SegmentPredicate]] per segment: or within a segment, and
273
- * between segments. A segment the condition does not mention is unconstrained, which is a different
274
- * thing from one listed with [[SegmentPredicate.orUnset]]
275
- */
276
- export type SegmentRuleCondition = SegmentPredicate | AllSegmentPredicate | AnySegmentPredicate;
277
- /**
278
- * This type represent one rule of a segmented 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 SegmentRule<T = any> = {
282
- /**
283
- * The rule id, unique in the field. Used for diagnostics only, matching never reads it
284
- */
285
- id?: string;
286
- /**
287
- * The condition under which this rule wins
288
- */
289
- when: SegmentRuleCondition;
290
- /**
291
- * The value served when this rule wins
292
- */
293
- value: T;
294
- };
295
- /**
296
- * This type represent the value a segmented 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
- * segmented 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 SegmentedFieldPayload<T = any> = {
304
- /**
305
- * The rules, in the order they are evaluated in
306
- */
307
- rules?: SegmentRule<T>[];
308
- /**
309
- * The value served when no rule matches
310
- */
311
- fallback?: T;
312
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SEGMENT_NAME_PATTERN = void 0;
4
- /**
5
- * A segment's mnemonicId and every one of its keys must match this pattern: lowercase, digits,
6
- * underscore and hyphen. Stricter than the other authoring mnemonicIds on purpose, because both halves
7
- * travel in the delivery `segments` query param and are compared against strings a client supplies
8
- */
9
- exports.SEGMENT_NAME_PATTERN = /^[a-z0-9_-]+$/;