@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,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,9 +1,9 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isBooleanFieldValue(value) {
|
|
2
3
|
return typeof value === 'boolean' || value === null;
|
|
3
4
|
}
|
|
4
5
|
export function isLocalizedBooleanFieldValue(value) {
|
|
5
|
-
return (
|
|
6
|
-
value !== null &&
|
|
6
|
+
return (isLocalizedFieldValue(value) &&
|
|
7
7
|
Object.values(value).every(isBooleanFieldValue));
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=boolean.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/fieldTypes/boolean.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../../src/fieldTypes/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAM5C,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAChD,CAAC;AACJ,CAAC"}
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isColorFieldValue(value) {
|
|
2
3
|
if (value === null)
|
|
3
4
|
return true;
|
|
@@ -9,8 +10,7 @@ export function isColorFieldValue(value) {
|
|
|
9
10
|
'alpha' in value);
|
|
10
11
|
}
|
|
11
12
|
export function isLocalizedColorFieldValue(value) {
|
|
12
|
-
return (
|
|
13
|
-
value !== null &&
|
|
13
|
+
return (isLocalizedFieldValue(value) &&
|
|
14
14
|
Object.values(value).every(isColorFieldValue));
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=color.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/fieldTypes/color.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../../../src/fieldTypes/color.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAW5C,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,IAAI,KAAK;QACd,OAAO,IAAI,KAAK;QAChB,MAAM,IAAI,KAAK;QACf,OAAO,IAAI,KAAK,CACjB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -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,11 +1,10 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isDateFieldValue(value) {
|
|
2
3
|
if (value === null)
|
|
3
4
|
return true;
|
|
4
5
|
return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value);
|
|
5
6
|
}
|
|
6
7
|
export function isLocalizedDateFieldValue(value) {
|
|
7
|
-
return (
|
|
8
|
-
value !== null &&
|
|
9
|
-
Object.values(value).every(isDateFieldValue));
|
|
8
|
+
return (isLocalizedFieldValue(value) && Object.values(value).every(isDateFieldValue));
|
|
10
9
|
}
|
|
11
10
|
//# sourceMappingURL=date.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/fieldTypes/date.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date.js","sourceRoot":"","sources":["../../../src/fieldTypes/date.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAO5C,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,qBAAqB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAC7E,CAAC;AACJ,CAAC"}
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isDateTimeFieldValue(value) {
|
|
2
3
|
if (value === null)
|
|
3
4
|
return true;
|
|
@@ -5,8 +6,7 @@ export function isDateTimeFieldValue(value) {
|
|
|
5
6
|
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(value));
|
|
6
7
|
}
|
|
7
8
|
export function isLocalizedDateTimeFieldValue(value) {
|
|
8
|
-
return (
|
|
9
|
-
value !== null &&
|
|
9
|
+
return (isLocalizedFieldValue(value) &&
|
|
10
10
|
Object.values(value).every(isDateTimeFieldValue));
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=date_time.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date_time.js","sourceRoot":"","sources":["../../../src/fieldTypes/date_time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"date_time.js","sourceRoot":"","sources":["../../../src/fieldTypes/date_time.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAO5C,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,sCAAsC,CAAC,IAAI,CAAC,KAAK,CAAC,CACnD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CACjD,CAAC;AACJ,CAAC"}
|
|
@@ -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,11 +1,37 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
2
|
+
/**
|
|
3
|
+
* =============================================================================
|
|
4
|
+
* TYPE GUARDS - Runtime validation functions
|
|
5
|
+
* =============================================================================
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Type guard for basic File field values (response format with all fields present).
|
|
9
|
+
* Validates that all required metadata fields are present.
|
|
10
|
+
*/
|
|
1
11
|
export function isFileFieldValue(value) {
|
|
12
|
+
if (value === null)
|
|
13
|
+
return true;
|
|
14
|
+
return (isLocalizedFieldValue(value) &&
|
|
15
|
+
'upload_id' in value &&
|
|
16
|
+
'alt' in value &&
|
|
17
|
+
'title' in value &&
|
|
18
|
+
'custom_data' in value &&
|
|
19
|
+
'focal_point' in value);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Type guard for File field values in API request format.
|
|
23
|
+
* Allows metadata fields to be optional or omitted.
|
|
24
|
+
*/
|
|
25
|
+
export function isFileFieldValueAsRequest(value) {
|
|
2
26
|
if (value === null)
|
|
3
27
|
return true;
|
|
4
28
|
return typeof value === 'object' && value !== null && 'upload_id' in value;
|
|
5
29
|
}
|
|
6
30
|
export function isLocalizedFileFieldValue(value) {
|
|
7
|
-
return (
|
|
8
|
-
|
|
9
|
-
|
|
31
|
+
return (isLocalizedFieldValue(value) && Object.values(value).every(isFileFieldValue));
|
|
32
|
+
}
|
|
33
|
+
export function isLocalizedFileFieldValueAsRequest(value) {
|
|
34
|
+
return (isLocalizedFieldValue(value) &&
|
|
35
|
+
Object.values(value).every(isFileFieldValueAsRequest));
|
|
10
36
|
}
|
|
11
37
|
//# sourceMappingURL=file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/fieldTypes/file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/fieldTypes/file.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AA4E5C;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,WAAW,IAAI,KAAK;QACpB,KAAK,IAAI,KAAK;QACd,OAAO,IAAI,KAAK;QAChB,aAAa,IAAI,KAAK;QACtB,aAAa,IAAI,KAAK,CACvB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAc;IAEd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,WAAW,IAAI,KAAK,CAAC;AAC7E,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kCAAkC,CAChD,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC,CACtD,CAAC;AACJ,CAAC"}
|
|
@@ -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,9 +1,9 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isFloatFieldValue(value) {
|
|
2
3
|
return typeof value === 'number' || value === null;
|
|
3
4
|
}
|
|
4
5
|
export function isLocalizedFloatFieldValue(value) {
|
|
5
|
-
return (
|
|
6
|
-
value !== null &&
|
|
6
|
+
return (isLocalizedFieldValue(value) &&
|
|
7
7
|
Object.values(value).every(isFloatFieldValue));
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=float.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"float.js","sourceRoot":"","sources":["../../../src/fieldTypes/float.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"float.js","sourceRoot":"","sources":["../../../src/fieldTypes/float.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAO5C,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -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,10 +1,23 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
2
|
+
import { isFileFieldValue, isFileFieldValueAsRequest, } from './file';
|
|
3
|
+
/**
|
|
4
|
+
* Type guard for Gallery field values - validates each item using File field validation
|
|
5
|
+
*/
|
|
1
6
|
export function isGalleryFieldValue(value) {
|
|
2
|
-
return
|
|
3
|
-
|
|
7
|
+
return Array.isArray(value) && value.every(isFileFieldValue);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Type guard for Gallery field values in API request format
|
|
11
|
+
*/
|
|
12
|
+
export function isGalleryFieldValueAsRequest(value) {
|
|
13
|
+
return Array.isArray(value) && value.every(isFileFieldValueAsRequest);
|
|
4
14
|
}
|
|
5
15
|
export function isLocalizedGalleryFieldValue(value) {
|
|
6
|
-
return (
|
|
7
|
-
value !== null &&
|
|
16
|
+
return (isLocalizedFieldValue(value) &&
|
|
8
17
|
Object.values(value).every(isGalleryFieldValue));
|
|
9
18
|
}
|
|
19
|
+
export function isLocalizedGalleryFieldValueAsRequest(value) {
|
|
20
|
+
return (isLocalizedFieldValue(value) &&
|
|
21
|
+
Object.values(value).every(isGalleryFieldValueAsRequest));
|
|
22
|
+
}
|
|
10
23
|
//# sourceMappingURL=gallery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../../src/fieldTypes/gallery.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gallery.js","sourceRoot":"","sources":["../../../src/fieldTypes/gallery.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAGL,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,QAAQ,CAAC;AA6BhB;;GAEG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAChD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,qCAAqC,CACnD,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,4BAA4B,CAAC,CACzD,CAAC;AACJ,CAAC"}
|
|
@@ -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,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,6 @@ 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';
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fieldTypes/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/fieldTypes/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,mBAAmB,CAAC;AAClC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
|
|
@@ -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,9 +1,9 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isIntegerFieldValue(value) {
|
|
2
3
|
return typeof value === 'number' || value === null;
|
|
3
4
|
}
|
|
4
5
|
export function isLocalizedIntegerFieldValue(value) {
|
|
5
|
-
return (
|
|
6
|
-
value !== null &&
|
|
6
|
+
return (isLocalizedFieldValue(value) &&
|
|
7
7
|
Object.values(value).every(isIntegerFieldValue));
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=integer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.js","sourceRoot":"","sources":["../../../src/fieldTypes/integer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"integer.js","sourceRoot":"","sources":["../../../src/fieldTypes/integer.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAO5C,MAAM,UAAU,mBAAmB,CACjC,KAAc;IAEd,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,4BAA4B,CAC1C,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAChD,CAAC;AACJ,CAAC"}
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isJsonFieldValue(value) {
|
|
2
3
|
if (value === null)
|
|
3
4
|
return true;
|
|
@@ -12,8 +13,6 @@ export function isJsonFieldValue(value) {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export function isLocalizedJsonFieldValue(value) {
|
|
15
|
-
return (
|
|
16
|
-
value !== null &&
|
|
17
|
-
Object.values(value).every(isJsonFieldValue));
|
|
16
|
+
return (isLocalizedFieldValue(value) && Object.values(value).every(isJsonFieldValue));
|
|
18
17
|
}
|
|
19
18
|
//# sourceMappingURL=json.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/fieldTypes/json.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json.js","sourceRoot":"","sources":["../../../src/fieldTypes/json.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAQ5C,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI;QACF,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC;KACb;IAAC,WAAM;QACN,OAAO,KAAK,CAAC;KACd;AACH,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAC7E,CAAC;AACJ,CAAC"}
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
export function isLatLonFieldValue(value) {
|
|
2
3
|
if (value === null)
|
|
3
4
|
return true;
|
|
@@ -7,8 +8,7 @@ export function isLatLonFieldValue(value) {
|
|
|
7
8
|
'longitude' in value);
|
|
8
9
|
}
|
|
9
10
|
export function isLocalizedLatLonFieldValue(value) {
|
|
10
|
-
return (
|
|
11
|
-
value !== null &&
|
|
11
|
+
return (isLocalizedFieldValue(value) &&
|
|
12
12
|
Object.values(value).every(isLatLonFieldValue));
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=lat_lon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lat_lon.js","sourceRoot":"","sources":["../../../src/fieldTypes/lat_lon.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"lat_lon.js","sourceRoot":"","sources":["../../../src/fieldTypes/lat_lon.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAS5C,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,UAAU,IAAI,KAAK;QACnB,WAAW,IAAI,KAAK,CACrB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAC/C,CAAC;AACJ,CAAC"}
|
|
@@ -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,9 +1,9 @@
|
|
|
1
|
+
import { isValidId } from '../utilities/id';
|
|
2
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
3
|
export function isLinkFieldValue(value) {
|
|
2
|
-
return typeof value === 'string' || value === null;
|
|
4
|
+
return (typeof value === 'string' && isValidId(value)) || value === null;
|
|
3
5
|
}
|
|
4
6
|
export function isLocalizedLinkFieldValue(value) {
|
|
5
|
-
return (
|
|
6
|
-
value !== null &&
|
|
7
|
-
Object.values(value).every(isLinkFieldValue));
|
|
7
|
+
return (isLocalizedFieldValue(value) && Object.values(value).every(isLinkFieldValue));
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=link.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/fieldTypes/link.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/fieldTypes/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAS5C,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,OAAO,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAC7E,CAAC;AACJ,CAAC"}
|
|
@@ -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,9 +1,11 @@
|
|
|
1
|
+
import { isValidId } from '../utilities/id';
|
|
2
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
3
|
export function isLinksFieldValue(value) {
|
|
2
|
-
return (Array.isArray(value) &&
|
|
4
|
+
return (Array.isArray(value) &&
|
|
5
|
+
value.every((item) => typeof item === 'string' && isValidId(item)));
|
|
3
6
|
}
|
|
4
7
|
export function isLocalizedLinksFieldValue(value) {
|
|
5
|
-
return (
|
|
6
|
-
value !== null &&
|
|
8
|
+
return (isLocalizedFieldValue(value) &&
|
|
7
9
|
Object.values(value).every(isLinksFieldValue));
|
|
8
10
|
}
|
|
9
11
|
//# sourceMappingURL=links.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../src/fieldTypes/links.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../src/fieldTypes/links.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAQ5C,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACpB,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,CACnE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAC9C,CAAC;AACJ,CAAC"}
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { isLocalizedFieldValue, } from '../utilities/normalizedFieldValues';
|
|
1
2
|
import { isItemId, isItemWithOptionalIdAndMeta, isItemWithOptionalMeta, } from './single_block';
|
|
2
3
|
/**
|
|
3
4
|
* =============================================================================
|
|
@@ -12,8 +13,7 @@ export function isRichTextFieldValue(value) {
|
|
|
12
13
|
return (Array.isArray(value) && value.every((block) => typeof block === 'string'));
|
|
13
14
|
}
|
|
14
15
|
export function isLocalizedRichTextFieldValue(value) {
|
|
15
|
-
return (
|
|
16
|
-
value !== null &&
|
|
16
|
+
return (isLocalizedFieldValue(value) &&
|
|
17
17
|
Object.values(value).every(isRichTextFieldValue));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
@@ -34,8 +34,7 @@ export function isRichTextFieldValueAsRequest(value) {
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
export function isLocalizedRichTextFieldValueAsRequest(value) {
|
|
37
|
-
return (
|
|
38
|
-
value !== null &&
|
|
37
|
+
return (isLocalizedFieldValue(value) &&
|
|
39
38
|
Object.values(value).every(isRichTextFieldValueAsRequest));
|
|
40
39
|
}
|
|
41
40
|
/**
|
|
@@ -51,8 +50,7 @@ export function isRichTextFieldValueWithNestedBlocks(value) {
|
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
52
|
export function isLocalizedRichTextFieldValueWithNestedBlocks(value) {
|
|
54
|
-
return (
|
|
55
|
-
value !== null &&
|
|
53
|
+
return (isLocalizedFieldValue(value) &&
|
|
56
54
|
Object.values(value).every(isRichTextFieldValueWithNestedBlocks));
|
|
57
55
|
}
|
|
58
56
|
//# sourceMappingURL=rich_text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/rich_text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rich_text.js","sourceRoot":"","sources":["../../../src/fieldTypes/rich_text.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,qBAAqB,GACtB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAEL,QAAQ,EACR,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AA2ExB;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAc;IAEd,OAAO,CACL,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAC1E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,6BAA6B,CAC3C,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CACjD,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,6BAA6B,CAE3C,KAAc;IACd,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAEhC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,yCAAyC;QACzC,IAAI,QAAQ,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEjC,0DAA0D;QAC1D,OAAO,2BAA2B,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,sCAAsC,CAGpD,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAC1D,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oCAAoC,CAElD,KAAc;IACd,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAExC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;QAC3B,uFAAuF;QACvF,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,6CAA6C,CAG3D,KAAc;IAEd,OAAO,CACL,qBAAqB,CAAC,KAAK,CAAC;QAC5B,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,oCAAoC,CAAC,CACjE,CAAC;AACJ,CAAC"}
|
|
@@ -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';
|