fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor(pinia-colada): simplify options handling

+18 -30
+18 -30
packages/openapi-ts/src/plugins/@pinia/colada/queryOptions.ts
··· 1 1 import type ts from 'typescript'; 2 2 3 - import { hasOperationPathOrQueryAny } from '../../../ir/operation'; 4 3 import type { IR } from '../../../ir/types'; 5 4 import { buildName } from '../../../openApi/shared/utils/name'; 6 5 import { tsc } from '../../../tsc'; ··· 66 65 plugin, 67 66 typeData, 68 67 }); 69 - const hasAnyRequestFields = hasOperationPathOrQueryAny(operation); 70 - const needsOptionsScope = hasAnyRequestFields || !!operation.body; 71 68 const awaitSdkExpression = tsc.awaitExpression({ 72 69 expression: tsc.callExpression({ 73 70 functionName: queryFn, 74 71 parameters: [ 75 - needsOptionsScope 76 - ? tsc.objectExpression({ 77 - multiLine: true, 78 - obj: [ 79 - ...(isRequiredOptions 80 - ? ([{ spread: optionsParamName }] as const) 81 - : []), 82 - { key: 'throwOnError', value: true }, 83 - ], 84 - }) 85 - : tsc.objectExpression({ 86 - multiLine: false, 87 - obj: [{ key: 'throwOnError', value: true }], 88 - }), 72 + tsc.objectExpression({ 73 + multiLine: true, 74 + obj: [ 75 + { spread: optionsParamName }, 76 + { key: 'throwOnError', value: true }, 77 + ], 78 + }), 89 79 ], 90 80 }), 91 81 }); ··· 115 105 key: 'key', 116 106 value: tsc.callExpression({ 117 107 functionName: symbolQueryKey.placeholder, 118 - parameters: needsOptionsScope ? [optionsParamName] : [], 108 + parameters: [optionsParamName], 119 109 }), 120 110 }, 121 111 { ··· 155 145 expression: tsc.callExpression({ 156 146 functionName: 'defineQueryOptions', 157 147 parameters: [ 158 - needsOptionsScope 159 - ? tsc.arrowFunction({ 160 - parameters: [ 161 - { 162 - isRequired: isRequiredOptions, 163 - name: optionsParamName, 164 - type: strippedTypeData, 165 - }, 166 - ], 167 - statements: tsc.objectExpression({ obj: queryOptionsObj }), 168 - }) 169 - : tsc.objectExpression({ obj: queryOptionsObj }), 148 + tsc.arrowFunction({ 149 + parameters: [ 150 + { 151 + isRequired: isRequiredOptions, 152 + name: optionsParamName, 153 + type: strippedTypeData, 154 + }, 155 + ], 156 + statements: tsc.objectExpression({ obj: queryOptionsObj }), 157 + }), 170 158 ], 171 159 }), 172 160 name: symbolQueryOptionsFn.placeholder,