@datocms/cma-client 5.1.9 → 5.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +575 -0
- package/dist/cjs/fieldTypes/boolean.js +2 -2
- package/dist/cjs/fieldTypes/boolean.js.map +1 -1
- package/dist/cjs/fieldTypes/color.js +2 -2
- package/dist/cjs/fieldTypes/color.js.map +1 -1
- package/dist/cjs/fieldTypes/date.js +2 -3
- package/dist/cjs/fieldTypes/date.js.map +1 -1
- package/dist/cjs/fieldTypes/date_time.js +2 -2
- package/dist/cjs/fieldTypes/date_time.js.map +1 -1
- package/dist/cjs/fieldTypes/file.js +33 -5
- package/dist/cjs/fieldTypes/file.js.map +1 -1
- package/dist/cjs/fieldTypes/float.js +2 -2
- package/dist/cjs/fieldTypes/float.js.map +1 -1
- package/dist/cjs/fieldTypes/gallery.js +20 -5
- package/dist/cjs/fieldTypes/gallery.js.map +1 -1
- package/dist/cjs/fieldTypes/index.js +2 -2
- package/dist/cjs/fieldTypes/index.js.map +1 -1
- package/dist/cjs/fieldTypes/integer.js +2 -2
- package/dist/cjs/fieldTypes/integer.js.map +1 -1
- package/dist/cjs/fieldTypes/json.js +2 -3
- package/dist/cjs/fieldTypes/json.js.map +1 -1
- package/dist/cjs/fieldTypes/lat_lon.js +2 -2
- package/dist/cjs/fieldTypes/lat_lon.js.map +1 -1
- package/dist/cjs/fieldTypes/link.js +4 -4
- package/dist/cjs/fieldTypes/link.js.map +1 -1
- package/dist/cjs/fieldTypes/links.js +5 -3
- package/dist/cjs/fieldTypes/links.js.map +1 -1
- package/dist/cjs/fieldTypes/rich_text.js +4 -6
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/seo.js +2 -3
- package/dist/cjs/fieldTypes/seo.js.map +1 -1
- package/dist/cjs/fieldTypes/single_block.js +7 -7
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/slug.js +2 -3
- package/dist/cjs/fieldTypes/slug.js.map +1 -1
- package/dist/cjs/fieldTypes/string.js +2 -2
- package/dist/cjs/fieldTypes/string.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +4 -6
- package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
- package/dist/cjs/fieldTypes/text.js +2 -3
- package/dist/cjs/fieldTypes/text.js.map +1 -1
- package/dist/cjs/fieldTypes/video.js +2 -2
- package/dist/cjs/fieldTypes/video.js.map +1 -1
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/generated/Client.js.map +1 -1
- package/dist/cjs/generated/resources/Item.js.map +1 -1
- package/dist/cjs/generated/resources/Upload.js.map +1 -1
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js +8 -7
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/cjs/utilities/inspectItem.js +397 -0
- package/dist/cjs/utilities/inspectItem.js.map +1 -0
- package/dist/cjs/utilities/{blocks.js → nonRecursiveBlocks.js} +106 -111
- package/dist/cjs/utilities/nonRecursiveBlocks.js.map +1 -0
- package/dist/cjs/utilities/{fieldValue.js → normalizedFieldValues.js} +53 -41
- package/dist/cjs/utilities/normalizedFieldValues.js.map +1 -0
- package/dist/cjs/utilities/recursiveBlocks.js +121 -80
- package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
- package/dist/cjs/utilities/schemaRepository.js +2 -2
- package/dist/esm/fieldTypes/boolean.d.ts +1 -1
- package/dist/esm/fieldTypes/boolean.js +2 -2
- package/dist/esm/fieldTypes/boolean.js.map +1 -1
- package/dist/esm/fieldTypes/color.d.ts +1 -1
- package/dist/esm/fieldTypes/color.js +2 -2
- package/dist/esm/fieldTypes/color.js.map +1 -1
- package/dist/esm/fieldTypes/date.d.ts +1 -1
- package/dist/esm/fieldTypes/date.js +2 -3
- package/dist/esm/fieldTypes/date.js.map +1 -1
- package/dist/esm/fieldTypes/date_time.d.ts +1 -1
- package/dist/esm/fieldTypes/date_time.js +2 -2
- package/dist/esm/fieldTypes/date_time.js.map +1 -1
- package/dist/esm/fieldTypes/file.d.ts +68 -1
- package/dist/esm/fieldTypes/file.js +29 -3
- package/dist/esm/fieldTypes/file.js.map +1 -1
- package/dist/esm/fieldTypes/float.d.ts +1 -1
- package/dist/esm/fieldTypes/float.js +2 -2
- package/dist/esm/fieldTypes/float.js.map +1 -1
- package/dist/esm/fieldTypes/gallery.d.ts +27 -11
- package/dist/esm/fieldTypes/gallery.js +17 -4
- package/dist/esm/fieldTypes/gallery.js.map +1 -1
- package/dist/esm/fieldTypes/index.d.ts +2 -2
- package/dist/esm/fieldTypes/index.js +2 -2
- package/dist/esm/fieldTypes/index.js.map +1 -1
- package/dist/esm/fieldTypes/integer.d.ts +1 -1
- package/dist/esm/fieldTypes/integer.js +2 -2
- package/dist/esm/fieldTypes/integer.js.map +1 -1
- package/dist/esm/fieldTypes/json.d.ts +1 -1
- package/dist/esm/fieldTypes/json.js +2 -3
- package/dist/esm/fieldTypes/json.js.map +1 -1
- package/dist/esm/fieldTypes/lat_lon.d.ts +1 -1
- package/dist/esm/fieldTypes/lat_lon.js +2 -2
- package/dist/esm/fieldTypes/lat_lon.js.map +1 -1
- package/dist/esm/fieldTypes/link.d.ts +1 -1
- package/dist/esm/fieldTypes/link.js +4 -4
- package/dist/esm/fieldTypes/link.js.map +1 -1
- package/dist/esm/fieldTypes/links.d.ts +1 -1
- package/dist/esm/fieldTypes/links.js +5 -3
- package/dist/esm/fieldTypes/links.js.map +1 -1
- package/dist/esm/fieldTypes/rich_text.d.ts +1 -1
- package/dist/esm/fieldTypes/rich_text.js +4 -6
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/seo.d.ts +1 -1
- package/dist/esm/fieldTypes/seo.js +2 -3
- package/dist/esm/fieldTypes/seo.js.map +1 -1
- package/dist/esm/fieldTypes/single_block.d.ts +3 -3
- package/dist/esm/fieldTypes/single_block.js +7 -7
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/slug.d.ts +1 -1
- package/dist/esm/fieldTypes/slug.js +2 -3
- package/dist/esm/fieldTypes/slug.js.map +1 -1
- package/dist/esm/fieldTypes/string.d.ts +1 -1
- package/dist/esm/fieldTypes/string.js +2 -2
- package/dist/esm/fieldTypes/string.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +1 -1
- package/dist/esm/fieldTypes/structured_text.js +4 -6
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/fieldTypes/text.d.ts +1 -1
- package/dist/esm/fieldTypes/text.js +2 -3
- package/dist/esm/fieldTypes/text.js.map +1 -1
- package/dist/esm/fieldTypes/video.d.ts +1 -1
- package/dist/esm/fieldTypes/video.js +2 -2
- package/dist/esm/fieldTypes/video.js.map +1 -1
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/generated/Client.js.map +1 -1
- package/dist/esm/generated/resources/Item.d.ts +46 -28
- package/dist/esm/generated/resources/Item.js.map +1 -1
- package/dist/esm/generated/resources/ScheduledPublication.d.ts +3 -3
- package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +3 -3
- package/dist/esm/generated/resources/Upload.d.ts +10 -4
- package/dist/esm/generated/resources/Upload.js.map +1 -1
- package/dist/esm/index.d.ts +4 -4
- package/dist/esm/index.js +4 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utilities/buildBlockRecord.d.ts +3 -3
- package/dist/esm/utilities/buildBlockRecord.js +9 -8
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/dist/esm/utilities/inspectItem.d.ts +8 -0
- package/dist/esm/utilities/inspectItem.js +393 -0
- package/dist/esm/utilities/inspectItem.js.map +1 -0
- package/dist/esm/utilities/itemDefinition.d.ts +36 -12
- package/dist/esm/utilities/nonRecursiveBlocks.d.ts +179 -0
- package/dist/esm/utilities/{blocks.js → nonRecursiveBlocks.js} +91 -96
- package/dist/esm/utilities/nonRecursiveBlocks.js.map +1 -0
- package/dist/{types/utilities/fieldValue.d.ts → esm/utilities/normalizedFieldValues.d.ts} +15 -14
- package/dist/esm/utilities/{fieldValue.js → normalizedFieldValues.js} +39 -28
- package/dist/esm/utilities/normalizedFieldValues.js.map +1 -0
- package/dist/esm/utilities/recursiveBlocks.d.ts +92 -9
- package/dist/esm/utilities/recursiveBlocks.js +113 -72
- package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
- package/dist/esm/utilities/schemaRepository.d.ts +2 -2
- package/dist/esm/utilities/schemaRepository.js +2 -2
- package/dist/types/fieldTypes/boolean.d.ts +1 -1
- package/dist/types/fieldTypes/color.d.ts +1 -1
- package/dist/types/fieldTypes/date.d.ts +1 -1
- package/dist/types/fieldTypes/date_time.d.ts +1 -1
- package/dist/types/fieldTypes/file.d.ts +68 -1
- package/dist/types/fieldTypes/float.d.ts +1 -1
- package/dist/types/fieldTypes/gallery.d.ts +27 -11
- package/dist/types/fieldTypes/index.d.ts +2 -2
- package/dist/types/fieldTypes/integer.d.ts +1 -1
- package/dist/types/fieldTypes/json.d.ts +1 -1
- package/dist/types/fieldTypes/lat_lon.d.ts +1 -1
- package/dist/types/fieldTypes/link.d.ts +1 -1
- package/dist/types/fieldTypes/links.d.ts +1 -1
- package/dist/types/fieldTypes/rich_text.d.ts +1 -1
- package/dist/types/fieldTypes/seo.d.ts +1 -1
- package/dist/types/fieldTypes/single_block.d.ts +3 -3
- package/dist/types/fieldTypes/slug.d.ts +1 -1
- package/dist/types/fieldTypes/string.d.ts +1 -1
- package/dist/types/fieldTypes/structured_text.d.ts +1 -1
- package/dist/types/fieldTypes/text.d.ts +1 -1
- package/dist/types/fieldTypes/video.d.ts +1 -1
- package/dist/types/generated/resources/Item.d.ts +46 -28
- package/dist/types/generated/resources/ScheduledPublication.d.ts +3 -3
- package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +3 -3
- package/dist/types/generated/resources/Upload.d.ts +10 -4
- package/dist/types/index.d.ts +4 -4
- package/dist/types/utilities/buildBlockRecord.d.ts +3 -3
- package/dist/types/utilities/inspectItem.d.ts +8 -0
- package/dist/types/utilities/itemDefinition.d.ts +36 -12
- package/dist/types/utilities/nonRecursiveBlocks.d.ts +179 -0
- package/dist/{esm/utilities/fieldValue.d.ts → types/utilities/normalizedFieldValues.d.ts} +15 -14
- package/dist/types/utilities/recursiveBlocks.d.ts +92 -9
- package/dist/types/utilities/schemaRepository.d.ts +2 -2
- package/package.json +4 -4
- package/src/fieldTypes/boolean.ts +5 -3
- package/src/fieldTypes/color.ts +5 -3
- package/src/fieldTypes/date.ts +5 -4
- package/src/fieldTypes/date_time.ts +5 -3
- package/src/fieldTypes/file.ts +98 -4
- package/src/fieldTypes/float.ts +5 -3
- package/src/fieldTypes/gallery.ts +53 -20
- package/src/fieldTypes/index.ts +2 -3
- package/src/fieldTypes/integer.ts +5 -3
- package/src/fieldTypes/json.ts +5 -4
- package/src/fieldTypes/lat_lon.ts +5 -3
- package/src/fieldTypes/link.ts +7 -5
- package/src/fieldTypes/links.ts +8 -4
- package/src/fieldTypes/rich_text.ts +7 -7
- package/src/fieldTypes/seo.ts +5 -4
- package/src/fieldTypes/single_block.ts +12 -10
- package/src/fieldTypes/slug.ts +5 -4
- package/src/fieldTypes/string.ts +5 -3
- package/src/fieldTypes/structured_text.ts +7 -7
- package/src/fieldTypes/text.ts +5 -4
- package/src/fieldTypes/video.ts +5 -3
- package/src/generated/Client.ts +1 -1
- package/src/generated/resources/Item.ts +129 -92
- package/src/generated/resources/ScheduledPublication.ts +6 -6
- package/src/generated/resources/ScheduledUnpublishing.ts +6 -6
- package/src/generated/resources/Upload.ts +36 -10
- package/src/index.ts +4 -4
- package/src/utilities/buildBlockRecord.ts +24 -31
- package/src/utilities/inspectItem.ts +590 -0
- package/src/utilities/itemDefinition.ts +53 -35
- package/src/utilities/{blocks.ts → nonRecursiveBlocks.ts} +170 -136
- package/src/utilities/{fieldValue.ts → normalizedFieldValues.ts} +70 -30
- package/src/utilities/recursiveBlocks.ts +186 -171
- package/src/utilities/schemaRepository.ts +2 -2
- package/dist/cjs/utilities/blocks.js.map +0 -1
- package/dist/cjs/utilities/fieldValue.js.map +0 -1
- package/dist/esm/utilities/blocks.d.ts +0 -180
- package/dist/esm/utilities/blocks.js.map +0 -1
- package/dist/esm/utilities/fieldValue.js.map +0 -1
- package/dist/types/utilities/blocks.d.ts +0 -180
|
@@ -50,13 +50,13 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
50
50
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
51
51
|
};
|
|
52
52
|
import { collectNodes, collectNodesAsync, filterNodes, filterNodesAsync, mapNodes, mapNodesAsync, } from 'datocms-structured-text-utils';
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
import { isLocalizedFieldValue } from './normalizedFieldValues';
|
|
54
|
+
function* iterateBlocks(fieldType, nonLocalizedFieldValue) {
|
|
55
|
+
if (isLocalizedFieldValue(nonLocalizedFieldValue)) {
|
|
56
|
+
throw new Error('A non-localized field value is required!');
|
|
57
|
+
}
|
|
58
58
|
if (fieldType === 'rich_text') {
|
|
59
|
-
const richTextValue =
|
|
59
|
+
const richTextValue = nonLocalizedFieldValue;
|
|
60
60
|
if (richTextValue) {
|
|
61
61
|
for (let index = 0; index < richTextValue.length; index++) {
|
|
62
62
|
const item = richTextValue[index];
|
|
@@ -66,14 +66,14 @@ function* iterateBlocks(field, value) {
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
if (fieldType === 'single_block') {
|
|
69
|
-
const singleBlockValue =
|
|
69
|
+
const singleBlockValue = nonLocalizedFieldValue;
|
|
70
70
|
if (singleBlockValue) {
|
|
71
71
|
yield { item: singleBlockValue, path: [] };
|
|
72
72
|
}
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
if (fieldType === 'structured_text') {
|
|
76
|
-
const structuredTextValue =
|
|
76
|
+
const structuredTextValue = nonLocalizedFieldValue;
|
|
77
77
|
if (structuredTextValue) {
|
|
78
78
|
const foundNodes = collectNodes(structuredTextValue.document, (node) => node.type === 'block' || node.type === 'inlineBlock');
|
|
79
79
|
for (const { node, path } of foundNodes) {
|
|
@@ -85,11 +85,10 @@ function* iterateBlocks(field, value) {
|
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function iterateBlocksAsync(
|
|
88
|
+
function iterateBlocksAsync(fieldType, nonLocalizedFieldValue) {
|
|
89
89
|
return __asyncGenerator(this, arguments, function* iterateBlocksAsync_1() {
|
|
90
|
-
const fieldType = getFieldType(field);
|
|
91
90
|
if (fieldType === 'rich_text') {
|
|
92
|
-
const richTextValue =
|
|
91
|
+
const richTextValue = nonLocalizedFieldValue;
|
|
93
92
|
if (richTextValue) {
|
|
94
93
|
for (let index = 0; index < richTextValue.length; index++) {
|
|
95
94
|
const item = richTextValue[index];
|
|
@@ -99,14 +98,14 @@ function iterateBlocksAsync(field, value) {
|
|
|
99
98
|
return yield __await(void 0);
|
|
100
99
|
}
|
|
101
100
|
if (fieldType === 'single_block') {
|
|
102
|
-
const singleBlockValue =
|
|
101
|
+
const singleBlockValue = nonLocalizedFieldValue;
|
|
103
102
|
if (singleBlockValue) {
|
|
104
103
|
yield yield __await({ item: singleBlockValue, path: [] });
|
|
105
104
|
}
|
|
106
105
|
return yield __await(void 0);
|
|
107
106
|
}
|
|
108
107
|
if (fieldType === 'structured_text') {
|
|
109
|
-
const structuredTextValue =
|
|
108
|
+
const structuredTextValue = nonLocalizedFieldValue;
|
|
110
109
|
if (structuredTextValue) {
|
|
111
110
|
const foundNodes = yield __await(collectNodesAsync(structuredTextValue.document, (node) => __awaiter(this, void 0, void 0, function* () { return node.type === 'block' || node.type === 'inlineBlock'; })));
|
|
112
111
|
for (const { node, path } of foundNodes) {
|
|
@@ -123,12 +122,12 @@ function iterateBlocksAsync(field, value) {
|
|
|
123
122
|
* Visit every block in a field value, calling the visitor function for each block found.
|
|
124
123
|
* Supports rich text, single block, and structured text field types.
|
|
125
124
|
*
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
125
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
126
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to visit
|
|
128
127
|
* @param visitor - Synchronous function called for each block. Receives the block item and its path
|
|
129
128
|
*/
|
|
130
|
-
export function
|
|
131
|
-
for (const { item, path } of iterateBlocks(
|
|
129
|
+
export function nonRecursiveVisitBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, visitor) {
|
|
130
|
+
for (const { item, path } of iterateBlocks(fieldType, nonLocalizedFieldValue)) {
|
|
132
131
|
visitor(item, path);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
@@ -136,16 +135,16 @@ export function nonRecursiveVisitBlocksInFieldValue(field, value, visitor) {
|
|
|
136
135
|
* Visit every block in a field value, calling the visitor function for each block found.
|
|
137
136
|
* Supports rich text, single block, and structured text field types.
|
|
138
137
|
*
|
|
139
|
-
* @param
|
|
140
|
-
* @param
|
|
138
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
139
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to visit
|
|
141
140
|
* @param visitor - Asynchronous function called for each block. Receives the block item and its path
|
|
142
141
|
* @returns Promise that resolves when all blocks have been visited
|
|
143
142
|
*/
|
|
144
|
-
export function
|
|
143
|
+
export function nonRecursiveVisitBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, visitor) {
|
|
145
144
|
var _a, e_1, _b, _c;
|
|
146
145
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
146
|
try {
|
|
148
|
-
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(
|
|
147
|
+
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(fieldType, nonLocalizedFieldValue)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
149
148
|
_c = _f.value;
|
|
150
149
|
_d = false;
|
|
151
150
|
try {
|
|
@@ -171,25 +170,24 @@ export function nonRecursiveVisitBlocksInFieldValueAsync(field, value, visitor)
|
|
|
171
170
|
* Creates a new field value structure with transformed blocks while preserving the original structure.
|
|
172
171
|
* Supports rich text, single block, and structured text field types.
|
|
173
172
|
*
|
|
174
|
-
* @param
|
|
175
|
-
* @param
|
|
173
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
174
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to transform
|
|
176
175
|
* @param mapper - Synchronous function that transforms each block. Receives block item and path, returns new block
|
|
177
176
|
* @returns The new field value with transformed blocks
|
|
178
177
|
*/
|
|
179
|
-
export function
|
|
180
|
-
const fieldType = getFieldType(field);
|
|
178
|
+
export function nonRecursiveMapBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, mapper) {
|
|
181
179
|
if (fieldType === 'rich_text') {
|
|
182
|
-
const richTextValue =
|
|
180
|
+
const richTextValue = nonLocalizedFieldValue;
|
|
183
181
|
return richTextValue
|
|
184
182
|
? richTextValue.map((item, index) => mapper(item, [index]))
|
|
185
183
|
: richTextValue;
|
|
186
184
|
}
|
|
187
185
|
if (fieldType === 'single_block') {
|
|
188
|
-
const singleBlockValue =
|
|
186
|
+
const singleBlockValue = nonLocalizedFieldValue;
|
|
189
187
|
return singleBlockValue ? mapper(singleBlockValue, []) : null;
|
|
190
188
|
}
|
|
191
189
|
if (fieldType === 'structured_text') {
|
|
192
|
-
const structuredTextValue =
|
|
190
|
+
const structuredTextValue = nonLocalizedFieldValue;
|
|
193
191
|
if (!structuredTextValue) {
|
|
194
192
|
return null;
|
|
195
193
|
}
|
|
@@ -203,33 +201,32 @@ export function nonRecursiveMapBlocksInFieldValue(field, value, mapper) {
|
|
|
203
201
|
}),
|
|
204
202
|
};
|
|
205
203
|
}
|
|
206
|
-
return
|
|
204
|
+
return nonLocalizedFieldValue;
|
|
207
205
|
}
|
|
208
206
|
/**
|
|
209
207
|
* Transform blocks in a field value by applying a mapping function to each block.
|
|
210
208
|
* Creates a new field value structure with transformed blocks while preserving the original structure.
|
|
211
209
|
* Supports rich text, single block, and structured text field types.
|
|
212
210
|
*
|
|
213
|
-
* @param
|
|
214
|
-
* @param
|
|
211
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
212
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to transform
|
|
215
213
|
* @param mapper - Asynchronous function that transforms each block. Receives block item and path, returns new block
|
|
216
214
|
* @returns Promise that resolves to the new field value with transformed blocks
|
|
217
215
|
*/
|
|
218
|
-
export function
|
|
216
|
+
export function nonRecursiveMapBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, mapper) {
|
|
219
217
|
return __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
const fieldType = getFieldType(field);
|
|
221
218
|
if (fieldType === 'rich_text') {
|
|
222
|
-
const richTextValue =
|
|
219
|
+
const richTextValue = nonLocalizedFieldValue;
|
|
223
220
|
return richTextValue
|
|
224
221
|
? yield Promise.all(richTextValue.map((item, index) => mapper(item, [index])))
|
|
225
222
|
: richTextValue;
|
|
226
223
|
}
|
|
227
224
|
if (fieldType === 'single_block') {
|
|
228
|
-
const singleBlockValue =
|
|
225
|
+
const singleBlockValue = nonLocalizedFieldValue;
|
|
229
226
|
return singleBlockValue ? yield mapper(singleBlockValue, []) : null;
|
|
230
227
|
}
|
|
231
228
|
if (fieldType === 'structured_text') {
|
|
232
|
-
const structuredTextValue =
|
|
229
|
+
const structuredTextValue = nonLocalizedFieldValue;
|
|
233
230
|
if (!structuredTextValue) {
|
|
234
231
|
return null;
|
|
235
232
|
}
|
|
@@ -243,21 +240,21 @@ export function nonRecursiveMapBlocksInFieldValueAsync(field, value, mapper) {
|
|
|
243
240
|
})),
|
|
244
241
|
};
|
|
245
242
|
}
|
|
246
|
-
return
|
|
243
|
+
return nonLocalizedFieldValue;
|
|
247
244
|
});
|
|
248
245
|
}
|
|
249
246
|
/**
|
|
250
247
|
* Find all blocks that match the predicate function.
|
|
251
|
-
* Searches through all blocks in the field value and returns all matches.
|
|
248
|
+
* Searches through all blocks in the non-localized field value and returns all matches.
|
|
252
249
|
*
|
|
253
|
-
* @param
|
|
254
|
-
* @param
|
|
250
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
251
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to search
|
|
255
252
|
* @param predicate - Synchronous function that tests each block. Should return true for matching blocks
|
|
256
253
|
* @returns Array of objects, each containing a matching block and its path
|
|
257
254
|
*/
|
|
258
|
-
export function
|
|
255
|
+
export function nonRecursiveFindAllBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, predicate) {
|
|
259
256
|
const results = [];
|
|
260
|
-
for (const { item, path } of iterateBlocks(
|
|
257
|
+
for (const { item, path } of iterateBlocks(fieldType, nonLocalizedFieldValue)) {
|
|
261
258
|
if (predicate(item, path)) {
|
|
262
259
|
results.push({ item, path });
|
|
263
260
|
}
|
|
@@ -266,19 +263,19 @@ export function nonRecursiveFindAllBlocksInFieldValue(field, value, predicate) {
|
|
|
266
263
|
}
|
|
267
264
|
/**
|
|
268
265
|
* Find all blocks that match the predicate function.
|
|
269
|
-
* Searches through all blocks in the field value and returns all matches.
|
|
266
|
+
* Searches through all blocks in the non-localized field value and returns all matches.
|
|
270
267
|
*
|
|
271
|
-
* @param
|
|
272
|
-
* @param
|
|
268
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
269
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to search
|
|
273
270
|
* @param predicate - Asynchronous function that tests each block. Should return true for matching blocks
|
|
274
271
|
* @returns Promise that resolves to an array of objects, each containing a matching block and its path
|
|
275
272
|
*/
|
|
276
|
-
export function
|
|
273
|
+
export function nonRecursiveFindAllBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, predicate) {
|
|
277
274
|
var _a, e_2, _b, _c;
|
|
278
275
|
return __awaiter(this, void 0, void 0, function* () {
|
|
279
276
|
const results = [];
|
|
280
277
|
try {
|
|
281
|
-
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(
|
|
278
|
+
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(fieldType, nonLocalizedFieldValue)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
282
279
|
_c = _f.value;
|
|
283
280
|
_d = false;
|
|
284
281
|
try {
|
|
@@ -307,24 +304,23 @@ export function nonRecursiveFindAllBlocksInFieldValueAsync(field, value, predica
|
|
|
307
304
|
* Creates a new field value containing only blocks that pass the predicate test.
|
|
308
305
|
* Preserves the original field value structure and hierarchy.
|
|
309
306
|
*
|
|
310
|
-
* @param
|
|
311
|
-
* @param
|
|
307
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
308
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to filter
|
|
312
309
|
* @param predicate - Synchronous function that tests each block. Blocks returning false are removed
|
|
313
310
|
* @returns The new field value with filtered blocks
|
|
314
311
|
*/
|
|
315
|
-
export function
|
|
316
|
-
const fieldType = getFieldType(field);
|
|
312
|
+
export function nonRecursiveFilterBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, predicate) {
|
|
317
313
|
if (fieldType === 'rich_text') {
|
|
318
314
|
const filteredItems = [];
|
|
319
|
-
for (const { item, path } of iterateBlocks(
|
|
315
|
+
for (const { item, path } of iterateBlocks(fieldType, nonLocalizedFieldValue)) {
|
|
320
316
|
if (predicate(item, path)) {
|
|
321
317
|
filteredItems.push(item);
|
|
322
318
|
}
|
|
323
319
|
}
|
|
324
|
-
return
|
|
320
|
+
return filteredItems;
|
|
325
321
|
}
|
|
326
322
|
if (fieldType === 'single_block') {
|
|
327
|
-
for (const { item, path } of iterateBlocks(
|
|
323
|
+
for (const { item, path } of iterateBlocks(fieldType, nonLocalizedFieldValue)) {
|
|
328
324
|
if (predicate(item, path)) {
|
|
329
325
|
return item;
|
|
330
326
|
}
|
|
@@ -332,7 +328,7 @@ export function nonRecursiveFilterBlocksInFieldValue(field, value, predicate) {
|
|
|
332
328
|
return null;
|
|
333
329
|
}
|
|
334
330
|
if (fieldType === 'structured_text') {
|
|
335
|
-
const structuredTextValue =
|
|
331
|
+
const structuredTextValue = nonLocalizedFieldValue;
|
|
336
332
|
if (!structuredTextValue) {
|
|
337
333
|
return null;
|
|
338
334
|
}
|
|
@@ -349,26 +345,25 @@ export function nonRecursiveFilterBlocksInFieldValue(field, value, predicate) {
|
|
|
349
345
|
}
|
|
350
346
|
: null;
|
|
351
347
|
}
|
|
352
|
-
return
|
|
348
|
+
return nonLocalizedFieldValue;
|
|
353
349
|
}
|
|
354
350
|
/**
|
|
355
351
|
* Filter blocks in a field value, removing those that don't match the predicate.
|
|
356
352
|
* Creates a new field value containing only blocks that pass the predicate test.
|
|
357
353
|
* Preserves the original field value structure and hierarchy.
|
|
358
354
|
*
|
|
359
|
-
* @param
|
|
360
|
-
* @param
|
|
355
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
356
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to filter
|
|
361
357
|
* @param predicate - Asynchronous function that tests each block. Blocks returning false are removed
|
|
362
358
|
* @returns Promise that resolves to the new field value with filtered blocks
|
|
363
359
|
*/
|
|
364
|
-
export function
|
|
360
|
+
export function nonRecursiveFilterBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, predicate) {
|
|
365
361
|
var _a, e_3, _b, _c, _d, e_4, _e, _f;
|
|
366
362
|
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
-
const fieldType = getFieldType(field);
|
|
368
363
|
if (fieldType === 'rich_text') {
|
|
369
364
|
const filteredItems = [];
|
|
370
365
|
try {
|
|
371
|
-
for (var _g = true, _h = __asyncValues(iterateBlocksAsync(
|
|
366
|
+
for (var _g = true, _h = __asyncValues(iterateBlocksAsync(fieldType, nonLocalizedFieldValue)), _j; _j = yield _h.next(), _a = _j.done, !_a;) {
|
|
372
367
|
_c = _j.value;
|
|
373
368
|
_g = false;
|
|
374
369
|
try {
|
|
@@ -389,11 +384,11 @@ export function nonRecursiveFilterBlocksInFieldValueAsync(field, value, predicat
|
|
|
389
384
|
}
|
|
390
385
|
finally { if (e_3) throw e_3.error; }
|
|
391
386
|
}
|
|
392
|
-
return
|
|
387
|
+
return filteredItems;
|
|
393
388
|
}
|
|
394
389
|
if (fieldType === 'single_block') {
|
|
395
390
|
try {
|
|
396
|
-
for (var _k = true, _l = __asyncValues(iterateBlocksAsync(
|
|
391
|
+
for (var _k = true, _l = __asyncValues(iterateBlocksAsync(fieldType, nonLocalizedFieldValue)), _m; _m = yield _l.next(), _d = _m.done, !_d;) {
|
|
397
392
|
_f = _m.value;
|
|
398
393
|
_k = false;
|
|
399
394
|
try {
|
|
@@ -417,7 +412,7 @@ export function nonRecursiveFilterBlocksInFieldValueAsync(field, value, predicat
|
|
|
417
412
|
return null;
|
|
418
413
|
}
|
|
419
414
|
if (fieldType === 'structured_text') {
|
|
420
|
-
const structuredTextValue =
|
|
415
|
+
const structuredTextValue = nonLocalizedFieldValue;
|
|
421
416
|
if (!structuredTextValue) {
|
|
422
417
|
return null;
|
|
423
418
|
}
|
|
@@ -434,44 +429,44 @@ export function nonRecursiveFilterBlocksInFieldValueAsync(field, value, predicat
|
|
|
434
429
|
}
|
|
435
430
|
: null;
|
|
436
431
|
}
|
|
437
|
-
return
|
|
432
|
+
return nonLocalizedFieldValue;
|
|
438
433
|
});
|
|
439
434
|
}
|
|
440
435
|
/**
|
|
441
436
|
* Reduce all blocks in a field value to a single value by applying a reducer function.
|
|
442
|
-
* Processes each block in the field value and accumulates the results into a single value.
|
|
437
|
+
* Processes each block in the non-localized field value and accumulates the results into a single value.
|
|
443
438
|
*
|
|
444
439
|
* @template R - The type of the accumulated result
|
|
445
|
-
* @param
|
|
446
|
-
* @param
|
|
440
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
441
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to reduce
|
|
447
442
|
* @param reducer - Synchronous function that processes each block and updates the accumulator
|
|
448
443
|
* @param initialValue - The initial value for the accumulator
|
|
449
444
|
* @returns The final accumulated value
|
|
450
445
|
*/
|
|
451
|
-
export function
|
|
446
|
+
export function nonRecursiveReduceBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, reducer, initialValue) {
|
|
452
447
|
let accumulator = initialValue;
|
|
453
|
-
for (const { item, path } of iterateBlocks(
|
|
448
|
+
for (const { item, path } of iterateBlocks(fieldType, nonLocalizedFieldValue)) {
|
|
454
449
|
accumulator = reducer(accumulator, item, path);
|
|
455
450
|
}
|
|
456
451
|
return accumulator;
|
|
457
452
|
}
|
|
458
453
|
/**
|
|
459
454
|
* Reduce all blocks in a field value to a single value by applying a reducer function.
|
|
460
|
-
* Processes each block in the field value and accumulates the results into a single value.
|
|
455
|
+
* Processes each block in the non-localized field value and accumulates the results into a single value.
|
|
461
456
|
*
|
|
462
457
|
* @template R - The type of the accumulated result
|
|
463
|
-
* @param
|
|
464
|
-
* @param
|
|
458
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
459
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to reduce
|
|
465
460
|
* @param reducer - Asynchronous function that processes each block and updates the accumulator
|
|
466
461
|
* @param initialValue - The initial value for the accumulator
|
|
467
462
|
* @returns Promise that resolves to the final accumulated value
|
|
468
463
|
*/
|
|
469
|
-
export function
|
|
464
|
+
export function nonRecursiveReduceBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, reducer, initialValue) {
|
|
470
465
|
var _a, e_5, _b, _c;
|
|
471
466
|
return __awaiter(this, void 0, void 0, function* () {
|
|
472
467
|
let accumulator = initialValue;
|
|
473
468
|
try {
|
|
474
|
-
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(
|
|
469
|
+
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(fieldType, nonLocalizedFieldValue)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
475
470
|
_c = _f.value;
|
|
476
471
|
_d = false;
|
|
477
472
|
try {
|
|
@@ -494,16 +489,16 @@ export function nonRecursiveReduceBlocksInFieldValueAsync(field, value, reducer,
|
|
|
494
489
|
});
|
|
495
490
|
}
|
|
496
491
|
/**
|
|
497
|
-
* Check if any block in the field value matches the predicate function.
|
|
492
|
+
* Check if any block in the non-localized field value matches the predicate function.
|
|
498
493
|
* Returns true as soon as the first matching block is found (short-circuit evaluation).
|
|
499
494
|
*
|
|
500
|
-
* @param
|
|
501
|
-
* @param
|
|
495
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
496
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
|
|
502
497
|
* @param predicate - Synchronous function that tests each block. Should return true for matching blocks
|
|
503
498
|
* @returns True if any block matches, false otherwise
|
|
504
499
|
*/
|
|
505
|
-
export function
|
|
506
|
-
for (const { item, path } of iterateBlocks(
|
|
500
|
+
export function nonRecursiveSomeBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, predicate) {
|
|
501
|
+
for (const { item, path } of iterateBlocks(fieldType, nonLocalizedFieldValue)) {
|
|
507
502
|
if (predicate(item, path)) {
|
|
508
503
|
return true;
|
|
509
504
|
}
|
|
@@ -511,19 +506,19 @@ export function nonRecursiveSomeBlocksInFieldValue(field, value, predicate) {
|
|
|
511
506
|
return false;
|
|
512
507
|
}
|
|
513
508
|
/**
|
|
514
|
-
* Check if any block in the field value matches the predicate function.
|
|
509
|
+
* Check if any block in the non-localized field value matches the predicate function.
|
|
515
510
|
* Returns true as soon as the first matching block is found (short-circuit evaluation).
|
|
516
511
|
*
|
|
517
|
-
* @param
|
|
518
|
-
* @param
|
|
512
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
513
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
|
|
519
514
|
* @param predicate - Asynchronous function that tests each block. Should return true for matching blocks
|
|
520
515
|
* @returns Promise that resolves to true if any block matches, false otherwise
|
|
521
516
|
*/
|
|
522
|
-
export function
|
|
517
|
+
export function nonRecursiveSomeBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, predicate) {
|
|
523
518
|
var _a, e_6, _b, _c;
|
|
524
519
|
return __awaiter(this, void 0, void 0, function* () {
|
|
525
520
|
try {
|
|
526
|
-
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(
|
|
521
|
+
for (var _d = true, _e = __asyncValues(iterateBlocksAsync(fieldType, nonLocalizedFieldValue)), _f; _f = yield _e.next(), _a = _f.done, !_a;) {
|
|
527
522
|
_c = _f.value;
|
|
528
523
|
_d = false;
|
|
529
524
|
try {
|
|
@@ -548,33 +543,33 @@ export function nonRecursiveSomeBlocksInFieldValueAsync(field, value, predicate)
|
|
|
548
543
|
});
|
|
549
544
|
}
|
|
550
545
|
/**
|
|
551
|
-
* Check if every block in the field value matches the predicate function.
|
|
546
|
+
* Check if every block in the non-localized field value matches the predicate function.
|
|
552
547
|
* Returns false as soon as the first non-matching block is found (short-circuit evaluation).
|
|
553
548
|
*
|
|
554
|
-
* @param
|
|
555
|
-
* @param
|
|
549
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
550
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
|
|
556
551
|
* @param predicate - Synchronous function that tests each block. Should return true for valid blocks
|
|
557
552
|
* @returns True if all blocks match, false otherwise
|
|
558
553
|
*/
|
|
559
|
-
export function
|
|
560
|
-
return !
|
|
554
|
+
export function nonRecursiveEveryBlockInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, predicate) {
|
|
555
|
+
return !nonRecursiveSomeBlocksInNonLocalizedFieldValue(fieldType, nonLocalizedFieldValue, (item, path) => {
|
|
561
556
|
return !predicate(item, path);
|
|
562
557
|
});
|
|
563
558
|
}
|
|
564
559
|
/**
|
|
565
|
-
* Check if every block in the field value matches the predicate function.
|
|
560
|
+
* Check if every block in the non-localized field value matches the predicate function.
|
|
566
561
|
* Returns false as soon as the first non-matching block is found (short-circuit evaluation).
|
|
567
562
|
*
|
|
568
|
-
* @param
|
|
569
|
-
* @param
|
|
563
|
+
* @param fieldType - The type of DatoCMS field definition that determines how the value is processed
|
|
564
|
+
* @param nonLocalizedFieldValue - The non-localized field value containing blocks to test
|
|
570
565
|
* @param predicate - Asynchronous function that tests each block. Should return true for valid blocks
|
|
571
566
|
* @returns Promise that resolves to true if all blocks match, false otherwise
|
|
572
567
|
*/
|
|
573
|
-
export function
|
|
568
|
+
export function nonRecursiveEveryBlockInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, predicate) {
|
|
574
569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
575
|
-
return !(yield
|
|
570
|
+
return !(yield nonRecursiveSomeBlocksInNonLocalizedFieldValueAsync(fieldType, nonLocalizedFieldValue, (item, path) => __awaiter(this, void 0, void 0, function* () {
|
|
576
571
|
return !(yield predicate(item, path));
|
|
577
572
|
})));
|
|
578
573
|
});
|
|
579
574
|
}
|
|
580
|
-
//# sourceMappingURL=
|
|
575
|
+
//# sourceMappingURL=nonRecursiveBlocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonRecursiveBlocks.js","sourceRoot":"","sources":["../../../src/utilities/nonRecursiveBlocks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,OAAO,EAEL,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAChB,QAAQ,EACR,aAAa,GACd,MAAM,+BAA+B,CAAC;AAcvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAehE,QAAQ,CAAC,CAAC,aAAa,CACrB,SAA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,CAAA,CACF,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -18,6 +18,7 @@ export type LocalizedFieldValue<T = unknown, L extends string = string> = Partia
|
|
|
18
18
|
* @returns true if the field is localized, false otherwise
|
|
19
19
|
*/
|
|
20
20
|
export declare function isLocalized(field: RawApiTypes.Field | ApiTypes.Field): boolean;
|
|
21
|
+
export declare function isLocalizedFieldValue<T = unknown, L extends string = string>(value: unknown): value is LocalizedFieldValue<T, L>;
|
|
21
22
|
/**
|
|
22
23
|
* A normalized entry that represents a single value from either a localized or non-localized field.
|
|
23
24
|
*
|
|
@@ -26,7 +27,7 @@ export declare function isLocalized(field: RawApiTypes.Field | ApiTypes.Field):
|
|
|
26
27
|
*
|
|
27
28
|
* This uniform structure allows the same processing logic to work with both field types.
|
|
28
29
|
*/
|
|
29
|
-
export type
|
|
30
|
+
export type NormalizedFieldValueEntry<T = unknown, L extends string = string> = {
|
|
30
31
|
locale: L | undefined;
|
|
31
32
|
value: T;
|
|
32
33
|
};
|
|
@@ -40,11 +41,11 @@ export type FieldValueEntry<T = unknown, L extends string = string> = {
|
|
|
40
41
|
* @param value - The field value to convert (either a localized object or direct value)
|
|
41
42
|
* @returns Array of entries where each entry contains a locale (string for localized, undefined for non-localized) and the corresponding value
|
|
42
43
|
*/
|
|
43
|
-
export declare function
|
|
44
|
+
export declare function toNormalizedFieldValueEntries<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>): NormalizedFieldValueEntry<T, L>[];
|
|
44
45
|
/**
|
|
45
46
|
* Converts an array of possibly localized entries back into the appropriate field value format.
|
|
46
47
|
*
|
|
47
|
-
* This function is the inverse of `
|
|
48
|
+
* This function is the inverse of `toNormalizedFieldValueEntries`. It takes a uniform
|
|
48
49
|
* array of entries and converts them back to either a localized object or a direct value,
|
|
49
50
|
* depending on the field's localization setting.
|
|
50
51
|
*
|
|
@@ -52,7 +53,7 @@ export declare function fieldValueToEntries<T = unknown, L extends string = stri
|
|
|
52
53
|
* @param entries - Array of entries to convert back to field value format
|
|
53
54
|
* @returns Either a localized object (for localized fields) or the direct value (for non-localized fields)
|
|
54
55
|
*/
|
|
55
|
-
export declare function
|
|
56
|
+
export declare function fromNormalizedFieldValueEntries<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, entries: NormalizedFieldValueEntry<T, L>[]): T | LocalizedFieldValue<T, L>;
|
|
56
57
|
/**
|
|
57
58
|
* Maps field values using a provided mapping function.
|
|
58
59
|
* For localized fields, applies the mapping function to each locale value.
|
|
@@ -64,7 +65,7 @@ export declare function entriesToFieldValue<T = unknown, L extends string = stri
|
|
|
64
65
|
* @param mapFn - The function to apply to each locale value or the direct value
|
|
65
66
|
* @returns The mapped value with the same structure as the input
|
|
66
67
|
*/
|
|
67
|
-
export declare function
|
|
68
|
+
export declare function mapNormalizedFieldValues<TInput = unknown, TOutput = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: TInput | LocalizedFieldValue<TInput, L>, mapFn: (locale: L | undefined, localeValue: TInput) => TOutput): TOutput | LocalizedFieldValue<TOutput, L>;
|
|
68
69
|
/**
|
|
69
70
|
* Maps field values using a provided mapping function (async version).
|
|
70
71
|
* For localized fields, applies the mapping function to each locale value.
|
|
@@ -76,7 +77,7 @@ export declare function mapFieldValue<TInput = unknown, TOutput = unknown, L ext
|
|
|
76
77
|
* @param mapFn - The function to apply to each locale value or the direct value
|
|
77
78
|
* @returns The mapped value with the same structure as the input
|
|
78
79
|
*/
|
|
79
|
-
export declare function
|
|
80
|
+
export declare function mapNormalizedFieldValuesAsync<TInput = unknown, TOutput = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: TInput | LocalizedFieldValue<TInput, L>, mapFn: (locale: L | undefined, localeValue: TInput) => Promise<TOutput>): Promise<TOutput | LocalizedFieldValue<TOutput, L>>;
|
|
80
81
|
/**
|
|
81
82
|
* Filters field values using a provided filter function.
|
|
82
83
|
* For localized fields, filters each locale value.
|
|
@@ -87,7 +88,7 @@ export declare function mapFieldValueAsync<TInput = unknown, TOutput = unknown,
|
|
|
87
88
|
* @param filterFn - The function to test each locale value or the direct value
|
|
88
89
|
* @returns The filtered value with the same structure as the input
|
|
89
90
|
*/
|
|
90
|
-
export declare function
|
|
91
|
+
export declare function filterNormalizedFieldValues<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, filterFn: (locale: L | undefined, localeValue: T) => boolean): T | LocalizedFieldValue<T, L> | undefined;
|
|
91
92
|
/**
|
|
92
93
|
* Filters field values using a provided filter function (async version).
|
|
93
94
|
* For localized fields, filters each locale value.
|
|
@@ -98,7 +99,7 @@ export declare function filterFieldValue<T = unknown, L extends string = string>
|
|
|
98
99
|
* @param filterFn - The function to test each locale value or the direct value
|
|
99
100
|
* @returns The filtered value with the same structure as the input
|
|
100
101
|
*/
|
|
101
|
-
export declare function
|
|
102
|
+
export declare function filterNormalizedFieldValuesAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, filterFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<T | LocalizedFieldValue<T, L> | undefined>;
|
|
102
103
|
/**
|
|
103
104
|
* Tests whether at least one field value passes the test implemented by the provided function.
|
|
104
105
|
* For localized fields, tests each locale value.
|
|
@@ -109,7 +110,7 @@ export declare function filterFieldValueAsync<T = unknown, L extends string = st
|
|
|
109
110
|
* @param testFn - The function to test each locale value or the direct value
|
|
110
111
|
* @returns true if at least one value passes the test, false otherwise
|
|
111
112
|
*/
|
|
112
|
-
export declare function
|
|
113
|
+
export declare function someNormalizedFieldValues<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => boolean): boolean;
|
|
113
114
|
/**
|
|
114
115
|
* Tests whether at least one field value passes the test implemented by the provided function (async version).
|
|
115
116
|
* For localized fields, tests each locale value.
|
|
@@ -120,7 +121,7 @@ export declare function someFieldValue<T = unknown, L extends string = string>(f
|
|
|
120
121
|
* @param testFn - The function to test each locale value or the direct value
|
|
121
122
|
* @returns true if at least one value passes the test, false otherwise
|
|
122
123
|
*/
|
|
123
|
-
export declare function
|
|
124
|
+
export declare function someNormalizedFieldValuesAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<boolean>;
|
|
124
125
|
/**
|
|
125
126
|
* Tests whether all field values pass the test implemented by the provided function.
|
|
126
127
|
* For localized fields, tests each locale value.
|
|
@@ -131,7 +132,7 @@ export declare function someFieldValueAsync<T = unknown, L extends string = stri
|
|
|
131
132
|
* @param testFn - The function to test each locale value or the direct value
|
|
132
133
|
* @returns true if all values pass the test, false otherwise
|
|
133
134
|
*/
|
|
134
|
-
export declare function
|
|
135
|
+
export declare function everyNormalizedFieldValue<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => boolean): boolean;
|
|
135
136
|
/**
|
|
136
137
|
* Tests whether all field values pass the test implemented by the provided function (async version).
|
|
137
138
|
* For localized fields, tests each locale value.
|
|
@@ -142,7 +143,7 @@ export declare function everyFieldValue<T = unknown, L extends string = string>(
|
|
|
142
143
|
* @param testFn - The function to test each locale value or the direct value
|
|
143
144
|
* @returns true if all values pass the test, false otherwise
|
|
144
145
|
*/
|
|
145
|
-
export declare function
|
|
146
|
+
export declare function everyNormalizedFieldValueAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, testFn: (locale: L | undefined, localeValue: T) => Promise<boolean>): Promise<boolean>;
|
|
146
147
|
/**
|
|
147
148
|
* Visits each field value with the provided function.
|
|
148
149
|
* For localized fields, visits each locale value.
|
|
@@ -152,7 +153,7 @@ export declare function everyFieldValueAsync<T = unknown, L extends string = str
|
|
|
152
153
|
* @param value - The field value (either localized object or direct value)
|
|
153
154
|
* @param visitFn - The function to call for each locale value or the direct value
|
|
154
155
|
*/
|
|
155
|
-
export declare function
|
|
156
|
+
export declare function visitNormalizedFieldValues<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, visitFn: (locale: L | undefined, localeValue: T) => void): void;
|
|
156
157
|
/**
|
|
157
158
|
* Visits each field value with the provided function (async version).
|
|
158
159
|
* For localized fields, visits each locale value.
|
|
@@ -162,4 +163,4 @@ export declare function visitFieldValue<T = unknown, L extends string = string>(
|
|
|
162
163
|
* @param value - The field value (either localized object or direct value)
|
|
163
164
|
* @param visitFn - The function to call for each locale value or the direct value
|
|
164
165
|
*/
|
|
165
|
-
export declare function
|
|
166
|
+
export declare function visitNormalizedFieldValuesAsync<T = unknown, L extends string = string>(field: RawApiTypes.Field | ApiTypes.Field, value: T | LocalizedFieldValue<T, L>, visitFn: (locale: L | undefined, localeValue: T) => Promise<void>): Promise<void>;
|