typeorm 0.3.27-dev.6965fa2 → 0.3.27-dev.f3c8d2f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/query-builder/SelectQueryBuilder.js +5 -0
- package/browser/query-builder/SelectQueryBuilder.js.map +1 -1
- package/browser/util/StringUtils.d.ts +1 -1
- package/browser/util/StringUtils.js +2 -2
- package/browser/util/StringUtils.js.map +1 -1
- package/package.json +1 -1
- package/query-builder/SelectQueryBuilder.js +5 -0
- package/query-builder/SelectQueryBuilder.js.map +1 -1
- package/util/StringUtils.d.ts +1 -1
- package/util/StringUtils.js +2 -2
- package/util/StringUtils.js.map +1 -1
package/util/StringUtils.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ interface IHashOptions {
|
|
|
54
54
|
length?: number;
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
* Returns a
|
|
57
|
+
* Returns a SHA-1 hex digest for internal IDs/aliases (not for cryptographic security)
|
|
58
58
|
*
|
|
59
59
|
* @param input String to be hashed.
|
|
60
60
|
* @param options.length Optionally, shorten the output to desired length.
|
package/util/StringUtils.js
CHANGED
|
@@ -95,7 +95,7 @@ function shorten(input, options = {}) {
|
|
|
95
95
|
return shortSegments.join(separator);
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
|
-
* Returns a
|
|
98
|
+
* Returns a SHA-1 hex digest for internal IDs/aliases (not for cryptographic security)
|
|
99
99
|
*
|
|
100
100
|
* @param input String to be hashed.
|
|
101
101
|
* @param options.length Optionally, shorten the output to desired length.
|
|
@@ -104,7 +104,7 @@ function hash(input, options = {}) {
|
|
|
104
104
|
const hashFunction = (0, sha_js_1.default)("sha1");
|
|
105
105
|
hashFunction.update(input, "utf8");
|
|
106
106
|
const hashedInput = hashFunction.digest("hex");
|
|
107
|
-
if (options.length) {
|
|
107
|
+
if (options.length && options.length > 0) {
|
|
108
108
|
return hashedInput.slice(0, options.length);
|
|
109
109
|
}
|
|
110
110
|
return hashedInput;
|
package/util/StringUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/StringUtils.ts"],"names":[],"mappings":";;AAOA,8BAMC;AAMD,8BASC;AAOD,8BAKC;AAKD,gCAQC;AAiCD,0BAoBC;AAYD,oBAQC;;AA9HD,4DAA0B;AAE1B;;;;GAIG;AACH,SAAgB,SAAS,CAAC,GAAW,EAAE,eAAwB,KAAK;IAChE,IAAI,YAAY;QAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAA;IACjC,OAAO,GAAG,CAAC,OAAO,CAAC,sBAAsB,EAAE,UAAU,KAAK,EAAE,EAAE,EAAE,EAAE;QAC9D,IAAI,EAAE;YAAE,OAAO,EAAE,CAAC,WAAW,EAAE,CAAA;QAC/B,OAAO,EAAE,CAAC,WAAW,EAAE,CAAA;IAC3B,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;GAGG;AACH,SAAgB,SAAS,CAAC,GAAW;IACjC,OAAO,CACH,GAAG;QACC,cAAc;SACb,OAAO,CAAC,wBAAwB,EAAE,SAAS,CAAC;QAC7C,YAAY;SACX,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE,CACrB,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,SAAgB,SAAS,CAAC,GAAW;IACjC,OAAO,GAAG,CAAC,OAAO,CACd,QAAQ,EACR,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CACrE,CAAA;AACL,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,GAAW,EAAE,mBAA2B,CAAC;IAChE,MAAM,KAAK,GAAG,GAAG;SACZ,OAAO,CAAC,kCAAkC,EAAE,OAAO,CAAC;SACpD,KAAK,CAAC,GAAG,CAAC,CAAA;IACf,OAAO,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N,OAAO,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACxC,CAAC;AAMD;;;;;GAKG;AACH,SAAgB,IAAI,CAAC,KAAa,EAAE,UAAwB,EAAE;IAC1D,MAAM,YAAY,GAAG,IAAA,gBAAK,EAAC,MAAM,CAAC,CAAA;IAClC,YAAY,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IAClC,MAAM,WAAW,GAAG,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC9C,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvC,OAAO,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IACD,OAAO,WAAW,CAAA;AACtB,CAAC","file":"StringUtils.js","sourcesContent":["import shajs from \"sha.js\"\n\n/**\n * Converts string into camelCase.\n *\n * @see http://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case\n */\nexport function camelCase(str: string, firstCapital: boolean = false): string {\n if (firstCapital) str = \" \" + str\n return str.replace(/^([A-Z])|[\\s-_](\\w)/g, function (match, p1, p2) {\n if (p2) return p2.toUpperCase()\n return p1.toLowerCase()\n })\n}\n\n/**\n * Converts string into snake_case.\n *\n */\nexport function snakeCase(str: string): string {\n return (\n str\n // ABc -> a_bc\n .replace(/([A-Z])([A-Z])([a-z])/g, \"$1_$2$3\")\n // aC -> a_c\n .replace(/([a-z0-9])([A-Z])/g, \"$1_$2\")\n .toLowerCase()\n )\n}\n\n/**\n * Converts string into Title Case.\n *\n * @see http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript\n */\nexport function titleCase(str: string): string {\n return str.replace(\n /\\w\\S*/g,\n (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(),\n )\n}\n\n/**\n * Builds abbreviated string from given string;\n */\nexport function abbreviate(str: string, abbrLettersCount: number = 1): string {\n const words = str\n .replace(/([a-z\\xE0-\\xFF])([A-Z\\xC0\\xDF])/g, \"$1 $2\")\n .split(\" \")\n return words.reduce((res, word) => {\n res += word.substr(0, abbrLettersCount)\n return res\n }, \"\")\n}\n\nexport interface IShortenOptions {\n /** String used to split \"segments\" of the alias/column name */\n separator?: string\n /** Maximum length of any \"segment\" */\n segmentLength?: number\n /** Length of any \"term\" in a \"segment\"; \"OrderItem\" is a segment, \"Order\" and \"Items\" are terms */\n termLength?: number\n}\n\n/**\n * Shorten a given `input`. Useful for RDBMS imposing a limit on the\n * maximum length of aliases and column names in SQL queries.\n *\n * @param input String to be shortened.\n * @param options Default to `4` for segments length, `2` for terms length, `'__'` as a separator.\n *\n * @return Shortened `input`.\n *\n * @example\n * // returns: \"UsShCa__orde__mark__dire\"\n * shorten('UserShoppingCart__order__market__director')\n *\n * // returns: \"cat_wit_ver_lon_nam_pos_wit_ver_lon_nam_pos_wit_ver_lon_nam\"\n * shorten(\n * 'category_with_very_long_name_posts_with_very_long_name_post_with_very_long_name',\n * { separator: '_', segmentLength: 3 }\n * )\n *\n * // equals: UsShCa__orde__mark_market_id\n * `${shorten('UserShoppingCart__order__market')}_market_id`\n */\nexport function shorten(input: string, options: IShortenOptions = {}): string {\n const { segmentLength = 4, separator = \"__\", termLength = 2 } = options\n\n const segments = input.split(separator)\n const shortSegments = segments.reduce((acc: string[], val: string) => {\n // split the given segment into many terms based on an eventual camel cased name\n const segmentTerms = val\n .replace(/([a-z\\xE0-\\xFF])([A-Z\\xC0-\\xDF])/g, \"$1 $2\")\n .split(\" \")\n // \"OrderItemList\" becomes \"OrItLi\", while \"company\" becomes \"comp\"\n const length = segmentTerms.length > 1 ? termLength : segmentLength\n const shortSegment = segmentTerms\n .map((term) => term.substr(0, length))\n .join(\"\")\n\n acc.push(shortSegment)\n return acc\n }, [])\n\n return shortSegments.join(separator)\n}\n\ninterface IHashOptions {\n length?: number\n}\n\n/**\n * Returns a SHA-1 hex digest for internal IDs/aliases (not for cryptographic security)\n *\n * @param input String to be hashed.\n * @param options.length Optionally, shorten the output to desired length.\n */\nexport function hash(input: string, options: IHashOptions = {}): string {\n const hashFunction = shajs(\"sha1\")\n hashFunction.update(input, \"utf8\")\n const hashedInput = hashFunction.digest(\"hex\")\n if (options.length && options.length > 0) {\n return hashedInput.slice(0, options.length)\n }\n return hashedInput\n}\n"],"sourceRoot":".."}
|