@openapi-codegen/typescript
Advanced tools
Comparing version 5.2.1 to 6.0.0
@@ -6,4 +6,5 @@ /** | ||
* @param filename path of the module | ||
* @param isTypeOnly whether fnName are used as types only | ||
* @returns ts.Node of the import declaration | ||
*/ | ||
export declare const createNamedImport: (fnName: string | string[], filename: string) => import("typescript").ImportDeclaration; | ||
export declare const createNamedImport: (fnName: string | string[], filename: string, isTypeOnly?: boolean) => import("typescript").ImportDeclaration; |
@@ -10,9 +10,10 @@ "use strict"; | ||
* @param filename path of the module | ||
* @param isTypeOnly whether fnName are used as types only | ||
* @returns ts.Node of the import declaration | ||
*/ | ||
const createNamedImport = (fnName, filename) => { | ||
const createNamedImport = (fnName, filename, isTypeOnly = false) => { | ||
const fnNames = Array.isArray(fnName) ? fnName : [fnName]; | ||
return typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(false, undefined, typescript_1.factory.createNamedImports(fnNames.map((name) => typescript_1.factory.createImportSpecifier(false, undefined, typescript_1.factory.createIdentifier(name))))), typescript_1.factory.createStringLiteral(filename), undefined); | ||
return typescript_1.factory.createImportDeclaration(undefined, typescript_1.factory.createImportClause(isTypeOnly, undefined, typescript_1.factory.createNamedImports(fnNames.map((name) => typescript_1.factory.createImportSpecifier(false, undefined, typescript_1.factory.createIdentifier(name))))), typescript_1.factory.createStringLiteral(filename), undefined); | ||
}; | ||
exports.createNamedImport = createNamedImport; | ||
//# sourceMappingURL=createNamedImport.js.map |
@@ -21,4 +21,7 @@ "use strict"; | ||
typescript_1.factory.createParameterDeclaration(undefined, undefined, typescript_1.factory.createIdentifier("variables"), undefined, variablesType, undefined), | ||
typescript_1.factory.createParameterDeclaration(undefined, undefined, typescript_1.factory.createIdentifier("signal"), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier("AbortSignal"))), | ||
] | ||
: [], undefined, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier(fetcherFn), [ | ||
: [ | ||
typescript_1.factory.createParameterDeclaration(undefined, undefined, typescript_1.factory.createIdentifier("signal"), typescript_1.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), typescript_1.factory.createTypeReferenceNode(typescript_1.factory.createIdentifier("AbortSignal"))), | ||
], undefined, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier(fetcherFn), [ | ||
dataType, | ||
@@ -37,4 +40,7 @@ errorType, | ||
typescript_1.factory.createSpreadAssignment(typescript_1.factory.createIdentifier("variables")), | ||
typescript_1.factory.createShorthandPropertyAssignment(typescript_1.factory.createIdentifier("signal")), | ||
] | ||
: []), | ||
: [ | ||
typescript_1.factory.createShorthandPropertyAssignment(typescript_1.factory.createIdentifier("signal")), | ||
]), | ||
], false), | ||
@@ -41,0 +47,0 @@ ]))), |
@@ -79,3 +79,3 @@ "use strict"; | ||
else { | ||
return (0, createNamedImport_1.createNamedImport)(Array.from(i.imports.values()), `./${i.from}`); | ||
return (0, createNamedImport_1.createNamedImport)(Array.from(i.imports.values()), `./${i.from}`, true); | ||
} | ||
@@ -82,0 +82,0 @@ }), |
@@ -220,3 +220,7 @@ "use strict"; | ||
]), | ||
typescript_1.factory.createArrowFunction(undefined, undefined, [], undefined, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier(operationFetcherFnName), undefined, [ | ||
typescript_1.factory.createArrowFunction(undefined, undefined, [ | ||
typescript_1.factory.createParameterDeclaration(undefined, undefined, typescript_1.factory.createObjectBindingPattern([ | ||
typescript_1.factory.createBindingElement(undefined, undefined, "signal"), | ||
])), | ||
], undefined, typescript_1.factory.createToken(typescript_1.default.SyntaxKind.EqualsGreaterThanToken), typescript_1.factory.createCallExpression(typescript_1.factory.createIdentifier(operationFetcherFnName), undefined, [ | ||
typescript_1.factory.createObjectLiteralExpression([ | ||
@@ -226,2 +230,3 @@ typescript_1.factory.createSpreadAssignment(typescript_1.factory.createIdentifier("fetcherOptions")), | ||
], false), | ||
typescript_1.factory.createIdentifier("signal"), | ||
])), | ||
@@ -228,0 +233,0 @@ typescript_1.factory.createObjectLiteralExpression([ |
@@ -34,2 +34,3 @@ "use strict"; | ||
pathParams?: TPathParams; | ||
signal?: AbortSignal; | ||
} & ${contextPath | ||
@@ -53,2 +54,3 @@ ? `${(0, case_1.pascal)(prefix)}Context["fetcherOptions"];` | ||
queryParams, | ||
signal, | ||
}: ${(0, case_1.pascal)(prefix)}FetcherOptions< | ||
@@ -63,2 +65,3 @@ TBody, | ||
{ | ||
signal, | ||
method: method.toUpperCase(), | ||
@@ -92,3 +95,3 @@ body: body ? JSON.stringify(body) : undefined, | ||
} else { | ||
// if it is not a json response, asume it is a blob and cast it to TData | ||
// if it is not a json response, assume it is a blob and cast it to TData | ||
return (await response.blob()) as unknown as TData; | ||
@@ -95,0 +98,0 @@ } |
{ | ||
"name": "@openapi-codegen/typescript", | ||
"version": "5.2.1", | ||
"version": "6.0.0", | ||
"description": "OpenAPI Codegen typescript generators", | ||
@@ -44,3 +44,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "75e7c8ae6087867bac4df446c3ec5e6a72424b6a" | ||
"gitHead": "13ca9b35ab0bbd363946baf4a015b3e6d317f728" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
191418
2385