mobx-tanstack-query-api 0.23.0 → 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.
- package/codegen/index.cjs +44 -76
- package/codegen/index.d.cts.map +1 -1
- package/codegen/index.d.ts.map +1 -1
- package/codegen/index.js +44 -76
- package/package.json +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
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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,36 +195,6 @@ 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;
|
|
@@ -205,47 +211,9 @@ const generateApi = async (params) => {
|
|
|
205
211
|
const codegenFs = codegenProcess.fileSystem;
|
|
206
212
|
codegenFs.cleanDir(params.output);
|
|
207
213
|
codegenFs.createDir(params.output);
|
|
208
|
-
if (generatedExtra) {
|
|
209
|
-
const allExtraOperationIdsSet = new Set([
|
|
210
|
-
...(generatedExtra.configuration.routes.outOfModule?.map((r) => r.raw.operationId) ?? []),
|
|
211
|
-
...(generatedExtra.configuration.routes.combined?.flatMap((r) => r.routes.map((r) => r.raw.operationId)) ?? []),
|
|
212
|
-
]);
|
|
213
|
-
const allExtraModelTypesSet = new Set([
|
|
214
|
-
...generatedExtra.configuration.modelTypes.map((m) => m.name),
|
|
215
|
-
]);
|
|
216
|
-
generated.configuration.routes.outOfModule =
|
|
217
|
-
generated.configuration.routes.outOfModule ?? [];
|
|
218
|
-
generated.configuration.routes.outOfModule = [
|
|
219
|
-
...generated.configuration.routes.outOfModule.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
|
|
220
|
-
...generatedExtra.configuration.routes.outOfModule,
|
|
221
|
-
];
|
|
222
|
-
generated.configuration.routes.combined =
|
|
223
|
-
generated.configuration.routes.combined ?? [];
|
|
224
|
-
generated.configuration.routes.combined.forEach((group) => {
|
|
225
|
-
group.routes = [
|
|
226
|
-
...group.routes.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
|
|
227
|
-
...(generatedExtra.configuration.routes.combined?.find((g) => g.moduleName === group.moduleName)?.routes ?? []),
|
|
228
|
-
];
|
|
229
|
-
});
|
|
230
|
-
const notExistedCombinedExtra = generatedExtra.configuration.routes.combined?.filter((group) => !generated.configuration.routes.combined?.some((g) => g.moduleName === group.moduleName));
|
|
231
|
-
generated.configuration.routes.combined.push(...(notExistedCombinedExtra ?? []));
|
|
232
|
-
generated.configuration.modelTypes = [
|
|
233
|
-
...generated.configuration.modelTypes.filter((it) => !allExtraModelTypesSet.has(it.name)),
|
|
234
|
-
...generatedExtra.configuration.modelTypes,
|
|
235
|
-
];
|
|
236
|
-
}
|
|
237
214
|
const filterTypes = (0, unpack_filter_option_js_1.unpackFilterOption)(params.filterTypes, (modelType) => modelType.name);
|
|
238
215
|
generated.configuration.modelTypes =
|
|
239
216
|
generated.configuration.modelTypes.filter((modelType) => filterTypes(modelType));
|
|
240
|
-
generated.configuration.modelTypes = generated.configuration.modelTypes.sort((modelType1, modelType2) => {
|
|
241
|
-
if (modelType1.name > modelType2.name) {
|
|
242
|
-
return 1;
|
|
243
|
-
}
|
|
244
|
-
if (modelType1.name < modelType2.name) {
|
|
245
|
-
return -1;
|
|
246
|
-
}
|
|
247
|
-
return 0;
|
|
248
|
-
});
|
|
249
217
|
const allRoutes = Object.values(generated.configuration.routes)
|
|
250
218
|
.flat()
|
|
251
219
|
.flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
|
package/codegen/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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"}
|
package/codegen/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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,36 +175,6 @@ 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;
|
|
@@ -185,47 +191,9 @@ export const generateApi = async (params) => {
|
|
|
185
191
|
const codegenFs = codegenProcess.fileSystem;
|
|
186
192
|
codegenFs.cleanDir(params.output);
|
|
187
193
|
codegenFs.createDir(params.output);
|
|
188
|
-
if (generatedExtra) {
|
|
189
|
-
const allExtraOperationIdsSet = new Set([
|
|
190
|
-
...(generatedExtra.configuration.routes.outOfModule?.map((r) => r.raw.operationId) ?? []),
|
|
191
|
-
...(generatedExtra.configuration.routes.combined?.flatMap((r) => r.routes.map((r) => r.raw.operationId)) ?? []),
|
|
192
|
-
]);
|
|
193
|
-
const allExtraModelTypesSet = new Set([
|
|
194
|
-
...generatedExtra.configuration.modelTypes.map((m) => m.name),
|
|
195
|
-
]);
|
|
196
|
-
generated.configuration.routes.outOfModule =
|
|
197
|
-
generated.configuration.routes.outOfModule ?? [];
|
|
198
|
-
generated.configuration.routes.outOfModule = [
|
|
199
|
-
...generated.configuration.routes.outOfModule.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
|
|
200
|
-
...generatedExtra.configuration.routes.outOfModule,
|
|
201
|
-
];
|
|
202
|
-
generated.configuration.routes.combined =
|
|
203
|
-
generated.configuration.routes.combined ?? [];
|
|
204
|
-
generated.configuration.routes.combined.forEach((group) => {
|
|
205
|
-
group.routes = [
|
|
206
|
-
...group.routes.filter((route) => !allExtraOperationIdsSet.has(route.raw.operationId)),
|
|
207
|
-
...(generatedExtra.configuration.routes.combined?.find((g) => g.moduleName === group.moduleName)?.routes ?? []),
|
|
208
|
-
];
|
|
209
|
-
});
|
|
210
|
-
const notExistedCombinedExtra = generatedExtra.configuration.routes.combined?.filter((group) => !generated.configuration.routes.combined?.some((g) => g.moduleName === group.moduleName));
|
|
211
|
-
generated.configuration.routes.combined.push(...(notExistedCombinedExtra ?? []));
|
|
212
|
-
generated.configuration.modelTypes = [
|
|
213
|
-
...generated.configuration.modelTypes.filter((it) => !allExtraModelTypesSet.has(it.name)),
|
|
214
|
-
...generatedExtra.configuration.modelTypes,
|
|
215
|
-
];
|
|
216
|
-
}
|
|
217
194
|
const filterTypes = unpackFilterOption(params.filterTypes, (modelType) => modelType.name);
|
|
218
195
|
generated.configuration.modelTypes =
|
|
219
196
|
generated.configuration.modelTypes.filter((modelType) => filterTypes(modelType));
|
|
220
|
-
generated.configuration.modelTypes = generated.configuration.modelTypes.sort((modelType1, modelType2) => {
|
|
221
|
-
if (modelType1.name > modelType2.name) {
|
|
222
|
-
return 1;
|
|
223
|
-
}
|
|
224
|
-
if (modelType1.name < modelType2.name) {
|
|
225
|
-
return -1;
|
|
226
|
-
}
|
|
227
|
-
return 0;
|
|
228
|
-
});
|
|
229
197
|
const allRoutes = Object.values(generated.configuration.routes)
|
|
230
198
|
.flat()
|
|
231
199
|
.flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
|
package/package.json
CHANGED