Skip to content

Commit ff78219

Browse files
committed
Better export names
1 parent a5c0477 commit ff78219

5 files changed

Lines changed: 131 additions & 56 deletions

File tree

packages/to-dom-nodes/src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
} from 'datocms-structured-text-generic-html-renderer';
1010
import {
1111
Adapter,
12+
CdaStructuredTextRecord,
13+
CdaStructuredTextValue,
1214
Document as StructuredTextDocument,
1315
isBlock,
1416
isInlineBlock,
@@ -21,18 +23,18 @@ import {
2123
RenderResult,
2224
RenderRule,
2325
StructuredText as StructuredTextGraphQlResponse,
26+
TypesafeCdaStructuredTextValue,
2427
TypesafeStructuredText as TypesafeStructuredTextGraphQlResponse,
2528
} from 'datocms-structured-text-utils';
2629
import hyperscript from 'hyperscript';
2730

2831
export { renderNodeRule, renderMarkRule, RenderError };
29-
// deprecated export
30-
export { renderNodeRule as renderRule };
32+
3133
export type {
3234
StructuredTextDocument,
33-
TypesafeStructuredTextGraphQlResponse,
34-
StructuredTextGraphQlResponse,
35-
StructuredTextGraphQlResponseRecord,
35+
CdaStructuredTextValue,
36+
TypesafeCdaStructuredTextValue,
37+
CdaStructuredTextRecord,
3638
};
3739

3840
type AdapterReturn = Element[] | Element | string | null;
@@ -286,3 +288,19 @@ export function render<
286288

287289
return result as ReturnType<F> | null;
288290
}
291+
292+
// ============================================================================
293+
// DEPRECATED EXPORTS - kept for backward compatibility
294+
// ============================================================================
295+
296+
/**
297+
* @deprecated Use renderNodeRule instead
298+
*/
299+
export { renderNodeRule as renderRule };
300+
301+
/** @deprecated Use CdaStructuredTextValue */
302+
export type { StructuredTextGraphQlResponse };
303+
/** @deprecated Use TypesafeCdaStructuredTextValue */
304+
export type { TypesafeStructuredTextGraphQlResponse };
305+
/** @deprecated Use CdaStructuredTextRecord */
306+
export type { StructuredTextGraphQlResponseRecord };

packages/to-html-string/src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
} from 'datocms-structured-text-generic-html-renderer';
1010
import {
1111
Adapter,
12+
CdaStructuredTextRecord,
13+
CdaStructuredTextValue,
1214
Document as StructuredTextDocument,
1315
isBlock,
1416
isInlineBlock,
@@ -21,18 +23,18 @@ import {
2123
RenderResult,
2224
RenderRule,
2325
StructuredText as StructuredTextGraphQlResponse,
26+
TypesafeCdaStructuredTextValue,
2427
TypesafeStructuredText as TypesafeStructuredTextGraphQlResponse,
2528
} from 'datocms-structured-text-utils';
2629
import vhtml from 'vhtml';
2730

2831
export { renderNodeRule, renderMarkRule, RenderError };
29-
// deprecated export
30-
export { renderNodeRule as renderRule };
32+
3133
export type {
3234
StructuredTextDocument,
33-
TypesafeStructuredTextGraphQlResponse,
34-
StructuredTextGraphQlResponse,
35-
StructuredTextGraphQlResponseRecord,
35+
CdaStructuredTextValue,
36+
TypesafeCdaStructuredTextValue,
37+
CdaStructuredTextRecord,
3638
};
3739

3840
type AdapterReturn = string | null;
@@ -286,3 +288,19 @@ export function render<
286288

287289
return result || null;
288290
}
291+
292+
// ============================================================================
293+
// DEPRECATED EXPORTS - kept for backward compatibility
294+
// ============================================================================
295+
296+
/**
297+
* @deprecated Use renderNodeRule instead
298+
*/
299+
export { renderNodeRule as renderRule };
300+
301+
/** @deprecated Use CdaStructuredTextValue */
302+
export type { StructuredTextGraphQlResponse };
303+
/** @deprecated Use TypesafeCdaStructuredTextValue */
304+
export type { TypesafeStructuredTextGraphQlResponse };
305+
/** @deprecated Use CdaStructuredTextRecord */
306+
export type { StructuredTextGraphQlResponseRecord };

packages/to-markdown/src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
} from 'datocms-structured-text-generic-html-renderer';
1010
import {
1111
Adapter,
12+
CdaStructuredTextRecord,
13+
CdaStructuredTextValue,
1214
Document as StructuredTextDocument,
1315
isBlock,
1416
isBlockquote,
@@ -29,17 +31,17 @@ import {
2931
RenderResult,
3032
RenderRule,
3133
StructuredText as StructuredTextGraphQlResponse,
34+
TypesafeCdaStructuredTextValue,
3235
TypesafeStructuredText as TypesafeStructuredTextGraphQlResponse,
3336
} from 'datocms-structured-text-utils';
3437

3538
export { renderNodeRule, renderMarkRule, RenderError };
36-
// deprecated export
37-
export { renderNodeRule as renderRule };
39+
3840
export type {
3941
StructuredTextDocument,
40-
TypesafeStructuredTextGraphQlResponse,
41-
StructuredTextGraphQlResponse,
42-
StructuredTextGraphQlResponseRecord,
42+
CdaStructuredTextValue,
43+
TypesafeCdaStructuredTextValue,
44+
CdaStructuredTextRecord,
4345
};
4446

4547
const renderFragment = (
@@ -425,3 +427,19 @@ export function render<
425427
}
426428
return result.trim();
427429
}
430+
431+
// ============================================================================
432+
// DEPRECATED EXPORTS - kept for backward compatibility
433+
// ============================================================================
434+
435+
/**
436+
* @deprecated Use renderNodeRule instead
437+
*/
438+
export { renderNodeRule as renderRule };
439+
440+
/** @deprecated Use CdaStructuredTextValue */
441+
export type { StructuredTextGraphQlResponse };
442+
/** @deprecated Use TypesafeCdaStructuredTextValue */
443+
export type { TypesafeStructuredTextGraphQlResponse };
444+
/** @deprecated Use CdaStructuredTextRecord */
445+
export type { StructuredTextGraphQlResponseRecord };

packages/to-plain-text/src/index.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
} from 'datocms-structured-text-generic-html-renderer';
1010
import {
1111
Adapter,
12+
CdaStructuredTextRecord,
13+
CdaStructuredTextValue,
1214
Document as StructuredTextDocument,
1315
isBlock,
1416
isInlineBlock,
@@ -21,17 +23,17 @@ import {
2123
RenderResult,
2224
RenderRule,
2325
StructuredText as StructuredTextGraphQlResponse,
26+
TypesafeCdaStructuredTextValue,
2427
TypesafeStructuredText as TypesafeStructuredTextGraphQlResponse,
2528
} from 'datocms-structured-text-utils';
2629

2730
export { renderNodeRule, renderMarkRule, RenderError };
28-
// deprecated export
29-
export { renderNodeRule as renderRule };
31+
3032
export type {
3133
StructuredTextDocument,
32-
TypesafeStructuredTextGraphQlResponse,
33-
StructuredTextGraphQlResponse,
34-
StructuredTextGraphQlResponseRecord,
34+
CdaStructuredTextValue,
35+
TypesafeCdaStructuredTextValue,
36+
CdaStructuredTextRecord,
3537
};
3638

3739
const renderFragment = (
@@ -273,3 +275,19 @@ export function render<
273275

274276
return result ? result.trim() : null;
275277
}
278+
279+
// ============================================================================
280+
// DEPRECATED EXPORTS - kept for backward compatibility
281+
// ============================================================================
282+
283+
/**
284+
* @deprecated Use renderNodeRule instead
285+
*/
286+
export { renderNodeRule as renderRule };
287+
288+
/** @deprecated Use CdaStructuredTextValue */
289+
export type { StructuredTextGraphQlResponse };
290+
/** @deprecated Use TypesafeCdaStructuredTextValue */
291+
export type { TypesafeStructuredTextGraphQlResponse };
292+
/** @deprecated Use CdaStructuredTextRecord */
293+
export type { StructuredTextGraphQlResponseRecord };

packages/utils/src/types.ts

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,26 @@ export type NodeType =
476476
| SpanType
477477
| ThematicBreakType;
478478

479-
/** @deprecated Use CdaStructuredTextValue */
480-
export type StructuredText<
481-
BlockRecord extends Record = Record,
482-
LinkRecord extends Record = Record,
483-
InlineBlockRecord extends Record = Record
479+
export type CdaStructuredTextRecord = {
480+
__typename: string;
481+
id: string;
482+
} & {
483+
[prop: string]: unknown;
484+
};
485+
486+
/**
487+
* CDA (Content Delivery API) format for structured text values.
488+
*
489+
* Structured Text enables authors to create rich text content, on par with
490+
* traditional editors.
491+
*
492+
* Additionally, it allows records and Media Area assets to be linked dynamically
493+
* and embedded within the flow of the text.
494+
*/
495+
export type CdaStructuredTextValue<
496+
BlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
497+
LinkRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
498+
InlineBlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord
484499
> = {
485500
/**
486501
* A DatoCMS "dast" document
@@ -505,17 +520,10 @@ export type StructuredText<
505520
* Additionally, it allows records and Media Area assets to be linked dynamically
506521
* and embedded within the flow of the text.
507522
*/
508-
export type CdaStructuredTextValue<
509-
BlockRecord extends Record = Record,
510-
LinkRecord extends Record = Record,
511-
InlineBlockRecord extends Record = Record
512-
> = StructuredText<BlockRecord, LinkRecord, InlineBlockRecord>;
513-
514-
/** @deprecated Use TypesafeCdaStructuredTextValue */
515-
export type TypesafeStructuredText<
516-
BlockRecord extends Record = Record,
517-
LinkRecord extends Record = Record,
518-
InlineBlockRecord extends Record = Record
523+
export type TypesafeCdaStructuredTextValue<
524+
BlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
525+
LinkRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
526+
InlineBlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord
519527
> = {
520528
/**
521529
* A DatoCMS "dast" document
@@ -531,24 +539,19 @@ export type TypesafeStructuredText<
531539
links?: LinkRecord[];
532540
};
533541

534-
/**
535-
* CDA (Content Delivery API) format for structured text values.
536-
*
537-
* Structured Text enables authors to create rich text content, on par with
538-
* traditional editors.
539-
*
540-
* Additionally, it allows records and Media Area assets to be linked dynamically
541-
* and embedded within the flow of the text.
542-
*/
543-
export type TypesafeCdaStructuredTextValue<
544-
BlockRecord extends Record = Record,
545-
LinkRecord extends Record = Record,
546-
InlineBlockRecord extends Record = Record
547-
> = TypesafeStructuredText<BlockRecord, LinkRecord, InlineBlockRecord>;
542+
/** @deprecated Use CdaStructuredTextRecord */
543+
export type Record = CdaStructuredTextRecord;
548544

549-
export type Record = {
550-
__typename: string;
551-
id: string;
552-
} & {
553-
[prop: string]: unknown;
554-
};
545+
/** @deprecated Use CdaStructuredTextValue */
546+
export type StructuredText<
547+
BlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
548+
LinkRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
549+
InlineBlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord
550+
> = CdaStructuredTextValue<BlockRecord, LinkRecord, InlineBlockRecord>;
551+
552+
/** @deprecated Use TypesafeCdaStructuredTextValue */
553+
export type TypesafeStructuredText<
554+
BlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
555+
LinkRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord,
556+
InlineBlockRecord extends CdaStructuredTextRecord = CdaStructuredTextRecord
557+
> = TypesafeCdaStructuredTextValue<BlockRecord, LinkRecord, InlineBlockRecord>;

0 commit comments

Comments
 (0)