typeorm 0.3.14-dev.daf1b47 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +0 -1
  2. package/browser/connection/ConnectionOptionsReader.d.ts +0 -1
  3. package/browser/connection/ConnectionOptionsReader.js +0 -15
  4. package/browser/connection/ConnectionOptionsReader.js.map +1 -1
  5. package/browser/globals.d.ts +1 -1
  6. package/browser/globals.js +2 -2
  7. package/browser/globals.js.map +1 -1
  8. package/connection/ConnectionOptionsReader.d.ts +0 -1
  9. package/connection/ConnectionOptionsReader.js +0 -15
  10. package/connection/ConnectionOptionsReader.js.map +1 -1
  11. package/globals.d.ts +1 -1
  12. package/globals.js +2 -2
  13. package/globals.js.map +1 -1
  14. package/package.json +268 -1
  15. package/browser/connection/options-reader/ConnectionOptionsXmlReader.d.ts +0 -16
  16. package/browser/connection/options-reader/ConnectionOptionsXmlReader.js +0 -66
  17. package/browser/connection/options-reader/ConnectionOptionsXmlReader.js.map +0 -1
  18. package/browser/connection/options-reader/ConnectionOptionsYmlReader.d.ts +0 -12
  19. package/browser/connection/options-reader/ConnectionOptionsYmlReader.js +0 -28
  20. package/browser/connection/options-reader/ConnectionOptionsYmlReader.js.map +0 -1
  21. package/connection/options-reader/ConnectionOptionsXmlReader.d.ts +0 -16
  22. package/connection/options-reader/ConnectionOptionsXmlReader.js +0 -70
  23. package/connection/options-reader/ConnectionOptionsXmlReader.js.map +0 -1
  24. package/connection/options-reader/ConnectionOptionsYmlReader.d.ts +0 -12
  25. package/connection/options-reader/ConnectionOptionsYmlReader.js +0 -33
  26. package/connection/options-reader/ConnectionOptionsYmlReader.js.map +0 -1
package/README.md CHANGED
@@ -66,7 +66,6 @@ TypeORM is highly influenced by other ORMs, such as [Hibernate](http://hibernate
66
66
  - Listeners and subscribers (hooks).
67
67
  - Supports closure table pattern.
68
68
  - Schema declaration in models or separate configuration files.
69
- - Connection configuration in json / xml / yml / env formats.
70
69
  - Supports MySQL / MariaDB / Postgres / CockroachDB / SQLite / Microsoft SQL Server / Oracle / SAP Hana / sql.js.
71
70
  - Supports MongoDB NoSQL database.
72
71
  - Works in NodeJS / Browser / Ionic / Cordova / React Native / NativeScript / Expo / Electron platforms.
@@ -1,7 +1,6 @@
1
1
  import { DataSourceOptions } from "../data-source/DataSourceOptions";
2
2
  /**
3
3
  * Reads connection options from the ormconfig.
4
- * Can read from multiple file extensions including env, json, js, xml and yml.
5
4
  */
6
5
  export declare class ConnectionOptionsReader {
7
6
  protected options?: {
@@ -2,14 +2,11 @@ import appRootPath from "app-root-path";
2
2
  import path from "path";
3
3
  import { PlatformTools } from "../platform/PlatformTools";
4
4
  import { ConnectionOptionsEnvReader } from "./options-reader/ConnectionOptionsEnvReader";
5
- import { ConnectionOptionsYmlReader } from "./options-reader/ConnectionOptionsYmlReader";
6
- import { ConnectionOptionsXmlReader } from "./options-reader/ConnectionOptionsXmlReader";
7
5
  import { TypeORMError } from "../error";
8
6
  import { isAbsolute } from "../util/PathUtils";
9
7
  import { importOrRequireFile } from "../util/ImportUtils";
10
8
  /**
11
9
  * Reads connection options from the ormconfig.
12
- * Can read from multiple file extensions including env, json, js, xml and yml.
13
10
  */
14
11
  export class ConnectionOptionsReader {
15
12
  // -------------------------------------------------------------------------
@@ -70,9 +67,6 @@ export class ConnectionOptionsReader {
70
67
  "mts",
71
68
  "cts",
72
69
  "json",
73
- "yml",
74
- "yaml",
75
- "xml",
76
70
  ];
77
71
  // Detect if baseFilePath contains file extension
78
72
  const possibleExtension = this.baseFilePath.substr(this.baseFilePath.lastIndexOf("."));
@@ -119,15 +113,6 @@ export class ConnectionOptionsReader {
119
113
  else if (foundFileFormat === "json") {
120
114
  connectionOptions = require(configFile);
121
115
  }
122
- else if (foundFileFormat === "yml") {
123
- connectionOptions = await new ConnectionOptionsYmlReader().read(configFile);
124
- }
125
- else if (foundFileFormat === "yaml") {
126
- connectionOptions = await new ConnectionOptionsYmlReader().read(configFile);
127
- }
128
- else if (foundFileFormat === "xml") {
129
- connectionOptions = await new ConnectionOptionsXmlReader().read(configFile);
130
- }
131
116
  // normalize and return connection options
132
117
  if (connectionOptions) {
133
118
  return this.normalizeConnectionOptions(connectionOptions);
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/connection/ConnectionOptionsReader.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAA;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAA;AACxF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEzD;;;GAGG;AACH,MAAM,OAAO,uBAAuB;IAChC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,OAWT;QAXS,YAAO,GAAP,OAAO,CAWhB;IACF,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACjC,IAAI,CAAC,OAAO;YACR,MAAM,IAAI,YAAY,CAClB,kEAAkE,CACrE,CAAA;QAEL,OAAO,OAAO,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QAClB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;QACnC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CACjC,CAAC,OAAO,EAAE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CAAC,CAAC,KAAK,GAAG,IAAI,gBAAgB;oBACzD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,IAAI,mBAAmB;oBAC9D,OAAO,CAAC,QAAQ,KAAK,UAAU,EACjC;oBACE,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE;wBACnB,QAAQ,EAAE,IAAI,CAAC,aAAa,GAAG,GAAG,GAAG,OAAO,CAAC,QAAQ;qBACxD,CAAC,CAAA;iBACL;aACJ;QACL,CAAC,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,IAAc,YAAY;QACtB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAChE,CAAC;IAED;;OAEG;IACH,IAAc,aAAa;QACvB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QAE/D,OAAO,WAAW,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,IAAc,cAAc;QACxB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAA;QAElC,OAAO,WAAW,CAAA;IACtB,CAAC;CACJ","file":"ConnectionOptionsReader.js","sourcesContent":["import appRootPath from \"app-root-path\"\nimport path from \"path\"\nimport { DataSourceOptions } from \"../data-source/DataSourceOptions\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { ConnectionOptionsEnvReader } from \"./options-reader/ConnectionOptionsEnvReader\"\nimport { ConnectionOptionsYmlReader } from \"./options-reader/ConnectionOptionsYmlReader\"\nimport { ConnectionOptionsXmlReader } from \"./options-reader/ConnectionOptionsXmlReader\"\nimport { TypeORMError } from \"../error\"\nimport { isAbsolute } from \"../util/PathUtils\"\nimport { importOrRequireFile } from \"../util/ImportUtils\"\n\n/**\n * Reads connection options from the ormconfig.\n * Can read from multiple file extensions including env, json, js, xml and yml.\n */\nexport class ConnectionOptionsReader {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected options?: {\n /**\n * Directory where ormconfig should be read from.\n * By default its your application root (where your app package.json is located).\n */\n root?: string\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n },\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async all(): Promise<DataSourceOptions[]> {\n const options = await this.load()\n if (!options)\n throw new TypeORMError(\n `No connection options were found in any orm configuration files.`,\n )\n\n return options\n }\n\n /**\n * Gets a connection with a given name read from ormconfig.\n * If connection with such name would not be found then it throw error.\n */\n async get(name: string): Promise<DataSourceOptions> {\n const allOptions = await this.all()\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n if (!targetOptions)\n throw new TypeORMError(\n `Cannot find connection ${name} because its not defined in any orm configuration files.`,\n )\n\n return targetOptions\n }\n\n /**\n * Checks if there is a TypeORM configuration file.\n */\n async has(name: string): Promise<boolean> {\n const allOptions = await this.load()\n if (!allOptions) return false\n\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n return !!targetOptions\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<DataSourceOptions[] | undefined> {\n let connectionOptions:\n | DataSourceOptions\n | DataSourceOptions[]\n | undefined = undefined\n\n const fileFormats = [\n \"env\",\n \"js\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"mts\",\n \"cts\",\n \"json\",\n \"yml\",\n \"yaml\",\n \"xml\",\n ]\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = this.baseFilePath.substr(\n this.baseFilePath.lastIndexOf(\".\"),\n )\n const fileExtension = fileFormats.find(\n (extension) => `.${extension}` === possibleExtension,\n )\n\n // try to find any of following configuration formats\n const foundFileFormat =\n fileExtension ||\n fileFormats.find((format) => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format)\n })\n\n // Determine config file name\n const configFile = fileExtension\n ? this.baseFilePath\n : this.baseFilePath + \".\" + foundFileFormat\n\n // if .env file found then load all its variables into process.env using dotenv package\n if (foundFileFormat === \"env\") {\n PlatformTools.dotenv(configFile)\n } else if (PlatformTools.fileExist(this.baseDirectory + \"/.env\")) {\n PlatformTools.dotenv(this.baseDirectory + \"/.env\")\n }\n\n // try to find connection options from any of available sources of configuration\n if (\n PlatformTools.getEnvVariable(\"TYPEORM_CONNECTION\") ||\n PlatformTools.getEnvVariable(\"TYPEORM_URL\")\n ) {\n connectionOptions = await new ConnectionOptionsEnvReader().read()\n } else if (\n foundFileFormat === \"js\" ||\n foundFileFormat === \"mjs\" ||\n foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" ||\n foundFileFormat === \"mts\" ||\n foundFileFormat === \"cts\"\n ) {\n const [importOrRequireResult, moduleSystem] =\n await importOrRequireFile(configFile)\n const configModule = await importOrRequireResult\n\n if (\n moduleSystem === \"esm\" ||\n (configModule &&\n \"__esModule\" in configModule &&\n \"default\" in configModule)\n ) {\n connectionOptions = configModule.default\n } else {\n connectionOptions = configModule\n }\n } else if (foundFileFormat === \"json\") {\n connectionOptions = require(configFile)\n } else if (foundFileFormat === \"yml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(\n configFile,\n )\n } else if (foundFileFormat === \"yaml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(\n configFile,\n )\n } else if (foundFileFormat === \"xml\") {\n connectionOptions = await new ConnectionOptionsXmlReader().read(\n configFile,\n )\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions)\n }\n\n return undefined\n }\n\n /**\n * Normalize connection options.\n */\n protected normalizeConnectionOptions(\n connectionOptions: DataSourceOptions | DataSourceOptions[],\n ): DataSourceOptions[] {\n if (!Array.isArray(connectionOptions))\n connectionOptions = [connectionOptions]\n\n connectionOptions.forEach((options) => {\n options.baseDirectory = this.baseDirectory\n if (options.entities) {\n const entities = (options.entities as any[]).map((entity) => {\n if (\n typeof entity === \"string\" &&\n entity.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + entity\n\n return entity\n })\n Object.assign(connectionOptions, { entities: entities })\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(\n (subscriber) => {\n if (\n typeof subscriber === \"string\" &&\n subscriber.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + subscriber\n\n return subscriber\n },\n )\n Object.assign(connectionOptions, { subscribers: subscribers })\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(\n (migration) => {\n if (\n typeof migration === \"string\" &&\n migration.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + migration\n\n return migration\n },\n )\n Object.assign(connectionOptions, { migrations: migrations })\n }\n\n // make database path file in sqlite relative to package.json\n if (\n options.type === \"sqlite\" ||\n options.type === \"better-sqlite3\"\n ) {\n if (\n typeof options.database === \"string\" &&\n !isAbsolute(options.database) &&\n options.database.substr(0, 1) !== \"/\" && // unix absolute\n options.database.substr(1, 2) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\"\n ) {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database,\n })\n }\n }\n })\n\n return connectionOptions\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName)\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n if (this.options && this.options.root) return this.options.root\n\n return appRootPath.path\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n if (this.options && this.options.configName)\n return this.options.configName\n\n return \"ormconfig\"\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../browser/src/connection/ConnectionOptionsReader.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAA;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAEzD;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAChC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,OAWT;QAXS,YAAO,GAAP,OAAO,CAWhB;IACF,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACjC,IAAI,CAAC,OAAO;YACR,MAAM,IAAI,YAAY,CAClB,kEAAkE,CACrE,CAAA;QAEL,OAAO,OAAO,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QAClB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,GAAG,EAAE,CAAA;QACnC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CACjC,CAAC,OAAO,EAAE,EAAE,CACR,OAAO,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CACrE,CAAA;QACD,IAAI,CAAC,aAAa;YACd,MAAM,IAAI,YAAY,CAClB,0BAA0B,I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AI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QAE/D,OAAO,WAAW,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,IAAc,cAAc;QACxB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAA;QAElC,OAAO,WAAW,CAAA;IACtB,CAAC;CACJ","file":"ConnectionOptionsReader.js","sourcesContent":["import appRootPath from \"app-root-path\"\nimport path from \"path\"\nimport { DataSourceOptions } from \"../data-source/DataSourceOptions\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { ConnectionOptionsEnvReader } from \"./options-reader/ConnectionOptionsEnvReader\"\nimport { TypeORMError } from \"../error\"\nimport { isAbsolute } from \"../util/PathUtils\"\nimport { importOrRequireFile } from \"../util/ImportUtils\"\n\n/**\n * Reads connection options from the ormconfig.\n */\nexport class ConnectionOptionsReader {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected options?: {\n /**\n * Directory where ormconfig should be read from.\n * By default its your application root (where your app package.json is located).\n */\n root?: string\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n },\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async all(): Promise<DataSourceOptions[]> {\n const options = await this.load()\n if (!options)\n throw new TypeORMError(\n `No connection options were found in any orm configuration files.`,\n )\n\n return options\n }\n\n /**\n * Gets a connection with a given name read from ormconfig.\n * If connection with such name would not be found then it throw error.\n */\n async get(name: string): Promise<DataSourceOptions> {\n const allOptions = await this.all()\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n if (!targetOptions)\n throw new TypeORMError(\n `Cannot find connection ${name} because its not defined in any orm configuration files.`,\n )\n\n return targetOptions\n }\n\n /**\n * Checks if there is a TypeORM configuration file.\n */\n async has(name: string): Promise<boolean> {\n const allOptions = await this.load()\n if (!allOptions) return false\n\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n return !!targetOptions\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<DataSourceOptions[] | undefined> {\n let connectionOptions:\n | DataSourceOptions\n | DataSourceOptions[]\n | undefined = undefined\n\n const fileFormats = [\n \"env\",\n \"js\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"mts\",\n \"cts\",\n \"json\",\n ]\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = this.baseFilePath.substr(\n this.baseFilePath.lastIndexOf(\".\"),\n )\n const fileExtension = fileFormats.find(\n (extension) => `.${extension}` === possibleExtension,\n )\n\n // try to find any of following configuration formats\n const foundFileFormat =\n fileExtension ||\n fileFormats.find((format) => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format)\n })\n\n // Determine config file name\n const configFile = fileExtension\n ? this.baseFilePath\n : this.baseFilePath + \".\" + foundFileFormat\n\n // if .env file found then load all its variables into process.env using dotenv package\n if (foundFileFormat === \"env\") {\n PlatformTools.dotenv(configFile)\n } else if (PlatformTools.fileExist(this.baseDirectory + \"/.env\")) {\n PlatformTools.dotenv(this.baseDirectory + \"/.env\")\n }\n\n // try to find connection options from any of available sources of configuration\n if (\n PlatformTools.getEnvVariable(\"TYPEORM_CONNECTION\") ||\n PlatformTools.getEnvVariable(\"TYPEORM_URL\")\n ) {\n connectionOptions = await new ConnectionOptionsEnvReader().read()\n } else if (\n foundFileFormat === \"js\" ||\n foundFileFormat === \"mjs\" ||\n foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" ||\n foundFileFormat === \"mts\" ||\n foundFileFormat === \"cts\"\n ) {\n const [importOrRequireResult, moduleSystem] =\n await importOrRequireFile(configFile)\n const configModule = await importOrRequireResult\n\n if (\n moduleSystem === \"esm\" ||\n (configModule &&\n \"__esModule\" in configModule &&\n \"default\" in configModule)\n ) {\n connectionOptions = configModule.default\n } else {\n connectionOptions = configModule\n }\n } else if (foundFileFormat === \"json\") {\n connectionOptions = require(configFile)\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions)\n }\n\n return undefined\n }\n\n /**\n * Normalize connection options.\n */\n protected normalizeConnectionOptions(\n connectionOptions: DataSourceOptions | DataSourceOptions[],\n ): DataSourceOptions[] {\n if (!Array.isArray(connectionOptions))\n connectionOptions = [connectionOptions]\n\n connectionOptions.forEach((options) => {\n options.baseDirectory = this.baseDirectory\n if (options.entities) {\n const entities = (options.entities as any[]).map((entity) => {\n if (\n typeof entity === \"string\" &&\n entity.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + entity\n\n return entity\n })\n Object.assign(connectionOptions, { entities: entities })\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(\n (subscriber) => {\n if (\n typeof subscriber === \"string\" &&\n subscriber.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + subscriber\n\n return subscriber\n },\n )\n Object.assign(connectionOptions, { subscribers: subscribers })\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(\n (migration) => {\n if (\n typeof migration === \"string\" &&\n migration.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + migration\n\n return migration\n },\n )\n Object.assign(connectionOptions, { migrations: migrations })\n }\n\n // make database path file in sqlite relative to package.json\n if (\n options.type === \"sqlite\" ||\n options.type === \"better-sqlite3\"\n ) {\n if (\n typeof options.database === \"string\" &&\n !isAbsolute(options.database) &&\n options.database.substr(0, 1) !== \"/\" && // unix absolute\n options.database.substr(1, 2) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\"\n ) {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database,\n })\n }\n }\n })\n\n return connectionOptions\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName)\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n if (this.options && this.options.root) return this.options.root\n\n return appRootPath.path\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n if (this.options && this.options.configName)\n return this.options.configName\n\n return \"ormconfig\"\n }\n}\n"],"sourceRoot":".."}
@@ -51,7 +51,7 @@ export declare function createConnection(options: DataSourceOptions): Promise<Da
51
51
  * Creates new connections and registers them in the manager.
52
52
  *
53
53
  * If connection options were not specified, then it will try to create connection automatically,
54
- * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.
54
+ * based on content of ormconfig (json/js/env) file or environment variables.
55
55
  * All connections from the ormconfig will be created.
56
56
  *
57
57
  * @deprecated
@@ -41,7 +41,7 @@ export function getConnectionManager() {
41
41
  * Creates a new connection and registers it in the manager.
42
42
  *
43
43
  * If connection options were not specified, then it will try to create connection automatically,
44
- * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.
44
+ * based on content of ormconfig (json/js/env) file or environment variables.
45
45
  * Only one connection from ormconfig will be created (name "default" or connection without name).
46
46
  *
47
47
  * @deprecated
@@ -57,7 +57,7 @@ export async function createConnection(optionsOrName) {
57
57
  * Creates new connections and registers them in the manager.
58
58
  *
59
59
  * If connection options were not specified, then it will try to create connection automatically,
60
- * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.
60
+ * based on content of ormconfig (json/js/env) file or environment variables.
61
61
  * All connections from the ormconfig will be created.
62
62
  *
63
63
  * @deprecated
@@ -1 +1 @@
1
- {"version":3,"sources":["../browser/src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CA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MAAM,UAAU,iBAAiB,CAC7B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,iBAAiB,CAAS,WAAW,CAAC,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAC/B,gBAA+B,EAC/B,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,kBAAkB,CAAS,WAAW,CAAC,CAAA;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,WAAkC,EAClC,KAAc,EACd,iBAAyB,SAAS;IAElC,IAAI,WAAW,EAAE;QACb,OAAO,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAChE,KAAK,CACR,CAAA;KACJ;IAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAA;AAC7D,CAAC","file":"globals.js","sourcesContent":["import { MetadataArgsStorage } from \"./metadata-args/MetadataArgsStorage\"\nimport { PlatformTools } from \"./platform/PlatformTools\"\nimport { DataSourceOptions } from \"./data-source/DataSourceOptions\"\nimport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\"\nimport { ConnectionManager } from \"./connection/ConnectionManager\"\nimport { getFromContainer } from \"./container\"\nimport { DataSource } from \"./data-source/DataSource\"\nimport { EntityManager } from \"./entity-manager/EntityManager\"\nimport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\"\nimport { SqljsEntityManager } from \"./entity-manager/SqljsEntityManager\"\nimport { EntityTarget } from \"./common/EntityTarget\"\nimport { Repository } from \"./repository/Repository\"\nimport { TreeRepository } from \"./repository/TreeRepository\"\nimport { ObjectType } from \"./common/ObjectType\"\nimport { MongoRepository } from \"./repository/MongoRepository\"\nimport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\"\nimport { ObjectUtils } from \"./util/ObjectUtils\"\nimport { ObjectLiteral } from \"./common/ObjectLiteral\"\n\n/**\n * Gets metadata args storage.\n */\nexport function getMetadataArgsStorage(): MetadataArgsStorage {\n // we should store metadata storage in a global variable otherwise it brings too much problems\n // one of the problem is that if any entity (or any other) will be imported before consumer will call\n // useContainer method with his own container implementation, that entity will be registered in the\n // old old container (default one post probably) and consumer will his entity.\n // calling useContainer before he imports any entity (or any other) is not always convenient.\n // another reason is that when we run migrations typeorm is being called from a global package\n // and it may load entities which register decorators in typeorm of local package\n // this leads to impossibility of usage of entities in migrations and cli related operations\n const globalScope = PlatformTools.getGlobalVariable()\n if (!globalScope.typeormMetadataArgsStorage)\n globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage()\n\n return globalScope.typeormMetadataArgsStorage\n}\n\n/**\n * Reads connection options stored in ormconfig configuration file.\n *\n * @deprecated\n */\nexport async function getConnectionOptions(\n connectionName: string = \"default\",\n): Promise<DataSourceOptions> {\n return new ConnectionOptionsReader().get(connectionName)\n}\n\n/**\n * Gets a ConnectionManager which creates connections.\n *\n * @deprecated\n */\nexport function getConnectionManager(): ConnectionManager {\n return getFromContainer(ConnectionManager)\n}\n\n/**\n * Creates a new connection and registers it in the manager.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(): Promise<DataSource>\n\n/**\n * Creates a new connection from the ormconfig file with a given name.\n *\n * @deprecated\n */\nexport async function createConnection(name: string): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * @deprecated\n */\nexport async function createConnection(\n options: DataSourceOptions,\n): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(\n optionsOrName?: any,\n): Promise<DataSource> {\n const connectionName =\n typeof optionsOrName === \"string\" ? optionsOrName : \"default\"\n const options = ObjectUtils.isObject(optionsOrName)\n ? (optionsOrName as DataSourceOptions)\n : await getConnectionOptions(connectionName)\n return getConnectionManager().create(options).connect()\n}\n\n/**\n * Creates new connections and registers them in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * All connections from the ormconfig will be created.\n *\n * @deprecated\n */\nexport async function createConnections(\n options?: DataSourceOptions[],\n): Promise<DataSource[]> {\n if (!options) options = await new ConnectionOptionsReader().all()\n const connections = options.map((options) =>\n getConnectionManager().create(options),\n )\n // Do not use Promise.all or test 8522 will produce a dangling sqlite connection\n for (const connection of connections) {\n await connection.connect()\n }\n return connections\n}\n\n/**\n * Gets connection from the connection manager.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getConnection(connectionName: string = \"default\"): DataSource {\n return getConnectionManager().get(connectionName)\n}\n\n/**\n * Gets entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getManager(connectionName: string = \"default\"): EntityManager {\n return getConnectionManager().get(connectionName).manager\n}\n\n/**\n * Gets MongoDB entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getMongoManager(\n connectionName: string = \"default\",\n): MongoEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as MongoEntityManager\n}\n\n/**\n * Gets Sqljs entity manager from connection name.\n * \"default\" connection is used, when no name is specified.\n * Only works when Sqljs driver is used.\n *\n * @deprecated\n */\nexport function getSqljsManager(\n connectionName: string = \"default\",\n): SqljsEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as SqljsEntityManager\n}\n\n/**\n * Gets repository for the given entity class.\n *\n * @deprecated\n */\nexport function getRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): Repository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getTreeRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): TreeRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getTreeRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getCustomRepository<T>(\n customRepository: ObjectType<T>,\n connectionName: string = \"default\",\n): T {\n return getConnectionManager()\n .get(connectionName)\n .getCustomRepository(customRepository)\n}\n\n/**\n * Gets mongodb repository for the given entity class or name.\n *\n * @deprecated\n */\nexport function getMongoRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): MongoRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getMongoRepository<Entity>(entityClass)\n}\n\n/**\n * Creates a new query builder.\n *\n * @deprecated\n */\nexport function createQueryBuilder<Entity extends ObjectLiteral>(\n entityClass?: EntityTarget<Entity>,\n alias?: string,\n connectionName: string = \"default\",\n): SelectQueryBuilder<Entity> {\n if (entityClass) {\n return getRepository(entityClass, connectionName).createQueryBuilder(\n alias,\n )\n }\n\n return getConnection(connectionName).createQueryBuilder()\n}\n"],"sourceRoot":"."}
1
+ {"version":3,"sources":["../browser/src/globals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAA;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAA;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,gC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,cAAc,CAAC;SACnB,iBAAiB,CAAS,WAAW,CAAC,CAAA;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAC/B,gBAA+B,EAC/B,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;AAC9C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,kBAAkB,CAAS,WAAW,CAAC,CAAA;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAC9B,WAAkC,EAClC,KAAc,EACd,iBAAyB,SAAS;IAElC,IAAI,WAAW,EAAE;QACb,OAAO,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAChE,KAAK,CACR,CAAA;KACJ;IAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAA;AAC7D,CAAC","file":"globals.js","sourcesContent":["import { MetadataArgsStorage } from \"./metadata-args/MetadataArgsStorage\"\nimport { PlatformTools } from \"./platform/PlatformTools\"\nimport { DataSourceOptions } from \"./data-source/DataSourceOptions\"\nimport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\"\nimport { ConnectionManager } from \"./connection/ConnectionManager\"\nimport { getFromContainer } from \"./container\"\nimport { DataSource } from \"./data-source/DataSource\"\nimport { EntityManager } from \"./entity-manager/EntityManager\"\nimport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\"\nimport { SqljsEntityManager } from \"./entity-manager/SqljsEntityManager\"\nimport { EntityTarget } from \"./common/EntityTarget\"\nimport { Repository } from \"./repository/Repository\"\nimport { TreeRepository } from \"./repository/TreeRepository\"\nimport { ObjectType } from \"./common/ObjectType\"\nimport { MongoRepository } from \"./repository/MongoRepository\"\nimport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\"\nimport { ObjectUtils } from \"./util/ObjectUtils\"\nimport { ObjectLiteral } from \"./common/ObjectLiteral\"\n\n/**\n * Gets metadata args storage.\n */\nexport function getMetadataArgsStorage(): MetadataArgsStorage {\n // we should store metadata storage in a global variable otherwise it brings too much problems\n // one of the problem is that if any entity (or any other) will be imported before consumer will call\n // useContainer method with his own container implementation, that entity will be registered in the\n // old old container (default one post probably) and consumer will his entity.\n // calling useContainer before he imports any entity (or any other) is not always convenient.\n // another reason is that when we run migrations typeorm is being called from a global package\n // and it may load entities which register decorators in typeorm of local package\n // this leads to impossibility of usage of entities in migrations and cli related operations\n const globalScope = PlatformTools.getGlobalVariable()\n if (!globalScope.typeormMetadataArgsStorage)\n globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage()\n\n return globalScope.typeormMetadataArgsStorage\n}\n\n/**\n * Reads connection options stored in ormconfig configuration file.\n *\n * @deprecated\n */\nexport async function getConnectionOptions(\n connectionName: string = \"default\",\n): Promise<DataSourceOptions> {\n return new ConnectionOptionsReader().get(connectionName)\n}\n\n/**\n * Gets a ConnectionManager which creates connections.\n *\n * @deprecated\n */\nexport function getConnectionManager(): ConnectionManager {\n return getFromContainer(ConnectionManager)\n}\n\n/**\n * Creates a new connection and registers it in the manager.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(): Promise<DataSource>\n\n/**\n * Creates a new connection from the ormconfig file with a given name.\n *\n * @deprecated\n */\nexport async function createConnection(name: string): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * @deprecated\n */\nexport async function createConnection(\n options: DataSourceOptions,\n): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/env) file or environment variables.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(\n optionsOrName?: any,\n): Promise<DataSource> {\n const connectionName =\n typeof optionsOrName === \"string\" ? optionsOrName : \"default\"\n const options = ObjectUtils.isObject(optionsOrName)\n ? (optionsOrName as DataSourceOptions)\n : await getConnectionOptions(connectionName)\n return getConnectionManager().create(options).connect()\n}\n\n/**\n * Creates new connections and registers them in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/env) file or environment variables.\n * All connections from the ormconfig will be created.\n *\n * @deprecated\n */\nexport async function createConnections(\n options?: DataSourceOptions[],\n): Promise<DataSource[]> {\n if (!options) options = await new ConnectionOptionsReader().all()\n const connections = options.map((options) =>\n getConnectionManager().create(options),\n )\n // Do not use Promise.all or test 8522 will produce a dangling sqlite connection\n for (const connection of connections) {\n await connection.connect()\n }\n return connections\n}\n\n/**\n * Gets connection from the connection manager.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getConnection(connectionName: string = \"default\"): DataSource {\n return getConnectionManager().get(connectionName)\n}\n\n/**\n * Gets entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getManager(connectionName: string = \"default\"): EntityManager {\n return getConnectionManager().get(connectionName).manager\n}\n\n/**\n * Gets MongoDB entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getMongoManager(\n connectionName: string = \"default\",\n): MongoEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as MongoEntityManager\n}\n\n/**\n * Gets Sqljs entity manager from connection name.\n * \"default\" connection is used, when no name is specified.\n * Only works when Sqljs driver is used.\n *\n * @deprecated\n */\nexport function getSqljsManager(\n connectionName: string = \"default\",\n): SqljsEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as SqljsEntityManager\n}\n\n/**\n * Gets repository for the given entity class.\n *\n * @deprecated\n */\nexport function getRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): Repository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getTreeRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): TreeRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getTreeRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getCustomRepository<T>(\n customRepository: ObjectType<T>,\n connectionName: string = \"default\",\n): T {\n return getConnectionManager()\n .get(connectionName)\n .getCustomRepository(customRepository)\n}\n\n/**\n * Gets mongodb repository for the given entity class or name.\n *\n * @deprecated\n */\nexport function getMongoRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): MongoRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getMongoRepository<Entity>(entityClass)\n}\n\n/**\n * Creates a new query builder.\n *\n * @deprecated\n */\nexport function createQueryBuilder<Entity extends ObjectLiteral>(\n entityClass?: EntityTarget<Entity>,\n alias?: string,\n connectionName: string = \"default\",\n): SelectQueryBuilder<Entity> {\n if (entityClass) {\n return getRepository(entityClass, connectionName).createQueryBuilder(\n alias,\n )\n }\n\n return getConnection(connectionName).createQueryBuilder()\n}\n"],"sourceRoot":"."}
@@ -1,7 +1,6 @@
1
1
  import { DataSourceOptions } from "../data-source/DataSourceOptions";
2
2
  /**
3
3
  * Reads connection options from the ormconfig.
4
- * Can read from multiple file extensions including env, json, js, xml and yml.
5
4
  */
6
5
  export declare class ConnectionOptionsReader {
7
6
  protected options?: {
@@ -6,14 +6,11 @@ const app_root_path_1 = tslib_1.__importDefault(require("app-root-path"));
6
6
  const path_1 = tslib_1.__importDefault(require("path"));
7
7
  const PlatformTools_1 = require("../platform/PlatformTools");
8
8
  const ConnectionOptionsEnvReader_1 = require("./options-reader/ConnectionOptionsEnvReader");
9
- const ConnectionOptionsYmlReader_1 = require("./options-reader/ConnectionOptionsYmlReader");
10
- const ConnectionOptionsXmlReader_1 = require("./options-reader/ConnectionOptionsXmlReader");
11
9
  const error_1 = require("../error");
12
10
  const PathUtils_1 = require("../util/PathUtils");
13
11
  const ImportUtils_1 = require("../util/ImportUtils");
14
12
  /**
15
13
  * Reads connection options from the ormconfig.
16
- * Can read from multiple file extensions including env, json, js, xml and yml.
17
14
  */
18
15
  class ConnectionOptionsReader {
19
16
  // -------------------------------------------------------------------------
@@ -74,9 +71,6 @@ class ConnectionOptionsReader {
74
71
  "mts",
75
72
  "cts",
76
73
  "json",
77
- "yml",
78
- "yaml",
79
- "xml",
80
74
  ];
81
75
  // Detect if baseFilePath contains file extension
82
76
  const possibleExtension = this.baseFilePath.substr(this.baseFilePath.lastIndexOf("."));
@@ -123,15 +117,6 @@ class ConnectionOptionsReader {
123
117
  else if (foundFileFormat === "json") {
124
118
  connectionOptions = require(configFile);
125
119
  }
126
- else if (foundFileFormat === "yml") {
127
- connectionOptions = await new ConnectionOptionsYmlReader_1.ConnectionOptionsYmlReader().read(configFile);
128
- }
129
- else if (foundFileFormat === "yaml") {
130
- connectionOptions = await new ConnectionOptionsYmlReader_1.ConnectionOptionsYmlReader().read(configFile);
131
- }
132
- else if (foundFileFormat === "xml") {
133
- connectionOptions = await new ConnectionOptionsXmlReader_1.ConnectionOptionsXmlReader().read(configFile);
134
- }
135
120
  // normalize and return connection options
136
121
  if (connectionOptions) {
137
122
  return this.normalizeConnectionOptions(connectionOptions);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/connection/ConnectionOptionsReader.ts"],"names":[],"mappings":";;;;AAAA,0EAAuC;AACvC,wDAAuB;AAEvB,6DAAyD;AACzD,4FAAwF;AACxF,4FAAwF;AACxF,4FAAwF;AACxF,oCAAuC;AACvC,iDAA8C;AAC9C,qDAAyD;AAEzD;;;GAGG;AACH,MAAa,uBAAuB;IAChC,4EAA4E;IAC5E,cAAc;I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AAC;IAED;;OAEG;IACH,IAAc,cAAc;QACxB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAA;QAElC,OAAO,WAAW,CAAA;IACtB,CAAC;CACJ;AApRD,0DAoRC","file":"ConnectionOptionsReader.js","sourcesContent":["import appRootPath from \"app-root-path\"\nimport path from \"path\"\nimport { DataSourceOptions } from \"../data-source/DataSourceOptions\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { ConnectionOptionsEnvReader } from \"./options-reader/ConnectionOptionsEnvReader\"\nimport { ConnectionOptionsYmlReader } from \"./options-reader/ConnectionOptionsYmlReader\"\nimport { ConnectionOptionsXmlReader } from \"./options-reader/ConnectionOptionsXmlReader\"\nimport { TypeORMError } from \"../error\"\nimport { isAbsolute } from \"../util/PathUtils\"\nimport { importOrRequireFile } from \"../util/ImportUtils\"\n\n/**\n * Reads connection options from the ormconfig.\n * Can read from multiple file extensions including env, json, js, xml and yml.\n */\nexport class ConnectionOptionsReader {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected options?: {\n /**\n * Directory where ormconfig should be read from.\n * By default its your application root (where your app package.json is located).\n */\n root?: string\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n },\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async all(): Promise<DataSourceOptions[]> {\n const options = await this.load()\n if (!options)\n throw new TypeORMError(\n `No connection options were found in any orm configuration files.`,\n )\n\n return options\n }\n\n /**\n * Gets a connection with a given name read from ormconfig.\n * If connection with such name would not be found then it throw error.\n */\n async get(name: string): Promise<DataSourceOptions> {\n const allOptions = await this.all()\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n if (!targetOptions)\n throw new TypeORMError(\n `Cannot find connection ${name} because its not defined in any orm configuration files.`,\n )\n\n return targetOptions\n }\n\n /**\n * Checks if there is a TypeORM configuration file.\n */\n async has(name: string): Promise<boolean> {\n const allOptions = await this.load()\n if (!allOptions) return false\n\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n return !!targetOptions\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<DataSourceOptions[] | undefined> {\n let connectionOptions:\n | DataSourceOptions\n | DataSourceOptions[]\n | undefined = undefined\n\n const fileFormats = [\n \"env\",\n \"js\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"mts\",\n \"cts\",\n \"json\",\n \"yml\",\n \"yaml\",\n \"xml\",\n ]\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = this.baseFilePath.substr(\n this.baseFilePath.lastIndexOf(\".\"),\n )\n const fileExtension = fileFormats.find(\n (extension) => `.${extension}` === possibleExtension,\n )\n\n // try to find any of following configuration formats\n const foundFileFormat =\n fileExtension ||\n fileFormats.find((format) => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format)\n })\n\n // Determine config file name\n const configFile = fileExtension\n ? this.baseFilePath\n : this.baseFilePath + \".\" + foundFileFormat\n\n // if .env file found then load all its variables into process.env using dotenv package\n if (foundFileFormat === \"env\") {\n PlatformTools.dotenv(configFile)\n } else if (PlatformTools.fileExist(this.baseDirectory + \"/.env\")) {\n PlatformTools.dotenv(this.baseDirectory + \"/.env\")\n }\n\n // try to find connection options from any of available sources of configuration\n if (\n PlatformTools.getEnvVariable(\"TYPEORM_CONNECTION\") ||\n PlatformTools.getEnvVariable(\"TYPEORM_URL\")\n ) {\n connectionOptions = await new ConnectionOptionsEnvReader().read()\n } else if (\n foundFileFormat === \"js\" ||\n foundFileFormat === \"mjs\" ||\n foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" ||\n foundFileFormat === \"mts\" ||\n foundFileFormat === \"cts\"\n ) {\n const [importOrRequireResult, moduleSystem] =\n await importOrRequireFile(configFile)\n const configModule = await importOrRequireResult\n\n if (\n moduleSystem === \"esm\" ||\n (configModule &&\n \"__esModule\" in configModule &&\n \"default\" in configModule)\n ) {\n connectionOptions = configModule.default\n } else {\n connectionOptions = configModule\n }\n } else if (foundFileFormat === \"json\") {\n connectionOptions = require(configFile)\n } else if (foundFileFormat === \"yml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(\n configFile,\n )\n } else if (foundFileFormat === \"yaml\") {\n connectionOptions = await new ConnectionOptionsYmlReader().read(\n configFile,\n )\n } else if (foundFileFormat === \"xml\") {\n connectionOptions = await new ConnectionOptionsXmlReader().read(\n configFile,\n )\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions)\n }\n\n return undefined\n }\n\n /**\n * Normalize connection options.\n */\n protected normalizeConnectionOptions(\n connectionOptions: DataSourceOptions | DataSourceOptions[],\n ): DataSourceOptions[] {\n if (!Array.isArray(connectionOptions))\n connectionOptions = [connectionOptions]\n\n connectionOptions.forEach((options) => {\n options.baseDirectory = this.baseDirectory\n if (options.entities) {\n const entities = (options.entities as any[]).map((entity) => {\n if (\n typeof entity === \"string\" &&\n entity.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + entity\n\n return entity\n })\n Object.assign(connectionOptions, { entities: entities })\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(\n (subscriber) => {\n if (\n typeof subscriber === \"string\" &&\n subscriber.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + subscriber\n\n return subscriber\n },\n )\n Object.assign(connectionOptions, { subscribers: subscribers })\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(\n (migration) => {\n if (\n typeof migration === \"string\" &&\n migration.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + migration\n\n return migration\n },\n )\n Object.assign(connectionOptions, { migrations: migrations })\n }\n\n // make database path file in sqlite relative to package.json\n if (\n options.type === \"sqlite\" ||\n options.type === \"better-sqlite3\"\n ) {\n if (\n typeof options.database === \"string\" &&\n !isAbsolute(options.database) &&\n options.database.substr(0, 1) !== \"/\" && // unix absolute\n options.database.substr(1, 2) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\"\n ) {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database,\n })\n }\n }\n })\n\n return connectionOptions\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName)\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n if (this.options && this.options.root) return this.options.root\n\n return appRootPath.path\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n if (this.options && this.options.configName)\n return this.options.configName\n\n return \"ormconfig\"\n }\n}\n"],"sourceRoot":".."}
1
+ {"version":3,"sources":["../../src/connection/ConnectionOptionsReader.ts"],"names":[],"mappings":";;;;AAAA,0EAAuC;AACvC,wDAAuB;AAEvB,6DAAyD;AACzD,4FAAwF;AACxF,oCAAuC;AACvC,iDAA8C;AAC9C,qDAAyD;AAEzD;;GAEG;AACH,MAAa,uBAAuB;IAChC,4EAA4E;IAC5E,cAAc;IACd,4EAA4E;IAE5E,YACc,OAWT;QAXS,YAAO,GAAP,OAAO,CAWhB;IACF,CAAC;IAEJ,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,GAAG;QACL,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAA;QACjC,IAAI,CAAC,OAAO;YACR,MAAM,IAAI,oBAAY,CAClB,kEAAkE,CACrE,CAAA;QAEL,OAAO,OAAO,CAAA;IAClB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;Q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AG,GAAG,GAAG,OAAO,CAAC,QAAQ;qBACxD,CAAC,CAAA;iBACL;aACJ;QACL,CAAC,CAAC,CAAA;QAEF,OAAO,iBAAiB,CAAA;IAC5B,CAAC;IAED;;OAEG;IACH,IAAc,YAAY;QACtB,OAAO,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IAChE,CAAC;IAED;;OAEG;IACH,IAAc,aAAa;QACvB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAA;QAE/D,OAAO,uBAAW,CAAC,IAAI,CAAA;IAC3B,CAAC;IAED;;OAEG;IACH,IAAc,cAAc;QACxB,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU;YACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAA;QAElC,OAAO,WAAW,CAAA;IACtB,CAAC;CACJ;AArQD,0DAqQC","file":"ConnectionOptionsReader.js","sourcesContent":["import appRootPath from \"app-root-path\"\nimport path from \"path\"\nimport { DataSourceOptions } from \"../data-source/DataSourceOptions\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\nimport { ConnectionOptionsEnvReader } from \"./options-reader/ConnectionOptionsEnvReader\"\nimport { TypeORMError } from \"../error\"\nimport { isAbsolute } from \"../util/PathUtils\"\nimport { importOrRequireFile } from \"../util/ImportUtils\"\n\n/**\n * Reads connection options from the ormconfig.\n */\nexport class ConnectionOptionsReader {\n // -------------------------------------------------------------------------\n // Constructor\n // -------------------------------------------------------------------------\n\n constructor(\n protected options?: {\n /**\n * Directory where ormconfig should be read from.\n * By default its your application root (where your app package.json is located).\n */\n root?: string\n\n /**\n * Filename of the ormconfig configuration. By default its equal to \"ormconfig\".\n */\n configName?: string\n },\n ) {}\n\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns all connection options read from the ormconfig.\n */\n async all(): Promise<DataSourceOptions[]> {\n const options = await this.load()\n if (!options)\n throw new TypeORMError(\n `No connection options were found in any orm configuration files.`,\n )\n\n return options\n }\n\n /**\n * Gets a connection with a given name read from ormconfig.\n * If connection with such name would not be found then it throw error.\n */\n async get(name: string): Promise<DataSourceOptions> {\n const allOptions = await this.all()\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n if (!targetOptions)\n throw new TypeORMError(\n `Cannot find connection ${name} because its not defined in any orm configuration files.`,\n )\n\n return targetOptions\n }\n\n /**\n * Checks if there is a TypeORM configuration file.\n */\n async has(name: string): Promise<boolean> {\n const allOptions = await this.load()\n if (!allOptions) return false\n\n const targetOptions = allOptions.find(\n (options) =>\n options.name === name || (name === \"default\" && !options.name),\n )\n return !!targetOptions\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Loads all connection options from a configuration file.\n *\n * todo: get in count NODE_ENV somehow\n */\n protected async load(): Promise<DataSourceOptions[] | undefined> {\n let connectionOptions:\n | DataSourceOptions\n | DataSourceOptions[]\n | undefined = undefined\n\n const fileFormats = [\n \"env\",\n \"js\",\n \"mjs\",\n \"cjs\",\n \"ts\",\n \"mts\",\n \"cts\",\n \"json\",\n ]\n\n // Detect if baseFilePath contains file extension\n const possibleExtension = this.baseFilePath.substr(\n this.baseFilePath.lastIndexOf(\".\"),\n )\n const fileExtension = fileFormats.find(\n (extension) => `.${extension}` === possibleExtension,\n )\n\n // try to find any of following configuration formats\n const foundFileFormat =\n fileExtension ||\n fileFormats.find((format) => {\n return PlatformTools.fileExist(this.baseFilePath + \".\" + format)\n })\n\n // Determine config file name\n const configFile = fileExtension\n ? this.baseFilePath\n : this.baseFilePath + \".\" + foundFileFormat\n\n // if .env file found then load all its variables into process.env using dotenv package\n if (foundFileFormat === \"env\") {\n PlatformTools.dotenv(configFile)\n } else if (PlatformTools.fileExist(this.baseDirectory + \"/.env\")) {\n PlatformTools.dotenv(this.baseDirectory + \"/.env\")\n }\n\n // try to find connection options from any of available sources of configuration\n if (\n PlatformTools.getEnvVariable(\"TYPEORM_CONNECTION\") ||\n PlatformTools.getEnvVariable(\"TYPEORM_URL\")\n ) {\n connectionOptions = await new ConnectionOptionsEnvReader().read()\n } else if (\n foundFileFormat === \"js\" ||\n foundFileFormat === \"mjs\" ||\n foundFileFormat === \"cjs\" ||\n foundFileFormat === \"ts\" ||\n foundFileFormat === \"mts\" ||\n foundFileFormat === \"cts\"\n ) {\n const [importOrRequireResult, moduleSystem] =\n await importOrRequireFile(configFile)\n const configModule = await importOrRequireResult\n\n if (\n moduleSystem === \"esm\" ||\n (configModule &&\n \"__esModule\" in configModule &&\n \"default\" in configModule)\n ) {\n connectionOptions = configModule.default\n } else {\n connectionOptions = configModule\n }\n } else if (foundFileFormat === \"json\") {\n connectionOptions = require(configFile)\n }\n\n // normalize and return connection options\n if (connectionOptions) {\n return this.normalizeConnectionOptions(connectionOptions)\n }\n\n return undefined\n }\n\n /**\n * Normalize connection options.\n */\n protected normalizeConnectionOptions(\n connectionOptions: DataSourceOptions | DataSourceOptions[],\n ): DataSourceOptions[] {\n if (!Array.isArray(connectionOptions))\n connectionOptions = [connectionOptions]\n\n connectionOptions.forEach((options) => {\n options.baseDirectory = this.baseDirectory\n if (options.entities) {\n const entities = (options.entities as any[]).map((entity) => {\n if (\n typeof entity === \"string\" &&\n entity.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + entity\n\n return entity\n })\n Object.assign(connectionOptions, { entities: entities })\n }\n if (options.subscribers) {\n const subscribers = (options.subscribers as any[]).map(\n (subscriber) => {\n if (\n typeof subscriber === \"string\" &&\n subscriber.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + subscriber\n\n return subscriber\n },\n )\n Object.assign(connectionOptions, { subscribers: subscribers })\n }\n if (options.migrations) {\n const migrations = (options.migrations as any[]).map(\n (migration) => {\n if (\n typeof migration === \"string\" &&\n migration.substr(0, 1) !== \"/\"\n )\n return this.baseDirectory + \"/\" + migration\n\n return migration\n },\n )\n Object.assign(connectionOptions, { migrations: migrations })\n }\n\n // make database path file in sqlite relative to package.json\n if (\n options.type === \"sqlite\" ||\n options.type === \"better-sqlite3\"\n ) {\n if (\n typeof options.database === \"string\" &&\n !isAbsolute(options.database) &&\n options.database.substr(0, 1) !== \"/\" && // unix absolute\n options.database.substr(1, 2) !== \":\\\\\" && // windows absolute\n options.database !== \":memory:\"\n ) {\n Object.assign(options, {\n database: this.baseDirectory + \"/\" + options.database,\n })\n }\n }\n })\n\n return connectionOptions\n }\n\n /**\n * Gets directory where configuration file should be located and configuration file name.\n */\n protected get baseFilePath(): string {\n return path.resolve(this.baseDirectory, this.baseConfigName)\n }\n\n /**\n * Gets directory where configuration file should be located.\n */\n protected get baseDirectory(): string {\n if (this.options && this.options.root) return this.options.root\n\n return appRootPath.path\n }\n\n /**\n * Gets configuration file name.\n */\n protected get baseConfigName(): string {\n if (this.options && this.options.configName)\n return this.options.configName\n\n return \"ormconfig\"\n }\n}\n"],"sourceRoot":".."}
package/globals.d.ts CHANGED
@@ -51,7 +51,7 @@ export declare function createConnection(options: DataSourceOptions): Promise<Da
51
51
  * Creates new connections and registers them in the manager.
52
52
  *
53
53
  * If connection options were not specified, then it will try to create connection automatically,
54
- * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.
54
+ * based on content of ormconfig (json/js/env) file or environment variables.
55
55
  * All connections from the ormconfig will be created.
56
56
  *
57
57
  * @deprecated
package/globals.js CHANGED
@@ -47,7 +47,7 @@ exports.getConnectionManager = getConnectionManager;
47
47
  * Creates a new connection and registers it in the manager.
48
48
  *
49
49
  * If connection options were not specified, then it will try to create connection automatically,
50
- * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.
50
+ * based on content of ormconfig (json/js/env) file or environment variables.
51
51
  * Only one connection from ormconfig will be created (name "default" or connection without name).
52
52
  *
53
53
  * @deprecated
@@ -64,7 +64,7 @@ exports.createConnection = createConnection;
64
64
  * Creates new connections and registers them in the manager.
65
65
  *
66
66
  * If connection options were not specified, then it will try to create connection automatically,
67
- * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.
67
+ * based on content of ormconfig (json/js/env) file or environment variables.
68
68
  * All connections from the ormconfig will be created.
69
69
  *
70
70
  * @deprecated
package/globals.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/globals.ts"],"names":[],"mappings":";;;AAAA,6EAAyE;AACzE,4DAAwD;AAExD,kFAA8E;AAC9E,sEAAkE;AAClE,2CAA8C;AAW9C,oDAAgD;AAGhD;;GAEG;AACH,SAAgB,sBAAsB;IAClC,8FAA8F;IAC9F,qGAAqG;IACrG,mGAAmG;IACnG,8EAA8E;IAC9E,6FAA6F;IAC7F,8FAA8F;IAC9F,iFAAiF;IACjF,4FAA4F;IAC5F,MAAM,WAAW,GAAG,6BAAa,CAAC,iBAAiB,EAAE,CAAA;IACrD,IAAI,CAAC,WAAW,CAAC,0BAA0B;QACvC,WAAW,CAAC,0BAA0B,GAAG,IAAI,yCAAmB,EAAE,CAAA;IAEtE,OAAO,WAAW,CAAC,0BAA0B,CAAA;AACjD,CAAC;AAdD,wDAcC;AAED;;;;GAIG;AACI,KAAK,UAAU,oBAAoB,CACtC,iBAAyB,SAAS;IAElC,OAAO,IAAI,iDAAuB,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AAC5D,CAAC;AAJD,oDAIC;AAED;;;;GAIG;AACH,SAAgB,oBAAoB;IAChC,OAAO,IAAA,4BAAgB,EAAC,qCAAiB,CAAC,CAAA;AAC9C,CAAC;AAFD,oDAEC;AA0BD;;;;;;;;GAQG;AACI,KAAK,UAAU,gBAAgB,CAClC,aAAmB;IAEnB,MAAM,cAAc,GAChB,OAAO,aAAa,KAAK,QAAQ,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAA;IACjE,MAAM,OAAO,GAAG,yBAAW,CA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AA6B,CAAA;AACtC,CAAC;AALD,0CAKC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CACzB,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,aAAa,CAAS,WAAW,CAAC,CAAA;AAC3C,CAAC;AAPD,sCAOC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAC7B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,iBAAiB,CAAS,WAAW,CAAC,CAAA;AAC/C,CAAC;AAPD,8CAOC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAC/B,gBAA+B,EAC/B,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;AAC9C,CAAC;AAPD,kDAOC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,kBAAkB,CAAS,WAAW,CAAC,CAAA;AAChD,CAAC;AAPD,gDAOC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,WAAkC,EAClC,KAAc,EACd,iBAAyB,SAAS;IAElC,IAAI,WAAW,EAAE;QACb,OAAO,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAChE,KAAK,CACR,CAAA;KACJ;IAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAA;AAC7D,CAAC;AAZD,gDAYC","file":"globals.js","sourcesContent":["import { MetadataArgsStorage } from \"./metadata-args/MetadataArgsStorage\"\nimport { PlatformTools } from \"./platform/PlatformTools\"\nimport { DataSourceOptions } from \"./data-source/DataSourceOptions\"\nimport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\"\nimport { ConnectionManager } from \"./connection/ConnectionManager\"\nimport { getFromContainer } from \"./container\"\nimport { DataSource } from \"./data-source/DataSource\"\nimport { EntityManager } from \"./entity-manager/EntityManager\"\nimport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\"\nimport { SqljsEntityManager } from \"./entity-manager/SqljsEntityManager\"\nimport { EntityTarget } from \"./common/EntityTarget\"\nimport { Repository } from \"./repository/Repository\"\nimport { TreeRepository } from \"./repository/TreeRepository\"\nimport { ObjectType } from \"./common/ObjectType\"\nimport { MongoRepository } from \"./repository/MongoRepository\"\nimport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\"\nimport { ObjectUtils } from \"./util/ObjectUtils\"\nimport { ObjectLiteral } from \"./common/ObjectLiteral\"\n\n/**\n * Gets metadata args storage.\n */\nexport function getMetadataArgsStorage(): MetadataArgsStorage {\n // we should store metadata storage in a global variable otherwise it brings too much problems\n // one of the problem is that if any entity (or any other) will be imported before consumer will call\n // useContainer method with his own container implementation, that entity will be registered in the\n // old old container (default one post probably) and consumer will his entity.\n // calling useContainer before he imports any entity (or any other) is not always convenient.\n // another reason is that when we run migrations typeorm is being called from a global package\n // and it may load entities which register decorators in typeorm of local package\n // this leads to impossibility of usage of entities in migrations and cli related operations\n const globalScope = PlatformTools.getGlobalVariable()\n if (!globalScope.typeormMetadataArgsStorage)\n globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage()\n\n return globalScope.typeormMetadataArgsStorage\n}\n\n/**\n * Reads connection options stored in ormconfig configuration file.\n *\n * @deprecated\n */\nexport async function getConnectionOptions(\n connectionName: string = \"default\",\n): Promise<DataSourceOptions> {\n return new ConnectionOptionsReader().get(connectionName)\n}\n\n/**\n * Gets a ConnectionManager which creates connections.\n *\n * @deprecated\n */\nexport function getConnectionManager(): ConnectionManager {\n return getFromContainer(ConnectionManager)\n}\n\n/**\n * Creates a new connection and registers it in the manager.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(): Promise<DataSource>\n\n/**\n * Creates a new connection from the ormconfig file with a given name.\n *\n * @deprecated\n */\nexport async function createConnection(name: string): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * @deprecated\n */\nexport async function createConnection(\n options: DataSourceOptions,\n): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(\n optionsOrName?: any,\n): Promise<DataSource> {\n const connectionName =\n typeof optionsOrName === \"string\" ? optionsOrName : \"default\"\n const options = ObjectUtils.isObject(optionsOrName)\n ? (optionsOrName as DataSourceOptions)\n : await getConnectionOptions(connectionName)\n return getConnectionManager().create(options).connect()\n}\n\n/**\n * Creates new connections and registers them in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/yml/xml/env) file or environment variables.\n * All connections from the ormconfig will be created.\n *\n * @deprecated\n */\nexport async function createConnections(\n options?: DataSourceOptions[],\n): Promise<DataSource[]> {\n if (!options) options = await new ConnectionOptionsReader().all()\n const connections = options.map((options) =>\n getConnectionManager().create(options),\n )\n // Do not use Promise.all or test 8522 will produce a dangling sqlite connection\n for (const connection of connections) {\n await connection.connect()\n }\n return connections\n}\n\n/**\n * Gets connection from the connection manager.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getConnection(connectionName: string = \"default\"): DataSource {\n return getConnectionManager().get(connectionName)\n}\n\n/**\n * Gets entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getManager(connectionName: string = \"default\"): EntityManager {\n return getConnectionManager().get(connectionName).manager\n}\n\n/**\n * Gets MongoDB entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getMongoManager(\n connectionName: string = \"default\",\n): MongoEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as MongoEntityManager\n}\n\n/**\n * Gets Sqljs entity manager from connection name.\n * \"default\" connection is used, when no name is specified.\n * Only works when Sqljs driver is used.\n *\n * @deprecated\n */\nexport function getSqljsManager(\n connectionName: string = \"default\",\n): SqljsEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as SqljsEntityManager\n}\n\n/**\n * Gets repository for the given entity class.\n *\n * @deprecated\n */\nexport function getRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): Repository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getTreeRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): TreeRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getTreeRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getCustomRepository<T>(\n customRepository: ObjectType<T>,\n connectionName: string = \"default\",\n): T {\n return getConnectionManager()\n .get(connectionName)\n .getCustomRepository(customRepository)\n}\n\n/**\n * Gets mongodb repository for the given entity class or name.\n *\n * @deprecated\n */\nexport function getMongoRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): MongoRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getMongoRepository<Entity>(entityClass)\n}\n\n/**\n * Creates a new query builder.\n *\n * @deprecated\n */\nexport function createQueryBuilder<Entity extends ObjectLiteral>(\n entityClass?: EntityTarget<Entity>,\n alias?: string,\n connectionName: string = \"default\",\n): SelectQueryBuilder<Entity> {\n if (entityClass) {\n return getRepository(entityClass, connectionName).createQueryBuilder(\n alias,\n )\n }\n\n return getConnection(connectionName).createQuery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AED;;;;GAIG;AACH,SAAgB,iBAAiB,CAC7B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,iBAAiB,CAAS,WAAW,CAAC,CAAA;AAC/C,CAAC;AAPD,8CAOC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB,CAC/B,gBAA+B,EAC/B,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;AAC9C,CAAC;AAPD,kDAOC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,WAAiC,EACjC,iBAAyB,SAAS;IAElC,OAAO,oBAAoB,EAAE;SACxB,GAAG,CAAC,cAAc,CAAC;SACnB,kBAAkB,CAAS,WAAW,CAAC,CAAA;AAChD,CAAC;AAPD,gDAOC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAC9B,WAAkC,EAClC,KAAc,EACd,iBAAyB,SAAS;IAElC,IAAI,WAAW,EAAE;QACb,OAAO,aAAa,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC,kBAAkB,CAChE,KAAK,CACR,CAAA;KACJ;IAED,OAAO,aAAa,CAAC,cAAc,CAAC,CAAC,kBAAkB,EAAE,CAAA;AAC7D,CAAC;AAZD,gDAYC","file":"globals.js","sourcesContent":["import { MetadataArgsStorage } from \"./metadata-args/MetadataArgsStorage\"\nimport { PlatformTools } from \"./platform/PlatformTools\"\nimport { DataSourceOptions } from \"./data-source/DataSourceOptions\"\nimport { ConnectionOptionsReader } from \"./connection/ConnectionOptionsReader\"\nimport { ConnectionManager } from \"./connection/ConnectionManager\"\nimport { getFromContainer } from \"./container\"\nimport { DataSource } from \"./data-source/DataSource\"\nimport { EntityManager } from \"./entity-manager/EntityManager\"\nimport { MongoEntityManager } from \"./entity-manager/MongoEntityManager\"\nimport { SqljsEntityManager } from \"./entity-manager/SqljsEntityManager\"\nimport { EntityTarget } from \"./common/EntityTarget\"\nimport { Repository } from \"./repository/Repository\"\nimport { TreeRepository } from \"./repository/TreeRepository\"\nimport { ObjectType } from \"./common/ObjectType\"\nimport { MongoRepository } from \"./repository/MongoRepository\"\nimport { SelectQueryBuilder } from \"./query-builder/SelectQueryBuilder\"\nimport { ObjectUtils } from \"./util/ObjectUtils\"\nimport { ObjectLiteral } from \"./common/ObjectLiteral\"\n\n/**\n * Gets metadata args storage.\n */\nexport function getMetadataArgsStorage(): MetadataArgsStorage {\n // we should store metadata storage in a global variable otherwise it brings too much problems\n // one of the problem is that if any entity (or any other) will be imported before consumer will call\n // useContainer method with his own container implementation, that entity will be registered in the\n // old old container (default one post probably) and consumer will his entity.\n // calling useContainer before he imports any entity (or any other) is not always convenient.\n // another reason is that when we run migrations typeorm is being called from a global package\n // and it may load entities which register decorators in typeorm of local package\n // this leads to impossibility of usage of entities in migrations and cli related operations\n const globalScope = PlatformTools.getGlobalVariable()\n if (!globalScope.typeormMetadataArgsStorage)\n globalScope.typeormMetadataArgsStorage = new MetadataArgsStorage()\n\n return globalScope.typeormMetadataArgsStorage\n}\n\n/**\n * Reads connection options stored in ormconfig configuration file.\n *\n * @deprecated\n */\nexport async function getConnectionOptions(\n connectionName: string = \"default\",\n): Promise<DataSourceOptions> {\n return new ConnectionOptionsReader().get(connectionName)\n}\n\n/**\n * Gets a ConnectionManager which creates connections.\n *\n * @deprecated\n */\nexport function getConnectionManager(): ConnectionManager {\n return getFromContainer(ConnectionManager)\n}\n\n/**\n * Creates a new connection and registers it in the manager.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(): Promise<DataSource>\n\n/**\n * Creates a new connection from the ormconfig file with a given name.\n *\n * @deprecated\n */\nexport async function createConnection(name: string): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * @deprecated\n */\nexport async function createConnection(\n options: DataSourceOptions,\n): Promise<DataSource>\n\n/**\n * Creates a new connection and registers it in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/env) file or environment variables.\n * Only one connection from ormconfig will be created (name \"default\" or connection without name).\n *\n * @deprecated\n */\nexport async function createConnection(\n optionsOrName?: any,\n): Promise<DataSource> {\n const connectionName =\n typeof optionsOrName === \"string\" ? optionsOrName : \"default\"\n const options = ObjectUtils.isObject(optionsOrName)\n ? (optionsOrName as DataSourceOptions)\n : await getConnectionOptions(connectionName)\n return getConnectionManager().create(options).connect()\n}\n\n/**\n * Creates new connections and registers them in the manager.\n *\n * If connection options were not specified, then it will try to create connection automatically,\n * based on content of ormconfig (json/js/env) file or environment variables.\n * All connections from the ormconfig will be created.\n *\n * @deprecated\n */\nexport async function createConnections(\n options?: DataSourceOptions[],\n): Promise<DataSource[]> {\n if (!options) options = await new ConnectionOptionsReader().all()\n const connections = options.map((options) =>\n getConnectionManager().create(options),\n )\n // Do not use Promise.all or test 8522 will produce a dangling sqlite connection\n for (const connection of connections) {\n await connection.connect()\n }\n return connections\n}\n\n/**\n * Gets connection from the connection manager.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getConnection(connectionName: string = \"default\"): DataSource {\n return getConnectionManager().get(connectionName)\n}\n\n/**\n * Gets entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getManager(connectionName: string = \"default\"): EntityManager {\n return getConnectionManager().get(connectionName).manager\n}\n\n/**\n * Gets MongoDB entity manager from the connection.\n * If connection name wasn't specified, then \"default\" connection will be retrieved.\n *\n * @deprecated\n */\nexport function getMongoManager(\n connectionName: string = \"default\",\n): MongoEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as MongoEntityManager\n}\n\n/**\n * Gets Sqljs entity manager from connection name.\n * \"default\" connection is used, when no name is specified.\n * Only works when Sqljs driver is used.\n *\n * @deprecated\n */\nexport function getSqljsManager(\n connectionName: string = \"default\",\n): SqljsEntityManager {\n return getConnectionManager().get(connectionName)\n .manager as SqljsEntityManager\n}\n\n/**\n * Gets repository for the given entity class.\n *\n * @deprecated\n */\nexport function getRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): Repository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getTreeRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): TreeRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getTreeRepository<Entity>(entityClass)\n}\n\n/**\n * Gets tree repository for the given entity class.\n *\n * @deprecated\n */\nexport function getCustomRepository<T>(\n customRepository: ObjectType<T>,\n connectionName: string = \"default\",\n): T {\n return getConnectionManager()\n .get(connectionName)\n .getCustomRepository(customRepository)\n}\n\n/**\n * Gets mongodb repository for the given entity class or name.\n *\n * @deprecated\n */\nexport function getMongoRepository<Entity extends ObjectLiteral>(\n entityClass: EntityTarget<Entity>,\n connectionName: string = \"default\",\n): MongoRepository<Entity> {\n return getConnectionManager()\n .get(connectionName)\n .getMongoRepository<Entity>(entityClass)\n}\n\n/**\n * Creates a new query builder.\n *\n * @deprecated\n */\nexport function createQueryBuilder<Entity extends ObjectLiteral>(\n entityClass?: EntityTarget<Entity>,\n alias?: string,\n connectionName: string = \"default\",\n): SelectQueryBuilder<Entity> {\n if (entityClass) {\n return getRepository(entityClass, connectionName).createQueryBuilder(\n alias,\n )\n }\n\n return getConnection(connectionName).createQueryBuilder()\n}\n"],"sourceRoot":"."}
package/package.json CHANGED
@@ -1 +1,268 @@
1
- { "name": "typeorm", "private": false, "version": "0.3.14-dev.daf1b47", "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.", "license": "MIT", "readmeFilename": "README.md", "author": { "name": "Umed Khudoiberdiev", "email": "pleerock.me@gmail.com" }, "engines": { "node": ">= 12.9.0" }, "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", "types": "./index.d.ts", "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/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" }, "repository": { "type": "git", "url": "https://github.com/typeorm/typeorm.git" }, "bugs": { "url": "https://github.com/typeorm/typeorm/issues" }, "homepage": "https://typeorm.io", "tags": [ "orm", "typescript", "typescript-orm", "mysql", "mysql-orm", "postgresql", "postgresql-orm", "mariadb", "mariadb-orm", "spanner", "sqlite", "sqlite-orm", "sql-server", "sql-server-orm", "oracle", "oracle-orm", "cloud-spanner", "cloud-spanner-orm" ], "devDependencies": { "@types/app-root-path": "^1.2.4", "@types/chai": "^4.3.4", "@types/chai-as-promised": "^7.1.5", "@types/debug": "^4.1.7", "@types/js-yaml": "^4.0.5", "@types/mkdirp": "^1.0.2", "@types/mocha": "^10.0.1", "@types/node": "^18.13.0", "@types/sha.js": "^2.4.0", "@types/sinon": "^10.0.13", "@types/source-map-support": "^0.5.6", "@types/uuid": "^9.0.0", "@types/xml2js": "^0.4.11", "@types/yargs": "^17.0.22", "better-sqlite3": "^8.1.0", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", "class-transformer": "^0.5.1", "conventional-changelog-angular": "^5.0.13", "conventional-changelog-cli": "^2.2.2", "del": "6.1.1", "gulp": "^4.0.2", "gulp-istanbul": "^1.1.3", "gulp-mocha": "^8.0.0", "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": "^8.0.3", "mocha": "^10.2.0", "mongodb": "^3.7.3", "mssql": "^9.1.1", "mysql": "^2.18.1", "mysql2": "^3.1.1", "pg": "^8.9.0", "pg-query-stream": "^4.3.0", "prettier": "^2.8.3", "redis": "^4.6.4", "remap-istanbul": "^0.13.0", "rimraf": "^4.1.2", "sinon": "^15.0.1", "sinon-chai": "^3.7.0", "source-map-support": "^0.5.21", "sql.js": "^1.8.0", "sqlite3": "^5.1.4", "ts-node": "^10.9.1", "typeorm-aurora-data-api-driver": "^2.4.4", "typescript": "^4.9.5" }, "peerDependencies": { "@google-cloud/spanner": "^5.18.0", "@sap/hana-client": "^2.12.25", "better-sqlite3": "^7.1.2 || ^8.0.0", "hdb-pool": "^0.1.6", "ioredis": "^5.0.4", "mongodb": "^3.6.0", "mssql": "^9.1.1", "mysql2": "^2.2.5 || ^3.0.1", "oracledb": "^5.1.0", "pg": "^8.5.1", "pg-native": "^3.0.0", "pg-query-stream": "^4.0.0", "redis": "^3.1.1 || ^4.0.0", "sql.js": "^1.4.0", "sqlite3": "^5.0.3", "ts-node": "^10.7.0", "typeorm-aurora-data-api-driver": "^2.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 } }, "dependencies": { "@sqltools/formatter": "^1.2.5", "app-root-path": "^3.1.0", "buffer": "^6.0.3", "chalk": "^4.1.2", "cli-highlight": "^2.1.11", "debug": "^4.3.4", "dotenv": "^16.0.3", "glob": "^8.1.0", "js-yaml": "^4.1.0", "mkdirp": "^2.1.3", "reflect-metadata": "^0.1.13", "sha.js": "^2.4.11", "tslib": "^2.5.0", "uuid": "^9.0.0", "xml2js": "^0.4.23", "yargs": "^17.6.2" }, "scripts": { "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test", "compile": "rimraf ./build && tsc", "watch": "./node_modules/.bin/tsc -w", "package": "gulp package", "pack": "gulp pack", "lint": "prettier --check \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"", "format": "prettier --write \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2" }, "bin": { "typeorm": "./cli.js", "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js", "typeorm-ts-node-esm": "./cli-ts-node-esm.js" }, "funding": "https://opencollective.com/typeorm", "collective": { "type": "opencollective", "url": "https://opencollective.com/typeorm", "logo": "https://opencollective.com/opencollective/logo.txt" }, "nyc": { "all": true, "cache": false, "exclude": [ "**/*.d.ts" ], "extension": [ ".ts" ], "include": [ "build/compiled/src/**", "src/**" ], "reporter": "json" } }
1
+ {
2
+ "name": "typeorm",
3
+ "private": false,
4
+ "version": "0.3.14",
5
+ "description": "Data-Mapper ORM for TypeScript, ES7, ES6, ES5. Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, MongoDB databases.",
6
+ "license": "MIT",
7
+ "readmeFilename": "README.md",
8
+ "author": {
9
+ "name": "Umed Khudoiberdiev",
10
+ "email": "pleerock.me@gmail.com"
11
+ },
12
+ "engines": {
13
+ "node": ">= 12.9.0"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./index.d.ts",
18
+ "node": {
19
+ "import": "./index.mjs",
20
+ "require": "./index.js",
21
+ "types": "./index.d.ts"
22
+ },
23
+ "browser": {
24
+ "require": "./index.js",
25
+ "import": "./browser/index.js",
26
+ "default": "./index.js"
27
+ }
28
+ },
29
+ "./browser": {
30
+ "types": "./index.d.ts",
31
+ "default": "./browser/index.js"
32
+ },
33
+ "./*.js": "./*.js",
34
+ "./*": {
35
+ "require": "./*.js",
36
+ "import": "./*"
37
+ }
38
+ },
39
+ "main": "./index.js",
40
+ "module": "./index.mjs",
41
+ "types": "./index.d.ts",
42
+ "browser": {
43
+ "./browser/connection/ConnectionOptionsReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
44
+ "./browser/connection/options-reader/ConnectionOptionsXmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
45
+ "./browser/connection/options-reader/ConnectionOptionsYmlReader.js": "./browser/platform/BrowserConnectionOptionsReaderDummy.js",
46
+ "./browser/driver/aurora-data-api/AuroraDataApiDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
47
+ "./browser/driver/better-sqlite3/BetterSqlite3Driver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
48
+ "./browser/driver/cockroachdb/CockroachDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
49
+ "./browser/driver/mongodb/MongoDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
50
+ "./browser/driver/mongodb/MongoQueryRunner.js": "./browser/platform/BrowserDisabledDriversDummy.js",
51
+ "./browser/driver/mysql/MysqlDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
52
+ "./browser/driver/oracle/OracleDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
53
+ "./browser/driver/postgres/PostgresDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
54
+ "./browser/driver/sap/SapDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
55
+ "./browser/driver/sqlite/SqliteDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
56
+ "./browser/driver/sqlserver/SqlServerDriver.js": "./browser/platform/BrowserDisabledDriversDummy.js",
57
+ "./browser/entity-manager/MongoEntityManager.js": "./browser/platform/BrowserDisabledDriversDummy.js",
58
+ "./browser/logger/FileLogger.js": "./browser/platform/BrowserFileLoggerDummy.js",
59
+ "./browser/platform/PlatformTools.js": "./browser/platform/BrowserPlatformTools.js",
60
+ "./browser/repository/MongoRepository.js": "./browser/platform/BrowserDisabledDriversDummy.js",
61
+ "./browser/util/DirectoryExportedClassesLoader.js": "./browser/platform/BrowserDirectoryExportedClassesLoader.js",
62
+ "./index.js": "./browser/index.js",
63
+ "./index.mjs": "./browser/index.js"
64
+ },
65
+ "repository": {
66
+ "type": "git",
67
+ "url": "https://github.com/typeorm/typeorm.git"
68
+ },
69
+ "bugs": {
70
+ "url": "https://github.com/typeorm/typeorm/issues"
71
+ },
72
+ "homepage": "https://typeorm.io",
73
+ "tags": [
74
+ "orm",
75
+ "typescript",
76
+ "typescript-orm",
77
+ "mysql",
78
+ "mysql-orm",
79
+ "postgresql",
80
+ "postgresql-orm",
81
+ "mariadb",
82
+ "mariadb-orm",
83
+ "spanner",
84
+ "sqlite",
85
+ "sqlite-orm",
86
+ "sql-server",
87
+ "sql-server-orm",
88
+ "oracle",
89
+ "oracle-orm",
90
+ "cloud-spanner",
91
+ "cloud-spanner-orm"
92
+ ],
93
+ "devDependencies": {
94
+ "@types/app-root-path": "^1.2.4",
95
+ "@types/chai": "^4.3.4",
96
+ "@types/chai-as-promised": "^7.1.5",
97
+ "@types/debug": "^4.1.7",
98
+ "@types/mkdirp": "^1.0.2",
99
+ "@types/mocha": "^10.0.1",
100
+ "@types/node": "^18.13.0",
101
+ "@types/sha.js": "^2.4.0",
102
+ "@types/sinon": "^10.0.13",
103
+ "@types/source-map-support": "^0.5.6",
104
+ "@types/uuid": "^9.0.0",
105
+ "@types/yargs": "^17.0.22",
106
+ "better-sqlite3": "^8.1.0",
107
+ "chai": "^4.3.7",
108
+ "chai-as-promised": "^7.1.1",
109
+ "class-transformer": "^0.5.1",
110
+ "conventional-changelog-angular": "^5.0.13",
111
+ "conventional-changelog-cli": "^2.2.2",
112
+ "del": "6.1.1",
113
+ "gulp": "^4.0.2",
114
+ "gulp-istanbul": "^1.1.3",
115
+ "gulp-mocha": "^8.0.0",
116
+ "gulp-rename": "^2.0.0",
117
+ "gulp-replace": "^1.1.4",
118
+ "gulp-shell": "^0.8.0",
119
+ "gulp-sourcemaps": "^3.0.0",
120
+ "gulp-typescript": "^6.0.0-alpha.1",
121
+ "gulpclass": "^0.2.0",
122
+ "husky": "^8.0.3",
123
+ "mocha": "^10.2.0",
124
+ "mongodb": "^3.7.3",
125
+ "mssql": "^9.1.1",
126
+ "mysql": "^2.18.1",
127
+ "mysql2": "^3.1.1",
128
+ "pg": "^8.9.0",
129
+ "pg-query-stream": "^4.3.0",
130
+ "prettier": "^2.8.3",
131
+ "redis": "^4.6.4",
132
+ "remap-istanbul": "^0.13.0",
133
+ "rimraf": "^4.1.2",
134
+ "sinon": "^15.0.1",
135
+ "sinon-chai": "^3.7.0",
136
+ "source-map-support": "^0.5.21",
137
+ "sql.js": "^1.8.0",
138
+ "sqlite3": "^5.1.4",
139
+ "ts-node": "^10.9.1",
140
+ "typeorm-aurora-data-api-driver": "^2.4.4",
141
+ "typescript": "^4.9.5"
142
+ },
143
+ "peerDependencies": {
144
+ "@google-cloud/spanner": "^5.18.0",
145
+ "@sap/hana-client": "^2.12.25",
146
+ "better-sqlite3": "^7.1.2 || ^8.0.0",
147
+ "hdb-pool": "^0.1.6",
148
+ "ioredis": "^5.0.4",
149
+ "mongodb": "^3.6.0",
150
+ "mssql": "^9.1.1",
151
+ "mysql2": "^2.2.5 || ^3.0.1",
152
+ "oracledb": "^5.1.0",
153
+ "pg": "^8.5.1",
154
+ "pg-native": "^3.0.0",
155
+ "pg-query-stream": "^4.0.0",
156
+ "redis": "^3.1.1 || ^4.0.0",
157
+ "sql.js": "^1.4.0",
158
+ "sqlite3": "^5.0.3",
159
+ "ts-node": "^10.7.0",
160
+ "typeorm-aurora-data-api-driver": "^2.0.0"
161
+ },
162
+ "peerDependenciesMeta": {
163
+ "@google-cloud/spanner": {
164
+ "optional": true
165
+ },
166
+ "@sap/hana-client": {
167
+ "optional": true
168
+ },
169
+ "better-sqlite3": {
170
+ "optional": true
171
+ },
172
+ "hdb-pool": {
173
+ "optional": true
174
+ },
175
+ "ioredis": {
176
+ "optional": true
177
+ },
178
+ "mongodb": {
179
+ "optional": true
180
+ },
181
+ "mssql": {
182
+ "optional": true
183
+ },
184
+ "mysql2": {
185
+ "optional": true
186
+ },
187
+ "oracledb": {
188
+ "optional": true
189
+ },
190
+ "pg": {
191
+ "optional": true
192
+ },
193
+ "pg-native": {
194
+ "optional": true
195
+ },
196
+ "pg-query-stream": {
197
+ "optional": true
198
+ },
199
+ "redis": {
200
+ "optional": true
201
+ },
202
+ "sql.js": {
203
+ "optional": true
204
+ },
205
+ "sqlite3": {
206
+ "optional": true
207
+ },
208
+ "ts-node": {
209
+ "optional": true
210
+ },
211
+ "typeorm-aurora-data-api-driver": {
212
+ "optional": true
213
+ }
214
+ },
215
+ "dependencies": {
216
+ "@sqltools/formatter": "^1.2.5",
217
+ "app-root-path": "^3.1.0",
218
+ "buffer": "^6.0.3",
219
+ "chalk": "^4.1.2",
220
+ "cli-highlight": "^2.1.11",
221
+ "debug": "^4.3.4",
222
+ "dotenv": "^16.0.3",
223
+ "glob": "^8.1.0",
224
+ "mkdirp": "^2.1.3",
225
+ "reflect-metadata": "^0.1.13",
226
+ "sha.js": "^2.4.11",
227
+ "tslib": "^2.5.0",
228
+ "uuid": "^9.0.0",
229
+ "yargs": "^17.6.2"
230
+ },
231
+ "scripts": {
232
+ "test": "rimraf ./build && tsc && mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test",
233
+ "test-fast": "mocha --file ./build/compiled/test/utils/test-setup.js --bail --recursive --timeout 60000 ./build/compiled/test",
234
+ "compile": "rimraf ./build && tsc",
235
+ "watch": "./node_modules/.bin/tsc -w",
236
+ "package": "gulp package",
237
+ "pack": "gulp pack",
238
+ "lint": "prettier --check \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
239
+ "format": "prettier --write \"./src/**/*.ts\" \"./test/**/*.ts\" \"./sample/**/*.ts\"",
240
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 2"
241
+ },
242
+ "bin": {
243
+ "typeorm": "./cli.js",
244
+ "typeorm-ts-node-commonjs": "./cli-ts-node-commonjs.js",
245
+ "typeorm-ts-node-esm": "./cli-ts-node-esm.js"
246
+ },
247
+ "funding": "https://opencollective.com/typeorm",
248
+ "collective": {
249
+ "type": "opencollective",
250
+ "url": "https://opencollective.com/typeorm",
251
+ "logo": "https://opencollective.com/opencollective/logo.txt"
252
+ },
253
+ "nyc": {
254
+ "all": true,
255
+ "cache": false,
256
+ "exclude": [
257
+ "**/*.d.ts"
258
+ ],
259
+ "extension": [
260
+ ".ts"
261
+ ],
262
+ "include": [
263
+ "build/compiled/src/**",
264
+ "src/**"
265
+ ],
266
+ "reporter": "json"
267
+ }
268
+ }
@@ -1,16 +0,0 @@
1
- import { DataSourceOptions } from "../../data-source/DataSourceOptions";
2
- /**
3
- * Reads connection options defined in the xml file.
4
- *
5
- * @deprecated
6
- */
7
- export declare class ConnectionOptionsXmlReader {
8
- /**
9
- * Reads connection options from given xml file.
10
- */
11
- read(path: string): Promise<DataSourceOptions[]>;
12
- /**
13
- * Reads xml file contents and returns them in a promise.
14
- */
15
- protected readXml(path: string): Promise<any>;
16
- }
@@ -1,66 +0,0 @@
1
- import { parseString as xmlParser } from "xml2js";
2
- import { PlatformTools } from "../../platform/PlatformTools";
3
- /**
4
- * Reads connection options defined in the xml file.
5
- *
6
- * @deprecated
7
- */
8
- export class ConnectionOptionsXmlReader {
9
- // -------------------------------------------------------------------------
10
- // Public Methods
11
- // -------------------------------------------------------------------------
12
- /**
13
- * Reads connection options from given xml file.
14
- */
15
- async read(path) {
16
- const xml = await this.readXml(path);
17
- return xml.connection.map((connection) => {
18
- return {
19
- name: connection.$.name,
20
- type: connection.$.type,
21
- url: connection.url ? connection.url[0] : undefined,
22
- host: connection.host ? connection.host[0] : undefined,
23
- port: connection.port && connection.port[0]
24
- ? parseInt(connection.port[0])
25
- : undefined,
26
- username: connection.username
27
- ? connection.username[0]
28
- : undefined,
29
- password: connection.password
30
- ? connection.password[0]
31
- : undefined,
32
- database: connection.database
33
- ? connection.database[0]
34
- : undefined,
35
- sid: connection.sid ? connection.sid[0] : undefined,
36
- extra: connection.extra ? connection.extra[0] : undefined,
37
- synchronize: connection.synchronize
38
- ? connection.synchronize[0]
39
- : undefined,
40
- entities: connection.entities
41
- ? connection.entities[0].entity
42
- : [],
43
- subscribers: connection.subscribers
44
- ? connection.subscribers[0].entity
45
- : [],
46
- logging: connection.logging[0]
47
- ? connection.logging[0].split(",")
48
- : undefined,
49
- };
50
- });
51
- }
52
- // -------------------------------------------------------------------------
53
- // Protected Methods
54
- // -------------------------------------------------------------------------
55
- /**
56
- * Reads xml file contents and returns them in a promise.
57
- */
58
- readXml(path) {
59
- const xmlOptions = { trim: true, explicitRoot: false };
60
- return new Promise((ok, fail) => {
61
- xmlParser(PlatformTools.readFileSync(path), xmlOptions, (err, result) => (err ? fail(err) : ok(result)));
62
- });
63
- }
64
- }
65
-
66
- //# sourceMappingURL=ConnectionOptionsXmlReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../browser/src/connection/options-reader/ConnectionOptionsXmlReader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAG5D;;;;GAIG;AACH,MAAM,OAAO,0BAA0B;IACnC,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,IAAY;QACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACpC,OAAQ,GAAG,CAAC,UAAoB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAChD,OAAO;gBACH,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI;gBACvB,IAAI,EAAE,UA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,CAAC,CAAC,CAAC,MAAM;oBAC/B,CAAC,CAAC,EAAE;gBACR,WAAW,EAAE,UAAU,CAAC,WAAW;oBAC/B,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM;oBAClC,CAAC,CAAC,EAAE;gBACR,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;oBAC1B,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;oBAClC,CAAC,CAAC,SAAS;aAClB,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,OAAO,CAAC,IAAY;QAC1B,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAA;QACtD,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;YAC5B,SAAS,CACL,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAChC,UAAU,EACV,CAAC,GAAQ,EAAE,MAAW,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAC5D,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ","file":"ConnectionOptionsXmlReader.js","sourcesContent":["import { parseString as xmlParser } from \"xml2js\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { DataSourceOptions } from \"../../data-source/DataSourceOptions\"\n\n/**\n * Reads connection options defined in the xml file.\n *\n * @deprecated\n */\nexport class ConnectionOptionsXmlReader {\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Reads connection options from given xml file.\n */\n async read(path: string): Promise<DataSourceOptions[]> {\n const xml = await this.readXml(path)\n return (xml.connection as any[]).map((connection) => {\n return {\n name: connection.$.name,\n type: connection.$.type,\n url: connection.url ? connection.url[0] : undefined,\n host: connection.host ? connection.host[0] : undefined,\n port:\n connection.port && connection.port[0]\n ? parseInt(connection.port[0])\n : undefined,\n username: connection.username\n ? connection.username[0]\n : undefined,\n password: connection.password\n ? connection.password[0]\n : undefined,\n database: connection.database\n ? connection.database[0]\n : undefined,\n sid: connection.sid ? connection.sid[0] : undefined,\n extra: connection.extra ? connection.extra[0] : undefined,\n synchronize: connection.synchronize\n ? connection.synchronize[0]\n : undefined,\n entities: connection.entities\n ? connection.entities[0].entity\n : [],\n subscribers: connection.subscribers\n ? connection.subscribers[0].entity\n : [],\n logging: connection.logging[0]\n ? connection.logging[0].split(\",\")\n : undefined,\n }\n })\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Reads xml file contents and returns them in a promise.\n */\n protected readXml(path: string): Promise<any> {\n const xmlOptions = { trim: true, explicitRoot: false }\n return new Promise((ok, fail) => {\n xmlParser(\n PlatformTools.readFileSync(path),\n xmlOptions,\n (err: any, result: any) => (err ? fail(err) : ok(result)),\n )\n })\n }\n}\n"],"sourceRoot":"../.."}
@@ -1,12 +0,0 @@
1
- import { DataSourceOptions } from "../../data-source/DataSourceOptions";
2
- /**
3
- * Reads connection options defined in the yml file.
4
- *
5
- * @deprecated
6
- */
7
- export declare class ConnectionOptionsYmlReader {
8
- /**
9
- * Reads connection options from given yml file.
10
- */
11
- read(path: string): Promise<DataSourceOptions[]>;
12
- }
@@ -1,28 +0,0 @@
1
- import ymlParser from "js-yaml";
2
- import { PlatformTools } from "../../platform/PlatformTools";
3
- /**
4
- * Reads connection options defined in the yml file.
5
- *
6
- * @deprecated
7
- */
8
- export class ConnectionOptionsYmlReader {
9
- // -------------------------------------------------------------------------
10
- // Public Methods
11
- // -------------------------------------------------------------------------
12
- /**
13
- * Reads connection options from given yml file.
14
- */
15
- async read(path) {
16
- const contentsBuffer = PlatformTools.readFileSync(path);
17
- const contents = contentsBuffer.toString();
18
- const config = ymlParser.load(contents);
19
- if (!config || typeof config !== "object" || config === null) {
20
- return [];
21
- }
22
- return Object.keys(config).map((connectionName) => {
23
- return Object.assign({ name: connectionName }, config[connectionName]);
24
- });
25
- }
26
- }
27
-
28
- //# sourceMappingURL=ConnectionOptionsYmlReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../browser/src/connection/options-reader/ConnectionOptionsYmlReader.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAG5D;;;;GAIG;AACH,MAAM,OAAO,0BAA0B;IACnC,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,IAAY;QACnB,MAAM,cAAc,GAAG,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACvD,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAA;QAE1C,MAAM,MAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEvC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;YAC1D,OAAO,EAAE,CAAA;SACZ;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;YAC9C,OAAO,MAAM,CAAC,MAAM,CAChB,EAAE,IAAI,EAAE,cAAc,EAAE,EACvB,MAAc,CAAC,cAAc,CAAC,CAClC,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ","file":"ConnectionOptionsYmlReader.js","sourcesContent":["import ymlParser from \"js-yaml\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { DataSourceOptions } from \"../../data-source/DataSourceOptions\"\n\n/**\n * Reads connection options defined in the yml file.\n *\n * @deprecated\n */\nexport class ConnectionOptionsYmlReader {\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Reads connection options from given yml file.\n */\n async read(path: string): Promise<DataSourceOptions[]> {\n const contentsBuffer = PlatformTools.readFileSync(path)\n const contents = contentsBuffer.toString()\n\n const config = ymlParser.load(contents)\n\n if (!config || typeof config !== \"object\" || config === null) {\n return []\n }\n\n return Object.keys(config).map((connectionName) => {\n return Object.assign(\n { name: connectionName },\n (config as any)[connectionName],\n )\n })\n }\n}\n"],"sourceRoot":"../.."}
@@ -1,16 +0,0 @@
1
- import { DataSourceOptions } from "../../data-source/DataSourceOptions";
2
- /**
3
- * Reads connection options defined in the xml file.
4
- *
5
- * @deprecated
6
- */
7
- export declare class ConnectionOptionsXmlReader {
8
- /**
9
- * Reads connection options from given xml file.
10
- */
11
- read(path: string): Promise<DataSourceOptions[]>;
12
- /**
13
- * Reads xml file contents and returns them in a promise.
14
- */
15
- protected readXml(path: string): Promise<any>;
16
- }
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionOptionsXmlReader = void 0;
4
- const xml2js_1 = require("xml2js");
5
- const PlatformTools_1 = require("../../platform/PlatformTools");
6
- /**
7
- * Reads connection options defined in the xml file.
8
- *
9
- * @deprecated
10
- */
11
- class ConnectionOptionsXmlReader {
12
- // -------------------------------------------------------------------------
13
- // Public Methods
14
- // -------------------------------------------------------------------------
15
- /**
16
- * Reads connection options from given xml file.
17
- */
18
- async read(path) {
19
- const xml = await this.readXml(path);
20
- return xml.connection.map((connection) => {
21
- return {
22
- name: connection.$.name,
23
- type: connection.$.type,
24
- url: connection.url ? connection.url[0] : undefined,
25
- host: connection.host ? connection.host[0] : undefined,
26
- port: connection.port && connection.port[0]
27
- ? parseInt(connection.port[0])
28
- : undefined,
29
- username: connection.username
30
- ? connection.username[0]
31
- : undefined,
32
- password: connection.password
33
- ? connection.password[0]
34
- : undefined,
35
- database: connection.database
36
- ? connection.database[0]
37
- : undefined,
38
- sid: connection.sid ? connection.sid[0] : undefined,
39
- extra: connection.extra ? connection.extra[0] : undefined,
40
- synchronize: connection.synchronize
41
- ? connection.synchronize[0]
42
- : undefined,
43
- entities: connection.entities
44
- ? connection.entities[0].entity
45
- : [],
46
- subscribers: connection.subscribers
47
- ? connection.subscribers[0].entity
48
- : [],
49
- logging: connection.logging[0]
50
- ? connection.logging[0].split(",")
51
- : undefined,
52
- };
53
- });
54
- }
55
- // -------------------------------------------------------------------------
56
- // Protected Methods
57
- // -------------------------------------------------------------------------
58
- /**
59
- * Reads xml file contents and returns them in a promise.
60
- */
61
- readXml(path) {
62
- const xmlOptions = { trim: true, explicitRoot: false };
63
- return new Promise((ok, fail) => {
64
- (0, xml2js_1.parseString)(PlatformTools_1.PlatformTools.readFileSync(path), xmlOptions, (err, result) => (err ? fail(err) : ok(result)));
65
- });
66
- }
67
- }
68
- exports.ConnectionOptionsXmlReader = ConnectionOptionsXmlReader;
69
-
70
- //# sourceMappingURL=ConnectionOptionsXmlReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/connection/options-reader/ConnectionOptionsXmlReader.ts"],"names":[],"mappings":";;;AAAA,mCAAiD;AACjD,gEAA4D;AAG5D;;;;GAIG;AACH,MAAa,0BAA0B;IACnC,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,IAAY;QACnB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QACpC,OAAQ,GAAG,CAAC,UAAoB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;YAChD,OAAO;gBACH,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI;gBACvB,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI;gBACvB,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,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AAC,WAAW;oBAC/B,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM;oBAClC,CAAC,CAAC,EAAE;gBACR,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC;oBAC1B,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;oBAClC,CAAC,CAAC,SAAS;aAClB,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;IAED,4EAA4E;IAC5E,oBAAoB;IACpB,4EAA4E;IAE5E;;OAEG;IACO,OAAO,CAAC,IAAY;QAC1B,MAAM,UAAU,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAA;QACtD,OAAO,IAAI,OAAO,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;YAC5B,IAAA,oBAAS,EACL,6BAAa,CAAC,YAAY,CAAC,IAAI,CAAC,EAChC,UAAU,EACV,CAAC,GAAQ,EAAE,MAAW,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAC5D,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAhED,gEAgEC","file":"ConnectionOptionsXmlReader.js","sourcesContent":["import { parseString as xmlParser } from \"xml2js\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { DataSourceOptions } from \"../../data-source/DataSourceOptions\"\n\n/**\n * Reads connection options defined in the xml file.\n *\n * @deprecated\n */\nexport class ConnectionOptionsXmlReader {\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Reads connection options from given xml file.\n */\n async read(path: string): Promise<DataSourceOptions[]> {\n const xml = await this.readXml(path)\n return (xml.connection as any[]).map((connection) => {\n return {\n name: connection.$.name,\n type: connection.$.type,\n url: connection.url ? connection.url[0] : undefined,\n host: connection.host ? connection.host[0] : undefined,\n port:\n connection.port && connection.port[0]\n ? parseInt(connection.port[0])\n : undefined,\n username: connection.username\n ? connection.username[0]\n : undefined,\n password: connection.password\n ? connection.password[0]\n : undefined,\n database: connection.database\n ? connection.database[0]\n : undefined,\n sid: connection.sid ? connection.sid[0] : undefined,\n extra: connection.extra ? connection.extra[0] : undefined,\n synchronize: connection.synchronize\n ? connection.synchronize[0]\n : undefined,\n entities: connection.entities\n ? connection.entities[0].entity\n : [],\n subscribers: connection.subscribers\n ? connection.subscribers[0].entity\n : [],\n logging: connection.logging[0]\n ? connection.logging[0].split(\",\")\n : undefined,\n }\n })\n }\n\n // -------------------------------------------------------------------------\n // Protected Methods\n // -------------------------------------------------------------------------\n\n /**\n * Reads xml file contents and returns them in a promise.\n */\n protected readXml(path: string): Promise<any> {\n const xmlOptions = { trim: true, explicitRoot: false }\n return new Promise((ok, fail) => {\n xmlParser(\n PlatformTools.readFileSync(path),\n xmlOptions,\n (err: any, result: any) => (err ? fail(err) : ok(result)),\n )\n })\n }\n}\n"],"sourceRoot":"../.."}
@@ -1,12 +0,0 @@
1
- import { DataSourceOptions } from "../../data-source/DataSourceOptions";
2
- /**
3
- * Reads connection options defined in the yml file.
4
- *
5
- * @deprecated
6
- */
7
- export declare class ConnectionOptionsYmlReader {
8
- /**
9
- * Reads connection options from given yml file.
10
- */
11
- read(path: string): Promise<DataSourceOptions[]>;
12
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConnectionOptionsYmlReader = void 0;
4
- const tslib_1 = require("tslib");
5
- const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
6
- const PlatformTools_1 = require("../../platform/PlatformTools");
7
- /**
8
- * Reads connection options defined in the yml file.
9
- *
10
- * @deprecated
11
- */
12
- class ConnectionOptionsYmlReader {
13
- // -------------------------------------------------------------------------
14
- // Public Methods
15
- // -------------------------------------------------------------------------
16
- /**
17
- * Reads connection options from given yml file.
18
- */
19
- async read(path) {
20
- const contentsBuffer = PlatformTools_1.PlatformTools.readFileSync(path);
21
- const contents = contentsBuffer.toString();
22
- const config = js_yaml_1.default.load(contents);
23
- if (!config || typeof config !== "object" || config === null) {
24
- return [];
25
- }
26
- return Object.keys(config).map((connectionName) => {
27
- return Object.assign({ name: connectionName }, config[connectionName]);
28
- });
29
- }
30
- }
31
- exports.ConnectionOptionsYmlReader = ConnectionOptionsYmlReader;
32
-
33
- //# sourceMappingURL=ConnectionOptionsYmlReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/connection/options-reader/ConnectionOptionsYmlReader.ts"],"names":[],"mappings":";;;;AAAA,8DAA+B;AAC/B,gEAA4D;AAG5D;;;;GAIG;AACH,MAAa,0BAA0B;IACnC,4EAA4E;IAC5E,iBAAiB;IACjB,4EAA4E;IAE5E;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,IAAY;QACnB,MAAM,cAAc,GAAG,6BAAa,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QACvD,MAAM,QAAQ,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAA;QAE1C,MAAM,MAAM,GAAG,iBAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEvC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE;YAC1D,OAAO,EAAE,CAAA;SACZ;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,cAAc,EAAE,EAAE;YAC9C,OAAO,MAAM,CAAC,MAAM,CAChB,EAAE,IAAI,EAAE,cAAc,EAAE,EACvB,MAAc,CAAC,cAAc,CAAC,CAClC,CAAA;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ;AAzBD,gEAyBC","file":"ConnectionOptionsYmlReader.js","sourcesContent":["import ymlParser from \"js-yaml\"\nimport { PlatformTools } from \"../../platform/PlatformTools\"\nimport { DataSourceOptions } from \"../../data-source/DataSourceOptions\"\n\n/**\n * Reads connection options defined in the yml file.\n *\n * @deprecated\n */\nexport class ConnectionOptionsYmlReader {\n // -------------------------------------------------------------------------\n // Public Methods\n // -------------------------------------------------------------------------\n\n /**\n * Reads connection options from given yml file.\n */\n async read(path: string): Promise<DataSourceOptions[]> {\n const contentsBuffer = PlatformTools.readFileSync(path)\n const contents = contentsBuffer.toString()\n\n const config = ymlParser.load(contents)\n\n if (!config || typeof config !== \"object\" || config === null) {\n return []\n }\n\n return Object.keys(config).map((connectionName) => {\n return Object.assign(\n { name: connectionName },\n (config as any)[connectionName],\n )\n })\n }\n}\n"],"sourceRoot":"../.."}