@rxap/ts-morph 0.1.0-dev.18 → 0.1.0-dev.19
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/CHANGELOG.md +10 -0
- package/package.json +2 -2
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/index.js.map +1 -1
- package/src/lib/coerce-mapping-class-method.d.ts +10 -0
- package/src/lib/coerce-mapping-class-method.js +29 -0
- package/src/lib/coerce-mapping-class-method.js.map +1 -0
- package/src/lib/nest/operation-id-utilities.d.ts +11 -0
- package/src/lib/nest/operation-id-utilities.js +91 -0
- package/src/lib/nest/operation-id-utilities.js.map +1 -0
- package/src/lib/to-mapping-object.d.ts +6 -0
- package/src/lib/to-mapping-object.js +29 -0
- package/src/lib/to-mapping-object.js.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.1.0-dev.19](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@0.1.0-dev.18...@rxap/ts-morph@0.1.0-dev.19) (2023-11-17)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- add utility function ([19e3337](https://gitlab.com/rxap/packages/commit/19e3337837b0222cda49dafdc675eb0010fc9d6a))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- add ToMappingObject function ([38b1074](https://gitlab.com/rxap/packages/commit/38b10749499e478cb08eb6d66008201426ebbd4c))
|
|
15
|
+
|
|
6
16
|
# [0.1.0-dev.18](https://gitlab.com/rxap/packages/compare/@rxap/ts-morph@0.1.0-dev.17...@rxap/ts-morph@0.1.0-dev.18) (2023-10-16)
|
|
7
17
|
|
|
8
18
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.0-dev.
|
|
2
|
+
"version": "0.1.0-dev.19",
|
|
3
3
|
"name": "@rxap/ts-morph",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"dependencies": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"directory": "packages/ts-morph"
|
|
43
43
|
},
|
|
44
44
|
"type": "commonjs",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "a4dca7e8327ee2684f6aad3d99080200c5ed0c48",
|
|
46
46
|
"main": "./src/index.js",
|
|
47
47
|
"types": "./src/index.d.ts"
|
|
48
48
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ export * from './lib/nest/get-nest-module-metadata';
|
|
|
24
24
|
export * from './lib/nest/has-nest-module-class';
|
|
25
25
|
export * from './lib/nest/is-nest-module-class';
|
|
26
26
|
export * from './lib/nest/nest-provider-object';
|
|
27
|
+
export * from './lib/nest/operation-id-utilities';
|
|
27
28
|
export * from './lib/nest/remove-nest-module-provider';
|
|
28
29
|
export * from './lib/nest/remove-nest-provider-to-array';
|
|
29
30
|
export * from './lib/angular/coerce-app-config-provider';
|
|
@@ -36,6 +37,7 @@ export * from './lib/coerce-class';
|
|
|
36
37
|
export * from './lib/coerce-decorator';
|
|
37
38
|
export * from './lib/coerce-dependency-injection';
|
|
38
39
|
export * from './lib/coerce-imports';
|
|
40
|
+
export * from './lib/coerce-mapping-class-method';
|
|
39
41
|
export * from './lib/coerce-source-file';
|
|
40
42
|
export * from './lib/coerce-statements';
|
|
41
43
|
export * from './lib/coerce-variable-declaration';
|
|
@@ -45,3 +47,4 @@ export * from './lib/get-class-decorator-arguments';
|
|
|
45
47
|
export * from './lib/get-class';
|
|
46
48
|
export * from './lib/get-coerce-array-literal-form-object-literal';
|
|
47
49
|
export * from './lib/provider-object';
|
|
50
|
+
export * from './lib/to-mapping-object';
|
package/src/index.js
CHANGED
|
@@ -28,6 +28,7 @@ tslib_1.__exportStar(require("./lib/nest/get-nest-module-metadata"), exports);
|
|
|
28
28
|
tslib_1.__exportStar(require("./lib/nest/has-nest-module-class"), exports);
|
|
29
29
|
tslib_1.__exportStar(require("./lib/nest/is-nest-module-class"), exports);
|
|
30
30
|
tslib_1.__exportStar(require("./lib/nest/nest-provider-object"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./lib/nest/operation-id-utilities"), exports);
|
|
31
32
|
tslib_1.__exportStar(require("./lib/nest/remove-nest-module-provider"), exports);
|
|
32
33
|
tslib_1.__exportStar(require("./lib/nest/remove-nest-provider-to-array"), exports);
|
|
33
34
|
// endregion
|
|
@@ -44,6 +45,7 @@ tslib_1.__exportStar(require("./lib/coerce-class"), exports);
|
|
|
44
45
|
tslib_1.__exportStar(require("./lib/coerce-decorator"), exports);
|
|
45
46
|
tslib_1.__exportStar(require("./lib/coerce-dependency-injection"), exports);
|
|
46
47
|
tslib_1.__exportStar(require("./lib/coerce-imports"), exports);
|
|
48
|
+
tslib_1.__exportStar(require("./lib/coerce-mapping-class-method"), exports);
|
|
47
49
|
tslib_1.__exportStar(require("./lib/coerce-source-file"), exports);
|
|
48
50
|
tslib_1.__exportStar(require("./lib/coerce-statements"), exports);
|
|
49
51
|
tslib_1.__exportStar(require("./lib/coerce-variable-declaration"), exports);
|
|
@@ -53,5 +55,6 @@ tslib_1.__exportStar(require("./lib/get-class-decorator-arguments"), exports);
|
|
|
53
55
|
tslib_1.__exportStar(require("./lib/get-class"), exports);
|
|
54
56
|
tslib_1.__exportStar(require("./lib/get-coerce-array-literal-form-object-literal"), exports);
|
|
55
57
|
tslib_1.__exportStar(require("./lib/provider-object"), exports);
|
|
58
|
+
tslib_1.__exportStar(require("./lib/to-mapping-object"), exports);
|
|
56
59
|
// endregion
|
|
57
60
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,0EAAgD;AAChD,0EAAgD;AAChD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,mFAAyD;AACzD,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,+DAAqC;AACrC,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,gEAAsC;AACtC,YAAY"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/ts-morph/src/index.ts"],"names":[],"mappings":";;;AAAA,cAAc;AACd,yEAA+C;AAC/C,0EAAgD;AAChD,mFAAyD;AACzD,+EAAqD;AACrD,8EAAoD;AACpD,0EAAgD;AAChD,4EAAkD;AAClD,gFAAsD;AACtD,4EAAkD;AAClD,sFAA4D;AAC5D,4EAAkD;AAClD,sFAA4D;AAC5D,iFAAuD;AACvD,mFAAyD;AACzD,+EAAqD;AACrD,iFAAuD;AACvD,wEAA8C;AAC9C,2EAAiD;AACjD,mFAAyD;AACzD,yFAA+D;AAC/D,kFAAwD;AACxD,0EAAgD;AAChD,8EAAoD;AACpD,2EAAiD;AACjD,0EAAgD;AAChD,0EAAgD;AAChD,4EAAkD;AAClD,iFAAuD;AACvD,mFAAyD;AACzD,YAAY;AAEZ,iBAAiB;AACjB,mFAAyD;AACzD,YAAY;AAEZ,UAAU;AACV,sEAA4C;AAC5C,qEAA2C;AAC3C,yEAA+C;AAC/C,oEAA0C;AAC1C,sEAA4C;AAC5C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,+DAAqC;AACrC,4EAAkD;AAClD,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,+DAAqC;AACrC,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,gEAAsC;AACtC,kEAAwC;AACxC,YAAY"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ClassDeclaration, SourceFile } from 'ts-morph';
|
|
2
|
+
import { ToMappingObjectOptions } from './to-mapping-object';
|
|
3
|
+
export interface CoerceMappingClassMethodOptions {
|
|
4
|
+
parameterType: string;
|
|
5
|
+
mapping: boolean | Record<string, any>;
|
|
6
|
+
mappingOptions?: ToMappingObjectOptions;
|
|
7
|
+
name: string;
|
|
8
|
+
returnType: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function CoerceMappingClassMethod(sourceFile: SourceFile, classDeclaration: ClassDeclaration, options: CoerceMappingClassMethodOptions): void;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoerceMappingClassMethod = void 0;
|
|
4
|
+
const coerce_class_method_1 = require("./coerce-class-method");
|
|
5
|
+
const to_mapping_object_1 = require("./to-mapping-object");
|
|
6
|
+
function CoerceMappingClassMethod(sourceFile, classDeclaration, options) {
|
|
7
|
+
var _a;
|
|
8
|
+
const { parameterType, name, mapping, returnType, mappingOptions = {} } = options;
|
|
9
|
+
(_a = mappingOptions.baseProperty) !== null && _a !== void 0 ? _a : (mappingOptions.baseProperty = 'input');
|
|
10
|
+
const { baseProperty } = mappingOptions;
|
|
11
|
+
(0, coerce_class_method_1.CoerceClassMethod)(classDeclaration, name, {
|
|
12
|
+
parameters: [
|
|
13
|
+
{
|
|
14
|
+
name: baseProperty,
|
|
15
|
+
type: parameterType,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
returnType: returnType,
|
|
19
|
+
statements: mapping === true ? [`return ${baseProperty};`] : [
|
|
20
|
+
w => {
|
|
21
|
+
w.write('return ');
|
|
22
|
+
(0, to_mapping_object_1.ToMappingObject)(mapping, mappingOptions)(w);
|
|
23
|
+
w.write(';');
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.CoerceMappingClassMethod = CoerceMappingClassMethod;
|
|
29
|
+
//# sourceMappingURL=coerce-mapping-class-method.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coerce-mapping-class-method.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-mapping-class-method.ts"],"names":[],"mappings":";;;AAIA,+DAA0D;AAC1D,2DAG6B;AAU7B,SAAgB,wBAAwB,CACtC,UAAsB,EACtB,gBAAkC,EAClC,OAAwC;;IAExC,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAClF,MAAA,cAAc,CAAC,YAAY,oCAA3B,cAAc,CAAC,YAAY,GAAK,OAAO,EAAC;IACxC,MAAM,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;IACxC,IAAA,uCAAiB,EAAC,gBAAgB,EAAE,IAAI,EAAE;QACxC,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,aAAa;aACpB;SACF;QACD,UAAU,EAAE,UAAU;QACtB,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,CAAE,UAAW,YAAa,GAAG,CAAE,CAAC,CAAC,CAAC;YAC/D,CAAC,CAAC,EAAE;gBACF,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;gBACnB,IAAA,mCAAe,EAAC,OAAc,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;gBACnD,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACf,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC;AAxBD,4DAwBC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function OperationIdToClassName(operationId: string): string;
|
|
2
|
+
export declare function ServiceOperationIdToClassName(operationId: string): string;
|
|
3
|
+
export declare function OperationIdToResponseClassName(operationId: string): string;
|
|
4
|
+
export declare function OperationIdToParameterClassName(operationId: string): string;
|
|
5
|
+
export declare function OperationIdToClassImportPath(operationId: string, scope?: string | null): string;
|
|
6
|
+
export declare function OperationIdToRequestBodyClassName(operationId: string): string;
|
|
7
|
+
export declare function ServiceOperationIdToClassImportPath(operationId: string, scope?: string | null): string;
|
|
8
|
+
export declare function OpenApiResponseClassImportPath(response: string, serverId: string, scope?: string | null): string;
|
|
9
|
+
export declare function OperationIdToResponseClassImportPath(operationId: string, scope?: string | null): string;
|
|
10
|
+
export declare function OperationIdToParameterClassImportPath(operationId: string, scope?: string | null): string;
|
|
11
|
+
export declare function OperationIdToRequestBodyClassImportPath(operationId: string, scope?: string | null): string;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationIdToRequestBodyClassImportPath = exports.OperationIdToParameterClassImportPath = exports.OperationIdToResponseClassImportPath = exports.OpenApiResponseClassImportPath = exports.ServiceOperationIdToClassImportPath = exports.OperationIdToRequestBodyClassName = exports.OperationIdToClassImportPath = exports.OperationIdToParameterClassName = exports.OperationIdToResponseClassName = exports.ServiceOperationIdToClassName = exports.OperationIdToClassName = void 0;
|
|
4
|
+
const utilities_1 = require("@rxap/utilities");
|
|
5
|
+
function OperationIdToClassName(operationId) {
|
|
6
|
+
const [id] = operationId.split('@');
|
|
7
|
+
return (0, utilities_1.classify)(id) + 'RemoteMethod';
|
|
8
|
+
}
|
|
9
|
+
exports.OperationIdToClassName = OperationIdToClassName;
|
|
10
|
+
function ServiceOperationIdToClassName(operationId) {
|
|
11
|
+
const [id] = operationId.split('@');
|
|
12
|
+
return (0, utilities_1.classify)(id) + 'Command';
|
|
13
|
+
}
|
|
14
|
+
exports.ServiceOperationIdToClassName = ServiceOperationIdToClassName;
|
|
15
|
+
function OperationIdToResponseClassName(operationId) {
|
|
16
|
+
const [id] = operationId.split('@');
|
|
17
|
+
return (0, utilities_1.classify)(id) + 'Response';
|
|
18
|
+
}
|
|
19
|
+
exports.OperationIdToResponseClassName = OperationIdToResponseClassName;
|
|
20
|
+
function OperationIdToParameterClassName(operationId) {
|
|
21
|
+
const [id] = operationId.split('@');
|
|
22
|
+
return (0, utilities_1.classify)(id) + 'Parameter';
|
|
23
|
+
}
|
|
24
|
+
exports.OperationIdToParameterClassName = OperationIdToParameterClassName;
|
|
25
|
+
function OperationIdToClassImportPath(operationId, scope) {
|
|
26
|
+
const [id, serverId = 'legacy'] = operationId.split('@');
|
|
27
|
+
if (scope) {
|
|
28
|
+
return `${scope}/open-api-${(0, utilities_1.dasherize)(serverId)}/remote-methods/${(0, utilities_1.dasherize)(id)}.remote-method`;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return `open-api-${(0, utilities_1.dasherize)(serverId)}/remote-methods/${(0, utilities_1.dasherize)(id)}.remote-method`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.OperationIdToClassImportPath = OperationIdToClassImportPath;
|
|
35
|
+
function OperationIdToRequestBodyClassName(operationId) {
|
|
36
|
+
const [id] = operationId.split('@');
|
|
37
|
+
return (0, utilities_1.classify)(id) + 'RequestBody';
|
|
38
|
+
}
|
|
39
|
+
exports.OperationIdToRequestBodyClassName = OperationIdToRequestBodyClassName;
|
|
40
|
+
function ServiceOperationIdToClassImportPath(operationId, scope) {
|
|
41
|
+
const [id, serverId = 'legacy'] = operationId.split('@');
|
|
42
|
+
if (scope) {
|
|
43
|
+
return `${scope}/service-open-api-${(0, utilities_1.dasherize)(serverId)}/commands/${(0, utilities_1.dasherize)(id)}.command`;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return `service-open-api-${(0, utilities_1.dasherize)(serverId)}/commands/${(0, utilities_1.dasherize)(id)}.command`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ServiceOperationIdToClassImportPath = ServiceOperationIdToClassImportPath;
|
|
50
|
+
function OpenApiResponseClassImportPath(response, serverId, scope) {
|
|
51
|
+
if (scope) {
|
|
52
|
+
return `${scope}/open-api-${(0, utilities_1.dasherize)(serverId)}/responses/${(0, utilities_1.dasherize)(response)
|
|
53
|
+
.replace('-response', '')}.response`;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return `open-api-${(0, utilities_1.dasherize)(serverId)}/responses/${(0, utilities_1.dasherize)(response)
|
|
57
|
+
.replace('-response', '')}.response`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.OpenApiResponseClassImportPath = OpenApiResponseClassImportPath;
|
|
61
|
+
function OperationIdToResponseClassImportPath(operationId, scope) {
|
|
62
|
+
const [id, serverId = 'legacy'] = operationId.split('@');
|
|
63
|
+
if (scope) {
|
|
64
|
+
return `${scope}/open-api-${(0, utilities_1.dasherize)(serverId)}/responses/${(0, utilities_1.dasherize)(id)}.response`;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return `open-api-${(0, utilities_1.dasherize)(serverId)}/responses/${(0, utilities_1.dasherize)(id)}.response`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.OperationIdToResponseClassImportPath = OperationIdToResponseClassImportPath;
|
|
71
|
+
function OperationIdToParameterClassImportPath(operationId, scope) {
|
|
72
|
+
const [id, serverId = 'legacy'] = operationId.split('@');
|
|
73
|
+
if (scope) {
|
|
74
|
+
return `${scope}/open-api-${(0, utilities_1.dasherize)(serverId)}/parameters/${(0, utilities_1.dasherize)(id)}.parameter`;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return `open-api-${(0, utilities_1.dasherize)(serverId)}/parameters/${(0, utilities_1.dasherize)(id)}.parameter`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.OperationIdToParameterClassImportPath = OperationIdToParameterClassImportPath;
|
|
81
|
+
function OperationIdToRequestBodyClassImportPath(operationId, scope) {
|
|
82
|
+
const [id, serverId = 'legacy'] = operationId.split('@');
|
|
83
|
+
if (scope) {
|
|
84
|
+
return `${scope}/open-api-${(0, utilities_1.dasherize)(serverId)}/request-bodies/${(0, utilities_1.dasherize)(id)}.request-body`;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return `open-api-${(0, utilities_1.dasherize)(serverId)}/request-bodies/${(0, utilities_1.dasherize)(id)}.request-body`;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.OperationIdToRequestBodyClassImportPath = OperationIdToRequestBodyClassImportPath;
|
|
91
|
+
//# sourceMappingURL=operation-id-utilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-id-utilities.js","sourceRoot":"","sources":["../../../../../../packages/ts-morph/src/lib/nest/operation-id-utilities.ts"],"names":[],"mappings":";;;AAAA,+CAGyB;AAGzB,SAAgB,sBAAsB,CAAC,WAAmB;IACxD,MAAM,CAAE,EAAE,CAAE,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,IAAA,oBAAQ,EAAC,EAAE,CAAC,GAAG,cAAc,CAAC;AACvC,CAAC;AAHD,wDAGC;AAED,SAAgB,6BAA6B,CAAC,WAAmB;IAC/D,MAAM,CAAE,EAAE,CAAE,GAAG,WAAW,CAAC,KAAK,CAAC,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,EAAE,KAAqB;IAC9F,MAAM,CAAE,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAAE,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3D,IAAI,KAAK,EAAE;QACT,OAAO,GAAI,KAAM,aAAc,IAAA,qBAAS,EAAC,QAAQ,CAAE,eAAgB,IAAA,qBAAS,EAAC,EAAE,CAAE,YAAY,CAAC;KAC/F;SAAM;QACL,OAAO,YAAa,IAAA,qBAAS,EAAC,QAAQ,CAAE,eAAgB,IAAA,qBAAS,EAAC,EAAE,CAAE,YAAY,CAAC;KACpF;AACH,CAAC;AAPD,sFAOC;AAED,SAAgB,uCAAuC,CAAC,WAAmB,EAAE,KAAqB;IAChG,MAAM,CAAE,EAAE,EAAE,QAAQ,GAAG,QAAQ,CAAE,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3D,IAAI,KAAK,EAAE;QACT,OAAO,GAAI,KAAM,aAAc,IAAA,qBAAS,EAAC,QAAQ,CAAE,mBAAoB,IAAA,qBAAS,EAAC,EAAE,CAAE,eAAe,CAAC;KACtG;SAAM;QACL,OAAO,YAAa,IAAA,qBAAS,EAAC,QAAQ,CAAE,mBAAoB,IAAA,qBAAS,EAAC,EAAE,CAAE,eAAe,CAAC;KAC3F;AACH,CAAC;AAPD,0FAOC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WriterFunction } from 'ts-morph';
|
|
2
|
+
export interface ToMappingObjectOptions {
|
|
3
|
+
baseProperty?: string;
|
|
4
|
+
aliasFnc?: (key: string, value: string) => string;
|
|
5
|
+
}
|
|
6
|
+
export declare function ToMappingObject(input: Record<string, any>, options?: ToMappingObjectOptions): WriterFunction;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToMappingObject = void 0;
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
function ToMappingObject(input, options = {}) {
|
|
6
|
+
const { baseProperty, aliasFnc, } = options;
|
|
7
|
+
const mapping = {};
|
|
8
|
+
for (const [key, value] of Object.entries(input)) {
|
|
9
|
+
if (typeof value === 'object') {
|
|
10
|
+
mapping[key] = ToMappingObject(value, options);
|
|
11
|
+
}
|
|
12
|
+
else if (typeof value === 'string') {
|
|
13
|
+
let accessKey = value;
|
|
14
|
+
if (aliasFnc) {
|
|
15
|
+
accessKey = aliasFnc(key, value);
|
|
16
|
+
}
|
|
17
|
+
if (baseProperty) {
|
|
18
|
+
accessKey = `${baseProperty}.${accessKey}`;
|
|
19
|
+
}
|
|
20
|
+
mapping[key] = accessKey;
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
throw new Error(`Invalid value type ${typeof value}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return ts_morph_1.Writers.object(mapping);
|
|
27
|
+
}
|
|
28
|
+
exports.ToMappingObject = ToMappingObject;
|
|
29
|
+
//# sourceMappingURL=to-mapping-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-mapping-object.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/to-mapping-object.ts"],"names":[],"mappings":";;;AAAA,uCAGkB;AAOlB,SAAgB,eAAe,CAAC,KAA0B,EAAE,UAAkC,EAAE;IAC9F,MAAM,EACJ,YAAY,EACZ,QAAQ,GACT,GAAG,OAAO,CAAC;IACZ,MAAM,OAAO,GAA4C,EAAE,CAAC;IAC5D,KAAK,MAAM,CAAE,GAAG,EAAE,KAAK,CAAE,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SAChD;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YACpC,IAAI,SAAS,GAAG,KAAK,CAAC;YACtB,IAAI,QAAQ,EAAE;gBACZ,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;aAClC;YACD,IAAI,YAAY,EAAE;gBAChB,SAAS,GAAG,GAAI,YAAa,IAAK,SAAU,EAAE,CAAC;aAChD;YACD,OAAO,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;SAC1B;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,sBAAuB,OAAO,KAAM,EAAE,CAAC,CAAC;SACzD;KACF;IACD,OAAO,kBAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAvBD,0CAuBC"}
|