@datocms/cma-client 5.1.0 → 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 +7 -7
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +21 -19
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +12 -24
- 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/fieldValue.js +253 -0
- 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 +7 -7
- package/dist/esm/fieldTypes/rich_text.js +6 -6
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/single_block.d.ts +30 -24
- package/dist/esm/fieldTypes/single_block.js +16 -14
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +20 -85
- package/dist/esm/fieldTypes/structured_text.js +11 -23
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +13 -8
- 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} +13 -8
- 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/esm/utilities/fieldValue.d.ts +166 -0
- package/dist/esm/utilities/fieldValue.js +237 -0
- 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 +7 -7
- package/dist/types/fieldTypes/single_block.d.ts +30 -24
- package/dist/types/fieldTypes/structured_text.d.ts +20 -85
- package/dist/types/generated/{SimpleSchemaTypes.d.ts → ApiTypes.d.ts} +13 -8
- package/dist/types/generated/Client.d.ts +1 -1
- package/dist/types/generated/{SchemaTypes.d.ts → RawApiTypes.d.ts} +13 -8
- 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/types/utilities/fieldValue.d.ts +166 -0
- 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 +14 -14
- package/src/fieldTypes/single_block.ts +48 -33
- package/src/fieldTypes/structured_text.ts +37 -153
- package/src/generated/{SimpleSchemaTypes.ts → ApiTypes.ts} +44 -9
- package/src/generated/Client.ts +2 -2
- package/src/generated/{SchemaTypes.ts → RawApiTypes.ts} +44 -9
- 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 +36 -36
- package/src/utilities/buildBlockRecord.ts +4 -4
- package/src/utilities/{fieldValueLocalization.ts → fieldValue.ts} +161 -147
- 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 +0 -218
- 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.d.ts +0 -123
- package/dist/esm/utilities/fieldValueLocalization.js +0 -204
- 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/fieldValueLocalization.d.ts +0 -123
- package/dist/types/utilities/structuredText.d.ts +0 -177
- package/src/utilities/structuredText.ts +0 -590
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import type * as SchemaTypes from '../generated/SchemaTypes';
|
|
2
|
-
import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
|
|
3
|
-
/**
|
|
4
|
-
* In DatoCMS, fields can be localized. In this scenario, their value contains values
|
|
5
|
-
* for various locales structured as an object, such as
|
|
6
|
-
`{ "en": "Hello", "it": "Ciao" }`)
|
|
7
|
-
*/
|
|
8
|
-
export type LocalizedFieldValue = Record<string, unknown>;
|
|
9
|
-
export declare function isLocalized(field: SchemaTypes.Field | SimpleSchemaTypes.Field): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Maps localized field values using a provided mapping function.
|
|
12
|
-
* For localized fields, applies the mapping function to each locale value.
|
|
13
|
-
* For non-localized fields, applies the mapping function directly to the only non-localizeed value.
|
|
14
|
-
*
|
|
15
|
-
* @template T - The type that the mapping function returns
|
|
16
|
-
* @param field - The DatoCMS field definition
|
|
17
|
-
* @param value - The field value (either localized object or direct value)
|
|
18
|
-
* @param mapFn - The function to apply to each locale value or the direct value
|
|
19
|
-
* @returns The mapped value with the same structure as the input
|
|
20
|
-
*/
|
|
21
|
-
export declare function mapLocalizedFieldValues<T>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => T): T | {
|
|
22
|
-
[k: string]: T;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Maps localized field values using a provided mapping function (async version).
|
|
26
|
-
* For localized fields, applies the mapping function to each locale value.
|
|
27
|
-
* For non-localized fields, applies the mapping function directly to the only non-localizeed value.
|
|
28
|
-
*
|
|
29
|
-
* @template T - The type that the mapping function returns
|
|
30
|
-
* @param field - The DatoCMS field definition
|
|
31
|
-
* @param value - The field value (either localized object or direct value)
|
|
32
|
-
* @param mapFn - The function to apply to each locale value or the direct value
|
|
33
|
-
* @returns The mapped value with the same structure as the input
|
|
34
|
-
*/
|
|
35
|
-
export declare function mapLocalizedFieldValuesAsync<T>(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, mapFn: (locale: string | undefined, localeValue: unknown) => Promise<T>): Promise<T | {
|
|
36
|
-
[k: string]: unknown;
|
|
37
|
-
}>;
|
|
38
|
-
/**
|
|
39
|
-
* Filters localized field values using a provided filter function.
|
|
40
|
-
* For localized fields, filters each locale value.
|
|
41
|
-
* For non-localized fields, returns the value if the filter passes, otherwise undefined.
|
|
42
|
-
*
|
|
43
|
-
* @param field - The DatoCMS field definition
|
|
44
|
-
* @param value - The field value (either localized object or direct value)
|
|
45
|
-
* @param filterFn - The function to test each locale value or the direct value
|
|
46
|
-
* @returns The filtered value with the same structure as the input
|
|
47
|
-
*/
|
|
48
|
-
export declare function filterLocalizedFieldValues(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => boolean): unknown;
|
|
49
|
-
/**
|
|
50
|
-
* Filters localized field values using a provided filter function (async version).
|
|
51
|
-
* For localized fields, filters each locale value.
|
|
52
|
-
* For non-localized fields, returns the value if the filter passes, otherwise undefined.
|
|
53
|
-
*
|
|
54
|
-
* @param field - The DatoCMS field definition
|
|
55
|
-
* @param value - The field value (either localized object or direct value)
|
|
56
|
-
* @param filterFn - The function to test each locale value or the direct value
|
|
57
|
-
* @returns The filtered value with the same structure as the input
|
|
58
|
-
*/
|
|
59
|
-
export declare function filterLocalizedFieldValuesAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, filterFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<unknown>;
|
|
60
|
-
/**
|
|
61
|
-
* Tests whether at least one localized field value passes the test implemented by the provided function.
|
|
62
|
-
* For localized fields, tests each locale value.
|
|
63
|
-
* For non-localized fields, tests the direct value.
|
|
64
|
-
*
|
|
65
|
-
* @param field - The DatoCMS field definition
|
|
66
|
-
* @param value - The field value (either localized object or direct value)
|
|
67
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
68
|
-
* @returns true if at least one value passes the test, false otherwise
|
|
69
|
-
*/
|
|
70
|
-
export declare function someLocalizedFieldValues(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => boolean): boolean;
|
|
71
|
-
/**
|
|
72
|
-
* Tests whether at least one localized field value passes the test implemented by the provided function (async version).
|
|
73
|
-
* For localized fields, tests each locale value.
|
|
74
|
-
* For non-localized fields, tests the direct value.
|
|
75
|
-
*
|
|
76
|
-
* @param field - The DatoCMS field definition
|
|
77
|
-
* @param value - The field value (either localized object or direct value)
|
|
78
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
79
|
-
* @returns true if at least one value passes the test, false otherwise
|
|
80
|
-
*/
|
|
81
|
-
export declare function someLocalizedFieldValuesAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<boolean>;
|
|
82
|
-
/**
|
|
83
|
-
* Tests whether all localized field values pass the test implemented by the provided function.
|
|
84
|
-
* For localized fields, tests each locale value.
|
|
85
|
-
* For non-localized fields, tests the direct value.
|
|
86
|
-
*
|
|
87
|
-
* @param field - The DatoCMS field definition
|
|
88
|
-
* @param value - The field value (either localized object or direct value)
|
|
89
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
90
|
-
* @returns true if all values pass the test, false otherwise
|
|
91
|
-
*/
|
|
92
|
-
export declare function everyLocalizedFieldValues(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => boolean): boolean;
|
|
93
|
-
/**
|
|
94
|
-
* Tests whether all localized field values pass the test implemented by the provided function (async version).
|
|
95
|
-
* For localized fields, tests each locale value.
|
|
96
|
-
* For non-localized fields, tests the direct value.
|
|
97
|
-
*
|
|
98
|
-
* @param field - The DatoCMS field definition
|
|
99
|
-
* @param value - The field value (either localized object or direct value)
|
|
100
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
101
|
-
* @returns true if all values pass the test, false otherwise
|
|
102
|
-
*/
|
|
103
|
-
export declare function everyLocalizedFieldValuesAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, testFn: (locale: string | undefined, localeValue: unknown) => Promise<boolean>): Promise<boolean>;
|
|
104
|
-
/**
|
|
105
|
-
* Visits each localized field value with the provided function.
|
|
106
|
-
* For localized fields, visits each locale value.
|
|
107
|
-
* For non-localized fields, visits the direct value.
|
|
108
|
-
*
|
|
109
|
-
* @param field - The DatoCMS field definition
|
|
110
|
-
* @param value - The field value (either localized object or direct value)
|
|
111
|
-
* @param visitFn - The function to call for each locale value or the direct value
|
|
112
|
-
*/
|
|
113
|
-
export declare function visitLocalizedFieldValues(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, visitFn: (locale: string | undefined, localeValue: unknown) => void): void;
|
|
114
|
-
/**
|
|
115
|
-
* Visits each localized field value with the provided function (async version).
|
|
116
|
-
* For localized fields, visits each locale value.
|
|
117
|
-
* For non-localized fields, visits the direct value.
|
|
118
|
-
*
|
|
119
|
-
* @param field - The DatoCMS field definition
|
|
120
|
-
* @param value - The field value (either localized object or direct value)
|
|
121
|
-
* @param visitFn - The function to call for each locale value or the direct value
|
|
122
|
-
*/
|
|
123
|
-
export declare function visitLocalizedFieldValuesAsync(field: SchemaTypes.Field | SimpleSchemaTypes.Field, value: unknown, visitFn: (locale: string | undefined, localeValue: unknown) => Promise<void>): Promise<void>;
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export function isLocalized(field) {
|
|
11
|
-
return 'attributes' in field ? field.attributes.localized : field.localized;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Maps localized field values using a provided mapping function.
|
|
15
|
-
* For localized fields, applies the mapping function to each locale value.
|
|
16
|
-
* For non-localized fields, applies the mapping function directly to the only non-localizeed value.
|
|
17
|
-
*
|
|
18
|
-
* @template T - The type that the mapping function returns
|
|
19
|
-
* @param field - The DatoCMS field definition
|
|
20
|
-
* @param value - The field value (either localized object or direct value)
|
|
21
|
-
* @param mapFn - The function to apply to each locale value or the direct value
|
|
22
|
-
* @returns The mapped value with the same structure as the input
|
|
23
|
-
*/
|
|
24
|
-
export function mapLocalizedFieldValues(field, value, mapFn) {
|
|
25
|
-
if (isLocalized(field)) {
|
|
26
|
-
const localizedValue = value;
|
|
27
|
-
return Object.fromEntries(Object.entries(localizedValue).map(([locale, value]) => [
|
|
28
|
-
locale,
|
|
29
|
-
mapFn(locale, value),
|
|
30
|
-
]));
|
|
31
|
-
}
|
|
32
|
-
return mapFn(undefined, value);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Maps localized field values using a provided mapping function (async version).
|
|
36
|
-
* For localized fields, applies the mapping function to each locale value.
|
|
37
|
-
* For non-localized fields, applies the mapping function directly to the only non-localizeed value.
|
|
38
|
-
*
|
|
39
|
-
* @template T - The type that the mapping function returns
|
|
40
|
-
* @param field - The DatoCMS field definition
|
|
41
|
-
* @param value - The field value (either localized object or direct value)
|
|
42
|
-
* @param mapFn - The function to apply to each locale value or the direct value
|
|
43
|
-
* @returns The mapped value with the same structure as the input
|
|
44
|
-
*/
|
|
45
|
-
export function mapLocalizedFieldValuesAsync(field, value, mapFn) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
if (isLocalized(field)) {
|
|
48
|
-
const localizedValue = value;
|
|
49
|
-
return Object.fromEntries(yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () { return [locale, yield mapFn(locale, value)]; }))));
|
|
50
|
-
}
|
|
51
|
-
return yield mapFn(undefined, value);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Filters localized field values using a provided filter function.
|
|
56
|
-
* For localized fields, filters each locale value.
|
|
57
|
-
* For non-localized fields, returns the value if the filter passes, otherwise undefined.
|
|
58
|
-
*
|
|
59
|
-
* @param field - The DatoCMS field definition
|
|
60
|
-
* @param value - The field value (either localized object or direct value)
|
|
61
|
-
* @param filterFn - The function to test each locale value or the direct value
|
|
62
|
-
* @returns The filtered value with the same structure as the input
|
|
63
|
-
*/
|
|
64
|
-
export function filterLocalizedFieldValues(field, value, filterFn) {
|
|
65
|
-
if (isLocalized(field)) {
|
|
66
|
-
const localizedValue = value;
|
|
67
|
-
return Object.fromEntries(Object.entries(localizedValue).filter(([locale, value]) => filterFn(locale, value)));
|
|
68
|
-
}
|
|
69
|
-
return filterFn(undefined, value) ? value : undefined;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Filters localized field values using a provided filter function (async version).
|
|
73
|
-
* For localized fields, filters each locale value.
|
|
74
|
-
* For non-localized fields, returns the value if the filter passes, otherwise undefined.
|
|
75
|
-
*
|
|
76
|
-
* @param field - The DatoCMS field definition
|
|
77
|
-
* @param value - The field value (either localized object or direct value)
|
|
78
|
-
* @param filterFn - The function to test each locale value or the direct value
|
|
79
|
-
* @returns The filtered value with the same structure as the input
|
|
80
|
-
*/
|
|
81
|
-
export function filterLocalizedFieldValuesAsync(field, value, filterFn) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
if (isLocalized(field)) {
|
|
84
|
-
const localizedValue = value;
|
|
85
|
-
const results = yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
return [
|
|
87
|
-
locale,
|
|
88
|
-
value,
|
|
89
|
-
yield filterFn(locale, value),
|
|
90
|
-
];
|
|
91
|
-
})));
|
|
92
|
-
return Object.fromEntries(results
|
|
93
|
-
.filter(([, , passed]) => passed)
|
|
94
|
-
.map(([locale, value]) => [locale, value]));
|
|
95
|
-
}
|
|
96
|
-
return (yield filterFn(undefined, value)) ? value : undefined;
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Tests whether at least one localized field value passes the test implemented by the provided function.
|
|
101
|
-
* For localized fields, tests each locale value.
|
|
102
|
-
* For non-localized fields, tests the direct value.
|
|
103
|
-
*
|
|
104
|
-
* @param field - The DatoCMS field definition
|
|
105
|
-
* @param value - The field value (either localized object or direct value)
|
|
106
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
107
|
-
* @returns true if at least one value passes the test, false otherwise
|
|
108
|
-
*/
|
|
109
|
-
export function someLocalizedFieldValues(field, value, testFn) {
|
|
110
|
-
if (isLocalized(field)) {
|
|
111
|
-
const localizedValue = value;
|
|
112
|
-
return Object.entries(localizedValue).some(([locale, value]) => testFn(locale, value));
|
|
113
|
-
}
|
|
114
|
-
return testFn(undefined, value);
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Tests whether at least one localized field value passes the test implemented by the provided function (async version).
|
|
118
|
-
* For localized fields, tests each locale value.
|
|
119
|
-
* For non-localized fields, tests the direct value.
|
|
120
|
-
*
|
|
121
|
-
* @param field - The DatoCMS field definition
|
|
122
|
-
* @param value - The field value (either localized object or direct value)
|
|
123
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
124
|
-
* @returns true if at least one value passes the test, false otherwise
|
|
125
|
-
*/
|
|
126
|
-
export function someLocalizedFieldValuesAsync(field, value, testFn) {
|
|
127
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
-
if (isLocalized(field)) {
|
|
129
|
-
const localizedValue = value;
|
|
130
|
-
const results = yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () { return yield testFn(locale, value); })));
|
|
131
|
-
return results.some((result) => result);
|
|
132
|
-
}
|
|
133
|
-
return yield testFn(undefined, value);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Tests whether all localized field values pass the test implemented by the provided function.
|
|
138
|
-
* For localized fields, tests each locale value.
|
|
139
|
-
* For non-localized fields, tests the direct value.
|
|
140
|
-
*
|
|
141
|
-
* @param field - The DatoCMS field definition
|
|
142
|
-
* @param value - The field value (either localized object or direct value)
|
|
143
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
144
|
-
* @returns true if all values pass the test, false otherwise
|
|
145
|
-
*/
|
|
146
|
-
export function everyLocalizedFieldValues(field, value, testFn) {
|
|
147
|
-
return !someLocalizedFieldValues(field, value, (locale, localeValue) => !testFn(locale, localeValue));
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Tests whether all localized field values pass the test implemented by the provided function (async version).
|
|
151
|
-
* For localized fields, tests each locale value.
|
|
152
|
-
* For non-localized fields, tests the direct value.
|
|
153
|
-
*
|
|
154
|
-
* @param field - The DatoCMS field definition
|
|
155
|
-
* @param value - The field value (either localized object or direct value)
|
|
156
|
-
* @param testFn - The function to test each locale value or the direct value
|
|
157
|
-
* @returns true if all values pass the test, false otherwise
|
|
158
|
-
*/
|
|
159
|
-
export function everyLocalizedFieldValuesAsync(field, value, testFn) {
|
|
160
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
return !(yield someLocalizedFieldValuesAsync(field, value, (locale, localeValue) => __awaiter(this, void 0, void 0, function* () { return !(yield testFn(locale, localeValue)); })));
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Visits each localized field value with the provided function.
|
|
166
|
-
* For localized fields, visits each locale value.
|
|
167
|
-
* For non-localized fields, visits the direct value.
|
|
168
|
-
*
|
|
169
|
-
* @param field - The DatoCMS field definition
|
|
170
|
-
* @param value - The field value (either localized object or direct value)
|
|
171
|
-
* @param visitFn - The function to call for each locale value or the direct value
|
|
172
|
-
*/
|
|
173
|
-
export function visitLocalizedFieldValues(field, value, visitFn) {
|
|
174
|
-
if (isLocalized(field)) {
|
|
175
|
-
const localizedValue = value;
|
|
176
|
-
for (const [locale, value] of Object.entries(localizedValue)) {
|
|
177
|
-
visitFn(locale, value);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
visitFn(undefined, value);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Visits each localized field value with the provided function (async version).
|
|
186
|
-
* For localized fields, visits each locale value.
|
|
187
|
-
* For non-localized fields, visits the direct value.
|
|
188
|
-
*
|
|
189
|
-
* @param field - The DatoCMS field definition
|
|
190
|
-
* @param value - The field value (either localized object or direct value)
|
|
191
|
-
* @param visitFn - The function to call for each locale value or the direct value
|
|
192
|
-
*/
|
|
193
|
-
export function visitLocalizedFieldValuesAsync(field, value, visitFn) {
|
|
194
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
195
|
-
if (isLocalized(field)) {
|
|
196
|
-
const localizedValue = value;
|
|
197
|
-
yield Promise.all(Object.entries(localizedValue).map(([locale, value]) => __awaiter(this, void 0, void 0, function* () { return yield visitFn(locale, value); })));
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
yield visitFn(undefined, value);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
//# sourceMappingURL=fieldValueLocalization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fieldValueLocalization.js","sourceRoot":"","sources":["../../../src/utilities/fieldValueLocalization.ts"],"names":[],"mappings":";;;;;;;;;AA8CA,MAAM,UAAU,WAAW,CACzB,KAAkD;IAElD,OAAO,YAAY,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAAkD,EAClD,KAAc,EACd,KAA8D;IAE9D,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;QACtB,MAAM,cAAc,GAAG,KAA4B,CAAC;QAEpD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YACtD,MAAM;YACN,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;SACrB,CAAC,CACH,CAAC;KACH;IAED,OAAO,KAAK,CAAC,SAAS,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CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SACxB;KACF;SAAM;QACL,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KAC3B;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAgB,8BAA8B,CAClD,KAAkD,EAClD,KAAc,EACd,OAA4E;;QAE5E,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE;YACtB,MAAM,cAAc,GAAG,KAA4B,CAAC;YAEpD,MAAM,OAAO,CAAC,GAAG,CACf,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,GAAG,CAChC,CAAO,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,gDAAC,OAAA,MAAM,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA,GAAA,CACxD,CACF,CAAC;SACH;aAAM;YACL,MAAM,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SACjC;IACH,CAAC;CAAA"}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tree manipulation utilities for DatoCMS structured text documents.
|
|
3
|
-
*
|
|
4
|
-
* Provides a set of low-level utilities for visiting, transforming, and querying
|
|
5
|
-
* structured text trees. Works with all tree variants (regular, request, nested).
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Recursively extract all possible node types that can appear in a tree structure
|
|
9
|
-
*/
|
|
10
|
-
type AllNodesInTree<T, Depth extends number = 10> = Depth extends 0 ? T extends readonly unknown[] ? never : T : T extends readonly (infer U)[] ? AllNodesInTree<U, Prev<Depth>> : T extends {
|
|
11
|
-
children: infer Children;
|
|
12
|
-
} ? T | AllNodesInTree<Children, Prev<Depth>> : T;
|
|
13
|
-
type Prev<T extends number> = T extends 0 ? 0 : T extends 1 ? 0 : T extends 2 ? 1 : T extends 3 ? 2 : T extends 4 ? 3 : T extends 5 ? 4 : T extends 6 ? 5 : T extends 7 ? 6 : T extends 8 ? 7 : T extends 9 ? 8 : T extends 10 ? 9 : number;
|
|
14
|
-
/**
|
|
15
|
-
* Path through the Structured Text tree structure
|
|
16
|
-
*/
|
|
17
|
-
export type TreePath = readonly (string | number)[];
|
|
18
|
-
/**
|
|
19
|
-
* Generic predicate function type for Structured Text tree node filtering
|
|
20
|
-
*/
|
|
21
|
-
export type NodePredicate<T, R> = (node: AllNodesInTree<T>, parent: AllNodesInTree<T> | null, path: TreePath) => R;
|
|
22
|
-
/**
|
|
23
|
-
* Visit every node in the Structured Text tree, calling the visitor function for each.
|
|
24
|
-
* Uses pre-order traversal (parent is visited before its children).
|
|
25
|
-
*
|
|
26
|
-
* @template T - The type of the root node in the Structured Text tree
|
|
27
|
-
* @param node - The root node to start visiting from
|
|
28
|
-
* @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
29
|
-
*/
|
|
30
|
-
export declare function visitNodes<T>(node: T, visitor: NodePredicate<T, void>, parent?: AllNodesInTree<T> | null, path?: TreePath): void;
|
|
31
|
-
/**
|
|
32
|
-
* Visit every node in the Structured Text tree, calling the visitor function for each.
|
|
33
|
-
* Uses pre-order traversal (parent is visited before its children).
|
|
34
|
-
*
|
|
35
|
-
* @template T - The type of the root node in the Structured Text tree
|
|
36
|
-
* @param node - The root node to start visiting from
|
|
37
|
-
* @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
38
|
-
* @returns Promise that resolves when all nodes have been visited
|
|
39
|
-
*/
|
|
40
|
-
export declare function visitNodesAsync<T>(node: T, visitor: NodePredicate<T, Promise<void>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Transform nodes in the Structured Text tree by applying a mapping function.
|
|
43
|
-
* Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
|
|
44
|
-
*
|
|
45
|
-
* @template T - The type of nodes in the input Structured Text tree
|
|
46
|
-
* @template R - The type of nodes in the output tree
|
|
47
|
-
* @param node - The root node to start mapping from
|
|
48
|
-
* @param mapper - Synchronous function that transforms each node. Receives the node, its parent, and path
|
|
49
|
-
* @returns The transformed tree
|
|
50
|
-
*/
|
|
51
|
-
export declare function mapNodes<T, R>(node: T, mapper: NodePredicate<T, R>, parent?: AllNodesInTree<T> | null, path?: TreePath): R;
|
|
52
|
-
/**
|
|
53
|
-
* Transform nodes in the Structured Text tree by applying a mapping function.
|
|
54
|
-
* Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
|
|
55
|
-
*
|
|
56
|
-
* @template T - The type of nodes in the input Structured Text tree
|
|
57
|
-
* @template R - The type of nodes in the output tree
|
|
58
|
-
* @param node - The root node to start mapping from
|
|
59
|
-
* @param mapper - Asynchronous function that transforms each node. Receives the node, its parent, and path
|
|
60
|
-
* @returns Promise that resolves to the transformed tree
|
|
61
|
-
*/
|
|
62
|
-
export declare function mapNodesAsync<T, R>(node: T, mapper: NodePredicate<T, Promise<R>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<R>;
|
|
63
|
-
/**
|
|
64
|
-
* Find all nodes that match the predicate function using depth-first search.
|
|
65
|
-
* Returns an array containing all matching nodes along with their paths through the Structured Text tree.
|
|
66
|
-
*
|
|
67
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
68
|
-
* @param node - The root node to start searching from
|
|
69
|
-
* @param predicate - Synchronous function that tests each node. Should return true for desired nodes
|
|
70
|
-
* @returns Array of objects, each containing a matching node and its path
|
|
71
|
-
*/
|
|
72
|
-
export declare function findAllNodes<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): Array<{
|
|
73
|
-
node: AllNodesInTree<T>;
|
|
74
|
-
path: TreePath;
|
|
75
|
-
}>;
|
|
76
|
-
/**
|
|
77
|
-
* Find all nodes that match the predicate function using depth-first search.
|
|
78
|
-
* Returns an array containing all matching nodes along with their paths through the Structured Text tree.
|
|
79
|
-
*
|
|
80
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
81
|
-
* @param node - The root node to start searching from
|
|
82
|
-
* @param predicate - Asynchronous function that tests each node. Should return true for desired nodes
|
|
83
|
-
* @returns Promise that resolves to an array of objects, each containing a matching node and its path
|
|
84
|
-
*/
|
|
85
|
-
export declare function findAllNodesAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<Array<{
|
|
86
|
-
node: AllNodesInTree<T>;
|
|
87
|
-
path: TreePath;
|
|
88
|
-
}>>;
|
|
89
|
-
/**
|
|
90
|
-
* Filter nodes in the Structured Text tree, removing those that don't match the predicate.
|
|
91
|
-
* Creates a new tree structure containing only nodes that pass the predicate test.
|
|
92
|
-
* Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
|
|
93
|
-
*
|
|
94
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
95
|
-
* @param node - The root node to start filtering from
|
|
96
|
-
* @param predicate - Synchronous function that tests each node. Nodes returning false are removed
|
|
97
|
-
* @returns The filtered tree, or null if root node is filtered out
|
|
98
|
-
*/
|
|
99
|
-
export declare function filterNodes<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): T | null;
|
|
100
|
-
/**
|
|
101
|
-
* Filter nodes in the Structured Text tree, removing those that don't match the predicate.
|
|
102
|
-
* Creates a new tree structure containing only nodes that pass the predicate test.
|
|
103
|
-
* Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
|
|
104
|
-
*
|
|
105
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
106
|
-
* @param node - The root node to start filtering from
|
|
107
|
-
* @param predicate - Asynchronous function that tests each node. Nodes returning false are removed
|
|
108
|
-
* @returns Promise that resolves to the filtered tree, or null if root node is filtered out
|
|
109
|
-
*/
|
|
110
|
-
export declare function filterNodesAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<T | null>;
|
|
111
|
-
/**
|
|
112
|
-
* Reduce the Structured Text tree to a single value by applying a reducer function to each node.
|
|
113
|
-
* Uses pre-order traversal (parent is processed before its children).
|
|
114
|
-
* The reducer function is called for each node with the current accumulator value.
|
|
115
|
-
*
|
|
116
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
117
|
-
* @template R - The type of the accumulated result
|
|
118
|
-
* @param node - The root node to start reducing from
|
|
119
|
-
* @param reducer - Synchronous function that processes each node and updates the accumulator
|
|
120
|
-
* @param initialValue - The initial value for the accumulator
|
|
121
|
-
* @returns The final accumulated value
|
|
122
|
-
*/
|
|
123
|
-
export declare function reduceNodes<T, R>(node: T, reducer: (accumulator: R, node: AllNodesInTree<T>, parent: AllNodesInTree<T> | null, path: TreePath) => R, initialValue: R, parent?: AllNodesInTree<T> | null, path?: TreePath): R;
|
|
124
|
-
/**
|
|
125
|
-
* Reduce the Structured Text tree to a single value by applying a reducer function to each node.
|
|
126
|
-
* Uses pre-order traversal (parent is processed before its children).
|
|
127
|
-
* The reducer function is called for each node with the current accumulator value.
|
|
128
|
-
*
|
|
129
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
130
|
-
* @template R - The type of the accumulated result
|
|
131
|
-
* @param node - The root node to start reducing from
|
|
132
|
-
* @param reducer - Asynchronous function that processes each node and updates the accumulator
|
|
133
|
-
* @param initialValue - The initial value for the accumulator
|
|
134
|
-
* @returns Promise that resolves to the final accumulated value
|
|
135
|
-
*/
|
|
136
|
-
export declare function reduceNodesAsync<T, R>(node: T, reducer: (accumulator: R, node: AllNodesInTree<T>, parent: AllNodesInTree<T> | null, path: TreePath) => Promise<R>, initialValue: R, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<R>;
|
|
137
|
-
/**
|
|
138
|
-
* Check if any node in the Structured Text tree matches the predicate function.
|
|
139
|
-
* Returns true as soon as the first matching node is found (short-circuit evaluation).
|
|
140
|
-
*
|
|
141
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
142
|
-
* @param node - The root node to start searching from
|
|
143
|
-
* @param predicate - Synchronous function that tests each node. Should return true for matching nodes
|
|
144
|
-
* @returns True if any node matches, false otherwise
|
|
145
|
-
*/
|
|
146
|
-
export declare function someNode<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): boolean;
|
|
147
|
-
/**
|
|
148
|
-
* Check if any node in the Structured Text tree matches the predicate function.
|
|
149
|
-
* Returns true as soon as the first matching node is found (short-circuit evaluation).
|
|
150
|
-
*
|
|
151
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
152
|
-
* @param node - The root node to start searching from
|
|
153
|
-
* @param predicate - Asynchronous function that tests each node. Should return true for matching nodes
|
|
154
|
-
* @returns Promise that resolves to true if any node matches, false otherwise
|
|
155
|
-
*/
|
|
156
|
-
export declare function someNodeAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<boolean>;
|
|
157
|
-
/**
|
|
158
|
-
* Check if every node in the Structured Text tree matches the predicate function.
|
|
159
|
-
* Returns false as soon as the first non-matching node is found (short-circuit evaluation).
|
|
160
|
-
*
|
|
161
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
162
|
-
* @param node - The root node to start testing from
|
|
163
|
-
* @param predicate - Synchronous function that tests each node. Should return true for valid nodes
|
|
164
|
-
* @returns True if all nodes match, false otherwise
|
|
165
|
-
*/
|
|
166
|
-
export declare function everyNode<T>(node: T, predicate: NodePredicate<T, boolean>, parent?: AllNodesInTree<T> | null, path?: TreePath): boolean;
|
|
167
|
-
/**
|
|
168
|
-
* Check if every node in the Structured Text tree matches the predicate function.
|
|
169
|
-
* Returns false as soon as the first non-matching node is found (short-circuit evaluation).
|
|
170
|
-
*
|
|
171
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
172
|
-
* @param node - The root node to start testing from
|
|
173
|
-
* @param predicate - Asynchronous function that tests each node. Should return true for valid nodes
|
|
174
|
-
* @returns Promise that resolves to true if all nodes match, false otherwise
|
|
175
|
-
*/
|
|
176
|
-
export declare function everyNodeAsync<T>(node: T, predicate: NodePredicate<T, Promise<boolean>>, parent?: AllNodesInTree<T> | null, path?: TreePath): Promise<boolean>;
|
|
177
|
-
export {};
|