@rxap/ts-morph 0.1.0-dev.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 (132) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/GETSTARTED.md +0 -0
  3. package/GUIDES.md +0 -0
  4. package/LICENSE.md +621 -0
  5. package/README.md +21 -0
  6. package/package.json +47 -0
  7. package/src/index.d.ts +41 -0
  8. package/src/index.js +49 -0
  9. package/src/index.js.map +1 -0
  10. package/src/lib/coerce-class-constructor.d.ts +2 -0
  11. package/src/lib/coerce-class-constructor.js +14 -0
  12. package/src/lib/coerce-class-constructor.js.map +1 -0
  13. package/src/lib/coerce-class-method.d.ts +2 -0
  14. package/src/lib/coerce-class-method.js +13 -0
  15. package/src/lib/coerce-class-method.js.map +1 -0
  16. package/src/lib/coerce-class.d.ts +2 -0
  17. package/src/lib/coerce-class.js +12 -0
  18. package/src/lib/coerce-class.js.map +1 -0
  19. package/src/lib/coerce-decorator.d.ts +5 -0
  20. package/src/lib/coerce-decorator.js +14 -0
  21. package/src/lib/coerce-decorator.js.map +1 -0
  22. package/src/lib/coerce-dependency-injection.d.ts +14 -0
  23. package/src/lib/coerce-dependency-injection.js +57 -0
  24. package/src/lib/coerce-dependency-injection.js.map +1 -0
  25. package/src/lib/coerce-imports.d.ts +21 -0
  26. package/src/lib/coerce-imports.js +235 -0
  27. package/src/lib/coerce-imports.js.map +1 -0
  28. package/src/lib/coerce-source-file.d.ts +2 -0
  29. package/src/lib/coerce-source-file.js +12 -0
  30. package/src/lib/coerce-source-file.js.map +1 -0
  31. package/src/lib/coerce-statements.d.ts +2 -0
  32. package/src/lib/coerce-statements.js +11 -0
  33. package/src/lib/coerce-statements.js.map +1 -0
  34. package/src/lib/coerce-variable-declaration.d.ts +2 -0
  35. package/src/lib/coerce-variable-declaration.js +25 -0
  36. package/src/lib/coerce-variable-declaration.js.map +1 -0
  37. package/src/lib/find-function.d.ts +7 -0
  38. package/src/lib/find-function.js +8 -0
  39. package/src/lib/find-function.js.map +1 -0
  40. package/src/lib/get-class-decorator-arguments.d.ts +3 -0
  41. package/src/lib/get-class-decorator-arguments.js +16 -0
  42. package/src/lib/get-class-decorator-arguments.js.map +1 -0
  43. package/src/lib/get-class.d.ts +3 -0
  44. package/src/lib/get-class.js +26 -0
  45. package/src/lib/get-class.js.map +1 -0
  46. package/src/lib/get-coerce-array-literal-form-object-literal.d.ts +2 -0
  47. package/src/lib/get-coerce-array-literal-form-object-literal.js +26 -0
  48. package/src/lib/get-coerce-array-literal-form-object-literal.js.map +1 -0
  49. package/src/lib/nest/add-health-endpoint.d.ts +2 -0
  50. package/src/lib/nest/add-health-endpoint.js +57 -0
  51. package/src/lib/nest/add-health-endpoint.js.map +1 -0
  52. package/src/lib/nest/add-health-indicator.d.ts +2 -0
  53. package/src/lib/nest/add-health-indicator.js +48 -0
  54. package/src/lib/nest/add-health-indicator.js.map +1 -0
  55. package/src/lib/nest/add-to-global-health-endpoint.d.ts +2 -0
  56. package/src/lib/nest/add-to-global-health-endpoint.js +53 -0
  57. package/src/lib/nest/add-to-global-health-endpoint.js.map +1 -0
  58. package/src/lib/nest/coerce-app-guard-provider.d.ts +2 -0
  59. package/src/lib/nest/coerce-app-guard-provider.js +24 -0
  60. package/src/lib/nest/coerce-app-guard-provider.js.map +1 -0
  61. package/src/lib/nest/coerce-health-controller.d.ts +2 -0
  62. package/src/lib/nest/coerce-health-controller.js +23 -0
  63. package/src/lib/nest/coerce-health-controller.js.map +1 -0
  64. package/src/lib/nest/coerce-health-module.d.ts +2 -0
  65. package/src/lib/nest/coerce-health-module.js +36 -0
  66. package/src/lib/nest/coerce-health-module.js.map +1 -0
  67. package/src/lib/nest/coerce-nest-app-config.d.ts +11 -0
  68. package/src/lib/nest/coerce-nest-app-config.js +77 -0
  69. package/src/lib/nest/coerce-nest-app-config.js.map +1 -0
  70. package/src/lib/nest/coerce-nest-app-controller.d.ts +5 -0
  71. package/src/lib/nest/coerce-nest-app-controller.js +49 -0
  72. package/src/lib/nest/coerce-nest-app-controller.js.map +1 -0
  73. package/src/lib/nest/coerce-nest-app-module.d.ts +5 -0
  74. package/src/lib/nest/coerce-nest-app-module.js +13 -0
  75. package/src/lib/nest/coerce-nest-app-module.js.map +1 -0
  76. package/src/lib/nest/coerce-nest-config-module-import.d.ts +4 -0
  77. package/src/lib/nest/coerce-nest-config-module-import.js +26 -0
  78. package/src/lib/nest/coerce-nest-config-module-import.js.map +1 -0
  79. package/src/lib/nest/coerce-nest-controller.d.ts +6 -0
  80. package/src/lib/nest/coerce-nest-controller.js +26 -0
  81. package/src/lib/nest/coerce-nest-controller.js.map +1 -0
  82. package/src/lib/nest/coerce-nest-environment-provider.d.ts +2 -0
  83. package/src/lib/nest/coerce-nest-environment-provider.js +24 -0
  84. package/src/lib/nest/coerce-nest-environment-provider.js.map +1 -0
  85. package/src/lib/nest/coerce-nest-logger-provider.d.ts +2 -0
  86. package/src/lib/nest/coerce-nest-logger-provider.js +24 -0
  87. package/src/lib/nest/coerce-nest-logger-provider.js.map +1 -0
  88. package/src/lib/nest/coerce-nest-module-controller.d.ts +8 -0
  89. package/src/lib/nest/coerce-nest-module-controller.js +24 -0
  90. package/src/lib/nest/coerce-nest-module-controller.js.map +1 -0
  91. package/src/lib/nest/coerce-nest-module-import.d.ts +9 -0
  92. package/src/lib/nest/coerce-nest-module-import.js +29 -0
  93. package/src/lib/nest/coerce-nest-module-import.js.map +1 -0
  94. package/src/lib/nest/coerce-nest-module-provider.d.ts +9 -0
  95. package/src/lib/nest/coerce-nest-module-provider.js +24 -0
  96. package/src/lib/nest/coerce-nest-module-provider.js.map +1 -0
  97. package/src/lib/nest/coerce-nest-module.d.ts +6 -0
  98. package/src/lib/nest/coerce-nest-module.js +31 -0
  99. package/src/lib/nest/coerce-nest-module.js.map +1 -0
  100. package/src/lib/nest/coerce-nest-operation.d.ts +40 -0
  101. package/src/lib/nest/coerce-nest-operation.js +253 -0
  102. package/src/lib/nest/coerce-nest-operation.js.map +1 -0
  103. package/src/lib/nest/coerce-nest-provider-to-array.d.ts +3 -0
  104. package/src/lib/nest/coerce-nest-provider-to-array.js +42 -0
  105. package/src/lib/nest/coerce-nest-provider-to-array.js.map +1 -0
  106. package/src/lib/nest/coerce-nest-throttler-module-import.d.ts +4 -0
  107. package/src/lib/nest/coerce-nest-throttler-module-import.js +34 -0
  108. package/src/lib/nest/coerce-nest-throttler-module-import.js.map +1 -0
  109. package/src/lib/nest/find-nest-module-source-file.d.ts +2 -0
  110. package/src/lib/nest/find-nest-module-source-file.js +10 -0
  111. package/src/lib/nest/find-nest-module-source-file.js.map +1 -0
  112. package/src/lib/nest/get-controller-class.d.ts +2 -0
  113. package/src/lib/nest/get-controller-class.js +18 -0
  114. package/src/lib/nest/get-controller-class.js.map +1 -0
  115. package/src/lib/nest/get-nest-module-metadata.d.ts +2 -0
  116. package/src/lib/nest/get-nest-module-metadata.js +19 -0
  117. package/src/lib/nest/get-nest-module-metadata.js.map +1 -0
  118. package/src/lib/nest/has-nest-module-class.d.ts +2 -0
  119. package/src/lib/nest/has-nest-module-class.js +11 -0
  120. package/src/lib/nest/has-nest-module-class.js.map +1 -0
  121. package/src/lib/nest/is-nest-module-class.d.ts +2 -0
  122. package/src/lib/nest/is-nest-module-class.js +8 -0
  123. package/src/lib/nest/is-nest-module-class.js.map +1 -0
  124. package/src/lib/nest/nest-provider-object.d.ts +10 -0
  125. package/src/lib/nest/nest-provider-object.js +3 -0
  126. package/src/lib/nest/nest-provider-object.js.map +1 -0
  127. package/src/lib/nest/remove-nest-module-provider.d.ts +3 -0
  128. package/src/lib/nest/remove-nest-module-provider.js +13 -0
  129. package/src/lib/nest/remove-nest-module-provider.js.map +1 -0
  130. package/src/lib/nest/remove-nest-provider-to-array.d.ts +3 -0
  131. package/src/lib/nest/remove-nest-provider-to-array.js +29 -0
  132. package/src/lib/nest/remove-nest-provider-to-array.js.map +1 -0
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@rxap/ts-morph",
3
+ "version": "0.1.0-dev.0",
4
+ "type": "commonjs",
5
+ "publishConfig": {
6
+ "access": "public",
7
+ "directory": "../../dist/packages/ts-morph"
8
+ },
9
+ "keywords": [
10
+ "rxap",
11
+ "packages",
12
+ "ts-morph"
13
+ ],
14
+ "homepage": "https:/gitlab.com/rxap/packages/packages/ts-morph",
15
+ "bugs": {
16
+ "url": "https://gitlab.com/rxap/packages/-/issues",
17
+ "email": "incoming+rxap-packages-14898188-issue-@incoming.gitlab.com"
18
+ },
19
+ "license": "GPL-3.0-or-later",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://gitlab.com/rxap/packages.git",
23
+ "directory": "packages/ts-morph"
24
+ },
25
+ "author": {
26
+ "name": "Merzough Münker",
27
+ "email": "mmuenker@digitaix.com"
28
+ },
29
+ "nx-migrations": {
30
+ "packageGroup": [
31
+ {
32
+ "package": "@rxap/utilities",
33
+ "version": "16.0.0-dev.12"
34
+ }
35
+ ]
36
+ },
37
+ "dependencies": {
38
+ "tslib": "2.6.2"
39
+ },
40
+ "peerDependencies": {
41
+ "@rxap/utilities": "*",
42
+ "ts-morph": "^18.0.0"
43
+ },
44
+ "gitHead": "3d49d0a2548a0c403ad55c564108b54ba734a677",
45
+ "main": "./src/index.js",
46
+ "types": "./src/index.d.ts"
47
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ export * from './lib/nest/add-health-endpoint';
2
+ export * from './lib/nest/add-health-indicator';
3
+ export * from './lib/nest/add-to-global-health-endpoint';
4
+ export * from './lib/nest/coerce-app-guard-provider';
5
+ export * from './lib/nest/coerce-health-controller';
6
+ export * from './lib/nest/coerce-health-module';
7
+ export * from './lib/nest/coerce-nest-app-config';
8
+ export * from './lib/nest/coerce-nest-app-controller';
9
+ export * from './lib/nest/coerce-nest-app-module';
10
+ export * from './lib/nest/coerce-nest-config-module-import';
11
+ export * from './lib/nest/coerce-nest-controller';
12
+ export * from './lib/nest/coerce-nest-environment-provider';
13
+ export * from './lib/nest/coerce-nest-logger-provider';
14
+ export * from './lib/nest/coerce-nest-module-controller';
15
+ export * from './lib/nest/coerce-nest-module-import';
16
+ export * from './lib/nest/coerce-nest-module-provider';
17
+ export * from './lib/nest/coerce-nest-module';
18
+ export * from './lib/nest/coerce-nest-operation';
19
+ export * from './lib/nest/coerce-nest-provider-to-array';
20
+ export * from './lib/nest/coerce-nest-throttler-module-import';
21
+ export * from './lib/nest/find-nest-module-source-file';
22
+ export * from './lib/nest/get-controller-class';
23
+ export * from './lib/nest/get-nest-module-metadata';
24
+ export * from './lib/nest/has-nest-module-class';
25
+ export * from './lib/nest/is-nest-module-class';
26
+ export * from './lib/nest/nest-provider-object';
27
+ export * from './lib/nest/remove-nest-module-provider';
28
+ export * from './lib/nest/remove-nest-provider-to-array';
29
+ export * from './lib/coerce-class-constructor';
30
+ export * from './lib/coerce-class-method';
31
+ export * from './lib/coerce-class';
32
+ export * from './lib/coerce-decorator';
33
+ export * from './lib/coerce-dependency-injection';
34
+ export * from './lib/coerce-imports';
35
+ export * from './lib/coerce-source-file';
36
+ export * from './lib/coerce-statements';
37
+ export * from './lib/coerce-variable-declaration';
38
+ export * from './lib/find-function';
39
+ export * from './lib/get-class-decorator-arguments';
40
+ export * from './lib/get-class';
41
+ export * from './lib/get-coerce-array-literal-form-object-literal';
package/src/index.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ // region nest
5
+ tslib_1.__exportStar(require("./lib/nest/add-health-endpoint"), exports);
6
+ tslib_1.__exportStar(require("./lib/nest/add-health-indicator"), exports);
7
+ tslib_1.__exportStar(require("./lib/nest/add-to-global-health-endpoint"), exports);
8
+ tslib_1.__exportStar(require("./lib/nest/coerce-app-guard-provider"), exports);
9
+ tslib_1.__exportStar(require("./lib/nest/coerce-health-controller"), exports);
10
+ tslib_1.__exportStar(require("./lib/nest/coerce-health-module"), exports);
11
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-app-config"), exports);
12
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-app-controller"), exports);
13
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-app-module"), exports);
14
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-config-module-import"), exports);
15
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-controller"), exports);
16
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-environment-provider"), exports);
17
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-logger-provider"), exports);
18
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-module-controller"), exports);
19
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-module-import"), exports);
20
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-module-provider"), exports);
21
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-module"), exports);
22
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-operation"), exports);
23
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-provider-to-array"), exports);
24
+ tslib_1.__exportStar(require("./lib/nest/coerce-nest-throttler-module-import"), exports);
25
+ tslib_1.__exportStar(require("./lib/nest/find-nest-module-source-file"), exports);
26
+ tslib_1.__exportStar(require("./lib/nest/get-controller-class"), exports);
27
+ tslib_1.__exportStar(require("./lib/nest/get-nest-module-metadata"), exports);
28
+ tslib_1.__exportStar(require("./lib/nest/has-nest-module-class"), exports);
29
+ tslib_1.__exportStar(require("./lib/nest/is-nest-module-class"), exports);
30
+ tslib_1.__exportStar(require("./lib/nest/nest-provider-object"), exports);
31
+ tslib_1.__exportStar(require("./lib/nest/remove-nest-module-provider"), exports);
32
+ tslib_1.__exportStar(require("./lib/nest/remove-nest-provider-to-array"), exports);
33
+ // endregion
34
+ // region
35
+ tslib_1.__exportStar(require("./lib/coerce-class-constructor"), exports);
36
+ tslib_1.__exportStar(require("./lib/coerce-class-method"), exports);
37
+ tslib_1.__exportStar(require("./lib/coerce-class"), exports);
38
+ tslib_1.__exportStar(require("./lib/coerce-decorator"), exports);
39
+ tslib_1.__exportStar(require("./lib/coerce-dependency-injection"), exports);
40
+ tslib_1.__exportStar(require("./lib/coerce-imports"), exports);
41
+ tslib_1.__exportStar(require("./lib/coerce-source-file"), exports);
42
+ tslib_1.__exportStar(require("./lib/coerce-statements"), exports);
43
+ tslib_1.__exportStar(require("./lib/coerce-variable-declaration"), exports);
44
+ tslib_1.__exportStar(require("./lib/find-function"), exports);
45
+ tslib_1.__exportStar(require("./lib/get-class-decorator-arguments"), exports);
46
+ tslib_1.__exportStar(require("./lib/get-class"), exports);
47
+ tslib_1.__exportStar(require("./lib/get-coerce-array-literal-form-object-literal"), exports);
48
+ // endregion
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,UAAU;AACV,yEAA+C;AAC/C,oEAA0C;AAC1C,6DAAmC;AACnC,iEAAuC;AACvC,4EAAkD;AAClD,+DAAqC;AACrC,mEAAyC;AACzC,kEAAwC;AACxC,4EAAkD;AAClD,8DAAoC;AACpC,8EAAoD;AACpD,0DAAgC;AAChC,6FAAmE;AACnE,YAAY"}
@@ -0,0 +1,2 @@
1
+ import { ClassDeclaration } from 'ts-morph';
2
+ export declare function CoerceClassConstructor(classDeclaration: ClassDeclaration): import("ts-morph").ConstructorDeclaration[];
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceClassConstructor = void 0;
4
+ function CoerceClassConstructor(classDeclaration) {
5
+ const constructorDeclarations = classDeclaration.getConstructors();
6
+ if (constructorDeclarations.length === 0) {
7
+ constructorDeclarations.push(classDeclaration.addConstructor({
8
+ parameters: [],
9
+ }));
10
+ }
11
+ return constructorDeclarations;
12
+ }
13
+ exports.CoerceClassConstructor = CoerceClassConstructor;
14
+ //# sourceMappingURL=coerce-class-constructor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-class-constructor.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-class-constructor.ts"],"names":[],"mappings":";;;AAEA,SAAgB,sBAAsB,CAAC,gBAAkC;IACvE,MAAM,uBAAuB,GAAG,gBAAgB,CAAC,eAAe,EAAE,CAAC;IACnE,IAAI,uBAAuB,CAAC,MAAM,KAAK,CAAC,EAAE;QACxC,uBAAuB,CAAC,IAAI,CAC1B,gBAAgB,CAAC,cAAc,CAAC;YAC9B,UAAU,EAAE,EAAE;SACf,CAAC,CACH,CAAC;KACH;IACD,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAVD,wDAUC"}
@@ -0,0 +1,2 @@
1
+ import { ClassDeclaration, MethodDeclarationStructure, OptionalKind } from 'ts-morph';
2
+ export declare function CoerceClassMethod(classDeclaration: ClassDeclaration, name: string, structure?: Omit<OptionalKind<MethodDeclarationStructure>, 'name'>): import("ts-morph").MethodDeclaration;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceClassMethod = void 0;
4
+ function CoerceClassMethod(classDeclaration, name, structure = {}) {
5
+ let methodDeclaration = classDeclaration.getMethod(name);
6
+ if (!methodDeclaration) {
7
+ methodDeclaration = classDeclaration.addMethod({ name });
8
+ methodDeclaration.set(structure);
9
+ }
10
+ return methodDeclaration;
11
+ }
12
+ exports.CoerceClassMethod = CoerceClassMethod;
13
+ //# sourceMappingURL=coerce-class-method.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-class-method.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-class-method.ts"],"names":[],"mappings":";;;AAMA,SAAgB,iBAAiB,CAC/B,gBAAkC,EAClC,IAAY,EACZ,YAAoE,EAAE;IAGtE,IAAI,iBAAiB,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAEzD,IAAI,CAAC,iBAAiB,EAAE;QAEtB,iBAAiB,GAAG,gBAAgB,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEzD,iBAAiB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KAElC;IAED,OAAO,iBAAiB,CAAC;AAE3B,CAAC;AAlBD,8CAkBC"}
@@ -0,0 +1,2 @@
1
+ import { ClassDeclaration, ClassDeclarationStructure, OptionalKind, SourceFile } from 'ts-morph';
2
+ export declare function CoerceClass(sourceFile: SourceFile, className: string, classStructure?: Omit<OptionalKind<ClassDeclarationStructure>, 'name'>): ClassDeclaration;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceClass = void 0;
4
+ function CoerceClass(sourceFile, className, classStructure = {}) {
5
+ let classDeclaration = sourceFile.getClass(className);
6
+ if (!classDeclaration) {
7
+ classDeclaration = sourceFile.addClass(Object.assign(Object.assign({}, classStructure), { name: className }));
8
+ }
9
+ return classDeclaration;
10
+ }
11
+ exports.CoerceClass = CoerceClass;
12
+ //# sourceMappingURL=coerce-class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-class.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-class.ts"],"names":[],"mappings":";;;AAOA,SAAgB,WAAW,CACzB,UAAsB,EACtB,SAAiB,EACjB,iBAAwE,EAAE;IAG1E,IAAI,gBAAgB,GAAG,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEtD,IAAI,CAAC,gBAAgB,EAAE;QACrB,gBAAgB,GAAG,UAAU,CAAC,QAAQ,iCACjC,cAAc,KACjB,IAAI,EAAE,SAAS,IACf,CAAC;KACJ;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAhBD,kCAgBC"}
@@ -0,0 +1,5 @@
1
+ import { DecoratableNode, Decorator, DecoratorStructure, OptionalKind } from 'ts-morph';
2
+ import { FindFunctionFactory } from './find-function';
3
+ export declare function CoerceDecorator(decoratableNode: DecoratableNode, name: string, structure?: Partial<Omit<OptionalKind<DecoratorStructure>, 'name'>>, compareTo?: FindFunctionFactory<Partial<DecoratorStructure> & {
4
+ name: string;
5
+ }, Decorator>): Decorator;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceDecorator = void 0;
4
+ const find_function_1 = require("./find-function");
5
+ function CoerceDecorator(decoratableNode, name, structure = {}, compareTo = find_function_1.FindByNameFunction) {
6
+ let decorator = decoratableNode.getDecorator(compareTo(Object.assign(Object.assign({}, structure), { name })));
7
+ if (!decorator) {
8
+ decorator = decoratableNode.addDecorator({ name });
9
+ decorator.set(structure);
10
+ }
11
+ return decorator;
12
+ }
13
+ exports.CoerceDecorator = CoerceDecorator;
14
+ //# sourceMappingURL=coerce-decorator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-decorator.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-decorator.ts"],"names":[],"mappings":";;;AAMA,mDAGyB;AAEzB,SAAgB,eAAe,CAC7B,eAAgC,EAChC,IAAY,EACZ,YAAqE,EAAE,EACvE,YAA4F,kCAAkB;IAE9G,IAAI,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,SAAS,iCACjD,SAAS,KACZ,IAAI,IACJ,CAAC,CAAC;IACJ,IAAI,CAAC,SAAS,EAAE;QACd,SAAS,GAAG,eAAe,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;KAC1B;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAfD,0CAeC"}
@@ -0,0 +1,14 @@
1
+ import { ImportDeclarationStructure, OptionalKind, Scope, SourceFile } from 'ts-morph';
2
+ export declare enum Module {
3
+ ANGULAR = "@angular/core",
4
+ NEST = "@nestjs/common"
5
+ }
6
+ export interface InjectionDefinition {
7
+ injectionToken: string;
8
+ parameterName: string;
9
+ optional?: boolean;
10
+ type?: string;
11
+ scope?: Scope;
12
+ module?: Module;
13
+ }
14
+ export declare function CoerceDependencyInjection(sourceFile: SourceFile, definition: InjectionDefinition, structures?: Array<OptionalKind<ImportDeclarationStructure>>): void;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceDependencyInjection = exports.Module = void 0;
4
+ const ts_morph_1 = require("ts-morph");
5
+ const coerce_class_constructor_1 = require("./coerce-class-constructor");
6
+ const coerce_imports_1 = require("./coerce-imports");
7
+ var Module;
8
+ (function (Module) {
9
+ Module["ANGULAR"] = "@angular/core";
10
+ Module["NEST"] = "@nestjs/common";
11
+ })(Module || (exports.Module = Module = {}));
12
+ function CoerceDependencyInjection(sourceFile, definition, structures = []) {
13
+ var _a, _b, _c, _d;
14
+ if (!definition.module) {
15
+ definition.module = Module.ANGULAR;
16
+ }
17
+ const classDeclaration = sourceFile.getClasses()[0];
18
+ if (!classDeclaration) {
19
+ throw new Error('Could not find class declaration');
20
+ }
21
+ const constructorDeclarations = (0, coerce_class_constructor_1.CoerceClassConstructor)(classDeclaration);
22
+ const constructorDeclaration = constructorDeclarations[0];
23
+ if (constructorDeclaration.getParameter(definition.parameterName)) {
24
+ return;
25
+ }
26
+ const constructorParameter = {
27
+ name: definition.parameterName,
28
+ type: (_a = definition.type) !== null && _a !== void 0 ? _a : definition.injectionToken,
29
+ scope: (_b = definition.scope) !== null && _b !== void 0 ? _b : ts_morph_1.Scope.Public,
30
+ isReadonly: true,
31
+ decorators: [
32
+ {
33
+ name: 'Inject',
34
+ arguments: [definition.injectionToken],
35
+ },
36
+ ],
37
+ };
38
+ if (definition.optional) {
39
+ (_c = constructorParameter.decorators) === null || _c === void 0 ? void 0 : _c.unshift({
40
+ name: 'Optional',
41
+ arguments: [],
42
+ });
43
+ constructorParameter.type = ts_morph_1.Writers.intersectionType((_d = definition.type) !== null && _d !== void 0 ? _d : definition.injectionToken, 'null');
44
+ (0, coerce_imports_1.CoerceImports)(sourceFile, {
45
+ namedImports: ['Optional'],
46
+ moduleSpecifier: definition.module,
47
+ });
48
+ }
49
+ constructorDeclaration.addParameter(constructorParameter);
50
+ (0, coerce_imports_1.CoerceImports)(sourceFile, {
51
+ namedImports: ['Inject'],
52
+ moduleSpecifier: definition.module,
53
+ });
54
+ (0, coerce_imports_1.CoerceImports)(sourceFile, structures);
55
+ }
56
+ exports.CoerceDependencyInjection = CoerceDependencyInjection;
57
+ //# sourceMappingURL=coerce-dependency-injection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-dependency-injection.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-dependency-injection.ts"],"names":[],"mappings":";;;AAAA,uCAOkB;AAClB,yEAAoE;AACpE,qDAAiD;AAEjD,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,mCAAyB,CAAA;IACzB,iCAAuB,CAAA;AACzB,CAAC,EAHW,MAAM,sBAAN,MAAM,QAGjB;AAWD,SAAgB,yBAAyB,CACvC,UAAsB,EACtB,UAA+B,EAC/B,aAA8D,EAAE;;IAGhE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;QACtB,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,O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UAAU,EAAE;QACxB,YAAY,EAAE,CAAE,QAAQ,CAAE;QAC1B,eAAe,EAAE,UAAU,CAAC,MAAM;KACnC,CAAC,CAAC;IAEH,IAAA,8BAAa,EAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AA3DD,8DA2DC"}
@@ -0,0 +1,21 @@
1
+ import { ImportDeclarationStructure, OptionalKind, SourceFile } from 'ts-morph';
2
+ /**
3
+ * This function, `CoerceImports`, is used to coerce import declarations in a given source file. It takes two parameters: `sourceFile` and `structures`.
4
+ *
5
+ * @param {SourceFile} sourceFile - The source file in which the import declarations are to be processed. This is an instance of the `SourceFile` class.
6
+ *
7
+ * @param {Array<OptionalKind<ImportDeclarationStructure>> | OptionalKind<ImportDeclarationStructure>} structures - An array of import declaration structures or a single import declaration structure. Each structure can be of type `OptionalKind<ImportDeclarationStructure>`, which means it may or may not contain certain properties.
8
+ *
9
+ * The function iterates over each import declaration structure in `structures`. For each structure, it extracts the following properties: `moduleSpecifier`, `namedImports`, `namespaceImport`, `isTypeOnly`, and `defaultImport`.
10
+ *
11
+ * If `namedImports` is present, it checks if the named imports are supported using the `isSupportedNamedImports` function. If not, it throws an error. If they are supported, it coerces the named imports using the `coerceNamedImports` function.
12
+ *
13
+ * If `namespaceImport` is present, it coerces the namespace import using the `coerceNamespaceImport` function.
14
+ *
15
+ * If `defaultImport` is present, it coerces the default import using the `coerceDefaultImport` function.
16
+ *
17
+ * The function does not return any value.
18
+ *
19
+ * Note: This function does not modify the original `sourceFile` or `structures` parameters. It only processes and validates the import declarations.
20
+ */
21
+ export declare function CoerceImports(sourceFile: SourceFile, structures: Array<OptionalKind<ImportDeclarationStructure>> | OptionalKind<ImportDeclarationStructure>): void;
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceImports = void 0;
4
+ const utilities_1 = require("@rxap/utilities");
5
+ /**
6
+ * This function, `CoerceImports`, is used to coerce import declarations in a given source file. It takes two parameters: `sourceFile` and `structures`.
7
+ *
8
+ * @param {SourceFile} sourceFile - The source file in which the import declarations are to be processed. This is an instance of the `SourceFile` class.
9
+ *
10
+ * @param {Array<OptionalKind<ImportDeclarationStructure>> | OptionalKind<ImportDeclarationStructure>} structures - An array of import declaration structures or a single import declaration structure. Each structure can be of type `OptionalKind<ImportDeclarationStructure>`, which means it may or may not contain certain properties.
11
+ *
12
+ * The function iterates over each import declaration structure in `structures`. For each structure, it extracts the following properties: `moduleSpecifier`, `namedImports`, `namespaceImport`, `isTypeOnly`, and `defaultImport`.
13
+ *
14
+ * If `namedImports` is present, it checks if the named imports are supported using the `isSupportedNamedImports` function. If not, it throws an error. If they are supported, it coerces the named imports using the `coerceNamedImports` function.
15
+ *
16
+ * If `namespaceImport` is present, it coerces the namespace import using the `coerceNamespaceImport` function.
17
+ *
18
+ * If `defaultImport` is present, it coerces the default import using the `coerceDefaultImport` function.
19
+ *
20
+ * The function does not return any value.
21
+ *
22
+ * Note: This function does not modify the original `sourceFile` or `structures` parameters. It only processes and validates the import declarations.
23
+ */
24
+ function CoerceImports(sourceFile, structures) {
25
+ for (const structure of (0, utilities_1.coerceArray)(structures)) {
26
+ const { moduleSpecifier, namedImports, namespaceImport, isTypeOnly, defaultImport, } = structure;
27
+ if (namedImports) {
28
+ coerceNamedImports(sourceFile, moduleSpecifier, namedImports, isTypeOnly);
29
+ }
30
+ if (namespaceImport) {
31
+ coerceNamespaceImport(sourceFile, moduleSpecifier, namespaceImport);
32
+ }
33
+ if (defaultImport) {
34
+ coerceDefaultImport(sourceFile, moduleSpecifier, defaultImport);
35
+ }
36
+ }
37
+ }
38
+ exports.CoerceImports = CoerceImports;
39
+ /**
40
+ * This method is used to coerce the default import of a module in a source file. If the import declaration for the specified module exists, it checks for the existence of a default import. If a default import does not exist, it sets the default import to the provided value. If a default import exists and it does not match the provided value, it removes the existing default import and sets it to the provided value. If the import declaration for the specified module does not exist, it adds a new import declaration with the provided module specifier and default import.
41
+ *
42
+ * @param {SourceFile} sourceFile - The source file in which the import declaration is to be coerced.
43
+ * @param {string} moduleSpecifier - The specifier of the module whose import declaration is to be coerced.
44
+ * @param {string} defaultImport - The value to be set as the default import in the import declaration.
45
+ *
46
+ * @returns {void} This method does not return anything.
47
+ *
48
+ * @example
49
+ * // Assuming `sourceFile` is a SourceFile instance and `moduleSpecifier` is 'myModule' and `defaultImport` is 'myDefaultImport'
50
+ * coerceDefaultImport(sourceFile, 'myModule', 'myDefaultImport');
51
+ */
52
+ function coerceDefaultImport(sourceFile, moduleSpecifier, defaultImport) {
53
+ const importDeclaration = sourceFile.getImportDeclaration(moduleSpecifier);
54
+ if (importDeclaration) {
55
+ const existingDefaultImport = importDeclaration.getDefaultImport();
56
+ if (!existingDefaultImport) {
57
+ importDeclaration.setDefaultImport(defaultImport);
58
+ }
59
+ else if (existingDefaultImport.getText() !== defaultImport) {
60
+ importDeclaration.removeDefaultImport();
61
+ importDeclaration.setDefaultImport(defaultImport);
62
+ }
63
+ }
64
+ else {
65
+ sourceFile.addImportDeclaration({
66
+ moduleSpecifier,
67
+ defaultImport,
68
+ });
69
+ }
70
+ }
71
+ /**
72
+ * This method is used to coerce or enforce a specific namespace import in a given source file.
73
+ * It first checks if an import declaration for the provided module specifier already exists in the source file.
74
+ * If such an import declaration exists, it then checks if a namespace import is already present.
75
+ * If no namespace import is present, it sets the namespace import to the provided namespace import.
76
+ * If a namespace import is present and it does not match the provided namespace import, it removes the existing namespace import and sets it to the provided namespace import.
77
+ * If no import declaration for the provided module specifier exists, it adds a new import declaration with the provided module specifier and namespace import.
78
+ *
79
+ * @param {SourceFile} sourceFile - The source file in which to enforce the namespace import.
80
+ * @param {string} moduleSpecifier - The module specifier for which to enforce the namespace import.
81
+ * @param {string} namespaceImport - The namespace import to be enforced in the source file for the provided module specifier.
82
+ * @returns {void} This method does not return anything.
83
+ */
84
+ function coerceNamespaceImport(sourceFile, moduleSpecifier, namespaceImport) {
85
+ const importDeclarations = sourceFile.getImportDeclarations()
86
+ .filter(id => id.getModuleSpecifier().getLiteralText() === moduleSpecifier)
87
+ .filter(id => id.getNamespaceImport() !== undefined);
88
+ for (const importDeclaration of importDeclarations) {
89
+ const existingNamespaceImport = importDeclaration.getNamespaceImport();
90
+ if (!existingNamespaceImport) {
91
+ importDeclaration.setNamespaceImport(namespaceImport);
92
+ }
93
+ else if (existingNamespaceImport.getText() !== namespaceImport) {
94
+ importDeclaration.removeNamespaceImport();
95
+ importDeclaration.setNamespaceImport(namespaceImport);
96
+ }
97
+ }
98
+ if (importDeclarations.length === 0) {
99
+ sourceFile.addImportDeclaration({
100
+ moduleSpecifier,
101
+ namespaceImport,
102
+ });
103
+ }
104
+ }
105
+ /**
106
+ * Checks if the provided named imports are supported.
107
+ *
108
+ * @param {((OptionalKind<ImportSpecifierStructure> | string | WriterFunction)[] | WriterFunction)} namedImports - The named imports to be checked. This can be an array of `OptionalKind<ImportSpecifierStructure>`, `string`, `WriterFunction` or a single `WriterFunction`.
109
+ *
110
+ * @returns {boolean} Returns `true` if the `namedImports` is an array and every element in the array is either a `string` or an `OptionalKind<ImportSpecifierStructure>`. Otherwise, it returns `false`.
111
+ *
112
+ * @example
113
+ * // returns true
114
+ * isSupportedNamedImports(['import1', 'import2', { name: 'import3', alias: 'alias3' }])
115
+ *
116
+ * @example
117
+ * // returns false
118
+ * isSupportedNamedImports(() => 'import1')
119
+ *
120
+ * @example
121
+ * // returns false
122
+ * isSupportedNamedImports(['import1', () => 'import2', { name: 'import3', alias: 'alias3' }])
123
+ *
124
+ */
125
+ function isSupportedNamedImports(namedImports) {
126
+ return Array.isArray(namedImports) &&
127
+ namedImports.every((named) => typeof named === 'string' || typeof named === 'object');
128
+ }
129
+ /**
130
+ * Transforms an array of named imports into a standardized format.
131
+ *
132
+ * @param {Array<string | OptionalKind<ImportSpecifierStructure>>} namedImports - An array of named imports. Each import can either be a string or an instance of `OptionalKind<ImportSpecifierStructure>`.
133
+ * @param {boolean} [isTypeOnly=false] - An optional flag indicating whether the import is type-only. If not provided, defaults to `false`.
134
+ *
135
+ * @returns {Array<OptionalKind<ImportSpecifierStructure>>} - Returns an array of `OptionalKind<ImportSpecifierStructure>`. Each element in the array represents a named import, and includes the name of the import and a flag indicating whether it is type-only.
136
+ *
137
+ * @example
138
+ * // Given the following input:
139
+ * // ['import1', { name: 'import2', isTypeOnly: true }]
140
+ * // The function will return:
141
+ * // [{ name: 'import1', isTypeOnly: false }, { name: 'import2', isTypeOnly: true }]
142
+ *
143
+ * @remarks
144
+ * This function is useful for standardizing the format of named imports, especially when dealing with a mix of string and `OptionalKind<ImportSpecifierStructure>` imports.
145
+ */
146
+ function normalizeNamedImports(namedImports, isTypeOnly) {
147
+ return namedImports.map((named) => typeof named === 'string' ?
148
+ {
149
+ name: named,
150
+ isTypeOnly,
151
+ } :
152
+ named);
153
+ }
154
+ /**
155
+ * This function `coerceNamedImports` is used to manage named imports in a TypeScript source file.
156
+ * It either adds new named imports to an existing import declaration or creates a new import declaration if one does not exist.
157
+ *
158
+ * @param {SourceFile} sourceFile - The TypeScript source file to be manipulated.
159
+ * @param {string} moduleSpecifier - The string specifier of the module from which the imports are derived.
160
+ * @param {Array<OptionalKind<ImportSpecifierStructure>>} namedImports - An array of named imports to be added. Each import is an object of type `OptionalKind<ImportSpecifierStructure>`.
161
+ * @param isTypeOnly - An optional flag indicating whether the import is type-only. If not provided, defaults to `false`.
162
+ *
163
+ * The function does not return any value.
164
+ *
165
+ * The function first tries to find an existing import declaration from the specified module in the source file.
166
+ * If such an import declaration exists, the function iterates over the provided named imports.
167
+ * For each named import, it checks if the import already exists in the import declaration.
168
+ * If the named import does not exist, it is added to the import declaration.
169
+ *
170
+ * If no import declaration from the specified module exists in the source file, a new import declaration is created.
171
+ * The new import declaration includes all the provided named imports.
172
+ */
173
+ function coerceNamedImports(sourceFile, moduleSpecifier, namedImports, isTypeOnly) {
174
+ var _a, _b;
175
+ const importDeclarations = sourceFile.getImportDeclarations()
176
+ .filter(id => id.getModuleSpecifier().getLiteralText() === moduleSpecifier)
177
+ .filter(id => id.getNamespaceImport() === undefined);
178
+ if (!isSupportedNamedImports(namedImports)) {
179
+ if (!importDeclarations.length) {
180
+ sourceFile.addImportDeclaration({
181
+ moduleSpecifier,
182
+ namedImports,
183
+ isTypeOnly,
184
+ });
185
+ return;
186
+ }
187
+ else {
188
+ throw new Error('Invalid named imports. Ensure that all named imports are either a string or an object and not a WriteFunction.');
189
+ }
190
+ }
191
+ const normalizedNamedImports = normalizeNamedImports(namedImports, isTypeOnly);
192
+ const typeOnlyNamedImports = normalizedNamedImports.filter((named) => named.isTypeOnly);
193
+ const nonTypeOnlyNamedImports = normalizedNamedImports.filter((named) => !named.isTypeOnly);
194
+ const typeOnlyImportDeclarations = importDeclarations.filter((id) => id.isTypeOnly());
195
+ const nonTypeOnlyImportDeclarations = importDeclarations.filter((id) => !id.isTypeOnly());
196
+ if (nonTypeOnlyNamedImports.length) {
197
+ if (!nonTypeOnlyImportDeclarations.length) {
198
+ sourceFile.addImportDeclaration({
199
+ moduleSpecifier,
200
+ namedImports: nonTypeOnlyNamedImports,
201
+ });
202
+ }
203
+ else {
204
+ for (const importDeclaration of nonTypeOnlyImportDeclarations) {
205
+ const existingImports = importDeclaration.getNamedImports();
206
+ for (const named of normalizedNamedImports) {
207
+ if (!existingImports.some((existing) => existing.getName() === named.name)) {
208
+ const namedImport = importDeclaration.addNamedImport(named);
209
+ namedImport.setIsTypeOnly((_a = named.isTypeOnly) !== null && _a !== void 0 ? _a : false);
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ if (typeOnlyNamedImports.length) {
216
+ if (!typeOnlyImportDeclarations.length) {
217
+ sourceFile.addImportDeclaration({
218
+ moduleSpecifier,
219
+ namedImports: typeOnlyNamedImports,
220
+ });
221
+ }
222
+ else {
223
+ for (const importDeclaration of typeOnlyImportDeclarations) {
224
+ const existingImports = importDeclaration.getNamedImports();
225
+ for (const named of normalizedNamedImports) {
226
+ if (!existingImports.some((existing) => existing.getName() === named.name)) {
227
+ const namedImport = importDeclaration.addNamedImport(named);
228
+ namedImport.setIsTypeOnly((_b = named.isTypeOnly) !== null && _b !== void 0 ? _b : false);
229
+ }
230
+ }
231
+ }
232
+ }
233
+ }
234
+ }
235
+ //# sourceMappingURL=coerce-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-imports.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-imports.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAS9C;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,aAAa,CAC3B,UAAsB,EACtB,UAAsG;IAGtG,KAAK,MAAM,SAAS,IAAI,IAAA,uBAAW,EAAC,UAAU,CAAC,EAAE;QAE/C,MAAM,EACJ,eAAe,EACf,YAAY,EACZ,eAAe,EACf,UAAU,EACV,aAAa,GACd,GAAG,SAAS,CAAC;QAEd,IAAI,YAAY,EAAE;YAChB,kBAAkB,CAAC,UAAU,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC;SAC3E;QAED,IAAI,eAAe,EAAE;YACnB,qBAAqB,CAAC,UAAU,EAAE,eAAe,EAAE,eAAe,CAAC,CAAC;SACrE;QAED,IAAI,aAAa,EAAE;YACjB,mBAAmB,CAAC,UAAU,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;SACjE;KAEF;AAEH,CAAC;AA7BD,sCA6BC;AAED;;;;;;;;;;;;GAYG;AACH,SAAS,mBAAmB,CAAC,UAAsB,EAAE,eAAuB,EAAE,aAAqB;IAEjG,MAAM,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAE3E,IAAI,iBAAiB,EAAE;QACrB,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,gBAAgB,EAAE,CAAC;QACnE,IAAI,CAAC,qBAAqB,EAAE;YAC1B,iBAAiB,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;SACnD;aAAM,IAAI,qBAAqB,CA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iBAAiB,CAAC,eAAe,EAAE,CAAC;gBAC5D,KAAK,MAAM,KAAK,IAAI,sBAAsB,EAAE;oBAC1C,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,KAAK,CAAC,IAAI,CAAC,EAAE;wBAC1E,MAAM,WAAW,GAAG,iBAAiB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;wBAC5D,WAAW,CAAC,aAAa,CAAC,MAAA,KAAK,CAAC,UAAU,mCAAI,KAAK,CAAC,CAAC;qBACtD;iBACF;aACF;SACF;KACF;AAEH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Project, SourceFile } from 'ts-morph';
2
+ export declare function CoerceSourceFile(project: Project, fileNameOrPath: string, content?: string): SourceFile;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceSourceFile = void 0;
4
+ function CoerceSourceFile(project, fileNameOrPath, content) {
5
+ let sourceFile = project.getSourceFile(fileNameOrPath);
6
+ if (!sourceFile) {
7
+ sourceFile = project.createSourceFile(fileNameOrPath, content);
8
+ }
9
+ return sourceFile;
10
+ }
11
+ exports.CoerceSourceFile = CoerceSourceFile;
12
+ //# sourceMappingURL=coerce-source-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-source-file.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-source-file.ts"],"names":[],"mappings":";;;AAKA,SAAgB,gBAAgB,CAC9B,OAAgB,EAChB,cAAsB,EACtB,OAAgB;IAGhB,IAAI,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAEvD,IAAI,CAAC,UAAU,EAAE;QACf,UAAU,GAAG,OAAO,CAAC,gBAAgB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;KAChE;IAED,OAAO,UAAU,CAAC;AAEpB,CAAC;AAdD,4CAcC"}
@@ -0,0 +1,2 @@
1
+ import { StatementedNode, StatementStructures, WriterFunction } from 'ts-morph';
2
+ export declare function CoerceStatements(node: StatementedNode, statements: (string | WriterFunction | StatementStructures)[] | string | WriterFunction): void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CoerceStatements = void 0;
4
+ function CoerceStatements(node, statements) {
5
+ if (node.getStatements().length ===
6
+ 0) {
7
+ node.addStatements(statements);
8
+ }
9
+ }
10
+ exports.CoerceStatements = CoerceStatements;
11
+ //# sourceMappingURL=coerce-statements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coerce-statements.js","sourceRoot":"","sources":["../../../../../packages/ts-morph/src/lib/coerce-statements.ts"],"names":[],"mappings":";;;AAMA,SAAgB,gBAAgB,CAC9B,IAAqB,EACrB,UAAuF;IAEvF,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,MAAM;QAC7B,CAAC,EAAE;QACH,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;KAChC;AACH,CAAC;AARD,4CAQC"}
@@ -0,0 +1,2 @@
1
+ import { OptionalKind, SourceFile, VariableDeclaration, VariableDeclarationStructure, VariableStatementStructure } from 'ts-morph';
2
+ export declare function CoerceVariableDeclaration(sourceFile: SourceFile, name: string, defaultDeclaration?: Omit<OptionalKind<VariableDeclarationStructure>, 'name'>, variableStatementStructure?: Partial<Omit<OptionalKind<VariableStatementStructure>, 'declarations'>>): VariableDeclaration;