mobx-tanstack-query-api 0.0.85 → 0.0.86
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.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LoDashStatic } from 'lodash';
|
|
2
2
|
import { AnyObject, KeyOfByValue, Maybe } from 'yummies/utils/types';
|
|
3
|
+
import { RemoveUnusedTypesParams } from './utils/remove-unused-types.js';
|
|
3
4
|
export type CodegenDataUtils = {
|
|
4
5
|
_: LoDashStatic;
|
|
5
6
|
getInlineParseContent: (requestParams: AnyObject) => string;
|
|
@@ -22,7 +23,9 @@ export interface GenerateQueryApiParams {
|
|
|
22
23
|
requestPathPrefix?: string;
|
|
23
24
|
requestPathSuffix?: string;
|
|
24
25
|
requestInfoPrefix?: string;
|
|
25
|
-
removeUnusedTypes?:
|
|
26
|
+
removeUnusedTypes?: true | {
|
|
27
|
+
keepTypes?: RemoveUnusedTypesParams['keepTypes'];
|
|
28
|
+
};
|
|
26
29
|
formatExportGroupName?: (groupName: string, utils: CodegenDataUtils) => string;
|
|
27
30
|
/**
|
|
28
31
|
* Group endpoints and collect it into object
|
package/codegen/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAWrE,OAAO,EAEL,uBAAuB,EACxB,MAA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AsB,CAAC,EAAE,SAAS,GAAG,gBAAgB,CAAC,EAC5E,gBAAgB,CACjB,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,QAAQ,sBAAsB,GAAG,sBAAsB,EAAE,KACxD,OAAO,CAAC,IAAI,CAifd,CAAC"}
|
package/codegen/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { dataContractsFileTmpl } from './templates/data-contracts-file.tmpl.js';
|
|
|
7
7
|
import { endpointPerFileTmpl } from './templates/endpoint-per-file.tmpl.js';
|
|
8
8
|
import { indexTsForEndpointPerFileTmpl } from './templates/index-ts-for-endpoint-per-file.tmpl.js';
|
|
9
9
|
import { metaInfoTmpl } from './templates/meta-info.tmpl.js';
|
|
10
|
-
import { removeUnusedTypes } from './utils/remove-unused-types.js';
|
|
10
|
+
import { removeUnusedTypes, } from './utils/remove-unused-types.js';
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
13
13
|
const __execdirname = process.cwd();
|
|
@@ -384,7 +384,10 @@ export * as ${namespace} from './__exports';
|
|
|
384
384
|
}
|
|
385
385
|
if (params.removeUnusedTypes) {
|
|
386
386
|
removeUnusedTypes({
|
|
387
|
-
|
|
387
|
+
directory: params.output,
|
|
388
|
+
keepTypes: params.removeUnusedTypes === true
|
|
389
|
+
? undefined
|
|
390
|
+
: params.removeUnusedTypes.keepTypes,
|
|
388
391
|
});
|
|
389
392
|
}
|
|
390
393
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface RemoveUnusedTypesParams {
|
|
2
|
+
directory: string;
|
|
3
|
+
keepTypes?: RegExp | (RegExp | string)[];
|
|
4
|
+
}
|
|
5
|
+
export declare const removeUnusedTypes: (params: RemoveUnusedTypesParams) => Promise<void>;
|
|
4
6
|
//# sourceMappingURL=remove-unused-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remove-unused-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/utils/remove-unused-types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"remove-unused-types.d.ts","sourceRoot":"","sources":["../../../src/codegen/utils/remove-unused-types.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;CAC1C;AAwJD,eAAO,MAAM,iBAAiB,GAAU,QAAQ,uBAAuB,kBAKtE,CAAC"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
1
|
/* eslint-disable no-constant-condition */
|
|
2
2
|
import { Project, SyntaxKind, Node } from 'ts-morph';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
-
const
|
|
4
|
+
const checkAbleToRemoveType = (typeName, keepTypes) => {
|
|
5
|
+
if (!keepTypes) {
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
const keepTypesArr = Array.isArray(keepTypes) ? keepTypes : [keepTypes];
|
|
9
|
+
return keepTypesArr.every((keepTypeCheck) => {
|
|
10
|
+
if (typeof keepTypeCheck === 'string') {
|
|
11
|
+
return typeName !== keepTypeCheck;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return !keepTypeCheck.test(typeName);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
const removeUnusedTypesItteration = async ({ directory, keepTypes, }) => {
|
|
5
19
|
const project = new Project();
|
|
6
20
|
project.addSourceFilesAtPaths([
|
|
7
|
-
path.join(
|
|
8
|
-
path.join(
|
|
21
|
+
path.join(directory, '**/*.ts'),
|
|
22
|
+
path.join(directory, '**/*.tsx'),
|
|
9
23
|
]);
|
|
10
|
-
const dataContractsSourceFile = project.getSourceFile((sourceFile) => sourceFile.getFilePath().includes(`${
|
|
24
|
+
const dataContractsSourceFile = project.getSourceFile((sourceFile) => sourceFile.getFilePath().includes(`${directory}/data-contracts.ts`));
|
|
11
25
|
if (!dataContractsSourceFile)
|
|
12
26
|
return;
|
|
13
27
|
const exportedDeclarations = dataContractsSourceFile.getExportedDeclarations();
|
|
@@ -87,7 +101,7 @@ const removeUnusedTypesItteration = async ({ dir }) => {
|
|
|
87
101
|
if (usedTypes.has(name))
|
|
88
102
|
continue;
|
|
89
103
|
for (const decl of declarations) {
|
|
90
|
-
if ('remove' in decl) {
|
|
104
|
+
if ('remove' in decl && checkAbleToRemoveType(name, keepTypes)) {
|
|
91
105
|
decl.remove();
|
|
92
106
|
removedCount++;
|
|
93
107
|
}
|
|
@@ -98,9 +112,9 @@ const removeUnusedTypesItteration = async ({ dir }) => {
|
|
|
98
112
|
}
|
|
99
113
|
return removedCount;
|
|
100
114
|
};
|
|
101
|
-
export const removeUnusedTypes = async (
|
|
115
|
+
export const removeUnusedTypes = async (params) => {
|
|
102
116
|
while (true) {
|
|
103
|
-
const removedCount = (await removeUnusedTypesItteration(
|
|
117
|
+
const removedCount = (await removeUnusedTypesItteration(params)) ?? 0;
|
|
104
118
|
if (removedCount === 0)
|
|
105
119
|
break;
|
|
106
120
|
}
|