typeorm 0.3.27-dev.9cdfb20 → 0.3.27-dev.fa3cd43

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.
@@ -86,6 +86,7 @@ export class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} implements
86
86
  const exportMethod = esm ? "export" : "module.exports =";
87
87
  return `/**
88
88
  * @typedef {import('typeorm').MigrationInterface} MigrationInterface
89
+ * @typedef {import('typeorm').QueryRunner} QueryRunner
89
90
  */
90
91
 
91
92
  /**
@@ -94,9 +95,15 @@ export class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} implements
94
95
  */
95
96
  ${exportMethod} class ${(0, StringUtils_1.camelCase)(name, true)}${timestamp} {
96
97
 
98
+ /**
99
+ * @param {QueryRunner} queryRunner
100
+ */
97
101
  async up(queryRunner) {
98
102
  }
99
103
 
104
+ /**
105
+ * @param {QueryRunner} queryRunner
106
+ */
100
107
  async down(queryRunner) {
101
108
  }
102
109
 
@@ -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;IAoH9C,CAAC;IAlHG,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,GAAG,EAAE;YACT,KAAK,EAAE,UAAU;YACjB,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EACJ,+DAA+D;SACtE,CAAC;aACD,MAAM,CAAC,KAAK,EAAE;YACX,IAAI,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,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAC7C,mCAAmC,CACvC,CAAA;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,6BAAa,CAAC,SAAS,CAAC,kCAAkC,EAAE,GAAG,CAAC,CAAA;YAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACnB,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,2BAA2B;IAC3B,4EAA4E;IAE5E;;OAEG;IACO,MAAM,CAAC,WAAW,CAAC,IAAY,EAAE,SAAiB;QACxD,OAAO;;eAEA,IAAA,uBAAS,EACZ,IAAI,EACJ,IAAI,CACP,GAAG,SAAS;;;;;;;;;CASpB,CAAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB,EACjB,GAAY;QAEZ,MAAM,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAA;QACxD,OAAO;;;;;;;;EAQb,YAAY,UAAU,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,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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AC,kBAAkB,CAAA;QACxD,OAAO;;;;;;;;;EASb,YAAY,UAAU,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS;;;;;;;;;;;;;;;CAexD,CAAA;IACG,CAAC;CACJ;AA7HD,wDA6HC","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 * @typedef {import('typeorm').QueryRunner} QueryRunner\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} class ${camelCase(name, true)}${timestamp} {\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async up(queryRunner) {\n }\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async down(queryRunner) {\n }\n\n}\n`\n }\n}\n"],"sourceRoot":".."}
@@ -196,6 +196,7 @@ ${downSqls.join(`
196
196
  const exportMethod = esm ? "export" : "module.exports =";
197
197
  return `/**
198
198
  * @typedef {import('typeorm').MigrationInterface} MigrationInterface
199
+ * @typedef {import('typeorm').QueryRunner} QueryRunner
199
200
  */
200
201
 
201
202
  /**
@@ -205,11 +206,17 @@ ${downSqls.join(`
205
206
  ${exportMethod} class ${migrationName} {
206
207
  name = '${migrationName}'
207
208
 
209
+ /**
210
+ * @param {QueryRunner} queryRunner
211
+ */
208
212
  async up(queryRunner) {
209
213
  ${upSqls.join(`
210
214
  `)}
211
215
  }
212
216
 
217
+ /**
218
+ * @param {QueryRunner} queryRunner
219
+ */
213
220
  async down(queryRunner) {
214
221
  ${downSqls.join(`
215
222
  `)}
@@ -1 +1 @@
1
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AAA;IACG,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,qBAAqB,CAClC,IAAY,EACZ,SAAiB,EACjB,MAAgB,EAChB,QAAkB,EAClB,GAAY;QAEZ,MAAM,aAAa,GAAG,GAAG,IAAA,uBAAS,EAAC,IAAI,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,CAAA;QAE5D,MAAM,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAA;QAExD,OAAO;;;;;;;;EAQb,YAAY,UAAU,aAAa;cACvB,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;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":".."}
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;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AAS,EAAE,CAAA;QAE5D,MAAM,YAAY,GAAG,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAA;QAExD,OAAO;;;;;;;;;EASb,YAAY,UAAU,aAAa;cACvB,aAAa;;;;;;EAMzB,MAAM,CAAC,IAAI,CAAC;CACb,CAAC;;;;;;;EAOA,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;AAzSD,4DAySC","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 * @typedef {import('typeorm').QueryRunner} QueryRunner\n */\n\n/**\n * @class\n * @implements {MigrationInterface}\n */\n${exportMethod} class ${migrationName} {\n name = '${migrationName}'\n\n /**\n * @param {QueryRunner} queryRunner\n */\n async up(queryRunner) {\n${upSqls.join(`\n`)}\n }\n\n /**\n * @param {QueryRunner} queryRunner\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.27-dev.9cdfb20", "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", "react-native": { "default": "./browser/index.js" }, "node": { "types": "./index.d.ts", "import": "./index.mjs", "require": "./index.js" }, "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", "docs:dev": "cd docs && npm run start", "format": "prettier --cache --write \"./**/*.ts\"", "format:ci": "prettier --check \"./**/*.ts\"", "lint": "eslint .", "pack": "gulp pack", "package": "gulp package", "pre-commit": "lint-staged", "prepare": "husky", "publish:preview": "pkg-pr-new publish './build/package' --pnpm --template='./sample/playground'", "test": "npm run compile && npm run test:fast --", "test:ci": "mocha --bail", "test:fast": "mocha", "typecheck": "tsc --noEmit", "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", "dedent": "^1.6.0", "dotenv": "^16.4.7", "glob": "^10.4.5", "sha.js": "^2.4.12", "sql-highlight": "^6.0.0", "tslib": "^2.8.1", "uuid": "^11.1.0", "yargs": "^17.7.2" }, "devDependencies": { "@eslint/js": "^9.29.0", "@sap/hana-client": "^2.25.22", "@tsconfig/node16": "^16.1.4", "@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.29.0", "globals": "^16.2.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", "husky": "^9.1.7", "lint-staged": "^15.5.2", "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", "pkg-pr-new": "^0.0.43", "prettier": "^2.8.8", "redis": "^5.7.0", "reflect-metadata": "^0.2.2", "remap-istanbul": "^0.13.0", "rimraf": "^5.0.10", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "sort-package-json": "^2.15.1", "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.3", "typescript-eslint": "^8.34.1" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", "@sap/hana-client": "^2.14.22", "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0", "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 || ^5.0.14", "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 }, "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" ] }
1
+ { "name": "typeorm", "version": "0.3.27-dev.fa3cd43", "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", "react-native": { "default": "./browser/index.js" }, "node": { "types": "./index.d.ts", "import": "./index.mjs", "require": "./index.js" }, "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", "docs:dev": "cd docs && npm run start", "format": "prettier --cache --write \"./**/*.ts\"", "format:ci": "prettier --check \"./**/*.ts\"", "lint": "eslint .", "pack": "gulp pack", "package": "gulp package", "pre-commit": "lint-staged", "prepare": "husky", "publish:preview": "pkg-pr-new publish './build/package' --pnpm --template='./sample/playground'", "test": "npm run compile && npm run test:fast --", "test:ci": "mocha --bail", "test:fast": "mocha", "typecheck": "tsc --noEmit", "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", "dedent": "^1.6.0", "dotenv": "^16.4.7", "glob": "^10.4.5", "sha.js": "^2.4.12", "sql-highlight": "^6.0.0", "tslib": "^2.8.1", "uuid": "^11.1.0", "yargs": "^17.7.2" }, "devDependencies": { "@eslint/js": "^9.29.0", "@sap/hana-client": "^2.25.22", "@tsconfig/node16": "^16.1.4", "@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.29.0", "globals": "^16.2.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", "husky": "^9.1.7", "lint-staged": "^15.5.2", "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", "pkg-pr-new": "^0.0.43", "prettier": "^2.8.8", "redis": "^5.7.0", "reflect-metadata": "^0.2.2", "remap-istanbul": "^0.13.0", "rimraf": "^5.0.10", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "sort-package-json": "^2.15.1", "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.3", "typescript-eslint": "^8.34.1" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0 || ^6.0.0 || ^7.0.0", "@sap/hana-client": "^2.14.22", "better-sqlite3": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0", "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 || ^5.0.14", "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 }, "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" ] }