@typeorm/codemod 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -10
- package/dist/cli/print-guide.js +2 -2
- package/dist/cli/print-summary.js +3 -2
- package/dist/cli/print-summary.js.map +1 -1
- package/dist/cli/print-usage.js +2 -1
- package/dist/cli/print-usage.js.map +1 -1
- package/dist/cli/run-transforms.js +181 -79
- package/dist/cli/run-transforms.js.map +1 -1
- package/dist/dependencies/v1.js +23 -9
- package/dist/dependencies/v1.js.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/transforms/ast-helpers.js +779 -19
- package/dist/transforms/ast-helpers.js.map +1 -1
- package/dist/transforms/stats.js +11 -0
- package/dist/transforms/stats.js.map +1 -1
- package/dist/transforms/todo.js +42 -2
- package/dist/transforms/todo.js.map +1 -1
- package/dist/transforms/v1/column-readonly.js +28 -13
- package/dist/transforms/v1/column-readonly.js.map +1 -1
- package/dist/transforms/v1/column-unsigned-numeric.js +27 -26
- package/dist/transforms/v1/column-unsigned-numeric.js.map +1 -1
- package/dist/transforms/v1/column-width-zerofill.js +2 -1
- package/dist/transforms/v1/column-width-zerofill.js.map +1 -1
- package/dist/transforms/v1/connection-manager.js +82 -0
- package/dist/transforms/v1/connection-manager.js.map +1 -0
- package/dist/transforms/v1/connection-options-reader.js +214 -0
- package/dist/transforms/v1/connection-options-reader.js.map +1 -0
- package/dist/transforms/v1/connection-to-datasource.js +858 -93
- package/dist/transforms/v1/connection-to-datasource.js.map +1 -1
- package/dist/transforms/v1/datasource-expo.js +79 -0
- package/dist/transforms/v1/datasource-expo.js.map +1 -0
- package/dist/transforms/v1/datasource-mongodb.js +103 -64
- package/dist/transforms/v1/datasource-mongodb.js.map +1 -1
- package/dist/transforms/v1/datasource-mssql.js +88 -46
- package/dist/transforms/v1/datasource-mssql.js.map +1 -1
- package/dist/transforms/v1/datasource-mysql-connector.js +25 -6
- package/dist/transforms/v1/datasource-mysql-connector.js.map +1 -1
- package/dist/transforms/v1/datasource-name.js +19 -14
- package/dist/transforms/v1/datasource-name.js.map +1 -1
- package/dist/transforms/v1/datasource-sap.js +51 -26
- package/dist/transforms/v1/datasource-sap.js.map +1 -1
- package/dist/transforms/v1/datasource-sqlite-options.js +48 -13
- package/dist/transforms/v1/datasource-sqlite-options.js.map +1 -1
- package/dist/transforms/v1/datasource-sqlite-type.js +28 -7
- package/dist/transforms/v1/datasource-sqlite-type.js.map +1 -1
- package/dist/transforms/v1/file-logger.js +163 -0
- package/dist/transforms/v1/file-logger.js.map +1 -0
- package/dist/transforms/v1/find-options-join.js +84 -0
- package/dist/transforms/v1/find-options-join.js.map +1 -0
- package/dist/transforms/v1/find-options-lock-modes.js +26 -21
- package/dist/transforms/v1/find-options-lock-modes.js.map +1 -1
- package/dist/transforms/v1/find-options-string-relations.js +75 -9
- package/dist/transforms/v1/find-options-string-relations.js.map +1 -1
- package/dist/transforms/v1/find-options-string-select.js +75 -11
- package/dist/transforms/v1/find-options-string-select.js.map +1 -1
- package/dist/transforms/v1/global-functions.js +150 -64
- package/dist/transforms/v1/global-functions.js.map +1 -1
- package/dist/transforms/v1/index.js +16 -3
- package/dist/transforms/v1/index.js.map +1 -1
- package/dist/transforms/v1/migrations-get-all.js +25 -9
- package/dist/transforms/v1/migrations-get-all.js.map +1 -1
- package/dist/transforms/v1/mongodb-stats.js +21 -11
- package/dist/transforms/v1/mongodb-stats.js.map +1 -1
- package/dist/transforms/v1/mongodb-types.js +59 -2
- package/dist/transforms/v1/mongodb-types.js.map +1 -1
- package/dist/transforms/v1/query-builder-native-parameters.js +2 -0
- package/dist/transforms/v1/query-builder-native-parameters.js.map +1 -1
- package/dist/transforms/v1/query-builder-on-conflict.js +32 -18
- package/dist/transforms/v1/query-builder-on-conflict.js.map +1 -1
- package/dist/transforms/v1/query-builder-or-update.js +8 -4
- package/dist/transforms/v1/query-builder-or-update.js.map +1 -1
- package/dist/transforms/v1/query-builder-print-sql.js +18 -12
- package/dist/transforms/v1/query-builder-print-sql.js.map +1 -1
- package/dist/transforms/v1/query-builder-replace-property-names.js +16 -12
- package/dist/transforms/v1/query-builder-replace-property-names.js.map +1 -1
- package/dist/transforms/v1/query-builder-where-expression.js +29 -12
- package/dist/transforms/v1/query-builder-where-expression.js.map +1 -1
- package/dist/transforms/v1/query-runner-loaded-tables-views.js +1 -6
- package/dist/transforms/v1/query-runner-loaded-tables-views.js.map +1 -1
- package/dist/transforms/v1/relation-count.js +78 -12
- package/dist/transforms/v1/relation-count.js.map +1 -1
- package/dist/transforms/v1/repository-abstract.js +148 -34
- package/dist/transforms/v1/repository-abstract.js.map +1 -1
- package/dist/transforms/v1/repository-exist.js +20 -1
- package/dist/transforms/v1/repository-exist.js.map +1 -1
- package/dist/transforms/v1/repository-find-by-ids.js +67 -27
- package/dist/transforms/v1/repository-find-by-ids.js.map +1 -1
- package/dist/transforms/v1/repository-find-one-by-id.js +6 -0
- package/dist/transforms/v1/repository-find-one-by-id.js.map +1 -1
- package/dist/transforms/v1/use-container.js +65 -15
- package/dist/transforms/v1/use-container.js.map +1 -1
- package/package.json +3 -1
- package/dist/cli/colors.d.ts +0 -7
- package/dist/cli/colors.js +0 -12
- package/dist/cli/colors.js.map +0 -1
- package/dist/cli/error.d.ts +0 -1
- package/dist/cli/error.js +0 -11
- package/dist/cli/error.js.map +0 -1
- package/dist/cli/list-transforms.d.ts +0 -1
- package/dist/cli/parse-args.d.ts +0 -10
- package/dist/cli/print-guide.d.ts +0 -1
- package/dist/cli/print-summary.d.ts +0 -17
- package/dist/cli/print-todos.d.ts +0 -1
- package/dist/cli/print-usage.d.ts +0 -1
- package/dist/cli/run-dependencies.d.ts +0 -6
- package/dist/cli/run-transforms.d.ts +0 -21
- package/dist/cli/run.d.ts +0 -9
- package/dist/dependencies/config.d.ts +0 -24
- package/dist/dependencies/find-package-json.d.ts +0 -5
- package/dist/dependencies/index.d.ts +0 -5
- package/dist/dependencies/upgrade.d.ts +0 -11
- package/dist/dependencies/v1.d.ts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/lib/colors.d.ts +0 -9
- package/dist/lib/error.d.ts +0 -1
- package/dist/lib/format-time.d.ts +0 -1
- package/dist/lib/highlight.d.ts +0 -1
- package/dist/lib/spinner.d.ts +0 -5
- package/dist/transforms/ast-helpers.d.ts +0 -50
- package/dist/transforms/index.d.ts +0 -7
- package/dist/transforms/resolve.d.ts +0 -1
- package/dist/transforms/scan.d.ts +0 -4
- package/dist/transforms/scan.js +0 -33
- package/dist/transforms/scan.js.map +0 -1
- package/dist/transforms/stats.d.ts +0 -11
- package/dist/transforms/todo.d.ts +0 -2
- package/dist/transforms/transformer.d.ts +0 -8
- package/dist/transforms/v1/column-readonly.d.ts +0 -6
- package/dist/transforms/v1/column-unsigned-numeric.d.ts +0 -6
- package/dist/transforms/v1/column-width-zerofill.d.ts +0 -6
- package/dist/transforms/v1/connection-to-datasource.d.ts +0 -6
- package/dist/transforms/v1/datasource-mongodb.d.ts +0 -7
- package/dist/transforms/v1/datasource-mssql-domain.d.ts +0 -7
- package/dist/transforms/v1/datasource-mssql-domain.js +0 -35
- package/dist/transforms/v1/datasource-mssql-domain.js.map +0 -1
- package/dist/transforms/v1/datasource-mssql.d.ts +0 -7
- package/dist/transforms/v1/datasource-mysql-connector.d.ts +0 -6
- package/dist/transforms/v1/datasource-name.d.ts +0 -6
- package/dist/transforms/v1/datasource-sap.d.ts +0 -6
- package/dist/transforms/v1/datasource-sqlite-options.d.ts +0 -6
- package/dist/transforms/v1/datasource-sqlite-type.d.ts +0 -6
- package/dist/transforms/v1/find-options-lock-modes.d.ts +0 -6
- package/dist/transforms/v1/find-options-string-relations.d.ts +0 -6
- package/dist/transforms/v1/find-options-string-select.d.ts +0 -6
- package/dist/transforms/v1/global-functions.d.ts +0 -7
- package/dist/transforms/v1/index.d.ts +0 -40
- package/dist/transforms/v1/migrations-get-all.d.ts +0 -7
- package/dist/transforms/v1/mongodb-stats.d.ts +0 -7
- package/dist/transforms/v1/mongodb-types.d.ts +0 -6
- package/dist/transforms/v1/query-builder-native-parameters.d.ts +0 -6
- package/dist/transforms/v1/query-builder-on-conflict.d.ts +0 -7
- package/dist/transforms/v1/query-builder-or-update.d.ts +0 -6
- package/dist/transforms/v1/query-builder-print-sql.d.ts +0 -7
- package/dist/transforms/v1/query-builder-replace-property-names.d.ts +0 -7
- package/dist/transforms/v1/query-builder-where-expression.d.ts +0 -6
- package/dist/transforms/v1/query-runner-loaded-tables-views.d.ts +0 -7
- package/dist/transforms/v1/relation-count.d.ts +0 -7
- package/dist/transforms/v1/remove-abstract-repository.d.ts +0 -5
- package/dist/transforms/v1/remove-abstract-repository.js +0 -93
- package/dist/transforms/v1/remove-abstract-repository.js.map +0 -1
- package/dist/transforms/v1/remove-connector-package.d.ts +0 -4
- package/dist/transforms/v1/remove-connector-package.js +0 -19
- package/dist/transforms/v1/remove-connector-package.js.map +0 -1
- package/dist/transforms/v1/remove-datasource-name.d.ts +0 -4
- package/dist/transforms/v1/remove-datasource-name.js +0 -56
- package/dist/transforms/v1/remove-datasource-name.js.map +0 -1
- package/dist/transforms/v1/remove-mongodb-options.d.ts +0 -5
- package/dist/transforms/v1/remove-mongodb-options.js +0 -86
- package/dist/transforms/v1/remove-mongodb-options.js.map +0 -1
- package/dist/transforms/v1/remove-relation-count.d.ts +0 -5
- package/dist/transforms/v1/remove-relation-count.js +0 -49
- package/dist/transforms/v1/remove-relation-count.js.map +0 -1
- package/dist/transforms/v1/remove-replace-property-names.d.ts +0 -5
- package/dist/transforms/v1/remove-replace-property-names.js +0 -35
- package/dist/transforms/v1/remove-replace-property-names.js.map +0 -1
- package/dist/transforms/v1/remove-sap-options.d.ts +0 -4
- package/dist/transforms/v1/remove-sap-options.js +0 -54
- package/dist/transforms/v1/remove-sap-options.js.map +0 -1
- package/dist/transforms/v1/remove-unsigned-numeric.d.ts +0 -4
- package/dist/transforms/v1/remove-unsigned-numeric.js +0 -76
- package/dist/transforms/v1/remove-unsigned-numeric.js.map +0 -1
- package/dist/transforms/v1/remove-use-container.d.ts +0 -5
- package/dist/transforms/v1/remove-use-container.js +0 -63
- package/dist/transforms/v1/remove-use-container.js.map +0 -1
- package/dist/transforms/v1/remove-width-zerofill.d.ts +0 -4
- package/dist/transforms/v1/remove-width-zerofill.js +0 -29
- package/dist/transforms/v1/remove-width-zerofill.js.map +0 -1
- package/dist/transforms/v1/rename-connection-to-datasource.d.ts +0 -4
- package/dist/transforms/v1/rename-connection-to-datasource.js +0 -111
- package/dist/transforms/v1/rename-connection-to-datasource.js.map +0 -1
- package/dist/transforms/v1/rename-exist-to-exists.d.ts +0 -4
- package/dist/transforms/v1/rename-exist-to-exists.js +0 -25
- package/dist/transforms/v1/rename-exist-to-exists.js.map +0 -1
- package/dist/transforms/v1/rename-find-by-ids.d.ts +0 -4
- package/dist/transforms/v1/rename-find-by-ids.js +0 -64
- package/dist/transforms/v1/rename-find-by-ids.js.map +0 -1
- package/dist/transforms/v1/rename-get-all-migrations.d.ts +0 -5
- package/dist/transforms/v1/rename-get-all-migrations.js +0 -32
- package/dist/transforms/v1/rename-get-all-migrations.js.map +0 -1
- package/dist/transforms/v1/rename-loaded-tables-views.d.ts +0 -5
- package/dist/transforms/v1/rename-loaded-tables-views.js +0 -48
- package/dist/transforms/v1/rename-loaded-tables-views.js.map +0 -1
- package/dist/transforms/v1/rename-or-update-overload.d.ts +0 -4
- package/dist/transforms/v1/rename-or-update-overload.js +0 -46
- package/dist/transforms/v1/rename-or-update-overload.js.map +0 -1
- package/dist/transforms/v1/rename-print-sql-to-log-query.d.ts +0 -4
- package/dist/transforms/v1/rename-print-sql-to-log-query.js +0 -25
- package/dist/transforms/v1/rename-print-sql-to-log-query.js.map +0 -1
- package/dist/transforms/v1/replace-global-functions.d.ts +0 -5
- package/dist/transforms/v1/replace-global-functions.js +0 -92
- package/dist/transforms/v1/replace-global-functions.js.map +0 -1
- package/dist/transforms/v1/replace-lock-modes.d.ts +0 -4
- package/dist/transforms/v1/replace-lock-modes.js +0 -75
- package/dist/transforms/v1/replace-lock-modes.js.map +0 -1
- package/dist/transforms/v1/replace-mongodb-stats.d.ts +0 -5
- package/dist/transforms/v1/replace-mongodb-stats.js +0 -54
- package/dist/transforms/v1/replace-mongodb-stats.js.map +0 -1
- package/dist/transforms/v1/replace-mongodb-types.d.ts +0 -4
- package/dist/transforms/v1/replace-mongodb-types.js +0 -72
- package/dist/transforms/v1/replace-mongodb-types.js.map +0 -1
- package/dist/transforms/v1/replace-mssql-domain.d.ts +0 -5
- package/dist/transforms/v1/replace-mssql-domain.js +0 -25
- package/dist/transforms/v1/replace-mssql-domain.js.map +0 -1
- package/dist/transforms/v1/replace-on-conflict.d.ts +0 -5
- package/dist/transforms/v1/replace-on-conflict.js +0 -49
- package/dist/transforms/v1/replace-on-conflict.js.map +0 -1
- package/dist/transforms/v1/replace-readonly-column.d.ts +0 -4
- package/dist/transforms/v1/replace-readonly-column.js +0 -28
- package/dist/transforms/v1/replace-readonly-column.js.map +0 -1
- package/dist/transforms/v1/replace-set-native-parameters.d.ts +0 -4
- package/dist/transforms/v1/replace-set-native-parameters.js +0 -25
- package/dist/transforms/v1/replace-set-native-parameters.js.map +0 -1
- package/dist/transforms/v1/replace-sqlite-options.d.ts +0 -4
- package/dist/transforms/v1/replace-sqlite-options.js +0 -29
- package/dist/transforms/v1/replace-sqlite-options.js.map +0 -1
- package/dist/transforms/v1/replace-sqlite-type.d.ts +0 -4
- package/dist/transforms/v1/replace-sqlite-type.js +0 -22
- package/dist/transforms/v1/replace-sqlite-type.js.map +0 -1
- package/dist/transforms/v1/replace-where-expression-type.d.ts +0 -4
- package/dist/transforms/v1/replace-where-expression-type.js +0 -41
- package/dist/transforms/v1/replace-where-expression-type.js.map +0 -1
- package/dist/transforms/v1/repository-abstract.d.ts +0 -7
- package/dist/transforms/v1/repository-exist.d.ts +0 -6
- package/dist/transforms/v1/repository-find-by-ids.d.ts +0 -6
- package/dist/transforms/v1/repository-find-one-by-id.d.ts +0 -6
- package/dist/transforms/v1/upgrade-dependencies.d.ts +0 -15
- package/dist/transforms/v1/upgrade-dependencies.js +0 -163
- package/dist/transforms/v1/upgrade-dependencies.js.map +0 -1
- package/dist/transforms/v1/use-container.d.ts +0 -7
|
@@ -33,11 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.transforms = exports.
|
|
36
|
+
exports.transforms = exports.upgradingGuide = exports.description = void 0;
|
|
37
37
|
const columnReadonly = __importStar(require("./column-readonly"));
|
|
38
38
|
const columnUnsignedNumeric = __importStar(require("./column-unsigned-numeric"));
|
|
39
39
|
const columnWidthZerofill = __importStar(require("./column-width-zerofill"));
|
|
40
|
+
const connectionManager = __importStar(require("./connection-manager"));
|
|
41
|
+
const connectionOptionsReader = __importStar(require("./connection-options-reader"));
|
|
40
42
|
const connectionToDataSource = __importStar(require("./connection-to-datasource"));
|
|
43
|
+
const datasourceExpo = __importStar(require("./datasource-expo"));
|
|
41
44
|
const datasourceMongodb = __importStar(require("./datasource-mongodb"));
|
|
42
45
|
const datasourceMssql = __importStar(require("./datasource-mssql"));
|
|
43
46
|
const datasourceMysqlConnector = __importStar(require("./datasource-mysql-connector"));
|
|
@@ -45,6 +48,8 @@ const datasourceName = __importStar(require("./datasource-name"));
|
|
|
45
48
|
const datasourceSap = __importStar(require("./datasource-sap"));
|
|
46
49
|
const datasourceSqliteOptions = __importStar(require("./datasource-sqlite-options"));
|
|
47
50
|
const datasourceSqliteType = __importStar(require("./datasource-sqlite-type"));
|
|
51
|
+
const fileLogger = __importStar(require("./file-logger"));
|
|
52
|
+
const findOptionsJoin = __importStar(require("./find-options-join"));
|
|
48
53
|
const findOptionsLockModes = __importStar(require("./find-options-lock-modes"));
|
|
49
54
|
const findOptionsStringRelations = __importStar(require("./find-options-string-relations"));
|
|
50
55
|
const findOptionsStringSelect = __importStar(require("./find-options-string-select"));
|
|
@@ -67,13 +72,17 @@ const repositoryFindOneById = __importStar(require("./repository-find-one-by-id"
|
|
|
67
72
|
const useContainer = __importStar(require("./use-container"));
|
|
68
73
|
const transformer_1 = require("../transformer");
|
|
69
74
|
exports.description = "Migrate from v0.3.x to v1.0";
|
|
70
|
-
exports.
|
|
75
|
+
exports.upgradingGuide = "https://typeorm.io/docs/releases/1.0/upgrading-from-0.3";
|
|
71
76
|
/**
|
|
72
77
|
* Ordered list of v1 transforms. Order matters — connection renames
|
|
73
78
|
* must run first so subsequent transforms see DataSource, not Connection.
|
|
79
|
+
* `datasourceName` also runs before `globalFunctions` so it can still see
|
|
80
|
+
* the `createConnection` import while rewriting `createConnection({ name })`
|
|
81
|
+
* arguments before the import is stripped.
|
|
74
82
|
*/
|
|
75
83
|
exports.transforms = [
|
|
76
84
|
connectionToDataSource,
|
|
85
|
+
datasourceName,
|
|
77
86
|
globalFunctions,
|
|
78
87
|
repositoryFindByIds,
|
|
79
88
|
repositoryFindOneById,
|
|
@@ -85,6 +94,7 @@ exports.transforms = [
|
|
|
85
94
|
columnReadonly,
|
|
86
95
|
columnWidthZerofill,
|
|
87
96
|
datasourceSqliteType,
|
|
97
|
+
findOptionsJoin,
|
|
88
98
|
findOptionsLockModes,
|
|
89
99
|
useContainer,
|
|
90
100
|
datasourceMysqlConnector,
|
|
@@ -94,7 +104,6 @@ exports.transforms = [
|
|
|
94
104
|
mongodbTypes,
|
|
95
105
|
datasourceMssql,
|
|
96
106
|
datasourceSap,
|
|
97
|
-
datasourceName,
|
|
98
107
|
columnUnsignedNumeric,
|
|
99
108
|
repositoryAbstract,
|
|
100
109
|
relationCount,
|
|
@@ -104,6 +113,10 @@ exports.transforms = [
|
|
|
104
113
|
queryBuilderReplacePropertyNames,
|
|
105
114
|
findOptionsStringSelect,
|
|
106
115
|
findOptionsStringRelations,
|
|
116
|
+
connectionManager,
|
|
117
|
+
connectionOptionsReader,
|
|
118
|
+
datasourceExpo,
|
|
119
|
+
fileLogger,
|
|
107
120
|
];
|
|
108
121
|
exports.default = (0, transformer_1.transformer)(exports.transforms);
|
|
109
122
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transforms/v1/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAmD;AACnD,iFAAkE;AAClE,6EAA8D;AAC9D,mFAAoE;AACpE,wEAAyD;AACzD,oEAAqD;AACrD,uFAAwE;AACxE,kEAAmD;AACnD,gEAAiD;AACjD,qFAAsE;AACtE,+EAAgE;AAChE,gFAAiE;AACjE,4FAA6E;AAC7E,sFAAuE;AACvE,oEAAqD;AACrD,uEAAwD;AACxD,8DAA+C;AAC/C,8DAA+C;AAC/C,gGAAiF;AACjF,oFAAqE;AACrE,gFAAiE;AACjE,gFAAiE;AACjE,yGAA0F;AAC1F,8FAA+E;AAC/E,iGAAkF;AAClF,gEAAiD;AACjD,0EAA2D;AAC3D,oEAAqD;AACrD,8EAA+D;AAC/D,mFAAoE;AACpE,8DAA+C;AAC/C,gDAA4C;AAE/B,QAAA,WAAW,GAAG,6BAA6B,CAAA;AAC3C,QAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transforms/v1/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAmD;AACnD,iFAAkE;AAClE,6EAA8D;AAC9D,wEAAyD;AACzD,qFAAsE;AACtE,mFAAoE;AACpE,kEAAmD;AACnD,wEAAyD;AACzD,oEAAqD;AACrD,uFAAwE;AACxE,kEAAmD;AACnD,gEAAiD;AACjD,qFAAsE;AACtE,+EAAgE;AAChE,0DAA2C;AAC3C,qEAAsD;AACtD,gFAAiE;AACjE,4FAA6E;AAC7E,sFAAuE;AACvE,oEAAqD;AACrD,uEAAwD;AACxD,8DAA+C;AAC/C,8DAA+C;AAC/C,gGAAiF;AACjF,oFAAqE;AACrE,gFAAiE;AACjE,gFAAiE;AACjE,yGAA0F;AAC1F,8FAA+E;AAC/E,iGAAkF;AAClF,gEAAiD;AACjD,0EAA2D;AAC3D,oEAAqD;AACrD,8EAA+D;AAC/D,mFAAoE;AACpE,8DAA+C;AAC/C,gDAA4C;AAE/B,QAAA,WAAW,GAAG,6BAA6B,CAAA;AAC3C,QAAA,cAAc,GACvB,yDAAyD,CAAA;AAE7D;;;;;;GAMG;AACU,QAAA,UAAU,GAAG;IACtB,sBAAsB;IACtB,cAAc;IACd,eAAe;IACf,mBAAmB;IACnB,qBAAqB;IACrB,eAAe;IACf,oBAAoB;IACpB,gBAAgB;IAChB,4BAA4B;IAC5B,2BAA2B;IAC3B,cAAc;IACd,mBAAmB;IACnB,oBAAoB;IACpB,eAAe;IACf,oBAAoB;IACpB,YAAY;IACZ,wBAAwB;IACxB,uBAAuB;IACvB,iBAAiB;IACjB,YAAY;IACZ,YAAY;IACZ,eAAe;IACf,aAAa;IACb,qBAAqB;IACrB,kBAAkB;IAClB,aAAa;IACb,sBAAsB;IACtB,oBAAoB;IACpB,4BAA4B;IAC5B,gCAAgC;IAChC,uBAAuB;IACvB,0BAA0B;IAC1B,iBAAiB;IACjB,uBAAuB;IACvB,cAAc;IACd,UAAU;CACb,CAAA;AAED,kBAAe,IAAA,yBAAW,EAAC,kBAAU,CAAC,CAAA"}
|
|
@@ -10,26 +10,42 @@ const stats_1 = require("../stats");
|
|
|
10
10
|
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
11
11
|
exports.description = "flag removed `getAllMigrations()` for manual migration";
|
|
12
12
|
exports.manual = true;
|
|
13
|
+
const MESSAGE = "`getAllMigrations()` was removed — use `getPendingMigrations()`, `getExecutedMigrations()`, or `dataSource.migrations` instead";
|
|
14
|
+
// Node types on which a leading line-comment survives jscodeshift/recast
|
|
15
|
+
// printing — walking up to one of these keeps the comment visible above
|
|
16
|
+
// the enclosing statement or declaration.
|
|
17
|
+
const isTodoHost = (type) => type.endsWith("Statement") ||
|
|
18
|
+
type === "VariableDeclaration" ||
|
|
19
|
+
type === "ExportDefaultDeclaration" ||
|
|
20
|
+
type === "ExportNamedDeclaration" ||
|
|
21
|
+
type === "ClassProperty" ||
|
|
22
|
+
type === "PropertyDefinition";
|
|
13
23
|
const migrationsGetAll = (file, api) => {
|
|
14
24
|
const j = api.jscodeshift;
|
|
15
25
|
const root = j(file.source);
|
|
16
26
|
let hasChanges = false;
|
|
27
|
+
let hasTodos = false;
|
|
17
28
|
root.find(j.CallExpression, {
|
|
18
29
|
callee: {
|
|
19
30
|
type: "MemberExpression",
|
|
20
31
|
property: { name: "getAllMigrations" },
|
|
21
32
|
},
|
|
22
|
-
}).forEach((
|
|
23
|
-
// Add a TODO comment before the statement
|
|
24
|
-
const statement = j(path).closest(j.ExpressionStatement);
|
|
25
|
-
if (statement.length > 0) {
|
|
26
|
-
statement.forEach((stmtPath) => {
|
|
27
|
-
(0, todo_1.addTodoComment)(stmtPath.node, "`getAllMigrations()` was removed — use `getPendingMigrations()`, `getExecutedMigrations()`, or `dataSource.migrations` instead", j);
|
|
28
|
-
});
|
|
29
|
-
}
|
|
33
|
+
}).forEach((callPath) => {
|
|
30
34
|
hasChanges = true;
|
|
35
|
+
let current = callPath.parent;
|
|
36
|
+
while (current) {
|
|
37
|
+
const node = current.node;
|
|
38
|
+
if (isTodoHost(node.type)) {
|
|
39
|
+
if (!(0, todo_1.hasTodoComment)(node, MESSAGE)) {
|
|
40
|
+
(0, todo_1.addTodoComment)(node, MESSAGE, j);
|
|
41
|
+
hasTodos = true;
|
|
42
|
+
}
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
current = current.parent;
|
|
46
|
+
}
|
|
31
47
|
});
|
|
32
|
-
if (
|
|
48
|
+
if (hasTodos)
|
|
33
49
|
stats_1.stats.count.todo(api, exports.name, file);
|
|
34
50
|
return hasChanges ? root.toSource() : undefined;
|
|
35
51
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations-get-all.js","sourceRoot":"","sources":["../../../src/transforms/v1/migrations-get-all.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"migrations-get-all.js","sourceRoot":"","sources":["../../../src/transforms/v1/migrations-get-all.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,kCAAwD;AACxD,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,wDAAwD,CAAA;AAC/C,QAAA,MAAM,GAAG,IAAI,CAAA;AAE1B,MAAM,OAAO,GACT,gIAAgI,CAAA;AAEpI,yEAAyE;AACzE,wEAAwE;AACxE,0CAA0C;AAC1C,MAAM,UAAU,GAAG,CAAC,IAAY,EAAW,EAAE,CACzC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IAC1B,IAAI,KAAK,qBAAqB;IAC9B,IAAI,KAAK,0BAA0B;IACnC,IAAI,KAAK,wBAAwB;IACjC,IAAI,KAAK,eAAe;IACxB,IAAI,KAAK,oBAAoB,CAAA;AAE1B,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;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,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,QAAQ,EAAE,EAAE;QACpB,UAAU,GAAG,IAAI,CAAA;QACjB,IAAI,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAA;QAC7B,OAAO,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,GAAS,OAAO,CAAC,IAAI,CAAA;YAC/B,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,IAAI,CAAC,IAAA,qBAAc,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;oBACjC,IAAA,qBAAc,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;oBAChC,QAAQ,GAAG,IAAI,CAAA;gBACnB,CAAC;gBACD,OAAM;YACV,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ;QAAE,aAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,YAAI,EAAE,IAAI,CAAC,CAAA;IAE/C,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA9BY,QAAA,gBAAgB,oBA8B5B;AAEY,QAAA,EAAE,GAAG,wBAAgB,CAAA;AAClC,kBAAe,UAAE,CAAA"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fn = exports.mongodbStats = exports.manual = exports.description = exports.name = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const ast_helpers_1 = require("../ast-helpers");
|
|
8
9
|
const todo_1 = require("../todo");
|
|
9
10
|
const stats_1 = require("../stats");
|
|
10
11
|
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
@@ -13,32 +14,41 @@ exports.manual = true;
|
|
|
13
14
|
const mongodbStats = (file, api) => {
|
|
14
15
|
const j = api.jscodeshift;
|
|
15
16
|
const root = j(file.source);
|
|
17
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
18
|
+
return undefined;
|
|
19
|
+
const bindings = (0, ast_helpers_1.collectRepositoryBindings)(root, j);
|
|
16
20
|
let hasChanges = false;
|
|
17
21
|
let hasTodos = false;
|
|
18
22
|
const message = "`stats()` was removed — use the MongoDB driver directly";
|
|
19
|
-
// Find .stats() calls
|
|
20
23
|
root.find(j.CallExpression, {
|
|
21
24
|
callee: {
|
|
22
25
|
type: "MemberExpression",
|
|
23
26
|
property: { type: "Identifier", name: "stats" },
|
|
24
27
|
},
|
|
25
|
-
}).forEach((
|
|
26
|
-
const
|
|
28
|
+
}).forEach((callPath) => {
|
|
29
|
+
const callee = callPath.node.callee;
|
|
30
|
+
if (callee.type !== "MemberExpression")
|
|
31
|
+
return;
|
|
32
|
+
if (!(0, ast_helpers_1.isRepositoryReceiver)(callee.object, bindings))
|
|
33
|
+
return;
|
|
34
|
+
// Prefer attaching the comment to the enclosing statement. Comments
|
|
35
|
+
// on bare CallExpressions are often dropped by recast during printing.
|
|
36
|
+
let host = callPath.node;
|
|
37
|
+
const parentNode = callPath.parent.node;
|
|
27
38
|
if (parentNode.type === "ExpressionStatement") {
|
|
28
|
-
|
|
39
|
+
host = parentNode;
|
|
29
40
|
}
|
|
30
41
|
else if (parentNode.type === "AwaitExpression") {
|
|
31
|
-
const grandparentNode =
|
|
42
|
+
const grandparentNode = callPath.parent.parent.node;
|
|
32
43
|
if (grandparentNode.type === "ExpressionStatement") {
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
(0, todo_1.addTodoComment)(path.node, message, j);
|
|
44
|
+
host = grandparentNode;
|
|
37
45
|
}
|
|
38
46
|
}
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
if ((0, todo_1.hasTodoComment)(host, message)) {
|
|
48
|
+
hasChanges = true;
|
|
49
|
+
return;
|
|
41
50
|
}
|
|
51
|
+
(0, todo_1.addTodoComment)(host, message, j);
|
|
42
52
|
hasChanges = true;
|
|
43
53
|
hasTodos = true;
|
|
44
54
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-stats.js","sourceRoot":"","sources":["../../../src/transforms/v1/mongodb-stats.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"mongodb-stats.js","sourceRoot":"","sources":["../../../src/transforms/v1/mongodb-stats.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAIuB;AACvB,kCAAwD;AACxD,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GAAG,6CAA6C,CAAA;AAC3D,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,YAAY,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACrD,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1D,MAAM,QAAQ,GAAG,IAAA,uCAAyB,EAAC,IAAI,EAAE,CAAC,CAAC,CAAA;IAEnD,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,OAAO,GAAG,yDAAyD,CAAA;IAEzE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,cAAc,EAAE;QACxB,MAAM,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,QAAQ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I,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA/CY,QAAA,YAAY,gBA+CxB;AAEY,QAAA,EAAE,GAAG,oBAAY,CAAA;AAC9B,kBAAe,UAAE,CAAA"}
|
|
@@ -55,14 +55,12 @@ const mongodbTypes = (file, api) => {
|
|
|
55
55
|
if (movedSpecifiers.length === 0)
|
|
56
56
|
return;
|
|
57
57
|
hasChanges = true;
|
|
58
|
-
// Update or remove the typeorm import
|
|
59
58
|
if (remaining?.length === 0) {
|
|
60
59
|
j(importPath).remove();
|
|
61
60
|
}
|
|
62
61
|
else if (remaining) {
|
|
63
62
|
importPath.node.specifiers = remaining;
|
|
64
63
|
}
|
|
65
|
-
// Check if there's already a mongodb import
|
|
66
64
|
const existingMongoImport = root.find(j.ImportDeclaration, {
|
|
67
65
|
source: { value: "mongodb" },
|
|
68
66
|
});
|
|
@@ -76,6 +74,65 @@ const mongodbTypes = (file, api) => {
|
|
|
76
74
|
createNewImport(j, root, importPath, movedSpecifiers);
|
|
77
75
|
}
|
|
78
76
|
});
|
|
77
|
+
// Move re-exports from typeorm to mongodb (barrel-file pattern).
|
|
78
|
+
// `export { ObjectId } from "typeorm"` → `export { ObjectId } from "mongodb"`.
|
|
79
|
+
root.find(j.ExportNamedDeclaration, {
|
|
80
|
+
source: { value: "typeorm" },
|
|
81
|
+
}).forEach((exportPath) => {
|
|
82
|
+
const moved = [];
|
|
83
|
+
const remaining = exportPath.node.specifiers?.filter((spec) => {
|
|
84
|
+
if (spec.type === "ExportSpecifier" &&
|
|
85
|
+
spec.local?.type === "Identifier" &&
|
|
86
|
+
movedTypes.has(spec.local.name)) {
|
|
87
|
+
moved.push(spec);
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return true;
|
|
91
|
+
});
|
|
92
|
+
if (moved.length === 0)
|
|
93
|
+
return;
|
|
94
|
+
hasChanges = true;
|
|
95
|
+
if (remaining?.length === 0) {
|
|
96
|
+
j(exportPath).remove();
|
|
97
|
+
}
|
|
98
|
+
else if (remaining) {
|
|
99
|
+
exportPath.node.specifiers = remaining;
|
|
100
|
+
}
|
|
101
|
+
// Merge into an existing `export { ... } from "mongodb"` if present —
|
|
102
|
+
// appending a fresh declaration unconditionally would produce a
|
|
103
|
+
// duplicate named export and fail at parse time. Skip type-only
|
|
104
|
+
// declarations (`export type { ... }`) because `ObjectId` is a runtime
|
|
105
|
+
// value; merging into a type-only export would strip its runtime form.
|
|
106
|
+
const sourceNode = exportPath.node;
|
|
107
|
+
const existingMongoExport = root
|
|
108
|
+
.find(j.ExportNamedDeclaration, {
|
|
109
|
+
source: { value: "mongodb" },
|
|
110
|
+
})
|
|
111
|
+
.filter((p) => p.node.exportKind !== "type");
|
|
112
|
+
if (existingMongoExport.length > 0) {
|
|
113
|
+
const existingPath = existingMongoExport.at(0).get();
|
|
114
|
+
const existingNames = new Set(existingPath.node.specifiers
|
|
115
|
+
?.filter((s) => s.type === "ExportSpecifier" &&
|
|
116
|
+
s.local?.type === "Identifier")
|
|
117
|
+
.map((s) => s.local?.name ?? "") ?? []);
|
|
118
|
+
for (const spec of moved) {
|
|
119
|
+
if (spec.type === "ExportSpecifier" &&
|
|
120
|
+
spec.local?.type === "Identifier" &&
|
|
121
|
+
!existingNames.has(spec.local.name)) {
|
|
122
|
+
existingPath.node.specifiers?.push(spec);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
const newExport = j.exportNamedDeclaration(null, moved, j.stringLiteral("mongodb"));
|
|
128
|
+
// Preserve the source declaration's exportKind so moved `export type`
|
|
129
|
+
// specifiers don't get silently promoted to value exports.
|
|
130
|
+
if (sourceNode.exportKind) {
|
|
131
|
+
newExport.exportKind = sourceNode.exportKind;
|
|
132
|
+
}
|
|
133
|
+
exportPath.insertAfter(newExport);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
79
136
|
return hasChanges ? root.toSource() : undefined;
|
|
80
137
|
};
|
|
81
138
|
exports.mongodbTypes = mongodbTypes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mongodb-types.js","sourceRoot":"","sources":["../../../src/transforms/v1/mongodb-types.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;
|
|
1
|
+
{"version":3,"file":"mongodb-types.js","sourceRoot":"","sources":["../../../src/transforms/v1/mongodb-types.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAYf,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GAAG,oDAAoD,CAAA;AAU/E,MAAM,mBAAmB,GAAG,CACxB,QAAoC,EACpC,eAAkC,EACpC,EAAE;IACA,MAAM,aAAa,GAAG,IAAI,GAAG,CACzB,QAAQ,CAAC,IAAI,CAAC,UAAU;QACpB,EAAE,MAAM,CACJ,CAAC,CAAC,EAAwB,EAAE,CACxB,CAAC,CAAC,IAAI,KAAK,iBAAiB;QAC5B,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY,CACvC;SACA,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,CACzC,CAAA;IAED,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACzC,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACxC,CAAC;IACL,CAAC;AACL,CAAC,CAAA;AAED,MAAM,eAAe,GAAG,CACpB,CAAc,EACd,IAAgB,EAChB,UAAsC,EACtC,eAAkC,EACpC,EAAE;IACA,MAAM,SAAS,GAAG,CAAC,CAAC,iBAAiB,CACjC,eAAe,EACf,CAAC,CA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CAAC,CAAA;AA/HY,QAAA,YAAY,gBA+HxB;AAEY,QAAA,EAAE,GAAG,oBAAY,CAAA;AAC9B,kBAAe,UAAE,CAAA"}
|
|
@@ -11,6 +11,8 @@ exports.description = "rename `setNativeParameters()` to `setParameters()`";
|
|
|
11
11
|
const queryBuilderNativeParameters = (file, api) => {
|
|
12
12
|
const j = api.jscodeshift;
|
|
13
13
|
const root = j(file.source);
|
|
14
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
15
|
+
return undefined;
|
|
14
16
|
const hasChanges = (0, ast_helpers_1.renameMemberMethod)(root, j, "setNativeParameters", "setParameters");
|
|
15
17
|
return hasChanges ? root.toSource() : undefined;
|
|
16
18
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder-native-parameters.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-native-parameters.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"query-builder-native-parameters.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-native-parameters.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAoE;AAEvD,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GAAG,qDAAqD,CAAA;AAEzE,MAAM,4BAA4B,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACrE,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1D,MAAM,UAAU,GAAG,IAAA,gCAAkB,EACjC,IAAI,EACJ,CAAC,EACD,qBAAqB,EACrB,eAAe,CAClB,CAAA;IAED,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AAdY,QAAA,4BAA4B,gCAcxC;AAEY,QAAA,EAAE,GAAG,oCAA4B,CAAA;AAC9C,kBAAe,UAAE,CAAA"}
|
|
@@ -11,9 +11,27 @@ const stats_1 = require("../stats");
|
|
|
11
11
|
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
12
12
|
exports.description = "flag removed `onConflict()` for manual migration to `orIgnore()` / `orUpdate()`";
|
|
13
13
|
exports.manual = true;
|
|
14
|
+
// Walks up from `startPath` and returns the first statement-like ancestor
|
|
15
|
+
// a leading line-comment survives recast printing on. Returns null when no
|
|
16
|
+
// such ancestor is reachable (caller should skip the comment rather than
|
|
17
|
+
// attach it to a CallExpression, where it would be silently dropped).
|
|
18
|
+
const findTodoHost = (startPath) => {
|
|
19
|
+
let current = startPath.parent;
|
|
20
|
+
while (current) {
|
|
21
|
+
const nodeType = current.node.type;
|
|
22
|
+
if (nodeType.endsWith("Statement") ||
|
|
23
|
+
nodeType === "VariableDeclaration") {
|
|
24
|
+
return current.node;
|
|
25
|
+
}
|
|
26
|
+
current = current.parent;
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
14
30
|
const queryBuilderOnConflict = (file, api) => {
|
|
15
31
|
const j = api.jscodeshift;
|
|
16
32
|
const root = j(file.source);
|
|
33
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
34
|
+
return undefined;
|
|
17
35
|
let hasChanges = false;
|
|
18
36
|
let hasTodos = false;
|
|
19
37
|
root.find(j.CallExpression, {
|
|
@@ -21,30 +39,26 @@ const queryBuilderOnConflict = (file, api) => {
|
|
|
21
39
|
type: "MemberExpression",
|
|
22
40
|
property: { type: "Identifier", name: "onConflict" },
|
|
23
41
|
},
|
|
24
|
-
}).forEach((
|
|
25
|
-
const arg =
|
|
42
|
+
}).forEach((callPath) => {
|
|
43
|
+
const arg = callPath.node.arguments[0];
|
|
26
44
|
const argValue = arg ? (0, ast_helpers_1.getStringValue)(arg) : null;
|
|
27
45
|
if (argValue && /DO\s+NOTHING/i.test(argValue)) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
path.node.arguments = [];
|
|
46
|
+
if (callPath.node.callee.type === "MemberExpression") {
|
|
47
|
+
callPath.node.callee.property = j.identifier("orIgnore");
|
|
48
|
+
callPath.node.arguments = [];
|
|
32
49
|
hasChanges = true;
|
|
33
50
|
}
|
|
51
|
+
return;
|
|
34
52
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
(0, todo_1.addTodoComment)(path.node, message, j);
|
|
44
|
-
}
|
|
45
|
-
hasChanges = true;
|
|
46
|
-
hasTodos = true;
|
|
53
|
+
const message = "`onConflict()` was removed — use `orIgnore()` or `orUpdate()` instead";
|
|
54
|
+
const host = findTodoHost(callPath);
|
|
55
|
+
if (!host)
|
|
56
|
+
return;
|
|
57
|
+
if (!(0, todo_1.hasTodoComment)(host, message)) {
|
|
58
|
+
(0, todo_1.addTodoComment)(host, message, j);
|
|
47
59
|
}
|
|
60
|
+
hasChanges = true;
|
|
61
|
+
hasTodos = true;
|
|
48
62
|
});
|
|
49
63
|
if (hasTodos)
|
|
50
64
|
stats_1.stats.count.todo(api, exports.name, file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder-on-conflict.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-on-conflict.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"query-builder-on-conflict.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-on-conflict.ts"],"names":[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AACnD,CAAC,CAAA;AAzCY,QAAA,sBAAsB,0BAyClC;AAEY,QAAA,EAAE,GAAG,8BAAsB,CAAA;AACxC,kBAAe,UAAE,CAAA"}
|
|
@@ -5,11 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fn = exports.queryBuilderOrUpdate = exports.description = exports.name = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const ast_helpers_1 = require("../ast-helpers");
|
|
8
9
|
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
9
10
|
exports.description = "replace object-style `orUpdate()` with array-style signature";
|
|
10
11
|
const queryBuilderOrUpdate = (file, api) => {
|
|
11
12
|
const j = api.jscodeshift;
|
|
12
13
|
const root = j(file.source);
|
|
14
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
15
|
+
return undefined;
|
|
13
16
|
let hasChanges = false;
|
|
14
17
|
// Find .orUpdate({ conflict_target: [...], overwrite: [...] })
|
|
15
18
|
root.find(j.CallExpression, {
|
|
@@ -29,12 +32,13 @@ const queryBuilderOrUpdate = (file, api) => {
|
|
|
29
32
|
for (const prop of arg.properties) {
|
|
30
33
|
if (prop.type !== "ObjectProperty")
|
|
31
34
|
continue;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const keyName = prop.key.type === "Identifier"
|
|
36
|
+
? prop.key.name
|
|
37
|
+
: (0, ast_helpers_1.getStringValue)(prop.key);
|
|
38
|
+
if (keyName === "conflict_target") {
|
|
35
39
|
conflictTarget = prop.value;
|
|
36
40
|
}
|
|
37
|
-
else if (
|
|
41
|
+
else if (keyName === "overwrite") {
|
|
38
42
|
overwrite = prop.value;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder-or-update.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-or-update.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;
|
|
1
|
+
{"version":3,"file":"query-builder-or-update.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-or-update.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAgE;AAEnD,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,8DAA8D,CAAA;AAE3D,MAAM,oBAAoB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1D,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,GAAmC,IAAI,CAAA;QACzD,IAAI,SAAS,GAAmC,IAAI,CAAA;QAEpD,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,IAAI,CAAC,IAAI,KAAK,gBAAgB;gBAAE,SAAQ;YAE5C,MAAM,OAAO,GACT,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;gBAC1B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI;gBACf,CAAC,CAAC,IAAA,4BAAc,EAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAElC,IAAI,OAAO,KAAK,iBAAiB,EAAE,CAAC;gBAChC,cAAc,GAAG,IAAI,CAAC,KAAK,CAAA;YAC/B,CAAC;iBAAM,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;gBACjC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAA;YAC1B,CAAC;QACL,CAAC;QAED,IAAI,CAAC,cAAc,IAAI,CAAC,SAAS;YAAE,OAAM;QAEzC,yDAAyD;QACzD,mFAAmF;QACnF,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG;YAClB,SAAS;YACT,cAAc;SACa,CAAA;QAC/B,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;AAnDY,QAAA,oBAAoB,wBAmDhC;AAEY,QAAA,EAAE,GAAG,4BAAoB,CAAA;AACtC,kBAAe,UAAE,CAAA"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fn = exports.queryBuilderPrintSql = exports.manual = exports.description = exports.name = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const ast_helpers_1 = require("../ast-helpers");
|
|
8
9
|
const todo_1 = require("../todo");
|
|
9
10
|
const stats_1 = require("../stats");
|
|
10
11
|
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
@@ -13,6 +14,8 @@ exports.manual = true;
|
|
|
13
14
|
const queryBuilderPrintSql = (file, api) => {
|
|
14
15
|
const j = api.jscodeshift;
|
|
15
16
|
const root = j(file.source);
|
|
17
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
18
|
+
return undefined;
|
|
16
19
|
let hasChanges = false;
|
|
17
20
|
let hasTodos = false;
|
|
18
21
|
const message = "`printSql()` was removed — use `getSql()` or `getQueryAndParameters()` to inspect SQL";
|
|
@@ -21,23 +24,26 @@ const queryBuilderPrintSql = (file, api) => {
|
|
|
21
24
|
type: "MemberExpression",
|
|
22
25
|
property: { name: "printSql" },
|
|
23
26
|
},
|
|
24
|
-
}).forEach((
|
|
25
|
-
// Walk up to
|
|
26
|
-
|
|
27
|
+
}).forEach((callPath) => {
|
|
28
|
+
// Walk up to the enclosing statement (ExpressionStatement or
|
|
29
|
+
// VariableDeclaration). If we reach the root without finding one,
|
|
30
|
+
// leave the file untouched — attaching a comment to a non-statement
|
|
31
|
+
// node is usually dropped by recast, and `hasChanges = true` with no
|
|
32
|
+
// actual edit would misreport the transform as having emitted a comment.
|
|
33
|
+
let current = callPath.parent;
|
|
27
34
|
while (current) {
|
|
28
35
|
const node = current.node;
|
|
29
|
-
if (node.type === "ExpressionStatement"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
if (node.type === "ExpressionStatement" ||
|
|
37
|
+
node.type === "VariableDeclaration") {
|
|
38
|
+
if (!(0, todo_1.hasTodoComment)(node, message)) {
|
|
39
|
+
(0, todo_1.addTodoComment)(node, message, j);
|
|
40
|
+
}
|
|
41
|
+
hasChanges = true;
|
|
42
|
+
hasTodos = true;
|
|
43
|
+
return;
|
|
36
44
|
}
|
|
37
45
|
current = current.parent;
|
|
38
46
|
}
|
|
39
|
-
hasChanges = true;
|
|
40
|
-
hasTodos = true;
|
|
41
47
|
});
|
|
42
48
|
if (hasTodos)
|
|
43
49
|
stats_1.stats.count.todo(api, exports.name, file);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder-print-sql.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-print-sql.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"query-builder-print-sql.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-print-sql.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAgD;AAChD,kCAAwD;AACxD,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,0FAA0F,CAAA;AACjF,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,oBAAoB,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IAC7D,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1D,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,OAAO,GACT,uFAAuF,CAAA;IAE3F,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,QAAQ,EAAE,EAAE;QACpB,6DAA6D;QAC7D,kEAAkE;QAClE,oEAAoE;QACpE,qEAAqE;QACrE,yEAAyE;QACzE,IAAI,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAA;QAC7B,OAAO,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,GAAS,OAAO,CAAC,IAAI,CAAA;YAC/B,IACI,IAAI,CAAC,IAAI,KAAK,qBAAqB;gBACnC,IAAI,CAAC,IAAI,KAAK,qBAAqB,EACrC,CAAC;gBACC,IAAI,CAAC,IAAA,qBAAc,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;oBACjC,IAAA,qBAAc,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;gBACpC,CAAC;gBACD,UAAU,GAAG,IAAI,CAAA;gBACjB,QAAQ,GAAG,IAAI,CAAA;gBACf,OAAM;YACV,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,MAAM,CAAA;QAC5B,CAAC;IACL,CAAC,CAAC,CAAA;IAEF,IAAI,QAAQ;QAAE,aAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,YAAI,EAAE,IAAI,CAAC,CAAA;IAE/C,OAAO,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAA;AACnD,CAAC,CAAA;AA5CY,QAAA,oBAAoB,wBA4ChC;AAEY,QAAA,EAAE,GAAG,4BAAoB,CAAA;AACtC,kBAAe,UAAE,CAAA"}
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fn = exports.queryBuilderReplacePropertyNames = exports.manual = exports.description = exports.name = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const ast_helpers_1 = require("../ast-helpers");
|
|
8
9
|
const todo_1 = require("../todo");
|
|
9
10
|
const stats_1 = require("../stats");
|
|
10
11
|
exports.name = node_path_1.default.basename(__filename, node_path_1.default.extname(__filename));
|
|
@@ -13,25 +14,28 @@ exports.manual = true;
|
|
|
13
14
|
const queryBuilderReplacePropertyNames = (file, api) => {
|
|
14
15
|
const j = api.jscodeshift;
|
|
15
16
|
const root = j(file.source);
|
|
17
|
+
if (!(0, ast_helpers_1.fileImportsFrom)(root, j, "typeorm"))
|
|
18
|
+
return undefined;
|
|
16
19
|
let hasChanges = false;
|
|
17
20
|
let hasTodos = false;
|
|
18
|
-
// Find method declarations named replacePropertyNames in classes
|
|
19
21
|
const message = "`replacePropertyNames` was removed — property name replacement is now handled internally";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const flag = (node) => {
|
|
23
|
+
if ((0, todo_1.hasTodoComment)(node, message)) {
|
|
24
|
+
hasChanges = true;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
(0, todo_1.addTodoComment)(node, message, j);
|
|
24
28
|
hasChanges = true;
|
|
25
29
|
hasTodos = true;
|
|
26
|
-
}
|
|
27
|
-
|
|
30
|
+
};
|
|
31
|
+
root.find(j.ClassMethod, {
|
|
32
|
+
key: { type: "Identifier", name: "replacePropertyNames" },
|
|
33
|
+
}).forEach((p) => flag(p.node));
|
|
34
|
+
// MethodDefinition is an alternative AST shape some parsers emit for the
|
|
35
|
+
// same construct; cover both so the transform is parser-agnostic.
|
|
28
36
|
root.find(j.MethodDefinition, {
|
|
29
37
|
key: { type: "Identifier", name: "replacePropertyNames" },
|
|
30
|
-
}).forEach((
|
|
31
|
-
(0, todo_1.addTodoComment)(path.node, message, j);
|
|
32
|
-
hasChanges = true;
|
|
33
|
-
hasTodos = true;
|
|
34
|
-
});
|
|
38
|
+
}).forEach((p) => flag(p.node));
|
|
35
39
|
if (hasTodos)
|
|
36
40
|
stats_1.stats.count.todo(api, exports.name, file);
|
|
37
41
|
return hasChanges ? root.toSource() : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder-replace-property-names.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-replace-property-names.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,
|
|
1
|
+
{"version":3,"file":"query-builder-replace-property-names.js","sourceRoot":"","sources":["../../../src/transforms/v1/query-builder-replace-property-names.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAE5B,gDAAgD;AAChD,kCAAwD;AACxD,oCAAgC;AAEnB,QAAA,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAA;AAC1D,QAAA,WAAW,GACpB,gEAAgE,CAAA;AACvD,QAAA,MAAM,GAAG,IAAI,CAAA;AAEnB,MAAM,gCAAgC,GAAG,CAAC,IAAc,EAAE,GAAQ,EAAE,EAAE;IACzE,MAAM,CAAC,GAAG,GAAG,CAAC,WAAW,CAAA;IACzB,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAE3B,IAAI,CAAC,IAAA,6BAAe,EAAC,IAAI,EAAE,CAAC,EAAE,SAAS,CAAC;QAAE,OAAO,SAAS,CAAA;IAE1D,IAAI,UAAU,GAAG,KAAK,CAAA;IACtB,IAAI,QAAQ,GAAG,KAAK,CAAA;IAEpB,MAAM,OAAO,GACT,0FAA0F,CAAA;IAE9F,MAAM,IAAI,GAAG,CAAC,IAAU,EAAQ,EAAE;QAC9B,IAAI,IAAA,qBAAc,EAAC,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC;YAChC,UAAU,GAAG,IAAI,CAAA;YACjB,OAAM;QACV,CAAC;QACD,IAAA,qBAAc,EAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAA;QAChC,UAAU,GAAG,IAAI,CAAA;QACjB,QAAQ,GAAG,IAAI,CAAA;IACnB,CAAC,CAAA;IAED,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,EAAE;QACrB,GAAG,EAAE,EAAE,IAAI,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