@datocms/cma-client 5.1.15 → 5.1.17

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.
Files changed (33) hide show
  1. package/README.md +31 -28
  2. package/dist/cjs/generated/Client.js +1 -1
  3. package/dist/cjs/generated/resources/Item.js.map +1 -1
  4. package/dist/cjs/utilities/itemInstancesHrefSchema.js +3 -0
  5. package/dist/cjs/utilities/itemInstancesHrefSchema.js.map +1 -0
  6. package/dist/cjs/utilities/normalizedFieldValues.js +39 -39
  7. package/dist/cjs/utilities/normalizedFieldValues.js.map +1 -1
  8. package/dist/esm/generated/ApiTypes.d.ts +4 -6
  9. package/dist/esm/generated/Client.js +1 -1
  10. package/dist/esm/generated/RawApiTypes.d.ts +4 -6
  11. package/dist/esm/generated/resources/Item.d.ts +7 -7
  12. package/dist/esm/generated/resources/Item.js.map +1 -1
  13. package/dist/esm/utilities/itemDefinition.d.ts +30 -0
  14. package/dist/esm/utilities/itemInstancesHrefSchema.d.ts +256 -0
  15. package/dist/esm/utilities/itemInstancesHrefSchema.js +2 -0
  16. package/dist/esm/utilities/itemInstancesHrefSchema.js.map +1 -0
  17. package/dist/esm/utilities/normalizedFieldValues.d.ts +25 -25
  18. package/dist/esm/utilities/normalizedFieldValues.js +39 -39
  19. package/dist/esm/utilities/normalizedFieldValues.js.map +1 -1
  20. package/dist/types/generated/ApiTypes.d.ts +4 -6
  21. package/dist/types/generated/RawApiTypes.d.ts +4 -6
  22. package/dist/types/generated/resources/Item.d.ts +7 -7
  23. package/dist/types/utilities/itemDefinition.d.ts +30 -0
  24. package/dist/types/utilities/itemInstancesHrefSchema.d.ts +256 -0
  25. package/dist/types/utilities/normalizedFieldValues.d.ts +25 -25
  26. package/package.json +2 -2
  27. package/src/generated/ApiTypes.ts +7 -5
  28. package/src/generated/Client.ts +1 -1
  29. package/src/generated/RawApiTypes.ts +7 -5
  30. package/src/generated/resources/Item.ts +10 -10
  31. package/src/utilities/itemDefinition.ts +92 -0
  32. package/src/utilities/itemInstancesHrefSchema.ts +308 -0
  33. package/src/utilities/normalizedFieldValues.ts +60 -39
@@ -0,0 +1,256 @@
1
+ export type StringMatchesFilter = {
2
+ /** Pattern to match against */
3
+ pattern: string;
4
+ /** Whether the match should be case sensitive */
5
+ case_sensitive?: boolean;
6
+ /** Whether to treat the pattern as a regular expression */
7
+ regexp?: boolean;
8
+ };
9
+ export type LatLonNearFilter = {
10
+ /** Latitude coordinate */
11
+ latitude: number;
12
+ /** Longitude coordinate */
13
+ longitude: number;
14
+ /** Radius in meters */
15
+ radius: number;
16
+ };
17
+ export type BooleanHrefFilter = {
18
+ /** Search for records with an exact match */
19
+ eq?: boolean;
20
+ };
21
+ export type IntegerHrefFilter = {
22
+ /** Filter records with a value that's strictly greater than the one specified */
23
+ gt?: number;
24
+ /** Filter records with a value that's less than the one specified */
25
+ lt?: number;
26
+ /** Filter records with a value that's greater than or equal to the one specified */
27
+ gte?: number;
28
+ /** Filter records with a value that's less or equal than the one specified */
29
+ lte?: number;
30
+ /** Filter records with the specified field defined (i.e. with any value) or not */
31
+ exists?: boolean;
32
+ /** Search for records with an exact match */
33
+ eq?: number;
34
+ /** Exclude records with an exact match */
35
+ neq?: number;
36
+ };
37
+ export type FloatHrefFilter = {
38
+ /** Filter records with a value that's strictly greater than the one specified */
39
+ gt?: number;
40
+ /** Filter records with a value that's less than the one specified */
41
+ lt?: number;
42
+ /** Filter records with a value that's greater than or equal to the one specified */
43
+ gte?: number;
44
+ /** Filter records with a value that's less or equal than the one specified */
45
+ lte?: number;
46
+ /** Filter records with the specified field defined (i.e. with any value) or not */
47
+ exists?: boolean;
48
+ /** Search for records with an exact match */
49
+ eq?: number;
50
+ /** Exclude records with an exact match */
51
+ neq?: number;
52
+ };
53
+ export type DateHrefFilter = {
54
+ /** Filter records with a value that's strictly greater than the one specified */
55
+ gt?: string;
56
+ /** Filter records with a value that's less than the one specified */
57
+ lt?: string;
58
+ /** Filter records with a value that's greater than or equal to the one specified */
59
+ gte?: string;
60
+ /** Filter records with a value that's less or equal than the one specified */
61
+ lte?: string;
62
+ /** Filter records with the specified field defined (i.e. with any value) or not */
63
+ exists?: boolean;
64
+ /** Search for records with an exact match */
65
+ eq?: string;
66
+ /** Exclude records with an exact match */
67
+ neq?: string;
68
+ };
69
+ export type ColorHrefFilter = {
70
+ /** Filter records with the specified field defined (i.e. with any value) or not */
71
+ exists?: boolean;
72
+ };
73
+ export type StringHrefFilter = {
74
+ /** Filter records based on a regular expression */
75
+ matches?: StringMatchesFilter;
76
+ /** Exclude records based on a regular expression */
77
+ not_matches?: StringMatchesFilter;
78
+ /** Filter records with the specified field set as blank (null or empty string) */
79
+ is_blank?: boolean;
80
+ /** Filter records with the specified field present (neither null, nor empty string) */
81
+ is_present?: boolean;
82
+ /** Search for records with an exact match */
83
+ eq?: string;
84
+ /** Exclude records with an exact match */
85
+ neq?: string;
86
+ /** Filter records that equal one of the specified values */
87
+ in?: string[];
88
+ /** Filter records that do not equal one of the specified values */
89
+ not_in?: string[];
90
+ /** @deprecated Use is_present instead. Filter records with the specified field defined (i.e. with any value) or not */
91
+ exists?: boolean;
92
+ };
93
+ export type DateTimeHrefFilter = {
94
+ /** Filter records with a value that's strictly greater than the one specified. Seconds and milliseconds are truncated from the argument. */
95
+ gt?: string;
96
+ /** Filter records with a value that's less than the one specified. Seconds and milliseconds are truncated from the argument. */
97
+ lt?: string;
98
+ /** Filter records with a value that's greater than or equal to than the one specified. Seconds and milliseconds are truncated from the argument. */
99
+ gte?: string;
100
+ /** Filter records with a value that's less or equal than the one specified. Seconds and milliseconds are truncated from the argument. */
101
+ lte?: string;
102
+ /** Filter records with a value that's within the specified minute range. Seconds and milliseconds are truncated from the argument. */
103
+ eq?: string;
104
+ /** Filter records with a value that's outside the specified minute range. Seconds and milliseconds are truncated from the argument. */
105
+ neq?: string;
106
+ /** Filter records with the specified field defined (i.e. with any value) or not */
107
+ exists?: boolean;
108
+ };
109
+ export type JsonHrefFilter = {
110
+ /** Filter records with the specified field defined (i.e. with any value) or not */
111
+ exists?: boolean;
112
+ };
113
+ export type LatLonHrefFilter = {
114
+ /** Filter records within the specified radius in meters */
115
+ near?: LatLonNearFilter;
116
+ /** Filter records with the specified field defined (i.e. with any value) or not */
117
+ exists?: boolean;
118
+ };
119
+ export type SlugHrefFilter = {
120
+ /** Search for records with an exact match */
121
+ eq?: string;
122
+ /** Exclude records with an exact match */
123
+ neq?: string;
124
+ /** Filter records that have one of the specified slugs */
125
+ in?: string[];
126
+ /** Filter records that do not have one of the specified slugs */
127
+ not_in?: string[];
128
+ };
129
+ export type VideoHrefFilter = {
130
+ /** Filter records with the specified field defined (i.e. with any value) or not */
131
+ exists?: boolean;
132
+ };
133
+ export type SeoHrefFilter = {
134
+ /** Filter records with the specified field defined (i.e. with any value) or not */
135
+ exists?: boolean;
136
+ };
137
+ export type FileHrefFilter = {
138
+ /** Search for records with an exact match. The specified value must be an Upload ID */
139
+ eq?: string;
140
+ /** Exclude records with an exact match. The specified value must be an Upload ID */
141
+ neq?: string;
142
+ /** Filter records that have one of the specified uploads */
143
+ in?: string[];
144
+ /** Filter records that do not have one of the specified uploads */
145
+ not_in?: string[];
146
+ /** Filter records with the specified field defined (i.e. with any value) or not */
147
+ exists?: boolean;
148
+ };
149
+ export type GalleryHrefFilter = {
150
+ /** Search for records with an exact match. The specified values must be Upload IDs */
151
+ eq?: string[];
152
+ /** Filter records that have all of the specified uploads. The specified values must be Upload IDs */
153
+ all_in?: string[];
154
+ /** Filter records that have one of the specified uploads. The specified values must be Upload IDs */
155
+ any_in?: string[];
156
+ /** Filter records that do not have any of the specified uploads. The specified values must be Upload IDs */
157
+ not_in?: string[];
158
+ /** Filter records with the specified field defined (i.e. with any value) or not */
159
+ exists?: boolean;
160
+ };
161
+ export type LinkHrefFilter = {
162
+ /** Search for records with an exact match. The specified value must be a Record ID */
163
+ eq?: string;
164
+ /** Exclude records with an exact match. The specified value must be a Record ID */
165
+ neq?: string;
166
+ /** Filter records linked to one of the specified records */
167
+ in?: string[];
168
+ /** Filter records not linked to one of the specified records */
169
+ not_in?: string[];
170
+ /** Filter records with the specified field defined (i.e. with any value) or not */
171
+ exists?: boolean;
172
+ };
173
+ export type LinksHrefFilter = {
174
+ /** Search for records with an exact match. The specified values must be Record IDs */
175
+ eq?: string[];
176
+ /** Filter records linked to all of the specified records. The specified values must be Record IDs */
177
+ all_in?: string[];
178
+ /** Filter records linked to at least one of the specified records. The specified values must be Record IDs */
179
+ any_in?: string[];
180
+ /** Filter records not linked to any of the specified records. The specified values must be Record IDs */
181
+ not_in?: string[];
182
+ /** Filter records with the specified field defined (i.e. with any value) or not */
183
+ exists?: boolean;
184
+ };
185
+ export type RichTextHrefFilter = Record<string, never>;
186
+ export type StructuredTextHrefFilter = {
187
+ /** Filter records based on a regular expression */
188
+ matches?: StringMatchesFilter;
189
+ /** Exclude records based on a regular expression */
190
+ not_matches?: StringMatchesFilter;
191
+ };
192
+ export type SingleBlockHrefFilter = Record<string, never>;
193
+ export type TextHrefFilter = {
194
+ /** Filter records based on a regular expression */
195
+ matches?: StringMatchesFilter;
196
+ /** Exclude records based on a regular expression */
197
+ not_matches?: StringMatchesFilter;
198
+ /** Filter records with the specified field set as blank (null or empty string) */
199
+ is_blank?: boolean;
200
+ /** Filter records with the specified field present (neither null, nor empty string) */
201
+ is_present?: boolean;
202
+ /** @deprecated Use is_present instead. Filter records with the specified field defined (i.e. with any value) or not */
203
+ exists?: boolean;
204
+ };
205
+ export type StatusFilter = {
206
+ /** Search the record with the specified status */
207
+ eq?: 'draft' | 'updated' | 'published';
208
+ /** Exclude the record with the specified status */
209
+ neq?: 'draft' | 'updated' | 'published';
210
+ /** Search records with the specified statuses */
211
+ in?: ('draft' | 'updated' | 'published')[];
212
+ /** Search records without the specified statuses */
213
+ notIn?: ('draft' | 'updated' | 'published')[];
214
+ };
215
+ export type ItemIdFilter = {
216
+ /** Search the record with the specified ID */
217
+ eq?: string;
218
+ /** Exclude the record with the specified ID */
219
+ neq?: string;
220
+ /** Search records with the specified IDs */
221
+ in?: string[];
222
+ /** Search records that do not have the specified IDs */
223
+ notIn?: string[];
224
+ };
225
+ export type ParentIdFilter = {
226
+ /** Filter records children of the specified record. Value must be a Record ID */
227
+ eq?: string;
228
+ /** Filter records with a parent record or not */
229
+ exists?: boolean;
230
+ };
231
+ export type PositionFilter = {
232
+ /** Filter records with a value that's strictly greater than the one specified */
233
+ gt?: number;
234
+ /** Filter records with a value that's less than the one specified */
235
+ lt?: number;
236
+ /** Filter records with a value that's greater than or equal to the one specified */
237
+ gte?: number;
238
+ /** Filter records with a value that's less or equal than the one specified */
239
+ lte?: number;
240
+ /** Search for records with an exact match */
241
+ eq?: number;
242
+ /** Exclude records with an exact match */
243
+ neq?: number;
244
+ };
245
+ export type ItemMetaFilter = {
246
+ _created_at?: DateTimeHrefFilter;
247
+ _first_published_at?: DateTimeHrefFilter;
248
+ _is_valid?: BooleanHrefFilter;
249
+ _publication_scheduled_at?: DateTimeHrefFilter;
250
+ _published_at?: DateTimeHrefFilter;
251
+ _status?: StatusFilter;
252
+ _unpublishing_scheduled_at?: DateTimeHrefFilter;
253
+ _updated_at?: DateTimeHrefFilter;
254
+ id?: ItemIdFilter;
255
+ };
256
+ export type ItemMetaOrderBy = '_created_at_ASC' | '_created_at_DESC' | 'id_ASC' | 'id_DESC' | '_first_published_at_ASC' | '_first_published_at_DESC' | '_publication_scheduled_at_ASC' | '_publication_scheduled_at_DESC' | '_unpublishing_scheduled_at_ASC' | '_unpublishing_scheduled_at_DESC' | '_published_at_ASC' | '_published_at_DESC' | '_status_ASC' | '_status_DESC' | '_updated_at_ASC' | '_updated_at_DESC' | '_is_valid_ASC' | '_is_valid_DESC';
@@ -14,8 +14,8 @@ export type LocalizedFieldValue<T = unknown, L extends string = string> = Partia
14
14
  * This function handles both full Schema field objects and simplified Schema field objects
15
15
  * by checking the appropriate property based on the object structure.
16
16
  *
17
- * @param field - The DatoCMS field definition (either full or simple schema)
18
17
  * @returns true if the field is localized, false otherwise
18
+ * @param field - The DatoCMS field definition (either full or simple schema)
19
19
  */
20
20
  export declare function isLocalized(field: RawApiTypes.Field | ApiTypes.Field): boolean;
21
21
  export declare function isLocalizedFieldValue<T = unknown, L extends string = string>(value: unknown): value is LocalizedFieldValue<T, L>;
@@ -37,11 +37,11 @@ export type NormalizedFieldValueEntry<T = unknown, L extends string = string> =
37
37
  * This function normalizes the handling of field values by converting them into a consistent
38
38
  * array format, regardless of whether the field is localized or not.
39
39
  *
40
- * @param field - The DatoCMS field definition that determines localization behavior
41
40
  * @param value - The field value to convert (either a localized object or direct value)
41
+ * @param field - The DatoCMS field definition that determines localization behavior
42
42
  * @returns Array of entries where each entry contains a locale (string for localized, undefined for non-localized) and the corresponding value
43
43
  */
44
- export declare function toNormalizedFieldValueEntries<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>): NormalizedFieldValueEntry<T, L>[];
44
+ export declare function toNormalizedFieldValueEntries<T = unknown, L extends string = string>(value: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field): NormalizedFieldValueEntry<T, L>[];
45
45
  /**
46
46
  * Converts an array of possibly localized entries back into the appropriate field value format.
47
47
  *
@@ -49,118 +49,118 @@ export declare function toNormalizedFieldValueEntries<T = unknown, L extends str
49
49
  * array of entries and converts them back to either a localized object or a direct value,
50
50
  * depending on the field's localization setting.
51
51
  *
52
- * @param field - The DatoCMS field definition that determines the output format
53
52
  * @param entries - Array of entries to convert back to field value format
53
+ * @param field - The DatoCMS field definition that determines the output format
54
54
  * @returns Either a localized object (for localized fields) or the direct value (for non-localized fields)
55
55
  */
56
- export declare function fromNormalizedFieldValueEntries<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, entries: NormalizedFieldValueEntry<T, L>[]): T | LocalizedFieldValue<T, L>;
56
+ export declare function fromNormalizedFieldValueEntries<T = unknown, L extends string = string>(entries: NormalizedFieldValueEntry<T, L>[], field: RawApiTypes.Field | ApiTypes.Field): T | LocalizedFieldValue<T, L>;
57
57
  /**
58
58
  * Maps field values using a provided mapping function.
59
59
  * For localized fields, applies the mapping function to each locale value.
60
60
  * For non-localized fields, applies the mapping function directly to the value.
61
61
  *
62
62
  * @template T - The type that the mapping function returns
63
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
63
64
  * @param field - The DatoCMS field definition
64
- * @param value - The field value (either localized object or direct value)
65
65
  * @param mapFn - The function to apply to each locale value or the direct value
66
66
  * @returns The mapped value with the same structure as the input
67
67
  */
68
- export declare function mapNormalizedFieldValues<TInput = unknown, TOutput = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: TInput | LocalizedFieldValue<TInput, L>, mapFn: (locale: L | undefined, localeValue: TInput) => TOutput): TOutput | LocalizedFieldValue<TOutput, L>;
68
+ export declare function mapNormalizedFieldValues<TInput = unknown, TOutput = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: TInput | LocalizedFieldValue<TInput, L>, field: RawApiTypes.Field | ApiTypes.Field, mapFn: (locale: L | undefined, localeValue: TInput) => TOutput): TOutput | LocalizedFieldValue<TOutput, L>;
69
69
  /**
70
70
  * Maps field values using a provided mapping function (async version).
71
71
  * For localized fields, applies the mapping function to each locale value.
72
72
  * For non-localized fields, applies the mapping function directly to the value.
73
73
  *
74
74
  * @template T - The type that the mapping function returns
75
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
75
76
  * @param field - The DatoCMS field definition
76
- * @param value - The field value (either localized object or direct value)
77
77
  * @param mapFn - The function to apply to each locale value or the direct value
78
78
  * @returns The mapped value with the same structure as the input
79
79
  */
80
- export declare function mapNormalizedFieldValuesAsync<TInput = unknown, TOutput = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: TInput | LocalizedFieldValue<TInput, L>, mapFn: (locale: L | undefined, localeValue: TInput) => Promise<TOutput>): Promise<TOutput | LocalizedFieldValue<TOutput, L>>;
80
+ export declare function mapNormalizedFieldValuesAsync<TInput = unknown, TOutput = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: TInput | LocalizedFieldValue<TInput, L>, field: RawApiTypes.Field | ApiTypes.Field, mapFn: (locale: L | undefined, localeValue: TInput) => Promise<TOutput>): Promise<TOutput | LocalizedFieldValue<TOutput, L>>;
81
81
  /**
82
82
  * Filters field values using a provided filter function.
83
83
  * For localized fields, filters each locale value.
84
84
  * For non-localized fields, returns the value if the filter passes, otherwise undefined.
85
85
  *
86
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
86
87
  * @param field - The DatoCMS field definition
87
- * @param value - The field value (either localized object or direct value)
88
88
  * @param filterFn - The function to test each locale value or the direct value
89
89
  * @returns The filtered value with the same structure as the input
90
90
  */
91
- export declare function filterNormalizedFieldValues<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, filterFn: (locale: L | undefined, localeValue: T) => boolean): T | LocalizedFieldValue<T, L> | undefined;
91
+ export declare function filterNormalizedFieldValues<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, filterFn: (locale: L | undefined, localeValue: T) => boolean): T | LocalizedFieldValue<T, L> | undefined;
92
92
  /**
93
93
  * Filters field values using a provided filter function (async version).
94
94
  * For localized fields, filters each locale value.
95
95
  * For non-localized fields, returns the value if the filter passes, otherwise undefined.
96
96
  *
97
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
97
98
  * @param field - The DatoCMS field definition
98
- * @param value - The field value (either localized object or direct value)
99
99
  * @param filterFn - The function to test each locale value or the direct value
100
100
  * @returns The filtered value with the same structure as the input
101
101
  */
102
- export declare function filterNormalizedFieldValuesAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, filterFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<T | LocalizedFieldValue<T, L> | undefined>;
102
+ export declare function filterNormalizedFieldValuesAsync<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, filterFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<T | LocalizedFieldValue<T, L> | undefined>;
103
103
  /**
104
104
  * Tests whether at least one field value passes the test implemented by the provided function.
105
105
  * For localized fields, tests each locale value.
106
106
  * For non-localized fields, tests the direct value.
107
107
  *
108
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
108
109
  * @param field - The DatoCMS field definition
109
- * @param value - The field value (either localized object or direct value)
110
110
  * @param testFn - The function to test each locale value or the direct value
111
111
  * @returns true if at least one value passes the test, false otherwise
112
112
  */
113
- export declare function someNormalizedFieldValues<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => boolean): boolean;
113
+ export declare function someNormalizedFieldValues<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, testFn: (locale: L | undefined, localeValue: T) => boolean): boolean;
114
114
  /**
115
115
  * Tests whether at least one field value passes the test implemented by the provided function (async version).
116
116
  * For localized fields, tests each locale value.
117
117
  * For non-localized fields, tests the direct value.
118
118
  *
119
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
119
120
  * @param field - The DatoCMS field definition
120
- * @param value - The field value (either localized object or direct value)
121
121
  * @param testFn - The function to test each locale value or the direct value
122
122
  * @returns true if at least one value passes the test, false otherwise
123
123
  */
124
- export declare function someNormalizedFieldValuesAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<boolean>;
124
+ export declare function someNormalizedFieldValuesAsync<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, testFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<boolean>;
125
125
  /**
126
126
  * Tests whether all field values pass the test implemented by the provided function.
127
127
  * For localized fields, tests each locale value.
128
128
  * For non-localized fields, tests the direct value.
129
129
  *
130
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
130
131
  * @param field - The DatoCMS field definition
131
- * @param value - The field value (either localized object or direct value)
132
132
  * @param testFn - The function to test each locale value or the direct value
133
133
  * @returns true if all values pass the test, false otherwise
134
134
  */
135
- export declare function everyNormalizedFieldValue<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => boolean): boolean;
135
+ export declare function everyNormalizedFieldValue<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, testFn: (locale: L | undefined, localeValue: T) => boolean): boolean;
136
136
  /**
137
137
  * Tests whether all field values pass the test implemented by the provided function (async version).
138
138
  * For localized fields, tests each locale value.
139
139
  * For non-localized fields, tests the direct value.
140
140
  *
141
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
141
142
  * @param field - The DatoCMS field definition
142
- * @param value - The field value (either localized object or direct value)
143
143
  * @param testFn - The function to test each locale value or the direct value
144
144
  * @returns true if all values pass the test, false otherwise
145
145
  */
146
- export declare function everyNormalizedFieldValueAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<boolean>;
146
+ export declare function everyNormalizedFieldValueAsync<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, testFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<boolean>;
147
147
  /**
148
148
  * Visits each field value with the provided function.
149
149
  * For localized fields, visits each locale value.
150
150
  * For non-localized fields, visits the direct value.
151
151
  *
152
- * @param field - The DatoCMS field definition
153
152
  * @param value - The field value (either localized object or direct value)
153
+ * @param field - The DatoCMS field definition
154
154
  * @param visitFn - The function to call for each locale value or the direct value
155
155
  */
156
- export declare function visitNormalizedFieldValues<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, visitFn: (locale: L | undefined, localeValue: T) => void): void;
156
+ export declare function visitNormalizedFieldValues<T = unknown, L extends string = string>(value: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, visitFn: (locale: L | undefined, localeValue: T) => void): void;
157
157
  /**
158
158
  * Visits each field value with the provided function (async version).
159
159
  * For localized fields, visits each locale value.
160
160
  * For non-localized fields, visits the direct value.
161
161
  *
162
+ * @param localizedOrNonLocalizedFieldValue - The field value (either localized object or direct value)
162
163
  * @param field - The DatoCMS field definition
163
- * @param value - The field value (either localized object or direct value)
164
164
  * @param visitFn - The function to call for each locale value or the direct value
165
165
  */
166
- export declare function visitNormalizedFieldValuesAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, visitFn: (locale: L | undefined, localeValue: T) => Promise<void>): Promise<void>;
166
+ export declare function visitNormalizedFieldValuesAsync<T = unknown, L extends string = string>(localizedOrNonLocalizedFieldValue: T | LocalizedFieldValue<T, L>, field: RawApiTypes.Field | ApiTypes.Field, visitFn: (locale: L | undefined, localeValue: T) => Promise<void>): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datocms/cma-client",
3
- "version": "5.1.15",
3
+ "version": "5.1.17",
4
4
  "description": "JS client for DatoCMS REST Content Management API",
5
5
  "keywords": [
6
6
  "datocms",
@@ -45,5 +45,5 @@
45
45
  "@datocms/dashboard-client": "^5.1.13",
46
46
  "@types/uuid": "^9.0.7"
47
47
  },
48
- "gitHead": "e7e829e9d0b769c0cc309b02332516a853f18bb3"
48
+ "gitHead": "b6e72b9fe9351c2dab803e48bd1d2418e9a19f35"
49
49
  }
@@ -9,6 +9,8 @@ import type {
9
9
  ToItemAttributes,
10
10
  ToItemAttributesInNestedResponse,
11
11
  ToItemAttributesInRequest,
12
+ ToItemHrefSchemaField,
13
+ ToItemHrefSchemaOrderBy,
12
14
  } from '../utilities/itemDefinition';
13
15
 
14
16
  export type Field = GenericFieldAttributes<FieldStableShell>;
@@ -853,7 +855,9 @@ export type ItemInstancesTargetSchema<
853
855
  * This interface was referenced by `Item`'s JSON-Schema
854
856
  * via the `instances.hrefSchema` link.
855
857
  */
856
- export type ItemInstancesHrefSchema = {
858
+ export type ItemInstancesHrefSchema<
859
+ D extends ItemTypeDefinition = ItemTypeDefinition,
860
+ > = {
857
861
  /**
858
862
  * For Modular Content, Structured Text and Single Block fields. If set, returns full payload for nested blocks instead of IDs
859
863
  */
@@ -877,9 +881,7 @@ export type ItemInstancesHrefSchema = {
877
881
  /**
878
882
  * Same as [GraphQL API records filters](/docs/content-delivery-api/filtering-records): you must use square brackets to indicate nesting levels. E.g. if you wanna [filter by parent record](/docs/content-delivery-api/filtering-records#parent) in a tree of records, you must use `filter[fields][parent][eq]=<ID_VALUE>`. Use snake_case for fields names. If `locale` is defined, search within that locale. Otherwise environment's main locale will be used.
879
883
  */
880
- fields?: {
881
- [k: string]: unknown;
882
- };
884
+ fields?: ToItemHrefSchemaField<D>;
883
885
  /**
884
886
  * When set, only valid records are included in the results.
885
887
  */
@@ -906,7 +908,7 @@ export type ItemInstancesHrefSchema = {
906
908
  /**
907
909
  * Fields used to order results. You **must** specify also `filter[type]` with one element only to be able use this option. Format: `<field_name>_(ASC|DESC)`, where `<field_name>` can be either the API key of a model's field, or one of the following meta columns: `id`, `_updated_at`, `_created_at`, `_status`, `_published_at`, `_first_published_at`, `_publication_scheduled_at`, `_unpublishing_scheduled_at`, `_is_valid`, `position` (only for sortable models). You can pass multiple comma separated rules.
908
910
  */
909
- order_by?: string;
911
+ order_by?: ToItemHrefSchemaOrderBy<D>;
910
912
  /**
911
913
  * Whether you want the currently published versions (`published`, default) of your records, or the latest available (`current`)
912
914
  */
@@ -147,7 +147,7 @@ export class Client {
147
147
  ...this.config,
148
148
  ...options,
149
149
  logFn: this.config.logFn || console.log,
150
- userAgent: '@datocms/cma-client v5.1.15',
150
+ userAgent: '@datocms/cma-client v5.1.17',
151
151
  baseUrl: this.baseUrl,
152
152
  preCallStack: new Error().stack,
153
153
  extraHeaders: {
@@ -9,6 +9,8 @@ import type {
9
9
  ToItemAttributes,
10
10
  ToItemAttributesInNestedResponse,
11
11
  ToItemAttributesInRequest,
12
+ ToItemHrefSchemaField,
13
+ ToItemHrefSchemaOrderBy,
12
14
  } from '../utilities/itemDefinition';
13
15
 
14
16
  export type Field = FieldStableShell;
@@ -665,7 +667,9 @@ export type BuildEventInstancesHrefSchema = {
665
667
  * This interface was referenced by `Item`'s JSON-Schema
666
668
  * via the `instances.hrefSchema` link.
667
669
  */
668
- export type ItemInstancesHrefSchema = {
670
+ export type ItemInstancesHrefSchema<
671
+ D extends ItemTypeDefinition = ItemTypeDefinition,
672
+ > = {
669
673
  /**
670
674
  * For Modular Content, Structured Text and Single Block fields. If set, returns full payload for nested blocks instead of IDs
671
675
  */
@@ -689,9 +693,7 @@ export type ItemInstancesHrefSchema = {
689
693
  /**
690
694
  * Same as [GraphQL API records filters](/docs/content-delivery-api/filtering-records): you must use square brackets to indicate nesting levels. E.g. if you wanna [filter by parent record](/docs/content-delivery-api/filtering-records#parent) in a tree of records, you must use `filter[fields][parent][eq]=<ID_VALUE>`. Use snake_case for fields names. If `locale` is defined, search within that locale. Otherwise environment's main locale will be used.
691
695
  */
692
- fields?: {
693
- [k: string]: unknown;
694
- };
696
+ fields?: ToItemHrefSchemaField<D>;
695
697
  /**
696
698
  * When set, only valid records are included in the results.
697
699
  */
@@ -718,7 +720,7 @@ export type ItemInstancesHrefSchema = {
718
720
  /**
719
721
  * Fields used to order results. You **must** specify also `filter[type]` with one element only to be able use this option. Format: `<field_name>_(ASC|DESC)`, where `<field_name>` can be either the API key of a model's field, or one of the following meta columns: `id`, `_updated_at`, `_created_at`, `_status`, `_published_at`, `_first_published_at`, `_publication_scheduled_at`, `_unpublishing_scheduled_at`, `_is_valid`, `position` (only for sortable models). You can pass multiple comma separated rules.
720
722
  */
721
- order_by?: string;
723
+ order_by?: ToItemHrefSchemaOrderBy<D>;
722
724
  /**
723
725
  * Whether you want the currently published versions (`published`, default) of your records, or the latest available (`current`)
724
726
  */
@@ -18,10 +18,10 @@ export default class Item extends BaseResource {
18
18
  * @throws {TimeoutError}
19
19
  */
20
20
  list<D extends ItemTypeDefinition = ItemTypeDefinition>(
21
- queryParams: ApiTypes.ItemInstancesHrefSchema & { nested: true },
21
+ queryParams: ApiTypes.ItemInstancesHrefSchema<D> & { nested: true },
22
22
  ): Promise<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
23
23
  list<D extends ItemTypeDefinition = ItemTypeDefinition>(
24
- queryParams?: ApiTypes.ItemInstancesHrefSchema & {
24
+ queryParams?: ApiTypes.ItemInstancesHrefSchema<D> & {
25
25
  nested?: false | undefined;
26
26
  },
27
27
  ): Promise<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>>;
@@ -34,7 +34,7 @@ export default class Item extends BaseResource {
34
34
  * @throws {TimeoutError}
35
35
  */
36
36
  list<D extends ItemTypeDefinition = ItemTypeDefinition>(
37
- queryParams?: ApiTypes.ItemInstancesHrefSchema,
37
+ queryParams?: ApiTypes.ItemInstancesHrefSchema<D>,
38
38
  ) {
39
39
  return this.rawList<D>(queryParams).then((body) =>
40
40
  Utils.deserializeResponseBody(body),
@@ -50,15 +50,15 @@ export default class Item extends BaseResource {
50
50
  * @throws {TimeoutError}
51
51
  */
52
52
  rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(
53
- queryParams: RawApiTypes.ItemInstancesHrefSchema & { nested: true },
53
+ queryParams: RawApiTypes.ItemInstancesHrefSchema<D> & { nested: true },
54
54
  ): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
55
55
  rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(
56
- queryParams?: RawApiTypes.ItemInstancesHrefSchema & {
56
+ queryParams?: RawApiTypes.ItemInstancesHrefSchema<D> & {
57
57
  nested?: false | undefined;
58
58
  },
59
59
  ): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>>;
60
60
  rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(
61
- queryParams?: RawApiTypes.ItemInstancesHrefSchema,
61
+ queryParams?: RawApiTypes.ItemInstancesHrefSchema<D>,
62
62
  ): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
63
63
  /**
64
64
  * List all records
@@ -69,7 +69,7 @@ export default class Item extends BaseResource {
69
69
  * @throws {TimeoutError}
70
70
  */
71
71
  rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(
72
- queryParams?: RawApiTypes.ItemInstancesHrefSchema,
72
+ queryParams?: RawApiTypes.ItemInstancesHrefSchema<D>,
73
73
  ) {
74
74
  return this.client
75
75
  .request({
@@ -92,7 +92,7 @@ export default class Item extends BaseResource {
92
92
  */
93
93
  async *listPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(
94
94
  queryParams?: Utils.OmitFromKnownKeys<
95
- ApiTypes.ItemInstancesHrefSchema,
95
+ ApiTypes.ItemInstancesHrefSchema<D>,
96
96
  'page'
97
97
  >,
98
98
  iteratorOptions?: Utils.IteratorOptions,
@@ -117,7 +117,7 @@ export default class Item extends BaseResource {
117
117
  */
118
118
  rawListPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(
119
119
  queryParams?: Utils.OmitFromKnownKeys<
120
- RawApiTypes.ItemInstancesHrefSchema,
120
+ RawApiTypes.ItemInstancesHrefSchema<D>,
121
121
  'page'
122
122
  >,
123
123
  iteratorOptions?: Utils.IteratorOptions,
@@ -131,7 +131,7 @@ export default class Item extends BaseResource {
131
131
  defaultLimit: 30,
132
132
  maxLimit: 500,
133
133
  },
134
- (page: RawApiTypes.ItemInstancesHrefSchema['page']) =>
134
+ (page: RawApiTypes.ItemInstancesHrefSchema<D>['page']) =>
135
135
  this.rawList<D>({ ...queryParams, page }),
136
136
  iteratorOptions,
137
137
  true,