stockhub-sms 1.0.0

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 (2189) hide show
  1. package/.gitignore +35 -0
  2. package/README.md +303 -0
  3. package/backend-project/.env +3 -0
  4. package/backend-project/.env.example +3 -0
  5. package/backend-project/config/database.js +13 -0
  6. package/backend-project/controllers/authController.js +70 -0
  7. package/backend-project/controllers/productController.js +58 -0
  8. package/backend-project/controllers/reportController.js +206 -0
  9. package/backend-project/controllers/transactionController.js +199 -0
  10. package/backend-project/controllers/warehouseController.js +54 -0
  11. package/backend-project/middleware/auth.js +20 -0
  12. package/backend-project/models/Product.js +44 -0
  13. package/backend-project/models/StockTransaction.js +32 -0
  14. package/backend-project/models/User.js +18 -0
  15. package/backend-project/models/Warehouse.js +24 -0
  16. package/backend-project/node_modules/.bin/mime +16 -0
  17. package/backend-project/node_modules/.bin/mime.cmd +17 -0
  18. package/backend-project/node_modules/.bin/mime.ps1 +28 -0
  19. package/backend-project/node_modules/.bin/nodemon +16 -0
  20. package/backend-project/node_modules/.bin/nodemon.cmd +17 -0
  21. package/backend-project/node_modules/.bin/nodemon.ps1 +28 -0
  22. package/backend-project/node_modules/.bin/nodetouch +16 -0
  23. package/backend-project/node_modules/.bin/nodetouch.cmd +17 -0
  24. package/backend-project/node_modules/.bin/nodetouch.ps1 +28 -0
  25. package/backend-project/node_modules/.bin/semver +16 -0
  26. package/backend-project/node_modules/.bin/semver.cmd +17 -0
  27. package/backend-project/node_modules/.bin/semver.ps1 +28 -0
  28. package/backend-project/node_modules/.package-lock.json +1609 -0
  29. package/backend-project/node_modules/@mongodb-js/saslprep/LICENSE +22 -0
  30. package/backend-project/node_modules/@mongodb-js/saslprep/dist/.esm-wrapper.mjs +4 -0
  31. package/backend-project/node_modules/@mongodb-js/saslprep/dist/browser.d.ts +5 -0
  32. package/backend-project/node_modules/@mongodb-js/saslprep/dist/browser.d.ts.map +1 -0
  33. package/backend-project/node_modules/@mongodb-js/saslprep/dist/browser.js +12 -0
  34. package/backend-project/node_modules/@mongodb-js/saslprep/dist/browser.js.map +1 -0
  35. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts +3 -0
  36. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts.map +1 -0
  37. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js +5 -0
  38. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js.map +1 -0
  39. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts +3 -0
  40. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts.map +1 -0
  41. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data.js +5 -0
  42. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-data.js.map +1 -0
  43. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts +7 -0
  44. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts.map +1 -0
  45. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-src.js +881 -0
  46. package/backend-project/node_modules/@mongodb-js/saslprep/dist/code-points-src.js.map +1 -0
  47. package/backend-project/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts +2 -0
  48. package/backend-project/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts.map +1 -0
  49. package/backend-project/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js +83 -0
  50. package/backend-project/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js.map +1 -0
  51. package/backend-project/node_modules/@mongodb-js/saslprep/dist/index.d.ts +11 -0
  52. package/backend-project/node_modules/@mongodb-js/saslprep/dist/index.d.ts.map +1 -0
  53. package/backend-project/node_modules/@mongodb-js/saslprep/dist/index.js +65 -0
  54. package/backend-project/node_modules/@mongodb-js/saslprep/dist/index.js.map +1 -0
  55. package/backend-project/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts +10 -0
  56. package/backend-project/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts.map +1 -0
  57. package/backend-project/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js +32 -0
  58. package/backend-project/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js.map +1 -0
  59. package/backend-project/node_modules/@mongodb-js/saslprep/dist/node.d.ts +10 -0
  60. package/backend-project/node_modules/@mongodb-js/saslprep/dist/node.d.ts.map +1 -0
  61. package/backend-project/node_modules/@mongodb-js/saslprep/dist/node.js +15 -0
  62. package/backend-project/node_modules/@mongodb-js/saslprep/dist/node.js.map +1 -0
  63. package/backend-project/node_modules/@mongodb-js/saslprep/dist/util.d.ts +2 -0
  64. package/backend-project/node_modules/@mongodb-js/saslprep/dist/util.d.ts.map +1 -0
  65. package/backend-project/node_modules/@mongodb-js/saslprep/dist/util.js +11 -0
  66. package/backend-project/node_modules/@mongodb-js/saslprep/dist/util.js.map +1 -0
  67. package/backend-project/node_modules/@mongodb-js/saslprep/package.json +87 -0
  68. package/backend-project/node_modules/@mongodb-js/saslprep/readme.md +29 -0
  69. package/backend-project/node_modules/@types/node/LICENSE +21 -0
  70. package/backend-project/node_modules/@types/node/README.md +15 -0
  71. package/backend-project/node_modules/@types/node/assert/strict.d.ts +59 -0
  72. package/backend-project/node_modules/@types/node/assert.d.ts +950 -0
  73. package/backend-project/node_modules/@types/node/async_hooks.d.ts +711 -0
  74. package/backend-project/node_modules/@types/node/buffer.buffer.d.ts +466 -0
  75. package/backend-project/node_modules/@types/node/buffer.d.ts +1765 -0
  76. package/backend-project/node_modules/@types/node/child_process.d.ts +1366 -0
  77. package/backend-project/node_modules/@types/node/cluster.d.ts +432 -0
  78. package/backend-project/node_modules/@types/node/compatibility/iterators.d.ts +21 -0
  79. package/backend-project/node_modules/@types/node/console.d.ts +93 -0
  80. package/backend-project/node_modules/@types/node/constants.d.ts +14 -0
  81. package/backend-project/node_modules/@types/node/crypto.d.ts +4058 -0
  82. package/backend-project/node_modules/@types/node/dgram.d.ts +537 -0
  83. package/backend-project/node_modules/@types/node/diagnostics_channel.d.ts +552 -0
  84. package/backend-project/node_modules/@types/node/dns/promises.d.ts +497 -0
  85. package/backend-project/node_modules/@types/node/dns.d.ts +876 -0
  86. package/backend-project/node_modules/@types/node/domain.d.ts +150 -0
  87. package/backend-project/node_modules/@types/node/events.d.ts +1008 -0
  88. package/backend-project/node_modules/@types/node/fs/promises.d.ts +1468 -0
  89. package/backend-project/node_modules/@types/node/fs.d.ts +4780 -0
  90. package/backend-project/node_modules/@types/node/globals.d.ts +150 -0
  91. package/backend-project/node_modules/@types/node/globals.typedarray.d.ts +101 -0
  92. package/backend-project/node_modules/@types/node/http.d.ts +2147 -0
  93. package/backend-project/node_modules/@types/node/http2.d.ts +2485 -0
  94. package/backend-project/node_modules/@types/node/https.d.ts +400 -0
  95. package/backend-project/node_modules/@types/node/index.d.ts +117 -0
  96. package/backend-project/node_modules/@types/node/inspector/promises.d.ts +35 -0
  97. package/backend-project/node_modules/@types/node/inspector.d.ts +264 -0
  98. package/backend-project/node_modules/@types/node/inspector.generated.d.ts +4406 -0
  99. package/backend-project/node_modules/@types/node/module.d.ts +755 -0
  100. package/backend-project/node_modules/@types/node/net.d.ts +970 -0
  101. package/backend-project/node_modules/@types/node/os.d.ts +498 -0
  102. package/backend-project/node_modules/@types/node/package.json +155 -0
  103. package/backend-project/node_modules/@types/node/path/posix.d.ts +8 -0
  104. package/backend-project/node_modules/@types/node/path/win32.d.ts +8 -0
  105. package/backend-project/node_modules/@types/node/path.d.ts +178 -0
  106. package/backend-project/node_modules/@types/node/perf_hooks.d.ts +612 -0
  107. package/backend-project/node_modules/@types/node/process.d.ts +2204 -0
  108. package/backend-project/node_modules/@types/node/punycode.d.ts +89 -0
  109. package/backend-project/node_modules/@types/node/querystring.d.ts +139 -0
  110. package/backend-project/node_modules/@types/node/quic.d.ts +897 -0
  111. package/backend-project/node_modules/@types/node/readline/promises.d.ts +158 -0
  112. package/backend-project/node_modules/@types/node/readline.d.ts +507 -0
  113. package/backend-project/node_modules/@types/node/repl.d.ts +420 -0
  114. package/backend-project/node_modules/@types/node/sea.d.ts +47 -0
  115. package/backend-project/node_modules/@types/node/sqlite.d.ts +1068 -0
  116. package/backend-project/node_modules/@types/node/stream/consumers.d.ts +114 -0
  117. package/backend-project/node_modules/@types/node/stream/iter.d.ts +301 -0
  118. package/backend-project/node_modules/@types/node/stream/promises.d.ts +211 -0
  119. package/backend-project/node_modules/@types/node/stream/web.d.ts +300 -0
  120. package/backend-project/node_modules/@types/node/stream.d.ts +1774 -0
  121. package/backend-project/node_modules/@types/node/string_decoder.d.ts +27 -0
  122. package/backend-project/node_modules/@types/node/test/reporters.d.ts +59 -0
  123. package/backend-project/node_modules/@types/node/test.d.ts +2279 -0
  124. package/backend-project/node_modules/@types/node/timers/promises.d.ts +93 -0
  125. package/backend-project/node_modules/@types/node/timers.d.ts +149 -0
  126. package/backend-project/node_modules/@types/node/tls.d.ts +1193 -0
  127. package/backend-project/node_modules/@types/node/trace_events.d.ts +103 -0
  128. package/backend-project/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +462 -0
  129. package/backend-project/node_modules/@types/node/ts5.6/compatibility/float16array.d.ts +71 -0
  130. package/backend-project/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +36 -0
  131. package/backend-project/node_modules/@types/node/ts5.6/index.d.ts +119 -0
  132. package/backend-project/node_modules/@types/node/ts5.7/compatibility/float16array.d.ts +72 -0
  133. package/backend-project/node_modules/@types/node/ts5.7/index.d.ts +119 -0
  134. package/backend-project/node_modules/@types/node/tty.d.ts +225 -0
  135. package/backend-project/node_modules/@types/node/url.d.ts +556 -0
  136. package/backend-project/node_modules/@types/node/util/types.d.ts +558 -0
  137. package/backend-project/node_modules/@types/node/util.d.ts +1677 -0
  138. package/backend-project/node_modules/@types/node/v8.d.ts +980 -0
  139. package/backend-project/node_modules/@types/node/vm.d.ts +1136 -0
  140. package/backend-project/node_modules/@types/node/wasi.d.ts +131 -0
  141. package/backend-project/node_modules/@types/node/web-globals/abortcontroller.d.ts +59 -0
  142. package/backend-project/node_modules/@types/node/web-globals/blob.d.ts +23 -0
  143. package/backend-project/node_modules/@types/node/web-globals/console.d.ts +9 -0
  144. package/backend-project/node_modules/@types/node/web-globals/crypto.d.ts +39 -0
  145. package/backend-project/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  146. package/backend-project/node_modules/@types/node/web-globals/encoding.d.ts +11 -0
  147. package/backend-project/node_modules/@types/node/web-globals/events.d.ts +106 -0
  148. package/backend-project/node_modules/@types/node/web-globals/fetch.d.ts +69 -0
  149. package/backend-project/node_modules/@types/node/web-globals/importmeta.d.ts +13 -0
  150. package/backend-project/node_modules/@types/node/web-globals/messaging.d.ts +23 -0
  151. package/backend-project/node_modules/@types/node/web-globals/navigator.d.ts +25 -0
  152. package/backend-project/node_modules/@types/node/web-globals/performance.d.ts +45 -0
  153. package/backend-project/node_modules/@types/node/web-globals/storage.d.ts +24 -0
  154. package/backend-project/node_modules/@types/node/web-globals/streams.d.ts +115 -0
  155. package/backend-project/node_modules/@types/node/web-globals/timers.d.ts +44 -0
  156. package/backend-project/node_modules/@types/node/web-globals/url.d.ts +24 -0
  157. package/backend-project/node_modules/@types/node/worker_threads.d.ts +671 -0
  158. package/backend-project/node_modules/@types/node/zlib/iter.d.ts +131 -0
  159. package/backend-project/node_modules/@types/node/zlib.d.ts +589 -0
  160. package/backend-project/node_modules/@types/webidl-conversions/LICENSE +21 -0
  161. package/backend-project/node_modules/@types/webidl-conversions/README.md +15 -0
  162. package/backend-project/node_modules/@types/webidl-conversions/index.d.ts +91 -0
  163. package/backend-project/node_modules/@types/webidl-conversions/package.json +30 -0
  164. package/backend-project/node_modules/@types/whatwg-url/LICENSE +21 -0
  165. package/backend-project/node_modules/@types/whatwg-url/README.md +16 -0
  166. package/backend-project/node_modules/@types/whatwg-url/dist/URL-impl.d.ts +23 -0
  167. package/backend-project/node_modules/@types/whatwg-url/dist/URL.d.ts +76 -0
  168. package/backend-project/node_modules/@types/whatwg-url/dist/URLSearchParams-impl.d.ts +23 -0
  169. package/backend-project/node_modules/@types/whatwg-url/dist/URLSearchParams.d.ts +91 -0
  170. package/backend-project/node_modules/@types/whatwg-url/index.d.ts +162 -0
  171. package/backend-project/node_modules/@types/whatwg-url/package.json +33 -0
  172. package/backend-project/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts +4 -0
  173. package/backend-project/node_modules/accepts/HISTORY.md +243 -0
  174. package/backend-project/node_modules/accepts/LICENSE +23 -0
  175. package/backend-project/node_modules/accepts/README.md +140 -0
  176. package/backend-project/node_modules/accepts/index.js +238 -0
  177. package/backend-project/node_modules/accepts/package.json +47 -0
  178. package/backend-project/node_modules/anymatch/LICENSE +15 -0
  179. package/backend-project/node_modules/anymatch/README.md +87 -0
  180. package/backend-project/node_modules/anymatch/index.d.ts +20 -0
  181. package/backend-project/node_modules/anymatch/index.js +104 -0
  182. package/backend-project/node_modules/anymatch/package.json +48 -0
  183. package/backend-project/node_modules/array-flatten/LICENSE +21 -0
  184. package/backend-project/node_modules/array-flatten/README.md +43 -0
  185. package/backend-project/node_modules/array-flatten/array-flatten.js +64 -0
  186. package/backend-project/node_modules/array-flatten/package.json +39 -0
  187. package/backend-project/node_modules/balanced-match/LICENSE.md +23 -0
  188. package/backend-project/node_modules/balanced-match/README.md +57 -0
  189. package/backend-project/node_modules/balanced-match/dist/commonjs/index.d.ts +9 -0
  190. package/backend-project/node_modules/balanced-match/dist/commonjs/index.d.ts.map +1 -0
  191. package/backend-project/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  192. package/backend-project/node_modules/balanced-match/dist/commonjs/index.js.map +1 -0
  193. package/backend-project/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  194. package/backend-project/node_modules/balanced-match/dist/esm/index.d.ts +9 -0
  195. package/backend-project/node_modules/balanced-match/dist/esm/index.d.ts.map +1 -0
  196. package/backend-project/node_modules/balanced-match/dist/esm/index.js +54 -0
  197. package/backend-project/node_modules/balanced-match/dist/esm/index.js.map +1 -0
  198. package/backend-project/node_modules/balanced-match/dist/esm/package.json +3 -0
  199. package/backend-project/node_modules/balanced-match/package.json +68 -0
  200. package/backend-project/node_modules/bcryptjs/.travis.yml +18 -0
  201. package/backend-project/node_modules/bcryptjs/.vscode/settings.json +3 -0
  202. package/backend-project/node_modules/bcryptjs/LICENSE +50 -0
  203. package/backend-project/node_modules/bcryptjs/README.md +251 -0
  204. package/backend-project/node_modules/bcryptjs/bin/bcrypt +25 -0
  205. package/backend-project/node_modules/bcryptjs/bower.json +22 -0
  206. package/backend-project/node_modules/bcryptjs/dist/README.md +15 -0
  207. package/backend-project/node_modules/bcryptjs/dist/bcrypt.js +1379 -0
  208. package/backend-project/node_modules/bcryptjs/dist/bcrypt.min.js +48 -0
  209. package/backend-project/node_modules/bcryptjs/dist/bcrypt.min.js.gz +0 -0
  210. package/backend-project/node_modules/bcryptjs/dist/bcrypt.min.map +8 -0
  211. package/backend-project/node_modules/bcryptjs/externs/bcrypt.js +91 -0
  212. package/backend-project/node_modules/bcryptjs/externs/minimal-env.js +98 -0
  213. package/backend-project/node_modules/bcryptjs/index.js +29 -0
  214. package/backend-project/node_modules/bcryptjs/package.json +47 -0
  215. package/backend-project/node_modules/bcryptjs/scripts/build.js +37 -0
  216. package/backend-project/node_modules/bcryptjs/src/bcrypt/impl.js +669 -0
  217. package/backend-project/node_modules/bcryptjs/src/bcrypt/prng/README.md +5 -0
  218. package/backend-project/node_modules/bcryptjs/src/bcrypt/prng/accum.js +133 -0
  219. package/backend-project/node_modules/bcryptjs/src/bcrypt/prng/isaac.js +140 -0
  220. package/backend-project/node_modules/bcryptjs/src/bcrypt/util/base64.js +115 -0
  221. package/backend-project/node_modules/bcryptjs/src/bcrypt/util.js +33 -0
  222. package/backend-project/node_modules/bcryptjs/src/bcrypt.js +327 -0
  223. package/backend-project/node_modules/bcryptjs/src/bower.json +22 -0
  224. package/backend-project/node_modules/bcryptjs/src/wrap.js +50 -0
  225. package/backend-project/node_modules/bcryptjs/tests/quickbrown.txt +150 -0
  226. package/backend-project/node_modules/bcryptjs/tests/suite.js +197 -0
  227. package/backend-project/node_modules/binary-extensions/binary-extensions.json +263 -0
  228. package/backend-project/node_modules/binary-extensions/binary-extensions.json.d.ts +3 -0
  229. package/backend-project/node_modules/binary-extensions/index.d.ts +14 -0
  230. package/backend-project/node_modules/binary-extensions/index.js +1 -0
  231. package/backend-project/node_modules/binary-extensions/license +10 -0
  232. package/backend-project/node_modules/binary-extensions/package.json +40 -0
  233. package/backend-project/node_modules/binary-extensions/readme.md +25 -0
  234. package/backend-project/node_modules/body-parser/HISTORY.md +686 -0
  235. package/backend-project/node_modules/body-parser/LICENSE +23 -0
  236. package/backend-project/node_modules/body-parser/README.md +476 -0
  237. package/backend-project/node_modules/body-parser/index.js +156 -0
  238. package/backend-project/node_modules/body-parser/lib/read.js +205 -0
  239. package/backend-project/node_modules/body-parser/lib/types/json.js +243 -0
  240. package/backend-project/node_modules/body-parser/lib/types/raw.js +101 -0
  241. package/backend-project/node_modules/body-parser/lib/types/text.js +121 -0
  242. package/backend-project/node_modules/body-parser/lib/types/urlencoded.js +299 -0
  243. package/backend-project/node_modules/body-parser/package.json +55 -0
  244. package/backend-project/node_modules/brace-expansion/LICENSE +23 -0
  245. package/backend-project/node_modules/brace-expansion/README.md +94 -0
  246. package/backend-project/node_modules/brace-expansion/dist/commonjs/index.d.ts +6 -0
  247. package/backend-project/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
  248. package/backend-project/node_modules/brace-expansion/dist/commonjs/index.js +201 -0
  249. package/backend-project/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
  250. package/backend-project/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  251. package/backend-project/node_modules/brace-expansion/dist/esm/index.d.ts +6 -0
  252. package/backend-project/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
  253. package/backend-project/node_modules/brace-expansion/dist/esm/index.js +197 -0
  254. package/backend-project/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
  255. package/backend-project/node_modules/brace-expansion/dist/esm/package.json +3 -0
  256. package/backend-project/node_modules/brace-expansion/package.json +64 -0
  257. package/backend-project/node_modules/braces/LICENSE +21 -0
  258. package/backend-project/node_modules/braces/README.md +586 -0
  259. package/backend-project/node_modules/braces/index.js +170 -0
  260. package/backend-project/node_modules/braces/lib/compile.js +60 -0
  261. package/backend-project/node_modules/braces/lib/constants.js +57 -0
  262. package/backend-project/node_modules/braces/lib/expand.js +113 -0
  263. package/backend-project/node_modules/braces/lib/parse.js +331 -0
  264. package/backend-project/node_modules/braces/lib/stringify.js +32 -0
  265. package/backend-project/node_modules/braces/lib/utils.js +122 -0
  266. package/backend-project/node_modules/braces/package.json +77 -0
  267. package/backend-project/node_modules/bson/LICENSE.md +201 -0
  268. package/backend-project/node_modules/bson/README.md +238 -0
  269. package/backend-project/node_modules/bson/bson.d.ts +1302 -0
  270. package/backend-project/node_modules/bson/etc/prepare.js +19 -0
  271. package/backend-project/node_modules/bson/lib/bson.bundle.js +4149 -0
  272. package/backend-project/node_modules/bson/lib/bson.bundle.js.map +1 -0
  273. package/backend-project/node_modules/bson/lib/bson.cjs +4144 -0
  274. package/backend-project/node_modules/bson/lib/bson.cjs.map +1 -0
  275. package/backend-project/node_modules/bson/lib/bson.mjs +4116 -0
  276. package/backend-project/node_modules/bson/lib/bson.mjs.map +1 -0
  277. package/backend-project/node_modules/bson/lib/bson.rn.cjs +4159 -0
  278. package/backend-project/node_modules/bson/lib/bson.rn.cjs.map +1 -0
  279. package/backend-project/node_modules/bson/package.json +116 -0
  280. package/backend-project/node_modules/bson/src/binary.ts +510 -0
  281. package/backend-project/node_modules/bson/src/bson.ts +250 -0
  282. package/backend-project/node_modules/bson/src/bson_value.ts +18 -0
  283. package/backend-project/node_modules/bson/src/code.ts +69 -0
  284. package/backend-project/node_modules/bson/src/constants.ts +141 -0
  285. package/backend-project/node_modules/bson/src/db_ref.ts +127 -0
  286. package/backend-project/node_modules/bson/src/decimal128.ts +858 -0
  287. package/backend-project/node_modules/bson/src/double.ts +83 -0
  288. package/backend-project/node_modules/bson/src/error.ts +83 -0
  289. package/backend-project/node_modules/bson/src/extended_json.ts +515 -0
  290. package/backend-project/node_modules/bson/src/index.ts +19 -0
  291. package/backend-project/node_modules/bson/src/int_32.ts +70 -0
  292. package/backend-project/node_modules/bson/src/long.ts +1067 -0
  293. package/backend-project/node_modules/bson/src/max_key.ts +36 -0
  294. package/backend-project/node_modules/bson/src/min_key.ts +36 -0
  295. package/backend-project/node_modules/bson/src/objectid.ts +323 -0
  296. package/backend-project/node_modules/bson/src/parser/calculate_size.ts +211 -0
  297. package/backend-project/node_modules/bson/src/parser/deserializer.ts +751 -0
  298. package/backend-project/node_modules/bson/src/parser/serializer.ts +1001 -0
  299. package/backend-project/node_modules/bson/src/parser/utils.ts +29 -0
  300. package/backend-project/node_modules/bson/src/regexp.ts +114 -0
  301. package/backend-project/node_modules/bson/src/symbol.ts +58 -0
  302. package/backend-project/node_modules/bson/src/timestamp.ts +152 -0
  303. package/backend-project/node_modules/bson/src/utils/byte_utils.ts +61 -0
  304. package/backend-project/node_modules/bson/src/utils/node_byte_utils.ts +141 -0
  305. package/backend-project/node_modules/bson/src/utils/web_byte_utils.ts +190 -0
  306. package/backend-project/node_modules/bson/src/validate_utf8.ts +47 -0
  307. package/backend-project/node_modules/bson/vendor/base64/LICENSE-MIT.txt +20 -0
  308. package/backend-project/node_modules/bson/vendor/base64/README.md +112 -0
  309. package/backend-project/node_modules/bson/vendor/base64/base64.js +157 -0
  310. package/backend-project/node_modules/bson/vendor/base64/package.json +43 -0
  311. package/backend-project/node_modules/bson/vendor/text-encoding/LICENSE.md +237 -0
  312. package/backend-project/node_modules/bson/vendor/text-encoding/README.md +111 -0
  313. package/backend-project/node_modules/bson/vendor/text-encoding/index.js +9 -0
  314. package/backend-project/node_modules/bson/vendor/text-encoding/lib/encoding-indexes.js +47 -0
  315. package/backend-project/node_modules/bson/vendor/text-encoding/lib/encoding.js +3301 -0
  316. package/backend-project/node_modules/bson/vendor/text-encoding/package.json +37 -0
  317. package/backend-project/node_modules/buffer-equal-constant-time/.travis.yml +4 -0
  318. package/backend-project/node_modules/buffer-equal-constant-time/LICENSE.txt +12 -0
  319. package/backend-project/node_modules/buffer-equal-constant-time/README.md +50 -0
  320. package/backend-project/node_modules/buffer-equal-constant-time/index.js +41 -0
  321. package/backend-project/node_modules/buffer-equal-constant-time/package.json +21 -0
  322. package/backend-project/node_modules/buffer-equal-constant-time/test.js +42 -0
  323. package/backend-project/node_modules/bytes/History.md +97 -0
  324. package/backend-project/node_modules/bytes/LICENSE +23 -0
  325. package/backend-project/node_modules/bytes/Readme.md +152 -0
  326. package/backend-project/node_modules/bytes/index.js +170 -0
  327. package/backend-project/node_modules/bytes/package.json +42 -0
  328. package/backend-project/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
  329. package/backend-project/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
  330. package/backend-project/node_modules/call-bind-apply-helpers/.nycrc +9 -0
  331. package/backend-project/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
  332. package/backend-project/node_modules/call-bind-apply-helpers/LICENSE +21 -0
  333. package/backend-project/node_modules/call-bind-apply-helpers/README.md +62 -0
  334. package/backend-project/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
  335. package/backend-project/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  336. package/backend-project/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
  337. package/backend-project/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  338. package/backend-project/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
  339. package/backend-project/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  340. package/backend-project/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
  341. package/backend-project/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  342. package/backend-project/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
  343. package/backend-project/node_modules/call-bind-apply-helpers/index.js +15 -0
  344. package/backend-project/node_modules/call-bind-apply-helpers/package.json +85 -0
  345. package/backend-project/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
  346. package/backend-project/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  347. package/backend-project/node_modules/call-bind-apply-helpers/test/index.js +63 -0
  348. package/backend-project/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
  349. package/backend-project/node_modules/call-bound/.eslintrc +13 -0
  350. package/backend-project/node_modules/call-bound/.github/FUNDING.yml +12 -0
  351. package/backend-project/node_modules/call-bound/.nycrc +9 -0
  352. package/backend-project/node_modules/call-bound/CHANGELOG.md +42 -0
  353. package/backend-project/node_modules/call-bound/LICENSE +21 -0
  354. package/backend-project/node_modules/call-bound/README.md +53 -0
  355. package/backend-project/node_modules/call-bound/index.d.ts +94 -0
  356. package/backend-project/node_modules/call-bound/index.js +19 -0
  357. package/backend-project/node_modules/call-bound/package.json +99 -0
  358. package/backend-project/node_modules/call-bound/test/index.js +61 -0
  359. package/backend-project/node_modules/call-bound/tsconfig.json +10 -0
  360. package/backend-project/node_modules/chokidar/LICENSE +21 -0
  361. package/backend-project/node_modules/chokidar/README.md +308 -0
  362. package/backend-project/node_modules/chokidar/index.js +973 -0
  363. package/backend-project/node_modules/chokidar/lib/constants.js +66 -0
  364. package/backend-project/node_modules/chokidar/lib/fsevents-handler.js +526 -0
  365. package/backend-project/node_modules/chokidar/lib/nodefs-handler.js +654 -0
  366. package/backend-project/node_modules/chokidar/package.json +70 -0
  367. package/backend-project/node_modules/chokidar/types/index.d.ts +192 -0
  368. package/backend-project/node_modules/content-disposition/HISTORY.md +60 -0
  369. package/backend-project/node_modules/content-disposition/LICENSE +22 -0
  370. package/backend-project/node_modules/content-disposition/README.md +142 -0
  371. package/backend-project/node_modules/content-disposition/index.js +458 -0
  372. package/backend-project/node_modules/content-disposition/package.json +44 -0
  373. package/backend-project/node_modules/content-type/HISTORY.md +29 -0
  374. package/backend-project/node_modules/content-type/LICENSE +22 -0
  375. package/backend-project/node_modules/content-type/README.md +94 -0
  376. package/backend-project/node_modules/content-type/index.js +225 -0
  377. package/backend-project/node_modules/content-type/package.json +42 -0
  378. package/backend-project/node_modules/cookie/LICENSE +24 -0
  379. package/backend-project/node_modules/cookie/README.md +317 -0
  380. package/backend-project/node_modules/cookie/SECURITY.md +25 -0
  381. package/backend-project/node_modules/cookie/index.js +335 -0
  382. package/backend-project/node_modules/cookie/package.json +44 -0
  383. package/backend-project/node_modules/cookie-signature/History.md +42 -0
  384. package/backend-project/node_modules/cookie-signature/Readme.md +42 -0
  385. package/backend-project/node_modules/cookie-signature/index.js +51 -0
  386. package/backend-project/node_modules/cookie-signature/package.json +18 -0
  387. package/backend-project/node_modules/cors/LICENSE +22 -0
  388. package/backend-project/node_modules/cors/README.md +277 -0
  389. package/backend-project/node_modules/cors/lib/index.js +238 -0
  390. package/backend-project/node_modules/cors/package.json +42 -0
  391. package/backend-project/node_modules/debug/.coveralls.yml +1 -0
  392. package/backend-project/node_modules/debug/.eslintrc +11 -0
  393. package/backend-project/node_modules/debug/.travis.yml +14 -0
  394. package/backend-project/node_modules/debug/CHANGELOG.md +362 -0
  395. package/backend-project/node_modules/debug/LICENSE +19 -0
  396. package/backend-project/node_modules/debug/Makefile +50 -0
  397. package/backend-project/node_modules/debug/README.md +312 -0
  398. package/backend-project/node_modules/debug/component.json +19 -0
  399. package/backend-project/node_modules/debug/karma.conf.js +70 -0
  400. package/backend-project/node_modules/debug/node.js +1 -0
  401. package/backend-project/node_modules/debug/package.json +49 -0
  402. package/backend-project/node_modules/debug/src/browser.js +185 -0
  403. package/backend-project/node_modules/debug/src/debug.js +202 -0
  404. package/backend-project/node_modules/debug/src/index.js +10 -0
  405. package/backend-project/node_modules/debug/src/inspector-log.js +15 -0
  406. package/backend-project/node_modules/debug/src/node.js +248 -0
  407. package/backend-project/node_modules/depd/History.md +103 -0
  408. package/backend-project/node_modules/depd/LICENSE +22 -0
  409. package/backend-project/node_modules/depd/Readme.md +280 -0
  410. package/backend-project/node_modules/depd/index.js +538 -0
  411. package/backend-project/node_modules/depd/lib/browser/index.js +77 -0
  412. package/backend-project/node_modules/depd/package.json +45 -0
  413. package/backend-project/node_modules/destroy/LICENSE +23 -0
  414. package/backend-project/node_modules/destroy/README.md +63 -0
  415. package/backend-project/node_modules/destroy/index.js +209 -0
  416. package/backend-project/node_modules/destroy/package.json +48 -0
  417. package/backend-project/node_modules/dotenv/CHANGELOG.md +520 -0
  418. package/backend-project/node_modules/dotenv/LICENSE +23 -0
  419. package/backend-project/node_modules/dotenv/README-es.md +411 -0
  420. package/backend-project/node_modules/dotenv/README.md +645 -0
  421. package/backend-project/node_modules/dotenv/SECURITY.md +1 -0
  422. package/backend-project/node_modules/dotenv/config.d.ts +1 -0
  423. package/backend-project/node_modules/dotenv/config.js +9 -0
  424. package/backend-project/node_modules/dotenv/lib/cli-options.js +17 -0
  425. package/backend-project/node_modules/dotenv/lib/env-options.js +28 -0
  426. package/backend-project/node_modules/dotenv/lib/main.d.ts +162 -0
  427. package/backend-project/node_modules/dotenv/lib/main.js +386 -0
  428. package/backend-project/node_modules/dotenv/package.json +62 -0
  429. package/backend-project/node_modules/dunder-proto/.eslintrc +5 -0
  430. package/backend-project/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
  431. package/backend-project/node_modules/dunder-proto/.nycrc +13 -0
  432. package/backend-project/node_modules/dunder-proto/CHANGELOG.md +24 -0
  433. package/backend-project/node_modules/dunder-proto/LICENSE +21 -0
  434. package/backend-project/node_modules/dunder-proto/README.md +54 -0
  435. package/backend-project/node_modules/dunder-proto/get.d.ts +5 -0
  436. package/backend-project/node_modules/dunder-proto/get.js +30 -0
  437. package/backend-project/node_modules/dunder-proto/package.json +76 -0
  438. package/backend-project/node_modules/dunder-proto/set.d.ts +5 -0
  439. package/backend-project/node_modules/dunder-proto/set.js +35 -0
  440. package/backend-project/node_modules/dunder-proto/test/get.js +34 -0
  441. package/backend-project/node_modules/dunder-proto/test/index.js +4 -0
  442. package/backend-project/node_modules/dunder-proto/test/set.js +50 -0
  443. package/backend-project/node_modules/dunder-proto/tsconfig.json +9 -0
  444. package/backend-project/node_modules/ecdsa-sig-formatter/CODEOWNERS +1 -0
  445. package/backend-project/node_modules/ecdsa-sig-formatter/LICENSE +201 -0
  446. package/backend-project/node_modules/ecdsa-sig-formatter/README.md +65 -0
  447. package/backend-project/node_modules/ecdsa-sig-formatter/package.json +46 -0
  448. package/backend-project/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.d.ts +17 -0
  449. package/backend-project/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js +187 -0
  450. package/backend-project/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js +23 -0
  451. package/backend-project/node_modules/ee-first/LICENSE +22 -0
  452. package/backend-project/node_modules/ee-first/README.md +80 -0
  453. package/backend-project/node_modules/ee-first/index.js +95 -0
  454. package/backend-project/node_modules/ee-first/package.json +29 -0
  455. package/backend-project/node_modules/encodeurl/LICENSE +22 -0
  456. package/backend-project/node_modules/encodeurl/README.md +109 -0
  457. package/backend-project/node_modules/encodeurl/index.js +60 -0
  458. package/backend-project/node_modules/encodeurl/package.json +40 -0
  459. package/backend-project/node_modules/es-define-property/.eslintrc +13 -0
  460. package/backend-project/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  461. package/backend-project/node_modules/es-define-property/.nycrc +9 -0
  462. package/backend-project/node_modules/es-define-property/CHANGELOG.md +29 -0
  463. package/backend-project/node_modules/es-define-property/LICENSE +21 -0
  464. package/backend-project/node_modules/es-define-property/README.md +49 -0
  465. package/backend-project/node_modules/es-define-property/index.d.ts +3 -0
  466. package/backend-project/node_modules/es-define-property/index.js +14 -0
  467. package/backend-project/node_modules/es-define-property/package.json +81 -0
  468. package/backend-project/node_modules/es-define-property/test/index.js +56 -0
  469. package/backend-project/node_modules/es-define-property/tsconfig.json +10 -0
  470. package/backend-project/node_modules/es-errors/.eslintrc +5 -0
  471. package/backend-project/node_modules/es-errors/.github/FUNDING.yml +12 -0
  472. package/backend-project/node_modules/es-errors/CHANGELOG.md +40 -0
  473. package/backend-project/node_modules/es-errors/LICENSE +21 -0
  474. package/backend-project/node_modules/es-errors/README.md +55 -0
  475. package/backend-project/node_modules/es-errors/eval.d.ts +3 -0
  476. package/backend-project/node_modules/es-errors/eval.js +4 -0
  477. package/backend-project/node_modules/es-errors/index.d.ts +3 -0
  478. package/backend-project/node_modules/es-errors/index.js +4 -0
  479. package/backend-project/node_modules/es-errors/package.json +80 -0
  480. package/backend-project/node_modules/es-errors/range.d.ts +3 -0
  481. package/backend-project/node_modules/es-errors/range.js +4 -0
  482. package/backend-project/node_modules/es-errors/ref.d.ts +3 -0
  483. package/backend-project/node_modules/es-errors/ref.js +4 -0
  484. package/backend-project/node_modules/es-errors/syntax.d.ts +3 -0
  485. package/backend-project/node_modules/es-errors/syntax.js +4 -0
  486. package/backend-project/node_modules/es-errors/test/index.js +19 -0
  487. package/backend-project/node_modules/es-errors/tsconfig.json +49 -0
  488. package/backend-project/node_modules/es-errors/type.d.ts +3 -0
  489. package/backend-project/node_modules/es-errors/type.js +4 -0
  490. package/backend-project/node_modules/es-errors/uri.d.ts +3 -0
  491. package/backend-project/node_modules/es-errors/uri.js +4 -0
  492. package/backend-project/node_modules/es-object-atoms/.eslintrc +16 -0
  493. package/backend-project/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  494. package/backend-project/node_modules/es-object-atoms/CHANGELOG.md +44 -0
  495. package/backend-project/node_modules/es-object-atoms/LICENSE +21 -0
  496. package/backend-project/node_modules/es-object-atoms/README.md +63 -0
  497. package/backend-project/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  498. package/backend-project/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  499. package/backend-project/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  500. package/backend-project/node_modules/es-object-atoms/ToObject.js +10 -0
  501. package/backend-project/node_modules/es-object-atoms/index.d.ts +3 -0
  502. package/backend-project/node_modules/es-object-atoms/index.js +4 -0
  503. package/backend-project/node_modules/es-object-atoms/isObject.d.ts +3 -0
  504. package/backend-project/node_modules/es-object-atoms/isObject.js +6 -0
  505. package/backend-project/node_modules/es-object-atoms/package.json +79 -0
  506. package/backend-project/node_modules/es-object-atoms/test/index.js +38 -0
  507. package/backend-project/node_modules/es-object-atoms/tsconfig.json +7 -0
  508. package/backend-project/node_modules/escape-html/LICENSE +24 -0
  509. package/backend-project/node_modules/escape-html/Readme.md +43 -0
  510. package/backend-project/node_modules/escape-html/index.js +78 -0
  511. package/backend-project/node_modules/escape-html/package.json +24 -0
  512. package/backend-project/node_modules/etag/HISTORY.md +83 -0
  513. package/backend-project/node_modules/etag/LICENSE +22 -0
  514. package/backend-project/node_modules/etag/README.md +159 -0
  515. package/backend-project/node_modules/etag/index.js +131 -0
  516. package/backend-project/node_modules/etag/package.json +47 -0
  517. package/backend-project/node_modules/express/History.md +3676 -0
  518. package/backend-project/node_modules/express/LICENSE +24 -0
  519. package/backend-project/node_modules/express/Readme.md +260 -0
  520. package/backend-project/node_modules/express/index.js +11 -0
  521. package/backend-project/node_modules/express/lib/application.js +661 -0
  522. package/backend-project/node_modules/express/lib/express.js +116 -0
  523. package/backend-project/node_modules/express/lib/middleware/init.js +43 -0
  524. package/backend-project/node_modules/express/lib/middleware/query.js +47 -0
  525. package/backend-project/node_modules/express/lib/request.js +525 -0
  526. package/backend-project/node_modules/express/lib/response.js +1179 -0
  527. package/backend-project/node_modules/express/lib/router/index.js +673 -0
  528. package/backend-project/node_modules/express/lib/router/layer.js +181 -0
  529. package/backend-project/node_modules/express/lib/router/route.js +230 -0
  530. package/backend-project/node_modules/express/lib/utils.js +304 -0
  531. package/backend-project/node_modules/express/lib/view.js +182 -0
  532. package/backend-project/node_modules/express/package.json +102 -0
  533. package/backend-project/node_modules/fill-range/LICENSE +21 -0
  534. package/backend-project/node_modules/fill-range/README.md +237 -0
  535. package/backend-project/node_modules/fill-range/index.js +248 -0
  536. package/backend-project/node_modules/fill-range/package.json +74 -0
  537. package/backend-project/node_modules/finalhandler/HISTORY.md +216 -0
  538. package/backend-project/node_modules/finalhandler/LICENSE +22 -0
  539. package/backend-project/node_modules/finalhandler/README.md +147 -0
  540. package/backend-project/node_modules/finalhandler/SECURITY.md +25 -0
  541. package/backend-project/node_modules/finalhandler/index.js +341 -0
  542. package/backend-project/node_modules/finalhandler/package.json +47 -0
  543. package/backend-project/node_modules/forwarded/HISTORY.md +21 -0
  544. package/backend-project/node_modules/forwarded/LICENSE +22 -0
  545. package/backend-project/node_modules/forwarded/README.md +57 -0
  546. package/backend-project/node_modules/forwarded/index.js +90 -0
  547. package/backend-project/node_modules/forwarded/package.json +45 -0
  548. package/backend-project/node_modules/fresh/HISTORY.md +70 -0
  549. package/backend-project/node_modules/fresh/LICENSE +23 -0
  550. package/backend-project/node_modules/fresh/README.md +119 -0
  551. package/backend-project/node_modules/fresh/index.js +137 -0
  552. package/backend-project/node_modules/fresh/package.json +46 -0
  553. package/backend-project/node_modules/function-bind/.eslintrc +21 -0
  554. package/backend-project/node_modules/function-bind/.github/FUNDING.yml +12 -0
  555. package/backend-project/node_modules/function-bind/.github/SECURITY.md +3 -0
  556. package/backend-project/node_modules/function-bind/.nycrc +13 -0
  557. package/backend-project/node_modules/function-bind/CHANGELOG.md +136 -0
  558. package/backend-project/node_modules/function-bind/LICENSE +20 -0
  559. package/backend-project/node_modules/function-bind/README.md +46 -0
  560. package/backend-project/node_modules/function-bind/implementation.js +84 -0
  561. package/backend-project/node_modules/function-bind/index.js +5 -0
  562. package/backend-project/node_modules/function-bind/package.json +87 -0
  563. package/backend-project/node_modules/function-bind/test/.eslintrc +9 -0
  564. package/backend-project/node_modules/function-bind/test/index.js +252 -0
  565. package/backend-project/node_modules/get-intrinsic/.eslintrc +42 -0
  566. package/backend-project/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  567. package/backend-project/node_modules/get-intrinsic/.nycrc +9 -0
  568. package/backend-project/node_modules/get-intrinsic/CHANGELOG.md +186 -0
  569. package/backend-project/node_modules/get-intrinsic/LICENSE +21 -0
  570. package/backend-project/node_modules/get-intrinsic/README.md +71 -0
  571. package/backend-project/node_modules/get-intrinsic/index.js +378 -0
  572. package/backend-project/node_modules/get-intrinsic/package.json +97 -0
  573. package/backend-project/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  574. package/backend-project/node_modules/get-proto/.eslintrc +10 -0
  575. package/backend-project/node_modules/get-proto/.github/FUNDING.yml +12 -0
  576. package/backend-project/node_modules/get-proto/.nycrc +9 -0
  577. package/backend-project/node_modules/get-proto/CHANGELOG.md +21 -0
  578. package/backend-project/node_modules/get-proto/LICENSE +21 -0
  579. package/backend-project/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
  580. package/backend-project/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  581. package/backend-project/node_modules/get-proto/README.md +50 -0
  582. package/backend-project/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
  583. package/backend-project/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  584. package/backend-project/node_modules/get-proto/index.d.ts +5 -0
  585. package/backend-project/node_modules/get-proto/index.js +27 -0
  586. package/backend-project/node_modules/get-proto/package.json +81 -0
  587. package/backend-project/node_modules/get-proto/test/index.js +68 -0
  588. package/backend-project/node_modules/get-proto/tsconfig.json +9 -0
  589. package/backend-project/node_modules/glob-parent/CHANGELOG.md +110 -0
  590. package/backend-project/node_modules/glob-parent/LICENSE +15 -0
  591. package/backend-project/node_modules/glob-parent/README.md +137 -0
  592. package/backend-project/node_modules/glob-parent/index.js +42 -0
  593. package/backend-project/node_modules/glob-parent/package.json +48 -0
  594. package/backend-project/node_modules/gopd/.eslintrc +16 -0
  595. package/backend-project/node_modules/gopd/.github/FUNDING.yml +12 -0
  596. package/backend-project/node_modules/gopd/CHANGELOG.md +45 -0
  597. package/backend-project/node_modules/gopd/LICENSE +21 -0
  598. package/backend-project/node_modules/gopd/README.md +40 -0
  599. package/backend-project/node_modules/gopd/gOPD.d.ts +1 -0
  600. package/backend-project/node_modules/gopd/gOPD.js +4 -0
  601. package/backend-project/node_modules/gopd/index.d.ts +5 -0
  602. package/backend-project/node_modules/gopd/index.js +15 -0
  603. package/backend-project/node_modules/gopd/package.json +77 -0
  604. package/backend-project/node_modules/gopd/test/index.js +36 -0
  605. package/backend-project/node_modules/gopd/tsconfig.json +9 -0
  606. package/backend-project/node_modules/has-flag/index.js +8 -0
  607. package/backend-project/node_modules/has-flag/license +9 -0
  608. package/backend-project/node_modules/has-flag/package.json +44 -0
  609. package/backend-project/node_modules/has-flag/readme.md +70 -0
  610. package/backend-project/node_modules/has-symbols/.eslintrc +11 -0
  611. package/backend-project/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  612. package/backend-project/node_modules/has-symbols/.nycrc +9 -0
  613. package/backend-project/node_modules/has-symbols/CHANGELOG.md +91 -0
  614. package/backend-project/node_modules/has-symbols/LICENSE +21 -0
  615. package/backend-project/node_modules/has-symbols/README.md +46 -0
  616. package/backend-project/node_modules/has-symbols/index.d.ts +3 -0
  617. package/backend-project/node_modules/has-symbols/index.js +14 -0
  618. package/backend-project/node_modules/has-symbols/package.json +111 -0
  619. package/backend-project/node_modules/has-symbols/shams.d.ts +3 -0
  620. package/backend-project/node_modules/has-symbols/shams.js +45 -0
  621. package/backend-project/node_modules/has-symbols/test/index.js +22 -0
  622. package/backend-project/node_modules/has-symbols/test/shams/core-js.js +29 -0
  623. package/backend-project/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  624. package/backend-project/node_modules/has-symbols/test/tests.js +58 -0
  625. package/backend-project/node_modules/has-symbols/tsconfig.json +10 -0
  626. package/backend-project/node_modules/hasown/.github/FUNDING.yml +12 -0
  627. package/backend-project/node_modules/hasown/.nycrc +13 -0
  628. package/backend-project/node_modules/hasown/CHANGELOG.md +58 -0
  629. package/backend-project/node_modules/hasown/LICENSE +21 -0
  630. package/backend-project/node_modules/hasown/README.md +40 -0
  631. package/backend-project/node_modules/hasown/eslint.config.mjs +6 -0
  632. package/backend-project/node_modules/hasown/index.d.ts +3 -0
  633. package/backend-project/node_modules/hasown/index.js +8 -0
  634. package/backend-project/node_modules/hasown/package.json +91 -0
  635. package/backend-project/node_modules/hasown/tsconfig.json +6 -0
  636. package/backend-project/node_modules/http-errors/HISTORY.md +186 -0
  637. package/backend-project/node_modules/http-errors/LICENSE +23 -0
  638. package/backend-project/node_modules/http-errors/README.md +169 -0
  639. package/backend-project/node_modules/http-errors/index.js +290 -0
  640. package/backend-project/node_modules/http-errors/package.json +54 -0
  641. package/backend-project/node_modules/iconv-lite/Changelog.md +162 -0
  642. package/backend-project/node_modules/iconv-lite/LICENSE +21 -0
  643. package/backend-project/node_modules/iconv-lite/README.md +156 -0
  644. package/backend-project/node_modules/iconv-lite/encodings/dbcs-codec.js +555 -0
  645. package/backend-project/node_modules/iconv-lite/encodings/dbcs-data.js +176 -0
  646. package/backend-project/node_modules/iconv-lite/encodings/index.js +22 -0
  647. package/backend-project/node_modules/iconv-lite/encodings/internal.js +188 -0
  648. package/backend-project/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
  649. package/backend-project/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  650. package/backend-project/node_modules/iconv-lite/encodings/sbcs-data.js +174 -0
  651. package/backend-project/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  652. package/backend-project/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  653. package/backend-project/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  654. package/backend-project/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  655. package/backend-project/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  656. package/backend-project/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  657. package/backend-project/node_modules/iconv-lite/encodings/tables/gbk-added.json +55 -0
  658. package/backend-project/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  659. package/backend-project/node_modules/iconv-lite/encodings/utf16.js +177 -0
  660. package/backend-project/node_modules/iconv-lite/encodings/utf7.js +290 -0
  661. package/backend-project/node_modules/iconv-lite/lib/bom-handling.js +52 -0
  662. package/backend-project/node_modules/iconv-lite/lib/extend-node.js +217 -0
  663. package/backend-project/node_modules/iconv-lite/lib/index.d.ts +24 -0
  664. package/backend-project/node_modules/iconv-lite/lib/index.js +153 -0
  665. package/backend-project/node_modules/iconv-lite/lib/streams.js +121 -0
  666. package/backend-project/node_modules/iconv-lite/package.json +46 -0
  667. package/backend-project/node_modules/ignore-by-default/LICENSE +14 -0
  668. package/backend-project/node_modules/ignore-by-default/README.md +26 -0
  669. package/backend-project/node_modules/ignore-by-default/index.js +12 -0
  670. package/backend-project/node_modules/ignore-by-default/package.json +34 -0
  671. package/backend-project/node_modules/inherits/LICENSE +16 -0
  672. package/backend-project/node_modules/inherits/README.md +42 -0
  673. package/backend-project/node_modules/inherits/inherits.js +9 -0
  674. package/backend-project/node_modules/inherits/inherits_browser.js +27 -0
  675. package/backend-project/node_modules/inherits/package.json +29 -0
  676. package/backend-project/node_modules/ip-address/LICENSE +19 -0
  677. package/backend-project/node_modules/ip-address/README.md +278 -0
  678. package/backend-project/node_modules/ip-address/dist/address-error.d.ts +4 -0
  679. package/backend-project/node_modules/ip-address/dist/address-error.js +12 -0
  680. package/backend-project/node_modules/ip-address/dist/address-error.js.map +1 -0
  681. package/backend-project/node_modules/ip-address/dist/common.d.ts +20 -0
  682. package/backend-project/node_modules/ip-address/dist/common.js +67 -0
  683. package/backend-project/node_modules/ip-address/dist/common.js.map +1 -0
  684. package/backend-project/node_modules/ip-address/dist/ip-address.d.ts +7 -0
  685. package/backend-project/node_modules/ip-address/dist/ip-address.js +35 -0
  686. package/backend-project/node_modules/ip-address/dist/ip-address.js.map +1 -0
  687. package/backend-project/node_modules/ip-address/dist/ipv4.d.ts +267 -0
  688. package/backend-project/node_modules/ip-address/dist/ipv4.js +485 -0
  689. package/backend-project/node_modules/ip-address/dist/ipv4.js.map +1 -0
  690. package/backend-project/node_modules/ip-address/dist/ipv6.d.ts +489 -0
  691. package/backend-project/node_modules/ip-address/dist/ipv6.js +1217 -0
  692. package/backend-project/node_modules/ip-address/dist/ipv6.js.map +1 -0
  693. package/backend-project/node_modules/ip-address/dist/v4/constants.d.ts +4 -0
  694. package/backend-project/node_modules/ip-address/dist/v4/constants.js +8 -0
  695. package/backend-project/node_modules/ip-address/dist/v4/constants.js.map +1 -0
  696. package/backend-project/node_modules/ip-address/dist/v6/constants.d.ts +44 -0
  697. package/backend-project/node_modules/ip-address/dist/v6/constants.js +81 -0
  698. package/backend-project/node_modules/ip-address/dist/v6/constants.js.map +1 -0
  699. package/backend-project/node_modules/ip-address/dist/v6/helpers.d.ts +18 -0
  700. package/backend-project/node_modules/ip-address/dist/v6/helpers.js +54 -0
  701. package/backend-project/node_modules/ip-address/dist/v6/helpers.js.map +1 -0
  702. package/backend-project/node_modules/ip-address/dist/v6/regular-expressions.d.ts +5 -0
  703. package/backend-project/node_modules/ip-address/dist/v6/regular-expressions.js +95 -0
  704. package/backend-project/node_modules/ip-address/dist/v6/regular-expressions.js.map +1 -0
  705. package/backend-project/node_modules/ip-address/package.json +88 -0
  706. package/backend-project/node_modules/ipaddr.js/LICENSE +19 -0
  707. package/backend-project/node_modules/ipaddr.js/README.md +233 -0
  708. package/backend-project/node_modules/ipaddr.js/ipaddr.min.js +1 -0
  709. package/backend-project/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
  710. package/backend-project/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
  711. package/backend-project/node_modules/ipaddr.js/package.json +35 -0
  712. package/backend-project/node_modules/is-binary-path/index.d.ts +17 -0
  713. package/backend-project/node_modules/is-binary-path/index.js +7 -0
  714. package/backend-project/node_modules/is-binary-path/license +9 -0
  715. package/backend-project/node_modules/is-binary-path/package.json +40 -0
  716. package/backend-project/node_modules/is-binary-path/readme.md +34 -0
  717. package/backend-project/node_modules/is-extglob/LICENSE +21 -0
  718. package/backend-project/node_modules/is-extglob/README.md +107 -0
  719. package/backend-project/node_modules/is-extglob/index.js +20 -0
  720. package/backend-project/node_modules/is-extglob/package.json +69 -0
  721. package/backend-project/node_modules/is-glob/LICENSE +21 -0
  722. package/backend-project/node_modules/is-glob/README.md +206 -0
  723. package/backend-project/node_modules/is-glob/index.js +150 -0
  724. package/backend-project/node_modules/is-glob/package.json +81 -0
  725. package/backend-project/node_modules/is-number/LICENSE +21 -0
  726. package/backend-project/node_modules/is-number/README.md +187 -0
  727. package/backend-project/node_modules/is-number/index.js +18 -0
  728. package/backend-project/node_modules/is-number/package.json +82 -0
  729. package/backend-project/node_modules/jsonwebtoken/LICENSE +21 -0
  730. package/backend-project/node_modules/jsonwebtoken/README.md +396 -0
  731. package/backend-project/node_modules/jsonwebtoken/decode.js +30 -0
  732. package/backend-project/node_modules/jsonwebtoken/index.js +8 -0
  733. package/backend-project/node_modules/jsonwebtoken/lib/JsonWebTokenError.js +14 -0
  734. package/backend-project/node_modules/jsonwebtoken/lib/NotBeforeError.js +13 -0
  735. package/backend-project/node_modules/jsonwebtoken/lib/TokenExpiredError.js +13 -0
  736. package/backend-project/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js +3 -0
  737. package/backend-project/node_modules/jsonwebtoken/lib/psSupported.js +3 -0
  738. package/backend-project/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js +3 -0
  739. package/backend-project/node_modules/jsonwebtoken/lib/timespan.js +18 -0
  740. package/backend-project/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js +66 -0
  741. package/backend-project/node_modules/jsonwebtoken/node_modules/ms/index.js +162 -0
  742. package/backend-project/node_modules/jsonwebtoken/node_modules/ms/license.md +21 -0
  743. package/backend-project/node_modules/jsonwebtoken/node_modules/ms/package.json +38 -0
  744. package/backend-project/node_modules/jsonwebtoken/node_modules/ms/readme.md +59 -0
  745. package/backend-project/node_modules/jsonwebtoken/package.json +70 -0
  746. package/backend-project/node_modules/jsonwebtoken/sign.js +253 -0
  747. package/backend-project/node_modules/jsonwebtoken/verify.js +263 -0
  748. package/backend-project/node_modules/jwa/LICENSE +17 -0
  749. package/backend-project/node_modules/jwa/README.md +150 -0
  750. package/backend-project/node_modules/jwa/index.js +266 -0
  751. package/backend-project/node_modules/jwa/opslevel.yml +6 -0
  752. package/backend-project/node_modules/jwa/package.json +37 -0
  753. package/backend-project/node_modules/jws/CHANGELOG.md +56 -0
  754. package/backend-project/node_modules/jws/LICENSE +17 -0
  755. package/backend-project/node_modules/jws/index.js +22 -0
  756. package/backend-project/node_modules/jws/lib/data-stream.js +55 -0
  757. package/backend-project/node_modules/jws/lib/sign-stream.js +83 -0
  758. package/backend-project/node_modules/jws/lib/tostring.js +10 -0
  759. package/backend-project/node_modules/jws/lib/verify-stream.js +125 -0
  760. package/backend-project/node_modules/jws/opslevel.yml +6 -0
  761. package/backend-project/node_modules/jws/package.json +34 -0
  762. package/backend-project/node_modules/jws/readme.md +255 -0
  763. package/backend-project/node_modules/kareem/LICENSE +202 -0
  764. package/backend-project/node_modules/kareem/README.md +420 -0
  765. package/backend-project/node_modules/kareem/index.js +668 -0
  766. package/backend-project/node_modules/kareem/package.json +31 -0
  767. package/backend-project/node_modules/lodash.includes/LICENSE +47 -0
  768. package/backend-project/node_modules/lodash.includes/README.md +18 -0
  769. package/backend-project/node_modules/lodash.includes/index.js +745 -0
  770. package/backend-project/node_modules/lodash.includes/package.json +17 -0
  771. package/backend-project/node_modules/lodash.isboolean/LICENSE +22 -0
  772. package/backend-project/node_modules/lodash.isboolean/README.md +18 -0
  773. package/backend-project/node_modules/lodash.isboolean/index.js +70 -0
  774. package/backend-project/node_modules/lodash.isboolean/package.json +17 -0
  775. package/backend-project/node_modules/lodash.isinteger/LICENSE +47 -0
  776. package/backend-project/node_modules/lodash.isinteger/README.md +18 -0
  777. package/backend-project/node_modules/lodash.isinteger/index.js +265 -0
  778. package/backend-project/node_modules/lodash.isinteger/package.json +17 -0
  779. package/backend-project/node_modules/lodash.isnumber/LICENSE +22 -0
  780. package/backend-project/node_modules/lodash.isnumber/README.md +18 -0
  781. package/backend-project/node_modules/lodash.isnumber/index.js +79 -0
  782. package/backend-project/node_modules/lodash.isnumber/package.json +17 -0
  783. package/backend-project/node_modules/lodash.isplainobject/LICENSE +47 -0
  784. package/backend-project/node_modules/lodash.isplainobject/README.md +18 -0
  785. package/backend-project/node_modules/lodash.isplainobject/index.js +139 -0
  786. package/backend-project/node_modules/lodash.isplainobject/package.json +17 -0
  787. package/backend-project/node_modules/lodash.isstring/LICENSE +22 -0
  788. package/backend-project/node_modules/lodash.isstring/README.md +18 -0
  789. package/backend-project/node_modules/lodash.isstring/index.js +95 -0
  790. package/backend-project/node_modules/lodash.isstring/package.json +17 -0
  791. package/backend-project/node_modules/lodash.once/LICENSE +47 -0
  792. package/backend-project/node_modules/lodash.once/README.md +18 -0
  793. package/backend-project/node_modules/lodash.once/index.js +294 -0
  794. package/backend-project/node_modules/lodash.once/package.json +17 -0
  795. package/backend-project/node_modules/math-intrinsics/.eslintrc +16 -0
  796. package/backend-project/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
  797. package/backend-project/node_modules/math-intrinsics/CHANGELOG.md +24 -0
  798. package/backend-project/node_modules/math-intrinsics/LICENSE +21 -0
  799. package/backend-project/node_modules/math-intrinsics/README.md +50 -0
  800. package/backend-project/node_modules/math-intrinsics/abs.d.ts +1 -0
  801. package/backend-project/node_modules/math-intrinsics/abs.js +4 -0
  802. package/backend-project/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
  803. package/backend-project/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
  804. package/backend-project/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
  805. package/backend-project/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
  806. package/backend-project/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
  807. package/backend-project/node_modules/math-intrinsics/constants/maxValue.js +5 -0
  808. package/backend-project/node_modules/math-intrinsics/floor.d.ts +1 -0
  809. package/backend-project/node_modules/math-intrinsics/floor.js +4 -0
  810. package/backend-project/node_modules/math-intrinsics/isFinite.d.ts +3 -0
  811. package/backend-project/node_modules/math-intrinsics/isFinite.js +12 -0
  812. package/backend-project/node_modules/math-intrinsics/isInteger.d.ts +3 -0
  813. package/backend-project/node_modules/math-intrinsics/isInteger.js +16 -0
  814. package/backend-project/node_modules/math-intrinsics/isNaN.d.ts +1 -0
  815. package/backend-project/node_modules/math-intrinsics/isNaN.js +6 -0
  816. package/backend-project/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
  817. package/backend-project/node_modules/math-intrinsics/isNegativeZero.js +6 -0
  818. package/backend-project/node_modules/math-intrinsics/max.d.ts +1 -0
  819. package/backend-project/node_modules/math-intrinsics/max.js +4 -0
  820. package/backend-project/node_modules/math-intrinsics/min.d.ts +1 -0
  821. package/backend-project/node_modules/math-intrinsics/min.js +4 -0
  822. package/backend-project/node_modules/math-intrinsics/mod.d.ts +3 -0
  823. package/backend-project/node_modules/math-intrinsics/mod.js +9 -0
  824. package/backend-project/node_modules/math-intrinsics/package.json +86 -0
  825. package/backend-project/node_modules/math-intrinsics/pow.d.ts +1 -0
  826. package/backend-project/node_modules/math-intrinsics/pow.js +4 -0
  827. package/backend-project/node_modules/math-intrinsics/round.d.ts +1 -0
  828. package/backend-project/node_modules/math-intrinsics/round.js +4 -0
  829. package/backend-project/node_modules/math-intrinsics/sign.d.ts +3 -0
  830. package/backend-project/node_modules/math-intrinsics/sign.js +11 -0
  831. package/backend-project/node_modules/math-intrinsics/test/index.js +192 -0
  832. package/backend-project/node_modules/math-intrinsics/tsconfig.json +3 -0
  833. package/backend-project/node_modules/media-typer/HISTORY.md +22 -0
  834. package/backend-project/node_modules/media-typer/LICENSE +22 -0
  835. package/backend-project/node_modules/media-typer/README.md +81 -0
  836. package/backend-project/node_modules/media-typer/index.js +270 -0
  837. package/backend-project/node_modules/media-typer/package.json +26 -0
  838. package/backend-project/node_modules/memory-pager/.travis.yml +4 -0
  839. package/backend-project/node_modules/memory-pager/LICENSE +21 -0
  840. package/backend-project/node_modules/memory-pager/README.md +65 -0
  841. package/backend-project/node_modules/memory-pager/index.js +160 -0
  842. package/backend-project/node_modules/memory-pager/package.json +24 -0
  843. package/backend-project/node_modules/memory-pager/test.js +80 -0
  844. package/backend-project/node_modules/merge-descriptors/HISTORY.md +21 -0
  845. package/backend-project/node_modules/merge-descriptors/LICENSE +23 -0
  846. package/backend-project/node_modules/merge-descriptors/README.md +49 -0
  847. package/backend-project/node_modules/merge-descriptors/index.js +60 -0
  848. package/backend-project/node_modules/merge-descriptors/package.json +39 -0
  849. package/backend-project/node_modules/methods/HISTORY.md +29 -0
  850. package/backend-project/node_modules/methods/LICENSE +24 -0
  851. package/backend-project/node_modules/methods/README.md +51 -0
  852. package/backend-project/node_modules/methods/index.js +69 -0
  853. package/backend-project/node_modules/methods/package.json +36 -0
  854. package/backend-project/node_modules/mime/CHANGELOG.md +164 -0
  855. package/backend-project/node_modules/mime/LICENSE +21 -0
  856. package/backend-project/node_modules/mime/README.md +90 -0
  857. package/backend-project/node_modules/mime/cli.js +8 -0
  858. package/backend-project/node_modules/mime/mime.js +108 -0
  859. package/backend-project/node_modules/mime/package.json +44 -0
  860. package/backend-project/node_modules/mime/src/build.js +53 -0
  861. package/backend-project/node_modules/mime/src/test.js +60 -0
  862. package/backend-project/node_modules/mime/types.json +1 -0
  863. package/backend-project/node_modules/mime-db/HISTORY.md +507 -0
  864. package/backend-project/node_modules/mime-db/LICENSE +23 -0
  865. package/backend-project/node_modules/mime-db/README.md +100 -0
  866. package/backend-project/node_modules/mime-db/db.json +8519 -0
  867. package/backend-project/node_modules/mime-db/index.js +12 -0
  868. package/backend-project/node_modules/mime-db/package.json +60 -0
  869. package/backend-project/node_modules/mime-types/HISTORY.md +397 -0
  870. package/backend-project/node_modules/mime-types/LICENSE +23 -0
  871. package/backend-project/node_modules/mime-types/README.md +113 -0
  872. package/backend-project/node_modules/mime-types/index.js +188 -0
  873. package/backend-project/node_modules/mime-types/package.json +44 -0
  874. package/backend-project/node_modules/minimatch/LICENSE.md +55 -0
  875. package/backend-project/node_modules/minimatch/README.md +528 -0
  876. package/backend-project/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  877. package/backend-project/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
  878. package/backend-project/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  879. package/backend-project/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
  880. package/backend-project/node_modules/minimatch/dist/commonjs/ast.d.ts +22 -0
  881. package/backend-project/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
  882. package/backend-project/node_modules/minimatch/dist/commonjs/ast.js +845 -0
  883. package/backend-project/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
  884. package/backend-project/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  885. package/backend-project/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
  886. package/backend-project/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  887. package/backend-project/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
  888. package/backend-project/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
  889. package/backend-project/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
  890. package/backend-project/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  891. package/backend-project/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
  892. package/backend-project/node_modules/minimatch/dist/commonjs/index.d.ts +174 -0
  893. package/backend-project/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
  894. package/backend-project/node_modules/minimatch/dist/commonjs/index.js +1127 -0
  895. package/backend-project/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
  896. package/backend-project/node_modules/minimatch/dist/commonjs/package.json +3 -0
  897. package/backend-project/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
  898. package/backend-project/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
  899. package/backend-project/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  900. package/backend-project/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
  901. package/backend-project/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  902. package/backend-project/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
  903. package/backend-project/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  904. package/backend-project/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  905. package/backend-project/node_modules/minimatch/dist/esm/ast.d.ts +22 -0
  906. package/backend-project/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
  907. package/backend-project/node_modules/minimatch/dist/esm/ast.js +841 -0
  908. package/backend-project/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  909. package/backend-project/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  910. package/backend-project/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
  911. package/backend-project/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  912. package/backend-project/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  913. package/backend-project/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
  914. package/backend-project/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
  915. package/backend-project/node_modules/minimatch/dist/esm/escape.js +26 -0
  916. package/backend-project/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  917. package/backend-project/node_modules/minimatch/dist/esm/index.d.ts +174 -0
  918. package/backend-project/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
  919. package/backend-project/node_modules/minimatch/dist/esm/index.js +1114 -0
  920. package/backend-project/node_modules/minimatch/dist/esm/index.js.map +1 -0
  921. package/backend-project/node_modules/minimatch/dist/esm/package.json +3 -0
  922. package/backend-project/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
  923. package/backend-project/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
  924. package/backend-project/node_modules/minimatch/dist/esm/unescape.js +34 -0
  925. package/backend-project/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  926. package/backend-project/node_modules/minimatch/package.json +73 -0
  927. package/backend-project/node_modules/mongodb/LICENSE.md +201 -0
  928. package/backend-project/node_modules/mongodb/README.md +310 -0
  929. package/backend-project/node_modules/mongodb/etc/prepare.js +12 -0
  930. package/backend-project/node_modules/mongodb/lib/admin.js +149 -0
  931. package/backend-project/node_modules/mongodb/lib/admin.js.map +1 -0
  932. package/backend-project/node_modules/mongodb/lib/bson.js +61 -0
  933. package/backend-project/node_modules/mongodb/lib/bson.js.map +1 -0
  934. package/backend-project/node_modules/mongodb/lib/bulk/common.js +907 -0
  935. package/backend-project/node_modules/mongodb/lib/bulk/common.js.map +1 -0
  936. package/backend-project/node_modules/mongodb/lib/bulk/ordered.js +67 -0
  937. package/backend-project/node_modules/mongodb/lib/bulk/ordered.js.map +1 -0
  938. package/backend-project/node_modules/mongodb/lib/bulk/unordered.js +92 -0
  939. package/backend-project/node_modules/mongodb/lib/bulk/unordered.js.map +1 -0
  940. package/backend-project/node_modules/mongodb/lib/change_stream.js +397 -0
  941. package/backend-project/node_modules/mongodb/lib/change_stream.js.map +1 -0
  942. package/backend-project/node_modules/mongodb/lib/cmap/auth/auth_provider.js +47 -0
  943. package/backend-project/node_modules/mongodb/lib/cmap/auth/auth_provider.js.map +1 -0
  944. package/backend-project/node_modules/mongodb/lib/cmap/auth/gssapi.js +153 -0
  945. package/backend-project/node_modules/mongodb/lib/cmap/auth/gssapi.js.map +1 -0
  946. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +177 -0
  947. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js.map +1 -0
  948. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongocr.js +35 -0
  949. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongocr.js.map +1 -0
  950. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +227 -0
  951. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js.map +1 -0
  952. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js +30 -0
  953. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/aws_service_workflow.js.map +1 -0
  954. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_service_workflow.js +73 -0
  955. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_service_workflow.js.map +1 -0
  956. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_token_cache.js +49 -0
  957. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_token_cache.js.map +1 -0
  958. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/cache.js +55 -0
  959. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/cache.js.map +1 -0
  960. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js +89 -0
  961. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_lock_cache.js.map +1 -0
  962. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js +204 -0
  963. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
  964. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/service_workflow.js +43 -0
  965. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/service_workflow.js.map +1 -0
  966. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_entry_cache.js +62 -0
  967. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_entry_cache.js.map +1 -0
  968. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +68 -0
  969. package/backend-project/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js.map +1 -0
  970. package/backend-project/node_modules/mongodb/lib/cmap/auth/plain.js +26 -0
  971. package/backend-project/node_modules/mongodb/lib/cmap/auth/plain.js.map +1 -0
  972. package/backend-project/node_modules/mongodb/lib/cmap/auth/providers.js +24 -0
  973. package/backend-project/node_modules/mongodb/lib/cmap/auth/providers.js.map +1 -0
  974. package/backend-project/node_modules/mongodb/lib/cmap/auth/scram.js +262 -0
  975. package/backend-project/node_modules/mongodb/lib/cmap/auth/scram.js.map +1 -0
  976. package/backend-project/node_modules/mongodb/lib/cmap/auth/x509.js +36 -0
  977. package/backend-project/node_modules/mongodb/lib/cmap/auth/x509.js.map +1 -0
  978. package/backend-project/node_modules/mongodb/lib/cmap/command_monitoring_events.js +251 -0
  979. package/backend-project/node_modules/mongodb/lib/cmap/command_monitoring_events.js.map +1 -0
  980. package/backend-project/node_modules/mongodb/lib/cmap/commands.js +487 -0
  981. package/backend-project/node_modules/mongodb/lib/cmap/commands.js.map +1 -0
  982. package/backend-project/node_modules/mongodb/lib/cmap/connect.js +378 -0
  983. package/backend-project/node_modules/mongodb/lib/cmap/connect.js.map +1 -0
  984. package/backend-project/node_modules/mongodb/lib/cmap/connection.js +492 -0
  985. package/backend-project/node_modules/mongodb/lib/cmap/connection.js.map +1 -0
  986. package/backend-project/node_modules/mongodb/lib/cmap/connection_pool.js +637 -0
  987. package/backend-project/node_modules/mongodb/lib/cmap/connection_pool.js.map +1 -0
  988. package/backend-project/node_modules/mongodb/lib/cmap/connection_pool_events.js +191 -0
  989. package/backend-project/node_modules/mongodb/lib/cmap/connection_pool_events.js.map +1 -0
  990. package/backend-project/node_modules/mongodb/lib/cmap/errors.js +64 -0
  991. package/backend-project/node_modules/mongodb/lib/cmap/errors.js.map +1 -0
  992. package/backend-project/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +173 -0
  993. package/backend-project/node_modules/mongodb/lib/cmap/handshake/client_metadata.js.map +1 -0
  994. package/backend-project/node_modules/mongodb/lib/cmap/message_stream.js +156 -0
  995. package/backend-project/node_modules/mongodb/lib/cmap/message_stream.js.map +1 -0
  996. package/backend-project/node_modules/mongodb/lib/cmap/metrics.js +62 -0
  997. package/backend-project/node_modules/mongodb/lib/cmap/metrics.js.map +1 -0
  998. package/backend-project/node_modules/mongodb/lib/cmap/stream_description.js +51 -0
  999. package/backend-project/node_modules/mongodb/lib/cmap/stream_description.js.map +1 -0
  1000. package/backend-project/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +107 -0
  1001. package/backend-project/node_modules/mongodb/lib/cmap/wire_protocol/compression.js.map +1 -0
  1002. package/backend-project/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +17 -0
  1003. package/backend-project/node_modules/mongodb/lib/cmap/wire_protocol/constants.js.map +1 -0
  1004. package/backend-project/node_modules/mongodb/lib/cmap/wire_protocol/shared.js +40 -0
  1005. package/backend-project/node_modules/mongodb/lib/cmap/wire_protocol/shared.js.map +1 -0
  1006. package/backend-project/node_modules/mongodb/lib/collection.js +629 -0
  1007. package/backend-project/node_modules/mongodb/lib/collection.js.map +1 -0
  1008. package/backend-project/node_modules/mongodb/lib/connection_string.js +1103 -0
  1009. package/backend-project/node_modules/mongodb/lib/connection_string.js.map +1 -0
  1010. package/backend-project/node_modules/mongodb/lib/constants.js +142 -0
  1011. package/backend-project/node_modules/mongodb/lib/constants.js.map +1 -0
  1012. package/backend-project/node_modules/mongodb/lib/cursor/abstract_cursor.js +698 -0
  1013. package/backend-project/node_modules/mongodb/lib/cursor/abstract_cursor.js.map +1 -0
  1014. package/backend-project/node_modules/mongodb/lib/cursor/aggregation_cursor.js +168 -0
  1015. package/backend-project/node_modules/mongodb/lib/cursor/aggregation_cursor.js.map +1 -0
  1016. package/backend-project/node_modules/mongodb/lib/cursor/change_stream_cursor.js +115 -0
  1017. package/backend-project/node_modules/mongodb/lib/cursor/change_stream_cursor.js.map +1 -0
  1018. package/backend-project/node_modules/mongodb/lib/cursor/find_cursor.js +382 -0
  1019. package/backend-project/node_modules/mongodb/lib/cursor/find_cursor.js.map +1 -0
  1020. package/backend-project/node_modules/mongodb/lib/cursor/list_collections_cursor.js +37 -0
  1021. package/backend-project/node_modules/mongodb/lib/cursor/list_collections_cursor.js.map +1 -0
  1022. package/backend-project/node_modules/mongodb/lib/cursor/list_indexes_cursor.js +36 -0
  1023. package/backend-project/node_modules/mongodb/lib/cursor/list_indexes_cursor.js.map +1 -0
  1024. package/backend-project/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js +14 -0
  1025. package/backend-project/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js.map +1 -0
  1026. package/backend-project/node_modules/mongodb/lib/cursor/run_command_cursor.js +94 -0
  1027. package/backend-project/node_modules/mongodb/lib/cursor/run_command_cursor.js.map +1 -0
  1028. package/backend-project/node_modules/mongodb/lib/db.js +379 -0
  1029. package/backend-project/node_modules/mongodb/lib/db.js.map +1 -0
  1030. package/backend-project/node_modules/mongodb/lib/deps.js +87 -0
  1031. package/backend-project/node_modules/mongodb/lib/deps.js.map +1 -0
  1032. package/backend-project/node_modules/mongodb/lib/encrypter.js +103 -0
  1033. package/backend-project/node_modules/mongodb/lib/encrypter.js.map +1 -0
  1034. package/backend-project/node_modules/mongodb/lib/error.js +832 -0
  1035. package/backend-project/node_modules/mongodb/lib/error.js.map +1 -0
  1036. package/backend-project/node_modules/mongodb/lib/explain.js +35 -0
  1037. package/backend-project/node_modules/mongodb/lib/explain.js.map +1 -0
  1038. package/backend-project/node_modules/mongodb/lib/gridfs/download.js +313 -0
  1039. package/backend-project/node_modules/mongodb/lib/gridfs/download.js.map +1 -0
  1040. package/backend-project/node_modules/mongodb/lib/gridfs/index.js +128 -0
  1041. package/backend-project/node_modules/mongodb/lib/gridfs/index.js.map +1 -0
  1042. package/backend-project/node_modules/mongodb/lib/gridfs/upload.js +330 -0
  1043. package/backend-project/node_modules/mongodb/lib/gridfs/upload.js.map +1 -0
  1044. package/backend-project/node_modules/mongodb/lib/index.js +162 -0
  1045. package/backend-project/node_modules/mongodb/lib/index.js.map +1 -0
  1046. package/backend-project/node_modules/mongodb/lib/mongo_client.js +329 -0
  1047. package/backend-project/node_modules/mongodb/lib/mongo_client.js.map +1 -0
  1048. package/backend-project/node_modules/mongodb/lib/mongo_logger.js +360 -0
  1049. package/backend-project/node_modules/mongodb/lib/mongo_logger.js.map +1 -0
  1050. package/backend-project/node_modules/mongodb/lib/mongo_types.js +22 -0
  1051. package/backend-project/node_modules/mongodb/lib/mongo_types.js.map +1 -0
  1052. package/backend-project/node_modules/mongodb/lib/operations/add_user.js +74 -0
  1053. package/backend-project/node_modules/mongodb/lib/operations/add_user.js.map +1 -0
  1054. package/backend-project/node_modules/mongodb/lib/operations/aggregate.js +92 -0
  1055. package/backend-project/node_modules/mongodb/lib/operations/aggregate.js.map +1 -0
  1056. package/backend-project/node_modules/mongodb/lib/operations/bulk_write.js +36 -0
  1057. package/backend-project/node_modules/mongodb/lib/operations/bulk_write.js.map +1 -0
  1058. package/backend-project/node_modules/mongodb/lib/operations/collections.js +32 -0
  1059. package/backend-project/node_modules/mongodb/lib/operations/collections.js.map +1 -0
  1060. package/backend-project/node_modules/mongodb/lib/operations/command.js +88 -0
  1061. package/backend-project/node_modules/mongodb/lib/operations/command.js.map +1 -0
  1062. package/backend-project/node_modules/mongodb/lib/operations/common_functions.js +69 -0
  1063. package/backend-project/node_modules/mongodb/lib/operations/common_functions.js.map +1 -0
  1064. package/backend-project/node_modules/mongodb/lib/operations/count.js +39 -0
  1065. package/backend-project/node_modules/mongodb/lib/operations/count.js.map +1 -0
  1066. package/backend-project/node_modules/mongodb/lib/operations/count_documents.js +37 -0
  1067. package/backend-project/node_modules/mongodb/lib/operations/count_documents.js.map +1 -0
  1068. package/backend-project/node_modules/mongodb/lib/operations/create_collection.js +108 -0
  1069. package/backend-project/node_modules/mongodb/lib/operations/create_collection.js.map +1 -0
  1070. package/backend-project/node_modules/mongodb/lib/operations/delete.js +119 -0
  1071. package/backend-project/node_modules/mongodb/lib/operations/delete.js.map +1 -0
  1072. package/backend-project/node_modules/mongodb/lib/operations/distinct.js +67 -0
  1073. package/backend-project/node_modules/mongodb/lib/operations/distinct.js.map +1 -0
  1074. package/backend-project/node_modules/mongodb/lib/operations/drop.js +82 -0
  1075. package/backend-project/node_modules/mongodb/lib/operations/drop.js.map +1 -0
  1076. package/backend-project/node_modules/mongodb/lib/operations/estimated_document_count.js +38 -0
  1077. package/backend-project/node_modules/mongodb/lib/operations/estimated_document_count.js.map +1 -0
  1078. package/backend-project/node_modules/mongodb/lib/operations/eval.js +55 -0
  1079. package/backend-project/node_modules/mongodb/lib/operations/eval.js.map +1 -0
  1080. package/backend-project/node_modules/mongodb/lib/operations/execute_operation.js +162 -0
  1081. package/backend-project/node_modules/mongodb/lib/operations/execute_operation.js.map +1 -0
  1082. package/backend-project/node_modules/mongodb/lib/operations/find.js +149 -0
  1083. package/backend-project/node_modules/mongodb/lib/operations/find.js.map +1 -0
  1084. package/backend-project/node_modules/mongodb/lib/operations/find_and_modify.js +152 -0
  1085. package/backend-project/node_modules/mongodb/lib/operations/find_and_modify.js.map +1 -0
  1086. package/backend-project/node_modules/mongodb/lib/operations/get_more.js +58 -0
  1087. package/backend-project/node_modules/mongodb/lib/operations/get_more.js.map +1 -0
  1088. package/backend-project/node_modules/mongodb/lib/operations/indexes.js +270 -0
  1089. package/backend-project/node_modules/mongodb/lib/operations/indexes.js.map +1 -0
  1090. package/backend-project/node_modules/mongodb/lib/operations/insert.js +95 -0
  1091. package/backend-project/node_modules/mongodb/lib/operations/insert.js.map +1 -0
  1092. package/backend-project/node_modules/mongodb/lib/operations/is_capped.js +28 -0
  1093. package/backend-project/node_modules/mongodb/lib/operations/is_capped.js.map +1 -0
  1094. package/backend-project/node_modules/mongodb/lib/operations/kill_cursors.js +32 -0
  1095. package/backend-project/node_modules/mongodb/lib/operations/kill_cursors.js.map +1 -0
  1096. package/backend-project/node_modules/mongodb/lib/operations/list_collections.js +47 -0
  1097. package/backend-project/node_modules/mongodb/lib/operations/list_collections.js.map +1 -0
  1098. package/backend-project/node_modules/mongodb/lib/operations/list_databases.js +35 -0
  1099. package/backend-project/node_modules/mongodb/lib/operations/list_databases.js.map +1 -0
  1100. package/backend-project/node_modules/mongodb/lib/operations/operation.js +82 -0
  1101. package/backend-project/node_modules/mongodb/lib/operations/operation.js.map +1 -0
  1102. package/backend-project/node_modules/mongodb/lib/operations/options_operation.js +28 -0
  1103. package/backend-project/node_modules/mongodb/lib/operations/options_operation.js.map +1 -0
  1104. package/backend-project/node_modules/mongodb/lib/operations/profiling_level.js +33 -0
  1105. package/backend-project/node_modules/mongodb/lib/operations/profiling_level.js.map +1 -0
  1106. package/backend-project/node_modules/mongodb/lib/operations/remove_user.js +21 -0
  1107. package/backend-project/node_modules/mongodb/lib/operations/remove_user.js.map +1 -0
  1108. package/backend-project/node_modules/mongodb/lib/operations/rename.js +46 -0
  1109. package/backend-project/node_modules/mongodb/lib/operations/rename.js.map +1 -0
  1110. package/backend-project/node_modules/mongodb/lib/operations/run_command.js +26 -0
  1111. package/backend-project/node_modules/mongodb/lib/operations/run_command.js.map +1 -0
  1112. package/backend-project/node_modules/mongodb/lib/operations/search_indexes/create.js +29 -0
  1113. package/backend-project/node_modules/mongodb/lib/operations/search_indexes/create.js.map +1 -0
  1114. package/backend-project/node_modules/mongodb/lib/operations/search_indexes/drop.js +30 -0
  1115. package/backend-project/node_modules/mongodb/lib/operations/search_indexes/drop.js.map +1 -0
  1116. package/backend-project/node_modules/mongodb/lib/operations/search_indexes/update.js +30 -0
  1117. package/backend-project/node_modules/mongodb/lib/operations/search_indexes/update.js.map +1 -0
  1118. package/backend-project/node_modules/mongodb/lib/operations/set_profiling_level.js +51 -0
  1119. package/backend-project/node_modules/mongodb/lib/operations/set_profiling_level.js.map +1 -0
  1120. package/backend-project/node_modules/mongodb/lib/operations/stats.js +48 -0
  1121. package/backend-project/node_modules/mongodb/lib/operations/stats.js.map +1 -0
  1122. package/backend-project/node_modules/mongodb/lib/operations/update.js +183 -0
  1123. package/backend-project/node_modules/mongodb/lib/operations/update.js.map +1 -0
  1124. package/backend-project/node_modules/mongodb/lib/operations/validate_collection.js +41 -0
  1125. package/backend-project/node_modules/mongodb/lib/operations/validate_collection.js.map +1 -0
  1126. package/backend-project/node_modules/mongodb/lib/read_concern.js +73 -0
  1127. package/backend-project/node_modules/mongodb/lib/read_concern.js.map +1 -0
  1128. package/backend-project/node_modules/mongodb/lib/read_preference.js +195 -0
  1129. package/backend-project/node_modules/mongodb/lib/read_preference.js.map +1 -0
  1130. package/backend-project/node_modules/mongodb/lib/sdam/common.js +56 -0
  1131. package/backend-project/node_modules/mongodb/lib/sdam/common.js.map +1 -0
  1132. package/backend-project/node_modules/mongodb/lib/sdam/events.js +125 -0
  1133. package/backend-project/node_modules/mongodb/lib/sdam/events.js.map +1 -0
  1134. package/backend-project/node_modules/mongodb/lib/sdam/monitor.js +414 -0
  1135. package/backend-project/node_modules/mongodb/lib/sdam/monitor.js.map +1 -0
  1136. package/backend-project/node_modules/mongodb/lib/sdam/server.js +382 -0
  1137. package/backend-project/node_modules/mongodb/lib/sdam/server.js.map +1 -0
  1138. package/backend-project/node_modules/mongodb/lib/sdam/server_description.js +189 -0
  1139. package/backend-project/node_modules/mongodb/lib/sdam/server_description.js.map +1 -0
  1140. package/backend-project/node_modules/mongodb/lib/sdam/server_selection.js +226 -0
  1141. package/backend-project/node_modules/mongodb/lib/sdam/server_selection.js.map +1 -0
  1142. package/backend-project/node_modules/mongodb/lib/sdam/srv_polling.js +103 -0
  1143. package/backend-project/node_modules/mongodb/lib/sdam/srv_polling.js.map +1 -0
  1144. package/backend-project/node_modules/mongodb/lib/sdam/topology.js +621 -0
  1145. package/backend-project/node_modules/mongodb/lib/sdam/topology.js.map +1 -0
  1146. package/backend-project/node_modules/mongodb/lib/sdam/topology_description.js +360 -0
  1147. package/backend-project/node_modules/mongodb/lib/sdam/topology_description.js.map +1 -0
  1148. package/backend-project/node_modules/mongodb/lib/sessions.js +739 -0
  1149. package/backend-project/node_modules/mongodb/lib/sessions.js.map +1 -0
  1150. package/backend-project/node_modules/mongodb/lib/sort.js +97 -0
  1151. package/backend-project/node_modules/mongodb/lib/sort.js.map +1 -0
  1152. package/backend-project/node_modules/mongodb/lib/transactions.js +138 -0
  1153. package/backend-project/node_modules/mongodb/lib/transactions.js.map +1 -0
  1154. package/backend-project/node_modules/mongodb/lib/utils.js +1064 -0
  1155. package/backend-project/node_modules/mongodb/lib/utils.js.map +1 -0
  1156. package/backend-project/node_modules/mongodb/lib/write_concern.js +86 -0
  1157. package/backend-project/node_modules/mongodb/lib/write_concern.js.map +1 -0
  1158. package/backend-project/node_modules/mongodb/mongodb.d.ts +6750 -0
  1159. package/backend-project/node_modules/mongodb/package.json +163 -0
  1160. package/backend-project/node_modules/mongodb/src/admin.ts +192 -0
  1161. package/backend-project/node_modules/mongodb/src/bson.ts +117 -0
  1162. package/backend-project/node_modules/mongodb/src/bulk/common.ts +1338 -0
  1163. package/backend-project/node_modules/mongodb/src/bulk/ordered.ts +83 -0
  1164. package/backend-project/node_modules/mongodb/src/bulk/unordered.ts +116 -0
  1165. package/backend-project/node_modules/mongodb/src/change_stream.ts +973 -0
  1166. package/backend-project/node_modules/mongodb/src/cmap/auth/auth_provider.ts +73 -0
  1167. package/backend-project/node_modules/mongodb/src/cmap/auth/gssapi.ts +204 -0
  1168. package/backend-project/node_modules/mongodb/src/cmap/auth/mongo_credentials.ts +278 -0
  1169. package/backend-project/node_modules/mongodb/src/cmap/auth/mongocr.ts +42 -0
  1170. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_aws.ts +293 -0
  1171. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/aws_service_workflow.ts +29 -0
  1172. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/azure_service_workflow.ts +86 -0
  1173. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/azure_token_cache.ts +51 -0
  1174. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/cache.ts +63 -0
  1175. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/callback_lock_cache.ts +114 -0
  1176. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/callback_workflow.ts +296 -0
  1177. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/service_workflow.ts +49 -0
  1178. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_entry_cache.ts +77 -0
  1179. package/backend-project/node_modules/mongodb/src/cmap/auth/mongodb_oidc.ts +149 -0
  1180. package/backend-project/node_modules/mongodb/src/cmap/auth/plain.ts +25 -0
  1181. package/backend-project/node_modules/mongodb/src/cmap/auth/providers.ts +24 -0
  1182. package/backend-project/node_modules/mongodb/src/cmap/auth/scram.ts +354 -0
  1183. package/backend-project/node_modules/mongodb/src/cmap/auth/x509.ts +47 -0
  1184. package/backend-project/node_modules/mongodb/src/cmap/command_monitoring_events.ts +316 -0
  1185. package/backend-project/node_modules/mongodb/src/cmap/commands.ts +712 -0
  1186. package/backend-project/node_modules/mongodb/src/cmap/connect.ts +503 -0
  1187. package/backend-project/node_modules/mongodb/src/cmap/connection.ts +758 -0
  1188. package/backend-project/node_modules/mongodb/src/cmap/connection_pool.ts +920 -0
  1189. package/backend-project/node_modules/mongodb/src/cmap/connection_pool_events.ts +268 -0
  1190. package/backend-project/node_modules/mongodb/src/cmap/errors.ts +75 -0
  1191. package/backend-project/node_modules/mongodb/src/cmap/handshake/client_metadata.ts +273 -0
  1192. package/backend-project/node_modules/mongodb/src/cmap/message_stream.ts +234 -0
  1193. package/backend-project/node_modules/mongodb/src/cmap/metrics.ts +58 -0
  1194. package/backend-project/node_modules/mongodb/src/cmap/stream_description.ts +76 -0
  1195. package/backend-project/node_modules/mongodb/src/cmap/wire_protocol/compression.ts +126 -0
  1196. package/backend-project/node_modules/mongodb/src/cmap/wire_protocol/constants.ts +13 -0
  1197. package/backend-project/node_modules/mongodb/src/cmap/wire_protocol/shared.ts +53 -0
  1198. package/backend-project/node_modules/mongodb/src/collection.ts +1145 -0
  1199. package/backend-project/node_modules/mongodb/src/connection_string.ts +1315 -0
  1200. package/backend-project/node_modules/mongodb/src/constants.ts +147 -0
  1201. package/backend-project/node_modules/mongodb/src/cursor/abstract_cursor.ts +948 -0
  1202. package/backend-project/node_modules/mongodb/src/cursor/aggregation_cursor.ts +208 -0
  1203. package/backend-project/node_modules/mongodb/src/cursor/change_stream_cursor.ts +194 -0
  1204. package/backend-project/node_modules/mongodb/src/cursor/find_cursor.ts +458 -0
  1205. package/backend-project/node_modules/mongodb/src/cursor/list_collections_cursor.ts +52 -0
  1206. package/backend-project/node_modules/mongodb/src/cursor/list_indexes_cursor.ts +41 -0
  1207. package/backend-project/node_modules/mongodb/src/cursor/list_search_indexes_cursor.ts +20 -0
  1208. package/backend-project/node_modules/mongodb/src/cursor/run_command_cursor.ts +140 -0
  1209. package/backend-project/node_modules/mongodb/src/db.ts +558 -0
  1210. package/backend-project/node_modules/mongodb/src/deps.ts +428 -0
  1211. package/backend-project/node_modules/mongodb/src/encrypter.ts +131 -0
  1212. package/backend-project/node_modules/mongodb/src/error.ts +968 -0
  1213. package/backend-project/node_modules/mongodb/src/explain.ts +52 -0
  1214. package/backend-project/node_modules/mongodb/src/gridfs/download.ts +474 -0
  1215. package/backend-project/node_modules/mongodb/src/gridfs/index.ts +213 -0
  1216. package/backend-project/node_modules/mongodb/src/gridfs/upload.ts +510 -0
  1217. package/backend-project/node_modules/mongodb/src/index.ts +508 -0
  1218. package/backend-project/node_modules/mongodb/src/mongo_client.ts +839 -0
  1219. package/backend-project/node_modules/mongodb/src/mongo_logger.ts +538 -0
  1220. package/backend-project/node_modules/mongodb/src/mongo_types.ts +575 -0
  1221. package/backend-project/node_modules/mongodb/src/operations/add_user.ts +124 -0
  1222. package/backend-project/node_modules/mongodb/src/operations/aggregate.ts +149 -0
  1223. package/backend-project/node_modules/mongodb/src/operations/bulk_write.ts +62 -0
  1224. package/backend-project/node_modules/mongodb/src/operations/collections.ts +50 -0
  1225. package/backend-project/node_modules/mongodb/src/operations/command.ts +177 -0
  1226. package/backend-project/node_modules/mongodb/src/operations/common_functions.ts +105 -0
  1227. package/backend-project/node_modules/mongodb/src/operations/count.ts +68 -0
  1228. package/backend-project/node_modules/mongodb/src/operations/count_documents.ts +57 -0
  1229. package/backend-project/node_modules/mongodb/src/operations/create_collection.ts +217 -0
  1230. package/backend-project/node_modules/mongodb/src/operations/delete.ts +182 -0
  1231. package/backend-project/node_modules/mongodb/src/operations/distinct.ts +90 -0
  1232. package/backend-project/node_modules/mongodb/src/operations/drop.ts +119 -0
  1233. package/backend-project/node_modules/mongodb/src/operations/estimated_document_count.ts +62 -0
  1234. package/backend-project/node_modules/mongodb/src/operations/eval.ts +82 -0
  1235. package/backend-project/node_modules/mongodb/src/operations/execute_operation.ts +270 -0
  1236. package/backend-project/node_modules/mongodb/src/operations/find.ts +271 -0
  1237. package/backend-project/node_modules/mongodb/src/operations/find_and_modify.ts +303 -0
  1238. package/backend-project/node_modules/mongodb/src/operations/get_more.ts +111 -0
  1239. package/backend-project/node_modules/mongodb/src/operations/indexes.ts +526 -0
  1240. package/backend-project/node_modules/mongodb/src/operations/insert.ts +158 -0
  1241. package/backend-project/node_modules/mongodb/src/operations/is_capped.ts +44 -0
  1242. package/backend-project/node_modules/mongodb/src/operations/kill_cursors.ts +62 -0
  1243. package/backend-project/node_modules/mongodb/src/operations/list_collections.ts +99 -0
  1244. package/backend-project/node_modules/mongodb/src/operations/list_databases.ts +66 -0
  1245. package/backend-project/node_modules/mongodb/src/operations/operation.ts +141 -0
  1246. package/backend-project/node_modules/mongodb/src/operations/options_operation.ts +45 -0
  1247. package/backend-project/node_modules/mongodb/src/operations/profiling_level.ts +39 -0
  1248. package/backend-project/node_modules/mongodb/src/operations/remove_user.ts +33 -0
  1249. package/backend-project/node_modules/mongodb/src/operations/rename.ts +67 -0
  1250. package/backend-project/node_modules/mongodb/src/operations/run_command.ts +73 -0
  1251. package/backend-project/node_modules/mongodb/src/operations/search_indexes/create.ts +54 -0
  1252. package/backend-project/node_modules/mongodb/src/operations/search_indexes/drop.ts +39 -0
  1253. package/backend-project/node_modules/mongodb/src/operations/search_indexes/update.ts +40 -0
  1254. package/backend-project/node_modules/mongodb/src/operations/set_profiling_level.ts +74 -0
  1255. package/backend-project/node_modules/mongodb/src/operations/stats.ts +280 -0
  1256. package/backend-project/node_modules/mongodb/src/operations/update.ts +314 -0
  1257. package/backend-project/node_modules/mongodb/src/operations/validate_collection.ts +59 -0
  1258. package/backend-project/node_modules/mongodb/src/read_concern.ts +88 -0
  1259. package/backend-project/node_modules/mongodb/src/read_preference.ts +262 -0
  1260. package/backend-project/node_modules/mongodb/src/sdam/common.ts +79 -0
  1261. package/backend-project/node_modules/mongodb/src/sdam/events.ts +182 -0
  1262. package/backend-project/node_modules/mongodb/src/sdam/monitor.ts +595 -0
  1263. package/backend-project/node_modules/mongodb/src/sdam/server.ts +587 -0
  1264. package/backend-project/node_modules/mongodb/src/sdam/server_description.ts +262 -0
  1265. package/backend-project/node_modules/mongodb/src/sdam/server_selection.ts +324 -0
  1266. package/backend-project/node_modules/mongodb/src/sdam/srv_polling.ts +142 -0
  1267. package/backend-project/node_modules/mongodb/src/sdam/topology.ts +994 -0
  1268. package/backend-project/node_modules/mongodb/src/sdam/topology_description.ts +511 -0
  1269. package/backend-project/node_modules/mongodb/src/sessions.ts +1050 -0
  1270. package/backend-project/node_modules/mongodb/src/sort.ts +132 -0
  1271. package/backend-project/node_modules/mongodb/src/transactions.ts +188 -0
  1272. package/backend-project/node_modules/mongodb/src/utils.ts +1336 -0
  1273. package/backend-project/node_modules/mongodb/src/write_concern.ts +161 -0
  1274. package/backend-project/node_modules/mongodb/tsconfig.json +45 -0
  1275. package/backend-project/node_modules/mongodb-connection-string-url/.esm-wrapper.mjs +6 -0
  1276. package/backend-project/node_modules/mongodb-connection-string-url/LICENSE +192 -0
  1277. package/backend-project/node_modules/mongodb-connection-string-url/README.md +25 -0
  1278. package/backend-project/node_modules/mongodb-connection-string-url/lib/index.d.ts +62 -0
  1279. package/backend-project/node_modules/mongodb-connection-string-url/lib/index.js +213 -0
  1280. package/backend-project/node_modules/mongodb-connection-string-url/lib/index.js.map +1 -0
  1281. package/backend-project/node_modules/mongodb-connection-string-url/lib/redact.d.ts +7 -0
  1282. package/backend-project/node_modules/mongodb-connection-string-url/lib/redact.js +86 -0
  1283. package/backend-project/node_modules/mongodb-connection-string-url/lib/redact.js.map +1 -0
  1284. package/backend-project/node_modules/mongodb-connection-string-url/package.json +62 -0
  1285. package/backend-project/node_modules/mongoose/.claude/settings.local.json +7 -0
  1286. package/backend-project/node_modules/mongoose/LICENSE.md +22 -0
  1287. package/backend-project/node_modules/mongoose/README.md +375 -0
  1288. package/backend-project/node_modules/mongoose/SECURITY.md +1 -0
  1289. package/backend-project/node_modules/mongoose/browser.js +8 -0
  1290. package/backend-project/node_modules/mongoose/dist/browser.umd.js +2 -0
  1291. package/backend-project/node_modules/mongoose/index.js +63 -0
  1292. package/backend-project/node_modules/mongoose/lib/aggregate.js +1199 -0
  1293. package/backend-project/node_modules/mongoose/lib/browser.js +132 -0
  1294. package/backend-project/node_modules/mongoose/lib/browserDocument.js +101 -0
  1295. package/backend-project/node_modules/mongoose/lib/cast/bigint.js +36 -0
  1296. package/backend-project/node_modules/mongoose/lib/cast/boolean.js +32 -0
  1297. package/backend-project/node_modules/mongoose/lib/cast/date.js +41 -0
  1298. package/backend-project/node_modules/mongoose/lib/cast/decimal128.js +39 -0
  1299. package/backend-project/node_modules/mongoose/lib/cast/number.js +42 -0
  1300. package/backend-project/node_modules/mongoose/lib/cast/objectid.js +29 -0
  1301. package/backend-project/node_modules/mongoose/lib/cast/string.js +37 -0
  1302. package/backend-project/node_modules/mongoose/lib/cast.js +443 -0
  1303. package/backend-project/node_modules/mongoose/lib/collection.js +327 -0
  1304. package/backend-project/node_modules/mongoose/lib/connection.js +1477 -0
  1305. package/backend-project/node_modules/mongoose/lib/connectionstate.js +26 -0
  1306. package/backend-project/node_modules/mongoose/lib/cursor/AggregationCursor.js +386 -0
  1307. package/backend-project/node_modules/mongoose/lib/cursor/ChangeStream.js +153 -0
  1308. package/backend-project/node_modules/mongoose/lib/cursor/QueryCursor.js +579 -0
  1309. package/backend-project/node_modules/mongoose/lib/document.js +4830 -0
  1310. package/backend-project/node_modules/mongoose/lib/document_provider.js +30 -0
  1311. package/backend-project/node_modules/mongoose/lib/driver.js +15 -0
  1312. package/backend-project/node_modules/mongoose/lib/drivers/SPEC.md +4 -0
  1313. package/backend-project/node_modules/mongoose/lib/drivers/browser/binary.js +14 -0
  1314. package/backend-project/node_modules/mongoose/lib/drivers/browser/decimal128.js +7 -0
  1315. package/backend-project/node_modules/mongoose/lib/drivers/browser/index.js +12 -0
  1316. package/backend-project/node_modules/mongoose/lib/drivers/browser/objectid.js +29 -0
  1317. package/backend-project/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +461 -0
  1318. package/backend-project/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +409 -0
  1319. package/backend-project/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js +8 -0
  1320. package/backend-project/node_modules/mongoose/lib/error/browserMissingSchema.js +28 -0
  1321. package/backend-project/node_modules/mongoose/lib/error/bulkWriteError.js +41 -0
  1322. package/backend-project/node_modules/mongoose/lib/error/cast.js +159 -0
  1323. package/backend-project/node_modules/mongoose/lib/error/createCollectionsError.js +26 -0
  1324. package/backend-project/node_modules/mongoose/lib/error/divergentArray.js +38 -0
  1325. package/backend-project/node_modules/mongoose/lib/error/eachAsyncMultiError.js +41 -0
  1326. package/backend-project/node_modules/mongoose/lib/error/index.js +227 -0
  1327. package/backend-project/node_modules/mongoose/lib/error/invalidSchemaOption.js +30 -0
  1328. package/backend-project/node_modules/mongoose/lib/error/messages.js +47 -0
  1329. package/backend-project/node_modules/mongoose/lib/error/missingSchema.js +31 -0
  1330. package/backend-project/node_modules/mongoose/lib/error/mongooseError.js +13 -0
  1331. package/backend-project/node_modules/mongoose/lib/error/notFound.js +45 -0
  1332. package/backend-project/node_modules/mongoose/lib/error/objectExpected.js +30 -0
  1333. package/backend-project/node_modules/mongoose/lib/error/objectParameter.js +30 -0
  1334. package/backend-project/node_modules/mongoose/lib/error/overwriteModel.js +30 -0
  1335. package/backend-project/node_modules/mongoose/lib/error/parallelSave.js +30 -0
  1336. package/backend-project/node_modules/mongoose/lib/error/parallelValidate.js +31 -0
  1337. package/backend-project/node_modules/mongoose/lib/error/serverSelection.js +61 -0
  1338. package/backend-project/node_modules/mongoose/lib/error/setOptionError.js +101 -0
  1339. package/backend-project/node_modules/mongoose/lib/error/strict.js +33 -0
  1340. package/backend-project/node_modules/mongoose/lib/error/strictPopulate.js +29 -0
  1341. package/backend-project/node_modules/mongoose/lib/error/syncIndexes.js +30 -0
  1342. package/backend-project/node_modules/mongoose/lib/error/validation.js +103 -0
  1343. package/backend-project/node_modules/mongoose/lib/error/validator.js +99 -0
  1344. package/backend-project/node_modules/mongoose/lib/error/version.js +36 -0
  1345. package/backend-project/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +39 -0
  1346. package/backend-project/node_modules/mongoose/lib/helpers/aggregate/stringifyFunctionOperators.js +50 -0
  1347. package/backend-project/node_modules/mongoose/lib/helpers/arrayDepth.js +33 -0
  1348. package/backend-project/node_modules/mongoose/lib/helpers/clone.js +180 -0
  1349. package/backend-project/node_modules/mongoose/lib/helpers/common.js +127 -0
  1350. package/backend-project/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +225 -0
  1351. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +32 -0
  1352. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
  1353. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
  1354. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +29 -0
  1355. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
  1356. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
  1357. package/backend-project/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +76 -0
  1358. package/backend-project/node_modules/mongoose/lib/helpers/document/applyDefaults.js +128 -0
  1359. package/backend-project/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +35 -0
  1360. package/backend-project/node_modules/mongoose/lib/helpers/document/compile.js +238 -0
  1361. package/backend-project/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
  1362. package/backend-project/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +53 -0
  1363. package/backend-project/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js +35 -0
  1364. package/backend-project/node_modules/mongoose/lib/helpers/each.js +25 -0
  1365. package/backend-project/node_modules/mongoose/lib/helpers/error/combinePathErrors.js +22 -0
  1366. package/backend-project/node_modules/mongoose/lib/helpers/firstKey.js +8 -0
  1367. package/backend-project/node_modules/mongoose/lib/helpers/get.js +65 -0
  1368. package/backend-project/node_modules/mongoose/lib/helpers/getConstructorName.js +16 -0
  1369. package/backend-project/node_modules/mongoose/lib/helpers/getDefaultBulkwriteResult.js +27 -0
  1370. package/backend-project/node_modules/mongoose/lib/helpers/getFunctionName.js +10 -0
  1371. package/backend-project/node_modules/mongoose/lib/helpers/immediate.js +16 -0
  1372. package/backend-project/node_modules/mongoose/lib/helpers/indexes/applySchemaCollation.js +13 -0
  1373. package/backend-project/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
  1374. package/backend-project/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +59 -0
  1375. package/backend-project/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
  1376. package/backend-project/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +96 -0
  1377. package/backend-project/node_modules/mongoose/lib/helpers/indexes/isTextIndex.js +16 -0
  1378. package/backend-project/node_modules/mongoose/lib/helpers/isAsyncFunction.js +9 -0
  1379. package/backend-project/node_modules/mongoose/lib/helpers/isBsonType.js +16 -0
  1380. package/backend-project/node_modules/mongoose/lib/helpers/isMongooseObject.js +22 -0
  1381. package/backend-project/node_modules/mongoose/lib/helpers/isObject.js +16 -0
  1382. package/backend-project/node_modules/mongoose/lib/helpers/isPOJO.js +12 -0
  1383. package/backend-project/node_modules/mongoose/lib/helpers/isPromise.js +6 -0
  1384. package/backend-project/node_modules/mongoose/lib/helpers/isSimpleValidator.js +22 -0
  1385. package/backend-project/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
  1386. package/backend-project/node_modules/mongoose/lib/helpers/model/applyHooks.js +149 -0
  1387. package/backend-project/node_modules/mongoose/lib/helpers/model/applyMethods.js +70 -0
  1388. package/backend-project/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +71 -0
  1389. package/backend-project/node_modules/mongoose/lib/helpers/model/applyStatics.js +13 -0
  1390. package/backend-project/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +284 -0
  1391. package/backend-project/node_modules/mongoose/lib/helpers/model/discriminator.js +213 -0
  1392. package/backend-project/node_modules/mongoose/lib/helpers/model/pushNestedArrayPaths.js +15 -0
  1393. package/backend-project/node_modules/mongoose/lib/helpers/once.js +12 -0
  1394. package/backend-project/node_modules/mongoose/lib/helpers/parallelLimit.js +55 -0
  1395. package/backend-project/node_modules/mongoose/lib/helpers/path/parentPaths.js +18 -0
  1396. package/backend-project/node_modules/mongoose/lib/helpers/path/setDottedPath.js +33 -0
  1397. package/backend-project/node_modules/mongoose/lib/helpers/pluralize.js +95 -0
  1398. package/backend-project/node_modules/mongoose/lib/helpers/populate/SkipPopulateValue.js +10 -0
  1399. package/backend-project/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +129 -0
  1400. package/backend-project/node_modules/mongoose/lib/helpers/populate/assignVals.js +344 -0
  1401. package/backend-project/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
  1402. package/backend-project/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +758 -0
  1403. package/backend-project/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +229 -0
  1404. package/backend-project/node_modules/mongoose/lib/helpers/populate/getVirtual.js +72 -0
  1405. package/backend-project/node_modules/mongoose/lib/helpers/populate/leanPopulateMap.js +7 -0
  1406. package/backend-project/node_modules/mongoose/lib/helpers/populate/lookupLocalFields.js +40 -0
  1407. package/backend-project/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +49 -0
  1408. package/backend-project/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +68 -0
  1409. package/backend-project/node_modules/mongoose/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
  1410. package/backend-project/node_modules/mongoose/lib/helpers/populate/validateRef.js +19 -0
  1411. package/backend-project/node_modules/mongoose/lib/helpers/printJestWarning.js +21 -0
  1412. package/backend-project/node_modules/mongoose/lib/helpers/processConnectionOptions.js +65 -0
  1413. package/backend-project/node_modules/mongoose/lib/helpers/projection/applyProjection.js +77 -0
  1414. package/backend-project/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +41 -0
  1415. package/backend-project/node_modules/mongoose/lib/helpers/projection/isDefiningProjection.js +18 -0
  1416. package/backend-project/node_modules/mongoose/lib/helpers/projection/isExclusive.js +37 -0
  1417. package/backend-project/node_modules/mongoose/lib/helpers/projection/isInclusive.js +39 -0
  1418. package/backend-project/node_modules/mongoose/lib/helpers/projection/isNestedProjection.js +8 -0
  1419. package/backend-project/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +40 -0
  1420. package/backend-project/node_modules/mongoose/lib/helpers/projection/isPathSelectedInclusive.js +28 -0
  1421. package/backend-project/node_modules/mongoose/lib/helpers/projection/isSubpath.js +14 -0
  1422. package/backend-project/node_modules/mongoose/lib/helpers/projection/parseProjection.js +33 -0
  1423. package/backend-project/node_modules/mongoose/lib/helpers/promiseOrCallback.js +54 -0
  1424. package/backend-project/node_modules/mongoose/lib/helpers/query/applyGlobalOption.js +29 -0
  1425. package/backend-project/node_modules/mongoose/lib/helpers/query/applyQueryMiddleware.js +54 -0
  1426. package/backend-project/node_modules/mongoose/lib/helpers/query/cast$expr.js +292 -0
  1427. package/backend-project/node_modules/mongoose/lib/helpers/query/castFilterPath.js +55 -0
  1428. package/backend-project/node_modules/mongoose/lib/helpers/query/castUpdate.js +584 -0
  1429. package/backend-project/node_modules/mongoose/lib/helpers/query/completeMany.js +36 -0
  1430. package/backend-project/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +94 -0
  1431. package/backend-project/node_modules/mongoose/lib/helpers/query/handleImmutable.js +32 -0
  1432. package/backend-project/node_modules/mongoose/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
  1433. package/backend-project/node_modules/mongoose/lib/helpers/query/hasDollarKeys.js +23 -0
  1434. package/backend-project/node_modules/mongoose/lib/helpers/query/isOperator.js +14 -0
  1435. package/backend-project/node_modules/mongoose/lib/helpers/query/sanitizeFilter.js +41 -0
  1436. package/backend-project/node_modules/mongoose/lib/helpers/query/sanitizeProjection.js +14 -0
  1437. package/backend-project/node_modules/mongoose/lib/helpers/query/selectPopulatedFields.js +62 -0
  1438. package/backend-project/node_modules/mongoose/lib/helpers/query/trusted.js +13 -0
  1439. package/backend-project/node_modules/mongoose/lib/helpers/query/validOps.js +22 -0
  1440. package/backend-project/node_modules/mongoose/lib/helpers/schema/addAutoId.js +7 -0
  1441. package/backend-project/node_modules/mongoose/lib/helpers/schema/applyBuiltinPlugins.js +12 -0
  1442. package/backend-project/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +55 -0
  1443. package/backend-project/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +33 -0
  1444. package/backend-project/node_modules/mongoose/lib/helpers/schema/cleanPositionalOperators.js +12 -0
  1445. package/backend-project/node_modules/mongoose/lib/helpers/schema/getIndexes.js +172 -0
  1446. package/backend-project/node_modules/mongoose/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
  1447. package/backend-project/node_modules/mongoose/lib/helpers/schema/getPath.js +37 -0
  1448. package/backend-project/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
  1449. package/backend-project/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +20 -0
  1450. package/backend-project/node_modules/mongoose/lib/helpers/schema/handleTimestampOption.js +24 -0
  1451. package/backend-project/node_modules/mongoose/lib/helpers/schema/idGetter.js +46 -0
  1452. package/backend-project/node_modules/mongoose/lib/helpers/schema/merge.js +36 -0
  1453. package/backend-project/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +50 -0
  1454. package/backend-project/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +132 -0
  1455. package/backend-project/node_modules/mongoose/lib/helpers/specialProperties.js +3 -0
  1456. package/backend-project/node_modules/mongoose/lib/helpers/symbols.js +20 -0
  1457. package/backend-project/node_modules/mongoose/lib/helpers/timers.js +3 -0
  1458. package/backend-project/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
  1459. package/backend-project/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +110 -0
  1460. package/backend-project/node_modules/mongoose/lib/helpers/topology/allServersUnknown.js +12 -0
  1461. package/backend-project/node_modules/mongoose/lib/helpers/topology/isAtlas.js +31 -0
  1462. package/backend-project/node_modules/mongoose/lib/helpers/topology/isSSLError.js +16 -0
  1463. package/backend-project/node_modules/mongoose/lib/helpers/update/applyTimestampsToChildren.js +193 -0
  1464. package/backend-project/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +131 -0
  1465. package/backend-project/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +109 -0
  1466. package/backend-project/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +26 -0
  1467. package/backend-project/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +33 -0
  1468. package/backend-project/node_modules/mongoose/lib/helpers/update/moveImmutableProperties.js +53 -0
  1469. package/backend-project/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +32 -0
  1470. package/backend-project/node_modules/mongoose/lib/helpers/update/updatedPathsByArrayFilter.js +27 -0
  1471. package/backend-project/node_modules/mongoose/lib/helpers/updateValidators.js +249 -0
  1472. package/backend-project/node_modules/mongoose/lib/index.js +1300 -0
  1473. package/backend-project/node_modules/mongoose/lib/internal.js +46 -0
  1474. package/backend-project/node_modules/mongoose/lib/model.js +4945 -0
  1475. package/backend-project/node_modules/mongoose/lib/options/PopulateOptions.js +36 -0
  1476. package/backend-project/node_modules/mongoose/lib/options/SchemaArrayOptions.js +78 -0
  1477. package/backend-project/node_modules/mongoose/lib/options/SchemaBufferOptions.js +38 -0
  1478. package/backend-project/node_modules/mongoose/lib/options/SchemaDateOptions.js +71 -0
  1479. package/backend-project/node_modules/mongoose/lib/options/SchemaDocumentArrayOptions.js +68 -0
  1480. package/backend-project/node_modules/mongoose/lib/options/SchemaMapOptions.js +43 -0
  1481. package/backend-project/node_modules/mongoose/lib/options/SchemaNumberOptions.js +101 -0
  1482. package/backend-project/node_modules/mongoose/lib/options/SchemaObjectIdOptions.js +64 -0
  1483. package/backend-project/node_modules/mongoose/lib/options/SchemaStringOptions.js +138 -0
  1484. package/backend-project/node_modules/mongoose/lib/options/SchemaSubdocumentOptions.js +42 -0
  1485. package/backend-project/node_modules/mongoose/lib/options/SchemaTypeOptions.js +244 -0
  1486. package/backend-project/node_modules/mongoose/lib/options/VirtualOptions.js +164 -0
  1487. package/backend-project/node_modules/mongoose/lib/options/propertyOptions.js +8 -0
  1488. package/backend-project/node_modules/mongoose/lib/options/saveOptions.js +14 -0
  1489. package/backend-project/node_modules/mongoose/lib/options.js +15 -0
  1490. package/backend-project/node_modules/mongoose/lib/plugins/index.js +7 -0
  1491. package/backend-project/node_modules/mongoose/lib/plugins/removeSubdocs.js +35 -0
  1492. package/backend-project/node_modules/mongoose/lib/plugins/saveSubdocs.js +66 -0
  1493. package/backend-project/node_modules/mongoose/lib/plugins/sharding.js +83 -0
  1494. package/backend-project/node_modules/mongoose/lib/plugins/trackTransaction.js +92 -0
  1495. package/backend-project/node_modules/mongoose/lib/plugins/validateBeforeSave.js +51 -0
  1496. package/backend-project/node_modules/mongoose/lib/query.js +5542 -0
  1497. package/backend-project/node_modules/mongoose/lib/queryhelpers.js +403 -0
  1498. package/backend-project/node_modules/mongoose/lib/schema/DocumentArrayElement.js +100 -0
  1499. package/backend-project/node_modules/mongoose/lib/schema/SubdocumentPath.js +397 -0
  1500. package/backend-project/node_modules/mongoose/lib/schema/array.js +686 -0
  1501. package/backend-project/node_modules/mongoose/lib/schema/bigint.js +240 -0
  1502. package/backend-project/node_modules/mongoose/lib/schema/boolean.js +290 -0
  1503. package/backend-project/node_modules/mongoose/lib/schema/buffer.js +290 -0
  1504. package/backend-project/node_modules/mongoose/lib/schema/date.js +426 -0
  1505. package/backend-project/node_modules/mongoose/lib/schema/decimal128.js +228 -0
  1506. package/backend-project/node_modules/mongoose/lib/schema/documentarray.js +616 -0
  1507. package/backend-project/node_modules/mongoose/lib/schema/index.js +28 -0
  1508. package/backend-project/node_modules/mongoose/lib/schema/map.js +84 -0
  1509. package/backend-project/node_modules/mongoose/lib/schema/mixed.js +131 -0
  1510. package/backend-project/node_modules/mongoose/lib/schema/number.js +440 -0
  1511. package/backend-project/node_modules/mongoose/lib/schema/objectid.js +297 -0
  1512. package/backend-project/node_modules/mongoose/lib/schema/operators/bitwise.js +38 -0
  1513. package/backend-project/node_modules/mongoose/lib/schema/operators/exists.js +12 -0
  1514. package/backend-project/node_modules/mongoose/lib/schema/operators/geospatial.js +107 -0
  1515. package/backend-project/node_modules/mongoose/lib/schema/operators/helpers.js +32 -0
  1516. package/backend-project/node_modules/mongoose/lib/schema/operators/text.js +39 -0
  1517. package/backend-project/node_modules/mongoose/lib/schema/operators/type.js +20 -0
  1518. package/backend-project/node_modules/mongoose/lib/schema/string.js +698 -0
  1519. package/backend-project/node_modules/mongoose/lib/schema/symbols.js +5 -0
  1520. package/backend-project/node_modules/mongoose/lib/schema/uuid.js +356 -0
  1521. package/backend-project/node_modules/mongoose/lib/schema.js +2780 -0
  1522. package/backend-project/node_modules/mongoose/lib/schematype.js +1709 -0
  1523. package/backend-project/node_modules/mongoose/lib/statemachine.js +211 -0
  1524. package/backend-project/node_modules/mongoose/lib/types/ArraySubdocument.js +197 -0
  1525. package/backend-project/node_modules/mongoose/lib/types/DocumentArray/index.js +113 -0
  1526. package/backend-project/node_modules/mongoose/lib/types/DocumentArray/isMongooseDocumentArray.js +5 -0
  1527. package/backend-project/node_modules/mongoose/lib/types/DocumentArray/methods/index.js +383 -0
  1528. package/backend-project/node_modules/mongoose/lib/types/array/index.js +119 -0
  1529. package/backend-project/node_modules/mongoose/lib/types/array/isMongooseArray.js +5 -0
  1530. package/backend-project/node_modules/mongoose/lib/types/array/methods/index.js +1031 -0
  1531. package/backend-project/node_modules/mongoose/lib/types/buffer.js +277 -0
  1532. package/backend-project/node_modules/mongoose/lib/types/decimal128.js +13 -0
  1533. package/backend-project/node_modules/mongoose/lib/types/index.js +22 -0
  1534. package/backend-project/node_modules/mongoose/lib/types/map.js +354 -0
  1535. package/backend-project/node_modules/mongoose/lib/types/objectid.js +41 -0
  1536. package/backend-project/node_modules/mongoose/lib/types/subdocument.js +436 -0
  1537. package/backend-project/node_modules/mongoose/lib/types/uuid.js +13 -0
  1538. package/backend-project/node_modules/mongoose/lib/utils.js +988 -0
  1539. package/backend-project/node_modules/mongoose/lib/validoptions.js +38 -0
  1540. package/backend-project/node_modules/mongoose/lib/virtualtype.js +175 -0
  1541. package/backend-project/node_modules/mongoose/node_modules/ms/index.js +162 -0
  1542. package/backend-project/node_modules/mongoose/node_modules/ms/license.md +21 -0
  1543. package/backend-project/node_modules/mongoose/node_modules/ms/package.json +38 -0
  1544. package/backend-project/node_modules/mongoose/node_modules/ms/readme.md +59 -0
  1545. package/backend-project/node_modules/mongoose/package.json +156 -0
  1546. package/backend-project/node_modules/mongoose/startmdb.mjs +19 -0
  1547. package/backend-project/node_modules/mongoose/types/aggregate.d.ts +180 -0
  1548. package/backend-project/node_modules/mongoose/types/augmentations.d.ts +9 -0
  1549. package/backend-project/node_modules/mongoose/types/callback.d.ts +8 -0
  1550. package/backend-project/node_modules/mongoose/types/collection.d.ts +44 -0
  1551. package/backend-project/node_modules/mongoose/types/connection.d.ts +234 -0
  1552. package/backend-project/node_modules/mongoose/types/cursor.d.ts +58 -0
  1553. package/backend-project/node_modules/mongoose/types/document.d.ts +261 -0
  1554. package/backend-project/node_modules/mongoose/types/error.d.ts +134 -0
  1555. package/backend-project/node_modules/mongoose/types/expressions.d.ts +3038 -0
  1556. package/backend-project/node_modules/mongoose/types/helpers.d.ts +32 -0
  1557. package/backend-project/node_modules/mongoose/types/index.d.ts +678 -0
  1558. package/backend-project/node_modules/mongoose/types/indexes.d.ts +89 -0
  1559. package/backend-project/node_modules/mongoose/types/inferschematype.d.ts +230 -0
  1560. package/backend-project/node_modules/mongoose/types/middlewares.d.ts +49 -0
  1561. package/backend-project/node_modules/mongoose/types/models.d.ts +790 -0
  1562. package/backend-project/node_modules/mongoose/types/mongooseoptions.d.ts +219 -0
  1563. package/backend-project/node_modules/mongoose/types/pipelinestage.d.ts +312 -0
  1564. package/backend-project/node_modules/mongoose/types/populate.d.ts +45 -0
  1565. package/backend-project/node_modules/mongoose/types/query.d.ts +781 -0
  1566. package/backend-project/node_modules/mongoose/types/schemaoptions.d.ts +261 -0
  1567. package/backend-project/node_modules/mongoose/types/schematypes.d.ts +490 -0
  1568. package/backend-project/node_modules/mongoose/types/session.d.ts +32 -0
  1569. package/backend-project/node_modules/mongoose/types/types.d.ts +103 -0
  1570. package/backend-project/node_modules/mongoose/types/utility.d.ts +43 -0
  1571. package/backend-project/node_modules/mongoose/types/validation.d.ts +34 -0
  1572. package/backend-project/node_modules/mongoose/types/virtuals.d.ts +14 -0
  1573. package/backend-project/node_modules/mpath/.travis.yml +9 -0
  1574. package/backend-project/node_modules/mpath/History.md +88 -0
  1575. package/backend-project/node_modules/mpath/LICENSE +22 -0
  1576. package/backend-project/node_modules/mpath/README.md +278 -0
  1577. package/backend-project/node_modules/mpath/SECURITY.md +5 -0
  1578. package/backend-project/node_modules/mpath/index.js +3 -0
  1579. package/backend-project/node_modules/mpath/lib/index.js +336 -0
  1580. package/backend-project/node_modules/mpath/lib/stringToParts.js +48 -0
  1581. package/backend-project/node_modules/mpath/package.json +144 -0
  1582. package/backend-project/node_modules/mpath/test/.eslintrc.yml +4 -0
  1583. package/backend-project/node_modules/mpath/test/index.js +1879 -0
  1584. package/backend-project/node_modules/mpath/test/stringToParts.js +30 -0
  1585. package/backend-project/node_modules/mquery/.github/ISSUE_TEMPLATE.md +11 -0
  1586. package/backend-project/node_modules/mquery/.github/PULL_REQUEST_TEMPLATE.md +9 -0
  1587. package/backend-project/node_modules/mquery/History.md +384 -0
  1588. package/backend-project/node_modules/mquery/LICENSE +22 -0
  1589. package/backend-project/node_modules/mquery/README.md +1247 -0
  1590. package/backend-project/node_modules/mquery/SECURITY.md +1 -0
  1591. package/backend-project/node_modules/mquery/lib/collection/collection.js +45 -0
  1592. package/backend-project/node_modules/mquery/lib/collection/index.js +13 -0
  1593. package/backend-project/node_modules/mquery/lib/collection/node.js +114 -0
  1594. package/backend-project/node_modules/mquery/lib/env.js +22 -0
  1595. package/backend-project/node_modules/mquery/lib/mquery.js +2705 -0
  1596. package/backend-project/node_modules/mquery/lib/permissions.js +78 -0
  1597. package/backend-project/node_modules/mquery/lib/utils.js +297 -0
  1598. package/backend-project/node_modules/mquery/node_modules/debug/LICENSE +20 -0
  1599. package/backend-project/node_modules/mquery/node_modules/debug/README.md +481 -0
  1600. package/backend-project/node_modules/mquery/node_modules/debug/package.json +64 -0
  1601. package/backend-project/node_modules/mquery/node_modules/debug/src/browser.js +272 -0
  1602. package/backend-project/node_modules/mquery/node_modules/debug/src/common.js +292 -0
  1603. package/backend-project/node_modules/mquery/node_modules/debug/src/index.js +10 -0
  1604. package/backend-project/node_modules/mquery/node_modules/debug/src/node.js +263 -0
  1605. package/backend-project/node_modules/mquery/node_modules/ms/index.js +162 -0
  1606. package/backend-project/node_modules/mquery/node_modules/ms/license.md +21 -0
  1607. package/backend-project/node_modules/mquery/node_modules/ms/package.json +38 -0
  1608. package/backend-project/node_modules/mquery/node_modules/ms/readme.md +59 -0
  1609. package/backend-project/node_modules/mquery/package.json +38 -0
  1610. package/backend-project/node_modules/ms/index.js +152 -0
  1611. package/backend-project/node_modules/ms/license.md +21 -0
  1612. package/backend-project/node_modules/ms/package.json +37 -0
  1613. package/backend-project/node_modules/ms/readme.md +51 -0
  1614. package/backend-project/node_modules/negotiator/HISTORY.md +108 -0
  1615. package/backend-project/node_modules/negotiator/LICENSE +24 -0
  1616. package/backend-project/node_modules/negotiator/README.md +203 -0
  1617. package/backend-project/node_modules/negotiator/index.js +82 -0
  1618. package/backend-project/node_modules/negotiator/lib/charset.js +169 -0
  1619. package/backend-project/node_modules/negotiator/lib/encoding.js +184 -0
  1620. package/backend-project/node_modules/negotiator/lib/language.js +179 -0
  1621. package/backend-project/node_modules/negotiator/lib/mediaType.js +294 -0
  1622. package/backend-project/node_modules/negotiator/package.json +42 -0
  1623. package/backend-project/node_modules/nodemon/.prettierrc.json +3 -0
  1624. package/backend-project/node_modules/nodemon/LICENSE +21 -0
  1625. package/backend-project/node_modules/nodemon/README.md +439 -0
  1626. package/backend-project/node_modules/nodemon/bin/nodemon.js +16 -0
  1627. package/backend-project/node_modules/nodemon/bin/windows-kill.exe +0 -0
  1628. package/backend-project/node_modules/nodemon/doc/cli/authors.txt +8 -0
  1629. package/backend-project/node_modules/nodemon/doc/cli/config.txt +44 -0
  1630. package/backend-project/node_modules/nodemon/doc/cli/help.txt +29 -0
  1631. package/backend-project/node_modules/nodemon/doc/cli/logo.txt +20 -0
  1632. package/backend-project/node_modules/nodemon/doc/cli/options.txt +36 -0
  1633. package/backend-project/node_modules/nodemon/doc/cli/topics.txt +8 -0
  1634. package/backend-project/node_modules/nodemon/doc/cli/usage.txt +3 -0
  1635. package/backend-project/node_modules/nodemon/doc/cli/whoami.txt +9 -0
  1636. package/backend-project/node_modules/nodemon/index.d.ts +124 -0
  1637. package/backend-project/node_modules/nodemon/jsconfig.json +7 -0
  1638. package/backend-project/node_modules/nodemon/lib/cli/index.js +49 -0
  1639. package/backend-project/node_modules/nodemon/lib/cli/parse.js +230 -0
  1640. package/backend-project/node_modules/nodemon/lib/config/command.js +43 -0
  1641. package/backend-project/node_modules/nodemon/lib/config/defaults.js +34 -0
  1642. package/backend-project/node_modules/nodemon/lib/config/exec.js +240 -0
  1643. package/backend-project/node_modules/nodemon/lib/config/index.js +93 -0
  1644. package/backend-project/node_modules/nodemon/lib/config/load.js +225 -0
  1645. package/backend-project/node_modules/nodemon/lib/help/index.js +27 -0
  1646. package/backend-project/node_modules/nodemon/lib/index.js +1 -0
  1647. package/backend-project/node_modules/nodemon/lib/monitor/index.js +4 -0
  1648. package/backend-project/node_modules/nodemon/lib/monitor/match.js +288 -0
  1649. package/backend-project/node_modules/nodemon/lib/monitor/run.js +562 -0
  1650. package/backend-project/node_modules/nodemon/lib/monitor/signals.js +34 -0
  1651. package/backend-project/node_modules/nodemon/lib/monitor/watch.js +244 -0
  1652. package/backend-project/node_modules/nodemon/lib/nodemon.js +317 -0
  1653. package/backend-project/node_modules/nodemon/lib/rules/add.js +89 -0
  1654. package/backend-project/node_modules/nodemon/lib/rules/index.js +53 -0
  1655. package/backend-project/node_modules/nodemon/lib/rules/parse.js +43 -0
  1656. package/backend-project/node_modules/nodemon/lib/spawn.js +74 -0
  1657. package/backend-project/node_modules/nodemon/lib/utils/bus.js +44 -0
  1658. package/backend-project/node_modules/nodemon/lib/utils/clone.js +40 -0
  1659. package/backend-project/node_modules/nodemon/lib/utils/colour.js +26 -0
  1660. package/backend-project/node_modules/nodemon/lib/utils/index.js +103 -0
  1661. package/backend-project/node_modules/nodemon/lib/utils/log.js +82 -0
  1662. package/backend-project/node_modules/nodemon/lib/utils/merge.js +47 -0
  1663. package/backend-project/node_modules/nodemon/lib/version.js +100 -0
  1664. package/backend-project/node_modules/nodemon/node_modules/debug/LICENSE +20 -0
  1665. package/backend-project/node_modules/nodemon/node_modules/debug/README.md +481 -0
  1666. package/backend-project/node_modules/nodemon/node_modules/debug/package.json +64 -0
  1667. package/backend-project/node_modules/nodemon/node_modules/debug/src/browser.js +272 -0
  1668. package/backend-project/node_modules/nodemon/node_modules/debug/src/common.js +292 -0
  1669. package/backend-project/node_modules/nodemon/node_modules/debug/src/index.js +10 -0
  1670. package/backend-project/node_modules/nodemon/node_modules/debug/src/node.js +263 -0
  1671. package/backend-project/node_modules/nodemon/node_modules/ms/index.js +162 -0
  1672. package/backend-project/node_modules/nodemon/node_modules/ms/license.md +21 -0
  1673. package/backend-project/node_modules/nodemon/node_modules/ms/package.json +38 -0
  1674. package/backend-project/node_modules/nodemon/node_modules/ms/readme.md +59 -0
  1675. package/backend-project/node_modules/nodemon/package.json +78 -0
  1676. package/backend-project/node_modules/normalize-path/LICENSE +21 -0
  1677. package/backend-project/node_modules/normalize-path/README.md +127 -0
  1678. package/backend-project/node_modules/normalize-path/index.js +35 -0
  1679. package/backend-project/node_modules/normalize-path/package.json +77 -0
  1680. package/backend-project/node_modules/object-assign/index.js +90 -0
  1681. package/backend-project/node_modules/object-assign/license +21 -0
  1682. package/backend-project/node_modules/object-assign/package.json +42 -0
  1683. package/backend-project/node_modules/object-assign/readme.md +61 -0
  1684. package/backend-project/node_modules/object-inspect/.eslintrc +53 -0
  1685. package/backend-project/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  1686. package/backend-project/node_modules/object-inspect/.nycrc +13 -0
  1687. package/backend-project/node_modules/object-inspect/CHANGELOG.md +424 -0
  1688. package/backend-project/node_modules/object-inspect/LICENSE +21 -0
  1689. package/backend-project/node_modules/object-inspect/example/all.js +23 -0
  1690. package/backend-project/node_modules/object-inspect/example/circular.js +6 -0
  1691. package/backend-project/node_modules/object-inspect/example/fn.js +5 -0
  1692. package/backend-project/node_modules/object-inspect/example/inspect.js +10 -0
  1693. package/backend-project/node_modules/object-inspect/index.js +544 -0
  1694. package/backend-project/node_modules/object-inspect/package-support.json +20 -0
  1695. package/backend-project/node_modules/object-inspect/package.json +105 -0
  1696. package/backend-project/node_modules/object-inspect/readme.markdown +84 -0
  1697. package/backend-project/node_modules/object-inspect/test/bigint.js +58 -0
  1698. package/backend-project/node_modules/object-inspect/test/browser/dom.js +15 -0
  1699. package/backend-project/node_modules/object-inspect/test/circular.js +16 -0
  1700. package/backend-project/node_modules/object-inspect/test/deep.js +12 -0
  1701. package/backend-project/node_modules/object-inspect/test/element.js +53 -0
  1702. package/backend-project/node_modules/object-inspect/test/err.js +48 -0
  1703. package/backend-project/node_modules/object-inspect/test/fakes.js +29 -0
  1704. package/backend-project/node_modules/object-inspect/test/fn.js +76 -0
  1705. package/backend-project/node_modules/object-inspect/test/global.js +17 -0
  1706. package/backend-project/node_modules/object-inspect/test/has.js +15 -0
  1707. package/backend-project/node_modules/object-inspect/test/holes.js +15 -0
  1708. package/backend-project/node_modules/object-inspect/test/indent-option.js +271 -0
  1709. package/backend-project/node_modules/object-inspect/test/inspect.js +139 -0
  1710. package/backend-project/node_modules/object-inspect/test/lowbyte.js +12 -0
  1711. package/backend-project/node_modules/object-inspect/test/number.js +58 -0
  1712. package/backend-project/node_modules/object-inspect/test/quoteStyle.js +26 -0
  1713. package/backend-project/node_modules/object-inspect/test/toStringTag.js +40 -0
  1714. package/backend-project/node_modules/object-inspect/test/undef.js +12 -0
  1715. package/backend-project/node_modules/object-inspect/test/values.js +261 -0
  1716. package/backend-project/node_modules/object-inspect/test-core-js.js +26 -0
  1717. package/backend-project/node_modules/object-inspect/util.inspect.js +1 -0
  1718. package/backend-project/node_modules/on-finished/HISTORY.md +98 -0
  1719. package/backend-project/node_modules/on-finished/LICENSE +23 -0
  1720. package/backend-project/node_modules/on-finished/README.md +162 -0
  1721. package/backend-project/node_modules/on-finished/index.js +234 -0
  1722. package/backend-project/node_modules/on-finished/package.json +39 -0
  1723. package/backend-project/node_modules/parseurl/HISTORY.md +58 -0
  1724. package/backend-project/node_modules/parseurl/LICENSE +24 -0
  1725. package/backend-project/node_modules/parseurl/README.md +133 -0
  1726. package/backend-project/node_modules/parseurl/index.js +158 -0
  1727. package/backend-project/node_modules/parseurl/package.json +40 -0
  1728. package/backend-project/node_modules/path-to-regexp/LICENSE +21 -0
  1729. package/backend-project/node_modules/path-to-regexp/Readme.md +35 -0
  1730. package/backend-project/node_modules/path-to-regexp/index.js +158 -0
  1731. package/backend-project/node_modules/path-to-regexp/package.json +30 -0
  1732. package/backend-project/node_modules/picomatch/LICENSE +21 -0
  1733. package/backend-project/node_modules/picomatch/README.md +716 -0
  1734. package/backend-project/node_modules/picomatch/index.js +3 -0
  1735. package/backend-project/node_modules/picomatch/lib/constants.js +184 -0
  1736. package/backend-project/node_modules/picomatch/lib/parse.js +1392 -0
  1737. package/backend-project/node_modules/picomatch/lib/picomatch.js +342 -0
  1738. package/backend-project/node_modules/picomatch/lib/scan.js +391 -0
  1739. package/backend-project/node_modules/picomatch/lib/utils.js +64 -0
  1740. package/backend-project/node_modules/picomatch/package.json +81 -0
  1741. package/backend-project/node_modules/proxy-addr/HISTORY.md +161 -0
  1742. package/backend-project/node_modules/proxy-addr/LICENSE +22 -0
  1743. package/backend-project/node_modules/proxy-addr/README.md +139 -0
  1744. package/backend-project/node_modules/proxy-addr/index.js +327 -0
  1745. package/backend-project/node_modules/proxy-addr/package.json +47 -0
  1746. package/backend-project/node_modules/pstree.remy/.travis.yml +8 -0
  1747. package/backend-project/node_modules/pstree.remy/LICENSE +7 -0
  1748. package/backend-project/node_modules/pstree.remy/README.md +26 -0
  1749. package/backend-project/node_modules/pstree.remy/lib/index.js +37 -0
  1750. package/backend-project/node_modules/pstree.remy/lib/tree.js +37 -0
  1751. package/backend-project/node_modules/pstree.remy/lib/utils.js +53 -0
  1752. package/backend-project/node_modules/pstree.remy/package.json +33 -0
  1753. package/backend-project/node_modules/pstree.remy/tests/fixtures/index.js +13 -0
  1754. package/backend-project/node_modules/pstree.remy/tests/fixtures/out1 +10 -0
  1755. package/backend-project/node_modules/pstree.remy/tests/fixtures/out2 +29 -0
  1756. package/backend-project/node_modules/pstree.remy/tests/index.test.js +51 -0
  1757. package/backend-project/node_modules/punycode/LICENSE-MIT.txt +20 -0
  1758. package/backend-project/node_modules/punycode/README.md +148 -0
  1759. package/backend-project/node_modules/punycode/package.json +58 -0
  1760. package/backend-project/node_modules/punycode/punycode.es6.js +444 -0
  1761. package/backend-project/node_modules/punycode/punycode.js +443 -0
  1762. package/backend-project/node_modules/qs/.editorconfig +46 -0
  1763. package/backend-project/node_modules/qs/.github/FUNDING.yml +12 -0
  1764. package/backend-project/node_modules/qs/.github/SECURITY.md +11 -0
  1765. package/backend-project/node_modules/qs/.github/THREAT_MODEL.md +78 -0
  1766. package/backend-project/node_modules/qs/.nycrc +13 -0
  1767. package/backend-project/node_modules/qs/CHANGELOG.md +822 -0
  1768. package/backend-project/node_modules/qs/LICENSE.md +29 -0
  1769. package/backend-project/node_modules/qs/README.md +758 -0
  1770. package/backend-project/node_modules/qs/dist/qs.js +141 -0
  1771. package/backend-project/node_modules/qs/eslint.config.mjs +57 -0
  1772. package/backend-project/node_modules/qs/lib/formats.js +23 -0
  1773. package/backend-project/node_modules/qs/lib/index.js +11 -0
  1774. package/backend-project/node_modules/qs/lib/parse.js +403 -0
  1775. package/backend-project/node_modules/qs/lib/stringify.js +363 -0
  1776. package/backend-project/node_modules/qs/lib/utils.js +342 -0
  1777. package/backend-project/node_modules/qs/package.json +94 -0
  1778. package/backend-project/node_modules/qs/test/empty-keys-cases.js +267 -0
  1779. package/backend-project/node_modules/qs/test/parse.js +1703 -0
  1780. package/backend-project/node_modules/qs/test/stringify.js +1448 -0
  1781. package/backend-project/node_modules/qs/test/utils.js +432 -0
  1782. package/backend-project/node_modules/range-parser/HISTORY.md +56 -0
  1783. package/backend-project/node_modules/range-parser/LICENSE +23 -0
  1784. package/backend-project/node_modules/range-parser/README.md +84 -0
  1785. package/backend-project/node_modules/range-parser/index.js +162 -0
  1786. package/backend-project/node_modules/range-parser/package.json +44 -0
  1787. package/backend-project/node_modules/raw-body/LICENSE +22 -0
  1788. package/backend-project/node_modules/raw-body/README.md +223 -0
  1789. package/backend-project/node_modules/raw-body/index.d.ts +87 -0
  1790. package/backend-project/node_modules/raw-body/index.js +336 -0
  1791. package/backend-project/node_modules/raw-body/package.json +47 -0
  1792. package/backend-project/node_modules/readdirp/LICENSE +21 -0
  1793. package/backend-project/node_modules/readdirp/README.md +122 -0
  1794. package/backend-project/node_modules/readdirp/index.d.ts +43 -0
  1795. package/backend-project/node_modules/readdirp/index.js +287 -0
  1796. package/backend-project/node_modules/readdirp/package.json +122 -0
  1797. package/backend-project/node_modules/safe-buffer/LICENSE +21 -0
  1798. package/backend-project/node_modules/safe-buffer/README.md +584 -0
  1799. package/backend-project/node_modules/safe-buffer/index.d.ts +187 -0
  1800. package/backend-project/node_modules/safe-buffer/index.js +65 -0
  1801. package/backend-project/node_modules/safe-buffer/package.json +51 -0
  1802. package/backend-project/node_modules/safer-buffer/LICENSE +21 -0
  1803. package/backend-project/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  1804. package/backend-project/node_modules/safer-buffer/Readme.md +156 -0
  1805. package/backend-project/node_modules/safer-buffer/dangerous.js +58 -0
  1806. package/backend-project/node_modules/safer-buffer/package.json +34 -0
  1807. package/backend-project/node_modules/safer-buffer/safer.js +77 -0
  1808. package/backend-project/node_modules/safer-buffer/tests.js +406 -0
  1809. package/backend-project/node_modules/semver/LICENSE +15 -0
  1810. package/backend-project/node_modules/semver/README.md +680 -0
  1811. package/backend-project/node_modules/semver/bin/semver.js +195 -0
  1812. package/backend-project/node_modules/semver/classes/comparator.js +143 -0
  1813. package/backend-project/node_modules/semver/classes/index.js +7 -0
  1814. package/backend-project/node_modules/semver/classes/range.js +564 -0
  1815. package/backend-project/node_modules/semver/classes/semver.js +333 -0
  1816. package/backend-project/node_modules/semver/functions/clean.js +8 -0
  1817. package/backend-project/node_modules/semver/functions/cmp.js +54 -0
  1818. package/backend-project/node_modules/semver/functions/coerce.js +62 -0
  1819. package/backend-project/node_modules/semver/functions/compare-build.js +9 -0
  1820. package/backend-project/node_modules/semver/functions/compare-loose.js +5 -0
  1821. package/backend-project/node_modules/semver/functions/compare.js +7 -0
  1822. package/backend-project/node_modules/semver/functions/diff.js +60 -0
  1823. package/backend-project/node_modules/semver/functions/eq.js +5 -0
  1824. package/backend-project/node_modules/semver/functions/gt.js +5 -0
  1825. package/backend-project/node_modules/semver/functions/gte.js +5 -0
  1826. package/backend-project/node_modules/semver/functions/inc.js +21 -0
  1827. package/backend-project/node_modules/semver/functions/lt.js +5 -0
  1828. package/backend-project/node_modules/semver/functions/lte.js +5 -0
  1829. package/backend-project/node_modules/semver/functions/major.js +5 -0
  1830. package/backend-project/node_modules/semver/functions/minor.js +5 -0
  1831. package/backend-project/node_modules/semver/functions/neq.js +5 -0
  1832. package/backend-project/node_modules/semver/functions/parse.js +18 -0
  1833. package/backend-project/node_modules/semver/functions/patch.js +5 -0
  1834. package/backend-project/node_modules/semver/functions/prerelease.js +8 -0
  1835. package/backend-project/node_modules/semver/functions/rcompare.js +5 -0
  1836. package/backend-project/node_modules/semver/functions/rsort.js +5 -0
  1837. package/backend-project/node_modules/semver/functions/satisfies.js +12 -0
  1838. package/backend-project/node_modules/semver/functions/sort.js +5 -0
  1839. package/backend-project/node_modules/semver/functions/truncate.js +48 -0
  1840. package/backend-project/node_modules/semver/functions/valid.js +8 -0
  1841. package/backend-project/node_modules/semver/index.js +93 -0
  1842. package/backend-project/node_modules/semver/internal/constants.js +37 -0
  1843. package/backend-project/node_modules/semver/internal/debug.js +11 -0
  1844. package/backend-project/node_modules/semver/internal/identifiers.js +29 -0
  1845. package/backend-project/node_modules/semver/internal/lrucache.js +42 -0
  1846. package/backend-project/node_modules/semver/internal/parse-options.js +17 -0
  1847. package/backend-project/node_modules/semver/internal/re.js +223 -0
  1848. package/backend-project/node_modules/semver/package.json +78 -0
  1849. package/backend-project/node_modules/semver/preload.js +4 -0
  1850. package/backend-project/node_modules/semver/range.bnf +17 -0
  1851. package/backend-project/node_modules/semver/ranges/gtr.js +6 -0
  1852. package/backend-project/node_modules/semver/ranges/intersects.js +9 -0
  1853. package/backend-project/node_modules/semver/ranges/ltr.js +6 -0
  1854. package/backend-project/node_modules/semver/ranges/max-satisfying.js +27 -0
  1855. package/backend-project/node_modules/semver/ranges/min-satisfying.js +26 -0
  1856. package/backend-project/node_modules/semver/ranges/min-version.js +63 -0
  1857. package/backend-project/node_modules/semver/ranges/outside.js +82 -0
  1858. package/backend-project/node_modules/semver/ranges/simplify.js +49 -0
  1859. package/backend-project/node_modules/semver/ranges/subset.js +249 -0
  1860. package/backend-project/node_modules/semver/ranges/to-comparators.js +10 -0
  1861. package/backend-project/node_modules/semver/ranges/valid.js +13 -0
  1862. package/backend-project/node_modules/send/HISTORY.md +538 -0
  1863. package/backend-project/node_modules/send/LICENSE +23 -0
  1864. package/backend-project/node_modules/send/README.md +327 -0
  1865. package/backend-project/node_modules/send/SECURITY.md +24 -0
  1866. package/backend-project/node_modules/send/index.js +1142 -0
  1867. package/backend-project/node_modules/send/node_modules/ms/index.js +162 -0
  1868. package/backend-project/node_modules/send/node_modules/ms/license.md +21 -0
  1869. package/backend-project/node_modules/send/node_modules/ms/package.json +38 -0
  1870. package/backend-project/node_modules/send/node_modules/ms/readme.md +59 -0
  1871. package/backend-project/node_modules/send/package.json +62 -0
  1872. package/backend-project/node_modules/serve-static/HISTORY.md +493 -0
  1873. package/backend-project/node_modules/serve-static/LICENSE +25 -0
  1874. package/backend-project/node_modules/serve-static/README.md +257 -0
  1875. package/backend-project/node_modules/serve-static/index.js +209 -0
  1876. package/backend-project/node_modules/serve-static/package.json +42 -0
  1877. package/backend-project/node_modules/setprototypeof/LICENSE +13 -0
  1878. package/backend-project/node_modules/setprototypeof/README.md +31 -0
  1879. package/backend-project/node_modules/setprototypeof/index.d.ts +2 -0
  1880. package/backend-project/node_modules/setprototypeof/index.js +17 -0
  1881. package/backend-project/node_modules/setprototypeof/package.json +38 -0
  1882. package/backend-project/node_modules/setprototypeof/test/index.js +24 -0
  1883. package/backend-project/node_modules/side-channel/.editorconfig +9 -0
  1884. package/backend-project/node_modules/side-channel/.eslintrc +12 -0
  1885. package/backend-project/node_modules/side-channel/.github/FUNDING.yml +12 -0
  1886. package/backend-project/node_modules/side-channel/.nycrc +13 -0
  1887. package/backend-project/node_modules/side-channel/CHANGELOG.md +110 -0
  1888. package/backend-project/node_modules/side-channel/LICENSE +21 -0
  1889. package/backend-project/node_modules/side-channel/README.md +61 -0
  1890. package/backend-project/node_modules/side-channel/index.d.ts +14 -0
  1891. package/backend-project/node_modules/side-channel/index.js +43 -0
  1892. package/backend-project/node_modules/side-channel/package.json +85 -0
  1893. package/backend-project/node_modules/side-channel/test/index.js +104 -0
  1894. package/backend-project/node_modules/side-channel/tsconfig.json +9 -0
  1895. package/backend-project/node_modules/side-channel-list/.editorconfig +9 -0
  1896. package/backend-project/node_modules/side-channel-list/.eslintrc +11 -0
  1897. package/backend-project/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  1898. package/backend-project/node_modules/side-channel-list/.nycrc +13 -0
  1899. package/backend-project/node_modules/side-channel-list/CHANGELOG.md +36 -0
  1900. package/backend-project/node_modules/side-channel-list/LICENSE +21 -0
  1901. package/backend-project/node_modules/side-channel-list/README.md +62 -0
  1902. package/backend-project/node_modules/side-channel-list/index.d.ts +13 -0
  1903. package/backend-project/node_modules/side-channel-list/index.js +111 -0
  1904. package/backend-project/node_modules/side-channel-list/list.d.ts +14 -0
  1905. package/backend-project/node_modules/side-channel-list/package.json +77 -0
  1906. package/backend-project/node_modules/side-channel-list/test/index.js +154 -0
  1907. package/backend-project/node_modules/side-channel-list/tsconfig.json +9 -0
  1908. package/backend-project/node_modules/side-channel-map/.editorconfig +9 -0
  1909. package/backend-project/node_modules/side-channel-map/.eslintrc +11 -0
  1910. package/backend-project/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
  1911. package/backend-project/node_modules/side-channel-map/.nycrc +13 -0
  1912. package/backend-project/node_modules/side-channel-map/CHANGELOG.md +22 -0
  1913. package/backend-project/node_modules/side-channel-map/LICENSE +21 -0
  1914. package/backend-project/node_modules/side-channel-map/README.md +62 -0
  1915. package/backend-project/node_modules/side-channel-map/index.d.ts +15 -0
  1916. package/backend-project/node_modules/side-channel-map/index.js +68 -0
  1917. package/backend-project/node_modules/side-channel-map/package.json +80 -0
  1918. package/backend-project/node_modules/side-channel-map/test/index.js +114 -0
  1919. package/backend-project/node_modules/side-channel-map/tsconfig.json +9 -0
  1920. package/backend-project/node_modules/side-channel-weakmap/.editorconfig +9 -0
  1921. package/backend-project/node_modules/side-channel-weakmap/.eslintrc +12 -0
  1922. package/backend-project/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
  1923. package/backend-project/node_modules/side-channel-weakmap/.nycrc +13 -0
  1924. package/backend-project/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
  1925. package/backend-project/node_modules/side-channel-weakmap/LICENSE +21 -0
  1926. package/backend-project/node_modules/side-channel-weakmap/README.md +62 -0
  1927. package/backend-project/node_modules/side-channel-weakmap/index.d.ts +15 -0
  1928. package/backend-project/node_modules/side-channel-weakmap/index.js +84 -0
  1929. package/backend-project/node_modules/side-channel-weakmap/package.json +87 -0
  1930. package/backend-project/node_modules/side-channel-weakmap/test/index.js +114 -0
  1931. package/backend-project/node_modules/side-channel-weakmap/tsconfig.json +9 -0
  1932. package/backend-project/node_modules/sift/MIT-LICENSE.txt +20 -0
  1933. package/backend-project/node_modules/sift/README.md +465 -0
  1934. package/backend-project/node_modules/sift/es/index.js +626 -0
  1935. package/backend-project/node_modules/sift/es/index.js.map +1 -0
  1936. package/backend-project/node_modules/sift/es5m/index.js +729 -0
  1937. package/backend-project/node_modules/sift/es5m/index.js.map +1 -0
  1938. package/backend-project/node_modules/sift/index.d.ts +4 -0
  1939. package/backend-project/node_modules/sift/index.js +4 -0
  1940. package/backend-project/node_modules/sift/lib/core.d.ts +120 -0
  1941. package/backend-project/node_modules/sift/lib/index.d.ts +6 -0
  1942. package/backend-project/node_modules/sift/lib/index.js +766 -0
  1943. package/backend-project/node_modules/sift/lib/index.js.map +1 -0
  1944. package/backend-project/node_modules/sift/lib/operations.d.ts +88 -0
  1945. package/backend-project/node_modules/sift/lib/utils.d.ts +9 -0
  1946. package/backend-project/node_modules/sift/package.json +62 -0
  1947. package/backend-project/node_modules/sift/sift.csp.min.js +763 -0
  1948. package/backend-project/node_modules/sift/sift.csp.min.js.map +1 -0
  1949. package/backend-project/node_modules/sift/sift.min.js +16 -0
  1950. package/backend-project/node_modules/sift/sift.min.js.map +1 -0
  1951. package/backend-project/node_modules/sift/src/core.d.ts +120 -0
  1952. package/backend-project/node_modules/sift/src/core.js +267 -0
  1953. package/backend-project/node_modules/sift/src/core.js.map +1 -0
  1954. package/backend-project/node_modules/sift/src/core.ts +481 -0
  1955. package/backend-project/node_modules/sift/src/index.d.ts +6 -0
  1956. package/backend-project/node_modules/sift/src/index.js +38 -0
  1957. package/backend-project/node_modules/sift/src/index.js.map +1 -0
  1958. package/backend-project/node_modules/sift/src/index.ts +54 -0
  1959. package/backend-project/node_modules/sift/src/operations.d.ts +88 -0
  1960. package/backend-project/node_modules/sift/src/operations.js +297 -0
  1961. package/backend-project/node_modules/sift/src/operations.js.map +1 -0
  1962. package/backend-project/node_modules/sift/src/operations.ts +411 -0
  1963. package/backend-project/node_modules/sift/src/utils.d.ts +9 -0
  1964. package/backend-project/node_modules/sift/src/utils.js +70 -0
  1965. package/backend-project/node_modules/sift/src/utils.js.map +1 -0
  1966. package/backend-project/node_modules/sift/src/utils.ts +68 -0
  1967. package/backend-project/node_modules/simple-update-notifier/LICENSE +21 -0
  1968. package/backend-project/node_modules/simple-update-notifier/README.md +82 -0
  1969. package/backend-project/node_modules/simple-update-notifier/build/index.d.ts +13 -0
  1970. package/backend-project/node_modules/simple-update-notifier/build/index.js +210 -0
  1971. package/backend-project/node_modules/simple-update-notifier/package.json +100 -0
  1972. package/backend-project/node_modules/simple-update-notifier/src/borderedText.ts +12 -0
  1973. package/backend-project/node_modules/simple-update-notifier/src/cache.spec.ts +17 -0
  1974. package/backend-project/node_modules/simple-update-notifier/src/cache.ts +44 -0
  1975. package/backend-project/node_modules/simple-update-notifier/src/getDistVersion.spec.ts +35 -0
  1976. package/backend-project/node_modules/simple-update-notifier/src/getDistVersion.ts +29 -0
  1977. package/backend-project/node_modules/simple-update-notifier/src/hasNewVersion.spec.ts +82 -0
  1978. package/backend-project/node_modules/simple-update-notifier/src/hasNewVersion.ts +40 -0
  1979. package/backend-project/node_modules/simple-update-notifier/src/index.spec.ts +27 -0
  1980. package/backend-project/node_modules/simple-update-notifier/src/index.ts +34 -0
  1981. package/backend-project/node_modules/simple-update-notifier/src/isNpmOrYarn.ts +12 -0
  1982. package/backend-project/node_modules/simple-update-notifier/src/types.ts +8 -0
  1983. package/backend-project/node_modules/smart-buffer/.prettierrc.yaml +5 -0
  1984. package/backend-project/node_modules/smart-buffer/.travis.yml +13 -0
  1985. package/backend-project/node_modules/smart-buffer/LICENSE +20 -0
  1986. package/backend-project/node_modules/smart-buffer/README.md +633 -0
  1987. package/backend-project/node_modules/smart-buffer/build/smartbuffer.js +1233 -0
  1988. package/backend-project/node_modules/smart-buffer/build/smartbuffer.js.map +1 -0
  1989. package/backend-project/node_modules/smart-buffer/build/utils.js +108 -0
  1990. package/backend-project/node_modules/smart-buffer/build/utils.js.map +1 -0
  1991. package/backend-project/node_modules/smart-buffer/docs/CHANGELOG.md +70 -0
  1992. package/backend-project/node_modules/smart-buffer/docs/README_v3.md +367 -0
  1993. package/backend-project/node_modules/smart-buffer/docs/ROADMAP.md +0 -0
  1994. package/backend-project/node_modules/smart-buffer/package.json +79 -0
  1995. package/backend-project/node_modules/smart-buffer/typings/smartbuffer.d.ts +755 -0
  1996. package/backend-project/node_modules/smart-buffer/typings/utils.d.ts +66 -0
  1997. package/backend-project/node_modules/socks/.eslintrc.cjs +11 -0
  1998. package/backend-project/node_modules/socks/.prettierrc.yaml +7 -0
  1999. package/backend-project/node_modules/socks/LICENSE +20 -0
  2000. package/backend-project/node_modules/socks/README.md +686 -0
  2001. package/backend-project/node_modules/socks/build/client/socksclient.js +793 -0
  2002. package/backend-project/node_modules/socks/build/client/socksclient.js.map +1 -0
  2003. package/backend-project/node_modules/socks/build/common/constants.js +108 -0
  2004. package/backend-project/node_modules/socks/build/common/constants.js.map +1 -0
  2005. package/backend-project/node_modules/socks/build/common/helpers.js +167 -0
  2006. package/backend-project/node_modules/socks/build/common/helpers.js.map +1 -0
  2007. package/backend-project/node_modules/socks/build/common/receivebuffer.js +43 -0
  2008. package/backend-project/node_modules/socks/build/common/receivebuffer.js.map +1 -0
  2009. package/backend-project/node_modules/socks/build/common/util.js +25 -0
  2010. package/backend-project/node_modules/socks/build/common/util.js.map +1 -0
  2011. package/backend-project/node_modules/socks/build/index.js +18 -0
  2012. package/backend-project/node_modules/socks/build/index.js.map +1 -0
  2013. package/backend-project/node_modules/socks/docs/examples/index.md +17 -0
  2014. package/backend-project/node_modules/socks/docs/examples/javascript/associateExample.md +90 -0
  2015. package/backend-project/node_modules/socks/docs/examples/javascript/bindExample.md +83 -0
  2016. package/backend-project/node_modules/socks/docs/examples/javascript/connectExample.md +258 -0
  2017. package/backend-project/node_modules/socks/docs/examples/typescript/associateExample.md +93 -0
  2018. package/backend-project/node_modules/socks/docs/examples/typescript/bindExample.md +86 -0
  2019. package/backend-project/node_modules/socks/docs/examples/typescript/connectExample.md +265 -0
  2020. package/backend-project/node_modules/socks/docs/index.md +5 -0
  2021. package/backend-project/node_modules/socks/docs/migratingFromV1.md +86 -0
  2022. package/backend-project/node_modules/socks/package.json +58 -0
  2023. package/backend-project/node_modules/socks/typings/client/socksclient.d.ts +162 -0
  2024. package/backend-project/node_modules/socks/typings/common/constants.d.ts +151 -0
  2025. package/backend-project/node_modules/socks/typings/common/helpers.d.ts +17 -0
  2026. package/backend-project/node_modules/socks/typings/common/receivebuffer.d.ts +12 -0
  2027. package/backend-project/node_modules/socks/typings/common/util.d.ts +14 -0
  2028. package/backend-project/node_modules/socks/typings/index.d.ts +1 -0
  2029. package/backend-project/node_modules/sparse-bitfield/.travis.yml +6 -0
  2030. package/backend-project/node_modules/sparse-bitfield/LICENSE +21 -0
  2031. package/backend-project/node_modules/sparse-bitfield/README.md +62 -0
  2032. package/backend-project/node_modules/sparse-bitfield/index.js +95 -0
  2033. package/backend-project/node_modules/sparse-bitfield/package.json +27 -0
  2034. package/backend-project/node_modules/sparse-bitfield/test.js +79 -0
  2035. package/backend-project/node_modules/statuses/HISTORY.md +87 -0
  2036. package/backend-project/node_modules/statuses/LICENSE +23 -0
  2037. package/backend-project/node_modules/statuses/README.md +139 -0
  2038. package/backend-project/node_modules/statuses/codes.json +65 -0
  2039. package/backend-project/node_modules/statuses/index.js +146 -0
  2040. package/backend-project/node_modules/statuses/package.json +49 -0
  2041. package/backend-project/node_modules/supports-color/browser.js +5 -0
  2042. package/backend-project/node_modules/supports-color/index.js +131 -0
  2043. package/backend-project/node_modules/supports-color/license +9 -0
  2044. package/backend-project/node_modules/supports-color/package.json +53 -0
  2045. package/backend-project/node_modules/supports-color/readme.md +66 -0
  2046. package/backend-project/node_modules/to-regex-range/LICENSE +21 -0
  2047. package/backend-project/node_modules/to-regex-range/README.md +305 -0
  2048. package/backend-project/node_modules/to-regex-range/index.js +288 -0
  2049. package/backend-project/node_modules/to-regex-range/package.json +88 -0
  2050. package/backend-project/node_modules/toidentifier/HISTORY.md +9 -0
  2051. package/backend-project/node_modules/toidentifier/LICENSE +21 -0
  2052. package/backend-project/node_modules/toidentifier/README.md +61 -0
  2053. package/backend-project/node_modules/toidentifier/index.js +32 -0
  2054. package/backend-project/node_modules/toidentifier/package.json +38 -0
  2055. package/backend-project/node_modules/touch/LICENSE +15 -0
  2056. package/backend-project/node_modules/touch/README.md +52 -0
  2057. package/backend-project/node_modules/touch/bin/nodetouch.js +112 -0
  2058. package/backend-project/node_modules/touch/index.js +224 -0
  2059. package/backend-project/node_modules/touch/package.json +25 -0
  2060. package/backend-project/node_modules/tr46/LICENSE.md +21 -0
  2061. package/backend-project/node_modules/tr46/README.md +78 -0
  2062. package/backend-project/node_modules/tr46/index.js +298 -0
  2063. package/backend-project/node_modules/tr46/lib/mappingTable.json +1 -0
  2064. package/backend-project/node_modules/tr46/lib/regexes.js +29 -0
  2065. package/backend-project/node_modules/tr46/lib/statusMapping.js +11 -0
  2066. package/backend-project/node_modules/tr46/package.json +47 -0
  2067. package/backend-project/node_modules/type-is/HISTORY.md +259 -0
  2068. package/backend-project/node_modules/type-is/LICENSE +23 -0
  2069. package/backend-project/node_modules/type-is/README.md +170 -0
  2070. package/backend-project/node_modules/type-is/index.js +266 -0
  2071. package/backend-project/node_modules/type-is/package.json +45 -0
  2072. package/backend-project/node_modules/undefsafe/.github/workflows/release.yml +25 -0
  2073. package/backend-project/node_modules/undefsafe/.jscsrc +13 -0
  2074. package/backend-project/node_modules/undefsafe/.jshintrc +16 -0
  2075. package/backend-project/node_modules/undefsafe/.travis.yml +18 -0
  2076. package/backend-project/node_modules/undefsafe/LICENSE +22 -0
  2077. package/backend-project/node_modules/undefsafe/README.md +63 -0
  2078. package/backend-project/node_modules/undefsafe/example.js +14 -0
  2079. package/backend-project/node_modules/undefsafe/lib/undefsafe.js +125 -0
  2080. package/backend-project/node_modules/undefsafe/package.json +34 -0
  2081. package/backend-project/node_modules/undici-types/LICENSE +21 -0
  2082. package/backend-project/node_modules/undici-types/README.md +6 -0
  2083. package/backend-project/node_modules/undici-types/agent.d.ts +32 -0
  2084. package/backend-project/node_modules/undici-types/api.d.ts +43 -0
  2085. package/backend-project/node_modules/undici-types/balanced-pool.d.ts +30 -0
  2086. package/backend-project/node_modules/undici-types/cache-interceptor.d.ts +179 -0
  2087. package/backend-project/node_modules/undici-types/cache.d.ts +36 -0
  2088. package/backend-project/node_modules/undici-types/client-stats.d.ts +15 -0
  2089. package/backend-project/node_modules/undici-types/client.d.ts +123 -0
  2090. package/backend-project/node_modules/undici-types/connector.d.ts +36 -0
  2091. package/backend-project/node_modules/undici-types/content-type.d.ts +21 -0
  2092. package/backend-project/node_modules/undici-types/cookies.d.ts +30 -0
  2093. package/backend-project/node_modules/undici-types/diagnostics-channel.d.ts +74 -0
  2094. package/backend-project/node_modules/undici-types/dispatcher.d.ts +279 -0
  2095. package/backend-project/node_modules/undici-types/env-http-proxy-agent.d.ts +22 -0
  2096. package/backend-project/node_modules/undici-types/errors.d.ts +177 -0
  2097. package/backend-project/node_modules/undici-types/eventsource.d.ts +66 -0
  2098. package/backend-project/node_modules/undici-types/fetch.d.ts +211 -0
  2099. package/backend-project/node_modules/undici-types/formdata.d.ts +108 -0
  2100. package/backend-project/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  2101. package/backend-project/node_modules/undici-types/global-origin.d.ts +7 -0
  2102. package/backend-project/node_modules/undici-types/h2c-client.d.ts +73 -0
  2103. package/backend-project/node_modules/undici-types/handlers.d.ts +15 -0
  2104. package/backend-project/node_modules/undici-types/header.d.ts +160 -0
  2105. package/backend-project/node_modules/undici-types/index.d.ts +91 -0
  2106. package/backend-project/node_modules/undici-types/interceptors.d.ts +80 -0
  2107. package/backend-project/node_modules/undici-types/mock-agent.d.ts +68 -0
  2108. package/backend-project/node_modules/undici-types/mock-call-history.d.ts +111 -0
  2109. package/backend-project/node_modules/undici-types/mock-client.d.ts +27 -0
  2110. package/backend-project/node_modules/undici-types/mock-errors.d.ts +12 -0
  2111. package/backend-project/node_modules/undici-types/mock-interceptor.d.ts +94 -0
  2112. package/backend-project/node_modules/undici-types/mock-pool.d.ts +27 -0
  2113. package/backend-project/node_modules/undici-types/package.json +55 -0
  2114. package/backend-project/node_modules/undici-types/patch.d.ts +29 -0
  2115. package/backend-project/node_modules/undici-types/pool-stats.d.ts +19 -0
  2116. package/backend-project/node_modules/undici-types/pool.d.ts +41 -0
  2117. package/backend-project/node_modules/undici-types/proxy-agent.d.ts +29 -0
  2118. package/backend-project/node_modules/undici-types/readable.d.ts +68 -0
  2119. package/backend-project/node_modules/undici-types/retry-agent.d.ts +8 -0
  2120. package/backend-project/node_modules/undici-types/retry-handler.d.ts +125 -0
  2121. package/backend-project/node_modules/undici-types/round-robin-pool.d.ts +41 -0
  2122. package/backend-project/node_modules/undici-types/snapshot-agent.d.ts +109 -0
  2123. package/backend-project/node_modules/undici-types/socks5-proxy-agent.d.ts +25 -0
  2124. package/backend-project/node_modules/undici-types/util.d.ts +18 -0
  2125. package/backend-project/node_modules/undici-types/utility.d.ts +7 -0
  2126. package/backend-project/node_modules/undici-types/webidl.d.ts +347 -0
  2127. package/backend-project/node_modules/undici-types/websocket.d.ts +188 -0
  2128. package/backend-project/node_modules/unpipe/HISTORY.md +4 -0
  2129. package/backend-project/node_modules/unpipe/LICENSE +22 -0
  2130. package/backend-project/node_modules/unpipe/README.md +43 -0
  2131. package/backend-project/node_modules/unpipe/index.js +69 -0
  2132. package/backend-project/node_modules/unpipe/package.json +27 -0
  2133. package/backend-project/node_modules/utils-merge/LICENSE +20 -0
  2134. package/backend-project/node_modules/utils-merge/README.md +34 -0
  2135. package/backend-project/node_modules/utils-merge/index.js +23 -0
  2136. package/backend-project/node_modules/utils-merge/package.json +40 -0
  2137. package/backend-project/node_modules/vary/HISTORY.md +39 -0
  2138. package/backend-project/node_modules/vary/LICENSE +22 -0
  2139. package/backend-project/node_modules/vary/README.md +101 -0
  2140. package/backend-project/node_modules/vary/index.js +149 -0
  2141. package/backend-project/node_modules/vary/package.json +43 -0
  2142. package/backend-project/node_modules/webidl-conversions/LICENSE.md +12 -0
  2143. package/backend-project/node_modules/webidl-conversions/README.md +99 -0
  2144. package/backend-project/node_modules/webidl-conversions/lib/index.js +450 -0
  2145. package/backend-project/node_modules/webidl-conversions/package.json +35 -0
  2146. package/backend-project/node_modules/whatwg-url/LICENSE.txt +21 -0
  2147. package/backend-project/node_modules/whatwg-url/README.md +106 -0
  2148. package/backend-project/node_modules/whatwg-url/index.js +27 -0
  2149. package/backend-project/node_modules/whatwg-url/lib/Function.js +42 -0
  2150. package/backend-project/node_modules/whatwg-url/lib/URL-impl.js +209 -0
  2151. package/backend-project/node_modules/whatwg-url/lib/URL.js +442 -0
  2152. package/backend-project/node_modules/whatwg-url/lib/URLSearchParams-impl.js +130 -0
  2153. package/backend-project/node_modules/whatwg-url/lib/URLSearchParams.js +472 -0
  2154. package/backend-project/node_modules/whatwg-url/lib/VoidFunction.js +26 -0
  2155. package/backend-project/node_modules/whatwg-url/lib/encoding.js +16 -0
  2156. package/backend-project/node_modules/whatwg-url/lib/infra.js +26 -0
  2157. package/backend-project/node_modules/whatwg-url/lib/percent-encoding.js +142 -0
  2158. package/backend-project/node_modules/whatwg-url/lib/url-state-machine.js +1244 -0
  2159. package/backend-project/node_modules/whatwg-url/lib/urlencoded.js +106 -0
  2160. package/backend-project/node_modules/whatwg-url/lib/utils.js +190 -0
  2161. package/backend-project/node_modules/whatwg-url/package.json +58 -0
  2162. package/backend-project/node_modules/whatwg-url/webidl2js-wrapper.js +7 -0
  2163. package/backend-project/package-lock.json +1640 -0
  2164. package/backend-project/package.json +29 -0
  2165. package/backend-project/routes/auth.js +8 -0
  2166. package/backend-project/routes/products.js +10 -0
  2167. package/backend-project/routes/reports.js +11 -0
  2168. package/backend-project/routes/transactions.js +12 -0
  2169. package/backend-project/routes/warehouses.js +10 -0
  2170. package/backend-project/server.js +49 -0
  2171. package/bin/stockhub.js +44 -0
  2172. package/frontend-project/package.json +41 -0
  2173. package/frontend-project/postcss.config.js +6 -0
  2174. package/frontend-project/public/index.html +14 -0
  2175. package/frontend-project/src/App.js +59 -0
  2176. package/frontend-project/src/components/Auth/Login.js +116 -0
  2177. package/frontend-project/src/components/Auth/Register.js +142 -0
  2178. package/frontend-project/src/components/Dashboard/Dashboard.js +183 -0
  2179. package/frontend-project/src/components/Layout/Layout.js +162 -0
  2180. package/frontend-project/src/components/Products/Products.js +253 -0
  2181. package/frontend-project/src/components/Reports/Reports.js +312 -0
  2182. package/frontend-project/src/components/Transactions/Transactions.js +310 -0
  2183. package/frontend-project/src/components/Warehouses/Warehouses.js +178 -0
  2184. package/frontend-project/src/index.css +30 -0
  2185. package/frontend-project/src/index.js +11 -0
  2186. package/frontend-project/src/services/api.js +76 -0
  2187. package/frontend-project/tailwind.config.js +19 -0
  2188. package/package.json +49 -0
  2189. package/setup.js +157 -0
@@ -0,0 +1,4830 @@
1
+ 'use strict';
2
+
3
+ /*!
4
+ * Module dependencies.
5
+ */
6
+
7
+ const EventEmitter = require('events').EventEmitter;
8
+ const InternalCache = require('./internal');
9
+ const MongooseError = require('./error/index');
10
+ const MixedSchema = require('./schema/mixed');
11
+ const ObjectExpectedError = require('./error/objectExpected');
12
+ const ObjectParameterError = require('./error/objectParameter');
13
+ const ParallelValidateError = require('./error/parallelValidate');
14
+ const Schema = require('./schema');
15
+ const StrictModeError = require('./error/strict');
16
+ const ValidationError = require('./error/validation');
17
+ const ValidatorError = require('./error/validator');
18
+ const $__hasIncludedChildren = require('./helpers/projection/hasIncludedChildren');
19
+ const applyDefaults = require('./helpers/document/applyDefaults');
20
+ const cleanModifiedSubpaths = require('./helpers/document/cleanModifiedSubpaths');
21
+ const clone = require('./helpers/clone');
22
+ const compile = require('./helpers/document/compile').compile;
23
+ const defineKey = require('./helpers/document/compile').defineKey;
24
+ const flatten = require('./helpers/common').flatten;
25
+ const get = require('./helpers/get');
26
+ const getEmbeddedDiscriminatorPath = require('./helpers/document/getEmbeddedDiscriminatorPath');
27
+ const getKeysInSchemaOrder = require('./helpers/schema/getKeysInSchemaOrder');
28
+ const getSubdocumentStrictValue = require('./helpers/schema/getSubdocumentStrictValue');
29
+ const handleSpreadDoc = require('./helpers/document/handleSpreadDoc');
30
+ const immediate = require('./helpers/immediate');
31
+ const isDefiningProjection = require('./helpers/projection/isDefiningProjection');
32
+ const isExclusive = require('./helpers/projection/isExclusive');
33
+ const inspect = require('util').inspect;
34
+ const internalToObjectOptions = require('./options').internalToObjectOptions;
35
+ const markArraySubdocsPopulated = require('./helpers/populate/markArraySubdocsPopulated');
36
+ const mpath = require('mpath');
37
+ const queryhelpers = require('./queryhelpers');
38
+ const utils = require('./utils');
39
+ const isPromise = require('./helpers/isPromise');
40
+
41
+ const deepEqual = utils.deepEqual;
42
+ const isMongooseObject = utils.isMongooseObject;
43
+
44
+ const arrayAtomicsBackupSymbol = require('./helpers/symbols').arrayAtomicsBackupSymbol;
45
+ const arrayAtomicsSymbol = require('./helpers/symbols').arrayAtomicsSymbol;
46
+ const documentArrayParent = require('./helpers/symbols').documentArrayParent;
47
+ const documentIsModified = require('./helpers/symbols').documentIsModified;
48
+ const documentModifiedPaths = require('./helpers/symbols').documentModifiedPaths;
49
+ const documentSchemaSymbol = require('./helpers/symbols').documentSchemaSymbol;
50
+ const getSymbol = require('./helpers/symbols').getSymbol;
51
+ const populateModelSymbol = require('./helpers/symbols').populateModelSymbol;
52
+ const scopeSymbol = require('./helpers/symbols').scopeSymbol;
53
+ const schemaMixedSymbol = require('./schema/symbols').schemaMixedSymbol;
54
+ const parentPaths = require('./helpers/path/parentPaths');
55
+ const getDeepestSubdocumentForPath = require('./helpers/document/getDeepestSubdocumentForPath');
56
+ const sessionNewDocuments = require('./helpers/symbols').sessionNewDocuments;
57
+
58
+ let DocumentArray;
59
+ let MongooseArray;
60
+ let Embedded;
61
+
62
+ const specialProperties = utils.specialProperties;
63
+
64
+ const VERSION_INC = 2;
65
+
66
+ /**
67
+ * The core Mongoose document constructor. You should not call this directly,
68
+ * the Mongoose [Model constructor](./api/model.html#Model) calls this for you.
69
+ *
70
+ * @param {Object} obj the values to set
71
+ * @param {Object} [fields] optional object containing the fields which were selected in the query returning this document and any populated paths data
72
+ * @param {Object} [options] various configuration options for the document
73
+ * @param {Boolean} [options.defaults=true] if `false`, skip applying default values to this document.
74
+ * @inherits NodeJS EventEmitter https://nodejs.org/api/events.html#class-eventemitter
75
+ * @event `init`: Emitted on a document after it has been retrieved from the db and fully hydrated by Mongoose.
76
+ * @event `save`: Emitted when the document is successfully saved
77
+ * @api private
78
+ */
79
+
80
+ function Document(obj, fields, skipId, options) {
81
+ if (typeof skipId === 'object' && skipId != null) {
82
+ options = skipId;
83
+ skipId = options.skipId;
84
+ }
85
+ options = Object.assign({}, options);
86
+
87
+ // Support `browserDocument.js` syntax
88
+ if (this.$__schema == null) {
89
+ const _schema = utils.isObject(fields) && !fields.instanceOfSchema ?
90
+ new Schema(fields) :
91
+ fields;
92
+ this.$__setSchema(_schema);
93
+ fields = skipId;
94
+ skipId = options;
95
+ options = arguments[4] || {};
96
+ }
97
+
98
+ this.$__ = new InternalCache();
99
+
100
+ // Avoid setting `isNew` to `true`, because it is `true` by default
101
+ if (options.isNew != null && options.isNew !== true) {
102
+ this.$isNew = options.isNew;
103
+ }
104
+
105
+ if (options.priorDoc != null) {
106
+ this.$__.priorDoc = options.priorDoc;
107
+ }
108
+
109
+ if (skipId) {
110
+ this.$__.skipId = skipId;
111
+ }
112
+
113
+ if (obj != null && typeof obj !== 'object') {
114
+ throw new ObjectParameterError(obj, 'obj', 'Document');
115
+ }
116
+
117
+ let defaults = true;
118
+ if (options.defaults !== undefined) {
119
+ this.$__.defaults = options.defaults;
120
+ defaults = options.defaults;
121
+ }
122
+
123
+ const schema = this.$__schema;
124
+
125
+ if (typeof fields === 'boolean' || fields === 'throw') {
126
+ if (fields !== true) {
127
+ this.$__.strictMode = fields;
128
+ }
129
+ fields = undefined;
130
+ } else if (schema.options.strict !== true) {
131
+ this.$__.strictMode = schema.options.strict;
132
+ }
133
+
134
+ const requiredPaths = schema.requiredPaths(true);
135
+ for (const path of requiredPaths) {
136
+ this.$__.activePaths.require(path);
137
+ }
138
+
139
+ let exclude = null;
140
+
141
+ // determine if this doc is a result of a query with
142
+ // excluded fields
143
+ if (utils.isPOJO(fields) && Object.keys(fields).length > 0) {
144
+ exclude = isExclusive(fields);
145
+ this.$__.selected = fields;
146
+ this.$__.exclude = exclude;
147
+ }
148
+
149
+ const hasIncludedChildren = exclude === false && fields ?
150
+ $__hasIncludedChildren(fields) :
151
+ null;
152
+
153
+ if (this._doc == null) {
154
+ this.$__buildDoc(obj, fields, skipId, exclude, hasIncludedChildren, false);
155
+
156
+ // By default, defaults get applied **before** setting initial values
157
+ // Re: gh-6155
158
+ if (defaults) {
159
+ applyDefaults(this, fields, exclude, hasIncludedChildren, true, null);
160
+ }
161
+ }
162
+ if (obj) {
163
+ // Skip set hooks
164
+ if (this.$__original_set) {
165
+ this.$__original_set(obj, undefined, true, options);
166
+ } else {
167
+ this.$set(obj, undefined, true, options);
168
+ }
169
+
170
+ if (obj instanceof Document) {
171
+ this.$isNew = obj.$isNew;
172
+ }
173
+ }
174
+
175
+ // Function defaults get applied **after** setting initial values so they
176
+ // see the full doc rather than an empty one, unless they opt out.
177
+ // Re: gh-3781, gh-6155
178
+ if (options.willInit && defaults) {
179
+ if (options.skipDefaults) {
180
+ this.$__.skipDefaults = options.skipDefaults;
181
+ }
182
+ } else if (defaults) {
183
+ applyDefaults(this, fields, exclude, hasIncludedChildren, false, options.skipDefaults);
184
+ }
185
+
186
+ if (!this.$__.strictMode && obj) {
187
+ const _this = this;
188
+ const keys = Object.keys(this._doc);
189
+
190
+ keys.forEach(function(key) {
191
+ // Avoid methods, virtuals, existing fields, and `$` keys. The latter is to avoid overwriting
192
+ // Mongoose internals.
193
+ if (!(key in schema.tree) && !(key in schema.methods) && !(key in schema.virtuals) && !key.startsWith('$')) {
194
+ defineKey({ prop: key, subprops: null, prototype: _this });
195
+ }
196
+ });
197
+ }
198
+
199
+ applyQueue(this);
200
+ }
201
+
202
+ Document.prototype.$isMongooseDocumentPrototype = true;
203
+
204
+ /**
205
+ * Boolean flag specifying if the document is new. If you create a document
206
+ * using `new`, this document will be considered "new". `$isNew` is how
207
+ * Mongoose determines whether `save()` should use `insertOne()` to create
208
+ * a new document or `updateOne()` to update an existing document.
209
+ *
210
+ * #### Example:
211
+ *
212
+ * const user = new User({ name: 'John Smith' });
213
+ * user.$isNew; // true
214
+ *
215
+ * await user.save(); // Sends an `insertOne` to MongoDB
216
+ *
217
+ * On the other hand, if you load an existing document from the database
218
+ * using `findOne()` or another [query operation](https://mongoosejs.com/docs/queries.html),
219
+ * `$isNew` will be false.
220
+ *
221
+ * #### Example:
222
+ *
223
+ * const user = await User.findOne({ name: 'John Smith' });
224
+ * user.$isNew; // false
225
+ *
226
+ * Mongoose sets `$isNew` to `false` immediately after `save()` succeeds.
227
+ * That means Mongoose sets `$isNew` to false **before** `post('save')` hooks run.
228
+ * In `post('save')` hooks, `$isNew` will be `false` if `save()` succeeded.
229
+ *
230
+ * #### Example:
231
+ *
232
+ * userSchema.post('save', function() {
233
+ * this.$isNew; // false
234
+ * });
235
+ * await User.create({ name: 'John Smith' });
236
+ *
237
+ * For subdocuments, `$isNew` is true if either the parent has `$isNew` set,
238
+ * or if you create a new subdocument.
239
+ *
240
+ * #### Example:
241
+ *
242
+ * // Assume `Group` has a document array `users`
243
+ * const group = await Group.findOne();
244
+ * group.users[0].$isNew; // false
245
+ *
246
+ * group.users.push({ name: 'John Smith' });
247
+ * group.users[1].$isNew; // true
248
+ *
249
+ * @api public
250
+ * @property $isNew
251
+ * @memberOf Document
252
+ * @instance
253
+ */
254
+
255
+ Object.defineProperty(Document.prototype, 'isNew', {
256
+ get: function() {
257
+ return this.$isNew;
258
+ },
259
+ set: function(value) {
260
+ this.$isNew = value;
261
+ }
262
+ });
263
+
264
+ /**
265
+ * Hash containing current validation errors.
266
+ *
267
+ * @api public
268
+ * @property errors
269
+ * @memberOf Document
270
+ * @instance
271
+ */
272
+
273
+ Object.defineProperty(Document.prototype, 'errors', {
274
+ get: function() {
275
+ return this.$errors;
276
+ },
277
+ set: function(value) {
278
+ this.$errors = value;
279
+ }
280
+ });
281
+
282
+ /*!
283
+ * ignore
284
+ */
285
+
286
+ Document.prototype.$isNew = true;
287
+
288
+ /*!
289
+ * Document exposes the NodeJS event emitter API, so you can use
290
+ * `on`, `once`, etc.
291
+ */
292
+ utils.each(
293
+ ['on', 'once', 'emit', 'listeners', 'removeListener', 'setMaxListeners',
294
+ 'removeAllListeners', 'addListener'],
295
+ function(emitterFn) {
296
+ Document.prototype[emitterFn] = function() {
297
+ // Delay creating emitter until necessary because emitters take up a lot of memory,
298
+ // especially for subdocuments.
299
+ if (!this.$__.emitter) {
300
+ if (emitterFn === 'emit') {
301
+ return;
302
+ }
303
+ this.$__.emitter = new EventEmitter();
304
+ this.$__.emitter.setMaxListeners(0);
305
+ }
306
+ return this.$__.emitter[emitterFn].apply(this.$__.emitter, arguments);
307
+ };
308
+ Document.prototype[`$${emitterFn}`] = Document.prototype[emitterFn];
309
+ });
310
+
311
+ Document.prototype.constructor = Document;
312
+
313
+ for (const i in EventEmitter.prototype) {
314
+ Document[i] = EventEmitter.prototype[i];
315
+ }
316
+
317
+ /**
318
+ * The document's internal schema.
319
+ *
320
+ * @api private
321
+ * @property schema
322
+ * @memberOf Document
323
+ * @instance
324
+ */
325
+
326
+ Document.prototype.$__schema;
327
+
328
+ /**
329
+ * The document's schema.
330
+ *
331
+ * @api public
332
+ * @property schema
333
+ * @memberOf Document
334
+ * @instance
335
+ */
336
+
337
+ Document.prototype.schema;
338
+
339
+ /**
340
+ * Empty object that you can use for storing properties on the document. This
341
+ * is handy for passing data to middleware without conflicting with Mongoose
342
+ * internals.
343
+ *
344
+ * #### Example:
345
+ *
346
+ * schema.pre('save', function() {
347
+ * // Mongoose will set `isNew` to `false` if `save()` succeeds
348
+ * this.$locals.wasNew = this.isNew;
349
+ * });
350
+ *
351
+ * schema.post('save', function() {
352
+ * // Prints true if `isNew` was set before `save()`
353
+ * console.log(this.$locals.wasNew);
354
+ * });
355
+ *
356
+ * @api public
357
+ * @property $locals
358
+ * @memberOf Document
359
+ * @instance
360
+ */
361
+
362
+ Object.defineProperty(Document.prototype, '$locals', {
363
+ configurable: false,
364
+ enumerable: false,
365
+ get: function() {
366
+ if (this.$__.locals == null) {
367
+ this.$__.locals = {};
368
+ }
369
+ return this.$__.locals;
370
+ },
371
+ set: function(v) {
372
+ this.$__.locals = v;
373
+ }
374
+ });
375
+
376
+ /**
377
+ * Legacy alias for `$isNew`.
378
+ *
379
+ * @api public
380
+ * @property isNew
381
+ * @memberOf Document
382
+ * @see $isNew https://mongoosejs.com/docs/api/document.html#Document.prototype.$isNew
383
+ * @instance
384
+ */
385
+
386
+ Document.prototype.isNew;
387
+
388
+ /**
389
+ * Set this property to add additional query filters when Mongoose saves this document and `isNew` is false.
390
+ *
391
+ * #### Example:
392
+ *
393
+ * // Make sure `save()` never updates a soft deleted document.
394
+ * schema.pre('save', function() {
395
+ * this.$where = { isDeleted: false };
396
+ * });
397
+ *
398
+ * @api public
399
+ * @property $where
400
+ * @memberOf Document
401
+ * @instance
402
+ */
403
+
404
+ Object.defineProperty(Document.prototype, '$where', {
405
+ configurable: false,
406
+ enumerable: false,
407
+ writable: true
408
+ });
409
+
410
+ /**
411
+ * The string version of this documents _id.
412
+ *
413
+ * #### Note:
414
+ *
415
+ * This getter exists on all documents by default. The getter can be disabled by setting the `id` [option](https://mongoosejs.com/docs/guide.html#id) of its `Schema` to false at construction time.
416
+ *
417
+ * new Schema({ name: String }, { id: false });
418
+ *
419
+ * @api public
420
+ * @see Schema options https://mongoosejs.com/docs/guide.html#options
421
+ * @property id
422
+ * @memberOf Document
423
+ * @instance
424
+ */
425
+
426
+ Document.prototype.id;
427
+
428
+ /**
429
+ * Hash containing current validation $errors.
430
+ *
431
+ * @api public
432
+ * @property $errors
433
+ * @memberOf Document
434
+ * @instance
435
+ */
436
+
437
+ Document.prototype.$errors;
438
+
439
+ /**
440
+ * A string containing the current operation that Mongoose is executing
441
+ * on this document. May be `null`, `'save'`, `'validate'`, or `'remove'`.
442
+ *
443
+ * #### Example:
444
+ *
445
+ * const doc = new Model({ name: 'test' });
446
+ * doc.$op; // null
447
+ *
448
+ * const promise = doc.save();
449
+ * doc.$op; // 'save'
450
+ *
451
+ * await promise;
452
+ * doc.$op; // null
453
+ *
454
+ * @api public
455
+ * @property $op
456
+ * @memberOf Document
457
+ * @instance
458
+ */
459
+
460
+ Object.defineProperty(Document.prototype, '$op', {
461
+ get: function() {
462
+ return this.$__.op || null;
463
+ },
464
+ set: function(value) {
465
+ this.$__.op = value;
466
+ }
467
+ });
468
+
469
+ /*!
470
+ * ignore
471
+ */
472
+
473
+ function $applyDefaultsToNested(val, path, doc) {
474
+ if (val == null) {
475
+ return;
476
+ }
477
+
478
+ const paths = Object.keys(doc.$__schema.paths);
479
+ const plen = paths.length;
480
+
481
+ const pathPieces = path.indexOf('.') === -1 ? [path] : path.split('.');
482
+
483
+ for (let i = 0; i < plen; ++i) {
484
+ let curPath = '';
485
+ const p = paths[i];
486
+
487
+ if (!p.startsWith(path + '.')) {
488
+ continue;
489
+ }
490
+
491
+ const type = doc.$__schema.paths[p];
492
+ const pieces = type.splitPath().slice(pathPieces.length);
493
+ const len = pieces.length;
494
+
495
+ if (type.defaultValue === void 0) {
496
+ continue;
497
+ }
498
+
499
+ let cur = val;
500
+
501
+ for (let j = 0; j < len; ++j) {
502
+ if (cur == null) {
503
+ break;
504
+ }
505
+
506
+ const piece = pieces[j];
507
+
508
+ if (j === len - 1) {
509
+ if (cur[piece] !== void 0) {
510
+ break;
511
+ }
512
+
513
+ try {
514
+ const def = type.getDefault(doc, false);
515
+ if (def !== void 0) {
516
+ cur[piece] = def;
517
+ }
518
+ } catch (err) {
519
+ doc.invalidate(path + '.' + curPath, err);
520
+ break;
521
+ }
522
+
523
+ break;
524
+ }
525
+
526
+ curPath += (!curPath.length ? '' : '.') + piece;
527
+
528
+ cur[piece] = cur[piece] || {};
529
+ cur = cur[piece];
530
+ }
531
+ }
532
+ }
533
+
534
+ /**
535
+ * Builds the default doc structure
536
+ *
537
+ * @param {Object} obj
538
+ * @param {Object} [fields]
539
+ * @param {Boolean} [skipId]
540
+ * @param {Boolean} [exclude]
541
+ * @param {Object} [hasIncludedChildren]
542
+ * @api private
543
+ * @method $__buildDoc
544
+ * @memberOf Document
545
+ * @instance
546
+ */
547
+
548
+ Document.prototype.$__buildDoc = function(obj, fields, skipId, exclude, hasIncludedChildren) {
549
+ const doc = {};
550
+
551
+ const paths = Object.keys(this.$__schema.paths).
552
+ // Don't build up any paths that are underneath a map, we don't know
553
+ // what the keys will be
554
+ filter(p => !p.includes('$*'));
555
+ const plen = paths.length;
556
+ let ii = 0;
557
+
558
+ for (; ii < plen; ++ii) {
559
+ const p = paths[ii];
560
+
561
+ if (p === '_id') {
562
+ if (skipId) {
563
+ continue;
564
+ }
565
+ if (obj && '_id' in obj) {
566
+ continue;
567
+ }
568
+ }
569
+
570
+ const path = this.$__schema.paths[p].splitPath();
571
+ const len = path.length;
572
+ const last = len - 1;
573
+ let curPath = '';
574
+ let doc_ = doc;
575
+ let included = false;
576
+
577
+ for (let i = 0; i < len; ++i) {
578
+ const piece = path[i];
579
+
580
+ if (!curPath.length) {
581
+ curPath = piece;
582
+ } else {
583
+ curPath += '.' + piece;
584
+ }
585
+
586
+ // support excluding intermediary levels
587
+ if (exclude === true) {
588
+ if (curPath in fields) {
589
+ break;
590
+ }
591
+ } else if (exclude === false && fields && !included) {
592
+ if (curPath in fields) {
593
+ included = true;
594
+ } else if (!hasIncludedChildren[curPath]) {
595
+ break;
596
+ }
597
+ }
598
+
599
+ if (i < last) {
600
+ doc_ = doc_[piece] || (doc_[piece] = {});
601
+ }
602
+ }
603
+ }
604
+
605
+ this._doc = doc;
606
+ };
607
+
608
+ /*!
609
+ * Converts to POJO when you use the document for querying
610
+ */
611
+
612
+ Document.prototype.toBSON = function() {
613
+ return this.toObject(internalToObjectOptions);
614
+ };
615
+
616
+ /**
617
+ * Initializes the document without setters or marking anything modified.
618
+ *
619
+ * Called internally after a document is returned from mongodb. Normally,
620
+ * you do **not** need to call this function on your own.
621
+ *
622
+ * This function triggers `init` [middleware](https://mongoosejs.com/docs/middleware.html).
623
+ * Note that `init` hooks are [synchronous](https://mongoosejs.com/docs/middleware.html#synchronous).
624
+ *
625
+ * @param {Object} doc document returned by mongo
626
+ * @param {Object} [opts]
627
+ * @param {Function} [fn]
628
+ * @api public
629
+ * @memberOf Document
630
+ * @instance
631
+ */
632
+
633
+ Document.prototype.init = function(doc, opts, fn) {
634
+ if (typeof opts === 'function') {
635
+ fn = opts;
636
+ opts = null;
637
+ }
638
+
639
+ this.$__init(doc, opts);
640
+
641
+ if (fn) {
642
+ fn(null, this);
643
+ }
644
+
645
+ return this;
646
+ };
647
+
648
+ /**
649
+ * Alias for [`.init`](https://mongoosejs.com/docs/api/document.html#Document.prototype.init())
650
+ *
651
+ * @api public
652
+ */
653
+
654
+ Document.prototype.$init = function() {
655
+ return this.constructor.prototype.init.apply(this, arguments);
656
+ };
657
+
658
+ /**
659
+ * Internal "init" function
660
+ *
661
+ * @param {Document} doc
662
+ * @param {Object} [opts]
663
+ * @returns {Document} this
664
+ * @api private
665
+ */
666
+
667
+ Document.prototype.$__init = function(doc, opts) {
668
+ this.$isNew = false;
669
+ opts = opts || {};
670
+
671
+ // handle docs with populated paths
672
+ // If doc._id is not null or undefined
673
+ if (doc._id != null && opts.populated && opts.populated.length) {
674
+ const id = String(doc._id);
675
+ for (const item of opts.populated) {
676
+ if (item.isVirtual) {
677
+ this.$populated(item.path, utils.getValue(item.path, doc), item);
678
+ } else {
679
+ this.$populated(item.path, item._docs[id], item);
680
+ }
681
+
682
+ if (item._childDocs == null) {
683
+ continue;
684
+ }
685
+ for (const child of item._childDocs) {
686
+ if (child == null || child.$__ == null) {
687
+ continue;
688
+ }
689
+ child.$__.parent = this;
690
+ }
691
+ item._childDocs = [];
692
+ }
693
+ }
694
+
695
+ init(this, doc, this._doc, opts);
696
+
697
+ markArraySubdocsPopulated(this, opts.populated);
698
+
699
+ this.$emit('init', this);
700
+ this.constructor.emit('init', this);
701
+
702
+ const hasIncludedChildren = this.$__.exclude === false && this.$__.selected ?
703
+ $__hasIncludedChildren(this.$__.selected) :
704
+ null;
705
+
706
+ applyDefaults(this, this.$__.selected, this.$__.exclude, hasIncludedChildren, false, this.$__.skipDefaults);
707
+
708
+ return this;
709
+ };
710
+
711
+ /**
712
+ * Init helper.
713
+ *
714
+ * @param {Object} self document instance
715
+ * @param {Object} obj raw mongodb doc
716
+ * @param {Object} doc object we are initializing
717
+ * @param {Object} [opts] Optional Options
718
+ * @param {Boolean} [opts.setters] Call `applySetters` instead of `cast`
719
+ * @param {String} [prefix] Prefix to add to each path
720
+ * @api private
721
+ */
722
+
723
+ function init(self, obj, doc, opts, prefix) {
724
+ prefix = prefix || '';
725
+
726
+ if (obj.$__ != null) {
727
+ obj = obj._doc;
728
+ }
729
+ const keys = Object.keys(obj);
730
+ const len = keys.length;
731
+ let schemaType;
732
+ let path;
733
+ let i;
734
+ let index = 0;
735
+ const strict = self.$__.strictMode;
736
+ const docSchema = self.$__schema;
737
+
738
+ while (index < len) {
739
+ _init(index++);
740
+ }
741
+
742
+ function _init(index) {
743
+ i = keys[index];
744
+ // avoid prototype pollution
745
+ if (i === '__proto__' || i === 'constructor') {
746
+ return;
747
+ }
748
+ path = prefix ? prefix + i : i;
749
+ schemaType = docSchema.path(path);
750
+
751
+ // Should still work if not a model-level discriminator, but should not be
752
+ // necessary. This is *only* to catch the case where we queried using the
753
+ // base model and the discriminated model has a projection
754
+ if (docSchema.$isRootDiscriminator && !self.$__isSelected(path)) {
755
+ return;
756
+ }
757
+
758
+ const value = obj[i];
759
+ if (!schemaType && utils.isPOJO(value)) {
760
+ // assume nested object
761
+ if (!doc[i]) {
762
+ doc[i] = {};
763
+ if (!strict && !(i in docSchema.tree) && !(i in docSchema.methods) && !(i in docSchema.virtuals)) {
764
+ self[i] = doc[i];
765
+ }
766
+ }
767
+ init(self, value, doc[i], opts, path + '.');
768
+ } else if (!schemaType) {
769
+ doc[i] = value;
770
+ if (!strict && !prefix) {
771
+ self[i] = value;
772
+ }
773
+ } else {
774
+ // Retain order when overwriting defaults
775
+ if (doc.hasOwnProperty(i) && value !== void 0) {
776
+ delete doc[i];
777
+ }
778
+ if (value === null) {
779
+ doc[i] = schemaType._castNullish(null);
780
+ } else if (value !== undefined) {
781
+ const wasPopulated = value.$__ == null ? null : value.$__.wasPopulated;
782
+
783
+ if (schemaType && !wasPopulated) {
784
+ try {
785
+ if (opts && opts.setters) {
786
+ // Call applySetters with `init = false` because otherwise setters are a noop
787
+ const overrideInit = false;
788
+ doc[i] = schemaType.applySetters(value, self, overrideInit);
789
+ } else {
790
+ doc[i] = schemaType.cast(value, self, true);
791
+ }
792
+ } catch (e) {
793
+ self.invalidate(e.path, new ValidatorError({
794
+ path: e.path,
795
+ message: e.message,
796
+ type: 'cast',
797
+ value: e.value,
798
+ reason: e
799
+ }));
800
+ }
801
+ } else {
802
+ doc[i] = value;
803
+ }
804
+ }
805
+ // mark as hydrated
806
+ if (!self.$isModified(path)) {
807
+ self.$__.activePaths.init(path);
808
+ }
809
+ }
810
+ }
811
+ }
812
+
813
+ /**
814
+ * Sends an updateOne command with this document `_id` as the query selector.
815
+ *
816
+ * #### Example:
817
+ *
818
+ * weirdCar.updateOne({$inc: {wheels:1}}, { w: 1 }, callback);
819
+ *
820
+ * #### Valid options:
821
+ *
822
+ * - same as in [Model.updateOne](https://mongoosejs.com/docs/api/model.html#Model.updateOne)
823
+ *
824
+ * @see Model.updateOne https://mongoosejs.com/docs/api/model.html#Model.updateOne
825
+ * @param {Object} doc
826
+ * @param {Object} [options] optional see [`Query.prototype.setOptions()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.setOptions())
827
+ * @param {Object} [options.lean] if truthy, mongoose will return the document as a plain JavaScript object rather than a mongoose document. See [`Query.lean()`](https://mongoosejs.com/docs/api/query.html#Query.prototype.lean()) and the [Mongoose lean tutorial](https://mongoosejs.com/docs/tutorials/lean.html).
828
+ * @param {Boolean|String} [options.strict] overwrites the schema's [strict mode option](https://mongoosejs.com/docs/guide.html#strict)
829
+ * @param {Boolean} [options.timestamps=null] If set to `false` and [schema-level timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this update. Note that this allows you to overwrite timestamps. Does nothing if schema-level timestamps are not set.
830
+ * @param {Function} [callback]
831
+ * @return {Query}
832
+ * @api public
833
+ * @memberOf Document
834
+ * @instance
835
+ */
836
+
837
+ Document.prototype.updateOne = function updateOne(doc, options, callback) {
838
+ const query = this.constructor.updateOne({ _id: this._id }, doc, options);
839
+ const self = this;
840
+ query.pre(function queryPreUpdateOne(cb) {
841
+ self.constructor._middleware.execPre('updateOne', self, [self], cb);
842
+ });
843
+ query.post(function queryPostUpdateOne(cb) {
844
+ self.constructor._middleware.execPost('updateOne', self, [self], {}, cb);
845
+ });
846
+
847
+ if (this.$session() != null) {
848
+ if (!('session' in query.options)) {
849
+ query.options.session = this.$session();
850
+ }
851
+ }
852
+
853
+ if (callback != null) {
854
+ return query.exec(callback);
855
+ }
856
+
857
+ return query;
858
+ };
859
+
860
+ /**
861
+ * Sends a replaceOne command with this document `_id` as the query selector.
862
+ *
863
+ * #### Valid options:
864
+ *
865
+ * - same as in [Model.replaceOne](https://mongoosejs.com/docs/api/model.html#Model.replaceOne())
866
+ *
867
+ * @see Model.replaceOne https://mongoosejs.com/docs/api/model.html#Model.replaceOne()
868
+ * @param {Object} doc
869
+ * @param {Object} [options]
870
+ * @param {Function} [callback]
871
+ * @return {Query}
872
+ * @api public
873
+ * @memberOf Document
874
+ * @instance
875
+ */
876
+
877
+ Document.prototype.replaceOne = function replaceOne() {
878
+ const args = [...arguments];
879
+ args.unshift({ _id: this._id });
880
+ return this.constructor.replaceOne.apply(this.constructor, args);
881
+ };
882
+
883
+ /**
884
+ * Getter/setter around the session associated with this document. Used to
885
+ * automatically set `session` if you `save()` a doc that you got from a
886
+ * query with an associated session.
887
+ *
888
+ * #### Example:
889
+ *
890
+ * const session = MyModel.startSession();
891
+ * const doc = await MyModel.findOne().session(session);
892
+ * doc.$session() === session; // true
893
+ * doc.$session(null);
894
+ * doc.$session() === null; // true
895
+ *
896
+ * If this is a top-level document, setting the session propagates to all child
897
+ * docs.
898
+ *
899
+ * @param {ClientSession} [session] overwrite the current session
900
+ * @return {ClientSession}
901
+ * @method $session
902
+ * @api public
903
+ * @memberOf Document
904
+ */
905
+
906
+ Document.prototype.$session = function $session(session) {
907
+ if (arguments.length === 0) {
908
+ if (this.$__.session != null && this.$__.session.hasEnded) {
909
+ this.$__.session = null;
910
+ return null;
911
+ }
912
+ return this.$__.session;
913
+ }
914
+
915
+ if (session != null && session.hasEnded) {
916
+ throw new MongooseError('Cannot set a document\'s session to a session that has ended. Make sure you haven\'t ' +
917
+ 'called `endSession()` on the session you are passing to `$session()`.');
918
+ }
919
+
920
+ if (session == null && this.$__.session == null) {
921
+ return;
922
+ }
923
+
924
+ this.$__.session = session;
925
+
926
+ if (!this.$isSubdocument) {
927
+ const subdocs = this.$getAllSubdocs();
928
+ for (const child of subdocs) {
929
+ child.$session(session);
930
+ }
931
+ }
932
+
933
+ return session;
934
+ };
935
+
936
+ /**
937
+ * Getter/setter around whether this document will apply timestamps by
938
+ * default when using `save()` and `bulkSave()`.
939
+ *
940
+ * #### Example:
941
+ *
942
+ * const TestModel = mongoose.model('Test', new Schema({ name: String }, { timestamps: true }));
943
+ * const doc = new TestModel({ name: 'John Smith' });
944
+ *
945
+ * doc.$timestamps(); // true
946
+ *
947
+ * doc.$timestamps(false);
948
+ * await doc.save(); // Does **not** apply timestamps
949
+ *
950
+ * @param {Boolean} [value] overwrite the current session
951
+ * @return {Document|boolean|undefined} When used as a getter (no argument), a boolean will be returned indicating the timestamps option state or if unset "undefined" will be used, otherwise will return "this"
952
+ * @method $timestamps
953
+ * @api public
954
+ * @memberOf Document
955
+ */
956
+
957
+ Document.prototype.$timestamps = function $timestamps(value) {
958
+ if (arguments.length === 0) {
959
+ if (this.$__.timestamps != null) {
960
+ return this.$__.timestamps;
961
+ }
962
+
963
+ if (this.$__schema) {
964
+ return this.$__schema.options.timestamps;
965
+ }
966
+
967
+ return undefined;
968
+ }
969
+
970
+ const currentValue = this.$timestamps();
971
+ if (value !== currentValue) {
972
+ this.$__.timestamps = value;
973
+ }
974
+
975
+ return this;
976
+ };
977
+
978
+ /**
979
+ * Overwrite all values in this document with the values of `obj`, except
980
+ * for immutable properties. Behaves similarly to `set()`, except for it
981
+ * unsets all properties that aren't in `obj`.
982
+ *
983
+ * @param {Object} obj the object to overwrite this document with
984
+ * @method overwrite
985
+ * @memberOf Document
986
+ * @instance
987
+ * @api public
988
+ * @return {Document} this
989
+ */
990
+
991
+ Document.prototype.overwrite = function overwrite(obj) {
992
+ const keys = Array.from(new Set(Object.keys(this._doc).concat(Object.keys(obj))));
993
+
994
+ for (const key of keys) {
995
+ if (key === '_id') {
996
+ continue;
997
+ }
998
+ // Explicitly skip version key
999
+ if (this.$__schema.options.versionKey && key === this.$__schema.options.versionKey) {
1000
+ continue;
1001
+ }
1002
+ if (this.$__schema.options.discriminatorKey && key === this.$__schema.options.discriminatorKey) {
1003
+ continue;
1004
+ }
1005
+ this.$set(key, obj[key]);
1006
+ }
1007
+
1008
+ return this;
1009
+ };
1010
+
1011
+ /**
1012
+ * Alias for `set()`, used internally to avoid conflicts
1013
+ *
1014
+ * @param {String|Object} path path or object of key/vals to set
1015
+ * @param {Any} val the value to set
1016
+ * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes
1017
+ * @param {Object} [options] optionally specify options that modify the behavior of the set
1018
+ * @param {Boolean} [options.merge=false] if true, setting a [nested path](https://mongoosejs.com/docs/subdocs.html#subdocuments-versus-nested-paths) will merge existing values rather than overwrite the whole object. So `doc.set('nested', { a: 1, b: 2 })` becomes `doc.set('nested.a', 1); doc.set('nested.b', 2);`
1019
+ * @return {Document} this
1020
+ * @method $set
1021
+ * @memberOf Document
1022
+ * @instance
1023
+ * @api public
1024
+ */
1025
+
1026
+ Document.prototype.$set = function $set(path, val, type, options) {
1027
+ if (utils.isPOJO(type)) {
1028
+ options = type;
1029
+ type = undefined;
1030
+ }
1031
+
1032
+ const merge = options && options.merge;
1033
+ const adhoc = type && type !== true;
1034
+ const constructing = type === true;
1035
+ let adhocs;
1036
+ let keys;
1037
+ let i = 0;
1038
+ let pathtype;
1039
+ let key;
1040
+ let prefix;
1041
+
1042
+ const userSpecifiedStrict = options && 'strict' in options;
1043
+ let strict = userSpecifiedStrict
1044
+ ? options.strict
1045
+ : this.$__.strictMode;
1046
+
1047
+ if (adhoc) {
1048
+ adhocs = this.$__.adhocPaths || (this.$__.adhocPaths = {});
1049
+ adhocs[path] = this.$__schema.interpretAsType(path, type, this.$__schema.options);
1050
+ }
1051
+
1052
+ if (path == null) {
1053
+ [path, val] = [val, path];
1054
+ } else if (typeof path !== 'string') {
1055
+ // new Document({ key: val })
1056
+ if (path instanceof Document) {
1057
+ if (path.$__isNested) {
1058
+ path = path.toObject();
1059
+ } else {
1060
+ // This ternary is to support gh-7898 (copying virtuals if same schema)
1061
+ // while not breaking gh-10819, which for some reason breaks if we use toObject()
1062
+ path = path.$__schema === this.$__schema
1063
+ ? applyVirtuals(path, { ...path._doc })
1064
+ : path._doc;
1065
+ }
1066
+ }
1067
+ if (path == null) {
1068
+ [path, val] = [val, path];
1069
+ }
1070
+
1071
+ prefix = val ? val + '.' : '';
1072
+ keys = getKeysInSchemaOrder(this.$__schema, path);
1073
+
1074
+ const len = keys.length;
1075
+
1076
+ // `_skipMinimizeTopLevel` is because we may have deleted the top-level
1077
+ // nested key to ensure key order.
1078
+ const _skipMinimizeTopLevel = options && options._skipMinimizeTopLevel || false;
1079
+ if (len === 0 && _skipMinimizeTopLevel) {
1080
+ delete options._skipMinimizeTopLevel;
1081
+ if (val) {
1082
+ this.$set(val, {});
1083
+ }
1084
+ return this;
1085
+ }
1086
+
1087
+ options = Object.assign({}, options, { _skipMinimizeTopLevel: false });
1088
+
1089
+ for (let i = 0; i < len; ++i) {
1090
+ key = keys[i];
1091
+ const pathName = prefix ? prefix + key : key;
1092
+ pathtype = this.$__schema.pathType(pathName);
1093
+ const valForKey = path[key];
1094
+
1095
+ // On initial set, delete any nested keys if we're going to overwrite
1096
+ // them to ensure we keep the user's key order.
1097
+ if (type === true &&
1098
+ !prefix &&
1099
+ valForKey != null &&
1100
+ pathtype === 'nested' &&
1101
+ this._doc[key] != null) {
1102
+ delete this._doc[key];
1103
+ }
1104
+
1105
+ if (utils.isNonBuiltinObject(valForKey) && pathtype === 'nested') {
1106
+ this.$set(pathName, valForKey, constructing, Object.assign({}, options, { _skipMarkModified: true }));
1107
+ $applyDefaultsToNested(this.$get(pathName), pathName, this);
1108
+ continue;
1109
+ } else if (strict) {
1110
+ // Don't overwrite defaults with undefined keys (gh-3981) (gh-9039)
1111
+ if (constructing && valForKey === void 0 &&
1112
+ this.$get(pathName) !== void 0) {
1113
+ continue;
1114
+ }
1115
+
1116
+ if (pathtype === 'adhocOrUndefined') {
1117
+ pathtype = getEmbeddedDiscriminatorPath(this, pathName, { typeOnly: true });
1118
+ }
1119
+
1120
+ if (pathtype === 'real' || pathtype === 'virtual') {
1121
+ this.$set(pathName, valForKey, constructing, options);
1122
+ } else if (pathtype === 'nested' && valForKey instanceof Document) {
1123
+ this.$set(pathName,
1124
+ valForKey.toObject({ transform: false }), constructing, options);
1125
+ } else if (strict === 'throw') {
1126
+ if (pathtype === 'nested') {
1127
+ throw new ObjectExpectedError(key, valForKey);
1128
+ } else {
1129
+ throw new StrictModeError(key);
1130
+ }
1131
+ } else if (pathtype === 'nested' && valForKey == null) {
1132
+ this.$set(pathName, valForKey, constructing, options);
1133
+ }
1134
+ } else if (valForKey !== void 0) {
1135
+ this.$set(pathName, valForKey, constructing, options);
1136
+ }
1137
+ }
1138
+
1139
+ // Ensure all properties are in correct order
1140
+ const orderedDoc = {};
1141
+ const orderedKeys = Object.keys(this.$__schema.tree);
1142
+ for (let i = 0, len = orderedKeys.length; i < len; ++i) {
1143
+ (key = orderedKeys[i]) &&
1144
+ (this._doc.hasOwnProperty(key)) &&
1145
+ (orderedDoc[key] = undefined);
1146
+ }
1147
+ this._doc = Object.assign(orderedDoc, this._doc);
1148
+
1149
+ return this;
1150
+ }
1151
+
1152
+ let pathType = this.$__schema.pathType(path);
1153
+ let parts = null;
1154
+ if (pathType === 'adhocOrUndefined') {
1155
+ parts = path.indexOf('.') === -1 ? [path] : path.split('.');
1156
+ pathType = getEmbeddedDiscriminatorPath(this, parts, { typeOnly: true });
1157
+ }
1158
+ if (pathType === 'adhocOrUndefined' && !userSpecifiedStrict) {
1159
+ // May be path underneath non-strict schema
1160
+ if (parts == null) {
1161
+ parts = path.indexOf('.') === -1 ? [path] : path.split('.');
1162
+ }
1163
+ const subdocStrict = getSubdocumentStrictValue(this.$__schema, parts);
1164
+ if (subdocStrict !== undefined) {
1165
+ strict = subdocStrict;
1166
+ }
1167
+ }
1168
+
1169
+ // Assume this is a Mongoose document that was copied into a POJO using
1170
+ // `Object.assign()` or `{...doc}`
1171
+ val = handleSpreadDoc(val);
1172
+
1173
+ // if this doc is being constructed we should not trigger getters
1174
+ const priorVal = (() => {
1175
+ if (this.$__.priorDoc != null) {
1176
+ return this.$__.priorDoc.$__getValue(path);
1177
+ }
1178
+ if (constructing) {
1179
+ return void 0;
1180
+ }
1181
+ return this.$__getValue(path);
1182
+ })();
1183
+
1184
+ if (pathType === 'nested' && val) {
1185
+ if (typeof val === 'object' && val != null) {
1186
+ if (val.$__ != null) {
1187
+ val = val.toObject(internalToObjectOptions);
1188
+ }
1189
+ if (val == null) {
1190
+ this.invalidate(path, new MongooseError.CastError('Object', val, path));
1191
+ return this;
1192
+ }
1193
+ const wasModified = this.$isModified(path);
1194
+ const hasInitialVal = this.$__.savedState != null && this.$__.savedState.hasOwnProperty(path);
1195
+ if (this.$__.savedState != null && !this.$isNew && !this.$__.savedState.hasOwnProperty(path)) {
1196
+ const initialVal = this.$__getValue(path);
1197
+ this.$__.savedState[path] = initialVal;
1198
+
1199
+ const keys = Object.keys(initialVal || {});
1200
+ for (const key of keys) {
1201
+ this.$__.savedState[path + '.' + key] = initialVal[key];
1202
+ }
1203
+ }
1204
+
1205
+ if (!merge) {
1206
+ this.$__setValue(path, null);
1207
+ cleanModifiedSubpaths(this, path);
1208
+ } else {
1209
+ return this.$set(val, path, constructing, options);
1210
+ }
1211
+
1212
+ const keys = getKeysInSchemaOrder(this.$__schema, val, path);
1213
+
1214
+ this.$__setValue(path, {});
1215
+ for (const key of keys) {
1216
+ this.$set(path + '.' + key, val[key], constructing, { ...options, _skipMarkModified: true });
1217
+ }
1218
+ if (priorVal != null &&
1219
+ (!wasModified || hasInitialVal) &&
1220
+ utils.deepEqual(hasInitialVal ? this.$__.savedState[path] : priorVal, val)) {
1221
+ this.unmarkModified(path);
1222
+ } else {
1223
+ this.markModified(path);
1224
+ }
1225
+ return this;
1226
+ }
1227
+ this.invalidate(path, new MongooseError.CastError('Object', val, path));
1228
+ return this;
1229
+ }
1230
+
1231
+ let schema;
1232
+ if (parts == null) {
1233
+ parts = path.indexOf('.') === -1 ? [path] : path.split('.');
1234
+ }
1235
+
1236
+ // Might need to change path for top-level alias
1237
+ if (typeof this.$__schema.aliases[parts[0]] === 'string') {
1238
+ parts[0] = this.$__schema.aliases[parts[0]];
1239
+ }
1240
+
1241
+ if (pathType === 'adhocOrUndefined' && strict) {
1242
+ // check for roots that are Mixed types
1243
+ let mixed;
1244
+
1245
+ for (i = 0; i < parts.length; ++i) {
1246
+ const subpath = parts.slice(0, i + 1).join('.');
1247
+
1248
+ // If path is underneath a virtual, bypass everything and just set it.
1249
+ if (i + 1 < parts.length && this.$__schema.pathType(subpath) === 'virtual') {
1250
+ mpath.set(path, val, this);
1251
+ return this;
1252
+ }
1253
+
1254
+ schema = this.$__schema.path(subpath);
1255
+ if (schema == null) {
1256
+ continue;
1257
+ }
1258
+
1259
+ if (schema instanceof MixedSchema) {
1260
+ // allow changes to sub paths of mixed types
1261
+ mixed = true;
1262
+ break;
1263
+ } else if (schema.$isSchemaMap && schema.$__schemaType instanceof MixedSchema && i < parts.length - 1) {
1264
+ // Map of mixed and not the last element in the path resolves to mixed
1265
+ mixed = true;
1266
+ schema = schema.$__schemaType;
1267
+ break;
1268
+ }
1269
+ }
1270
+
1271
+ if (schema == null) {
1272
+ // Check for embedded discriminators
1273
+ schema = getEmbeddedDiscriminatorPath(this, path);
1274
+ }
1275
+
1276
+ if (!mixed && !schema) {
1277
+ if (strict === 'throw') {
1278
+ throw new StrictModeError(path);
1279
+ }
1280
+ return this;
1281
+ }
1282
+ } else if (pathType === 'virtual') {
1283
+ schema = this.$__schema.virtualpath(path);
1284
+ schema.applySetters(val, this);
1285
+ return this;
1286
+ } else {
1287
+ schema = this.$__path(path);
1288
+ }
1289
+
1290
+ // gh-4578, if setting a deeply nested path that doesn't exist yet, create it
1291
+ let cur = this._doc;
1292
+ let curPath = '';
1293
+ for (i = 0; i < parts.length - 1; ++i) {
1294
+ cur = cur[parts[i]];
1295
+ curPath += (curPath.length !== 0 ? '.' : '') + parts[i];
1296
+ if (!cur) {
1297
+ this.$set(curPath, {});
1298
+ // Hack re: gh-5800. If nested field is not selected, it probably exists
1299
+ // so `MongoServerError: cannot use the part (nested of nested.num) to
1300
+ // traverse the element ({nested: null})` is not likely. If user gets
1301
+ // that error, its their fault for now. We should reconsider disallowing
1302
+ // modifying not selected paths for 6.x
1303
+ if (!this.$__isSelected(curPath)) {
1304
+ this.unmarkModified(curPath);
1305
+ }
1306
+ cur = this.$__getValue(curPath);
1307
+ }
1308
+ }
1309
+
1310
+ let pathToMark;
1311
+
1312
+ // When using the $set operator the path to the field must already exist.
1313
+ // Else mongodb throws: "LEFT_SUBFIELD only supports Object"
1314
+
1315
+ if (parts.length <= 1) {
1316
+ pathToMark = path;
1317
+ } else {
1318
+ const len = parts.length;
1319
+ for (i = 0; i < len; ++i) {
1320
+ const subpath = parts.slice(0, i + 1).join('.');
1321
+ if (this.$get(subpath, null, { getters: false }) === null) {
1322
+ pathToMark = subpath;
1323
+ break;
1324
+ }
1325
+ }
1326
+
1327
+ if (!pathToMark) {
1328
+ pathToMark = path;
1329
+ }
1330
+ }
1331
+
1332
+ if (!schema) {
1333
+ this.$__set(pathToMark, path, options, constructing, parts, schema, val, priorVal);
1334
+
1335
+ if (pathType === 'nested' && val == null) {
1336
+ cleanModifiedSubpaths(this, path);
1337
+ }
1338
+ return this;
1339
+ }
1340
+
1341
+ // If overwriting a subdocument path, make sure to clear out
1342
+ // any errors _before_ setting, so new errors that happen
1343
+ // get persisted. Re: #9080
1344
+ if (schema.$isSingleNested || schema.$isMongooseArray) {
1345
+ _markValidSubpaths(this, path);
1346
+ }
1347
+
1348
+ if (val != null && merge && schema.$isSingleNested) {
1349
+ if (val instanceof Document) {
1350
+ val = val.toObject({ virtuals: false, transform: false });
1351
+ }
1352
+ const keys = Object.keys(val);
1353
+ for (const key of keys) {
1354
+ this.$set(path + '.' + key, val[key], constructing, options);
1355
+ }
1356
+
1357
+ return this;
1358
+ }
1359
+
1360
+ let shouldSet = true;
1361
+ try {
1362
+ // If the user is trying to set a ref path to a document with
1363
+ // the correct model name, treat it as populated
1364
+ const refMatches = (() => {
1365
+ if (schema.options == null) {
1366
+ return false;
1367
+ }
1368
+ if (!(val instanceof Document)) {
1369
+ return false;
1370
+ }
1371
+ const model = val.constructor;
1372
+
1373
+ // Check ref
1374
+ const ref = schema.options.ref;
1375
+ if (ref != null && (ref === model.modelName || ref === model.baseModelName)) {
1376
+ return true;
1377
+ }
1378
+
1379
+ // Check refPath
1380
+ const refPath = schema.options.refPath;
1381
+ if (refPath == null) {
1382
+ return false;
1383
+ }
1384
+ const modelName = val.get(refPath);
1385
+ return modelName === model.modelName || modelName === model.baseModelName;
1386
+ })();
1387
+
1388
+ let didPopulate = false;
1389
+ if (refMatches && val instanceof Document && (!val.$__.wasPopulated || utils.deepEqual(val.$__.wasPopulated.value, val._id))) {
1390
+ const unpopulatedValue = (schema && schema.$isSingleNested) ? schema.cast(val, this) : val._id;
1391
+ this.$populated(path, unpopulatedValue, { [populateModelSymbol]: val.constructor });
1392
+ val.$__.wasPopulated = { value: unpopulatedValue };
1393
+ didPopulate = true;
1394
+ }
1395
+
1396
+ let popOpts;
1397
+ const typeKey = this.$__schema.options.typeKey;
1398
+ if (schema.options &&
1399
+ Array.isArray(schema.options[typeKey]) &&
1400
+ schema.options[typeKey].length &&
1401
+ schema.options[typeKey][0].ref &&
1402
+ _isManuallyPopulatedArray(val, schema.options[typeKey][0].ref)) {
1403
+ popOpts = { [populateModelSymbol]: val[0].constructor };
1404
+ this.$populated(path, val.map(function(v) { return v._id; }), popOpts);
1405
+
1406
+ for (const doc of val) {
1407
+ doc.$__.wasPopulated = { value: doc._id };
1408
+ }
1409
+ didPopulate = true;
1410
+ }
1411
+
1412
+ if (!refMatches || !schema.$isSingleNested || !val.$__) {
1413
+ // If this path is underneath a single nested schema, we'll call the setter
1414
+ // later in `$__set()` because we don't take `_doc` when we iterate through
1415
+ // a single nested doc. That's to make sure we get the correct context.
1416
+ // Otherwise we would double-call the setter, see gh-7196.
1417
+ let setterContext = this;
1418
+ if (this.$__schema.singleNestedPaths[path] != null && parts.length > 1) {
1419
+ setterContext = getDeepestSubdocumentForPath(this, parts, this.schema);
1420
+ }
1421
+ if (options != null && options.overwriteImmutable) {
1422
+ val = schema.applySetters(val, setterContext, false, priorVal, { overwriteImmutable: true });
1423
+ } else {
1424
+ val = schema.applySetters(val, setterContext, false, priorVal);
1425
+ }
1426
+ }
1427
+
1428
+ if (Array.isArray(val) &&
1429
+ !Array.isArray(schema) &&
1430
+ schema.$isMongooseDocumentArray &&
1431
+ val.length !== 0 &&
1432
+ val[0] != null &&
1433
+ val[0].$__ != null &&
1434
+ val[0].$__.populated != null) {
1435
+ const populatedPaths = Object.keys(val[0].$__.populated);
1436
+ for (const populatedPath of populatedPaths) {
1437
+ this.$populated(path + '.' + populatedPath,
1438
+ val.map(v => v.$populated(populatedPath)),
1439
+ val[0].$__.populated[populatedPath].options);
1440
+ }
1441
+ didPopulate = true;
1442
+ }
1443
+
1444
+ if (!didPopulate && this.$__.populated) {
1445
+ // If this array partially contains populated documents, convert them
1446
+ // all to ObjectIds re: #8443
1447
+ if (Array.isArray(val) && this.$__.populated[path]) {
1448
+ for (let i = 0; i < val.length; ++i) {
1449
+ if (val[i] instanceof Document) {
1450
+ val.set(i, val[i]._id, true);
1451
+ }
1452
+ }
1453
+ }
1454
+ delete this.$__.populated[path];
1455
+ }
1456
+
1457
+ if (val != null && schema.$isSingleNested) {
1458
+ _checkImmutableSubpaths(val, schema, priorVal);
1459
+ }
1460
+
1461
+ this.$markValid(path);
1462
+ } catch (e) {
1463
+ if (e instanceof MongooseError.StrictModeError && e.isImmutableError) {
1464
+ this.invalidate(path, e);
1465
+ } else if (e instanceof MongooseError.CastError) {
1466
+ this.invalidate(e.path, e);
1467
+ if (e.$originalErrorPath) {
1468
+ this.invalidate(path,
1469
+ new MongooseError.CastError(schema.instance, val, path, e.$originalErrorPath));
1470
+ }
1471
+ } else {
1472
+ this.invalidate(path,
1473
+ new MongooseError.CastError(schema.instance, val, path, e));
1474
+ }
1475
+ shouldSet = false;
1476
+ }
1477
+
1478
+ if (shouldSet) {
1479
+ let savedState = null;
1480
+ let savedStatePath = null;
1481
+ if (!constructing) {
1482
+ const doc = this.$isSubdocument ? this.ownerDocument() : this;
1483
+ savedState = doc.$__.savedState;
1484
+ savedStatePath = this.$isSubdocument ? this.$__.fullPath + '.' + path : path;
1485
+ doc.$__saveInitialState(savedStatePath);
1486
+ }
1487
+
1488
+ this.$__set(pathToMark, path, options, constructing, parts, schema, val, priorVal);
1489
+
1490
+ const isInTransaction = !!this.$__.session?.transaction;
1491
+ const isModifiedWithinTransaction = this.$__.session &&
1492
+ this.$__.session[sessionNewDocuments] &&
1493
+ this.$__.session[sessionNewDocuments].has(this) &&
1494
+ this.$__.session[sessionNewDocuments].get(this).modifiedPaths &&
1495
+ !this.$__.session[sessionNewDocuments].get(this).modifiedPaths.has(savedStatePath);
1496
+ if (savedState != null &&
1497
+ savedState.hasOwnProperty(savedStatePath) &&
1498
+ (!isInTransaction || isModifiedWithinTransaction) &&
1499
+ utils.deepEqual(val, savedState[savedStatePath])) {
1500
+ this.unmarkModified(path);
1501
+ }
1502
+ }
1503
+
1504
+ if (schema.$isSingleNested && (this.isDirectModified(path) || val == null)) {
1505
+ cleanModifiedSubpaths(this, path);
1506
+ }
1507
+
1508
+ return this;
1509
+ };
1510
+
1511
+ /*!
1512
+ * ignore
1513
+ */
1514
+
1515
+ function _isManuallyPopulatedArray(val, ref) {
1516
+ if (!Array.isArray(val)) {
1517
+ return false;
1518
+ }
1519
+ if (val.length === 0) {
1520
+ return false;
1521
+ }
1522
+
1523
+ for (const el of val) {
1524
+ if (!(el instanceof Document)) {
1525
+ return false;
1526
+ }
1527
+ const modelName = el.constructor.modelName;
1528
+ if (modelName == null) {
1529
+ return false;
1530
+ }
1531
+ if (el.constructor.modelName != ref && el.constructor.baseModelName != ref) {
1532
+ return false;
1533
+ }
1534
+ }
1535
+
1536
+ return true;
1537
+ }
1538
+
1539
+ /**
1540
+ * Sets the value of a path, or many paths.
1541
+ * Alias for [`.$set`](https://mongoosejs.com/docs/api/document.html#Document.prototype.$set()).
1542
+ *
1543
+ * #### Example:
1544
+ *
1545
+ * // path, value
1546
+ * doc.set(path, value)
1547
+ *
1548
+ * // object
1549
+ * doc.set({
1550
+ * path : value
1551
+ * , path2 : {
1552
+ * path : value
1553
+ * }
1554
+ * })
1555
+ *
1556
+ * // on-the-fly cast to number
1557
+ * doc.set(path, value, Number)
1558
+ *
1559
+ * // on-the-fly cast to string
1560
+ * doc.set(path, value, String)
1561
+ *
1562
+ * // changing strict mode behavior
1563
+ * doc.set(path, value, { strict: false });
1564
+ *
1565
+ * @param {String|Object} path path or object of key/vals to set
1566
+ * @param {Any} val the value to set
1567
+ * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for "on-the-fly" attributes
1568
+ * @param {Object} [options] optionally specify options that modify the behavior of the set
1569
+ * @return {Document} this
1570
+ * @api public
1571
+ * @method set
1572
+ * @memberOf Document
1573
+ * @instance
1574
+ */
1575
+
1576
+ Document.prototype.set = Document.prototype.$set;
1577
+
1578
+ /**
1579
+ * Determine if we should mark this change as modified.
1580
+ *
1581
+ * @param {never} pathToMark UNUSED
1582
+ * @param {String|Symbol} path
1583
+ * @param {Object} options
1584
+ * @param {Any} constructing
1585
+ * @param {never} parts UNUSED
1586
+ * @param {Schema} schema
1587
+ * @param {Any} val
1588
+ * @param {Any} priorVal
1589
+ * @return {Boolean}
1590
+ * @api private
1591
+ * @method $__shouldModify
1592
+ * @memberOf Document
1593
+ * @instance
1594
+ */
1595
+
1596
+ Document.prototype.$__shouldModify = function(pathToMark, path, options, constructing, parts, schema, val, priorVal) {
1597
+ if (options && options._skipMarkModified) {
1598
+ return false;
1599
+ }
1600
+ if (this.$isNew) {
1601
+ return true;
1602
+ }
1603
+ // Is path already modified? If so, always modify. We may unmark modified later.
1604
+ if (path in this.$__.activePaths.getStatePaths('modify')) {
1605
+ return true;
1606
+ }
1607
+
1608
+ if (val === void 0 && !this.$__isSelected(path)) {
1609
+ // when a path is not selected in a query, its initial
1610
+ // value will be undefined.
1611
+ return true;
1612
+ }
1613
+
1614
+ if (val === void 0 && path in this.$__.activePaths.getStatePaths('default')) {
1615
+ // we're just unsetting the default value which was never saved
1616
+ return false;
1617
+ }
1618
+
1619
+ // gh-3992: if setting a populated field to a doc, don't mark modified
1620
+ // if they have the same _id
1621
+ if (this.$populated(path) &&
1622
+ val instanceof Document &&
1623
+ deepEqual(val._id, priorVal)) {
1624
+ return false;
1625
+ }
1626
+
1627
+ if (!deepEqual(val, priorVal !== undefined ? priorVal : utils.getValue(path, this))) {
1628
+ return true;
1629
+ }
1630
+
1631
+ if (!constructing &&
1632
+ val !== null &&
1633
+ val !== undefined &&
1634
+ path in this.$__.activePaths.getStatePaths('default') &&
1635
+ deepEqual(val, schema.getDefault(this, constructing))) {
1636
+ // a path with a default was $unset on the server
1637
+ // and the user is setting it to the same value again
1638
+ return true;
1639
+ }
1640
+ return false;
1641
+ };
1642
+
1643
+ /**
1644
+ * Handles the actual setting of the value and marking the path modified if appropriate.
1645
+ *
1646
+ * @param {String} pathToMark
1647
+ * @param {String|Symbol} path
1648
+ * @param {Object} options
1649
+ * @param {Any} constructing
1650
+ * @param {Array} parts
1651
+ * @param {Schema} schema
1652
+ * @param {Any} val
1653
+ * @param {Any} priorVal
1654
+ * @api private
1655
+ * @method $__set
1656
+ * @memberOf Document
1657
+ * @instance
1658
+ */
1659
+
1660
+ Document.prototype.$__set = function(pathToMark, path, options, constructing, parts, schema, val, priorVal) {
1661
+ Embedded = Embedded || require('./types/ArraySubdocument');
1662
+
1663
+ const shouldModify = this.$__shouldModify(pathToMark, path, options, constructing, parts,
1664
+ schema, val, priorVal);
1665
+
1666
+ if (shouldModify) {
1667
+ if (this.$__.primitiveAtomics && this.$__.primitiveAtomics[path]) {
1668
+ delete this.$__.primitiveAtomics[path];
1669
+ if (Object.keys(this.$__.primitiveAtomics).length === 0) {
1670
+ delete this.$__.primitiveAtomics;
1671
+ }
1672
+ }
1673
+ this.markModified(pathToMark);
1674
+
1675
+ // handle directly setting arrays (gh-1126)
1676
+ MongooseArray || (MongooseArray = require('./types/array'));
1677
+ if (val && utils.isMongooseArray(val)) {
1678
+ val._registerAtomic('$set', val);
1679
+
1680
+ // Update embedded document parent references (gh-5189)
1681
+ if (utils.isMongooseDocumentArray(val)) {
1682
+ val.forEach(function(item) {
1683
+ item && item.__parentArray && (item.__parentArray = val);
1684
+ });
1685
+ }
1686
+ }
1687
+ } else if (Array.isArray(val) && Array.isArray(priorVal) && utils.isMongooseArray(val) && utils.isMongooseArray(priorVal)) {
1688
+ val[arrayAtomicsSymbol] = priorVal[arrayAtomicsSymbol];
1689
+ val[arrayAtomicsBackupSymbol] = priorVal[arrayAtomicsBackupSymbol];
1690
+ if (utils.isMongooseDocumentArray(val)) {
1691
+ val.forEach(doc => {
1692
+ if (doc != null) {
1693
+ doc.$isNew = false;
1694
+ }
1695
+ });
1696
+ }
1697
+ }
1698
+
1699
+ let obj = this._doc;
1700
+ let i = 0;
1701
+ const l = parts.length;
1702
+ let cur = '';
1703
+
1704
+ for (; i < l; i++) {
1705
+ const next = i + 1;
1706
+ const last = next === l;
1707
+ cur += (cur ? '.' + parts[i] : parts[i]);
1708
+ if (specialProperties.has(parts[i])) {
1709
+ return;
1710
+ }
1711
+
1712
+ if (last) {
1713
+ if (obj instanceof Map) {
1714
+ obj.set(parts[i], val);
1715
+ } else if (obj.$isSingleNested) {
1716
+ if (!(parts[i] in obj)) {
1717
+ obj[parts[i]] = val;
1718
+ obj._doc[parts[i]] = val;
1719
+ } else {
1720
+ obj._doc[parts[i]] = val;
1721
+ }
1722
+ } else {
1723
+ obj[parts[i]] = val;
1724
+ }
1725
+ } else {
1726
+ const isMap = obj instanceof Map;
1727
+ let value = isMap ? obj.get(parts[i]) : obj[parts[i]];
1728
+ if (utils.isPOJO(value)) {
1729
+ obj = value;
1730
+ } else if (value && value instanceof Embedded) {
1731
+ obj = value;
1732
+ } else if (value && !Array.isArray(value) && value.$isSingleNested) {
1733
+ obj = value;
1734
+ } else if (value && Array.isArray(value)) {
1735
+ obj = value;
1736
+ } else if (value == null) {
1737
+ value = {};
1738
+ if (isMap) {
1739
+ obj.set(parts[i], value);
1740
+ } else {
1741
+ obj[parts[i]] = value;
1742
+ }
1743
+ obj = value;
1744
+ } else {
1745
+ obj = value;
1746
+ }
1747
+ }
1748
+ }
1749
+ };
1750
+
1751
+ /**
1752
+ * Gets a raw value from a path (no getters)
1753
+ *
1754
+ * @param {String} path
1755
+ * @return {Any} Returns the value from the given `path`.
1756
+ * @api private
1757
+ */
1758
+
1759
+ Document.prototype.$__getValue = function(path) {
1760
+ return utils.getValue(path, this._doc);
1761
+ };
1762
+
1763
+ /**
1764
+ * Increments the numeric value at `path` by the given `val`.
1765
+ * When you call `save()` on this document, Mongoose will send a
1766
+ * [`$inc`](https://www.mongodb.com/docs/manual/reference/operator/update/inc/)
1767
+ * as opposed to a `$set`.
1768
+ *
1769
+ * #### Example:
1770
+ *
1771
+ * const schema = new Schema({ counter: Number });
1772
+ * const Test = db.model('Test', schema);
1773
+ *
1774
+ * const doc = await Test.create({ counter: 0 });
1775
+ * doc.$inc('counter', 2);
1776
+ * await doc.save(); // Sends a `{ $inc: { counter: 2 } }` to MongoDB
1777
+ * doc.counter; // 2
1778
+ *
1779
+ * doc.counter += 2;
1780
+ * await doc.save(); // Sends a `{ $set: { counter: 2 } }` to MongoDB
1781
+ *
1782
+ * @param {String|Array} path path or paths to update
1783
+ * @param {Number} val increment `path` by this value
1784
+ * @return {Document} this
1785
+ */
1786
+
1787
+ Document.prototype.$inc = function $inc(path, val) {
1788
+ if (val == null) {
1789
+ val = 1;
1790
+ }
1791
+
1792
+ if (Array.isArray(path)) {
1793
+ path.forEach((p) => this.$inc(p, val));
1794
+ return this;
1795
+ }
1796
+
1797
+ const schemaType = this.$__path(path);
1798
+ if (schemaType == null) {
1799
+ if (this.$__.strictMode === 'throw') {
1800
+ throw new StrictModeError(path);
1801
+ } else if (this.$__.strictMode === true) {
1802
+ return this;
1803
+ }
1804
+ } else if (schemaType.instance !== 'Number') {
1805
+ this.invalidate(path, new MongooseError.CastError(schemaType.instance, val, path));
1806
+ return this;
1807
+ }
1808
+
1809
+ const currentValue = this.$__getValue(path) || 0;
1810
+ let shouldSet = false;
1811
+ let valToSet = null;
1812
+ let valToInc = val;
1813
+
1814
+ try {
1815
+ val = schemaType.cast(val);
1816
+ valToSet = schemaType.applySetters(currentValue + val, this);
1817
+ valToInc = valToSet - currentValue;
1818
+ shouldSet = true;
1819
+ } catch (err) {
1820
+ this.invalidate(path, new MongooseError.CastError('number', val, path, err));
1821
+ }
1822
+
1823
+ if (shouldSet) {
1824
+ this.$__.primitiveAtomics = this.$__.primitiveAtomics || {};
1825
+ if (this.$__.primitiveAtomics[path] == null) {
1826
+ this.$__.primitiveAtomics[path] = { $inc: valToInc };
1827
+ } else {
1828
+ this.$__.primitiveAtomics[path].$inc += valToInc;
1829
+ }
1830
+ this.markModified(path);
1831
+ this.$__setValue(path, valToSet);
1832
+ }
1833
+
1834
+ return this;
1835
+ };
1836
+
1837
+ /**
1838
+ * Sets a raw value for a path (no casting, setters, transformations)
1839
+ *
1840
+ * @param {String} path
1841
+ * @param {Object} value
1842
+ * @return {Document} this
1843
+ * @api private
1844
+ */
1845
+
1846
+ Document.prototype.$__setValue = function(path, val) {
1847
+ utils.setValue(path, val, this._doc);
1848
+ return this;
1849
+ };
1850
+
1851
+ /**
1852
+ * Returns the value of a path.
1853
+ *
1854
+ * #### Example:
1855
+ *
1856
+ * // path
1857
+ * doc.get('age') // 47
1858
+ *
1859
+ * // dynamic casting to a string
1860
+ * doc.get('age', String) // "47"
1861
+ *
1862
+ * @param {String} path
1863
+ * @param {Schema|String|Number|Buffer|*} [type] optionally specify a type for on-the-fly attributes
1864
+ * @param {Object} [options]
1865
+ * @param {Boolean} [options.virtuals=false] Apply virtuals before getting this path
1866
+ * @param {Boolean} [options.getters=true] If false, skip applying getters and just get the raw value
1867
+ * @return {Any}
1868
+ * @api public
1869
+ */
1870
+
1871
+ Document.prototype.get = function(path, type, options) {
1872
+ let adhoc;
1873
+ if (options == null) {
1874
+ options = {};
1875
+ }
1876
+ if (type) {
1877
+ adhoc = this.$__schema.interpretAsType(path, type, this.$__schema.options);
1878
+ }
1879
+ const noDottedPath = options.noDottedPath;
1880
+
1881
+ // Fast path if we know we're just accessing top-level path on the document:
1882
+ // just get the schema path, avoid `$__path()` because that does string manipulation
1883
+ let schema = noDottedPath ? this.$__schema.paths[path] : this.$__path(path);
1884
+ if (schema == null) {
1885
+ schema = this.$__schema.virtualpath(path);
1886
+
1887
+ if (schema != null) {
1888
+ return schema.applyGetters(void 0, this);
1889
+ }
1890
+ }
1891
+
1892
+ if (noDottedPath) {
1893
+ let obj = this._doc[path];
1894
+ if (adhoc) {
1895
+ obj = adhoc.cast(obj);
1896
+ }
1897
+ if (schema != null && options.getters !== false) {
1898
+ return schema.applyGetters(obj, this);
1899
+ }
1900
+ return obj;
1901
+ }
1902
+
1903
+ if (schema != null && schema.instance === 'Mixed') {
1904
+ const virtual = this.$__schema.virtualpath(path);
1905
+ if (virtual != null) {
1906
+ schema = virtual;
1907
+ }
1908
+ }
1909
+
1910
+ const hasDot = path.indexOf('.') !== -1;
1911
+ let obj = this._doc;
1912
+
1913
+ const pieces = hasDot ? path.split('.') : [path];
1914
+ // Might need to change path for top-level alias
1915
+ if (typeof this.$__schema.aliases[pieces[0]] === 'string') {
1916
+ pieces[0] = this.$__schema.aliases[pieces[0]];
1917
+ }
1918
+
1919
+ for (let i = 0, l = pieces.length; i < l; i++) {
1920
+ if (obj && obj._doc) {
1921
+ obj = obj._doc;
1922
+ }
1923
+
1924
+ if (obj == null) {
1925
+ obj = void 0;
1926
+ } else if (obj instanceof Map) {
1927
+ obj = obj.get(pieces[i], { getters: false });
1928
+ } else if (i === l - 1) {
1929
+ obj = utils.getValue(pieces[i], obj);
1930
+ } else {
1931
+ obj = obj[pieces[i]];
1932
+ }
1933
+ }
1934
+
1935
+ if (adhoc) {
1936
+ obj = adhoc.cast(obj);
1937
+ }
1938
+
1939
+ if (schema != null && options.getters !== false) {
1940
+ obj = schema.applyGetters(obj, this);
1941
+ } else if (this.$__schema.nested[path] && options.virtuals) {
1942
+ // Might need to apply virtuals if this is a nested path
1943
+ return applyVirtuals(this, clone(obj) || {}, { path: path });
1944
+ }
1945
+
1946
+ return obj;
1947
+ };
1948
+
1949
+ /*!
1950
+ * ignore
1951
+ */
1952
+
1953
+ Document.prototype[getSymbol] = Document.prototype.get;
1954
+ Document.prototype.$get = Document.prototype.get;
1955
+
1956
+ /**
1957
+ * Returns the schematype for the given `path`.
1958
+ *
1959
+ * @param {String} path
1960
+ * @return {SchemaPath}
1961
+ * @api private
1962
+ * @method $__path
1963
+ * @memberOf Document
1964
+ * @instance
1965
+ */
1966
+
1967
+ Document.prototype.$__path = function(path) {
1968
+ const adhocs = this.$__.adhocPaths;
1969
+ const adhocType = adhocs && adhocs.hasOwnProperty(path) ? adhocs[path] : null;
1970
+
1971
+ if (adhocType) {
1972
+ return adhocType;
1973
+ }
1974
+ return this.$__schema.path(path);
1975
+ };
1976
+
1977
+ /**
1978
+ * Marks the path as having pending changes to write to the db.
1979
+ *
1980
+ * _Very helpful when using [Mixed](https://mongoosejs.com/docs/schematypes.html#mixed) types._
1981
+ *
1982
+ * #### Example:
1983
+ *
1984
+ * doc.mixed.type = 'changed';
1985
+ * doc.markModified('mixed.type');
1986
+ * doc.save() // changes to mixed.type are now persisted
1987
+ *
1988
+ * @param {String} path the path to mark modified
1989
+ * @param {Document} [scope] the scope to run validators with
1990
+ * @api public
1991
+ */
1992
+
1993
+ Document.prototype.markModified = function(path, scope) {
1994
+ this.$__saveInitialState(path);
1995
+
1996
+ this.$__.activePaths.modify(path);
1997
+ if (scope != null && !this.$isSubdocument) {
1998
+ this.$__.pathsToScopes = this.$__pathsToScopes || {};
1999
+ this.$__.pathsToScopes[path] = scope;
2000
+ }
2001
+ };
2002
+
2003
+ /*!
2004
+ * ignore
2005
+ */
2006
+
2007
+ Document.prototype.$__saveInitialState = function $__saveInitialState(path) {
2008
+ const savedState = this.$__.savedState;
2009
+ const savedStatePath = path;
2010
+ if (savedState != null) {
2011
+ const firstDot = savedStatePath.indexOf('.');
2012
+ const topLevelPath = firstDot === -1 ? savedStatePath : savedStatePath.slice(0, firstDot);
2013
+ if (!savedState.hasOwnProperty(topLevelPath)) {
2014
+ savedState[topLevelPath] = clone(this.$__getValue(topLevelPath));
2015
+ }
2016
+ }
2017
+ };
2018
+
2019
+ /**
2020
+ * Clears the modified state on the specified path.
2021
+ *
2022
+ * #### Example:
2023
+ *
2024
+ * doc.foo = 'bar';
2025
+ * doc.unmarkModified('foo');
2026
+ * doc.save(); // changes to foo will not be persisted
2027
+ *
2028
+ * @param {String} path the path to unmark modified
2029
+ * @api public
2030
+ */
2031
+
2032
+ Document.prototype.unmarkModified = function(path) {
2033
+ this.$__.activePaths.init(path);
2034
+ if (this.$__.pathsToScopes != null) {
2035
+ delete this.$__.pathsToScopes[path];
2036
+ }
2037
+ };
2038
+
2039
+ /**
2040
+ * Don't run validation on this path or persist changes to this path.
2041
+ *
2042
+ * #### Example:
2043
+ *
2044
+ * doc.foo = null;
2045
+ * doc.$ignore('foo');
2046
+ * doc.save(); // changes to foo will not be persisted and validators won't be run
2047
+ *
2048
+ * @memberOf Document
2049
+ * @instance
2050
+ * @method $ignore
2051
+ * @param {String} path the path to ignore
2052
+ * @api public
2053
+ */
2054
+
2055
+ Document.prototype.$ignore = function(path) {
2056
+ this.$__.activePaths.ignore(path);
2057
+ };
2058
+
2059
+ /**
2060
+ * Returns the list of paths that have been directly modified. A direct
2061
+ * modified path is a path that you explicitly set, whether via `doc.foo = 'bar'`,
2062
+ * `Object.assign(doc, { foo: 'bar' })`, or `doc.set('foo', 'bar')`.
2063
+ *
2064
+ * A path `a` may be in `modifiedPaths()` but not in `directModifiedPaths()`
2065
+ * because a child of `a` was directly modified.
2066
+ *
2067
+ * #### Example:
2068
+ *
2069
+ * const schema = new Schema({ foo: String, nested: { bar: String } });
2070
+ * const Model = mongoose.model('Test', schema);
2071
+ * await Model.create({ foo: 'original', nested: { bar: 'original' } });
2072
+ *
2073
+ * const doc = await Model.findOne();
2074
+ * doc.nested.bar = 'modified';
2075
+ * doc.directModifiedPaths(); // ['nested.bar']
2076
+ * doc.modifiedPaths(); // ['nested', 'nested.bar']
2077
+ *
2078
+ * @return {String[]}
2079
+ * @api public
2080
+ */
2081
+
2082
+ Document.prototype.directModifiedPaths = function() {
2083
+ return Object.keys(this.$__.activePaths.getStatePaths('modify'));
2084
+ };
2085
+
2086
+ /**
2087
+ * Returns true if the given path is nullish or only contains empty objects.
2088
+ * Useful for determining whether this subdoc will get stripped out by the
2089
+ * [minimize option](https://mongoosejs.com/docs/guide.html#minimize).
2090
+ *
2091
+ * #### Example:
2092
+ *
2093
+ * const schema = new Schema({ nested: { foo: String } });
2094
+ * const Model = mongoose.model('Test', schema);
2095
+ * const doc = new Model({});
2096
+ * doc.$isEmpty('nested'); // true
2097
+ * doc.nested.$isEmpty(); // true
2098
+ *
2099
+ * doc.nested.foo = 'bar';
2100
+ * doc.$isEmpty('nested'); // false
2101
+ * doc.nested.$isEmpty(); // false
2102
+ *
2103
+ * @param {String} [path]
2104
+ * @memberOf Document
2105
+ * @instance
2106
+ * @api public
2107
+ * @method $isEmpty
2108
+ * @return {Boolean}
2109
+ */
2110
+
2111
+ Document.prototype.$isEmpty = function(path) {
2112
+ const isEmptyOptions = {
2113
+ minimize: true,
2114
+ virtuals: false,
2115
+ getters: false,
2116
+ transform: false
2117
+ };
2118
+
2119
+ if (arguments.length !== 0) {
2120
+ const v = this.$get(path);
2121
+ if (v == null) {
2122
+ return true;
2123
+ }
2124
+ if (typeof v !== 'object') {
2125
+ return false;
2126
+ }
2127
+ if (utils.isPOJO(v)) {
2128
+ return _isEmpty(v);
2129
+ }
2130
+ return Object.keys(v.toObject(isEmptyOptions)).length === 0;
2131
+ }
2132
+
2133
+ return Object.keys(this.toObject(isEmptyOptions)).length === 0;
2134
+ };
2135
+
2136
+ /*!
2137
+ * ignore
2138
+ */
2139
+
2140
+ function _isEmpty(v) {
2141
+ if (v == null) {
2142
+ return true;
2143
+ }
2144
+ if (typeof v !== 'object' || Array.isArray(v)) {
2145
+ return false;
2146
+ }
2147
+ for (const key of Object.keys(v)) {
2148
+ if (!_isEmpty(v[key])) {
2149
+ return false;
2150
+ }
2151
+ }
2152
+ return true;
2153
+ }
2154
+
2155
+ /**
2156
+ * Returns the list of paths that have been modified.
2157
+ *
2158
+ * @param {Object} [options]
2159
+ * @param {Boolean} [options.includeChildren=false] if true, returns children of modified paths as well. For example, if false, the list of modified paths for `doc.colors = { primary: 'blue' };` will **not** contain `colors.primary`. If true, `modifiedPaths()` will return an array that contains `colors.primary`.
2160
+ * @return {String[]}
2161
+ * @api public
2162
+ */
2163
+
2164
+ Document.prototype.modifiedPaths = function(options) {
2165
+ options = options || {};
2166
+
2167
+ const directModifiedPaths = Object.keys(this.$__.activePaths.getStatePaths('modify'));
2168
+ const result = new Set();
2169
+
2170
+ let i = 0;
2171
+ let j = 0;
2172
+ const len = directModifiedPaths.length;
2173
+
2174
+ for (i = 0; i < len; ++i) {
2175
+ const path = directModifiedPaths[i];
2176
+ const parts = parentPaths(path);
2177
+ const pLen = parts.length;
2178
+
2179
+ for (j = 0; j < pLen; ++j) {
2180
+ result.add(parts[j]);
2181
+ }
2182
+
2183
+ if (!options.includeChildren) {
2184
+ continue;
2185
+ }
2186
+
2187
+ let ii = 0;
2188
+ let cur = this.$get(path);
2189
+ if (typeof cur === 'object' && cur !== null) {
2190
+ if (cur._doc) {
2191
+ cur = cur._doc;
2192
+ }
2193
+ const len = cur.length;
2194
+ if (Array.isArray(cur)) {
2195
+ for (ii = 0; ii < len; ++ii) {
2196
+ const subPath = path + '.' + ii;
2197
+ if (!result.has(subPath)) {
2198
+ result.add(subPath);
2199
+ if (cur[ii] != null && cur[ii].$__) {
2200
+ const modified = cur[ii].modifiedPaths();
2201
+ let iii = 0;
2202
+ const iiiLen = modified.length;
2203
+ for (iii = 0; iii < iiiLen; ++iii) {
2204
+ result.add(subPath + '.' + modified[iii]);
2205
+ }
2206
+ }
2207
+ }
2208
+ }
2209
+ } else {
2210
+ const keys = Object.keys(cur);
2211
+ let ii = 0;
2212
+ const len = keys.length;
2213
+ for (ii = 0; ii < len; ++ii) {
2214
+ result.add(path + '.' + keys[ii]);
2215
+ }
2216
+ }
2217
+ }
2218
+ }
2219
+ return Array.from(result);
2220
+ };
2221
+
2222
+ Document.prototype[documentModifiedPaths] = Document.prototype.modifiedPaths;
2223
+
2224
+ /**
2225
+ * Returns true if any of the given paths is modified, else false. If no arguments, returns `true` if any path
2226
+ * in this document is modified.
2227
+ *
2228
+ * If `path` is given, checks if a path or any full path containing `path` as part of its path chain has been modified.
2229
+ *
2230
+ * #### Example:
2231
+ *
2232
+ * doc.set('documents.0.title', 'changed');
2233
+ * doc.isModified() // true
2234
+ * doc.isModified('documents') // true
2235
+ * doc.isModified('documents.0.title') // true
2236
+ * doc.isModified('documents otherProp') // true
2237
+ * doc.isDirectModified('documents') // false
2238
+ *
2239
+ * @param {String} [path] optional
2240
+ * @param {Object} [options]
2241
+ * @param {Boolean} [options.ignoreAtomics=false] If true, doesn't return true if path is underneath an array that was modified with atomic operations like `push()`
2242
+ * @return {Boolean}
2243
+ * @api public
2244
+ */
2245
+
2246
+ Document.prototype.isModified = function(paths, options, modifiedPaths) {
2247
+ if (paths) {
2248
+ const ignoreAtomics = options && options.ignoreAtomics;
2249
+ const directModifiedPathsObj = this.$__.activePaths.states.modify;
2250
+ if (directModifiedPathsObj == null) {
2251
+ return false;
2252
+ }
2253
+
2254
+ if (typeof paths === 'string') {
2255
+ paths = paths.indexOf(' ') === -1 ? [paths] : paths.split(' ');
2256
+ }
2257
+
2258
+ for (const path of paths) {
2259
+ if (directModifiedPathsObj[path] != null) {
2260
+ return true;
2261
+ }
2262
+ }
2263
+
2264
+ const modified = modifiedPaths || this[documentModifiedPaths]();
2265
+ const isModifiedChild = paths.some(function(path) {
2266
+ return !!~modified.indexOf(path);
2267
+ });
2268
+
2269
+ let directModifiedPaths = Object.keys(directModifiedPathsObj);
2270
+ if (ignoreAtomics) {
2271
+ directModifiedPaths = directModifiedPaths.filter(path => {
2272
+ const value = this.$__getValue(path);
2273
+ if (value != null && value[arrayAtomicsSymbol] != null && value[arrayAtomicsSymbol].$set === undefined) {
2274
+ return false;
2275
+ }
2276
+ return true;
2277
+ });
2278
+ }
2279
+ return isModifiedChild || paths.some(function(path) {
2280
+ return directModifiedPaths.some(function(mod) {
2281
+ return mod === path || path.startsWith(mod + '.');
2282
+ });
2283
+ });
2284
+ }
2285
+
2286
+ return this.$__.activePaths.some('modify');
2287
+ };
2288
+
2289
+ /**
2290
+ * Alias of [`.isModified`](https://mongoosejs.com/docs/api/document.html#Document.prototype.isModified())
2291
+ *
2292
+ * @method $isModified
2293
+ * @memberOf Document
2294
+ * @api public
2295
+ */
2296
+
2297
+ Document.prototype.$isModified = Document.prototype.isModified;
2298
+
2299
+ Document.prototype[documentIsModified] = Document.prototype.isModified;
2300
+
2301
+ /**
2302
+ * Checks if a path is set to its default.
2303
+ *
2304
+ * #### Example:
2305
+ *
2306
+ * MyModel = mongoose.model('test', { name: { type: String, default: 'Val '} });
2307
+ * const m = new MyModel();
2308
+ * m.$isDefault('name'); // true
2309
+ *
2310
+ * @memberOf Document
2311
+ * @instance
2312
+ * @method $isDefault
2313
+ * @param {String} [path]
2314
+ * @return {Boolean}
2315
+ * @api public
2316
+ */
2317
+
2318
+ Document.prototype.$isDefault = function(path) {
2319
+ if (path == null) {
2320
+ return this.$__.activePaths.some('default');
2321
+ }
2322
+
2323
+ if (typeof path === 'string' && path.indexOf(' ') === -1) {
2324
+ return this.$__.activePaths.getStatePaths('default').hasOwnProperty(path);
2325
+ }
2326
+
2327
+ let paths = path;
2328
+ if (!Array.isArray(paths)) {
2329
+ paths = paths.split(' ');
2330
+ }
2331
+
2332
+ return paths.some(path => this.$__.activePaths.getStatePaths('default').hasOwnProperty(path));
2333
+ };
2334
+
2335
+ /**
2336
+ * Getter/setter, determines whether the document was removed or not.
2337
+ *
2338
+ * #### Example:
2339
+ *
2340
+ * const product = await product.remove();
2341
+ * product.$isDeleted(); // true
2342
+ * product.remove(); // no-op, doesn't send anything to the db
2343
+ *
2344
+ * product.$isDeleted(false);
2345
+ * product.$isDeleted(); // false
2346
+ * product.remove(); // will execute a remove against the db
2347
+ *
2348
+ *
2349
+ * @param {Boolean} [val] optional, overrides whether mongoose thinks the doc is deleted
2350
+ * @return {Boolean|Document} whether mongoose thinks this doc is deleted.
2351
+ * @method $isDeleted
2352
+ * @memberOf Document
2353
+ * @instance
2354
+ * @api public
2355
+ */
2356
+
2357
+ Document.prototype.$isDeleted = function(val) {
2358
+ if (arguments.length === 0) {
2359
+ return !!this.$__.isDeleted;
2360
+ }
2361
+
2362
+ this.$__.isDeleted = !!val;
2363
+ return this;
2364
+ };
2365
+
2366
+ /**
2367
+ * Returns true if `path` was directly set and modified, else false.
2368
+ *
2369
+ * #### Example:
2370
+ *
2371
+ * doc.set('documents.0.title', 'changed');
2372
+ * doc.isDirectModified('documents.0.title') // true
2373
+ * doc.isDirectModified('documents') // false
2374
+ *
2375
+ * @param {String|String[]} [path]
2376
+ * @return {Boolean}
2377
+ * @api public
2378
+ */
2379
+
2380
+ Document.prototype.isDirectModified = function(path) {
2381
+ if (path == null) {
2382
+ return this.$__.activePaths.some('modify');
2383
+ }
2384
+
2385
+ if (typeof path === 'string' && path.indexOf(' ') === -1) {
2386
+ const res = this.$__.activePaths.getStatePaths('modify').hasOwnProperty(path);
2387
+ if (res || path.indexOf('.') === -1) {
2388
+ return res;
2389
+ }
2390
+
2391
+ const pieces = path.split('.');
2392
+ for (let i = 0; i < pieces.length - 1; ++i) {
2393
+ const subpath = pieces.slice(0, i + 1).join('.');
2394
+ const subdoc = this.$get(subpath);
2395
+ if (subdoc != null && subdoc.$__ != null && subdoc.isDirectModified(pieces.slice(i + 1).join('.'))) {
2396
+ return true;
2397
+ }
2398
+ }
2399
+
2400
+ return false;
2401
+ }
2402
+
2403
+ let paths = path;
2404
+ if (typeof paths === 'string') {
2405
+ paths = paths.split(' ');
2406
+ }
2407
+
2408
+ return paths.some(path => this.isDirectModified(path));
2409
+ };
2410
+
2411
+ /**
2412
+ * Checks if `path` is in the `init` state, that is, it was set by `Document#init()` and not modified since.
2413
+ *
2414
+ * @param {String} [path]
2415
+ * @return {Boolean}
2416
+ * @api public
2417
+ */
2418
+
2419
+ Document.prototype.isInit = function(path) {
2420
+ if (path == null) {
2421
+ return this.$__.activePaths.some('init');
2422
+ }
2423
+
2424
+ if (typeof path === 'string' && path.indexOf(' ') === -1) {
2425
+ return this.$__.activePaths.getStatePaths('init').hasOwnProperty(path);
2426
+ }
2427
+
2428
+ let paths = path;
2429
+ if (!Array.isArray(paths)) {
2430
+ paths = paths.split(' ');
2431
+ }
2432
+
2433
+ return paths.some(path => this.$__.activePaths.getStatePaths('init').hasOwnProperty(path));
2434
+ };
2435
+
2436
+ /**
2437
+ * Checks if `path` was selected in the source query which initialized this document.
2438
+ *
2439
+ * #### Example:
2440
+ *
2441
+ * const doc = await Thing.findOne().select('name');
2442
+ * doc.isSelected('name') // true
2443
+ * doc.isSelected('age') // false
2444
+ *
2445
+ * @param {String|String[]} path
2446
+ * @return {Boolean}
2447
+ * @api public
2448
+ */
2449
+
2450
+ Document.prototype.isSelected = function isSelected(path) {
2451
+ if (this.$__.selected == null) {
2452
+ return true;
2453
+ }
2454
+ if (!path) {
2455
+ return false;
2456
+ }
2457
+ if (path === '_id') {
2458
+ return this.$__.selected._id !== 0;
2459
+ }
2460
+
2461
+ if (path.indexOf(' ') !== -1) {
2462
+ path = path.split(' ');
2463
+ }
2464
+ if (Array.isArray(path)) {
2465
+ return path.some(p => this.$__isSelected(p));
2466
+ }
2467
+
2468
+ const paths = Object.keys(this.$__.selected);
2469
+ let inclusive = null;
2470
+
2471
+ if (paths.length === 1 && paths[0] === '_id') {
2472
+ // only _id was selected.
2473
+ return this.$__.selected._id === 0;
2474
+ }
2475
+
2476
+ for (const cur of paths) {
2477
+ if (cur === '_id') {
2478
+ continue;
2479
+ }
2480
+ if (!isDefiningProjection(this.$__.selected[cur])) {
2481
+ continue;
2482
+ }
2483
+ inclusive = !!this.$__.selected[cur];
2484
+ break;
2485
+ }
2486
+
2487
+ if (inclusive === null) {
2488
+ return true;
2489
+ }
2490
+
2491
+ if (path in this.$__.selected) {
2492
+ return inclusive;
2493
+ }
2494
+
2495
+ const pathDot = path + '.';
2496
+
2497
+ for (const cur of paths) {
2498
+ if (cur === '_id') {
2499
+ continue;
2500
+ }
2501
+
2502
+ if (cur.startsWith(pathDot)) {
2503
+ return inclusive || cur !== pathDot;
2504
+ }
2505
+
2506
+ if (pathDot.startsWith(cur + '.')) {
2507
+ return inclusive;
2508
+ }
2509
+ }
2510
+ return !inclusive;
2511
+ };
2512
+
2513
+ Document.prototype.$__isSelected = Document.prototype.isSelected;
2514
+
2515
+ /**
2516
+ * Checks if `path` was explicitly selected. If no projection, always returns
2517
+ * true.
2518
+ *
2519
+ * #### Example:
2520
+ *
2521
+ * Thing.findOne().select('nested.name').exec(function (err, doc) {
2522
+ * doc.isDirectSelected('nested.name') // true
2523
+ * doc.isDirectSelected('nested.otherName') // false
2524
+ * doc.isDirectSelected('nested') // false
2525
+ * })
2526
+ *
2527
+ * @param {String} path
2528
+ * @return {Boolean}
2529
+ * @api public
2530
+ */
2531
+
2532
+ Document.prototype.isDirectSelected = function isDirectSelected(path) {
2533
+ if (this.$__.selected == null) {
2534
+ return true;
2535
+ }
2536
+
2537
+ if (path === '_id') {
2538
+ return this.$__.selected._id !== 0;
2539
+ }
2540
+
2541
+ if (path.indexOf(' ') !== -1) {
2542
+ path = path.split(' ');
2543
+ }
2544
+ if (Array.isArray(path)) {
2545
+ return path.some(p => this.isDirectSelected(p));
2546
+ }
2547
+
2548
+ const paths = Object.keys(this.$__.selected);
2549
+ let inclusive = null;
2550
+
2551
+ if (paths.length === 1 && paths[0] === '_id') {
2552
+ // only _id was selected.
2553
+ return this.$__.selected._id === 0;
2554
+ }
2555
+
2556
+ for (const cur of paths) {
2557
+ if (cur === '_id') {
2558
+ continue;
2559
+ }
2560
+ if (!isDefiningProjection(this.$__.selected[cur])) {
2561
+ continue;
2562
+ }
2563
+ inclusive = !!this.$__.selected[cur];
2564
+ break;
2565
+ }
2566
+
2567
+ if (inclusive === null) {
2568
+ return true;
2569
+ }
2570
+
2571
+ if (this.$__.selected.hasOwnProperty(path)) {
2572
+ return inclusive;
2573
+ }
2574
+
2575
+ return !inclusive;
2576
+ };
2577
+
2578
+ /**
2579
+ * Executes registered validation rules for this document.
2580
+ *
2581
+ * #### Note:
2582
+ *
2583
+ * This method is called `pre` save and if a validation rule is violated, [save](https://mongoosejs.com/docs/api/model.html#Model.prototype.save()) is aborted and the error is thrown.
2584
+ *
2585
+ * #### Example:
2586
+ *
2587
+ * await doc.validate({ validateModifiedOnly: false, pathsToSkip: ['name', 'email']});
2588
+ *
2589
+ * @param {Array|String} [pathsToValidate] list of paths to validate. If set, Mongoose will validate only the modified paths that are in the given list.
2590
+ * @param {Object} [options] internal options
2591
+ * @param {Boolean} [options.validateModifiedOnly=false] if `true` mongoose validates only modified paths.
2592
+ * @param {Array|string} [options.pathsToSkip] list of paths to skip. If set, Mongoose will validate every modified path that is not in this list.
2593
+ * @return {Promise} Returns a Promise.
2594
+ * @api public
2595
+ */
2596
+
2597
+ Document.prototype.validate = async function validate(pathsToValidate, options) {
2598
+ if (typeof pathsToValidate === 'function' || typeof options === 'function' || typeof arguments[2] === 'function') {
2599
+ throw new MongooseError('Document.prototype.validate() no longer accepts a callback');
2600
+ }
2601
+ let parallelValidate;
2602
+ this.$op = 'validate';
2603
+
2604
+ if (this.$isSubdocument != null) {
2605
+ // Skip parallel validate check for subdocuments
2606
+ } else if (this.$__.validating) {
2607
+ parallelValidate = new ParallelValidateError(this, {
2608
+ parentStack: options && options.parentStack,
2609
+ conflictStack: this.$__.validating.stack
2610
+ });
2611
+ } else {
2612
+ this.$__.validating = new ParallelValidateError(this, { parentStack: options && options.parentStack });
2613
+ }
2614
+
2615
+ if (arguments.length === 1) {
2616
+ if (typeof arguments[0] === 'object' && !Array.isArray(arguments[0])) {
2617
+ options = arguments[0];
2618
+ pathsToValidate = null;
2619
+ }
2620
+ }
2621
+ if (options && typeof options.pathsToSkip === 'string') {
2622
+ const isOnePathOnly = options.pathsToSkip.indexOf(' ') === -1;
2623
+ options.pathsToSkip = isOnePathOnly ? [options.pathsToSkip] : options.pathsToSkip.split(' ');
2624
+ }
2625
+
2626
+ if (parallelValidate != null) {
2627
+ throw parallelValidate;
2628
+ }
2629
+
2630
+ return new Promise((resolve, reject) => {
2631
+ this.$__validate(pathsToValidate, options, (error) => {
2632
+ this.$op = null;
2633
+ this.$__.validating = null;
2634
+ if (error != null) {
2635
+ return reject(error);
2636
+ }
2637
+ resolve();
2638
+ });
2639
+ });
2640
+ };
2641
+
2642
+ /**
2643
+ * Alias of [`.validate`](https://mongoosejs.com/docs/api/document.html#Document.prototype.validate())
2644
+ *
2645
+ * @method $validate
2646
+ * @memberOf Document
2647
+ * @api public
2648
+ */
2649
+
2650
+ Document.prototype.$validate = Document.prototype.validate;
2651
+
2652
+ /*!
2653
+ * ignore
2654
+ */
2655
+
2656
+ function _evaluateRequiredFunctions(doc) {
2657
+ const requiredFields = Object.keys(doc.$__.activePaths.getStatePaths('require'));
2658
+ let i = 0;
2659
+ const len = requiredFields.length;
2660
+ for (i = 0; i < len; ++i) {
2661
+ const path = requiredFields[i];
2662
+
2663
+ const p = doc.$__schema.path(path);
2664
+
2665
+ if (p != null && typeof p.originalRequiredValue === 'function') {
2666
+ doc.$__.cachedRequired = doc.$__.cachedRequired || {};
2667
+ try {
2668
+ doc.$__.cachedRequired[path] = p.originalRequiredValue.call(doc, doc);
2669
+ } catch (err) {
2670
+ doc.invalidate(path, err);
2671
+ }
2672
+ }
2673
+ }
2674
+ }
2675
+
2676
+ /*!
2677
+ * ignore
2678
+ */
2679
+
2680
+ function _getPathsToValidate(doc, pathsToValidate, pathsToSkip) {
2681
+ const doValidateOptions = {};
2682
+
2683
+ _evaluateRequiredFunctions(doc);
2684
+ // only validate required fields when necessary
2685
+ let paths = new Set(Object.keys(doc.$__.activePaths.getStatePaths('require')).filter(function(path) {
2686
+ if (!doc.$__isSelected(path) && !doc.$isModified(path)) {
2687
+ return false;
2688
+ }
2689
+ if (doc.$__.cachedRequired != null && path in doc.$__.cachedRequired) {
2690
+ return doc.$__.cachedRequired[path];
2691
+ }
2692
+ return true;
2693
+ }));
2694
+
2695
+ Object.keys(doc.$__.activePaths.getStatePaths('init')).forEach(addToPaths);
2696
+ Object.keys(doc.$__.activePaths.getStatePaths('modify')).forEach(addToPaths);
2697
+ Object.keys(doc.$__.activePaths.getStatePaths('default')).forEach(addToPaths);
2698
+ function addToPaths(p) { paths.add(p); }
2699
+
2700
+ const subdocs = doc.$getAllSubdocs();
2701
+ const modifiedPaths = doc.modifiedPaths();
2702
+ for (const subdoc of subdocs) {
2703
+ if (subdoc.$basePath) {
2704
+ const fullPathToSubdoc = subdoc.$isSingleNested ? subdoc.$__pathRelativeToParent() : subdoc.$__fullPathWithIndexes();
2705
+
2706
+ // Remove child paths for now, because we'll be validating the whole
2707
+ // subdoc.
2708
+ // The following is a faster take on looping through every path in `paths`
2709
+ // and checking if the path starts with `fullPathToSubdoc` re: gh-13191
2710
+ for (const modifiedPath of subdoc.modifiedPaths()) {
2711
+ paths.delete(fullPathToSubdoc + '.' + modifiedPath);
2712
+ }
2713
+
2714
+ if (doc.$isModified(fullPathToSubdoc, null, modifiedPaths) &&
2715
+ !doc.isDirectModified(fullPathToSubdoc) &&
2716
+ !doc.$isDefault(fullPathToSubdoc)) {
2717
+ paths.add(fullPathToSubdoc);
2718
+ if (doc.$__.pathsToScopes == null) {
2719
+ doc.$__.pathsToScopes = {};
2720
+ }
2721
+ doc.$__.pathsToScopes[fullPathToSubdoc] = subdoc.$isDocumentArrayElement ?
2722
+ subdoc.__parentArray :
2723
+ subdoc.$parent();
2724
+
2725
+ doValidateOptions[fullPathToSubdoc] = { skipSchemaValidators: true };
2726
+ if (subdoc.$isDocumentArrayElement && subdoc.__index != null) {
2727
+ doValidateOptions[fullPathToSubdoc].index = subdoc.__index;
2728
+ }
2729
+ }
2730
+ }
2731
+ }
2732
+
2733
+ for (const path of paths) {
2734
+ const _pathType = doc.$__schema.path(path);
2735
+ if (!_pathType) {
2736
+ continue;
2737
+ }
2738
+
2739
+ if (_pathType.$isMongooseDocumentArray) {
2740
+ for (const p of paths) {
2741
+ if (p == null || p.startsWith(_pathType.path + '.')) {
2742
+ paths.delete(p);
2743
+ }
2744
+ }
2745
+ }
2746
+
2747
+ // Optimization: if primitive path with no validators, or array of primitives
2748
+ // with no validators, skip validating this path entirely.
2749
+ if (!_pathType.caster && _pathType.validators.length === 0 && !_pathType.$parentSchemaDocArray) {
2750
+ paths.delete(path);
2751
+ } else if (_pathType.$isMongooseArray &&
2752
+ !_pathType.$isMongooseDocumentArray && // Skip document arrays...
2753
+ !_pathType.$embeddedSchemaType.$isMongooseArray && // and arrays of arrays
2754
+ _pathType.validators.length === 0 && // and arrays with top-level validators
2755
+ _pathType.$embeddedSchemaType.validators.length === 0) {
2756
+ paths.delete(path);
2757
+ }
2758
+ }
2759
+
2760
+ for (const path of paths) {
2761
+ // Single nested paths (paths embedded under single nested subdocs) will
2762
+ // be validated on their own when we call `validate()` on the subdoc itself.
2763
+ // Re: gh-8468
2764
+ if (doc.$__schema.singleNestedPaths.hasOwnProperty(path)) {
2765
+ paths.delete(path);
2766
+ continue;
2767
+ }
2768
+ }
2769
+
2770
+ if (Array.isArray(pathsToValidate)) {
2771
+ paths = _handlePathsToValidate(paths, pathsToValidate);
2772
+ } else if (Array.isArray(pathsToSkip)) {
2773
+ paths = _handlePathsToSkip(paths, pathsToSkip);
2774
+ }
2775
+
2776
+ // from here on we're not removing items from paths
2777
+
2778
+ // gh-661: if a whole array is modified, make sure to run validation on all
2779
+ // the children as well
2780
+ for (const path of paths) {
2781
+ const _pathType = doc.$__schema.path(path);
2782
+ if (!_pathType) {
2783
+ continue;
2784
+ }
2785
+
2786
+ if (!_pathType.$isMongooseArray ||
2787
+ // To avoid potential performance issues, skip doc arrays whose children
2788
+ // are not required. `getPositionalPathType()` may be slow, so avoid
2789
+ // it unless we have a case of #6364
2790
+ (!Array.isArray(_pathType) &&
2791
+ _pathType.$isMongooseDocumentArray &&
2792
+ !(_pathType && _pathType.schemaOptions && _pathType.schemaOptions.required))) {
2793
+ continue;
2794
+ }
2795
+
2796
+ // gh-11380: optimization. If the array isn't a document array and there's no validators
2797
+ // on the array type, there's no need to run validation on the individual array elements.
2798
+ if (_pathType.$isMongooseArray &&
2799
+ !_pathType.$isMongooseDocumentArray && // Skip document arrays...
2800
+ !_pathType.$embeddedSchemaType.$isMongooseArray && // and arrays of arrays
2801
+ _pathType.$embeddedSchemaType.validators.length === 0) {
2802
+ continue;
2803
+ }
2804
+
2805
+ const val = doc.$__getValue(path);
2806
+ _pushNestedArrayPaths(val, paths, path);
2807
+ }
2808
+
2809
+ function _pushNestedArrayPaths(val, paths, path) {
2810
+ if (val != null) {
2811
+ const numElements = val.length;
2812
+ for (let j = 0; j < numElements; ++j) {
2813
+ if (Array.isArray(val[j])) {
2814
+ _pushNestedArrayPaths(val[j], paths, path + '.' + j);
2815
+ } else {
2816
+ paths.add(path + '.' + j);
2817
+ }
2818
+ }
2819
+ }
2820
+ }
2821
+
2822
+ const flattenOptions = { skipArrays: true };
2823
+ for (const pathToCheck of paths) {
2824
+ if (doc.$__schema.nested[pathToCheck]) {
2825
+ let _v = doc.$__getValue(pathToCheck);
2826
+ if (isMongooseObject(_v)) {
2827
+ _v = _v.toObject({ transform: false });
2828
+ }
2829
+ const flat = flatten(_v, pathToCheck, flattenOptions, doc.$__schema);
2830
+ Object.keys(flat).forEach(addToPaths);
2831
+ }
2832
+ }
2833
+
2834
+ for (const path of paths) {
2835
+ const _pathType = doc.$__schema.path(path);
2836
+
2837
+ if (!_pathType) {
2838
+ continue;
2839
+ }
2840
+
2841
+ // If underneath a document array, may need to re-validate the parent
2842
+ // array re: gh-6818. Do this _after_ adding subpaths, because
2843
+ // we don't want to add every array subpath.
2844
+ if (_pathType.$parentSchemaDocArray && typeof _pathType.$parentSchemaDocArray.path === 'string') {
2845
+ paths.add(_pathType.$parentSchemaDocArray.path);
2846
+ }
2847
+
2848
+ if (!_pathType.$isSchemaMap) {
2849
+ continue;
2850
+ }
2851
+
2852
+ const val = doc.$__getValue(path);
2853
+ if (val == null) {
2854
+ continue;
2855
+ }
2856
+ for (const key of val.keys()) {
2857
+ paths.add(path + '.' + key);
2858
+ }
2859
+ }
2860
+
2861
+ paths = Array.from(paths);
2862
+ return [paths, doValidateOptions];
2863
+ }
2864
+
2865
+ /*!
2866
+ * ignore
2867
+ */
2868
+
2869
+ Document.prototype.$__validate = function(pathsToValidate, options, callback) {
2870
+ if (typeof pathsToValidate === 'function') {
2871
+ callback = pathsToValidate;
2872
+ options = null;
2873
+ pathsToValidate = null;
2874
+ } else if (typeof options === 'function') {
2875
+ callback = options;
2876
+ options = null;
2877
+ }
2878
+
2879
+ const hasValidateModifiedOnlyOption = options &&
2880
+ (typeof options === 'object') &&
2881
+ ('validateModifiedOnly' in options);
2882
+
2883
+ const pathsToSkip = (options && options.pathsToSkip) || null;
2884
+
2885
+ let shouldValidateModifiedOnly;
2886
+ if (hasValidateModifiedOnlyOption) {
2887
+ shouldValidateModifiedOnly = !!options.validateModifiedOnly;
2888
+ } else {
2889
+ shouldValidateModifiedOnly = this.$__schema.options.validateModifiedOnly;
2890
+ }
2891
+
2892
+ const _this = this;
2893
+ const _complete = () => {
2894
+ let validationError = this.$__.validationError;
2895
+ this.$__.validationError = null;
2896
+ this.$__.validating = null;
2897
+
2898
+ if (shouldValidateModifiedOnly && validationError != null) {
2899
+ // Remove any validation errors that aren't from modified paths
2900
+ const errors = Object.keys(validationError.errors);
2901
+ for (const errPath of errors) {
2902
+ if (!this.$isModified(errPath)) {
2903
+ delete validationError.errors[errPath];
2904
+ }
2905
+ }
2906
+ if (Object.keys(validationError.errors).length === 0) {
2907
+ validationError = void 0;
2908
+ }
2909
+ }
2910
+
2911
+ this.$__.cachedRequired = {};
2912
+ this.$emit('validate', _this);
2913
+ this.constructor.emit('validate', _this);
2914
+
2915
+ if (validationError) {
2916
+ for (const key in validationError.errors) {
2917
+ // Make sure cast errors persist
2918
+ if (!this[documentArrayParent] &&
2919
+ validationError.errors[key] instanceof MongooseError.CastError) {
2920
+ this.invalidate(key, validationError.errors[key]);
2921
+ }
2922
+ }
2923
+
2924
+ return validationError;
2925
+ }
2926
+ };
2927
+
2928
+ // only validate required fields when necessary
2929
+ const pathDetails = _getPathsToValidate(this, pathsToValidate, pathsToSkip);
2930
+ const paths = shouldValidateModifiedOnly ?
2931
+ pathDetails[0].filter((path) => this.$isModified(path)) :
2932
+ pathDetails[0];
2933
+ const doValidateOptionsByPath = pathDetails[1];
2934
+ if (typeof pathsToValidate === 'string') {
2935
+ pathsToValidate = pathsToValidate.split(' ');
2936
+ }
2937
+
2938
+ if (paths.length === 0) {
2939
+ return immediate(function() {
2940
+ const error = _complete();
2941
+ if (error) {
2942
+ return _this.$__schema.s.hooks.execPost('validate:error', _this, [_this], { error: error }, function(error) {
2943
+ callback(error);
2944
+ });
2945
+ }
2946
+ callback(null, _this);
2947
+ });
2948
+ }
2949
+
2950
+ const validated = {};
2951
+ let total = 0;
2952
+
2953
+ for (const path of paths) {
2954
+ validatePath(path);
2955
+ }
2956
+
2957
+ function validatePath(path) {
2958
+ if (path == null || validated[path]) {
2959
+ return;
2960
+ }
2961
+
2962
+ validated[path] = true;
2963
+ total++;
2964
+
2965
+ immediate(function() {
2966
+ const schemaType = _this.$__schema.path(path);
2967
+
2968
+ if (!schemaType) {
2969
+ return --total || complete();
2970
+ }
2971
+
2972
+ // If user marked as invalid or there was a cast error, don't validate
2973
+ if (!_this.$isValid(path)) {
2974
+ --total || complete();
2975
+ return;
2976
+ }
2977
+
2978
+ // If setting a path under a mixed path, avoid using the mixed path validator (gh-10141)
2979
+ if (schemaType[schemaMixedSymbol] != null && path !== schemaType.path) {
2980
+ return --total || complete();
2981
+ }
2982
+
2983
+ let val = _this.$__getValue(path);
2984
+
2985
+ // If you `populate()` and get back a null value, required validators
2986
+ // shouldn't fail (gh-8018). We should always fall back to the populated
2987
+ // value.
2988
+ let pop;
2989
+ if ((pop = _this.$populated(path))) {
2990
+ val = pop;
2991
+ } else if (val != null && val.$__ != null && val.$__.wasPopulated) {
2992
+ // Array paths, like `somearray.1`, do not show up as populated with `$populated()`,
2993
+ // so in that case pull out the document's id
2994
+ val = val._id;
2995
+ }
2996
+ const scope = _this.$__.pathsToScopes != null && path in _this.$__.pathsToScopes ?
2997
+ _this.$__.pathsToScopes[path] :
2998
+ _this;
2999
+
3000
+ const doValidateOptions = {
3001
+ ...doValidateOptionsByPath[path],
3002
+ path: path,
3003
+ validateModifiedOnly: shouldValidateModifiedOnly
3004
+ };
3005
+
3006
+ schemaType.doValidate(val, function(err) {
3007
+ if (err) {
3008
+ const isSubdoc = schemaType.$isSingleNested ||
3009
+ schemaType.$isArraySubdocument ||
3010
+ schemaType.$isMongooseDocumentArray;
3011
+ if (isSubdoc && err instanceof ValidationError) {
3012
+ return --total || complete();
3013
+ }
3014
+ _this.invalidate(path, err, undefined, true);
3015
+ }
3016
+ --total || complete();
3017
+ }, scope, doValidateOptions);
3018
+ });
3019
+ }
3020
+
3021
+ function complete() {
3022
+ const error = _complete();
3023
+ if (error) {
3024
+ return _this.$__schema.s.hooks.execPost('validate:error', _this, [_this], { error: error }, function(error) {
3025
+ callback(error);
3026
+ });
3027
+ }
3028
+ callback(null, _this);
3029
+ }
3030
+
3031
+ };
3032
+
3033
+ /*!
3034
+ * ignore
3035
+ */
3036
+
3037
+ function _handlePathsToValidate(paths, pathsToValidate) {
3038
+ const _pathsToValidate = new Set(pathsToValidate);
3039
+ const parentPaths = new Map([]);
3040
+ for (const path of pathsToValidate) {
3041
+ if (path.indexOf('.') === -1) {
3042
+ continue;
3043
+ }
3044
+ const pieces = path.split('.');
3045
+ let cur = pieces[0];
3046
+ for (let i = 1; i < pieces.length; ++i) {
3047
+ // Since we skip subpaths under single nested subdocs to
3048
+ // avoid double validation, we need to add back the
3049
+ // single nested subpath if the user asked for it (gh-8626)
3050
+ parentPaths.set(cur, path);
3051
+ cur = cur + '.' + pieces[i];
3052
+ }
3053
+ }
3054
+
3055
+ const ret = new Set();
3056
+ for (const path of paths) {
3057
+ if (_pathsToValidate.has(path)) {
3058
+ ret.add(path);
3059
+ } else if (parentPaths.has(path)) {
3060
+ ret.add(parentPaths.get(path));
3061
+ }
3062
+ }
3063
+ return ret;
3064
+ }
3065
+
3066
+ /*!
3067
+ * ignore
3068
+ */
3069
+
3070
+ function _handlePathsToSkip(paths, pathsToSkip) {
3071
+ pathsToSkip = new Set(pathsToSkip);
3072
+ paths = Array.from(paths).filter(p => !pathsToSkip.has(p));
3073
+ return new Set(paths);
3074
+ }
3075
+
3076
+ /**
3077
+ * Executes registered validation rules (skipping asynchronous validators) for this document.
3078
+ *
3079
+ * #### Note:
3080
+ *
3081
+ * This method is useful if you need synchronous validation.
3082
+ *
3083
+ * #### Example:
3084
+ *
3085
+ * const err = doc.validateSync();
3086
+ * if (err) {
3087
+ * handleError(err);
3088
+ * } else {
3089
+ * // validation passed
3090
+ * }
3091
+ *
3092
+ * @param {Array|string} [pathsToValidate] only validate the given paths
3093
+ * @param {Object} [options] options for validation
3094
+ * @param {Boolean} [options.validateModifiedOnly=false] If `true`, Mongoose will only validate modified paths, as opposed to modified paths and `required` paths.
3095
+ * @param {Array|string} [options.pathsToSkip] list of paths to skip. If set, Mongoose will validate every modified path that is not in this list.
3096
+ * @return {ValidationError|undefined} ValidationError if there are errors during validation, or undefined if there is no error.
3097
+ * @api public
3098
+ */
3099
+
3100
+ Document.prototype.validateSync = function(pathsToValidate, options) {
3101
+ const _this = this;
3102
+
3103
+ if (arguments.length === 1 && typeof arguments[0] === 'object' && !Array.isArray(arguments[0])) {
3104
+ options = arguments[0];
3105
+ pathsToValidate = null;
3106
+ }
3107
+
3108
+ const hasValidateModifiedOnlyOption = options &&
3109
+ (typeof options === 'object') &&
3110
+ ('validateModifiedOnly' in options);
3111
+
3112
+ let shouldValidateModifiedOnly;
3113
+ if (hasValidateModifiedOnlyOption) {
3114
+ shouldValidateModifiedOnly = !!options.validateModifiedOnly;
3115
+ } else {
3116
+ shouldValidateModifiedOnly = this.$__schema.options.validateModifiedOnly;
3117
+ }
3118
+
3119
+ let pathsToSkip = options && options.pathsToSkip;
3120
+
3121
+ if (typeof pathsToValidate === 'string') {
3122
+ const isOnePathOnly = pathsToValidate.indexOf(' ') === -1;
3123
+ pathsToValidate = isOnePathOnly ? [pathsToValidate] : pathsToValidate.split(' ');
3124
+ } else if (typeof pathsToSkip === 'string' && pathsToSkip.indexOf(' ') !== -1) {
3125
+ pathsToSkip = pathsToSkip.split(' ');
3126
+ }
3127
+
3128
+ // only validate required fields when necessary
3129
+ const pathDetails = _getPathsToValidate(this, pathsToValidate, pathsToSkip);
3130
+ const paths = shouldValidateModifiedOnly ?
3131
+ pathDetails[0].filter((path) => this.$isModified(path)) :
3132
+ pathDetails[0];
3133
+ const skipSchemaValidators = pathDetails[1];
3134
+
3135
+ const validating = {};
3136
+
3137
+ for (let i = 0, len = paths.length; i < len; ++i) {
3138
+ const path = paths[i];
3139
+
3140
+ if (validating[path]) {
3141
+ continue;
3142
+ }
3143
+
3144
+ validating[path] = true;
3145
+
3146
+ const p = _this.$__schema.path(path);
3147
+ if (!p) {
3148
+ continue;
3149
+ }
3150
+ if (!_this.$isValid(path)) {
3151
+ continue;
3152
+ }
3153
+
3154
+ const val = _this.$__getValue(path);
3155
+ const err = p.doValidateSync(val, _this, {
3156
+ skipSchemaValidators: skipSchemaValidators[path],
3157
+ path: path,
3158
+ validateModifiedOnly: shouldValidateModifiedOnly
3159
+ });
3160
+ if (err) {
3161
+ const isSubdoc = p.$isSingleNested ||
3162
+ p.$isArraySubdocument ||
3163
+ p.$isMongooseDocumentArray;
3164
+ if (isSubdoc && err instanceof ValidationError) {
3165
+ continue;
3166
+ }
3167
+ _this.invalidate(path, err, undefined, true);
3168
+ }
3169
+ }
3170
+
3171
+ const err = _this.$__.validationError;
3172
+ _this.$__.validationError = undefined;
3173
+ _this.$emit('validate', _this);
3174
+ _this.constructor.emit('validate', _this);
3175
+
3176
+ if (err) {
3177
+ for (const key in err.errors) {
3178
+ // Make sure cast errors persist
3179
+ if (err.errors[key] instanceof MongooseError.CastError) {
3180
+ _this.invalidate(key, err.errors[key]);
3181
+ }
3182
+ }
3183
+ }
3184
+
3185
+ return err;
3186
+ };
3187
+
3188
+ /**
3189
+ * Marks a path as invalid, causing validation to fail.
3190
+ *
3191
+ * The `errorMsg` argument will become the message of the `ValidationError`.
3192
+ *
3193
+ * The `value` argument (if passed) will be available through the `ValidationError.value` property.
3194
+ *
3195
+ * doc.invalidate('size', 'must be less than 20', 14);
3196
+ *
3197
+ * doc.validate(function (err) {
3198
+ * console.log(err)
3199
+ * // prints
3200
+ * { message: 'Validation failed',
3201
+ * name: 'ValidationError',
3202
+ * errors:
3203
+ * { size:
3204
+ * { message: 'must be less than 20',
3205
+ * name: 'ValidatorError',
3206
+ * path: 'size',
3207
+ * type: 'user defined',
3208
+ * value: 14 } } }
3209
+ * })
3210
+ *
3211
+ * @param {String} path the field to invalidate. For array elements, use the `array.i.field` syntax, where `i` is the 0-based index in the array.
3212
+ * @param {String|Error} err the error which states the reason `path` was invalid
3213
+ * @param {Object|String|Number|any} val optional invalid value
3214
+ * @param {String} [kind] optional `kind` property for the error
3215
+ * @return {ValidationError} the current ValidationError, with all currently invalidated paths
3216
+ * @api public
3217
+ */
3218
+
3219
+ Document.prototype.invalidate = function(path, err, val, kind) {
3220
+ if (!this.$__.validationError) {
3221
+ this.$__.validationError = new ValidationError(this);
3222
+ }
3223
+
3224
+ if (this.$__.validationError.errors[path]) {
3225
+ return;
3226
+ }
3227
+
3228
+ if (!err || typeof err === 'string') {
3229
+ err = new ValidatorError({
3230
+ path: path,
3231
+ message: err,
3232
+ type: kind || 'user defined',
3233
+ value: val
3234
+ });
3235
+ }
3236
+
3237
+ if (this.$__.validationError === err) {
3238
+ return this.$__.validationError;
3239
+ }
3240
+
3241
+ this.$__.validationError.addError(path, err);
3242
+ return this.$__.validationError;
3243
+ };
3244
+
3245
+ /**
3246
+ * Marks a path as valid, removing existing validation errors.
3247
+ *
3248
+ * @param {String} path the field to mark as valid
3249
+ * @api public
3250
+ * @memberOf Document
3251
+ * @instance
3252
+ * @method $markValid
3253
+ */
3254
+
3255
+ Document.prototype.$markValid = function(path) {
3256
+ if (!this.$__.validationError || !this.$__.validationError.errors[path]) {
3257
+ return;
3258
+ }
3259
+
3260
+ delete this.$__.validationError.errors[path];
3261
+ if (Object.keys(this.$__.validationError.errors).length === 0) {
3262
+ this.$__.validationError = null;
3263
+ }
3264
+ };
3265
+
3266
+ /*!
3267
+ * ignore
3268
+ */
3269
+
3270
+ function _markValidSubpaths(doc, path) {
3271
+ if (!doc.$__.validationError) {
3272
+ return;
3273
+ }
3274
+
3275
+ const keys = Object.keys(doc.$__.validationError.errors);
3276
+ for (const key of keys) {
3277
+ if (key.startsWith(path + '.')) {
3278
+ delete doc.$__.validationError.errors[key];
3279
+ }
3280
+ }
3281
+ if (Object.keys(doc.$__.validationError.errors).length === 0) {
3282
+ doc.$__.validationError = null;
3283
+ }
3284
+ }
3285
+
3286
+ /*!
3287
+ * ignore
3288
+ */
3289
+
3290
+ function _checkImmutableSubpaths(subdoc, schematype, priorVal) {
3291
+ const schema = schematype.schema;
3292
+ if (schema == null) {
3293
+ return;
3294
+ }
3295
+
3296
+ for (const key of Object.keys(schema.paths)) {
3297
+ const path = schema.paths[key];
3298
+ if (path.$immutableSetter == null) {
3299
+ continue;
3300
+ }
3301
+ const oldVal = priorVal == null ? void 0 : priorVal.$__getValue(key);
3302
+ // Calling immutableSetter with `oldVal` even though it expects `newVal`
3303
+ // is intentional. That's because `$immutableSetter` compares its param
3304
+ // to the current value.
3305
+ path.$immutableSetter.call(subdoc, oldVal);
3306
+ }
3307
+ }
3308
+
3309
+ /**
3310
+ * Saves this document by inserting a new document into the database if [document.isNew](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()) is `true`,
3311
+ * or sends an [updateOne](https://mongoosejs.com/docs/api/document.html#Document.prototype.updateOne()) operation **only** with the modifications to the database, it does not replace the whole document in the latter case.
3312
+ *
3313
+ * #### Example:
3314
+ *
3315
+ * product.sold = Date.now();
3316
+ * product = await product.save();
3317
+ *
3318
+ * If save is successful, the returned promise will fulfill with the document
3319
+ * saved.
3320
+ *
3321
+ * #### Example:
3322
+ *
3323
+ * const newProduct = await product.save();
3324
+ * newProduct === product; // true
3325
+ *
3326
+ * @param {Object} [options] options optional options
3327
+ * @param {Session} [options.session=null] the [session](https://www.mongodb.com/docs/manual/reference/server-sessions/) associated with this save operation. If not specified, defaults to the [document's associated session](https://mongoosejs.com/docs/api/document.html#Document.prototype.$session()).
3328
+ * @param {Object} [options.safe] (DEPRECATED) overrides [schema's safe option](https://mongoosejs.com/docs/guide.html#safe). Use the `w` option instead.
3329
+ * @param {Boolean} [options.validateBeforeSave] set to false to save without validating.
3330
+ * @param {Boolean} [options.validateModifiedOnly=false] If `true`, Mongoose will only validate modified paths, as opposed to modified paths and `required` paths.
3331
+ * @param {Number|String} [options.w] set the [write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#w-option). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern)
3332
+ * @param {Boolean} [options.j] set to true for MongoDB to wait until this `save()` has been [journaled before resolving the returned promise](https://www.mongodb.com/docs/manual/reference/write-concern/#j-option). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern)
3333
+ * @param {Number} [options.wtimeout] sets a [timeout for the write concern](https://www.mongodb.com/docs/manual/reference/write-concern/#wtimeout). Overrides the [schema-level `writeConcern` option](https://mongoosejs.com/docs/guide.html#writeConcern).
3334
+ * @param {Boolean} [options.checkKeys=true] the MongoDB driver prevents you from saving keys that start with '$' or contain '.' by default. Set this option to `false` to skip that check. See [restrictions on field names](https://www.mongodb.com/docs/manual/reference/limits/#Restrictions-on-Field-Names)
3335
+ * @param {Boolean} [options.timestamps=true] if `false` and [timestamps](https://mongoosejs.com/docs/guide.html#timestamps) are enabled, skip timestamps for this `save()`.
3336
+ * @param {Function} [fn] optional callback
3337
+ * @method save
3338
+ * @memberOf Document
3339
+ * @instance
3340
+ * @throws {DocumentNotFoundError} if this [save updates an existing document](https://mongoosejs.com/docs/api/document.html#Document.prototype.isNew()) but the document doesn't exist in the database. For example, you will get this error if the document is [deleted between when you retrieved the document and when you saved it](documents.html#updating).
3341
+ * @return {Promise|undefined} Returns undefined if used with callback or a Promise otherwise.
3342
+ * @api public
3343
+ * @see middleware https://mongoosejs.com/docs/middleware.html
3344
+ */
3345
+
3346
+ /**
3347
+ * Checks if a path is invalid
3348
+ *
3349
+ * @param {String|String[]} [path] the field to check. If unset will always return "false"
3350
+ * @method $isValid
3351
+ * @memberOf Document
3352
+ * @instance
3353
+ * @api private
3354
+ */
3355
+
3356
+ Document.prototype.$isValid = function(path) {
3357
+ if (this.$__.validationError == null || Object.keys(this.$__.validationError.errors).length === 0) {
3358
+ return true;
3359
+ }
3360
+ if (path == null) {
3361
+ return false;
3362
+ }
3363
+
3364
+ if (path.indexOf(' ') !== -1) {
3365
+ path = path.split(' ');
3366
+ }
3367
+ if (Array.isArray(path)) {
3368
+ return path.some(p => this.$__.validationError.errors[p] == null);
3369
+ }
3370
+
3371
+ return this.$__.validationError.errors[path] == null;
3372
+ };
3373
+
3374
+ /**
3375
+ * Resets the internal modified state of this document.
3376
+ *
3377
+ * @api private
3378
+ * @return {Document} this
3379
+ * @method $__reset
3380
+ * @memberOf Document
3381
+ * @instance
3382
+ */
3383
+
3384
+ Document.prototype.$__reset = function reset() {
3385
+ let _this = this;
3386
+
3387
+ // Skip for subdocuments
3388
+ const subdocs = this.$parent() === this ? this.$getAllSubdocs() : [];
3389
+ const resetArrays = new Set();
3390
+ for (const subdoc of subdocs) {
3391
+ const fullPathWithIndexes = subdoc.$__fullPathWithIndexes();
3392
+ subdoc.$__reset();
3393
+ if (this.isModified(fullPathWithIndexes) || isParentInit(fullPathWithIndexes)) {
3394
+ if (subdoc.$isDocumentArrayElement) {
3395
+ resetArrays.add(subdoc.parentArray());
3396
+ } else {
3397
+ const parent = subdoc.$parent();
3398
+ if (parent === this) {
3399
+ this.$__.activePaths.clearPath(subdoc.$basePath);
3400
+ } else if (parent != null && parent.$isSubdocument) {
3401
+ // If map path underneath subdocument, may end up with a case where
3402
+ // map path is modified but parent still needs to be reset. See gh-10295
3403
+ parent.$__reset();
3404
+ }
3405
+ }
3406
+ }
3407
+ }
3408
+
3409
+ for (const array of resetArrays) {
3410
+ this.$__.activePaths.clearPath(array.$path());
3411
+ array[arrayAtomicsBackupSymbol] = array[arrayAtomicsSymbol];
3412
+ array[arrayAtomicsSymbol] = {};
3413
+ }
3414
+
3415
+ function isParentInit(path) {
3416
+ path = path.indexOf('.') === -1 ? [path] : path.split('.');
3417
+ let cur = '';
3418
+ for (let i = 0; i < path.length; ++i) {
3419
+ cur += (cur.length ? '.' : '') + path[i];
3420
+ if (_this.$__.activePaths[cur] === 'init') {
3421
+ return true;
3422
+ }
3423
+ }
3424
+
3425
+ return false;
3426
+ }
3427
+
3428
+ // clear atomics
3429
+ this.$__dirty().forEach(function(dirt) {
3430
+ const type = dirt.value;
3431
+
3432
+ if (type && type[arrayAtomicsSymbol]) {
3433
+ type[arrayAtomicsBackupSymbol] = type[arrayAtomicsSymbol];
3434
+ type[arrayAtomicsSymbol] = {};
3435
+ }
3436
+ });
3437
+
3438
+ this.$__.backup = {};
3439
+ this.$__.backup.activePaths = {
3440
+ modify: Object.assign({}, this.$__.activePaths.getStatePaths('modify')),
3441
+ default: Object.assign({}, this.$__.activePaths.getStatePaths('default'))
3442
+ };
3443
+ this.$__.backup.validationError = this.$__.validationError;
3444
+ this.$__.backup.errors = this.$errors;
3445
+
3446
+ // Clear 'dirty' cache
3447
+ this.$__.activePaths.clear('modify');
3448
+ this.$__.activePaths.clear('default');
3449
+ this.$__.validationError = undefined;
3450
+ this.$errors = undefined;
3451
+ _this = this;
3452
+ this.$__schema.requiredPaths().forEach(function(path) {
3453
+ _this.$__.activePaths.require(path);
3454
+ });
3455
+
3456
+ return this;
3457
+ };
3458
+
3459
+ /*!
3460
+ * ignore
3461
+ */
3462
+
3463
+ Document.prototype.$__undoReset = function $__undoReset() {
3464
+ if (this.$__.backup == null || this.$__.backup.activePaths == null) {
3465
+ return;
3466
+ }
3467
+
3468
+ this.$__.activePaths.states.modify = this.$__.backup.activePaths.modify;
3469
+ this.$__.activePaths.states.default = this.$__.backup.activePaths.default;
3470
+
3471
+ this.$__.validationError = this.$__.backup.validationError;
3472
+ this.$errors = this.$__.backup.errors;
3473
+
3474
+ for (const dirt of this.$__dirty()) {
3475
+ const type = dirt.value;
3476
+
3477
+ if (type && type[arrayAtomicsSymbol] && type[arrayAtomicsBackupSymbol]) {
3478
+ type[arrayAtomicsSymbol] = type[arrayAtomicsBackupSymbol];
3479
+ }
3480
+ }
3481
+
3482
+ for (const subdoc of this.$getAllSubdocs()) {
3483
+ subdoc.$__undoReset();
3484
+ }
3485
+ };
3486
+
3487
+ /**
3488
+ * Returns this documents dirty paths / vals.
3489
+ *
3490
+ * @return {Array}
3491
+ * @api private
3492
+ * @method $__dirty
3493
+ * @memberOf Document
3494
+ * @instance
3495
+ */
3496
+
3497
+ Document.prototype.$__dirty = function() {
3498
+ const _this = this;
3499
+ let all = this.$__.activePaths.map('modify', function(path) {
3500
+ return {
3501
+ path: path,
3502
+ value: _this.$__getValue(path),
3503
+ schema: _this.$__path(path)
3504
+ };
3505
+ });
3506
+
3507
+ // gh-2558: if we had to set a default and the value is not undefined,
3508
+ // we have to save as well
3509
+ all = all.concat(this.$__.activePaths.map('default', function(path) {
3510
+ if (path === '_id' || _this.$__getValue(path) == null) {
3511
+ return;
3512
+ }
3513
+ return {
3514
+ path: path,
3515
+ value: _this.$__getValue(path),
3516
+ schema: _this.$__path(path)
3517
+ };
3518
+ }));
3519
+
3520
+ const allPaths = new Map(all.filter((el) => el != null).map((el) => [el.path, el.value]));
3521
+ // Ignore "foo.a" if "foo" is dirty already.
3522
+ const minimal = [];
3523
+
3524
+ all.forEach(function(item) {
3525
+ if (!item) {
3526
+ return;
3527
+ }
3528
+
3529
+ let top = null;
3530
+
3531
+ const array = parentPaths(item.path);
3532
+ for (let i = 0; i < array.length - 1; i++) {
3533
+ if (allPaths.has(array[i])) {
3534
+ top = allPaths.get(array[i]);
3535
+ break;
3536
+ }
3537
+ }
3538
+ if (top == null) {
3539
+ minimal.push(item);
3540
+ } else if (top != null &&
3541
+ top[arrayAtomicsSymbol] != null &&
3542
+ top.hasAtomics()) {
3543
+ // special case for top level MongooseArrays
3544
+ // the `top` array itself and a sub path of `top` are being set.
3545
+ // the only way to honor all of both modifications is through a $set
3546
+ // of entire array.
3547
+ top[arrayAtomicsSymbol] = {};
3548
+ top[arrayAtomicsSymbol].$set = top;
3549
+ }
3550
+ });
3551
+ return minimal;
3552
+ };
3553
+
3554
+ /**
3555
+ * Assigns/compiles `schema` into this documents prototype.
3556
+ *
3557
+ * @param {Schema} schema
3558
+ * @api private
3559
+ * @method $__setSchema
3560
+ * @memberOf Document
3561
+ * @instance
3562
+ */
3563
+
3564
+ Document.prototype.$__setSchema = function(schema) {
3565
+ compile(schema.tree, this, undefined, schema.options);
3566
+
3567
+ // Apply default getters if virtual doesn't have any (gh-6262)
3568
+ for (const key of Object.keys(schema.virtuals)) {
3569
+ schema.virtuals[key]._applyDefaultGetters();
3570
+ }
3571
+ if (schema.path('schema') == null) {
3572
+ this.schema = schema;
3573
+ }
3574
+ this.$__schema = schema;
3575
+ this[documentSchemaSymbol] = schema;
3576
+ };
3577
+
3578
+
3579
+ /**
3580
+ * Get active path that were changed and are arrays
3581
+ *
3582
+ * @return {Array}
3583
+ * @api private
3584
+ * @method $__getArrayPathsToValidate
3585
+ * @memberOf Document
3586
+ * @instance
3587
+ */
3588
+
3589
+ Document.prototype.$__getArrayPathsToValidate = function() {
3590
+ DocumentArray || (DocumentArray = require('./types/DocumentArray'));
3591
+
3592
+ // validate all document arrays.
3593
+ return this.$__.activePaths
3594
+ .map('init', 'modify', function(i) {
3595
+ return this.$__getValue(i);
3596
+ }.bind(this))
3597
+ .filter(function(val) {
3598
+ return val && Array.isArray(val) && utils.isMongooseDocumentArray(val) && val.length;
3599
+ }).reduce(function(seed, array) {
3600
+ return seed.concat(array);
3601
+ }, [])
3602
+ .filter(function(doc) {
3603
+ return doc;
3604
+ });
3605
+ };
3606
+
3607
+
3608
+ /**
3609
+ * Get all subdocs (by bfs)
3610
+ *
3611
+ * @return {Array}
3612
+ * @api public
3613
+ * @method $getAllSubdocs
3614
+ * @memberOf Document
3615
+ * @instance
3616
+ */
3617
+
3618
+ Document.prototype.$getAllSubdocs = function() {
3619
+ DocumentArray || (DocumentArray = require('./types/DocumentArray'));
3620
+ Embedded = Embedded || require('./types/ArraySubdocument');
3621
+
3622
+ function docReducer(doc, seed, path) {
3623
+ let val = doc;
3624
+ let isNested = false;
3625
+ if (path) {
3626
+ if (doc instanceof Document && doc[documentSchemaSymbol].paths[path]) {
3627
+ val = doc._doc[path];
3628
+ } else if (doc instanceof Document && doc[documentSchemaSymbol].nested[path]) {
3629
+ val = doc._doc[path];
3630
+ isNested = true;
3631
+ } else {
3632
+ val = doc[path];
3633
+ }
3634
+ }
3635
+ if (val instanceof Embedded) {
3636
+ seed.push(val);
3637
+ } else if (val instanceof Map) {
3638
+ seed = Array.from(val.keys()).reduce(function(seed, path) {
3639
+ return docReducer(val.get(path), seed, null);
3640
+ }, seed);
3641
+ } else if (val && !Array.isArray(val) && val.$isSingleNested) {
3642
+ seed = Object.keys(val._doc).reduce(function(seed, path) {
3643
+ return docReducer(val, seed, path);
3644
+ }, seed);
3645
+ seed.push(val);
3646
+ } else if (val && utils.isMongooseDocumentArray(val)) {
3647
+ val.forEach(function _docReduce(doc) {
3648
+ if (!doc || !doc._doc) {
3649
+ return;
3650
+ }
3651
+ seed = Object.keys(doc._doc).reduce(function(seed, path) {
3652
+ return docReducer(doc._doc, seed, path);
3653
+ }, seed);
3654
+ if (doc instanceof Embedded) {
3655
+ seed.push(doc);
3656
+ }
3657
+ });
3658
+ } else if (isNested && val != null) {
3659
+ for (const path of Object.keys(val)) {
3660
+ docReducer(val, seed, path);
3661
+ }
3662
+ }
3663
+ return seed;
3664
+ }
3665
+
3666
+ const subDocs = [];
3667
+ for (const path of Object.keys(this._doc)) {
3668
+ docReducer(this, subDocs, path);
3669
+ }
3670
+
3671
+ return subDocs;
3672
+ };
3673
+
3674
+ /*!
3675
+ * Runs queued functions
3676
+ */
3677
+
3678
+ function applyQueue(doc) {
3679
+ const q = doc.$__schema && doc.$__schema.callQueue;
3680
+ if (!q.length) {
3681
+ return;
3682
+ }
3683
+
3684
+ for (const pair of q) {
3685
+ if (pair[0] !== 'pre' && pair[0] !== 'post' && pair[0] !== 'on') {
3686
+ doc[pair[0]].apply(doc, pair[1]);
3687
+ }
3688
+ }
3689
+ }
3690
+
3691
+ /*!
3692
+ * ignore
3693
+ */
3694
+
3695
+ Document.prototype.$__handleReject = function handleReject(err) {
3696
+ // emit on the Model if listening
3697
+ if (this.$listeners('error').length) {
3698
+ this.$emit('error', err);
3699
+ } else if (this.constructor.listeners && this.constructor.listeners('error').length) {
3700
+ this.constructor.emit('error', err);
3701
+ }
3702
+ };
3703
+
3704
+ /**
3705
+ * Internal helper for toObject() and toJSON() that doesn't manipulate options
3706
+ *
3707
+ * @return {Object}
3708
+ * @api private
3709
+ * @method $toObject
3710
+ * @memberOf Document
3711
+ * @instance
3712
+ */
3713
+
3714
+ Document.prototype.$toObject = function(options, json) {
3715
+ let defaultOptions = {
3716
+ transform: true,
3717
+ flattenDecimals: true
3718
+ };
3719
+
3720
+ const path = json ? 'toJSON' : 'toObject';
3721
+ const baseOptions = this.constructor &&
3722
+ this.constructor.base &&
3723
+ this.constructor.base.options &&
3724
+ get(this.constructor.base.options, path) || {};
3725
+ const schemaOptions = this.$__schema && this.$__schema.options || {};
3726
+ // merge base default options with Schema's set default options if available.
3727
+ // `clone` is necessary here because `utils.options` directly modifies the second input.
3728
+ defaultOptions = { ...defaultOptions, ...baseOptions, ...schemaOptions[path] };
3729
+
3730
+ // If options do not exist or is not an object, set it to empty object
3731
+ options = utils.isPOJO(options) ? { ...options } : {};
3732
+ options._calledWithOptions = options._calledWithOptions || { ...options };
3733
+
3734
+ let _minimize;
3735
+ if (options._calledWithOptions.minimize != null) {
3736
+ _minimize = options.minimize;
3737
+ } else if (defaultOptions.minimize != null) {
3738
+ _minimize = defaultOptions.minimize;
3739
+ } else {
3740
+ _minimize = schemaOptions.minimize;
3741
+ }
3742
+
3743
+ let flattenMaps;
3744
+ if (options._calledWithOptions.flattenMaps != null) {
3745
+ flattenMaps = options.flattenMaps;
3746
+ } else if (defaultOptions.flattenMaps != null) {
3747
+ flattenMaps = defaultOptions.flattenMaps;
3748
+ } else {
3749
+ flattenMaps = schemaOptions.flattenMaps;
3750
+ }
3751
+
3752
+ let flattenObjectIds;
3753
+ if (options._calledWithOptions.flattenObjectIds != null) {
3754
+ flattenObjectIds = options.flattenObjectIds;
3755
+ } else if (defaultOptions.flattenObjectIds != null) {
3756
+ flattenObjectIds = defaultOptions.flattenObjectIds;
3757
+ } else {
3758
+ flattenObjectIds = schemaOptions.flattenObjectIds;
3759
+ }
3760
+
3761
+ // The original options that will be passed to `clone()`. Important because
3762
+ // `clone()` will recursively call `$toObject()` on embedded docs, so we
3763
+ // need the original options the user passed in, plus `_isNested` and
3764
+ // `_parentOptions` for checking whether we need to depopulate.
3765
+ const cloneOptions = Object.assign({}, options, {
3766
+ _isNested: true,
3767
+ json: json,
3768
+ minimize: _minimize,
3769
+ flattenMaps: flattenMaps,
3770
+ flattenObjectIds: flattenObjectIds,
3771
+ _seen: (options && options._seen) || new Map()
3772
+ });
3773
+
3774
+ if (utils.hasUserDefinedProperty(options, 'getters')) {
3775
+ cloneOptions.getters = options.getters;
3776
+ }
3777
+ if (utils.hasUserDefinedProperty(options, 'virtuals')) {
3778
+ cloneOptions.virtuals = options.virtuals;
3779
+ }
3780
+
3781
+ const depopulate = options.depopulate ||
3782
+ (options._parentOptions && options._parentOptions.depopulate || false);
3783
+ // _isNested will only be true if this is not the top level document, we
3784
+ // should never depopulate the top-level document
3785
+ if (depopulate && options._isNested && this.$__.wasPopulated) {
3786
+ return clone(this.$__.wasPopulated.value || this._id, cloneOptions);
3787
+ }
3788
+
3789
+ // merge default options with input options.
3790
+ options = { ...defaultOptions, ...options };
3791
+ options._isNested = true;
3792
+ options.json = json;
3793
+ options.minimize = _minimize;
3794
+
3795
+ cloneOptions._parentOptions = options;
3796
+ cloneOptions._skipSingleNestedGetters = false;
3797
+
3798
+ const gettersOptions = Object.assign({}, cloneOptions);
3799
+ gettersOptions._skipSingleNestedGetters = true;
3800
+
3801
+ // remember the root transform function
3802
+ // to save it from being overwritten by sub-transform functions
3803
+ const originalTransform = options.transform;
3804
+
3805
+ let ret = clone(this._doc, cloneOptions) || {};
3806
+
3807
+ if (options.getters) {
3808
+ applyGetters(this, ret, gettersOptions);
3809
+
3810
+ if (options.minimize) {
3811
+ ret = minimize(ret) || {};
3812
+ }
3813
+ }
3814
+
3815
+ if (options.virtuals || (options.getters && options.virtuals !== false)) {
3816
+ applyVirtuals(this, ret, gettersOptions, options);
3817
+ }
3818
+
3819
+ if (options.versionKey === false && this.$__schema.options.versionKey) {
3820
+ delete ret[this.$__schema.options.versionKey];
3821
+ }
3822
+
3823
+ let transform = options.transform;
3824
+
3825
+ // In the case where a subdocument has its own transform function, we need to
3826
+ // check and see if the parent has a transform (options.transform) and if the
3827
+ // child schema has a transform (this.schema.options.toObject) In this case,
3828
+ // we need to adjust options.transform to be the child schema's transform and
3829
+ // not the parent schema's
3830
+ if (transform) {
3831
+ applySchemaTypeTransforms(this, ret);
3832
+ }
3833
+
3834
+ if (options.useProjection) {
3835
+ omitDeselectedFields(this, ret);
3836
+ }
3837
+
3838
+ if (transform === true || (schemaOptions.toObject && transform)) {
3839
+ const opts = options.json ? schemaOptions.toJSON : schemaOptions.toObject;
3840
+
3841
+ if (opts) {
3842
+ transform = (typeof options.transform === 'function' ? options.transform : opts.transform);
3843
+ }
3844
+ } else {
3845
+ options.transform = originalTransform;
3846
+ }
3847
+
3848
+ if (typeof transform === 'function') {
3849
+ const xformed = transform(this, ret, options);
3850
+ if (typeof xformed !== 'undefined') {
3851
+ ret = xformed;
3852
+ }
3853
+ }
3854
+
3855
+ return ret;
3856
+ };
3857
+
3858
+ /**
3859
+ * Converts this document into a plain-old JavaScript object ([POJO](https://masteringjs.io/tutorials/fundamentals/pojo)).
3860
+ *
3861
+ * Buffers are converted to instances of [mongodb.Binary](https://mongodb.github.io/node-mongodb-native/4.9/classes/Binary.html) for proper storage.
3862
+ *
3863
+ * #### Getters/Virtuals
3864
+ *
3865
+ * Example of only applying path getters
3866
+ *
3867
+ * doc.toObject({ getters: true, virtuals: false })
3868
+ *
3869
+ * Example of only applying virtual getters
3870
+ *
3871
+ * doc.toObject({ virtuals: true })
3872
+ *
3873
+ * Example of applying both path and virtual getters
3874
+ *
3875
+ * doc.toObject({ getters: true })
3876
+ *
3877
+ * To apply these options to every document of your schema by default, set your [schemas](https://mongoosejs.com/docs/api/schema.html#Schema()) `toObject` option to the same argument.
3878
+ *
3879
+ * schema.set('toObject', { virtuals: true })
3880
+ *
3881
+ * #### Transform:
3882
+ *
3883
+ * We may need to perform a transformation of the resulting object based on some criteria, say to remove some sensitive information or return a custom object. In this case we set the optional `transform` function.
3884
+ *
3885
+ * Transform functions receive three arguments
3886
+ *
3887
+ * function (doc, ret, options) {}
3888
+ *
3889
+ * - `doc` The mongoose document which is being converted
3890
+ * - `ret` The plain object representation which has been converted
3891
+ * - `options` The options in use (either schema options or the options passed inline)
3892
+ *
3893
+ * #### Example:
3894
+ *
3895
+ * // specify the transform schema option
3896
+ * if (!schema.options.toObject) schema.options.toObject = {};
3897
+ * schema.options.toObject.transform = function (doc, ret, options) {
3898
+ * // remove the _id of every document before returning the result
3899
+ * delete ret._id;
3900
+ * return ret;
3901
+ * }
3902
+ *
3903
+ * // without the transformation in the schema
3904
+ * doc.toObject(); // { _id: 'anId', name: 'Wreck-it Ralph' }
3905
+ *
3906
+ * // with the transformation
3907
+ * doc.toObject(); // { name: 'Wreck-it Ralph' }
3908
+ *
3909
+ * With transformations we can do a lot more than remove properties. We can even return completely new customized objects:
3910
+ *
3911
+ * if (!schema.options.toObject) schema.options.toObject = {};
3912
+ * schema.options.toObject.transform = function (doc, ret, options) {
3913
+ * return { movie: ret.name }
3914
+ * }
3915
+ *
3916
+ * // without the transformation in the schema
3917
+ * doc.toObject(); // { _id: 'anId', name: 'Wreck-it Ralph' }
3918
+ *
3919
+ * // with the transformation
3920
+ * doc.toObject(); // { movie: 'Wreck-it Ralph' }
3921
+ *
3922
+ * _Note: if a transform function returns `undefined`, the return value will be ignored._
3923
+ *
3924
+ * Transformations may also be applied inline, overridding any transform set in the options:
3925
+ *
3926
+ * function xform (doc, ret, options) {
3927
+ * return { inline: ret.name, custom: true }
3928
+ * }
3929
+ *
3930
+ * // pass the transform as an inline option
3931
+ * doc.toObject({ transform: xform }); // { inline: 'Wreck-it Ralph', custom: true }
3932
+ *
3933
+ * If you want to skip transformations, use `transform: false`:
3934
+ *
3935
+ * schema.options.toObject.hide = '_id';
3936
+ * schema.options.toObject.transform = function (doc, ret, options) {
3937
+ * if (options.hide) {
3938
+ * options.hide.split(' ').forEach(function (prop) {
3939
+ * delete ret[prop];
3940
+ * });
3941
+ * }
3942
+ * return ret;
3943
+ * }
3944
+ *
3945
+ * const doc = new Doc({ _id: 'anId', secret: 47, name: 'Wreck-it Ralph' });
3946
+ * doc.toObject(); // { secret: 47, name: 'Wreck-it Ralph' }
3947
+ * doc.toObject({ hide: 'secret _id', transform: false });// { _id: 'anId', secret: 47, name: 'Wreck-it Ralph' }
3948
+ * doc.toObject({ hide: 'secret _id', transform: true }); // { name: 'Wreck-it Ralph' }
3949
+ *
3950
+ * If you pass a transform in `toObject()` options, Mongoose will apply the transform
3951
+ * to [subdocuments](https://mongoosejs.com/docs/subdocs.html) in addition to the top-level document.
3952
+ * Similarly, `transform: false` skips transforms for all subdocuments.
3953
+ * Note that this behavior is different for transforms defined in the schema:
3954
+ * if you define a transform in `schema.options.toObject.transform`, that transform
3955
+ * will **not** apply to subdocuments.
3956
+ *
3957
+ * const memberSchema = new Schema({ name: String, email: String });
3958
+ * const groupSchema = new Schema({ members: [memberSchema], name: String, email });
3959
+ * const Group = mongoose.model('Group', groupSchema);
3960
+ *
3961
+ * const doc = new Group({
3962
+ * name: 'Engineering',
3963
+ * email: 'dev@mongoosejs.io',
3964
+ * members: [{ name: 'Val', email: 'val@mongoosejs.io' }]
3965
+ * });
3966
+ *
3967
+ * // Removes `email` from both top-level document **and** array elements
3968
+ * // { name: 'Engineering', members: [{ name: 'Val' }] }
3969
+ * doc.toObject({ transform: (doc, ret) => { delete ret.email; return ret; } });
3970
+ *
3971
+ * Transforms, like all of these options, are also available for `toJSON`. See [this guide to `JSON.stringify()`](https://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript.html) to learn why `toJSON()` and `toObject()` are separate functions.
3972
+ *
3973
+ * See [schema options](https://mongoosejs.com/docs/guide.html#toObject) for some more details.
3974
+ *
3975
+ * _During save, no custom options are applied to the document before being sent to the database._
3976
+ *
3977
+ * @param {Object} [options]
3978
+ * @param {Boolean} [options.getters=false] if true, apply all getters, including virtuals
3979
+ * @param {Boolean|Object} [options.virtuals=false] if true, apply virtuals, including aliases. Use `{ getters: true, virtuals: false }` to just apply getters, not virtuals. An object of the form `{ pathsToSkip: ['someVirtual'] }` may also be used to omit specific virtuals.
3980
+ * @param {Boolean} [options.aliases=true] if `options.virtuals = true`, you can set `options.aliases = false` to skip applying aliases. This option is a no-op if `options.virtuals = false`.
3981
+ * @param {Boolean} [options.minimize=true] if true, omit any empty objects from the output
3982
+ * @param {Function|null} [options.transform=null] if set, mongoose will call this function to allow you to transform the returned object
3983
+ * @param {Boolean} [options.depopulate=false] if true, replace any conventionally populated paths with the original id in the output. Has no affect on virtual populated paths.
3984
+ * @param {Boolean} [options.versionKey=true] if false, exclude the version key (`__v` by default) from the output
3985
+ * @param {Boolean} [options.flattenMaps=false] if true, convert Maps to POJOs. Useful if you want to `JSON.stringify()` the result of `toObject()`.
3986
+ * @param {Boolean} [options.flattenObjectIds=false] if true, convert any ObjectIds in the result to 24 character hex strings.
3987
+ * @param {Boolean} [options.useProjection=false] - If true, omits fields that are excluded in this document's projection. Unless you specified a projection, this will omit any field that has `select: false` in the schema.
3988
+ * @return {Object} js object (not a POJO)
3989
+ * @see mongodb.Binary https://mongodb.github.io/node-mongodb-native/4.9/classes/Binary.html
3990
+ * @api public
3991
+ * @memberOf Document
3992
+ * @instance
3993
+ */
3994
+
3995
+ Document.prototype.toObject = function(options) {
3996
+ return this.$toObject(options);
3997
+ };
3998
+
3999
+ /**
4000
+ * Minimizes an object, removing undefined values and empty objects
4001
+ *
4002
+ * @param {Object} object to minimize
4003
+ * @return {Object}
4004
+ * @api private
4005
+ */
4006
+
4007
+ function minimize(obj) {
4008
+ const keys = Object.keys(obj);
4009
+ let i = keys.length;
4010
+ let hasKeys;
4011
+ let key;
4012
+ let val;
4013
+
4014
+ while (i--) {
4015
+ key = keys[i];
4016
+ val = obj[key];
4017
+
4018
+ if (utils.isPOJO(val)) {
4019
+ obj[key] = minimize(val);
4020
+ }
4021
+
4022
+ if (undefined === obj[key]) {
4023
+ delete obj[key];
4024
+ continue;
4025
+ }
4026
+
4027
+ hasKeys = true;
4028
+ }
4029
+
4030
+ return hasKeys
4031
+ ? obj
4032
+ : undefined;
4033
+ }
4034
+
4035
+ /*!
4036
+ * Applies virtuals properties to `json`.
4037
+ */
4038
+
4039
+ function applyVirtuals(self, json, options, toObjectOptions) {
4040
+ const schema = self.$__schema;
4041
+ const paths = Object.keys(schema.virtuals);
4042
+ let i = paths.length;
4043
+ const numPaths = i;
4044
+ let path;
4045
+ let assignPath;
4046
+ let cur = self._doc;
4047
+ let v;
4048
+ const aliases = typeof (toObjectOptions && toObjectOptions.aliases) === 'boolean'
4049
+ ? toObjectOptions.aliases
4050
+ : true;
4051
+
4052
+ options = options || {};
4053
+ let virtualsToApply = null;
4054
+ if (Array.isArray(options.virtuals)) {
4055
+ virtualsToApply = new Set(options.virtuals);
4056
+ } else if (options.virtuals && options.virtuals.pathsToSkip) {
4057
+ virtualsToApply = new Set(paths);
4058
+ for (let i = 0; i < options.virtuals.pathsToSkip.length; i++) {
4059
+ if (virtualsToApply.has(options.virtuals.pathsToSkip[i])) {
4060
+ virtualsToApply.delete(options.virtuals.pathsToSkip[i]);
4061
+ }
4062
+ }
4063
+ }
4064
+
4065
+ if (!cur) {
4066
+ return json;
4067
+ }
4068
+
4069
+ for (i = 0; i < numPaths; ++i) {
4070
+ path = paths[i];
4071
+
4072
+ if (virtualsToApply != null && !virtualsToApply.has(path)) {
4073
+ continue;
4074
+ }
4075
+
4076
+ // Allow skipping aliases with `toObject({ virtuals: true, aliases: false })`
4077
+ if (!aliases && schema.aliases.hasOwnProperty(path)) {
4078
+ continue;
4079
+ }
4080
+
4081
+ // We may be applying virtuals to a nested object, for example if calling
4082
+ // `doc.nestedProp.toJSON()`. If so, the path we assign to, `assignPath`,
4083
+ // will be a trailing substring of the `path`.
4084
+ assignPath = path;
4085
+ if (options.path != null) {
4086
+ if (!path.startsWith(options.path + '.')) {
4087
+ continue;
4088
+ }
4089
+ assignPath = path.substring(options.path.length + 1);
4090
+ }
4091
+ const parts = assignPath.split('.');
4092
+ v = clone(self.get(path), options);
4093
+ if (v === void 0) {
4094
+ continue;
4095
+ }
4096
+ const plen = parts.length;
4097
+ cur = json;
4098
+ for (let j = 0; j < plen - 1; ++j) {
4099
+ cur[parts[j]] = cur[parts[j]] || {};
4100
+ cur = cur[parts[j]];
4101
+ }
4102
+ cur[parts[plen - 1]] = v;
4103
+ }
4104
+
4105
+ return json;
4106
+ }
4107
+
4108
+
4109
+ /**
4110
+ * Applies virtuals properties to `json`.
4111
+ *
4112
+ * @param {Document} self
4113
+ * @param {Object} json
4114
+ * @param {Object} [options]
4115
+ * @return {Object} `json`
4116
+ * @api private
4117
+ */
4118
+
4119
+ function applyGetters(self, json, options) {
4120
+ const schema = self.$__schema;
4121
+ const paths = Object.keys(schema.paths);
4122
+ let i = paths.length;
4123
+ let path;
4124
+ let cur = self._doc;
4125
+ let v;
4126
+
4127
+ if (!cur) {
4128
+ return json;
4129
+ }
4130
+
4131
+ while (i--) {
4132
+ path = paths[i];
4133
+
4134
+ const parts = path.split('.');
4135
+
4136
+ const plen = parts.length;
4137
+ const last = plen - 1;
4138
+ let branch = json;
4139
+ let part;
4140
+ cur = self._doc;
4141
+
4142
+ if (!self.$__isSelected(path)) {
4143
+ continue;
4144
+ }
4145
+
4146
+ for (let ii = 0; ii < plen; ++ii) {
4147
+ part = parts[ii];
4148
+ v = cur[part];
4149
+ // If we've reached a non-object part of the branch, continuing would
4150
+ // cause "Cannot create property 'foo' on string 'bar'" error.
4151
+ // Necessary for mongoose-intl plugin re: gh-14446
4152
+ if (branch != null && typeof branch !== 'object') {
4153
+ break;
4154
+ } else if (ii === last) {
4155
+ const val = self.$get(path);
4156
+ branch[part] = clone(val, options);
4157
+ if (Array.isArray(branch[part]) && schema.paths[path].$embeddedSchemaType) {
4158
+ for (let i = 0; i < branch[part].length; ++i) {
4159
+ branch[part][i] = schema.paths[path].$embeddedSchemaType.applyGetters(
4160
+ branch[part][i],
4161
+ self
4162
+ );
4163
+ }
4164
+ }
4165
+ } else if (v == null) {
4166
+ if (part in cur) {
4167
+ branch[part] = v;
4168
+ }
4169
+ break;
4170
+ } else {
4171
+ branch = branch[part] || (branch[part] = {});
4172
+ }
4173
+ cur = v;
4174
+ }
4175
+ }
4176
+
4177
+ return json;
4178
+ }
4179
+
4180
+ /**
4181
+ * Applies schema type transforms to `json`.
4182
+ *
4183
+ * @param {Document} self
4184
+ * @param {Object} json
4185
+ * @return {Object} `json`
4186
+ * @api private
4187
+ */
4188
+
4189
+ function applySchemaTypeTransforms(self, json) {
4190
+ const schema = self.$__schema;
4191
+ const paths = Object.keys(schema.paths || {});
4192
+ const cur = self._doc;
4193
+
4194
+ if (!cur) {
4195
+ return json;
4196
+ }
4197
+
4198
+ for (const path of paths) {
4199
+ const schematype = schema.paths[path];
4200
+ if (typeof schematype.options.transform === 'function') {
4201
+ const val = self.$get(path);
4202
+ if (val === undefined) {
4203
+ continue;
4204
+ }
4205
+ const transformedValue = schematype.options.transform.call(self, val);
4206
+ throwErrorIfPromise(path, transformedValue);
4207
+ utils.setValue(path, transformedValue, json);
4208
+ } else if (schematype.$embeddedSchemaType != null &&
4209
+ typeof schematype.$embeddedSchemaType.options.transform === 'function') {
4210
+ const val = self.$get(path);
4211
+ if (val === undefined) {
4212
+ continue;
4213
+ }
4214
+ const vals = [].concat(val);
4215
+ const transform = schematype.$embeddedSchemaType.options.transform;
4216
+ for (let i = 0; i < vals.length; ++i) {
4217
+ const transformedValue = transform.call(self, vals[i]);
4218
+ vals[i] = transformedValue;
4219
+ throwErrorIfPromise(path, transformedValue);
4220
+ }
4221
+
4222
+ json[path] = vals;
4223
+ }
4224
+ }
4225
+
4226
+ return json;
4227
+ }
4228
+
4229
+ function throwErrorIfPromise(path, transformedValue) {
4230
+ if (isPromise(transformedValue)) {
4231
+ throw new Error('`transform` function must be synchronous, but the transform on path `' + path + '` returned a promise.');
4232
+ }
4233
+ }
4234
+
4235
+ /*!
4236
+ * ignore
4237
+ */
4238
+
4239
+ function omitDeselectedFields(self, json) {
4240
+ const schema = self.$__schema;
4241
+ const paths = Object.keys(schema.paths || {});
4242
+ const cur = self._doc;
4243
+
4244
+ if (!cur) {
4245
+ return json;
4246
+ }
4247
+
4248
+ let selected = self.$__.selected;
4249
+ if (selected === void 0) {
4250
+ selected = {};
4251
+ queryhelpers.applyPaths(selected, schema);
4252
+ }
4253
+ if (selected == null || Object.keys(selected).length === 0) {
4254
+ return json;
4255
+ }
4256
+
4257
+ for (const path of paths) {
4258
+ if (selected[path] != null && !selected[path]) {
4259
+ delete json[path];
4260
+ }
4261
+ }
4262
+
4263
+ return json;
4264
+ }
4265
+
4266
+ /**
4267
+ * The return value of this method is used in calls to [`JSON.stringify(doc)`](https://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript#the-tojson-function).
4268
+ *
4269
+ * This method accepts the same options as [Document#toObject](https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()). To apply the options to every document of your schema by default, set your [schemas](https://mongoosejs.com/docs/api/schema.html#Schema()) `toJSON` option to the same argument.
4270
+ *
4271
+ * schema.set('toJSON', { virtuals: true });
4272
+ *
4273
+ * There is one difference between `toJSON()` and `toObject()` options.
4274
+ * When you call `toJSON()`, the [`flattenMaps` option](https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()) defaults to `true`, because `JSON.stringify()` doesn't convert maps to objects by default.
4275
+ * When you call `toObject()`, the `flattenMaps` option is `false` by default.
4276
+ *
4277
+ * See [schema options](https://mongoosejs.com/docs/guide.html#toJSON) for more information on setting `toJSON` option defaults.
4278
+ *
4279
+ * @param {Object} options
4280
+ * @param {Boolean} [options.flattenMaps=true] if true, convert Maps to [POJOs](https://masteringjs.io/tutorials/fundamentals/pojo). Useful if you want to `JSON.stringify()` the result.
4281
+ * @param {Boolean} [options.flattenObjectIds=false] if true, convert any ObjectIds in the result to 24 character hex strings.
4282
+ * @return {Object}
4283
+ * @see Document#toObject https://mongoosejs.com/docs/api/document.html#Document.prototype.toObject()
4284
+ * @see JSON.stringify() in JavaScript https://thecodebarbarian.com/the-80-20-guide-to-json-stringify-in-javascript.html
4285
+ * @api public
4286
+ * @memberOf Document
4287
+ * @instance
4288
+ */
4289
+
4290
+ Document.prototype.toJSON = function(options) {
4291
+ return this.$toObject(options, true);
4292
+ };
4293
+
4294
+ /*!
4295
+ * ignore
4296
+ */
4297
+
4298
+ Document.prototype.ownerDocument = function() {
4299
+ return this;
4300
+ };
4301
+
4302
+
4303
+ /**
4304
+ * If this document is a subdocument or populated document, returns the document's
4305
+ * parent. Returns the original document if there is no parent.
4306
+ *
4307
+ * @return {Document}
4308
+ * @api public
4309
+ * @method parent
4310
+ * @memberOf Document
4311
+ * @instance
4312
+ */
4313
+
4314
+ Document.prototype.parent = function() {
4315
+ if (this.$isSubdocument || this.$__.wasPopulated) {
4316
+ return this.$__.parent;
4317
+ }
4318
+ return this;
4319
+ };
4320
+
4321
+ /**
4322
+ * Alias for [`parent()`](https://mongoosejs.com/docs/api/document.html#Document.prototype.parent()). If this document is a subdocument or populated
4323
+ * document, returns the document's parent. Returns `undefined` otherwise.
4324
+ *
4325
+ * @return {Document}
4326
+ * @api public
4327
+ * @method $parent
4328
+ * @memberOf Document
4329
+ * @instance
4330
+ */
4331
+
4332
+ Document.prototype.$parent = Document.prototype.parent;
4333
+
4334
+ /**
4335
+ * Helper for console.log
4336
+ *
4337
+ * @return {String}
4338
+ * @api public
4339
+ * @method inspect
4340
+ * @memberOf Document
4341
+ * @instance
4342
+ */
4343
+
4344
+ Document.prototype.inspect = function(options) {
4345
+ const isPOJO = utils.isPOJO(options);
4346
+ let opts;
4347
+ if (isPOJO) {
4348
+ opts = options;
4349
+ opts.minimize = false;
4350
+ }
4351
+ const ret = this.toObject(opts);
4352
+
4353
+ if (ret == null) {
4354
+ // If `toObject()` returns null, `this` is still an object, so if `inspect()`
4355
+ // prints out null this can cause some serious confusion. See gh-7942.
4356
+ return 'MongooseDocument { ' + ret + ' }';
4357
+ }
4358
+
4359
+ return ret;
4360
+ };
4361
+
4362
+ if (inspect.custom) {
4363
+ // Avoid Node deprecation warning DEP0079
4364
+ Document.prototype[inspect.custom] = Document.prototype.inspect;
4365
+ }
4366
+
4367
+ /**
4368
+ * Helper for console.log
4369
+ *
4370
+ * @return {String}
4371
+ * @api public
4372
+ * @method toString
4373
+ * @memberOf Document
4374
+ * @instance
4375
+ */
4376
+
4377
+ Document.prototype.toString = function() {
4378
+ const ret = this.inspect();
4379
+ if (typeof ret === 'string') {
4380
+ return ret;
4381
+ }
4382
+ return inspect(ret);
4383
+ };
4384
+
4385
+ /**
4386
+ * Returns true if this document is equal to another document.
4387
+ *
4388
+ * Documents are considered equal when they have matching `_id`s, unless neither
4389
+ * document has an `_id`, in which case this function falls back to using
4390
+ * `deepEqual()`.
4391
+ *
4392
+ * @param {Document} [doc] a document to compare. If falsy, will always return "false".
4393
+ * @return {Boolean}
4394
+ * @api public
4395
+ * @memberOf Document
4396
+ * @instance
4397
+ */
4398
+
4399
+ Document.prototype.equals = function(doc) {
4400
+ if (!doc) {
4401
+ return false;
4402
+ }
4403
+
4404
+ const tid = this.$__getValue('_id');
4405
+ const docid = doc.$__ != null ? doc.$__getValue('_id') : doc;
4406
+ if (!tid && !docid) {
4407
+ return deepEqual(this, doc);
4408
+ }
4409
+ return tid && tid.equals
4410
+ ? tid.equals(docid)
4411
+ : tid === docid;
4412
+ };
4413
+
4414
+ /**
4415
+ * Populates paths on an existing document.
4416
+ *
4417
+ * #### Example:
4418
+ *
4419
+ * // Given a document, `populate()` lets you pull in referenced docs
4420
+ * await doc.populate([
4421
+ * 'stories',
4422
+ * { path: 'fans', sort: { name: -1 } }
4423
+ * ]);
4424
+ * doc.populated('stories'); // Array of ObjectIds
4425
+ * doc.stories[0].title; // 'Casino Royale'
4426
+ * doc.populated('fans'); // Array of ObjectIds
4427
+ *
4428
+ * // If the referenced doc has been deleted, `populate()` will
4429
+ * // remove that entry from the array.
4430
+ * await Story.delete({ title: 'Casino Royale' });
4431
+ * await doc.populate('stories'); // Empty array
4432
+ *
4433
+ * // You can also pass additional query options to `populate()`,
4434
+ * // like projections:
4435
+ * await doc.populate('fans', '-email');
4436
+ * doc.fans[0].email // undefined because of 2nd param `select`
4437
+ *
4438
+ * @param {String|Object|Array} path either the path to populate or an object specifying all parameters, or either an array of those
4439
+ * @param {Object|String} [select] Field selection for the population query
4440
+ * @param {Model} [model] The model you wish to use for population. If not specified, populate will look up the model by the name in the Schema's `ref` field.
4441
+ * @param {Object} [match] Conditions for the population query
4442
+ * @param {Object} [options] Options for the population query (sort, etc)
4443
+ * @param {String} [options.path=null] The path to populate.
4444
+ * @param {string|PopulateOptions} [options.populate=null] Recursively populate paths in the populated documents. See [deep populate docs](https://mongoosejs.com/docs/populate.html#deep-populate).
4445
+ * @param {boolean} [options.retainNullValues=false] by default, Mongoose removes null and undefined values from populated arrays. Use this option to make `populate()` retain `null` and `undefined` array entries.
4446
+ * @param {boolean} [options.getters=false] if true, Mongoose will call any getters defined on the `localField`. By default, Mongoose gets the raw value of `localField`. For example, you would need to set this option to `true` if you wanted to [add a `lowercase` getter to your `localField`](https://mongoosejs.com/docs/schematypes.html#schematype-options).
4447
+ * @param {boolean} [options.clone=false] When you do `BlogPost.find().populate('author')`, blog posts with the same author will share 1 copy of an `author` doc. Enable this option to make Mongoose clone populated docs before assigning them.
4448
+ * @param {Object|Function} [options.match=null] Add an additional filter to the populate query. Can be a filter object containing [MongoDB query syntax](https://www.mongodb.com/docs/manual/tutorial/query-documents/), or a function that returns a filter object.
4449
+ * @param {Function} [options.transform=null] Function that Mongoose will call on every populated document that allows you to transform the populated document.
4450
+ * @param {Object} [options.options=null] Additional options like `limit` and `lean`.
4451
+ * @param {Function} [callback] Callback
4452
+ * @see population https://mongoosejs.com/docs/populate.html
4453
+ * @see Query#select https://mongoosejs.com/docs/api/query.html#Query.prototype.select()
4454
+ * @see Model.populate https://mongoosejs.com/docs/api/model.html#Model.populate()
4455
+ * @memberOf Document
4456
+ * @instance
4457
+ * @return {Promise|null} Returns a Promise if no `callback` is given.
4458
+ * @api public
4459
+ */
4460
+
4461
+ Document.prototype.populate = async function populate() {
4462
+ const pop = {};
4463
+ const args = [...arguments];
4464
+ if (typeof args[args.length - 1] === 'function') {
4465
+ throw new MongooseError('Document.prototype.populate() no longer accepts a callback');
4466
+ }
4467
+
4468
+ if (args.length !== 0) {
4469
+ // use hash to remove duplicate paths
4470
+ const res = utils.populate.apply(null, args);
4471
+ for (const populateOptions of res) {
4472
+ pop[populateOptions.path] = populateOptions;
4473
+ }
4474
+ }
4475
+
4476
+ const paths = utils.object.vals(pop);
4477
+ let topLevelModel = this.constructor;
4478
+ if (this.$__isNested) {
4479
+ topLevelModel = this.$__[scopeSymbol].constructor;
4480
+ const nestedPath = this.$__.nestedPath;
4481
+ paths.forEach(function(populateOptions) {
4482
+ populateOptions.path = nestedPath + '.' + populateOptions.path;
4483
+ });
4484
+ }
4485
+
4486
+ // Use `$session()` by default if the document has an associated session
4487
+ // See gh-6754
4488
+ if (this.$session() != null) {
4489
+ const session = this.$session();
4490
+ paths.forEach(path => {
4491
+ if (path.options == null) {
4492
+ path.options = { session: session };
4493
+ return;
4494
+ }
4495
+ if (!('session' in path.options)) {
4496
+ path.options.session = session;
4497
+ }
4498
+ });
4499
+ }
4500
+
4501
+ paths.forEach(p => {
4502
+ p._localModel = topLevelModel;
4503
+ });
4504
+
4505
+ return topLevelModel.populate(this, paths);
4506
+ };
4507
+
4508
+ /**
4509
+ * Gets all populated documents associated with this document.
4510
+ *
4511
+ * @api public
4512
+ * @return {Document[]} array of populated documents. Empty array if there are no populated documents associated with this document.
4513
+ * @memberOf Document
4514
+ * @method $getPopulatedDocs
4515
+ * @instance
4516
+ */
4517
+
4518
+ Document.prototype.$getPopulatedDocs = function $getPopulatedDocs() {
4519
+ let keys = [];
4520
+ if (this.$__.populated != null) {
4521
+ keys = keys.concat(Object.keys(this.$__.populated));
4522
+ }
4523
+ let result = [];
4524
+ for (const key of keys) {
4525
+ const value = this.$get(key);
4526
+ if (Array.isArray(value)) {
4527
+ result = result.concat(value);
4528
+ } else if (value instanceof Document) {
4529
+ result.push(value);
4530
+ }
4531
+ }
4532
+ return result;
4533
+ };
4534
+
4535
+ /**
4536
+ * Gets _id(s) used during population of the given `path`.
4537
+ *
4538
+ * #### Example:
4539
+ *
4540
+ * const doc = await Model.findOne().populate('author');
4541
+ *
4542
+ * console.log(doc.author.name); // Dr.Seuss
4543
+ * console.log(doc.populated('author')); // '5144cf8050f071d979c118a7'
4544
+ *
4545
+ * If the path was not populated, returns `undefined`.
4546
+ *
4547
+ * @param {String} path
4548
+ * @param {Any} [val]
4549
+ * @param {Object} [options]
4550
+ * @return {Array|ObjectId|Number|Buffer|String|undefined}
4551
+ * @memberOf Document
4552
+ * @instance
4553
+ * @api public
4554
+ */
4555
+
4556
+ Document.prototype.populated = function(path, val, options) {
4557
+ // val and options are internal
4558
+ if (val == null || val === true) {
4559
+ if (!this.$__.populated) {
4560
+ return undefined;
4561
+ }
4562
+ if (typeof path !== 'string') {
4563
+ return undefined;
4564
+ }
4565
+
4566
+ // Map paths can be populated with either `path.$*` or just `path`
4567
+ const _path = path.endsWith('.$*') ? path.replace(/\.\$\*$/, '') : path;
4568
+
4569
+ const v = this.$__.populated[_path];
4570
+ if (v) {
4571
+ return val === true ? v : v.value;
4572
+ }
4573
+ return undefined;
4574
+ }
4575
+
4576
+ this.$__.populated || (this.$__.populated = {});
4577
+ this.$__.populated[path] = { value: val, options: options };
4578
+
4579
+ // If this was a nested populate, make sure each populated doc knows
4580
+ // about its populated children (gh-7685)
4581
+ const pieces = path.split('.');
4582
+ for (let i = 0; i < pieces.length - 1; ++i) {
4583
+ const subpath = pieces.slice(0, i + 1).join('.');
4584
+ const subdoc = this.$get(subpath);
4585
+ if (subdoc != null && subdoc.$__ != null && this.$populated(subpath)) {
4586
+ const rest = pieces.slice(i + 1).join('.');
4587
+ subdoc.$populated(rest, val, options);
4588
+ // No need to continue because the above recursion should take care of
4589
+ // marking the rest of the docs as populated
4590
+ break;
4591
+ }
4592
+ }
4593
+
4594
+ return val;
4595
+ };
4596
+
4597
+ /**
4598
+ * Alias of [`.populated`](https://mongoosejs.com/docs/api/document.html#Document.prototype.populated()).
4599
+ *
4600
+ * @method $populated
4601
+ * @memberOf Document
4602
+ * @api public
4603
+ */
4604
+
4605
+ Document.prototype.$populated = Document.prototype.populated;
4606
+
4607
+ /**
4608
+ * Throws an error if a given path is not populated
4609
+ *
4610
+ * #### Example:
4611
+ *
4612
+ * const doc = await Model.findOne().populate('author');
4613
+ *
4614
+ * doc.$assertPopulated('author'); // does not throw
4615
+ * doc.$assertPopulated('other path'); // throws an error
4616
+ *
4617
+ * // Manually populate and assert in one call. The following does
4618
+ * // `doc.$set({ likes })` before asserting.
4619
+ * doc.$assertPopulated('likes', { likes });
4620
+ *
4621
+ *
4622
+ * @param {String|String[]} path path or array of paths to check. `$assertPopulated` throws if any of the given paths is not populated.
4623
+ * @param {Object} [values] optional values to `$set()`. Convenient if you want to manually populate a path and assert that the path was populated in 1 call.
4624
+ * @return {Document} this
4625
+ * @memberOf Document
4626
+ * @method $assertPopulated
4627
+ * @instance
4628
+ * @api public
4629
+ */
4630
+
4631
+ Document.prototype.$assertPopulated = function $assertPopulated(path, values) {
4632
+ if (Array.isArray(path)) {
4633
+ path.forEach(p => this.$assertPopulated(p, values));
4634
+ return this;
4635
+ }
4636
+
4637
+ if (arguments.length > 1) {
4638
+ this.$set(values);
4639
+ }
4640
+
4641
+ if (!this.$populated(path)) {
4642
+ throw new MongooseError(`Expected path "${path}" to be populated`);
4643
+ }
4644
+
4645
+ return this;
4646
+ };
4647
+
4648
+ /**
4649
+ * Takes a populated field and returns it to its unpopulated state.
4650
+ *
4651
+ * #### Example:
4652
+ *
4653
+ * Model.findOne().populate('author').exec(function (err, doc) {
4654
+ * console.log(doc.author.name); // Dr.Seuss
4655
+ * console.log(doc.depopulate('author'));
4656
+ * console.log(doc.author); // '5144cf8050f071d979c118a7'
4657
+ * })
4658
+ *
4659
+ * If the path was not provided, then all populated fields are returned to their unpopulated state.
4660
+ *
4661
+ * @param {String|String[]} [path] Specific Path to depopulate. If unset, will depopulate all paths on the Document. Or multiple space-delimited paths.
4662
+ * @return {Document} this
4663
+ * @see Document.populate https://mongoosejs.com/docs/api/document.html#Document.prototype.populate()
4664
+ * @api public
4665
+ * @memberOf Document
4666
+ * @instance
4667
+ */
4668
+
4669
+ Document.prototype.depopulate = function(path) {
4670
+ if (typeof path === 'string') {
4671
+ path = path.indexOf(' ') === -1 ? [path] : path.split(' ');
4672
+ }
4673
+
4674
+ let populatedIds;
4675
+ const virtualKeys = this.$$populatedVirtuals ? Object.keys(this.$$populatedVirtuals) : [];
4676
+ const populated = this.$__ && this.$__.populated || {};
4677
+
4678
+ if (arguments.length === 0) {
4679
+ // Depopulate all
4680
+ for (const virtualKey of virtualKeys) {
4681
+ delete this.$$populatedVirtuals[virtualKey];
4682
+ delete this._doc[virtualKey];
4683
+ delete populated[virtualKey];
4684
+ }
4685
+
4686
+ const keys = Object.keys(populated);
4687
+
4688
+ for (const key of keys) {
4689
+ populatedIds = this.$populated(key);
4690
+ if (!populatedIds) {
4691
+ continue;
4692
+ }
4693
+ delete populated[key];
4694
+ utils.setValue(key, populatedIds, this._doc);
4695
+ }
4696
+ return this;
4697
+ }
4698
+
4699
+ for (const singlePath of path) {
4700
+ populatedIds = this.$populated(singlePath);
4701
+ delete populated[singlePath];
4702
+
4703
+ if (virtualKeys.indexOf(singlePath) !== -1) {
4704
+ delete this.$$populatedVirtuals[singlePath];
4705
+ delete this._doc[singlePath];
4706
+ } else if (populatedIds) {
4707
+ utils.setValue(singlePath, populatedIds, this._doc);
4708
+ }
4709
+ }
4710
+ return this;
4711
+ };
4712
+
4713
+
4714
+ /**
4715
+ * Returns the full path to this document.
4716
+ *
4717
+ * @param {String} [path]
4718
+ * @return {String}
4719
+ * @api private
4720
+ * @method $__fullPath
4721
+ * @memberOf Document
4722
+ * @instance
4723
+ */
4724
+
4725
+ Document.prototype.$__fullPath = function(path) {
4726
+ // overridden in SubDocuments
4727
+ return path || '';
4728
+ };
4729
+
4730
+ /**
4731
+ * Returns the changes that happened to the document
4732
+ * in the format that will be sent to MongoDB.
4733
+ *
4734
+ * #### Example:
4735
+ *
4736
+ * const userSchema = new Schema({
4737
+ * name: String,
4738
+ * age: Number,
4739
+ * country: String
4740
+ * });
4741
+ * const User = mongoose.model('User', userSchema);
4742
+ * const user = await User.create({
4743
+ * name: 'Hafez',
4744
+ * age: 25,
4745
+ * country: 'Egypt'
4746
+ * });
4747
+ *
4748
+ * // returns an empty object, no changes happened yet
4749
+ * user.getChanges(); // { }
4750
+ *
4751
+ * user.country = undefined;
4752
+ * user.age = 26;
4753
+ *
4754
+ * user.getChanges(); // { $set: { age: 26 }, { $unset: { country: 1 } } }
4755
+ *
4756
+ * await user.save();
4757
+ *
4758
+ * user.getChanges(); // { }
4759
+ *
4760
+ * Modifying the object that `getChanges()` returns does not affect the document's
4761
+ * change tracking state. Even if you `delete user.getChanges().$set`, Mongoose
4762
+ * will still send a `$set` to the server.
4763
+ *
4764
+ * @return {Object}
4765
+ * @api public
4766
+ * @method getChanges
4767
+ * @memberOf Document
4768
+ * @instance
4769
+ */
4770
+
4771
+ Document.prototype.getChanges = function() {
4772
+ const delta = this.$__delta();
4773
+ const changes = delta ? delta[1] : {};
4774
+ return changes;
4775
+ };
4776
+
4777
+ /**
4778
+ * Returns a copy of this document with a deep clone of `_doc` and `$__`.
4779
+ *
4780
+ * @return {Document} a copy of this document
4781
+ * @api public
4782
+ * @method $clone
4783
+ * @memberOf Document
4784
+ * @instance
4785
+ */
4786
+
4787
+ Document.prototype.$clone = function() {
4788
+ const Model = this.constructor;
4789
+ const clonedDoc = new Model();
4790
+ clonedDoc.$isNew = this.$isNew;
4791
+ if (this._doc) {
4792
+ clonedDoc._doc = clone(this._doc);
4793
+ }
4794
+ if (this.$__) {
4795
+ const Cache = this.$__.constructor;
4796
+ const clonedCache = new Cache();
4797
+ for (const key of Object.getOwnPropertyNames(this.$__)) {
4798
+ if (key === 'activePaths') {
4799
+ continue;
4800
+ }
4801
+ clonedCache[key] = clone(this.$__[key]);
4802
+ }
4803
+ Object.assign(clonedCache.activePaths, clone({ ...this.$__.activePaths }));
4804
+ clonedDoc.$__ = clonedCache;
4805
+ }
4806
+ return clonedDoc;
4807
+ };
4808
+
4809
+ /*!
4810
+ * Increment this document's version if necessary.
4811
+ */
4812
+
4813
+ Document.prototype._applyVersionIncrement = function _applyVersionIncrement() {
4814
+ if (!this.$__.version) return;
4815
+ const doIncrement = VERSION_INC === (VERSION_INC & this.$__.version);
4816
+
4817
+ this.$__.version = undefined;
4818
+ if (doIncrement) {
4819
+ const key = this.$__schema.options.versionKey;
4820
+ const version = this.$__getValue(key) || 0;
4821
+ this.$__setValue(key, version + 1); // increment version if was successful
4822
+ }
4823
+ };
4824
+
4825
+ /*!
4826
+ * Module exports.
4827
+ */
4828
+
4829
+ Document.ValidationError = ValidationError;
4830
+ module.exports = exports = Document;