@datocms/cma-client 5.1.4 → 5.1.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.
@@ -88,7 +88,7 @@ class Client {
88
88
  return this.config.baseUrl || Client.defaultBaseUrl;
89
89
  }
90
90
  request(options) {
91
- return (0, rest_client_utils_1.request)(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.4', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
91
+ return (0, rest_client_utils_1.request)(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.5', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
92
92
  ? { 'X-Environment': this.config.environment }
93
93
  : {})), { 'X-API-Version': '3' }), fetchJobResult: (jobId) => {
94
94
  return this.jobResultsFetcher
@@ -15,7 +15,7 @@ export type GalleryFieldValue = Array<{
15
15
  x: number;
16
16
  y: number;
17
17
  } | null;
18
- }> | null;
18
+ }>;
19
19
  export declare function isGalleryFieldValue(value: unknown): value is GalleryFieldValue;
20
20
  export declare function isLocalizedGalleryFieldValue(value: unknown): value is LocalizedFieldValue<GalleryFieldValue>;
21
21
  export type GalleryFieldValidators = {
@@ -60,10 +60,17 @@ type FieldUpdateConfigForFieldType<SourceType, FieldType extends RawFieldAttribu
60
60
  };
61
61
  type FieldUpdateConfig<SourceType> = FieldUpdateConfigForFieldType<SourceType, 'boolean', BooleanFieldValue, BooleanFieldValidators, BooleanFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'color', ColorFieldValue, ColorFieldValidators, ColorFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'date', DateFieldValue, DateFieldValidators, DateFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'date_time', DateTimeFieldValue, DateTimeFieldValidators, DateTimeFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'file', null, FileFieldValidators, FileFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'float', FloatFieldValue, FloatFieldValidators, FloatFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'gallery', null, GalleryFieldValidators, GalleryFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'integer', IntegerFieldValue, IntegerFieldValidators, IntegerFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'json', JsonFieldValue, JsonFieldValidators, JsonFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'lat_lon', LatLonFieldValue, LatLonFieldValidators, LatLonFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'link', null, LinkFieldValidators, LinkFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'links', null, LinksFieldValidators, LinksFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'rich_text', null, RichTextFieldValidators, RichTextFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'seo', null, SeoFieldValidators, SeoFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'single_block', null, SingleBlockFieldValidators, SingleBlockFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'slug', null, SlugFieldValidators, SlugFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'string', StringFieldValue, StringFieldValidators, StringFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'structured_text', null, StructuredTextFieldValidators, StructuredTextFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'text', TextFieldValue, TextFieldValidators, TextFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'video', null, VideoFieldValidators, VideoFieldAppearance>;
62
62
  export type FieldUpdateSchema = FieldUpdateConfig<RawFieldUpdateSchema>;
63
- export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? Schema & D['fields'] & {
63
+ type ForceItemTypeDataId<ItemTypeId> = Omit<ItemTypeData, 'id'> & {
64
+ id: ItemTypeId;
65
+ };
66
+ type ForceItemTypeData<T, ItemTypeId> = {
67
+ [K in keyof T]: T[K] extends ItemTypeData ? ForceItemTypeDataId<ItemTypeId> : T[K] extends object ? ForceItemTypeData<T[K], ItemTypeId> : T[K];
68
+ };
69
+ type ForceItemTypeId<T, ItemTypeId> = ForceItemTypeData<T, ItemTypeId> & {
64
70
  /** Useful for type narrowing */
65
- __itemTypeId?: D['itemTypeId'];
66
- } : never;
71
+ __itemTypeId?: ItemTypeId;
72
+ };
73
+ export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? ForceItemTypeId<Schema, D['itemTypeId']> & D['fields'] : never;
67
74
  export type Item<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItem, D>;
68
75
  export type ItemValidateExistingSchema<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItemValidateExistingSchema, D>;
69
76
  export type ItemValidateNewSchema<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItemValidateNewSchema, D>;
@@ -62,7 +62,7 @@ export class Client {
62
62
  return this.config.baseUrl || Client.defaultBaseUrl;
63
63
  }
64
64
  request(options) {
65
- return request(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.4', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
65
+ return request(Object.assign(Object.assign(Object.assign({}, this.config), options), { logFn: this.config.logFn || console.log, userAgent: '@datocms/cma-client v5.1.5', baseUrl: this.baseUrl, preCallStack: new Error().stack, extraHeaders: Object.assign(Object.assign(Object.assign({}, (this.config.extraHeaders || {})), (this.config.environment
66
66
  ? { 'X-Environment': this.config.environment }
67
67
  : {})), { 'X-API-Version': '3' }), fetchJobResult: (jobId) => {
68
68
  return this.jobResultsFetcher
@@ -68,11 +68,18 @@ export type FieldUpdateSchema = Omit<RawFieldUpdateSchema, 'data'> & {
68
68
  attributes: FieldUpdateConfig<RawFieldUpdateSchema['data']['attributes']>;
69
69
  };
70
70
  };
71
- export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? Schema & {
72
- attributes: D['fields'];
73
- } & {
71
+ type ForceItemTypeDataId<ItemTypeId> = Omit<ItemTypeData, 'id'> & {
72
+ id: ItemTypeId;
73
+ };
74
+ type ForceItemTypeData<T, ItemTypeId> = {
75
+ [K in keyof T]: T[K] extends ItemTypeData ? ForceItemTypeDataId<ItemTypeId> : T[K] extends object ? ForceItemTypeData<T[K], ItemTypeId> : T[K];
76
+ };
77
+ type ForceItemTypeId<T, ItemTypeId> = ForceItemTypeData<T, ItemTypeId> & {
74
78
  /** Useful for type narrowing */
75
- __itemTypeId?: D['itemTypeId'];
79
+ __itemTypeId?: ItemTypeId;
80
+ };
81
+ export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? ForceItemTypeId<Schema, D['itemTypeId']> & {
82
+ attributes: D['fields'];
76
83
  } : never;
77
84
  export type Item<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItem, D>;
78
85
  export type ItemValidateExistingSchema<D extends ItemDefinition = ItemDefinition> = {
@@ -15,7 +15,7 @@ export type GalleryFieldValue = Array<{
15
15
  x: number;
16
16
  y: number;
17
17
  } | null;
18
- }> | null;
18
+ }>;
19
19
  export declare function isGalleryFieldValue(value: unknown): value is GalleryFieldValue;
20
20
  export declare function isLocalizedGalleryFieldValue(value: unknown): value is LocalizedFieldValue<GalleryFieldValue>;
21
21
  export type GalleryFieldValidators = {
@@ -60,10 +60,17 @@ type FieldUpdateConfigForFieldType<SourceType, FieldType extends RawFieldAttribu
60
60
  };
61
61
  type FieldUpdateConfig<SourceType> = FieldUpdateConfigForFieldType<SourceType, 'boolean', BooleanFieldValue, BooleanFieldValidators, BooleanFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'color', ColorFieldValue, ColorFieldValidators, ColorFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'date', DateFieldValue, DateFieldValidators, DateFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'date_time', DateTimeFieldValue, DateTimeFieldValidators, DateTimeFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'file', null, FileFieldValidators, FileFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'float', FloatFieldValue, FloatFieldValidators, FloatFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'gallery', null, GalleryFieldValidators, GalleryFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'integer', IntegerFieldValue, IntegerFieldValidators, IntegerFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'json', JsonFieldValue, JsonFieldValidators, JsonFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'lat_lon', LatLonFieldValue, LatLonFieldValidators, LatLonFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'link', null, LinkFieldValidators, LinkFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'links', null, LinksFieldValidators, LinksFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'rich_text', null, RichTextFieldValidators, RichTextFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'seo', null, SeoFieldValidators, SeoFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'single_block', null, SingleBlockFieldValidators, SingleBlockFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'slug', null, SlugFieldValidators, SlugFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'string', StringFieldValue, StringFieldValidators, StringFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'structured_text', null, StructuredTextFieldValidators, StructuredTextFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'text', TextFieldValue, TextFieldValidators, TextFieldAppearance> | FieldUpdateConfigForFieldType<SourceType, 'video', null, VideoFieldValidators, VideoFieldAppearance>;
62
62
  export type FieldUpdateSchema = FieldUpdateConfig<RawFieldUpdateSchema>;
63
- export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? Schema & D['fields'] & {
63
+ type ForceItemTypeDataId<ItemTypeId> = Omit<ItemTypeData, 'id'> & {
64
+ id: ItemTypeId;
65
+ };
66
+ type ForceItemTypeData<T, ItemTypeId> = {
67
+ [K in keyof T]: T[K] extends ItemTypeData ? ForceItemTypeDataId<ItemTypeId> : T[K] extends object ? ForceItemTypeData<T[K], ItemTypeId> : T[K];
68
+ };
69
+ type ForceItemTypeId<T, ItemTypeId> = ForceItemTypeData<T, ItemTypeId> & {
64
70
  /** Useful for type narrowing */
65
- __itemTypeId?: D['itemTypeId'];
66
- } : never;
71
+ __itemTypeId?: ItemTypeId;
72
+ };
73
+ export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? ForceItemTypeId<Schema, D['itemTypeId']> & D['fields'] : never;
67
74
  export type Item<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItem, D>;
68
75
  export type ItemValidateExistingSchema<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItemValidateExistingSchema, D>;
69
76
  export type ItemValidateNewSchema<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItemValidateNewSchema, D>;
@@ -68,11 +68,18 @@ export type FieldUpdateSchema = Omit<RawFieldUpdateSchema, 'data'> & {
68
68
  attributes: FieldUpdateConfig<RawFieldUpdateSchema['data']['attributes']>;
69
69
  };
70
70
  };
71
- export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? Schema & {
72
- attributes: D['fields'];
73
- } & {
71
+ type ForceItemTypeDataId<ItemTypeId> = Omit<ItemTypeData, 'id'> & {
72
+ id: ItemTypeId;
73
+ };
74
+ type ForceItemTypeData<T, ItemTypeId> = {
75
+ [K in keyof T]: T[K] extends ItemTypeData ? ForceItemTypeDataId<ItemTypeId> : T[K] extends object ? ForceItemTypeData<T[K], ItemTypeId> : T[K];
76
+ };
77
+ type ForceItemTypeId<T, ItemTypeId> = ForceItemTypeData<T, ItemTypeId> & {
74
78
  /** Useful for type narrowing */
75
- __itemTypeId?: D['itemTypeId'];
79
+ __itemTypeId?: ItemTypeId;
80
+ };
81
+ export type ApplyItemDefinitionToSchema<Schema, D extends ItemDefinition = ItemDefinition> = D extends any ? ForceItemTypeId<Schema, D['itemTypeId']> & {
82
+ attributes: D['fields'];
76
83
  } : never;
77
84
  export type Item<D extends ItemDefinition = ItemDefinition> = ApplyItemDefinitionToSchema<RawItem, D>;
78
85
  export type ItemValidateExistingSchema<D extends ItemDefinition = ItemDefinition> = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datocms/cma-client",
3
- "version": "5.1.4",
3
+ "version": "5.1.5",
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.4",
46
46
  "@types/uuid": "^9.0.7"
47
47
  },
48
- "gitHead": "b9b3aee7d6c78acdfef811fa42a84bc42abc36f7"
48
+ "gitHead": "e23fca2a772dfbc2441d2b8cdabac5f10b437eb0"
49
49
  }
@@ -16,7 +16,7 @@ export type GalleryFieldValue = Array<{
16
16
  x: number;
17
17
  y: number;
18
18
  } | null;
19
- }> | null;
19
+ }>;
20
20
 
21
21
  export function isGalleryFieldValue(
22
22
  value: unknown,
@@ -665,15 +665,28 @@ type FieldUpdateConfig<SourceType> =
665
665
 
666
666
  export type FieldUpdateSchema = FieldUpdateConfig<RawFieldUpdateSchema>;
667
667
 
668
+ type ForceItemTypeDataId<ItemTypeId> = Omit<ItemTypeData, 'id'> & {
669
+ id: ItemTypeId;
670
+ };
671
+
672
+ type ForceItemTypeData<T, ItemTypeId> = {
673
+ [K in keyof T]: T[K] extends ItemTypeData
674
+ ? ForceItemTypeDataId<ItemTypeId>
675
+ : T[K] extends object
676
+ ? ForceItemTypeData<T[K], ItemTypeId>
677
+ : T[K];
678
+ };
679
+
680
+ type ForceItemTypeId<T, ItemTypeId> = ForceItemTypeData<T, ItemTypeId> & {
681
+ /** Useful for type narrowing */
682
+ __itemTypeId?: ItemTypeId;
683
+ };
684
+
668
685
  export type ApplyItemDefinitionToSchema<
669
686
  Schema,
670
687
  D extends ItemDefinition = ItemDefinition,
671
688
  > = D extends any
672
- ? Schema &
673
- D['fields'] & {
674
- /** Useful for type narrowing */
675
- __itemTypeId?: D['itemTypeId'];
676
- }
689
+ ? ForceItemTypeId<Schema, D['itemTypeId']> & D['fields']
677
690
  : never;
678
691
 
679
692
  export type Item<D extends ItemDefinition = ItemDefinition> =
@@ -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.4',
150
+ userAgent: '@datocms/cma-client v5.1.5',
151
151
  baseUrl: this.baseUrl,
152
152
  preCallStack: new Error().stack,
153
153
  extraHeaders: {
@@ -673,14 +673,28 @@ export type FieldUpdateSchema = Omit<RawFieldUpdateSchema, 'data'> & {
673
673
  };
674
674
  };
675
675
 
676
+ type ForceItemTypeDataId<ItemTypeId> = Omit<ItemTypeData, 'id'> & {
677
+ id: ItemTypeId;
678
+ };
679
+
680
+ type ForceItemTypeData<T, ItemTypeId> = {
681
+ [K in keyof T]: T[K] extends ItemTypeData
682
+ ? ForceItemTypeDataId<ItemTypeId>
683
+ : T[K] extends object
684
+ ? ForceItemTypeData<T[K], ItemTypeId>
685
+ : T[K];
686
+ };
687
+
688
+ type ForceItemTypeId<T, ItemTypeId> = ForceItemTypeData<T, ItemTypeId> & {
689
+ /** Useful for type narrowing */
690
+ __itemTypeId?: ItemTypeId;
691
+ };
692
+
676
693
  export type ApplyItemDefinitionToSchema<
677
694
  Schema,
678
695
  D extends ItemDefinition = ItemDefinition,
679
696
  > = D extends any
680
- ? Schema & { attributes: D['fields'] } & {
681
- /** Useful for type narrowing */
682
- __itemTypeId?: D['itemTypeId'];
683
- }
697
+ ? ForceItemTypeId<Schema, D['itemTypeId']> & { attributes: D['fields'] }
684
698
  : never;
685
699
 
686
700
  export type Item<D extends ItemDefinition = ItemDefinition> =