mobx-tanstack-query-api 0.40.1 → 0.41.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/cli.cjs +144 -109
- package/cli.cjs.map +1 -1
- package/cli.d.ts +34 -18
- package/cli.js +144 -109
- package/cli.js.map +1 -1
- package/index.cjs +6 -6
- package/index.cjs.map +1 -1
- package/index.d.ts +4 -4
- package/index.js +6 -6
- package/index.js.map +1 -1
- package/package.json +1 -1
package/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParsedRoute, ModelType, RawRouteInfo, GenerateApiConfiguration, GenerateApiParams } from 'swagger-typescript-api';
|
|
2
|
-
import { AnyObject, PartialKeys, Maybe, KeyOfByValue, Defined } from 'yummies/types';
|
|
2
|
+
import { AnyObject, PartialKeys, Maybe, MaybeFn, KeyOfByValue, Defined } from 'yummies/types';
|
|
3
3
|
import { LoDashStatic } from '/home/runner/work/mobx-tanstack-query-api/mobx-tanstack-query-api/node_modules/.pnpm/@types+lodash@4.17.24/node_modules/@types/lodash/index.d.ts';
|
|
4
4
|
|
|
5
5
|
type AnyFilterOptionFn = (...args: any[]) => boolean;
|
|
@@ -27,6 +27,7 @@ interface ImportFileParams {
|
|
|
27
27
|
|
|
28
28
|
type TypeInfo = PartialKeys<ModelType, 'rawContent'>;
|
|
29
29
|
|
|
30
|
+
type RuntimeExpressionOrBoolean = string | boolean;
|
|
30
31
|
interface GenerateQueryApiParams {
|
|
31
32
|
/**
|
|
32
33
|
* [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/codegen/config/#output)
|
|
@@ -186,15 +187,15 @@ interface GenerateQueryApiParams {
|
|
|
186
187
|
*/
|
|
187
188
|
noBarrelFiles?: boolean;
|
|
188
189
|
/**
|
|
189
|
-
* Generate Zod contracts (params + data schemas) for each endpoint and add `
|
|
190
|
-
* When truthy, can also enable validation via `
|
|
190
|
+
* Generate Zod contracts (params + data schemas) for each endpoint and add `contract` to the endpoint config.
|
|
191
|
+
* When truthy, can also enable validation via `validateContract` in the endpoint config.
|
|
191
192
|
* Requires `zod` to be installed.
|
|
192
193
|
*
|
|
193
|
-
* - `true`: generate contracts and set `
|
|
194
|
+
* - `true`: generate contracts and set `validateContract: true` (validate params + data).
|
|
194
195
|
* - `false`: no contracts, no validation.
|
|
195
|
-
* - `{ validate: boolean }`: set `
|
|
196
|
-
* - `{ validate: string }`: set `
|
|
197
|
-
* - `{ validate: { params?: boolean | string; data?: boolean | string } }`: set `
|
|
196
|
+
* - `{ validate: boolean }`: set `validateContract` to that boolean.
|
|
197
|
+
* - `{ validate: string }`: set `validateContract` to the expression (inserted as-is). E.g. `"process.env.NODE_ENV === 'development'"`.
|
|
198
|
+
* - `{ validate: { params?: boolean | string; data?: boolean | string } }`: set `validateContract` to an object; each value is literal or expression (string inserted as-is).
|
|
198
199
|
*
|
|
199
200
|
* When using an object form, optional `throw` controls `throwContracts` (throw on validation errors vs warn):
|
|
200
201
|
* - `{ throw: boolean }`: set `throwContracts` to that boolean.
|
|
@@ -202,20 +203,35 @@ interface GenerateQueryApiParams {
|
|
|
202
203
|
* - `{ throw: { params?: boolean | string; data?: boolean | string } }`: set `throwContracts` to an object; each value is literal or expression (string inserted as-is).
|
|
203
204
|
*
|
|
204
205
|
* Optional `appendRule`: either a string (runtime) or a function (codegen-time).
|
|
205
|
-
* - **string**: expression inserted as-is → `
|
|
206
|
-
* - **function** (contractName, routeInfo) => boolean: at codegen time, if true → `
|
|
206
|
+
* - **string**: expression inserted as-is → `contract: <expr> ? <contractVar> : undefined`. E.g. `"process.env.NODE_ENV === \"development\""`.
|
|
207
|
+
* - **function** (contractName, routeInfo) => boolean: at codegen time, if true → `contract: <contractVar>`, if false → `contract: undefined`.
|
|
208
|
+
*
|
|
209
|
+
* Optional `suffix`: suffix for generated shared Zod schema variables.
|
|
210
|
+
* Shared schema names are based on data contract names in camelCase, e.g. `DispatchReceiptDC` -> `dispatchReceiptDc`.
|
|
211
|
+
* Default: `""`.
|
|
207
212
|
*/
|
|
208
213
|
zodContracts?: boolean | {
|
|
209
|
-
validate:
|
|
210
|
-
params?:
|
|
211
|
-
data?:
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
214
|
+
validate: MaybeFn<RuntimeExpressionOrBoolean | {
|
|
215
|
+
params?: RuntimeExpressionOrBoolean;
|
|
216
|
+
data?: RuntimeExpressionOrBoolean;
|
|
217
|
+
}, [
|
|
218
|
+
contractName: string,
|
|
219
|
+
routeInfo: ZodContractsRouteInfo
|
|
220
|
+
]>;
|
|
221
|
+
throw?: MaybeFn<RuntimeExpressionOrBoolean | {
|
|
222
|
+
params?: RuntimeExpressionOrBoolean;
|
|
223
|
+
data?: RuntimeExpressionOrBoolean;
|
|
224
|
+
}, [
|
|
225
|
+
contractName: string,
|
|
226
|
+
routeInfo: ZodContractsRouteInfo
|
|
227
|
+
]>;
|
|
217
228
|
/** String: runtime condition. Function: codegen-time filter for (contractName, routeInfo). */
|
|
218
|
-
appendRule?:
|
|
229
|
+
appendRule?: MaybeFn<RuntimeExpressionOrBoolean, [
|
|
230
|
+
contractName: string,
|
|
231
|
+
routeInfo: ZodContractsRouteInfo
|
|
232
|
+
]>;
|
|
233
|
+
/** Suffix for generated shared Zod schema variables. Default: "". */
|
|
234
|
+
suffix?: string;
|
|
219
235
|
};
|
|
220
236
|
}
|
|
221
237
|
/** Route info passed to zodContracts.appendRule at codegen time. */
|