@datocms/cma-client 5.1.10 → 5.1.11
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.
- package/README.md +575 -0
- package/dist/cjs/fieldTypes/boolean.js +2 -2
- package/dist/cjs/fieldTypes/boolean.js.map +1 -1
- package/dist/cjs/fieldTypes/color.js +2 -2
- package/dist/cjs/fieldTypes/color.js.map +1 -1
- package/dist/cjs/fieldTypes/date.js +2 -3
- package/dist/cjs/fieldTypes/date.js.map +1 -1
- package/dist/cjs/fieldTypes/date_time.js +2 -2
- package/dist/cjs/fieldTypes/date_time.js.map +1 -1
- package/dist/cjs/fieldTypes/file.js +33 -5
- package/dist/cjs/fieldTypes/file.js.map +1 -1
- package/dist/cjs/fieldTypes/float.js +2 -2
- package/dist/cjs/fieldTypes/float.js.map +1 -1
- package/dist/cjs/fieldTypes/gallery.js +20 -5
- package/dist/cjs/fieldTypes/gallery.js.map +1 -1
- package/dist/cjs/fieldTypes/index.js +2 -2
- package/dist/cjs/fieldTypes/index.js.map +1 -1
- package/dist/cjs/fieldTypes/integer.js +2 -2
- package/dist/cjs/fieldTypes/integer.js.map +1 -1
- package/dist/cjs/fieldTypes/json.js +2 -3
- package/dist/cjs/fieldTypes/json.js.map +1 -1
- package/dist/cjs/fieldTypes/lat_lon.js +2 -2
- package/dist/cjs/fieldTypes/lat_lon.js.map +1 -1
- package/dist/cjs/fieldTypes/link.js +4 -4
- package/dist/cjs/fieldTypes/link.js.map +1 -1
- package/dist/cjs/fieldTypes/links.js +5 -3
- package/dist/cjs/fieldTypes/links.js.map +1 -1
- package/dist/cjs/fieldTypes/rich_text.js +4 -6
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/seo.js +2 -3
- package/dist/cjs/fieldTypes/seo.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +7 -7
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/slug.js +2 -3
- package/dist/cjs/fieldTypes/slug.js.map +1 -1
- package/dist/cjs/fieldTypes/string.js +2 -2
- package/dist/cjs/fieldTypes/string.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +4 -6
- package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
- package/dist/cjs/fieldTypes/text.js +2 -3
- package/dist/cjs/fieldTypes/text.js.map +1 -1
- package/dist/cjs/fieldTypes/video.js +2 -2
- package/dist/cjs/fieldTypes/video.js.map +1 -1
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js +8 -7
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/cjs/utilities/inspectItem.js +397 -0
- package/dist/cjs/utilities/inspectItem.js.map +1 -0
- package/dist/cjs/utilities/{blocks.js → nonRecursiveBlocks.js} +106 -111
- package/dist/cjs/utilities/nonRecursiveBlocks.js.map +1 -0
- package/dist/cjs/utilities/{fieldValue.js → normalizedFieldValues.js} +53 -41
- package/dist/cjs/utilities/normalizedFieldValues.js.map +1 -0
- package/dist/cjs/utilities/recursiveBlocks.js +121 -80
- package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
- package/dist/cjs/utilities/schemaRepository.js +2 -2
- package/dist/esm/fieldTypes/boolean.d.ts +1 -1
- package/dist/esm/fieldTypes/boolean.js +2 -2
- package/dist/esm/fieldTypes/boolean.js.map +1 -1
- package/dist/esm/fieldTypes/color.d.ts +1 -1
- package/dist/esm/fieldTypes/color.js +2 -2
- package/dist/esm/fieldTypes/color.js.map +1 -1
- package/dist/esm/fieldTypes/date.d.ts +1 -1
- package/dist/esm/fieldTypes/date.js +2 -3
- package/dist/esm/fieldTypes/date.js.map +1 -1
- package/dist/esm/fieldTypes/date_time.d.ts +1 -1
- package/dist/esm/fieldTypes/date_time.js +2 -2
- package/dist/esm/fieldTypes/date_time.js.map +1 -1
- package/dist/esm/fieldTypes/file.d.ts +68 -1
- package/dist/esm/fieldTypes/file.js +29 -3
- package/dist/esm/fieldTypes/file.js.map +1 -1
- package/dist/esm/fieldTypes/float.d.ts +1 -1
- package/dist/esm/fieldTypes/float.js +2 -2
- package/dist/esm/fieldTypes/float.js.map +1 -1
- package/dist/esm/fieldTypes/gallery.d.ts +27 -11
- package/dist/esm/fieldTypes/gallery.js +17 -4
- package/dist/esm/fieldTypes/gallery.js.map +1 -1
- package/dist/esm/fieldTypes/index.d.ts +2 -2
- package/dist/esm/fieldTypes/index.js +2 -2
- package/dist/esm/fieldTypes/index.js.map +1 -1
- package/dist/esm/fieldTypes/integer.d.ts +1 -1
- package/dist/esm/fieldTypes/integer.js +2 -2
- package/dist/esm/fieldTypes/integer.js.map +1 -1
- package/dist/esm/fieldTypes/json.d.ts +1 -1
- package/dist/esm/fieldTypes/json.js +2 -3
- package/dist/esm/fieldTypes/json.js.map +1 -1
- package/dist/esm/fieldTypes/lat_lon.d.ts +1 -1
- package/dist/esm/fieldTypes/lat_lon.js +2 -2
- package/dist/esm/fieldTypes/lat_lon.js.map +1 -1
- package/dist/esm/fieldTypes/link.d.ts +1 -1
- package/dist/esm/fieldTypes/link.js +4 -4
- package/dist/esm/fieldTypes/link.js.map +1 -1
- package/dist/esm/fieldTypes/links.d.ts +1 -1
- package/dist/esm/fieldTypes/links.js +5 -3
- package/dist/esm/fieldTypes/links.js.map +1 -1
- package/dist/esm/fieldTypes/rich_text.d.ts +1 -1
- package/dist/esm/fieldTypes/rich_text.js +4 -6
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/seo.d.ts +1 -1
- package/dist/esm/fieldTypes/seo.js +2 -3
- package/dist/esm/fieldTypes/seo.js.map +1 -1
- package/dist/esm/fieldTypes/single_block.d.ts +1 -1
- package/dist/esm/fieldTypes/single_block.js +7 -7
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/slug.d.ts +1 -1
- package/dist/esm/fieldTypes/slug.js +2 -3
- package/dist/esm/fieldTypes/slug.js.map +1 -1
- package/dist/esm/fieldTypes/string.d.ts +1 -1
- package/dist/esm/fieldTypes/string.js +2 -2
- package/dist/esm/fieldTypes/string.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +1 -1
- package/dist/esm/fieldTypes/structured_text.js +4 -6
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/fieldTypes/text.d.ts +1 -1
- package/dist/esm/fieldTypes/text.js +2 -3
- package/dist/esm/fieldTypes/text.js.map +1 -1
- package/dist/esm/fieldTypes/video.d.ts +1 -1
- package/dist/esm/fieldTypes/video.js +2 -2
- package/dist/esm/fieldTypes/video.js.map +1 -1
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utilities/buildBlockRecord.js +9 -8
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/dist/esm/utilities/inspectItem.d.ts +8 -0
- package/dist/esm/utilities/inspectItem.js +393 -0
- package/dist/esm/utilities/inspectItem.js.map +1 -0
- package/dist/esm/utilities/itemDefinition.d.ts +28 -4
- package/dist/esm/utilities/nonRecursiveBlocks.d.ts +179 -0
- package/dist/esm/utilities/{blocks.js → nonRecursiveBlocks.js} +91 -96
- package/dist/esm/utilities/nonRecursiveBlocks.js.map +1 -0
- package/dist/{types/utilities/fieldValue.d.ts → esm/utilities/normalizedFieldValues.d.ts} +15 -14
- package/dist/esm/utilities/{fieldValue.js → normalizedFieldValues.js} +39 -28
- package/dist/esm/utilities/normalizedFieldValues.js.map +1 -0
- package/dist/esm/utilities/recursiveBlocks.d.ts +92 -9
- package/dist/esm/utilities/recursiveBlocks.js +113 -72
- package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
- package/dist/esm/utilities/schemaRepository.d.ts +2 -2
- package/dist/esm/utilities/schemaRepository.js +2 -2
- package/dist/types/fieldTypes/boolean.d.ts +1 -1
- package/dist/types/fieldTypes/color.d.ts +1 -1
- package/dist/types/fieldTypes/date.d.ts +1 -1
- package/dist/types/fieldTypes/date_time.d.ts +1 -1
- package/dist/types/fieldTypes/file.d.ts +68 -1
- package/dist/types/fieldTypes/float.d.ts +1 -1
- package/dist/types/fieldTypes/gallery.d.ts +27 -11
- package/dist/types/fieldTypes/index.d.ts +2 -2
- package/dist/types/fieldTypes/integer.d.ts +1 -1
- package/dist/types/fieldTypes/json.d.ts +1 -1
- package/dist/types/fieldTypes/lat_lon.d.ts +1 -1
- package/dist/types/fieldTypes/link.d.ts +1 -1
- package/dist/types/fieldTypes/links.d.ts +1 -1
- package/dist/types/fieldTypes/rich_text.d.ts +1 -1
- package/dist/types/fieldTypes/seo.d.ts +1 -1
- package/dist/types/fieldTypes/single_block.d.ts +1 -1
- package/dist/types/fieldTypes/slug.d.ts +1 -1
- package/dist/types/fieldTypes/string.d.ts +1 -1
- package/dist/types/fieldTypes/structured_text.d.ts +1 -1
- package/dist/types/fieldTypes/text.d.ts +1 -1
- package/dist/types/fieldTypes/video.d.ts +1 -1
- package/dist/types/index.d.ts +4 -4
- package/dist/types/utilities/inspectItem.d.ts +8 -0
- package/dist/types/utilities/itemDefinition.d.ts +28 -4
- package/dist/types/utilities/nonRecursiveBlocks.d.ts +179 -0
- package/dist/{esm/utilities/fieldValue.d.ts → types/utilities/normalizedFieldValues.d.ts} +15 -14
- package/dist/types/utilities/recursiveBlocks.d.ts +92 -9
- package/dist/types/utilities/schemaRepository.d.ts +2 -2
- package/package.json +3 -3
- package/src/fieldTypes/boolean.ts +5 -3
- package/src/fieldTypes/color.ts +5 -3
- package/src/fieldTypes/date.ts +5 -4
- package/src/fieldTypes/date_time.ts +5 -3
- package/src/fieldTypes/file.ts +98 -4
- package/src/fieldTypes/float.ts +5 -3
- package/src/fieldTypes/gallery.ts +53 -20
- package/src/fieldTypes/index.ts +2 -3
- package/src/fieldTypes/integer.ts +5 -3
- package/src/fieldTypes/json.ts +5 -4
- package/src/fieldTypes/lat_lon.ts +5 -3
- package/src/fieldTypes/link.ts +7 -5
- package/src/fieldTypes/links.ts +8 -4
- package/src/fieldTypes/rich_text.ts +7 -7
- package/src/fieldTypes/seo.ts +5 -4
- package/src/fieldTypes/single_block.ts +10 -8
- package/src/fieldTypes/slug.ts +5 -4
- package/src/fieldTypes/string.ts +5 -3
- package/src/fieldTypes/structured_text.ts +7 -7
- package/src/fieldTypes/text.ts +5 -4
- package/src/fieldTypes/video.ts +5 -3
- package/src/generated/Client.ts +1 -1
- package/src/index.ts +4 -4
- package/src/utilities/buildBlockRecord.ts +16 -15
- package/src/utilities/inspectItem.ts +590 -0
- package/src/utilities/itemDefinition.ts +30 -3
- package/src/utilities/{blocks.ts → nonRecursiveBlocks.ts} +170 -136
- package/src/utilities/{fieldValue.ts → normalizedFieldValues.ts} +70 -30
- package/src/utilities/recursiveBlocks.ts +186 -171
- package/src/utilities/schemaRepository.ts +2 -2
- package/dist/cjs/utilities/blocks.js.map +0 -1
- package/dist/cjs/utilities/fieldValue.js.map +0 -1
- package/dist/esm/utilities/blocks.d.ts +0 -180
- package/dist/esm/utilities/blocks.js.map +0 -1
- package/dist/esm/utilities/fieldValue.js.map +0 -1
- package/dist/types/utilities/blocks.d.ts +0 -180
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recursiveBlocks.js","sourceRoot":"","sources":["../../../src/utilities/recursiveBlocks.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"recursiveBlocks.js","sourceRoot":"","sources":["../../../src/utilities/recursiveBlocks.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAEL,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,qDAAqD,EACrD,sDAAsD,EACtD,kDAAkD,EAClD,qDAAqD,EACrD,mDAAmD,EACnD,oDAAoD,GACrD,M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AI,CAAC,CAAC,CAAA,GAAA,EACpD,IAAI,CACL,CAAC,CAAC;IACL,CAAC;CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAgB,iCAAiC,CACrD,gBAAkC,EAClC,SAAuC,EACvC,sBAA+B,EAC/B,MAGuD,EACvD,OAAiB,EAAE;;QAEnB,OAAO,kDAAkD,CACvD,SAAS,EACT,sBAAsB,EACtB,CAAO,KAAK,EAAE,SAAS,EAAE,EAAE;YACzB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;YAE9D,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,EAAE;gBAC1C,OAAO,QAAQ,CAAC;aACjB;YAED,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAC,kBAAkB,CACxD,QAAQ,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CACzC,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;YAErE,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;gBAC1B,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC;oBAC3C,MAAM,iCAAiC,CACrC,gBAAgB,EAChB,SAAS,EACT,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,EAC7C,MAAM,EACN,CAAC,GAAG,IAAI,EAAE,GAAG,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAChE,CAAC;aACL;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAA,CACF,CAAC;IACJ,CAAC;CAAA"}
|
|
@@ -41,7 +41,7 @@ interface GenericClient {
|
|
|
41
41
|
* - **Caching schema entities**: Automatically caches item types, fields, fieldsets,
|
|
42
42
|
* and plugins after the first API request, returning cached results on subsequent calls
|
|
43
43
|
* - **Complex traversal operations**: Essential when using utilities like
|
|
44
|
-
* `
|
|
44
|
+
* `mapBlocksInNonLocalizedFieldValue()` that need to repeatedly lookup block models and fields
|
|
45
45
|
* while traversing nested content structures
|
|
46
46
|
* - **Bulk operations**: Ideal for scripts that process multiple records of different
|
|
47
47
|
* types and need efficient access to schema information
|
|
@@ -73,7 +73,7 @@ interface GenericClient {
|
|
|
73
73
|
* const sameBlogPost = await schemaRepository.getItemTypeByApiKey('blog_post');
|
|
74
74
|
*
|
|
75
75
|
* // Pass the repository to utilities that need schema information
|
|
76
|
-
* await
|
|
76
|
+
* await mapBlocksInNonLocalizedFieldValue(schemaRepository, record, (block) => {
|
|
77
77
|
* // The utility will use the cached schema data internally
|
|
78
78
|
* });
|
|
79
79
|
* ```
|
|
@@ -24,7 +24,7 @@ import { deserializeResponseBody } from '@datocms/rest-client-utils';
|
|
|
24
24
|
* - **Caching schema entities**: Automatically caches item types, fields, fieldsets,
|
|
25
25
|
* and plugins after the first API request, returning cached results on subsequent calls
|
|
26
26
|
* - **Complex traversal operations**: Essential when using utilities like
|
|
27
|
-
* `
|
|
27
|
+
* `mapBlocksInNonLocalizedFieldValue()` that need to repeatedly lookup block models and fields
|
|
28
28
|
* while traversing nested content structures
|
|
29
29
|
* - **Bulk operations**: Ideal for scripts that process multiple records of different
|
|
30
30
|
* types and need efficient access to schema information
|
|
@@ -56,7 +56,7 @@ import { deserializeResponseBody } from '@datocms/rest-client-utils';
|
|
|
56
56
|
* const sameBlogPost = await schemaRepository.getItemTypeByApiKey('blog_post');
|
|
57
57
|
*
|
|
58
58
|
* // Pass the repository to utilities that need schema information
|
|
59
|
-
* await
|
|
59
|
+
* await mapBlocksInNonLocalizedFieldValue(schemaRepository, record, (block) => {
|
|
60
60
|
* // The utility will use the cached schema data internally
|
|
61
61
|
* });
|
|
62
62
|
* ```
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { BooleanEditorConfiguration } from './appearance/boolean';
|
|
3
3
|
import type { BooleanRadioGroupEditorConfiguration } from './appearance/boolean_radio_group';
|
|
4
4
|
export type BooleanFieldValue = boolean | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { ColorPickerEditorConfiguration } from './appearance/color_picker';
|
|
3
3
|
import type { RequiredValidator } from './validators/required';
|
|
4
4
|
export type ColorFieldValue = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { DatePickerEditorConfiguration } from './appearance/date_picker';
|
|
3
3
|
import type { DateRangeValidator } from './validators/date_range';
|
|
4
4
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { DateTimePickerEditorConfiguration } from './appearance/date_time_picker';
|
|
3
3
|
import type { DateTimeRangeValidator } from './validators/date_time_range';
|
|
4
4
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { FileEditorConfiguration } from './appearance/file';
|
|
3
3
|
import type { ExtensionValidator } from './validators/extension';
|
|
4
4
|
import type { FileSizeValidator } from './validators/file_size';
|
|
@@ -6,7 +6,59 @@ import type { ImageAspectRatioValidator } from './validators/image_aspect_ratio'
|
|
|
6
6
|
import type { ImageDimensionsValidator } from './validators/image_dimensions';
|
|
7
7
|
import type { RequiredValidator } from './validators/required';
|
|
8
8
|
import type { RequiredAltTitleValidator } from './validators/required_alt_title';
|
|
9
|
+
/**
|
|
10
|
+
* FILE FIELD TYPE SYSTEM FOR DATOCMS
|
|
11
|
+
*
|
|
12
|
+
* This module defines a comprehensive type system for handling DatoCMS File fields,
|
|
13
|
+
* which contain file uploads with optional metadata like alt text, title, custom data, and focal points.
|
|
14
|
+
*
|
|
15
|
+
* The challenge we're solving:
|
|
16
|
+
* - DatoCMS File fields can have optional metadata fields (alt, title, custom_data, focal_point)
|
|
17
|
+
* - For API requests, all these fields are optional and can be omitted
|
|
18
|
+
* - For API responses, DatoCMS provides default values for missing fields:
|
|
19
|
+
* - alt: null
|
|
20
|
+
* - title: null
|
|
21
|
+
* - custom_data: {}
|
|
22
|
+
* - focal_point: null
|
|
23
|
+
* - This creates a need for different type variants for the same conceptual data structure
|
|
24
|
+
*
|
|
25
|
+
* This module provides separate types for:
|
|
26
|
+
* 1. API request format (optional metadata fields)
|
|
27
|
+
* 2. API response format (all fields present with defaults)
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* =============================================================================
|
|
31
|
+
* BASIC FILE TYPE - Default API response format
|
|
32
|
+
* =============================================================================
|
|
33
|
+
*
|
|
34
|
+
* The standard File field value with all metadata fields present and default values applied.
|
|
35
|
+
* This is what you get from API responses where DatoCMS has applied default values.
|
|
36
|
+
*/
|
|
37
|
+
/**
|
|
38
|
+
* Basic File field value - all metadata fields present with defaults applied
|
|
39
|
+
*/
|
|
9
40
|
export type FileFieldValue = {
|
|
41
|
+
upload_id: string;
|
|
42
|
+
alt: string | null;
|
|
43
|
+
title: string | null;
|
|
44
|
+
custom_data: Record<string, unknown>;
|
|
45
|
+
focal_point: {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
} | null;
|
|
49
|
+
} | null;
|
|
50
|
+
/**
|
|
51
|
+
* =============================================================================
|
|
52
|
+
* REQUEST VARIANT - Type for sending data TO the DatoCMS API
|
|
53
|
+
* =============================================================================
|
|
54
|
+
*
|
|
55
|
+
* When making API requests, metadata fields are optional and can be omitted.
|
|
56
|
+
* DatoCMS will apply default values for any missing fields in the response.
|
|
57
|
+
*/
|
|
58
|
+
/**
|
|
59
|
+
* File field value for API requests - metadata fields are optional
|
|
60
|
+
*/
|
|
61
|
+
export type FileFieldValueAsRequest = {
|
|
10
62
|
upload_id: string;
|
|
11
63
|
alt?: string | null;
|
|
12
64
|
title?: string | null;
|
|
@@ -16,8 +68,23 @@ export type FileFieldValue = {
|
|
|
16
68
|
y: number;
|
|
17
69
|
} | null;
|
|
18
70
|
} | null;
|
|
71
|
+
/**
|
|
72
|
+
* =============================================================================
|
|
73
|
+
* TYPE GUARDS - Runtime validation functions
|
|
74
|
+
* =============================================================================
|
|
75
|
+
*/
|
|
76
|
+
/**
|
|
77
|
+
* Type guard for basic File field values (response format with all fields present).
|
|
78
|
+
* Validates that all required metadata fields are present.
|
|
79
|
+
*/
|
|
19
80
|
export declare function isFileFieldValue(value: unknown): value is FileFieldValue;
|
|
81
|
+
/**
|
|
82
|
+
* Type guard for File field values in API request format.
|
|
83
|
+
* Allows metadata fields to be optional or omitted.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isFileFieldValueAsRequest(value: unknown): value is FileFieldValueAsRequest;
|
|
20
86
|
export declare function isLocalizedFileFieldValue(value: unknown): value is LocalizedFieldValue<FileFieldValue>;
|
|
87
|
+
export declare function isLocalizedFileFieldValueAsRequest(value: unknown): value is LocalizedFieldValue<FileFieldValueAsRequest>;
|
|
21
88
|
export type FileFieldValidators = {
|
|
22
89
|
/** Value must be specified or it won't be valid */
|
|
23
90
|
required?: RequiredValidator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { FloatEditorConfiguration } from './appearance/float';
|
|
3
3
|
import type { NumberRangeValidator } from './validators/number_range';
|
|
4
4
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -1,23 +1,39 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { GalleryEditorConfiguration } from './appearance/gallery';
|
|
3
|
+
import { type FileFieldValue, type FileFieldValueAsRequest } from './file';
|
|
3
4
|
import type { ExtensionValidator } from './validators/extension';
|
|
4
5
|
import type { FileSizeValidator } from './validators/file_size';
|
|
5
6
|
import type { ImageAspectRatioValidator } from './validators/image_aspect_ratio';
|
|
6
7
|
import type { ImageDimensionsValidator } from './validators/image_dimensions';
|
|
7
8
|
import type { RequiredAltTitleValidator } from './validators/required_alt_title';
|
|
8
9
|
import type { SizeValidator } from './validators/size';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Gallery field type system - similar to File field but for arrays.
|
|
12
|
+
* See file.ts for detailed explanation of request/response duality.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Individual gallery item types - extracted from File field types
|
|
16
|
+
*/
|
|
17
|
+
export type GalleryItem = NonNullable<FileFieldValue>;
|
|
18
|
+
export type GalleryItemAsRequest = NonNullable<FileFieldValueAsRequest>;
|
|
19
|
+
/**
|
|
20
|
+
* Gallery field value - response format with all metadata fields present
|
|
21
|
+
*/
|
|
22
|
+
export type GalleryFieldValue = Array<GalleryItem>;
|
|
23
|
+
/**
|
|
24
|
+
* Gallery field value for API requests - metadata fields are optional
|
|
25
|
+
*/
|
|
26
|
+
export type GalleryFieldValueAsRequest = Array<GalleryItemAsRequest>;
|
|
27
|
+
/**
|
|
28
|
+
* Type guard for Gallery field values - validates each item using File field validation
|
|
29
|
+
*/
|
|
19
30
|
export declare function isGalleryFieldValue(value: unknown): value is GalleryFieldValue;
|
|
31
|
+
/**
|
|
32
|
+
* Type guard for Gallery field values in API request format
|
|
33
|
+
*/
|
|
34
|
+
export declare function isGalleryFieldValueAsRequest(value: unknown): value is GalleryFieldValueAsRequest;
|
|
20
35
|
export declare function isLocalizedGalleryFieldValue(value: unknown): value is LocalizedFieldValue<GalleryFieldValue>;
|
|
36
|
+
export declare function isLocalizedGalleryFieldValueAsRequest(value: unknown): value is LocalizedFieldValue<GalleryFieldValueAsRequest>;
|
|
21
37
|
export type GalleryFieldValidators = {
|
|
22
38
|
/** Only accept a number of items within the specified range */
|
|
23
39
|
size?: SizeValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './appearance';
|
|
1
2
|
export * from './boolean';
|
|
2
3
|
export * from './color';
|
|
3
4
|
export * from './date';
|
|
@@ -17,6 +18,5 @@ export * from './slug';
|
|
|
17
18
|
export * from './string';
|
|
18
19
|
export * from './structured_text';
|
|
19
20
|
export * from './text';
|
|
20
|
-
export * from './video';
|
|
21
|
-
export * from './appearance';
|
|
22
21
|
export * from './validators';
|
|
22
|
+
export * from './video';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { IntegerEditorConfiguration } from './appearance/integer';
|
|
3
3
|
import type { NumberRangeValidator } from './validators/number_range';
|
|
4
4
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { JsonEditorConfiguration } from './appearance/json';
|
|
3
3
|
import type { StringCheckboxGroupEditorConfiguration } from './appearance/string_checkbox_group';
|
|
4
4
|
import type { StringMultiSelectEditorConfiguration } from './appearance/string_multi_select';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { MapEditorConfiguration } from './appearance/map';
|
|
3
3
|
import type { RequiredValidator } from './validators/required';
|
|
4
4
|
export type LatLonFieldValue = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { LinkEmbedEditorConfiguration } from './appearance/link_embed';
|
|
3
3
|
import type { LinkSelectEditorConfiguration } from './appearance/link_select';
|
|
4
4
|
import type { ItemItemTypeValidator } from './validators/item_item_type';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { LinksEmbedEditorConfiguration } from './appearance/links_embed';
|
|
3
3
|
import type { LinksSelectEditorConfiguration } from './appearance/links_select';
|
|
4
4
|
import type { ItemsItemTypeValidator } from './validators/items_item_type';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
2
|
-
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
3
2
|
import type { ItemDefinition } from '../utilities/itemDefinition';
|
|
3
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
4
4
|
import type { RichTextEditorConfiguration } from './appearance/rich_text';
|
|
5
5
|
import { type BlockItemInARequest } from './single_block';
|
|
6
6
|
import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { SeoEditorConfiguration } from './appearance/seo';
|
|
3
3
|
import type { DescriptionLengthValidator } from './validators/description_length';
|
|
4
4
|
import type { FileSizeValidator } from './validators/file_size';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
2
|
-
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
3
2
|
import type { ItemDefinition } from '../utilities/itemDefinition';
|
|
3
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
4
4
|
import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
|
|
5
5
|
import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
|
|
6
6
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { SlugEditorConfiguration } from './appearance/slug';
|
|
3
3
|
import type { LengthValidator } from './validators/length';
|
|
4
4
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { SingleLineEditorConfiguration } from './appearance/single_line';
|
|
3
3
|
import type { StringRadioGroupEditorConfiguration } from './appearance/string_radio_group';
|
|
4
4
|
import type { StringSelectEditorConfiguration } from './appearance/string_select';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Block, type Document, type InlineBlock } from 'datocms-structured-text-utils';
|
|
2
2
|
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
3
|
-
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
4
3
|
import type { ItemDefinition } from '../utilities/itemDefinition';
|
|
4
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
5
5
|
import type { StructuredTextEditorConfiguration } from './appearance/structured_text';
|
|
6
6
|
import { type BlockItemInARequest } from './single_block';
|
|
7
7
|
import type { LengthValidator } from './validators/length';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { MarkdownEditorConfiguration } from './appearance/markdown';
|
|
3
3
|
import type { TextareaEditorConfiguration } from './appearance/textarea';
|
|
4
4
|
import type { WysiwygEditorConfiguration } from './appearance/wysiwyg';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type LocalizedFieldValue } from '../utilities/normalizedFieldValues';
|
|
2
2
|
import type { VideoEditorConfiguration } from './appearance/video';
|
|
3
3
|
import type { RequiredValidator } from './validators/required';
|
|
4
4
|
export type VideoFieldValue = {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export { ApiError, LogLevel, TimeoutError } from '@datocms/rest-client-utils';
|
|
2
2
|
export * from './buildClient';
|
|
3
|
+
export * from './fieldTypes';
|
|
3
4
|
export { Client } from './generated/Client';
|
|
4
5
|
export type { ClientConfigOptions } from './generated/Client';
|
|
5
6
|
export * as Resources from './generated/resources';
|
|
6
|
-
export * from './utilities/blocks';
|
|
7
7
|
export * from './utilities/buildBlockRecord';
|
|
8
8
|
export * from './utilities/fieldsContainingReferences';
|
|
9
|
-
export * from './utilities/fieldValue';
|
|
10
9
|
export * from './utilities/id';
|
|
10
|
+
export * from './utilities/inspectItem';
|
|
11
|
+
export * from './utilities/itemDefinition';
|
|
12
|
+
export * from './utilities/normalizedFieldValues';
|
|
11
13
|
export * from './utilities/recursiveBlocks';
|
|
12
14
|
export * from './utilities/schemaRepository';
|
|
13
|
-
export * from './utilities/itemDefinition';
|
|
14
|
-
export * from './fieldTypes';
|
|
15
15
|
export type { ApiTypes, RawApiTypes };
|
|
16
16
|
export type { ApiTypes as SchemaTypes, RawApiTypes as SimpleSchemaTypes };
|
|
17
17
|
import type * as ApiTypes from './generated/ApiTypes';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type NewBlockInARequest, type UpdatedBlockInARequest } from '../fieldTypes';
|
|
2
|
+
import { type ApiTypes, type RawApiTypes } from '../index';
|
|
3
|
+
type Item = ApiTypes.Item | RawApiTypes.Item | NewBlockInARequest | UpdatedBlockInARequest | RawApiTypes.ItemCreateSchema | RawApiTypes.ItemUpdateSchema | ApiTypes.ItemCreateSchema | ApiTypes.ItemUpdateSchema;
|
|
4
|
+
export type InspectItemOptions = {
|
|
5
|
+
maxWidth?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function inspectItem(item: Item, options?: InspectItemOptions): string;
|
|
8
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BooleanFieldValue, ColorFieldValue, DateFieldValue, DateTimeFieldValue, FileFieldValue, FloatFieldValue, GalleryFieldValue, IntegerFieldValue, JsonFieldValue, LatLonFieldValue, LinkFieldValue, LinksFieldValue, RichTextFieldValue, RichTextFieldValueAsRequest, RichTextFieldValueWithNestedBlocks, SeoFieldValue, SingleBlockFieldValue, SingleBlockFieldValueAsRequest, SingleBlockFieldValueWithNestedBlocks, SlugFieldValue, StringFieldValue, StructuredTextFieldValue, StructuredTextFieldValueAsRequest, StructuredTextFieldValueWithNestedBlocks, TextFieldValue, VideoFieldValue } from '../fieldTypes';
|
|
2
|
-
import type { LocalizedFieldValue } from './
|
|
1
|
+
import type { BooleanFieldValue, ColorFieldValue, DateFieldValue, DateTimeFieldValue, FileFieldValue, FileFieldValueAsRequest, FloatFieldValue, GalleryFieldValue, GalleryFieldValueAsRequest, IntegerFieldValue, JsonFieldValue, LatLonFieldValue, LinkFieldValue, LinksFieldValue, RichTextFieldValue, RichTextFieldValueAsRequest, RichTextFieldValueWithNestedBlocks, SeoFieldValue, SingleBlockFieldValue, SingleBlockFieldValueAsRequest, SingleBlockFieldValueWithNestedBlocks, SlugFieldValue, StringFieldValue, StructuredTextFieldValue, StructuredTextFieldValueAsRequest, StructuredTextFieldValueWithNestedBlocks, TextFieldValue, VideoFieldValue } from '../fieldTypes';
|
|
2
|
+
import type { LocalizedFieldValue } from './normalizedFieldValues';
|
|
3
3
|
/** Base field definition */
|
|
4
4
|
type BaseFieldDefinition<Type extends string> = {
|
|
5
5
|
type: Type;
|
|
@@ -32,7 +32,7 @@ export type ItemDefinition<ItemTypeId extends string = string, FieldValues exten
|
|
|
32
32
|
itemTypeId: ItemTypeId;
|
|
33
33
|
fields: FieldValues;
|
|
34
34
|
};
|
|
35
|
-
/** Standard field values */
|
|
35
|
+
/** Standard field values (response format) */
|
|
36
36
|
type FieldTypeToValue = {
|
|
37
37
|
boolean: BooleanFieldValue;
|
|
38
38
|
color: ColorFieldValue;
|
|
@@ -56,6 +56,30 @@ type FieldTypeToValue = {
|
|
|
56
56
|
video: VideoFieldValue;
|
|
57
57
|
unknown: unknown;
|
|
58
58
|
};
|
|
59
|
+
/** Request field values (request format with optional metadata) */
|
|
60
|
+
type FieldTypeToValueAsRequest = {
|
|
61
|
+
boolean: BooleanFieldValue;
|
|
62
|
+
color: ColorFieldValue;
|
|
63
|
+
date: DateFieldValue;
|
|
64
|
+
date_time: DateTimeFieldValue;
|
|
65
|
+
file: FileFieldValueAsRequest;
|
|
66
|
+
float: FloatFieldValue;
|
|
67
|
+
gallery: GalleryFieldValueAsRequest;
|
|
68
|
+
integer: IntegerFieldValue;
|
|
69
|
+
json: JsonFieldValue;
|
|
70
|
+
lat_lon: LatLonFieldValue;
|
|
71
|
+
link: LinkFieldValue;
|
|
72
|
+
links: LinksFieldValue;
|
|
73
|
+
rich_text: RichTextFieldValueAsRequest;
|
|
74
|
+
seo: SeoFieldValue;
|
|
75
|
+
single_block: SingleBlockFieldValueAsRequest;
|
|
76
|
+
slug: SlugFieldValue;
|
|
77
|
+
string: StringFieldValue;
|
|
78
|
+
structured_text: StructuredTextFieldValueAsRequest;
|
|
79
|
+
text: TextFieldValue;
|
|
80
|
+
video: VideoFieldValue;
|
|
81
|
+
unknown: unknown;
|
|
82
|
+
};
|
|
59
83
|
/** Localized wrapper */
|
|
60
84
|
type LocalizeIfNeeded<T extends FieldDefinition, Value, Locales extends string> = T extends {
|
|
61
85
|
localized: true;
|
|
@@ -67,7 +91,7 @@ type FieldDefinitionToFieldValueAsRequest<T extends FieldDefinition, Locales ext
|
|
|
67
91
|
blocks: any;
|
|
68
92
|
} ? ToItemDefinitionAsRequest<B> : never, T extends {
|
|
69
93
|
inline_blocks: any;
|
|
70
|
-
} ? ToItemDefinitionAsRequest<I> : never>, Locales> : LocalizeIfNeeded<T,
|
|
94
|
+
} ? ToItemDefinitionAsRequest<I> : never>, Locales> : LocalizeIfNeeded<T, FieldTypeToValueAsRequest[T['type']], Locales>;
|
|
71
95
|
type FieldDefinitionToFieldValueWithNestedBlocks<T extends FieldDefinition, Locales extends string> = T extends RichTextFieldDefinition<infer B> ? LocalizeIfNeeded<T, RichTextFieldValueWithNestedBlocks<ToItemDefinitionWithNestedBlocks<B>>, Locales> : T extends SingleBlockFieldDefinition<infer B> ? LocalizeIfNeeded<T, SingleBlockFieldValueWithNestedBlocks<ToItemDefinitionWithNestedBlocks<B>>, Locales> : T extends StructuredTextFieldDefinition<infer B, infer I> ? LocalizeIfNeeded<T, StructuredTextFieldValueWithNestedBlocks<T extends {
|
|
72
96
|
blocks: any;
|
|
73
97
|
} ? ToItemDefinitionWithNestedBlocks<B> : never, T extends {
|