@datocms/cma-client 5.1.16 → 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.
@@ -14,10 +14,10 @@ export default class Item extends BaseResource {
14
14
  * @throws {ApiError}
15
15
  * @throws {TimeoutError}
16
16
  */
17
- list<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: ApiTypes.ItemInstancesHrefSchema & {
17
+ list<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: ApiTypes.ItemInstancesHrefSchema<D> & {
18
18
  nested: true;
19
19
  }): Promise<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
20
- list<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: ApiTypes.ItemInstancesHrefSchema & {
20
+ list<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: ApiTypes.ItemInstancesHrefSchema<D> & {
21
21
  nested?: false | undefined;
22
22
  }): Promise<ApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>>;
23
23
  /**
@@ -28,13 +28,13 @@ export default class Item extends BaseResource {
28
28
  * @throws {ApiError}
29
29
  * @throws {TimeoutError}
30
30
  */
31
- rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: RawApiTypes.ItemInstancesHrefSchema & {
31
+ rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams: RawApiTypes.ItemInstancesHrefSchema<D> & {
32
32
  nested: true;
33
33
  }): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
34
- rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: RawApiTypes.ItemInstancesHrefSchema & {
34
+ rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: RawApiTypes.ItemInstancesHrefSchema<D> & {
35
35
  nested?: false | undefined;
36
36
  }): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, false>>;
37
- rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: RawApiTypes.ItemInstancesHrefSchema): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
37
+ rawList<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: RawApiTypes.ItemInstancesHrefSchema<D>): Promise<RawApiTypes.ItemInstancesTargetSchema<NoInfer<D>, true>>;
38
38
  /**
39
39
  * Async iterator to auto-paginate over elements returned by list()
40
40
  *
@@ -43,7 +43,7 @@ export default class Item extends BaseResource {
43
43
  * @throws {ApiError}
44
44
  * @throws {TimeoutError}
45
45
  */
46
- listPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<ApiTypes.ItemInstancesHrefSchema, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<ApiTypes.ItemInNestedResponse<NoInfer<D>>, void, unknown>;
46
+ listPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<ApiTypes.ItemInstancesHrefSchema<D>, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<ApiTypes.ItemInNestedResponse<NoInfer<D>>, void, unknown>;
47
47
  /**
48
48
  * Async iterator to auto-paginate over elements returned by rawList()
49
49
  *
@@ -52,7 +52,7 @@ export default class Item extends BaseResource {
52
52
  * @throws {ApiError}
53
53
  * @throws {TimeoutError}
54
54
  */
55
- rawListPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<RawApiTypes.ItemInstancesHrefSchema, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<RawApiTypes.ItemInNestedResponse<NoInfer<D>>, void, unknown>;
55
+ rawListPagedIterator<D extends ItemTypeDefinition = ItemTypeDefinition>(queryParams?: Utils.OmitFromKnownKeys<RawApiTypes.ItemInstancesHrefSchema<D>, 'page'>, iteratorOptions?: Utils.IteratorOptions): AsyncGenerator<RawApiTypes.ItemInNestedResponse<NoInfer<D>>, void, unknown>;
56
56
  /**
57
57
  * Validates an existing record field
58
58
  *
@@ -1,4 +1,5 @@
1
1
  import type { BlockInNestedResponse, BlockInRequest, BooleanFieldValue, ColorFieldValue, DateFieldValue, DateTimeFieldValue, FileFieldValue, FileFieldValueInRequest, FloatFieldValue, GalleryFieldValue, GalleryFieldValueInRequest, IntegerFieldValue, JsonFieldValue, LatLonFieldValue, LinkFieldValue, LinksFieldValue, RichTextFieldValue, RichTextFieldValueInNestedResponse, RichTextFieldValueInRequest, SeoFieldValue, SingleBlockFieldValue, SingleBlockFieldValueInNestedResponse, SingleBlockFieldValueInRequest, SlugFieldValue, StringFieldValue, StructuredTextFieldValue, StructuredTextFieldValueInNestedResponse, StructuredTextFieldValueInRequest, TextFieldValue, VideoFieldValue } from '../fieldTypes';
2
+ import type { BooleanHrefFilter, ColorHrefFilter, DateHrefFilter, DateTimeHrefFilter, FileHrefFilter, FloatHrefFilter, GalleryHrefFilter, IntegerHrefFilter, ItemMetaFilter, ItemMetaOrderBy, JsonHrefFilter, LatLonHrefFilter, LinkHrefFilter, LinksHrefFilter, ParentIdFilter, PositionFilter, RichTextHrefFilter, SeoHrefFilter, SingleBlockHrefFilter, SlugHrefFilter, StringHrefFilter, StructuredTextHrefFilter, TextHrefFilter, VideoHrefFilter } from './itemInstancesHrefSchema';
2
3
  import type { LocalizedFieldValue } from './normalizedFieldValues';
3
4
  /** Base field definition */
4
5
  type BaseFieldDefinition<Type extends string> = {
@@ -75,6 +76,29 @@ type FieldTypeToValueInRequest = {
75
76
  video: VideoFieldValue;
76
77
  unknown: unknown;
77
78
  };
79
+ type FieldTypeToHrefFilter = {
80
+ boolean: BooleanHrefFilter;
81
+ color: ColorHrefFilter;
82
+ date: DateHrefFilter;
83
+ date_time: DateTimeHrefFilter;
84
+ file: FileHrefFilter;
85
+ float: FloatHrefFilter;
86
+ gallery: GalleryHrefFilter;
87
+ integer: IntegerHrefFilter;
88
+ json: JsonHrefFilter;
89
+ lat_lon: LatLonHrefFilter;
90
+ link: LinkHrefFilter;
91
+ links: LinksHrefFilter;
92
+ rich_text: RichTextHrefFilter;
93
+ seo: SeoHrefFilter;
94
+ single_block: SingleBlockHrefFilter;
95
+ slug: SlugHrefFilter;
96
+ string: StringHrefFilter;
97
+ structured_text: StructuredTextHrefFilter;
98
+ text: TextHrefFilter;
99
+ video: VideoHrefFilter;
100
+ unknown: unknown;
101
+ };
78
102
  /** Localized wrapper */
79
103
  type LocalizeIfNeeded<T extends FieldDefinition, Value, Locales extends string> = T extends {
80
104
  localized: true;
@@ -102,6 +126,12 @@ export type ToItemAttributesInRequest<T extends ItemTypeDefinition<any, any, any
102
126
  export type ToItemAttributesInNestedResponse<T extends ItemTypeDefinition<any, any, any>> = T extends ItemTypeDefinition<infer Settings, infer ItemTypeId, infer Fields> ? keyof Fields extends never ? Record<string, unknown> : {
103
127
  [K in keyof Fields]: Fields[K] extends FieldDefinition ? FieldDefinitionToFieldValueInNestedResponse<Fields[K], Settings['locales']> : never;
104
128
  } : never;
129
+ export type ToItemHrefSchemaField<T extends ItemTypeDefinition<any, any, any>> = T extends ItemTypeDefinition<infer Settings, infer ItemTypeId, infer Fields> ? keyof Fields extends never ? Record<string, unknown> : ItemMetaFilter & Partial<{
130
+ [K in keyof Fields]: K extends 'position' ? PositionFilter : K extends 'parent_id' ? ParentIdFilter : Fields[K] extends FieldDefinition ? FieldTypeToHrefFilter[Fields[K]['type']] : never;
131
+ }> : never;
132
+ export type ToItemHrefSchemaOrderBy<T extends ItemTypeDefinition<any, any, any>> = (T extends ItemTypeDefinition<infer Settings, infer ItemTypeId, infer Fields> ? keyof Fields extends never ? string : {
133
+ [K in keyof Fields]: Fields[K] extends FieldDefinition ? Fields[K]['type'] extends 'boolean' | 'date' | 'date_time' | 'float' | 'integer' | 'string' ? `${K & string}_ASC` | `${K & string}_DESC` : never : never;
134
+ }[keyof Fields] : never) | ItemMetaOrderBy;
105
135
  type NestedItemTypeDefinitions<T extends ItemTypeDefinition<any, any, any>, Seen extends string = never> = T extends ItemTypeDefinition<any, infer Id, infer Fields> ? Id extends Seen ? never : {
106
136
  [K in keyof Fields]: Fields[K] extends RichTextFieldDefinition<infer B> ? B | NestedItemTypeDefinitions<B, Seen | Id> : Fields[K] extends SingleBlockFieldDefinition<infer B> ? B | NestedItemTypeDefinitions<B, Seen | Id> : Fields[K] extends StructuredTextFieldDefinition<infer B, infer I> ? B | I | NestedItemTypeDefinitions<B, Seen | Id> | NestedItemTypeDefinitions<I, Seen | Id> : never;
107
137
  }[keyof Fields] : never;
@@ -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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datocms/cma-client",
3
- "version": "5.1.16",
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": "f11b6b358c281fb2efff2e337be07f6c4ba30e77"
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.16',
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,
@@ -30,6 +30,32 @@ import type {
30
30
  TextFieldValue,
31
31
  VideoFieldValue,
32
32
  } from '../fieldTypes';
33
+ import type {
34
+ BooleanHrefFilter,
35
+ ColorHrefFilter,
36
+ DateHrefFilter,
37
+ DateTimeHrefFilter,
38
+ FileHrefFilter,
39
+ FloatHrefFilter,
40
+ GalleryHrefFilter,
41
+ IntegerHrefFilter,
42
+ ItemMetaFilter,
43
+ ItemMetaOrderBy,
44
+ JsonHrefFilter,
45
+ LatLonHrefFilter,
46
+ LinkHrefFilter,
47
+ LinksHrefFilter,
48
+ ParentIdFilter,
49
+ PositionFilter,
50
+ RichTextHrefFilter,
51
+ SeoHrefFilter,
52
+ SingleBlockHrefFilter,
53
+ SlugHrefFilter,
54
+ StringHrefFilter,
55
+ StructuredTextHrefFilter,
56
+ TextHrefFilter,
57
+ VideoHrefFilter,
58
+ } from './itemInstancesHrefSchema';
33
59
  import type { LocalizedFieldValue } from './normalizedFieldValues';
34
60
 
35
61
  /** Base field definition */
@@ -139,6 +165,30 @@ type FieldTypeToValueInRequest = {
139
165
  unknown: unknown;
140
166
  };
141
167
 
168
+ type FieldTypeToHrefFilter = {
169
+ boolean: BooleanHrefFilter;
170
+ color: ColorHrefFilter;
171
+ date: DateHrefFilter;
172
+ date_time: DateTimeHrefFilter;
173
+ file: FileHrefFilter;
174
+ float: FloatHrefFilter;
175
+ gallery: GalleryHrefFilter;
176
+ integer: IntegerHrefFilter;
177
+ json: JsonHrefFilter;
178
+ lat_lon: LatLonHrefFilter;
179
+ link: LinkHrefFilter;
180
+ links: LinksHrefFilter;
181
+ rich_text: RichTextHrefFilter;
182
+ seo: SeoHrefFilter;
183
+ single_block: SingleBlockHrefFilter;
184
+ slug: SlugHrefFilter;
185
+ string: StringHrefFilter;
186
+ structured_text: StructuredTextHrefFilter;
187
+ text: TextHrefFilter;
188
+ video: VideoHrefFilter;
189
+ unknown: unknown;
190
+ };
191
+
142
192
  /** Localized wrapper */
143
193
  type LocalizeIfNeeded<
144
194
  T extends FieldDefinition,
@@ -228,6 +278,48 @@ export type ToItemAttributesInNestedResponse<
228
278
  }
229
279
  : never;
230
280
 
281
+ export type ToItemHrefSchemaField<T extends ItemTypeDefinition<any, any, any>> =
282
+ T extends ItemTypeDefinition<infer Settings, infer ItemTypeId, infer Fields>
283
+ ? keyof Fields extends never
284
+ ? Record<string, unknown>
285
+ : ItemMetaFilter &
286
+ Partial<{
287
+ [K in keyof Fields]: K extends 'position'
288
+ ? PositionFilter
289
+ : K extends 'parent_id'
290
+ ? ParentIdFilter
291
+ : Fields[K] extends FieldDefinition
292
+ ? FieldTypeToHrefFilter[Fields[K]['type']]
293
+ : never;
294
+ }>
295
+ : never;
296
+
297
+ export type ToItemHrefSchemaOrderBy<
298
+ T extends ItemTypeDefinition<any, any, any>,
299
+ > =
300
+ | (T extends ItemTypeDefinition<
301
+ infer Settings,
302
+ infer ItemTypeId,
303
+ infer Fields
304
+ >
305
+ ? keyof Fields extends never
306
+ ? string
307
+ : {
308
+ [K in keyof Fields]: Fields[K] extends FieldDefinition
309
+ ? Fields[K]['type'] extends
310
+ | 'boolean'
311
+ | 'date'
312
+ | 'date_time'
313
+ | 'float'
314
+ | 'integer'
315
+ | 'string'
316
+ ? `${K & string}_ASC` | `${K & string}_DESC`
317
+ : never
318
+ : never;
319
+ }[keyof Fields]
320
+ : never)
321
+ | ItemMetaOrderBy;
322
+
231
323
  type NestedItemTypeDefinitions<
232
324
  T extends ItemTypeDefinition<any, any, any>,
233
325
  Seen extends string = never,