Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "contentstack-cli-tsgen",
"description": "Generate TypeScript typings from a Stack.",
"version": "2.1.6",
"version": "2.1.7",
"author": "Michael Davis",
"bugs": "https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/issues",
"dependencies": {
Expand Down Expand Up @@ -58,5 +58,10 @@
"prepack": "rm -rf lib && tsc -b && oclif manifest && oclif readme",
"test": "jest",
"version": "oclif readme && git add README.md"
},
"csdxConfig": {
"shortCommandName": {
"tsgen": "TSGEN"
}
}
}
1 change: 1 addition & 0 deletions src/lib/stack/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type Block = {
export type GlobalField = {
reference_to: string;
schema: Schema;
_version?: number
} & FieldOptions;

export type ReferenceField = {
Expand Down
2 changes: 2 additions & 0 deletions src/lib/tsgen/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ export default function (userOptions: TSGenOptions) {
options.docgen.interface(contentType.description),
define_interface(contentType),
'{',
['/**', "Version", '*/'].join(' '),
[`version: `,contentType._version,';'].join(' '),
visit_fields(contentType.schema),
'}',
]
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/boolean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe('builtin boolean field', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface IBoolean
{
/** Version */
version: 2 ;
title: string;
boolean?: boolean;
}"
Expand Down
4 changes: 4 additions & 0 deletions tests/tsgen/defaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ describe('default single content block', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface IMetadataSingleContentBlock
{
/** Version */
version: 2 ;
title: string;
}"
`)
Expand All @@ -41,6 +43,8 @@ describe('default single webpage', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface IMetadataSingleWebpage
{
/** Version */
version: 2 ;
title: string;
url: string;
}"
Expand Down
4 changes: 4 additions & 0 deletions tests/tsgen/global.fields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe('global fields', () => {
expect(globalField.definition).toMatchInlineSnapshot(`
"export interface ISeo
{
/** Version */
version: ;
keywords?: string;
description?: string;
}"
Expand All @@ -34,6 +36,8 @@ describe('global fields', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface IGlobalFields
{
/** Version */
version: 2 ;
title: string;
seo?: ISeo;
}"
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ describe('group', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface Group
{
/** Version */
version: 3 ;
title: string;
multiple_group_max_limit?: [{
number?: number;
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/isodate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ describe('builtin isodate field', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface Isodate
{
/** Version */
version: 2 ;
title: string;
date?: string;
date_required: string;
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/jsdoc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ describe('jsdoc', () => {
"/** Content Type Description */
export interface Jsdoc
{
/** Version */
version: 3 ;
/** Name */
title: string;
/** Age */
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/modular.blocks.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('modular blocks', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface ModularBlocks
{
/** Version */
version: 2 ;
title: string;
url: string;
modular_blocks?: ({string_block: {single_line?: string;
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/number.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('builtin number field', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface Number
{
/** Version */
version: 2 ;
title: string;
url: string;
number?: number;
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ describe('all options', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface Options
{
/** Version */
version: 4 ;
title: string;
url: string;
single_line_textbox_not_required?: string;
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/references.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ describe('references', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface IReferenceParent
{
/** Version */
version: 5 ;
title: string;
url: string;
single_reference: (IReferenceChild)[];
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/select.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ describe('select (dropdown)', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface Select
{
/** Version */
version: 5 ;
title: string;
select_single_value?: (\\"Option 1\\" | \\"Option 2\\" | \\"Option 3\\");
select_single_value_required: (\\"Test 1\\" | \\"Test 2\\" | \\"Test 3\\");
Expand Down
2 changes: 2 additions & 0 deletions tests/tsgen/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('builtin string fields', () => {
expect(result.definition).toMatchInlineSnapshot(`
"export interface BuiltinStrings
{
/** Version */
version: 4 ;
title: string;
single_line?: string;
multi_line?: string;
Expand Down