Skip to content

Commit f9b8e16

Browse files
authored
Merge pull request #126 from contentstack/staging
DX | 09-09-2024 | Release
2 parents 1613385 + b1d3523 commit f9b8e16

File tree

7 files changed

+1743
-1277
lines changed

7 files changed

+1743
-1277
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Contentstack Solutions
3+
Copyright (c) 2024 Contentstack
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

MIGRATION.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
## Migrating from v2 to v3
2+
This document outlines the necessary changes to separate nested modular blocks into distinct interfaces. This update will affect how modular blocks are structured and used throughout the codebase.
3+
4+
## Before
5+
```typescript
6+
export interface Test {
7+
/** Version */
8+
_version?: 2;
9+
/** Title */
10+
title: string;
11+
/** Modular Blocks */
12+
modular_blocks?: {
13+
test: {
14+
/** Multi Line Textbox */
15+
multi_line?: string;
16+
/** Rich Text Editor */
17+
rich_text_editor?: string;
18+
/** Modular Blocks1 */
19+
modular_blocks1?: {
20+
test1: {
21+
/** Multi Line Textbox */
22+
multi_line?: string;
23+
};
24+
}[];
25+
};
26+
}[];
27+
}
28+
```
29+
30+
31+
## After
32+
```typescript
33+
export interface Test {
34+
/** Version */
35+
_version: 2;
36+
/** Title */
37+
title: string;
38+
/** Modular Blocks */
39+
modular_blocks?: ModularBlocks[];
40+
}
41+
42+
43+
export interface ModularBlocks {
44+
/** Multi Line Textbox */
45+
multi_line?: string;
46+
/** Rich Text Editor */
47+
rich_text_editor?: string;
48+
/** Modular Blocks1 */
49+
modular_blocks1?: ModularBlocks1[];
50+
}
51+
52+
export interface ModularBlocks1 {
53+
/** Multi Line Textbox */
54+
multi_line?: string;
55+
}
56+
```

README.md

Lines changed: 27 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![Node.js CI](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/workflows/Node.js%20CI/badge.svg)
1+
![Node.js CI](https://github.com/contentstack/contentstack-cli-tsgen/workflows/Node.js%20CI/badge.svg)
22
![npm](https://img.shields.io/npm/v/contentstack-cli-tsgen)
33

44
## Description
@@ -11,6 +11,9 @@ This plugin generates TypeScript typings from Content Types. Interfaces and fiel
1111
$ csdx plugins:install contentstack-cli-tsgen
1212
```
1313

14+
## Migration
15+
Refer to the [Migration Guide](https://github.com/contentstack/contentstack-cli-tsgen/blob/master/MIGRATION.md) version 3 if you are migrating from version 2 or older.
16+
1417
## How to use this plugin
1518

1619
`$ csdx tsgen`
@@ -33,7 +36,7 @@ EXAMPLES
3336
$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --no-doc
3437
```
3538

36-
_See code: [src/commands/tsgen.ts](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/blob/v1.0.6/src/commands/tsgen.ts)_
39+
_See code: [src/commands/tsgen.ts](https://github.com/contentstack/contentstack-cli-tsgen/blob/v2.3.4/src/commands/tsgen.ts)_
3740
<!-- commandsstop -->
3841

3942
## Supported Fields
@@ -92,38 +95,7 @@ interface BuiltinExample {
9295
/** Single Choice */
9396
single_choice: "Choice 1" | "Choice 2" | "Choice 3";
9497
/** Modular Blocks */
95-
modular_blocks?: (
96-
| {
97-
block_1: {
98-
/** Number */
99-
number?: number;
100-
/** Single line textbox */
101-
single_line?: string;
102-
};
103-
block_2: undefined;
104-
seo_gf: undefined;
105-
}
106-
| {
107-
block_2: {
108-
/** Boolean */
109-
boolean?: boolean;
110-
/** Date */
111-
date?: string;
112-
};
113-
block_1: undefined;
114-
seo_gf: undefined;
115-
}
116-
| {
117-
seo_gf: {
118-
/** Keywords */
119-
keywords?: string;
120-
/** Description */
121-
description?: string;
122-
};
123-
block_1: undefined;
124-
block_2: undefined;
125-
}
126-
)[];
98+
modular_blocks?:ModularBlocks[];
12799
/** Number */
128100
number?: number;
129101
/** Link */
@@ -135,4 +107,25 @@ interface BuiltinExample {
135107
/** Date */
136108
date?: string;
137109
}
110+
111+
interface ModularBlocks {
112+
block_1: {
113+
/** Number */
114+
number?: number;
115+
/** Single line textbox */
116+
single_line?: string;
117+
};
118+
block_2: {
119+
/** Boolean */
120+
boolean?: boolean;
121+
/** Date */
122+
date?: string;
123+
};
124+
seo_gf: {
125+
/** Keywords */
126+
keywords?: string;
127+
/** Description */
128+
description?: string;
129+
};
130+
}
138131
```

0 commit comments

Comments
 (0)