Skip to content

Commit

Permalink
feat: If args is not used, the args argument is not included.
Browse files Browse the repository at this point in the history
  • Loading branch information
kahirokunn committed May 1, 2024
1 parent ecfc13c commit 2e10472
Show file tree
Hide file tree
Showing 5 changed files with 252 additions and 322 deletions.
2 changes: 1 addition & 1 deletion packages/kubekit-codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kubekit/codegen",
"version": "0.0.15",
"version": "0.0.18",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"author": "kahirokunn",
Expand Down
31 changes: 19 additions & 12 deletions packages/kubekit-codegen/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,20 @@ export function generateEndpointDefinition({
queryFn,
isListWatch,
isListOrWatch,
isUnusedArgs,
}: {
operationName: string;
Response: ts.TypeReferenceNode;
QueryArg: ts.TypeReferenceNode;
queryFn: ts.ObjectLiteralExpression;
isListWatch: boolean;
isListOrWatch: boolean;
isUnusedArgs: boolean;
}) {
const CustomizedResponse = factory.createTypeReferenceNode(factory.createIdentifier(isListOrWatch ? "MinimumRequiredList" : "MinimumRequiredGet"), [Response])
const CustomizedResponse = factory.createTypeReferenceNode(
factory.createIdentifier(isListOrWatch ? 'MinimumRequiredList' : 'MinimumRequiredGet'),
[Response]
);
if (!isListWatch) {
return [
factory.createVariableStatement(
Expand All @@ -102,14 +107,18 @@ export function generateEndpointDefinition({
undefined,
undefined,
[
factory.createParameterDeclaration(
undefined,
undefined,
factory.createIdentifier('args'),
undefined,
QueryArg,
undefined
),
...(isUnusedArgs
? []
: [
factory.createParameterDeclaration(
undefined,
undefined,
factory.createIdentifier('args'),
undefined,
QueryArg,
undefined
),
]),
factory.createParameterDeclaration(
undefined,
undefined,
Expand Down Expand Up @@ -165,9 +174,7 @@ export function generateEndpointDefinition({
undefined
),
],
factory.createTypeReferenceNode(factory.createIdentifier('Promise'), [
CustomizedResponse
]),
factory.createTypeReferenceNode(factory.createIdentifier('Promise'), [CustomizedResponse]),
undefined
),
factory.createFunctionDeclaration(
Expand Down
Loading

0 comments on commit 2e10472

Please sign in to comment.