From 0e884344ddbdd6f5d142193e120c2cee45539052 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 7 Jul 2020 21:08:29 +0000 Subject: [PATCH 1/4] chore(deps): bump npm from 6.14.4 to 6.14.6 Bumps [npm](https://github.com/npm/cli) from 6.14.4 to 6.14.6. - [Release notes](https://github.com/npm/cli/releases) - [Changelog](https://github.com/npm/cli/blob/latest/CHANGELOG.md) - [Commits](https://github.com/npm/cli/compare/v6.14.4...v6.14.6) Signed-off-by: dependabot[bot] --- yarn.lock | 241 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 140 insertions(+), 101 deletions(-) diff --git a/yarn.lock b/yarn.lock index 40238cd..6f7f03e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1564,7 +1564,7 @@ aggregate-error@^3.0.0: clean-stack "^2.0.0" indent-string "^4.0.0" -ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: +ajv@^6.10.0, ajv@^6.10.2: version "6.12.0" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.0.tgz#06d60b96d87b8454a5adaba86e7854da629db4b7" integrity sha512-D6gFiFA0RRLyUbvijN74DWAjXSFxWKaWP7mldxkVhyhAV3+SWA9HEJPHQ2c9soIeTFJqcSdFDGFgdqs1iUU2Hw== @@ -1574,6 +1574,16 @@ ajv@^6.10.0, ajv@^6.10.2, ajv@^6.5.5: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ajv@^6.5.5: + version "6.12.3" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.3.tgz#18c5af38a111ddeb4f2697bd78d68abc1cabd706" + integrity sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + ansi-align@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-2.0.0.tgz#c36aeccba563b89ceb556f3690f0b1d9e3547f7f" @@ -1787,9 +1797,9 @@ aws-sign2@~0.7.0: integrity sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg= aws4@^1.8.0: - version "1.9.1" - resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e" - integrity sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug== + version "1.10.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.0.tgz#a17b3a8ea811060e74d47d306122400ad4497ae2" + integrity sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA== babel-jest@^25.2.6: version "25.2.6" @@ -2593,7 +2603,7 @@ debug@^3.1.0: dependencies: ms "^2.1.1" -debuglog@^1.0.1: +debuglog@*, debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" integrity sha1-qiT/uaw9+aI1GDfPstJ5NgzXhJI= @@ -2881,21 +2891,21 @@ error-ex@^1.2.0, error-ex@^1.3.1: is-arrayish "^0.2.1" es-abstract@^1.17.0-next.1, es-abstract@^1.17.5: - version "1.17.5" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.5.tgz#d8c9d1d66c8981fb9200e2251d799eee92774ae9" - integrity sha512-BR9auzDbySxOcfog0tLECW8l28eRGpDpU3Dm3Hp4q/N+VtLTmyj4EUN088XZWQDW/hzj6sYRDXeOFsaAODKvpg== + version "1.17.6" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" + integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== dependencies: es-to-primitive "^1.2.1" function-bind "^1.1.1" has "^1.0.3" has-symbols "^1.0.1" - is-callable "^1.1.5" - is-regex "^1.0.5" + is-callable "^1.2.0" + is-regex "^1.1.0" object-inspect "^1.7.0" object-keys "^1.1.1" object.assign "^4.1.0" - string.prototype.trimleft "^2.1.1" - string.prototype.trimright "^2.1.1" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" es-to-primitive@^1.2.1: version "1.2.1" @@ -3223,9 +3233,9 @@ extsprintf@^1.2.0: integrity sha1-4mifjzVvrWLMplo6kcXfX5VRaS8= fast-deep-equal@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" - integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== + version "3.1.3" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" + integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== fast-diff@^1.1.2: version "1.2.0" @@ -3645,10 +3655,10 @@ got@^6.7.1: unzip-response "^2.0.1" url-parse-lax "^1.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3: - version "4.2.3" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423" - integrity sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ== +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.2.0, graceful-fs@^4.2.2, graceful-fs@^4.2.3, graceful-fs@^4.2.4: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== growly@^1.3.0: version "1.3.0" @@ -3904,7 +3914,7 @@ import-local@^3.0.2: pkg-dir "^4.2.0" resolve-cwd "^3.0.0" -imurmurhash@^0.1.4: +imurmurhash@*, imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= @@ -4034,10 +4044,10 @@ is-buffer@^1.1.5: resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== -is-callable@^1.1.4, is-callable@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" - integrity sha512-ESKv5sMCJB2jnHTWZ3O5itG+O128Hsus4K4Qh1h2/cgn2vbgnLSVqfV46AeJA9D5EeeLa9w81KUXMtn34zhX+Q== +is-callable@^1.1.4, is-callable@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" + integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw== is-ci@^1.0.10: version "1.2.1" @@ -4054,9 +4064,9 @@ is-ci@^2.0.0: ci-info "^2.0.0" is-cidr@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/is-cidr/-/is-cidr-3.1.0.tgz#72e233d8e1c4cd1d3f11713fcce3eba7b0e3476f" - integrity sha512-3kxTForpuj8O4iHn0ocsn1jxRm5VYm60GDghK6HXmpn4IyZOoRy9/GmdjFA2yEMqw91TB1/K3bFTuI7FlFNR1g== + version "3.1.1" + resolved "https://registry.yarnpkg.com/is-cidr/-/is-cidr-3.1.1.tgz#e92ef121bdec2782271a77ce487a8b8df3718ab7" + integrity sha512-Gx+oErgq1j2jAKCR2Kbq0b3wbH0vQKqZ0wOlHxm0o56nq51Cs/DZA8oz9dMDhbHyHEGgJ86eTeVudtgMMOx3Mw== dependencies: cidr-regex "^2.0.10" @@ -4209,12 +4219,12 @@ is-redirect@^1.0.0: resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24" integrity sha1-HQPd7VO9jbDzDCbk+V02/HyH3CQ= -is-regex@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.5.tgz#39d589a358bf18967f726967120b8fc1aed74eae" - integrity sha512-vlKW17SNq44owv5AQR3Cq0bQPEb8+kF3UKZ2fiZNOWtztYE5i0CzCZxFDwO58qAOWtxdBRVO/V5Qin1wjCqFYQ== +is-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.0.tgz#ece38e389e490df0dc21caea2bd596f987f767ff" + integrity sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw== dependencies: - has "^1.0.3" + has-symbols "^1.0.1" is-relative@^1.0.0: version "1.0.0" @@ -5190,6 +5200,11 @@ lockfile@^1.0.4: dependencies: signal-exit "^3.0.2" +lodash._baseindexof@*: + version "3.1.0" + resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" + integrity sha1-/lK1OhxnYeQmGNZU5KJXie1hgiw= + lodash._baseuniq@~4.6.0: version "4.6.0" resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" @@ -5198,11 +5213,33 @@ lodash._baseuniq@~4.6.0: lodash._createset "~4.0.0" lodash._root "~3.0.0" +lodash._bindcallback@*: + version "3.0.1" + resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" + integrity sha1-5THCdkTPi1epnhftlbNcdIeJOS4= + +lodash._cacheindexof@*: + version "3.0.2" + resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" + integrity sha1-PcaayCSY0u5ePOVgkbr9Ktx73pI= + +lodash._createcache@*: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" + integrity sha1-VtagZAF2JeeevKa4AY4XRAvc8JM= + dependencies: + lodash._getnative "^3.0.0" + lodash._createset@~4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" integrity sha1-D0ZZ+7CddRlPqeK4imZE02PJ/iY= +lodash._getnative@*, lodash._getnative@^3.0.0: + version "3.9.1" + resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" + integrity sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U= + lodash._root@~3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._root/-/lodash._root-3.0.1.tgz#fba1c4524c19ee9a5f8136b4609f017cf4ded692" @@ -5248,6 +5285,11 @@ lodash.memoize@4.x: resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe" integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4= +lodash.restparam@*: + version "3.6.1" + resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" + integrity sha1-k2pOMJ7zMKdkXtQUWYbIWuWyCAU= + lodash.sortby@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" @@ -5492,17 +5534,17 @@ micromatch@^3.1.4: snapdragon "^0.8.1" to-regex "^3.0.2" -mime-db@1.43.0: - version "1.43.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.43.0.tgz#0a12e0502650e473d735535050e7c8f4eb4fae58" - integrity sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ== +mime-db@1.44.0: + version "1.44.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.44.0.tgz#fa11c5eb0aca1334b4233cb4d52f10c5a6272f92" + integrity sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg== mime-types@^2.1.12, mime-types@~2.1.19: - version "2.1.26" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.26.tgz#9c921fc09b7e149a65dfdc0da4d20997200b0a06" - integrity sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ== + version "2.1.27" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.27.tgz#47949f98e279ea53119f5722e0f34e529bec009f" + integrity sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w== dependencies: - mime-db "1.43.0" + mime-db "1.44.0" mime@^2.4.3: version "2.4.4" @@ -5583,7 +5625,7 @@ mkdirp@1.x, mkdirp@^1.0.3: resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== -mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.4, mkdirp@~0.5.0: +mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@^0.5.5, mkdirp@~0.5.0: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== @@ -5708,9 +5750,9 @@ node-fetch@^2.3.0: integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA== node-gyp@^5.0.2, node-gyp@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-5.1.0.tgz#8e31260a7af4a2e2f994b0673d4e0b3866156332" - integrity sha512-OUTryc5bt/P8zVgNUmC6xdXiDJxLMAW8cF5tLQOT9E5sOQj+UeQxnnPy74K3CLCa/SOjjBlbuzDLR8ANwA+wmw== + version "5.1.1" + resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-5.1.1.tgz#eb915f7b631c937d282e33aed44cb7a025f62a3e" + integrity sha512-WH0WKGi+a4i4DUt2mHnvocex/xPLp9pYt5R6M2JdFB7pJ7Z34hveZ4nDTGTiLXCkitA9T8HFZjhinBCiVHYcWw== dependencies: env-paths "^2.2.0" glob "^7.1.4" @@ -5750,7 +5792,7 @@ node-releases@^1.1.53: resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.53.tgz#2d821bfa499ed7c5dffc5e2f28c88e78a08ee3f4" integrity sha512-wp8zyQVwef2hpZ/dJH7SfSrIPD6YoJz6BDQDpGEkcA0s3LpAQoxBIYmfIq6QAhC1DhwsyCgTaTTcONwX8qzCuQ== -nopt@^4.0.1, nopt@~4.0.1: +nopt@^4.0.1, nopt@^4.0.3: version "4.0.3" resolved "https://registry.yarnpkg.com/nopt/-/nopt-4.0.3.tgz#a375cad9d02fd921278d954c2254d5aa57e15e48" integrity sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg== @@ -5873,10 +5915,10 @@ npm-profile@^4.0.2, npm-profile@^4.0.4: figgy-pudding "^3.4.1" npm-registry-fetch "^4.0.0" -npm-registry-fetch@^4.0.0, npm-registry-fetch@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/npm-registry-fetch/-/npm-registry-fetch-4.0.3.tgz#3c2179e39e04f9348b1c2979545951d36bee8766" - integrity sha512-WGvUx0lkKFhu9MbiGFuT9nG2NpfQ+4dCJwRwwtK2HK5izJEvwDxMeUyqbuMS7N/OkpVCqDorV6rO5E4V9F8lJw== +npm-registry-fetch@^4.0.0, npm-registry-fetch@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/npm-registry-fetch/-/npm-registry-fetch-4.0.5.tgz#cb87cf7f25bfb048d6c3ee19d115bebf93ea5bfa" + integrity sha512-yQ0/U4fYpCCqmueB2g8sc+89ckQ3eXpmU4+Yi2j5o/r0WkKvE2+Y0tK3DEILAtn2UaQTkjTHxIXe2/CSdit+/Q== dependencies: JSONStream "^1.3.4" bluebird "^3.5.1" @@ -5913,9 +5955,9 @@ npm-user-validate@~1.0.0: integrity sha1-jOyg9c6gTU6TUZ73LQVXp1Ei6VE= npm@^6.10.3: - version "6.14.4" - resolved "https://registry.yarnpkg.com/npm/-/npm-6.14.4.tgz#50a1c6274fb451ca18f6ff472d2a73f006adbd66" - integrity sha512-B8UDDbWvdkW6RgXFn8/h2cHJP/u/FPa4HWeGzW23aNEBARN3QPrRaHqPIZW2NSN3fW649gtgUDNZpaRs0zTMPw== + version "6.14.6" + resolved "https://registry.yarnpkg.com/npm/-/npm-6.14.6.tgz#1a81ce1fac2bf5457dbf6342ceed503627ff228f" + integrity sha512-axnz6iHFK6WPE0js/+mRp+4IOwpHn5tJEw5KB6FiCU764zmffrhsYHbSHi2kKqNkRBt53XasXjngZfBD3FQzrQ== dependencies: JSONStream "^1.3.5" abbrev "~1.1.1" @@ -5935,6 +5977,7 @@ npm@^6.10.3: cmd-shim "^3.0.3" columnify "~1.5.4" config-chain "^1.1.12" + debuglog "*" detect-indent "~5.0.0" detect-newline "^2.1.0" dezalgo "~1.0.3" @@ -5945,10 +5988,11 @@ npm@^6.10.3: fs-write-stream-atomic "~1.0.10" gentle-fs "^2.3.0" glob "^7.1.6" - graceful-fs "^4.2.3" + graceful-fs "^4.2.4" has-unicode "~2.0.1" hosted-git-info "^2.8.8" iferr "^1.0.2" + imurmurhash "*" infer-owner "^1.0.4" inflight "~1.0.6" inherits "^2.0.4" @@ -5967,18 +6011,24 @@ npm@^6.10.3: libnpx "^10.2.2" lock-verify "^2.1.0" lockfile "^1.0.4" + lodash._baseindexof "*" lodash._baseuniq "~4.6.0" + lodash._bindcallback "*" + lodash._cacheindexof "*" + lodash._createcache "*" + lodash._getnative "*" lodash.clonedeep "~4.5.0" + lodash.restparam "*" lodash.union "~4.6.0" lodash.uniq "~4.5.0" lodash.without "~4.4.0" lru-cache "^5.1.1" meant "~1.0.1" mississippi "^3.0.0" - mkdirp "^0.5.4" + mkdirp "^0.5.5" move-concurrently "^1.0.1" node-gyp "^5.1.0" - nopt "~4.0.1" + nopt "^4.0.3" normalize-package-data "^2.5.0" npm-audit-report "^1.3.2" npm-cache-filename "~1.0.2" @@ -5988,7 +6038,7 @@ npm@^6.10.3: npm-packlist "^1.4.8" npm-pick-manifest "^3.0.2" npm-profile "^4.0.4" - npm-registry-fetch "^4.0.3" + npm-registry-fetch "^4.0.5" npm-user-validate "~1.0.0" npmlog "~4.1.2" once "~1.4.0" @@ -6073,9 +6123,9 @@ object-copy@^0.1.0: kind-of "^3.0.3" object-inspect@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" - integrity sha512-a7pEHdh1xKIAgTySUGgLMx/xwDZskN1Ud6egYYN3EdRW4ZMPNEDUTF+hwy2LUC+Bl+SyLXANnwz/jyh/qutKUw== + version "1.8.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" + integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" @@ -6695,9 +6745,9 @@ qs@~6.5.2: integrity sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA== query-string@^6.8.2: - version "6.12.0" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.12.0.tgz#fa0fe5b3ddf4d040d1236b80672949ab33d5cf80" - integrity sha512-aoiFW9ZU7jP8Itjqfpw80Qe7RoyCIhFrW522sdsp9LG92pat6CCG3d8qNZBaUi71FsEjIfLjx9Ky347FtVoqXA== + version "6.13.1" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-6.13.1.tgz#d913ccfce3b4b3a713989fe6d39466d92e71ccad" + integrity sha512-RfoButmcK+yCta1+FuU8REvisx1oEzhMKwhLUNcepQTPGcNMp1sIqjnfCtfnvGSQZQEhaBHvccujtWoUV3TTbA== dependencies: decode-uri-component "^0.2.0" split-on-first "^1.0.0" @@ -7085,13 +7135,20 @@ resolve@1.1.7: resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" integrity sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= -resolve@1.x, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.15.1, resolve@^1.3.2: +resolve@1.x, resolve@^1.1.7, resolve@^1.15.1, resolve@^1.3.2: version "1.15.1" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8" integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w== dependencies: path-parse "^1.0.6" +resolve@^1.10.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" + integrity sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== + dependencies: + path-parse "^1.0.6" + restore-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" @@ -7173,9 +7230,9 @@ rxjs@^6.5.3: tslib "^1.9.0" safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519" - integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg== + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.2" @@ -7512,22 +7569,22 @@ spawn-error-forwarder@~1.0.0: integrity sha1-Gv2Uc46ZmwNG17n8NzvlXgdXcCk= spdx-correct@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.0.tgz#fb83e504445268f154b074e218c87c003cd31df4" - integrity sha512-lr2EZCctC2BNR7j7WzJ2FpDznxky1sjfxvvYEyzxNyb6lZXHODmEoJeFu4JupYlkfha1KZpJyoqiJ7pgA1qq8Q== + version "3.1.1" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.1.1.tgz#dece81ac9c1e6713e5f7d1b6f17d468fa53d89a9" + integrity sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w== dependencies: spdx-expression-parse "^3.0.0" spdx-license-ids "^3.0.0" spdx-exceptions@^2.1.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.2.0.tgz#2ea450aee74f2a89bfb94519c07fcd6f41322977" - integrity sha512-2XQACfElKi9SlVb1CYadKDXvoajPgBVPn/gOQLrTvHdElaVhr7ZEbqJaRnJLVNeaI4cMEAgVCeBMKF6MWRDCRA== + version "2.3.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d" + integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A== spdx-expression-parse@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" - integrity sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg== + version "3.0.1" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679" + integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q== dependencies: spdx-exceptions "^2.1.0" spdx-license-ids "^3.0.0" @@ -7692,36 +7749,18 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string.prototype.trimend@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.0.tgz#ee497fd29768646d84be2c9b819e292439614373" - integrity sha512-EEJnGqa/xNfIg05SxiPSqRS7S9qwDhYts1TSLR1BQfYUfPe1stofgGKvwERK9+9yf+PpfBMlpBaCHucXGPQfUA== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - -string.prototype.trimleft@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/string.prototype.trimleft/-/string.prototype.trimleft-2.1.2.tgz#4408aa2e5d6ddd0c9a80739b087fbc067c03b3cc" - integrity sha512-gCA0tza1JBvqr3bfAIFJGqfdRTyPae82+KTnm3coDXkZN9wnuW3HjGgN386D7hfv5CHQYCI022/rJPVlqXyHSw== - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - string.prototype.trimstart "^1.0.0" - -string.prototype.trimright@^2.1.1: - version "2.1.2" - resolved "https://registry.yarnpkg.com/string.prototype.trimright/-/string.prototype.trimright-2.1.2.tgz#c76f1cef30f21bbad8afeb8db1511496cfb0f2a3" - integrity sha512-ZNRQ7sY3KroTaYjRS6EbNiiHrOkjihL9aQE/8gfQ4DtAC/aEBRHFJa44OmoWxGGqXuJlfKkZW4WcXErGr+9ZFg== +string.prototype.trimend@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" + integrity sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g== dependencies: define-properties "^1.1.3" es-abstract "^1.17.5" - string.prototype.trimend "^1.0.0" -string.prototype.trimstart@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.0.tgz#afe596a7ce9de905496919406c9734845f01a2f2" - integrity sha512-iCP8g01NFYiiBOnwG1Xc3WZLyoo+RuBymwIlWncShXDDJYWN6DbnM3odslBJdgCdRlq94B5s63NWAZlcn2CS4w== +string.prototype.trimstart@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" + integrity sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw== dependencies: define-properties "^1.1.3" es-abstract "^1.17.5" From 6f23707c3b365b143d77f14bf4614bd59fff38b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jul 2020 11:13:23 +0000 Subject: [PATCH 2/4] chore(deps): bump lodash from 4.17.15 to 4.17.19 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 40238cd..b074d83 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5279,9 +5279,9 @@ lodash.without@~4.4.0: integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw= lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.19" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" + integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== lolex@^5.0.0: version "5.1.2" From 847d1745df243bcaa364d4dc60a0f780262136e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2020 12:36:31 +0000 Subject: [PATCH 3/4] chore(deps): bump lodash from 4.17.15 to 4.17.20 Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.20. - [Release notes](https://github.com/lodash/lodash/releases) - [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.20) Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6f7f03e..7077d66 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5321,9 +5321,9 @@ lodash.without@~4.4.0: integrity sha1-PNRXSgC2e643OpS3SHcmQFB7eqw= lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.4: - version "4.17.15" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + version "4.17.20" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52" + integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA== lolex@^5.0.0: version "5.1.2" From 9e144eb702f29bc9b30f4b6b49997f77c6439a00 Mon Sep 17 00:00:00 2001 From: Ivan Hell Date: Thu, 27 Aug 2020 15:55:26 +0200 Subject: [PATCH 4/4] feat: export function for reading/writing model/collection versions directly --- src/abstract-migrator.spec.ts | 19 ++++++- src/index.ts | 16 ++++-- src/mongodb-collection-migrator.ts | 18 ------- ...mongodb-collection-version-storage.spec.ts | 33 ++++++++++++ src/mongodb-collection-version-storage.ts | 5 -- src/mongodb-collection-versioning-utils.ts | 50 ++++++++++++++++++ src/mongoose-model-migrator.ts | 18 ------- src/mongoose-model-versioning-utils.ts | 51 +++++++++++++++++++ 8 files changed, 164 insertions(+), 46 deletions(-) create mode 100644 src/mongodb-collection-version-storage.spec.ts create mode 100644 src/mongodb-collection-versioning-utils.ts create mode 100644 src/mongoose-model-versioning-utils.ts diff --git a/src/abstract-migrator.spec.ts b/src/abstract-migrator.spec.ts index 8c12fe0..8168192 100644 --- a/src/abstract-migrator.spec.ts +++ b/src/abstract-migrator.spec.ts @@ -34,7 +34,7 @@ class TestVersionStorage implements VersionStorage { } describe('AbstractMigrator', () => { - test('Migrator should not update is existing version matches target version', async () => { + test('Migrator should not update if existing version matches target version', async () => { const initialVersion = { current: 1, updated: new Date() }; const versionStorage = new TestVersionStorage(initialVersion); const migrator = new TestMigrator(versionStorage); @@ -50,4 +50,21 @@ describe('AbstractMigrator', () => { expect(writeVersionSpy).toHaveBeenCalledTimes(0); expect(readVersionSpy).toHaveBeenCalledTimes(1); }); + + test('Migrator should update if current version is lower than target version', async () => { + const initialVersion = { current: 1, updated: new Date() }; + const versionStorage = new TestVersionStorage(initialVersion); + const migrator = new TestMigrator(versionStorage); + const upgradeSpy = jest.spyOn(migrator, 'upgrade'); + const downgradeSpy = jest.spyOn(migrator, 'downgrade'); + const writeVersionSpy = jest.spyOn(versionStorage, 'writeVersion'); + const readVersionSpy = jest.spyOn(versionStorage, 'readVersion'); + + const result = await migrator.migrate(2); + expect(result).toMatchObject({ last: 1, current: 2, updated: expect.any(Date) }); + expect(upgradeSpy).toHaveBeenCalledTimes(1); + expect(downgradeSpy).toHaveBeenCalledTimes(0); + expect(writeVersionSpy).toHaveBeenCalledTimes(1); + expect(readVersionSpy).toHaveBeenCalledTimes(1); + }); }); diff --git a/src/index.ts b/src/index.ts index 297434e..3ea7412 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,15 @@ export { AbstractMigrator, VersionInformation, VersionStorage } from './abstract-migrator'; +export { CollectionMigrationHandler } from './mongodb-collection-migrator'; +export { ModelMigrationHandler } from './mongoose-model-migrator'; export { - CollectionMigrationHandler, CollectionMigratorOptions, - migrateCollection -} from './mongodb-collection-migrator'; -export { ModelMigrationHandler, ModelMigratorOptions, migrateModel } from './mongoose-model-migrator'; + migrateCollection, + readCollectionVersion, + writeCollectionVersion +} from './mongodb-collection-versioning-utils'; +export { + ModelMigratorOptions, + migrateModel, + readModelVersion, + writeModelVersion +} from './mongoose-model-versioning-utils'; diff --git a/src/mongodb-collection-migrator.ts b/src/mongodb-collection-migrator.ts index 6df8d32..59c3718 100644 --- a/src/mongodb-collection-migrator.ts +++ b/src/mongodb-collection-migrator.ts @@ -2,7 +2,6 @@ import { Collection, Db } from 'mongodb'; import { AbstractMigrator } from './abstract-migrator'; import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage'; -import { getGlobalMongooseConnectionDb } from './utils'; // TODO: remove // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -31,20 +30,3 @@ export class CollectionMigrator extends AbstractMigrato throw new Error(`Downgrading a collection from version ${fromVersion} to ${toVersion} not supported yet!`); } } - -export interface CollectionMigratorOptions { - db?: Db; - versionCollectionName?: string; -} - -export async function migrateCollection( - collectionName: string, - version: number, - migrationHandler: CollectionMigrationHandler, - options?: CollectionMigratorOptions -): Promise { - const versionCollectionName = options?.versionCollectionName || `${collectionName}.version`; - const db = options?.db ?? (await getGlobalMongooseConnectionDb()); - const migrator = new CollectionMigrator(db, collectionName, versionCollectionName, migrationHandler); - await migrator.migrate(version); -} diff --git a/src/mongodb-collection-version-storage.spec.ts b/src/mongodb-collection-version-storage.spec.ts new file mode 100644 index 0000000..bf33418 --- /dev/null +++ b/src/mongodb-collection-version-storage.spec.ts @@ -0,0 +1,33 @@ +import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage'; +import { VersionInformation } from './abstract-migrator'; + +class VersionCollectionMock { + private versionInformation: VersionInformation | null; + + constructor(versionInformation?: VersionInformation) { + this.versionInformation = versionInformation ?? null; + } + + public async findOne(_filter: unknown): Promise { + return this.versionInformation; + } + public async insertOne(versionInformation: VersionInformation): Promise { + this.versionInformation = versionInformation; + } + public async findOneAndUpdate(filter: unknown, updateOptions: { $set: VersionInformation }): Promise { + this.versionInformation = { ...this.versionInformation, ...updateOptions.$set }; + } +} + +describe('MongodbCollectionVersionStorage', () => { + test('read version should return the current version information', async () => { + const currentVersion = { current: 1, updated: new Date() }; + const collectionMock = new VersionCollectionMock(currentVersion); + const versionStorage = new MongodbCollectionVersionStorage(collectionMock as any); + const findOneSpy = jest.spyOn(collectionMock, 'findOne'); + + const resultVersion = await versionStorage.readVersion(); + expect(resultVersion).toEqual(currentVersion); + expect(findOneSpy).toHaveBeenCalledWith({}); + }); +}); diff --git a/src/mongodb-collection-version-storage.ts b/src/mongodb-collection-version-storage.ts index 5ed05a0..757329d 100644 --- a/src/mongodb-collection-version-storage.ts +++ b/src/mongodb-collection-version-storage.ts @@ -27,8 +27,3 @@ export class MongodbCollectionVersionStorage implements VersionStorage { return this.versionCollection.findOne({}); } } - -/*protected getVersionCollection(): Collection { - const collectionName = this.options?.versionCollectionName || `${this.collectionName}.version`; - return connection.db.collection(collectionName); -}*/ diff --git a/src/mongodb-collection-versioning-utils.ts b/src/mongodb-collection-versioning-utils.ts new file mode 100644 index 0000000..c1130f4 --- /dev/null +++ b/src/mongodb-collection-versioning-utils.ts @@ -0,0 +1,50 @@ +import { Db } from 'mongodb'; + +import { VersionInformation } from './abstract-migrator'; +import { CollectionMigrationHandler, CollectionMigrator } from './mongodb-collection-migrator'; +import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage'; +import { getGlobalMongooseConnectionDb } from './utils'; + +export interface CollectionMigratorOptions { + db?: Db; + versionCollectionName?: string; +} + +async function sanitizeCollectionMigratorOptions( + collectionName: string, + options?: CollectionMigratorOptions +): Promise> { + const versionCollectionName = options?.versionCollectionName || `${collectionName}.version`; + const db = options?.db ?? (await getGlobalMongooseConnectionDb()); + return { db, versionCollectionName }; +} + +export async function migrateCollection( + collectionName: string, + version: number, + migrationHandler: CollectionMigrationHandler, + options?: CollectionMigratorOptions +): Promise { + const { db, versionCollectionName } = await sanitizeCollectionMigratorOptions(collectionName, options); + const migrator = new CollectionMigrator(db, collectionName, versionCollectionName, migrationHandler); + await migrator.migrate(version); +} + +export async function writeCollectionVersion( + collectionName: string, + version: number, + options?: CollectionMigratorOptions +): Promise { + const { db, versionCollectionName } = await sanitizeCollectionMigratorOptions(collectionName, options); + const versionStorage = new MongodbCollectionVersionStorage(db.collection(versionCollectionName)); + return versionStorage.writeVersion(version); +} + +export async function readCollectionVersion( + collectionName: string, + options?: CollectionMigratorOptions +): Promise { + const { db, versionCollectionName } = await sanitizeCollectionMigratorOptions(collectionName, options); + const versionStorage = new MongodbCollectionVersionStorage(db.collection(versionCollectionName)); + return versionStorage.readVersion(); +} diff --git a/src/mongoose-model-migrator.ts b/src/mongoose-model-migrator.ts index 7c99bae..b713e1e 100644 --- a/src/mongoose-model-migrator.ts +++ b/src/mongoose-model-migrator.ts @@ -3,7 +3,6 @@ import { Db } from 'mongodb'; import { AbstractMigrator } from './abstract-migrator'; import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage'; -import { getGlobalMongooseConnectionDb } from './utils'; export interface ModelMigrationHandler { up(db: Db, model: Model, fromVersion: number, toVersion: number): Promise; @@ -28,20 +27,3 @@ export class ModelMigrator extends AbstractMigr throw new Error(`Downgrading a model version from ${fromVersion} to ${toVersion} not supported yet!`); } } - -export interface ModelMigratorOptions { - db?: Db; - versionCollectionName?: string; -} - -export async function migrateModel( - model: Model, - version: number, - migrationHandler: ModelMigrationHandler, - options?: ModelMigratorOptions -): Promise { - const versionCollectionName = options?.versionCollectionName || `${model.collection.collectionName}.version`; - const db = options?.db ?? (await getGlobalMongooseConnectionDb()); - const migrator = new ModelMigrator(db, model, versionCollectionName, migrationHandler); - await migrator.migrate(version); -} diff --git a/src/mongoose-model-versioning-utils.ts b/src/mongoose-model-versioning-utils.ts new file mode 100644 index 0000000..aa5264f --- /dev/null +++ b/src/mongoose-model-versioning-utils.ts @@ -0,0 +1,51 @@ +import { Document, Model } from 'mongoose'; +import { Db } from 'mongodb'; + +import { ModelMigrationHandler, ModelMigrator } from './mongoose-model-migrator'; +import { getGlobalMongooseConnectionDb } from './utils'; +import { VersionInformation } from './abstract-migrator'; +import { MongodbCollectionVersionStorage } from './mongodb-collection-version-storage'; + +export interface ModelMigratorOptions { + db?: Db; + versionCollectionName?: string; +} + +async function sanitizeModelMigratorOptions( + model: Model, + options?: ModelMigratorOptions +): Promise> { + const versionCollectionName = options?.versionCollectionName || `${model.collection.collectionName}.version`; + const db = options?.db ?? (await getGlobalMongooseConnectionDb()); + return { db, versionCollectionName }; +} + +export async function migrateModel( + model: Model, + version: number, + migrationHandler: ModelMigrationHandler, + options?: ModelMigratorOptions +): Promise { + const { db, versionCollectionName } = await sanitizeModelMigratorOptions(model, options); + const migrator = new ModelMigrator(db, model, versionCollectionName, migrationHandler); + await migrator.migrate(version); +} + +export async function writeModelVersion( + model: Model, + version: number, + options?: ModelMigratorOptions +): Promise { + const { db, versionCollectionName } = await sanitizeModelMigratorOptions(model, options); + const versionStorage = new MongodbCollectionVersionStorage(db.collection(versionCollectionName)); + return versionStorage.writeVersion(version); +} + +export async function readModelVersion( + model: Model, + options?: ModelMigratorOptions +): Promise { + const { db, versionCollectionName } = await sanitizeModelMigratorOptions(model, options); + const versionStorage = new MongodbCollectionVersionStorage(db.collection(versionCollectionName)); + return versionStorage.readVersion(); +}