Skip to content

Commit ea65280

Browse files
committed
Proposed changes
1 parent 593d757 commit ea65280

5 files changed

Lines changed: 146 additions & 118 deletions

File tree

packages/cma-client/src/fieldTypes/rich_text.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export type RichTextFieldValueAsRequest = BlockItemInARequest[] | null;
7171
/**
7272
* Modular Content field value with nested blocks - array of fully populated block objects
7373
*/
74-
export type RichTextFieldValueWithResolvedBlocks = SchemaTypes.Item[] | null;
74+
export type RichTextFieldValueWithNestedBlocks = SchemaTypes.Item[] | null;
7575

7676
/**
7777
* =============================================================================
@@ -117,9 +117,9 @@ export function isRichTextFieldValueAsRequest(
117117
* Type guard for Modular Content field values with nested blocks (?nested=true format).
118118
* Ensures all blocks are full SchemaTypes.Item objects with complete data.
119119
*/
120-
export function isRichTextFieldValueWithResolvedBlocks(
120+
export function isRichTextFieldValueWithNestedBlocks(
121121
value: unknown,
122-
): value is RichTextFieldValueWithResolvedBlocks {
122+
): value is RichTextFieldValueWithNestedBlocks {
123123
if (value === null) return true;
124124

125125
if (!Array.isArray(value)) return false;

packages/cma-client/src/fieldTypes/single_block.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export type SingleBlockFieldValueAsRequest = BlockItemInARequest | null;
7777
/**
7878
* Single Block field value with nested block - fully populated block object
7979
*/
80-
export type SingleBlockFieldValueWithResolvedBlocks = SchemaTypes.Item | null;
80+
export type SingleBlockFieldValueWithNestedBlocks = SchemaTypes.Item | null;
8181

8282
/**
8383
* =============================================================================
@@ -159,9 +159,9 @@ export function isSingleBlockFieldValueAsRequest(
159159
* Type guard for Single Block field values with nested blocks (?nested=true format).
160160
* Ensures block is a full SchemaTypes.Item object with complete data.
161161
*/
162-
export function isSingleBlockFieldValueWithResolvedBlocks(
162+
export function isSingleBlockFieldValueWithNestedBlocks(
163163
value: unknown,
164-
): value is SingleBlockFieldValueWithResolvedBlocks {
164+
): value is SingleBlockFieldValueWithNestedBlocks {
165165
if (value === null) return true;
166166

167167
// Must be a full object with ID (nested format always includes complete block objects)

packages/cma-client/src/fieldTypes/structured_text.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,35 +94,35 @@ export type DocumentAsRequest = {
9494
/**
9595
* Variant of 'block' structured text node for ?nested=true API responses
9696
*/
97-
export type BlockWithResolvedBlocks = Omit<Block, 'item'> & {
97+
export type BlockWithNestedBlocks = Omit<Block, 'item'> & {
9898
item: SchemaTypes.Item;
9999
};
100100

101101
/**
102102
* Variant of 'inlineBlock' structured text node for ?nested=true API responses
103103
*/
104-
export type InlineBlockWithResolvedBlocks = Omit<InlineBlock, 'item'> & {
104+
export type InlineBlockWithNestedBlocks = Omit<InlineBlock, 'item'> & {
105105
item: SchemaTypes.Item;
106106
};
107107

108108
/**
109109
* Generic type to transform a node that might be containing a 'block' or 'inlineBlock' as a (deeply nested) children to it's variant for ?nested=true API responses
110110
*/
111-
export type NodeWithResolvedBlocks<T> = WithMappedChildren<
111+
export type NodeWithNestedBlocks<T> = WithMappedChildren<
112112
T,
113113
DeepMapVariants<
114114
T extends { children: infer C } ? C : never,
115-
BlockWithResolvedBlocks,
116-
InlineBlockWithResolvedBlocks
115+
BlockWithNestedBlocks,
116+
InlineBlockWithNestedBlocks
117117
>
118118
>;
119119

120120
/**
121121
* Variant of Structured Text document for ?nested=true API responses
122122
*/
123-
export type DocumentWithResolvedBlocks = {
123+
export type DocumentWithNestedBlocks = {
124124
schema: 'dast';
125-
document: NodeWithResolvedBlocks<Root>;
125+
document: NodeWithNestedBlocks<Root>;
126126
};
127127

128128
/**
@@ -137,8 +137,8 @@ export type DocumentWithResolvedBlocks = {
137137
*/
138138
export type StructuredTextFieldValue = Document | null;
139139
export type StructuredTextFieldValueAsRequest = DocumentAsRequest | null;
140-
export type StructuredTextFieldValueWithResolvedBlocks =
141-
DocumentWithResolvedBlocks | null;
140+
export type StructuredTextFieldValueWithNestedBlocks =
141+
DocumentWithNestedBlocks | null;
142142

143143
/**
144144
* Helper function to validate if a value has the expected structured text document structure.
@@ -165,10 +165,10 @@ function validateAllBlockNodes(
165165
node:
166166
| Block
167167
| BlockAsRequest
168-
| BlockWithResolvedBlocks
168+
| BlockWithNestedBlocks
169169
| InlineBlock
170170
| InlineBlockAsRequest
171-
| InlineBlockWithResolvedBlocks,
171+
| InlineBlockWithNestedBlocks,
172172
) => boolean,
173173
): boolean {
174174
return everyNode(node, (currentNode) => {
@@ -232,9 +232,9 @@ export function isStructuredTextFieldValueAsRequest(
232232
* Type guard for structured text field values with nested blocks (?nested=true format).
233233
* Ensures all block/inlineBlock nodes have full SchemaTypes.Item objects.
234234
*/
235-
export function isStructuredTextFieldValueWithResolvedBlocks(
235+
export function isStructuredTextFieldValueWithNestedBlocks(
236236
value: unknown,
237-
): value is StructuredTextFieldValueWithResolvedBlocks {
237+
): value is StructuredTextFieldValueWithNestedBlocks {
238238
if (value === null) return true;
239239

240240
if (!isValidDocumentStructure(value)) {

packages/cma-client/src/utilities/blocks.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import type {
2626
BlockItemInARequest,
2727
RichTextFieldValue,
2828
RichTextFieldValueAsRequest,
29-
RichTextFieldValueWithResolvedBlocks,
29+
RichTextFieldValueWithNestedBlocks,
3030
SingleBlockFieldValue,
3131
SingleBlockFieldValueAsRequest,
32-
SingleBlockFieldValueWithResolvedBlocks,
32+
SingleBlockFieldValueWithNestedBlocks,
3333
StructuredTextFieldValue,
3434
StructuredTextFieldValueAsRequest,
35-
StructuredTextFieldValueWithResolvedBlocks,
35+
StructuredTextFieldValueWithNestedBlocks,
3636
} from '../fieldTypes';
3737
import type * as SchemaTypes from '../generated/SchemaTypes';
3838
import type * as SimpleSchemaTypes from '../generated/SimpleSchemaTypes';
@@ -49,15 +49,15 @@ import {
4949
type PossibleRichTextValue =
5050
| RichTextFieldValue
5151
| RichTextFieldValueAsRequest
52-
| RichTextFieldValueWithResolvedBlocks;
52+
| RichTextFieldValueWithNestedBlocks;
5353
type PossibleSingleBlockValue =
5454
| SingleBlockFieldValue
5555
| SingleBlockFieldValueAsRequest
56-
| SingleBlockFieldValueWithResolvedBlocks;
56+
| SingleBlockFieldValueWithNestedBlocks;
5757
type PossibleStructuredTextValue =
5858
| StructuredTextFieldValue
5959
| StructuredTextFieldValueAsRequest
60-
| StructuredTextFieldValueWithResolvedBlocks;
60+
| StructuredTextFieldValueWithNestedBlocks;
6161

6262
function getFieldType(field: SchemaTypes.Field | SimpleSchemaTypes.Field) {
6363
return 'attributes' in field ? field.attributes.field_type : field.field_type;

0 commit comments

Comments
 (0)