????
Current Path : C:/inetpub/vhost/invest.gdtsolutions.vn/api/node_modules/typeorm/driver/ |
Current File : C:/inetpub/vhost/invest.gdtsolutions.vn/api/node_modules/typeorm/driver/DriverUtils.js.map |
{"version":3,"sources":["../../src/driver/DriverUtils.ts"],"names":[],"mappings":";;;AACA,qDAAmD;AACnD,uDAAmD;AAEnD;;GAEG;AACH,MAAa,WAAW;IACpB,4EAA4E;IAC5E,wBAAwB;IACxB,4EAA4E;IAE5E;;OAEG;IACH,MAAM,CAAC,cAAc,CAAC,MAAc;QAChC,OAAO;YACH,QAAQ;YACR,SAAS;YACT,cAAc;YACd,cAAc;YACd,OAAO;YACP,MAAM;YACN,gBAAgB;YAChB,WAAW;SACd,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,aAAa,CAAC,MAAc;QAC/B,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7D,CAAC;IAED,MAAM,CAAC,yBAAyB,CAAC,MAAc,EAAE,OAAe;QAC5D,OAAO,CACH,MAAM,CAAC,OAAO,IAAI,IAAI;YACtB,2BAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,CACzD,CAAA;IACL,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc;QAClC,OAAO,CAAC,UAAU,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC,QAAQ,CAC1D,MAAM,CAAC,OAAO,CAAC,IAAI,CACtB,CAAA;IACL,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,kBAAkB,CACrB,OAAY,EACZ,YAAkC;QAElC,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,gBAAgB,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAE3D,CAAA;YAED,I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AI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;YACvD,aAAa,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QAC9B,CAAC;QAED,OAAO,aAAa,CAAA;IACxB,CAAC;CACJ;AApSD,kCAoSC","file":"DriverUtils.js","sourcesContent":["import { Driver } from \"./Driver\"\nimport { hash, shorten } from \"../util/StringUtils\"\nimport { VersionUtils } from \"../util/VersionUtils\"\n\n/**\n * Common driver utility functions.\n */\nexport class DriverUtils {\n // -------------------------------------------------------------------------\n // Public Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Returns true if given driver is SQLite-based driver.\n */\n static isSQLiteFamily(driver: Driver): boolean {\n return [\n \"sqlite\",\n \"cordova\",\n \"react-native\",\n \"nativescript\",\n \"sqljs\",\n \"expo\",\n \"better-sqlite3\",\n \"capacitor\",\n ].includes(driver.options.type)\n }\n\n /**\n * Returns true if given driver is MySQL-based driver.\n */\n static isMySQLFamily(driver: Driver): boolean {\n return [\"mysql\", \"mariadb\"].includes(driver.options.type)\n }\n\n static isReleaseVersionOrGreater(driver: Driver, version: string): boolean {\n return (\n driver.version != null &&\n VersionUtils.isGreaterOrEqual(driver.version, version)\n )\n }\n\n static isPostgresFamily(driver: Driver): boolean {\n return [\"postgres\", \"aurora-postgres\", \"cockroachdb\"].includes(\n driver.options.type,\n )\n }\n\n /**\n * Normalizes and builds a new driver options.\n * Extracts settings from connection url and sets to a new options object.\n */\n static buildDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseConnectionUrl(options.url) as {\n [key: string]: any\n }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * buildDriverOptions for MongodDB only to support replica set\n */\n static buildMongoDBDriverOptions(\n options: any,\n buildOptions?: { useSid: boolean },\n ): any {\n if (options.url) {\n const urlDriverOptions = this.parseMongoDBConnectionUrl(\n options.url,\n ) as { [key: string]: any }\n\n if (\n buildOptions &&\n buildOptions.useSid &&\n urlDriverOptions.database\n ) {\n urlDriverOptions.sid = urlDriverOptions.database\n }\n\n for (const key of Object.keys(urlDriverOptions)) {\n if (typeof urlDriverOptions[key] === \"undefined\") {\n delete urlDriverOptions[key]\n }\n }\n\n return Object.assign({}, options, urlDriverOptions)\n }\n return Object.assign({}, options)\n }\n\n /**\n * Joins and shortens alias if needed.\n *\n * If the alias length is greater than the limit allowed by the current\n * driver, replaces it with a shortend string, if the shortend string\n * is still too long, it will then hash the alias.\n *\n * @param driver Current `Driver`.\n * @param buildOptions Optional settings.\n * @param alias Alias parts.\n *\n * @return An alias that is no longer than the divers max alias length.\n */\n static buildAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | undefined,\n ...alias: string[]\n ): string {\n const joiner =\n buildOptions && buildOptions.joiner ? buildOptions.joiner : \"_\"\n\n let newAlias = alias.length === 1 ? alias[0] : alias.join(joiner)\n\n if (\n maxAliasLength &&\n maxAliasLength > 0 &&\n newAlias.length > maxAliasLength\n ) {\n if (buildOptions && buildOptions.shorten === true) {\n const shortenedAlias = shorten(newAlias)\n if (shortenedAlias.length < maxAliasLength) {\n return shortenedAlias\n }\n }\n\n return hash(newAlias, { length: maxAliasLength })\n }\n\n return newAlias\n }\n\n /**\n * @deprecated use `buildAlias` instead.\n */\n static buildColumnAlias(\n { maxAliasLength }: Driver,\n buildOptions: { shorten?: boolean; joiner?: string } | string,\n ...alias: string[]\n ) {\n if (typeof buildOptions === \"string\") {\n alias.unshift(buildOptions)\n buildOptions = { shorten: false, joiner: \"_\" }\n } else {\n buildOptions = Object.assign(\n { shorten: false, joiner: \"_\" },\n buildOptions,\n )\n }\n return this.buildAlias(\n { maxAliasLength } as Driver,\n buildOptions,\n ...alias,\n )\n }\n\n // -------------------------------------------------------------------------\n // Private Static Methods\n // -------------------------------------------------------------------------\n\n /**\n * Extracts connection data from the connection url.\n */\n private static parseConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n // remove mongodb query params\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n const [host, port] = hostAndPort.split(\":\")\n\n return {\n type: type,\n host: host,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n }\n\n /**\n * Extracts connection data from the connection url for MongoDB to support replica set.\n */\n private static parseMongoDBConnectionUrl(url: string) {\n const type = url.split(\":\")[0]\n const firstSlashes = url.indexOf(\"//\")\n const preBase = url.substr(firstSlashes + 2)\n const secondSlash = preBase.indexOf(\"/\")\n const base =\n secondSlash !== -1 ? preBase.substr(0, secondSlash) : preBase\n let afterBase =\n secondSlash !== -1 ? preBase.substr(secondSlash + 1) : undefined\n let afterQuestionMark = \"\"\n let host = undefined\n let port = undefined\n let hostReplicaSet = undefined\n let replicaSet = undefined\n\n let optionsObject: any = {}\n\n if (afterBase && afterBase.indexOf(\"?\") !== -1) {\n // split params\n afterQuestionMark = afterBase.substr(\n afterBase.indexOf(\"?\") + 1,\n afterBase.length,\n )\n\n const optionsList = afterQuestionMark.split(\"&\")\n let optionKey: string\n let optionValue: string\n\n // create optionsObject for merge with connectionUrl object before return\n optionsList.forEach((optionItem) => {\n optionKey = optionItem.split(\"=\")[0]\n optionValue = optionItem.split(\"=\")[1]\n optionsObject[optionKey] = optionValue\n })\n\n // specific replicaSet value to set options about hostReplicaSet\n replicaSet = optionsObject[\"replicaSet\"]\n afterBase = afterBase.substr(0, afterBase.indexOf(\"?\"))\n }\n\n const lastAtSign = base.lastIndexOf(\"@\")\n const usernameAndPassword = base.substr(0, lastAtSign)\n const hostAndPort = base.substr(lastAtSign + 1)\n\n let username = usernameAndPassword\n let password = \"\"\n const firstColon = usernameAndPassword.indexOf(\":\")\n if (firstColon !== -1) {\n username = usernameAndPassword.substr(0, firstColon)\n password = usernameAndPassword.substr(firstColon + 1)\n }\n\n // If replicaSet have value set It as hostlist, If not set like standalone host\n if (replicaSet) {\n hostReplicaSet = hostAndPort\n } else {\n ;[host, port] = hostAndPort.split(\":\")\n }\n\n let connectionUrl: any = {\n type: type,\n host: host,\n hostReplicaSet: hostReplicaSet,\n username: decodeURIComponent(username),\n password: decodeURIComponent(password),\n port: port ? parseInt(port) : undefined,\n database: afterBase || undefined,\n }\n\n // Loop to set every options in connectionUrl to object\n for (const [key, value] of Object.entries(optionsObject)) {\n connectionUrl[key] = value\n }\n\n return connectionUrl\n }\n}\n"],"sourceRoot":".."}