Skip to content

Commit

Permalink
Merge pull request #126 from contentstack/staging
Browse files Browse the repository at this point in the history
DX | 09-09-2024 | Release
  • Loading branch information
cs-raj authored Sep 12, 2024
2 parents 1613385 + b1d3523 commit f9b8e16
Show file tree
Hide file tree
Showing 7 changed files with 1,743 additions and 1,277 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Contentstack Solutions
Copyright (c) 2024 Contentstack

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
56 changes: 56 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## Migrating from v2 to v3
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.

## Before
```typescript
export interface Test {
/** Version */
_version?: 2;
/** Title */
title: string;
/** Modular Blocks */
modular_blocks?: {
test: {
/** Multi Line Textbox */
multi_line?: string;
/** Rich Text Editor */
rich_text_editor?: string;
/** Modular Blocks1 */
modular_blocks1?: {
test1: {
/** Multi Line Textbox */
multi_line?: string;
};
}[];
};
}[];
}
```


## After
```typescript
export interface Test {
/** Version */
_version: 2;
/** Title */
title: string;
/** Modular Blocks */
modular_blocks?: ModularBlocks[];
}


export interface ModularBlocks {
/** Multi Line Textbox */
multi_line?: string;
/** Rich Text Editor */
rich_text_editor?: string;
/** Modular Blocks1 */
modular_blocks1?: ModularBlocks1[];
}

export interface ModularBlocks1 {
/** Multi Line Textbox */
multi_line?: string;
}
```
61 changes: 27 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Node.js CI](https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/workflows/Node.js%20CI/badge.svg)
![Node.js CI](https://github.com/contentstack/contentstack-cli-tsgen/workflows/Node.js%20CI/badge.svg)
![npm](https://img.shields.io/npm/v/contentstack-cli-tsgen)

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

## Migration
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.

## How to use this plugin

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

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

## Supported Fields
Expand Down Expand Up @@ -92,38 +95,7 @@ interface BuiltinExample {
/** Single Choice */
single_choice: "Choice 1" | "Choice 2" | "Choice 3";
/** Modular Blocks */
modular_blocks?: (
| {
block_1: {
/** Number */
number?: number;
/** Single line textbox */
single_line?: string;
};
block_2: undefined;
seo_gf: undefined;
}
| {
block_2: {
/** Boolean */
boolean?: boolean;
/** Date */
date?: string;
};
block_1: undefined;
seo_gf: undefined;
}
| {
seo_gf: {
/** Keywords */
keywords?: string;
/** Description */
description?: string;
};
block_1: undefined;
block_2: undefined;
}
)[];
modular_blocks?:ModularBlocks[];
/** Number */
number?: number;
/** Link */
Expand All @@ -135,4 +107,25 @@ interface BuiltinExample {
/** Date */
date?: string;
}

interface ModularBlocks {
block_1: {
/** Number */
number?: number;
/** Single line textbox */
single_line?: string;
};
block_2: {
/** Boolean */
boolean?: boolean;
/** Date */
date?: string;
};
seo_gf: {
/** Keywords */
keywords?: string;
/** Description */
description?: string;
};
}
```
Loading

0 comments on commit f9b8e16

Please sign in to comment.