mobx-tanstack-query-api 0.22.1 → 0.23.1

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.
Files changed (65) hide show
  1. package/codegen/index.cjs +57 -76
  2. package/codegen/index.d.cts.map +1 -1
  3. package/codegen/index.d.ts.map +1 -1
  4. package/codegen/index.js +57 -76
  5. package/codegen/templates/all-endpoints-per-file.tmpl.d.cts +3 -2
  6. package/codegen/templates/all-endpoints-per-file.tmpl.d.cts.map +1 -1
  7. package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +3 -2
  8. package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +1 -1
  9. package/codegen/templates/endpoint-per-file.tmpl.d.cts +3 -2
  10. package/codegen/templates/endpoint-per-file.tmpl.d.cts.map +1 -1
  11. package/codegen/templates/endpoint-per-file.tmpl.d.ts +3 -2
  12. package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +1 -1
  13. package/codegen/templates/new-endpoint.tmpl.cjs +23 -13
  14. package/codegen/templates/new-endpoint.tmpl.d.cts +5 -8
  15. package/codegen/templates/new-endpoint.tmpl.d.cts.map +1 -1
  16. package/codegen/templates/new-endpoint.tmpl.d.ts +5 -8
  17. package/codegen/templates/new-endpoint.tmpl.d.ts.map +1 -1
  18. package/codegen/templates/new-endpoint.tmpl.js +23 -13
  19. package/codegen/types/base-tmpl-params.d.cts +5 -3
  20. package/codegen/types/base-tmpl-params.d.cts.map +1 -1
  21. package/codegen/types/base-tmpl-params.d.ts +5 -3
  22. package/codegen/types/base-tmpl-params.d.ts.map +1 -1
  23. package/codegen/types/generate-query-api-params.d.cts +7 -5
  24. package/codegen/types/generate-query-api-params.d.cts.map +1 -1
  25. package/codegen/types/generate-query-api-params.d.ts +7 -5
  26. package/codegen/types/generate-query-api-params.d.ts.map +1 -1
  27. package/codegen/types/type-info.cjs +2 -0
  28. package/codegen/types/type-info.d.cts +4 -0
  29. package/codegen/types/type-info.d.cts.map +1 -0
  30. package/codegen/types/type-info.d.ts +4 -0
  31. package/codegen/types/type-info.d.ts.map +1 -0
  32. package/codegen/types/type-info.js +1 -0
  33. package/codegen/utils/create-short-model-type.cjs +12 -0
  34. package/codegen/utils/create-short-model-type.d.cts +5 -0
  35. package/codegen/utils/create-short-model-type.d.cts.map +1 -0
  36. package/codegen/utils/create-short-model-type.d.ts +5 -0
  37. package/codegen/utils/create-short-model-type.d.ts.map +1 -0
  38. package/codegen/utils/create-short-model-type.js +8 -0
  39. package/codegen/utils/unpack-filter-option.cjs +3 -0
  40. package/codegen/utils/unpack-filter-option.d.cts +5 -2
  41. package/codegen/utils/unpack-filter-option.d.cts.map +1 -1
  42. package/codegen/utils/unpack-filter-option.d.ts +5 -2
  43. package/codegen/utils/unpack-filter-option.d.ts.map +1 -1
  44. package/codegen/utils/unpack-filter-option.js +3 -0
  45. package/package.json +1 -1
  46. package/runtime/endpoint-mutation.cjs +2 -1
  47. package/runtime/endpoint-mutation.d.cts +1 -3
  48. package/runtime/endpoint-mutation.d.cts.map +1 -1
  49. package/runtime/endpoint-mutation.d.ts +1 -3
  50. package/runtime/endpoint-mutation.d.ts.map +1 -1
  51. package/runtime/endpoint-mutation.js +2 -1
  52. package/runtime/endpoint-mutation.types.d.cts +7 -1
  53. package/runtime/endpoint-mutation.types.d.cts.map +1 -1
  54. package/runtime/endpoint-mutation.types.d.ts +7 -1
  55. package/runtime/endpoint-mutation.types.d.ts.map +1 -1
  56. package/runtime/endpoint-query.cjs +3 -2
  57. package/runtime/endpoint-query.d.cts +1 -1
  58. package/runtime/endpoint-query.d.cts.map +1 -1
  59. package/runtime/endpoint-query.d.ts +1 -1
  60. package/runtime/endpoint-query.d.ts.map +1 -1
  61. package/runtime/endpoint-query.js +3 -2
  62. package/runtime/endpoint-query.types.d.cts +2 -0
  63. package/runtime/endpoint-query.types.d.cts.map +1 -1
  64. package/runtime/endpoint-query.types.d.ts +2 -0
  65. package/runtime/endpoint-query.types.d.ts.map +1 -1
package/codegen/index.cjs CHANGED
@@ -118,20 +118,56 @@ const generateApi = async (params) => {
118
118
  }
119
119
  return inputData;
120
120
  };
121
+ const generatedExtra = params.mixinInput
122
+ ? await (0, swagger_typescript_api_1.generateApi)({
123
+ ...swaggerTypescriptApiCodegenBaseParams,
124
+ ...inputToCodegenInput(params.mixinInput),
125
+ hooks: {
126
+ onPrepareConfig: (config) => {
127
+ config.routes.combined?.forEach((routeInfo) => {
128
+ routeInfo.routes.sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
129
+ });
130
+ },
131
+ onFormatRouteName: (routeInfo, usageRouteName) => {
132
+ let formattedRouteName = usageRouteName;
133
+ if (params.addPathSegmentToRouteName === true ||
134
+ typeof params.addPathSegmentToRouteName === 'number') {
135
+ const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === 'number'
136
+ ? params.addPathSegmentToRouteName
137
+ : 0;
138
+ const pathSegments = routeInfo.route.split('/').filter(Boolean);
139
+ const { _ } = codegenProcess.getRenderTemplateData()
140
+ .utils;
141
+ formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
142
+ }
143
+ const endpointName = formattedRouteName;
144
+ return (params?.formatEndpointName?.(endpointName, routeInfo) ??
145
+ swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(routeInfo, endpointName) ??
146
+ endpointName);
147
+ },
148
+ },
149
+ })
150
+ : null;
121
151
  const generated = await (0, swagger_typescript_api_1.generateApi)({
122
152
  ...swaggerTypescriptApiCodegenBaseParams,
123
153
  ...inputToCodegenInput(params.input),
124
154
  hooks: {
125
155
  onInit: (configuration, codeGenProcessFromInit) => {
126
156
  codegenProcess = codeGenProcessFromInit;
127
- // @ts-expect-error
128
- configuration.swaggerSchema.components =
129
- // @ts-expect-error
130
- configuration.swaggerSchema.components || {};
131
- // @ts-expect-error
132
- configuration.swaggerSchema.components.schemas =
133
- // @ts-expect-error
134
- configuration.swaggerSchema.components.schemas || {};
157
+ const resultSwaggerSchema = configuration.swaggerSchema;
158
+ const extraSwaggerSchema = generatedExtra?.configuration?.config
159
+ ?.swaggerSchema;
160
+ resultSwaggerSchema.components = resultSwaggerSchema.components || {};
161
+ resultSwaggerSchema.components.schemas =
162
+ resultSwaggerSchema.components.schemas || {};
163
+ resultSwaggerSchema.paths = {
164
+ ...resultSwaggerSchema.paths,
165
+ ...extraSwaggerSchema?.paths,
166
+ };
167
+ resultSwaggerSchema.components.schemas = {
168
+ ...resultSwaggerSchema.components.schemas,
169
+ ...extraSwaggerSchema?.components?.schemas,
170
+ };
135
171
  return swaggerTypescriptApiCodegenBaseParams?.hooks?.onInit?.(configuration, codeGenProcessFromInit);
136
172
  },
137
173
  onPrepareConfig: (config) => {
@@ -159,48 +195,9 @@ const generateApi = async (params) => {
159
195
  },
160
196
  },
161
197
  });
162
- const generatedExtra = params.mixinInput
163
- ? await (0, swagger_typescript_api_1.generateApi)({
164
- ...swaggerTypescriptApiCodegenBaseParams,
165
- ...inputToCodegenInput(params.mixinInput),
166
- hooks: {
167
- onPrepareConfig: (config) => {
168
- config.routes.combined?.forEach((routeInfo) => {
169
- routeInfo.routes.sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
170
- });
171
- },
172
- onFormatRouteName: (routeInfo, usageRouteName) => {
173
- let formattedRouteName = usageRouteName;
174
- if (params.addPathSegmentToRouteName === true ||
175
- typeof params.addPathSegmentToRouteName === 'number') {
176
- const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === 'number'
177
- ? params.addPathSegmentToRouteName
178
- : 0;
179
- const pathSegments = routeInfo.route.split('/').filter(Boolean);
180
- const { _ } = codegenProcess.getRenderTemplateData()
181
- .utils;
182
- formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
183
- }
184
- const endpointName = formattedRouteName;
185
- return (params?.formatEndpointName?.(endpointName, routeInfo) ??
186
- swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(routeInfo, endpointName) ??
187
- endpointName);
188
- },
189
- },
190
- })
191
- : null;
192
198
  //#endregion
193
199
  const utils = codegenProcess.getRenderTemplateData()
194
200
  .utils;
195
- const baseTmplParams = {
196
- ...generated,
197
- codegenParams: params,
198
- configuration: generated.configuration,
199
- formatTSContent: generated.formatTSContent,
200
- codegenProcess,
201
- importFileParams,
202
- utils,
203
- };
204
201
  const { _ } = utils;
205
202
  let namespace = null;
206
203
  if (params.namespace) {
@@ -214,39 +211,23 @@ const generateApi = async (params) => {
214
211
  const codegenFs = codegenProcess.fileSystem;
215
212
  codegenFs.cleanDir(params.output);
216
213
  codegenFs.createDir(params.output);
217
- if (generatedExtra) {
218
- const allExtraOperationIdsSet = new Set([
219
- ...(generatedExtra.configuration.routes.outOfModule?.map((r) => r.raw.operationId) ?? []),
220
- ...(generatedExtra.configuration.routes.combined?.flatMap((r) => r.routes.map((r) => r.raw.operationId)) ?? []),
221
- ]);
222
- const allExtraModelTypesSet = new Set([
223
- ...generatedExtra.configuration.modelTypes.map((m) => m.name),
224
- ]);
225
- generated.configuration.routes.outOfModule =
226
- generated.configuration.routes.outOfModule ?? [];
227
- generated.configuration.routes.outOfModule = [
228
- ...generated.configuration.routes.outOfModule.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
229
- ...generatedExtra.configuration.routes.outOfModule,
230
- ];
231
- generated.configuration.routes.combined =
232
- generated.configuration.routes.combined ?? [];
233
- generated.configuration.routes.combined.forEach((group) => {
234
- group.routes = [
235
- ...group.routes.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
236
- ...(generatedExtra.configuration.routes.combined?.find((g) => g.moduleName === group.moduleName)?.routes ?? []),
237
- ];
238
- });
239
- const notExistedCombinedExtra = generatedExtra.configuration.routes.combined?.filter((group) => !generated.configuration.routes.combined?.some((g) => g.moduleName === group.moduleName));
240
- generated.configuration.routes.combined.push(...(notExistedCombinedExtra ?? []));
241
- generated.configuration.modelTypes = [
242
- ...generated.configuration.modelTypes.filter((it) => !allExtraModelTypesSet.has(it.name)),
243
- ...generatedExtra.configuration.modelTypes,
244
- ];
245
- }
214
+ const filterTypes = (0, unpack_filter_option_js_1.unpackFilterOption)(params.filterTypes, (modelType) => modelType.name);
215
+ generated.configuration.modelTypes =
216
+ generated.configuration.modelTypes.filter((modelType) => filterTypes(modelType));
246
217
  const allRoutes = Object.values(generated.configuration.routes)
247
218
  .flat()
248
219
  .flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
249
220
  const filterEndpoint = (0, unpack_filter_option_js_1.unpackFilterOption)(params.filterEndpoints, (route) => route.raw?.operationId || '');
221
+ const baseTmplParams = {
222
+ ...generated,
223
+ codegenParams: params,
224
+ configuration: generated.configuration,
225
+ formatTSContent: generated.formatTSContent,
226
+ codegenProcess,
227
+ importFileParams,
228
+ utils,
229
+ filterTypes,
230
+ };
250
231
  const reservedDataContractNamesMap = new Map();
251
232
  const collectedExportFilesFromIndexFile = [];
252
233
  const groupsMap = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,0BAAyB;AAI1B,kCAAiC;AAOjC,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KAExD,OAAO,CAAC,IAAI,CAstBd,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,0BAAyB;AAI1B,kCAAiC;AAOjC,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KAExD,OAAO,CAAC,IAAI,CAkrBd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,yBAAyB;AAI1B,iCAAiC;AAOjC,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KAExD,OAAO,CAAC,IAAI,CAstBd,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAIV,sBAAsB,EAEvB,yBAAyB;AAI1B,iCAAiC;AAOjC,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KAExD,OAAO,CAAC,IAAI,CAkrBd,CAAC"}
package/codegen/index.js CHANGED
@@ -98,20 +98,56 @@ export const generateApi = async (params) => {
98
98
  }
99
99
  return inputData;
100
100
  };
101
+ const generatedExtra = params.mixinInput
102
+ ? await generateApiFromSwagger({
103
+ ...swaggerTypescriptApiCodegenBaseParams,
104
+ ...inputToCodegenInput(params.mixinInput),
105
+ hooks: {
106
+ onPrepareConfig: (config) => {
107
+ config.routes.combined?.forEach((routeInfo) => {
108
+ routeInfo.routes.sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
109
+ });
110
+ },
111
+ onFormatRouteName: (routeInfo, usageRouteName) => {
112
+ let formattedRouteName = usageRouteName;
113
+ if (params.addPathSegmentToRouteName === true ||
114
+ typeof params.addPathSegmentToRouteName === 'number') {
115
+ const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === 'number'
116
+ ? params.addPathSegmentToRouteName
117
+ : 0;
118
+ const pathSegments = routeInfo.route.split('/').filter(Boolean);
119
+ const { _ } = codegenProcess.getRenderTemplateData()
120
+ .utils;
121
+ formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
122
+ }
123
+ const endpointName = formattedRouteName;
124
+ return (params?.formatEndpointName?.(endpointName, routeInfo) ??
125
+ swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(routeInfo, endpointName) ??
126
+ endpointName);
127
+ },
128
+ },
129
+ })
130
+ : null;
101
131
  const generated = await generateApiFromSwagger({
102
132
  ...swaggerTypescriptApiCodegenBaseParams,
103
133
  ...inputToCodegenInput(params.input),
104
134
  hooks: {
105
135
  onInit: (configuration, codeGenProcessFromInit) => {
106
136
  codegenProcess = codeGenProcessFromInit;
107
- // @ts-expect-error
108
- configuration.swaggerSchema.components =
109
- // @ts-expect-error
110
- configuration.swaggerSchema.components || {};
111
- // @ts-expect-error
112
- configuration.swaggerSchema.components.schemas =
113
- // @ts-expect-error
114
- configuration.swaggerSchema.components.schemas || {};
137
+ const resultSwaggerSchema = configuration.swaggerSchema;
138
+ const extraSwaggerSchema = generatedExtra?.configuration?.config
139
+ ?.swaggerSchema;
140
+ resultSwaggerSchema.components = resultSwaggerSchema.components || {};
141
+ resultSwaggerSchema.components.schemas =
142
+ resultSwaggerSchema.components.schemas || {};
143
+ resultSwaggerSchema.paths = {
144
+ ...resultSwaggerSchema.paths,
145
+ ...extraSwaggerSchema?.paths,
146
+ };
147
+ resultSwaggerSchema.components.schemas = {
148
+ ...resultSwaggerSchema.components.schemas,
149
+ ...extraSwaggerSchema?.components?.schemas,
150
+ };
115
151
  return swaggerTypescriptApiCodegenBaseParams?.hooks?.onInit?.(configuration, codeGenProcessFromInit);
116
152
  },
117
153
  onPrepareConfig: (config) => {
@@ -139,48 +175,9 @@ export const generateApi = async (params) => {
139
175
  },
140
176
  },
141
177
  });
142
- const generatedExtra = params.mixinInput
143
- ? await generateApiFromSwagger({
144
- ...swaggerTypescriptApiCodegenBaseParams,
145
- ...inputToCodegenInput(params.mixinInput),
146
- hooks: {
147
- onPrepareConfig: (config) => {
148
- config.routes.combined?.forEach((routeInfo) => {
149
- routeInfo.routes.sort((routeA, routeB) => routeA.routeName.usage.localeCompare(routeB.routeName.usage));
150
- });
151
- },
152
- onFormatRouteName: (routeInfo, usageRouteName) => {
153
- let formattedRouteName = usageRouteName;
154
- if (params.addPathSegmentToRouteName === true ||
155
- typeof params.addPathSegmentToRouteName === 'number') {
156
- const pathSegmentForSuffix = typeof params.addPathSegmentToRouteName === 'number'
157
- ? params.addPathSegmentToRouteName
158
- : 0;
159
- const pathSegments = routeInfo.route.split('/').filter(Boolean);
160
- const { _ } = codegenProcess.getRenderTemplateData()
161
- .utils;
162
- formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
163
- }
164
- const endpointName = formattedRouteName;
165
- return (params?.formatEndpointName?.(endpointName, routeInfo) ??
166
- swaggerTypescriptApiCodegenBaseParams?.hooks?.onFormatRouteName?.(routeInfo, endpointName) ??
167
- endpointName);
168
- },
169
- },
170
- })
171
- : null;
172
178
  //#endregion
173
179
  const utils = codegenProcess.getRenderTemplateData()
174
180
  .utils;
175
- const baseTmplParams = {
176
- ...generated,
177
- codegenParams: params,
178
- configuration: generated.configuration,
179
- formatTSContent: generated.formatTSContent,
180
- codegenProcess,
181
- importFileParams,
182
- utils,
183
- };
184
181
  const { _ } = utils;
185
182
  let namespace = null;
186
183
  if (params.namespace) {
@@ -194,39 +191,23 @@ export const generateApi = async (params) => {
194
191
  const codegenFs = codegenProcess.fileSystem;
195
192
  codegenFs.cleanDir(params.output);
196
193
  codegenFs.createDir(params.output);
197
- if (generatedExtra) {
198
- const allExtraOperationIdsSet = new Set([
199
- ...(generatedExtra.configuration.routes.outOfModule?.map((r) => r.raw.operationId) ?? []),
200
- ...(generatedExtra.configuration.routes.combined?.flatMap((r) => r.routes.map((r) => r.raw.operationId)) ?? []),
201
- ]);
202
- const allExtraModelTypesSet = new Set([
203
- ...generatedExtra.configuration.modelTypes.map((m) => m.name),
204
- ]);
205
- generated.configuration.routes.outOfModule =
206
- generated.configuration.routes.outOfModule ?? [];
207
- generated.configuration.routes.outOfModule = [
208
- ...generated.configuration.routes.outOfModule.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
209
- ...generatedExtra.configuration.routes.outOfModule,
210
- ];
211
- generated.configuration.routes.combined =
212
- generated.configuration.routes.combined ?? [];
213
- generated.configuration.routes.combined.forEach((group) => {
214
- group.routes = [
215
- ...group.routes.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
216
- ...(generatedExtra.configuration.routes.combined?.find((g) => g.moduleName === group.moduleName)?.routes ?? []),
217
- ];
218
- });
219
- const notExistedCombinedExtra = generatedExtra.configuration.routes.combined?.filter((group) => !generated.configuration.routes.combined?.some((g) => g.moduleName === group.moduleName));
220
- generated.configuration.routes.combined.push(...(notExistedCombinedExtra ?? []));
221
- generated.configuration.modelTypes = [
222
- ...generated.configuration.modelTypes.filter((it) => !allExtraModelTypesSet.has(it.name)),
223
- ...generatedExtra.configuration.modelTypes,
224
- ];
225
- }
194
+ const filterTypes = unpackFilterOption(params.filterTypes, (modelType) => modelType.name);
195
+ generated.configuration.modelTypes =
196
+ generated.configuration.modelTypes.filter((modelType) => filterTypes(modelType));
226
197
  const allRoutes = Object.values(generated.configuration.routes)
227
198
  .flat()
228
199
  .flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
229
200
  const filterEndpoint = unpackFilterOption(params.filterEndpoints, (route) => route.raw?.operationId || '');
201
+ const baseTmplParams = {
202
+ ...generated,
203
+ codegenParams: params,
204
+ configuration: generated.configuration,
205
+ formatTSContent: generated.formatTSContent,
206
+ codegenProcess,
207
+ importFileParams,
208
+ utils,
209
+ filterTypes,
210
+ };
230
211
  const reservedDataContractNamesMap = new Map();
231
212
  const collectedExportFilesFromIndexFile = [];
232
213
  const groupsMap = new Map();
@@ -1,7 +1,8 @@
1
- import type { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { ParsedRoute } from 'swagger-typescript-api';
2
+ import type { Maybe } from 'yummies/utils/types';
2
3
  import type { BaseTmplParams, MetaInfo } from "../types/index.cjs";
3
4
  export interface AllEndpointPerFileTmplParams extends BaseTmplParams {
4
- routes: AnyObject[];
5
+ routes: ParsedRoute[];
5
6
  groupName: Maybe<string>;
6
7
  metaInfo: Maybe<MetaInfo>;
7
8
  relativePathDataContracts: string;
@@ -1 +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":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,2BAA0B;AAMlE,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B;;;EA8IrC,CAAC"}
1
+ {"version":3,"file":"all-endpoints-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-endpoints-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,2BAA0B;AAMlE,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B;;;EA8IrC,CAAC"}
@@ -1,7 +1,8 @@
1
- import type { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { ParsedRoute } from 'swagger-typescript-api';
2
+ import type { Maybe } from 'yummies/utils/types';
2
3
  import type { BaseTmplParams, MetaInfo } from "../types/index.js";
3
4
  export interface AllEndpointPerFileTmplParams extends BaseTmplParams {
4
- routes: AnyObject[];
5
+ routes: ParsedRoute[];
5
6
  groupName: Maybe<string>;
6
7
  metaInfo: Maybe<MetaInfo>;
7
8
  relativePathDataContracts: string;
@@ -1 +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":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,0BAA0B;AAMlE,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B;;;EA8IrC,CAAC"}
1
+ {"version":3,"file":"all-endpoints-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-endpoints-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,0BAA0B;AAMlE,MAAM,WAAW,4BAA6B,SAAQ,cAAc;IAClE,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,yBAAyB,EAAE,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,sBAAsB,GACjC,QAAQ,4BAA4B;;;EA8IrC,CAAC"}
@@ -1,7 +1,8 @@
1
- import type { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { ParsedRoute } from 'swagger-typescript-api';
2
+ import type { Maybe } from 'yummies/utils/types';
2
3
  import type { BaseTmplParams, MetaInfo } from "../types/index.cjs";
3
4
  export interface EndpointPerFileTmplParams extends BaseTmplParams {
4
- route: AnyObject;
5
+ route: ParsedRoute;
5
6
  relativePathDataContracts: string;
6
7
  groupName: Maybe<string>;
7
8
  metaInfo: Maybe<MetaInfo>;
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,2BAA0B;AAMlE,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC/D,KAAK,EAAE,SAAS,CAAC;IACjB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB;;;EAgIlC,CAAC"}
1
+ {"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,2BAA0B;AAMlE,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC/D,KAAK,EAAE,WAAW,CAAC;IACnB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB;;;EAgIlC,CAAC"}
@@ -1,7 +1,8 @@
1
- import type { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { ParsedRoute } from 'swagger-typescript-api';
2
+ import type { Maybe } from 'yummies/utils/types';
2
3
  import type { BaseTmplParams, MetaInfo } from "../types/index.js";
3
4
  export interface EndpointPerFileTmplParams extends BaseTmplParams {
4
- route: AnyObject;
5
+ route: ParsedRoute;
5
6
  relativePathDataContracts: string;
6
7
  groupName: Maybe<string>;
7
8
  metaInfo: Maybe<MetaInfo>;
@@ -1 +1 @@
1
- {"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,0BAA0B;AAMlE,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC/D,KAAK,EAAE,SAAS,CAAC;IACjB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB;;;EAgIlC,CAAC"}
1
+ {"version":3,"file":"endpoint-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/endpoint-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,QAAQ,EAAE,0BAA0B;AAMlE,MAAM,WAAW,yBAA0B,SAAQ,cAAc;IAC/D,KAAK,EAAE,WAAW,CAAC;IACnB,yBAAyB,EAAE,MAAM,CAAC;IAClC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAED,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,yBAAyB;;;EAgIlC,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.newEndpointTmpl = void 0;
4
+ const create_short_model_type_js_1 = require("../utils/create-short-model-type.cjs");
4
5
  const meta_info_tmpl_js_1 = require("./meta-info.tmpl.cjs");
5
6
  // RequestParams["type"]
6
7
  const requestContentKind = {
@@ -16,9 +17,11 @@ const responseContentKind = {
16
17
  FORM_DATA: '"formData"',
17
18
  BYTES: '"bytes"',
18
19
  };
19
- const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, }) => {
20
+ const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, filterTypes, configuration, }) => {
20
21
  const { _ } = utils;
21
- const positiveResponseTypes = route.raw.responsesTypes?.filter((it) => +it.status >= 200 && +it.status < 300);
22
+ const positiveResponseTypes = route.raw.responsesTypes?.filter((it) => +it.status >= 200 &&
23
+ +it.status < 300 &&
24
+ (!it.typeData || filterTypes(it.typeData)));
22
25
  const { requestBodyInfo, responseBodyInfo } = route;
23
26
  const routeRequest = route.request;
24
27
  const routeResponse = route.response;
@@ -58,7 +61,12 @@ const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupN
58
61
  };
59
62
  const tags = (raw.tags || []).filter(Boolean);
60
63
  const requestOutputDataTypes = positiveResponseTypes.map((it) => it.type);
61
- const requestOutputErrorType = routeResponse.errorType;
64
+ const foundErrorModelType = (routeResponse.errorType &&
65
+ configuration.modelTypes.find((it) => it.name === routeResponse.errorType)) ||
66
+ null;
67
+ const requestOutputErrorType = foundErrorModelType
68
+ ? routeResponse.errorType
69
+ : 'any';
62
70
  const pathParamsToInline = path.split('/').slice(1);
63
71
  let lastDynamicStructPos = 0;
64
72
  const queryParamStruct = query == null
@@ -81,7 +89,7 @@ const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupN
81
89
  const responseFormat = responseContentKind[responseBodyInfo.success?.schema?.contentKind] || null;
82
90
  const reservedDataContractNames = _.uniq([
83
91
  ...requestOutputDataTypes,
84
- requestOutputErrorType,
92
+ requestOutputErrorType || 'any',
85
93
  ...getArgs({
86
94
  withPayload: true,
87
95
  }).map((it) => it.type),
@@ -89,14 +97,15 @@ const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupN
89
97
  const pathDeclaration = resultPath.replaceAll('$', '');
90
98
  const getHttpRequestGenerics = () => {
91
99
  const defaultOkResponse = positiveResponseTypes?.[0]?.type || 'unknown';
92
- const defaultBadResponse = routeResponse.errorType;
93
- const responses = raw.responsesTypes?.filter((it) => it.status !== 'default') ||
94
- [];
100
+ const defaultBadResponse = requestOutputErrorType;
101
+ const responses = raw.responsesTypes?.filter((it) => it.status !== 'default' &&
102
+ (!it.typeData ||
103
+ filterTypes(it.typeData))) || [];
95
104
  if (!responses?.length) {
96
- return `HttpResponse<unknown, ${routeResponse.errorType}>`;
105
+ return `HttpResponse<unknown, ${requestOutputErrorType}>`;
97
106
  }
98
107
  if (responses.length === 1 && responses[0].isSuccess) {
99
- return `HttpResponse<${responses[0].type}, ${routeResponse.errorType}>`;
108
+ return `HttpResponse<${responses[0].type}, ${requestOutputErrorType}>`;
100
109
  }
101
110
  return `HttpMultistatusResponse<{
102
111
  ${responses
@@ -114,7 +123,7 @@ const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupN
114
123
  ${defaultBadResponse}
115
124
  >`;
116
125
  };
117
- const requestInputTypeDc = {
126
+ const requestInputTypeDc = (0, create_short_model_type_js_1.createShortModelType)({
118
127
  typeIdentifier: 'type',
119
128
  name: _.upperFirst(_.camelCase(`${route.routeName.usage}Params`)),
120
129
  content: `{
@@ -125,14 +134,15 @@ const newEndpointTmpl = ({ route, codegenParams, importFileParams, utils, groupN
125
134
  .filter(Boolean)
126
135
  .join(', ')}
127
136
  }`,
128
- };
137
+ });
138
+ const isAllowedInputType = filterTypes(requestInputTypeDc);
129
139
  return {
130
140
  reservedDataContractNames,
131
- localModelTypes: [requestInputTypeDc],
141
+ localModelTypes: isAllowedInputType ? [requestInputTypeDc] : [],
132
142
  content: `
133
143
  new ${importFileParams.endpoint.exportName}<
134
144
  ${getHttpRequestGenerics()},
135
- ${requestInputTypeDc.name},
145
+ ${isAllowedInputType ? requestInputTypeDc.name : 'any'},
136
146
  ${requestInfoMeta?.typeName ?? 'any'}
137
147
  >(
138
148
  {
@@ -1,18 +1,15 @@
1
- import type { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { ParsedRoute } from 'swagger-typescript-api';
2
+ import type { Maybe } from 'yummies/utils/types';
2
3
  import type { BaseTmplParams } from "../types/base-tmpl-params.cjs";
3
4
  import type { MetaInfo } from "../types/index.cjs";
4
5
  export interface NewEndpointTmplParams extends BaseTmplParams {
5
- route: AnyObject;
6
+ route: ParsedRoute;
6
7
  groupName: Maybe<string>;
7
8
  metaInfo: Maybe<MetaInfo>;
8
9
  }
9
- export declare const newEndpointTmpl: ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, }: NewEndpointTmplParams) => {
10
+ export declare const newEndpointTmpl: ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, filterTypes, configuration, }: NewEndpointTmplParams) => {
10
11
  reservedDataContractNames: string[];
11
- localModelTypes: {
12
- typeIdentifier: string;
13
- name: Capitalize<string>;
14
- content: string;
15
- }[];
12
+ localModelTypes: (Omit<import("swagger-typescript-api").ModelType, "rawContent"> & Partial<Pick<import("swagger-typescript-api").ModelType, "rawContent">> & import("swagger-typescript-api").ModelType)[];
16
13
  content: string;
17
14
  };
18
15
  //# sourceMappingURL=new-endpoint.tmpl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,sCAAqC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,2BAA0B;AAMlD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,yEAO7B,qBAAqB;;;;;;;;CA6MvB,CAAC"}
1
+ {"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,sCAAqC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,2BAA0B;AAOlD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,qGAS7B,qBAAqB;;;;CA8NvB,CAAC"}
@@ -1,18 +1,15 @@
1
- import type { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { ParsedRoute } from 'swagger-typescript-api';
2
+ import type { Maybe } from 'yummies/utils/types';
2
3
  import type { BaseTmplParams } from "../types/base-tmpl-params.js";
3
4
  import type { MetaInfo } from "../types/index.js";
4
5
  export interface NewEndpointTmplParams extends BaseTmplParams {
5
- route: AnyObject;
6
+ route: ParsedRoute;
6
7
  groupName: Maybe<string>;
7
8
  metaInfo: Maybe<MetaInfo>;
8
9
  }
9
- export declare const newEndpointTmpl: ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, }: NewEndpointTmplParams) => {
10
+ export declare const newEndpointTmpl: ({ route, codegenParams, importFileParams, utils, groupName, metaInfo, filterTypes, configuration, }: NewEndpointTmplParams) => {
10
11
  reservedDataContractNames: string[];
11
- localModelTypes: {
12
- typeIdentifier: string;
13
- name: Capitalize<string>;
14
- content: string;
15
- }[];
12
+ localModelTypes: (Omit<import("swagger-typescript-api").ModelType, "rawContent"> & Partial<Pick<import("swagger-typescript-api").ModelType, "rawContent">> & import("swagger-typescript-api").ModelType)[];
16
13
  content: string;
17
14
  };
18
15
  //# sourceMappingURL=new-endpoint.tmpl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,qCAAqC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,0BAA0B;AAMlD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,SAAS,CAAC;IACjB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,yEAO7B,qBAAqB;;;;;;;;CA6MvB,CAAC"}
1
+ {"version":3,"file":"new-endpoint.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-endpoint.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAa,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,qCAAqC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,0BAA0B;AAOlD,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,KAAK,EAAE,WAAW,CAAC;IACnB,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC3B;AAiBD,eAAO,MAAM,eAAe,GAAI,qGAS7B,qBAAqB;;;;CA8NvB,CAAC"}