typeorm 0.3.23-dev.6ebae3b → 0.3.23-dev.c15cb07
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/browser/subscriber/event/UpdateEvent.d.ts +4 -0
- package/browser/subscriber/event/UpdateEvent.js.map +1 -1
- package/commands/MigrationCreateCommand.d.ts +3 -1
- package/commands/MigrationCreateCommand.js +17 -3
- package/commands/MigrationCreateCommand.js.map +1 -1
- package/commands/MigrationGenerateCommand.d.ts +3 -1
- package/commands/MigrationGenerateCommand.js +17 -3
- package/commands/MigrationGenerateCommand.js.map +1 -1
- package/package.json +1 -1
- package/subscriber/event/UpdateEvent.d.ts +4 -0
- package/subscriber/event/UpdateEvent.js.map +1 -1
|
@@ -25,6 +25,8 @@ export interface UpdateEvent<Entity> {
|
|
|
25
25
|
manager: EntityManager;
|
|
26
26
|
/**
|
|
27
27
|
* Updating entity.
|
|
28
|
+
*
|
|
29
|
+
* Contains the same data that was passed to the updating method, be it the instance of an entity or the partial entity.
|
|
28
30
|
*/
|
|
29
31
|
entity: ObjectLiteral | undefined;
|
|
30
32
|
/**
|
|
@@ -33,6 +35,8 @@ export interface UpdateEvent<Entity> {
|
|
|
33
35
|
metadata: EntityMetadata;
|
|
34
36
|
/**
|
|
35
37
|
* Updating entity in the database.
|
|
38
|
+
*
|
|
39
|
+
* Is set only when one of the following methods are used: .save(), .remove(), .softRemove(), and .recover()
|
|
36
40
|
*/
|
|
37
41
|
databaseEntity: Entity;
|
|
38
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../browser/src/subscriber/event/UpdateEvent.ts"],"names":[],"mappings":"","file":"UpdateEvent.js","sourcesContent":["import { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../../metadata/RelationMetadata\"\nimport { EntityManager } from \"../../entity-manager/EntityManager\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\n\n/**\n * UpdateEvent is an object that broadcaster sends to the entity subscriber when entity is being updated in the database.\n */\nexport interface UpdateEvent<Entity> {\n /**\n * Connection used in the event.\n */\n connection: DataSource\n\n /**\n * QueryRunner used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this query runner instance.\n */\n queryRunner: QueryRunner\n\n /**\n * EntityManager used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this entity manager instance.\n */\n manager: EntityManager\n\n /**\n * Updating entity.\n */\n entity: ObjectLiteral | undefined\n\n /**\n * Metadata of the entity.\n */\n metadata: EntityMetadata\n\n /**\n * Updating entity in the database.\n */\n databaseEntity: Entity\n\n /**\n * List of updated columns. In query builder has no affected\n */\n updatedColumns: ColumnMetadata[]\n\n /**\n * List of updated relations. In query builder has no affected\n */\n updatedRelations: RelationMetadata[]\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../browser/src/subscriber/event/UpdateEvent.ts"],"names":[],"mappings":"","file":"UpdateEvent.js","sourcesContent":["import { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../../metadata/RelationMetadata\"\nimport { EntityManager } from \"../../entity-manager/EntityManager\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\n\n/**\n * UpdateEvent is an object that broadcaster sends to the entity subscriber when entity is being updated in the database.\n */\nexport interface UpdateEvent<Entity> {\n /**\n * Connection used in the event.\n */\n connection: DataSource\n\n /**\n * QueryRunner used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this query runner instance.\n */\n queryRunner: QueryRunner\n\n /**\n * EntityManager used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this entity manager instance.\n */\n manager: EntityManager\n\n /**\n * Updating entity.\n *\n * Contains the same data that was passed to the updating method, be it the instance of an entity or the partial entity.\n */\n entity: ObjectLiteral | undefined\n\n /**\n * Metadata of the entity.\n */\n metadata: EntityMetadata\n\n /**\n * Updating entity in the database.\n *\n * Is set only when one of the following methods are used: .save(), .remove(), .softRemove(), and .recover()\n */\n databaseEntity: Entity\n\n /**\n * List of updated columns. In query builder has no affected\n */\n updatedColumns: ColumnMetadata[]\n\n /**\n * List of updated relations. In query builder has no affected\n */\n updatedRelations: RelationMetadata[]\n}\n"],"sourceRoot":"../.."}
|
|
@@ -9,6 +9,8 @@ export declare class MigrationCreateCommand implements yargs.CommandModule {
|
|
|
9
9
|
path: string;
|
|
10
10
|
} & {
|
|
11
11
|
o: boolean;
|
|
12
|
+
} & {
|
|
13
|
+
esm: boolean;
|
|
12
14
|
} & {
|
|
13
15
|
t: number | boolean;
|
|
14
16
|
}>;
|
|
@@ -22,5 +24,5 @@ export declare class MigrationCreateCommand implements yargs.CommandModule {
|
|
|
22
24
|
/**
|
|
23
25
|
* Gets contents of the migration file in Javascript.
|
|
24
26
|
*/
|
|
25
|
-
protected static getJavascriptTemplate(name: string, timestamp: number): string;
|
|
27
|
+
protected static getJavascriptTemplate(name: string, timestamp: number, esm: boolean): string;
|
|
26
28
|
}
|
|
@@ -27,6 +27,11 @@ class MigrationCreateCommand {
|
|
|
27
27
|
type: "boolean",
|
|
28
28
|
default: false,
|
|
29
29
|
describe: "Generate a migration file on Javascript instead of Typescript",
|
|
30
|
+
})
|
|
31
|
+
.option("esm", {
|
|
32
|
+
type: "boolean",
|
|
33
|
+
default: false,
|
|
34
|
+
describe: "Generate a migration file on ESM instead of CommonJS",
|
|
30
35
|
})
|
|
31
36
|
.option("t", {
|
|
32
37
|
alias: "timestamp",
|
|
@@ -44,7 +49,7 @@ class MigrationCreateCommand {
|
|
|
44
49
|
const filename = path_1.default.basename(inputPath);
|
|
45
50
|
const fullPath = path_1.default.dirname(inputPath) + "/" + timestamp + "-" + filename;
|
|
46
51
|
const fileContent = args.outputJs
|
|
47
|
-
? MigrationCreateCommand.getJavascriptTemplate(filename, timestamp)
|
|
52
|
+
? MigrationCreateCommand.getJavascriptTemplate(filename, timestamp, args.esm)
|
|
48
53
|
: MigrationCreateCommand.getTemplate(filename, timestamp);
|
|
49
54
|
await CommandUtils_1.CommandUtils.createFile(fullPath + (args.outputJs ? ".js" : ".ts"), fileContent);
|
|
50
55
|
console.log(`Migration ${ansis_1.default.blue(fullPath + (args.outputJs ? ".js" : ".ts"))} has been generated successfully.`);
|
|
@@ -77,8 +82,17 @@ export class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} implements
|
|
|
77
82
|
/**
|
|
78
83
|
* Gets contents of the migration file in Javascript.
|
|
79
84
|
*/
|
|
80
|
-
static getJavascriptTemplate(name, timestamp) {
|
|
81
|
-
|
|
85
|
+
static getJavascriptTemplate(name, timestamp, esm) {
|
|
86
|
+
const exportMethod = esm ? "export" : "module.exports =";
|
|
87
|
+
return `/**
|
|
88
|
+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
|
|
89
|
+
*/
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @class
|
|
93
|
+
* @implements {MigrationInterface}
|
|
94
|
+
*/
|
|
95
|
+
${exportMethod} class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} {
|
|
82
96
|
|
|
83
97
|
async up(queryRunner) {
|
|
84
98
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/MigrationCreateCommand.ts"],"names":[],"mappings":";;;;AAAA,0DAAwB;AACxB,wDAAuB;AAEvB,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,sBAAsB;IAAnC;QACI,YAAO,GAAG,yBAAyB,CAAA;QACnC,aAAQ,GAAG,+BAA+B,CAAA;
|
|
1
|
+
{"version":3,"sources":["../../src/commands/MigrationCreateCommand.ts"],"names":[],"mappings":";;;;AAAA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CAAC,GAAG,SAAS;;;;;;;;;CASxD,CAAA;IACG,CAAC;CACJ;AAtHD,wDAsHC","file":"MigrationCreateCommand.js","sourcesContent":["import ansi from \"ansis\"\nimport path from \"path\"\nimport yargs from \"yargs\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Creates a new migration file.\n */\nexport class MigrationCreateCommand implements yargs.CommandModule {\n command = \"migration:create <path>\"\n describe = \"Creates a new migration file.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"esm\", {\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on ESM instead of CommonJS\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n try {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const inputPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = path.basename(inputPath)\n const fullPath =\n path.dirname(inputPath) + \"/\" + timestamp + \"-\" + filename\n\n const fileContent = args.outputJs\n ? MigrationCreateCommand.getJavascriptTemplate(\n filename,\n timestamp,\n args.esm,\n )\n : MigrationCreateCommand.getTemplate(filename, timestamp)\n\n await CommandUtils.createFile(\n fullPath + (args.outputJs ? \".js\" : \".ts\"),\n fileContent,\n )\n console.log(\n `Migration ${ansi.blue(\n fullPath + (args.outputJs ? \".js\" : \".ts\"),\n )} has been generated successfully.`,\n )\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration creation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(name: string, timestamp: number): string {\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${camelCase(\n name,\n true,\n )}${timestamp} implements MigrationInterface {\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n esm: boolean,\n ): string {\n const exportMethod = esm ? \"export\" : \"module.exports =\"\n return `/**\n * @typedef {import('typeorm').MigrationInterface} MigrationInterface\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} class ${camelCase(name, true)}${timestamp} {\n\n async up(queryRunner) {\n }\n\n async down(queryRunner) {\n }\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
|
|
@@ -13,6 +13,8 @@ export declare class MigrationGenerateCommand implements yargs.CommandModule {
|
|
|
13
13
|
p: boolean;
|
|
14
14
|
} & {
|
|
15
15
|
o: boolean;
|
|
16
|
+
} & {
|
|
17
|
+
esm: boolean;
|
|
16
18
|
} & {
|
|
17
19
|
dr: boolean;
|
|
18
20
|
} & {
|
|
@@ -34,7 +36,7 @@ export declare class MigrationGenerateCommand implements yargs.CommandModule {
|
|
|
34
36
|
/**
|
|
35
37
|
* Gets contents of the migration file in Javascript.
|
|
36
38
|
*/
|
|
37
|
-
protected static getJavascriptTemplate(name: string, timestamp: number, upSqls: string[], downSqls: string[]): string;
|
|
39
|
+
protected static getJavascriptTemplate(name: string, timestamp: number, upSqls: string[], downSqls: string[], esm: boolean): string;
|
|
38
40
|
/**
|
|
39
41
|
*
|
|
40
42
|
*/
|
|
@@ -41,6 +41,11 @@ class MigrationGenerateCommand {
|
|
|
41
41
|
type: "boolean",
|
|
42
42
|
default: false,
|
|
43
43
|
describe: "Generate a migration file on Javascript instead of Typescript",
|
|
44
|
+
})
|
|
45
|
+
.option("esm", {
|
|
46
|
+
type: "boolean",
|
|
47
|
+
default: false,
|
|
48
|
+
describe: "Generate a migration file on ESM instead of CommonJS",
|
|
44
49
|
})
|
|
45
50
|
.option("dr", {
|
|
46
51
|
alias: "dryrun",
|
|
@@ -125,7 +130,7 @@ class MigrationGenerateCommand {
|
|
|
125
130
|
process_1.default.exit(1);
|
|
126
131
|
}
|
|
127
132
|
const fileContent = args.outputJs
|
|
128
|
-
? MigrationGenerateCommand.getJavascriptTemplate(path_1.default.basename(fullPath), timestamp, upSqls, downSqls.reverse())
|
|
133
|
+
? MigrationGenerateCommand.getJavascriptTemplate(path_1.default.basename(fullPath), timestamp, upSqls, downSqls.reverse(), args.esm)
|
|
129
134
|
: MigrationGenerateCommand.getTemplate(path_1.default.basename(fullPath), timestamp, upSqls, downSqls.reverse());
|
|
130
135
|
if (args.check) {
|
|
131
136
|
console.log(ansis_1.default.yellow `Unexpected changes in database schema were found in check mode:\n\n${ansis_1.default.white(fileContent)}`);
|
|
@@ -186,9 +191,18 @@ ${downSqls.join(`
|
|
|
186
191
|
/**
|
|
187
192
|
* Gets contents of the migration file in Javascript.
|
|
188
193
|
*/
|
|
189
|
-
static getJavascriptTemplate(name, timestamp, upSqls, downSqls) {
|
|
194
|
+
static getJavascriptTemplate(name, timestamp, upSqls, downSqls, esm) {
|
|
190
195
|
const migrationName = `${(0, StringUtils_1.camelCase)(name, true)}${timestamp}`;
|
|
191
|
-
|
|
196
|
+
const exportMethod = esm ? "export" : "module.exports =";
|
|
197
|
+
return `/**
|
|
198
|
+
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
|
|
199
|
+
*/
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* @class
|
|
203
|
+
* @implements {MigrationInterface}
|
|
204
|
+
*/
|
|
205
|
+
${exportMethod} class ${migrationName} {
|
|
192
206
|
name = '${migrationName}'
|
|
193
207
|
|
|
194
208
|
async up(queryRunner) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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AAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,OAAO,0BAA0B,aAAa;cACxC,aAAa;;;EAGzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;EAIA,QAAQ,CAAC,IAAI,CAAC;CACf,CAAC;;;CAGD,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,aAAa,CAAC,KAAa;QACxC,MAAM,cAAc,GAAG,IAAA,qBAAM,EAAC,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;QACxD,OAAO,CACH,IAAI,GAAG,cAAc,CAAC,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AAhRD,4DAgRC","file":"MigrationGenerateCommand.js","sourcesContent":["import { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replaceAll(\"`\", \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replaceAll(\"`\", \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n ansi.green`No changes in database schema were found`,\n )\n process.exit(0)\n } else {\n console.log(\n ansi.yellow`No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(ansi.yellow`Please specify a migration path`)\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n ansi.yellow`Unexpected changes in database schema were found in check mode:\\n\\n${ansi.white(\n fileContent,\n )}`,\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n ansi.green(\n `Migration ${ansi.blue(\n fullPath + extension,\n )} has content:\\n\\n${ansi.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n ansi.green`Migration ${ansi.blue(\n migrationFileName,\n )} has been generated successfully.`,\n )\n if (args.exitProcess !== false) {\n process.exit(0)\n }\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `module.exports = class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
|
|
1
|
+
{"version":3,"sources":["../../src/commands/MigrationGenerateCommand.ts"],"names":[],"mappings":";;;;AAAA,uEAA6D;AAC7D,0DAAwB;AACxB,wDAAuB;AACvB,8DAA6B;AAG7B,6DAAyD;AACzD,qDAA+C;AAC/C,iDAA6C;AAE7C;;GAEG;AACH,MAAa,wBAAwB;IAArC;QACI,YAAO,GAAG,2BAA2B,CAAA;QACrC,aAAQ,GACJ,gFAAgF,CAAA;IA+RxF,CAAC;IA7RG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,UAAU,CAAC,MAAM,EAAE;YAChB,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,4BAA4B;YACtC,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,YAAY,EAAE;YAClB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EACJ,6DAA6D;YACjE,YAAY,EAAE,IAAI;SACrB,CAAC;aACD,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,SAAS;YACf,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AO,CAAC,KAAK,EAAE,cAAc,CAAC,GAAG,YAAY,CACtE,CAAA;IACL,CAAC;CACJ;AAlSD,4DAkSC","file":"MigrationGenerateCommand.js","sourcesContent":["import { format } from \"@sqltools/formatter/lib/sqlFormatter\"\nimport ansi from \"ansis\"\nimport path from \"path\"\nimport process from \"process\"\nimport yargs from \"yargs\"\nimport { DataSource } from \"../data-source\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { camelCase } from \"../util/StringUtils\"\nimport { CommandUtils } from \"./CommandUtils\"\n\n/**\n * Generates a new migration file with sql needs to be executed to update schema.\n */\nexport class MigrationGenerateCommand implements yargs.CommandModule {\n command = \"migration:generate <path>\"\n describe =\n \"Generates a new migration file with sql needs to be executed to update schema.\"\n\n builder(args: yargs.Argv) {\n return args\n .positional(\"path\", {\n type: \"string\",\n describe: \"Path of the migration file\",\n demandOption: true,\n })\n .option(\"dataSource\", {\n alias: \"d\",\n type: \"string\",\n describe:\n \"Path to the file where your DataSource instance is defined.\",\n demandOption: true,\n })\n .option(\"p\", {\n alias: \"pretty\",\n type: \"boolean\",\n default: false,\n describe: \"Pretty-print generated SQL\",\n })\n .option(\"o\", {\n alias: \"outputJs\",\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on Javascript instead of Typescript\",\n })\n .option(\"esm\", {\n type: \"boolean\",\n default: false,\n describe:\n \"Generate a migration file on ESM instead of CommonJS\",\n })\n .option(\"dr\", {\n alias: \"dryrun\",\n type: \"boolean\",\n default: false,\n describe:\n \"Prints out the contents of the migration instead of writing it to a file\",\n })\n .option(\"ch\", {\n alias: \"check\",\n type: \"boolean\",\n default: false,\n describe:\n \"Verifies that the current database is up to date and that no migrations are needed. Otherwise exits with code 1.\",\n })\n .option(\"t\", {\n alias: \"timestamp\",\n type: \"number\",\n default: false,\n describe: \"Custom timestamp for the migration name\",\n })\n }\n\n async handler(args: yargs.Arguments<any & { path: string }>) {\n const timestamp = CommandUtils.getTimestamp(args.timestamp)\n const extension = args.outputJs ? \".js\" : \".ts\"\n const fullPath = args.path.startsWith(\"/\")\n ? args.path\n : path.resolve(process.cwd(), args.path)\n const filename = timestamp + \"-\" + path.basename(fullPath) + extension\n\n let dataSource: DataSource | undefined = undefined\n try {\n dataSource = await CommandUtils.loadDataSource(\n path.resolve(process.cwd(), args.dataSource as string),\n )\n dataSource.setOptions({\n synchronize: false,\n migrationsRun: false,\n dropSchema: false,\n logging: false,\n })\n await dataSource.initialize()\n\n const upSqls: string[] = [],\n downSqls: string[] = []\n\n try {\n const sqlInMemory = await dataSource.driver\n .createSchemaBuilder()\n .log()\n\n if (args.pretty) {\n sqlInMemory.upQueries.forEach((upQuery) => {\n upQuery.query = MigrationGenerateCommand.prettifyQuery(\n upQuery.query,\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downQuery.query =\n MigrationGenerateCommand.prettifyQuery(\n downQuery.query,\n )\n })\n }\n\n sqlInMemory.upQueries.forEach((upQuery) => {\n upSqls.push(\n \" await queryRunner.query(`\" +\n upQuery.query.replaceAll(\"`\", \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n upQuery.parameters,\n ) +\n \");\",\n )\n })\n sqlInMemory.downQueries.forEach((downQuery) => {\n downSqls.push(\n \" await queryRunner.query(`\" +\n downQuery.query.replaceAll(\"`\", \"\\\\`\") +\n \"`\" +\n MigrationGenerateCommand.queryParams(\n downQuery.parameters,\n ) +\n \");\",\n )\n })\n } finally {\n await dataSource.destroy()\n }\n\n if (!upSqls.length) {\n if (args.check) {\n console.log(\n ansi.green`No changes in database schema were found`,\n )\n process.exit(0)\n } else {\n console.log(\n ansi.yellow`No changes in database schema were found - cannot generate a migration. To create a new empty migration use \"typeorm migration:create\" command`,\n )\n process.exit(1)\n }\n } else if (!args.path) {\n console.log(ansi.yellow`Please specify a migration path`)\n process.exit(1)\n }\n\n const fileContent = args.outputJs\n ? MigrationGenerateCommand.getJavascriptTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n args.esm,\n )\n : MigrationGenerateCommand.getTemplate(\n path.basename(fullPath),\n timestamp,\n upSqls,\n downSqls.reverse(),\n )\n\n if (args.check) {\n console.log(\n ansi.yellow`Unexpected changes in database schema were found in check mode:\\n\\n${ansi.white(\n fileContent,\n )}`,\n )\n process.exit(1)\n }\n\n if (args.dryrun) {\n console.log(\n ansi.green(\n `Migration ${ansi.blue(\n fullPath + extension,\n )} has content:\\n\\n${ansi.white(fileContent)}`,\n ),\n )\n } else {\n const migrationFileName =\n path.dirname(fullPath) + \"/\" + filename\n await CommandUtils.createFile(migrationFileName, fileContent)\n\n console.log(\n ansi.green`Migration ${ansi.blue(\n migrationFileName,\n )} has been generated successfully.`,\n )\n if (args.exitProcess !== false) {\n process.exit(0)\n }\n }\n } catch (err) {\n PlatformTools.logCmdErr(\"Error during migration generation:\", err)\n process.exit(1)\n }\n }\n\n // -------------------------------------------------------------------------\n // Protected Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Formats query parameters for migration queries if parameters actually exist\n */\n protected static queryParams(parameters: any[] | undefined): string {\n if (!parameters || !parameters.length) {\n return \"\"\n }\n\n return `, ${JSON.stringify(parameters)}`\n }\n\n /**\n * Gets contents of the migration file.\n */\n protected static getTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n return `import { MigrationInterface, QueryRunner } from \"typeorm\";\n\nexport class ${migrationName} implements MigrationInterface {\n name = '${migrationName}'\n\n public async up(queryRunner: QueryRunner): Promise<void> {\n${upSqls.join(`\n`)}\n }\n\n public async down(queryRunner: QueryRunner): Promise<void> {\n${downSqls.join(`\n`)}\n }\n\n}\n`\n }\n\n /**\n * Gets contents of the migration file in Javascript.\n */\n protected static getJavascriptTemplate(\n name: string,\n timestamp: number,\n upSqls: string[],\n downSqls: string[],\n esm: boolean,\n ): string {\n const migrationName = `${camelCase(name, true)}${timestamp}`\n\n const exportMethod = esm ? \"export\" : \"module.exports =\"\n\n return `/**\n * @typedef {import('typeorm').MigrationInterface} MigrationInterface\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} class ${migrationName} {\n name = '${migrationName}'\n\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n async down(queryRunner) {\n${downSqls.join(`\n`)}\n }\n}\n`\n }\n\n /**\n *\n */\n protected static prettifyQuery(query: string) {\n const formattedQuery = format(query, { indent: \" \" })\n return (\n \"\\n\" + formattedQuery.replace(/^/gm, \" \") + \"\\n \"\n )\n }\n}\n"],"sourceRoot":".."}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "name": "typeorm", "version": "0.3.23-dev.
|
|
1
|
+
{ "name": "typeorm", "version": "0.3.23-dev.c15cb07", "private": false, "description": "Data-Mapper ORM for TypeScript and ES2021+. Supports MySQL/MariaDB, PostgreSQL, MS SQL Server, Oracle, SAP HANA, SQLite, MongoDB databases.", "homepage": "https://typeorm.io", "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "funding": "https://opencollective.com/typeorm", "license": "MIT", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "exports": { ".": { "types": "./index.d.ts", "node": { "import": "./index.mjs", "require": "./index.js", "types": "./index.d.ts" }, "browser": { "require": "./index.js", "import": "./browser/index.js", "default": "./index.js" } }, "./browser": { "types": "./index.d.ts", "default": "./browser/index.js" }, "./*.js": "./*.js", "./*": { "require": "./*.js", "import": "./*" } }, "main": "./index.js", "module": "./index.mjs", "browser": { "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js", "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/bson.typings.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mongodb/typings.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js", "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js", "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js", "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js", "./index.js": "./browser/index.js", "./index.mjs": "./browser/index.js" }, "types": "./index.d.ts", "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "scripts": { "changelog": "standard-changelog", "compile": "rimraf ./build && tsc", "format": "prettier --cache --write \"./**/*.ts\"", "format:ci": "prettier --check \"./**/*.ts\"", "lint": "eslint .", "pack": "gulp pack", "package": "gulp package", "test": "npm run compile && npm run test:fast --", "test:ci": "mocha --bail", "test:fast": "mocha", "watch": "tsc --watch" }, "dependencies": { "@sqltools/formatter": "^1.2.5", "ansis": "^3.17.0", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "dayjs": "^1.11.13", "debug": "^4.4.0", "dotenv": "^16.4.7", "glob": "^10.4.5", "sha.js": "^2.4.11", "sql-highlight": "^6.0.0", "tslib": "^2.8.1", "uuid": "^11.1.0", "yargs": "^17.7.2" }, "devDependencies": { "@eslint/js": "^9.22.0", "@sap/hana-client": "^2.24.21", "@tsconfig/node16": "^16.1.3", "@types/chai": "^4.3.20", "@types/chai-as-promised": "^7.1.8", "@types/debug": "^4.1.12", "@types/gulp-rename": "^2.0.6", "@types/gulp-sourcemaps": "^0.0.38", "@types/mocha": "^10.0.10", "@types/node": "^16.18.126", "@types/sha.js": "^2.4.4", "@types/sinon": "^10.0.20", "@types/sinon-chai": "^4.0.0", "@types/source-map-support": "^0.5.10", "@types/yargs": "^17.0.33", "better-sqlite3": "^8.7.0", "chai": "^4.5.0", "chai-as-promised": "^7.1.2", "class-transformer": "^0.5.1", "eslint": "^9.22.0", "globals": "^16.0.0", "gulp": "^4.0.2", "gulp-rename": "^2.0.0", "gulp-replace": "^1.1.4", "gulp-shell": "^0.8.0", "gulp-sourcemaps": "^3.0.0", "gulp-typescript": "^6.0.0-alpha.1", "gulpclass": "^0.2.0", "hdb-pool": "^0.1.6", "mocha": "^10.8.2", "mongodb": "^6.15.0", "mssql": "^11.0.1", "mysql": "^2.18.1", "mysql2": "^3.14.0", "nyc": "^17.1.0", "oracledb": "^6.8.0", "pg": "^8.14.1", "pg-query-stream": "^4.8.1", "prettier": "^2.8.8", "redis": "^4.7.0", "remap-istanbul": "^0.13.0", "rimraf": "^5.0.10", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.13.0", "sqlite3": "^5.1.7", "standard-changelog": "^6.0.0", "ts-node": "^10.9.2", "typescript": "^5.8.2", "typescript-eslint": "^8.27.0" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^5.8.0 || ^6.0.0", "mssql": "^9.1.1 || ^10.0.1 || ^11.0.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^6.3.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "reflect-metadata": "^0.1.14 || ^0.2.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.0.0 || ^3.0.0" }, "peerDependenciesMeta": { "@google-cloud/spanner": { "optional": true }, "@sap/hana-client": { "optional": true }, "better-sqlite3": { "optional": true }, "hdb-pool": { "optional": true }, "ioredis": { "optional": true }, "mongodb": { "optional": true }, "mssql": { "optional": true }, "mysql2": { "optional": true }, "oracledb": { "optional": true }, "pg": { "optional": true }, "pg-native": { "optional": true }, "pg-query-stream": { "optional": true }, "redis": { "optional": true }, "sql.js": { "optional": true }, "sqlite3": { "optional": true }, "ts-node": { "optional": true }, "typeorm-aurora-data-api-driver": { "optional": true } }, "engines": { "node": ">=16.13.0" }, "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "readmeFilename": "README.md", "tags": [ "orm", "typescript", "typescript-orm", "mariadb", "mariadb-orm", "mysql", "mysql-orm", "oracle", "oracle-orm", "postgresql", "postgresql-orm", "sap-hana", "sap-hana-orm", "spanner", "cloud-spanner", "cloud-spanner-orm", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm" ] }
|
|
@@ -25,6 +25,8 @@ export interface UpdateEvent<Entity> {
|
|
|
25
25
|
manager: EntityManager;
|
|
26
26
|
/**
|
|
27
27
|
* Updating entity.
|
|
28
|
+
*
|
|
29
|
+
* Contains the same data that was passed to the updating method, be it the instance of an entity or the partial entity.
|
|
28
30
|
*/
|
|
29
31
|
entity: ObjectLiteral | undefined;
|
|
30
32
|
/**
|
|
@@ -33,6 +35,8 @@ export interface UpdateEvent<Entity> {
|
|
|
33
35
|
metadata: EntityMetadata;
|
|
34
36
|
/**
|
|
35
37
|
* Updating entity in the database.
|
|
38
|
+
*
|
|
39
|
+
* Is set only when one of the following methods are used: .save(), .remove(), .softRemove(), and .recover()
|
|
36
40
|
*/
|
|
37
41
|
databaseEntity: Entity;
|
|
38
42
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/subscriber/event/UpdateEvent.ts"],"names":[],"mappings":"","file":"UpdateEvent.js","sourcesContent":["import { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../../metadata/RelationMetadata\"\nimport { EntityManager } from \"../../entity-manager/EntityManager\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\n\n/**\n * UpdateEvent is an object that broadcaster sends to the entity subscriber when entity is being updated in the database.\n */\nexport interface UpdateEvent<Entity> {\n /**\n * Connection used in the event.\n */\n connection: DataSource\n\n /**\n * QueryRunner used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this query runner instance.\n */\n queryRunner: QueryRunner\n\n /**\n * EntityManager used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this entity manager instance.\n */\n manager: EntityManager\n\n /**\n * Updating entity.\n */\n entity: ObjectLiteral | undefined\n\n /**\n * Metadata of the entity.\n */\n metadata: EntityMetadata\n\n /**\n * Updating entity in the database.\n */\n databaseEntity: Entity\n\n /**\n * List of updated columns. In query builder has no affected\n */\n updatedColumns: ColumnMetadata[]\n\n /**\n * List of updated relations. In query builder has no affected\n */\n updatedRelations: RelationMetadata[]\n}\n"],"sourceRoot":"../.."}
|
|
1
|
+
{"version":3,"sources":["../../src/subscriber/event/UpdateEvent.ts"],"names":[],"mappings":"","file":"UpdateEvent.js","sourcesContent":["import { ColumnMetadata } from \"../../metadata/ColumnMetadata\"\nimport { RelationMetadata } from \"../../metadata/RelationMetadata\"\nimport { EntityManager } from \"../../entity-manager/EntityManager\"\nimport { QueryRunner } from \"../../query-runner/QueryRunner\"\nimport { DataSource } from \"../../data-source/DataSource\"\nimport { EntityMetadata } from \"../../metadata/EntityMetadata\"\nimport { ObjectLiteral } from \"../../common/ObjectLiteral\"\n\n/**\n * UpdateEvent is an object that broadcaster sends to the entity subscriber when entity is being updated in the database.\n */\nexport interface UpdateEvent<Entity> {\n /**\n * Connection used in the event.\n */\n connection: DataSource\n\n /**\n * QueryRunner used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this query runner instance.\n */\n queryRunner: QueryRunner\n\n /**\n * EntityManager used in the event transaction.\n * All database operations in the subscribed event listener should be performed using this entity manager instance.\n */\n manager: EntityManager\n\n /**\n * Updating entity.\n *\n * Contains the same data that was passed to the updating method, be it the instance of an entity or the partial entity.\n */\n entity: ObjectLiteral | undefined\n\n /**\n * Metadata of the entity.\n */\n metadata: EntityMetadata\n\n /**\n * Updating entity in the database.\n *\n * Is set only when one of the following methods are used: .save(), .remove(), .softRemove(), and .recover()\n */\n databaseEntity: Entity\n\n /**\n * List of updated columns. In query builder has no affected\n */\n updatedColumns: ColumnMetadata[]\n\n /**\n * List of updated relations. In query builder has no affected\n */\n updatedRelations: RelationMetadata[]\n}\n"],"sourceRoot":"../.."}
|