@datocms/cma-client 5.1.1 → 5.1.2
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/rich_text.js +4 -4
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +19 -17
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +9 -21
- package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
- package/dist/cjs/generated/{SchemaTypes.js → ApiTypes.js} +1 -1
- package/dist/cjs/generated/ApiTypes.js.map +1 -0
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/generated/{SimpleSchemaTypes.js → RawApiTypes.js} +1 -1
- package/dist/cjs/generated/RawApiTypes.js.map +1 -0
- package/dist/cjs/generated/resources/AccessToken.js.map +1 -1
- package/dist/cjs/generated/resources/AuditLogEvent.js.map +1 -1
- package/dist/cjs/generated/resources/BuildEvent.js.map +1 -1
- package/dist/cjs/generated/resources/BuildTrigger.js.map +1 -1
- package/dist/cjs/generated/resources/EditingSession.js.map +1 -1
- package/dist/cjs/generated/resources/EmojiSuggestions.js.map +1 -1
- package/dist/cjs/generated/resources/Environment.js.map +1 -1
- package/dist/cjs/generated/resources/Field.js.map +1 -1
- package/dist/cjs/generated/resources/Fieldset.js.map +1 -1
- package/dist/cjs/generated/resources/Item.js.map +1 -1
- package/dist/cjs/generated/resources/ItemType.js.map +1 -1
- package/dist/cjs/generated/resources/ItemTypeFilter.js.map +1 -1
- package/dist/cjs/generated/resources/ItemVersion.js.map +1 -1
- package/dist/cjs/generated/resources/JobResult.js.map +1 -1
- package/dist/cjs/generated/resources/MaintenanceMode.js.map +1 -1
- package/dist/cjs/generated/resources/MenuItem.js.map +1 -1
- package/dist/cjs/generated/resources/Plugin.js.map +1 -1
- package/dist/cjs/generated/resources/PublicInfo.js.map +1 -1
- package/dist/cjs/generated/resources/Role.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/cjs/generated/resources/SchemaMenuItem.js.map +1 -1
- package/dist/cjs/generated/resources/SearchResult.js.map +1 -1
- package/dist/cjs/generated/resources/Session.js.map +1 -1
- package/dist/cjs/generated/resources/Site.js.map +1 -1
- package/dist/cjs/generated/resources/SiteInvitation.js.map +1 -1
- package/dist/cjs/generated/resources/SsoGroup.js.map +1 -1
- package/dist/cjs/generated/resources/SsoSettings.js.map +1 -1
- package/dist/cjs/generated/resources/SsoUser.js.map +1 -1
- package/dist/cjs/generated/resources/SubscriptionLimit.js.map +1 -1
- package/dist/cjs/generated/resources/Upload.js.map +1 -1
- package/dist/cjs/generated/resources/UploadCollection.js.map +1 -1
- package/dist/cjs/generated/resources/UploadFilter.js.map +1 -1
- package/dist/cjs/generated/resources/UploadRequest.js.map +1 -1
- package/dist/cjs/generated/resources/UploadSmartTag.js.map +1 -1
- package/dist/cjs/generated/resources/UploadTag.js.map +1 -1
- package/dist/cjs/generated/resources/UploadTrack.js.map +1 -1
- package/dist/cjs/generated/resources/UsageCounter.js.map +1 -1
- package/dist/cjs/generated/resources/User.js.map +1 -1
- package/dist/cjs/generated/resources/Webhook.js.map +1 -1
- package/dist/cjs/generated/resources/WebhookCall.js.map +1 -1
- package/dist/cjs/generated/resources/WhiteLabelSettings.js.map +1 -1
- package/dist/cjs/generated/resources/Workflow.js.map +1 -1
- package/dist/cjs/index.js +2 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/resources/Role.js.map +1 -1
- package/dist/cjs/utilities/blocks.js +7 -7
- package/dist/cjs/utilities/blocks.js.map +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/cjs/utilities/{fieldValueLocalization.js → fieldValue.js} +52 -52
- package/dist/cjs/utilities/fieldValue.js.map +1 -0
- package/dist/cjs/utilities/fieldsContainingReferences.js.map +1 -1
- package/dist/cjs/utilities/recursiveBlocks.js +18 -19
- package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
- package/dist/cjs/utilities/schemaRepository.js.map +1 -1
- package/dist/esm/fieldTypes/rich_text.d.ts +6 -6
- package/dist/esm/fieldTypes/rich_text.js +5 -5
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/single_block.d.ts +29 -23
- package/dist/esm/fieldTypes/single_block.js +15 -13
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +18 -83
- package/dist/esm/fieldTypes/structured_text.js +10 -22
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +2 -2
- package/dist/esm/generated/ApiTypes.js +2 -0
- package/dist/esm/generated/ApiTypes.js.map +1 -0
- package/dist/esm/generated/Client.d.ts +1 -1
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/generated/{SchemaTypes.d.ts → RawApiTypes.d.ts} +2 -2
- package/dist/esm/generated/RawApiTypes.js +2 -0
- package/dist/esm/generated/RawApiTypes.js.map +1 -0
- package/dist/esm/generated/resources/AccessToken.d.ts +14 -14
- package/dist/esm/generated/resources/AccessToken.js.map +1 -1
- package/dist/esm/generated/resources/AuditLogEvent.d.ts +4 -4
- package/dist/esm/generated/resources/AuditLogEvent.js.map +1 -1
- package/dist/esm/generated/resources/BuildEvent.d.ts +8 -8
- package/dist/esm/generated/resources/BuildEvent.js.map +1 -1
- package/dist/esm/generated/resources/BuildTrigger.d.ts +16 -16
- package/dist/esm/generated/resources/BuildTrigger.js.map +1 -1
- package/dist/esm/generated/resources/DailyUsage.d.ts +4 -4
- package/dist/esm/generated/resources/EditingSession.d.ts +7 -7
- package/dist/esm/generated/resources/EditingSession.js.map +1 -1
- package/dist/esm/generated/resources/EmojiSuggestions.d.ts +4 -4
- package/dist/esm/generated/resources/EmojiSuggestions.js.map +1 -1
- package/dist/esm/generated/resources/Environment.d.ts +14 -14
- package/dist/esm/generated/resources/Environment.js.map +1 -1
- package/dist/esm/generated/resources/Field.d.ts +213 -213
- package/dist/esm/generated/resources/Field.js.map +1 -1
- package/dist/esm/generated/resources/Fieldset.d.ts +12 -12
- package/dist/esm/generated/resources/Fieldset.js.map +1 -1
- package/dist/esm/generated/resources/Item.d.ts +36 -36
- package/dist/esm/generated/resources/Item.js.map +1 -1
- package/dist/esm/generated/resources/ItemType.d.ts +15 -15
- package/dist/esm/generated/resources/ItemType.js.map +1 -1
- package/dist/esm/generated/resources/ItemTypeFilter.d.ts +12 -12
- package/dist/esm/generated/resources/ItemTypeFilter.js.map +1 -1
- package/dist/esm/generated/resources/ItemVersion.d.ts +10 -10
- package/dist/esm/generated/resources/ItemVersion.js.map +1 -1
- package/dist/esm/generated/resources/JobResult.d.ts +4 -4
- package/dist/esm/generated/resources/JobResult.js.map +1 -1
- package/dist/esm/generated/resources/MaintenanceMode.d.ts +8 -8
- package/dist/esm/generated/resources/MaintenanceMode.js.map +1 -1
- package/dist/esm/generated/resources/MenuItem.d.ts +14 -14
- package/dist/esm/generated/resources/MenuItem.js.map +1 -1
- package/dist/esm/generated/resources/Plugin.d.ts +14 -14
- package/dist/esm/generated/resources/Plugin.js.map +1 -1
- package/dist/esm/generated/resources/PublicInfo.d.ts +4 -4
- package/dist/esm/generated/resources/PublicInfo.js.map +1 -1
- package/dist/esm/generated/resources/Role.d.ts +14 -14
- package/dist/esm/generated/resources/Role.js.map +1 -1
- package/dist/esm/generated/resources/ScheduledPublication.d.ts +6 -6
- package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +6 -6
- package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/esm/generated/resources/SchemaMenuItem.d.ts +14 -14
- package/dist/esm/generated/resources/SchemaMenuItem.js.map +1 -1
- package/dist/esm/generated/resources/SearchResult.d.ts +6 -6
- package/dist/esm/generated/resources/SearchResult.js.map +1 -1
- package/dist/esm/generated/resources/Session.d.ts +4 -4
- package/dist/esm/generated/resources/Session.js.map +1 -1
- package/dist/esm/generated/resources/Site.d.ts +24 -24
- package/dist/esm/generated/resources/Site.js.map +1 -1
- package/dist/esm/generated/resources/SiteInvitation.d.ts +14 -14
- package/dist/esm/generated/resources/SiteInvitation.js.map +1 -1
- package/dist/esm/generated/resources/SsoGroup.d.ts +10 -10
- package/dist/esm/generated/resources/SsoGroup.js.map +1 -1
- package/dist/esm/generated/resources/SsoSettings.d.ts +8 -8
- package/dist/esm/generated/resources/SsoSettings.js.map +1 -1
- package/dist/esm/generated/resources/SsoUser.d.ts +10 -10
- package/dist/esm/generated/resources/SsoUser.js.map +1 -1
- package/dist/esm/generated/resources/SubscriptionFeature.d.ts +4 -4
- package/dist/esm/generated/resources/SubscriptionLimit.d.ts +6 -6
- package/dist/esm/generated/resources/SubscriptionLimit.js.map +1 -1
- package/dist/esm/generated/resources/Upload.d.ts +22 -22
- package/dist/esm/generated/resources/Upload.js.map +1 -1
- package/dist/esm/generated/resources/UploadCollection.d.ts +14 -14
- package/dist/esm/generated/resources/UploadCollection.js.map +1 -1
- package/dist/esm/generated/resources/UploadFilter.d.ts +12 -12
- package/dist/esm/generated/resources/UploadFilter.js.map +1 -1
- package/dist/esm/generated/resources/UploadRequest.d.ts +4 -4
- package/dist/esm/generated/resources/UploadRequest.js.map +1 -1
- package/dist/esm/generated/resources/UploadSmartTag.d.ts +6 -6
- package/dist/esm/generated/resources/UploadSmartTag.js.map +1 -1
- package/dist/esm/generated/resources/UploadTag.d.ts +8 -8
- package/dist/esm/generated/resources/UploadTag.js.map +1 -1
- package/dist/esm/generated/resources/UploadTrack.d.ts +10 -10
- package/dist/esm/generated/resources/UploadTrack.js.map +1 -1
- package/dist/esm/generated/resources/UsageCounter.d.ts +4 -4
- package/dist/esm/generated/resources/UsageCounter.js.map +1 -1
- package/dist/esm/generated/resources/User.d.ts +12 -12
- package/dist/esm/generated/resources/User.js.map +1 -1
- package/dist/esm/generated/resources/Webhook.d.ts +12 -12
- package/dist/esm/generated/resources/Webhook.js.map +1 -1
- package/dist/esm/generated/resources/WebhookCall.d.ts +9 -9
- package/dist/esm/generated/resources/WebhookCall.js.map +1 -1
- package/dist/esm/generated/resources/WhiteLabelSettings.d.ts +6 -6
- package/dist/esm/generated/resources/WhiteLabelSettings.js.map +1 -1
- package/dist/esm/generated/resources/Workflow.d.ts +11 -11
- package/dist/esm/generated/resources/Workflow.js.map +1 -1
- package/dist/esm/index.d.ts +5 -4
- package/dist/esm/index.js +1 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/resources/Role.d.ts +4 -4
- package/dist/esm/resources/Role.js.map +1 -1
- package/dist/esm/utilities/blocks.d.ts +17 -17
- package/dist/esm/utilities/blocks.js +3 -3
- package/dist/esm/utilities/blocks.js.map +1 -1
- package/dist/esm/utilities/buildBlockRecord.d.ts +5 -5
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/dist/{types/utilities/fieldValueLocalization.d.ts → esm/utilities/fieldValue.d.ts} +29 -28
- package/dist/esm/utilities/{fieldValueLocalization.js → fieldValue.js} +39 -39
- package/dist/esm/utilities/fieldValue.js.map +1 -0
- package/dist/esm/utilities/fieldsContainingReferences.d.ts +4 -4
- package/dist/esm/utilities/fieldsContainingReferences.js.map +1 -1
- package/dist/esm/utilities/recursiveBlocks.d.ts +13 -10
- package/dist/esm/utilities/recursiveBlocks.js +19 -20
- package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
- package/dist/esm/utilities/schemaRepository.d.ts +29 -26
- package/dist/esm/utilities/schemaRepository.js.map +1 -1
- package/dist/types/fieldTypes/rich_text.d.ts +6 -6
- package/dist/types/fieldTypes/single_block.d.ts +29 -23
- package/dist/types/fieldTypes/structured_text.d.ts +18 -83
- package/dist/types/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +2 -2
- package/dist/types/generated/Client.d.ts +1 -1
- package/dist/types/generated/{SchemaTypes.d.ts → RawApiTypes.d.ts} +2 -2
- package/dist/types/generated/resources/AccessToken.d.ts +14 -14
- package/dist/types/generated/resources/AuditLogEvent.d.ts +4 -4
- package/dist/types/generated/resources/BuildEvent.d.ts +8 -8
- package/dist/types/generated/resources/BuildTrigger.d.ts +16 -16
- package/dist/types/generated/resources/DailyUsage.d.ts +4 -4
- package/dist/types/generated/resources/EditingSession.d.ts +7 -7
- package/dist/types/generated/resources/EmojiSuggestions.d.ts +4 -4
- package/dist/types/generated/resources/Environment.d.ts +14 -14
- package/dist/types/generated/resources/Field.d.ts +213 -213
- package/dist/types/generated/resources/Fieldset.d.ts +12 -12
- package/dist/types/generated/resources/Item.d.ts +36 -36
- package/dist/types/generated/resources/ItemType.d.ts +15 -15
- package/dist/types/generated/resources/ItemTypeFilter.d.ts +12 -12
- package/dist/types/generated/resources/ItemVersion.d.ts +10 -10
- package/dist/types/generated/resources/JobResult.d.ts +4 -4
- package/dist/types/generated/resources/MaintenanceMode.d.ts +8 -8
- package/dist/types/generated/resources/MenuItem.d.ts +14 -14
- package/dist/types/generated/resources/Plugin.d.ts +14 -14
- package/dist/types/generated/resources/PublicInfo.d.ts +4 -4
- package/dist/types/generated/resources/Role.d.ts +14 -14
- package/dist/types/generated/resources/ScheduledPublication.d.ts +6 -6
- package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +6 -6
- package/dist/types/generated/resources/SchemaMenuItem.d.ts +14 -14
- package/dist/types/generated/resources/SearchResult.d.ts +6 -6
- package/dist/types/generated/resources/Session.d.ts +4 -4
- package/dist/types/generated/resources/Site.d.ts +24 -24
- package/dist/types/generated/resources/SiteInvitation.d.ts +14 -14
- package/dist/types/generated/resources/SsoGroup.d.ts +10 -10
- package/dist/types/generated/resources/SsoSettings.d.ts +8 -8
- package/dist/types/generated/resources/SsoUser.d.ts +10 -10
- package/dist/types/generated/resources/SubscriptionFeature.d.ts +4 -4
- package/dist/types/generated/resources/SubscriptionLimit.d.ts +6 -6
- package/dist/types/generated/resources/Upload.d.ts +22 -22
- package/dist/types/generated/resources/UploadCollection.d.ts +14 -14
- package/dist/types/generated/resources/UploadFilter.d.ts +12 -12
- package/dist/types/generated/resources/UploadRequest.d.ts +4 -4
- package/dist/types/generated/resources/UploadSmartTag.d.ts +6 -6
- package/dist/types/generated/resources/UploadTag.d.ts +8 -8
- package/dist/types/generated/resources/UploadTrack.d.ts +10 -10
- package/dist/types/generated/resources/UsageCounter.d.ts +4 -4
- package/dist/types/generated/resources/User.d.ts +12 -12
- package/dist/types/generated/resources/Webhook.d.ts +12 -12
- package/dist/types/generated/resources/WebhookCall.d.ts +9 -9
- package/dist/types/generated/resources/WhiteLabelSettings.d.ts +6 -6
- package/dist/types/generated/resources/Workflow.d.ts +11 -11
- package/dist/types/index.d.ts +5 -4
- package/dist/types/resources/Role.d.ts +4 -4
- package/dist/types/utilities/blocks.d.ts +17 -17
- package/dist/types/utilities/buildBlockRecord.d.ts +5 -5
- package/dist/{esm/utilities/fieldValueLocalization.d.ts → types/utilities/fieldValue.d.ts} +29 -28
- package/dist/types/utilities/fieldsContainingReferences.d.ts +4 -4
- package/dist/types/utilities/recursiveBlocks.d.ts +13 -10
- package/dist/types/utilities/schemaRepository.d.ts +29 -26
- package/package.json +5 -5
- package/src/fieldTypes/rich_text.ts +12 -12
- package/src/fieldTypes/single_block.ts +46 -31
- package/src/fieldTypes/structured_text.ts +33 -149
- package/src/generated/{SimpleSchemaTypes.ts → ApiTypes.ts} +2 -2
- package/src/generated/Client.ts +2 -2
- package/src/generated/{SchemaTypes.ts → RawApiTypes.ts} +2 -2
- package/src/generated/resources/AccessToken.ts +32 -34
- package/src/generated/resources/AuditLogEvent.ts +8 -8
- package/src/generated/resources/BuildEvent.ts +16 -18
- package/src/generated/resources/BuildTrigger.ts +30 -30
- package/src/generated/resources/DailyUsage.ts +5 -5
- package/src/generated/resources/EditingSession.ts +12 -12
- package/src/generated/resources/EmojiSuggestions.ts +7 -7
- package/src/generated/resources/Environment.ts +33 -39
- package/src/generated/resources/Field.ts +40 -54
- package/src/generated/resources/Fieldset.ts +28 -36
- package/src/generated/resources/Item.ts +99 -126
- package/src/generated/resources/ItemType.ts +37 -45
- package/src/generated/resources/ItemTypeFilter.ts +26 -26
- package/src/generated/resources/ItemVersion.ts +22 -26
- package/src/generated/resources/JobResult.ts +6 -8
- package/src/generated/resources/MaintenanceMode.ts +13 -13
- package/src/generated/resources/MenuItem.ts +34 -44
- package/src/generated/resources/Plugin.ts +30 -42
- package/src/generated/resources/PublicInfo.ts +5 -7
- package/src/generated/resources/Role.ts +29 -44
- package/src/generated/resources/ScheduledPublication.ts +13 -13
- package/src/generated/resources/ScheduledUnpublishing.ts +13 -13
- package/src/generated/resources/SchemaMenuItem.ts +34 -34
- package/src/generated/resources/SearchResult.ts +12 -12
- package/src/generated/resources/Session.ts +8 -10
- package/src/generated/resources/Site.ts +43 -47
- package/src/generated/resources/SiteInvitation.ts +30 -30
- package/src/generated/resources/SsoGroup.ts +20 -24
- package/src/generated/resources/SsoSettings.ts +14 -16
- package/src/generated/resources/SsoUser.ts +18 -22
- package/src/generated/resources/SubscriptionFeature.ts +5 -5
- package/src/generated/resources/SubscriptionLimit.ts +9 -9
- package/src/generated/resources/Upload.ts +57 -73
- package/src/generated/resources/UploadCollection.ts +34 -34
- package/src/generated/resources/UploadFilter.ts +26 -26
- package/src/generated/resources/UploadRequest.ts +8 -8
- package/src/generated/resources/UploadSmartTag.ts +12 -12
- package/src/generated/resources/UploadTag.ts +18 -20
- package/src/generated/resources/UploadTrack.ts +25 -29
- package/src/generated/resources/UsageCounter.ts +8 -8
- package/src/generated/resources/User.ts +28 -39
- package/src/generated/resources/Webhook.ts +26 -34
- package/src/generated/resources/WebhookCall.ts +17 -19
- package/src/generated/resources/WhiteLabelSettings.ts +11 -11
- package/src/generated/resources/Workflow.ts +23 -29
- package/src/index.ts +7 -4
- package/src/resources/Role.ts +6 -6
- package/src/utilities/blocks.ts +30 -30
- package/src/utilities/buildBlockRecord.ts +4 -4
- package/src/utilities/{fieldValueLocalization.ts → fieldValue.ts} +58 -73
- package/src/utilities/fieldsContainingReferences.ts +4 -4
- package/src/utilities/recursiveBlocks.ts +47 -44
- package/src/utilities/schemaRepository.ts +53 -56
- package/dist/cjs/generated/SchemaTypes.js.map +0 -1
- package/dist/cjs/generated/SimpleSchemaTypes.js.map +0 -1
- package/dist/cjs/utilities/fieldValueLocalization.js.map +0 -1
- package/dist/cjs/utilities/structuredText.js +0 -371
- package/dist/cjs/utilities/structuredText.js.map +0 -1
- package/dist/esm/generated/SchemaTypes.js +0 -2
- package/dist/esm/generated/SchemaTypes.js.map +0 -1
- package/dist/esm/generated/SimpleSchemaTypes.js +0 -2
- package/dist/esm/generated/SimpleSchemaTypes.js.map +0 -1
- package/dist/esm/utilities/fieldValueLocalization.js.map +0 -1
- package/dist/esm/utilities/structuredText.d.ts +0 -177
- package/dist/esm/utilities/structuredText.js +0 -354
- package/dist/esm/utilities/structuredText.js.map +0 -1
- package/dist/types/utilities/structuredText.d.ts +0 -177
- package/src/utilities/structuredText.ts +0 -590
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
2
2
|
import {
|
|
3
3
|
type BlockItemInARequest,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
isItemId,
|
|
5
|
+
isItemWithOptionalIdAndMeta,
|
|
6
|
+
isItemWithOptionalMeta,
|
|
7
7
|
} from './single_block';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -53,8 +53,8 @@ export type RichTextFieldValue = string[] | null;
|
|
|
53
53
|
/**
|
|
54
54
|
* Modular Content field value for API requests - allows flexible block representations:
|
|
55
55
|
* - string: Just the block ID (most common case)
|
|
56
|
-
* -
|
|
57
|
-
* - Omit<
|
|
56
|
+
* - RawApiTypes.Item: Full block object with ID (for updates)
|
|
57
|
+
* - Omit<RawApiTypes.Item, 'id'>: Block object without ID (for creation)
|
|
58
58
|
*/
|
|
59
59
|
export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
|
|
60
60
|
|
|
@@ -64,14 +64,14 @@ export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
|
|
|
64
64
|
* =============================================================================
|
|
65
65
|
*
|
|
66
66
|
* When using the ?nested=true query parameter, the API returns Modular Content data
|
|
67
|
-
* with embedded blocks fully populated as complete
|
|
67
|
+
* with embedded blocks fully populated as complete RawApiTypes.Item objects instead
|
|
68
68
|
* of just string IDs. This provides type safety for working with fully resolved data.
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
72
|
* Modular Content field value with nested blocks - array of fully populated block objects
|
|
73
73
|
*/
|
|
74
|
-
export type RichTextFieldValueWithNestedBlocks =
|
|
74
|
+
export type RichTextFieldValueWithNestedBlocks = RawApiTypes.Item[] | null;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* =============================================================================
|
|
@@ -106,16 +106,16 @@ export function isRichTextFieldValueAsRequest(
|
|
|
106
106
|
|
|
107
107
|
return value.every((block) => {
|
|
108
108
|
// String ID - referencing existing block
|
|
109
|
-
if (
|
|
109
|
+
if (isItemId(block)) return true;
|
|
110
110
|
|
|
111
111
|
// Object (either with or without ID for updates/creation)
|
|
112
|
-
return
|
|
112
|
+
return isItemWithOptionalIdAndMeta(block);
|
|
113
113
|
});
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
117
|
* Type guard for Modular Content field values with nested blocks (?nested=true format).
|
|
118
|
-
* Ensures all blocks are full
|
|
118
|
+
* Ensures all blocks are full RawApiTypes.Item objects with complete data.
|
|
119
119
|
*/
|
|
120
120
|
export function isRichTextFieldValueWithNestedBlocks(
|
|
121
121
|
value: unknown,
|
|
@@ -126,7 +126,7 @@ export function isRichTextFieldValueWithNestedBlocks(
|
|
|
126
126
|
|
|
127
127
|
return value.every((block) => {
|
|
128
128
|
// Must be a full object with ID (nested format always includes complete block objects)
|
|
129
|
-
return
|
|
129
|
+
return isItemWithOptionalMeta(block);
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
2
|
+
|
|
3
|
+
import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
|
|
4
|
+
import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
|
|
5
|
+
import type { RequiredValidator } from './validators/required';
|
|
6
|
+
import type { SingleBlockBlocksValidator } from './validators/single_block_blocks';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* SINGLE BLOCK FIELD TYPE SYSTEM FOR DATOCMS
|
|
@@ -44,23 +49,34 @@ export type SingleBlockFieldValue = string | null;
|
|
|
44
49
|
* - Omit ID for new blocks being created
|
|
45
50
|
*/
|
|
46
51
|
|
|
52
|
+
/** Represents an existing block in a CMA request */
|
|
53
|
+
export type UnchangedBlockInARequest = string;
|
|
54
|
+
/** Represents a block we want to update in a CMA request */
|
|
55
|
+
export type UpdatedBlockInARequest = OptionalFields<RawApiTypes.Item, 'meta'>;
|
|
56
|
+
/** Represents a new block to create in a CMA request */
|
|
57
|
+
export type NewBlockInARequest = OptionalFields<
|
|
58
|
+
RawApiTypes.Item,
|
|
59
|
+
'id' | 'meta'
|
|
60
|
+
>;
|
|
61
|
+
|
|
47
62
|
/**
|
|
48
63
|
* Union type representing the different ways a block can be specified in API requests:
|
|
49
|
-
* - string: Just the block ID (
|
|
50
|
-
* - Full block object with ID (
|
|
51
|
-
* - Block object without ID (
|
|
64
|
+
* - string: Just the block ID (to keep existing blocks unchanged)
|
|
65
|
+
* - Full block object with ID (to update an existing block)
|
|
66
|
+
* - Block object without ID (to create a new block)
|
|
52
67
|
*
|
|
53
68
|
* Also, 'meta' can always be omitted
|
|
54
69
|
*/
|
|
55
70
|
export type BlockItemInARequest =
|
|
56
|
-
|
|
|
57
|
-
|
|
|
71
|
+
| UnchangedBlockInARequest
|
|
72
|
+
| UpdatedBlockInARequest
|
|
73
|
+
| NewBlockInARequest;
|
|
58
74
|
|
|
59
75
|
/**
|
|
60
76
|
* Single Block field value for API requests - allows flexible block representations:
|
|
61
|
-
* - string: Just the block ID (
|
|
62
|
-
* -
|
|
63
|
-
* -
|
|
77
|
+
* - string: Just the block ID (to keep existing blocks unchanged)
|
|
78
|
+
* - Full block object with ID (to update an existing block)
|
|
79
|
+
* - Block object without ID (to create a new block)
|
|
64
80
|
*/
|
|
65
81
|
export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
|
|
66
82
|
|
|
@@ -70,14 +86,14 @@ export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
|
|
|
70
86
|
* =============================================================================
|
|
71
87
|
*
|
|
72
88
|
* When using the ?nested=true query parameter, the API returns Single Block data
|
|
73
|
-
* with embedded block fully populated as complete
|
|
89
|
+
* with embedded block fully populated as complete RawApiTypes.Item object instead
|
|
74
90
|
* of just string ID. This provides type safety for working with fully resolved data.
|
|
75
91
|
*/
|
|
76
92
|
|
|
77
93
|
/**
|
|
78
94
|
* Single Block field value with nested block - fully populated block object
|
|
79
95
|
*/
|
|
80
|
-
export type SingleBlockFieldValueWithNestedBlocks =
|
|
96
|
+
export type SingleBlockFieldValueWithNestedBlocks = RawApiTypes.Item | null;
|
|
81
97
|
|
|
82
98
|
/**
|
|
83
99
|
* =============================================================================
|
|
@@ -87,21 +103,21 @@ export type SingleBlockFieldValueWithNestedBlocks = SchemaTypes.Item | null;
|
|
|
87
103
|
*/
|
|
88
104
|
|
|
89
105
|
/**
|
|
90
|
-
* Validates if a
|
|
106
|
+
* Validates if the input is a valid item (either block or record) ID
|
|
91
107
|
*/
|
|
92
|
-
export function
|
|
93
|
-
return typeof
|
|
108
|
+
export function isItemId(input: unknown): input is string {
|
|
109
|
+
return typeof input === 'string';
|
|
94
110
|
}
|
|
95
111
|
|
|
96
112
|
export type ItemWithOptionalIdAndMeta = OptionalFields<
|
|
97
|
-
|
|
113
|
+
RawApiTypes.Item,
|
|
98
114
|
'id' | 'meta'
|
|
99
115
|
>;
|
|
100
116
|
|
|
101
117
|
/**
|
|
102
|
-
* Validates if
|
|
118
|
+
* Validates if the input is a RawApiTypes.Item object (with optional `id` and `meta`)
|
|
103
119
|
*/
|
|
104
|
-
export function
|
|
120
|
+
export function isItemWithOptionalIdAndMeta(
|
|
105
121
|
block: unknown,
|
|
106
122
|
): block is ItemWithOptionalIdAndMeta {
|
|
107
123
|
return (
|
|
@@ -112,15 +128,19 @@ export function isBlockObject(
|
|
|
112
128
|
);
|
|
113
129
|
}
|
|
114
130
|
|
|
115
|
-
export type ItemWithOptionalMeta = OptionalFields<
|
|
131
|
+
export type ItemWithOptionalMeta = OptionalFields<RawApiTypes.Item, 'meta'>;
|
|
116
132
|
|
|
117
133
|
/**
|
|
118
|
-
* Validates if
|
|
134
|
+
* Validates if the input is a a complete RawApiTypes.Item object with optional `meta`
|
|
119
135
|
*/
|
|
120
|
-
export function
|
|
136
|
+
export function isItemWithOptionalMeta(
|
|
121
137
|
block: unknown,
|
|
122
138
|
): block is ItemWithOptionalMeta {
|
|
123
|
-
return
|
|
139
|
+
return (
|
|
140
|
+
isItemWithOptionalIdAndMeta(block) &&
|
|
141
|
+
'id' in block &&
|
|
142
|
+
typeof block.id === 'string'
|
|
143
|
+
);
|
|
124
144
|
}
|
|
125
145
|
|
|
126
146
|
/**
|
|
@@ -148,16 +168,16 @@ export function isSingleBlockFieldValueAsRequest(
|
|
|
148
168
|
): value is SingleBlockFieldValueAsRequest {
|
|
149
169
|
if (value === null) return true;
|
|
150
170
|
|
|
151
|
-
// String ID
|
|
152
|
-
if (
|
|
171
|
+
// String ID - referencing existing block
|
|
172
|
+
if (isItemId(value)) return true;
|
|
153
173
|
|
|
154
174
|
// Object (either with or without ID for updates/creation)
|
|
155
|
-
return
|
|
175
|
+
return isItemWithOptionalIdAndMeta(value);
|
|
156
176
|
}
|
|
157
177
|
|
|
158
178
|
/**
|
|
159
179
|
* Type guard for Single Block field values with nested blocks (?nested=true format).
|
|
160
|
-
* Ensures block is a full
|
|
180
|
+
* Ensures block is a full RawApiTypes.Item object with complete data.
|
|
161
181
|
*/
|
|
162
182
|
export function isSingleBlockFieldValueWithNestedBlocks(
|
|
163
183
|
value: unknown,
|
|
@@ -165,14 +185,9 @@ export function isSingleBlockFieldValueWithNestedBlocks(
|
|
|
165
185
|
if (value === null) return true;
|
|
166
186
|
|
|
167
187
|
// Must be a full object with ID (nested format always includes complete block objects)
|
|
168
|
-
return
|
|
188
|
+
return isItemWithOptionalMeta(value);
|
|
169
189
|
}
|
|
170
190
|
|
|
171
|
-
import type { FramedSingleBlockEditorConfiguration } from './appearance/framed_single_block';
|
|
172
|
-
import type { FramelessSingleBlockEditorConfiguration } from './appearance/frameless_single_block';
|
|
173
|
-
import type { RequiredValidator } from './validators/required';
|
|
174
|
-
import type { SingleBlockBlocksValidator } from './validators/single_block_blocks';
|
|
175
|
-
|
|
176
191
|
export type SingleBlockFieldValidators = {
|
|
177
192
|
/** Only accept references to block records of the specified block models */
|
|
178
193
|
single_block_blocks: SingleBlockBlocksValidator;
|
|
@@ -2,19 +2,24 @@ import {
|
|
|
2
2
|
type Block,
|
|
3
3
|
type Document,
|
|
4
4
|
type InlineBlock,
|
|
5
|
-
type
|
|
5
|
+
type Node,
|
|
6
|
+
everyNode,
|
|
6
7
|
isBlock,
|
|
8
|
+
isDocument,
|
|
7
9
|
isInlineBlock,
|
|
8
|
-
isNode,
|
|
9
10
|
} from 'datocms-structured-text-utils';
|
|
10
|
-
import type * as
|
|
11
|
-
import {
|
|
11
|
+
import type * as RawApiTypes from '../generated/RawApiTypes';
|
|
12
|
+
import type { StructuredTextEditorConfiguration } from './appearance/structured_text';
|
|
12
13
|
import {
|
|
13
14
|
type BlockItemInARequest,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
isItemId,
|
|
16
|
+
isItemWithOptionalIdAndMeta,
|
|
17
|
+
isItemWithOptionalMeta,
|
|
17
18
|
} from './single_block';
|
|
19
|
+
import type { LengthValidator } from './validators/length';
|
|
20
|
+
import type { StructuredTextBlocksValidator } from './validators/structured_text_blocks';
|
|
21
|
+
import type { StructuredTextInlineBlocksValidator } from './validators/structured_text_inline_blocks';
|
|
22
|
+
import type { StructuredTextLinksValidator } from './validators/structured_text_links';
|
|
18
23
|
|
|
19
24
|
/**
|
|
20
25
|
* STRUCTURED TEXT TYPE SYSTEM FOR DATOCMS
|
|
@@ -25,10 +30,10 @@ import {
|
|
|
25
30
|
* The challenge we're solving:
|
|
26
31
|
* - DatoCMS structured text can contain "blocks" (embedded content items) in bloth 'block'
|
|
27
32
|
* and 'inlineBlock' nodes
|
|
28
|
-
* - By default,
|
|
33
|
+
* - By default, CMA responses contain blocks as string IDs (lightweight references)
|
|
29
34
|
* - With ?nested=true parameter though, API responses contain blocks as full item objects
|
|
30
35
|
* (which in turn can contain other blocks)
|
|
31
|
-
* - For
|
|
36
|
+
* - For CMA requests, blocks can be represented as:
|
|
32
37
|
* 1. String IDs (referencing existing items)
|
|
33
38
|
* 2. Full item objects with IDs (for updates)
|
|
34
39
|
* 3. Item objects without IDs (for creation)
|
|
@@ -50,80 +55,42 @@ import {
|
|
|
50
55
|
/**
|
|
51
56
|
* Variant of 'block' structured text node for API requests
|
|
52
57
|
*/
|
|
53
|
-
export type BlockAsRequest =
|
|
54
|
-
item: BlockItemInARequest;
|
|
55
|
-
};
|
|
58
|
+
export type BlockAsRequest = Block<BlockItemInARequest>;
|
|
56
59
|
|
|
57
60
|
/**
|
|
58
61
|
* Variant of 'inlineBlock' structured text node for API requests
|
|
59
62
|
*/
|
|
60
|
-
export type InlineBlockAsRequest =
|
|
61
|
-
item: BlockItemInARequest;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Generic type to transform a node that might be containing a 'block' or 'inlineBlock' as a (deeply nested) children to its variant for API requests
|
|
66
|
-
*/
|
|
67
|
-
export type NodeAsRequest<T> = WithMappedChildren<
|
|
68
|
-
T,
|
|
69
|
-
DeepMapVariants<
|
|
70
|
-
T extends { children: infer C } ? C : never,
|
|
71
|
-
BlockAsRequest,
|
|
72
|
-
InlineBlockAsRequest
|
|
73
|
-
>
|
|
74
|
-
>;
|
|
63
|
+
export type InlineBlockAsRequest = InlineBlock<BlockItemInARequest>;
|
|
75
64
|
|
|
76
65
|
/**
|
|
77
66
|
* Variant of Structured Text document for API requests
|
|
78
67
|
*/
|
|
79
|
-
export type DocumentAsRequest =
|
|
80
|
-
schema: 'dast';
|
|
81
|
-
document: NodeAsRequest<Root>;
|
|
82
|
-
};
|
|
68
|
+
export type DocumentAsRequest = Document<BlockItemInARequest>;
|
|
83
69
|
|
|
84
70
|
/**
|
|
85
71
|
* =============================================================================
|
|
86
72
|
* NESTED VARIANTS - Types for API responses with ?nested=true parameter
|
|
87
73
|
* =============================================================================
|
|
88
74
|
*
|
|
89
|
-
* When using the GET /items?nested=true, the
|
|
90
|
-
* with embedded blocks fully populated as complete
|
|
75
|
+
* When using the GET /items?nested=true, the CMA returns Structured Text documents
|
|
76
|
+
* with embedded blocks fully populated as complete RawApiTypes.Item objects instead
|
|
91
77
|
* of just string IDs.
|
|
92
78
|
*/
|
|
93
79
|
|
|
94
80
|
/**
|
|
95
81
|
* Variant of 'block' structured text node for ?nested=true API responses
|
|
96
82
|
*/
|
|
97
|
-
export type BlockWithNestedBlocks =
|
|
98
|
-
item: SchemaTypes.Item;
|
|
99
|
-
};
|
|
83
|
+
export type BlockWithNestedBlocks = Block<RawApiTypes.Item>;
|
|
100
84
|
|
|
101
85
|
/**
|
|
102
86
|
* Variant of 'inlineBlock' structured text node for ?nested=true API responses
|
|
103
87
|
*/
|
|
104
|
-
export type InlineBlockWithNestedBlocks =
|
|
105
|
-
item: SchemaTypes.Item;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Generic type to transform a node that might be containing a 'block' or 'inlineBlock' as a (deeply nested) children to it's variant for ?nested=true API responses
|
|
110
|
-
*/
|
|
111
|
-
export type NodeWithNestedBlocks<T> = WithMappedChildren<
|
|
112
|
-
T,
|
|
113
|
-
DeepMapVariants<
|
|
114
|
-
T extends { children: infer C } ? C : never,
|
|
115
|
-
BlockWithNestedBlocks,
|
|
116
|
-
InlineBlockWithNestedBlocks
|
|
117
|
-
>
|
|
118
|
-
>;
|
|
88
|
+
export type InlineBlockWithNestedBlocks = InlineBlock<RawApiTypes.Item>;
|
|
119
89
|
|
|
120
90
|
/**
|
|
121
91
|
* Variant of Structured Text document for ?nested=true API responses
|
|
122
92
|
*/
|
|
123
|
-
export type DocumentWithNestedBlocks =
|
|
124
|
-
schema: 'dast';
|
|
125
|
-
document: NodeWithNestedBlocks<Root>;
|
|
126
|
-
};
|
|
93
|
+
export type DocumentWithNestedBlocks = Document<RawApiTypes.Item>;
|
|
127
94
|
|
|
128
95
|
/**
|
|
129
96
|
* =============================================================================
|
|
@@ -140,43 +107,17 @@ export type StructuredTextFieldValueAsRequest = DocumentAsRequest | null;
|
|
|
140
107
|
export type StructuredTextFieldValueWithNestedBlocks =
|
|
141
108
|
DocumentWithNestedBlocks | null;
|
|
142
109
|
|
|
143
|
-
/**
|
|
144
|
-
* Helper function to validate if a value has the expected structured text document structure.
|
|
145
|
-
* Checks for the presence of 'schema' and 'document' properties on a non-null object.
|
|
146
|
-
*/
|
|
147
|
-
function isValidDocumentStructure(
|
|
148
|
-
value: unknown,
|
|
149
|
-
): value is { schema: unknown; document: unknown } {
|
|
150
|
-
return (
|
|
151
|
-
typeof value === 'object' &&
|
|
152
|
-
value !== null &&
|
|
153
|
-
'schema' in value &&
|
|
154
|
-
'document' in value
|
|
155
|
-
);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
110
|
/**
|
|
159
111
|
* Utility function to validate all block/inlineBlock nodes in a structured text document tree.
|
|
160
112
|
* Calls the provided callback for each block/inlineBlock node found and returns true only if all pass.
|
|
161
113
|
*/
|
|
162
|
-
function validateAllBlockNodes(
|
|
163
|
-
node:
|
|
164
|
-
callback: (
|
|
165
|
-
node:
|
|
166
|
-
| Block
|
|
167
|
-
| BlockAsRequest
|
|
168
|
-
| BlockWithNestedBlocks
|
|
169
|
-
| InlineBlock
|
|
170
|
-
| InlineBlockAsRequest
|
|
171
|
-
| InlineBlockWithNestedBlocks,
|
|
172
|
-
) => boolean,
|
|
114
|
+
function validateAllBlockNodes<T>(
|
|
115
|
+
node: Node<T>,
|
|
116
|
+
callback: (node: Block<T> | InlineBlock<T>) => boolean,
|
|
173
117
|
): boolean {
|
|
174
118
|
return everyNode(node, (currentNode) => {
|
|
175
119
|
// If this is a block or inlineBlock node, validate it with the callback
|
|
176
|
-
if (
|
|
177
|
-
isNode(currentNode) &&
|
|
178
|
-
(isBlock(currentNode) || isInlineBlock(currentNode))
|
|
179
|
-
) {
|
|
120
|
+
if (isBlock<T>(currentNode) || isInlineBlock<T>(currentNode)) {
|
|
180
121
|
return callback(currentNode);
|
|
181
122
|
}
|
|
182
123
|
// For all other node types, they're valid by default
|
|
@@ -193,7 +134,7 @@ export function isStructuredTextFieldValue(
|
|
|
193
134
|
): value is StructuredTextFieldValue {
|
|
194
135
|
if (value === null) return true;
|
|
195
136
|
|
|
196
|
-
if (!
|
|
137
|
+
if (!isDocument<unknown>(value)) {
|
|
197
138
|
return false;
|
|
198
139
|
}
|
|
199
140
|
|
|
@@ -212,7 +153,7 @@ export function isStructuredTextFieldValueAsRequest(
|
|
|
212
153
|
): value is StructuredTextFieldValueAsRequest {
|
|
213
154
|
if (value === null) return true;
|
|
214
155
|
|
|
215
|
-
if (!
|
|
156
|
+
if (!isDocument<unknown>(value)) {
|
|
216
157
|
return false;
|
|
217
158
|
}
|
|
218
159
|
|
|
@@ -221,23 +162,23 @@ export function isStructuredTextFieldValueAsRequest(
|
|
|
221
162
|
const item = node.item;
|
|
222
163
|
|
|
223
164
|
// String ID
|
|
224
|
-
if (
|
|
165
|
+
if (isItemId(item)) return true;
|
|
225
166
|
|
|
226
167
|
// Object (either with or without ID)
|
|
227
|
-
return
|
|
168
|
+
return isItemWithOptionalIdAndMeta(item);
|
|
228
169
|
});
|
|
229
170
|
}
|
|
230
171
|
|
|
231
172
|
/**
|
|
232
173
|
* Type guard for structured text field values with nested blocks (?nested=true format).
|
|
233
|
-
* Ensures all block/inlineBlock nodes have full
|
|
174
|
+
* Ensures all block/inlineBlock nodes have full RawApiTypes.Item objects.
|
|
234
175
|
*/
|
|
235
176
|
export function isStructuredTextFieldValueWithNestedBlocks(
|
|
236
177
|
value: unknown,
|
|
237
178
|
): value is StructuredTextFieldValueWithNestedBlocks {
|
|
238
179
|
if (value === null) return true;
|
|
239
180
|
|
|
240
|
-
if (!
|
|
181
|
+
if (!isDocument<unknown>(value)) {
|
|
241
182
|
return false;
|
|
242
183
|
}
|
|
243
184
|
|
|
@@ -246,67 +187,10 @@ export function isStructuredTextFieldValueWithNestedBlocks(
|
|
|
246
187
|
const item = node.item;
|
|
247
188
|
|
|
248
189
|
// Must be a full object with ID (nested format always includes full items)
|
|
249
|
-
return
|
|
190
|
+
return isItemWithOptionalMeta(item);
|
|
250
191
|
});
|
|
251
192
|
}
|
|
252
193
|
|
|
253
|
-
/**
|
|
254
|
-
* =============================================================================
|
|
255
|
-
* SHARED TRANSFORMATION UTILITIES
|
|
256
|
-
* =============================================================================
|
|
257
|
-
*
|
|
258
|
-
* These utility types provide the machinery for automatically transforming
|
|
259
|
-
* structured text types between their different variants. The goal is to
|
|
260
|
-
* recursively walk through complex nested structures and apply the appropriate
|
|
261
|
-
* transformations to Block and InlineBlock nodes while preserving all other types.
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Utility type that preserves the structure of T but replaces its children with ChildrenType.
|
|
266
|
-
* If T doesn't have children, it returns T unchanged.
|
|
267
|
-
*/
|
|
268
|
-
type WithMappedChildren<T, ChildrenType> = T extends { children: any }
|
|
269
|
-
? Omit<T, 'children'> & { children: ChildrenType }
|
|
270
|
-
: T;
|
|
271
|
-
|
|
272
|
-
/**
|
|
273
|
-
* Generic transformation type that replace 'block' and 'inlineBlock' node types to their variants.
|
|
274
|
-
*/
|
|
275
|
-
type MapVariants<T, BlockVariant, InlineBlockVariant> = T extends Block
|
|
276
|
-
? BlockVariant
|
|
277
|
-
: T extends InlineBlock
|
|
278
|
-
? InlineBlockVariant
|
|
279
|
-
: T;
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* Recursively transform a Structured Text node type using the provided variants for 'block' and 'inlineBlock' nodes.
|
|
283
|
-
*
|
|
284
|
-
* This handles three cases:
|
|
285
|
-
* _ Arrays: Transform each array element recursively
|
|
286
|
-
* _ Objects with children: Transform the object itself AND recursively transform its children
|
|
287
|
-
* _ Leaf nodes: Apply the variant mapping
|
|
288
|
-
*/
|
|
289
|
-
type DeepMapVariants<T, BlockVariant, InlineBlockVariant> =
|
|
290
|
-
T extends (infer U)[]
|
|
291
|
-
? DeepMapVariants<U, BlockVariant, InlineBlockVariant>[]
|
|
292
|
-
: T extends { children: infer Children }
|
|
293
|
-
? T extends { children: any }
|
|
294
|
-
? Omit<T, 'children'> & {
|
|
295
|
-
children: DeepMapVariants<
|
|
296
|
-
Children,
|
|
297
|
-
BlockVariant,
|
|
298
|
-
InlineBlockVariant
|
|
299
|
-
>;
|
|
300
|
-
}
|
|
301
|
-
: MapVariants<T, BlockVariant, InlineBlockVariant>
|
|
302
|
-
: MapVariants<T, BlockVariant, InlineBlockVariant>;
|
|
303
|
-
|
|
304
|
-
import type { StructuredTextEditorConfiguration } from './appearance/structured_text';
|
|
305
|
-
import type { LengthValidator } from './validators/length';
|
|
306
|
-
import type { StructuredTextBlocksValidator } from './validators/structured_text_blocks';
|
|
307
|
-
import type { StructuredTextInlineBlocksValidator } from './validators/structured_text_inline_blocks';
|
|
308
|
-
import type { StructuredTextLinksValidator } from './validators/structured_text_links';
|
|
309
|
-
|
|
310
194
|
export type StructuredTextFieldValidators = {
|
|
311
195
|
/** Only accept references to block records of the specified block models */
|
|
312
196
|
structured_text_blocks: StructuredTextBlocksValidator;
|
|
@@ -58,7 +58,7 @@ type FieldAppearanceConfig<TAppearance> = TAppearance &
|
|
|
58
58
|
Omit<RawFieldAttributes['appearance'], keyof TAppearance>;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Base field configuration for attributes (non-localized), extending the original
|
|
61
|
+
* Base field configuration for attributes (non-localized), extending the original RawApiTypes
|
|
62
62
|
*/
|
|
63
63
|
type NonLocalizedFieldAttributesForFieldType<
|
|
64
64
|
SourceType,
|
|
@@ -78,7 +78,7 @@ type NonLocalizedFieldAttributesForFieldType<
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Base field configuration for attributes (localized), extending the original
|
|
81
|
+
* Base field configuration for attributes (localized), extending the original RawApiTypes
|
|
82
82
|
*/
|
|
83
83
|
type LocalizedFieldAttributesForFieldType<
|
|
84
84
|
SourceType,
|
package/src/generated/Client.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
pollJobResult,
|
|
4
4
|
request,
|
|
5
5
|
} from '@datocms/rest-client-utils';
|
|
6
|
-
import type { JobResult } from './
|
|
6
|
+
import type { JobResult } from './ApiTypes';
|
|
7
7
|
import * as Resources from './resources';
|
|
8
8
|
|
|
9
9
|
export type RequestOptions = {
|
|
@@ -147,7 +147,7 @@ export class Client {
|
|
|
147
147
|
...this.config,
|
|
148
148
|
...options,
|
|
149
149
|
logFn: this.config.logFn || console.log,
|
|
150
|
-
userAgent: '@datocms/cma-client v5.1.
|
|
150
|
+
userAgent: '@datocms/cma-client v5.1.2',
|
|
151
151
|
baseUrl: this.baseUrl,
|
|
152
152
|
preCallStack: new Error().stack,
|
|
153
153
|
extraHeaders: {
|
|
@@ -58,7 +58,7 @@ type FieldAppearanceConfig<TAppearance> = TAppearance &
|
|
|
58
58
|
Omit<RawFieldAttributes['appearance'], keyof TAppearance>;
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* Base field configuration for attributes (non-localized), extending the original
|
|
61
|
+
* Base field configuration for attributes (non-localized), extending the original RawApiTypes
|
|
62
62
|
*/
|
|
63
63
|
type NonLocalizedFieldAttributesForFieldType<
|
|
64
64
|
SourceType,
|
|
@@ -78,7 +78,7 @@ type NonLocalizedFieldAttributesForFieldType<
|
|
|
78
78
|
};
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Base field configuration for attributes (localized), extending the original
|
|
81
|
+
* Base field configuration for attributes (localized), extending the original RawApiTypes
|
|
82
82
|
*/
|
|
83
83
|
type LocalizedFieldAttributesForFieldType<
|
|
84
84
|
SourceType,
|