Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 7 additions & 10 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
module.exports = {
"roots": [
"<rootDir>"
],
"testMatch": [
"**/tests/**/*.+(ts|tsx)",
"**/?(*.)+(spec|test).+(ts|tsx)"
],
"transform": {
"^.+\\.(ts|tsx)$": "ts-jest"
preset: "ts-jest",
testEnvironment: "node",
roots: ["<rootDir>"],
testMatch: ["**/tests/**/*.+(ts|tsx)", "**/?(*.)+(spec|test).+(ts|tsx)"],
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
},
}
};
6 changes: 3 additions & 3 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions 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": "4.4.0",
"version": "4.5.0",
"author": "Michael Davis",
"bugs": "https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/issues",
"dependencies": {
Expand All @@ -14,7 +14,7 @@
"@oclif/plugin-help": "^6.2.27",
"@oclif/test": "^4.1.12",
"@types/jest": "^29.5.14",
"@types/node": "^22.14.0",
"@types/node": "^22.17.1",
"@typescript-eslint/eslint-plugin": "^8.29.1",
"@typescript-eslint/parser": "^8.29.1",
"eslint": "^8.57.0",
Expand Down
10 changes: 10 additions & 0 deletions src/commands/tsgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts"',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" -p "I"',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --no-doc',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --include-referenced-entry',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --api-type graphql',
'$ csdx tsgen -a "delivery token alias" -o "contentstack/generated.d.ts" --api-type graphql --namespace "GraphQL" ',
];
Expand Down Expand Up @@ -92,6 +93,13 @@
default: false,
}),

"include-referenced-entry": flags.boolean({
description:
"Includes the ReferencedEntry interface in generated types. Use this option to add a generic interface for handling referenced entries when the exact content type is unknown or when you need a flexible reference type",
default: false,
allowNo: true,
}),

"api-type": flags.string({
default: "rest",
multiple: false,
Expand All @@ -117,6 +125,7 @@
const branch = flags.branch;
const includeSystemFields = flags["include-system-fields"];
const includeEditableTags = flags["include-editable-tags"];
const includeReferencedEntry = flags["include-referenced-entry"];
const namespace = flags.namespace;

const outputPath = createOutputPath(filePath);
Expand Down Expand Up @@ -200,6 +209,7 @@
prefix,
systemFields: includeSystemFields,
isEditableTags: includeEditableTags,
includeReferencedEntry,

Check failure on line 212 in src/commands/tsgen.ts

View workflow job for this annotation

GitHub Actions / build (20.x)

Object literal may only specify known properties, and 'includeReferencedEntry' does not exist in type 'GenerateTSBase'.

Check failure on line 212 in src/commands/tsgen.ts

View workflow job for this annotation

GitHub Actions / build (18.x)

Object literal may only specify known properties, and 'includeReferencedEntry' does not exist in type 'GenerateTSBase'.
});

fs.writeFileSync(outputPath, result || "");
Expand Down
6 changes: 4 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
"declaration": true,
"importHelpers": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "lib",
"rootDir": "src",
"strict": true,
"target": "es2017",
"skipLibCheck": true,
"resolveJsonModule": true,
"types": ["node", "jest"]
},
"include": [
"src/**/*"
"src/**/*",
"tests/**/*"
]
}
Loading