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
270 changes: 2 additions & 268 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/types-generator",
"version": "3.2.0",
"version": "3.3.0",
"description": "Contentstack type definition generation library",
"private": false,
"author": "Contentstack",
Expand Down
4 changes: 1 addition & 3 deletions src/generateTS/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ export default function (userOptions: TSGenOptions) {
define_interface(contentType, options.systemFields),
"{",
["/**", "Version", "*/"].join(" "),
contentType.schema_type === "global_field"
? `_version?: number;`
: `_version: number;`,
`_version?: number;`,
visit_fields(contentType.schema),
"}",
]
Expand Down
5 changes: 3 additions & 2 deletions src/generateTS/stack/builtins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export const defaultInterfaces = (
const defaultInterfaces = [
`type BuildTuple<T, N extends number, R extends T[] = []> =
R['length'] extends N ? R : BuildTuple<T, N, [...R, T]>`,
`type TuplePrefixes<T extends any[]> =
`type TuplePrefixes<T extends any[]> =
T extends [any, ...infer Rest] ? T | TuplePrefixes<Rest extends any[] ? Rest : []> : []`,
`type MaxTuple<T, N extends number> = TuplePrefixes<BuildTuple<T, N>>`,
`type MaxTuple<T, N extends number> = TuplePrefixes<BuildTuple<T, N>>`,
`export interface ${prefix}PublishDetails {
environment: string;
locale: string;
Expand All @@ -32,6 +32,7 @@ export const defaultInterfaces = (
_version: number;
title: string;
_metadata?:object;
description?:string;
publish_details: ${prefix}PublishDetails;
}`,
`export interface ${prefix}Link {
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tsgen/boolean.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("builtin boolean field", () => {
"export interface IBoolean
{
/** Version */
_version: number;
_version?: number;
title: string;
boolean: boolean;
}"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tsgen/custom-field.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe("JSON RTE", () => {
"export interface Home
{
/** Version */
_version: number;
_version?: number;
title: string;
custom_key_value_pair?: { value: { key: string; value: string }[] };
}"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/tsgen/defaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("default single content block", () => {
"export interface IMetadataSingleContentBlock
{
/** Version */
_version: number;
_version?: number;
title: string;
}"
`);
Expand All @@ -44,7 +44,7 @@ describe("default single webpage", () => {
"export interface IMetadataSingleWebpage
{
/** Version */
_version: number;
_version?: number;
title: string;
url: string;
}"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tsgen/global.fields.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe("global fields", () => {
"export interface IHome
{
/** Version */
_version: number;
_version?: number;
title: string;
taxonomies?: ITaxonomy[];
}"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tsgen/group.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe("group", () => {
"export interface Group
{
/** Version */
_version: number;
_version?: number;
title: string;
multiple_group_max_limit?: MaxTuple<{
number?: number | null;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tsgen/isodate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe("builtin isodate field", () => {
"export interface Isodate
{
/** Version */
_version: number;
_version?: number;
title: string;
date?: string | null;
date_required: string;
Expand Down
Loading