Skip to content

Commit 65f151d

Browse files
committed
chore: progress on TanStack Query plugin
1 parent fa65218 commit 65f151d

File tree

30 files changed

+2517
-3197
lines changed

30 files changed

+2517
-3197
lines changed

.changeset/tall-deers-shout.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: update TanStack Query key to contain base URL

.changeset/wild-toys-yawn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@hey-api/openapi-ts': patch
3+
---
4+
5+
fix: change TanStack Query mutation helpers to functions for consistent API

packages/openapi-ts/src/compiler/module.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,20 @@ export const createCallExpression = ({
3636
types,
3737
}: {
3838
functionName: string | ts.PropertyAccessExpression;
39-
parameters?: Array<string | ts.Expression>;
39+
parameters?: Array<string | ts.Expression | undefined>;
4040
types?: ReadonlyArray<ts.TypeNode>;
4141
}) => {
4242
const expression =
4343
typeof functionName === 'string'
4444
? createIdentifier({ text: functionName })
4545
: functionName;
46-
const argumentsArray = parameters.map((parameter) =>
47-
typeof parameter === 'string'
48-
? createIdentifier({ text: parameter })
49-
: parameter,
50-
);
46+
const argumentsArray = parameters
47+
.filter((parameter) => parameter !== undefined)
48+
.map((parameter) =>
49+
typeof parameter === 'string'
50+
? createIdentifier({ text: parameter })
51+
: parameter,
52+
);
5153
const callExpression = ts.factory.createCallExpression(
5254
expression,
5355
types,

packages/openapi-ts/src/compiler/typedef.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ export const createTypeUnionNode = (
9898
* @param isNullable - if the whole type can be null
9999
* @returns ts.IntersectionTypeNode | ts.UnionTypeNode
100100
*/
101-
export const createTypeIntersectNode = (
102-
types: (any | ts.TypeNode)[],
103-
isNullable: boolean = false,
104-
) => {
101+
export const createTypeIntersectNode = ({
102+
isNullable,
103+
types,
104+
}: {
105+
isNullable?: boolean;
106+
types: (any | ts.TypeNode)[];
107+
}) => {
105108
const nodes = types.map((type) => createTypeNode(type));
106109
const node = ts.factory.createIntersectionTypeNode(nodes);
107110
return maybeNullable({ isNullable, node });

packages/openapi-ts/src/compiler/types.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ export type ObjectValue =
338338
comments?: Comments;
339339
isValueAccess?: boolean;
340340
key: string;
341+
shorthand?: boolean;
341342
value: any;
342343
};
343344

@@ -363,7 +364,7 @@ export const createObjectType = <
363364
identifiers = [],
364365
multiLine = true,
365366
obj,
366-
shorthand = false,
367+
shorthand,
367368
unescape = false,
368369
}: {
369370
comments?: Comments;
@@ -399,7 +400,9 @@ export const createObjectType = <
399400
}
400401
let assignment: ObjectAssignment;
401402
if ('spread' in value) {
402-
const nameIdentifier = createIdentifier({ text: value.spread });
403+
const nameIdentifier = isTsNode(value.spread)
404+
? value.spread
405+
: createIdentifier({ text: value.spread });
403406
assignment = ts.factory.createSpreadAssignment(
404407
value.assertion
405408
? ts.factory.createAsExpression(
@@ -408,7 +411,7 @@ export const createObjectType = <
408411
)
409412
: nameIdentifier,
410413
);
411-
} else if (shorthand && canShorthand) {
414+
} else if (value.shorthand || (shorthand && canShorthand)) {
412415
assignment = ts.factory.createShorthandPropertyAssignment(
413416
value.value,
414417
);

0 commit comments

Comments
 (0)