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.

feat(pinia-colada): init`serializeQueryKeyValue`

+95 -20
+2
packages/openapi-ts/src/plugins/@pinia/colada/api.ts
··· 6 6 | '_JSONValue' 7 7 | 'AxiosError' 8 8 | 'createQueryKey' 9 + | 'serializeQueryKeyValue' 9 10 | 'defineQueryOptions' 10 11 | 'queryOptionsFn' 11 12 | 'QueryKey' ··· 19 20 * - `_JSONValue`: never 20 21 * - `AxiosError`: never 21 22 * - `createQueryKey`: never 23 + * - `serializeQueryKeyValue`: never 22 24 * - `defineQueryOptions`: never 23 25 * - `queryOptionsFn`: `operation.id` string 24 26 * - `QueryKey`: never
+93 -20
packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts
··· 22 22 }: { 23 23 plugin: PiniaColadaPlugin['Instance']; 24 24 }) => { 25 + const coreModule = '../core/queryKeySerializer.gen'; 25 26 const symbolCreateQueryKey = plugin.registerSymbol({ 26 27 name: buildName({ 27 28 config: { ··· 34 35 const symbolQueryKeyType = plugin.referenceSymbol( 35 36 plugin.api.getSelector('QueryKey'), 36 37 ); 38 + const symbolSerializeQueryValue = plugin.registerSymbol({ 39 + external: coreModule, 40 + name: 'serializeQueryKeyValue', 41 + }); 37 42 38 43 const returnType = tsc.indexedAccessTypeNode({ 39 44 indexType: tsc.literalTypeNode({ ··· 129 134 }), 130 135 }), 131 136 tsc.ifStatement({ 137 + expression: tsc.binaryExpression({ 138 + left: tsc.propertyAccessExpression({ 139 + expression: optionsIdentifier, 140 + isOptional: true, 141 + name: tsc.identifier({ text: 'body' }), 142 + }), 143 + operator: '!==', 144 + right: 'undefined', 145 + }), 146 + thenStatement: tsc.block({ 147 + statements: [ 148 + tsc.constVariable({ 149 + expression: tsc.callExpression({ 150 + functionName: symbolSerializeQueryValue.placeholder, 151 + parameters: [ 152 + tsc.propertyAccessExpression({ 153 + expression: 'options', 154 + name: 'body', 155 + }), 156 + ], 157 + }), 158 + name: 'normalizedBody', 159 + }), 160 + tsc.ifStatement({ 161 + expression: tsc.binaryExpression({ 162 + left: tsc.identifier({ text: 'normalizedBody' }), 163 + operator: '!==', 164 + right: 'undefined', 165 + }), 166 + thenStatement: tsc.block({ 167 + statements: [ 168 + tsc.expressionToStatement({ 169 + expression: tsc.binaryExpression({ 170 + left: tsc.propertyAccessExpression({ 171 + expression: 'params', 172 + name: 'body', 173 + }), 174 + right: tsc.identifier({ text: 'normalizedBody' }), 175 + }), 176 + }), 177 + ], 178 + }), 179 + }), 180 + ], 181 + }), 182 + }), 183 + tsc.ifStatement({ 132 184 expression: tsc.propertyAccessExpression({ 133 185 expression: optionsIdentifier, 134 186 isOptional: true, ··· 152 204 }), 153 205 }), 154 206 tsc.ifStatement({ 155 - expression: tsc.propertyAccessExpression({ 156 - expression: optionsIdentifier, 157 - isOptional: true, 158 - name: tsc.identifier({ text: 'query' }), 207 + expression: tsc.binaryExpression({ 208 + left: tsc.propertyAccessExpression({ 209 + expression: optionsIdentifier, 210 + isOptional: true, 211 + name: tsc.identifier({ text: 'query' }), 212 + }), 213 + operator: '!==', 214 + right: 'undefined', 159 215 }), 160 216 thenStatement: tsc.block({ 161 217 statements: [ 162 - tsc.expressionToStatement({ 218 + tsc.constVariable({ 219 + expression: tsc.callExpression({ 220 + functionName: symbolSerializeQueryValue.placeholder, 221 + parameters: [ 222 + tsc.propertyAccessExpression({ 223 + expression: 'options', 224 + name: 'query', 225 + }), 226 + ], 227 + }), 228 + name: 'normalizedQuery', 229 + }), 230 + tsc.ifStatement({ 163 231 expression: tsc.binaryExpression({ 164 - left: tsc.propertyAccessExpression({ 165 - expression: 'params', 166 - name: 'query', 167 - }), 168 - right: tsc.asExpression({ 169 - expression: tsc.asExpression({ 170 - expression: tsc.propertyAccessExpression({ 171 - expression: 'options', 172 - name: 'query', 232 + left: tsc.identifier({ text: 'normalizedQuery' }), 233 + operator: '!==', 234 + right: 'undefined', 235 + }), 236 + thenStatement: tsc.block({ 237 + statements: [ 238 + tsc.expressionToStatement({ 239 + expression: tsc.binaryExpression({ 240 + left: tsc.propertyAccessExpression({ 241 + expression: 'params', 242 + name: 'query', 243 + }), 244 + right: tsc.identifier({ text: 'normalizedQuery' }), 173 245 }), 174 - type: tsc.keywordTypeNode({ keyword: 'unknown' }), 175 246 }), 176 - type: tsc.typeReferenceNode({ 177 - typeName: symbolJsonValue.placeholder, 178 - }), 179 - }), 247 + ], 180 248 }), 181 249 }), 182 250 ], ··· 247 315 }, 248 316 { 249 317 isRequired: false, 318 + name: 'body', 319 + type: tsc.typeReferenceNode({ typeName: symbolJsonValue.placeholder }), 320 + }, 321 + { 322 + isRequired: false, 250 323 name: 'query', 251 324 type: tsc.typeReferenceNode({ typeName: symbolJsonValue.placeholder }), 252 325 }, ··· 275 348 tsc.typeIntersectionNode({ 276 349 types: [ 277 350 tsc.typeReferenceNode({ 278 - typeName: `Pick<${TOptionsType}, 'path'>`, 351 + typeName: `Pick<${TOptionsType}, '${getClientBaseUrlKey(plugin.context.config)}' | 'body' | 'path' | 'query'>`, 279 352 }), 280 353 tsc.typeInterfaceNode({ 281 354 properties,