mobx-tanstack-query-api 0.0.1 → 0.0.4

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.
@@ -0,0 +1,4 @@
1
+ import { HttpClient } from '../runtime/http-client.js';
2
+ export { queryClient } from 'mobx-tanstack-query/preset';
3
+ export declare const http: HttpClient<unknown>;
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,eAAO,MAAM,IAAI,qBAAqB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { HttpClient } from '../runtime/http-client.js';
2
+ export { queryClient } from 'mobx-tanstack-query/preset';
3
+ export const http = new HttpClient({});
@@ -1,10 +1,21 @@
1
1
  import { GenerateApiParams as GenerateApiParamsFromSwagger, ParsedRoute } from 'swagger-typescript-api';
2
- import { AnyObject } from 'yummies/utils/types';
2
+ import { AnyObject, KeyOfByValue } from 'yummies/utils/types';
3
+ export type CodegenProcess = Parameters<Exclude<Required<Extract<GenerateApiParamsFromSwagger, {
4
+ input: string;
5
+ }>['hooks']>, undefined>['onInit']>[1];
6
+ export interface ImportFileParams {
7
+ path: string;
8
+ exportName: string;
9
+ }
3
10
  export interface QueryApiParams {
4
11
  requestPathPrefix?: string;
5
12
  requestPathSuffix?: string;
6
13
  requestInfoPrefix?: string;
7
14
  outputType: 'request-info-per-file';
15
+ addPathSegmentToRouteName?: boolean | number;
16
+ queryClient: 'builtin' | ImportFileParams;
17
+ requestInfo: 'builtin' | ImportFileParams;
18
+ httpClient: 'builtin' | ImportFileParams;
8
19
  getRequestInfoMeta?: (route: ParsedRoute) => {
9
20
  typeName: string;
10
21
  importTypePath: string;
@@ -16,6 +27,7 @@ export interface QueryApiParams {
16
27
  tmplData: string;
17
28
  };
18
29
  }
30
+ export type AllImportFileParams = Record<KeyOfByValue<Required<QueryApiParams>, 'builtin' | ImportFileParams>, ImportFileParams>;
19
31
  type GenerateApiParams = Omit<GenerateApiParamsFromSwagger, 'output' | 'moduleNameFirstTag' | 'moduleNameIndex' | 'url' | 'input' | 'spec'> & {
20
32
  output: string;
21
33
  input: string | AnyObject;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,IAAI,4BAA4B,EACjD,WAAW,EAEZ,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAWhD,MAAM,WAAW,cAAc;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,uBAAuB,CAAC;IAEpC,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK;QAC3C,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK;QACvC,QAAQ,EAAE,MAAM,CAAC;QACjB,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,KAAK,iBAAiB,GAAG,IAAI,CAC3B,4BAA4B,EAC5B,QAAQ,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAC/E,GAAG;IACF,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,GAAG,cAAc,CAAC;AAEnB,eAAO,MAAM,WAAW,gBAAu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C;KAClB,CAAC;CACH;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC,EACpE,gBAAgB,CACjB,CAAC;AAEF,KAAK,iBAAiB,GAAG,IAAI,CAC3B,4BAA4B,EAC5B,QAAQ,GAAG,oBAAoB,GAAG,iBAAiB,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAC/E,GAAG;IACF,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3B,GAAG,cAAc,CAAC;AAEnB,eAAO,MAAM,WAAW,gBAAuB,iBAAiB,kBAiN/D,CAAC"}
package/codegen/index.js CHANGED
@@ -1,11 +1,33 @@
1
1
  import { generateApi as generateApiFromSwagger, } from 'swagger-typescript-api';
2
2
  import path from 'node:path';
3
3
  import { fileURLToPath } from 'node:url';
4
+ import { dataContractsTmpl } from './templates/data-contracts.tmpl.js';
5
+ import { indexTsForRequestPerFileTmpl } from './templates/index-ts-for-request-per-file.tmpl.js';
4
6
  import { requestInfoPerFileTmpl } from './templates/request-info-per-file.tmpl.js';
5
7
  const __filename = fileURLToPath(import.meta.url);
6
8
  const __dirname = path.dirname(__filename);
7
9
  export const generateApi = async (inputParams) => {
8
10
  const { output, input, ...params } = inputParams;
11
+ const importFileParams = {
12
+ queryClient: typeof inputParams.queryClient === 'string'
13
+ ? {
14
+ exportName: 'queryClient',
15
+ path: 'mobx-tanstack-query-api/builtin',
16
+ }
17
+ : inputParams.queryClient,
18
+ requestInfo: typeof inputParams.requestInfo === 'string'
19
+ ? {
20
+ exportName: 'RequestInfo',
21
+ path: 'mobx-tanstack-query-api',
22
+ }
23
+ : inputParams.requestInfo,
24
+ httpClient: typeof inputParams.httpClient === 'string'
25
+ ? {
26
+ exportName: 'http',
27
+ path: 'mobx-tanstack-query-api/builtin',
28
+ }
29
+ : inputParams.httpClient,
30
+ };
9
31
  const paths = {
10
32
  templates: path.resolve(__dirname, 'templates'),
11
33
  requestInfoClass: path.resolve(__dirname, 'templates/request-info-class.ejs'),
@@ -64,8 +86,22 @@ export const generateApi = async (inputParams) => {
64
86
  });
65
87
  return codegenParams?.hooks?.onPrepareConfig?.(config);
66
88
  },
89
+ onFormatRouteName: (routeInfo, usageRouteName) => {
90
+ let formattedRouteName = usageRouteName;
91
+ if (inputParams.addPathSegmentToRouteName === true ||
92
+ typeof inputParams.addPathSegmentToRouteName === 'number') {
93
+ const pathSegmentForSuffix = typeof inputParams.addPathSegmentToRouteName === 'number'
94
+ ? inputParams.addPathSegmentToRouteName
95
+ : 0;
96
+ const pathSegments = routeInfo.route.split('/').filter(Boolean);
97
+ const { _ } = codegenProcess.getRenderTemplateData().utils;
98
+ formattedRouteName = _.camelCase(`${pathSegments[pathSegmentForSuffix] || ''}_${formattedRouteName}`);
99
+ }
100
+ return (codegenParams?.hooks?.onFormatRouteName?.(routeInfo, formattedRouteName) ?? formattedRouteName);
101
+ },
67
102
  },
68
103
  });
104
+ const { _ } = codegenProcess.getRenderTemplateData().utils;
69
105
  const codegenFs = codegenProcess.fileSystem;
70
106
  codegenFs.cleanDir(output);
71
107
  codegenFs.createDir(output);
@@ -73,17 +109,52 @@ export const generateApi = async (inputParams) => {
73
109
  const allRoutes = Object.values(generated.configuration.routes)
74
110
  .flat()
75
111
  .flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
112
+ const reservedDataContractNamesMap = new Map();
113
+ const fileNamesWithRequestInfo = [];
76
114
  for await (const route of allRoutes) {
77
- const requestInfoPerFileContent = await requestInfoPerFileTmpl({
115
+ const { content: requestInfoPerFileContent, reservedDataContractNames } = await requestInfoPerFileTmpl({
78
116
  ...generated,
79
117
  route,
80
118
  apiParams: inputParams,
119
+ codegenProcess,
120
+ importFileParams,
81
121
  });
122
+ reservedDataContractNames.forEach((name) => {
123
+ reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
124
+ });
125
+ const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
126
+ fileNamesWithRequestInfo.push(fileName);
82
127
  codegenFs.createFile({
83
128
  path: paths.outputRequestsDir.toString(),
84
- fileName: `${generated.configuration.utils._.kebabCase(route.routeName.usage)}.ts`,
129
+ fileName,
85
130
  withPrefix: false,
86
131
  content: requestInfoPerFileContent,
87
132
  });
88
133
  }
134
+ const excludedDataContractNames = Array.from(reservedDataContractNamesMap.entries())
135
+ .filter(([_, count]) => count === 1)
136
+ .map(([name]) => name);
137
+ const dataContractsContent = await dataContractsTmpl({
138
+ ...generated,
139
+ apiParams: inputParams,
140
+ codegenProcess,
141
+ excludedDataContractNames,
142
+ });
143
+ codegenFs.createFile({
144
+ path: paths.outputRequestsDir.toString(),
145
+ fileName: 'data-contracts.ts',
146
+ withPrefix: false,
147
+ content: dataContractsContent,
148
+ });
149
+ codegenFs.createFile({
150
+ path: paths.outputRequestsDir.toString(),
151
+ fileName: 'index.ts',
152
+ withPrefix: false,
153
+ content: await indexTsForRequestPerFileTmpl({
154
+ ...generated,
155
+ apiParams: inputParams,
156
+ codegenProcess,
157
+ generatedRequestFileNames: fileNamesWithRequestInfo,
158
+ }),
159
+ });
89
160
  };
@@ -0,0 +1,8 @@
1
+ import { GenerateApiConfiguration, ModelType } from 'swagger-typescript-api';
2
+ export interface DataContractTmplParams {
3
+ configuration: GenerateApiConfiguration;
4
+ contract: ModelType;
5
+ addExportKeyword?: boolean;
6
+ }
7
+ export declare const dataContractTmpl: ({ contract, configuration, addExportKeyword, }: DataContractTmplParams) => Promise<string>;
8
+ //# sourceMappingURL=data-contract.tmpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-contract.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contract.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE7E,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,wBAAwB,CAAC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAuBD,eAAO,MAAM,gBAAgB,mDAI1B,sBAAsB,oBAmCxB,CAAC"}
@@ -0,0 +1,45 @@
1
+ const buildGenerics = (contract) => {
2
+ if (!contract.genericArgs?.length)
3
+ return '';
4
+ return ('<' +
5
+ contract.genericArgs
6
+ .map((arg) => {
7
+ const { name, default: defaultType, extends: extendsType } = arg;
8
+ return [
9
+ name,
10
+ extendsType && `extends ${extendsType}`,
11
+ defaultType && `= ${defaultType}`,
12
+ ]
13
+ .filter(Boolean)
14
+ .join(' ');
15
+ })
16
+ .join(', ') +
17
+ '>');
18
+ };
19
+ export const dataContractTmpl = async ({ contract, configuration, addExportKeyword, }) => {
20
+ const { utils } = configuration;
21
+ const { formatDescription } = utils;
22
+ const dataContractTemplates = {
23
+ enum: (contract) => {
24
+ return `enum ${contract.name} {\r\n${contract.content}\r\n}`;
25
+ },
26
+ interface: (contract) => {
27
+ return `interface ${contract.name}${buildGenerics(contract)} {\r\n${contract.content}}`;
28
+ },
29
+ type: (contract) => {
30
+ return `type ${contract.name}${buildGenerics(contract)} = ${contract.content}`;
31
+ },
32
+ };
33
+ let result = '';
34
+ let jsdoc = '';
35
+ if (contract.description) {
36
+ jsdoc = `/**\n * ${formatDescription(contract.description, true)}\n */`;
37
+ }
38
+ if (jsdoc) {
39
+ result += jsdoc + '\n\n';
40
+ }
41
+ const templateFn = dataContractTemplates[contract.typeIdentifier] ||
42
+ dataContractTemplates.type;
43
+ const contractType = `${addExportKeyword ? 'export ' : ''}${templateFn(contract)}`;
44
+ return result + contractType;
45
+ };
@@ -0,0 +1,10 @@
1
+ import { GenerateApiConfiguration, GenerateApiOutput } from 'swagger-typescript-api';
2
+ import type { CodegenProcess, QueryApiParams } from '../index.js';
3
+ export interface DataContractsTmplParams extends GenerateApiOutput {
4
+ configuration: GenerateApiConfiguration;
5
+ apiParams: QueryApiParams;
6
+ codegenProcess: CodegenProcess;
7
+ excludedDataContractNames?: string[];
8
+ }
9
+ export declare const dataContractsTmpl: ({ configuration, formatTSContent, excludedDataContractNames, }: DataContractsTmplParams) => Promise<string>;
10
+ //# sourceMappingURL=data-contracts.tmpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-contracts.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contracts.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlE,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,eAAO,MAAM,iBAAiB,mEAI3B,uBAAuB,oBA+BzB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { dataContractTmpl } from './data-contract.tmpl.js';
2
+ export const dataContractsTmpl = async ({ configuration, formatTSContent, excludedDataContractNames, }) => {
3
+ const { config, modelTypes } = configuration;
4
+ const contractDefinitions = [];
5
+ if (config.internalTemplateOptions?.addUtilRequiredKeysType) {
6
+ contractDefinitions.push(`type UtilRequiredKeys<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>`);
7
+ }
8
+ for await (const contract of modelTypes) {
9
+ if (excludedDataContractNames?.includes(contract.name)) {
10
+ continue;
11
+ }
12
+ contractDefinitions.push(await dataContractTmpl({
13
+ configuration,
14
+ contract,
15
+ addExportKeyword: true,
16
+ }));
17
+ }
18
+ return await formatTSContent(`
19
+ /* eslint-disable */
20
+ /* tslint:disable */
21
+
22
+ ${contractDefinitions.join('\n\n')}
23
+ `);
24
+ };
@@ -0,0 +1,10 @@
1
+ import { GenerateApiConfiguration, GenerateApiOutput } from 'swagger-typescript-api';
2
+ import { CodegenProcess, QueryApiParams } from '../index.js';
3
+ export interface IndexTsForRequestPerFileTmplParams extends GenerateApiOutput {
4
+ configuration: GenerateApiConfiguration;
5
+ apiParams: QueryApiParams;
6
+ codegenProcess: CodegenProcess;
7
+ generatedRequestFileNames: string[];
8
+ }
9
+ export declare const indexTsForRequestPerFileTmpl: ({ generatedRequestFileNames, }: IndexTsForRequestPerFileTmplParams) => Promise<string>;
10
+ //# sourceMappingURL=index-ts-for-request-per-file.tmpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-ts-for-request-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/index-ts-for-request-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D,MAAM,WAAW,kCAAmC,SAAQ,iBAAiB;IAC3E,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC;AAED,eAAO,MAAM,4BAA4B,mCAEtC,kCAAkC,oBAKpC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export const indexTsForRequestPerFileTmpl = async ({ generatedRequestFileNames, }) => {
2
+ return `
3
+ export * from './data-contracts';
4
+ ${generatedRequestFileNames.map((fileName) => `export * from './${fileName}';`).join('\n')}
5
+ `;
6
+ };
@@ -1,9 +1,13 @@
1
1
  import { GenerateApiConfiguration, ParsedRoute } from 'swagger-typescript-api';
2
- import type { QueryApiParams } from '../index.js';
2
+ import type { AllImportFileParams, QueryApiParams } from '../index.js';
3
3
  export interface NewRequestInfoTmplParams {
4
4
  route: ParsedRoute;
5
5
  configuration: GenerateApiConfiguration;
6
6
  apiParams: QueryApiParams;
7
+ importFileParams: AllImportFileParams;
7
8
  }
8
- export declare const newRequestInfoTmpl: ({ route, configuration, apiParams, }: NewRequestInfoTmplParams) => string;
9
+ export declare const newRequestInfoTmpl: ({ route, configuration, apiParams, importFileParams, }: NewRequestInfoTmplParams) => {
10
+ reservedDataContractNames: string[];
11
+ content: string;
12
+ };
9
13
  //# sourceMappingURL=new-request-info.tmpl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"new-request-info.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-request-info.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,EAAE,cAAc,CAAC;CAC3B;AAiBD,eAAO,MAAM,kBAAkB,yCAI5B,wBAAwB,WAyM1B,CAAC"}
1
+ {"version":3,"file":"new-request-info.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/new-request-info.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAG/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,MAAM,WAAW,wBAAwB;IACvC,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,EAAE,cAAc,CAAC;IAC1B,gBAAgB,EAAE,mBAAmB,CAAC;CACvC;AAiBD,eAAO,MAAM,kBAAkB,2DAK5B,wBAAwB;;;CA0N1B,CAAC"}
@@ -1,9 +1,9 @@
1
1
  // RequestParams["type"]
2
2
  const requestContentKind = {
3
- URL_ENCODED: 'application/x-www-form-urlencoded',
4
- FORM_DATA: 'multipart/form-data',
5
- TEXT: 'text/plain',
6
- BINARY: 'application/octet-stream',
3
+ URL_ENCODED: '"application/x-www-form-urlencoded"',
4
+ FORM_DATA: '"multipart/form-data"',
5
+ TEXT: '"text/plain"',
6
+ BINARY: '"application/octet-stream"',
7
7
  };
8
8
  // RequestParams["format"]
9
9
  const responseContentKind = {
@@ -12,7 +12,7 @@ const responseContentKind = {
12
12
  FORM_DATA: '"formData"',
13
13
  BYTES: '"bytes"',
14
14
  };
15
- export const newRequestInfoTmpl = ({ route, configuration, apiParams, }) => {
15
+ export const newRequestInfoTmpl = ({ route, configuration, apiParams, importFileParams, }) => {
16
16
  const { utils } = configuration;
17
17
  const { _ } = utils;
18
18
  const positiveResponseTypes = route.raw.responsesTypes?.filter((it) => +it.status >= 200 && +it.status < 300);
@@ -47,7 +47,7 @@ export const newRequestInfoTmpl = ({ route, configuration, apiParams, }) => {
47
47
  withRequestConfigParam && requestConfigParam,
48
48
  ]), [(o) => o.optional]);
49
49
  };
50
- const requestOutputDataType = positiveResponseTypes.map((it) => it.type).join('|') || 'any';
50
+ const requestOutputDataTypes = positiveResponseTypes.map((it) => it.type);
51
51
  const requestOutputErrorType = routeResponse.errorType;
52
52
  let requestInputCombinedType;
53
53
  const requestInfoFnArgNames = getArgs({
@@ -122,9 +122,19 @@ export const newRequestInfoTmpl = ({ route, configuration, apiParams, }) => {
122
122
  (apiParams.requestPathSuffix ?? '');
123
123
  const bodyContentType = requestContentKind[requestBodyInfo.contentKind] || null;
124
124
  const responseFormat = responseContentKind[responseBodyInfo.success?.schema?.contentKind] || null;
125
- return `
126
- new RequestInfo<
127
- ${requestOutputDataType},
125
+ const reservedDataContractNames = _.uniq([
126
+ ...requestOutputDataTypes,
127
+ requestOutputErrorType,
128
+ ...getArgs({
129
+ withRequestParams: true,
130
+ withPayload: true,
131
+ }).map((it) => it.type),
132
+ ]);
133
+ return {
134
+ reservedDataContractNames,
135
+ content: `
136
+ new ${importFileParams.requestInfo.exportName}<
137
+ ${requestOutputDataTypes.join('|') || 'any'},
128
138
  ${requestOutputErrorType},
129
139
  ${requestInputType},
130
140
  ${requestKeyType},
@@ -149,19 +159,26 @@ new RequestInfo<
149
159
  meta: ${requestInfoMeta?.tmplData ?? '{} as any'},
150
160
  keys: [
151
161
  ${_.compact([
152
- ...pathParamsStructs.map((struct) => {
153
- if (struct.type === 'dynamic') {
154
- return `{ name: '${struct.key}', param: ${struct.param} }`;
155
- }
156
- return `"${struct.value}"`;
157
- }),
158
- queryParamStruct &&
159
- `{ name: "${queryParamStruct.key}", rest: true }`,
160
- requestConfigParam &&
161
- `{ name: "${requestConfigParam.name}", param: ${lastDynamicStructPos} }`,
162
- ]).join(',')}
162
+ ...pathParamsStructs.map((struct) => {
163
+ if (struct.type === 'dynamic') {
164
+ return `{ name: '${struct.key}', param: ${struct.param} }`;
165
+ }
166
+ return `"${struct.value}"`;
167
+ }),
168
+ queryParamStruct &&
169
+ `{ name: "${queryParamStruct.key}", rest: true }`,
170
+ requestConfigParam &&
171
+ `{ name: "${requestConfigParam.name}", param: ${lastDynamicStructPos} }`,
172
+ ]).join(',')}
163
173
  ],
164
- }
174
+ },
175
+ ${importFileParams.httpClient.exportName},
176
+ ${importFileParams.queryClient.exportName},
165
177
  )
166
- `;
178
+ `
179
+ .split('\n')
180
+ .map((it) => it.trim())
181
+ .filter(Boolean)
182
+ .join('\n'),
183
+ };
167
184
  };
@@ -1,9 +1,14 @@
1
1
  import { ParsedRoute, GenerateApiConfiguration, GenerateApiOutput } from 'swagger-typescript-api';
2
- import type { QueryApiParams } from '../index.js';
2
+ import type { AllImportFileParams, CodegenProcess, QueryApiParams } from '../index.js';
3
3
  export interface RequestInfoPerFileTmplParams extends GenerateApiOutput {
4
4
  route: ParsedRoute;
5
5
  configuration: GenerateApiConfiguration;
6
6
  apiParams: QueryApiParams;
7
+ codegenProcess: CodegenProcess;
8
+ importFileParams: AllImportFileParams;
7
9
  }
8
- export declare const requestInfoPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, }: RequestInfoPerFileTmplParams) => Promise<string>;
10
+ export declare const requestInfoPerFileTmpl: ({ route, configuration, apiParams, formatTSContent, importFileParams, }: RequestInfoPerFileTmplParams) => Promise<{
11
+ reservedDataContractNames: string[];
12
+ content: string;
13
+ }>;
9
14
  //# sourceMappingURL=request-info-per-file.tmpl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-info-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/request-info-per-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAKlD,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,EAAE,cAAc,CAAC;CAC3B;AAED,eAAO,MAAM,sBAAsB,0DAKhC,4BAA4B,oBA4B9B,CAAC"}
1
+ {"version":3,"file":"request-info-per-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/request-info-per-file.tmpl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EACV,mBAAmB,EACnB,cAAc,EACd,cAAc,EACf,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,KAAK,EAAE,WAAW,CAAC;IACnB,aAAa,EAAE,wBAAwB,CAAC;IACxC,SAAS,EAAE,cAAc,CAAC;IAC1B,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,mBAAmB,CAAC;CACvC;AAED,eAAO,MAAM,sBAAsB,4EAMhC,4BAA4B;;;EAuE9B,CAAC"}
@@ -1,28 +1,56 @@
1
+ import { dataContractTmpl } from './data-contract.tmpl.js';
1
2
  import { newRequestInfoTmpl } from './new-request-info.tmpl.js';
2
3
  import { requestInfoJSDocTmpl } from './request-info-jsdoc.tmpl.js';
3
- export const requestInfoPerFileTmpl = async ({ route, configuration, apiParams, formatTSContent, }) => {
4
- const dataContractNames = configuration.modelTypes.map((it) => it.name);
4
+ export const requestInfoPerFileTmpl = async ({ route, configuration, apiParams, formatTSContent, importFileParams, }) => {
5
5
  const { utils } = configuration;
6
6
  const { _ } = utils;
7
- return await formatTSContent(`
8
- /* eslint-disable */
9
- /* tslint:disable */
10
- import { RequestInfo, RequestParams } from "mobx-tanstack-query-api";
11
- ${dataContractNames.length > 0
12
- ? `
13
- import { ${dataContractNames.join(', ')} } from "./data-contracts.ts";
14
- `
15
- : ''}
16
-
17
- ${requestInfoJSDocTmpl({
7
+ const { content: requestInfoInstanceContent, reservedDataContractNames } = newRequestInfoTmpl({
18
8
  route,
19
9
  configuration,
20
10
  apiParams,
21
- })}
22
- export const ${_.camelCase(route.routeName.usage)} = ${newRequestInfoTmpl({
23
- route,
24
- configuration,
25
- apiParams,
26
- })}
27
- `);
11
+ importFileParams,
12
+ });
13
+ const dataContactNames = new Set(Object.keys(configuration.config.swaggerSchema?.components?.schemas).map((schemaName) => utils.formatModelName(schemaName)));
14
+ const dataContractNamesInThisFile = [];
15
+ reservedDataContractNames.forEach((reservedDataContractName) => {
16
+ if (!dataContactNames.has(reservedDataContractName)) {
17
+ dataContractNamesInThisFile.push(reservedDataContractName);
18
+ }
19
+ });
20
+ return {
21
+ reservedDataContractNames: dataContractNamesInThisFile,
22
+ content: await formatTSContent(`
23
+ /* eslint-disable */
24
+ /* tslint:disable */
25
+ import { RequestParams } from "mobx-tanstack-query-api";
26
+ import { ${importFileParams.requestInfo.exportName} } from "${importFileParams.requestInfo.path}";
27
+ import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
28
+ import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
29
+ ${configuration.modelTypes.length > 0
30
+ ? `
31
+ import { ${configuration.modelTypes
32
+ .map((it) => it.name)
33
+ .filter((it) => !dataContractNamesInThisFile.includes(it))
34
+ .join(', ')} } from "./data-contracts.ts";
35
+ `
36
+ : ''}
37
+
38
+ ${(await Promise.all(dataContractNamesInThisFile.map(async (dataContractName) => {
39
+ const modelType = configuration.modelTypes.find((modelType) => modelType.name === dataContractName);
40
+ const contractType = await dataContractTmpl({
41
+ configuration,
42
+ contract: modelType,
43
+ addExportKeyword: true,
44
+ });
45
+ return contractType;
46
+ }))).join('\n\n')}
47
+
48
+ ${requestInfoJSDocTmpl({
49
+ route,
50
+ configuration,
51
+ apiParams,
52
+ })}
53
+ export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
54
+ `),
55
+ };
28
56
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx-tanstack-query-api",
3
- "version": "0.0.1",
3
+ "version": "0.0.4",
4
4
  "keywords": [],
5
5
  "author": "js2me",
6
6
  "license": "MIT",
@@ -20,7 +20,7 @@
20
20
  "mobx-tanstack-query": "^4.2.5"
21
21
  },
22
22
  "dependencies": {
23
- "swagger-typescript-api": "^13.0.23",
23
+ "swagger-typescript-api": "13.0.23",
24
24
  "yummies": "^3.0.36"
25
25
  },
26
26
  "devDependencies": {
@@ -35,11 +35,31 @@
35
35
  "vitest": "^3.0.5"
36
36
  },
37
37
  "exports": {
38
+ "./builtin": {
39
+ "import": "./builtin/index.js",
40
+ "default": "./builtin/index.js",
41
+ "types": "./builtin/index.d.ts"
42
+ },
38
43
  "./codegen": {
39
44
  "import": "./codegen/index.js",
40
45
  "default": "./codegen/index.js",
41
46
  "types": "./codegen/index.d.ts"
42
47
  },
48
+ "./codegen/templates/data-contract.tmpl": {
49
+ "import": "./codegen/templates/data-contract.tmpl.js",
50
+ "default": "./codegen/templates/data-contract.tmpl.js",
51
+ "types": "./codegen/templates/data-contract.tmpl.d.ts"
52
+ },
53
+ "./codegen/templates/data-contracts.tmpl": {
54
+ "import": "./codegen/templates/data-contracts.tmpl.js",
55
+ "default": "./codegen/templates/data-contracts.tmpl.js",
56
+ "types": "./codegen/templates/data-contracts.tmpl.d.ts"
57
+ },
58
+ "./codegen/templates/index-ts-for-request-per-file.tmpl": {
59
+ "import": "./codegen/templates/index-ts-for-request-per-file.tmpl.js",
60
+ "default": "./codegen/templates/index-ts-for-request-per-file.tmpl.js",
61
+ "types": "./codegen/templates/index-ts-for-request-per-file.tmpl.d.ts"
62
+ },
43
63
  "./codegen/templates/new-request-info.tmpl": {
44
64
  "import": "./codegen/templates/new-request-info.tmpl.js",
45
65
  "default": "./codegen/templates/new-request-info.tmpl.js",
@@ -1,5 +1,5 @@
1
1
  import { InvalidateOptions, InvalidateQueryFilters, QueryClient, QueryFunctionContext } from '@tanstack/query-core';
2
- import { MobxQuery, MobxQueryConfig } from 'mobx-tanstack-query';
2
+ import { MobxMutation, MobxMutationConfig, MobxQuery, MobxQueryConfig } from 'mobx-tanstack-query';
3
3
  import { AnyObject, MaybeFalsy } from 'yummies/utils/types';
4
4
  import type { FullRequestParams, HttpClient, HttpResponse } from './http-client.js';
5
5
  export interface RequestInfo<TData, TError, TInput extends AnyObject, TParams extends any[] = any[]> {
@@ -50,6 +50,7 @@ export declare class RequestInfo<TData, TError, TInput extends AnyObject, TParam
50
50
  invalidate(input: TInput, filters?: Omit<InvalidateQueryFilters<HttpResponse<TData, TError>>, 'queryKey' | 'predicate'> & {
51
51
  queryKeyIndex?: number;
52
52
  }, options?: InvalidateOptions): Promise<void>;
53
+ toMutation({ ...options }: Omit<MobxMutationConfig<HttpResponse<TData, TError>, TInput, TError>, 'queryClient' | 'mutationFn'>): MobxMutation<HttpResponse<TData, TError>, TInput, TError, unknown>;
53
54
  toQuery({ input: getInput, ...options }: Omit<MobxQueryConfig<HttpResponse<TData, TError>, TError>, 'options' | 'queryFn' | 'queryClient'> & {
54
55
  input: () => MaybeFalsy<TInput>;
55
56
  }): MobxQuery<HttpResponse<TData, TError>, TError, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"request-info.d.ts","sourceRoot":"","sources":["../../src/runtime/request-info.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACrB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAE5D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,YAAY,EACb,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,WAAW,CAC1B,KAAK,EACL,MAAM,EACN,MAAM,SAAS,SAAS,EACxB,OAAO,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE;IAE7B,CACE,GAAG,MAAM,EAAE,OAAO,GACjB,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;CACvE;AAED,qBAAa,WAAW,CACtB,KAAK,EACL,MAAM,EACN,MAAM,SAAS,SAAS,EACxB,OAAO,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,EAC7B,SAAS,SAAS,SAAS,GAAG,SAAS;IAKrC,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,SAAS,CAAC;QACjB,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,OAAO,KAAK,iBAAiB,CAAC;QAClD,IAAI,EAAE,CACF,MAAM,GACN;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,GAC/B;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,IAAI,CAAA;SAAE,CAC/B,EAAE,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AAM,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAC/D,aAAa,GAAG,YAAY,CAC7B;IAWD,OAAO,CAAC,EACN,KAAK,EAAE,QAAQ,EACf,GAAG,OAAO,EACX,EAAE,IAAI,CACL,eAAe,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EACpD,SAAS,GAAG,SAAS,GAAG,aAAa,CACtC,GAAG;QACF,KAAK,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;KACjC;CAoCF"}
@@ -1,4 +1,4 @@
1
- import { MobxQuery } from 'mobx-tanstack-query';
1
+ import { MobxMutation, MobxQuery, } from 'mobx-tanstack-query';
2
2
  export class RequestInfo {
3
3
  cfg;
4
4
  queryClient;
@@ -152,6 +152,15 @@ export class RequestInfo {
152
152
  exact: filters?.exact ?? false,
153
153
  }, options);
154
154
  }
155
+ toMutation({ ...options }) {
156
+ return new MobxMutation({
157
+ ...options,
158
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
159
+ // @ts-expect-error
160
+ queryClient: this.queryClient,
161
+ mutationFn: (input) => this.request(...this.buildParamsFromInput(input)),
162
+ });
163
+ }
155
164
  toQuery({ input: getInput, ...options }) {
156
165
  return new MobxQuery({
157
166
  ...options,