tangled
alpha
login
or
join now
mokkenstorm.dev
/
openapi-ts
0
fork
atom
fork of hey-api/openapi-ts because I need some additional things
0
fork
atom
overview
issues
pulls
pipelines
refactor: remove selectors from sdk plugin
Lubos
4 months ago
20881192
ff89df22
+226
-140
18 changed files
expand all
collapse all
unified
split
.vscode
launch.json
dev
openapi-ts.config.ts
packages
codegen-core
src
__tests__
symbols.test.ts
symbols
registry.ts
openapi-ts
src
index.ts
plugins
@angular
common
httpRequests.ts
httpResources.ts
@hey-api
sdk
api.ts
config.ts
shared
class.ts
functions.ts
operation.ts
typeOptions.ts
v1
plugin.ts
@pinia
colada
plugin.ts
queryKey.ts
@tanstack
query-core
plugin.ts
queryKey.ts
+4
-1
.vscode/launch.json
···
16
16
"cwd": "${workspaceFolder}/dev",
17
17
"runtimeExecutable": "node",
18
18
"runtimeArgs": ["-r", "ts-node/register/transpile-only"],
19
19
-
"program": "${workspaceFolder}/packages/openapi-ts/src/run.ts"
19
19
+
"program": "${workspaceFolder}/packages/openapi-ts/src/run.ts",
20
20
+
"env": {
21
21
+
"DEBUG": "false"
22
22
+
}
20
23
}
21
24
]
22
25
}
+4
-4
dev/openapi-ts.config.ts
···
40
40
// 'dutchie.json',
41
41
// 'invalid',
42
42
// 'openai.yaml',
43
43
-
'full.yaml',
43
43
+
// 'full.yaml',
44
44
// 'opencode.yaml',
45
45
-
// 'sdk-instance.yaml',
45
45
+
'sdk-instance.yaml',
46
46
// 'string-with-format.yaml',
47
47
// 'transformers.json',
48
48
// 'type-format.yaml',
···
214
214
{
215
215
// baseUrl: false,
216
216
// exportFromIndex: true,
217
217
-
name: '@hey-api/client-fetch',
217
217
+
// name: '@hey-api/client-fetch',
218
218
// name: 'legacy/angular',
219
219
// runtimeConfigPath: path.resolve(__dirname, 'hey-api.ts'),
220
220
// runtimeConfigPath: './src/hey-api.ts',
···
259
259
// fields.unwrap('path')
260
260
// },
261
261
// include...
262
262
-
// instance: true,
262
262
+
instance: true,
263
263
name: '@hey-api/sdk',
264
264
// operationId: false,
265
265
// params_EXPERIMENTAL: 'experiment',
+39
packages/codegen-core/src/__tests__/symbols.test.ts
···
230
230
expect(cacheKeys3.length).toBe(3);
231
231
expect(registry['queryCache'].get(cacheKeys3[2]!)).toEqual([]);
232
232
});
233
233
+
234
234
+
it('returns the same stub reference for identical unresolved meta', () => {
235
235
+
const registry = new SymbolRegistry();
236
236
+
237
237
+
const stubA1 = registry.reference({ a: 1 });
238
238
+
const stubA2 = registry.reference({ a: 1 });
239
239
+
240
240
+
// Same reference, not new instance
241
241
+
expect(stubA1).toBe(stubA2);
242
242
+
243
243
+
// Cache entry created by the internal query call
244
244
+
const cacheKey = registry['buildCacheKey']({ a: 1 });
245
245
+
expect(registry['queryCache'].has(cacheKey)).toBe(true);
246
246
+
expect(registry['queryCache'].get(cacheKey)).toEqual([]);
247
247
+
});
248
248
+
249
249
+
it('demonstrates stub addition does not invalidate unrelated cache', () => {
250
250
+
const registry = new SymbolRegistry();
251
251
+
252
252
+
// Create one indexed symbol and one query to seed cache
253
253
+
const symA = registry.register({ meta: { foo: 'bar' }, name: 'A' });
254
254
+
const resultFoo = registry.query({ foo: 'bar' });
255
255
+
expect(resultFoo).toEqual([symA]);
256
256
+
const cacheKeysBefore = Array.from(registry['queryCache'].keys());
257
257
+
expect(cacheKeysBefore.length).toBe(1);
258
258
+
259
259
+
// Add unrelated stub (its meta triggers its own query)
260
260
+
const stub = registry.reference({ something: 'else' });
261
261
+
expect(stub.meta).toEqual({ something: 'else' });
262
262
+
263
263
+
// Existing cache entry still present, plus one new entry for stub
264
264
+
const cacheKeysAfter = Array.from(registry['queryCache'].keys());
265
265
+
expect(cacheKeysAfter.length).toBe(cacheKeysBefore.length + 1);
266
266
+
expect(cacheKeysAfter).toEqual(expect.arrayContaining(cacheKeysBefore));
267
267
+
268
268
+
// The new stub isn't indexed, so query returns nothing yet
269
269
+
const newQuery = registry.query({ something: 'else' });
270
270
+
expect(newQuery).toEqual([]);
271
271
+
});
233
272
});
+7
packages/codegen-core/src/symbols/registry.ts
···
23
23
private registerOrder: Set<SymbolId> = new Set();
24
24
// TODO: remove after removing selectors
25
25
private selectorToId: Map<string, SymbolId> = new Map();
26
26
+
private stubCache: Map<QueryCacheKey, SymbolId> = new Map();
26
27
private stubs: Set<SymbolId> = new Set();
27
28
private values: Map<SymbolId, ISymbolOut> = new Map();
28
29
···
118
119
}
119
120
const [registered] = this.query(symbol.meta);
120
121
if (registered) return registered;
122
122
+
const cacheKey = this.buildCacheKey(symbol.meta);
123
123
+
const cachedId = this.stubCache.get(cacheKey);
124
124
+
if (cachedId !== undefined) return this.values.get(cachedId)!;
121
125
const id = this.id;
122
126
const stub: ISymbolOut = {
123
127
exportFrom: [],
···
127
131
};
128
132
this.values.set(stub.id, stub);
129
133
this.stubs.add(stub.id);
134
134
+
this.stubCache.set(cacheKey, stub.id);
130
135
return stub;
131
136
}
132
137
···
294
299
stub?.meta &&
295
300
this.isSubset(this.buildIndexKeySpace(stub.meta), indexKeySpace)
296
301
) {
302
302
+
const cacheKey = this.buildCacheKey(stub.meta);
303
303
+
this.stubCache.delete(cacheKey);
297
304
this.values.set(stubId, Object.assign(stub, symbol));
298
305
this.stubs.delete(stubId);
299
306
}
+1
packages/openapi-ts/src/index.ts
···
57
57
| 'arktype'
58
58
| 'fastify'
59
59
| 'json-schema'
60
60
+
| 'sdk'
60
61
| 'typescript'
61
62
| 'valibot'
62
63
| 'zod'
+10
-8
packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts
···
289
289
resource: '@angular/common/http.HttpRequest',
290
290
});
291
291
292
292
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
293
293
-
const symbolOptions = plugin.referenceSymbol(
294
294
-
sdkPlugin.api.selector('Options'),
295
295
-
);
292
292
+
const symbolOptions = plugin.referenceSymbol({
293
293
+
category: 'type',
294
294
+
resource: 'client-options',
295
295
+
tool: 'sdk',
296
296
+
});
296
297
297
298
const symbolDataType = plugin.querySymbol({
298
299
category: 'type',
···
349
350
resource: '@angular/common/http.HttpRequest',
350
351
});
351
352
352
352
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
353
353
-
const symbolOptions = plugin.referenceSymbol(
354
354
-
sdkPlugin.api.selector('Options'),
355
355
-
);
353
353
+
const symbolOptions = plugin.referenceSymbol({
354
354
+
category: 'type',
355
355
+
resource: 'client-options',
356
356
+
tool: 'sdk',
357
357
+
});
356
358
357
359
const symbolDataType = plugin.querySymbol({
358
360
category: 'type',
+10
-8
packages/openapi-ts/src/plugins/@angular/common/httpResources.ts
···
375
375
operation: IR.OperationObject;
376
376
plugin: AngularCommonPlugin['Instance'];
377
377
}) => {
378
378
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
379
379
-
const symbolOptions = plugin.referenceSymbol(
380
380
-
sdkPlugin.api.selector('Options'),
381
381
-
);
378
378
+
const symbolOptions = plugin.referenceSymbol({
379
379
+
category: 'type',
380
380
+
resource: 'client-options',
381
381
+
tool: 'sdk',
382
382
+
});
382
383
383
384
const symbolDataType = plugin.querySymbol({
384
385
category: 'type',
···
430
431
plugin: AngularCommonPlugin['Instance'];
431
432
symbol: Symbol;
432
433
}) => {
433
433
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
434
434
-
const symbolOptions = plugin.referenceSymbol(
435
435
-
sdkPlugin.api.selector('Options'),
436
436
-
);
434
434
+
const symbolOptions = plugin.referenceSymbol({
435
435
+
category: 'type',
436
436
+
resource: 'client-options',
437
437
+
tool: 'sdk',
438
438
+
});
437
439
438
440
const symbolDataType = plugin.querySymbol({
439
441
category: 'type',
+2
-38
packages/openapi-ts/src/plugins/@hey-api/sdk/api.ts
···
1
1
-
import type { Selector } from '@hey-api/codegen-core';
2
2
-
3
3
-
import type { Plugin } from '~/plugins';
4
4
-
5
5
-
type SelectorType =
6
6
-
| 'buildClientParams'
7
7
-
| 'class'
8
8
-
| 'Client'
9
9
-
| 'Composable'
10
10
-
| 'formDataBodySerializer'
11
11
-
| 'function'
12
12
-
| 'Options'
13
13
-
| 'urlSearchParamsBodySerializer';
14
14
-
15
15
-
export type IApi = {
16
16
-
/**
17
17
-
* @param type Selector type.
18
18
-
* @param value Depends on `type`:
19
19
-
* - `buildClientParams`: never
20
20
-
* - `class`: current class name
21
21
-
* - `Client`: never
22
22
-
* - `Composable`: never
23
23
-
* - `formDataBodySerializer`: never
24
24
-
* - `function`: `operation.id` string
25
25
-
* - `Options`: never
26
26
-
* - `urlSearchParamsBodySerializer`: never
27
27
-
* @returns Selector array
28
28
-
* @deprecated
29
29
-
*/
30
30
-
selector: (type: SelectorType, value?: string) => Selector;
31
31
-
};
32
32
-
33
33
-
export class Api implements IApi {
34
34
-
constructor(public meta: Plugin.Name<'@hey-api/sdk'>) {}
1
1
+
export type IApi = any;
35
2
36
36
-
selector(...args: ReadonlyArray<string | undefined>): Selector {
37
37
-
return [this.meta.name, ...(args as Selector)];
38
38
-
}
39
39
-
}
3
3
+
export class Api implements IApi {}
+1
-3
packages/openapi-ts/src/plugins/@hey-api/sdk/config.ts
···
6
6
import type { HeyApiSdkPlugin } from './types';
7
7
8
8
export const defaultConfig: HeyApiSdkPlugin['Config'] = {
9
9
-
api: new Api({
10
10
-
name: '@hey-api/sdk',
11
11
-
}),
9
9
+
api: new Api(),
12
10
config: {
13
11
asClass: false,
14
12
auth: true,
+43
-23
packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts
···
22
22
*/
23
23
className: string;
24
24
/**
25
25
-
* Symbol IDs for child classes located inside this class.
25
25
+
* Class names for child classes located inside this class.
26
26
*/
27
27
-
classes: Set<number>;
27
27
+
classes: Set<string>;
28
28
/**
29
29
* Symbol ID for the class.
30
30
*/
···
62
62
}),
63
63
});
64
64
65
65
-
const symbolClient = plugin.referenceSymbol(plugin.api.selector('Client'));
65
65
+
const symbolClient = plugin.referenceSymbol({
66
66
+
category: 'external',
67
67
+
resource: 'client.Client',
68
68
+
});
66
69
const symClient = plugin.getSymbol({
67
70
category: 'client',
68
71
});
···
122
125
const client = getClientPlugin(plugin.context.config);
123
126
const isAngularClient = client.name === '@hey-api/client-angular';
124
127
const isNuxtClient = client.name === '@hey-api/client-nuxt';
125
125
-
const sdkClasses = new Map<number, SdkClassEntry>();
128
128
+
const sdkClasses = new Map<string, SdkClassEntry>();
126
129
/**
127
130
* Track unique added classes.
128
131
*/
129
129
-
const generatedClasses = new Set<number>();
132
132
+
const generatedClasses = new Set<string>();
130
133
131
134
const clientClassNodes = plugin.config.instance
132
135
? createClientClassNodes({ plugin })
···
156
159
157
160
for (const entry of classes.values()) {
158
161
entry.path.forEach((currentClassName, index) => {
159
159
-
const symbolCurrentClass = plugin.referenceSymbol(
160
160
-
plugin.api.selector('class', currentClassName),
161
161
-
);
162
162
-
if (!sdkClasses.has(symbolCurrentClass.id)) {
163
163
-
sdkClasses.set(symbolCurrentClass.id, {
162
162
+
const symbolCurrentClass = plugin.referenceSymbol({
163
163
+
category: 'utility',
164
164
+
resource: 'class',
165
165
+
resourceId: currentClassName,
166
166
+
tool: 'sdk',
167
167
+
});
168
168
+
if (!sdkClasses.has(symbolCurrentClass.meta!.resourceId!)) {
169
169
+
sdkClasses.set(symbolCurrentClass.meta!.resourceId!, {
164
170
className: currentClassName,
165
171
classes: new Set(),
166
172
id: symbolCurrentClass.id,
···
172
178
173
179
const parentClassName = entry.path[index - 1];
174
180
if (parentClassName) {
175
175
-
const symbolParentClass = plugin.referenceSymbol(
176
176
-
plugin.api.selector('class', parentClassName),
177
177
-
);
181
181
+
const symbolParentClass = plugin.referenceSymbol({
182
182
+
category: 'utility',
183
183
+
resource: 'class',
184
184
+
resourceId: parentClassName,
185
185
+
tool: 'sdk',
186
186
+
});
178
187
if (
179
188
symbolParentClass.placeholder !== symbolCurrentClass.placeholder
180
189
) {
181
181
-
const parentClass = sdkClasses.get(symbolParentClass.id)!;
182
182
-
parentClass.classes.add(symbolCurrentClass.id);
183
183
-
sdkClasses.set(symbolParentClass.id, parentClass);
190
190
+
const parentClass = sdkClasses.get(
191
191
+
symbolParentClass.meta!.resourceId!,
192
192
+
)!;
193
193
+
parentClass.classes.add(symbolCurrentClass.meta!.resourceId!);
194
194
+
sdkClasses.set(symbolParentClass.meta!.resourceId!, parentClass);
184
195
}
185
196
}
186
197
···
190
201
return;
191
202
}
192
203
193
193
-
const currentClass = sdkClasses.get(symbolCurrentClass.id)!;
204
204
+
const currentClass = sdkClasses.get(
205
205
+
symbolCurrentClass.meta!.resourceId!,
206
206
+
)!;
194
207
195
208
// avoid duplicate methods
196
209
if (currentClass.methods.has(entry.methodName)) {
···
221
234
{
222
235
default: tsc.ots.string('$fetch'),
223
236
extends: tsc.typeNode(
224
224
-
plugin.referenceSymbol(plugin.api.selector('Composable'))
225
225
-
.placeholder,
237
237
+
plugin.referenceSymbol({
238
238
+
category: 'external',
239
239
+
resource: 'client.Composable',
240
240
+
}).placeholder,
226
241
),
227
242
name: nuxtTypeComposable,
228
243
},
···
264
279
265
280
currentClass.methods.add(entry.methodName);
266
281
267
267
-
sdkClasses.set(symbolCurrentClass.id, currentClass);
282
282
+
sdkClasses.set(symbolCurrentClass.meta!.resourceId!, currentClass);
268
283
});
269
284
}
270
285
},
···
279
294
});
280
295
281
296
const generateClass = (currentClass: SdkClassEntry) => {
282
282
-
if (generatedClasses.has(currentClass.id)) {
297
297
+
if (generatedClasses.has(currentClass.className)) {
283
298
return;
284
299
}
285
300
···
327
342
328
343
const symbol = plugin.registerSymbol({
329
344
exported: true,
345
345
+
meta: {
346
346
+
category: 'utility',
347
347
+
resource: 'class',
348
348
+
resourceId: currentClass.className,
349
349
+
tool: 'sdk',
350
350
+
},
330
351
name: currentClass.className,
331
331
-
selector: plugin.api.selector('class', currentClass.className),
332
352
});
333
353
const node = tsc.classDeclaration({
334
354
decorator:
···
353
373
nodes: currentClass.nodes,
354
374
});
355
375
plugin.setSymbolValue(symbol, node);
356
356
-
generatedClasses.add(symbol.id);
376
376
+
generatedClasses.add(symbol.meta!.resourceId!);
357
377
};
358
378
359
379
if (clientClassNodes.length) {
+8
-3
packages/openapi-ts/src/plugins/@hey-api/sdk/shared/functions.ts
···
47
47
});
48
48
const symbol = plugin.registerSymbol({
49
49
meta: {
50
50
+
category: 'sdk',
50
51
path: event._path,
52
52
+
resource: 'operation',
53
53
+
resourceId: operation.id,
51
54
tags: event.tags,
55
55
+
tool: 'sdk',
52
56
},
53
57
name: serviceFunctionIdentifier({
54
58
config: plugin.context.config,
···
56
60
id: operation.id,
57
61
operation,
58
62
}),
59
59
-
selector: plugin.api.selector('function', operation.id),
60
63
});
61
64
const node = tsc.constVariable({
62
65
comment: createOperationComment({ operation }),
···
70
73
{
71
74
default: tsc.ots.string('$fetch'),
72
75
extends: tsc.typeNode(
73
73
-
plugin.referenceSymbol(plugin.api.selector('Composable'))
74
74
-
.placeholder,
76
76
+
plugin.referenceSymbol({
77
77
+
category: 'external',
78
78
+
resource: 'client.Composable',
79
79
+
}).placeholder,
75
80
),
76
81
name: nuxtTypeComposable,
77
82
},
+17
-10
packages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.ts
···
168
168
});
169
169
const dataType = symbolDataType?.placeholder || 'unknown';
170
170
171
171
-
const symbolOptions = plugin.referenceSymbol(plugin.api.selector('Options'));
171
171
+
const symbolOptions = plugin.referenceSymbol({
172
172
+
category: 'type',
173
173
+
resource: 'client-options',
174
174
+
tool: 'sdk',
175
175
+
});
172
176
173
177
if (isNuxtClient) {
174
178
const symbolResponseType = plugin.querySymbol({
···
412
416
if (operation.body) {
413
417
switch (operation.body.type) {
414
418
case 'form-data': {
415
415
-
const symbol = plugin.referenceSymbol(
416
416
-
plugin.api.selector('formDataBodySerializer'),
417
417
-
);
419
419
+
const symbol = plugin.referenceSymbol({
420
420
+
category: 'external',
421
421
+
resource: 'client.formDataBodySerializer',
422
422
+
});
418
423
requestOptions.push({ spread: symbol.placeholder });
419
424
break;
420
425
}
···
430
435
});
431
436
break;
432
437
case 'url-search-params': {
433
433
-
const symbol = plugin.referenceSymbol(
434
434
-
plugin.api.selector('urlSearchParamsBodySerializer'),
435
435
-
);
438
438
+
const symbol = plugin.referenceSymbol({
439
439
+
category: 'external',
440
440
+
resource: 'client.urlSearchParamsBodySerializer',
441
441
+
});
436
442
requestOptions.push({ spread: symbol.placeholder });
437
443
break;
438
444
}
···
631
637
}
632
638
config.push(tsc.objectExpression({ obj }));
633
639
}
634
634
-
const symbol = plugin.referenceSymbol(
635
635
-
plugin.api.selector('buildClientParams'),
636
636
-
);
640
640
+
const symbol = plugin.referenceSymbol({
641
641
+
category: 'external',
642
642
+
resource: 'client.buildClientParams',
643
643
+
});
637
644
statements.push(
638
645
tsc.constVariable({
639
646
expression: tsc.callExpression({
+14
-5
packages/openapi-ts/src/plugins/@hey-api/sdk/shared/typeOptions.ts
···
22
22
const symbolClient = plugin.registerSymbol({
23
23
external: clientModule,
24
24
kind: 'type',
25
25
+
meta: {
26
26
+
category: 'external',
27
27
+
resource: 'client.Client',
28
28
+
tool: client.name,
29
29
+
},
25
30
name: 'Client',
26
26
-
selector: plugin.api.selector('Client'),
27
31
});
28
32
const symbolClientOptions = plugin.registerSymbol({
29
33
external: clientModule,
···
33
37
const symbolOptions = plugin.registerSymbol({
34
38
exported: true,
35
39
kind: 'type',
40
40
+
meta: {
41
41
+
category: 'type',
42
42
+
resource: 'client-options',
43
43
+
tool: 'sdk',
44
44
+
},
36
45
name: 'Options',
37
37
-
selector: plugin.api.selector('Options'),
38
46
});
39
47
40
48
const typeOptions = tsc.typeAliasDeclaration({
···
94
102
? [
95
103
tsc.typeParameterDeclaration({
96
104
constraint: tsc.typeReferenceNode({
97
97
-
typeName: plugin.referenceSymbol(
98
98
-
plugin.api.selector('Composable'),
99
99
-
).placeholder,
105
105
+
typeName: plugin.referenceSymbol({
106
106
+
category: 'external',
107
107
+
resource: 'client.Composable',
108
108
+
}).placeholder,
100
109
}),
101
110
defaultType: tsc.typeNode("'$fetch'"),
102
111
name: 'TComposable',
+24
-9
packages/openapi-ts/src/plugins/@hey-api/sdk/v1/plugin.ts
···
8
8
9
9
export const handlerV1: HeyApiSdkPlugin['Handler'] = ({ plugin }) => {
10
10
const clientModule = clientFolderAbsolutePath(plugin.context.config);
11
11
+
const client = getClientPlugin(plugin.context.config);
12
12
+
const isAngularClient = client.name === '@hey-api/client-angular';
13
13
+
const isNuxtClient = client.name === '@hey-api/client-nuxt';
14
14
+
11
15
plugin.registerSymbol({
12
16
external: clientModule,
17
17
+
meta: {
18
18
+
category: 'external',
19
19
+
resource: 'client.formDataBodySerializer',
20
20
+
tool: client.name,
21
21
+
},
13
22
name: 'formDataBodySerializer',
14
14
-
selector: plugin.api.selector('formDataBodySerializer'),
15
23
});
16
24
plugin.registerSymbol({
17
25
external: clientModule,
26
26
+
meta: {
27
27
+
category: 'external',
28
28
+
resource: 'client.urlSearchParamsBodySerializer',
29
29
+
tool: client.name,
30
30
+
},
18
31
name: 'urlSearchParamsBodySerializer',
19
19
-
selector: plugin.api.selector('urlSearchParamsBodySerializer'),
20
32
});
21
33
plugin.registerSymbol({
22
34
external: clientModule,
35
35
+
meta: {
36
36
+
category: 'external',
37
37
+
resource: 'client.buildClientParams',
38
38
+
tool: client.name,
39
39
+
},
23
40
name: 'buildClientParams',
24
24
-
selector: plugin.api.selector('buildClientParams'),
25
41
});
26
26
-
27
27
-
const client = getClientPlugin(plugin.context.config);
28
28
-
const isAngularClient = client.name === '@hey-api/client-angular';
29
29
-
const isNuxtClient = client.name === '@hey-api/client-nuxt';
30
42
if (isNuxtClient) {
31
43
plugin.registerSymbol({
32
44
external: clientModule,
33
45
kind: 'type',
46
46
+
meta: {
47
47
+
category: 'external',
48
48
+
resource: 'client.Composable',
49
49
+
tool: client.name,
50
50
+
},
34
51
name: 'Composable',
35
35
-
selector: plugin.api.selector('Composable'),
36
52
});
37
53
}
38
38
-
39
54
if (isAngularClient && plugin.config.asClass) {
40
55
plugin.registerSymbol({
41
56
external: '@angular/core',
+11
-6
packages/openapi-ts/src/plugins/@pinia/colada/plugin.ts
···
69
69
// as it's really easy to break once we change the class casing
70
70
entry
71
71
? [
72
72
-
plugin.referenceSymbol(
73
73
-
sdkPlugin.api.selector('class', entry.path[0]),
74
74
-
).placeholder,
72
72
+
plugin.referenceSymbol({
73
73
+
category: 'utility',
74
74
+
resource: 'class',
75
75
+
resourceId: entry.path[0],
76
76
+
tool: 'sdk',
77
77
+
}).placeholder,
75
78
...entry.path.slice(1).map((className: string) =>
76
79
stringCase({
77
80
case: 'camelCase',
···
82
85
]
83
86
.filter(Boolean)
84
87
.join('.')
85
85
-
: plugin.referenceSymbol(
86
86
-
sdkPlugin.api.selector('function', operation.id),
87
87
-
).placeholder;
88
88
+
: plugin.referenceSymbol({
89
89
+
category: 'sdk',
90
90
+
resource: 'operation',
91
91
+
resourceId: operation.id,
92
92
+
}).placeholder;
88
93
89
94
if (plugin.hooks.operation.isQuery(operation)) {
90
95
if (plugin.config.queryOptions.enabled) {
+10
-8
packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts
···
56
56
57
57
const baseUrlKey = getClientBaseUrlKey(plugin.context.config);
58
58
59
59
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
60
60
-
const symbolOptions = plugin.referenceSymbol(
61
61
-
sdkPlugin.api.selector('Options'),
62
62
-
);
59
59
+
const symbolOptions = plugin.referenceSymbol({
60
60
+
category: 'type',
61
61
+
resource: 'client-options',
62
62
+
tool: 'sdk',
63
63
+
});
63
64
const symbolClient = plugin.getSymbol({
64
65
category: 'client',
65
66
});
···
338
339
},
339
340
];
340
341
341
341
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
342
342
-
const symbolOptions = plugin.referenceSymbol(
343
343
-
sdkPlugin.api.selector('Options'),
344
344
-
);
342
342
+
const symbolOptions = plugin.referenceSymbol({
343
343
+
category: 'type',
344
344
+
resource: 'client-options',
345
345
+
tool: 'sdk',
346
346
+
});
345
347
const symbolQueryKeyType = plugin.registerSymbol({
346
348
exported: true,
347
349
kind: 'type',
+11
-6
packages/openapi-ts/src/plugins/@tanstack/query-core/plugin.ts
···
93
93
// as it's really easy to break once we change the class casing
94
94
entry
95
95
? [
96
96
-
plugin.referenceSymbol(
97
97
-
sdkPlugin.api.selector('class', entry.path[0]),
98
98
-
).placeholder,
96
96
+
plugin.referenceSymbol({
97
97
+
category: 'utility',
98
98
+
resource: 'class',
99
99
+
resourceId: entry.path[0],
100
100
+
tool: 'sdk',
101
101
+
}).placeholder,
99
102
...entry.path.slice(1).map((className) =>
100
103
stringCase({
101
104
case: 'camelCase',
···
106
109
]
107
110
.filter(Boolean)
108
111
.join('.')
109
109
-
: plugin.referenceSymbol(
110
110
-
sdkPlugin.api.selector('function', operation.id),
111
111
-
).placeholder;
112
112
+
: plugin.referenceSymbol({
113
113
+
category: 'sdk',
114
114
+
resource: 'operation',
115
115
+
resourceId: operation.id,
116
116
+
}).placeholder;
112
117
113
118
if (plugin.hooks.operation.isQuery(operation)) {
114
119
if (plugin.config.queryOptions.enabled) {
+10
-8
packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts
···
55
55
category: 'client',
56
56
});
57
57
58
58
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
59
59
-
const symbolOptions = plugin.referenceSymbol(
60
60
-
sdkPlugin.api.selector('Options'),
61
61
-
);
58
58
+
const symbolOptions = plugin.referenceSymbol({
59
59
+
category: 'type',
60
60
+
resource: 'client-options',
61
61
+
tool: 'sdk',
62
62
+
});
62
63
63
64
const fn = tsc.constVariable({
64
65
expression: tsc.arrowFunction({
···
310
311
},
311
312
];
312
313
313
313
-
const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk');
314
314
-
const symbolOptions = plugin.referenceSymbol(
315
315
-
sdkPlugin.api.selector('Options'),
316
316
-
);
314
314
+
const symbolOptions = plugin.referenceSymbol({
315
315
+
category: 'type',
316
316
+
resource: 'client-options',
317
317
+
tool: 'sdk',
318
318
+
});
317
319
const symbolQueryKeyType = plugin.registerSymbol({
318
320
exported: true,
319
321
kind: 'type',