You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Narrow request-shape blocks via id + relax mapNodes mapper return
NarrowBlockItemByItemType now requires `id: string` and accepts an
optional `relationships?` constraint. That picks both the response form
(ItemInNestedResponse, id always present) and the updated request form
(UpdatedBlockInRequest, relationships optional), while excluding bare
string ids and freshly-created New blocks — finding those via item-type
isn't the typical use case anyway.
mapNodes / mapNodesAsync gain a free `R` parameter on the mapper so the
return type isn't constrained to `MapNodesMapperResult<T>`. Callers can
return nodes whose `item` payload is shaped differently from the input
tree (e.g. swapping a nested-response block for a request-shape block
built via buildBlockRecord) without fighting the inference.
| [`mapNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L297) | Transform nodes in the tree synchronously (1:1, splat, or remove) |
241
-
| [`mapNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L340) | Transform nodes in the tree asynchronously (1:1, splat, or remove) |
240
+
| [`mapNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L309) | Transform nodes in the tree synchronously (1:1, splat, or remove) |
241
+
| [`mapNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L355) | Transform nodes in the tree asynchronously (1:1, splat, or remove) |
242
242
243
243
`mapNodes`walksthetree**bottom-up**: whenthemapperseesanode, its
244
244
descendantshavealreadybeentransformed, andthemapper's return for that
| [`collectNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L387) | Collect all nodes that match a predicate function |
310
-
| [`collectNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L445) | Collect all nodes that match an async predicate function |
311
-
| [`findFirstNode`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L484) | Find the first node that matches a predicate function |
312
-
| [`findFirstNodeAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L562) | Find the first node that matches an async predicate function |
309
+
| [`collectNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L402) | Collect all nodes that match a predicate function |
310
+
| [`collectNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L460) | Collect all nodes that match an async predicate function |
311
+
| [`findFirstNode`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L499) | Find the first node that matches a predicate function |
312
+
| [`findFirstNodeAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L577) | Find the first node that matches an async predicate function |
313
313
314
314
Find specific nodes using predicates or type guards:
| [`filterNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L611) | Remove nodes that don't match a predicate synchronously |
348
-
| [`filterNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L694) | Remove nodes that don't match an async predicate |
347
+
| [`filterNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L626) | Remove nodes that don't match a predicate synchronously |
348
+
| [`filterNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L709) | Remove nodes that don't match an async predicate |
| [`reduceNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L781) | Reduce the tree to a single value using a synchronous reducer function |
377
-
| [`reduceNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L826) | Reduce the tree to a single value using an async reducer function |
376
+
| [`reduceNodes`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L796) | Reduce the tree to a single value using a synchronous reducer function |
377
+
| [`reduceNodesAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L841) | Reduce the tree to a single value using an async reducer function |
| [`someNode`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L868) | Check if any node in the tree matches a predicate (short-circuit evaluation) |
412
-
| [`someNodeAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L910) | Check if any node in the tree matches an async predicate (short-circuit evaluation) |
413
-
| [`everyNode`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L952) | Check if every node in the tree matches a predicate (short-circuit evaluation) |
414
-
| [`everyNodeAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L983) | Check if every node in the tree matches an async predicate (short-circuit evaluation) |
411
+
| [`someNode`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L883) | Check if any node in the tree matches a predicate (short-circuit evaluation) |
412
+
| [`someNodeAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L925) | Check if any node in the tree matches an async predicate (short-circuit evaluation) |
413
+
| [`everyNode`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L967) | Check if every node in the tree matches a predicate (short-circuit evaluation) |
414
+
| [`everyNodeAsync`](https://github.com/datocms/structured-text/blob/main/packages/utils/src/manipulation.ts#L998) | Check if every node in the tree matches an async predicate (short-circuit evaluation) |
0 commit comments