@datocms/cma-client 5.1.2 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/fieldTypes/boolean.js +7 -1
- package/dist/cjs/fieldTypes/boolean.js.map +1 -1
- package/dist/cjs/fieldTypes/color.js +7 -1
- package/dist/cjs/fieldTypes/color.js.map +1 -1
- package/dist/cjs/fieldTypes/date.js +7 -1
- package/dist/cjs/fieldTypes/date.js.map +1 -1
- package/dist/cjs/fieldTypes/date_time.js +7 -1
- package/dist/cjs/fieldTypes/date_time.js.map +1 -1
- package/dist/cjs/fieldTypes/file.js +7 -1
- package/dist/cjs/fieldTypes/file.js.map +1 -1
- package/dist/cjs/fieldTypes/float.js +7 -1
- package/dist/cjs/fieldTypes/float.js.map +1 -1
- package/dist/cjs/fieldTypes/gallery.js +7 -1
- package/dist/cjs/fieldTypes/gallery.js.map +1 -1
- package/dist/cjs/fieldTypes/integer.js +7 -1
- package/dist/cjs/fieldTypes/integer.js.map +1 -1
- package/dist/cjs/fieldTypes/json.js +7 -1
- package/dist/cjs/fieldTypes/json.js.map +1 -1
- package/dist/cjs/fieldTypes/lat_lon.js +9 -3
- package/dist/cjs/fieldTypes/lat_lon.js.map +1 -1
- package/dist/cjs/fieldTypes/link.js +7 -1
- package/dist/cjs/fieldTypes/link.js.map +1 -1
- package/dist/cjs/fieldTypes/links.js +7 -1
- package/dist/cjs/fieldTypes/links.js.map +1 -1
- package/dist/cjs/fieldTypes/rich_text.js +19 -1
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/seo.js +7 -1
- package/dist/cjs/fieldTypes/seo.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +19 -1
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/slug.js +8 -2
- package/dist/cjs/fieldTypes/slug.js.map +1 -1
- package/dist/cjs/fieldTypes/string.js +7 -1
- package/dist/cjs/fieldTypes/string.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +19 -1
- package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
- package/dist/cjs/fieldTypes/text.js +7 -1
- package/dist/cjs/fieldTypes/text.js.map +1 -1
- package/dist/cjs/fieldTypes/video.js +7 -1
- package/dist/cjs/fieldTypes/video.js.map +1 -1
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/generated/resources/Item.js +41 -23
- package/dist/cjs/generated/resources/Item.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledPublication.js +4 -2
- package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledUnpublishing.js +4 -2
- package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/cjs/generated/resources/Upload.js +4 -2
- package/dist/cjs/generated/resources/Upload.js.map +1 -1
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/cjs/utilities/itemDefinition.js +3 -0
- package/dist/cjs/utilities/itemDefinition.js.map +1 -0
- package/dist/esm/fieldTypes/boolean.d.ts +2 -0
- package/dist/esm/fieldTypes/boolean.js +5 -0
- package/dist/esm/fieldTypes/boolean.js.map +1 -1
- package/dist/esm/fieldTypes/color.d.ts +2 -0
- package/dist/esm/fieldTypes/color.js +5 -0
- package/dist/esm/fieldTypes/color.js.map +1 -1
- package/dist/esm/fieldTypes/date.d.ts +2 -0
- package/dist/esm/fieldTypes/date.js +5 -0
- package/dist/esm/fieldTypes/date.js.map +1 -1
- package/dist/esm/fieldTypes/date_time.d.ts +2 -0
- package/dist/esm/fieldTypes/date_time.js +5 -0
- package/dist/esm/fieldTypes/date_time.js.map +1 -1
- package/dist/esm/fieldTypes/file.d.ts +2 -0
- package/dist/esm/fieldTypes/file.js +5 -0
- package/dist/esm/fieldTypes/file.js.map +1 -1
- package/dist/esm/fieldTypes/float.d.ts +2 -0
- package/dist/esm/fieldTypes/float.js +5 -0
- package/dist/esm/fieldTypes/float.js.map +1 -1
- package/dist/esm/fieldTypes/gallery.d.ts +2 -0
- package/dist/esm/fieldTypes/gallery.js +5 -0
- package/dist/esm/fieldTypes/gallery.js.map +1 -1
- package/dist/esm/fieldTypes/integer.d.ts +2 -0
- package/dist/esm/fieldTypes/integer.js +5 -0
- package/dist/esm/fieldTypes/integer.js.map +1 -1
- package/dist/esm/fieldTypes/json.d.ts +2 -0
- package/dist/esm/fieldTypes/json.js +5 -0
- package/dist/esm/fieldTypes/json.js.map +1 -1
- package/dist/esm/fieldTypes/lat_lon.d.ts +6 -4
- package/dist/esm/fieldTypes/lat_lon.js +6 -1
- package/dist/esm/fieldTypes/lat_lon.js.map +1 -1
- package/dist/esm/fieldTypes/link.d.ts +2 -0
- package/dist/esm/fieldTypes/link.js +5 -0
- package/dist/esm/fieldTypes/link.js.map +1 -1
- package/dist/esm/fieldTypes/links.d.ts +2 -0
- package/dist/esm/fieldTypes/links.js +5 -0
- package/dist/esm/fieldTypes/links.js.map +1 -1
- package/dist/esm/fieldTypes/rich_text.d.ts +13 -8
- package/dist/esm/fieldTypes/rich_text.js +15 -0
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/seo.d.ts +2 -0
- package/dist/esm/fieldTypes/seo.js +5 -0
- package/dist/esm/fieldTypes/seo.js.map +1 -1
- package/dist/esm/fieldTypes/single_block.d.ts +17 -12
- package/dist/esm/fieldTypes/single_block.js +15 -0
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/slug.d.ts +2 -0
- package/dist/esm/fieldTypes/slug.js +6 -1
- package/dist/esm/fieldTypes/slug.js.map +1 -1
- package/dist/esm/fieldTypes/string.d.ts +2 -0
- package/dist/esm/fieldTypes/string.js +5 -0
- package/dist/esm/fieldTypes/string.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +15 -10
- package/dist/esm/fieldTypes/structured_text.js +15 -0
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/fieldTypes/text.d.ts +2 -0
- package/dist/esm/fieldTypes/text.js +5 -0
- package/dist/esm/fieldTypes/text.js.map +1 -1
- package/dist/esm/fieldTypes/video.d.ts +2 -0
- package/dist/esm/fieldTypes/video.js +5 -0
- package/dist/esm/fieldTypes/video.js.map +1 -1
- package/dist/esm/generated/ApiTypes.d.ts +67 -62
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/generated/RawApiTypes.d.ts +116 -121
- package/dist/esm/generated/resources/Field.d.ts +700 -700
- package/dist/esm/generated/resources/Item.d.ts +42 -24
- package/dist/esm/generated/resources/Item.js +41 -23
- package/dist/esm/generated/resources/Item.js.map +1 -1
- package/dist/esm/generated/resources/ItemVersion.d.ts +1 -1
- package/dist/esm/generated/resources/ScheduledPublication.d.ts +5 -2
- package/dist/esm/generated/resources/ScheduledPublication.js +4 -2
- package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +5 -2
- package/dist/esm/generated/resources/ScheduledUnpublishing.js +4 -2
- package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/esm/generated/resources/Upload.d.ts +10 -2
- package/dist/esm/generated/resources/Upload.js +4 -2
- package/dist/esm/generated/resources/Upload.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utilities/buildBlockRecord.d.ts +5 -31
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/dist/esm/utilities/fieldValue.d.ts +1 -1
- package/dist/esm/utilities/itemDefinition.d.ts +74 -0
- package/dist/esm/utilities/itemDefinition.js +2 -0
- package/dist/esm/utilities/itemDefinition.js.map +1 -0
- package/dist/types/fieldTypes/boolean.d.ts +2 -0
- package/dist/types/fieldTypes/color.d.ts +2 -0
- package/dist/types/fieldTypes/date.d.ts +2 -0
- package/dist/types/fieldTypes/date_time.d.ts +2 -0
- package/dist/types/fieldTypes/file.d.ts +2 -0
- package/dist/types/fieldTypes/float.d.ts +2 -0
- package/dist/types/fieldTypes/gallery.d.ts +2 -0
- package/dist/types/fieldTypes/integer.d.ts +2 -0
- package/dist/types/fieldTypes/json.d.ts +2 -0
- package/dist/types/fieldTypes/lat_lon.d.ts +6 -4
- package/dist/types/fieldTypes/link.d.ts +2 -0
- package/dist/types/fieldTypes/links.d.ts +2 -0
- package/dist/types/fieldTypes/rich_text.d.ts +13 -8
- package/dist/types/fieldTypes/seo.d.ts +2 -0
- package/dist/types/fieldTypes/single_block.d.ts +17 -12
- package/dist/types/fieldTypes/slug.d.ts +2 -0
- package/dist/types/fieldTypes/string.d.ts +2 -0
- package/dist/types/fieldTypes/structured_text.d.ts +15 -10
- package/dist/types/fieldTypes/text.d.ts +2 -0
- package/dist/types/fieldTypes/video.d.ts +2 -0
- package/dist/types/generated/ApiTypes.d.ts +67 -62
- package/dist/types/generated/RawApiTypes.d.ts +116 -121
- package/dist/types/generated/resources/Field.d.ts +700 -700
- package/dist/types/generated/resources/Item.d.ts +42 -24
- package/dist/types/generated/resources/ItemVersion.d.ts +1 -1
- package/dist/types/generated/resources/ScheduledPublication.d.ts +5 -2
- package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +5 -2
- package/dist/types/generated/resources/Upload.d.ts +10 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/utilities/buildBlockRecord.d.ts +5 -31
- package/dist/types/utilities/fieldValue.d.ts +1 -1
- package/dist/types/utilities/itemDefinition.d.ts +74 -0
- package/package.json +5 -5
- package/resources.json +564 -0
- package/src/fieldTypes/boolean.ts +11 -0
- package/src/fieldTypes/color.ts +11 -0
- package/src/fieldTypes/date.ts +11 -0
- package/src/fieldTypes/date_time.ts +11 -0
- package/src/fieldTypes/file.ts +11 -0
- package/src/fieldTypes/float.ts +11 -0
- package/src/fieldTypes/gallery.ts +11 -0
- package/src/fieldTypes/integer.ts +11 -0
- package/src/fieldTypes/json.ts +11 -0
- package/src/fieldTypes/lat_lon.ts +15 -6
- package/src/fieldTypes/link.ts +11 -0
- package/src/fieldTypes/links.ts +11 -0
- package/src/fieldTypes/rich_text.ts +51 -12
- package/src/fieldTypes/seo.ts +11 -0
- package/src/fieldTypes/single_block.ts +69 -28
- package/src/fieldTypes/slug.ts +12 -1
- package/src/fieldTypes/string.ts +11 -0
- package/src/fieldTypes/structured_text.ts +87 -19
- package/src/fieldTypes/text.ts +11 -0
- package/src/fieldTypes/video.ts +11 -0
- package/src/generated/ApiTypes.ts +110 -70
- package/src/generated/Client.ts +1 -1
- package/src/generated/RawApiTypes.ts +160 -138
- package/src/generated/resources/Item.ts +360 -108
- package/src/generated/resources/ScheduledPublication.ts +31 -11
- package/src/generated/resources/ScheduledUnpublishing.ts +31 -11
- package/src/generated/resources/Upload.ts +54 -12
- package/src/index.ts +2 -0
- package/src/utilities/buildBlockRecord.ts +19 -3
- package/src/utilities/fieldValue.ts +1 -1
- package/src/utilities/itemDefinition.ts +229 -0
package/dist/esm/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ export * from './utilities/fieldValue';
|
|
|
10
10
|
export * from './utilities/id';
|
|
11
11
|
export * from './utilities/recursiveBlocks';
|
|
12
12
|
export * from './utilities/schemaRepository';
|
|
13
|
+
export * from './utilities/itemDefinition';
|
|
14
|
+
export * from './fieldTypes';
|
|
13
15
|
export type { ApiTypes, RawApiTypes };
|
|
14
16
|
export type { ApiTypes as SchemaTypes, RawApiTypes as SimpleSchemaTypes };
|
|
15
17
|
import type * as ApiTypes from './generated/ApiTypes';
|
package/dist/esm/index.js
CHANGED
|
@@ -9,4 +9,6 @@ export * from './utilities/fieldValue';
|
|
|
9
9
|
export * from './utilities/id';
|
|
10
10
|
export * from './utilities/recursiveBlocks';
|
|
11
11
|
export * from './utilities/schemaRepository';
|
|
12
|
+
export * from './utilities/itemDefinition';
|
|
13
|
+
export * from './fieldTypes';
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9E,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9E,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,cAAc,CAAC"}
|
|
@@ -1,32 +1,6 @@
|
|
|
1
|
+
import type { NewBlockInARequest } from '../fieldTypes';
|
|
1
2
|
import type * as ApiTypes from '../generated/ApiTypes';
|
|
2
|
-
import type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
attributes?: {
|
|
7
|
-
[k: string]: unknown;
|
|
8
|
-
} | undefined;
|
|
9
|
-
meta?: {
|
|
10
|
-
created_at?: string | undefined;
|
|
11
|
-
updated_at?: string | undefined;
|
|
12
|
-
published_at?: string | null | undefined;
|
|
13
|
-
first_published_at?: string | null | undefined;
|
|
14
|
-
publication_scheduled_at?: string | null | undefined;
|
|
15
|
-
unpublishing_scheduled_at?: string | null | undefined;
|
|
16
|
-
status?: "published" | "draft" | "updated" | null | undefined;
|
|
17
|
-
is_valid?: boolean | undefined;
|
|
18
|
-
current_version?: string | undefined;
|
|
19
|
-
is_current_version_valid?: boolean | null | undefined;
|
|
20
|
-
is_published_version_valid?: boolean | null | undefined;
|
|
21
|
-
stage?: string | null | undefined;
|
|
22
|
-
has_children?: boolean | null | undefined;
|
|
23
|
-
} | undefined;
|
|
24
|
-
relationships?: {
|
|
25
|
-
item_type?: {
|
|
26
|
-
data: RawApiTypes.ItemTypeData;
|
|
27
|
-
} | undefined;
|
|
28
|
-
creator?: {
|
|
29
|
-
data: RawApiTypes.UserData | RawApiTypes.SsoUserData | RawApiTypes.AccessTokenData | RawApiTypes.AccountData | RawApiTypes.OrganizationData;
|
|
30
|
-
} | undefined;
|
|
31
|
-
} | undefined;
|
|
32
|
-
};
|
|
3
|
+
import type { ItemTypeDefinition, ItemTypeDefinitionToItemDefinitionAsRequest } from './itemDefinition';
|
|
4
|
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
5
|
+
export declare function buildBlockRecord<D extends ItemTypeDefinition = ItemTypeDefinition>(body: ApiTypes.ItemUpdateSchema<ItemTypeDefinitionToItemDefinitionAsRequest<NoInfer<D>>>): NewBlockInARequest<ItemTypeDefinitionToItemDefinitionAsRequest<NoInfer<D>>>;
|
|
6
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildBlockRecord.js","sourceRoot":"","sources":["../../../src/utilities/buildBlockRecord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"buildBlockRecord.js","sourceRoot":"","sources":["../../../src/utilities/buildBlockRecord.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AAGpD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAQ9C,MAAM,UAAU,gBAAgB,CAG9B,IAEC;IAED,OAAO,KAAK,CAAC,oBAAoB,CAI9B,IAAI,EAAE;QACP,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,UAAU,EAAE,GAAG;QACf,aAAa,EAAE,CAAC,WAAW,CAAC;KAC7B,CAAC,CAAC,IAAI,CAAC;AACV,CAAC"}
|
|
@@ -7,7 +7,7 @@ import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
|
7
7
|
* for various locales structured as an object, such as
|
|
8
8
|
* `{ "en": "Hello", "it": "Ciao" }`
|
|
9
9
|
*/
|
|
10
|
-
export type LocalizedFieldValue = Record<string,
|
|
10
|
+
export type LocalizedFieldValue<T = unknown> = Record<string, T>;
|
|
11
11
|
/**
|
|
12
12
|
* Determines whether a DatoCMS field is localized or not.
|
|
13
13
|
*
|
|
@@ -0,0 +1,74 @@
|
|
|
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 './fieldValue';
|
|
3
|
+
/** Base field definition */
|
|
4
|
+
type BaseFieldDefinition<Type extends string> = {
|
|
5
|
+
type: Type;
|
|
6
|
+
localized?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type RichTextFieldDefinition<AllowedBlocks extends ItemTypeDefinition = ItemTypeDefinition> = BaseFieldDefinition<'rich_text'> & {
|
|
9
|
+
blocks: AllowedBlocks;
|
|
10
|
+
};
|
|
11
|
+
type SingleBlockFieldDefinition<AllowedBlocks extends ItemTypeDefinition = ItemTypeDefinition> = BaseFieldDefinition<'single_block'> & {
|
|
12
|
+
blocks: AllowedBlocks;
|
|
13
|
+
};
|
|
14
|
+
type StructuredTextFieldDefinition<AllowedBlocks extends ItemTypeDefinition = ItemTypeDefinition, AllowedInlineBlocks extends ItemTypeDefinition = ItemTypeDefinition> = BaseFieldDefinition<'structured_text'> & {
|
|
15
|
+
blocks: AllowedBlocks;
|
|
16
|
+
inline_blocks: AllowedInlineBlocks;
|
|
17
|
+
};
|
|
18
|
+
/** Field definition union */
|
|
19
|
+
export type FieldDefinition = BaseFieldDefinition<'boolean' | 'color' | 'date' | 'date_time' | 'file' | 'float' | 'gallery' | 'integer' | 'json' | 'lat_lon' | 'link' | 'links' | 'seo' | 'slug' | 'string' | 'text' | 'video' | 'unknown'> | RichTextFieldDefinition | SingleBlockFieldDefinition | StructuredTextFieldDefinition;
|
|
20
|
+
/** Item type definition */
|
|
21
|
+
export type ItemTypeDefinition<ItemTypeId extends string = string, FieldDefinitions extends Record<string, FieldDefinition> = {}> = {
|
|
22
|
+
itemTypeId: ItemTypeId;
|
|
23
|
+
fields: FieldDefinitions;
|
|
24
|
+
};
|
|
25
|
+
/** Item definition */
|
|
26
|
+
export type ItemDefinition<ItemTypeId extends string = string, FieldValues extends Record<string, unknown> = Record<string, unknown>> = {
|
|
27
|
+
itemTypeId: ItemTypeId;
|
|
28
|
+
fields: FieldValues;
|
|
29
|
+
};
|
|
30
|
+
/** Standard field values */
|
|
31
|
+
type FieldTypeToValue = {
|
|
32
|
+
boolean: BooleanFieldValue;
|
|
33
|
+
color: ColorFieldValue;
|
|
34
|
+
date: DateFieldValue;
|
|
35
|
+
date_time: DateTimeFieldValue;
|
|
36
|
+
file: FileFieldValue;
|
|
37
|
+
float: FloatFieldValue;
|
|
38
|
+
gallery: GalleryFieldValue;
|
|
39
|
+
integer: IntegerFieldValue;
|
|
40
|
+
json: JsonFieldValue;
|
|
41
|
+
lat_lon: LatLonFieldValue;
|
|
42
|
+
link: LinkFieldValue;
|
|
43
|
+
links: LinksFieldValue;
|
|
44
|
+
rich_text: RichTextFieldValue;
|
|
45
|
+
seo: SeoFieldValue;
|
|
46
|
+
single_block: SingleBlockFieldValue;
|
|
47
|
+
slug: SlugFieldValue;
|
|
48
|
+
string: StringFieldValue;
|
|
49
|
+
structured_text: StructuredTextFieldValue;
|
|
50
|
+
text: TextFieldValue;
|
|
51
|
+
video: VideoFieldValue;
|
|
52
|
+
unknown: unknown;
|
|
53
|
+
};
|
|
54
|
+
/** Localized wrapper */
|
|
55
|
+
type LocalizeIfNeeded<T extends FieldDefinition, Value> = T extends {
|
|
56
|
+
localized: true;
|
|
57
|
+
} ? LocalizedFieldValue<Value> : Value;
|
|
58
|
+
/** Standard mapping */
|
|
59
|
+
type FieldDefinitionToFieldValue<T extends FieldDefinition> = LocalizeIfNeeded<T, FieldTypeToValue[T['type']]>;
|
|
60
|
+
/** AsRequest mapping (block fields become generic over allowed blocks) */
|
|
61
|
+
type FieldDefinitionToFieldValueAsRequest<T extends FieldDefinition> = T extends RichTextFieldDefinition<infer B> ? LocalizeIfNeeded<T, RichTextFieldValueAsRequest<ItemTypeDefinitionToItemDefinitionAsRequest<B>>> : T extends SingleBlockFieldDefinition<infer B> ? LocalizeIfNeeded<T, SingleBlockFieldValueAsRequest<ItemTypeDefinitionToItemDefinitionAsRequest<B>>> : T extends StructuredTextFieldDefinition<infer B, infer I> ? LocalizeIfNeeded<T, StructuredTextFieldValueAsRequest<ItemTypeDefinitionToItemDefinitionAsRequest<B>, ItemTypeDefinitionToItemDefinitionAsRequest<I>>> : LocalizeIfNeeded<T, FieldTypeToValue[T['type']]>;
|
|
62
|
+
type FieldDefinitionToFieldValueWithNestedBlocks<T extends FieldDefinition> = T extends RichTextFieldDefinition<infer B> ? LocalizeIfNeeded<T, RichTextFieldValueWithNestedBlocks<ItemTypeDefinitionToItemDefinitionWithNestedBlocks<B>>> : T extends SingleBlockFieldDefinition<infer B> ? LocalizeIfNeeded<T, SingleBlockFieldValueWithNestedBlocks<ItemTypeDefinitionToItemDefinitionWithNestedBlocks<B>>> : T extends StructuredTextFieldDefinition<infer B, infer I> ? LocalizeIfNeeded<T, StructuredTextFieldValueWithNestedBlocks<ItemTypeDefinitionToItemDefinitionWithNestedBlocks<B>, ItemTypeDefinitionToItemDefinitionWithNestedBlocks<I>>> : LocalizeIfNeeded<T, FieldTypeToValue[T['type']]>;
|
|
63
|
+
/** Transformers */
|
|
64
|
+
export type ItemTypeDefinitionToItemDefinition<T extends ItemTypeDefinition> = T extends ItemTypeDefinition ? keyof T['fields'] extends never ? ItemDefinition<T['itemTypeId']> : ItemDefinition<T['itemTypeId'], {
|
|
65
|
+
[K in keyof T['fields']]: T['fields'][K] extends FieldDefinition ? FieldDefinitionToFieldValue<T['fields'][K]> : never;
|
|
66
|
+
}> : never;
|
|
67
|
+
export type ItemTypeDefinitionToItemDefinitionAsRequest<T extends ItemTypeDefinition> = T extends ItemTypeDefinition ? keyof T['fields'] extends never ? ItemDefinition<T['itemTypeId']> : ItemDefinition<T['itemTypeId'], Partial<{
|
|
68
|
+
[K in keyof T['fields']]: T['fields'][K] extends FieldDefinition ? FieldDefinitionToFieldValueAsRequest<T['fields'][K]> : never;
|
|
69
|
+
}>> : never;
|
|
70
|
+
export type ItemTypeDefinitionToItemDefinitionWithNestedBlocks<T extends ItemTypeDefinition> = T extends ItemTypeDefinition ? keyof T['fields'] extends never ? ItemDefinition<T['itemTypeId']> : ItemDefinition<T['itemTypeId'], {
|
|
71
|
+
[K in keyof T['fields']]: T['fields'][K] extends FieldDefinition ? FieldDefinitionToFieldValueWithNestedBlocks<T['fields'][K]> : never;
|
|
72
|
+
}> : never;
|
|
73
|
+
export type UnknownField = Record<string, unknown>;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"itemDefinition.js","sourceRoot":"","sources":["../../../src/utilities/itemDefinition.ts"],"names":[],"mappings":""}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { BooleanEditorConfiguration } from './appearance/boolean';
|
|
2
3
|
import type { BooleanRadioGroupEditorConfiguration } from './appearance/boolean_radio_group';
|
|
3
4
|
export type BooleanFieldValue = boolean | null;
|
|
4
5
|
export declare function isBooleanFieldValue(value: unknown): value is BooleanFieldValue;
|
|
6
|
+
export declare function isLocalizedBooleanFieldValue(value: unknown): value is LocalizedFieldValue<BooleanFieldValue>;
|
|
5
7
|
export type BooleanFieldValidators = Record<string, never>;
|
|
6
8
|
export type BooleanFieldAppearance = {
|
|
7
9
|
editor: 'boolean';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { ColorPickerEditorConfiguration } from './appearance/color_picker';
|
|
2
3
|
import type { RequiredValidator } from './validators/required';
|
|
3
4
|
export type ColorFieldValue = {
|
|
@@ -7,6 +8,7 @@ export type ColorFieldValue = {
|
|
|
7
8
|
alpha: number;
|
|
8
9
|
} | null;
|
|
9
10
|
export declare function isColorFieldValue(value: unknown): value is ColorFieldValue;
|
|
11
|
+
export declare function isLocalizedColorFieldValue(value: unknown): value is LocalizedFieldValue<ColorFieldValue>;
|
|
10
12
|
export type ColorFieldValidators = {
|
|
11
13
|
/** Value must be specified or it won't be valid */
|
|
12
14
|
required?: RequiredValidator;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { DatePickerEditorConfiguration } from './appearance/date_picker';
|
|
2
3
|
import type { DateRangeValidator } from './validators/date_range';
|
|
3
4
|
import type { RequiredValidator } from './validators/required';
|
|
4
5
|
export type DateFieldValue = string | null;
|
|
5
6
|
export declare function isDateFieldValue(value: unknown): value is DateFieldValue;
|
|
7
|
+
export declare function isLocalizedDateFieldValue(value: unknown): value is LocalizedFieldValue<DateFieldValue>;
|
|
6
8
|
export type DateFieldValidators = {
|
|
7
9
|
/** Value must be specified or it won't be valid */
|
|
8
10
|
required?: RequiredValidator;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { DateTimePickerEditorConfiguration } from './appearance/date_time_picker';
|
|
2
3
|
import type { DateTimeRangeValidator } from './validators/date_time_range';
|
|
3
4
|
import type { RequiredValidator } from './validators/required';
|
|
4
5
|
export type DateTimeFieldValue = string | null;
|
|
5
6
|
export declare function isDateTimeFieldValue(value: unknown): value is DateTimeFieldValue;
|
|
7
|
+
export declare function isLocalizedDateTimeFieldValue(value: unknown): value is LocalizedFieldValue<DateTimeFieldValue>;
|
|
6
8
|
export type DateTimeFieldValidators = {
|
|
7
9
|
/** Value must be specified or it won't be valid */
|
|
8
10
|
required?: RequiredValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { FileEditorConfiguration } from './appearance/file';
|
|
2
3
|
import type { ExtensionValidator } from './validators/extension';
|
|
3
4
|
import type { FileSizeValidator } from './validators/file_size';
|
|
@@ -16,6 +17,7 @@ export type FileFieldValue = {
|
|
|
16
17
|
} | null;
|
|
17
18
|
} | null;
|
|
18
19
|
export declare function isFileFieldValue(value: unknown): value is FileFieldValue;
|
|
20
|
+
export declare function isLocalizedFileFieldValue(value: unknown): value is LocalizedFieldValue<FileFieldValue>;
|
|
19
21
|
export type FileFieldValidators = {
|
|
20
22
|
/** Value must be specified or it won't be valid */
|
|
21
23
|
required?: RequiredValidator;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { FloatEditorConfiguration } from './appearance/float';
|
|
2
3
|
import type { NumberRangeValidator } from './validators/number_range';
|
|
3
4
|
import type { RequiredValidator } from './validators/required';
|
|
4
5
|
export type FloatFieldValue = number | null;
|
|
5
6
|
export declare function isFloatFieldValue(value: unknown): value is FloatFieldValue;
|
|
7
|
+
export declare function isLocalizedFloatFieldValue(value: unknown): value is LocalizedFieldValue<FloatFieldValue>;
|
|
6
8
|
export type FloatFieldValidators = {
|
|
7
9
|
/** Value must be specified or it won't be valid */
|
|
8
10
|
required?: RequiredValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { GalleryEditorConfiguration } from './appearance/gallery';
|
|
2
3
|
import type { ExtensionValidator } from './validators/extension';
|
|
3
4
|
import type { FileSizeValidator } from './validators/file_size';
|
|
@@ -16,6 +17,7 @@ export type GalleryFieldValue = Array<{
|
|
|
16
17
|
} | null;
|
|
17
18
|
}> | null;
|
|
18
19
|
export declare function isGalleryFieldValue(value: unknown): value is GalleryFieldValue;
|
|
20
|
+
export declare function isLocalizedGalleryFieldValue(value: unknown): value is LocalizedFieldValue<GalleryFieldValue>;
|
|
19
21
|
export type GalleryFieldValidators = {
|
|
20
22
|
/** Only accept a number of items within the specified range */
|
|
21
23
|
size?: SizeValidator;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { IntegerEditorConfiguration } from './appearance/integer';
|
|
2
3
|
import type { NumberRangeValidator } from './validators/number_range';
|
|
3
4
|
import type { RequiredValidator } from './validators/required';
|
|
4
5
|
export type IntegerFieldValue = number | null;
|
|
5
6
|
export declare function isIntegerFieldValue(value: unknown): value is IntegerFieldValue;
|
|
7
|
+
export declare function isLocalizedIntegerFieldValue(value: unknown): value is LocalizedFieldValue<IntegerFieldValue>;
|
|
6
8
|
export type IntegerFieldValidators = {
|
|
7
9
|
/** Value must be specified or it won't be valid */
|
|
8
10
|
required?: RequiredValidator;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { JsonEditorConfiguration } from './appearance/json';
|
|
2
3
|
import type { StringCheckboxGroupEditorConfiguration } from './appearance/string_checkbox_group';
|
|
3
4
|
import type { StringMultiSelectEditorConfiguration } from './appearance/string_multi_select';
|
|
4
5
|
import type { RequiredValidator } from './validators/required';
|
|
5
6
|
export type JsonFieldValue = string | null;
|
|
6
7
|
export declare function isJsonFieldValue(value: unknown): value is JsonFieldValue;
|
|
8
|
+
export declare function isLocalizedJsonFieldValue(value: unknown): value is LocalizedFieldValue<JsonFieldValue>;
|
|
7
9
|
export type JsonFieldValidators = {
|
|
8
10
|
/** Value must be specified or it won't be valid */
|
|
9
11
|
required?: RequiredValidator;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { MapEditorConfiguration } from './appearance/map';
|
|
2
3
|
import type { RequiredValidator } from './validators/required';
|
|
3
|
-
export type
|
|
4
|
+
export type LatLonFieldValue = {
|
|
4
5
|
latitude: number;
|
|
5
6
|
longitude: number;
|
|
6
7
|
} | null;
|
|
7
|
-
export declare function
|
|
8
|
-
export
|
|
8
|
+
export declare function isLatLonFieldValue(value: unknown): value is LatLonFieldValue;
|
|
9
|
+
export declare function isLocalizedLatLonFieldValue(value: unknown): value is LocalizedFieldValue<LatLonFieldValue>;
|
|
10
|
+
export type LatLonFieldValidators = {
|
|
9
11
|
/** Value must be specified or it won't be valid */
|
|
10
12
|
required?: RequiredValidator;
|
|
11
13
|
};
|
|
12
|
-
export type
|
|
14
|
+
export type LatLonFieldAppearance = {
|
|
13
15
|
editor: 'map';
|
|
14
16
|
parameters: MapEditorConfiguration;
|
|
15
17
|
} | {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { LinkEmbedEditorConfiguration } from './appearance/link_embed';
|
|
2
3
|
import type { LinkSelectEditorConfiguration } from './appearance/link_select';
|
|
3
4
|
import type { ItemItemTypeValidator } from './validators/item_item_type';
|
|
@@ -5,6 +6,7 @@ import type { RequiredValidator } from './validators/required';
|
|
|
5
6
|
import type { UniqueValidator } from './validators/unique';
|
|
6
7
|
export type LinkFieldValue = string | null;
|
|
7
8
|
export declare function isLinkFieldValue(value: unknown): value is LinkFieldValue;
|
|
9
|
+
export declare function isLocalizedLinkFieldValue(value: unknown): value is LocalizedFieldValue<LinkFieldValue>;
|
|
8
10
|
export type LinkFieldValidators = {
|
|
9
11
|
/** Only accept references to records of the specified models */
|
|
10
12
|
item_item_type: ItemItemTypeValidator;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { LinksEmbedEditorConfiguration } from './appearance/links_embed';
|
|
2
3
|
import type { LinksSelectEditorConfiguration } from './appearance/links_select';
|
|
3
4
|
import type { ItemsItemTypeValidator } from './validators/items_item_type';
|
|
4
5
|
import type { SizeValidator } from './validators/size';
|
|
5
6
|
export type LinksFieldValue = string[] | null;
|
|
6
7
|
export declare function isLinksFieldValue(value: unknown): value is LinksFieldValue;
|
|
8
|
+
export declare function isLocalizedLinksFieldValue(value: unknown): value is LocalizedFieldValue<LinksFieldValue>;
|
|
7
9
|
export type LinksFieldValidators = {
|
|
8
10
|
/** Only accept references to records of the specified models */
|
|
9
11
|
items_item_type: ItemsItemTypeValidator;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
2
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
3
|
+
import type { ItemDefinition } from '../utilities/itemDefinition';
|
|
4
|
+
import type { RichTextEditorConfiguration } from './appearance/rich_text';
|
|
2
5
|
import { type BlockItemInARequest } from './single_block';
|
|
6
|
+
import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
|
|
7
|
+
import type { SizeValidator } from './validators/size';
|
|
3
8
|
/**
|
|
4
9
|
* MODULAR CONTENT FIELD TYPE SYSTEM FOR DATOCMS
|
|
5
10
|
*
|
|
@@ -29,7 +34,7 @@ import { type BlockItemInARequest } from './single_block';
|
|
|
29
34
|
/**
|
|
30
35
|
* Basic Modular Content field value - array of string block IDs (lightweight references)
|
|
31
36
|
*/
|
|
32
|
-
export type RichTextFieldValue = string[]
|
|
37
|
+
export type RichTextFieldValue = string[];
|
|
33
38
|
/**
|
|
34
39
|
* =============================================================================
|
|
35
40
|
* REQUEST VARIANT - Type for sending data TO the DatoCMS API
|
|
@@ -46,7 +51,7 @@ export type RichTextFieldValue = string[] | null;
|
|
|
46
51
|
* - RawApiTypes.Item: Full block object with ID (for updates)
|
|
47
52
|
* - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
|
|
48
53
|
*/
|
|
49
|
-
export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
|
|
54
|
+
export type RichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition> = BlockItemInARequest<D>[] | null;
|
|
50
55
|
/**
|
|
51
56
|
* =============================================================================
|
|
52
57
|
* NESTED VARIANT - Type for API responses with ?nested=true parameter
|
|
@@ -59,7 +64,7 @@ export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
|
|
|
59
64
|
/**
|
|
60
65
|
* Modular Content field value with nested blocks - array of fully populated block objects
|
|
61
66
|
*/
|
|
62
|
-
export type RichTextFieldValueWithNestedBlocks = RawApiTypes.Item[]
|
|
67
|
+
export type RichTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition> = RawApiTypes.Item<D>[];
|
|
63
68
|
/**
|
|
64
69
|
* =============================================================================
|
|
65
70
|
* TYPE GUARDS - Runtime validation functions
|
|
@@ -70,19 +75,19 @@ export type RichTextFieldValueWithNestedBlocks = RawApiTypes.Item[] | null;
|
|
|
70
75
|
* Checks for array structure and ensures all blocks are string references.
|
|
71
76
|
*/
|
|
72
77
|
export declare function isRichTextFieldValue(value: unknown): value is RichTextFieldValue;
|
|
78
|
+
export declare function isLocalizedRichTextFieldValue(value: unknown): value is LocalizedFieldValue<RichTextFieldValue>;
|
|
73
79
|
/**
|
|
74
80
|
* Type guard for Modular Content field values in API request format.
|
|
75
81
|
* Allows blocks as string IDs, full objects with IDs, or objects without IDs.
|
|
76
82
|
*/
|
|
77
|
-
export declare function isRichTextFieldValueAsRequest(value: unknown): value is RichTextFieldValueAsRequest
|
|
83
|
+
export declare function isRichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is RichTextFieldValueAsRequest<D>;
|
|
84
|
+
export declare function isLocalizedRichTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<RichTextFieldValueAsRequest<D>>;
|
|
78
85
|
/**
|
|
79
86
|
* Type guard for Modular Content field values with nested blocks (?nested=true format).
|
|
80
87
|
* Ensures all blocks are full RawApiTypes.Item objects with complete data.
|
|
81
88
|
*/
|
|
82
|
-
export declare function isRichTextFieldValueWithNestedBlocks(value: unknown): value is RichTextFieldValueWithNestedBlocks
|
|
83
|
-
|
|
84
|
-
import type { RichTextBlocksValidator } from './validators/rich_text_blocks';
|
|
85
|
-
import type { SizeValidator } from './validators/size';
|
|
89
|
+
export declare function isRichTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is RichTextFieldValueWithNestedBlocks<D>;
|
|
90
|
+
export declare function isLocalizedRichTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<RichTextFieldValueWithNestedBlocks<D>>;
|
|
86
91
|
export type RichTextFieldValidators = {
|
|
87
92
|
/** Only accept references to block records of the specified block models */
|
|
88
93
|
rich_text_blocks: RichTextBlocksValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { SeoEditorConfiguration } from './appearance/seo';
|
|
2
3
|
import type { DescriptionLengthValidator } from './validators/description_length';
|
|
3
4
|
import type { FileSizeValidator } from './validators/file_size';
|
|
@@ -13,6 +14,7 @@ export type SeoFieldValue = {
|
|
|
13
14
|
no_index?: boolean;
|
|
14
15
|
} | null;
|
|
15
16
|
export declare function isSeoFieldValue(value: unknown): value is SeoFieldValue;
|
|
17
|
+
export declare function isLocalizedSeoFieldValue(value: unknown): value is LocalizedFieldValue<SeoFieldValue>;
|
|
16
18
|
export type SeoFieldValidators = {
|
|
17
19
|
/** SEO field has to specify one or more properties, or it won't be valid */
|
|
18
20
|
required_seo_fields?: RequiredSeoFieldsValidator;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
2
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
3
|
+
import type { ItemDefinition } from '../utilities/itemDefinition';
|
|
2
4
|
import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
|
|
3
5
|
import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
|
|
4
6
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -44,11 +46,11 @@ export type SingleBlockFieldValue = string | null;
|
|
|
44
46
|
* - Omit ID for new blocks being created
|
|
45
47
|
*/
|
|
46
48
|
/** Represents an existing block in a CMA request */
|
|
47
|
-
export type UnchangedBlockInARequest =
|
|
49
|
+
export type UnchangedBlockInARequest<D extends ItemDefinition = ItemDefinition> = RawApiTypes.Item<D>['id'];
|
|
48
50
|
/** Represents a block we want to update in a CMA request */
|
|
49
|
-
export type UpdatedBlockInARequest = OptionalFields<RawApiTypes.Item
|
|
51
|
+
export type UpdatedBlockInARequest<D extends ItemDefinition = ItemDefinition> = OptionalFields<RawApiTypes.Item<D>, 'meta'>;
|
|
50
52
|
/** Represents a new block to create in a CMA request */
|
|
51
|
-
export type NewBlockInARequest = OptionalFields<RawApiTypes.Item
|
|
53
|
+
export type NewBlockInARequest<D extends ItemDefinition = ItemDefinition> = OptionalFields<RawApiTypes.Item<D>, 'id' | 'meta'>;
|
|
52
54
|
/**
|
|
53
55
|
* Union type representing the different ways a block can be specified in API requests:
|
|
54
56
|
* - string: Just the block ID (to keep existing blocks unchanged)
|
|
@@ -57,14 +59,14 @@ export type NewBlockInARequest = OptionalFields<RawApiTypes.Item, 'id' | 'meta'>
|
|
|
57
59
|
*
|
|
58
60
|
* Also, 'meta' can always be omitted
|
|
59
61
|
*/
|
|
60
|
-
export type BlockItemInARequest = UnchangedBlockInARequest | UpdatedBlockInARequest | NewBlockInARequest
|
|
62
|
+
export type BlockItemInARequest<D extends ItemDefinition = ItemDefinition> = UnchangedBlockInARequest | UpdatedBlockInARequest<D> | NewBlockInARequest<D>;
|
|
61
63
|
/**
|
|
62
64
|
* Single Block field value for API requests - allows flexible block representations:
|
|
63
65
|
* - string: Just the block ID (to keep existing blocks unchanged)
|
|
64
66
|
* - Full block object with ID (to update an existing block)
|
|
65
67
|
* - Block object without ID (to create a new block)
|
|
66
68
|
*/
|
|
67
|
-
export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
|
|
69
|
+
export type SingleBlockFieldValueAsRequest<D extends ItemDefinition = ItemDefinition> = BlockItemInARequest<D> | null;
|
|
68
70
|
/**
|
|
69
71
|
* =============================================================================
|
|
70
72
|
* NESTED VARIANT - Type for API responses with ?nested=true parameter
|
|
@@ -77,7 +79,7 @@ export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
|
|
|
77
79
|
/**
|
|
78
80
|
* Single Block field value with nested block - fully populated block object
|
|
79
81
|
*/
|
|
80
|
-
export type SingleBlockFieldValueWithNestedBlocks = RawApiTypes.Item | null;
|
|
82
|
+
export type SingleBlockFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition> = RawApiTypes.Item<D> | null;
|
|
81
83
|
/**
|
|
82
84
|
* =============================================================================
|
|
83
85
|
* SHARED UTILITY FUNCTIONS
|
|
@@ -88,16 +90,16 @@ export type SingleBlockFieldValueWithNestedBlocks = RawApiTypes.Item | null;
|
|
|
88
90
|
* Validates if the input is a valid item (either block or record) ID
|
|
89
91
|
*/
|
|
90
92
|
export declare function isItemId(input: unknown): input is string;
|
|
91
|
-
export type ItemWithOptionalIdAndMeta = OptionalFields<RawApiTypes.Item
|
|
93
|
+
export type ItemWithOptionalIdAndMeta<D extends ItemDefinition = ItemDefinition> = OptionalFields<RawApiTypes.Item<D>, 'id' | 'meta'>;
|
|
92
94
|
/**
|
|
93
95
|
* Validates if the input is a RawApiTypes.Item object (with optional `id` and `meta`)
|
|
94
96
|
*/
|
|
95
|
-
export declare function isItemWithOptionalIdAndMeta(block: unknown): block is ItemWithOptionalIdAndMeta
|
|
96
|
-
export type ItemWithOptionalMeta = OptionalFields<RawApiTypes.Item
|
|
97
|
+
export declare function isItemWithOptionalIdAndMeta<D extends ItemDefinition = ItemDefinition>(block: unknown): block is ItemWithOptionalIdAndMeta<D>;
|
|
98
|
+
export type ItemWithOptionalMeta<D extends ItemDefinition = ItemDefinition> = OptionalFields<RawApiTypes.Item<D>, 'meta'>;
|
|
97
99
|
/**
|
|
98
100
|
* Validates if the input is a a complete RawApiTypes.Item object with optional `meta`
|
|
99
101
|
*/
|
|
100
|
-
export declare function isItemWithOptionalMeta(block: unknown): block is ItemWithOptionalMeta
|
|
102
|
+
export declare function isItemWithOptionalMeta<D extends ItemDefinition = ItemDefinition>(block: unknown): block is ItemWithOptionalMeta<D>;
|
|
101
103
|
/**
|
|
102
104
|
* =============================================================================
|
|
103
105
|
* TYPE GUARDS - Runtime validation functions
|
|
@@ -108,16 +110,19 @@ export declare function isItemWithOptionalMeta(block: unknown): block is ItemWit
|
|
|
108
110
|
* Checks for string structure and ensures block is a string reference.
|
|
109
111
|
*/
|
|
110
112
|
export declare function isSingleBlockFieldValue(value: unknown): value is SingleBlockFieldValue;
|
|
113
|
+
export declare function isLocalizedSingleBlockFieldValue(value: unknown): value is LocalizedFieldValue<SingleBlockFieldValue>;
|
|
111
114
|
/**
|
|
112
115
|
* Type guard for Single Block field values in API request format.
|
|
113
116
|
* Allows block as string ID, full object with ID, or object without ID.
|
|
114
117
|
*/
|
|
115
|
-
export declare function isSingleBlockFieldValueAsRequest(value: unknown): value is SingleBlockFieldValueAsRequest
|
|
118
|
+
export declare function isSingleBlockFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is SingleBlockFieldValueAsRequest<D>;
|
|
119
|
+
export declare function isLocalizedSingleBlockFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<SingleBlockFieldValueAsRequest<D>>;
|
|
116
120
|
/**
|
|
117
121
|
* Type guard for Single Block field values with nested blocks (?nested=true format).
|
|
118
122
|
* Ensures block is a full RawApiTypes.Item object with complete data.
|
|
119
123
|
*/
|
|
120
|
-
export declare function isSingleBlockFieldValueWithNestedBlocks(value: unknown): value is SingleBlockFieldValueWithNestedBlocks
|
|
124
|
+
export declare function isSingleBlockFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is SingleBlockFieldValueWithNestedBlocks<D>;
|
|
125
|
+
export declare function isLocalizedSingleBlockFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<SingleBlockFieldValueWithNestedBlocks<D>>;
|
|
121
126
|
export type SingleBlockFieldValidators = {
|
|
122
127
|
/** Only accept references to block records of the specified block models */
|
|
123
128
|
single_block_blocks: SingleBlockBlocksValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { SlugEditorConfiguration } from './appearance/slug';
|
|
2
3
|
import type { LengthValidator } from './validators/length';
|
|
3
4
|
import type { RequiredValidator } from './validators/required';
|
|
@@ -5,6 +6,7 @@ import type { SlugFormatValidator } from './validators/slug_format';
|
|
|
5
6
|
import type { SlugTitleFieldValidator } from './validators/slug_title_field';
|
|
6
7
|
export type SlugFieldValue = string | null;
|
|
7
8
|
export declare function isSlugFieldValue(value: unknown): value is SlugFieldValue;
|
|
9
|
+
export declare function isLocalizedSlugFieldValue(value: unknown): value is LocalizedFieldValue<SlugFieldValue>;
|
|
8
10
|
export type SlugFieldValidators = {
|
|
9
11
|
/** Value must be specified or it won't be valid */
|
|
10
12
|
required?: RequiredValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { SingleLineEditorConfiguration } from './appearance/single_line';
|
|
2
3
|
import type { StringRadioGroupEditorConfiguration } from './appearance/string_radio_group';
|
|
3
4
|
import type { StringSelectEditorConfiguration } from './appearance/string_select';
|
|
@@ -8,6 +9,7 @@ import type { RequiredValidator } from './validators/required';
|
|
|
8
9
|
import type { UniqueValidator } from './validators/unique';
|
|
9
10
|
export type StringFieldValue = string | null;
|
|
10
11
|
export declare function isStringFieldValue(value: unknown): value is StringFieldValue;
|
|
12
|
+
export declare function isLocalizedStringFieldValue(value: unknown): value is LocalizedFieldValue<StringFieldValue>;
|
|
11
13
|
export type StringFieldValidators = {
|
|
12
14
|
/** Value must be specified or it won't be valid */
|
|
13
15
|
required?: RequiredValidator;
|
|
@@ -1,5 +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
|
+
import type { ItemDefinition } from '../utilities/itemDefinition';
|
|
3
5
|
import type { StructuredTextEditorConfiguration } from './appearance/structured_text';
|
|
4
6
|
import { type BlockItemInARequest } from './single_block';
|
|
5
7
|
import type { LengthValidator } from './validators/length';
|
|
@@ -38,15 +40,15 @@ import type { StructuredTextLinksValidator } from './validators/structured_text_
|
|
|
38
40
|
/**
|
|
39
41
|
* Variant of 'block' structured text node for API requests
|
|
40
42
|
*/
|
|
41
|
-
export type BlockAsRequest = Block<BlockItemInARequest
|
|
43
|
+
export type BlockAsRequest<D extends ItemDefinition = ItemDefinition> = Block<BlockItemInARequest<D>>;
|
|
42
44
|
/**
|
|
43
45
|
* Variant of 'inlineBlock' structured text node for API requests
|
|
44
46
|
*/
|
|
45
|
-
export type InlineBlockAsRequest = InlineBlock<BlockItemInARequest
|
|
47
|
+
export type InlineBlockAsRequest<D extends ItemDefinition = ItemDefinition> = InlineBlock<BlockItemInARequest<D>>;
|
|
46
48
|
/**
|
|
47
49
|
* Variant of Structured Text document for API requests
|
|
48
50
|
*/
|
|
49
|
-
export type DocumentAsRequest = Document<BlockItemInARequest
|
|
51
|
+
export type DocumentAsRequest<BlockItemDefinition extends ItemDefinition = ItemDefinition, InlineBlockItemDefinition extends ItemDefinition = ItemDefinition> = Document<BlockItemInARequest<BlockItemDefinition>, BlockItemInARequest<InlineBlockItemDefinition>>;
|
|
50
52
|
/**
|
|
51
53
|
* =============================================================================
|
|
52
54
|
* NESTED VARIANTS - Types for API responses with ?nested=true parameter
|
|
@@ -59,15 +61,15 @@ export type DocumentAsRequest = Document<BlockItemInARequest>;
|
|
|
59
61
|
/**
|
|
60
62
|
* Variant of 'block' structured text node for ?nested=true API responses
|
|
61
63
|
*/
|
|
62
|
-
export type BlockWithNestedBlocks = Block<RawApiTypes.Item
|
|
64
|
+
export type BlockWithNestedBlocks<D extends ItemDefinition = ItemDefinition> = Block<RawApiTypes.Item<D>>;
|
|
63
65
|
/**
|
|
64
66
|
* Variant of 'inlineBlock' structured text node for ?nested=true API responses
|
|
65
67
|
*/
|
|
66
|
-
export type InlineBlockWithNestedBlocks = InlineBlock<RawApiTypes.Item
|
|
68
|
+
export type InlineBlockWithNestedBlocks<D extends ItemDefinition = ItemDefinition> = InlineBlock<RawApiTypes.Item<D>>;
|
|
67
69
|
/**
|
|
68
70
|
* Variant of Structured Text document for ?nested=true API responses
|
|
69
71
|
*/
|
|
70
|
-
export type DocumentWithNestedBlocks = Document<RawApiTypes.Item
|
|
72
|
+
export type DocumentWithNestedBlocks<BlockItemDefinition extends ItemDefinition = ItemDefinition, InlineBlockItemDefinition extends ItemDefinition = ItemDefinition> = Document<RawApiTypes.Item<BlockItemDefinition>, RawApiTypes.Item<InlineBlockItemDefinition>>;
|
|
71
73
|
/**
|
|
72
74
|
* =============================================================================
|
|
73
75
|
* MAIN APPLICATION TYPES
|
|
@@ -78,23 +80,26 @@ export type DocumentWithNestedBlocks = Document<RawApiTypes.Item>;
|
|
|
78
80
|
* Can be null (empty field) or a document with blocks as string IDs
|
|
79
81
|
*/
|
|
80
82
|
export type StructuredTextFieldValue = Document | null;
|
|
81
|
-
export type StructuredTextFieldValueAsRequest = DocumentAsRequest | null;
|
|
82
|
-
export type StructuredTextFieldValueWithNestedBlocks = DocumentWithNestedBlocks | null;
|
|
83
|
+
export type StructuredTextFieldValueAsRequest<BlockItemDefinition extends ItemDefinition = ItemDefinition, InlineBlockItemDefinition extends ItemDefinition = ItemDefinition> = DocumentAsRequest<BlockItemDefinition, InlineBlockItemDefinition> | null;
|
|
84
|
+
export type StructuredTextFieldValueWithNestedBlocks<BlockItemDefinition extends ItemDefinition = ItemDefinition, InlineBlockItemDefinition extends ItemDefinition = ItemDefinition> = DocumentWithNestedBlocks<BlockItemDefinition, InlineBlockItemDefinition> | null;
|
|
83
85
|
/**
|
|
84
86
|
* Type guard for basic structured text field values (blocks as string IDs only).
|
|
85
87
|
* Checks for the expected structure and ensures all block/inlineBlock nodes have string IDs.
|
|
86
88
|
*/
|
|
87
89
|
export declare function isStructuredTextFieldValue(value: unknown): value is StructuredTextFieldValue;
|
|
90
|
+
export declare function isLocalizedStructuredTextFieldValue(value: unknown): value is LocalizedFieldValue<StructuredTextFieldValue>;
|
|
88
91
|
/**
|
|
89
92
|
* Type guard for structured text field values in API request format.
|
|
90
93
|
* Allows blocks as string IDs, full objects with IDs, or objects without IDs.
|
|
91
94
|
*/
|
|
92
|
-
export declare function isStructuredTextFieldValueAsRequest(value: unknown): value is StructuredTextFieldValueAsRequest
|
|
95
|
+
export declare function isStructuredTextFieldValueAsRequest<BlockItemDefinition extends ItemDefinition = ItemDefinition, InlineBlockItemDefinition extends ItemDefinition = ItemDefinition>(value: unknown): value is StructuredTextFieldValueAsRequest<BlockItemDefinition, InlineBlockItemDefinition>;
|
|
96
|
+
export declare function isLocalizedStructuredTextFieldValueAsRequest<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<StructuredTextFieldValueAsRequest<D>>;
|
|
93
97
|
/**
|
|
94
98
|
* Type guard for structured text field values with nested blocks (?nested=true format).
|
|
95
99
|
* Ensures all block/inlineBlock nodes have full RawApiTypes.Item objects.
|
|
96
100
|
*/
|
|
97
|
-
export declare function isStructuredTextFieldValueWithNestedBlocks(value: unknown): value is StructuredTextFieldValueWithNestedBlocks
|
|
101
|
+
export declare function isStructuredTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is StructuredTextFieldValueWithNestedBlocks<D>;
|
|
102
|
+
export declare function isLocalizedStructuredTextFieldValueWithNestedBlocks<D extends ItemDefinition = ItemDefinition>(value: unknown): value is LocalizedFieldValue<StructuredTextFieldValueWithNestedBlocks<D>>;
|
|
98
103
|
export type StructuredTextFieldValidators = {
|
|
99
104
|
/** Only accept references to block records of the specified block models */
|
|
100
105
|
structured_text_blocks: StructuredTextBlocksValidator;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LocalizedFieldValue } from '../utilities/fieldValue';
|
|
1
2
|
import type { MarkdownEditorConfiguration } from './appearance/markdown';
|
|
2
3
|
import type { TextareaEditorConfiguration } from './appearance/textarea';
|
|
3
4
|
import type { WysiwygEditorConfiguration } from './appearance/wysiwyg';
|
|
@@ -7,6 +8,7 @@ import type { RequiredValidator } from './validators/required';
|
|
|
7
8
|
import type { SanitizationValidator } from './validators/sanitization';
|
|
8
9
|
export type TextFieldValue = string | null;
|
|
9
10
|
export declare function isTextFieldValue(value: unknown): value is TextFieldValue;
|
|
11
|
+
export declare function isLocalizedTextFieldValue(value: unknown): value is LocalizedFieldValue<TextFieldValue>;
|
|
10
12
|
export type TextFieldValidators = {
|
|
11
13
|
/** Value must be specified or it won't be valid */
|
|
12
14
|
required?: RequiredValidator;
|