mobx-tanstack-query-api 0.0.108 → 0.0.110
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/codegen/index.d.ts +40 -0
- package/codegen/index.d.ts.map +1 -1
- package/codegen/index.js +160 -74
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +18 -0
- package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +1 -0
- package/codegen/templates/all-endpoints-per-file.tmpl.js +92 -0
- package/package.json +6 -1
- package/runtime/http-client.d.ts +1 -1
- package/runtime/http-client.d.ts.map +1 -1
- package/runtime/http-client.js +2 -3
package/codegen/index.d.ts
CHANGED
|
@@ -31,6 +31,46 @@ export interface GenerateQueryApiParams {
|
|
|
31
31
|
*/
|
|
32
32
|
formatEndpointName?: (endpointName: string, endpointData: AnyObject) => Maybe<string>;
|
|
33
33
|
formatExportGroupName?: (groupName: string, utils: CodegenDataUtils) => string;
|
|
34
|
+
/**
|
|
35
|
+
* Various generation output types
|
|
36
|
+
*
|
|
37
|
+
* `one-endpoint-per-file`
|
|
38
|
+
* @example
|
|
39
|
+
* ```
|
|
40
|
+
* outputdir
|
|
41
|
+
* groupname
|
|
42
|
+
* index.ts
|
|
43
|
+
* endpoints
|
|
44
|
+
* index.ts
|
|
45
|
+
* get-endpoint-1.ts
|
|
46
|
+
* get-endpoint-n.ts
|
|
47
|
+
* ```
|
|
48
|
+
* @example
|
|
49
|
+
* ```
|
|
50
|
+
* outputdir
|
|
51
|
+
* index.ts
|
|
52
|
+
* endpoints
|
|
53
|
+
* index.ts
|
|
54
|
+
* get-endpoint-1.ts
|
|
55
|
+
* get-endpoint-n.ts
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* `endpoints-per-file`
|
|
59
|
+
* @example
|
|
60
|
+
* ```
|
|
61
|
+
* outputdir
|
|
62
|
+
* groupname
|
|
63
|
+
* index.ts
|
|
64
|
+
* endpoints.ts
|
|
65
|
+
* ```
|
|
66
|
+
* @example
|
|
67
|
+
* ```
|
|
68
|
+
* outputdir
|
|
69
|
+
* index.ts
|
|
70
|
+
* endpoints.ts
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
outputType?: 'one-endpoint-per-file' | 'endpoints-per-file';
|
|
34
74
|
/**
|
|
35
75
|
* Group endpoints and collect it into object
|
|
36
76
|
*/
|
package/codegen/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAYrE,OAAO,EAEL,uBAAuB,EACxB,MAAM,gCAAgC,CAAC;AAOxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,EAAE,YAAY,CAAC;IAChB,qBAAqB,EAAE,CAAC,aAAa,EAAE,SAAS,KAAK,MAAM,CAAC;IAC5D,eAAe,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CAChD,CAAC;AAEF,KAAK,iBAAiB,GAAG,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC;AAE1D,MAAM,MAAM,cAAc,GAAG,SAAS,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,EAA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
import { generateApi as generateApiFromSwagger } from 'swagger-typescript-api';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { allEndpointPerFileTmpl } from './templates/all-endpoints-per-file.tmpl.js';
|
|
4
5
|
import { allExportsTmpl } from './templates/all-exports.tmpl.js';
|
|
5
6
|
import { LINTERS_IGNORE } from './templates/constants.js';
|
|
6
7
|
import { dataContractsFileTmpl } from './templates/data-contracts-file.tmpl.js';
|
|
@@ -150,16 +151,16 @@ export const generateApi = async (params) => {
|
|
|
150
151
|
const allRoutes = Object.values(generated.configuration.routes)
|
|
151
152
|
.flat()
|
|
152
153
|
.flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
|
|
153
|
-
let
|
|
154
|
+
let filterEndpoint;
|
|
154
155
|
if (params.filterEndpoints) {
|
|
155
156
|
if (typeof params.filterEndpoints === 'function') {
|
|
156
|
-
|
|
157
|
+
filterEndpoint = params.filterEndpoints;
|
|
157
158
|
}
|
|
158
159
|
else {
|
|
159
160
|
const regexps = Array.isArray(params.filterEndpoints)
|
|
160
161
|
? params.filterEndpoints
|
|
161
162
|
: [params.filterEndpoints];
|
|
162
|
-
|
|
163
|
+
filterEndpoint = (route) => regexps.some((regexpOrString) => {
|
|
163
164
|
if (!route.raw) {
|
|
164
165
|
return false;
|
|
165
166
|
}
|
|
@@ -171,63 +172,103 @@ export const generateApi = async (params) => {
|
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
else {
|
|
174
|
-
|
|
175
|
+
filterEndpoint = () => true;
|
|
175
176
|
}
|
|
176
177
|
const reservedDataContractNamesMap = new Map();
|
|
177
|
-
const
|
|
178
|
+
const collectedExportFilesFromIndexFile = [];
|
|
178
179
|
const groupsMap = new Map();
|
|
179
180
|
const nonEmptyGroups = new Set();
|
|
180
181
|
const tagsSet = new Set();
|
|
181
182
|
if (params.groupBy == null) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
collectedExportFilesFromIndexFile.push('endpoints');
|
|
184
|
+
if (params.outputType === 'one-endpoint-per-file') {
|
|
185
|
+
// #region кодогенерация 1 эндпоинт - 1 файл без группировки
|
|
186
|
+
codegenFs.createDir(path.resolve(params.output, 'endpoints'));
|
|
187
|
+
const fileNamesWithRequestInfo = [];
|
|
188
|
+
for await (const route of allRoutes) {
|
|
189
|
+
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await endpointPerFileTmpl({
|
|
190
|
+
...generated,
|
|
191
|
+
route,
|
|
192
|
+
apiParams: params,
|
|
193
|
+
codegenProcess,
|
|
194
|
+
importFileParams,
|
|
195
|
+
utils,
|
|
196
|
+
relativePathDataContracts: '../data-contracts',
|
|
197
|
+
groupName: null,
|
|
198
|
+
metaInfo: {
|
|
199
|
+
groupNames: [],
|
|
200
|
+
namespace,
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
if (Array.isArray(route.raw.tags)) {
|
|
204
|
+
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
205
|
+
}
|
|
206
|
+
reservedDataContractNames.forEach((name) => {
|
|
207
|
+
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
208
|
+
});
|
|
209
|
+
if (!filterEndpoint(route)) {
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
|
|
213
|
+
fileNamesWithRequestInfo.push(fileName);
|
|
214
|
+
codegenFs.createFile({
|
|
215
|
+
path: path.resolve(params.output, 'endpoints'),
|
|
216
|
+
fileName,
|
|
217
|
+
withPrefix: false,
|
|
218
|
+
content: requestInfoPerFileContent,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
codegenFs.createFile({
|
|
222
|
+
path: path.resolve(params.output, 'endpoints'),
|
|
223
|
+
fileName: 'index.ts',
|
|
224
|
+
withPrefix: false,
|
|
225
|
+
content: await indexTsForEndpointPerFileTmpl({
|
|
226
|
+
...generated,
|
|
227
|
+
apiParams: params,
|
|
228
|
+
codegenProcess,
|
|
229
|
+
generatedRequestFileNames: fileNamesWithRequestInfo,
|
|
230
|
+
}),
|
|
231
|
+
});
|
|
232
|
+
// #endregion
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
// #region кодогенерация несколько эндпоинтов в 1 файле без группировки
|
|
236
|
+
const { content: requestInfoPerFileContent, reservedDataContractNames } = await allEndpointPerFileTmpl({
|
|
188
237
|
...generated,
|
|
189
|
-
|
|
238
|
+
routes: allRoutes,
|
|
190
239
|
apiParams: params,
|
|
191
240
|
codegenProcess,
|
|
192
241
|
importFileParams,
|
|
193
242
|
utils,
|
|
194
|
-
relativePathDataContracts: '
|
|
243
|
+
relativePathDataContracts: './data-contracts',
|
|
195
244
|
groupName: null,
|
|
196
245
|
metaInfo: {
|
|
197
|
-
groupNames: [],
|
|
198
246
|
namespace,
|
|
247
|
+
groupNames: [],
|
|
199
248
|
},
|
|
200
249
|
});
|
|
201
|
-
if (Array.isArray(route.raw.tags)) {
|
|
202
|
-
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
203
|
-
}
|
|
204
250
|
reservedDataContractNames.forEach((name) => {
|
|
205
251
|
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
206
252
|
});
|
|
207
|
-
|
|
208
|
-
|
|
253
|
+
const filteredRoutes = allRoutes.filter(filterEndpoint);
|
|
254
|
+
const hasFilteredRoutes = filteredRoutes.length > 0;
|
|
255
|
+
if (hasFilteredRoutes) {
|
|
256
|
+
filteredRoutes.forEach((route) => {
|
|
257
|
+
if (Array.isArray(route.raw.tags)) {
|
|
258
|
+
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
const fileName = 'endpoints.ts';
|
|
262
|
+
collectedExportFilesFromIndexFile.push('endpoints');
|
|
263
|
+
codegenFs.createFile({
|
|
264
|
+
path: params.output,
|
|
265
|
+
fileName,
|
|
266
|
+
withPrefix: false,
|
|
267
|
+
content: requestInfoPerFileContent,
|
|
268
|
+
});
|
|
209
269
|
}
|
|
210
|
-
|
|
211
|
-
fileNamesWithRequestInfo.push(fileName);
|
|
212
|
-
codegenFs.createFile({
|
|
213
|
-
path: path.resolve(params.output, 'endpoints'),
|
|
214
|
-
fileName,
|
|
215
|
-
withPrefix: false,
|
|
216
|
-
content: requestInfoPerFileContent,
|
|
217
|
-
});
|
|
270
|
+
// #endregion
|
|
218
271
|
}
|
|
219
|
-
codegenFs.createFile({
|
|
220
|
-
path: path.resolve(params.output, 'endpoints'),
|
|
221
|
-
fileName: 'index.ts',
|
|
222
|
-
withPrefix: false,
|
|
223
|
-
content: await indexTsForEndpointPerFileTmpl({
|
|
224
|
-
...generated,
|
|
225
|
-
apiParams: params,
|
|
226
|
-
codegenProcess,
|
|
227
|
-
generatedRequestFileNames: fileNamesWithRequestInfo,
|
|
228
|
-
}),
|
|
229
|
-
});
|
|
230
|
-
// #endregion
|
|
231
272
|
}
|
|
232
273
|
else {
|
|
233
274
|
// #region кодогенерация с группировкой
|
|
@@ -260,18 +301,58 @@ export const generateApi = async (params) => {
|
|
|
260
301
|
continue;
|
|
261
302
|
}
|
|
262
303
|
const fileNamesWithRequestInfo = [];
|
|
263
|
-
|
|
264
|
-
codegenFs.createDir(
|
|
304
|
+
const groupDirectory = path.resolve(params.output, _.kebabCase(groupName));
|
|
305
|
+
codegenFs.createDir(groupDirectory);
|
|
265
306
|
let hasFilteredRoutes = false;
|
|
266
|
-
|
|
267
|
-
|
|
307
|
+
if (params.outputType === 'one-endpoint-per-file') {
|
|
308
|
+
// #region Генерация одного эндпоинта на 1 файл
|
|
309
|
+
codegenFs.createDir(path.resolve(groupDirectory, 'endpoints'));
|
|
310
|
+
for await (const route of routes) {
|
|
311
|
+
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await endpointPerFileTmpl({
|
|
312
|
+
...generated,
|
|
313
|
+
route,
|
|
314
|
+
apiParams: params,
|
|
315
|
+
codegenProcess,
|
|
316
|
+
importFileParams,
|
|
317
|
+
utils,
|
|
318
|
+
relativePathDataContracts: '../../data-contracts',
|
|
319
|
+
groupName,
|
|
320
|
+
metaInfo: {
|
|
321
|
+
namespace,
|
|
322
|
+
groupNames: [],
|
|
323
|
+
},
|
|
324
|
+
});
|
|
325
|
+
reservedDataContractNames.forEach((name) => {
|
|
326
|
+
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
327
|
+
});
|
|
328
|
+
if (!filterEndpoint(route)) {
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
hasFilteredRoutes = true;
|
|
332
|
+
if (Array.isArray(route.raw.tags)) {
|
|
333
|
+
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
334
|
+
}
|
|
335
|
+
const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
|
|
336
|
+
fileNamesWithRequestInfo.push(fileName);
|
|
337
|
+
codegenFs.createFile({
|
|
338
|
+
path: path.resolve(params.output, _.kebabCase(groupName), 'endpoints'),
|
|
339
|
+
fileName,
|
|
340
|
+
withPrefix: false,
|
|
341
|
+
content: requestInfoPerFileContent,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
// #endregion
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
// #region Генерация нескольких эндпоинтов на 1 файл
|
|
348
|
+
const { content: requestInfoPerFileContent, reservedDataContractNames, } = await allEndpointPerFileTmpl({
|
|
268
349
|
...generated,
|
|
269
|
-
|
|
350
|
+
routes,
|
|
270
351
|
apiParams: params,
|
|
271
352
|
codegenProcess,
|
|
272
353
|
importFileParams,
|
|
273
354
|
utils,
|
|
274
|
-
relativePathDataContracts: '
|
|
355
|
+
relativePathDataContracts: '../data-contracts',
|
|
275
356
|
groupName,
|
|
276
357
|
metaInfo: {
|
|
277
358
|
namespace,
|
|
@@ -281,21 +362,24 @@ export const generateApi = async (params) => {
|
|
|
281
362
|
reservedDataContractNames.forEach((name) => {
|
|
282
363
|
reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
|
|
283
364
|
});
|
|
284
|
-
|
|
285
|
-
|
|
365
|
+
const filteredRoutes = routes.filter(filterEndpoint);
|
|
366
|
+
hasFilteredRoutes = filteredRoutes.length > 0;
|
|
367
|
+
if (hasFilteredRoutes) {
|
|
368
|
+
filteredRoutes.forEach((route) => {
|
|
369
|
+
if (Array.isArray(route.raw.tags)) {
|
|
370
|
+
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
const fileName = 'endpoints.ts';
|
|
374
|
+
fileNamesWithRequestInfo.push(fileName);
|
|
375
|
+
codegenFs.createFile({
|
|
376
|
+
path: groupDirectory,
|
|
377
|
+
fileName,
|
|
378
|
+
withPrefix: false,
|
|
379
|
+
content: requestInfoPerFileContent,
|
|
380
|
+
});
|
|
286
381
|
}
|
|
287
|
-
|
|
288
|
-
if (Array.isArray(route.raw.tags)) {
|
|
289
|
-
route.raw.tags.forEach((tag) => tagsSet.add(tag));
|
|
290
|
-
}
|
|
291
|
-
const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
|
|
292
|
-
fileNamesWithRequestInfo.push(fileName);
|
|
293
|
-
codegenFs.createFile({
|
|
294
|
-
path: path.resolve(params.output, _.kebabCase(groupName), 'endpoints'),
|
|
295
|
-
fileName,
|
|
296
|
-
withPrefix: false,
|
|
297
|
-
content: requestInfoPerFileContent,
|
|
298
|
-
});
|
|
382
|
+
// #endregion
|
|
299
383
|
}
|
|
300
384
|
if (hasFilteredRoutes) {
|
|
301
385
|
nonEmptyGroups.add(groupName);
|
|
@@ -303,25 +387,27 @@ export const generateApi = async (params) => {
|
|
|
303
387
|
? params.formatExportGroupName(_.camelCase(groupName), utils)
|
|
304
388
|
: _.camelCase(groupName);
|
|
305
389
|
codegenFs.createFile({
|
|
306
|
-
path:
|
|
390
|
+
path: groupDirectory,
|
|
307
391
|
fileName: 'index.ts',
|
|
308
392
|
withPrefix: false,
|
|
309
393
|
content: `${LINTERS_IGNORE}
|
|
310
394
|
export * as ${exportGroupName} from './endpoints';
|
|
311
395
|
`,
|
|
312
396
|
});
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
397
|
+
if (params.outputType === 'one-endpoint-per-file') {
|
|
398
|
+
codegenFs.createFile({
|
|
399
|
+
path: path.resolve(groupDirectory, 'endpoints'),
|
|
400
|
+
fileName: 'index.ts',
|
|
401
|
+
withPrefix: false,
|
|
402
|
+
content: await indexTsForEndpointPerFileTmpl({
|
|
403
|
+
...generated,
|
|
404
|
+
apiParams: params,
|
|
405
|
+
codegenProcess,
|
|
406
|
+
generatedRequestFileNames: fileNamesWithRequestInfo,
|
|
407
|
+
}),
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
collectedExportFilesFromIndexFile.push(_.kebabCase(groupName));
|
|
325
411
|
}
|
|
326
412
|
else {
|
|
327
413
|
codegenFs.removeDir(path.resolve(params.output, _.kebabCase(groupName)));
|
|
@@ -369,7 +455,7 @@ export * as ${exportGroupName} from './endpoints';
|
|
|
369
455
|
withPrefix: false,
|
|
370
456
|
content: await allExportsTmpl({
|
|
371
457
|
...generated,
|
|
372
|
-
collectedExportFiles,
|
|
458
|
+
collectedExportFiles: collectedExportFilesFromIndexFile,
|
|
373
459
|
metaInfo,
|
|
374
460
|
utils,
|
|
375
461
|
}),
|
|
@@ -390,7 +476,7 @@ export * as ${namespace} from './__exports';
|
|
|
390
476
|
withPrefix: false,
|
|
391
477
|
content: await allExportsTmpl({
|
|
392
478
|
...generated,
|
|
393
|
-
collectedExportFiles,
|
|
479
|
+
collectedExportFiles: collectedExportFilesFromIndexFile,
|
|
394
480
|
metaInfo,
|
|
395
481
|
utils,
|
|
396
482
|
}),
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AnyObject, Maybe } from 'yummies/utils/types';
|
|
2
|
+
import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from '../index.js';
|
|
3
|
+
export interface AllEndpointPerFileTmplParams extends AnyObject {
|
|
4
|
+
routes: AnyObject[];
|
|
5
|
+
configuration: AnyObject;
|
|
6
|
+
apiParams: GenerateQueryApiParams;
|
|
7
|
+
codegenProcess: CodegenProcess;
|
|
8
|
+
importFileParams: AllImportFileParams;
|
|
9
|
+
utils: CodegenDataUtils;
|
|
10
|
+
relativePathDataContracts: string;
|
|
11
|
+
groupName: Maybe<string>;
|
|
12
|
+
metaInfo: Maybe<MetaInfo>;
|
|
13
|
+
}
|
|
14
|
+
export declare const allEndpointPerFileTmpl: ({ routes, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }: AllEndpointPerFileTmplParams) => Promise<{
|
|
15
|
+
reservedDataContractNames: string[];
|
|
16
|
+
content: any;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=all-endpoints-per-file.tmpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-endpoints-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-endpoints-per-file.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,QAAQ,EACT,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,4BAA6B,SAAQ,SAAS;IAC7D,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,KAAK,EAAE,gBAAgB,CAAC;IACxB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,sBAAsB,GAAU,iIAU1C,4BAA4B;;;EA+H9B,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { LINTERS_IGNORE } from './constants.js';
|
|
2
|
+
import { dataContractTmpl } from './data-contract.tmpl.js';
|
|
3
|
+
import { endpointJSDocTmpl } from './endpoint-jsdoc.tmpl.js';
|
|
4
|
+
import { newEndpointTmpl } from './new-endpoint.tmpl.js';
|
|
5
|
+
export const allEndpointPerFileTmpl = async ({ routes, configuration, apiParams, formatTSContent, importFileParams, utils, relativePathDataContracts, groupName, metaInfo, }) => {
|
|
6
|
+
const { _ } = utils;
|
|
7
|
+
const dataContractNamesInThisFile = [];
|
|
8
|
+
const newEndpointTemplates = routes.map((route) => {
|
|
9
|
+
const newEndpointTemplateData = newEndpointTmpl({
|
|
10
|
+
route,
|
|
11
|
+
configuration,
|
|
12
|
+
apiParams,
|
|
13
|
+
importFileParams,
|
|
14
|
+
utils,
|
|
15
|
+
groupName,
|
|
16
|
+
metaInfo,
|
|
17
|
+
});
|
|
18
|
+
const { reservedDataContractNames } = newEndpointTemplateData;
|
|
19
|
+
const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
|
|
20
|
+
reservedDataContractNames.forEach((reservedDataContractName) => {
|
|
21
|
+
if (!dataContactNames.has(reservedDataContractName)) {
|
|
22
|
+
dataContractNamesInThisFile.push(reservedDataContractName);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
return { ...newEndpointTemplateData, route };
|
|
26
|
+
});
|
|
27
|
+
let metaInfoImport = '';
|
|
28
|
+
if (metaInfo) {
|
|
29
|
+
metaInfoImport = `import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "${groupName ? '../' : './'}meta-info";`;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
reservedDataContractNames: dataContractNamesInThisFile,
|
|
33
|
+
content: await formatTSContent(`${LINTERS_IGNORE}
|
|
34
|
+
import {
|
|
35
|
+
RequestParams,
|
|
36
|
+
HttpResponse,
|
|
37
|
+
HttpMultistatusResponse,
|
|
38
|
+
} from "${apiParams.libImports?.['mobx-tanstack-query-api'] ?? 'mobx-tanstack-query-api'}";
|
|
39
|
+
import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
|
|
40
|
+
import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
|
|
41
|
+
import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
|
|
42
|
+
${metaInfoImport}
|
|
43
|
+
|
|
44
|
+
${configuration.modelTypes.length > 0
|
|
45
|
+
? `
|
|
46
|
+
import { ${configuration.modelTypes
|
|
47
|
+
.map((it) => it.name)
|
|
48
|
+
.filter((it) => !dataContractNamesInThisFile.includes(it))} } from "${relativePathDataContracts}";
|
|
49
|
+
`
|
|
50
|
+
: ''}
|
|
51
|
+
|
|
52
|
+
${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
|
|
53
|
+
const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
|
|
54
|
+
if (!modelType) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
const contractType = await dataContractTmpl({
|
|
58
|
+
configuration,
|
|
59
|
+
contract: modelType,
|
|
60
|
+
addExportKeyword: true,
|
|
61
|
+
});
|
|
62
|
+
return contractType;
|
|
63
|
+
})))
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.join('\n\n')}
|
|
66
|
+
|
|
67
|
+
${(await Promise.all(newEndpointTemplates.map(async ({ content: requestInfoInstanceContent, localModelTypes, route, }) => {
|
|
68
|
+
return `
|
|
69
|
+
${(await Promise.all(localModelTypes.map(async (modelType) => {
|
|
70
|
+
const contractType = await dataContractTmpl({
|
|
71
|
+
configuration,
|
|
72
|
+
contract: modelType,
|
|
73
|
+
addExportKeyword: true,
|
|
74
|
+
});
|
|
75
|
+
return contractType;
|
|
76
|
+
})))
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join('\n\n')}
|
|
79
|
+
|
|
80
|
+
${endpointJSDocTmpl({
|
|
81
|
+
route,
|
|
82
|
+
configuration,
|
|
83
|
+
apiParams,
|
|
84
|
+
})}
|
|
85
|
+
export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
|
|
86
|
+
`;
|
|
87
|
+
})))
|
|
88
|
+
.filter(Boolean)
|
|
89
|
+
.join('\n\n')}
|
|
90
|
+
`),
|
|
91
|
+
};
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-tanstack-query-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.110",
|
|
4
4
|
"keywords": [],
|
|
5
5
|
"author": "js2me",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,6 +68,11 @@
|
|
|
68
68
|
"default": "./codegen/index.js",
|
|
69
69
|
"types": "./codegen/index.d.ts"
|
|
70
70
|
},
|
|
71
|
+
"./codegen/templates/all-endpoints-per-file.tmpl": {
|
|
72
|
+
"import": "./codegen/templates/all-endpoints-per-file.tmpl.js",
|
|
73
|
+
"default": "./codegen/templates/all-endpoints-per-file.tmpl.js",
|
|
74
|
+
"types": "./codegen/templates/all-endpoints-per-file.tmpl.d.ts"
|
|
75
|
+
},
|
|
71
76
|
"./codegen/templates/all-exports.tmpl": {
|
|
72
77
|
"import": "./codegen/templates/all-exports.tmpl.js",
|
|
73
78
|
"default": "./codegen/templates/all-exports.tmpl.js",
|
package/runtime/http-client.d.ts
CHANGED
|
@@ -73,7 +73,7 @@ export declare class HttpClient<TMeta = unknown> {
|
|
|
73
73
|
protected toQueryString(rawQuery?: QueryParamsType): string;
|
|
74
74
|
private contentFormatters;
|
|
75
75
|
protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
|
|
76
|
-
|
|
76
|
+
protected formatResponse(responseFormat: FullRequestParams['format'], raw: Response): Promise<AnyHttpResponse>;
|
|
77
77
|
buildUrl: (params: FullRequestParams) => string;
|
|
78
78
|
request<T, E>(fullParams: FullRequestParams): Promise<HttpResponse<T, E>>;
|
|
79
79
|
request<THttpResponse extends HttpResponse<any, any>>(fullParams: FullRequestParams): Promise<THttpResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/runtime/http-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/E,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC;AAC3D,MAAM,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC;AAEnE,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC;IAClE,yEAAyE;IACzE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB;IACnB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,kEAAkE;IAClE,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,mBAAmB;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IAC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,CAAC,MAAM,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAgBrD,OAAO,GAAI,MAAM,KAAK,GAAG,IAAI,UAElC;IAEK,cAAc,GAAI,UAAU,OAAO,UAExC;IAEF,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAOlD,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM;IAI3D,SAAS,CAAC,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM;IAKhE,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,eAAe,GAAG,MAAM;IAkB3D,OAAO,CAAC,iBAAiB,CA0BvB;IAEF,SAAS,CAAC,kBAAkB,CAC1B,OAAO,EAAE,aAAa,EACtB,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa;cAaA,cAAc,CAC5B,cAAc,EAAE,iBAAiB,CAAC,QAAQ,CAAC,EAC3C,GAAG,EAAE,QAAQ,GACZ,OAAO,CAAC,eAAe,CAAC;IA8BpB,QAAQ,GAAI,QAAQ,iBAAiB,YAgB1C;IAEK,OAAO,CAAC,CAAC,EAAE,CAAC,EACjB,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACvB,OAAO,CAAC,aAAa,SAAS,YAAY,CAAC,GAAG,EAAE,GAAG,CAAC,EACzD,UAAU,EAAE,iBAAiB,GAC5B,OAAO,CAAC,aAAa,CAAC;CA+C1B"}
|
package/runtime/http-client.js
CHANGED
|
@@ -164,7 +164,6 @@ export class HttpClient {
|
|
|
164
164
|
const payloadFormatter = this.contentFormatters[contentType];
|
|
165
165
|
const responseFormat = format || requestParams.format;
|
|
166
166
|
const url = this.buildUrl(fullParams);
|
|
167
|
-
const responseFormatter = this.formatResponse.bind(this, responseFormat);
|
|
168
167
|
let headers;
|
|
169
168
|
if (requestParams.headers instanceof Headers) {
|
|
170
169
|
headers = requestParams.headers;
|
|
@@ -183,7 +182,7 @@ export class HttpClient {
|
|
|
183
182
|
headers,
|
|
184
183
|
body: body == null ? null : payloadFormatter(body),
|
|
185
184
|
})
|
|
186
|
-
.then(
|
|
187
|
-
.catch(
|
|
185
|
+
.then((response) => this.formatResponse(responseFormat, response))
|
|
186
|
+
.catch((error) => this.formatResponse(responseFormat, error));
|
|
188
187
|
}
|
|
189
188
|
}
|