mobx-tanstack-query-api 0.11.0 → 0.13.0

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 (80) hide show
  1. package/README.md +2 -4
  2. package/assets/gh-repo-template.pxz +0 -0
  3. package/assets/logo.png +0 -0
  4. package/assets/logo.pxz +0 -0
  5. package/builtin/index.d.ts.map +1 -1
  6. package/cli/bin.d.ts +0 -1
  7. package/cli/bin.js +13 -25
  8. package/cli/bin.mjs +13 -25
  9. package/cli/index.d.ts +1 -1
  10. package/cli/index.d.ts.map +1 -1
  11. package/cli/index.js +1 -1
  12. package/cli/utils/define-config.d.ts +4 -0
  13. package/cli/utils/define-config.d.ts.map +1 -0
  14. package/cli/utils/exec-config-path.d.ts +2 -0
  15. package/cli/utils/exec-config-path.d.ts.map +1 -0
  16. package/cli/utils/exec-config-path.js +12 -0
  17. package/cli/utils/resolve-config-path.d.ts +3 -0
  18. package/cli/utils/resolve-config-path.d.ts.map +1 -0
  19. package/cli/utils/resolve-config-path.js +25 -0
  20. package/codegen/index.d.ts +62 -38
  21. package/codegen/index.d.ts.map +1 -1
  22. package/codegen/index.js +21 -33
  23. package/codegen/templates/all-endpoints-per-file.tmpl.d.ts +1 -1
  24. package/codegen/templates/all-endpoints-per-file.tmpl.d.ts.map +1 -1
  25. package/codegen/templates/all-endpoints-per-file.tmpl.js +29 -26
  26. package/codegen/templates/all-exports.tmpl.d.ts +2 -2
  27. package/codegen/templates/all-exports.tmpl.d.ts.map +1 -1
  28. package/codegen/templates/data-contract.tmpl.d.ts +1 -1
  29. package/codegen/templates/data-contract.tmpl.d.ts.map +1 -1
  30. package/codegen/templates/data-contracts-file.tmpl.d.ts +1 -1
  31. package/codegen/templates/data-contracts-file.tmpl.d.ts.map +1 -1
  32. package/codegen/templates/endpoint-jsdoc.tmpl.d.ts +2 -2
  33. package/codegen/templates/endpoint-jsdoc.tmpl.d.ts.map +1 -1
  34. package/codegen/templates/endpoint-per-file.tmpl.d.ts +1 -1
  35. package/codegen/templates/endpoint-per-file.tmpl.d.ts.map +1 -1
  36. package/codegen/templates/endpoint-per-file.tmpl.js +7 -3
  37. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts +2 -2
  38. package/codegen/templates/index-ts-for-endpoint-per-file.tmpl.d.ts.map +1 -1
  39. package/codegen/templates/meta-info.tmpl.d.ts +2 -2
  40. package/codegen/templates/meta-info.tmpl.d.ts.map +1 -1
  41. package/codegen/templates/new-endpoint.tmpl.d.ts +1 -1
  42. package/codegen/templates/new-endpoint.tmpl.d.ts.map +1 -1
  43. package/codegen/utils/remove-unused-types.d.ts +2 -1
  44. package/codegen/utils/remove-unused-types.d.ts.map +1 -1
  45. package/codegen/utils/remove-unused-types.js +7 -18
  46. package/codegen/utils/unpack-filter-option.d.ts +4 -0
  47. package/codegen/utils/unpack-filter-option.d.ts.map +1 -0
  48. package/codegen/utils/unpack-filter-option.js +16 -0
  49. package/package.json +51 -21
  50. package/runtime/endpoint-infinite-query.d.ts +5 -5
  51. package/runtime/endpoint-infinite-query.d.ts.map +1 -1
  52. package/runtime/endpoint-infinite-query.types.d.ts +5 -5
  53. package/runtime/endpoint-infinite-query.types.d.ts.map +1 -1
  54. package/runtime/endpoint-mutation.d.ts +4 -4
  55. package/runtime/endpoint-mutation.d.ts.map +1 -1
  56. package/runtime/endpoint-mutation.types.d.ts +4 -4
  57. package/runtime/endpoint-mutation.types.d.ts.map +1 -1
  58. package/runtime/endpoint-query-client.d.ts +3 -3
  59. package/runtime/endpoint-query-client.d.ts.map +1 -1
  60. package/runtime/endpoint-query-client.js +0 -2
  61. package/runtime/endpoint-query-client.types.d.ts +3 -3
  62. package/runtime/endpoint-query-client.types.d.ts.map +1 -1
  63. package/runtime/endpoint-query.d.ts +7 -6
  64. package/runtime/endpoint-query.d.ts.map +1 -1
  65. package/runtime/endpoint-query.js +1 -1
  66. package/runtime/endpoint-query.types.d.ts +4 -4
  67. package/runtime/endpoint-query.types.d.ts.map +1 -1
  68. package/runtime/endpoint.d.ts +8 -7
  69. package/runtime/endpoint.d.ts.map +1 -1
  70. package/runtime/endpoint.js +1 -1
  71. package/runtime/endpoint.types.d.ts +3 -3
  72. package/runtime/endpoint.types.d.ts.map +1 -1
  73. package/runtime/http-client.d.ts +2 -2
  74. package/runtime/http-client.d.ts.map +1 -1
  75. package/runtime/index.d.ts +5 -5
  76. package/runtime/index.d.ts.map +1 -1
  77. package/runtime/index.js +5 -5
  78. package/cli/define-config.d.ts +0 -4
  79. package/cli/define-config.d.ts.map +0 -1
  80. /package/cli/{define-config.js → utils/define-config.js} +0 -0
package/README.md CHANGED
@@ -12,8 +12,6 @@
12
12
  [bundlephobia-url]: https://bundlephobia.com/result?p=mobx-tanstack-query-api
13
13
  [bundlephobia-image]: https://badgen.net/bundlephobia/minzip/mobx-tanstack-query-api
14
14
 
15
- # WIP
15
+ API codegen from swagger for `mobx-tanstack-query`
16
16
 
17
- API codegen from swagger
18
-
19
- # [Documentation](https://js2me.github.io/mobx-tanstack-query/other/swagger-codegen.html)
17
+ # [Documentation](https://js2me.github.io/mobx-tanstack-query-api/)
Binary file
Binary file
Binary file
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAqB,MAAM,2BAA2B,CAAC;AAG1E,eAAO,MAAM,WAAW,qBAkBtB,CAAC;AAEH,eAAO,MAAM,IAAI,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/builtin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAqB,MAAM,2BAA2B,CAAC;AAI1E,eAAO,MAAM,WAAW,qBAkBtB,CAAC;AAEH,eAAO,MAAM,IAAI,qBAAqB,CAAC"}
package/cli/bin.d.ts CHANGED
@@ -1,3 +1,2 @@
1
- #!/usr/bin/env node
2
1
  export {};
3
2
  //# sourceMappingURL=bin.d.ts.map
package/cli/bin.js CHANGED
@@ -1,27 +1,15 @@
1
- #!/usr/bin/env node
2
- import { existsSync } from 'node:fs';
3
- import path from 'node:path';
1
+ import { cac } from 'cac';
4
2
  import { generateApi } from '../codegen/index.js';
5
- import { defineConfig } from './define-config.js';
6
- const projectDir = process.cwd();
7
- let generateApiParams;
8
- let module;
9
- if (existsSync(path.resolve(projectDir, 'api-codegen.config.js'))) {
10
- module = await import(path.resolve(projectDir, 'api-codegen.config.js'));
3
+ import { defineConfig } from './utils/define-config.js';
4
+ import { execConfigPath } from './utils/exec-config-path.js';
5
+ import { resolveConfigPath } from './utils/resolve-config-path.js';
6
+ let cli = cac('mobx-tanstack-query-api');
7
+ cli = cli.option('-c, --config <file>', `[string] use specified config file`);
8
+ cli.help();
9
+ const parsed = cli.parse();
10
+ if (!parsed.options.help) {
11
+ const configPath = resolveConfigPath(typeof parsed.options.config === 'string' ? parsed.options.config : null);
12
+ execConfigPath(configPath).then((generateApiParams) => {
13
+ defineConfig(generateApiParams).forEach(generateApi);
14
+ });
11
15
  }
12
- else if (existsSync(path.resolve(projectDir, 'api-codegen.config.mjs'))) {
13
- module = await import(path.resolve(projectDir, 'api-codegen.config.mjs'));
14
- }
15
- else if (existsSync(path.resolve(projectDir, 'api-codegen.config.json'))) {
16
- module = await import(path.resolve(projectDir, 'api-codegen.config.json'));
17
- }
18
- else {
19
- throw new Error('api-codegen.config.(js|mjs|json) not found');
20
- }
21
- if (module.default) {
22
- generateApiParams = module.default;
23
- }
24
- else {
25
- throw new Error('api-codegen.config.(js|mjs|json) is not valid, This file should return object - result of the defineConfig function');
26
- }
27
- defineConfig(generateApiParams).forEach(generateApi);
package/cli/bin.mjs CHANGED
@@ -1,27 +1,15 @@
1
- #!/usr/bin/env node
2
- import { existsSync } from 'node:fs';
3
- import path from 'node:path';
1
+ import { cac } from 'cac';
4
2
  import { generateApi } from '../codegen/index.js';
5
- import { defineConfig } from './define-config.js';
6
- const projectDir = process.cwd();
7
- let generateApiParams;
8
- let module;
9
- if (existsSync(path.resolve(projectDir, 'api-codegen.config.js'))) {
10
- module = await import(path.resolve(projectDir, 'api-codegen.config.js'));
3
+ import { defineConfig } from './utils/define-config.js';
4
+ import { execConfigPath } from './utils/exec-config-path.js';
5
+ import { resolveConfigPath } from './utils/resolve-config-path.js';
6
+ let cli = cac('mobx-tanstack-query-api');
7
+ cli = cli.option('-c, --config <file>', `[string] use specified config file`);
8
+ cli.help();
9
+ const parsed = cli.parse();
10
+ if (!parsed.options.help) {
11
+ const configPath = resolveConfigPath(typeof parsed.options.config === 'string' ? parsed.options.config : null);
12
+ execConfigPath(configPath).then((generateApiParams) => {
13
+ defineConfig(generateApiParams).forEach(generateApi);
14
+ });
11
15
  }
12
- else if (existsSync(path.resolve(projectDir, 'api-codegen.config.mjs'))) {
13
- module = await import(path.resolve(projectDir, 'api-codegen.config.mjs'));
14
- }
15
- else if (existsSync(path.resolve(projectDir, 'api-codegen.config.json'))) {
16
- module = await import(path.resolve(projectDir, 'api-codegen.config.json'));
17
- }
18
- else {
19
- throw new Error('api-codegen.config.(js|mjs|json) not found');
20
- }
21
- if (module.default) {
22
- generateApiParams = module.default;
23
- }
24
- else {
25
- throw new Error('api-codegen.config.(js|mjs|json) is not valid, This file should return object - result of the defineConfig function');
26
- }
27
- defineConfig(generateApiParams).forEach(generateApi);
package/cli/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './define-config.js';
1
+ export * from './utils/define-config.js';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC"}
package/cli/index.js CHANGED
@@ -1 +1 @@
1
- export * from './define-config.js';
1
+ export * from './utils/define-config.js';
@@ -0,0 +1,4 @@
1
+ import type { Maybe } from 'yummies/utils/types';
2
+ import type { GenerateQueryApiParams } from '../../codegen/index.js';
3
+ export declare const defineConfig: (...configs: Maybe<GenerateQueryApiParams | GenerateQueryApiParams[]>[]) => GenerateQueryApiParams[];
4
+ //# sourceMappingURL=define-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define-config.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/define-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,eAAO,MAAM,YAAY,GACvB,GAAG,SAAS,KAAK,CAAC,sBAAsB,GAAG,sBAAsB,EAAE,CAAC,EAAE,KACrE,sBAAsB,EAIxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const execConfigPath: (configPath: string) => Promise<unknown>;
2
+ //# sourceMappingURL=exec-config-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec-config-path.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/exec-config-path.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,YAAY,MAAM,qBAatD,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { createJiti } from 'jiti';
2
+ export const execConfigPath = async (configPath) => {
3
+ const jiti = createJiti(import.meta.url);
4
+ try {
5
+ const config = await jiti.import(configPath, { default: true });
6
+ return config;
7
+ }
8
+ catch (error) {
9
+ console.error(error);
10
+ }
11
+ throw new Error(`${configPath} is not valid, This file should return object - result of the defineConfig function`);
12
+ };
@@ -0,0 +1,3 @@
1
+ import type { Maybe } from 'yummies/utils/types';
2
+ export declare const resolveConfigPath: (userSpefiedPath?: Maybe<string>) => string;
3
+ //# sourceMappingURL=resolve-config-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-config-path.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/resolve-config-path.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAIjD,eAAO,MAAM,iBAAiB,GAAI,kBAAkB,KAAK,CAAC,MAAM,CAAC,WAsBhE,CAAC"}
@@ -0,0 +1,25 @@
1
+ import fs, { existsSync } from 'node:fs';
2
+ import path from 'node:path';
3
+ const projectDir = process.cwd();
4
+ export const resolveConfigPath = (userSpefiedPath) => {
5
+ if (userSpefiedPath) {
6
+ const fullUserSpecifiedPath = path.resolve(projectDir, userSpefiedPath);
7
+ if (!fs.existsSync(fullUserSpecifiedPath)) {
8
+ throw `Config file not found by path - ${userSpefiedPath}`;
9
+ }
10
+ return path.resolve(projectDir, userSpefiedPath);
11
+ }
12
+ if (existsSync(path.resolve(projectDir, 'api-codegen.config.js'))) {
13
+ return path.resolve(projectDir, 'api-codegen.config.js');
14
+ }
15
+ else if (existsSync(path.resolve(projectDir, 'api-codegen.config.mjs'))) {
16
+ return path.resolve(projectDir, 'api-codegen.config.mjs');
17
+ }
18
+ else if (existsSync(path.resolve(projectDir, 'api-codegen.config.json'))) {
19
+ return path.resolve(projectDir, 'api-codegen.config.json');
20
+ }
21
+ else if (existsSync(path.resolve(projectDir, 'api-codegen.config.ts'))) {
22
+ return path.resolve(projectDir, 'api-codegen.config.ts');
23
+ }
24
+ throw new Error('api-codegen.config.(js|mjs|json|ts) not found');
25
+ };
@@ -1,13 +1,17 @@
1
- import { LoDashStatic } from 'lodash';
2
- import { RequestInit } from 'undici-types';
3
- import { AnyObject, KeyOfByValue, Maybe } from 'yummies/utils/types';
4
- import { RemoveUnusedTypesParams } from './utils/remove-unused-types.js';
1
+ import type { LoDashStatic } from 'lodash';
2
+ import { type ParsedRoute, type RawRouteInfo } from 'swagger-typescript-api';
3
+ import type { RequestInit } from 'undici-types';
4
+ import type { AnyObject, KeyOfByValue, Maybe } from 'yummies/utils/types';
5
+ import { type RemoveUnusedTypesParams } from './utils/remove-unused-types.js';
5
6
  export type CodegenDataUtils = {
6
7
  _: LoDashStatic;
7
8
  getInlineParseContent: (requestParams: AnyObject) => string;
8
9
  formatModelName: (modelName: string) => string;
9
10
  };
10
- type FilterEndpointsFn = (endpoint: AnyObject) => boolean;
11
+ export type EndpointData = ParsedRoute;
12
+ export type FilterOption<T extends (...args: any[]) => boolean> = T | string | RegExp | (RegExp | string)[];
13
+ type FilterEndpointsOption = FilterOption<(endpoint: EndpointData) => boolean>;
14
+ type FilterGroupsOption = FilterOption<(groupName: string) => boolean>;
11
15
  export type CodegenProcess = AnyObject;
12
16
  export interface ImportFileParams {
13
17
  path: string;
@@ -19,22 +23,41 @@ export interface MetaInfo {
19
23
  tags?: string[];
20
24
  }
21
25
  export interface GenerateQueryApiParams {
26
+ /**
27
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#output)
28
+ */
22
29
  output: string;
30
+ /**
31
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#input)
32
+ */
23
33
  input: string | AnyObject;
34
+ /**
35
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#requestpathprefix)
36
+ */
24
37
  requestPathPrefix?: string;
38
+ /**
39
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#requestpathsuffix)
40
+ */
25
41
  requestPathSuffix?: string;
26
- requestInfoPrefix?: string;
42
+ /**
43
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#removeunusedtypes)
44
+ */
27
45
  removeUnusedTypes?: true | {
28
46
  keepTypes?: RemoveUnusedTypesParams['keepTypes'];
29
47
  };
30
48
  /**
31
- * getFruits -> getFruitsEndpoint
49
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#formatendpointname)
50
+ */
51
+ formatEndpointName?: (endpointName: string, endpointData: RawRouteInfo) => Maybe<string>;
52
+ /**
53
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#formatexportgroupname)
32
54
  */
33
- formatEndpointName?: (endpointName: string, endpointData: AnyObject) => Maybe<string>;
34
55
  formatExportGroupName?: (groupName: string, utils: CodegenDataUtils) => string;
35
56
  /**
36
57
  * Various generation output types
37
58
  *
59
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#outputtype)
60
+ *
38
61
  * `one-endpoint-per-file`
39
62
  * @example
40
63
  * ```
@@ -74,60 +97,61 @@ export interface GenerateQueryApiParams {
74
97
  outputType?: 'one-endpoint-per-file' | 'endpoints-per-file';
75
98
  /**
76
99
  * Group endpoints and collect it into object
100
+ *
101
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#groupby)
77
102
  */
78
- groupBy?: ((endpoint: AnyObject) => string) | `path-segment` | `path-segment-${number}` | `tag` | `tag-${number}`;
103
+ groupBy?: ((endpoint: EndpointData) => string) | `path-segment` | `path-segment-${number}` | `tag` | `tag-${number}`;
79
104
  /**
80
105
  * Collect all exports into single namespace
81
106
  *
82
- * Example:
83
- * without namespace:
84
- *
85
- * export * from "./endpoints";
86
- * export * from "./data-contracts";
87
- *
88
- * with namespace:
89
- *
90
- * export * as namespaceName from "./__exports"; // exports like above
91
- *
92
- *
93
- * namespaceName.login.toMutation()
107
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#namespace)
94
108
  */
95
109
  namespace?: string | ((utils: AnyObject) => string);
96
110
  /**
97
- * Example:
98
- * operationId: 'getById'
99
- * /api/v1/users/{userId} => /api/v1/users/1
100
- *
101
- * addPathSegmentToRouteName: 2 (users), 0 - api
102
- *
103
- * output endpoint instance name: `usersGetById` (pathSegments[2] + operationId)
111
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#addpathsegmenttoroutename)
104
112
  */
105
113
  addPathSegmentToRouteName?: boolean | number;
114
+ /**
115
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#queryclient)
116
+ */
106
117
  queryClient?: 'builtin' | ImportFileParams;
118
+ /**
119
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#endpoint)
120
+ */
107
121
  endpoint?: 'builtin' | ImportFileParams;
122
+ /**
123
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#httpclient)
124
+ */
108
125
  httpClient?: 'builtin' | ImportFileParams;
126
+ /**
127
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#getendpointmeta)
128
+ */
109
129
  getEndpointMeta?: (route: AnyObject, utils: AnyObject) => {
110
- typeName: string;
111
- importTypePath: string;
130
+ typeName?: string;
131
+ typeNameImportPath?: string;
112
132
  tmplData: string;
113
133
  };
134
+ /**
135
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#getrequestmeta)
136
+ */
114
137
  getRequestMeta?: (route: AnyObject, utils: AnyObject) => {
115
138
  tmplData: string;
116
139
  };
117
140
  /**
118
141
  * Additional parameters used to fetch your OpenAPI schema
119
142
  *
120
- * @example
121
- * fetchSchemaRequestOptions: {
122
- * headers: {
123
- * 'PRIVATE-TOKEN': '12345'
124
- * }
125
- * }
143
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#fetchschemarequestoptions)
126
144
  */
127
145
  fetchSchemaRequestOptions?: RequestInit;
128
146
  otherCodegenParams?: AnyObject;
129
- filterEndpoints?: FilterEndpointsFn | string | RegExp | (RegExp | string)[];
130
- filterGroups?: (groupName: string) => boolean;
147
+ /**
148
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#filterendpoints)
149
+ */
150
+ filterEndpoints?: FilterEndpointsOption;
151
+ /**
152
+ * [**Documentation**](https://js2me.github.io/mobx-tanstack-query-api/config/#filtergroups)
153
+ */
154
+ filterGroups?: FilterGroupsOption;
131
155
  libImports?: {
132
156
  'mobx-tanstack-query-api'?: string;
133
157
  };
@@ -1 +1 @@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Ae,CAAC,EAAE,qBAAqB,CAAC;IAExC;;OAEG;IACH,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAElC,UAAU,CAAC,EAAE;QACX,yBAAyB,CAAC,EAAE,MAAM,CAAC;KACpC,CAAC;IAEF,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,UAAU,CAAC,EAAE;QACX,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;QACtE,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;KACnE,CAAC;CACH;AAED,MAAM,MAAM,mBAAmB,GAAG,MAAM,CACtC,YAAY,CAAC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC,EAC5E,gBAAgB,CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KAExD,OAAO,CAAC,IAAI,CAomBd,CAAC"}
package/codegen/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { generateApi as generateApiFromSwagger } from 'swagger-typescript-api';
2
1
  import path from 'node:path';
3
2
  import { fileURLToPath } from 'node:url';
3
+ import { generateApi as generateApiFromSwagger, } from 'swagger-typescript-api';
4
4
  import { allEndpointPerFileTmpl } from './templates/all-endpoints-per-file.tmpl.js';
5
5
  import { allExportsTmpl } from './templates/all-exports.tmpl.js';
6
6
  import { LINTERS_IGNORE } from './templates/constants.js';
@@ -9,6 +9,7 @@ import { endpointPerFileTmpl } from './templates/endpoint-per-file.tmpl.js';
9
9
  import { indexTsForEndpointPerFileTmpl } from './templates/index-ts-for-endpoint-per-file.tmpl.js';
10
10
  import { metaInfoTmpl } from './templates/meta-info.tmpl.js';
11
11
  import { removeUnusedTypes, } from './utils/remove-unused-types.js';
12
+ import { unpackFilterOption } from './utils/unpack-filter-option.js';
12
13
  const __filename = fileURLToPath(import.meta.url);
13
14
  const __dirname = path.dirname(__filename);
14
15
  const __execdirname = process.cwd();
@@ -97,13 +98,13 @@ export const generateApi = async (params) => {
97
98
  hooks: {
98
99
  onInit: (configuration, codeGenProcessFromInit) => {
99
100
  codegenProcess = codeGenProcessFromInit;
100
- // @ts-ignore
101
+ // @ts-expect-error
101
102
  configuration.swaggerSchema.components =
102
- // @ts-ignore
103
+ // @ts-expect-error
103
104
  configuration.swaggerSchema.components || {};
104
- // @ts-ignore
105
+ // @ts-expect-error
105
106
  configuration.swaggerSchema.components.schemas =
106
- // @ts-ignore
107
+ // @ts-expect-error
107
108
  configuration.swaggerSchema.components.schemas || {};
108
109
  return codegenParams?.hooks?.onInit?.(configuration, codeGenProcessFromInit);
109
110
  },
@@ -151,29 +152,7 @@ export const generateApi = async (params) => {
151
152
  const allRoutes = Object.values(generated.configuration.routes)
152
153
  .flat()
153
154
  .flatMap((routeGroup) => 'routes' in routeGroup ? routeGroup.routes : routeGroup);
154
- let filterEndpoint;
155
- if (params.filterEndpoints) {
156
- if (typeof params.filterEndpoints === 'function') {
157
- filterEndpoint = params.filterEndpoints;
158
- }
159
- else {
160
- const regexps = Array.isArray(params.filterEndpoints)
161
- ? params.filterEndpoints
162
- : [params.filterEndpoints];
163
- filterEndpoint = (route) => regexps.some((regexpOrString) => {
164
- if (!route.raw) {
165
- return false;
166
- }
167
- if (typeof regexpOrString === 'string') {
168
- return regexpOrString === route.raw.operationId;
169
- }
170
- return regexpOrString.test(route.raw.operationId);
171
- });
172
- }
173
- }
174
- else {
175
- filterEndpoint = () => true;
176
- }
155
+ const filterEndpoint = unpackFilterOption(params.filterEndpoints, (route) => route.raw?.operationId || '');
177
156
  const reservedDataContractNamesMap = new Map();
178
157
  const collectedExportFilesFromIndexFile = [];
179
158
  const groupsMap = new Map();
@@ -201,7 +180,9 @@ export const generateApi = async (params) => {
201
180
  },
202
181
  });
203
182
  if (Array.isArray(route.raw.tags)) {
204
- route.raw.tags.forEach((tag) => tagsSet.add(tag));
183
+ route.raw.tags.forEach((tag) => {
184
+ tagsSet.add(tag);
185
+ });
205
186
  }
206
187
  reservedDataContractNames.forEach((name) => {
207
188
  reservedDataContractNamesMap.set(name, (reservedDataContractNamesMap.get(name) ?? 0) + 1);
@@ -255,7 +236,9 @@ export const generateApi = async (params) => {
255
236
  if (hasFilteredRoutes) {
256
237
  filteredRoutes.forEach((route) => {
257
238
  if (Array.isArray(route.raw.tags)) {
258
- route.raw.tags.forEach((tag) => tagsSet.add(tag));
239
+ route.raw.tags.forEach((tag) => {
240
+ tagsSet.add(tag);
241
+ });
259
242
  }
260
243
  });
261
244
  const fileName = 'endpoints.ts';
@@ -296,8 +279,9 @@ export const generateApi = async (params) => {
296
279
  groupsMap.get(group)?.push(route);
297
280
  });
298
281
  // #endregion
282
+ const filterGroups = unpackFilterOption(params.filterGroups, (groupName) => groupName);
299
283
  for await (const [groupName, routes] of groupsMap) {
300
- if (params.filterGroups && !params.filterGroups(groupName)) {
284
+ if (!filterGroups(groupName)) {
301
285
  continue;
302
286
  }
303
287
  const fileNamesWithRequestInfo = [];
@@ -330,7 +314,9 @@ export const generateApi = async (params) => {
330
314
  }
331
315
  hasFilteredRoutes = true;
332
316
  if (Array.isArray(route.raw.tags)) {
333
- route.raw.tags.forEach((tag) => tagsSet.add(tag));
317
+ route.raw.tags.forEach((tag) => {
318
+ tagsSet.add(tag);
319
+ });
334
320
  }
335
321
  const fileName = `${_.kebabCase(route.routeName.usage)}.ts`;
336
322
  fileNamesWithRequestInfo.push(fileName);
@@ -367,7 +353,9 @@ export const generateApi = async (params) => {
367
353
  if (hasFilteredRoutes) {
368
354
  filteredRoutes.forEach((route) => {
369
355
  if (Array.isArray(route.raw.tags)) {
370
- route.raw.tags.forEach((tag) => tagsSet.add(tag));
356
+ route.raw.tags.forEach((tag) => {
357
+ tagsSet.add(tag);
358
+ });
371
359
  }
372
360
  });
373
361
  const fileName = 'endpoints.ts';
@@ -1,4 +1,4 @@
1
- import { AnyObject, Maybe } from 'yummies/utils/types';
1
+ import type { AnyObject, Maybe } from 'yummies/utils/types';
2
2
  import type { AllImportFileParams, CodegenDataUtils, CodegenProcess, GenerateQueryApiParams, MetaInfo } from '../index.js';
3
3
  export interface AllEndpointPerFileTmplParams extends AnyObject {
4
4
  routes: AnyObject[];
@@ -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":"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"}
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;AAE5D,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;;;EAuI9B,CAAC"}
@@ -24,9 +24,34 @@ export const allEndpointPerFileTmpl = async ({ routes, configuration, apiParams,
24
24
  });
25
25
  return { ...newEndpointTemplateData, route };
26
26
  });
27
- let metaInfoImport = '';
27
+ const extraImportLines = [];
28
+ const endpointTemplates = await Promise.all(newEndpointTemplates.map(async ({ content: requestInfoInstanceContent, localModelTypes, route, }) => {
29
+ const requestInfoMeta = apiParams.getEndpointMeta?.(route, utils);
30
+ if (requestInfoMeta?.typeNameImportPath && requestInfoMeta.typeName) {
31
+ extraImportLines.push(`import { ${requestInfoMeta.typeName} } from "${requestInfoMeta.typeNameImportPath}";`);
32
+ }
33
+ return `
34
+ ${(await Promise.all(localModelTypes.map(async (modelType) => {
35
+ const contractType = await dataContractTmpl({
36
+ configuration,
37
+ contract: modelType,
38
+ addExportKeyword: true,
39
+ });
40
+ return contractType;
41
+ })))
42
+ .filter(Boolean)
43
+ .join('\n\n')}
44
+
45
+ ${endpointJSDocTmpl({
46
+ route,
47
+ configuration,
48
+ apiParams,
49
+ })}
50
+ export const ${_.camelCase(route.routeName.usage)} = ${requestInfoInstanceContent}
51
+ `;
52
+ }));
28
53
  if (metaInfo) {
29
- metaInfoImport = `import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "${groupName ? '../' : './'}meta-info";`;
54
+ extraImportLines.push(`import { ${[groupName && 'Group', metaInfo?.namespace && 'namespace', 'Tag'].filter(Boolean).join(',')} } from "${groupName ? '../' : './'}meta-info";`);
30
55
  }
31
56
  return {
32
57
  reservedDataContractNames: dataContractNamesInThisFile,
@@ -39,7 +64,7 @@ export const allEndpointPerFileTmpl = async ({ routes, configuration, apiParams,
39
64
  import { ${importFileParams.endpoint.exportName} } from "${importFileParams.endpoint.path}";
40
65
  import { ${importFileParams.httpClient.exportName} } from "${importFileParams.httpClient.path}";
41
66
  import { ${importFileParams.queryClient.exportName} } from "${importFileParams.queryClient.path}";
42
- ${metaInfoImport}
67
+ ${extraImportLines.join('\n')}
43
68
 
44
69
  ${configuration.modelTypes.length > 0
45
70
  ? `
@@ -64,29 +89,7 @@ export const allEndpointPerFileTmpl = async ({ routes, configuration, apiParams,
64
89
  .filter(Boolean)
65
90
  .join('\n\n')}
66
91
 
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')}
92
+ ${endpointTemplates.filter(Boolean).join('\n\n')}
90
93
  `),
91
94
  };
92
95
  };
@@ -1,5 +1,5 @@
1
- import { Maybe } from 'yummies/utils/types';
2
- import { CodegenDataUtils, MetaInfo } from '../index.js';
1
+ import type { Maybe } from 'yummies/utils/types';
2
+ import type { CodegenDataUtils, MetaInfo } from '../index.js';
3
3
  export interface AllExportsTmplParams {
4
4
  formatTSContent: (...args: any[]) => Promise<string>;
5
5
  collectedExportFiles: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"all-exports.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-exports.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIzD,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,OAAO,gBAAgB,uBACgB,CAAC;AAE1C,eAAO,MAAM,cAAc,GAAU,sDAIlC,oBAAoB,oBAMtB,CAAC"}
1
+ {"version":3,"file":"all-exports.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/all-exports.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI9D,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACrD,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC;CACzB;AAED,eAAO,MAAM,sBAAsB,GACjC,WAAW,MAAM,EACjB,OAAO,gBAAgB,uBACgB,CAAC;AAE1C,eAAO,MAAM,cAAc,GAAU,sDAIlC,oBAAoB,oBAMtB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { AnyObject } from 'yummies/utils/types';
1
+ import type { AnyObject } from 'yummies/utils/types';
2
2
  export interface DataContractTmplParams {
3
3
  configuration: AnyObject;
4
4
  contract: AnyObject;
@@ -1 +1 @@
1
- {"version":3,"file":"data-contract.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contract.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,SAAS,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAuBD,eAAO,MAAM,gBAAgB,GAAU,gDAIpC,sBAAsB,oBAmCxB,CAAC"}
1
+ {"version":3,"file":"data-contract.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contract.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,SAAS,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAuBD,eAAO,MAAM,gBAAgB,GAAU,gDAIpC,sBAAsB,oBAmCxB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { AnyObject } from 'yummies/utils/types';
1
+ import type { AnyObject } from 'yummies/utils/types';
2
2
  import type { CodegenProcess, GenerateQueryApiParams } from '../index.js';
3
3
  export interface DataContractsTmplParams extends AnyObject {
4
4
  configuration: AnyObject;
@@ -1 +1 @@
1
- {"version":3,"file":"data-contracts-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contracts-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAK1E,MAAM,WAAW,uBAAwB,SAAQ,SAAS;IACxD,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,eAAO,MAAM,qBAAqB,GAAU,gEAIzC,uBAAuB,iBA6BzB,CAAC"}
1
+ {"version":3,"file":"data-contracts-file.tmpl.d.ts","sourceRoot":"","sources":["../../../src/codegen/templates/data-contracts-file.tmpl.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAK1E,MAAM,WAAW,uBAAwB,SAAQ,SAAS;IACxD,aAAa,EAAE,SAAS,CAAC;IACzB,SAAS,EAAE,sBAAsB,CAAC;IAClC,cAAc,EAAE,cAAc,CAAC;IAC/B,yBAAyB,CAAC,EAAE,MAAM,EAAE,CAAC;CACtC;AAED,eAAO,MAAM,qBAAqB,GAAU,gEAIzC,uBAAuB,iBA6BzB,CAAC"}
@@ -1,5 +1,5 @@
1
- import { AnyObject } from 'yummies/utils/types';
2
- import { GenerateQueryApiParams } from '../index.js';
1
+ import type { AnyObject } from 'yummies/utils/types';
2
+ import type { GenerateQueryApiParams } from '../index.js';
3
3
  export interface EndpointJSDocTmplParams {
4
4
  route: AnyObject;
5
5
  configuration: AnyObject;