@typeorm/codemod 1.0.0 → 1.0.1

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 (240) hide show
  1. package/README.md +12 -10
  2. package/dist/cli/print-guide.js +2 -2
  3. package/dist/cli/print-summary.js +3 -2
  4. package/dist/cli/print-summary.js.map +1 -1
  5. package/dist/cli/print-usage.js +1 -1
  6. package/dist/cli/print-usage.js.map +1 -1
  7. package/dist/cli/run-transforms.js +16 -2
  8. package/dist/cli/run-transforms.js.map +1 -1
  9. package/dist/dependencies/v1.js +22 -9
  10. package/dist/dependencies/v1.js.map +1 -1
  11. package/dist/transforms/ast-helpers.js +150 -14
  12. package/dist/transforms/ast-helpers.js.map +1 -1
  13. package/dist/transforms/todo.js +25 -2
  14. package/dist/transforms/todo.js.map +1 -1
  15. package/dist/transforms/v1/column-readonly.js +28 -13
  16. package/dist/transforms/v1/column-readonly.js.map +1 -1
  17. package/dist/transforms/v1/column-unsigned-numeric.js +6 -8
  18. package/dist/transforms/v1/column-unsigned-numeric.js.map +1 -1
  19. package/dist/transforms/v1/column-width-zerofill.js +2 -1
  20. package/dist/transforms/v1/column-width-zerofill.js.map +1 -1
  21. package/dist/transforms/v1/connection-manager.js +82 -0
  22. package/dist/transforms/v1/connection-manager.js.map +1 -0
  23. package/dist/transforms/v1/connection-options-reader.js +198 -0
  24. package/dist/transforms/v1/connection-options-reader.js.map +1 -0
  25. package/dist/transforms/v1/connection-to-datasource.js +285 -56
  26. package/dist/transforms/v1/connection-to-datasource.js.map +1 -1
  27. package/dist/transforms/v1/datasource-mongodb.js +40 -28
  28. package/dist/transforms/v1/datasource-mongodb.js.map +1 -1
  29. package/dist/transforms/v1/datasource-mssql.js +1 -3
  30. package/dist/transforms/v1/datasource-mssql.js.map +1 -1
  31. package/dist/transforms/v1/datasource-mysql-connector.js +3 -0
  32. package/dist/transforms/v1/datasource-mysql-connector.js.map +1 -1
  33. package/dist/transforms/v1/datasource-name.js +2 -0
  34. package/dist/transforms/v1/datasource-name.js.map +1 -1
  35. package/dist/transforms/v1/datasource-sap.js +21 -8
  36. package/dist/transforms/v1/datasource-sap.js.map +1 -1
  37. package/dist/transforms/v1/datasource-sqlite-options.js +48 -13
  38. package/dist/transforms/v1/datasource-sqlite-options.js.map +1 -1
  39. package/dist/transforms/v1/datasource-sqlite-type.js +28 -7
  40. package/dist/transforms/v1/datasource-sqlite-type.js.map +1 -1
  41. package/dist/transforms/v1/file-logger.js +182 -0
  42. package/dist/transforms/v1/file-logger.js.map +1 -0
  43. package/dist/transforms/v1/find-options-join.js +84 -0
  44. package/dist/transforms/v1/find-options-join.js.map +1 -0
  45. package/dist/transforms/v1/find-options-lock-modes.js +26 -21
  46. package/dist/transforms/v1/find-options-lock-modes.js.map +1 -1
  47. package/dist/transforms/v1/find-options-string-relations.js +2 -0
  48. package/dist/transforms/v1/find-options-string-relations.js.map +1 -1
  49. package/dist/transforms/v1/find-options-string-select.js +2 -0
  50. package/dist/transforms/v1/find-options-string-select.js.map +1 -1
  51. package/dist/transforms/v1/global-functions.js +92 -64
  52. package/dist/transforms/v1/global-functions.js.map +1 -1
  53. package/dist/transforms/v1/index.js +10 -2
  54. package/dist/transforms/v1/index.js.map +1 -1
  55. package/dist/transforms/v1/migrations-get-all.js +25 -9
  56. package/dist/transforms/v1/migrations-get-all.js.map +1 -1
  57. package/dist/transforms/v1/mongodb-stats.js +3 -0
  58. package/dist/transforms/v1/mongodb-stats.js.map +1 -1
  59. package/dist/transforms/v1/query-builder-native-parameters.js +2 -0
  60. package/dist/transforms/v1/query-builder-native-parameters.js.map +1 -1
  61. package/dist/transforms/v1/query-builder-on-conflict.js +2 -1
  62. package/dist/transforms/v1/query-builder-on-conflict.js.map +1 -1
  63. package/dist/transforms/v1/query-builder-or-update.js +8 -4
  64. package/dist/transforms/v1/query-builder-or-update.js.map +1 -1
  65. package/dist/transforms/v1/query-builder-print-sql.js +3 -0
  66. package/dist/transforms/v1/query-builder-print-sql.js.map +1 -1
  67. package/dist/transforms/v1/query-builder-replace-property-names.js +3 -0
  68. package/dist/transforms/v1/query-builder-replace-property-names.js.map +1 -1
  69. package/dist/transforms/v1/query-runner-loaded-tables-views.js +1 -5
  70. package/dist/transforms/v1/query-runner-loaded-tables-views.js.map +1 -1
  71. package/dist/transforms/v1/relation-count.js +75 -12
  72. package/dist/transforms/v1/relation-count.js.map +1 -1
  73. package/dist/transforms/v1/repository-abstract.js +2 -5
  74. package/dist/transforms/v1/repository-abstract.js.map +1 -1
  75. package/dist/transforms/v1/repository-exist.js +2 -0
  76. package/dist/transforms/v1/repository-exist.js.map +1 -1
  77. package/dist/transforms/v1/repository-find-by-ids.js +0 -3
  78. package/dist/transforms/v1/repository-find-by-ids.js.map +1 -1
  79. package/dist/transforms/v1/repository-find-one-by-id.js +3 -0
  80. package/dist/transforms/v1/repository-find-one-by-id.js.map +1 -1
  81. package/dist/transforms/v1/use-container.js +5 -3
  82. package/dist/transforms/v1/use-container.js.map +1 -1
  83. package/package.json +3 -1
  84. package/dist/cli/colors.d.ts +0 -7
  85. package/dist/cli/colors.js +0 -12
  86. package/dist/cli/colors.js.map +0 -1
  87. package/dist/cli/error.d.ts +0 -1
  88. package/dist/cli/error.js +0 -11
  89. package/dist/cli/error.js.map +0 -1
  90. package/dist/cli/list-transforms.d.ts +0 -1
  91. package/dist/cli/parse-args.d.ts +0 -10
  92. package/dist/cli/print-guide.d.ts +0 -1
  93. package/dist/cli/print-summary.d.ts +0 -17
  94. package/dist/cli/print-todos.d.ts +0 -1
  95. package/dist/cli/print-usage.d.ts +0 -1
  96. package/dist/cli/run-dependencies.d.ts +0 -6
  97. package/dist/cli/run-transforms.d.ts +0 -21
  98. package/dist/cli/run.d.ts +0 -9
  99. package/dist/dependencies/config.d.ts +0 -24
  100. package/dist/dependencies/find-package-json.d.ts +0 -5
  101. package/dist/dependencies/index.d.ts +0 -5
  102. package/dist/dependencies/upgrade.d.ts +0 -11
  103. package/dist/dependencies/v1.d.ts +0 -2
  104. package/dist/index.d.ts +0 -2
  105. package/dist/lib/colors.d.ts +0 -9
  106. package/dist/lib/error.d.ts +0 -1
  107. package/dist/lib/format-time.d.ts +0 -1
  108. package/dist/lib/highlight.d.ts +0 -1
  109. package/dist/lib/spinner.d.ts +0 -5
  110. package/dist/transforms/ast-helpers.d.ts +0 -50
  111. package/dist/transforms/index.d.ts +0 -7
  112. package/dist/transforms/resolve.d.ts +0 -1
  113. package/dist/transforms/scan.d.ts +0 -4
  114. package/dist/transforms/scan.js +0 -33
  115. package/dist/transforms/scan.js.map +0 -1
  116. package/dist/transforms/stats.d.ts +0 -11
  117. package/dist/transforms/todo.d.ts +0 -2
  118. package/dist/transforms/transformer.d.ts +0 -8
  119. package/dist/transforms/v1/column-readonly.d.ts +0 -6
  120. package/dist/transforms/v1/column-unsigned-numeric.d.ts +0 -6
  121. package/dist/transforms/v1/column-width-zerofill.d.ts +0 -6
  122. package/dist/transforms/v1/connection-to-datasource.d.ts +0 -6
  123. package/dist/transforms/v1/datasource-mongodb.d.ts +0 -7
  124. package/dist/transforms/v1/datasource-mssql-domain.d.ts +0 -7
  125. package/dist/transforms/v1/datasource-mssql-domain.js +0 -35
  126. package/dist/transforms/v1/datasource-mssql-domain.js.map +0 -1
  127. package/dist/transforms/v1/datasource-mssql.d.ts +0 -7
  128. package/dist/transforms/v1/datasource-mysql-connector.d.ts +0 -6
  129. package/dist/transforms/v1/datasource-name.d.ts +0 -6
  130. package/dist/transforms/v1/datasource-sap.d.ts +0 -6
  131. package/dist/transforms/v1/datasource-sqlite-options.d.ts +0 -6
  132. package/dist/transforms/v1/datasource-sqlite-type.d.ts +0 -6
  133. package/dist/transforms/v1/find-options-lock-modes.d.ts +0 -6
  134. package/dist/transforms/v1/find-options-string-relations.d.ts +0 -6
  135. package/dist/transforms/v1/find-options-string-select.d.ts +0 -6
  136. package/dist/transforms/v1/global-functions.d.ts +0 -7
  137. package/dist/transforms/v1/index.d.ts +0 -40
  138. package/dist/transforms/v1/migrations-get-all.d.ts +0 -7
  139. package/dist/transforms/v1/mongodb-stats.d.ts +0 -7
  140. package/dist/transforms/v1/mongodb-types.d.ts +0 -6
  141. package/dist/transforms/v1/query-builder-native-parameters.d.ts +0 -6
  142. package/dist/transforms/v1/query-builder-on-conflict.d.ts +0 -7
  143. package/dist/transforms/v1/query-builder-or-update.d.ts +0 -6
  144. package/dist/transforms/v1/query-builder-print-sql.d.ts +0 -7
  145. package/dist/transforms/v1/query-builder-replace-property-names.d.ts +0 -7
  146. package/dist/transforms/v1/query-builder-where-expression.d.ts +0 -6
  147. package/dist/transforms/v1/query-runner-loaded-tables-views.d.ts +0 -7
  148. package/dist/transforms/v1/relation-count.d.ts +0 -7
  149. package/dist/transforms/v1/remove-abstract-repository.d.ts +0 -5
  150. package/dist/transforms/v1/remove-abstract-repository.js +0 -93
  151. package/dist/transforms/v1/remove-abstract-repository.js.map +0 -1
  152. package/dist/transforms/v1/remove-connector-package.d.ts +0 -4
  153. package/dist/transforms/v1/remove-connector-package.js +0 -19
  154. package/dist/transforms/v1/remove-connector-package.js.map +0 -1
  155. package/dist/transforms/v1/remove-datasource-name.d.ts +0 -4
  156. package/dist/transforms/v1/remove-datasource-name.js +0 -56
  157. package/dist/transforms/v1/remove-datasource-name.js.map +0 -1
  158. package/dist/transforms/v1/remove-mongodb-options.d.ts +0 -5
  159. package/dist/transforms/v1/remove-mongodb-options.js +0 -86
  160. package/dist/transforms/v1/remove-mongodb-options.js.map +0 -1
  161. package/dist/transforms/v1/remove-relation-count.d.ts +0 -5
  162. package/dist/transforms/v1/remove-relation-count.js +0 -49
  163. package/dist/transforms/v1/remove-relation-count.js.map +0 -1
  164. package/dist/transforms/v1/remove-replace-property-names.d.ts +0 -5
  165. package/dist/transforms/v1/remove-replace-property-names.js +0 -35
  166. package/dist/transforms/v1/remove-replace-property-names.js.map +0 -1
  167. package/dist/transforms/v1/remove-sap-options.d.ts +0 -4
  168. package/dist/transforms/v1/remove-sap-options.js +0 -54
  169. package/dist/transforms/v1/remove-sap-options.js.map +0 -1
  170. package/dist/transforms/v1/remove-unsigned-numeric.d.ts +0 -4
  171. package/dist/transforms/v1/remove-unsigned-numeric.js +0 -76
  172. package/dist/transforms/v1/remove-unsigned-numeric.js.map +0 -1
  173. package/dist/transforms/v1/remove-use-container.d.ts +0 -5
  174. package/dist/transforms/v1/remove-use-container.js +0 -63
  175. package/dist/transforms/v1/remove-use-container.js.map +0 -1
  176. package/dist/transforms/v1/remove-width-zerofill.d.ts +0 -4
  177. package/dist/transforms/v1/remove-width-zerofill.js +0 -29
  178. package/dist/transforms/v1/remove-width-zerofill.js.map +0 -1
  179. package/dist/transforms/v1/rename-connection-to-datasource.d.ts +0 -4
  180. package/dist/transforms/v1/rename-connection-to-datasource.js +0 -111
  181. package/dist/transforms/v1/rename-connection-to-datasource.js.map +0 -1
  182. package/dist/transforms/v1/rename-exist-to-exists.d.ts +0 -4
  183. package/dist/transforms/v1/rename-exist-to-exists.js +0 -25
  184. package/dist/transforms/v1/rename-exist-to-exists.js.map +0 -1
  185. package/dist/transforms/v1/rename-find-by-ids.d.ts +0 -4
  186. package/dist/transforms/v1/rename-find-by-ids.js +0 -64
  187. package/dist/transforms/v1/rename-find-by-ids.js.map +0 -1
  188. package/dist/transforms/v1/rename-get-all-migrations.d.ts +0 -5
  189. package/dist/transforms/v1/rename-get-all-migrations.js +0 -32
  190. package/dist/transforms/v1/rename-get-all-migrations.js.map +0 -1
  191. package/dist/transforms/v1/rename-loaded-tables-views.d.ts +0 -5
  192. package/dist/transforms/v1/rename-loaded-tables-views.js +0 -48
  193. package/dist/transforms/v1/rename-loaded-tables-views.js.map +0 -1
  194. package/dist/transforms/v1/rename-or-update-overload.d.ts +0 -4
  195. package/dist/transforms/v1/rename-or-update-overload.js +0 -46
  196. package/dist/transforms/v1/rename-or-update-overload.js.map +0 -1
  197. package/dist/transforms/v1/rename-print-sql-to-log-query.d.ts +0 -4
  198. package/dist/transforms/v1/rename-print-sql-to-log-query.js +0 -25
  199. package/dist/transforms/v1/rename-print-sql-to-log-query.js.map +0 -1
  200. package/dist/transforms/v1/replace-global-functions.d.ts +0 -5
  201. package/dist/transforms/v1/replace-global-functions.js +0 -92
  202. package/dist/transforms/v1/replace-global-functions.js.map +0 -1
  203. package/dist/transforms/v1/replace-lock-modes.d.ts +0 -4
  204. package/dist/transforms/v1/replace-lock-modes.js +0 -75
  205. package/dist/transforms/v1/replace-lock-modes.js.map +0 -1
  206. package/dist/transforms/v1/replace-mongodb-stats.d.ts +0 -5
  207. package/dist/transforms/v1/replace-mongodb-stats.js +0 -54
  208. package/dist/transforms/v1/replace-mongodb-stats.js.map +0 -1
  209. package/dist/transforms/v1/replace-mongodb-types.d.ts +0 -4
  210. package/dist/transforms/v1/replace-mongodb-types.js +0 -72
  211. package/dist/transforms/v1/replace-mongodb-types.js.map +0 -1
  212. package/dist/transforms/v1/replace-mssql-domain.d.ts +0 -5
  213. package/dist/transforms/v1/replace-mssql-domain.js +0 -25
  214. package/dist/transforms/v1/replace-mssql-domain.js.map +0 -1
  215. package/dist/transforms/v1/replace-on-conflict.d.ts +0 -5
  216. package/dist/transforms/v1/replace-on-conflict.js +0 -49
  217. package/dist/transforms/v1/replace-on-conflict.js.map +0 -1
  218. package/dist/transforms/v1/replace-readonly-column.d.ts +0 -4
  219. package/dist/transforms/v1/replace-readonly-column.js +0 -28
  220. package/dist/transforms/v1/replace-readonly-column.js.map +0 -1
  221. package/dist/transforms/v1/replace-set-native-parameters.d.ts +0 -4
  222. package/dist/transforms/v1/replace-set-native-parameters.js +0 -25
  223. package/dist/transforms/v1/replace-set-native-parameters.js.map +0 -1
  224. package/dist/transforms/v1/replace-sqlite-options.d.ts +0 -4
  225. package/dist/transforms/v1/replace-sqlite-options.js +0 -29
  226. package/dist/transforms/v1/replace-sqlite-options.js.map +0 -1
  227. package/dist/transforms/v1/replace-sqlite-type.d.ts +0 -4
  228. package/dist/transforms/v1/replace-sqlite-type.js +0 -22
  229. package/dist/transforms/v1/replace-sqlite-type.js.map +0 -1
  230. package/dist/transforms/v1/replace-where-expression-type.d.ts +0 -4
  231. package/dist/transforms/v1/replace-where-expression-type.js +0 -41
  232. package/dist/transforms/v1/replace-where-expression-type.js.map +0 -1
  233. package/dist/transforms/v1/repository-abstract.d.ts +0 -7
  234. package/dist/transforms/v1/repository-exist.d.ts +0 -6
  235. package/dist/transforms/v1/repository-find-by-ids.d.ts +0 -6
  236. package/dist/transforms/v1/repository-find-one-by-id.d.ts +0 -6
  237. package/dist/transforms/v1/upgrade-dependencies.d.ts +0 -15
  238. package/dist/transforms/v1/upgrade-dependencies.js +0 -163
  239. package/dist/transforms/v1/upgrade-dependencies.js.map +0 -1
  240. package/dist/transforms/v1/use-container.d.ts +0 -7
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-exist-to-exists.js","sourceRoot":"","sources":["../../../src/transforms/v1/rename-exist-to-exists.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG,2CAA2C,CAAA;AAE/D,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC5D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;SAC9B;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,IACI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;YAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACjD,CAAC;YACC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,QAAQ,CAAA;YACzC,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AArBY,QAAA,mBAAmB,uBAqB/B;AAED,kBAAe,2BAAmB,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace `findByIds()` with `findBy()` and `In` operator";
3
- export declare const renameFindByIds: (file: FileInfo, api: API) => string | undefined;
4
- export default renameFindByIds;
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameFindByIds = exports.description = void 0;
4
- exports.description = "replace `findByIds()` with `findBy()` and `In` operator";
5
- const renameFindByIds = (file, api) => {
6
- const j = api.jscodeshift;
7
- const root = j(file.source);
8
- let hasChanges = false;
9
- let needsInImport = false;
10
- root.find(j.CallExpression, {
11
- callee: {
12
- type: "MemberExpression",
13
- property: { name: "findByIds" },
14
- },
15
- }).forEach((path) => {
16
- if (path.node.callee.type !== "MemberExpression" ||
17
- path.node.arguments.length < 1) {
18
- return;
19
- }
20
- const idsArg = path.node.arguments[0];
21
- // Replace .findByIds(ids) with .findBy({ id: In(ids) })
22
- path.node.callee.property = j.identifier("findBy");
23
- path.node.arguments = [
24
- j.objectExpression([
25
- j.property("init", j.identifier("id"), j.callExpression(j.identifier("In"), [idsArg])),
26
- ]),
27
- ];
28
- hasChanges = true;
29
- needsInImport = true;
30
- });
31
- // Add In import if needed
32
- if (needsInImport) {
33
- const typeormImports = root.find(j.ImportDeclaration, {
34
- source: { value: "typeorm" },
35
- });
36
- let hasInImport = false;
37
- typeormImports.forEach((path) => {
38
- path.node.specifiers?.forEach((spec) => {
39
- if (spec.type === "ImportSpecifier" &&
40
- spec.imported.type === "Identifier" &&
41
- spec.imported.name === "In") {
42
- hasInImport = true;
43
- }
44
- });
45
- });
46
- if (!hasInImport) {
47
- if (typeormImports.length > 0) {
48
- // Add to existing typeorm import
49
- typeormImports.at(0).forEach((path) => {
50
- path.node.specifiers?.push(j.importSpecifier(j.identifier("In")));
51
- });
52
- }
53
- else {
54
- // Create new import
55
- const newImport = j.importDeclaration([j.importSpecifier(j.identifier("In"))], j.literal("typeorm"));
56
- root.find(j.ImportDeclaration).at(-1).insertAfter(newImport);
57
- }
58
- }
59
- }
60
- return hasChanges ? root.toSource() : undefined;
61
- };
62
- exports.renameFindByIds = renameFindByIds;
63
- exports.default = exports.renameFindByIds;
64
- //# sourceMappingURL=rename-find-by-ids.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-find-by-ids.js","sourceRoot":"","sources":["../../../src/transforms/v1/rename-find-by-ids.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GACpB,yDAAyD,CAAA;AAEtD,MAAM,eAAe,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACxD,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,IAAI,aAAa,GAAG,KAAK,CAAA;IAEzB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;SAClC;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,IACI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;YAC5C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAChC,CAAC;YACC,OAAM;QACV,CAAC;QAED,MAAM,MAAM,GAAG,I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AAiC;gBACjC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;oBAClC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CACtB,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CACxC,CAAA;gBACL,CAAC,CAAC,CAAA;YACN,CAAC;iBAAM,CAAC;gBACJ,oBAAoB;gBACpB,MAAM,SAAS,GAAG,CAAC,CAAC,iBAAiB,CACjC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EACvC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CACvB,CAAA;gBACD,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;YAChE,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA5EY,QAAA,eAAe,mBA4E3B;AAED,kBAAe,uBAAe,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace removed `getAllMigrations()` with TODO comment";
3
- export declare const manual = true;
4
- export declare const renameGetAllMigrations: (file: FileInfo, api: API) => string | undefined;
5
- export default renameGetAllMigrations;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameGetAllMigrations = exports.manual = exports.description = void 0;
4
- const todo_1 = require("../todo");
5
- exports.description = "replace removed `getAllMigrations()` with TODO comment";
6
- exports.manual = true;
7
- const renameGetAllMigrations = (file, api) => {
8
- const j = api.jscodeshift;
9
- const root = j(file.source);
10
- let hasChanges = false;
11
- root.find(j.CallExpression, {
12
- callee: {
13
- type: "MemberExpression",
14
- property: { name: "getAllMigrations" },
15
- },
16
- }).forEach((path) => {
17
- // Add a TODO comment before the statement
18
- const statement = j(path).closest(j.ExpressionStatement);
19
- if (statement.length > 0) {
20
- statement.forEach((stmtPath) => {
21
- (0, todo_1.addTodoComment)(stmtPath.node, "getAllMigrations() was removed in TypeORM v1. Use getPendingMigrations(), getExecutedMigrations(), or dataSource.migrations instead.", j);
22
- });
23
- }
24
- hasChanges = true;
25
- });
26
- if (hasChanges)
27
- (0, todo_1.reportTodo)("rename-get-all-migrations", file, api);
28
- return hasChanges ? root.toSource() : undefined;
29
- };
30
- exports.renameGetAllMigrations = renameGetAllMigrations;
31
- exports.default = exports.renameGetAllMigrations;
32
- //# sourceMappingURL=rename-get-all-migrations.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-get-all-migrations.js","sourceRoot":"","sources":["../../../src/transforms/v1/rename-get-all-migrations.ts"],"names":[],"mappings":";;;AACA,kCAAoD;AAEvC,QAAA,WAAW,GACpB,wDAAwD,CAAA;AAC/C,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,kBAAkB,EAAE;SACzC;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,0CAA0C;QAC1C,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAA;QACxD,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBAC3B,IAAA,qBAAc,EACV,QAAQ,CAAC,IAAI,EACb,sIAAsI,EACtI,CAAC,CACJ,CAAA;YACL,CAAC,CAAC,CAAA;QACN,CAAC;QACD,UAAU,GAAG,IAAI,CAAA;IACrB,CAAC,CAAC,CAAA;IAEF,IAAI,UAAU;QAAE,IAAA,iBAAU,EAAC,2BAA2B,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAElE,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA5BY,QAAA,sBAAsB,0BA4BlC;AAED,kBAAe,8BAAsB,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace removed `loadedTables` and `loadedViews` with TODO";
3
- export declare const manual = true;
4
- export declare const renameLoadedTablesViews: (file: FileInfo, api: API) => string | undefined;
5
- export default renameLoadedTablesViews;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameLoadedTablesViews = exports.manual = exports.description = void 0;
4
- const todo_1 = require("../todo");
5
- exports.description = "replace removed `loadedTables` and `loadedViews` with TODO";
6
- exports.manual = true;
7
- const renameLoadedTablesViews = (file, api) => {
8
- const j = api.jscodeshift;
9
- const root = j(file.source);
10
- let hasChanges = false;
11
- let hasTodos = false;
12
- const removedProps = new Set(["loadedTables", "loadedViews"]);
13
- root.find(j.MemberExpression).forEach((path) => {
14
- if (path.node.property.type !== "Identifier")
15
- return;
16
- if (!removedProps.has(path.node.property.name))
17
- return;
18
- const propName = path.node.property.name;
19
- // Find the containing statement to add a comment
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- let current = path;
22
- while (current.parent && current.parent.node.type !== "Program") {
23
- if (current.parent.node.type === "ExpressionStatement" ||
24
- current.parent.node.type === "VariableDeclaration" ||
25
- current.parent.node.type === "ReturnStatement") {
26
- const stmt = current.parent.node;
27
- const message = `\`${propName}\` was removed in TypeORM v1. Use async \`loadTables()\` / \`loadViews()\` methods instead. See migration guide: https://typeorm.io/docs/guides/migration-v1`;
28
- // Avoid duplicate comments
29
- const commentValue = ` TODO: ${message}`;
30
- const comments = (stmt.comments = stmt.comments || []);
31
- const hasSameComment = comments.some((c) => c.value === commentValue);
32
- if (!hasSameComment) {
33
- (0, todo_1.addTodoComment)(stmt, message, j);
34
- hasTodos = true;
35
- }
36
- hasChanges = true;
37
- break;
38
- }
39
- current = current.parent;
40
- }
41
- });
42
- if (hasTodos)
43
- (0, todo_1.reportTodo)("rename-loaded-tables-views", file, api);
44
- return hasChanges ? root.toSource() : undefined;
45
- };
46
- exports.renameLoadedTablesViews = renameLoadedTablesViews;
47
- exports.default = exports.renameLoadedTablesViews;
48
- //# sourceMappingURL=rename-loaded-tables-views.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-loaded-tables-views.js","sourceRoot":"","sources":["../../../src/transforms/v1/rename-loaded-tables-views.ts"],"names":[],"mappings":";;;AACA,kCAAoD;AAEvC,QAAA,WAAW,GACpB,4DAA4D,CAAA;AACnD,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,uBAAuB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAChE,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAA;IAE7D,IAAI,CAAC,IAAI,CAAC,CA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IAAI,CAAA;gBACnB,CAAC;gBACD,UAAU,GAAG,IAAI,CAAA;gBACjB,MAAK;YACT,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ;QAAE,IAAA,iBAAU,EAAC,4BAA4B,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEjE,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA9CY,QAAA,uBAAuB,2BA8CnC;AAED,kBAAe,+BAAuB,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace object-style `orUpdate()` with array-style signature";
3
- export declare const renameOrUpdateOverload: (file: FileInfo, api: API) => string | undefined;
4
- export default renameOrUpdateOverload;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renameOrUpdateOverload = exports.description = void 0;
4
- exports.description = "replace object-style `orUpdate()` with array-style signature";
5
- const renameOrUpdateOverload = (file, api) => {
6
- const j = api.jscodeshift;
7
- const root = j(file.source);
8
- let hasChanges = false;
9
- // Find .orUpdate({ conflict_target: [...], overwrite: [...] })
10
- root.find(j.CallExpression, {
11
- callee: {
12
- type: "MemberExpression",
13
- property: { type: "Identifier", name: "orUpdate" },
14
- },
15
- }).forEach((path) => {
16
- const args = path.node.arguments;
17
- if (args.length !== 1)
18
- return;
19
- const arg = args[0];
20
- if (arg.type !== "ObjectExpression")
21
- return;
22
- let conflictTarget = null;
23
- let overwrite = null;
24
- for (const prop of arg.properties) {
25
- if (prop.type !== "ObjectProperty")
26
- continue;
27
- if (prop.key.type !== "Identifier")
28
- continue;
29
- if (prop.key.name === "conflict_target") {
30
- conflictTarget = prop.value;
31
- }
32
- else if (prop.key.name === "overwrite") {
33
- overwrite = prop.value;
34
- }
35
- }
36
- if (!conflictTarget || !overwrite)
37
- return;
38
- // Transform to .orUpdate([overwrite], [conflict_target])
39
- path.node.arguments = [overwrite, conflictTarget];
40
- hasChanges = true;
41
- });
42
- return hasChanges ? root.toSource() : undefined;
43
- };
44
- exports.renameOrUpdateOverload = renameOrUpdateOverload;
45
- exports.default = exports.renameOrUpdateOverload;
46
- //# sourceMappingURL=rename-or-update-overload.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-or-update-overload.js","sourceRoot":"","sources":["../../../src/transforms/v1/rename-or-update-overload.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GACpB,8DAA8D,CAAA;AAE3D,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,+DAA+D;IAC/D,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE;SACrD;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAA;QAChC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QAE7B,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB;YAAE,OAAM;QAE3C,IAAI,cAAc,GAAQ,IAAI,CAAA;QAC9B,IAAI,SAAS,GAAQ,IAAI,CAAA;QAEzB,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB;gBAAE,SAAQ;YAC5C,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;gBAAE,SAAQ;YAE5C,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;gBACtC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAA;YAC/B,CAAC;iBAAM,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBACvC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAA;YAC1B,CAAC;QACL,CAAC;QAED,IAAI,CAAC,cAAc,IAAI,CAAC,SAAS;YAAE,OAAM;QAEzC,yDAAyD;QACzD,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;QACjD,UAAU,GAAG,IAAI,CAAA;IACrB,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAxCY,QAAA,sBAAsB,0BAwClC;AAED,kBAAe,8BAAsB,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "rename `printSql()` to `logQuery()`";
3
- export declare const renamePrintSqlToLogQuery: (file: FileInfo, api: API) => string | undefined;
4
- export default renamePrintSqlToLogQuery;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renamePrintSqlToLogQuery = exports.description = void 0;
4
- exports.description = "rename `printSql()` to `logQuery()`";
5
- const renamePrintSqlToLogQuery = (file, api) => {
6
- const j = api.jscodeshift;
7
- const root = j(file.source);
8
- let hasChanges = false;
9
- root.find(j.CallExpression, {
10
- callee: {
11
- type: "MemberExpression",
12
- property: { name: "printSql" },
13
- },
14
- }).forEach((path) => {
15
- if (path.node.callee.type === "MemberExpression" &&
16
- path.node.callee.property.type === "Identifier") {
17
- path.node.callee.property.name = "logQuery";
18
- hasChanges = true;
19
- }
20
- });
21
- return hasChanges ? root.toSource() : undefined;
22
- };
23
- exports.renamePrintSqlToLogQuery = renamePrintSqlToLogQuery;
24
- exports.default = exports.renamePrintSqlToLogQuery;
25
- //# sourceMappingURL=rename-print-sql-to-log-query.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"rename-print-sql-to-log-query.js","sourceRoot":"","sources":["../../../src/transforms/v1/rename-print-sql-to-log-query.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG,qCAAqC,CAAA;AAEzD,MAAM,wBAAwB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACjE,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;SACjC;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,IACI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,KAAK,kBAAkB;YAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACjD,CAAC;YACC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,UAAU,CAAA;YAC3C,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AArBY,QAAA,wBAAwB,4BAqBpC;AAED,kBAAe,gCAAwB,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace deprecated global functions with `DataSource` methods";
3
- export declare const manual = true;
4
- export declare const replaceGlobalFunctions: (file: FileInfo, api: API) => string | undefined;
5
- export default replaceGlobalFunctions;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceGlobalFunctions = exports.manual = exports.description = void 0;
4
- const todo_1 = require("../todo");
5
- exports.description = "replace deprecated global functions with `DataSource` methods";
6
- exports.manual = true;
7
- const replaceGlobalFunctions = (file, api) => {
8
- const j = api.jscodeshift;
9
- const root = j(file.source);
10
- let hasChanges = false;
11
- const removedGlobals = new Set([
12
- "createConnection",
13
- "createConnections",
14
- "getConnection",
15
- "getConnectionManager",
16
- "getConnectionOptions",
17
- "getManager",
18
- "getSqljsManager",
19
- "getRepository",
20
- "getTreeRepository",
21
- "createQueryBuilder",
22
- "getMongoManager",
23
- "getMongoRepository",
24
- ]);
25
- // Simple replacements: getX(args) → dataSource.x(args)
26
- const simpleReplacements = {
27
- getManager: "dataSource.manager",
28
- getRepository: "dataSource.getRepository",
29
- getTreeRepository: "dataSource.getTreeRepository",
30
- createQueryBuilder: "dataSource.createQueryBuilder",
31
- getMongoManager: "dataSource.mongoManager",
32
- getMongoRepository: "dataSource.getMongoRepository",
33
- };
34
- // Replace function calls
35
- for (const [funcName, replacement] of Object.entries(simpleReplacements)) {
36
- root.find(j.CallExpression, {
37
- callee: { type: "Identifier", name: funcName },
38
- }).forEach((path) => {
39
- const parts = replacement.split(".");
40
- if (parts.length === 2 && !replacement.includes("(")) {
41
- // Property access like dataSource.manager — check if it's called with no args
42
- if (path.node.arguments.length === 0 &&
43
- !replacement.includes("get")) {
44
- // Replace with property access
45
- j(path).replaceWith(j.memberExpression(j.identifier(parts[0]), j.identifier(parts[1])));
46
- }
47
- else {
48
- // Replace with method call
49
- j(path).replaceWith(j.callExpression(j.memberExpression(j.identifier(parts[0]), j.identifier(parts[1])), path.node.arguments));
50
- }
51
- hasChanges = true;
52
- }
53
- });
54
- }
55
- // getConnection() → dataSource (just a reference)
56
- root.find(j.CallExpression, {
57
- callee: { type: "Identifier", name: "getConnection" },
58
- }).forEach((path) => {
59
- if (path.node.arguments.length === 0) {
60
- j(path).replaceWith(j.identifier("dataSource"));
61
- hasChanges = true;
62
- }
63
- });
64
- // Remove imports of deprecated globals from "typeorm"
65
- root.find(j.ImportDeclaration, {
66
- source: { value: "typeorm" },
67
- }).forEach((importPath) => {
68
- const remaining = importPath.node.specifiers?.filter((spec) => {
69
- if (spec.type === "ImportSpecifier" &&
70
- spec.imported.type === "Identifier") {
71
- return !removedGlobals.has(spec.imported.name);
72
- }
73
- return true;
74
- });
75
- if (remaining &&
76
- remaining.length !== importPath.node.specifiers?.length) {
77
- hasChanges = true;
78
- if (remaining.length === 0) {
79
- j(importPath).remove();
80
- }
81
- else {
82
- importPath.node.specifiers = remaining;
83
- }
84
- }
85
- });
86
- if (hasChanges)
87
- (0, todo_1.reportTodo)("replace-global-functions", file, api);
88
- return hasChanges ? root.toSource() : undefined;
89
- };
90
- exports.replaceGlobalFunctions = replaceGlobalFunctions;
91
- exports.default = exports.replaceGlobalFunctions;
92
- //# sourceMappingURL=replace-global-functions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replace-global-functions.js","sourceRoot":"","sources":["../../../src/transforms/v1/replace-global-functions.ts"],"names":[],"mappings":";;;AACA,kCAAoC;AAEvB,QAAA,WAAW,GACpB,+DAA+D,CAAA;AACtD,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,sBAAsB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC/D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IA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,iBAAiB;gBAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,EACrC,CAAC;gBACC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YAClD,CAAC;YACD,OAAO,IAAI,CAAA;QACf,CAAC,CAAC,CAAA;QAEF,IACI,SAAS;YACT,SAAS,CAAC,MAAM,KAAK,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,EACzD,CAAC;YACC,UAAU,GAAG,IAAI,CAAA;YACjB,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACzB,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAA;YAC1B,CAAC;iBAAM,CAAC;gBACJ,UAAU,CAAC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;YAC1C,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,UAAU;QAAE,IAAA,iBAAU,EAAC,0BAA0B,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAEjE,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA1GY,QAAA,sBAAsB,0BA0GlC;AAED,kBAAe,8BAAsB,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace deprecated pessimistic lock modes";
3
- export declare const replaceLockModes: (file: FileInfo, api: API) => string | undefined;
4
- export default replaceLockModes;
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceLockModes = exports.description = void 0;
4
- const ast_helpers_1 = require("../ast-helpers");
5
- exports.description = "replace deprecated pessimistic lock modes";
6
- const replaceLockModes = (file, api) => {
7
- const j = api.jscodeshift;
8
- const root = j(file.source);
9
- let hasChanges = false;
10
- const lockModeMap = {
11
- pessimistic_partial_write: {
12
- mode: "pessimistic_write",
13
- onLocked: "skip_locked",
14
- },
15
- pessimistic_write_or_fail: {
16
- mode: "pessimistic_write",
17
- onLocked: "nowait",
18
- },
19
- };
20
- // Handle .setLock("pessimistic_partial_write") → .setLock("pessimistic_write").setOnLocked("skip_locked")
21
- root.find(j.CallExpression, {
22
- callee: {
23
- type: "MemberExpression",
24
- property: { name: "setLock" },
25
- },
26
- }).forEach((path) => {
27
- const arg = path.node.arguments[0];
28
- if (!arg)
29
- return;
30
- const value = (0, ast_helpers_1.getStringValue)(arg);
31
- if (!value || !lockModeMap[value])
32
- return;
33
- const replacement = lockModeMap[value];
34
- // Change the lock mode argument
35
- (0, ast_helpers_1.setStringValue)(arg, replacement.mode);
36
- // Wrap in .setOnLocked() call
37
- const setOnLocked = j.callExpression(j.memberExpression(path.node, j.identifier("setOnLocked")), [j.stringLiteral(replacement.onLocked)]);
38
- j(path).replaceWith(setOnLocked);
39
- hasChanges = true;
40
- });
41
- // Handle find options: { lock: { mode: "pessimistic_partial_write" } }
42
- // → { lock: { mode: "pessimistic_write", onLocked: "skip_locked" } }
43
- root.find(j.ObjectProperty, {
44
- key: { name: "mode" },
45
- }).forEach((path) => {
46
- const value = (0, ast_helpers_1.getStringValue)(path.node.value);
47
- if (!value || !lockModeMap[value])
48
- return;
49
- // Check parent is a lock options object
50
- const parent = path.parent;
51
- if (parent.node.type !== "ObjectExpression")
52
- return;
53
- const grandparent = parent.parent;
54
- if (grandparent.node.type !== "Property" ||
55
- grandparent.node.key.type !== "Identifier" ||
56
- grandparent.node.key.name !== "lock") {
57
- return;
58
- }
59
- const replacement = lockModeMap[value];
60
- // Update mode value
61
- (0, ast_helpers_1.setStringValue)(path.node.value, replacement.mode);
62
- // Add onLocked property to the lock object
63
- const hasOnLocked = parent.node.properties.some((p) => p.type === "Property" &&
64
- p.key.type === "Identifier" &&
65
- p.key.name === "onLocked");
66
- if (!hasOnLocked) {
67
- parent.node.properties.push(j.property("init", j.identifier("onLocked"), j.stringLiteral(replacement.onLocked)));
68
- }
69
- hasChanges = true;
70
- });
71
- return hasChanges ? root.toSource() : undefined;
72
- };
73
- exports.replaceLockModes = replaceLockModes;
74
- exports.default = exports.replaceLockModes;
75
- //# sourceMappingURL=replace-lock-modes.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replace-lock-modes.js","sourceRoot":"","sources":["../../../src/transforms/v1/replace-lock-modes.ts"],"names":[],"mappings":";;;AACA,gDAA+D;AAElD,QAAA,WAAW,GAAG,2CAA2C,CAAA;AAE/D,MAAM,gBAAgB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACzD,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,IAAI,UAAU,GAAG,KAAK,CAAA;IAEtB,MAAM,WAAW,GAAuD;QACpE,yBAAyB,EAAE;YACvB,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,aAAa;SAC1B;QACD,yBAAyB,EAAE;YACvB,IAAI,EAAE,mBAAmB;YACzB,QAAQ,EAAE,QAAQ;SACrB;KACJ,CAAA;IAED,0GAA0G;IAC1G,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;SAChC;KACJ,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAChB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAClC,IAAI,CAAC,GAAG;YAAE,OAAM;QAEhB,MAAM,KAAK,GAAG,IAAA,4BAAc,EAAC,GAAG,CAAC,CAAA;QACjC,IAAI,CAAC,KAAK,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC;YAAE,OAAM;QAEzC,MAAM,W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,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;QAEtC,oBAAoB;QACpB,IAAA,4BAAc,EAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;QAEjD,2CAA2C;QAC3C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAC3C,CAAC,CAAM,EAAE,EAAE,CACP,CAAC,CAAC,IAAI,KAAK,UAAU;YACrB,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;YAC3B,CAAC,CAAC,GAAG,CAAC,IAAI,KAAK,UAAU,CAChC,CAAA;QAED,IAAI,CAAC,WAAW,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CACvB,CAAC,CAAC,QAAQ,CACN,MAAM,EACN,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,EACxB,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,CACxC,CACJ,CAAA;QACL,CAAC;QAED,UAAU,GAAG,IAAI,CAAA;IACrB,CAAC,CAAC,CAAA;IAEF,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA5FY,QAAA,gBAAgB,oBA4F5B;AAED,kBAAe,wBAAgB,CAAA"}
@@ -1,5 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "replace removed `stats()` with TODO comment";
3
- export declare const manual = true;
4
- export declare const replaceMongodbStats: (file: FileInfo, api: API) => string | undefined;
5
- export default replaceMongodbStats;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceMongodbStats = exports.manual = exports.description = void 0;
4
- const todo_1 = require("../todo");
5
- exports.description = "replace removed `stats()` with TODO comment";
6
- exports.manual = true;
7
- const replaceMongodbStats = (file, api) => {
8
- const j = api.jscodeshift;
9
- const root = j(file.source);
10
- let hasChanges = false;
11
- let hasTodos = false;
12
- const message = "`stats()` was removed in TypeORM v1. Use the MongoDB driver directly. See migration guide: https://typeorm.io/docs/guides/migration-v1";
13
- // Find .stats() calls
14
- root.find(j.CallExpression, {
15
- callee: {
16
- type: "MemberExpression",
17
- property: { type: "Identifier", name: "stats" },
18
- },
19
- }).forEach((path) => {
20
- // Check if this is a statement expression we can add a comment before
21
- const parent = path.parent;
22
- if (parent.node.type === "ExpressionStatement") {
23
- (0, todo_1.addTodoComment)(parent.node, message, j);
24
- hasChanges = true;
25
- hasTodos = true;
26
- }
27
- else if (parent.node.type === "AwaitExpression") {
28
- const grandparent = path.parent.parent;
29
- if (grandparent.node.type === "ExpressionStatement") {
30
- (0, todo_1.addTodoComment)(grandparent.node, message, j);
31
- hasChanges = true;
32
- hasTodos = true;
33
- }
34
- else {
35
- // Nested in an expression — add comment to the call itself
36
- (0, todo_1.addTodoComment)(path.node, message, j);
37
- hasChanges = true;
38
- hasTodos = true;
39
- }
40
- }
41
- else {
42
- // Nested in an expression — add comment to the call itself
43
- (0, todo_1.addTodoComment)(path.node, message, j);
44
- hasChanges = true;
45
- hasTodos = true;
46
- }
47
- });
48
- if (hasTodos)
49
- (0, todo_1.reportTodo)("replace-mongodb-stats", file, api);
50
- return hasChanges ? root.toSource() : undefined;
51
- };
52
- exports.replaceMongodbStats = replaceMongodbStats;
53
- exports.default = exports.replaceMongodbStats;
54
- //# sourceMappingURL=replace-mongodb-stats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replace-mongodb-stats.js","sourceRoot":"","sources":["../../../src/transforms/v1/replace-mongodb-stats.ts"],"names":[],"mappings":";;;AACA,kCAAoD;AAEvC,QAAA,WAAW,GAAG,6CAA6C,CAAA;AAC3D,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC5D,MAAM,CAAC,GAAG,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A;gBACjB,QAAQ,GAAG,IAAI,CAAA;YACnB,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,2DAA2D;YAC3D,IAAA,qBAAc,EAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;YACrC,UAAU,GAAG,IAAI,CAAA;YACjB,QAAQ,GAAG,IAAI,CAAA;QACnB,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ;QAAE,IAAA,iBAAU,EAAC,uBAAuB,EAAE,IAAI,EAAE,GAAG,CAAC,CAAA;IAE5D,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA7CY,QAAA,mBAAmB,uBA6C/B;AAED,kBAAe,2BAAmB,CAAA"}
@@ -1,4 +0,0 @@
1
- import type { API, FileInfo } from "jscodeshift";
2
- export declare const description = "move `ObjectId` import from `typeorm` to `mongodb`";
3
- export declare const replaceMongodbTypes: (file: FileInfo, api: API) => string | undefined;
4
- export default replaceMongodbTypes;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.replaceMongodbTypes = exports.description = void 0;
4
- exports.description = "move `ObjectId` import from `typeorm` to `mongodb`";
5
- const addToExistingImport = (existing, movedSpecifiers) => {
6
- const existingNames = new Set(existing.node.specifiers
7
- ?.filter((s) => s.type === "ImportSpecifier" &&
8
- s.imported.type === "Identifier")
9
- .map((s) => s.imported.name) ?? []);
10
- for (const spec of movedSpecifiers) {
11
- if (!existingNames.has(spec.imported.name)) {
12
- existing.node.specifiers?.push(spec);
13
- }
14
- }
15
- };
16
- const createNewImport = (j, root, importPath, movedSpecifiers) => {
17
- const newImport = j.importDeclaration(movedSpecifiers, j.stringLiteral("mongodb"));
18
- if (importPath.node.importKind === "type") {
19
- newImport.importKind = "type";
20
- }
21
- const allImports = root.find(j.ImportDeclaration);
22
- if (allImports.length > 0) {
23
- j(allImports.at(-1).get()).insertAfter(newImport);
24
- }
25
- else {
26
- root.get().node.program.body.unshift(newImport);
27
- }
28
- };
29
- const replaceMongodbTypes = (file, api) => {
30
- const j = api.jscodeshift;
31
- const root = j(file.source);
32
- let hasChanges = false;
33
- const movedTypes = new Set(["ObjectId"]);
34
- root.find(j.ImportDeclaration, {
35
- source: { value: "typeorm" },
36
- }).forEach((importPath) => {
37
- const movedSpecifiers = [];
38
- const remaining = importPath.node.specifiers?.filter((spec) => {
39
- if (spec.type === "ImportSpecifier" &&
40
- spec.imported.type === "Identifier" &&
41
- movedTypes.has(spec.imported.name)) {
42
- movedSpecifiers.push(spec);
43
- return false;
44
- }
45
- return true;
46
- });
47
- if (movedSpecifiers.length === 0)
48
- return;
49
- hasChanges = true;
50
- // Update or remove the typeorm import
51
- if (remaining?.length === 0) {
52
- j(importPath).remove();
53
- }
54
- else if (remaining) {
55
- importPath.node.specifiers = remaining;
56
- }
57
- // Check if there's already a mongodb import
58
- const existingMongoImport = root.find(j.ImportDeclaration, {
59
- source: { value: "mongodb" },
60
- });
61
- if (existingMongoImport.length > 0) {
62
- addToExistingImport(existingMongoImport.at(0).get(), movedSpecifiers);
63
- }
64
- else {
65
- createNewImport(j, root, importPath, movedSpecifiers);
66
- }
67
- });
68
- return hasChanges ? root.toSource() : undefined;
69
- };
70
- exports.replaceMongodbTypes = replaceMongodbTypes;
71
- exports.default = exports.replaceMongodbTypes;
72
- //# sourceMappingURL=replace-mongodb-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"replace-mongodb-types.js","sourceRoot":"","sources":["../../../src/transforms/v1/replace-mongodb-types.ts"],"names":[],"mappings":";;;AAEa,QAAA,WAAW,GAAG,oDAAoD,CAAA;AAE/E,MAAM,mBAAmB,GAAG,CAAC,QAAa,EAAE,eAAsB,EAAE,EAAE;IAClE,MAAM,aAAa,GAAG,IAAI,GAAG,CACzB,QAAQ,CAAC,IAAI,CAAC,UAAU;QACpB,EAAE,MAAM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