@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,354 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Check if a value has children property that is an array
|
|
18
|
-
*/
|
|
19
|
-
function hasChildren(node) {
|
|
20
|
-
return (typeof node === 'object' &&
|
|
21
|
-
node !== null &&
|
|
22
|
-
'children' in node &&
|
|
23
|
-
Array.isArray(node.children));
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Visit every node in the Structured Text tree, calling the visitor function for each.
|
|
27
|
-
* Uses pre-order traversal (parent is visited before its children).
|
|
28
|
-
*
|
|
29
|
-
* @template T - The type of the root node in the Structured Text tree
|
|
30
|
-
* @param node - The root node to start visiting from
|
|
31
|
-
* @param visitor - Synchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
32
|
-
*/
|
|
33
|
-
export function visitNodes(node, visitor, parent = null, path = []) {
|
|
34
|
-
// Visit current node
|
|
35
|
-
visitor(node, parent, path);
|
|
36
|
-
// Recursively visit children
|
|
37
|
-
if (hasChildren(node)) {
|
|
38
|
-
for (let index = 0; index < node.children.length; index++) {
|
|
39
|
-
const child = node.children[index];
|
|
40
|
-
visitNodes(child, visitor, node, [
|
|
41
|
-
...path,
|
|
42
|
-
'children',
|
|
43
|
-
index,
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Visit every node in the Structured Text tree, calling the visitor function for each.
|
|
50
|
-
* Uses pre-order traversal (parent is visited before its children).
|
|
51
|
-
*
|
|
52
|
-
* @template T - The type of the root node in the Structured Text tree
|
|
53
|
-
* @param node - The root node to start visiting from
|
|
54
|
-
* @param visitor - Asynchronous function called for each node. Receives the node, its parent, and path through the Structured Text tree
|
|
55
|
-
* @returns Promise that resolves when all nodes have been visited
|
|
56
|
-
*/
|
|
57
|
-
export function visitNodesAsync(node, visitor, parent = null, path = []) {
|
|
58
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
-
// Visit current node
|
|
60
|
-
yield visitor(node, parent, path);
|
|
61
|
-
// Recursively visit children
|
|
62
|
-
if (hasChildren(node)) {
|
|
63
|
-
for (let index = 0; index < node.children.length; index++) {
|
|
64
|
-
const child = node.children[index];
|
|
65
|
-
yield visitNodesAsync(child, visitor, node, [
|
|
66
|
-
...path,
|
|
67
|
-
'children',
|
|
68
|
-
index,
|
|
69
|
-
]);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Transform nodes in the Structured Text tree by applying a mapping function.
|
|
76
|
-
* Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
|
|
77
|
-
*
|
|
78
|
-
* @template T - The type of nodes in the input Structured Text tree
|
|
79
|
-
* @template R - The type of nodes in the output tree
|
|
80
|
-
* @param node - The root node to start mapping from
|
|
81
|
-
* @param mapper - Synchronous function that transforms each node. Receives the node, its parent, and path
|
|
82
|
-
* @returns The transformed tree
|
|
83
|
-
*/
|
|
84
|
-
export function mapNodes(node, mapper, parent = null, path = []) {
|
|
85
|
-
// Transform current node
|
|
86
|
-
const transformedNode = mapper(node, parent, path);
|
|
87
|
-
// If the original node has children, recursively transform them
|
|
88
|
-
if (hasChildren(node) &&
|
|
89
|
-
typeof transformedNode === 'object' &&
|
|
90
|
-
transformedNode !== null) {
|
|
91
|
-
const transformedChildren = node.children.map((child, index) => mapNodes(child, mapper, node, [
|
|
92
|
-
...path,
|
|
93
|
-
'children',
|
|
94
|
-
index,
|
|
95
|
-
]));
|
|
96
|
-
return Object.assign(Object.assign({}, transformedNode), { children: transformedChildren });
|
|
97
|
-
}
|
|
98
|
-
return transformedNode;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Transform nodes in the Structured Text tree by applying a mapping function.
|
|
102
|
-
* Creates a new tree structure with transformed nodes while preserving the Structured Text tree hierarchy.
|
|
103
|
-
*
|
|
104
|
-
* @template T - The type of nodes in the input Structured Text tree
|
|
105
|
-
* @template R - The type of nodes in the output tree
|
|
106
|
-
* @param node - The root node to start mapping from
|
|
107
|
-
* @param mapper - Asynchronous function that transforms each node. Receives the node, its parent, and path
|
|
108
|
-
* @returns Promise that resolves to the transformed tree
|
|
109
|
-
*/
|
|
110
|
-
export function mapNodesAsync(node, mapper, parent = null, path = []) {
|
|
111
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
-
// Transform current node
|
|
113
|
-
const transformedNode = yield mapper(node, parent, path);
|
|
114
|
-
// If the original node has children, recursively transform them
|
|
115
|
-
if (hasChildren(node) &&
|
|
116
|
-
typeof transformedNode === 'object' &&
|
|
117
|
-
transformedNode !== null) {
|
|
118
|
-
const transformedChildren = yield Promise.all(node.children.map((child, index) => mapNodesAsync(child, mapper, node, [
|
|
119
|
-
...path,
|
|
120
|
-
'children',
|
|
121
|
-
index,
|
|
122
|
-
])));
|
|
123
|
-
return Object.assign(Object.assign({}, transformedNode), { children: transformedChildren });
|
|
124
|
-
}
|
|
125
|
-
return transformedNode;
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Find all nodes that match the predicate function using depth-first search.
|
|
130
|
-
* Returns an array containing all matching nodes along with their paths through the Structured Text tree.
|
|
131
|
-
*
|
|
132
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
133
|
-
* @param node - The root node to start searching from
|
|
134
|
-
* @param predicate - Synchronous function that tests each node. Should return true for desired nodes
|
|
135
|
-
* @returns Array of objects, each containing a matching node and its path
|
|
136
|
-
*/
|
|
137
|
-
export function findAllNodes(node, predicate, parent = null, path = []) {
|
|
138
|
-
const results = [];
|
|
139
|
-
visitNodes(node, (currentNode, currentParent, currentPath) => {
|
|
140
|
-
if (predicate(currentNode, currentParent, currentPath)) {
|
|
141
|
-
results.push({ node: currentNode, path: currentPath });
|
|
142
|
-
}
|
|
143
|
-
}, parent, path);
|
|
144
|
-
return results;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Find all nodes that match the predicate function using depth-first search.
|
|
148
|
-
* Returns an array containing all matching nodes along with their paths through the Structured Text tree.
|
|
149
|
-
*
|
|
150
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
151
|
-
* @param node - The root node to start searching from
|
|
152
|
-
* @param predicate - Asynchronous function that tests each node. Should return true for desired nodes
|
|
153
|
-
* @returns Promise that resolves to an array of objects, each containing a matching node and its path
|
|
154
|
-
*/
|
|
155
|
-
export function findAllNodesAsync(node, predicate, parent = null, path = []) {
|
|
156
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
-
const results = [];
|
|
158
|
-
yield visitNodesAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
if (yield predicate(currentNode, currentParent, currentPath)) {
|
|
160
|
-
results.push({ node: currentNode, path: currentPath });
|
|
161
|
-
}
|
|
162
|
-
}), parent, path);
|
|
163
|
-
return results;
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Filter nodes in the Structured Text tree, removing those that don't match the predicate.
|
|
168
|
-
* Creates a new tree structure containing only nodes that pass the predicate test.
|
|
169
|
-
* Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
|
|
170
|
-
*
|
|
171
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
172
|
-
* @param node - The root node to start filtering from
|
|
173
|
-
* @param predicate - Synchronous function that tests each node. Nodes returning false are removed
|
|
174
|
-
* @returns The filtered tree, or null if root node is filtered out
|
|
175
|
-
*/
|
|
176
|
-
export function filterNodes(node, predicate, parent = null, path = []) {
|
|
177
|
-
// If current node doesn't match predicate, return null
|
|
178
|
-
if (!predicate(node, parent, path)) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
// If node has no children, return it as-is
|
|
182
|
-
if (!hasChildren(node)) {
|
|
183
|
-
return node;
|
|
184
|
-
}
|
|
185
|
-
// Filter children recursively
|
|
186
|
-
const childrenResults = node.children.map((child, index) => filterNodes(child, predicate, node, [
|
|
187
|
-
...path,
|
|
188
|
-
'children',
|
|
189
|
-
index,
|
|
190
|
-
]));
|
|
191
|
-
const filteredChildren = childrenResults.filter((child) => child !== null);
|
|
192
|
-
return Object.assign(Object.assign({}, node), { children: filteredChildren });
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Filter nodes in the Structured Text tree, removing those that don't match the predicate.
|
|
196
|
-
* Creates a new tree structure containing only nodes that pass the predicate test.
|
|
197
|
-
* Maintains the Structured Text tree hierarchy - if a parent node is kept, its structure is preserved.
|
|
198
|
-
*
|
|
199
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
200
|
-
* @param node - The root node to start filtering from
|
|
201
|
-
* @param predicate - Asynchronous function that tests each node. Nodes returning false are removed
|
|
202
|
-
* @returns Promise that resolves to the filtered tree, or null if root node is filtered out
|
|
203
|
-
*/
|
|
204
|
-
export function filterNodesAsync(node, predicate, parent = null, path = []) {
|
|
205
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
206
|
-
// If current node doesn't match predicate, return null
|
|
207
|
-
if (!(yield predicate(node, parent, path))) {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
// If node has no children, return it as-is
|
|
211
|
-
if (!hasChildren(node)) {
|
|
212
|
-
return node;
|
|
213
|
-
}
|
|
214
|
-
// Filter children recursively
|
|
215
|
-
const childrenResults = yield Promise.all(node.children.map((child, index) => filterNodesAsync(child, predicate, node, [
|
|
216
|
-
...path,
|
|
217
|
-
'children',
|
|
218
|
-
index,
|
|
219
|
-
])));
|
|
220
|
-
const filteredChildren = childrenResults.filter((child) => child !== null);
|
|
221
|
-
return Object.assign(Object.assign({}, node), { children: filteredChildren });
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Reduce the Structured Text tree to a single value by applying a reducer function to each node.
|
|
226
|
-
* Uses pre-order traversal (parent is processed before its children).
|
|
227
|
-
* The reducer function is called for each node with the current accumulator value.
|
|
228
|
-
*
|
|
229
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
230
|
-
* @template R - The type of the accumulated result
|
|
231
|
-
* @param node - The root node to start reducing from
|
|
232
|
-
* @param reducer - Synchronous function that processes each node and updates the accumulator
|
|
233
|
-
* @param initialValue - The initial value for the accumulator
|
|
234
|
-
* @returns The final accumulated value
|
|
235
|
-
*/
|
|
236
|
-
export function reduceNodes(node, reducer, initialValue, parent = null, path = []) {
|
|
237
|
-
let accumulator = initialValue;
|
|
238
|
-
visitNodes(node, (currentNode, currentParent, currentPath) => {
|
|
239
|
-
accumulator = reducer(accumulator, currentNode, currentParent, currentPath);
|
|
240
|
-
}, parent, path);
|
|
241
|
-
return accumulator;
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Reduce the Structured Text tree to a single value by applying a reducer function to each node.
|
|
245
|
-
* Uses pre-order traversal (parent is processed before its children).
|
|
246
|
-
* The reducer function is called for each node with the current accumulator value.
|
|
247
|
-
*
|
|
248
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
249
|
-
* @template R - The type of the accumulated result
|
|
250
|
-
* @param node - The root node to start reducing from
|
|
251
|
-
* @param reducer - Asynchronous function that processes each node and updates the accumulator
|
|
252
|
-
* @param initialValue - The initial value for the accumulator
|
|
253
|
-
* @returns Promise that resolves to the final accumulated value
|
|
254
|
-
*/
|
|
255
|
-
export function reduceNodesAsync(node, reducer, initialValue, parent = null, path = []) {
|
|
256
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
-
let accumulator = initialValue;
|
|
258
|
-
yield visitNodesAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
259
|
-
accumulator = yield reducer(accumulator, currentNode, currentParent, currentPath);
|
|
260
|
-
}), parent, path);
|
|
261
|
-
return accumulator;
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Check if any node in the Structured Text tree matches the predicate function.
|
|
266
|
-
* Returns true as soon as the first matching node is found (short-circuit evaluation).
|
|
267
|
-
*
|
|
268
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
269
|
-
* @param node - The root node to start searching from
|
|
270
|
-
* @param predicate - Synchronous function that tests each node. Should return true for matching nodes
|
|
271
|
-
* @returns True if any node matches, false otherwise
|
|
272
|
-
*/
|
|
273
|
-
export function someNode(node, predicate, parent = null, path = []) {
|
|
274
|
-
// Check current node
|
|
275
|
-
if (predicate(node, parent, path)) {
|
|
276
|
-
return true;
|
|
277
|
-
}
|
|
278
|
-
// Recursively check children
|
|
279
|
-
if (hasChildren(node)) {
|
|
280
|
-
for (let index = 0; index < node.children.length; index++) {
|
|
281
|
-
const child = node.children[index];
|
|
282
|
-
if (someNode(child, predicate, node, [
|
|
283
|
-
...path,
|
|
284
|
-
'children',
|
|
285
|
-
index,
|
|
286
|
-
])) {
|
|
287
|
-
return true;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Check if any node in the Structured Text tree matches the predicate function.
|
|
295
|
-
* Returns true as soon as the first matching node is found (short-circuit evaluation).
|
|
296
|
-
*
|
|
297
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
298
|
-
* @param node - The root node to start searching from
|
|
299
|
-
* @param predicate - Asynchronous function that tests each node. Should return true for matching nodes
|
|
300
|
-
* @returns Promise that resolves to true if any node matches, false otherwise
|
|
301
|
-
*/
|
|
302
|
-
export function someNodeAsync(node, predicate, parent = null, path = []) {
|
|
303
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
304
|
-
// Check current node
|
|
305
|
-
if (yield predicate(node, parent, path)) {
|
|
306
|
-
return true;
|
|
307
|
-
}
|
|
308
|
-
// Recursively check children
|
|
309
|
-
if (hasChildren(node)) {
|
|
310
|
-
for (let index = 0; index < node.children.length; index++) {
|
|
311
|
-
const child = node.children[index];
|
|
312
|
-
if (yield someNodeAsync(child, predicate, node, [
|
|
313
|
-
...path,
|
|
314
|
-
'children',
|
|
315
|
-
index,
|
|
316
|
-
])) {
|
|
317
|
-
return true;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
return false;
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Check if every node in the Structured Text tree matches the predicate function.
|
|
326
|
-
* Returns false as soon as the first non-matching node is found (short-circuit evaluation).
|
|
327
|
-
*
|
|
328
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
329
|
-
* @param node - The root node to start testing from
|
|
330
|
-
* @param predicate - Synchronous function that tests each node. Should return true for valid nodes
|
|
331
|
-
* @returns True if all nodes match, false otherwise
|
|
332
|
-
*/
|
|
333
|
-
export function everyNode(node, predicate, parent = null, path = []) {
|
|
334
|
-
return !someNode(node, (currentNode, currentParent, currentPath) => {
|
|
335
|
-
return !predicate(currentNode, currentParent, currentPath);
|
|
336
|
-
}, parent, path);
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Check if every node in the Structured Text tree matches the predicate function.
|
|
340
|
-
* Returns false as soon as the first non-matching node is found (short-circuit evaluation).
|
|
341
|
-
*
|
|
342
|
-
* @template T - The type of nodes in the Structured Text tree
|
|
343
|
-
* @param node - The root node to start testing from
|
|
344
|
-
* @param predicate - Asynchronous function that tests each node. Should return true for valid nodes
|
|
345
|
-
* @returns Promise that resolves to true if all nodes match, false otherwise
|
|
346
|
-
*/
|
|
347
|
-
export function everyNodeAsync(node, predicate, parent = null, path = []) {
|
|
348
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
349
|
-
return !(yield someNodeAsync(node, (currentNode, currentParent, currentPath) => __awaiter(this, void 0, void 0, function* () {
|
|
350
|
-
return !(yield predicate(currentNode, currentParent, currentPath));
|
|
351
|
-
}), parent, path));
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
//# sourceMappingURL=structuredText.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"structuredText.js","sourceRoot":"","sources":["../../../src/utilities/structuredText.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;;;;;;;;;;AAqDH;;GAEG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,OAAO,CACL,OAAO,IAAI,KAAK,QAAQ;QACxB,IAAI,KAAK,IAAI;QACb,UAAU,IAAI,IAAI;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,IAAO,EACP,OAA+B,EAC/B,SAAmC,IAAI,EACvC,OAAiB,EAAE;IAEnB,qBAAqB;IACrB,OAAO,CAAC,IAAyB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;IAEjD,6BAA6B;IAC7B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;QACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACzD,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACnC,UAAU,CAAC,KAAU,EAAE,OAAO,EAAE,IAAyB,EAAE;gBACzD,GAAG,IAAI;gBACP,UAAU;gBACV,KAAK;aACN,CAAC,CAAC;SACJ;KACF;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAgB,eAAe,CACnC,IAAO,EACP,OAAwC,EACxC,SAAmC,IAAI,EACvC,OAAiB,EAAE;;QAEnB,qBAAqB;QACrB,MAAM,OAAO,CAAC,IAAyB,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAEvD,6BAA6B;QAC7B,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE;YACrB,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG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O,IAAI,CAAC;iBACb;aACF;SACF;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,IAAO,EACP,SAAoC,EACpC,SAAmC,IAAI,EACvC,OAAiB,EAAE;IAEnB,OAAO,CAAC,QAAQ,CACd,IAAI,EACJ,CACE,WAA8B,EAC9B,aAAuC,EACvC,WAAqB,EACrB,EAAE;QACF,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC,EACD,MAAM,EACN,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAgB,cAAc,CAClC,IAAO,EACP,SAA6C,EAC7C,SAAmC,IAAI,EACvC,OAAiB,EAAE;;QAEnB,OAAO,CAAC,CAAC,MAAM,aAAa,CAC1B,IAAI,EACJ,CACE,WAA8B,EAC9B,aAAuC,EACvC,WAAqB,EACrB,EAAE;YACF,OAAO,CAAC,CAAC,MAAM,SAAS,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;QACrE,CAAC,CAAA,EACD,MAAM,EACN,IAAI,CACL,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -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,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 {};
|