@datocms/cma-client 5.1.10 → 5.1.12
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 +569 -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 +18 -18
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/schema.js +3 -0
- package/dist/cjs/fieldTypes/schema.js.map +1 -0
- package/dist/cjs/fieldTypes/seo.js +2 -3
- package/dist/cjs/fieldTypes/seo.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +20 -19
- 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 +17 -18
- 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/generated/resources/Item.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/cjs/generated/resources/Upload.js.map +1 -1
- package/dist/cjs/index.js +5 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js +1 -45
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/cjs/utilities/duplicateBlockRecord.js +49 -0
- package/dist/cjs/utilities/duplicateBlockRecord.js.map +1 -0
- package/dist/cjs/utilities/inspectItem.js +427 -0
- package/dist/cjs/utilities/inspectItem.js.map +1 -0
- package/dist/cjs/utilities/{blocks.js → nonRecursiveBlocks.js} +60 -234
- 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 +73 -92
- 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 +9 -10
- package/dist/esm/fieldTypes/rich_text.js +13 -13
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/schema.d.ts +59 -0
- package/dist/esm/fieldTypes/schema.js +2 -0
- package/dist/esm/fieldTypes/schema.js.map +1 -0
- 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 +31 -16
- package/dist/esm/fieldTypes/single_block.js +15 -14
- 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 +15 -16
- package/dist/esm/fieldTypes/structured_text.js +12 -13
- 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/ApiTypes.d.ts +90 -980
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/generated/RawApiTypes.d.ts +156 -999
- package/dist/esm/generated/resources/Field.d.ts +200 -200
- package/dist/esm/generated/resources/Item.d.ts +34 -34
- package/dist/esm/generated/resources/Item.js.map +1 -1
- package/dist/esm/generated/resources/ItemVersion.d.ts +3 -1
- package/dist/esm/generated/resources/ScheduledPublication.d.ts +3 -3
- package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +3 -3
- package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/esm/generated/resources/Upload.d.ts +6 -6
- package/dist/esm/generated/resources/Upload.js.map +1 -1
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.js +5 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utilities/buildBlockRecord.d.ts +3 -5
- package/dist/esm/utilities/buildBlockRecord.js +0 -43
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/dist/esm/utilities/duplicateBlockRecord.d.ts +6 -0
- package/dist/esm/utilities/duplicateBlockRecord.js +45 -0
- package/dist/esm/utilities/duplicateBlockRecord.js.map +1 -0
- package/dist/esm/utilities/inspectItem.d.ts +8 -0
- package/dist/esm/utilities/inspectItem.js +400 -0
- package/dist/esm/utilities/inspectItem.js.map +1 -0
- package/dist/esm/utilities/itemDefinition.d.ts +45 -23
- package/dist/esm/utilities/nonRecursiveBlocks.d.ts +114 -0
- package/dist/esm/utilities/{blocks.js → nonRecursiveBlocks.js} +52 -220
- 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 +124 -11
- package/dist/esm/utilities/recursiveBlocks.js +65 -84
- 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 +9 -10
- package/dist/types/fieldTypes/schema.d.ts +59 -0
- package/dist/types/fieldTypes/seo.d.ts +1 -1
- package/dist/types/fieldTypes/single_block.d.ts +31 -16
- 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 +15 -16
- package/dist/types/fieldTypes/text.d.ts +1 -1
- package/dist/types/fieldTypes/video.d.ts +1 -1
- package/dist/types/generated/ApiTypes.d.ts +90 -980
- package/dist/types/generated/RawApiTypes.d.ts +156 -999
- package/dist/types/generated/resources/Field.d.ts +200 -200
- package/dist/types/generated/resources/Item.d.ts +34 -34
- package/dist/types/generated/resources/ItemVersion.d.ts +3 -1
- package/dist/types/generated/resources/ScheduledPublication.d.ts +3 -3
- package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +3 -3
- package/dist/types/generated/resources/Upload.d.ts +6 -6
- package/dist/types/index.d.ts +5 -4
- package/dist/types/utilities/buildBlockRecord.d.ts +3 -5
- package/dist/types/utilities/duplicateBlockRecord.d.ts +6 -0
- package/dist/types/utilities/inspectItem.d.ts +8 -0
- package/dist/types/utilities/itemDefinition.d.ts +45 -23
- package/dist/types/utilities/nonRecursiveBlocks.d.ts +114 -0
- package/dist/{esm/utilities/fieldValue.d.ts → types/utilities/normalizedFieldValues.d.ts} +15 -14
- package/dist/types/utilities/recursiveBlocks.d.ts +124 -11
- package/dist/types/utilities/schemaRepository.d.ts +2 -2
- package/package.json +4 -4
- 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 +33 -31
- package/src/fieldTypes/schema.ts +657 -0
- package/src/fieldTypes/seo.ts +5 -4
- package/src/fieldTypes/single_block.ts +71 -46
- package/src/fieldTypes/slug.ts +5 -4
- package/src/fieldTypes/string.ts +5 -3
- package/src/fieldTypes/structured_text.ts +64 -58
- package/src/fieldTypes/text.ts +5 -4
- package/src/fieldTypes/video.ts +5 -3
- package/src/generated/ApiTypes.ts +217 -1880
- package/src/generated/Client.ts +1 -1
- package/src/generated/RawApiTypes.ts +272 -2113
- package/src/generated/resources/Item.ts +93 -187
- package/src/generated/resources/ScheduledPublication.ts +4 -15
- package/src/generated/resources/ScheduledUnpublishing.ts +4 -15
- package/src/generated/resources/Upload.ts +9 -32
- package/src/index.ts +5 -4
- package/src/utilities/buildBlockRecord.ts +4 -59
- package/src/utilities/duplicateBlockRecord.ts +52 -0
- package/src/utilities/inspectItem.ts +602 -0
- package/src/utilities/itemDefinition.ts +130 -92
- package/src/utilities/nonRecursiveBlocks.ts +406 -0
- package/src/utilities/{fieldValue.ts → normalizedFieldValues.ts} +70 -30
- package/src/utilities/recursiveBlocks.ts +484 -204
- 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
- package/src/utilities/blocks.ts +0 -626
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type LocalizedFieldValue,
|
|
3
|
+
isLocalizedFieldValue,
|
|
4
|
+
} from '../utilities/normalizedFieldValues';
|
|
2
5
|
import type { GalleryEditorConfiguration } from './appearance/gallery';
|
|
6
|
+
import {
|
|
7
|
+
type FileFieldValue,
|
|
8
|
+
type FileFieldValueInRequest,
|
|
9
|
+
isFileFieldValue,
|
|
10
|
+
isFileFieldValueInRequest,
|
|
11
|
+
} from './file';
|
|
3
12
|
import type { ExtensionValidator } from './validators/extension';
|
|
4
13
|
import type { FileSizeValidator } from './validators/file_size';
|
|
5
14
|
import type { ImageAspectRatioValidator } from './validators/image_aspect_ratio';
|
|
@@ -7,39 +16,63 @@ import type { ImageDimensionsValidator } from './validators/image_dimensions';
|
|
|
7
16
|
import type { RequiredAltTitleValidator } from './validators/required_alt_title';
|
|
8
17
|
import type { SizeValidator } from './validators/size';
|
|
9
18
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
custom_data?: Record<string, unknown>;
|
|
15
|
-
focal_point?: {
|
|
16
|
-
x: number;
|
|
17
|
-
y: number;
|
|
18
|
-
} | null;
|
|
19
|
-
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Gallery field type system - similar to File field but for arrays.
|
|
21
|
+
* See file.ts for detailed explanation of request/response duality.
|
|
22
|
+
*/
|
|
20
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Individual gallery item types - extracted from File field types
|
|
26
|
+
*/
|
|
27
|
+
export type GalleryItem = NonNullable<FileFieldValue>;
|
|
28
|
+
export type GalleryItemInRequest = NonNullable<FileFieldValueInRequest>;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Gallery field value - response format with all metadata fields present
|
|
32
|
+
*/
|
|
33
|
+
export type GalleryFieldValue = Array<GalleryItem>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Gallery field value for API requests - metadata fields are optional
|
|
37
|
+
*/
|
|
38
|
+
export type GalleryFieldValueInRequest = Array<GalleryItemInRequest>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Type guard for Gallery field values - validates each item using File field validation
|
|
42
|
+
*/
|
|
21
43
|
export function isGalleryFieldValue(
|
|
22
44
|
value: unknown,
|
|
23
45
|
): value is GalleryFieldValue {
|
|
24
|
-
return (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
46
|
+
return Array.isArray(value) && value.every(isFileFieldValue);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Type guard for Gallery field values in API request format
|
|
51
|
+
*/
|
|
52
|
+
export function isGalleryFieldValueInRequest(
|
|
53
|
+
value: unknown,
|
|
54
|
+
): value is GalleryFieldValueInRequest {
|
|
55
|
+
return Array.isArray(value) && value.every(isFileFieldValueInRequest);
|
|
31
56
|
}
|
|
32
57
|
|
|
33
58
|
export function isLocalizedGalleryFieldValue(
|
|
34
59
|
value: unknown,
|
|
35
60
|
): value is LocalizedFieldValue<GalleryFieldValue> {
|
|
36
61
|
return (
|
|
37
|
-
|
|
38
|
-
value !== null &&
|
|
62
|
+
isLocalizedFieldValue(value) &&
|
|
39
63
|
Object.values(value).every(isGalleryFieldValue)
|
|
40
64
|
);
|
|
41
65
|
}
|
|
42
66
|
|
|
67
|
+
export function isLocalizedGalleryFieldValueInRequest(
|
|
68
|
+
value: unknown,
|
|
69
|
+
): value is LocalizedFieldValue<GalleryFieldValueInRequest> {
|
|
70
|
+
return (
|
|
71
|
+
isLocalizedFieldValue(value) &&
|
|
72
|
+
Object.values(value).every(isGalleryFieldValueInRequest)
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
43
76
|
export type GalleryFieldValidators = {
|
|
44
77
|
/** Only accept a number of items within the specified range */
|
|
45
78
|
size?: SizeValidator;
|
package/src/fieldTypes/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './appearance';
|
|
1
2
|
export * from './boolean';
|
|
2
3
|
export * from './color';
|
|
3
4
|
export * from './date';
|
|
@@ -17,7 +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
|
-
|
|
22
|
-
export * from './appearance';
|
|
23
21
|
export * from './validators';
|
|
22
|
+
export * from './video';
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type LocalizedFieldValue,
|
|
3
|
+
isLocalizedFieldValue,
|
|
4
|
+
} from '../utilities/normalizedFieldValues';
|
|
2
5
|
import type { IntegerEditorConfiguration } from './appearance/integer';
|
|
3
6
|
import type { NumberRangeValidator } from './validators/number_range';
|
|
4
7
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -15,8 +18,7 @@ export function isLocalizedIntegerFieldValue(
|
|
|
15
18
|
value: unknown,
|
|
16
19
|
): value is LocalizedFieldValue<IntegerFieldValue> {
|
|
17
20
|
return (
|
|
18
|
-
|
|
19
|
-
value !== null &&
|
|
21
|
+
isLocalizedFieldValue(value) &&
|
|
20
22
|
Object.values(value).every(isIntegerFieldValue)
|
|
21
23
|
);
|
|
22
24
|
}
|
package/src/fieldTypes/json.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type LocalizedFieldValue,
|
|
3
|
+
isLocalizedFieldValue,
|
|
4
|
+
} from '../utilities/normalizedFieldValues';
|
|
2
5
|
import type { JsonEditorConfiguration } from './appearance/json';
|
|
3
6
|
import type { StringCheckboxGroupEditorConfiguration } from './appearance/string_checkbox_group';
|
|
4
7
|
import type { StringMultiSelectEditorConfiguration } from './appearance/string_multi_select';
|
|
@@ -21,9 +24,7 @@ export function isLocalizedJsonFieldValue(
|
|
|
21
24
|
value: unknown,
|
|
22
25
|
): value is LocalizedFieldValue<JsonFieldValue> {
|
|
23
26
|
return (
|
|
24
|
-
|
|
25
|
-
value !== null &&
|
|
26
|
-
Object.values(value).every(isJsonFieldValue)
|
|
27
|
+
isLocalizedFieldValue(value) && Object.values(value).every(isJsonFieldValue)
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
30
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
type LocalizedFieldValue,
|
|
3
|
+
isLocalizedFieldValue,
|
|
4
|
+
} from '../utilities/normalizedFieldValues';
|
|
2
5
|
import type { MapEditorConfiguration } from './appearance/map';
|
|
3
6
|
import type { RequiredValidator } from './validators/required';
|
|
4
7
|
|
|
@@ -21,8 +24,7 @@ export function isLocalizedLatLonFieldValue(
|
|
|
21
24
|
value: unknown,
|
|
22
25
|
): value is LocalizedFieldValue<LatLonFieldValue> {
|
|
23
26
|
return (
|
|
24
|
-
|
|
25
|
-
value !== null &&
|
|
27
|
+
isLocalizedFieldValue(value) &&
|
|
26
28
|
Object.values(value).every(isLatLonFieldValue)
|
|
27
29
|
);
|
|
28
30
|
}
|
package/src/fieldTypes/link.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isValidId } from '../utilities/id';
|
|
2
|
+
import {
|
|
3
|
+
type LocalizedFieldValue,
|
|
4
|
+
isLocalizedFieldValue,
|
|
5
|
+
} from '../utilities/normalizedFieldValues';
|
|
2
6
|
import type { LinkEmbedEditorConfiguration } from './appearance/link_embed';
|
|
3
7
|
import type { LinkSelectEditorConfiguration } from './appearance/link_select';
|
|
4
8
|
import type { ItemItemTypeValidator } from './validators/item_item_type';
|
|
@@ -8,16 +12,14 @@ import type { UniqueValidator } from './validators/unique';
|
|
|
8
12
|
export type LinkFieldValue = string | null;
|
|
9
13
|
|
|
10
14
|
export function isLinkFieldValue(value: unknown): value is LinkFieldValue {
|
|
11
|
-
return typeof value === 'string' || value === null;
|
|
15
|
+
return (typeof value === 'string' && isValidId(value)) || value === null;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export function isLocalizedLinkFieldValue(
|
|
15
19
|
value: unknown,
|
|
16
20
|
): value is LocalizedFieldValue<LinkFieldValue> {
|
|
17
21
|
return (
|
|
18
|
-
|
|
19
|
-
value !== null &&
|
|
20
|
-
Object.values(value).every(isLinkFieldValue)
|
|
22
|
+
isLocalizedFieldValue(value) && Object.values(value).every(isLinkFieldValue)
|
|
21
23
|
);
|
|
22
24
|
}
|
|
23
25
|
|
package/src/fieldTypes/links.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isValidId } from '../utilities/id';
|
|
2
|
+
import {
|
|
3
|
+
type LocalizedFieldValue,
|
|
4
|
+
isLocalizedFieldValue,
|
|
5
|
+
} from '../utilities/normalizedFieldValues';
|
|
2
6
|
import type { LinksEmbedEditorConfiguration } from './appearance/links_embed';
|
|
3
7
|
import type { LinksSelectEditorConfiguration } from './appearance/links_select';
|
|
4
8
|
import type { ItemsItemTypeValidator } from './validators/items_item_type';
|
|
@@ -8,7 +12,8 @@ export type LinksFieldValue = string[];
|
|
|
8
12
|
|
|
9
13
|
export function isLinksFieldValue(value: unknown): value is LinksFieldValue {
|
|
10
14
|
return (
|
|
11
|
-
Array.isArray(value) &&
|
|
15
|
+
Array.isArray(value) &&
|
|
16
|
+
value.every((item) => typeof item === 'string' && isValidId(item))
|
|
12
17
|
);
|
|
13
18
|
}
|
|
14
19
|
|
|
@@ -16,8 +21,7 @@ export function isLocalizedLinksFieldValue(
|
|
|
16
21
|
value: unknown,
|
|
17
22
|
): value is LocalizedFieldValue<LinksFieldValue> {
|
|
18
23
|
return (
|
|
19
|
-
|
|
20
|
-
value !== null &&
|
|
24
|
+
isLocalizedFieldValue(value) &&
|
|
21
25
|
Object.values(value).every(isLinksFieldValue)
|
|
22
26
|
);
|
|
23
27
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
1
|
+
import { isValidId } from '../utilities/id';
|
|
2
|
+
import type { ItemTypeDefinition } from '../utilities/itemDefinition';
|
|
3
|
+
import {
|
|
4
|
+
type LocalizedFieldValue,
|
|
5
|
+
isLocalizedFieldValue,
|
|
6
|
+
} from '../utilities/normalizedFieldValues';
|
|
4
7
|
import type { RichTextEditorConfiguration } from './appearance/rich_text';
|
|
5
8
|
import {
|
|
6
|
-
type
|
|
9
|
+
type BlockInNestedResponse,
|
|
10
|
+
type BlockInRequest,
|
|
7
11
|
isItemId,
|
|
8
12
|
isItemWithOptionalIdAndMeta,
|
|
9
13
|
isItemWithOptionalMeta,
|
|
@@ -61,9 +65,9 @@ export type RichTextFieldValue = string[];
|
|
|
61
65
|
* - RawApiTypes.Item: Full block object with ID (for updates)
|
|
62
66
|
* - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
|
|
63
67
|
*/
|
|
64
|
-
export type
|
|
65
|
-
D extends
|
|
66
|
-
> =
|
|
68
|
+
export type RichTextFieldValueInRequest<
|
|
69
|
+
D extends ItemTypeDefinition = ItemTypeDefinition,
|
|
70
|
+
> = BlockInRequest<D>[] | null;
|
|
67
71
|
|
|
68
72
|
/**
|
|
69
73
|
* =============================================================================
|
|
@@ -78,9 +82,9 @@ export type RichTextFieldValueAsRequest<
|
|
|
78
82
|
/**
|
|
79
83
|
* Modular Content field value with nested blocks - array of fully populated block objects
|
|
80
84
|
*/
|
|
81
|
-
export type
|
|
82
|
-
D extends
|
|
83
|
-
> =
|
|
85
|
+
export type RichTextFieldValueInNestedResponse<
|
|
86
|
+
D extends ItemTypeDefinition = ItemTypeDefinition,
|
|
87
|
+
> = BlockInNestedResponse<D>[];
|
|
84
88
|
|
|
85
89
|
/**
|
|
86
90
|
* =============================================================================
|
|
@@ -96,7 +100,8 @@ export function isRichTextFieldValue(
|
|
|
96
100
|
value: unknown,
|
|
97
101
|
): value is RichTextFieldValue {
|
|
98
102
|
return (
|
|
99
|
-
Array.isArray(value) &&
|
|
103
|
+
Array.isArray(value) &&
|
|
104
|
+
value.every((block) => typeof block === 'string' && isValidId(block))
|
|
100
105
|
);
|
|
101
106
|
}
|
|
102
107
|
|
|
@@ -104,8 +109,7 @@ export function isLocalizedRichTextFieldValue(
|
|
|
104
109
|
value: unknown,
|
|
105
110
|
): value is LocalizedFieldValue<RichTextFieldValue> {
|
|
106
111
|
return (
|
|
107
|
-
|
|
108
|
-
value !== null &&
|
|
112
|
+
isLocalizedFieldValue(value) &&
|
|
109
113
|
Object.values(value).every(isRichTextFieldValue)
|
|
110
114
|
);
|
|
111
115
|
}
|
|
@@ -114,9 +118,9 @@ export function isLocalizedRichTextFieldValue(
|
|
|
114
118
|
* Type guard for Modular Content field values in API request format.
|
|
115
119
|
* Allows blocks as string IDs, full objects with IDs, or objects without IDs.
|
|
116
120
|
*/
|
|
117
|
-
export function
|
|
118
|
-
D extends
|
|
119
|
-
>(value: unknown): value is
|
|
121
|
+
export function isRichTextFieldValueInRequest<
|
|
122
|
+
D extends ItemTypeDefinition = ItemTypeDefinition,
|
|
123
|
+
>(value: unknown): value is RichTextFieldValueInRequest<D> {
|
|
120
124
|
if (value === null) return true;
|
|
121
125
|
|
|
122
126
|
if (!Array.isArray(value)) return false;
|
|
@@ -130,15 +134,14 @@ export function isRichTextFieldValueAsRequest<
|
|
|
130
134
|
});
|
|
131
135
|
}
|
|
132
136
|
|
|
133
|
-
export function
|
|
134
|
-
D extends
|
|
137
|
+
export function isLocalizedRichTextFieldValueInRequest<
|
|
138
|
+
D extends ItemTypeDefinition = ItemTypeDefinition,
|
|
135
139
|
>(
|
|
136
140
|
value: unknown,
|
|
137
|
-
): value is LocalizedFieldValue<
|
|
141
|
+
): value is LocalizedFieldValue<RichTextFieldValueInRequest<D>> {
|
|
138
142
|
return (
|
|
139
|
-
|
|
140
|
-
value
|
|
141
|
-
Object.values(value).every(isRichTextFieldValueAsRequest)
|
|
143
|
+
isLocalizedFieldValue(value) &&
|
|
144
|
+
Object.values(value).every(isRichTextFieldValueInRequest)
|
|
142
145
|
);
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -146,9 +149,9 @@ export function isLocalizedRichTextFieldValueAsRequest<
|
|
|
146
149
|
* Type guard for Modular Content field values with nested blocks (?nested=true format).
|
|
147
150
|
* Ensures all blocks are full RawApiTypes.Item objects with complete data.
|
|
148
151
|
*/
|
|
149
|
-
export function
|
|
150
|
-
D extends
|
|
151
|
-
>(value: unknown): value is
|
|
152
|
+
export function isRichTextFieldValueInNestedResponse<
|
|
153
|
+
D extends ItemTypeDefinition = ItemTypeDefinition,
|
|
154
|
+
>(value: unknown): value is RichTextFieldValueInNestedResponse<D> {
|
|
152
155
|
if (!Array.isArray(value)) return false;
|
|
153
156
|
|
|
154
157
|
return value.every((block) => {
|
|
@@ -157,15 +160,14 @@ export function isRichTextFieldValueWithNestedBlocks<
|
|
|
157
160
|
});
|
|
158
161
|
}
|
|
159
162
|
|
|
160
|
-
export function
|
|
161
|
-
D extends
|
|
163
|
+
export function isLocalizedRichTextFieldValueInNestedResponse<
|
|
164
|
+
D extends ItemTypeDefinition = ItemTypeDefinition,
|
|
162
165
|
>(
|
|
163
166
|
value: unknown,
|
|
164
|
-
): value is LocalizedFieldValue<
|
|
167
|
+
): value is LocalizedFieldValue<RichTextFieldValueInNestedResponse<D>> {
|
|
165
168
|
return (
|
|
166
|
-
|
|
167
|
-
value
|
|
168
|
-
Object.values(value).every(isRichTextFieldValueWithNestedBlocks)
|
|
169
|
+
isLocalizedFieldValue(value) &&
|
|
170
|
+
Object.values(value).every(isRichTextFieldValueInNestedResponse)
|
|
169
171
|
);
|
|
170
172
|
}
|
|
171
173
|
|