@datocms/cma-client 5.1.2 → 5.1.4

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 (205) hide show
  1. package/dist/cjs/fieldTypes/boolean.js +7 -1
  2. package/dist/cjs/fieldTypes/boolean.js.map +1 -1
  3. package/dist/cjs/fieldTypes/color.js +7 -1
  4. package/dist/cjs/fieldTypes/color.js.map +1 -1
  5. package/dist/cjs/fieldTypes/date.js +7 -1
  6. package/dist/cjs/fieldTypes/date.js.map +1 -1
  7. package/dist/cjs/fieldTypes/date_time.js +7 -1
  8. package/dist/cjs/fieldTypes/date_time.js.map +1 -1
  9. package/dist/cjs/fieldTypes/file.js +7 -1
  10. package/dist/cjs/fieldTypes/file.js.map +1 -1
  11. package/dist/cjs/fieldTypes/float.js +7 -1
  12. package/dist/cjs/fieldTypes/float.js.map +1 -1
  13. package/dist/cjs/fieldTypes/gallery.js +7 -1
  14. package/dist/cjs/fieldTypes/gallery.js.map +1 -1
  15. package/dist/cjs/fieldTypes/integer.js +7 -1
  16. package/dist/cjs/fieldTypes/integer.js.map +1 -1
  17. package/dist/cjs/fieldTypes/json.js +7 -1
  18. package/dist/cjs/fieldTypes/json.js.map +1 -1
  19. package/dist/cjs/fieldTypes/lat_lon.js +9 -3
  20. package/dist/cjs/fieldTypes/lat_lon.js.map +1 -1
  21. package/dist/cjs/fieldTypes/link.js +7 -1
  22. package/dist/cjs/fieldTypes/link.js.map +1 -1
  23. package/dist/cjs/fieldTypes/links.js +7 -1
  24. package/dist/cjs/fieldTypes/links.js.map +1 -1
  25. package/dist/cjs/fieldTypes/rich_text.js +19 -1
  26. package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
  27. package/dist/cjs/fieldTypes/seo.js +7 -1
  28. package/dist/cjs/fieldTypes/seo.js.map +1 -1
  29. package/dist/cjs/fieldTypes/single_block.js +19 -1
  30. package/dist/cjs/fieldTypes/single_block.js.map +1 -1
  31. package/dist/cjs/fieldTypes/slug.js +8 -2
  32. package/dist/cjs/fieldTypes/slug.js.map +1 -1
  33. package/dist/cjs/fieldTypes/string.js +7 -1
  34. package/dist/cjs/fieldTypes/string.js.map +1 -1
  35. package/dist/cjs/fieldTypes/structured_text.js +19 -1
  36. package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
  37. package/dist/cjs/fieldTypes/text.js +7 -1
  38. package/dist/cjs/fieldTypes/text.js.map +1 -1
  39. package/dist/cjs/fieldTypes/video.js +7 -1
  40. package/dist/cjs/fieldTypes/video.js.map +1 -1
  41. package/dist/cjs/generated/Client.js +1 -1
  42. package/dist/cjs/generated/resources/Item.js +41 -23
  43. package/dist/cjs/generated/resources/Item.js.map +1 -1
  44. package/dist/cjs/generated/resources/ScheduledPublication.js +4 -2
  45. package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
  46. package/dist/cjs/generated/resources/ScheduledUnpublishing.js +4 -2
  47. package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
  48. package/dist/cjs/generated/resources/Upload.js +4 -2
  49. package/dist/cjs/generated/resources/Upload.js.map +1 -1
  50. package/dist/cjs/index.js +2 -0
  51. package/dist/cjs/index.js.map +1 -1
  52. package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
  53. package/dist/cjs/utilities/itemDefinition.js +3 -0
  54. package/dist/cjs/utilities/itemDefinition.js.map +1 -0
  55. package/dist/esm/fieldTypes/boolean.d.ts +2 -0
  56. package/dist/esm/fieldTypes/boolean.js +5 -0
  57. package/dist/esm/fieldTypes/boolean.js.map +1 -1
  58. package/dist/esm/fieldTypes/color.d.ts +2 -0
  59. package/dist/esm/fieldTypes/color.js +5 -0
  60. package/dist/esm/fieldTypes/color.js.map +1 -1
  61. package/dist/esm/fieldTypes/date.d.ts +2 -0
  62. package/dist/esm/fieldTypes/date.js +5 -0
  63. package/dist/esm/fieldTypes/date.js.map +1 -1
  64. package/dist/esm/fieldTypes/date_time.d.ts +2 -0
  65. package/dist/esm/fieldTypes/date_time.js +5 -0
  66. package/dist/esm/fieldTypes/date_time.js.map +1 -1
  67. package/dist/esm/fieldTypes/file.d.ts +2 -0
  68. package/dist/esm/fieldTypes/file.js +5 -0
  69. package/dist/esm/fieldTypes/file.js.map +1 -1
  70. package/dist/esm/fieldTypes/float.d.ts +2 -0
  71. package/dist/esm/fieldTypes/float.js +5 -0
  72. package/dist/esm/fieldTypes/float.js.map +1 -1
  73. package/dist/esm/fieldTypes/gallery.d.ts +2 -0
  74. package/dist/esm/fieldTypes/gallery.js +5 -0
  75. package/dist/esm/fieldTypes/gallery.js.map +1 -1
  76. package/dist/esm/fieldTypes/integer.d.ts +2 -0
  77. package/dist/esm/fieldTypes/integer.js +5 -0
  78. package/dist/esm/fieldTypes/integer.js.map +1 -1
  79. package/dist/esm/fieldTypes/json.d.ts +2 -0
  80. package/dist/esm/fieldTypes/json.js +5 -0
  81. package/dist/esm/fieldTypes/json.js.map +1 -1
  82. package/dist/esm/fieldTypes/lat_lon.d.ts +6 -4
  83. package/dist/esm/fieldTypes/lat_lon.js +6 -1
  84. package/dist/esm/fieldTypes/lat_lon.js.map +1 -1
  85. package/dist/esm/fieldTypes/link.d.ts +2 -0
  86. package/dist/esm/fieldTypes/link.js +5 -0
  87. package/dist/esm/fieldTypes/link.js.map +1 -1
  88. package/dist/esm/fieldTypes/links.d.ts +2 -0
  89. package/dist/esm/fieldTypes/links.js +5 -0
  90. package/dist/esm/fieldTypes/links.js.map +1 -1
  91. package/dist/esm/fieldTypes/rich_text.d.ts +13 -8
  92. package/dist/esm/fieldTypes/rich_text.js +15 -0
  93. package/dist/esm/fieldTypes/rich_text.js.map +1 -1
  94. package/dist/esm/fieldTypes/seo.d.ts +2 -0
  95. package/dist/esm/fieldTypes/seo.js +5 -0
  96. package/dist/esm/fieldTypes/seo.js.map +1 -1
  97. package/dist/esm/fieldTypes/single_block.d.ts +17 -12
  98. package/dist/esm/fieldTypes/single_block.js +15 -0
  99. package/dist/esm/fieldTypes/single_block.js.map +1 -1
  100. package/dist/esm/fieldTypes/slug.d.ts +2 -0
  101. package/dist/esm/fieldTypes/slug.js +6 -1
  102. package/dist/esm/fieldTypes/slug.js.map +1 -1
  103. package/dist/esm/fieldTypes/string.d.ts +2 -0
  104. package/dist/esm/fieldTypes/string.js +5 -0
  105. package/dist/esm/fieldTypes/string.js.map +1 -1
  106. package/dist/esm/fieldTypes/structured_text.d.ts +15 -10
  107. package/dist/esm/fieldTypes/structured_text.js +15 -0
  108. package/dist/esm/fieldTypes/structured_text.js.map +1 -1
  109. package/dist/esm/fieldTypes/text.d.ts +2 -0
  110. package/dist/esm/fieldTypes/text.js +5 -0
  111. package/dist/esm/fieldTypes/text.js.map +1 -1
  112. package/dist/esm/fieldTypes/video.d.ts +2 -0
  113. package/dist/esm/fieldTypes/video.js +5 -0
  114. package/dist/esm/fieldTypes/video.js.map +1 -1
  115. package/dist/esm/generated/ApiTypes.d.ts +67 -62
  116. package/dist/esm/generated/Client.js +1 -1
  117. package/dist/esm/generated/RawApiTypes.d.ts +116 -121
  118. package/dist/esm/generated/resources/Field.d.ts +700 -700
  119. package/dist/esm/generated/resources/Item.d.ts +42 -24
  120. package/dist/esm/generated/resources/Item.js +41 -23
  121. package/dist/esm/generated/resources/Item.js.map +1 -1
  122. package/dist/esm/generated/resources/ItemVersion.d.ts +1 -1
  123. package/dist/esm/generated/resources/ScheduledPublication.d.ts +5 -2
  124. package/dist/esm/generated/resources/ScheduledPublication.js +4 -2
  125. package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
  126. package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +5 -2
  127. package/dist/esm/generated/resources/ScheduledUnpublishing.js +4 -2
  128. package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
  129. package/dist/esm/generated/resources/Upload.d.ts +10 -2
  130. package/dist/esm/generated/resources/Upload.js +4 -2
  131. package/dist/esm/generated/resources/Upload.js.map +1 -1
  132. package/dist/esm/index.d.ts +2 -0
  133. package/dist/esm/index.js +2 -0
  134. package/dist/esm/index.js.map +1 -1
  135. package/dist/esm/utilities/buildBlockRecord.d.ts +5 -31
  136. package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
  137. package/dist/esm/utilities/fieldValue.d.ts +1 -1
  138. package/dist/esm/utilities/itemDefinition.d.ts +74 -0
  139. package/dist/esm/utilities/itemDefinition.js +2 -0
  140. package/dist/esm/utilities/itemDefinition.js.map +1 -0
  141. package/dist/types/fieldTypes/boolean.d.ts +2 -0
  142. package/dist/types/fieldTypes/color.d.ts +2 -0
  143. package/dist/types/fieldTypes/date.d.ts +2 -0
  144. package/dist/types/fieldTypes/date_time.d.ts +2 -0
  145. package/dist/types/fieldTypes/file.d.ts +2 -0
  146. package/dist/types/fieldTypes/float.d.ts +2 -0
  147. package/dist/types/fieldTypes/gallery.d.ts +2 -0
  148. package/dist/types/fieldTypes/integer.d.ts +2 -0
  149. package/dist/types/fieldTypes/json.d.ts +2 -0
  150. package/dist/types/fieldTypes/lat_lon.d.ts +6 -4
  151. package/dist/types/fieldTypes/link.d.ts +2 -0
  152. package/dist/types/fieldTypes/links.d.ts +2 -0
  153. package/dist/types/fieldTypes/rich_text.d.ts +13 -8
  154. package/dist/types/fieldTypes/seo.d.ts +2 -0
  155. package/dist/types/fieldTypes/single_block.d.ts +17 -12
  156. package/dist/types/fieldTypes/slug.d.ts +2 -0
  157. package/dist/types/fieldTypes/string.d.ts +2 -0
  158. package/dist/types/fieldTypes/structured_text.d.ts +15 -10
  159. package/dist/types/fieldTypes/text.d.ts +2 -0
  160. package/dist/types/fieldTypes/video.d.ts +2 -0
  161. package/dist/types/generated/ApiTypes.d.ts +67 -62
  162. package/dist/types/generated/RawApiTypes.d.ts +116 -121
  163. package/dist/types/generated/resources/Field.d.ts +700 -700
  164. package/dist/types/generated/resources/Item.d.ts +42 -24
  165. package/dist/types/generated/resources/ItemVersion.d.ts +1 -1
  166. package/dist/types/generated/resources/ScheduledPublication.d.ts +5 -2
  167. package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +5 -2
  168. package/dist/types/generated/resources/Upload.d.ts +10 -2
  169. package/dist/types/index.d.ts +2 -0
  170. package/dist/types/utilities/buildBlockRecord.d.ts +5 -31
  171. package/dist/types/utilities/fieldValue.d.ts +1 -1
  172. package/dist/types/utilities/itemDefinition.d.ts +74 -0
  173. package/package.json +5 -5
  174. package/resources.json +564 -0
  175. package/src/fieldTypes/boolean.ts +11 -0
  176. package/src/fieldTypes/color.ts +11 -0
  177. package/src/fieldTypes/date.ts +11 -0
  178. package/src/fieldTypes/date_time.ts +11 -0
  179. package/src/fieldTypes/file.ts +11 -0
  180. package/src/fieldTypes/float.ts +11 -0
  181. package/src/fieldTypes/gallery.ts +11 -0
  182. package/src/fieldTypes/integer.ts +11 -0
  183. package/src/fieldTypes/json.ts +11 -0
  184. package/src/fieldTypes/lat_lon.ts +15 -6
  185. package/src/fieldTypes/link.ts +11 -0
  186. package/src/fieldTypes/links.ts +11 -0
  187. package/src/fieldTypes/rich_text.ts +51 -12
  188. package/src/fieldTypes/seo.ts +11 -0
  189. package/src/fieldTypes/single_block.ts +69 -28
  190. package/src/fieldTypes/slug.ts +12 -1
  191. package/src/fieldTypes/string.ts +11 -0
  192. package/src/fieldTypes/structured_text.ts +87 -19
  193. package/src/fieldTypes/text.ts +11 -0
  194. package/src/fieldTypes/video.ts +11 -0
  195. package/src/generated/ApiTypes.ts +110 -70
  196. package/src/generated/Client.ts +1 -1
  197. package/src/generated/RawApiTypes.ts +160 -138
  198. package/src/generated/resources/Item.ts +360 -108
  199. package/src/generated/resources/ScheduledPublication.ts +31 -11
  200. package/src/generated/resources/ScheduledUnpublishing.ts +31 -11
  201. package/src/generated/resources/Upload.ts +54 -12
  202. package/src/index.ts +2 -0
  203. package/src/utilities/buildBlockRecord.ts +19 -3
  204. package/src/utilities/fieldValue.ts +1 -1
  205. package/src/utilities/itemDefinition.ts +229 -0
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { BooleanEditorConfiguration } from './appearance/boolean';
2
3
  import type { BooleanRadioGroupEditorConfiguration } from './appearance/boolean_radio_group';
3
4
 
@@ -9,6 +10,16 @@ export function isBooleanFieldValue(
9
10
  return typeof value === 'boolean' || value === null;
10
11
  }
11
12
 
13
+ export function isLocalizedBooleanFieldValue(
14
+ value: unknown,
15
+ ): value is LocalizedFieldValue<BooleanFieldValue> {
16
+ return (
17
+ typeof value === 'object' &&
18
+ value !== null &&
19
+ Object.values(value).every(isBooleanFieldValue)
20
+ );
21
+ }
22
+
12
23
  export type BooleanFieldValidators = Record<string, never>;
13
24
 
14
25
  export type BooleanFieldAppearance =
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { ColorPickerEditorConfiguration } from './appearance/color_picker';
2
3
  import type { RequiredValidator } from './validators/required';
3
4
 
@@ -20,6 +21,16 @@ export function isColorFieldValue(value: unknown): value is ColorFieldValue {
20
21
  );
21
22
  }
22
23
 
24
+ export function isLocalizedColorFieldValue(
25
+ value: unknown,
26
+ ): value is LocalizedFieldValue<ColorFieldValue> {
27
+ return (
28
+ typeof value === 'object' &&
29
+ value !== null &&
30
+ Object.values(value).every(isColorFieldValue)
31
+ );
32
+ }
33
+
23
34
  export type ColorFieldValidators = {
24
35
  /** Value must be specified or it won't be valid */
25
36
  required?: RequiredValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { DatePickerEditorConfiguration } from './appearance/date_picker';
2
3
  import type { DateRangeValidator } from './validators/date_range';
3
4
  import type { RequiredValidator } from './validators/required';
@@ -9,6 +10,16 @@ export function isDateFieldValue(value: unknown): value is DateFieldValue {
9
10
  return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value);
10
11
  }
11
12
 
13
+ export function isLocalizedDateFieldValue(
14
+ value: unknown,
15
+ ): value is LocalizedFieldValue<DateFieldValue> {
16
+ return (
17
+ typeof value === 'object' &&
18
+ value !== null &&
19
+ Object.values(value).every(isDateFieldValue)
20
+ );
21
+ }
22
+
12
23
  export type DateFieldValidators = {
13
24
  /** Value must be specified or it won't be valid */
14
25
  required?: RequiredValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { DateTimePickerEditorConfiguration } from './appearance/date_time_picker';
2
3
  import type { DateTimeRangeValidator } from './validators/date_time_range';
3
4
  import type { RequiredValidator } from './validators/required';
@@ -14,6 +15,16 @@ export function isDateTimeFieldValue(
14
15
  );
15
16
  }
16
17
 
18
+ export function isLocalizedDateTimeFieldValue(
19
+ value: unknown,
20
+ ): value is LocalizedFieldValue<DateTimeFieldValue> {
21
+ return (
22
+ typeof value === 'object' &&
23
+ value !== null &&
24
+ Object.values(value).every(isDateTimeFieldValue)
25
+ );
26
+ }
27
+
17
28
  export type DateTimeFieldValidators = {
18
29
  /** Value must be specified or it won't be valid */
19
30
  required?: RequiredValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { FileEditorConfiguration } from './appearance/file';
2
3
  import type { ExtensionValidator } from './validators/extension';
3
4
  import type { FileSizeValidator } from './validators/file_size';
@@ -22,6 +23,16 @@ export function isFileFieldValue(value: unknown): value is FileFieldValue {
22
23
  return typeof value === 'object' && value !== null && 'upload_id' in value;
23
24
  }
24
25
 
26
+ export function isLocalizedFileFieldValue(
27
+ value: unknown,
28
+ ): value is LocalizedFieldValue<FileFieldValue> {
29
+ return (
30
+ typeof value === 'object' &&
31
+ value !== null &&
32
+ Object.values(value).every(isFileFieldValue)
33
+ );
34
+ }
35
+
25
36
  export type FileFieldValidators = {
26
37
  /** Value must be specified or it won't be valid */
27
38
  required?: RequiredValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { FloatEditorConfiguration } from './appearance/float';
2
3
  import type { NumberRangeValidator } from './validators/number_range';
3
4
  import type { RequiredValidator } from './validators/required';
@@ -8,6 +9,16 @@ export function isFloatFieldValue(value: unknown): value is FloatFieldValue {
8
9
  return typeof value === 'number' || value === null;
9
10
  }
10
11
 
12
+ export function isLocalizedFloatFieldValue(
13
+ value: unknown,
14
+ ): value is LocalizedFieldValue<FloatFieldValue> {
15
+ return (
16
+ typeof value === 'object' &&
17
+ value !== null &&
18
+ Object.values(value).every(isFloatFieldValue)
19
+ );
20
+ }
21
+
11
22
  export type FloatFieldValidators = {
12
23
  /** Value must be specified or it won't be valid */
13
24
  required?: RequiredValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { GalleryEditorConfiguration } from './appearance/gallery';
2
3
  import type { ExtensionValidator } from './validators/extension';
3
4
  import type { FileSizeValidator } from './validators/file_size';
@@ -30,6 +31,16 @@ export function isGalleryFieldValue(
30
31
  );
31
32
  }
32
33
 
34
+ export function isLocalizedGalleryFieldValue(
35
+ value: unknown,
36
+ ): value is LocalizedFieldValue<GalleryFieldValue> {
37
+ return (
38
+ typeof value === 'object' &&
39
+ value !== null &&
40
+ Object.values(value).every(isGalleryFieldValue)
41
+ );
42
+ }
43
+
33
44
  export type GalleryFieldValidators = {
34
45
  /** Only accept a number of items within the specified range */
35
46
  size?: SizeValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { IntegerEditorConfiguration } from './appearance/integer';
2
3
  import type { NumberRangeValidator } from './validators/number_range';
3
4
  import type { RequiredValidator } from './validators/required';
@@ -10,6 +11,16 @@ export function isIntegerFieldValue(
10
11
  return typeof value === 'number' || value === null;
11
12
  }
12
13
 
14
+ export function isLocalizedIntegerFieldValue(
15
+ value: unknown,
16
+ ): value is LocalizedFieldValue<IntegerFieldValue> {
17
+ return (
18
+ typeof value === 'object' &&
19
+ value !== null &&
20
+ Object.values(value).every(isIntegerFieldValue)
21
+ );
22
+ }
23
+
13
24
  export type IntegerFieldValidators = {
14
25
  /** Value must be specified or it won't be valid */
15
26
  required?: RequiredValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { JsonEditorConfiguration } from './appearance/json';
2
3
  import type { StringCheckboxGroupEditorConfiguration } from './appearance/string_checkbox_group';
3
4
  import type { StringMultiSelectEditorConfiguration } from './appearance/string_multi_select';
@@ -16,6 +17,16 @@ export function isJsonFieldValue(value: unknown): value is JsonFieldValue {
16
17
  }
17
18
  }
18
19
 
20
+ export function isLocalizedJsonFieldValue(
21
+ value: unknown,
22
+ ): value is LocalizedFieldValue<JsonFieldValue> {
23
+ return (
24
+ typeof value === 'object' &&
25
+ value !== null &&
26
+ Object.values(value).every(isJsonFieldValue)
27
+ );
28
+ }
29
+
19
30
  export type JsonFieldValidators = {
20
31
  /** Value must be specified or it won't be valid */
21
32
  required?: RequiredValidator;
@@ -1,14 +1,13 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { MapEditorConfiguration } from './appearance/map';
2
3
  import type { RequiredValidator } from './validators/required';
3
4
 
4
- export type LocationFieldValue = {
5
+ export type LatLonFieldValue = {
5
6
  latitude: number;
6
7
  longitude: number;
7
8
  } | null;
8
9
 
9
- export function isLocationFieldValue(
10
- value: unknown,
11
- ): value is LocationFieldValue {
10
+ export function isLatLonFieldValue(value: unknown): value is LatLonFieldValue {
12
11
  if (value === null) return true;
13
12
  return (
14
13
  typeof value === 'object' &&
@@ -18,12 +17,22 @@ export function isLocationFieldValue(
18
17
  );
19
18
  }
20
19
 
21
- export type LocationFieldValidators = {
20
+ export function isLocalizedLatLonFieldValue(
21
+ value: unknown,
22
+ ): value is LocalizedFieldValue<LatLonFieldValue> {
23
+ return (
24
+ typeof value === 'object' &&
25
+ value !== null &&
26
+ Object.values(value).every(isLatLonFieldValue)
27
+ );
28
+ }
29
+
30
+ export type LatLonFieldValidators = {
22
31
  /** Value must be specified or it won't be valid */
23
32
  required?: RequiredValidator;
24
33
  };
25
34
 
26
- export type LocationFieldAppearance =
35
+ export type LatLonFieldAppearance =
27
36
  | { editor: 'map'; parameters: MapEditorConfiguration }
28
37
  | {
29
38
  /** Plugin ID */
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { LinkEmbedEditorConfiguration } from './appearance/link_embed';
2
3
  import type { LinkSelectEditorConfiguration } from './appearance/link_select';
3
4
  import type { ItemItemTypeValidator } from './validators/item_item_type';
@@ -10,6 +11,16 @@ export function isLinkFieldValue(value: unknown): value is LinkFieldValue {
10
11
  return typeof value === 'string' || value === null;
11
12
  }
12
13
 
14
+ export function isLocalizedLinkFieldValue(
15
+ value: unknown,
16
+ ): value is LocalizedFieldValue<LinkFieldValue> {
17
+ return (
18
+ typeof value === 'object' &&
19
+ value !== null &&
20
+ Object.values(value).every(isLinkFieldValue)
21
+ );
22
+ }
23
+
13
24
  export type LinkFieldValidators = {
14
25
  /** Only accept references to records of the specified models */
15
26
  item_item_type: ItemItemTypeValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { LinksEmbedEditorConfiguration } from './appearance/links_embed';
2
3
  import type { LinksSelectEditorConfiguration } from './appearance/links_select';
3
4
  import type { ItemsItemTypeValidator } from './validators/items_item_type';
@@ -12,6 +13,16 @@ export function isLinksFieldValue(value: unknown): value is LinksFieldValue {
12
13
  );
13
14
  }
14
15
 
16
+ export function isLocalizedLinksFieldValue(
17
+ value: unknown,
18
+ ): value is LocalizedFieldValue<LinksFieldValue> {
19
+ return (
20
+ typeof value === 'object' &&
21
+ value !== null &&
22
+ Object.values(value).every(isLinksFieldValue)
23
+ );
24
+ }
25
+
15
26
  export type LinksFieldValidators = {
16
27
  /** Only accept references to records of the specified models */
17
28
  items_item_type: ItemsItemTypeValidator;
@@ -1,10 +1,15 @@
1
1
  import type * as RawApiTypes from '../generated/RawApiTypes';
2
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
3
+ import type { ItemDefinition } from '../utilities/itemDefinition';
4
+ import type { RichTextEditorConfiguration } from './appearance/rich_text';
2
5
  import {
3
6
  type BlockItemInARequest,
4
7
  isItemId,
5
8
  isItemWithOptionalIdAndMeta,
6
9
  isItemWithOptionalMeta,
7
10
  } from './single_block';
11
+ import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
12
+ import type { SizeValidator } from './validators/size';
8
13
 
9
14
  /**
10
15
  * MODULAR CONTENT FIELD TYPE SYSTEM FOR DATOCMS
@@ -37,7 +42,7 @@ import {
37
42
  /**
38
43
  * Basic Modular Content field value - array of string block IDs (lightweight references)
39
44
  */
40
- export type RichTextFieldValue = string[] | null;
45
+ export type RichTextFieldValue = string[];
41
46
 
42
47
  /**
43
48
  * =============================================================================
@@ -56,7 +61,9 @@ export type RichTextFieldValue = string[] | null;
56
61
  * - RawApiTypes.Item: Full block object with ID (for updates)
57
62
  * - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
58
63
  */
59
- export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
64
+ export type RichTextFieldValueAsRequest<
65
+ D extends ItemDefinition = ItemDefinition,
66
+ > = BlockItemInARequest<D>[] | null;
60
67
 
61
68
  /**
62
69
  * =============================================================================
@@ -71,7 +78,9 @@ export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
71
78
  /**
72
79
  * Modular Content field value with nested blocks - array of fully populated block objects
73
80
  */
74
- export type RichTextFieldValueWithNestedBlocks = RawApiTypes.Item[] | null;
81
+ export type RichTextFieldValueWithNestedBlocks<
82
+ D extends ItemDefinition = ItemDefinition,
83
+ > = RawApiTypes.Item<D>[];
75
84
 
76
85
  /**
77
86
  * =============================================================================
@@ -93,13 +102,23 @@ export function isRichTextFieldValue(
93
102
  );
94
103
  }
95
104
 
105
+ export function isLocalizedRichTextFieldValue(
106
+ value: unknown,
107
+ ): value is LocalizedFieldValue<RichTextFieldValue> {
108
+ return (
109
+ typeof value === 'object' &&
110
+ value !== null &&
111
+ Object.values(value).every(isRichTextFieldValue)
112
+ );
113
+ }
114
+
96
115
  /**
97
116
  * Type guard for Modular Content field values in API request format.
98
117
  * Allows blocks as string IDs, full objects with IDs, or objects without IDs.
99
118
  */
100
- export function isRichTextFieldValueAsRequest(
101
- value: unknown,
102
- ): value is RichTextFieldValueAsRequest {
119
+ export function isRichTextFieldValueAsRequest<
120
+ D extends ItemDefinition = ItemDefinition,
121
+ >(value: unknown): value is RichTextFieldValueAsRequest<D> {
103
122
  if (value === null) return true;
104
123
 
105
124
  if (!Array.isArray(value)) return false;
@@ -113,13 +132,25 @@ export function isRichTextFieldValueAsRequest(
113
132
  });
114
133
  }
115
134
 
135
+ export function isLocalizedRichTextFieldValueAsRequest<
136
+ D extends ItemDefinition = ItemDefinition,
137
+ >(
138
+ value: unknown,
139
+ ): value is LocalizedFieldValue<RichTextFieldValueAsRequest<D>> {
140
+ return (
141
+ typeof value === 'object' &&
142
+ value !== null &&
143
+ Object.values(value).every(isRichTextFieldValueAsRequest)
144
+ );
145
+ }
146
+
116
147
  /**
117
148
  * Type guard for Modular Content field values with nested blocks (?nested=true format).
118
149
  * Ensures all blocks are full RawApiTypes.Item objects with complete data.
119
150
  */
120
- export function isRichTextFieldValueWithNestedBlocks(
121
- value: unknown,
122
- ): value is RichTextFieldValueWithNestedBlocks {
151
+ export function isRichTextFieldValueWithNestedBlocks<
152
+ D extends ItemDefinition = ItemDefinition,
153
+ >(value: unknown): value is RichTextFieldValueWithNestedBlocks<D> {
123
154
  if (value === null) return true;
124
155
 
125
156
  if (!Array.isArray(value)) return false;
@@ -130,9 +161,17 @@ export function isRichTextFieldValueWithNestedBlocks(
130
161
  });
131
162
  }
132
163
 
133
- import type { RichTextEditorConfiguration } from './appearance/rich_text';
134
- import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
135
- import type { SizeValidator } from './validators/size';
164
+ export function isLocalizedRichTextFieldValueWithNestedBlocks<
165
+ D extends ItemDefinition = ItemDefinition,
166
+ >(
167
+ value: unknown,
168
+ ): value is LocalizedFieldValue<RichTextFieldValueWithNestedBlocks<D>> {
169
+ return (
170
+ typeof value === 'object' &&
171
+ value !== null &&
172
+ Object.values(value).every(isRichTextFieldValueWithNestedBlocks)
173
+ );
174
+ }
136
175
 
137
176
  export type RichTextFieldValidators = {
138
177
  /** Only accept references to block records of the specified block models */
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { SeoEditorConfiguration } from './appearance/seo';
2
3
  import type { DescriptionLengthValidator } from './validators/description_length';
3
4
  import type { FileSizeValidator } from './validators/file_size';
@@ -27,6 +28,16 @@ export function isSeoFieldValue(value: unknown): value is SeoFieldValue {
27
28
  );
28
29
  }
29
30
 
31
+ export function isLocalizedSeoFieldValue(
32
+ value: unknown,
33
+ ): value is LocalizedFieldValue<SeoFieldValue> {
34
+ return (
35
+ typeof value === 'object' &&
36
+ value !== null &&
37
+ Object.values(value).every(isSeoFieldValue)
38
+ );
39
+ }
40
+
30
41
  export type SeoFieldValidators = {
31
42
  /** SEO field has to specify one or more properties, or it won't be valid */
32
43
  required_seo_fields?: RequiredSeoFieldsValidator;
@@ -1,4 +1,6 @@
1
1
  import type * as RawApiTypes from '../generated/RawApiTypes';
2
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
3
+ import type { ItemDefinition } from '../utilities/itemDefinition';
2
4
 
3
5
  import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
4
6
  import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
@@ -50,14 +52,15 @@ export type SingleBlockFieldValue = string | null;
50
52
  */
51
53
 
52
54
  /** Represents an existing block in a CMA request */
53
- export type UnchangedBlockInARequest = string;
55
+ export type UnchangedBlockInARequest<
56
+ D extends ItemDefinition = ItemDefinition,
57
+ > = RawApiTypes.Item<D>['id'];
54
58
  /** Represents a block we want to update in a CMA request */
55
- export type UpdatedBlockInARequest = OptionalFields<RawApiTypes.Item, 'meta'>;
59
+ export type UpdatedBlockInARequest<D extends ItemDefinition = ItemDefinition> =
60
+ OptionalFields<RawApiTypes.Item<D>, 'meta'>;
56
61
  /** Represents a new block to create in a CMA request */
57
- export type NewBlockInARequest = OptionalFields<
58
- RawApiTypes.Item,
59
- 'id' | 'meta'
60
- >;
62
+ export type NewBlockInARequest<D extends ItemDefinition = ItemDefinition> =
63
+ OptionalFields<RawApiTypes.Item<D>, 'id' | 'meta'>;
61
64
 
62
65
  /**
63
66
  * Union type representing the different ways a block can be specified in API requests:
@@ -67,10 +70,10 @@ export type NewBlockInARequest = OptionalFields<
67
70
  *
68
71
  * Also, 'meta' can always be omitted
69
72
  */
70
- export type BlockItemInARequest =
73
+ export type BlockItemInARequest<D extends ItemDefinition = ItemDefinition> =
71
74
  | UnchangedBlockInARequest
72
- | UpdatedBlockInARequest
73
- | NewBlockInARequest;
75
+ | UpdatedBlockInARequest<D>
76
+ | NewBlockInARequest<D>;
74
77
 
75
78
  /**
76
79
  * Single Block field value for API requests - allows flexible block representations:
@@ -78,7 +81,9 @@ export type BlockItemInARequest =
78
81
  * - Full block object with ID (to update an existing block)
79
82
  * - Block object without ID (to create a new block)
80
83
  */
81
- export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
84
+ export type SingleBlockFieldValueAsRequest<
85
+ D extends ItemDefinition = ItemDefinition,
86
+ > = BlockItemInARequest<D> | null;
82
87
 
83
88
  /**
84
89
  * =============================================================================
@@ -93,7 +98,9 @@ export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
93
98
  /**
94
99
  * Single Block field value with nested block - fully populated block object
95
100
  */
96
- export type SingleBlockFieldValueWithNestedBlocks = RawApiTypes.Item | null;
101
+ export type SingleBlockFieldValueWithNestedBlocks<
102
+ D extends ItemDefinition = ItemDefinition,
103
+ > = RawApiTypes.Item<D> | null;
97
104
 
98
105
  /**
99
106
  * =============================================================================
@@ -109,17 +116,16 @@ export function isItemId(input: unknown): input is string {
109
116
  return typeof input === 'string';
110
117
  }
111
118
 
112
- export type ItemWithOptionalIdAndMeta = OptionalFields<
113
- RawApiTypes.Item,
114
- 'id' | 'meta'
115
- >;
119
+ export type ItemWithOptionalIdAndMeta<
120
+ D extends ItemDefinition = ItemDefinition,
121
+ > = OptionalFields<RawApiTypes.Item<D>, 'id' | 'meta'>;
116
122
 
117
123
  /**
118
124
  * Validates if the input is a RawApiTypes.Item object (with optional `id` and `meta`)
119
125
  */
120
- export function isItemWithOptionalIdAndMeta(
121
- block: unknown,
122
- ): block is ItemWithOptionalIdAndMeta {
126
+ export function isItemWithOptionalIdAndMeta<
127
+ D extends ItemDefinition = ItemDefinition,
128
+ >(block: unknown): block is ItemWithOptionalIdAndMeta<D> {
123
129
  return (
124
130
  typeof block === 'object' &&
125
131
  block !== null &&
@@ -128,14 +134,15 @@ export function isItemWithOptionalIdAndMeta(
128
134
  );
129
135
  }
130
136
 
131
- export type ItemWithOptionalMeta = OptionalFields<RawApiTypes.Item, 'meta'>;
137
+ export type ItemWithOptionalMeta<D extends ItemDefinition = ItemDefinition> =
138
+ OptionalFields<RawApiTypes.Item<D>, 'meta'>;
132
139
 
133
140
  /**
134
141
  * Validates if the input is a a complete RawApiTypes.Item object with optional `meta`
135
142
  */
136
- export function isItemWithOptionalMeta(
137
- block: unknown,
138
- ): block is ItemWithOptionalMeta {
143
+ export function isItemWithOptionalMeta<
144
+ D extends ItemDefinition = ItemDefinition,
145
+ >(block: unknown): block is ItemWithOptionalMeta<D> {
139
146
  return (
140
147
  isItemWithOptionalIdAndMeta(block) &&
141
148
  'id' in block &&
@@ -159,13 +166,23 @@ export function isSingleBlockFieldValue(
159
166
  return typeof value === 'string' || value === null;
160
167
  }
161
168
 
169
+ export function isLocalizedSingleBlockFieldValue(
170
+ value: unknown,
171
+ ): value is LocalizedFieldValue<SingleBlockFieldValue> {
172
+ return (
173
+ typeof value === 'object' &&
174
+ value !== null &&
175
+ Object.values(value).every(isSingleBlockFieldValue)
176
+ );
177
+ }
178
+
162
179
  /**
163
180
  * Type guard for Single Block field values in API request format.
164
181
  * Allows block as string ID, full object with ID, or object without ID.
165
182
  */
166
- export function isSingleBlockFieldValueAsRequest(
167
- value: unknown,
168
- ): value is SingleBlockFieldValueAsRequest {
183
+ export function isSingleBlockFieldValueAsRequest<
184
+ D extends ItemDefinition = ItemDefinition,
185
+ >(value: unknown): value is SingleBlockFieldValueAsRequest<D> {
169
186
  if (value === null) return true;
170
187
 
171
188
  // String ID - referencing existing block
@@ -175,19 +192,43 @@ export function isSingleBlockFieldValueAsRequest(
175
192
  return isItemWithOptionalIdAndMeta(value);
176
193
  }
177
194
 
195
+ export function isLocalizedSingleBlockFieldValueAsRequest<
196
+ D extends ItemDefinition = ItemDefinition,
197
+ >(
198
+ value: unknown,
199
+ ): value is LocalizedFieldValue<SingleBlockFieldValueAsRequest<D>> {
200
+ return (
201
+ typeof value === 'object' &&
202
+ value !== null &&
203
+ Object.values(value).every(isSingleBlockFieldValueAsRequest)
204
+ );
205
+ }
206
+
178
207
  /**
179
208
  * Type guard for Single Block field values with nested blocks (?nested=true format).
180
209
  * Ensures block is a full RawApiTypes.Item object with complete data.
181
210
  */
182
- export function isSingleBlockFieldValueWithNestedBlocks(
183
- value: unknown,
184
- ): value is SingleBlockFieldValueWithNestedBlocks {
211
+ export function isSingleBlockFieldValueWithNestedBlocks<
212
+ D extends ItemDefinition = ItemDefinition,
213
+ >(value: unknown): value is SingleBlockFieldValueWithNestedBlocks<D> {
185
214
  if (value === null) return true;
186
215
 
187
216
  // Must be a full object with ID (nested format always includes complete block objects)
188
217
  return isItemWithOptionalMeta(value);
189
218
  }
190
219
 
220
+ export function isLocalizedSingleBlockFieldValueWithNestedBlocks<
221
+ D extends ItemDefinition = ItemDefinition,
222
+ >(
223
+ value: unknown,
224
+ ): value is LocalizedFieldValue<SingleBlockFieldValueWithNestedBlocks<D>> {
225
+ return (
226
+ typeof value === 'object' &&
227
+ value !== null &&
228
+ Object.values(value).every(isSingleBlockFieldValueWithNestedBlocks)
229
+ );
230
+ }
231
+
191
232
  export type SingleBlockFieldValidators = {
192
233
  /** Only accept references to block records of the specified block models */
193
234
  single_block_blocks: SingleBlockBlocksValidator;
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { SlugEditorConfiguration } from './appearance/slug';
2
3
  import type { LengthValidator } from './validators/length';
3
4
  import type { RequiredValidator } from './validators/required';
@@ -8,7 +9,17 @@ export type SlugFieldValue = string | null;
8
9
 
9
10
  export function isSlugFieldValue(value: unknown): value is SlugFieldValue {
10
11
  if (value === null) return true;
11
- return typeof value === 'string' && /^[a-z0-9_]+(?:-[a-z0-9]+)*$/.test(value);
12
+ return typeof value === 'string';
13
+ }
14
+
15
+ export function isLocalizedSlugFieldValue(
16
+ value: unknown,
17
+ ): value is LocalizedFieldValue<SlugFieldValue> {
18
+ return (
19
+ typeof value === 'object' &&
20
+ value !== null &&
21
+ Object.values(value).every(isSlugFieldValue)
22
+ );
12
23
  }
13
24
 
14
25
  export type SlugFieldValidators = {
@@ -1,3 +1,4 @@
1
+ import type { LocalizedFieldValue } from '../utilities/fieldValue';
1
2
  import type { SingleLineEditorConfiguration } from './appearance/single_line';
2
3
  import type { StringRadioGroupEditorConfiguration } from './appearance/string_radio_group';
3
4
  import type { StringSelectEditorConfiguration } from './appearance/string_select';
@@ -13,6 +14,16 @@ export function isStringFieldValue(value: unknown): value is StringFieldValue {
13
14
  return typeof value === 'string' || value === null;
14
15
  }
15
16
 
17
+ export function isLocalizedStringFieldValue(
18
+ value: unknown,
19
+ ): value is LocalizedFieldValue<StringFieldValue> {
20
+ return (
21
+ typeof value === 'object' &&
22
+ value !== null &&
23
+ Object.values(value).every(isStringFieldValue)
24
+ );
25
+ }
26
+
16
27
  export type StringFieldValidators = {
17
28
  /** Value must be specified or it won't be valid */
18
29
  required?: RequiredValidator;