create-exam-cli 1.0.0 → 1.0.1

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 (1947) hide show
  1. package/index.js +7 -3
  2. package/package.json +2 -2
  3. package/templates/backend/.env +2 -0
  4. package/templates/backend/node_modules/.bin/bcrypt +16 -0
  5. package/templates/backend/node_modules/.bin/bcrypt.cmd +17 -0
  6. package/templates/backend/node_modules/.bin/bcrypt.ps1 +28 -0
  7. package/templates/backend/node_modules/.bin/nodemon +16 -0
  8. package/templates/backend/node_modules/.bin/nodemon.cmd +17 -0
  9. package/templates/backend/node_modules/.bin/nodemon.ps1 +28 -0
  10. package/templates/backend/node_modules/.bin/nodetouch +16 -0
  11. package/templates/backend/node_modules/.bin/nodetouch.cmd +17 -0
  12. package/templates/backend/node_modules/.bin/nodetouch.ps1 +28 -0
  13. package/templates/backend/node_modules/.bin/semver +16 -0
  14. package/templates/backend/node_modules/.bin/semver.cmd +17 -0
  15. package/templates/backend/node_modules/.bin/semver.ps1 +28 -0
  16. package/templates/backend/node_modules/.package-lock.json +1515 -0
  17. package/templates/backend/node_modules/@mongodb-js/saslprep/LICENSE +22 -0
  18. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/.esm-wrapper.mjs +4 -0
  19. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.d.ts +5 -0
  20. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.d.ts.map +1 -0
  21. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.js +12 -0
  22. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.js.map +1 -0
  23. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts +3 -0
  24. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts.map +1 -0
  25. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js +5 -0
  26. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js.map +1 -0
  27. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts +3 -0
  28. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts.map +1 -0
  29. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.js +5 -0
  30. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.js.map +1 -0
  31. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts +7 -0
  32. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts.map +1 -0
  33. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.js +881 -0
  34. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.js.map +1 -0
  35. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts +2 -0
  36. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts.map +1 -0
  37. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js +83 -0
  38. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js.map +1 -0
  39. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.d.ts +11 -0
  40. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.d.ts.map +1 -0
  41. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.js +65 -0
  42. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.js.map +1 -0
  43. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts +10 -0
  44. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts.map +1 -0
  45. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js +32 -0
  46. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js.map +1 -0
  47. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.d.ts +10 -0
  48. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.d.ts.map +1 -0
  49. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.js +15 -0
  50. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.js.map +1 -0
  51. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.d.ts +2 -0
  52. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.d.ts.map +1 -0
  53. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.js +11 -0
  54. package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.js.map +1 -0
  55. package/templates/backend/node_modules/@mongodb-js/saslprep/package.json +87 -0
  56. package/templates/backend/node_modules/@mongodb-js/saslprep/readme.md +29 -0
  57. package/templates/backend/node_modules/@types/webidl-conversions/LICENSE +21 -0
  58. package/templates/backend/node_modules/@types/webidl-conversions/README.md +15 -0
  59. package/templates/backend/node_modules/@types/webidl-conversions/index.d.ts +91 -0
  60. package/templates/backend/node_modules/@types/webidl-conversions/package.json +30 -0
  61. package/templates/backend/node_modules/@types/whatwg-url/LICENSE +21 -0
  62. package/templates/backend/node_modules/@types/whatwg-url/README.md +15 -0
  63. package/templates/backend/node_modules/@types/whatwg-url/index.d.ts +172 -0
  64. package/templates/backend/node_modules/@types/whatwg-url/lib/URL-impl.d.ts +22 -0
  65. package/templates/backend/node_modules/@types/whatwg-url/lib/URL.d.ts +66 -0
  66. package/templates/backend/node_modules/@types/whatwg-url/lib/URLSearchParams-impl.d.ts +20 -0
  67. package/templates/backend/node_modules/@types/whatwg-url/lib/URLSearchParams.d.ts +92 -0
  68. package/templates/backend/node_modules/@types/whatwg-url/package.json +38 -0
  69. package/templates/backend/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts +4 -0
  70. package/templates/backend/node_modules/accepts/HISTORY.md +250 -0
  71. package/templates/backend/node_modules/accepts/LICENSE +23 -0
  72. package/templates/backend/node_modules/accepts/README.md +140 -0
  73. package/templates/backend/node_modules/accepts/index.js +238 -0
  74. package/templates/backend/node_modules/accepts/package.json +47 -0
  75. package/templates/backend/node_modules/anymatch/LICENSE +15 -0
  76. package/templates/backend/node_modules/anymatch/README.md +87 -0
  77. package/templates/backend/node_modules/anymatch/index.d.ts +20 -0
  78. package/templates/backend/node_modules/anymatch/index.js +104 -0
  79. package/templates/backend/node_modules/anymatch/package.json +48 -0
  80. package/templates/backend/node_modules/balanced-match/LICENSE.md +23 -0
  81. package/templates/backend/node_modules/balanced-match/README.md +57 -0
  82. package/templates/backend/node_modules/balanced-match/dist/commonjs/index.d.ts +9 -0
  83. package/templates/backend/node_modules/balanced-match/dist/commonjs/index.d.ts.map +1 -0
  84. package/templates/backend/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  85. package/templates/backend/node_modules/balanced-match/dist/commonjs/index.js.map +1 -0
  86. package/templates/backend/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  87. package/templates/backend/node_modules/balanced-match/dist/esm/index.d.ts +9 -0
  88. package/templates/backend/node_modules/balanced-match/dist/esm/index.d.ts.map +1 -0
  89. package/templates/backend/node_modules/balanced-match/dist/esm/index.js +54 -0
  90. package/templates/backend/node_modules/balanced-match/dist/esm/index.js.map +1 -0
  91. package/templates/backend/node_modules/balanced-match/dist/esm/package.json +3 -0
  92. package/templates/backend/node_modules/balanced-match/package.json +68 -0
  93. package/templates/backend/node_modules/bcryptjs/LICENSE +27 -0
  94. package/templates/backend/node_modules/bcryptjs/README.md +201 -0
  95. package/templates/backend/node_modules/bcryptjs/bin/bcrypt +23 -0
  96. package/templates/backend/node_modules/bcryptjs/index.d.ts +3 -0
  97. package/templates/backend/node_modules/bcryptjs/index.js +1159 -0
  98. package/templates/backend/node_modules/bcryptjs/package.json +76 -0
  99. package/templates/backend/node_modules/bcryptjs/types.d.ts +157 -0
  100. package/templates/backend/node_modules/bcryptjs/umd/index.d.ts +3 -0
  101. package/templates/backend/node_modules/bcryptjs/umd/index.js +1220 -0
  102. package/templates/backend/node_modules/bcryptjs/umd/package.json +3 -0
  103. package/templates/backend/node_modules/bcryptjs/umd/types.d.ts +157 -0
  104. package/templates/backend/node_modules/binary-extensions/binary-extensions.json +263 -0
  105. package/templates/backend/node_modules/binary-extensions/binary-extensions.json.d.ts +3 -0
  106. package/templates/backend/node_modules/binary-extensions/index.d.ts +14 -0
  107. package/templates/backend/node_modules/binary-extensions/index.js +1 -0
  108. package/templates/backend/node_modules/binary-extensions/license +10 -0
  109. package/templates/backend/node_modules/binary-extensions/package.json +40 -0
  110. package/templates/backend/node_modules/binary-extensions/readme.md +25 -0
  111. package/templates/backend/node_modules/body-parser/LICENSE +23 -0
  112. package/templates/backend/node_modules/body-parser/README.md +494 -0
  113. package/templates/backend/node_modules/body-parser/index.js +71 -0
  114. package/templates/backend/node_modules/body-parser/lib/read.js +247 -0
  115. package/templates/backend/node_modules/body-parser/lib/types/json.js +158 -0
  116. package/templates/backend/node_modules/body-parser/lib/types/raw.js +42 -0
  117. package/templates/backend/node_modules/body-parser/lib/types/text.js +36 -0
  118. package/templates/backend/node_modules/body-parser/lib/types/urlencoded.js +142 -0
  119. package/templates/backend/node_modules/body-parser/lib/utils.js +98 -0
  120. package/templates/backend/node_modules/body-parser/package.json +52 -0
  121. package/templates/backend/node_modules/brace-expansion/LICENSE +23 -0
  122. package/templates/backend/node_modules/brace-expansion/README.md +94 -0
  123. package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.d.ts +6 -0
  124. package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
  125. package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.js +201 -0
  126. package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
  127. package/templates/backend/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  128. package/templates/backend/node_modules/brace-expansion/dist/esm/index.d.ts +6 -0
  129. package/templates/backend/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
  130. package/templates/backend/node_modules/brace-expansion/dist/esm/index.js +197 -0
  131. package/templates/backend/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
  132. package/templates/backend/node_modules/brace-expansion/dist/esm/package.json +3 -0
  133. package/templates/backend/node_modules/brace-expansion/package.json +64 -0
  134. package/templates/backend/node_modules/braces/LICENSE +21 -0
  135. package/templates/backend/node_modules/braces/README.md +586 -0
  136. package/templates/backend/node_modules/braces/index.js +170 -0
  137. package/templates/backend/node_modules/braces/lib/compile.js +60 -0
  138. package/templates/backend/node_modules/braces/lib/constants.js +57 -0
  139. package/templates/backend/node_modules/braces/lib/expand.js +113 -0
  140. package/templates/backend/node_modules/braces/lib/parse.js +331 -0
  141. package/templates/backend/node_modules/braces/lib/stringify.js +32 -0
  142. package/templates/backend/node_modules/braces/lib/utils.js +122 -0
  143. package/templates/backend/node_modules/braces/package.json +77 -0
  144. package/templates/backend/node_modules/bson/LICENSE.md +201 -0
  145. package/templates/backend/node_modules/bson/README.md +291 -0
  146. package/templates/backend/node_modules/bson/bson.d.ts +1770 -0
  147. package/templates/backend/node_modules/bson/etc/prepare.js +19 -0
  148. package/templates/backend/node_modules/bson/lib/bson.bundle.js +4750 -0
  149. package/templates/backend/node_modules/bson/lib/bson.bundle.js.map +1 -0
  150. package/templates/backend/node_modules/bson/lib/bson.cjs +4745 -0
  151. package/templates/backend/node_modules/bson/lib/bson.cjs.map +1 -0
  152. package/templates/backend/node_modules/bson/lib/bson.mjs +4712 -0
  153. package/templates/backend/node_modules/bson/lib/bson.mjs.map +1 -0
  154. package/templates/backend/node_modules/bson/lib/bson.node.mjs +4712 -0
  155. package/templates/backend/node_modules/bson/lib/bson.node.mjs.map +1 -0
  156. package/templates/backend/node_modules/bson/lib/bson.rn.cjs +4755 -0
  157. package/templates/backend/node_modules/bson/lib/bson.rn.cjs.map +1 -0
  158. package/templates/backend/node_modules/bson/package.json +118 -0
  159. package/templates/backend/node_modules/bson/src/binary.ts +751 -0
  160. package/templates/backend/node_modules/bson/src/bson.ts +255 -0
  161. package/templates/backend/node_modules/bson/src/bson_value.ts +55 -0
  162. package/templates/backend/node_modules/bson/src/code.ts +69 -0
  163. package/templates/backend/node_modules/bson/src/constants.ts +147 -0
  164. package/templates/backend/node_modules/bson/src/db_ref.ts +128 -0
  165. package/templates/backend/node_modules/bson/src/decimal128.ts +855 -0
  166. package/templates/backend/node_modules/bson/src/double.ts +115 -0
  167. package/templates/backend/node_modules/bson/src/error.ts +105 -0
  168. package/templates/backend/node_modules/bson/src/extended_json.ts +533 -0
  169. package/templates/backend/node_modules/bson/src/index.ts +19 -0
  170. package/templates/backend/node_modules/bson/src/int_32.ts +101 -0
  171. package/templates/backend/node_modules/bson/src/long.ts +1240 -0
  172. package/templates/backend/node_modules/bson/src/max_key.ts +31 -0
  173. package/templates/backend/node_modules/bson/src/min_key.ts +31 -0
  174. package/templates/backend/node_modules/bson/src/objectid.ts +382 -0
  175. package/templates/backend/node_modules/bson/src/parse_utf8.ts +35 -0
  176. package/templates/backend/node_modules/bson/src/parser/calculate_size.ts +218 -0
  177. package/templates/backend/node_modules/bson/src/parser/deserializer.ts +627 -0
  178. package/templates/backend/node_modules/bson/src/parser/on_demand/index.ts +32 -0
  179. package/templates/backend/node_modules/bson/src/parser/on_demand/parse_to_elements.ts +190 -0
  180. package/templates/backend/node_modules/bson/src/parser/serializer.ts +954 -0
  181. package/templates/backend/node_modules/bson/src/parser/utils.ts +69 -0
  182. package/templates/backend/node_modules/bson/src/regexp.ts +114 -0
  183. package/templates/backend/node_modules/bson/src/symbol.ts +55 -0
  184. package/templates/backend/node_modules/bson/src/timestamp.ts +176 -0
  185. package/templates/backend/node_modules/bson/src/utils/byte_utils.ts +80 -0
  186. package/templates/backend/node_modules/bson/src/utils/latin.ts +104 -0
  187. package/templates/backend/node_modules/bson/src/utils/node_byte_utils.ts +193 -0
  188. package/templates/backend/node_modules/bson/src/utils/number_utils.ts +204 -0
  189. package/templates/backend/node_modules/bson/src/utils/string_utils.ts +44 -0
  190. package/templates/backend/node_modules/bson/src/utils/web_byte_utils.ts +304 -0
  191. package/templates/backend/node_modules/buffer-equal-constant-time/.travis.yml +4 -0
  192. package/templates/backend/node_modules/buffer-equal-constant-time/LICENSE.txt +12 -0
  193. package/templates/backend/node_modules/buffer-equal-constant-time/README.md +50 -0
  194. package/templates/backend/node_modules/buffer-equal-constant-time/index.js +41 -0
  195. package/templates/backend/node_modules/buffer-equal-constant-time/package.json +21 -0
  196. package/templates/backend/node_modules/buffer-equal-constant-time/test.js +42 -0
  197. package/templates/backend/node_modules/bytes/History.md +97 -0
  198. package/templates/backend/node_modules/bytes/LICENSE +23 -0
  199. package/templates/backend/node_modules/bytes/Readme.md +152 -0
  200. package/templates/backend/node_modules/bytes/index.js +170 -0
  201. package/templates/backend/node_modules/bytes/package.json +42 -0
  202. package/templates/backend/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
  203. package/templates/backend/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
  204. package/templates/backend/node_modules/call-bind-apply-helpers/.nycrc +9 -0
  205. package/templates/backend/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
  206. package/templates/backend/node_modules/call-bind-apply-helpers/LICENSE +21 -0
  207. package/templates/backend/node_modules/call-bind-apply-helpers/README.md +62 -0
  208. package/templates/backend/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
  209. package/templates/backend/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
  210. package/templates/backend/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
  211. package/templates/backend/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
  212. package/templates/backend/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
  213. package/templates/backend/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
  214. package/templates/backend/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
  215. package/templates/backend/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
  216. package/templates/backend/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
  217. package/templates/backend/node_modules/call-bind-apply-helpers/index.js +15 -0
  218. package/templates/backend/node_modules/call-bind-apply-helpers/package.json +85 -0
  219. package/templates/backend/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
  220. package/templates/backend/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
  221. package/templates/backend/node_modules/call-bind-apply-helpers/test/index.js +63 -0
  222. package/templates/backend/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
  223. package/templates/backend/node_modules/call-bound/.eslintrc +13 -0
  224. package/templates/backend/node_modules/call-bound/.github/FUNDING.yml +12 -0
  225. package/templates/backend/node_modules/call-bound/.nycrc +9 -0
  226. package/templates/backend/node_modules/call-bound/CHANGELOG.md +42 -0
  227. package/templates/backend/node_modules/call-bound/LICENSE +21 -0
  228. package/templates/backend/node_modules/call-bound/README.md +53 -0
  229. package/templates/backend/node_modules/call-bound/index.d.ts +94 -0
  230. package/templates/backend/node_modules/call-bound/index.js +19 -0
  231. package/templates/backend/node_modules/call-bound/package.json +99 -0
  232. package/templates/backend/node_modules/call-bound/test/index.js +61 -0
  233. package/templates/backend/node_modules/call-bound/tsconfig.json +10 -0
  234. package/templates/backend/node_modules/chokidar/LICENSE +21 -0
  235. package/templates/backend/node_modules/chokidar/README.md +308 -0
  236. package/templates/backend/node_modules/chokidar/index.js +973 -0
  237. package/templates/backend/node_modules/chokidar/lib/constants.js +66 -0
  238. package/templates/backend/node_modules/chokidar/lib/fsevents-handler.js +526 -0
  239. package/templates/backend/node_modules/chokidar/lib/nodefs-handler.js +654 -0
  240. package/templates/backend/node_modules/chokidar/package.json +70 -0
  241. package/templates/backend/node_modules/chokidar/types/index.d.ts +192 -0
  242. package/templates/backend/node_modules/content-disposition/LICENSE +22 -0
  243. package/templates/backend/node_modules/content-disposition/README.md +141 -0
  244. package/templates/backend/node_modules/content-disposition/index.js +536 -0
  245. package/templates/backend/node_modules/content-disposition/package.json +40 -0
  246. package/templates/backend/node_modules/content-type/HISTORY.md +29 -0
  247. package/templates/backend/node_modules/content-type/LICENSE +22 -0
  248. package/templates/backend/node_modules/content-type/README.md +94 -0
  249. package/templates/backend/node_modules/content-type/index.js +225 -0
  250. package/templates/backend/node_modules/content-type/package.json +42 -0
  251. package/templates/backend/node_modules/cookie/LICENSE +24 -0
  252. package/templates/backend/node_modules/cookie/README.md +317 -0
  253. package/templates/backend/node_modules/cookie/SECURITY.md +25 -0
  254. package/templates/backend/node_modules/cookie/index.js +335 -0
  255. package/templates/backend/node_modules/cookie/package.json +44 -0
  256. package/templates/backend/node_modules/cookie-signature/History.md +70 -0
  257. package/templates/backend/node_modules/cookie-signature/LICENSE +22 -0
  258. package/templates/backend/node_modules/cookie-signature/Readme.md +23 -0
  259. package/templates/backend/node_modules/cookie-signature/index.js +47 -0
  260. package/templates/backend/node_modules/cookie-signature/package.json +24 -0
  261. package/templates/backend/node_modules/cors/LICENSE +22 -0
  262. package/templates/backend/node_modules/cors/README.md +277 -0
  263. package/templates/backend/node_modules/cors/lib/index.js +238 -0
  264. package/templates/backend/node_modules/cors/package.json +42 -0
  265. package/templates/backend/node_modules/debug/LICENSE +20 -0
  266. package/templates/backend/node_modules/debug/README.md +481 -0
  267. package/templates/backend/node_modules/debug/package.json +64 -0
  268. package/templates/backend/node_modules/debug/src/browser.js +272 -0
  269. package/templates/backend/node_modules/debug/src/common.js +292 -0
  270. package/templates/backend/node_modules/debug/src/index.js +10 -0
  271. package/templates/backend/node_modules/debug/src/node.js +263 -0
  272. package/templates/backend/node_modules/depd/History.md +103 -0
  273. package/templates/backend/node_modules/depd/LICENSE +22 -0
  274. package/templates/backend/node_modules/depd/Readme.md +280 -0
  275. package/templates/backend/node_modules/depd/index.js +538 -0
  276. package/templates/backend/node_modules/depd/lib/browser/index.js +77 -0
  277. package/templates/backend/node_modules/depd/package.json +45 -0
  278. package/templates/backend/node_modules/dotenv/CHANGELOG.md +643 -0
  279. package/templates/backend/node_modules/dotenv/LICENSE +23 -0
  280. package/templates/backend/node_modules/dotenv/README-es.md +757 -0
  281. package/templates/backend/node_modules/dotenv/README.md +812 -0
  282. package/templates/backend/node_modules/dotenv/SECURITY.md +1 -0
  283. package/templates/backend/node_modules/dotenv/config.d.ts +1 -0
  284. package/templates/backend/node_modules/dotenv/config.js +9 -0
  285. package/templates/backend/node_modules/dotenv/lib/cli-options.js +17 -0
  286. package/templates/backend/node_modules/dotenv/lib/env-options.js +28 -0
  287. package/templates/backend/node_modules/dotenv/lib/main.d.ts +179 -0
  288. package/templates/backend/node_modules/dotenv/lib/main.js +423 -0
  289. package/templates/backend/node_modules/dotenv/package.json +62 -0
  290. package/templates/backend/node_modules/dotenv/skills/dotenv/SKILL.md +200 -0
  291. package/templates/backend/node_modules/dotenv/skills/dotenvx/SKILL.md +118 -0
  292. package/templates/backend/node_modules/dunder-proto/.eslintrc +5 -0
  293. package/templates/backend/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
  294. package/templates/backend/node_modules/dunder-proto/.nycrc +13 -0
  295. package/templates/backend/node_modules/dunder-proto/CHANGELOG.md +24 -0
  296. package/templates/backend/node_modules/dunder-proto/LICENSE +21 -0
  297. package/templates/backend/node_modules/dunder-proto/README.md +54 -0
  298. package/templates/backend/node_modules/dunder-proto/get.d.ts +5 -0
  299. package/templates/backend/node_modules/dunder-proto/get.js +30 -0
  300. package/templates/backend/node_modules/dunder-proto/package.json +76 -0
  301. package/templates/backend/node_modules/dunder-proto/set.d.ts +5 -0
  302. package/templates/backend/node_modules/dunder-proto/set.js +35 -0
  303. package/templates/backend/node_modules/dunder-proto/test/get.js +34 -0
  304. package/templates/backend/node_modules/dunder-proto/test/index.js +4 -0
  305. package/templates/backend/node_modules/dunder-proto/test/set.js +50 -0
  306. package/templates/backend/node_modules/dunder-proto/tsconfig.json +9 -0
  307. package/templates/backend/node_modules/ecdsa-sig-formatter/CODEOWNERS +1 -0
  308. package/templates/backend/node_modules/ecdsa-sig-formatter/LICENSE +201 -0
  309. package/templates/backend/node_modules/ecdsa-sig-formatter/README.md +65 -0
  310. package/templates/backend/node_modules/ecdsa-sig-formatter/package.json +46 -0
  311. package/templates/backend/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.d.ts +17 -0
  312. package/templates/backend/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js +187 -0
  313. package/templates/backend/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js +23 -0
  314. package/templates/backend/node_modules/ee-first/LICENSE +22 -0
  315. package/templates/backend/node_modules/ee-first/README.md +80 -0
  316. package/templates/backend/node_modules/ee-first/index.js +95 -0
  317. package/templates/backend/node_modules/ee-first/package.json +29 -0
  318. package/templates/backend/node_modules/encodeurl/LICENSE +22 -0
  319. package/templates/backend/node_modules/encodeurl/README.md +109 -0
  320. package/templates/backend/node_modules/encodeurl/index.js +60 -0
  321. package/templates/backend/node_modules/encodeurl/package.json +40 -0
  322. package/templates/backend/node_modules/es-define-property/.eslintrc +13 -0
  323. package/templates/backend/node_modules/es-define-property/.github/FUNDING.yml +12 -0
  324. package/templates/backend/node_modules/es-define-property/.nycrc +9 -0
  325. package/templates/backend/node_modules/es-define-property/CHANGELOG.md +29 -0
  326. package/templates/backend/node_modules/es-define-property/LICENSE +21 -0
  327. package/templates/backend/node_modules/es-define-property/README.md +49 -0
  328. package/templates/backend/node_modules/es-define-property/index.d.ts +3 -0
  329. package/templates/backend/node_modules/es-define-property/index.js +14 -0
  330. package/templates/backend/node_modules/es-define-property/package.json +81 -0
  331. package/templates/backend/node_modules/es-define-property/test/index.js +56 -0
  332. package/templates/backend/node_modules/es-define-property/tsconfig.json +10 -0
  333. package/templates/backend/node_modules/es-errors/.eslintrc +5 -0
  334. package/templates/backend/node_modules/es-errors/.github/FUNDING.yml +12 -0
  335. package/templates/backend/node_modules/es-errors/CHANGELOG.md +40 -0
  336. package/templates/backend/node_modules/es-errors/LICENSE +21 -0
  337. package/templates/backend/node_modules/es-errors/README.md +55 -0
  338. package/templates/backend/node_modules/es-errors/eval.d.ts +3 -0
  339. package/templates/backend/node_modules/es-errors/eval.js +4 -0
  340. package/templates/backend/node_modules/es-errors/index.d.ts +3 -0
  341. package/templates/backend/node_modules/es-errors/index.js +4 -0
  342. package/templates/backend/node_modules/es-errors/package.json +80 -0
  343. package/templates/backend/node_modules/es-errors/range.d.ts +3 -0
  344. package/templates/backend/node_modules/es-errors/range.js +4 -0
  345. package/templates/backend/node_modules/es-errors/ref.d.ts +3 -0
  346. package/templates/backend/node_modules/es-errors/ref.js +4 -0
  347. package/templates/backend/node_modules/es-errors/syntax.d.ts +3 -0
  348. package/templates/backend/node_modules/es-errors/syntax.js +4 -0
  349. package/templates/backend/node_modules/es-errors/test/index.js +19 -0
  350. package/templates/backend/node_modules/es-errors/tsconfig.json +49 -0
  351. package/templates/backend/node_modules/es-errors/type.d.ts +3 -0
  352. package/templates/backend/node_modules/es-errors/type.js +4 -0
  353. package/templates/backend/node_modules/es-errors/uri.d.ts +3 -0
  354. package/templates/backend/node_modules/es-errors/uri.js +4 -0
  355. package/templates/backend/node_modules/es-object-atoms/.eslintrc +16 -0
  356. package/templates/backend/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
  357. package/templates/backend/node_modules/es-object-atoms/CHANGELOG.md +37 -0
  358. package/templates/backend/node_modules/es-object-atoms/LICENSE +21 -0
  359. package/templates/backend/node_modules/es-object-atoms/README.md +63 -0
  360. package/templates/backend/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
  361. package/templates/backend/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
  362. package/templates/backend/node_modules/es-object-atoms/ToObject.d.ts +7 -0
  363. package/templates/backend/node_modules/es-object-atoms/ToObject.js +10 -0
  364. package/templates/backend/node_modules/es-object-atoms/index.d.ts +3 -0
  365. package/templates/backend/node_modules/es-object-atoms/index.js +4 -0
  366. package/templates/backend/node_modules/es-object-atoms/isObject.d.ts +3 -0
  367. package/templates/backend/node_modules/es-object-atoms/isObject.js +6 -0
  368. package/templates/backend/node_modules/es-object-atoms/package.json +80 -0
  369. package/templates/backend/node_modules/es-object-atoms/test/index.js +38 -0
  370. package/templates/backend/node_modules/es-object-atoms/tsconfig.json +6 -0
  371. package/templates/backend/node_modules/escape-html/LICENSE +24 -0
  372. package/templates/backend/node_modules/escape-html/Readme.md +43 -0
  373. package/templates/backend/node_modules/escape-html/index.js +78 -0
  374. package/templates/backend/node_modules/escape-html/package.json +24 -0
  375. package/templates/backend/node_modules/etag/HISTORY.md +83 -0
  376. package/templates/backend/node_modules/etag/LICENSE +22 -0
  377. package/templates/backend/node_modules/etag/README.md +159 -0
  378. package/templates/backend/node_modules/etag/index.js +131 -0
  379. package/templates/backend/node_modules/etag/package.json +47 -0
  380. package/templates/backend/node_modules/express/LICENSE +24 -0
  381. package/templates/backend/node_modules/express/Readme.md +276 -0
  382. package/templates/backend/node_modules/express/index.js +11 -0
  383. package/templates/backend/node_modules/express/lib/application.js +631 -0
  384. package/templates/backend/node_modules/express/lib/express.js +81 -0
  385. package/templates/backend/node_modules/express/lib/request.js +514 -0
  386. package/templates/backend/node_modules/express/lib/response.js +1053 -0
  387. package/templates/backend/node_modules/express/lib/utils.js +271 -0
  388. package/templates/backend/node_modules/express/lib/view.js +205 -0
  389. package/templates/backend/node_modules/express/package.json +99 -0
  390. package/templates/backend/node_modules/fill-range/LICENSE +21 -0
  391. package/templates/backend/node_modules/fill-range/README.md +237 -0
  392. package/templates/backend/node_modules/fill-range/index.js +248 -0
  393. package/templates/backend/node_modules/fill-range/package.json +74 -0
  394. package/templates/backend/node_modules/finalhandler/HISTORY.md +239 -0
  395. package/templates/backend/node_modules/finalhandler/LICENSE +22 -0
  396. package/templates/backend/node_modules/finalhandler/README.md +150 -0
  397. package/templates/backend/node_modules/finalhandler/index.js +293 -0
  398. package/templates/backend/node_modules/finalhandler/package.json +47 -0
  399. package/templates/backend/node_modules/forwarded/HISTORY.md +21 -0
  400. package/templates/backend/node_modules/forwarded/LICENSE +22 -0
  401. package/templates/backend/node_modules/forwarded/README.md +57 -0
  402. package/templates/backend/node_modules/forwarded/index.js +90 -0
  403. package/templates/backend/node_modules/forwarded/package.json +45 -0
  404. package/templates/backend/node_modules/fresh/HISTORY.md +80 -0
  405. package/templates/backend/node_modules/fresh/LICENSE +23 -0
  406. package/templates/backend/node_modules/fresh/README.md +117 -0
  407. package/templates/backend/node_modules/fresh/index.js +136 -0
  408. package/templates/backend/node_modules/fresh/package.json +46 -0
  409. package/templates/backend/node_modules/function-bind/.eslintrc +21 -0
  410. package/templates/backend/node_modules/function-bind/.github/FUNDING.yml +12 -0
  411. package/templates/backend/node_modules/function-bind/.github/SECURITY.md +3 -0
  412. package/templates/backend/node_modules/function-bind/.nycrc +13 -0
  413. package/templates/backend/node_modules/function-bind/CHANGELOG.md +136 -0
  414. package/templates/backend/node_modules/function-bind/LICENSE +20 -0
  415. package/templates/backend/node_modules/function-bind/README.md +46 -0
  416. package/templates/backend/node_modules/function-bind/implementation.js +84 -0
  417. package/templates/backend/node_modules/function-bind/index.js +5 -0
  418. package/templates/backend/node_modules/function-bind/package.json +87 -0
  419. package/templates/backend/node_modules/function-bind/test/.eslintrc +9 -0
  420. package/templates/backend/node_modules/function-bind/test/index.js +252 -0
  421. package/templates/backend/node_modules/get-intrinsic/.eslintrc +42 -0
  422. package/templates/backend/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
  423. package/templates/backend/node_modules/get-intrinsic/.nycrc +9 -0
  424. package/templates/backend/node_modules/get-intrinsic/CHANGELOG.md +186 -0
  425. package/templates/backend/node_modules/get-intrinsic/LICENSE +21 -0
  426. package/templates/backend/node_modules/get-intrinsic/README.md +71 -0
  427. package/templates/backend/node_modules/get-intrinsic/index.js +378 -0
  428. package/templates/backend/node_modules/get-intrinsic/package.json +97 -0
  429. package/templates/backend/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
  430. package/templates/backend/node_modules/get-proto/.eslintrc +10 -0
  431. package/templates/backend/node_modules/get-proto/.github/FUNDING.yml +12 -0
  432. package/templates/backend/node_modules/get-proto/.nycrc +9 -0
  433. package/templates/backend/node_modules/get-proto/CHANGELOG.md +21 -0
  434. package/templates/backend/node_modules/get-proto/LICENSE +21 -0
  435. package/templates/backend/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
  436. package/templates/backend/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
  437. package/templates/backend/node_modules/get-proto/README.md +50 -0
  438. package/templates/backend/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
  439. package/templates/backend/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
  440. package/templates/backend/node_modules/get-proto/index.d.ts +5 -0
  441. package/templates/backend/node_modules/get-proto/index.js +27 -0
  442. package/templates/backend/node_modules/get-proto/package.json +81 -0
  443. package/templates/backend/node_modules/get-proto/test/index.js +68 -0
  444. package/templates/backend/node_modules/get-proto/tsconfig.json +9 -0
  445. package/templates/backend/node_modules/glob-parent/CHANGELOG.md +110 -0
  446. package/templates/backend/node_modules/glob-parent/LICENSE +15 -0
  447. package/templates/backend/node_modules/glob-parent/README.md +137 -0
  448. package/templates/backend/node_modules/glob-parent/index.js +42 -0
  449. package/templates/backend/node_modules/glob-parent/package.json +48 -0
  450. package/templates/backend/node_modules/gopd/.eslintrc +16 -0
  451. package/templates/backend/node_modules/gopd/.github/FUNDING.yml +12 -0
  452. package/templates/backend/node_modules/gopd/CHANGELOG.md +45 -0
  453. package/templates/backend/node_modules/gopd/LICENSE +21 -0
  454. package/templates/backend/node_modules/gopd/README.md +40 -0
  455. package/templates/backend/node_modules/gopd/gOPD.d.ts +1 -0
  456. package/templates/backend/node_modules/gopd/gOPD.js +4 -0
  457. package/templates/backend/node_modules/gopd/index.d.ts +5 -0
  458. package/templates/backend/node_modules/gopd/index.js +15 -0
  459. package/templates/backend/node_modules/gopd/package.json +77 -0
  460. package/templates/backend/node_modules/gopd/test/index.js +36 -0
  461. package/templates/backend/node_modules/gopd/tsconfig.json +9 -0
  462. package/templates/backend/node_modules/has-flag/index.js +8 -0
  463. package/templates/backend/node_modules/has-flag/license +9 -0
  464. package/templates/backend/node_modules/has-flag/package.json +44 -0
  465. package/templates/backend/node_modules/has-flag/readme.md +70 -0
  466. package/templates/backend/node_modules/has-symbols/.eslintrc +11 -0
  467. package/templates/backend/node_modules/has-symbols/.github/FUNDING.yml +12 -0
  468. package/templates/backend/node_modules/has-symbols/.nycrc +9 -0
  469. package/templates/backend/node_modules/has-symbols/CHANGELOG.md +91 -0
  470. package/templates/backend/node_modules/has-symbols/LICENSE +21 -0
  471. package/templates/backend/node_modules/has-symbols/README.md +46 -0
  472. package/templates/backend/node_modules/has-symbols/index.d.ts +3 -0
  473. package/templates/backend/node_modules/has-symbols/index.js +14 -0
  474. package/templates/backend/node_modules/has-symbols/package.json +111 -0
  475. package/templates/backend/node_modules/has-symbols/shams.d.ts +3 -0
  476. package/templates/backend/node_modules/has-symbols/shams.js +45 -0
  477. package/templates/backend/node_modules/has-symbols/test/index.js +22 -0
  478. package/templates/backend/node_modules/has-symbols/test/shams/core-js.js +29 -0
  479. package/templates/backend/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
  480. package/templates/backend/node_modules/has-symbols/test/tests.js +58 -0
  481. package/templates/backend/node_modules/has-symbols/tsconfig.json +10 -0
  482. package/templates/backend/node_modules/hasown/.github/FUNDING.yml +12 -0
  483. package/templates/backend/node_modules/hasown/.nycrc +13 -0
  484. package/templates/backend/node_modules/hasown/CHANGELOG.md +51 -0
  485. package/templates/backend/node_modules/hasown/LICENSE +21 -0
  486. package/templates/backend/node_modules/hasown/README.md +40 -0
  487. package/templates/backend/node_modules/hasown/eslint.config.mjs +6 -0
  488. package/templates/backend/node_modules/hasown/index.d.ts +4 -0
  489. package/templates/backend/node_modules/hasown/index.js +8 -0
  490. package/templates/backend/node_modules/hasown/package.json +92 -0
  491. package/templates/backend/node_modules/hasown/tsconfig.json +6 -0
  492. package/templates/backend/node_modules/http-errors/HISTORY.md +186 -0
  493. package/templates/backend/node_modules/http-errors/LICENSE +23 -0
  494. package/templates/backend/node_modules/http-errors/README.md +169 -0
  495. package/templates/backend/node_modules/http-errors/index.js +290 -0
  496. package/templates/backend/node_modules/http-errors/package.json +54 -0
  497. package/templates/backend/node_modules/iconv-lite/LICENSE +21 -0
  498. package/templates/backend/node_modules/iconv-lite/README.md +138 -0
  499. package/templates/backend/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
  500. package/templates/backend/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
  501. package/templates/backend/node_modules/iconv-lite/encodings/index.js +23 -0
  502. package/templates/backend/node_modules/iconv-lite/encodings/internal.js +218 -0
  503. package/templates/backend/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
  504. package/templates/backend/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
  505. package/templates/backend/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
  506. package/templates/backend/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
  507. package/templates/backend/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
  508. package/templates/backend/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
  509. package/templates/backend/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
  510. package/templates/backend/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
  511. package/templates/backend/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
  512. package/templates/backend/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
  513. package/templates/backend/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
  514. package/templates/backend/node_modules/iconv-lite/encodings/utf16.js +187 -0
  515. package/templates/backend/node_modules/iconv-lite/encodings/utf32.js +307 -0
  516. package/templates/backend/node_modules/iconv-lite/encodings/utf7.js +283 -0
  517. package/templates/backend/node_modules/iconv-lite/lib/bom-handling.js +48 -0
  518. package/templates/backend/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
  519. package/templates/backend/node_modules/iconv-lite/lib/index.d.ts +129 -0
  520. package/templates/backend/node_modules/iconv-lite/lib/index.js +182 -0
  521. package/templates/backend/node_modules/iconv-lite/lib/streams.js +105 -0
  522. package/templates/backend/node_modules/iconv-lite/package.json +70 -0
  523. package/templates/backend/node_modules/iconv-lite/types/encodings.d.ts +423 -0
  524. package/templates/backend/node_modules/ignore-by-default/LICENSE +14 -0
  525. package/templates/backend/node_modules/ignore-by-default/README.md +26 -0
  526. package/templates/backend/node_modules/ignore-by-default/index.js +12 -0
  527. package/templates/backend/node_modules/ignore-by-default/package.json +34 -0
  528. package/templates/backend/node_modules/inherits/LICENSE +16 -0
  529. package/templates/backend/node_modules/inherits/README.md +42 -0
  530. package/templates/backend/node_modules/inherits/inherits.js +9 -0
  531. package/templates/backend/node_modules/inherits/inherits_browser.js +27 -0
  532. package/templates/backend/node_modules/inherits/package.json +29 -0
  533. package/templates/backend/node_modules/ipaddr.js/LICENSE +19 -0
  534. package/templates/backend/node_modules/ipaddr.js/README.md +233 -0
  535. package/templates/backend/node_modules/ipaddr.js/ipaddr.min.js +1 -0
  536. package/templates/backend/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
  537. package/templates/backend/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
  538. package/templates/backend/node_modules/ipaddr.js/package.json +35 -0
  539. package/templates/backend/node_modules/is-binary-path/index.d.ts +17 -0
  540. package/templates/backend/node_modules/is-binary-path/index.js +7 -0
  541. package/templates/backend/node_modules/is-binary-path/license +9 -0
  542. package/templates/backend/node_modules/is-binary-path/package.json +40 -0
  543. package/templates/backend/node_modules/is-binary-path/readme.md +34 -0
  544. package/templates/backend/node_modules/is-extglob/LICENSE +21 -0
  545. package/templates/backend/node_modules/is-extglob/README.md +107 -0
  546. package/templates/backend/node_modules/is-extglob/index.js +20 -0
  547. package/templates/backend/node_modules/is-extglob/package.json +69 -0
  548. package/templates/backend/node_modules/is-glob/LICENSE +21 -0
  549. package/templates/backend/node_modules/is-glob/README.md +206 -0
  550. package/templates/backend/node_modules/is-glob/index.js +150 -0
  551. package/templates/backend/node_modules/is-glob/package.json +81 -0
  552. package/templates/backend/node_modules/is-number/LICENSE +21 -0
  553. package/templates/backend/node_modules/is-number/README.md +187 -0
  554. package/templates/backend/node_modules/is-number/index.js +18 -0
  555. package/templates/backend/node_modules/is-number/package.json +82 -0
  556. package/templates/backend/node_modules/is-promise/LICENSE +19 -0
  557. package/templates/backend/node_modules/is-promise/index.d.ts +2 -0
  558. package/templates/backend/node_modules/is-promise/index.js +6 -0
  559. package/templates/backend/node_modules/is-promise/index.mjs +3 -0
  560. package/templates/backend/node_modules/is-promise/package.json +30 -0
  561. package/templates/backend/node_modules/is-promise/readme.md +33 -0
  562. package/templates/backend/node_modules/jsonwebtoken/LICENSE +21 -0
  563. package/templates/backend/node_modules/jsonwebtoken/README.md +396 -0
  564. package/templates/backend/node_modules/jsonwebtoken/decode.js +30 -0
  565. package/templates/backend/node_modules/jsonwebtoken/index.js +8 -0
  566. package/templates/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js +14 -0
  567. package/templates/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js +13 -0
  568. package/templates/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js +13 -0
  569. package/templates/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js +3 -0
  570. package/templates/backend/node_modules/jsonwebtoken/lib/psSupported.js +3 -0
  571. package/templates/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js +3 -0
  572. package/templates/backend/node_modules/jsonwebtoken/lib/timespan.js +18 -0
  573. package/templates/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js +66 -0
  574. package/templates/backend/node_modules/jsonwebtoken/package.json +70 -0
  575. package/templates/backend/node_modules/jsonwebtoken/sign.js +253 -0
  576. package/templates/backend/node_modules/jsonwebtoken/verify.js +263 -0
  577. package/templates/backend/node_modules/jwa/LICENSE +17 -0
  578. package/templates/backend/node_modules/jwa/README.md +150 -0
  579. package/templates/backend/node_modules/jwa/index.js +266 -0
  580. package/templates/backend/node_modules/jwa/opslevel.yml +6 -0
  581. package/templates/backend/node_modules/jwa/package.json +37 -0
  582. package/templates/backend/node_modules/jws/CHANGELOG.md +56 -0
  583. package/templates/backend/node_modules/jws/LICENSE +17 -0
  584. package/templates/backend/node_modules/jws/index.js +22 -0
  585. package/templates/backend/node_modules/jws/lib/data-stream.js +55 -0
  586. package/templates/backend/node_modules/jws/lib/sign-stream.js +83 -0
  587. package/templates/backend/node_modules/jws/lib/tostring.js +10 -0
  588. package/templates/backend/node_modules/jws/lib/verify-stream.js +125 -0
  589. package/templates/backend/node_modules/jws/opslevel.yml +6 -0
  590. package/templates/backend/node_modules/jws/package.json +34 -0
  591. package/templates/backend/node_modules/jws/readme.md +255 -0
  592. package/templates/backend/node_modules/kareem/CHANGELOG.md +845 -0
  593. package/templates/backend/node_modules/kareem/LICENSE +202 -0
  594. package/templates/backend/node_modules/kareem/README.md +385 -0
  595. package/templates/backend/node_modules/kareem/SECURITY.md +5 -0
  596. package/templates/backend/node_modules/kareem/index.d.ts +31 -0
  597. package/templates/backend/node_modules/kareem/index.js +553 -0
  598. package/templates/backend/node_modules/kareem/package.json +28 -0
  599. package/templates/backend/node_modules/lodash.includes/LICENSE +47 -0
  600. package/templates/backend/node_modules/lodash.includes/README.md +18 -0
  601. package/templates/backend/node_modules/lodash.includes/index.js +745 -0
  602. package/templates/backend/node_modules/lodash.includes/package.json +17 -0
  603. package/templates/backend/node_modules/lodash.isboolean/LICENSE +22 -0
  604. package/templates/backend/node_modules/lodash.isboolean/README.md +18 -0
  605. package/templates/backend/node_modules/lodash.isboolean/index.js +70 -0
  606. package/templates/backend/node_modules/lodash.isboolean/package.json +17 -0
  607. package/templates/backend/node_modules/lodash.isinteger/LICENSE +47 -0
  608. package/templates/backend/node_modules/lodash.isinteger/README.md +18 -0
  609. package/templates/backend/node_modules/lodash.isinteger/index.js +265 -0
  610. package/templates/backend/node_modules/lodash.isinteger/package.json +17 -0
  611. package/templates/backend/node_modules/lodash.isnumber/LICENSE +22 -0
  612. package/templates/backend/node_modules/lodash.isnumber/README.md +18 -0
  613. package/templates/backend/node_modules/lodash.isnumber/index.js +79 -0
  614. package/templates/backend/node_modules/lodash.isnumber/package.json +17 -0
  615. package/templates/backend/node_modules/lodash.isplainobject/LICENSE +47 -0
  616. package/templates/backend/node_modules/lodash.isplainobject/README.md +18 -0
  617. package/templates/backend/node_modules/lodash.isplainobject/index.js +139 -0
  618. package/templates/backend/node_modules/lodash.isplainobject/package.json +17 -0
  619. package/templates/backend/node_modules/lodash.isstring/LICENSE +22 -0
  620. package/templates/backend/node_modules/lodash.isstring/README.md +18 -0
  621. package/templates/backend/node_modules/lodash.isstring/index.js +95 -0
  622. package/templates/backend/node_modules/lodash.isstring/package.json +17 -0
  623. package/templates/backend/node_modules/lodash.once/LICENSE +47 -0
  624. package/templates/backend/node_modules/lodash.once/README.md +18 -0
  625. package/templates/backend/node_modules/lodash.once/index.js +294 -0
  626. package/templates/backend/node_modules/lodash.once/package.json +17 -0
  627. package/templates/backend/node_modules/math-intrinsics/.eslintrc +16 -0
  628. package/templates/backend/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
  629. package/templates/backend/node_modules/math-intrinsics/CHANGELOG.md +24 -0
  630. package/templates/backend/node_modules/math-intrinsics/LICENSE +21 -0
  631. package/templates/backend/node_modules/math-intrinsics/README.md +50 -0
  632. package/templates/backend/node_modules/math-intrinsics/abs.d.ts +1 -0
  633. package/templates/backend/node_modules/math-intrinsics/abs.js +4 -0
  634. package/templates/backend/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
  635. package/templates/backend/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
  636. package/templates/backend/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
  637. package/templates/backend/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
  638. package/templates/backend/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
  639. package/templates/backend/node_modules/math-intrinsics/constants/maxValue.js +5 -0
  640. package/templates/backend/node_modules/math-intrinsics/floor.d.ts +1 -0
  641. package/templates/backend/node_modules/math-intrinsics/floor.js +4 -0
  642. package/templates/backend/node_modules/math-intrinsics/isFinite.d.ts +3 -0
  643. package/templates/backend/node_modules/math-intrinsics/isFinite.js +12 -0
  644. package/templates/backend/node_modules/math-intrinsics/isInteger.d.ts +3 -0
  645. package/templates/backend/node_modules/math-intrinsics/isInteger.js +16 -0
  646. package/templates/backend/node_modules/math-intrinsics/isNaN.d.ts +1 -0
  647. package/templates/backend/node_modules/math-intrinsics/isNaN.js +6 -0
  648. package/templates/backend/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
  649. package/templates/backend/node_modules/math-intrinsics/isNegativeZero.js +6 -0
  650. package/templates/backend/node_modules/math-intrinsics/max.d.ts +1 -0
  651. package/templates/backend/node_modules/math-intrinsics/max.js +4 -0
  652. package/templates/backend/node_modules/math-intrinsics/min.d.ts +1 -0
  653. package/templates/backend/node_modules/math-intrinsics/min.js +4 -0
  654. package/templates/backend/node_modules/math-intrinsics/mod.d.ts +3 -0
  655. package/templates/backend/node_modules/math-intrinsics/mod.js +9 -0
  656. package/templates/backend/node_modules/math-intrinsics/package.json +86 -0
  657. package/templates/backend/node_modules/math-intrinsics/pow.d.ts +1 -0
  658. package/templates/backend/node_modules/math-intrinsics/pow.js +4 -0
  659. package/templates/backend/node_modules/math-intrinsics/round.d.ts +1 -0
  660. package/templates/backend/node_modules/math-intrinsics/round.js +4 -0
  661. package/templates/backend/node_modules/math-intrinsics/sign.d.ts +3 -0
  662. package/templates/backend/node_modules/math-intrinsics/sign.js +11 -0
  663. package/templates/backend/node_modules/math-intrinsics/test/index.js +192 -0
  664. package/templates/backend/node_modules/math-intrinsics/tsconfig.json +3 -0
  665. package/templates/backend/node_modules/media-typer/HISTORY.md +50 -0
  666. package/templates/backend/node_modules/media-typer/LICENSE +22 -0
  667. package/templates/backend/node_modules/media-typer/README.md +93 -0
  668. package/templates/backend/node_modules/media-typer/index.js +143 -0
  669. package/templates/backend/node_modules/media-typer/package.json +33 -0
  670. package/templates/backend/node_modules/memory-pager/.travis.yml +4 -0
  671. package/templates/backend/node_modules/memory-pager/LICENSE +21 -0
  672. package/templates/backend/node_modules/memory-pager/README.md +65 -0
  673. package/templates/backend/node_modules/memory-pager/index.js +160 -0
  674. package/templates/backend/node_modules/memory-pager/package.json +24 -0
  675. package/templates/backend/node_modules/memory-pager/test.js +80 -0
  676. package/templates/backend/node_modules/merge-descriptors/index.d.ts +11 -0
  677. package/templates/backend/node_modules/merge-descriptors/index.js +26 -0
  678. package/templates/backend/node_modules/merge-descriptors/license +11 -0
  679. package/templates/backend/node_modules/merge-descriptors/package.json +50 -0
  680. package/templates/backend/node_modules/merge-descriptors/readme.md +55 -0
  681. package/templates/backend/node_modules/mime-db/HISTORY.md +541 -0
  682. package/templates/backend/node_modules/mime-db/LICENSE +23 -0
  683. package/templates/backend/node_modules/mime-db/README.md +109 -0
  684. package/templates/backend/node_modules/mime-db/db.json +9342 -0
  685. package/templates/backend/node_modules/mime-db/index.js +12 -0
  686. package/templates/backend/node_modules/mime-db/package.json +56 -0
  687. package/templates/backend/node_modules/mime-types/HISTORY.md +428 -0
  688. package/templates/backend/node_modules/mime-types/LICENSE +23 -0
  689. package/templates/backend/node_modules/mime-types/README.md +126 -0
  690. package/templates/backend/node_modules/mime-types/index.js +211 -0
  691. package/templates/backend/node_modules/mime-types/mimeScore.js +57 -0
  692. package/templates/backend/node_modules/mime-types/package.json +49 -0
  693. package/templates/backend/node_modules/minimatch/LICENSE.md +55 -0
  694. package/templates/backend/node_modules/minimatch/README.md +528 -0
  695. package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  696. package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
  697. package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  698. package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
  699. package/templates/backend/node_modules/minimatch/dist/commonjs/ast.d.ts +22 -0
  700. package/templates/backend/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
  701. package/templates/backend/node_modules/minimatch/dist/commonjs/ast.js +845 -0
  702. package/templates/backend/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
  703. package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  704. package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
  705. package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  706. package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
  707. package/templates/backend/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
  708. package/templates/backend/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
  709. package/templates/backend/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  710. package/templates/backend/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
  711. package/templates/backend/node_modules/minimatch/dist/commonjs/index.d.ts +174 -0
  712. package/templates/backend/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
  713. package/templates/backend/node_modules/minimatch/dist/commonjs/index.js +1127 -0
  714. package/templates/backend/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
  715. package/templates/backend/node_modules/minimatch/dist/commonjs/package.json +3 -0
  716. package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
  717. package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
  718. package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  719. package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
  720. package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  721. package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
  722. package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  723. package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  724. package/templates/backend/node_modules/minimatch/dist/esm/ast.d.ts +22 -0
  725. package/templates/backend/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
  726. package/templates/backend/node_modules/minimatch/dist/esm/ast.js +841 -0
  727. package/templates/backend/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  728. package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  729. package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
  730. package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  731. package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  732. package/templates/backend/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
  733. package/templates/backend/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
  734. package/templates/backend/node_modules/minimatch/dist/esm/escape.js +26 -0
  735. package/templates/backend/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  736. package/templates/backend/node_modules/minimatch/dist/esm/index.d.ts +174 -0
  737. package/templates/backend/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
  738. package/templates/backend/node_modules/minimatch/dist/esm/index.js +1114 -0
  739. package/templates/backend/node_modules/minimatch/dist/esm/index.js.map +1 -0
  740. package/templates/backend/node_modules/minimatch/dist/esm/package.json +3 -0
  741. package/templates/backend/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
  742. package/templates/backend/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
  743. package/templates/backend/node_modules/minimatch/dist/esm/unescape.js +34 -0
  744. package/templates/backend/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  745. package/templates/backend/node_modules/minimatch/package.json +73 -0
  746. package/templates/backend/node_modules/mongodb/LICENSE.md +201 -0
  747. package/templates/backend/node_modules/mongodb/README.md +366 -0
  748. package/templates/backend/node_modules/mongodb/etc/prepare.js +12 -0
  749. package/templates/backend/node_modules/mongodb/lib/admin.js +136 -0
  750. package/templates/backend/node_modules/mongodb/lib/admin.js.map +1 -0
  751. package/templates/backend/node_modules/mongodb/lib/bson.js +106 -0
  752. package/templates/backend/node_modules/mongodb/lib/bson.js.map +1 -0
  753. package/templates/backend/node_modules/mongodb/lib/bulk/common.js +835 -0
  754. package/templates/backend/node_modules/mongodb/lib/bulk/common.js.map +1 -0
  755. package/templates/backend/node_modules/mongodb/lib/bulk/ordered.js +67 -0
  756. package/templates/backend/node_modules/mongodb/lib/bulk/ordered.js.map +1 -0
  757. package/templates/backend/node_modules/mongodb/lib/bulk/unordered.js +92 -0
  758. package/templates/backend/node_modules/mongodb/lib/bulk/unordered.js.map +1 -0
  759. package/templates/backend/node_modules/mongodb/lib/change_stream.js +517 -0
  760. package/templates/backend/node_modules/mongodb/lib/change_stream.js.map +1 -0
  761. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +281 -0
  762. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js.map +1 -0
  763. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +607 -0
  764. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/client_encryption.js.map +1 -0
  765. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/errors.js +138 -0
  766. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/errors.js.map +1 -0
  767. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +85 -0
  768. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js.map +1 -0
  769. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/aws.js +23 -0
  770. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/aws.js.map +1 -0
  771. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/azure.js +132 -0
  772. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/azure.js.map +1 -0
  773. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/gcp.js +16 -0
  774. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/gcp.js.map +1 -0
  775. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/index.js +43 -0
  776. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/index.js.map +1 -0
  777. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/state_machine.js +427 -0
  778. package/templates/backend/node_modules/mongodb/lib/client-side-encryption/state_machine.js.map +1 -0
  779. package/templates/backend/node_modules/mongodb/lib/cmap/auth/auth_provider.js +51 -0
  780. package/templates/backend/node_modules/mongodb/lib/cmap/auth/auth_provider.js.map +1 -0
  781. package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
  782. package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws4.js.map +1 -0
  783. package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +103 -0
  784. package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
  785. package/templates/backend/node_modules/mongodb/lib/cmap/auth/gssapi.js +152 -0
  786. package/templates/backend/node_modules/mongodb/lib/cmap/auth/gssapi.js.map +1 -0
  787. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +169 -0
  788. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js.map +1 -0
  789. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +129 -0
  790. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js.map +1 -0
  791. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +84 -0
  792. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -0
  793. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +62 -0
  794. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -0
  795. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js +141 -0
  796. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
  797. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js +44 -0
  798. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -0
  799. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +39 -0
  800. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -0
  801. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +122 -0
  802. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -0
  803. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +32 -0
  804. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js.map +1 -0
  805. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js +52 -0
  806. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -0
  807. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +23 -0
  808. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -0
  809. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +73 -0
  810. package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js.map +1 -0
  811. package/templates/backend/node_modules/mongodb/lib/cmap/auth/plain.js +26 -0
  812. package/templates/backend/node_modules/mongodb/lib/cmap/auth/plain.js.map +1 -0
  813. package/templates/backend/node_modules/mongodb/lib/cmap/auth/providers.js +22 -0
  814. package/templates/backend/node_modules/mongodb/lib/cmap/auth/providers.js.map +1 -0
  815. package/templates/backend/node_modules/mongodb/lib/cmap/auth/scram.js +267 -0
  816. package/templates/backend/node_modules/mongodb/lib/cmap/auth/scram.js.map +1 -0
  817. package/templates/backend/node_modules/mongodb/lib/cmap/auth/x509.js +36 -0
  818. package/templates/backend/node_modules/mongodb/lib/cmap/auth/x509.js.map +1 -0
  819. package/templates/backend/node_modules/mongodb/lib/cmap/command_monitoring_events.js +223 -0
  820. package/templates/backend/node_modules/mongodb/lib/cmap/command_monitoring_events.js.map +1 -0
  821. package/templates/backend/node_modules/mongodb/lib/cmap/commands.js +542 -0
  822. package/templates/backend/node_modules/mongodb/lib/cmap/commands.js.map +1 -0
  823. package/templates/backend/node_modules/mongodb/lib/cmap/connect.js +398 -0
  824. package/templates/backend/node_modules/mongodb/lib/cmap/connect.js.map +1 -0
  825. package/templates/backend/node_modules/mongodb/lib/cmap/connection.js +574 -0
  826. package/templates/backend/node_modules/mongodb/lib/cmap/connection.js.map +1 -0
  827. package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool.js +558 -0
  828. package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool.js.map +1 -0
  829. package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool_events.js +190 -0
  830. package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool_events.js.map +1 -0
  831. package/templates/backend/node_modules/mongodb/lib/cmap/errors.js +108 -0
  832. package/templates/backend/node_modules/mongodb/lib/cmap/errors.js.map +1 -0
  833. package/templates/backend/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +241 -0
  834. package/templates/backend/node_modules/mongodb/lib/cmap/handshake/client_metadata.js.map +1 -0
  835. package/templates/backend/node_modules/mongodb/lib/cmap/metrics.js +62 -0
  836. package/templates/backend/node_modules/mongodb/lib/cmap/metrics.js.map +1 -0
  837. package/templates/backend/node_modules/mongodb/lib/cmap/stream_description.js +70 -0
  838. package/templates/backend/node_modules/mongodb/lib/cmap/stream_description.js.map +1 -0
  839. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +179 -0
  840. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/compression.js.map +1 -0
  841. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +21 -0
  842. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/constants.js.map +1 -0
  843. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +111 -0
  844. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js.map +1 -0
  845. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +222 -0
  846. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
  847. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +315 -0
  848. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/responses.js.map +1 -0
  849. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/shared.js +35 -0
  850. package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/shared.js.map +1 -0
  851. package/templates/backend/node_modules/mongodb/lib/collection.js +751 -0
  852. package/templates/backend/node_modules/mongodb/lib/collection.js.map +1 -0
  853. package/templates/backend/node_modules/mongodb/lib/connection_string.js +1106 -0
  854. package/templates/backend/node_modules/mongodb/lib/connection_string.js.map +1 -0
  855. package/templates/backend/node_modules/mongodb/lib/constants.js +170 -0
  856. package/templates/backend/node_modules/mongodb/lib/constants.js.map +1 -0
  857. package/templates/backend/node_modules/mongodb/lib/cursor/abstract_cursor.js +924 -0
  858. package/templates/backend/node_modules/mongodb/lib/cursor/abstract_cursor.js.map +1 -0
  859. package/templates/backend/node_modules/mongodb/lib/cursor/aggregation_cursor.js +164 -0
  860. package/templates/backend/node_modules/mongodb/lib/cursor/aggregation_cursor.js.map +1 -0
  861. package/templates/backend/node_modules/mongodb/lib/cursor/change_stream_cursor.js +104 -0
  862. package/templates/backend/node_modules/mongodb/lib/cursor/change_stream_cursor.js.map +1 -0
  863. package/templates/backend/node_modules/mongodb/lib/cursor/client_bulk_write_cursor.js +52 -0
  864. package/templates/backend/node_modules/mongodb/lib/cursor/client_bulk_write_cursor.js.map +1 -0
  865. package/templates/backend/node_modules/mongodb/lib/cursor/explainable_cursor.js +36 -0
  866. package/templates/backend/node_modules/mongodb/lib/cursor/explainable_cursor.js.map +1 -0
  867. package/templates/backend/node_modules/mongodb/lib/cursor/find_cursor.js +399 -0
  868. package/templates/backend/node_modules/mongodb/lib/cursor/find_cursor.js.map +1 -0
  869. package/templates/backend/node_modules/mongodb/lib/cursor/list_collections_cursor.js +34 -0
  870. package/templates/backend/node_modules/mongodb/lib/cursor/list_collections_cursor.js.map +1 -0
  871. package/templates/backend/node_modules/mongodb/lib/cursor/list_indexes_cursor.js +32 -0
  872. package/templates/backend/node_modules/mongodb/lib/cursor/list_indexes_cursor.js.map +1 -0
  873. package/templates/backend/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js +14 -0
  874. package/templates/backend/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js.map +1 -0
  875. package/templates/backend/node_modules/mongodb/lib/cursor/run_command_cursor.js +94 -0
  876. package/templates/backend/node_modules/mongodb/lib/cursor/run_command_cursor.js.map +1 -0
  877. package/templates/backend/node_modules/mongodb/lib/db.js +419 -0
  878. package/templates/backend/node_modules/mongodb/lib/db.js.map +1 -0
  879. package/templates/backend/node_modules/mongodb/lib/deps.js +112 -0
  880. package/templates/backend/node_modules/mongodb/lib/deps.js.map +1 -0
  881. package/templates/backend/node_modules/mongodb/lib/encrypter.js +106 -0
  882. package/templates/backend/node_modules/mongodb/lib/encrypter.js.map +1 -0
  883. package/templates/backend/node_modules/mongodb/lib/error.js +1380 -0
  884. package/templates/backend/node_modules/mongodb/lib/error.js.map +1 -0
  885. package/templates/backend/node_modules/mongodb/lib/explain.js +59 -0
  886. package/templates/backend/node_modules/mongodb/lib/explain.js.map +1 -0
  887. package/templates/backend/node_modules/mongodb/lib/gridfs/download.js +306 -0
  888. package/templates/backend/node_modules/mongodb/lib/gridfs/download.js.map +1 -0
  889. package/templates/backend/node_modules/mongodb/lib/gridfs/index.js +164 -0
  890. package/templates/backend/node_modules/mongodb/lib/gridfs/index.js.map +1 -0
  891. package/templates/backend/node_modules/mongodb/lib/gridfs/upload.js +358 -0
  892. package/templates/backend/node_modules/mongodb/lib/gridfs/upload.js.map +1 -0
  893. package/templates/backend/node_modules/mongodb/lib/index.js +193 -0
  894. package/templates/backend/node_modules/mongodb/lib/index.js.map +1 -0
  895. package/templates/backend/node_modules/mongodb/lib/mongo_client.js +557 -0
  896. package/templates/backend/node_modules/mongodb/lib/mongo_client.js.map +1 -0
  897. package/templates/backend/node_modules/mongodb/lib/mongo_client_auth_providers.js +80 -0
  898. package/templates/backend/node_modules/mongodb/lib/mongo_client_auth_providers.js.map +1 -0
  899. package/templates/backend/node_modules/mongodb/lib/mongo_logger.js +655 -0
  900. package/templates/backend/node_modules/mongodb/lib/mongo_logger.js.map +1 -0
  901. package/templates/backend/node_modules/mongodb/lib/mongo_types.js +56 -0
  902. package/templates/backend/node_modules/mongodb/lib/mongo_types.js.map +1 -0
  903. package/templates/backend/node_modules/mongodb/lib/operations/aggregate.js +90 -0
  904. package/templates/backend/node_modules/mongodb/lib/operations/aggregate.js.map +1 -0
  905. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js +51 -0
  906. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -0
  907. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js +340 -0
  908. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js.map +1 -0
  909. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/common.js +3 -0
  910. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/common.js.map +1 -0
  911. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/executor.js +120 -0
  912. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/executor.js.map +1 -0
  913. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js +204 -0
  914. package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js.map +1 -0
  915. package/templates/backend/node_modules/mongodb/lib/operations/command.js +83 -0
  916. package/templates/backend/node_modules/mongodb/lib/operations/command.js.map +1 -0
  917. package/templates/backend/node_modules/mongodb/lib/operations/count.js +45 -0
  918. package/templates/backend/node_modules/mongodb/lib/operations/count.js.map +1 -0
  919. package/templates/backend/node_modules/mongodb/lib/operations/create_collection.js +109 -0
  920. package/templates/backend/node_modules/mongodb/lib/operations/create_collection.js.map +1 -0
  921. package/templates/backend/node_modules/mongodb/lib/operations/delete.js +125 -0
  922. package/templates/backend/node_modules/mongodb/lib/operations/delete.js.map +1 -0
  923. package/templates/backend/node_modules/mongodb/lib/operations/distinct.js +61 -0
  924. package/templates/backend/node_modules/mongodb/lib/operations/distinct.js.map +1 -0
  925. package/templates/backend/node_modules/mongodb/lib/operations/drop.js +93 -0
  926. package/templates/backend/node_modules/mongodb/lib/operations/drop.js.map +1 -0
  927. package/templates/backend/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
  928. package/templates/backend/node_modules/mongodb/lib/operations/end_sessions.js.map +1 -0
  929. package/templates/backend/node_modules/mongodb/lib/operations/estimated_document_count.js +41 -0
  930. package/templates/backend/node_modules/mongodb/lib/operations/estimated_document_count.js.map +1 -0
  931. package/templates/backend/node_modules/mongodb/lib/operations/execute_operation.js +312 -0
  932. package/templates/backend/node_modules/mongodb/lib/operations/execute_operation.js.map +1 -0
  933. package/templates/backend/node_modules/mongodb/lib/operations/find.js +148 -0
  934. package/templates/backend/node_modules/mongodb/lib/operations/find.js.map +1 -0
  935. package/templates/backend/node_modules/mongodb/lib/operations/find_and_modify.js +158 -0
  936. package/templates/backend/node_modules/mongodb/lib/operations/find_and_modify.js.map +1 -0
  937. package/templates/backend/node_modules/mongodb/lib/operations/get_more.js +62 -0
  938. package/templates/backend/node_modules/mongodb/lib/operations/get_more.js.map +1 -0
  939. package/templates/backend/node_modules/mongodb/lib/operations/indexes.js +186 -0
  940. package/templates/backend/node_modules/mongodb/lib/operations/indexes.js.map +1 -0
  941. package/templates/backend/node_modules/mongodb/lib/operations/insert.js +70 -0
  942. package/templates/backend/node_modules/mongodb/lib/operations/insert.js.map +1 -0
  943. package/templates/backend/node_modules/mongodb/lib/operations/kill_cursors.js +43 -0
  944. package/templates/backend/node_modules/mongodb/lib/operations/kill_cursors.js.map +1 -0
  945. package/templates/backend/node_modules/mongodb/lib/operations/list_collections.js +53 -0
  946. package/templates/backend/node_modules/mongodb/lib/operations/list_collections.js.map +1 -0
  947. package/templates/backend/node_modules/mongodb/lib/operations/list_databases.js +40 -0
  948. package/templates/backend/node_modules/mongodb/lib/operations/list_databases.js.map +1 -0
  949. package/templates/backend/node_modules/mongodb/lib/operations/operation.js +103 -0
  950. package/templates/backend/node_modules/mongodb/lib/operations/operation.js.map +1 -0
  951. package/templates/backend/node_modules/mongodb/lib/operations/profiling_level.js +43 -0
  952. package/templates/backend/node_modules/mongodb/lib/operations/profiling_level.js.map +1 -0
  953. package/templates/backend/node_modules/mongodb/lib/operations/remove_user.js +27 -0
  954. package/templates/backend/node_modules/mongodb/lib/operations/remove_user.js.map +1 -0
  955. package/templates/backend/node_modules/mongodb/lib/operations/rename.js +38 -0
  956. package/templates/backend/node_modules/mongodb/lib/operations/rename.js.map +1 -0
  957. package/templates/backend/node_modules/mongodb/lib/operations/run_command.js +47 -0
  958. package/templates/backend/node_modules/mongodb/lib/operations/run_command.js.map +1 -0
  959. package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/create.js +33 -0
  960. package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/create.js.map +1 -0
  961. package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/drop.js +43 -0
  962. package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/drop.js.map +1 -0
  963. package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/update.js +35 -0
  964. package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/update.js.map +1 -0
  965. package/templates/backend/node_modules/mongodb/lib/operations/set_profiling_level.js +53 -0
  966. package/templates/backend/node_modules/mongodb/lib/operations/set_profiling_level.js.map +1 -0
  967. package/templates/backend/node_modules/mongodb/lib/operations/stats.js +27 -0
  968. package/templates/backend/node_modules/mongodb/lib/operations/stats.js.map +1 -0
  969. package/templates/backend/node_modules/mongodb/lib/operations/update.js +188 -0
  970. package/templates/backend/node_modules/mongodb/lib/operations/update.js.map +1 -0
  971. package/templates/backend/node_modules/mongodb/lib/operations/validate_collection.js +37 -0
  972. package/templates/backend/node_modules/mongodb/lib/operations/validate_collection.js.map +1 -0
  973. package/templates/backend/node_modules/mongodb/lib/read_concern.js +73 -0
  974. package/templates/backend/node_modules/mongodb/lib/read_concern.js.map +1 -0
  975. package/templates/backend/node_modules/mongodb/lib/read_preference.js +191 -0
  976. package/templates/backend/node_modules/mongodb/lib/read_preference.js.map +1 -0
  977. package/templates/backend/node_modules/mongodb/lib/runtime_adapters.js +32 -0
  978. package/templates/backend/node_modules/mongodb/lib/runtime_adapters.js.map +1 -0
  979. package/templates/backend/node_modules/mongodb/lib/sdam/common.js +49 -0
  980. package/templates/backend/node_modules/mongodb/lib/sdam/common.js.map +1 -0
  981. package/templates/backend/node_modules/mongodb/lib/sdam/events.js +146 -0
  982. package/templates/backend/node_modules/mongodb/lib/sdam/events.js.map +1 -0
  983. package/templates/backend/node_modules/mongodb/lib/sdam/monitor.js +544 -0
  984. package/templates/backend/node_modules/mongodb/lib/sdam/monitor.js.map +1 -0
  985. package/templates/backend/node_modules/mongodb/lib/sdam/server.js +404 -0
  986. package/templates/backend/node_modules/mongodb/lib/sdam/server.js.map +1 -0
  987. package/templates/backend/node_modules/mongodb/lib/sdam/server_description.js +204 -0
  988. package/templates/backend/node_modules/mongodb/lib/sdam/server_description.js.map +1 -0
  989. package/templates/backend/node_modules/mongodb/lib/sdam/server_selection.js +294 -0
  990. package/templates/backend/node_modules/mongodb/lib/sdam/server_selection.js.map +1 -0
  991. package/templates/backend/node_modules/mongodb/lib/sdam/server_selection_events.js +85 -0
  992. package/templates/backend/node_modules/mongodb/lib/sdam/server_selection_events.js.map +1 -0
  993. package/templates/backend/node_modules/mongodb/lib/sdam/srv_polling.js +108 -0
  994. package/templates/backend/node_modules/mongodb/lib/sdam/srv_polling.js.map +1 -0
  995. package/templates/backend/node_modules/mongodb/lib/sdam/topology.js +654 -0
  996. package/templates/backend/node_modules/mongodb/lib/sdam/topology.js.map +1 -0
  997. package/templates/backend/node_modules/mongodb/lib/sdam/topology_description.js +383 -0
  998. package/templates/backend/node_modules/mongodb/lib/sdam/topology_description.js.map +1 -0
  999. package/templates/backend/node_modules/mongodb/lib/sessions.js +937 -0
  1000. package/templates/backend/node_modules/mongodb/lib/sessions.js.map +1 -0
  1001. package/templates/backend/node_modules/mongodb/lib/sort.js +103 -0
  1002. package/templates/backend/node_modules/mongodb/lib/sort.js.map +1 -0
  1003. package/templates/backend/node_modules/mongodb/lib/timeout.js +296 -0
  1004. package/templates/backend/node_modules/mongodb/lib/timeout.js.map +1 -0
  1005. package/templates/backend/node_modules/mongodb/lib/transactions.js +135 -0
  1006. package/templates/backend/node_modules/mongodb/lib/transactions.js.map +1 -0
  1007. package/templates/backend/node_modules/mongodb/lib/utils.js +1155 -0
  1008. package/templates/backend/node_modules/mongodb/lib/utils.js.map +1 -0
  1009. package/templates/backend/node_modules/mongodb/lib/write_concern.js +100 -0
  1010. package/templates/backend/node_modules/mongodb/lib/write_concern.js.map +1 -0
  1011. package/templates/backend/node_modules/mongodb/mongodb.d.ts +9061 -0
  1012. package/templates/backend/node_modules/mongodb/package.json +182 -0
  1013. package/templates/backend/node_modules/mongodb/src/admin.ts +173 -0
  1014. package/templates/backend/node_modules/mongodb/src/bson.ts +172 -0
  1015. package/templates/backend/node_modules/mongodb/src/bulk/common.ts +1251 -0
  1016. package/templates/backend/node_modules/mongodb/src/bulk/ordered.ts +83 -0
  1017. package/templates/backend/node_modules/mongodb/src/bulk/unordered.ts +115 -0
  1018. package/templates/backend/node_modules/mongodb/src/change_stream.ts +1165 -0
  1019. package/templates/backend/node_modules/mongodb/src/client-side-encryption/auto_encrypter.ts +475 -0
  1020. package/templates/backend/node_modules/mongodb/src/client-side-encryption/client_encryption.ts +1148 -0
  1021. package/templates/backend/node_modules/mongodb/src/client-side-encryption/errors.ts +144 -0
  1022. package/templates/backend/node_modules/mongodb/src/client-side-encryption/mongocryptd_manager.ts +100 -0
  1023. package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/aws.ts +33 -0
  1024. package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/azure.ts +181 -0
  1025. package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/gcp.ts +16 -0
  1026. package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/index.ts +207 -0
  1027. package/templates/backend/node_modules/mongodb/src/client-side-encryption/state_machine.ts +651 -0
  1028. package/templates/backend/node_modules/mongodb/src/cmap/auth/auth_provider.ts +77 -0
  1029. package/templates/backend/node_modules/mongodb/src/cmap/auth/aws4.ts +207 -0
  1030. package/templates/backend/node_modules/mongodb/src/cmap/auth/aws_temporary_credentials.ts +129 -0
  1031. package/templates/backend/node_modules/mongodb/src/cmap/auth/gssapi.ts +206 -0
  1032. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongo_credentials.ts +292 -0
  1033. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_aws.ts +179 -0
  1034. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/automated_callback_workflow.ts +88 -0
  1035. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts +73 -0
  1036. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/callback_workflow.ts +188 -0
  1037. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/command_builders.ts +53 -0
  1038. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts +46 -0
  1039. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/human_callback_workflow.ts +141 -0
  1040. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts +31 -0
  1041. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_cache.ts +62 -0
  1042. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_machine_workflow.ts +22 -0
  1043. package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc.ts +185 -0
  1044. package/templates/backend/node_modules/mongodb/src/cmap/auth/plain.ts +25 -0
  1045. package/templates/backend/node_modules/mongodb/src/cmap/auth/providers.ts +22 -0
  1046. package/templates/backend/node_modules/mongodb/src/cmap/auth/scram.ts +371 -0
  1047. package/templates/backend/node_modules/mongodb/src/cmap/auth/x509.ts +43 -0
  1048. package/templates/backend/node_modules/mongodb/src/cmap/command_monitoring_events.ts +316 -0
  1049. package/templates/backend/node_modules/mongodb/src/cmap/commands.ts +807 -0
  1050. package/templates/backend/node_modules/mongodb/src/cmap/connect.ts +538 -0
  1051. package/templates/backend/node_modules/mongodb/src/cmap/connection.ts +938 -0
  1052. package/templates/backend/node_modules/mongodb/src/cmap/connection_pool.ts +831 -0
  1053. package/templates/backend/node_modules/mongodb/src/cmap/connection_pool_events.ts +300 -0
  1054. package/templates/backend/node_modules/mongodb/src/cmap/errors.ts +119 -0
  1055. package/templates/backend/node_modules/mongodb/src/cmap/handshake/client_metadata.ts +353 -0
  1056. package/templates/backend/node_modules/mongodb/src/cmap/metrics.ts +58 -0
  1057. package/templates/backend/node_modules/mongodb/src/cmap/stream_description.ts +96 -0
  1058. package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/compression.ts +215 -0
  1059. package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/constants.ts +17 -0
  1060. package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/on_data.ts +139 -0
  1061. package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/on_demand/document.ts +356 -0
  1062. package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/responses.ts +393 -0
  1063. package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/shared.ts +48 -0
  1064. package/templates/backend/node_modules/mongodb/src/collection.ts +1314 -0
  1065. package/templates/backend/node_modules/mongodb/src/connection_string.ts +1315 -0
  1066. package/templates/backend/node_modules/mongodb/src/constants.ts +176 -0
  1067. package/templates/backend/node_modules/mongodb/src/cursor/abstract_cursor.ts +1247 -0
  1068. package/templates/backend/node_modules/mongodb/src/cursor/aggregation_cursor.ts +245 -0
  1069. package/templates/backend/node_modules/mongodb/src/cursor/change_stream_cursor.ts +171 -0
  1070. package/templates/backend/node_modules/mongodb/src/cursor/client_bulk_write_cursor.ts +83 -0
  1071. package/templates/backend/node_modules/mongodb/src/cursor/explainable_cursor.ts +51 -0
  1072. package/templates/backend/node_modules/mongodb/src/cursor/find_cursor.ts +497 -0
  1073. package/templates/backend/node_modules/mongodb/src/cursor/list_collections_cursor.ts +50 -0
  1074. package/templates/backend/node_modules/mongodb/src/cursor/list_indexes_cursor.ts +37 -0
  1075. package/templates/backend/node_modules/mongodb/src/cursor/list_search_indexes_cursor.ts +20 -0
  1076. package/templates/backend/node_modules/mongodb/src/cursor/run_command_cursor.ts +178 -0
  1077. package/templates/backend/node_modules/mongodb/src/db.ts +621 -0
  1078. package/templates/backend/node_modules/mongodb/src/deps.ts +227 -0
  1079. package/templates/backend/node_modules/mongodb/src/encrypter.ts +127 -0
  1080. package/templates/backend/node_modules/mongodb/src/error.ts +1567 -0
  1081. package/templates/backend/node_modules/mongodb/src/explain.ts +124 -0
  1082. package/templates/backend/node_modules/mongodb/src/gridfs/download.ts +483 -0
  1083. package/templates/backend/node_modules/mongodb/src/gridfs/index.ts +264 -0
  1084. package/templates/backend/node_modules/mongodb/src/gridfs/upload.ts +538 -0
  1085. package/templates/backend/node_modules/mongodb/src/index.ts +634 -0
  1086. package/templates/backend/node_modules/mongodb/src/mongo_client.ts +1179 -0
  1087. package/templates/backend/node_modules/mongodb/src/mongo_client_auth_providers.ts +87 -0
  1088. package/templates/backend/node_modules/mongodb/src/mongo_logger.ts +1081 -0
  1089. package/templates/backend/node_modules/mongodb/src/mongo_types.ts +678 -0
  1090. package/templates/backend/node_modules/mongodb/src/operations/aggregate.ts +153 -0
  1091. package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/client_bulk_write.ts +72 -0
  1092. package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/command_builder.ts +487 -0
  1093. package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/common.ts +276 -0
  1094. package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/executor.ts +149 -0
  1095. package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/results_merger.ts +260 -0
  1096. package/templates/backend/node_modules/mongodb/src/operations/command.ts +171 -0
  1097. package/templates/backend/node_modules/mongodb/src/operations/count.ts +74 -0
  1098. package/templates/backend/node_modules/mongodb/src/operations/create_collection.ts +218 -0
  1099. package/templates/backend/node_modules/mongodb/src/operations/delete.ts +183 -0
  1100. package/templates/backend/node_modules/mongodb/src/operations/distinct.ts +92 -0
  1101. package/templates/backend/node_modules/mongodb/src/operations/drop.ts +130 -0
  1102. package/templates/backend/node_modules/mongodb/src/operations/end_sessions.ts +44 -0
  1103. package/templates/backend/node_modules/mongodb/src/operations/estimated_document_count.ts +61 -0
  1104. package/templates/backend/node_modules/mongodb/src/operations/execute_operation.ts +420 -0
  1105. package/templates/backend/node_modules/mongodb/src/operations/find.ts +254 -0
  1106. package/templates/backend/node_modules/mongodb/src/operations/find_and_modify.ts +319 -0
  1107. package/templates/backend/node_modules/mongodb/src/operations/get_more.ts +108 -0
  1108. package/templates/backend/node_modules/mongodb/src/operations/indexes.ts +418 -0
  1109. package/templates/backend/node_modules/mongodb/src/operations/insert.ts +108 -0
  1110. package/templates/backend/node_modules/mongodb/src/operations/kill_cursors.ts +64 -0
  1111. package/templates/backend/node_modules/mongodb/src/operations/list_collections.ts +108 -0
  1112. package/templates/backend/node_modules/mongodb/src/operations/list_databases.ts +68 -0
  1113. package/templates/backend/node_modules/mongodb/src/operations/operation.ts +189 -0
  1114. package/templates/backend/node_modules/mongodb/src/operations/profiling_level.ts +46 -0
  1115. package/templates/backend/node_modules/mongodb/src/operations/remove_user.ts +36 -0
  1116. package/templates/backend/node_modules/mongodb/src/operations/rename.ts +60 -0
  1117. package/templates/backend/node_modules/mongodb/src/operations/run_command.ts +79 -0
  1118. package/templates/backend/node_modules/mongodb/src/operations/search_indexes/create.ts +56 -0
  1119. package/templates/backend/node_modules/mongodb/src/operations/search_indexes/drop.ts +58 -0
  1120. package/templates/backend/node_modules/mongodb/src/operations/search_indexes/update.ts +45 -0
  1121. package/templates/backend/node_modules/mongodb/src/operations/set_profiling_level.ts +74 -0
  1122. package/templates/backend/node_modules/mongodb/src/operations/stats.ts +37 -0
  1123. package/templates/backend/node_modules/mongodb/src/operations/update.ts +318 -0
  1124. package/templates/backend/node_modules/mongodb/src/operations/validate_collection.ts +50 -0
  1125. package/templates/backend/node_modules/mongodb/src/read_concern.ts +88 -0
  1126. package/templates/backend/node_modules/mongodb/src/read_preference.ts +256 -0
  1127. package/templates/backend/node_modules/mongodb/src/runtime_adapters.ts +64 -0
  1128. package/templates/backend/node_modules/mongodb/src/sdam/common.ts +74 -0
  1129. package/templates/backend/node_modules/mongodb/src/sdam/events.ts +219 -0
  1130. package/templates/backend/node_modules/mongodb/src/sdam/monitor.ts +771 -0
  1131. package/templates/backend/node_modules/mongodb/src/sdam/server.ts +595 -0
  1132. package/templates/backend/node_modules/mongodb/src/sdam/server_description.ts +297 -0
  1133. package/templates/backend/node_modules/mongodb/src/sdam/server_selection.ts +415 -0
  1134. package/templates/backend/node_modules/mongodb/src/sdam/server_selection_events.ts +142 -0
  1135. package/templates/backend/node_modules/mongodb/src/sdam/srv_polling.ts +146 -0
  1136. package/templates/backend/node_modules/mongodb/src/sdam/topology.ts +1103 -0
  1137. package/templates/backend/node_modules/mongodb/src/sdam/topology_description.ts +548 -0
  1138. package/templates/backend/node_modules/mongodb/src/sessions.ts +1288 -0
  1139. package/templates/backend/node_modules/mongodb/src/sort.ts +141 -0
  1140. package/templates/backend/node_modules/mongodb/src/timeout.ts +405 -0
  1141. package/templates/backend/node_modules/mongodb/src/transactions.ts +181 -0
  1142. package/templates/backend/node_modules/mongodb/src/utils.ts +1429 -0
  1143. package/templates/backend/node_modules/mongodb/src/write_concern.ts +183 -0
  1144. package/templates/backend/node_modules/mongodb/tsconfig.json +46 -0
  1145. package/templates/backend/node_modules/mongodb-connection-string-url/.esm-wrapper.mjs +6 -0
  1146. package/templates/backend/node_modules/mongodb-connection-string-url/LICENSE +192 -0
  1147. package/templates/backend/node_modules/mongodb-connection-string-url/README.md +25 -0
  1148. package/templates/backend/node_modules/mongodb-connection-string-url/lib/index.d.ts +63 -0
  1149. package/templates/backend/node_modules/mongodb-connection-string-url/lib/index.js +239 -0
  1150. package/templates/backend/node_modules/mongodb-connection-string-url/lib/index.js.map +1 -0
  1151. package/templates/backend/node_modules/mongodb-connection-string-url/lib/redact.d.ts +7 -0
  1152. package/templates/backend/node_modules/mongodb-connection-string-url/lib/redact.js +97 -0
  1153. package/templates/backend/node_modules/mongodb-connection-string-url/lib/redact.js.map +1 -0
  1154. package/templates/backend/node_modules/mongodb-connection-string-url/package.json +71 -0
  1155. package/templates/backend/node_modules/mongoose/LICENSE.md +22 -0
  1156. package/templates/backend/node_modules/mongoose/README.md +395 -0
  1157. package/templates/backend/node_modules/mongoose/SECURITY.md +1 -0
  1158. package/templates/backend/node_modules/mongoose/eslint.config.mjs +198 -0
  1159. package/templates/backend/node_modules/mongoose/index.js +64 -0
  1160. package/templates/backend/node_modules/mongoose/lib/aggregate.js +1226 -0
  1161. package/templates/backend/node_modules/mongoose/lib/cast/bigint.js +46 -0
  1162. package/templates/backend/node_modules/mongoose/lib/cast/boolean.js +32 -0
  1163. package/templates/backend/node_modules/mongoose/lib/cast/date.js +41 -0
  1164. package/templates/backend/node_modules/mongoose/lib/cast/decimal128.js +39 -0
  1165. package/templates/backend/node_modules/mongoose/lib/cast/double.js +50 -0
  1166. package/templates/backend/node_modules/mongoose/lib/cast/int32.js +36 -0
  1167. package/templates/backend/node_modules/mongoose/lib/cast/number.js +42 -0
  1168. package/templates/backend/node_modules/mongoose/lib/cast/objectid.js +29 -0
  1169. package/templates/backend/node_modules/mongoose/lib/cast/string.js +37 -0
  1170. package/templates/backend/node_modules/mongoose/lib/cast/uuid.js +35 -0
  1171. package/templates/backend/node_modules/mongoose/lib/cast.js +436 -0
  1172. package/templates/backend/node_modules/mongoose/lib/collection.js +321 -0
  1173. package/templates/backend/node_modules/mongoose/lib/connection.js +1853 -0
  1174. package/templates/backend/node_modules/mongoose/lib/connectionState.js +26 -0
  1175. package/templates/backend/node_modules/mongoose/lib/constants.js +73 -0
  1176. package/templates/backend/node_modules/mongoose/lib/cursor/aggregationCursor.js +466 -0
  1177. package/templates/backend/node_modules/mongoose/lib/cursor/changeStream.js +218 -0
  1178. package/templates/backend/node_modules/mongoose/lib/cursor/queryCursor.js +625 -0
  1179. package/templates/backend/node_modules/mongoose/lib/document.js +5693 -0
  1180. package/templates/backend/node_modules/mongoose/lib/driver.js +15 -0
  1181. package/templates/backend/node_modules/mongoose/lib/drivers/SPEC.md +4 -0
  1182. package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
  1183. package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +426 -0
  1184. package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +519 -0
  1185. package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js +10 -0
  1186. package/templates/backend/node_modules/mongoose/lib/error/browserMissingSchema.js +29 -0
  1187. package/templates/backend/node_modules/mongoose/lib/error/bulkSaveIncompleteError.js +44 -0
  1188. package/templates/backend/node_modules/mongoose/lib/error/bulkWriteError.js +41 -0
  1189. package/templates/backend/node_modules/mongoose/lib/error/cast.js +167 -0
  1190. package/templates/backend/node_modules/mongoose/lib/error/createCollectionsError.js +26 -0
  1191. package/templates/backend/node_modules/mongoose/lib/error/divergentArray.js +40 -0
  1192. package/templates/backend/node_modules/mongoose/lib/error/eachAsyncMultiError.js +41 -0
  1193. package/templates/backend/node_modules/mongoose/lib/error/index.js +237 -0
  1194. package/templates/backend/node_modules/mongoose/lib/error/invalidSchemaOption.js +32 -0
  1195. package/templates/backend/node_modules/mongoose/lib/error/messages.js +48 -0
  1196. package/templates/backend/node_modules/mongoose/lib/error/missingSchema.js +33 -0
  1197. package/templates/backend/node_modules/mongoose/lib/error/mongooseError.js +13 -0
  1198. package/templates/backend/node_modules/mongoose/lib/error/notFound.js +47 -0
  1199. package/templates/backend/node_modules/mongoose/lib/error/objectExpected.js +31 -0
  1200. package/templates/backend/node_modules/mongoose/lib/error/objectParameter.js +31 -0
  1201. package/templates/backend/node_modules/mongoose/lib/error/overwriteModel.js +31 -0
  1202. package/templates/backend/node_modules/mongoose/lib/error/parallelSave.js +33 -0
  1203. package/templates/backend/node_modules/mongoose/lib/error/parallelValidate.js +33 -0
  1204. package/templates/backend/node_modules/mongoose/lib/error/serverSelection.js +62 -0
  1205. package/templates/backend/node_modules/mongoose/lib/error/setOptionError.js +103 -0
  1206. package/templates/backend/node_modules/mongoose/lib/error/strict.js +35 -0
  1207. package/templates/backend/node_modules/mongoose/lib/error/strictPopulate.js +31 -0
  1208. package/templates/backend/node_modules/mongoose/lib/error/syncIndexes.js +30 -0
  1209. package/templates/backend/node_modules/mongoose/lib/error/validation.js +97 -0
  1210. package/templates/backend/node_modules/mongoose/lib/error/validator.js +100 -0
  1211. package/templates/backend/node_modules/mongoose/lib/error/version.js +38 -0
  1212. package/templates/backend/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +39 -0
  1213. package/templates/backend/node_modules/mongoose/lib/helpers/aggregate/stringifyFunctionOperators.js +50 -0
  1214. package/templates/backend/node_modules/mongoose/lib/helpers/arrayDepth.js +33 -0
  1215. package/templates/backend/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
  1216. package/templates/backend/node_modules/mongoose/lib/helpers/clone.js +236 -0
  1217. package/templates/backend/node_modules/mongoose/lib/helpers/common.js +127 -0
  1218. package/templates/backend/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +225 -0
  1219. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
  1220. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
  1221. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
  1222. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +29 -0
  1223. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
  1224. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
  1225. package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +96 -0
  1226. package/templates/backend/node_modules/mongoose/lib/helpers/document/applyDefaults.js +132 -0
  1227. package/templates/backend/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +106 -0
  1228. package/templates/backend/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +147 -0
  1229. package/templates/backend/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +45 -0
  1230. package/templates/backend/node_modules/mongoose/lib/helpers/document/compile.js +241 -0
  1231. package/templates/backend/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
  1232. package/templates/backend/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +53 -0
  1233. package/templates/backend/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js +35 -0
  1234. package/templates/backend/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
  1235. package/templates/backend/node_modules/mongoose/lib/helpers/each.js +25 -0
  1236. package/templates/backend/node_modules/mongoose/lib/helpers/error/combinePathErrors.js +22 -0
  1237. package/templates/backend/node_modules/mongoose/lib/helpers/firstKey.js +8 -0
  1238. package/templates/backend/node_modules/mongoose/lib/helpers/get.js +65 -0
  1239. package/templates/backend/node_modules/mongoose/lib/helpers/getConstructorName.js +16 -0
  1240. package/templates/backend/node_modules/mongoose/lib/helpers/getDefaultBulkwriteResult.js +18 -0
  1241. package/templates/backend/node_modules/mongoose/lib/helpers/getFunctionName.js +10 -0
  1242. package/templates/backend/node_modules/mongoose/lib/helpers/immediate.js +16 -0
  1243. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/applySchemaCollation.js +13 -0
  1244. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
  1245. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +63 -0
  1246. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
  1247. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +95 -0
  1248. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
  1249. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isTextIndex.js +16 -0
  1250. package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
  1251. package/templates/backend/node_modules/mongoose/lib/helpers/isAsyncFunction.js +9 -0
  1252. package/templates/backend/node_modules/mongoose/lib/helpers/isBsonType.js +15 -0
  1253. package/templates/backend/node_modules/mongoose/lib/helpers/isMongooseObject.js +22 -0
  1254. package/templates/backend/node_modules/mongoose/lib/helpers/isObject.js +16 -0
  1255. package/templates/backend/node_modules/mongoose/lib/helpers/isPOJO.js +12 -0
  1256. package/templates/backend/node_modules/mongoose/lib/helpers/isPromise.js +6 -0
  1257. package/templates/backend/node_modules/mongoose/lib/helpers/isSimpleValidator.js +22 -0
  1258. package/templates/backend/node_modules/mongoose/lib/helpers/minimize.js +41 -0
  1259. package/templates/backend/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
  1260. package/templates/backend/node_modules/mongoose/lib/helpers/model/applyHooks.js +151 -0
  1261. package/templates/backend/node_modules/mongoose/lib/helpers/model/applyMethods.js +70 -0
  1262. package/templates/backend/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +33 -0
  1263. package/templates/backend/node_modules/mongoose/lib/helpers/model/applyStatics.js +13 -0
  1264. package/templates/backend/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +322 -0
  1265. package/templates/backend/node_modules/mongoose/lib/helpers/model/decorateBulkWriteResult.js +8 -0
  1266. package/templates/backend/node_modules/mongoose/lib/helpers/model/discriminator.js +265 -0
  1267. package/templates/backend/node_modules/mongoose/lib/helpers/model/pushNestedArrayPaths.js +15 -0
  1268. package/templates/backend/node_modules/mongoose/lib/helpers/omitUndefined.js +20 -0
  1269. package/templates/backend/node_modules/mongoose/lib/helpers/once.js +12 -0
  1270. package/templates/backend/node_modules/mongoose/lib/helpers/parallelLimit.js +37 -0
  1271. package/templates/backend/node_modules/mongoose/lib/helpers/path/parentPaths.js +18 -0
  1272. package/templates/backend/node_modules/mongoose/lib/helpers/path/setDottedPath.js +33 -0
  1273. package/templates/backend/node_modules/mongoose/lib/helpers/pluralize.js +95 -0
  1274. package/templates/backend/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +129 -0
  1275. package/templates/backend/node_modules/mongoose/lib/helpers/populate/assignVals.js +360 -0
  1276. package/templates/backend/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
  1277. package/templates/backend/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +894 -0
  1278. package/templates/backend/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +229 -0
  1279. package/templates/backend/node_modules/mongoose/lib/helpers/populate/getVirtual.js +103 -0
  1280. package/templates/backend/node_modules/mongoose/lib/helpers/populate/leanPopulateMap.js +7 -0
  1281. package/templates/backend/node_modules/mongoose/lib/helpers/populate/lookupLocalFields.js +40 -0
  1282. package/templates/backend/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +49 -0
  1283. package/templates/backend/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +74 -0
  1284. package/templates/backend/node_modules/mongoose/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
  1285. package/templates/backend/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
  1286. package/templates/backend/node_modules/mongoose/lib/helpers/populate/skipPopulateValue.js +10 -0
  1287. package/templates/backend/node_modules/mongoose/lib/helpers/populate/validateRef.js +19 -0
  1288. package/templates/backend/node_modules/mongoose/lib/helpers/printJestWarning.js +21 -0
  1289. package/templates/backend/node_modules/mongoose/lib/helpers/processConnectionOptions.js +65 -0
  1290. package/templates/backend/node_modules/mongoose/lib/helpers/projection/applyProjection.js +83 -0
  1291. package/templates/backend/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +41 -0
  1292. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isDefiningProjection.js +18 -0
  1293. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isExclusive.js +37 -0
  1294. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isInclusive.js +39 -0
  1295. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isNestedProjection.js +8 -0
  1296. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +40 -0
  1297. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isPathSelectedInclusive.js +28 -0
  1298. package/templates/backend/node_modules/mongoose/lib/helpers/projection/isSubpath.js +14 -0
  1299. package/templates/backend/node_modules/mongoose/lib/helpers/projection/parseProjection.js +38 -0
  1300. package/templates/backend/node_modules/mongoose/lib/helpers/query/applyGlobalOption.js +29 -0
  1301. package/templates/backend/node_modules/mongoose/lib/helpers/query/cast$expr.js +287 -0
  1302. package/templates/backend/node_modules/mongoose/lib/helpers/query/castFilterPath.js +54 -0
  1303. package/templates/backend/node_modules/mongoose/lib/helpers/query/castUpdate.js +647 -0
  1304. package/templates/backend/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +103 -0
  1305. package/templates/backend/node_modules/mongoose/lib/helpers/query/handleImmutable.js +44 -0
  1306. package/templates/backend/node_modules/mongoose/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
  1307. package/templates/backend/node_modules/mongoose/lib/helpers/query/hasDollarKeys.js +23 -0
  1308. package/templates/backend/node_modules/mongoose/lib/helpers/query/isOperator.js +14 -0
  1309. package/templates/backend/node_modules/mongoose/lib/helpers/query/sanitizeFilter.js +41 -0
  1310. package/templates/backend/node_modules/mongoose/lib/helpers/query/sanitizeProjection.js +14 -0
  1311. package/templates/backend/node_modules/mongoose/lib/helpers/query/selectPopulatedFields.js +62 -0
  1312. package/templates/backend/node_modules/mongoose/lib/helpers/query/trusted.js +13 -0
  1313. package/templates/backend/node_modules/mongoose/lib/helpers/query/validOps.js +3 -0
  1314. package/templates/backend/node_modules/mongoose/lib/helpers/schema/addAutoId.js +7 -0
  1315. package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyBuiltinPlugins.js +12 -0
  1316. package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +55 -0
  1317. package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +20 -0
  1318. package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +39 -0
  1319. package/templates/backend/node_modules/mongoose/lib/helpers/schema/cleanPositionalOperators.js +12 -0
  1320. package/templates/backend/node_modules/mongoose/lib/helpers/schema/getIndexes.js +171 -0
  1321. package/templates/backend/node_modules/mongoose/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
  1322. package/templates/backend/node_modules/mongoose/lib/helpers/schema/getPath.js +43 -0
  1323. package/templates/backend/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
  1324. package/templates/backend/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +20 -0
  1325. package/templates/backend/node_modules/mongoose/lib/helpers/schema/handleTimestampOption.js +24 -0
  1326. package/templates/backend/node_modules/mongoose/lib/helpers/schema/idGetter.js +34 -0
  1327. package/templates/backend/node_modules/mongoose/lib/helpers/schema/merge.js +36 -0
  1328. package/templates/backend/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +50 -0
  1329. package/templates/backend/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +174 -0
  1330. package/templates/backend/node_modules/mongoose/lib/helpers/specialProperties.js +3 -0
  1331. package/templates/backend/node_modules/mongoose/lib/helpers/symbols.js +20 -0
  1332. package/templates/backend/node_modules/mongoose/lib/helpers/timers.js +3 -0
  1333. package/templates/backend/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
  1334. package/templates/backend/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +132 -0
  1335. package/templates/backend/node_modules/mongoose/lib/helpers/topology/allServersUnknown.js +12 -0
  1336. package/templates/backend/node_modules/mongoose/lib/helpers/topology/isAtlas.js +31 -0
  1337. package/templates/backend/node_modules/mongoose/lib/helpers/topology/isSSLError.js +16 -0
  1338. package/templates/backend/node_modules/mongoose/lib/helpers/update/applyTimestampsToChildren.js +193 -0
  1339. package/templates/backend/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +131 -0
  1340. package/templates/backend/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +113 -0
  1341. package/templates/backend/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
  1342. package/templates/backend/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +33 -0
  1343. package/templates/backend/node_modules/mongoose/lib/helpers/update/moveImmutableProperties.js +53 -0
  1344. package/templates/backend/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +37 -0
  1345. package/templates/backend/node_modules/mongoose/lib/helpers/update/updatedPathsByArrayFilter.js +27 -0
  1346. package/templates/backend/node_modules/mongoose/lib/helpers/updateValidators.js +186 -0
  1347. package/templates/backend/node_modules/mongoose/lib/index.js +17 -0
  1348. package/templates/backend/node_modules/mongoose/lib/internal.js +46 -0
  1349. package/templates/backend/node_modules/mongoose/lib/model.js +5202 -0
  1350. package/templates/backend/node_modules/mongoose/lib/modifiedPathsSnapshot.js +9 -0
  1351. package/templates/backend/node_modules/mongoose/lib/mongoose.js +1435 -0
  1352. package/templates/backend/node_modules/mongoose/lib/options/populateOptions.js +36 -0
  1353. package/templates/backend/node_modules/mongoose/lib/options/propertyOptions.js +8 -0
  1354. package/templates/backend/node_modules/mongoose/lib/options/saveOptions.js +16 -0
  1355. package/templates/backend/node_modules/mongoose/lib/options/schemaArrayOptions.js +78 -0
  1356. package/templates/backend/node_modules/mongoose/lib/options/schemaBufferOptions.js +38 -0
  1357. package/templates/backend/node_modules/mongoose/lib/options/schemaDateOptions.js +71 -0
  1358. package/templates/backend/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +91 -0
  1359. package/templates/backend/node_modules/mongoose/lib/options/schemaMapOptions.js +43 -0
  1360. package/templates/backend/node_modules/mongoose/lib/options/schemaNumberOptions.js +101 -0
  1361. package/templates/backend/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +64 -0
  1362. package/templates/backend/node_modules/mongoose/lib/options/schemaStringOptions.js +138 -0
  1363. package/templates/backend/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +89 -0
  1364. package/templates/backend/node_modules/mongoose/lib/options/schemaTypeOptions.js +258 -0
  1365. package/templates/backend/node_modules/mongoose/lib/options/schemaUnionOptions.js +32 -0
  1366. package/templates/backend/node_modules/mongoose/lib/options/virtualOptions.js +164 -0
  1367. package/templates/backend/node_modules/mongoose/lib/options.js +18 -0
  1368. package/templates/backend/node_modules/mongoose/lib/plugins/index.js +5 -0
  1369. package/templates/backend/node_modules/mongoose/lib/plugins/saveSubdocs.js +94 -0
  1370. package/templates/backend/node_modules/mongoose/lib/plugins/sharding.js +101 -0
  1371. package/templates/backend/node_modules/mongoose/lib/plugins/trackTransaction.js +89 -0
  1372. package/templates/backend/node_modules/mongoose/lib/query.js +5845 -0
  1373. package/templates/backend/node_modules/mongoose/lib/queryHelpers.js +396 -0
  1374. package/templates/backend/node_modules/mongoose/lib/schema/array.js +700 -0
  1375. package/templates/backend/node_modules/mongoose/lib/schema/bigint.js +280 -0
  1376. package/templates/backend/node_modules/mongoose/lib/schema/boolean.js +330 -0
  1377. package/templates/backend/node_modules/mongoose/lib/schema/buffer.js +341 -0
  1378. package/templates/backend/node_modules/mongoose/lib/schema/date.js +465 -0
  1379. package/templates/backend/node_modules/mongoose/lib/schema/decimal128.js +261 -0
  1380. package/templates/backend/node_modules/mongoose/lib/schema/documentArray.js +664 -0
  1381. package/templates/backend/node_modules/mongoose/lib/schema/documentArrayElement.js +136 -0
  1382. package/templates/backend/node_modules/mongoose/lib/schema/double.js +244 -0
  1383. package/templates/backend/node_modules/mongoose/lib/schema/index.js +32 -0
  1384. package/templates/backend/node_modules/mongoose/lib/schema/int32.js +287 -0
  1385. package/templates/backend/node_modules/mongoose/lib/schema/map.js +194 -0
  1386. package/templates/backend/node_modules/mongoose/lib/schema/mixed.js +146 -0
  1387. package/templates/backend/node_modules/mongoose/lib/schema/number.js +508 -0
  1388. package/templates/backend/node_modules/mongoose/lib/schema/objectId.js +331 -0
  1389. package/templates/backend/node_modules/mongoose/lib/schema/operators/bitwise.js +38 -0
  1390. package/templates/backend/node_modules/mongoose/lib/schema/operators/exists.js +12 -0
  1391. package/templates/backend/node_modules/mongoose/lib/schema/operators/geospatial.js +107 -0
  1392. package/templates/backend/node_modules/mongoose/lib/schema/operators/helpers.js +32 -0
  1393. package/templates/backend/node_modules/mongoose/lib/schema/operators/text.js +39 -0
  1394. package/templates/backend/node_modules/mongoose/lib/schema/operators/type.js +20 -0
  1395. package/templates/backend/node_modules/mongoose/lib/schema/string.js +731 -0
  1396. package/templates/backend/node_modules/mongoose/lib/schema/subdocument.js +434 -0
  1397. package/templates/backend/node_modules/mongoose/lib/schema/symbols.js +5 -0
  1398. package/templates/backend/node_modules/mongoose/lib/schema/union.js +163 -0
  1399. package/templates/backend/node_modules/mongoose/lib/schema/uuid.js +303 -0
  1400. package/templates/backend/node_modules/mongoose/lib/schema.js +3244 -0
  1401. package/templates/backend/node_modules/mongoose/lib/schemaType.js +1928 -0
  1402. package/templates/backend/node_modules/mongoose/lib/stateMachine.js +229 -0
  1403. package/templates/backend/node_modules/mongoose/lib/types/array/index.js +119 -0
  1404. package/templates/backend/node_modules/mongoose/lib/types/array/isMongooseArray.js +5 -0
  1405. package/templates/backend/node_modules/mongoose/lib/types/array/methods/index.js +1095 -0
  1406. package/templates/backend/node_modules/mongoose/lib/types/arraySubdocument.js +208 -0
  1407. package/templates/backend/node_modules/mongoose/lib/types/buffer.js +294 -0
  1408. package/templates/backend/node_modules/mongoose/lib/types/decimal128.js +13 -0
  1409. package/templates/backend/node_modules/mongoose/lib/types/documentArray/index.js +113 -0
  1410. package/templates/backend/node_modules/mongoose/lib/types/documentArray/isMongooseDocumentArray.js +5 -0
  1411. package/templates/backend/node_modules/mongoose/lib/types/documentArray/methods/index.js +415 -0
  1412. package/templates/backend/node_modules/mongoose/lib/types/double.js +13 -0
  1413. package/templates/backend/node_modules/mongoose/lib/types/index.js +23 -0
  1414. package/templates/backend/node_modules/mongoose/lib/types/map.js +368 -0
  1415. package/templates/backend/node_modules/mongoose/lib/types/objectid.js +41 -0
  1416. package/templates/backend/node_modules/mongoose/lib/types/subdocument.js +443 -0
  1417. package/templates/backend/node_modules/mongoose/lib/types/uuid.js +13 -0
  1418. package/templates/backend/node_modules/mongoose/lib/utils.js +1064 -0
  1419. package/templates/backend/node_modules/mongoose/lib/validOptions.js +43 -0
  1420. package/templates/backend/node_modules/mongoose/lib/virtualType.js +204 -0
  1421. package/templates/backend/node_modules/mongoose/package.json +139 -0
  1422. package/templates/backend/node_modules/mongoose/tstyche.json +7 -0
  1423. package/templates/backend/node_modules/mongoose/types/aggregate.d.ts +185 -0
  1424. package/templates/backend/node_modules/mongoose/types/augmentations.d.ts +9 -0
  1425. package/templates/backend/node_modules/mongoose/types/callback.d.ts +8 -0
  1426. package/templates/backend/node_modules/mongoose/types/collection.d.ts +49 -0
  1427. package/templates/backend/node_modules/mongoose/types/connection.d.ts +297 -0
  1428. package/templates/backend/node_modules/mongoose/types/cursor.d.ts +67 -0
  1429. package/templates/backend/node_modules/mongoose/types/document.d.ts +328 -0
  1430. package/templates/backend/node_modules/mongoose/types/error.d.ts +143 -0
  1431. package/templates/backend/node_modules/mongoose/types/expressions.d.ts +3053 -0
  1432. package/templates/backend/node_modules/mongoose/types/helpers.d.ts +32 -0
  1433. package/templates/backend/node_modules/mongoose/types/index.d.ts +1161 -0
  1434. package/templates/backend/node_modules/mongoose/types/indexes.d.ts +97 -0
  1435. package/templates/backend/node_modules/mongoose/types/inferhydrateddoctype.d.ts +135 -0
  1436. package/templates/backend/node_modules/mongoose/types/inferrawdoctype.d.ts +185 -0
  1437. package/templates/backend/node_modules/mongoose/types/inferschematype.d.ts +387 -0
  1438. package/templates/backend/node_modules/mongoose/types/middlewares.d.ts +66 -0
  1439. package/templates/backend/node_modules/mongoose/types/models.d.ts +1265 -0
  1440. package/templates/backend/node_modules/mongoose/types/mongooseoptions.d.ts +232 -0
  1441. package/templates/backend/node_modules/mongoose/types/pipelinestage.d.ts +334 -0
  1442. package/templates/backend/node_modules/mongoose/types/populate.d.ts +97 -0
  1443. package/templates/backend/node_modules/mongoose/types/query.d.ts +982 -0
  1444. package/templates/backend/node_modules/mongoose/types/schemaoptions.d.ts +284 -0
  1445. package/templates/backend/node_modules/mongoose/types/schematypes.d.ts +667 -0
  1446. package/templates/backend/node_modules/mongoose/types/session.d.ts +32 -0
  1447. package/templates/backend/node_modules/mongoose/types/types.d.ts +109 -0
  1448. package/templates/backend/node_modules/mongoose/types/utility.d.ts +175 -0
  1449. package/templates/backend/node_modules/mongoose/types/validation.d.ts +39 -0
  1450. package/templates/backend/node_modules/mongoose/types/virtuals.d.ts +14 -0
  1451. package/templates/backend/node_modules/mpath/.travis.yml +9 -0
  1452. package/templates/backend/node_modules/mpath/History.md +88 -0
  1453. package/templates/backend/node_modules/mpath/LICENSE +22 -0
  1454. package/templates/backend/node_modules/mpath/README.md +278 -0
  1455. package/templates/backend/node_modules/mpath/SECURITY.md +5 -0
  1456. package/templates/backend/node_modules/mpath/index.js +3 -0
  1457. package/templates/backend/node_modules/mpath/lib/index.js +336 -0
  1458. package/templates/backend/node_modules/mpath/lib/stringToParts.js +48 -0
  1459. package/templates/backend/node_modules/mpath/package.json +144 -0
  1460. package/templates/backend/node_modules/mpath/test/.eslintrc.yml +4 -0
  1461. package/templates/backend/node_modules/mpath/test/index.js +1879 -0
  1462. package/templates/backend/node_modules/mpath/test/stringToParts.js +30 -0
  1463. package/templates/backend/node_modules/mquery/.github/ISSUE_TEMPLATE.md +11 -0
  1464. package/templates/backend/node_modules/mquery/.github/PULL_REQUEST_TEMPLATE.md +9 -0
  1465. package/templates/backend/node_modules/mquery/History.md +393 -0
  1466. package/templates/backend/node_modules/mquery/LICENSE +22 -0
  1467. package/templates/backend/node_modules/mquery/README.md +1387 -0
  1468. package/templates/backend/node_modules/mquery/SECURITY.md +1 -0
  1469. package/templates/backend/node_modules/mquery/lib/collection/collection.js +47 -0
  1470. package/templates/backend/node_modules/mquery/lib/collection/index.js +13 -0
  1471. package/templates/backend/node_modules/mquery/lib/collection/node.js +128 -0
  1472. package/templates/backend/node_modules/mquery/lib/env.js +22 -0
  1473. package/templates/backend/node_modules/mquery/lib/mquery.js +2748 -0
  1474. package/templates/backend/node_modules/mquery/lib/permissions.js +93 -0
  1475. package/templates/backend/node_modules/mquery/lib/utils.js +297 -0
  1476. package/templates/backend/node_modules/mquery/package.json +35 -0
  1477. package/templates/backend/node_modules/ms/index.js +162 -0
  1478. package/templates/backend/node_modules/ms/license.md +21 -0
  1479. package/templates/backend/node_modules/ms/package.json +38 -0
  1480. package/templates/backend/node_modules/ms/readme.md +59 -0
  1481. package/templates/backend/node_modules/negotiator/HISTORY.md +114 -0
  1482. package/templates/backend/node_modules/negotiator/LICENSE +24 -0
  1483. package/templates/backend/node_modules/negotiator/README.md +212 -0
  1484. package/templates/backend/node_modules/negotiator/index.js +83 -0
  1485. package/templates/backend/node_modules/negotiator/lib/charset.js +169 -0
  1486. package/templates/backend/node_modules/negotiator/lib/encoding.js +205 -0
  1487. package/templates/backend/node_modules/negotiator/lib/language.js +179 -0
  1488. package/templates/backend/node_modules/negotiator/lib/mediaType.js +294 -0
  1489. package/templates/backend/node_modules/negotiator/package.json +43 -0
  1490. package/templates/backend/node_modules/nodemon/.prettierrc.json +3 -0
  1491. package/templates/backend/node_modules/nodemon/LICENSE +21 -0
  1492. package/templates/backend/node_modules/nodemon/README.md +439 -0
  1493. package/templates/backend/node_modules/nodemon/bin/nodemon.js +16 -0
  1494. package/templates/backend/node_modules/nodemon/bin/windows-kill.exe +0 -0
  1495. package/templates/backend/node_modules/nodemon/doc/cli/authors.txt +8 -0
  1496. package/templates/backend/node_modules/nodemon/doc/cli/config.txt +44 -0
  1497. package/templates/backend/node_modules/nodemon/doc/cli/help.txt +29 -0
  1498. package/templates/backend/node_modules/nodemon/doc/cli/logo.txt +20 -0
  1499. package/templates/backend/node_modules/nodemon/doc/cli/options.txt +36 -0
  1500. package/templates/backend/node_modules/nodemon/doc/cli/topics.txt +8 -0
  1501. package/templates/backend/node_modules/nodemon/doc/cli/usage.txt +3 -0
  1502. package/templates/backend/node_modules/nodemon/doc/cli/whoami.txt +9 -0
  1503. package/templates/backend/node_modules/nodemon/index.d.ts +124 -0
  1504. package/templates/backend/node_modules/nodemon/jsconfig.json +7 -0
  1505. package/templates/backend/node_modules/nodemon/lib/cli/index.js +49 -0
  1506. package/templates/backend/node_modules/nodemon/lib/cli/parse.js +230 -0
  1507. package/templates/backend/node_modules/nodemon/lib/config/command.js +43 -0
  1508. package/templates/backend/node_modules/nodemon/lib/config/defaults.js +34 -0
  1509. package/templates/backend/node_modules/nodemon/lib/config/exec.js +240 -0
  1510. package/templates/backend/node_modules/nodemon/lib/config/index.js +93 -0
  1511. package/templates/backend/node_modules/nodemon/lib/config/load.js +225 -0
  1512. package/templates/backend/node_modules/nodemon/lib/help/index.js +27 -0
  1513. package/templates/backend/node_modules/nodemon/lib/index.js +1 -0
  1514. package/templates/backend/node_modules/nodemon/lib/monitor/index.js +4 -0
  1515. package/templates/backend/node_modules/nodemon/lib/monitor/match.js +288 -0
  1516. package/templates/backend/node_modules/nodemon/lib/monitor/run.js +562 -0
  1517. package/templates/backend/node_modules/nodemon/lib/monitor/signals.js +34 -0
  1518. package/templates/backend/node_modules/nodemon/lib/monitor/watch.js +244 -0
  1519. package/templates/backend/node_modules/nodemon/lib/nodemon.js +317 -0
  1520. package/templates/backend/node_modules/nodemon/lib/rules/add.js +89 -0
  1521. package/templates/backend/node_modules/nodemon/lib/rules/index.js +53 -0
  1522. package/templates/backend/node_modules/nodemon/lib/rules/parse.js +43 -0
  1523. package/templates/backend/node_modules/nodemon/lib/spawn.js +74 -0
  1524. package/templates/backend/node_modules/nodemon/lib/utils/bus.js +44 -0
  1525. package/templates/backend/node_modules/nodemon/lib/utils/clone.js +40 -0
  1526. package/templates/backend/node_modules/nodemon/lib/utils/colour.js +26 -0
  1527. package/templates/backend/node_modules/nodemon/lib/utils/index.js +103 -0
  1528. package/templates/backend/node_modules/nodemon/lib/utils/log.js +82 -0
  1529. package/templates/backend/node_modules/nodemon/lib/utils/merge.js +47 -0
  1530. package/templates/backend/node_modules/nodemon/lib/version.js +100 -0
  1531. package/templates/backend/node_modules/nodemon/package.json +78 -0
  1532. package/templates/backend/node_modules/normalize-path/LICENSE +21 -0
  1533. package/templates/backend/node_modules/normalize-path/README.md +127 -0
  1534. package/templates/backend/node_modules/normalize-path/index.js +35 -0
  1535. package/templates/backend/node_modules/normalize-path/package.json +77 -0
  1536. package/templates/backend/node_modules/object-assign/index.js +90 -0
  1537. package/templates/backend/node_modules/object-assign/license +21 -0
  1538. package/templates/backend/node_modules/object-assign/package.json +42 -0
  1539. package/templates/backend/node_modules/object-assign/readme.md +61 -0
  1540. package/templates/backend/node_modules/object-inspect/.eslintrc +53 -0
  1541. package/templates/backend/node_modules/object-inspect/.github/FUNDING.yml +12 -0
  1542. package/templates/backend/node_modules/object-inspect/.nycrc +13 -0
  1543. package/templates/backend/node_modules/object-inspect/CHANGELOG.md +424 -0
  1544. package/templates/backend/node_modules/object-inspect/LICENSE +21 -0
  1545. package/templates/backend/node_modules/object-inspect/example/all.js +23 -0
  1546. package/templates/backend/node_modules/object-inspect/example/circular.js +6 -0
  1547. package/templates/backend/node_modules/object-inspect/example/fn.js +5 -0
  1548. package/templates/backend/node_modules/object-inspect/example/inspect.js +10 -0
  1549. package/templates/backend/node_modules/object-inspect/index.js +544 -0
  1550. package/templates/backend/node_modules/object-inspect/package-support.json +20 -0
  1551. package/templates/backend/node_modules/object-inspect/package.json +105 -0
  1552. package/templates/backend/node_modules/object-inspect/readme.markdown +84 -0
  1553. package/templates/backend/node_modules/object-inspect/test/bigint.js +58 -0
  1554. package/templates/backend/node_modules/object-inspect/test/browser/dom.js +15 -0
  1555. package/templates/backend/node_modules/object-inspect/test/circular.js +16 -0
  1556. package/templates/backend/node_modules/object-inspect/test/deep.js +12 -0
  1557. package/templates/backend/node_modules/object-inspect/test/element.js +53 -0
  1558. package/templates/backend/node_modules/object-inspect/test/err.js +48 -0
  1559. package/templates/backend/node_modules/object-inspect/test/fakes.js +29 -0
  1560. package/templates/backend/node_modules/object-inspect/test/fn.js +76 -0
  1561. package/templates/backend/node_modules/object-inspect/test/global.js +17 -0
  1562. package/templates/backend/node_modules/object-inspect/test/has.js +15 -0
  1563. package/templates/backend/node_modules/object-inspect/test/holes.js +15 -0
  1564. package/templates/backend/node_modules/object-inspect/test/indent-option.js +271 -0
  1565. package/templates/backend/node_modules/object-inspect/test/inspect.js +139 -0
  1566. package/templates/backend/node_modules/object-inspect/test/lowbyte.js +12 -0
  1567. package/templates/backend/node_modules/object-inspect/test/number.js +58 -0
  1568. package/templates/backend/node_modules/object-inspect/test/quoteStyle.js +26 -0
  1569. package/templates/backend/node_modules/object-inspect/test/toStringTag.js +40 -0
  1570. package/templates/backend/node_modules/object-inspect/test/undef.js +12 -0
  1571. package/templates/backend/node_modules/object-inspect/test/values.js +261 -0
  1572. package/templates/backend/node_modules/object-inspect/test-core-js.js +26 -0
  1573. package/templates/backend/node_modules/object-inspect/util.inspect.js +1 -0
  1574. package/templates/backend/node_modules/on-finished/HISTORY.md +98 -0
  1575. package/templates/backend/node_modules/on-finished/LICENSE +23 -0
  1576. package/templates/backend/node_modules/on-finished/README.md +162 -0
  1577. package/templates/backend/node_modules/on-finished/index.js +234 -0
  1578. package/templates/backend/node_modules/on-finished/package.json +39 -0
  1579. package/templates/backend/node_modules/once/LICENSE +15 -0
  1580. package/templates/backend/node_modules/once/README.md +79 -0
  1581. package/templates/backend/node_modules/once/once.js +42 -0
  1582. package/templates/backend/node_modules/once/package.json +33 -0
  1583. package/templates/backend/node_modules/parseurl/HISTORY.md +58 -0
  1584. package/templates/backend/node_modules/parseurl/LICENSE +24 -0
  1585. package/templates/backend/node_modules/parseurl/README.md +133 -0
  1586. package/templates/backend/node_modules/parseurl/index.js +158 -0
  1587. package/templates/backend/node_modules/parseurl/package.json +40 -0
  1588. package/templates/backend/node_modules/path-to-regexp/LICENSE +21 -0
  1589. package/templates/backend/node_modules/path-to-regexp/Readme.md +224 -0
  1590. package/templates/backend/node_modules/path-to-regexp/dist/index.d.ts +147 -0
  1591. package/templates/backend/node_modules/path-to-regexp/dist/index.js +431 -0
  1592. package/templates/backend/node_modules/path-to-regexp/dist/index.js.map +1 -0
  1593. package/templates/backend/node_modules/path-to-regexp/package.json +64 -0
  1594. package/templates/backend/node_modules/picomatch/LICENSE +21 -0
  1595. package/templates/backend/node_modules/picomatch/README.md +716 -0
  1596. package/templates/backend/node_modules/picomatch/index.js +3 -0
  1597. package/templates/backend/node_modules/picomatch/lib/constants.js +184 -0
  1598. package/templates/backend/node_modules/picomatch/lib/parse.js +1392 -0
  1599. package/templates/backend/node_modules/picomatch/lib/picomatch.js +342 -0
  1600. package/templates/backend/node_modules/picomatch/lib/scan.js +391 -0
  1601. package/templates/backend/node_modules/picomatch/lib/utils.js +64 -0
  1602. package/templates/backend/node_modules/picomatch/package.json +81 -0
  1603. package/templates/backend/node_modules/proxy-addr/HISTORY.md +161 -0
  1604. package/templates/backend/node_modules/proxy-addr/LICENSE +22 -0
  1605. package/templates/backend/node_modules/proxy-addr/README.md +139 -0
  1606. package/templates/backend/node_modules/proxy-addr/index.js +327 -0
  1607. package/templates/backend/node_modules/proxy-addr/package.json +47 -0
  1608. package/templates/backend/node_modules/pstree.remy/.travis.yml +8 -0
  1609. package/templates/backend/node_modules/pstree.remy/LICENSE +7 -0
  1610. package/templates/backend/node_modules/pstree.remy/README.md +26 -0
  1611. package/templates/backend/node_modules/pstree.remy/lib/index.js +37 -0
  1612. package/templates/backend/node_modules/pstree.remy/lib/tree.js +37 -0
  1613. package/templates/backend/node_modules/pstree.remy/lib/utils.js +53 -0
  1614. package/templates/backend/node_modules/pstree.remy/package.json +33 -0
  1615. package/templates/backend/node_modules/pstree.remy/tests/fixtures/index.js +13 -0
  1616. package/templates/backend/node_modules/pstree.remy/tests/fixtures/out1 +10 -0
  1617. package/templates/backend/node_modules/pstree.remy/tests/fixtures/out2 +29 -0
  1618. package/templates/backend/node_modules/pstree.remy/tests/index.test.js +51 -0
  1619. package/templates/backend/node_modules/punycode/LICENSE-MIT.txt +20 -0
  1620. package/templates/backend/node_modules/punycode/README.md +148 -0
  1621. package/templates/backend/node_modules/punycode/package.json +58 -0
  1622. package/templates/backend/node_modules/punycode/punycode.es6.js +444 -0
  1623. package/templates/backend/node_modules/punycode/punycode.js +443 -0
  1624. package/templates/backend/node_modules/qs/.editorconfig +46 -0
  1625. package/templates/backend/node_modules/qs/.github/FUNDING.yml +12 -0
  1626. package/templates/backend/node_modules/qs/.github/SECURITY.md +11 -0
  1627. package/templates/backend/node_modules/qs/.github/THREAT_MODEL.md +78 -0
  1628. package/templates/backend/node_modules/qs/.nycrc +13 -0
  1629. package/templates/backend/node_modules/qs/CHANGELOG.md +822 -0
  1630. package/templates/backend/node_modules/qs/LICENSE.md +29 -0
  1631. package/templates/backend/node_modules/qs/README.md +758 -0
  1632. package/templates/backend/node_modules/qs/dist/qs.js +141 -0
  1633. package/templates/backend/node_modules/qs/eslint.config.mjs +57 -0
  1634. package/templates/backend/node_modules/qs/lib/formats.js +23 -0
  1635. package/templates/backend/node_modules/qs/lib/index.js +11 -0
  1636. package/templates/backend/node_modules/qs/lib/parse.js +403 -0
  1637. package/templates/backend/node_modules/qs/lib/stringify.js +363 -0
  1638. package/templates/backend/node_modules/qs/lib/utils.js +342 -0
  1639. package/templates/backend/node_modules/qs/package.json +94 -0
  1640. package/templates/backend/node_modules/qs/test/empty-keys-cases.js +267 -0
  1641. package/templates/backend/node_modules/qs/test/parse.js +1703 -0
  1642. package/templates/backend/node_modules/qs/test/stringify.js +1448 -0
  1643. package/templates/backend/node_modules/qs/test/utils.js +432 -0
  1644. package/templates/backend/node_modules/range-parser/HISTORY.md +56 -0
  1645. package/templates/backend/node_modules/range-parser/LICENSE +23 -0
  1646. package/templates/backend/node_modules/range-parser/README.md +84 -0
  1647. package/templates/backend/node_modules/range-parser/index.js +162 -0
  1648. package/templates/backend/node_modules/range-parser/package.json +44 -0
  1649. package/templates/backend/node_modules/raw-body/LICENSE +22 -0
  1650. package/templates/backend/node_modules/raw-body/README.md +223 -0
  1651. package/templates/backend/node_modules/raw-body/index.d.ts +85 -0
  1652. package/templates/backend/node_modules/raw-body/index.js +336 -0
  1653. package/templates/backend/node_modules/raw-body/package.json +46 -0
  1654. package/templates/backend/node_modules/readdirp/LICENSE +21 -0
  1655. package/templates/backend/node_modules/readdirp/README.md +122 -0
  1656. package/templates/backend/node_modules/readdirp/index.d.ts +43 -0
  1657. package/templates/backend/node_modules/readdirp/index.js +287 -0
  1658. package/templates/backend/node_modules/readdirp/package.json +122 -0
  1659. package/templates/backend/node_modules/router/HISTORY.md +228 -0
  1660. package/templates/backend/node_modules/router/LICENSE +23 -0
  1661. package/templates/backend/node_modules/router/README.md +416 -0
  1662. package/templates/backend/node_modules/router/index.js +748 -0
  1663. package/templates/backend/node_modules/router/lib/layer.js +247 -0
  1664. package/templates/backend/node_modules/router/lib/route.js +242 -0
  1665. package/templates/backend/node_modules/router/package.json +44 -0
  1666. package/templates/backend/node_modules/safe-buffer/LICENSE +21 -0
  1667. package/templates/backend/node_modules/safe-buffer/README.md +584 -0
  1668. package/templates/backend/node_modules/safe-buffer/index.d.ts +187 -0
  1669. package/templates/backend/node_modules/safe-buffer/index.js +65 -0
  1670. package/templates/backend/node_modules/safe-buffer/package.json +51 -0
  1671. package/templates/backend/node_modules/safer-buffer/LICENSE +21 -0
  1672. package/templates/backend/node_modules/safer-buffer/Porting-Buffer.md +268 -0
  1673. package/templates/backend/node_modules/safer-buffer/Readme.md +156 -0
  1674. package/templates/backend/node_modules/safer-buffer/dangerous.js +58 -0
  1675. package/templates/backend/node_modules/safer-buffer/package.json +34 -0
  1676. package/templates/backend/node_modules/safer-buffer/safer.js +77 -0
  1677. package/templates/backend/node_modules/safer-buffer/tests.js +406 -0
  1678. package/templates/backend/node_modules/semver/LICENSE +15 -0
  1679. package/templates/backend/node_modules/semver/README.md +680 -0
  1680. package/templates/backend/node_modules/semver/bin/semver.js +195 -0
  1681. package/templates/backend/node_modules/semver/classes/comparator.js +143 -0
  1682. package/templates/backend/node_modules/semver/classes/index.js +7 -0
  1683. package/templates/backend/node_modules/semver/classes/range.js +557 -0
  1684. package/templates/backend/node_modules/semver/classes/semver.js +333 -0
  1685. package/templates/backend/node_modules/semver/functions/clean.js +8 -0
  1686. package/templates/backend/node_modules/semver/functions/cmp.js +54 -0
  1687. package/templates/backend/node_modules/semver/functions/coerce.js +62 -0
  1688. package/templates/backend/node_modules/semver/functions/compare-build.js +9 -0
  1689. package/templates/backend/node_modules/semver/functions/compare-loose.js +5 -0
  1690. package/templates/backend/node_modules/semver/functions/compare.js +7 -0
  1691. package/templates/backend/node_modules/semver/functions/diff.js +60 -0
  1692. package/templates/backend/node_modules/semver/functions/eq.js +5 -0
  1693. package/templates/backend/node_modules/semver/functions/gt.js +5 -0
  1694. package/templates/backend/node_modules/semver/functions/gte.js +5 -0
  1695. package/templates/backend/node_modules/semver/functions/inc.js +21 -0
  1696. package/templates/backend/node_modules/semver/functions/lt.js +5 -0
  1697. package/templates/backend/node_modules/semver/functions/lte.js +5 -0
  1698. package/templates/backend/node_modules/semver/functions/major.js +5 -0
  1699. package/templates/backend/node_modules/semver/functions/minor.js +5 -0
  1700. package/templates/backend/node_modules/semver/functions/neq.js +5 -0
  1701. package/templates/backend/node_modules/semver/functions/parse.js +18 -0
  1702. package/templates/backend/node_modules/semver/functions/patch.js +5 -0
  1703. package/templates/backend/node_modules/semver/functions/prerelease.js +8 -0
  1704. package/templates/backend/node_modules/semver/functions/rcompare.js +5 -0
  1705. package/templates/backend/node_modules/semver/functions/rsort.js +5 -0
  1706. package/templates/backend/node_modules/semver/functions/satisfies.js +12 -0
  1707. package/templates/backend/node_modules/semver/functions/sort.js +5 -0
  1708. package/templates/backend/node_modules/semver/functions/truncate.js +48 -0
  1709. package/templates/backend/node_modules/semver/functions/valid.js +8 -0
  1710. package/templates/backend/node_modules/semver/index.js +93 -0
  1711. package/templates/backend/node_modules/semver/internal/constants.js +37 -0
  1712. package/templates/backend/node_modules/semver/internal/debug.js +11 -0
  1713. package/templates/backend/node_modules/semver/internal/identifiers.js +29 -0
  1714. package/templates/backend/node_modules/semver/internal/lrucache.js +42 -0
  1715. package/templates/backend/node_modules/semver/internal/parse-options.js +17 -0
  1716. package/templates/backend/node_modules/semver/internal/re.js +223 -0
  1717. package/templates/backend/node_modules/semver/package.json +78 -0
  1718. package/templates/backend/node_modules/semver/preload.js +4 -0
  1719. package/templates/backend/node_modules/semver/range.bnf +17 -0
  1720. package/templates/backend/node_modules/semver/ranges/gtr.js +6 -0
  1721. package/templates/backend/node_modules/semver/ranges/intersects.js +9 -0
  1722. package/templates/backend/node_modules/semver/ranges/ltr.js +6 -0
  1723. package/templates/backend/node_modules/semver/ranges/max-satisfying.js +27 -0
  1724. package/templates/backend/node_modules/semver/ranges/min-satisfying.js +26 -0
  1725. package/templates/backend/node_modules/semver/ranges/min-version.js +63 -0
  1726. package/templates/backend/node_modules/semver/ranges/outside.js +82 -0
  1727. package/templates/backend/node_modules/semver/ranges/simplify.js +49 -0
  1728. package/templates/backend/node_modules/semver/ranges/subset.js +249 -0
  1729. package/templates/backend/node_modules/semver/ranges/to-comparators.js +10 -0
  1730. package/templates/backend/node_modules/semver/ranges/valid.js +13 -0
  1731. package/templates/backend/node_modules/send/LICENSE +23 -0
  1732. package/templates/backend/node_modules/send/README.md +317 -0
  1733. package/templates/backend/node_modules/send/index.js +997 -0
  1734. package/templates/backend/node_modules/send/package.json +63 -0
  1735. package/templates/backend/node_modules/serve-static/LICENSE +25 -0
  1736. package/templates/backend/node_modules/serve-static/README.md +253 -0
  1737. package/templates/backend/node_modules/serve-static/index.js +208 -0
  1738. package/templates/backend/node_modules/serve-static/package.json +44 -0
  1739. package/templates/backend/node_modules/setprototypeof/LICENSE +13 -0
  1740. package/templates/backend/node_modules/setprototypeof/README.md +31 -0
  1741. package/templates/backend/node_modules/setprototypeof/index.d.ts +2 -0
  1742. package/templates/backend/node_modules/setprototypeof/index.js +17 -0
  1743. package/templates/backend/node_modules/setprototypeof/package.json +38 -0
  1744. package/templates/backend/node_modules/setprototypeof/test/index.js +24 -0
  1745. package/templates/backend/node_modules/side-channel/.editorconfig +9 -0
  1746. package/templates/backend/node_modules/side-channel/.eslintrc +12 -0
  1747. package/templates/backend/node_modules/side-channel/.github/FUNDING.yml +12 -0
  1748. package/templates/backend/node_modules/side-channel/.nycrc +13 -0
  1749. package/templates/backend/node_modules/side-channel/CHANGELOG.md +110 -0
  1750. package/templates/backend/node_modules/side-channel/LICENSE +21 -0
  1751. package/templates/backend/node_modules/side-channel/README.md +61 -0
  1752. package/templates/backend/node_modules/side-channel/index.d.ts +14 -0
  1753. package/templates/backend/node_modules/side-channel/index.js +43 -0
  1754. package/templates/backend/node_modules/side-channel/package.json +85 -0
  1755. package/templates/backend/node_modules/side-channel/test/index.js +104 -0
  1756. package/templates/backend/node_modules/side-channel/tsconfig.json +9 -0
  1757. package/templates/backend/node_modules/side-channel-list/.editorconfig +9 -0
  1758. package/templates/backend/node_modules/side-channel-list/.eslintrc +11 -0
  1759. package/templates/backend/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
  1760. package/templates/backend/node_modules/side-channel-list/.nycrc +13 -0
  1761. package/templates/backend/node_modules/side-channel-list/CHANGELOG.md +36 -0
  1762. package/templates/backend/node_modules/side-channel-list/LICENSE +21 -0
  1763. package/templates/backend/node_modules/side-channel-list/README.md +62 -0
  1764. package/templates/backend/node_modules/side-channel-list/index.d.ts +13 -0
  1765. package/templates/backend/node_modules/side-channel-list/index.js +111 -0
  1766. package/templates/backend/node_modules/side-channel-list/list.d.ts +14 -0
  1767. package/templates/backend/node_modules/side-channel-list/package.json +77 -0
  1768. package/templates/backend/node_modules/side-channel-list/test/index.js +154 -0
  1769. package/templates/backend/node_modules/side-channel-list/tsconfig.json +9 -0
  1770. package/templates/backend/node_modules/side-channel-map/.editorconfig +9 -0
  1771. package/templates/backend/node_modules/side-channel-map/.eslintrc +11 -0
  1772. package/templates/backend/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
  1773. package/templates/backend/node_modules/side-channel-map/.nycrc +13 -0
  1774. package/templates/backend/node_modules/side-channel-map/CHANGELOG.md +22 -0
  1775. package/templates/backend/node_modules/side-channel-map/LICENSE +21 -0
  1776. package/templates/backend/node_modules/side-channel-map/README.md +62 -0
  1777. package/templates/backend/node_modules/side-channel-map/index.d.ts +15 -0
  1778. package/templates/backend/node_modules/side-channel-map/index.js +68 -0
  1779. package/templates/backend/node_modules/side-channel-map/package.json +80 -0
  1780. package/templates/backend/node_modules/side-channel-map/test/index.js +114 -0
  1781. package/templates/backend/node_modules/side-channel-map/tsconfig.json +9 -0
  1782. package/templates/backend/node_modules/side-channel-weakmap/.editorconfig +9 -0
  1783. package/templates/backend/node_modules/side-channel-weakmap/.eslintrc +12 -0
  1784. package/templates/backend/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
  1785. package/templates/backend/node_modules/side-channel-weakmap/.nycrc +13 -0
  1786. package/templates/backend/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
  1787. package/templates/backend/node_modules/side-channel-weakmap/LICENSE +21 -0
  1788. package/templates/backend/node_modules/side-channel-weakmap/README.md +62 -0
  1789. package/templates/backend/node_modules/side-channel-weakmap/index.d.ts +15 -0
  1790. package/templates/backend/node_modules/side-channel-weakmap/index.js +84 -0
  1791. package/templates/backend/node_modules/side-channel-weakmap/package.json +87 -0
  1792. package/templates/backend/node_modules/side-channel-weakmap/test/index.js +114 -0
  1793. package/templates/backend/node_modules/side-channel-weakmap/tsconfig.json +9 -0
  1794. package/templates/backend/node_modules/sift/MIT-LICENSE.txt +20 -0
  1795. package/templates/backend/node_modules/sift/README.md +465 -0
  1796. package/templates/backend/node_modules/sift/es/index.js +632 -0
  1797. package/templates/backend/node_modules/sift/es/index.js.map +1 -0
  1798. package/templates/backend/node_modules/sift/es5m/index.js +743 -0
  1799. package/templates/backend/node_modules/sift/es5m/index.js.map +1 -0
  1800. package/templates/backend/node_modules/sift/index.d.ts +4 -0
  1801. package/templates/backend/node_modules/sift/index.js +4 -0
  1802. package/templates/backend/node_modules/sift/lib/core.d.ts +116 -0
  1803. package/templates/backend/node_modules/sift/lib/index.d.ts +6 -0
  1804. package/templates/backend/node_modules/sift/lib/index.js +781 -0
  1805. package/templates/backend/node_modules/sift/lib/index.js.map +1 -0
  1806. package/templates/backend/node_modules/sift/lib/operations.d.ts +88 -0
  1807. package/templates/backend/node_modules/sift/lib/utils.d.ts +11 -0
  1808. package/templates/backend/node_modules/sift/package.json +61 -0
  1809. package/templates/backend/node_modules/sift/sift.csp.min.js +778 -0
  1810. package/templates/backend/node_modules/sift/sift.csp.min.js.map +1 -0
  1811. package/templates/backend/node_modules/sift/sift.min.js +2 -0
  1812. package/templates/backend/node_modules/sift/sift.min.js.map +1 -0
  1813. package/templates/backend/node_modules/sift/src/core.ts +494 -0
  1814. package/templates/backend/node_modules/sift/src/index.ts +54 -0
  1815. package/templates/backend/node_modules/sift/src/operations.ts +422 -0
  1816. package/templates/backend/node_modules/sift/src/utils.ts +74 -0
  1817. package/templates/backend/node_modules/simple-update-notifier/LICENSE +21 -0
  1818. package/templates/backend/node_modules/simple-update-notifier/README.md +82 -0
  1819. package/templates/backend/node_modules/simple-update-notifier/build/index.d.ts +13 -0
  1820. package/templates/backend/node_modules/simple-update-notifier/build/index.js +210 -0
  1821. package/templates/backend/node_modules/simple-update-notifier/package.json +100 -0
  1822. package/templates/backend/node_modules/simple-update-notifier/src/borderedText.ts +12 -0
  1823. package/templates/backend/node_modules/simple-update-notifier/src/cache.spec.ts +17 -0
  1824. package/templates/backend/node_modules/simple-update-notifier/src/cache.ts +44 -0
  1825. package/templates/backend/node_modules/simple-update-notifier/src/getDistVersion.spec.ts +35 -0
  1826. package/templates/backend/node_modules/simple-update-notifier/src/getDistVersion.ts +29 -0
  1827. package/templates/backend/node_modules/simple-update-notifier/src/hasNewVersion.spec.ts +82 -0
  1828. package/templates/backend/node_modules/simple-update-notifier/src/hasNewVersion.ts +40 -0
  1829. package/templates/backend/node_modules/simple-update-notifier/src/index.spec.ts +27 -0
  1830. package/templates/backend/node_modules/simple-update-notifier/src/index.ts +34 -0
  1831. package/templates/backend/node_modules/simple-update-notifier/src/isNpmOrYarn.ts +12 -0
  1832. package/templates/backend/node_modules/simple-update-notifier/src/types.ts +8 -0
  1833. package/templates/backend/node_modules/sparse-bitfield/.travis.yml +6 -0
  1834. package/templates/backend/node_modules/sparse-bitfield/LICENSE +21 -0
  1835. package/templates/backend/node_modules/sparse-bitfield/README.md +62 -0
  1836. package/templates/backend/node_modules/sparse-bitfield/index.js +95 -0
  1837. package/templates/backend/node_modules/sparse-bitfield/package.json +27 -0
  1838. package/templates/backend/node_modules/sparse-bitfield/test.js +79 -0
  1839. package/templates/backend/node_modules/statuses/HISTORY.md +87 -0
  1840. package/templates/backend/node_modules/statuses/LICENSE +23 -0
  1841. package/templates/backend/node_modules/statuses/README.md +139 -0
  1842. package/templates/backend/node_modules/statuses/codes.json +65 -0
  1843. package/templates/backend/node_modules/statuses/index.js +146 -0
  1844. package/templates/backend/node_modules/statuses/package.json +49 -0
  1845. package/templates/backend/node_modules/supports-color/browser.js +5 -0
  1846. package/templates/backend/node_modules/supports-color/index.js +131 -0
  1847. package/templates/backend/node_modules/supports-color/license +9 -0
  1848. package/templates/backend/node_modules/supports-color/package.json +53 -0
  1849. package/templates/backend/node_modules/supports-color/readme.md +66 -0
  1850. package/templates/backend/node_modules/to-regex-range/LICENSE +21 -0
  1851. package/templates/backend/node_modules/to-regex-range/README.md +305 -0
  1852. package/templates/backend/node_modules/to-regex-range/index.js +288 -0
  1853. package/templates/backend/node_modules/to-regex-range/package.json +88 -0
  1854. package/templates/backend/node_modules/toidentifier/HISTORY.md +9 -0
  1855. package/templates/backend/node_modules/toidentifier/LICENSE +21 -0
  1856. package/templates/backend/node_modules/toidentifier/README.md +61 -0
  1857. package/templates/backend/node_modules/toidentifier/index.js +32 -0
  1858. package/templates/backend/node_modules/toidentifier/package.json +38 -0
  1859. package/templates/backend/node_modules/touch/LICENSE +15 -0
  1860. package/templates/backend/node_modules/touch/README.md +52 -0
  1861. package/templates/backend/node_modules/touch/bin/nodetouch.js +112 -0
  1862. package/templates/backend/node_modules/touch/index.js +224 -0
  1863. package/templates/backend/node_modules/touch/package.json +25 -0
  1864. package/templates/backend/node_modules/tr46/LICENSE.md +21 -0
  1865. package/templates/backend/node_modules/tr46/README.md +76 -0
  1866. package/templates/backend/node_modules/tr46/index.js +344 -0
  1867. package/templates/backend/node_modules/tr46/lib/mappingTable.json +1 -0
  1868. package/templates/backend/node_modules/tr46/lib/regexes.js +29 -0
  1869. package/templates/backend/node_modules/tr46/lib/statusMapping.js +9 -0
  1870. package/templates/backend/node_modules/tr46/package.json +44 -0
  1871. package/templates/backend/node_modules/type-is/HISTORY.md +292 -0
  1872. package/templates/backend/node_modules/type-is/LICENSE +23 -0
  1873. package/templates/backend/node_modules/type-is/README.md +198 -0
  1874. package/templates/backend/node_modules/type-is/index.js +240 -0
  1875. package/templates/backend/node_modules/type-is/node_modules/content-type/LICENSE +22 -0
  1876. package/templates/backend/node_modules/type-is/node_modules/content-type/README.md +69 -0
  1877. package/templates/backend/node_modules/type-is/node_modules/content-type/dist/index.d.ts +26 -0
  1878. package/templates/backend/node_modules/type-is/node_modules/content-type/dist/index.js +170 -0
  1879. package/templates/backend/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -0
  1880. package/templates/backend/node_modules/type-is/node_modules/content-type/package.json +52 -0
  1881. package/templates/backend/node_modules/type-is/package.json +51 -0
  1882. package/templates/backend/node_modules/undefsafe/.github/workflows/release.yml +25 -0
  1883. package/templates/backend/node_modules/undefsafe/.jscsrc +13 -0
  1884. package/templates/backend/node_modules/undefsafe/.jshintrc +16 -0
  1885. package/templates/backend/node_modules/undefsafe/.travis.yml +18 -0
  1886. package/templates/backend/node_modules/undefsafe/LICENSE +22 -0
  1887. package/templates/backend/node_modules/undefsafe/README.md +63 -0
  1888. package/templates/backend/node_modules/undefsafe/example.js +14 -0
  1889. package/templates/backend/node_modules/undefsafe/lib/undefsafe.js +125 -0
  1890. package/templates/backend/node_modules/undefsafe/package.json +34 -0
  1891. package/templates/backend/node_modules/unpipe/HISTORY.md +4 -0
  1892. package/templates/backend/node_modules/unpipe/LICENSE +22 -0
  1893. package/templates/backend/node_modules/unpipe/README.md +43 -0
  1894. package/templates/backend/node_modules/unpipe/index.js +69 -0
  1895. package/templates/backend/node_modules/unpipe/package.json +27 -0
  1896. package/templates/backend/node_modules/vary/HISTORY.md +39 -0
  1897. package/templates/backend/node_modules/vary/LICENSE +22 -0
  1898. package/templates/backend/node_modules/vary/README.md +101 -0
  1899. package/templates/backend/node_modules/vary/index.js +149 -0
  1900. package/templates/backend/node_modules/vary/package.json +43 -0
  1901. package/templates/backend/node_modules/webidl-conversions/LICENSE.md +12 -0
  1902. package/templates/backend/node_modules/webidl-conversions/README.md +99 -0
  1903. package/templates/backend/node_modules/webidl-conversions/lib/index.js +450 -0
  1904. package/templates/backend/node_modules/webidl-conversions/package.json +35 -0
  1905. package/templates/backend/node_modules/whatwg-url/LICENSE.txt +21 -0
  1906. package/templates/backend/node_modules/whatwg-url/README.md +106 -0
  1907. package/templates/backend/node_modules/whatwg-url/index.js +27 -0
  1908. package/templates/backend/node_modules/whatwg-url/lib/Function.js +42 -0
  1909. package/templates/backend/node_modules/whatwg-url/lib/URL-impl.js +233 -0
  1910. package/templates/backend/node_modules/whatwg-url/lib/URL.js +499 -0
  1911. package/templates/backend/node_modules/whatwg-url/lib/URLSearchParams-impl.js +135 -0
  1912. package/templates/backend/node_modules/whatwg-url/lib/URLSearchParams.js +505 -0
  1913. package/templates/backend/node_modules/whatwg-url/lib/VoidFunction.js +26 -0
  1914. package/templates/backend/node_modules/whatwg-url/lib/encoding.js +16 -0
  1915. package/templates/backend/node_modules/whatwg-url/lib/infra.js +26 -0
  1916. package/templates/backend/node_modules/whatwg-url/lib/percent-encoding.js +142 -0
  1917. package/templates/backend/node_modules/whatwg-url/lib/url-state-machine.js +1274 -0
  1918. package/templates/backend/node_modules/whatwg-url/lib/urlencoded.js +89 -0
  1919. package/templates/backend/node_modules/whatwg-url/lib/utils.js +190 -0
  1920. package/templates/backend/node_modules/whatwg-url/package.json +53 -0
  1921. package/templates/backend/node_modules/whatwg-url/webidl2js-wrapper.js +7 -0
  1922. package/templates/backend/node_modules/wrappy/LICENSE +15 -0
  1923. package/templates/backend/node_modules/wrappy/README.md +36 -0
  1924. package/templates/backend/node_modules/wrappy/package.json +29 -0
  1925. package/templates/backend/node_modules/wrappy/wrappy.js +33 -0
  1926. package/templates/backend/package-lock.json +1543 -0
  1927. package/templates/backend/package.json +22 -0
  1928. package/templates/backend/server.js +131 -0
  1929. package/templates/frontend/README.md +18 -0
  1930. package/templates/frontend/eslint.config.js +21 -0
  1931. package/templates/frontend/index.html +13 -0
  1932. package/templates/frontend/package-lock.json +3136 -0
  1933. package/templates/frontend/package.json +34 -0
  1934. package/templates/frontend/public/favicon.svg +1 -0
  1935. package/templates/frontend/public/icons.svg +24 -0
  1936. package/templates/frontend/src/App.css +184 -0
  1937. package/templates/frontend/src/App.jsx +17 -0
  1938. package/templates/frontend/src/admin.jsx +29 -0
  1939. package/templates/frontend/src/assets/hero.png +0 -0
  1940. package/templates/frontend/src/assets/react.svg +1 -0
  1941. package/templates/frontend/src/assets/vite.svg +1 -0
  1942. package/templates/frontend/src/auth/login.jsx +82 -0
  1943. package/templates/frontend/src/auth/logout.jsx +17 -0
  1944. package/templates/frontend/src/auth/signup.jsx +137 -0
  1945. package/templates/frontend/src/index.css +1 -0
  1946. package/templates/frontend/src/main.jsx +10 -0
  1947. package/templates/frontend/vite.config.js +12 -0
@@ -0,0 +1,4745 @@
1
+ 'use strict';
2
+
3
+ const TypedArrayPrototypeGetSymbolToStringTag = (() => {
4
+ const g = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
5
+ return (value) => g.call(value);
6
+ })();
7
+ function isUint8Array(value) {
8
+ return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8Array';
9
+ }
10
+ function isAnyArrayBuffer(value) {
11
+ return (typeof value === 'object' &&
12
+ value != null &&
13
+ Symbol.toStringTag in value &&
14
+ (value[Symbol.toStringTag] === 'ArrayBuffer' ||
15
+ value[Symbol.toStringTag] === 'SharedArrayBuffer'));
16
+ }
17
+ function isRegExp(regexp) {
18
+ return regexp instanceof RegExp || Object.prototype.toString.call(regexp) === '[object RegExp]';
19
+ }
20
+ function isMap(value) {
21
+ return (typeof value === 'object' &&
22
+ value != null &&
23
+ Symbol.toStringTag in value &&
24
+ value[Symbol.toStringTag] === 'Map');
25
+ }
26
+ function isDate(date) {
27
+ return date instanceof Date || Object.prototype.toString.call(date) === '[object Date]';
28
+ }
29
+ function defaultInspect(x, _options) {
30
+ return JSON.stringify(x, (k, v) => {
31
+ if (typeof v === 'bigint') {
32
+ return { $numberLong: `${v}` };
33
+ }
34
+ else if (isMap(v)) {
35
+ return Object.fromEntries(v);
36
+ }
37
+ return v;
38
+ });
39
+ }
40
+ function getStylizeFunction(options) {
41
+ const stylizeExists = options != null &&
42
+ typeof options === 'object' &&
43
+ 'stylize' in options &&
44
+ typeof options.stylize === 'function';
45
+ if (stylizeExists) {
46
+ return options.stylize;
47
+ }
48
+ }
49
+
50
+ const BSON_MAJOR_VERSION = 7;
51
+ const BSON_VERSION_SYMBOL = Symbol.for('@@mdb.bson.version');
52
+ const BSON_INT32_MAX = 0x7fffffff;
53
+ const BSON_INT32_MIN = -2147483648;
54
+ const BSON_INT64_MAX = Math.pow(2, 63) - 1;
55
+ const BSON_INT64_MIN = -Math.pow(2, 63);
56
+ const JS_INT_MAX = Math.pow(2, 53);
57
+ const JS_INT_MIN = -Math.pow(2, 53);
58
+ const BSON_DATA_NUMBER = 1;
59
+ const BSON_DATA_STRING = 2;
60
+ const BSON_DATA_OBJECT = 3;
61
+ const BSON_DATA_ARRAY = 4;
62
+ const BSON_DATA_BINARY = 5;
63
+ const BSON_DATA_UNDEFINED = 6;
64
+ const BSON_DATA_OID = 7;
65
+ const BSON_DATA_BOOLEAN = 8;
66
+ const BSON_DATA_DATE = 9;
67
+ const BSON_DATA_NULL = 10;
68
+ const BSON_DATA_REGEXP = 11;
69
+ const BSON_DATA_DBPOINTER = 12;
70
+ const BSON_DATA_CODE = 13;
71
+ const BSON_DATA_SYMBOL = 14;
72
+ const BSON_DATA_CODE_W_SCOPE = 15;
73
+ const BSON_DATA_INT = 16;
74
+ const BSON_DATA_TIMESTAMP = 17;
75
+ const BSON_DATA_LONG = 18;
76
+ const BSON_DATA_DECIMAL128 = 19;
77
+ const BSON_DATA_MIN_KEY = 0xff;
78
+ const BSON_DATA_MAX_KEY = 0x7f;
79
+ const BSON_BINARY_SUBTYPE_DEFAULT = 0;
80
+ const BSON_BINARY_SUBTYPE_UUID_NEW = 4;
81
+ const BSONType = Object.freeze({
82
+ double: 1,
83
+ string: 2,
84
+ object: 3,
85
+ array: 4,
86
+ binData: 5,
87
+ undefined: 6,
88
+ objectId: 7,
89
+ bool: 8,
90
+ date: 9,
91
+ null: 10,
92
+ regex: 11,
93
+ dbPointer: 12,
94
+ javascript: 13,
95
+ symbol: 14,
96
+ javascriptWithScope: 15,
97
+ int: 16,
98
+ timestamp: 17,
99
+ long: 18,
100
+ decimal: 19,
101
+ minKey: -1,
102
+ maxKey: 127
103
+ });
104
+
105
+ class BSONError extends Error {
106
+ get bsonError() {
107
+ return true;
108
+ }
109
+ get name() {
110
+ return 'BSONError';
111
+ }
112
+ constructor(message, options) {
113
+ super(message, options);
114
+ }
115
+ static isBSONError(value) {
116
+ return (value != null &&
117
+ typeof value === 'object' &&
118
+ 'bsonError' in value &&
119
+ value.bsonError === true &&
120
+ 'name' in value &&
121
+ 'message' in value &&
122
+ 'stack' in value);
123
+ }
124
+ }
125
+ class BSONVersionError extends BSONError {
126
+ get name() {
127
+ return 'BSONVersionError';
128
+ }
129
+ constructor() {
130
+ super(`Unsupported BSON version, bson types must be from bson ${BSON_MAJOR_VERSION}.x.x`);
131
+ }
132
+ }
133
+ class BSONRuntimeError extends BSONError {
134
+ get name() {
135
+ return 'BSONRuntimeError';
136
+ }
137
+ constructor(message) {
138
+ super(message);
139
+ }
140
+ }
141
+ class BSONOffsetError extends BSONError {
142
+ get name() {
143
+ return 'BSONOffsetError';
144
+ }
145
+ offset;
146
+ constructor(message, offset, options) {
147
+ super(`${message}. offset: ${offset}`, options);
148
+ this.offset = offset;
149
+ }
150
+ }
151
+
152
+ let TextDecoderFatal;
153
+ let TextDecoderNonFatal;
154
+ function parseUtf8(buffer, start, end, fatal) {
155
+ if (fatal) {
156
+ TextDecoderFatal ??= new TextDecoder('utf8', { fatal: true });
157
+ try {
158
+ return TextDecoderFatal.decode(buffer.subarray(start, end));
159
+ }
160
+ catch (cause) {
161
+ throw new BSONError('Invalid UTF-8 string in BSON document', { cause });
162
+ }
163
+ }
164
+ TextDecoderNonFatal ??= new TextDecoder('utf8', { fatal: false });
165
+ return TextDecoderNonFatal.decode(buffer.subarray(start, end));
166
+ }
167
+
168
+ function tryReadBasicLatin(uint8array, start, end) {
169
+ if (uint8array.length === 0) {
170
+ return '';
171
+ }
172
+ const stringByteLength = end - start;
173
+ if (stringByteLength === 0) {
174
+ return '';
175
+ }
176
+ if (stringByteLength > 20) {
177
+ return null;
178
+ }
179
+ if (stringByteLength === 1 && uint8array[start] < 128) {
180
+ return String.fromCharCode(uint8array[start]);
181
+ }
182
+ if (stringByteLength === 2 && uint8array[start] < 128 && uint8array[start + 1] < 128) {
183
+ return String.fromCharCode(uint8array[start]) + String.fromCharCode(uint8array[start + 1]);
184
+ }
185
+ if (stringByteLength === 3 &&
186
+ uint8array[start] < 128 &&
187
+ uint8array[start + 1] < 128 &&
188
+ uint8array[start + 2] < 128) {
189
+ return (String.fromCharCode(uint8array[start]) +
190
+ String.fromCharCode(uint8array[start + 1]) +
191
+ String.fromCharCode(uint8array[start + 2]));
192
+ }
193
+ const latinBytes = [];
194
+ for (let i = start; i < end; i++) {
195
+ const byte = uint8array[i];
196
+ if (byte > 127) {
197
+ return null;
198
+ }
199
+ latinBytes.push(byte);
200
+ }
201
+ return String.fromCharCode(...latinBytes);
202
+ }
203
+ function tryWriteBasicLatin(destination, source, offset) {
204
+ if (source.length === 0)
205
+ return 0;
206
+ if (source.length > 25)
207
+ return null;
208
+ if (destination.length - offset < source.length)
209
+ return null;
210
+ for (let charOffset = 0, destinationOffset = offset; charOffset < source.length; charOffset++, destinationOffset++) {
211
+ const char = source.charCodeAt(charOffset);
212
+ if (char > 127)
213
+ return null;
214
+ destination[destinationOffset] = char;
215
+ }
216
+ return source.length;
217
+ }
218
+
219
+ function nodejsMathRandomBytes(byteLength) {
220
+ return nodeJsByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
221
+ }
222
+ function nodejsSecureRandomBytes(byteLength) {
223
+ return crypto.getRandomValues(nodeJsByteUtils.allocate(byteLength));
224
+ }
225
+ const nodejsRandomBytes = (() => {
226
+ const { crypto } = globalThis;
227
+ if (crypto != null && typeof crypto.getRandomValues === 'function') {
228
+ return nodejsSecureRandomBytes;
229
+ }
230
+ else {
231
+ return nodejsMathRandomBytes;
232
+ }
233
+ })();
234
+ const nodeJsByteUtils = {
235
+ isUint8Array: isUint8Array,
236
+ toLocalBufferType(potentialBuffer) {
237
+ if (Buffer.isBuffer(potentialBuffer)) {
238
+ return potentialBuffer;
239
+ }
240
+ if (ArrayBuffer.isView(potentialBuffer)) {
241
+ return Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
242
+ }
243
+ const stringTag = potentialBuffer?.[Symbol.toStringTag] ?? Object.prototype.toString.call(potentialBuffer);
244
+ if (stringTag === 'ArrayBuffer' ||
245
+ stringTag === 'SharedArrayBuffer' ||
246
+ stringTag === '[object ArrayBuffer]' ||
247
+ stringTag === '[object SharedArrayBuffer]') {
248
+ return Buffer.from(potentialBuffer);
249
+ }
250
+ throw new BSONError(`Cannot create Buffer from the passed potentialBuffer.`);
251
+ },
252
+ allocate(size) {
253
+ return Buffer.alloc(size);
254
+ },
255
+ allocateUnsafe(size) {
256
+ return Buffer.allocUnsafe(size);
257
+ },
258
+ compare(a, b) {
259
+ return nodeJsByteUtils.toLocalBufferType(a).compare(b);
260
+ },
261
+ concat(list) {
262
+ return Buffer.concat(list);
263
+ },
264
+ copy(source, target, targetStart, sourceStart, sourceEnd) {
265
+ return nodeJsByteUtils
266
+ .toLocalBufferType(source)
267
+ .copy(target, targetStart ?? 0, sourceStart ?? 0, sourceEnd ?? source.length);
268
+ },
269
+ equals(a, b) {
270
+ return nodeJsByteUtils.toLocalBufferType(a).equals(b);
271
+ },
272
+ fromNumberArray(array) {
273
+ return Buffer.from(array);
274
+ },
275
+ fromBase64(base64) {
276
+ return Buffer.from(base64, 'base64');
277
+ },
278
+ fromUTF8(utf8) {
279
+ return Buffer.from(utf8, 'utf8');
280
+ },
281
+ toBase64(buffer) {
282
+ return nodeJsByteUtils.toLocalBufferType(buffer).toString('base64');
283
+ },
284
+ fromISO88591(codePoints) {
285
+ return Buffer.from(codePoints, 'binary');
286
+ },
287
+ toISO88591(buffer) {
288
+ return nodeJsByteUtils.toLocalBufferType(buffer).toString('binary');
289
+ },
290
+ fromHex(hex) {
291
+ return Buffer.from(hex, 'hex');
292
+ },
293
+ toHex(buffer) {
294
+ return nodeJsByteUtils.toLocalBufferType(buffer).toString('hex');
295
+ },
296
+ toUTF8(buffer, start, end, fatal) {
297
+ const basicLatin = end - start <= 20 ? tryReadBasicLatin(buffer, start, end) : null;
298
+ if (basicLatin != null) {
299
+ return basicLatin;
300
+ }
301
+ const string = nodeJsByteUtils.toLocalBufferType(buffer).toString('utf8', start, end);
302
+ if (fatal) {
303
+ for (let i = 0; i < string.length; i++) {
304
+ if (string.charCodeAt(i) === 0xfffd) {
305
+ parseUtf8(buffer, start, end, true);
306
+ break;
307
+ }
308
+ }
309
+ }
310
+ return string;
311
+ },
312
+ utf8ByteLength(input) {
313
+ return Buffer.byteLength(input, 'utf8');
314
+ },
315
+ encodeUTF8Into(buffer, source, byteOffset) {
316
+ const latinBytesWritten = tryWriteBasicLatin(buffer, source, byteOffset);
317
+ if (latinBytesWritten != null) {
318
+ return latinBytesWritten;
319
+ }
320
+ return nodeJsByteUtils.toLocalBufferType(buffer).write(source, byteOffset, undefined, 'utf8');
321
+ },
322
+ randomBytes: nodejsRandomBytes,
323
+ swap32(buffer) {
324
+ return nodeJsByteUtils.toLocalBufferType(buffer).swap32();
325
+ }
326
+ };
327
+
328
+ function isReactNative() {
329
+ const { navigator } = globalThis;
330
+ return typeof navigator === 'object' && navigator.product === 'ReactNative';
331
+ }
332
+ function webMathRandomBytes(byteLength) {
333
+ if (byteLength < 0) {
334
+ throw new RangeError(`The argument 'byteLength' is invalid. Received ${byteLength}`);
335
+ }
336
+ return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
337
+ }
338
+ const webRandomBytes = (() => {
339
+ const { crypto } = globalThis;
340
+ if (crypto != null && typeof crypto.getRandomValues === 'function') {
341
+ return (byteLength) => {
342
+ return crypto.getRandomValues(webByteUtils.allocate(byteLength));
343
+ };
344
+ }
345
+ else {
346
+ if (isReactNative()) {
347
+ const { console } = globalThis;
348
+ console?.warn?.('BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.');
349
+ }
350
+ return webMathRandomBytes;
351
+ }
352
+ })();
353
+ const HEX_DIGIT = /(\d|[a-f])/i;
354
+ const webByteUtils = {
355
+ isUint8Array: isUint8Array,
356
+ toLocalBufferType(potentialUint8array) {
357
+ const stringTag = potentialUint8array?.[Symbol.toStringTag] ??
358
+ Object.prototype.toString.call(potentialUint8array);
359
+ if (stringTag === 'Uint8Array') {
360
+ return potentialUint8array;
361
+ }
362
+ if (ArrayBuffer.isView(potentialUint8array)) {
363
+ return new Uint8Array(potentialUint8array.buffer.slice(potentialUint8array.byteOffset, potentialUint8array.byteOffset + potentialUint8array.byteLength));
364
+ }
365
+ if (stringTag === 'ArrayBuffer' ||
366
+ stringTag === 'SharedArrayBuffer' ||
367
+ stringTag === '[object ArrayBuffer]' ||
368
+ stringTag === '[object SharedArrayBuffer]') {
369
+ return new Uint8Array(potentialUint8array);
370
+ }
371
+ throw new BSONError(`Cannot make a Uint8Array from passed potentialBuffer.`);
372
+ },
373
+ allocate(size) {
374
+ if (typeof size !== 'number') {
375
+ throw new TypeError(`The "size" argument must be of type number. Received ${String(size)}`);
376
+ }
377
+ return new Uint8Array(size);
378
+ },
379
+ allocateUnsafe(size) {
380
+ return webByteUtils.allocate(size);
381
+ },
382
+ compare(uint8Array, otherUint8Array) {
383
+ if (uint8Array === otherUint8Array)
384
+ return 0;
385
+ const len = Math.min(uint8Array.length, otherUint8Array.length);
386
+ for (let i = 0; i < len; i++) {
387
+ if (uint8Array[i] < otherUint8Array[i])
388
+ return -1;
389
+ if (uint8Array[i] > otherUint8Array[i])
390
+ return 1;
391
+ }
392
+ if (uint8Array.length < otherUint8Array.length)
393
+ return -1;
394
+ if (uint8Array.length > otherUint8Array.length)
395
+ return 1;
396
+ return 0;
397
+ },
398
+ concat(uint8Arrays) {
399
+ if (uint8Arrays.length === 0)
400
+ return webByteUtils.allocate(0);
401
+ let totalLength = 0;
402
+ for (const uint8Array of uint8Arrays) {
403
+ totalLength += uint8Array.length;
404
+ }
405
+ const result = webByteUtils.allocate(totalLength);
406
+ let offset = 0;
407
+ for (const uint8Array of uint8Arrays) {
408
+ result.set(uint8Array, offset);
409
+ offset += uint8Array.length;
410
+ }
411
+ return result;
412
+ },
413
+ copy(source, target, targetStart, sourceStart, sourceEnd) {
414
+ if (sourceEnd !== undefined && sourceEnd < 0) {
415
+ throw new RangeError(`The value of "sourceEnd" is out of range. It must be >= 0. Received ${sourceEnd}`);
416
+ }
417
+ sourceEnd = sourceEnd ?? source.length;
418
+ if (sourceStart !== undefined && (sourceStart < 0 || sourceStart > sourceEnd)) {
419
+ throw new RangeError(`The value of "sourceStart" is out of range. It must be >= 0 and <= ${sourceEnd}. Received ${sourceStart}`);
420
+ }
421
+ sourceStart = sourceStart ?? 0;
422
+ if (targetStart !== undefined && targetStart < 0) {
423
+ throw new RangeError(`The value of "targetStart" is out of range. It must be >= 0. Received ${targetStart}`);
424
+ }
425
+ targetStart = targetStart ?? 0;
426
+ const srcSlice = source.subarray(sourceStart, sourceEnd);
427
+ const maxLen = Math.min(srcSlice.length, target.length - targetStart);
428
+ if (maxLen <= 0) {
429
+ return 0;
430
+ }
431
+ target.set(srcSlice.subarray(0, maxLen), targetStart);
432
+ return maxLen;
433
+ },
434
+ equals(uint8Array, otherUint8Array) {
435
+ if (uint8Array.byteLength !== otherUint8Array.byteLength) {
436
+ return false;
437
+ }
438
+ for (let i = 0; i < uint8Array.byteLength; i++) {
439
+ if (uint8Array[i] !== otherUint8Array[i]) {
440
+ return false;
441
+ }
442
+ }
443
+ return true;
444
+ },
445
+ fromNumberArray(array) {
446
+ return Uint8Array.from(array);
447
+ },
448
+ fromBase64(base64) {
449
+ return Uint8Array.from(atob(base64), c => c.charCodeAt(0));
450
+ },
451
+ fromUTF8(utf8) {
452
+ return new TextEncoder().encode(utf8);
453
+ },
454
+ toBase64(uint8array) {
455
+ return btoa(webByteUtils.toISO88591(uint8array));
456
+ },
457
+ fromISO88591(codePoints) {
458
+ return Uint8Array.from(codePoints, c => c.charCodeAt(0) & 0xff);
459
+ },
460
+ toISO88591(uint8array) {
461
+ return Array.from(Uint16Array.from(uint8array), b => String.fromCharCode(b)).join('');
462
+ },
463
+ fromHex(hex) {
464
+ const evenLengthHex = hex.length % 2 === 0 ? hex : hex.slice(0, hex.length - 1);
465
+ const buffer = [];
466
+ for (let i = 0; i < evenLengthHex.length; i += 2) {
467
+ const firstDigit = evenLengthHex[i];
468
+ const secondDigit = evenLengthHex[i + 1];
469
+ if (!HEX_DIGIT.test(firstDigit)) {
470
+ break;
471
+ }
472
+ if (!HEX_DIGIT.test(secondDigit)) {
473
+ break;
474
+ }
475
+ const hexDigit = Number.parseInt(`${firstDigit}${secondDigit}`, 16);
476
+ buffer.push(hexDigit);
477
+ }
478
+ return Uint8Array.from(buffer);
479
+ },
480
+ toHex(uint8array) {
481
+ return Array.from(uint8array, byte => byte.toString(16).padStart(2, '0')).join('');
482
+ },
483
+ toUTF8(uint8array, start, end, fatal) {
484
+ const basicLatin = end - start <= 20 ? tryReadBasicLatin(uint8array, start, end) : null;
485
+ if (basicLatin != null) {
486
+ return basicLatin;
487
+ }
488
+ return parseUtf8(uint8array, start, end, fatal);
489
+ },
490
+ utf8ByteLength(input) {
491
+ return new TextEncoder().encode(input).byteLength;
492
+ },
493
+ encodeUTF8Into(uint8array, source, byteOffset) {
494
+ const bytes = new TextEncoder().encode(source);
495
+ uint8array.set(bytes, byteOffset);
496
+ return bytes.byteLength;
497
+ },
498
+ randomBytes: webRandomBytes,
499
+ swap32(buffer) {
500
+ if (buffer.length % 4 !== 0) {
501
+ throw new RangeError('Buffer size must be a multiple of 32-bits');
502
+ }
503
+ for (let i = 0; i < buffer.length; i += 4) {
504
+ const byte0 = buffer[i];
505
+ const byte1 = buffer[i + 1];
506
+ const byte2 = buffer[i + 2];
507
+ const byte3 = buffer[i + 3];
508
+ buffer[i] = byte3;
509
+ buffer[i + 1] = byte2;
510
+ buffer[i + 2] = byte1;
511
+ buffer[i + 3] = byte0;
512
+ }
513
+ return buffer;
514
+ }
515
+ };
516
+
517
+ const hasGlobalBuffer = typeof Buffer === 'function' && Buffer.prototype?._isBuffer !== true;
518
+ const ByteUtils = hasGlobalBuffer ? nodeJsByteUtils : webByteUtils;
519
+
520
+ const bsonType = Symbol.for('@@mdb.bson.type');
521
+ class BSONValue {
522
+ get [bsonType]() {
523
+ return this._bsontype;
524
+ }
525
+ get [BSON_VERSION_SYMBOL]() {
526
+ return BSON_MAJOR_VERSION;
527
+ }
528
+ [Symbol.for('nodejs.util.inspect.custom')](depth, options, inspect) {
529
+ return this.inspect(depth, options, inspect);
530
+ }
531
+ }
532
+
533
+ const FLOAT = new Float64Array(1);
534
+ const FLOAT_BYTES = new Uint8Array(FLOAT.buffer, 0, 8);
535
+ FLOAT[0] = -1;
536
+ const isBigEndian = FLOAT_BYTES[7] === 0;
537
+ const NumberUtils = {
538
+ isBigEndian,
539
+ getNonnegativeInt32LE(source, offset) {
540
+ if (source[offset + 3] > 127) {
541
+ throw new RangeError(`Size cannot be negative at offset: ${offset}`);
542
+ }
543
+ return (source[offset] |
544
+ (source[offset + 1] << 8) |
545
+ (source[offset + 2] << 16) |
546
+ (source[offset + 3] << 24));
547
+ },
548
+ getInt32LE(source, offset) {
549
+ return (source[offset] |
550
+ (source[offset + 1] << 8) |
551
+ (source[offset + 2] << 16) |
552
+ (source[offset + 3] << 24));
553
+ },
554
+ getUint32LE(source, offset) {
555
+ return (source[offset] +
556
+ source[offset + 1] * 256 +
557
+ source[offset + 2] * 65536 +
558
+ source[offset + 3] * 16777216);
559
+ },
560
+ getUint32BE(source, offset) {
561
+ return (source[offset + 3] +
562
+ source[offset + 2] * 256 +
563
+ source[offset + 1] * 65536 +
564
+ source[offset] * 16777216);
565
+ },
566
+ getBigInt64LE(source, offset) {
567
+ const hi = BigInt(source[offset + 4] +
568
+ source[offset + 5] * 256 +
569
+ source[offset + 6] * 65536 +
570
+ (source[offset + 7] << 24));
571
+ const lo = BigInt(source[offset] +
572
+ source[offset + 1] * 256 +
573
+ source[offset + 2] * 65536 +
574
+ source[offset + 3] * 16777216);
575
+ return (hi << 32n) + lo;
576
+ },
577
+ getFloat64LE: isBigEndian
578
+ ? (source, offset) => {
579
+ FLOAT_BYTES[7] = source[offset];
580
+ FLOAT_BYTES[6] = source[offset + 1];
581
+ FLOAT_BYTES[5] = source[offset + 2];
582
+ FLOAT_BYTES[4] = source[offset + 3];
583
+ FLOAT_BYTES[3] = source[offset + 4];
584
+ FLOAT_BYTES[2] = source[offset + 5];
585
+ FLOAT_BYTES[1] = source[offset + 6];
586
+ FLOAT_BYTES[0] = source[offset + 7];
587
+ return FLOAT[0];
588
+ }
589
+ : (source, offset) => {
590
+ FLOAT_BYTES[0] = source[offset];
591
+ FLOAT_BYTES[1] = source[offset + 1];
592
+ FLOAT_BYTES[2] = source[offset + 2];
593
+ FLOAT_BYTES[3] = source[offset + 3];
594
+ FLOAT_BYTES[4] = source[offset + 4];
595
+ FLOAT_BYTES[5] = source[offset + 5];
596
+ FLOAT_BYTES[6] = source[offset + 6];
597
+ FLOAT_BYTES[7] = source[offset + 7];
598
+ return FLOAT[0];
599
+ },
600
+ setInt32BE(destination, offset, value) {
601
+ destination[offset + 3] = value;
602
+ value >>>= 8;
603
+ destination[offset + 2] = value;
604
+ value >>>= 8;
605
+ destination[offset + 1] = value;
606
+ value >>>= 8;
607
+ destination[offset] = value;
608
+ return 4;
609
+ },
610
+ setInt32LE(destination, offset, value) {
611
+ destination[offset] = value;
612
+ value >>>= 8;
613
+ destination[offset + 1] = value;
614
+ value >>>= 8;
615
+ destination[offset + 2] = value;
616
+ value >>>= 8;
617
+ destination[offset + 3] = value;
618
+ return 4;
619
+ },
620
+ setBigInt64LE(destination, offset, value) {
621
+ const mask32bits = 0xffffffffn;
622
+ let lo = Number(value & mask32bits);
623
+ destination[offset] = lo;
624
+ lo >>= 8;
625
+ destination[offset + 1] = lo;
626
+ lo >>= 8;
627
+ destination[offset + 2] = lo;
628
+ lo >>= 8;
629
+ destination[offset + 3] = lo;
630
+ let hi = Number((value >> 32n) & mask32bits);
631
+ destination[offset + 4] = hi;
632
+ hi >>= 8;
633
+ destination[offset + 5] = hi;
634
+ hi >>= 8;
635
+ destination[offset + 6] = hi;
636
+ hi >>= 8;
637
+ destination[offset + 7] = hi;
638
+ return 8;
639
+ },
640
+ setFloat64LE: isBigEndian
641
+ ? (destination, offset, value) => {
642
+ FLOAT[0] = value;
643
+ destination[offset] = FLOAT_BYTES[7];
644
+ destination[offset + 1] = FLOAT_BYTES[6];
645
+ destination[offset + 2] = FLOAT_BYTES[5];
646
+ destination[offset + 3] = FLOAT_BYTES[4];
647
+ destination[offset + 4] = FLOAT_BYTES[3];
648
+ destination[offset + 5] = FLOAT_BYTES[2];
649
+ destination[offset + 6] = FLOAT_BYTES[1];
650
+ destination[offset + 7] = FLOAT_BYTES[0];
651
+ return 8;
652
+ }
653
+ : (destination, offset, value) => {
654
+ FLOAT[0] = value;
655
+ destination[offset] = FLOAT_BYTES[0];
656
+ destination[offset + 1] = FLOAT_BYTES[1];
657
+ destination[offset + 2] = FLOAT_BYTES[2];
658
+ destination[offset + 3] = FLOAT_BYTES[3];
659
+ destination[offset + 4] = FLOAT_BYTES[4];
660
+ destination[offset + 5] = FLOAT_BYTES[5];
661
+ destination[offset + 6] = FLOAT_BYTES[6];
662
+ destination[offset + 7] = FLOAT_BYTES[7];
663
+ return 8;
664
+ }
665
+ };
666
+
667
+ class Binary extends BSONValue {
668
+ get _bsontype() {
669
+ return 'Binary';
670
+ }
671
+ static BSON_BINARY_SUBTYPE_DEFAULT = 0;
672
+ static BUFFER_SIZE = 256;
673
+ static SUBTYPE_DEFAULT = 0;
674
+ static SUBTYPE_FUNCTION = 1;
675
+ static SUBTYPE_BYTE_ARRAY = 2;
676
+ static SUBTYPE_UUID_OLD = 3;
677
+ static SUBTYPE_UUID = 4;
678
+ static SUBTYPE_MD5 = 5;
679
+ static SUBTYPE_ENCRYPTED = 6;
680
+ static SUBTYPE_COLUMN = 7;
681
+ static SUBTYPE_SENSITIVE = 8;
682
+ static SUBTYPE_VECTOR = 9;
683
+ static SUBTYPE_USER_DEFINED = 128;
684
+ static VECTOR_TYPE = Object.freeze({
685
+ Int8: 0x03,
686
+ Float32: 0x27,
687
+ PackedBit: 0x10
688
+ });
689
+ buffer;
690
+ sub_type;
691
+ position;
692
+ constructor(buffer, subType) {
693
+ super();
694
+ if (!(buffer == null) &&
695
+ typeof buffer === 'string' &&
696
+ !ArrayBuffer.isView(buffer) &&
697
+ !isAnyArrayBuffer(buffer) &&
698
+ !Array.isArray(buffer)) {
699
+ throw new BSONError('Binary can only be constructed from Uint8Array or number[]');
700
+ }
701
+ this.sub_type = subType ?? Binary.BSON_BINARY_SUBTYPE_DEFAULT;
702
+ if (buffer == null) {
703
+ this.buffer = ByteUtils.allocate(Binary.BUFFER_SIZE);
704
+ this.position = 0;
705
+ }
706
+ else {
707
+ this.buffer = Array.isArray(buffer)
708
+ ? ByteUtils.fromNumberArray(buffer)
709
+ : ByteUtils.toLocalBufferType(buffer);
710
+ this.position = this.buffer.byteLength;
711
+ }
712
+ }
713
+ put(byteValue) {
714
+ if (typeof byteValue === 'string' && byteValue.length !== 1) {
715
+ throw new BSONError('only accepts single character String');
716
+ }
717
+ else if (typeof byteValue !== 'number' && byteValue.length !== 1)
718
+ throw new BSONError('only accepts single character Uint8Array or Array');
719
+ let decodedByte;
720
+ if (typeof byteValue === 'string') {
721
+ decodedByte = byteValue.charCodeAt(0);
722
+ }
723
+ else if (typeof byteValue === 'number') {
724
+ decodedByte = byteValue;
725
+ }
726
+ else {
727
+ decodedByte = byteValue[0];
728
+ }
729
+ if (decodedByte < 0 || decodedByte > 255) {
730
+ throw new BSONError('only accepts number in a valid unsigned byte range 0-255');
731
+ }
732
+ if (this.buffer.byteLength > this.position) {
733
+ this.buffer[this.position++] = decodedByte;
734
+ }
735
+ else {
736
+ const newSpace = ByteUtils.allocate(Binary.BUFFER_SIZE + this.buffer.length);
737
+ newSpace.set(this.buffer, 0);
738
+ this.buffer = newSpace;
739
+ this.buffer[this.position++] = decodedByte;
740
+ }
741
+ }
742
+ write(sequence, offset) {
743
+ offset = typeof offset === 'number' ? offset : this.position;
744
+ if (this.buffer.byteLength < offset + sequence.length) {
745
+ const newSpace = ByteUtils.allocate(this.buffer.byteLength + sequence.length);
746
+ newSpace.set(this.buffer, 0);
747
+ this.buffer = newSpace;
748
+ }
749
+ if (ArrayBuffer.isView(sequence)) {
750
+ this.buffer.set(ByteUtils.toLocalBufferType(sequence), offset);
751
+ this.position =
752
+ offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
753
+ }
754
+ else if (typeof sequence === 'string') {
755
+ throw new BSONError('input cannot be string');
756
+ }
757
+ }
758
+ read(position, length) {
759
+ length = length && length > 0 ? length : this.position;
760
+ const end = position + length;
761
+ return this.buffer.subarray(position, end > this.position ? this.position : end);
762
+ }
763
+ value() {
764
+ return this.buffer.length === this.position
765
+ ? this.buffer
766
+ : this.buffer.subarray(0, this.position);
767
+ }
768
+ length() {
769
+ return this.position;
770
+ }
771
+ toJSON() {
772
+ return ByteUtils.toBase64(this.buffer.subarray(0, this.position));
773
+ }
774
+ toString(encoding) {
775
+ if (encoding === 'hex')
776
+ return ByteUtils.toHex(this.buffer.subarray(0, this.position));
777
+ if (encoding === 'base64')
778
+ return ByteUtils.toBase64(this.buffer.subarray(0, this.position));
779
+ if (encoding === 'utf8' || encoding === 'utf-8')
780
+ return ByteUtils.toUTF8(this.buffer, 0, this.position, false);
781
+ return ByteUtils.toUTF8(this.buffer, 0, this.position, false);
782
+ }
783
+ toExtendedJSON(options) {
784
+ options = options || {};
785
+ if (this.sub_type === Binary.SUBTYPE_VECTOR) {
786
+ validateBinaryVector(this);
787
+ }
788
+ const base64String = ByteUtils.toBase64(this.buffer);
789
+ const subType = Number(this.sub_type).toString(16);
790
+ if (options.legacy) {
791
+ return {
792
+ $binary: base64String,
793
+ $type: subType.length === 1 ? '0' + subType : subType
794
+ };
795
+ }
796
+ return {
797
+ $binary: {
798
+ base64: base64String,
799
+ subType: subType.length === 1 ? '0' + subType : subType
800
+ }
801
+ };
802
+ }
803
+ toUUID() {
804
+ if (this.sub_type === Binary.SUBTYPE_UUID) {
805
+ return new UUID(this.buffer.subarray(0, this.position));
806
+ }
807
+ throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Binary.SUBTYPE_UUID}" is currently supported.`);
808
+ }
809
+ static createFromHexString(hex, subType) {
810
+ return new Binary(ByteUtils.fromHex(hex), subType);
811
+ }
812
+ static createFromBase64(base64, subType) {
813
+ return new Binary(ByteUtils.fromBase64(base64), subType);
814
+ }
815
+ static fromExtendedJSON(doc, options) {
816
+ options = options || {};
817
+ let data;
818
+ let type;
819
+ if ('$binary' in doc) {
820
+ if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) {
821
+ type = doc.$type ? parseInt(doc.$type, 16) : 0;
822
+ data = ByteUtils.fromBase64(doc.$binary);
823
+ }
824
+ else {
825
+ if (typeof doc.$binary !== 'string') {
826
+ type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0;
827
+ data = ByteUtils.fromBase64(doc.$binary.base64);
828
+ }
829
+ }
830
+ }
831
+ else if ('$uuid' in doc) {
832
+ type = 4;
833
+ data = UUID.bytesFromString(doc.$uuid);
834
+ }
835
+ if (!data) {
836
+ throw new BSONError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`);
837
+ }
838
+ return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type);
839
+ }
840
+ inspect(depth, options, inspect) {
841
+ inspect ??= defaultInspect;
842
+ const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position));
843
+ const base64Arg = inspect(base64, options);
844
+ const subTypeArg = inspect(this.sub_type, options);
845
+ return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`;
846
+ }
847
+ toInt8Array() {
848
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
849
+ throw new BSONError('Binary sub_type is not Vector');
850
+ }
851
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.Int8) {
852
+ throw new BSONError('Binary datatype field is not Int8');
853
+ }
854
+ validateBinaryVector(this);
855
+ return new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
856
+ }
857
+ toFloat32Array() {
858
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
859
+ throw new BSONError('Binary sub_type is not Vector');
860
+ }
861
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.Float32) {
862
+ throw new BSONError('Binary datatype field is not Float32');
863
+ }
864
+ validateBinaryVector(this);
865
+ const floatBytes = new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
866
+ if (NumberUtils.isBigEndian)
867
+ ByteUtils.swap32(floatBytes);
868
+ return new Float32Array(floatBytes.buffer);
869
+ }
870
+ toPackedBits() {
871
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
872
+ throw new BSONError('Binary sub_type is not Vector');
873
+ }
874
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
875
+ throw new BSONError('Binary datatype field is not packed bit');
876
+ }
877
+ validateBinaryVector(this);
878
+ return new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
879
+ }
880
+ toBits() {
881
+ if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
882
+ throw new BSONError('Binary sub_type is not Vector');
883
+ }
884
+ if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
885
+ throw new BSONError('Binary datatype field is not packed bit');
886
+ }
887
+ validateBinaryVector(this);
888
+ const byteCount = this.length() - 2;
889
+ const bitCount = byteCount * 8 - this.buffer[1];
890
+ const bits = new Int8Array(bitCount);
891
+ for (let bitOffset = 0; bitOffset < bits.length; bitOffset++) {
892
+ const byteOffset = (bitOffset / 8) | 0;
893
+ const byte = this.buffer[byteOffset + 2];
894
+ const shift = 7 - (bitOffset % 8);
895
+ const bit = (byte >> shift) & 1;
896
+ bits[bitOffset] = bit;
897
+ }
898
+ return bits;
899
+ }
900
+ static fromInt8Array(array) {
901
+ const buffer = ByteUtils.allocate(array.byteLength + 2);
902
+ buffer[0] = Binary.VECTOR_TYPE.Int8;
903
+ buffer[1] = 0;
904
+ const intBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
905
+ buffer.set(intBytes, 2);
906
+ const bin = new this(buffer, this.SUBTYPE_VECTOR);
907
+ validateBinaryVector(bin);
908
+ return bin;
909
+ }
910
+ static fromFloat32Array(array) {
911
+ const binaryBytes = ByteUtils.allocate(array.byteLength + 2);
912
+ binaryBytes[0] = Binary.VECTOR_TYPE.Float32;
913
+ binaryBytes[1] = 0;
914
+ const floatBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
915
+ binaryBytes.set(floatBytes, 2);
916
+ if (NumberUtils.isBigEndian)
917
+ ByteUtils.swap32(new Uint8Array(binaryBytes.buffer, 2));
918
+ const bin = new this(binaryBytes, this.SUBTYPE_VECTOR);
919
+ validateBinaryVector(bin);
920
+ return bin;
921
+ }
922
+ static fromPackedBits(array, padding = 0) {
923
+ const buffer = ByteUtils.allocate(array.byteLength + 2);
924
+ buffer[0] = Binary.VECTOR_TYPE.PackedBit;
925
+ buffer[1] = padding;
926
+ buffer.set(array, 2);
927
+ const bin = new this(buffer, this.SUBTYPE_VECTOR);
928
+ validateBinaryVector(bin);
929
+ return bin;
930
+ }
931
+ static fromBits(bits) {
932
+ const byteLength = (bits.length + 7) >>> 3;
933
+ const bytes = new Uint8Array(byteLength + 2);
934
+ bytes[0] = Binary.VECTOR_TYPE.PackedBit;
935
+ const remainder = bits.length % 8;
936
+ bytes[1] = remainder === 0 ? 0 : 8 - remainder;
937
+ for (let bitOffset = 0; bitOffset < bits.length; bitOffset++) {
938
+ const byteOffset = bitOffset >>> 3;
939
+ const bit = bits[bitOffset];
940
+ if (bit !== 0 && bit !== 1) {
941
+ throw new BSONError(`Invalid bit value at ${bitOffset}: must be 0 or 1, found ${bits[bitOffset]}`);
942
+ }
943
+ if (bit === 0)
944
+ continue;
945
+ const shift = 7 - (bitOffset % 8);
946
+ bytes[byteOffset + 2] |= bit << shift;
947
+ }
948
+ return new this(bytes, Binary.SUBTYPE_VECTOR);
949
+ }
950
+ }
951
+ function validateBinaryVector(vector) {
952
+ if (vector.sub_type !== Binary.SUBTYPE_VECTOR)
953
+ return;
954
+ const size = vector.position;
955
+ const datatype = vector.buffer[0];
956
+ const padding = vector.buffer[1];
957
+ if ((datatype === Binary.VECTOR_TYPE.Float32 || datatype === Binary.VECTOR_TYPE.Int8) &&
958
+ padding !== 0) {
959
+ throw new BSONError('Invalid Vector: padding must be zero for int8 and float32 vectors');
960
+ }
961
+ if (datatype === Binary.VECTOR_TYPE.Float32) {
962
+ if (size !== 0 && size - 2 !== 0 && (size - 2) % 4 !== 0) {
963
+ throw new BSONError('Invalid Vector: Float32 vector must contain a multiple of 4 bytes');
964
+ }
965
+ }
966
+ if (datatype === Binary.VECTOR_TYPE.PackedBit && padding !== 0 && size === 2) {
967
+ throw new BSONError('Invalid Vector: padding must be zero for packed bit vectors that are empty');
968
+ }
969
+ if (datatype === Binary.VECTOR_TYPE.PackedBit && padding > 7) {
970
+ throw new BSONError(`Invalid Vector: padding must be a value between 0 and 7. found: ${padding}`);
971
+ }
972
+ }
973
+ const UUID_BYTE_LENGTH = 16;
974
+ const UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i;
975
+ const UUID_WITH_DASHES = /^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
976
+ class UUID extends Binary {
977
+ constructor(input) {
978
+ let bytes;
979
+ if (input == null) {
980
+ bytes = UUID.generate();
981
+ }
982
+ else if (input instanceof UUID) {
983
+ bytes = ByteUtils.toLocalBufferType(new Uint8Array(input.buffer));
984
+ }
985
+ else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) {
986
+ bytes = ByteUtils.toLocalBufferType(input);
987
+ }
988
+ else if (typeof input === 'string') {
989
+ bytes = UUID.bytesFromString(input);
990
+ }
991
+ else {
992
+ throw new BSONError('Argument passed in UUID constructor must be a UUID, a 16 byte Buffer or a 32/36 character hex string (dashes excluded/included, format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).');
993
+ }
994
+ super(bytes, BSON_BINARY_SUBTYPE_UUID_NEW);
995
+ }
996
+ get id() {
997
+ return this.buffer;
998
+ }
999
+ set id(value) {
1000
+ this.buffer = value;
1001
+ }
1002
+ toHexString(includeDashes = true) {
1003
+ if (includeDashes) {
1004
+ return [
1005
+ ByteUtils.toHex(this.buffer.subarray(0, 4)),
1006
+ ByteUtils.toHex(this.buffer.subarray(4, 6)),
1007
+ ByteUtils.toHex(this.buffer.subarray(6, 8)),
1008
+ ByteUtils.toHex(this.buffer.subarray(8, 10)),
1009
+ ByteUtils.toHex(this.buffer.subarray(10, 16))
1010
+ ].join('-');
1011
+ }
1012
+ return ByteUtils.toHex(this.buffer);
1013
+ }
1014
+ toString(encoding) {
1015
+ if (encoding === 'hex')
1016
+ return ByteUtils.toHex(this.id);
1017
+ if (encoding === 'base64')
1018
+ return ByteUtils.toBase64(this.id);
1019
+ return this.toHexString();
1020
+ }
1021
+ toJSON() {
1022
+ return this.toHexString();
1023
+ }
1024
+ equals(otherId) {
1025
+ if (!otherId) {
1026
+ return false;
1027
+ }
1028
+ if (otherId instanceof UUID) {
1029
+ return ByteUtils.equals(otherId.id, this.id);
1030
+ }
1031
+ try {
1032
+ return ByteUtils.equals(new UUID(otherId).id, this.id);
1033
+ }
1034
+ catch {
1035
+ return false;
1036
+ }
1037
+ }
1038
+ toBinary() {
1039
+ return new Binary(this.id, Binary.SUBTYPE_UUID);
1040
+ }
1041
+ static generate() {
1042
+ const bytes = ByteUtils.randomBytes(UUID_BYTE_LENGTH);
1043
+ bytes[6] = (bytes[6] & 0x0f) | 0x40;
1044
+ bytes[8] = (bytes[8] & 0x3f) | 0x80;
1045
+ return bytes;
1046
+ }
1047
+ static isValid(input) {
1048
+ if (!input) {
1049
+ return false;
1050
+ }
1051
+ if (typeof input === 'string') {
1052
+ return UUID.isValidUUIDString(input);
1053
+ }
1054
+ if (isUint8Array(input)) {
1055
+ return input.byteLength === UUID_BYTE_LENGTH;
1056
+ }
1057
+ return (input._bsontype === 'Binary' &&
1058
+ input.sub_type === this.SUBTYPE_UUID &&
1059
+ input.buffer.byteLength === 16);
1060
+ }
1061
+ static createFromHexString(hexString) {
1062
+ const buffer = UUID.bytesFromString(hexString);
1063
+ return new UUID(buffer);
1064
+ }
1065
+ static createFromBase64(base64) {
1066
+ return new UUID(ByteUtils.fromBase64(base64));
1067
+ }
1068
+ static bytesFromString(representation) {
1069
+ if (!UUID.isValidUUIDString(representation)) {
1070
+ throw new BSONError('UUID string representation must be 32 hex digits or canonical hyphenated representation');
1071
+ }
1072
+ return ByteUtils.fromHex(representation.replace(/-/g, ''));
1073
+ }
1074
+ static isValidUUIDString(representation) {
1075
+ return UUID_WITHOUT_DASHES.test(representation) || UUID_WITH_DASHES.test(representation);
1076
+ }
1077
+ inspect(depth, options, inspect) {
1078
+ inspect ??= defaultInspect;
1079
+ return `new UUID(${inspect(this.toHexString(), options)})`;
1080
+ }
1081
+ }
1082
+
1083
+ class Code extends BSONValue {
1084
+ get _bsontype() {
1085
+ return 'Code';
1086
+ }
1087
+ code;
1088
+ scope;
1089
+ constructor(code, scope) {
1090
+ super();
1091
+ this.code = code.toString();
1092
+ this.scope = scope ?? null;
1093
+ }
1094
+ toJSON() {
1095
+ if (this.scope != null) {
1096
+ return { code: this.code, scope: this.scope };
1097
+ }
1098
+ return { code: this.code };
1099
+ }
1100
+ toExtendedJSON() {
1101
+ if (this.scope) {
1102
+ return { $code: this.code, $scope: this.scope };
1103
+ }
1104
+ return { $code: this.code };
1105
+ }
1106
+ static fromExtendedJSON(doc) {
1107
+ return new Code(doc.$code, doc.$scope);
1108
+ }
1109
+ inspect(depth, options, inspect) {
1110
+ inspect ??= defaultInspect;
1111
+ let parametersString = inspect(this.code, options);
1112
+ const multiLineFn = parametersString.includes('\n');
1113
+ if (this.scope != null) {
1114
+ parametersString += `,${multiLineFn ? '\n' : ' '}${inspect(this.scope, options)}`;
1115
+ }
1116
+ const endingNewline = multiLineFn && this.scope === null;
1117
+ return `new Code(${multiLineFn ? '\n' : ''}${parametersString}${endingNewline ? '\n' : ''})`;
1118
+ }
1119
+ }
1120
+
1121
+ function isDBRefLike(value) {
1122
+ return (value != null &&
1123
+ typeof value === 'object' &&
1124
+ '$id' in value &&
1125
+ value.$id != null &&
1126
+ '$ref' in value &&
1127
+ typeof value.$ref === 'string' &&
1128
+ (!('$db' in value) || ('$db' in value && typeof value.$db === 'string')));
1129
+ }
1130
+ class DBRef extends BSONValue {
1131
+ get _bsontype() {
1132
+ return 'DBRef';
1133
+ }
1134
+ collection;
1135
+ oid;
1136
+ db;
1137
+ fields;
1138
+ constructor(collection, oid, db, fields) {
1139
+ super();
1140
+ const parts = collection.split('.');
1141
+ if (parts.length === 2) {
1142
+ db = parts.shift();
1143
+ collection = parts.shift();
1144
+ }
1145
+ this.collection = collection;
1146
+ this.oid = oid;
1147
+ this.db = db;
1148
+ this.fields = fields || {};
1149
+ }
1150
+ get namespace() {
1151
+ return this.collection;
1152
+ }
1153
+ set namespace(value) {
1154
+ this.collection = value;
1155
+ }
1156
+ toJSON() {
1157
+ const o = Object.assign({
1158
+ $ref: this.collection,
1159
+ $id: this.oid
1160
+ }, this.fields);
1161
+ if (this.db != null)
1162
+ o.$db = this.db;
1163
+ return o;
1164
+ }
1165
+ toExtendedJSON(options) {
1166
+ options = options || {};
1167
+ let o = {
1168
+ $ref: this.collection,
1169
+ $id: this.oid
1170
+ };
1171
+ if (options.legacy) {
1172
+ return o;
1173
+ }
1174
+ if (this.db)
1175
+ o.$db = this.db;
1176
+ o = Object.assign(o, this.fields);
1177
+ return o;
1178
+ }
1179
+ static fromExtendedJSON(doc) {
1180
+ const copy = Object.assign({}, doc);
1181
+ delete copy.$ref;
1182
+ delete copy.$id;
1183
+ delete copy.$db;
1184
+ return new DBRef(doc.$ref, doc.$id, doc.$db, copy);
1185
+ }
1186
+ inspect(depth, options, inspect) {
1187
+ inspect ??= defaultInspect;
1188
+ const args = [
1189
+ inspect(this.namespace, options),
1190
+ inspect(this.oid, options),
1191
+ ...(this.db ? [inspect(this.db, options)] : []),
1192
+ ...(Object.keys(this.fields).length > 0 ? [inspect(this.fields, options)] : [])
1193
+ ];
1194
+ args[1] = inspect === defaultInspect ? `new ObjectId(${args[1]})` : args[1];
1195
+ return `new DBRef(${args.join(', ')})`;
1196
+ }
1197
+ }
1198
+
1199
+ function removeLeadingZerosAndExplicitPlus(str) {
1200
+ if (str === '') {
1201
+ return str;
1202
+ }
1203
+ let startIndex = 0;
1204
+ const isNegative = str[startIndex] === '-';
1205
+ const isExplicitlyPositive = str[startIndex] === '+';
1206
+ if (isExplicitlyPositive || isNegative) {
1207
+ startIndex += 1;
1208
+ }
1209
+ let foundInsignificantZero = false;
1210
+ for (; startIndex < str.length && str[startIndex] === '0'; ++startIndex) {
1211
+ foundInsignificantZero = true;
1212
+ }
1213
+ if (!foundInsignificantZero) {
1214
+ return isExplicitlyPositive ? str.slice(1) : str;
1215
+ }
1216
+ return `${isNegative ? '-' : ''}${str.length === startIndex ? '0' : str.slice(startIndex)}`;
1217
+ }
1218
+ function validateStringCharacters(str, radix) {
1219
+ radix = radix ?? 10;
1220
+ const validCharacters = '0123456789abcdefghijklmnopqrstuvwxyz'.slice(0, radix);
1221
+ const regex = new RegExp(`[^-+${validCharacters}]`, 'i');
1222
+ return regex.test(str) ? false : str;
1223
+ }
1224
+
1225
+ let wasm = undefined;
1226
+ try {
1227
+ wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11])), {}).exports;
1228
+ }
1229
+ catch {
1230
+ }
1231
+ const TWO_PWR_16_DBL = 1 << 16;
1232
+ const TWO_PWR_24_DBL = 1 << 24;
1233
+ const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
1234
+ const TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
1235
+ const TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
1236
+ const INT_CACHE = {};
1237
+ const UINT_CACHE = {};
1238
+ const MAX_INT64_STRING_LENGTH = 20;
1239
+ const DECIMAL_REG_EX = /^(\+?0|(\+|-)?[1-9][0-9]*)$/;
1240
+ class Long extends BSONValue {
1241
+ get _bsontype() {
1242
+ return 'Long';
1243
+ }
1244
+ get __isLong__() {
1245
+ return true;
1246
+ }
1247
+ high;
1248
+ low;
1249
+ unsigned;
1250
+ constructor(lowOrValue = 0, highOrUnsigned, unsigned) {
1251
+ super();
1252
+ const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned);
1253
+ const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0;
1254
+ const res = typeof lowOrValue === 'string'
1255
+ ? Long.fromString(lowOrValue, unsignedBool)
1256
+ : typeof lowOrValue === 'bigint'
1257
+ ? Long.fromBigInt(lowOrValue, unsignedBool)
1258
+ : { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool };
1259
+ this.low = res.low;
1260
+ this.high = res.high;
1261
+ this.unsigned = res.unsigned;
1262
+ }
1263
+ static TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL);
1264
+ static MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true);
1265
+ static ZERO = Long.fromInt(0);
1266
+ static UZERO = Long.fromInt(0, true);
1267
+ static ONE = Long.fromInt(1);
1268
+ static UONE = Long.fromInt(1, true);
1269
+ static NEG_ONE = Long.fromInt(-1);
1270
+ static MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false);
1271
+ static MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
1272
+ static fromBits(lowBits, highBits, unsigned) {
1273
+ return new Long(lowBits, highBits, unsigned);
1274
+ }
1275
+ static fromInt(value, unsigned) {
1276
+ let obj, cachedObj, cache;
1277
+ if (unsigned) {
1278
+ value >>>= 0;
1279
+ if ((cache = 0 <= value && value < 256)) {
1280
+ cachedObj = UINT_CACHE[value];
1281
+ if (cachedObj)
1282
+ return cachedObj;
1283
+ }
1284
+ obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true);
1285
+ if (cache)
1286
+ UINT_CACHE[value] = obj;
1287
+ return obj;
1288
+ }
1289
+ else {
1290
+ value |= 0;
1291
+ if ((cache = -128 <= value && value < 128)) {
1292
+ cachedObj = INT_CACHE[value];
1293
+ if (cachedObj)
1294
+ return cachedObj;
1295
+ }
1296
+ obj = Long.fromBits(value, value < 0 ? -1 : 0, false);
1297
+ if (cache)
1298
+ INT_CACHE[value] = obj;
1299
+ return obj;
1300
+ }
1301
+ }
1302
+ static fromNumber(value, unsigned) {
1303
+ if (isNaN(value))
1304
+ return unsigned ? Long.UZERO : Long.ZERO;
1305
+ if (unsigned) {
1306
+ if (value < 0)
1307
+ return Long.UZERO;
1308
+ if (value >= TWO_PWR_64_DBL)
1309
+ return Long.MAX_UNSIGNED_VALUE;
1310
+ }
1311
+ else {
1312
+ if (value <= -TWO_PWR_63_DBL)
1313
+ return Long.MIN_VALUE;
1314
+ if (value + 1 >= TWO_PWR_63_DBL)
1315
+ return Long.MAX_VALUE;
1316
+ }
1317
+ if (value < 0)
1318
+ return Long.fromNumber(-value, unsigned).neg();
1319
+ return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
1320
+ }
1321
+ static fromBigInt(value, unsigned) {
1322
+ const FROM_BIGINT_BIT_MASK = 0xffffffffn;
1323
+ const FROM_BIGINT_BIT_SHIFT = 32n;
1324
+ return new Long(Number(value & FROM_BIGINT_BIT_MASK), Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), unsigned);
1325
+ }
1326
+ static _fromString(str, unsigned, radix) {
1327
+ if (str.length === 0)
1328
+ throw new BSONError('empty string');
1329
+ if (radix < 2 || 36 < radix)
1330
+ throw new BSONError('radix');
1331
+ let p;
1332
+ if ((p = str.indexOf('-')) > 0)
1333
+ throw new BSONError('interior hyphen');
1334
+ else if (p === 0) {
1335
+ return Long._fromString(str.substring(1), unsigned, radix).neg();
1336
+ }
1337
+ const radixToPower = Long.fromNumber(Math.pow(radix, 8));
1338
+ let result = Long.ZERO;
1339
+ for (let i = 0; i < str.length; i += 8) {
1340
+ const size = Math.min(8, str.length - i), value = parseInt(str.substring(i, i + size), radix);
1341
+ if (size < 8) {
1342
+ const power = Long.fromNumber(Math.pow(radix, size));
1343
+ result = result.mul(power).add(Long.fromNumber(value));
1344
+ }
1345
+ else {
1346
+ result = result.mul(radixToPower);
1347
+ result = result.add(Long.fromNumber(value));
1348
+ }
1349
+ }
1350
+ result.unsigned = unsigned;
1351
+ return result;
1352
+ }
1353
+ static fromStringStrict(str, unsignedOrRadix, radix) {
1354
+ let unsigned = false;
1355
+ if (typeof unsignedOrRadix === 'number') {
1356
+ ((radix = unsignedOrRadix), (unsignedOrRadix = false));
1357
+ }
1358
+ else {
1359
+ unsigned = !!unsignedOrRadix;
1360
+ }
1361
+ radix ??= 10;
1362
+ if (str.trim() !== str) {
1363
+ throw new BSONError(`Input: '${str}' contains leading and/or trailing whitespace`);
1364
+ }
1365
+ if (!validateStringCharacters(str, radix)) {
1366
+ throw new BSONError(`Input: '${str}' contains invalid characters for radix: ${radix}`);
1367
+ }
1368
+ const cleanedStr = removeLeadingZerosAndExplicitPlus(str);
1369
+ const result = Long._fromString(cleanedStr, unsigned, radix);
1370
+ if (result.toString(radix).toLowerCase() !== cleanedStr.toLowerCase()) {
1371
+ throw new BSONError(`Input: ${str} is not representable as ${result.unsigned ? 'an unsigned' : 'a signed'} 64-bit Long ${radix != null ? `with radix: ${radix}` : ''}`);
1372
+ }
1373
+ return result;
1374
+ }
1375
+ static fromString(str, unsignedOrRadix, radix) {
1376
+ let unsigned = false;
1377
+ if (typeof unsignedOrRadix === 'number') {
1378
+ ((radix = unsignedOrRadix), (unsignedOrRadix = false));
1379
+ }
1380
+ else {
1381
+ unsigned = !!unsignedOrRadix;
1382
+ }
1383
+ radix ??= 10;
1384
+ if (str === 'NaN' && radix < 24) {
1385
+ return Long.ZERO;
1386
+ }
1387
+ else if ((str === 'Infinity' || str === '+Infinity' || str === '-Infinity') && radix < 35) {
1388
+ return Long.ZERO;
1389
+ }
1390
+ return Long._fromString(str, unsigned, radix);
1391
+ }
1392
+ static fromBytes(bytes, unsigned, le) {
1393
+ return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
1394
+ }
1395
+ static fromBytesLE(bytes, unsigned) {
1396
+ return new Long(bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24), bytes[4] | (bytes[5] << 8) | (bytes[6] << 16) | (bytes[7] << 24), unsigned);
1397
+ }
1398
+ static fromBytesBE(bytes, unsigned) {
1399
+ return new Long((bytes[4] << 24) | (bytes[5] << 16) | (bytes[6] << 8) | bytes[7], (bytes[0] << 24) | (bytes[1] << 16) | (bytes[2] << 8) | bytes[3], unsigned);
1400
+ }
1401
+ static isLong(value) {
1402
+ return (value != null &&
1403
+ typeof value === 'object' &&
1404
+ '__isLong__' in value &&
1405
+ value.__isLong__ === true);
1406
+ }
1407
+ static fromValue(val, unsigned) {
1408
+ if (typeof val === 'number')
1409
+ return Long.fromNumber(val, unsigned);
1410
+ if (typeof val === 'string')
1411
+ return Long.fromString(val, unsigned);
1412
+ return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);
1413
+ }
1414
+ add(addend) {
1415
+ if (!Long.isLong(addend))
1416
+ addend = Long.fromValue(addend);
1417
+ const a48 = this.high >>> 16;
1418
+ const a32 = this.high & 0xffff;
1419
+ const a16 = this.low >>> 16;
1420
+ const a00 = this.low & 0xffff;
1421
+ const b48 = addend.high >>> 16;
1422
+ const b32 = addend.high & 0xffff;
1423
+ const b16 = addend.low >>> 16;
1424
+ const b00 = addend.low & 0xffff;
1425
+ let c48 = 0, c32 = 0, c16 = 0, c00 = 0;
1426
+ c00 += a00 + b00;
1427
+ c16 += c00 >>> 16;
1428
+ c00 &= 0xffff;
1429
+ c16 += a16 + b16;
1430
+ c32 += c16 >>> 16;
1431
+ c16 &= 0xffff;
1432
+ c32 += a32 + b32;
1433
+ c48 += c32 >>> 16;
1434
+ c32 &= 0xffff;
1435
+ c48 += a48 + b48;
1436
+ c48 &= 0xffff;
1437
+ return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
1438
+ }
1439
+ and(other) {
1440
+ if (!Long.isLong(other))
1441
+ other = Long.fromValue(other);
1442
+ return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);
1443
+ }
1444
+ compare(other) {
1445
+ if (!Long.isLong(other))
1446
+ other = Long.fromValue(other);
1447
+ if (this.eq(other))
1448
+ return 0;
1449
+ const thisNeg = this.isNegative(), otherNeg = other.isNegative();
1450
+ if (thisNeg && !otherNeg)
1451
+ return -1;
1452
+ if (!thisNeg && otherNeg)
1453
+ return 1;
1454
+ if (!this.unsigned)
1455
+ return this.sub(other).isNegative() ? -1 : 1;
1456
+ return other.high >>> 0 > this.high >>> 0 ||
1457
+ (other.high === this.high && other.low >>> 0 > this.low >>> 0)
1458
+ ? -1
1459
+ : 1;
1460
+ }
1461
+ comp(other) {
1462
+ return this.compare(other);
1463
+ }
1464
+ divide(divisor) {
1465
+ if (!Long.isLong(divisor))
1466
+ divisor = Long.fromValue(divisor);
1467
+ if (divisor.isZero())
1468
+ throw new BSONError('division by zero');
1469
+ if (wasm) {
1470
+ if (!this.unsigned &&
1471
+ this.high === -2147483648 &&
1472
+ divisor.low === -1 &&
1473
+ divisor.high === -1) {
1474
+ return this;
1475
+ }
1476
+ const low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high);
1477
+ return Long.fromBits(low, wasm.get_high(), this.unsigned);
1478
+ }
1479
+ if (this.isZero())
1480
+ return this.unsigned ? Long.UZERO : Long.ZERO;
1481
+ let approx, rem, res;
1482
+ if (!this.unsigned) {
1483
+ if (this.eq(Long.MIN_VALUE)) {
1484
+ if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE))
1485
+ return Long.MIN_VALUE;
1486
+ else if (divisor.eq(Long.MIN_VALUE))
1487
+ return Long.ONE;
1488
+ else {
1489
+ const halfThis = this.shr(1);
1490
+ approx = halfThis.div(divisor).shl(1);
1491
+ if (approx.eq(Long.ZERO)) {
1492
+ return divisor.isNegative() ? Long.ONE : Long.NEG_ONE;
1493
+ }
1494
+ else {
1495
+ rem = this.sub(divisor.mul(approx));
1496
+ res = approx.add(rem.div(divisor));
1497
+ return res;
1498
+ }
1499
+ }
1500
+ }
1501
+ else if (divisor.eq(Long.MIN_VALUE))
1502
+ return this.unsigned ? Long.UZERO : Long.ZERO;
1503
+ if (this.isNegative()) {
1504
+ if (divisor.isNegative())
1505
+ return this.neg().div(divisor.neg());
1506
+ return this.neg().div(divisor).neg();
1507
+ }
1508
+ else if (divisor.isNegative())
1509
+ return this.div(divisor.neg()).neg();
1510
+ res = Long.ZERO;
1511
+ }
1512
+ else {
1513
+ if (!divisor.unsigned)
1514
+ divisor = divisor.toUnsigned();
1515
+ if (divisor.gt(this))
1516
+ return Long.UZERO;
1517
+ if (divisor.gt(this.shru(1)))
1518
+ return Long.UONE;
1519
+ res = Long.UZERO;
1520
+ }
1521
+ rem = this;
1522
+ while (rem.gte(divisor)) {
1523
+ approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
1524
+ const log2 = Math.ceil(Math.log(approx) / Math.LN2);
1525
+ const delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48);
1526
+ let approxRes = Long.fromNumber(approx);
1527
+ let approxRem = approxRes.mul(divisor);
1528
+ while (approxRem.isNegative() || approxRem.gt(rem)) {
1529
+ approx -= delta;
1530
+ approxRes = Long.fromNumber(approx, this.unsigned);
1531
+ approxRem = approxRes.mul(divisor);
1532
+ }
1533
+ if (approxRes.isZero())
1534
+ approxRes = Long.ONE;
1535
+ res = res.add(approxRes);
1536
+ rem = rem.sub(approxRem);
1537
+ }
1538
+ return res;
1539
+ }
1540
+ div(divisor) {
1541
+ return this.divide(divisor);
1542
+ }
1543
+ equals(other) {
1544
+ if (!Long.isLong(other))
1545
+ other = Long.fromValue(other);
1546
+ if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
1547
+ return false;
1548
+ return this.high === other.high && this.low === other.low;
1549
+ }
1550
+ eq(other) {
1551
+ return this.equals(other);
1552
+ }
1553
+ getHighBits() {
1554
+ return this.high;
1555
+ }
1556
+ getHighBitsUnsigned() {
1557
+ return this.high >>> 0;
1558
+ }
1559
+ getLowBits() {
1560
+ return this.low;
1561
+ }
1562
+ getLowBitsUnsigned() {
1563
+ return this.low >>> 0;
1564
+ }
1565
+ getNumBitsAbs() {
1566
+ if (this.isNegative()) {
1567
+ return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
1568
+ }
1569
+ const val = this.high !== 0 ? this.high : this.low;
1570
+ let bit;
1571
+ for (bit = 31; bit > 0; bit--)
1572
+ if ((val & (1 << bit)) !== 0)
1573
+ break;
1574
+ return this.high !== 0 ? bit + 33 : bit + 1;
1575
+ }
1576
+ greaterThan(other) {
1577
+ return this.comp(other) > 0;
1578
+ }
1579
+ gt(other) {
1580
+ return this.greaterThan(other);
1581
+ }
1582
+ greaterThanOrEqual(other) {
1583
+ return this.comp(other) >= 0;
1584
+ }
1585
+ gte(other) {
1586
+ return this.greaterThanOrEqual(other);
1587
+ }
1588
+ ge(other) {
1589
+ return this.greaterThanOrEqual(other);
1590
+ }
1591
+ isEven() {
1592
+ return (this.low & 1) === 0;
1593
+ }
1594
+ isNegative() {
1595
+ return !this.unsigned && this.high < 0;
1596
+ }
1597
+ isOdd() {
1598
+ return (this.low & 1) === 1;
1599
+ }
1600
+ isPositive() {
1601
+ return this.unsigned || this.high >= 0;
1602
+ }
1603
+ isZero() {
1604
+ return this.high === 0 && this.low === 0;
1605
+ }
1606
+ lessThan(other) {
1607
+ return this.comp(other) < 0;
1608
+ }
1609
+ lt(other) {
1610
+ return this.lessThan(other);
1611
+ }
1612
+ lessThanOrEqual(other) {
1613
+ return this.comp(other) <= 0;
1614
+ }
1615
+ lte(other) {
1616
+ return this.lessThanOrEqual(other);
1617
+ }
1618
+ modulo(divisor) {
1619
+ if (!Long.isLong(divisor))
1620
+ divisor = Long.fromValue(divisor);
1621
+ if (wasm) {
1622
+ const low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high);
1623
+ return Long.fromBits(low, wasm.get_high(), this.unsigned);
1624
+ }
1625
+ return this.sub(this.div(divisor).mul(divisor));
1626
+ }
1627
+ mod(divisor) {
1628
+ return this.modulo(divisor);
1629
+ }
1630
+ rem(divisor) {
1631
+ return this.modulo(divisor);
1632
+ }
1633
+ multiply(multiplier) {
1634
+ if (this.isZero())
1635
+ return Long.ZERO;
1636
+ if (!Long.isLong(multiplier))
1637
+ multiplier = Long.fromValue(multiplier);
1638
+ if (wasm) {
1639
+ const low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high);
1640
+ return Long.fromBits(low, wasm.get_high(), this.unsigned);
1641
+ }
1642
+ if (multiplier.isZero())
1643
+ return Long.ZERO;
1644
+ if (this.eq(Long.MIN_VALUE))
1645
+ return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO;
1646
+ if (multiplier.eq(Long.MIN_VALUE))
1647
+ return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
1648
+ if (this.isNegative()) {
1649
+ if (multiplier.isNegative())
1650
+ return this.neg().mul(multiplier.neg());
1651
+ else
1652
+ return this.neg().mul(multiplier).neg();
1653
+ }
1654
+ else if (multiplier.isNegative())
1655
+ return this.mul(multiplier.neg()).neg();
1656
+ if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24))
1657
+ return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
1658
+ const a48 = this.high >>> 16;
1659
+ const a32 = this.high & 0xffff;
1660
+ const a16 = this.low >>> 16;
1661
+ const a00 = this.low & 0xffff;
1662
+ const b48 = multiplier.high >>> 16;
1663
+ const b32 = multiplier.high & 0xffff;
1664
+ const b16 = multiplier.low >>> 16;
1665
+ const b00 = multiplier.low & 0xffff;
1666
+ let c48 = 0, c32 = 0, c16 = 0, c00 = 0;
1667
+ c00 += a00 * b00;
1668
+ c16 += c00 >>> 16;
1669
+ c00 &= 0xffff;
1670
+ c16 += a16 * b00;
1671
+ c32 += c16 >>> 16;
1672
+ c16 &= 0xffff;
1673
+ c16 += a00 * b16;
1674
+ c32 += c16 >>> 16;
1675
+ c16 &= 0xffff;
1676
+ c32 += a32 * b00;
1677
+ c48 += c32 >>> 16;
1678
+ c32 &= 0xffff;
1679
+ c32 += a16 * b16;
1680
+ c48 += c32 >>> 16;
1681
+ c32 &= 0xffff;
1682
+ c32 += a00 * b32;
1683
+ c48 += c32 >>> 16;
1684
+ c32 &= 0xffff;
1685
+ c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
1686
+ c48 &= 0xffff;
1687
+ return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
1688
+ }
1689
+ mul(multiplier) {
1690
+ return this.multiply(multiplier);
1691
+ }
1692
+ negate() {
1693
+ if (!this.unsigned && this.eq(Long.MIN_VALUE))
1694
+ return Long.MIN_VALUE;
1695
+ return this.not().add(Long.ONE);
1696
+ }
1697
+ neg() {
1698
+ return this.negate();
1699
+ }
1700
+ not() {
1701
+ return Long.fromBits(~this.low, ~this.high, this.unsigned);
1702
+ }
1703
+ notEquals(other) {
1704
+ return !this.equals(other);
1705
+ }
1706
+ neq(other) {
1707
+ return this.notEquals(other);
1708
+ }
1709
+ ne(other) {
1710
+ return this.notEquals(other);
1711
+ }
1712
+ or(other) {
1713
+ if (!Long.isLong(other))
1714
+ other = Long.fromValue(other);
1715
+ return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);
1716
+ }
1717
+ shiftLeft(numBits) {
1718
+ if (Long.isLong(numBits))
1719
+ numBits = numBits.toInt();
1720
+ if ((numBits &= 63) === 0)
1721
+ return this;
1722
+ else if (numBits < 32)
1723
+ return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
1724
+ else
1725
+ return Long.fromBits(0, this.low << (numBits - 32), this.unsigned);
1726
+ }
1727
+ shl(numBits) {
1728
+ return this.shiftLeft(numBits);
1729
+ }
1730
+ shiftRight(numBits) {
1731
+ if (Long.isLong(numBits))
1732
+ numBits = numBits.toInt();
1733
+ if ((numBits &= 63) === 0)
1734
+ return this;
1735
+ else if (numBits < 32)
1736
+ return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
1737
+ else
1738
+ return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
1739
+ }
1740
+ shr(numBits) {
1741
+ return this.shiftRight(numBits);
1742
+ }
1743
+ shiftRightUnsigned(numBits) {
1744
+ if (Long.isLong(numBits))
1745
+ numBits = numBits.toInt();
1746
+ numBits &= 63;
1747
+ if (numBits === 0)
1748
+ return this;
1749
+ else {
1750
+ const high = this.high;
1751
+ if (numBits < 32) {
1752
+ const low = this.low;
1753
+ return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
1754
+ }
1755
+ else if (numBits === 32)
1756
+ return Long.fromBits(high, 0, this.unsigned);
1757
+ else
1758
+ return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned);
1759
+ }
1760
+ }
1761
+ shr_u(numBits) {
1762
+ return this.shiftRightUnsigned(numBits);
1763
+ }
1764
+ shru(numBits) {
1765
+ return this.shiftRightUnsigned(numBits);
1766
+ }
1767
+ subtract(subtrahend) {
1768
+ if (!Long.isLong(subtrahend))
1769
+ subtrahend = Long.fromValue(subtrahend);
1770
+ return this.add(subtrahend.neg());
1771
+ }
1772
+ sub(subtrahend) {
1773
+ return this.subtract(subtrahend);
1774
+ }
1775
+ toInt() {
1776
+ return this.unsigned ? this.low >>> 0 : this.low;
1777
+ }
1778
+ toNumber() {
1779
+ if (this.unsigned)
1780
+ return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
1781
+ return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
1782
+ }
1783
+ toBigInt() {
1784
+ return BigInt(this.toString());
1785
+ }
1786
+ toBytes(le) {
1787
+ return le ? this.toBytesLE() : this.toBytesBE();
1788
+ }
1789
+ toBytesLE() {
1790
+ const hi = this.high, lo = this.low;
1791
+ return [
1792
+ lo & 0xff,
1793
+ (lo >>> 8) & 0xff,
1794
+ (lo >>> 16) & 0xff,
1795
+ lo >>> 24,
1796
+ hi & 0xff,
1797
+ (hi >>> 8) & 0xff,
1798
+ (hi >>> 16) & 0xff,
1799
+ hi >>> 24
1800
+ ];
1801
+ }
1802
+ toBytesBE() {
1803
+ const hi = this.high, lo = this.low;
1804
+ return [
1805
+ hi >>> 24,
1806
+ (hi >>> 16) & 0xff,
1807
+ (hi >>> 8) & 0xff,
1808
+ hi & 0xff,
1809
+ lo >>> 24,
1810
+ (lo >>> 16) & 0xff,
1811
+ (lo >>> 8) & 0xff,
1812
+ lo & 0xff
1813
+ ];
1814
+ }
1815
+ toSigned() {
1816
+ if (!this.unsigned)
1817
+ return this;
1818
+ return Long.fromBits(this.low, this.high, false);
1819
+ }
1820
+ toString(radix) {
1821
+ radix = radix || 10;
1822
+ if (radix < 2 || 36 < radix)
1823
+ throw new BSONError('radix');
1824
+ if (this.isZero())
1825
+ return '0';
1826
+ if (this.isNegative()) {
1827
+ if (this.eq(Long.MIN_VALUE)) {
1828
+ const radixLong = Long.fromNumber(radix), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this);
1829
+ return div.toString(radix) + rem1.toInt().toString(radix);
1830
+ }
1831
+ else
1832
+ return '-' + this.neg().toString(radix);
1833
+ }
1834
+ const radixToPower = Long.fromNumber(Math.pow(radix, 6), this.unsigned);
1835
+ let rem = this;
1836
+ let result = '';
1837
+ while (true) {
1838
+ const remDiv = rem.div(radixToPower);
1839
+ const intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0;
1840
+ let digits = intval.toString(radix);
1841
+ rem = remDiv;
1842
+ if (rem.isZero()) {
1843
+ return digits + result;
1844
+ }
1845
+ else {
1846
+ while (digits.length < 6)
1847
+ digits = '0' + digits;
1848
+ result = '' + digits + result;
1849
+ }
1850
+ }
1851
+ }
1852
+ toUnsigned() {
1853
+ if (this.unsigned)
1854
+ return this;
1855
+ return Long.fromBits(this.low, this.high, true);
1856
+ }
1857
+ xor(other) {
1858
+ if (!Long.isLong(other))
1859
+ other = Long.fromValue(other);
1860
+ return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
1861
+ }
1862
+ eqz() {
1863
+ return this.isZero();
1864
+ }
1865
+ le(other) {
1866
+ return this.lessThanOrEqual(other);
1867
+ }
1868
+ toExtendedJSON(options) {
1869
+ if (options && options.relaxed)
1870
+ return this.toNumber();
1871
+ return { $numberLong: this.toString() };
1872
+ }
1873
+ static fromExtendedJSON(doc, options) {
1874
+ const { useBigInt64 = false, relaxed = true } = { ...options };
1875
+ if (doc.$numberLong.length > MAX_INT64_STRING_LENGTH) {
1876
+ throw new BSONError('$numberLong string is too long');
1877
+ }
1878
+ if (!DECIMAL_REG_EX.test(doc.$numberLong)) {
1879
+ throw new BSONError(`$numberLong string "${doc.$numberLong}" is in an invalid format`);
1880
+ }
1881
+ if (useBigInt64) {
1882
+ const bigIntResult = BigInt(doc.$numberLong);
1883
+ return BigInt.asIntN(64, bigIntResult);
1884
+ }
1885
+ const longResult = Long.fromString(doc.$numberLong);
1886
+ if (relaxed) {
1887
+ return longResult.toNumber();
1888
+ }
1889
+ return longResult;
1890
+ }
1891
+ inspect(depth, options, inspect) {
1892
+ inspect ??= defaultInspect;
1893
+ const longVal = inspect(this.toString(), options);
1894
+ const unsignedVal = this.unsigned ? `, ${inspect(this.unsigned, options)}` : '';
1895
+ return `new Long(${longVal}${unsignedVal})`;
1896
+ }
1897
+ }
1898
+
1899
+ const PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/;
1900
+ const PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i;
1901
+ const PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i;
1902
+ const EXPONENT_MAX = 6111;
1903
+ const EXPONENT_MIN = -6176;
1904
+ const EXPONENT_BIAS = 6176;
1905
+ const MAX_DIGITS = 34;
1906
+ const NAN_BUFFER = ByteUtils.fromNumberArray([
1907
+ 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1908
+ ].reverse());
1909
+ const INF_NEGATIVE_BUFFER = ByteUtils.fromNumberArray([
1910
+ 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1911
+ ].reverse());
1912
+ const INF_POSITIVE_BUFFER = ByteUtils.fromNumberArray([
1913
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1914
+ ].reverse());
1915
+ const EXPONENT_REGEX = /^([-+])?(\d+)?$/;
1916
+ const COMBINATION_MASK = 0x1f;
1917
+ const EXPONENT_MASK = 0x3fff;
1918
+ const COMBINATION_INFINITY = 30;
1919
+ const COMBINATION_NAN = 31;
1920
+ function isDigit(value) {
1921
+ return !isNaN(parseInt(value, 10));
1922
+ }
1923
+ function divideu128(value) {
1924
+ const DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
1925
+ let _rem = Long.fromNumber(0);
1926
+ if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
1927
+ return { quotient: value, rem: _rem };
1928
+ }
1929
+ for (let i = 0; i <= 3; i++) {
1930
+ _rem = _rem.shiftLeft(32);
1931
+ _rem = _rem.add(new Long(value.parts[i], 0));
1932
+ value.parts[i] = _rem.div(DIVISOR).low;
1933
+ _rem = _rem.modulo(DIVISOR);
1934
+ }
1935
+ return { quotient: value, rem: _rem };
1936
+ }
1937
+ function multiply64x2(left, right) {
1938
+ if (!left && !right) {
1939
+ return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
1940
+ }
1941
+ const leftHigh = left.shiftRightUnsigned(32);
1942
+ const leftLow = new Long(left.getLowBits(), 0);
1943
+ const rightHigh = right.shiftRightUnsigned(32);
1944
+ const rightLow = new Long(right.getLowBits(), 0);
1945
+ let productHigh = leftHigh.multiply(rightHigh);
1946
+ let productMid = leftHigh.multiply(rightLow);
1947
+ const productMid2 = leftLow.multiply(rightHigh);
1948
+ let productLow = leftLow.multiply(rightLow);
1949
+ productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
1950
+ productMid = new Long(productMid.getLowBits(), 0)
1951
+ .add(productMid2)
1952
+ .add(productLow.shiftRightUnsigned(32));
1953
+ productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
1954
+ productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0));
1955
+ return { high: productHigh, low: productLow };
1956
+ }
1957
+ function lessThan(left, right) {
1958
+ const uhleft = left.high >>> 0;
1959
+ const uhright = right.high >>> 0;
1960
+ if (uhleft < uhright) {
1961
+ return true;
1962
+ }
1963
+ else if (uhleft === uhright) {
1964
+ const ulleft = left.low >>> 0;
1965
+ const ulright = right.low >>> 0;
1966
+ if (ulleft < ulright)
1967
+ return true;
1968
+ }
1969
+ return false;
1970
+ }
1971
+ function invalidErr(string, message) {
1972
+ throw new BSONError(`"${string}" is not a valid Decimal128 string - ${message}`);
1973
+ }
1974
+ class Decimal128 extends BSONValue {
1975
+ get _bsontype() {
1976
+ return 'Decimal128';
1977
+ }
1978
+ bytes;
1979
+ constructor(bytes) {
1980
+ super();
1981
+ if (typeof bytes === 'string') {
1982
+ this.bytes = Decimal128.fromString(bytes).bytes;
1983
+ }
1984
+ else if (bytes instanceof Uint8Array || isUint8Array(bytes)) {
1985
+ if (bytes.byteLength !== 16) {
1986
+ throw new BSONError('Decimal128 must take a Buffer of 16 bytes');
1987
+ }
1988
+ this.bytes = bytes;
1989
+ }
1990
+ else {
1991
+ throw new BSONError('Decimal128 must take a Buffer or string');
1992
+ }
1993
+ }
1994
+ static fromString(representation) {
1995
+ return Decimal128._fromString(representation, { allowRounding: false });
1996
+ }
1997
+ static fromStringWithRounding(representation) {
1998
+ return Decimal128._fromString(representation, { allowRounding: true });
1999
+ }
2000
+ static _fromString(representation, options) {
2001
+ let isNegative = false;
2002
+ let sawSign = false;
2003
+ let sawRadix = false;
2004
+ let foundNonZero = false;
2005
+ let significantDigits = 0;
2006
+ let nDigitsRead = 0;
2007
+ let nDigits = 0;
2008
+ let radixPosition = 0;
2009
+ let firstNonZero = 0;
2010
+ const digits = [0];
2011
+ let nDigitsStored = 0;
2012
+ let digitsInsert = 0;
2013
+ let lastDigit = 0;
2014
+ let exponent = 0;
2015
+ let significandHigh = new Long(0, 0);
2016
+ let significandLow = new Long(0, 0);
2017
+ let biasedExponent = 0;
2018
+ let index = 0;
2019
+ if (representation.length >= 7000) {
2020
+ throw new BSONError('' + representation + ' not a valid Decimal128 string');
2021
+ }
2022
+ const stringMatch = representation.match(PARSE_STRING_REGEXP);
2023
+ const infMatch = representation.match(PARSE_INF_REGEXP);
2024
+ const nanMatch = representation.match(PARSE_NAN_REGEXP);
2025
+ if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) {
2026
+ throw new BSONError('' + representation + ' not a valid Decimal128 string');
2027
+ }
2028
+ if (stringMatch) {
2029
+ const unsignedNumber = stringMatch[2];
2030
+ const e = stringMatch[4];
2031
+ const expSign = stringMatch[5];
2032
+ const expNumber = stringMatch[6];
2033
+ if (e && expNumber === undefined)
2034
+ invalidErr(representation, 'missing exponent power');
2035
+ if (e && unsignedNumber === undefined)
2036
+ invalidErr(representation, 'missing exponent base');
2037
+ if (e === undefined && (expSign || expNumber)) {
2038
+ invalidErr(representation, 'missing e before exponent');
2039
+ }
2040
+ }
2041
+ if (representation[index] === '+' || representation[index] === '-') {
2042
+ sawSign = true;
2043
+ isNegative = representation[index++] === '-';
2044
+ }
2045
+ if (!isDigit(representation[index]) && representation[index] !== '.') {
2046
+ if (representation[index] === 'i' || representation[index] === 'I') {
2047
+ return new Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER);
2048
+ }
2049
+ else if (representation[index] === 'N') {
2050
+ return new Decimal128(NAN_BUFFER);
2051
+ }
2052
+ }
2053
+ while (isDigit(representation[index]) || representation[index] === '.') {
2054
+ if (representation[index] === '.') {
2055
+ if (sawRadix)
2056
+ invalidErr(representation, 'contains multiple periods');
2057
+ sawRadix = true;
2058
+ index = index + 1;
2059
+ continue;
2060
+ }
2061
+ if (nDigitsStored < MAX_DIGITS) {
2062
+ if (representation[index] !== '0' || foundNonZero) {
2063
+ if (!foundNonZero) {
2064
+ firstNonZero = nDigitsRead;
2065
+ }
2066
+ foundNonZero = true;
2067
+ digits[digitsInsert++] = parseInt(representation[index], 10);
2068
+ nDigitsStored = nDigitsStored + 1;
2069
+ }
2070
+ }
2071
+ if (foundNonZero)
2072
+ nDigits = nDigits + 1;
2073
+ if (sawRadix)
2074
+ radixPosition = radixPosition + 1;
2075
+ nDigitsRead = nDigitsRead + 1;
2076
+ index = index + 1;
2077
+ }
2078
+ if (sawRadix && !nDigitsRead)
2079
+ throw new BSONError('' + representation + ' not a valid Decimal128 string');
2080
+ if (representation[index] === 'e' || representation[index] === 'E') {
2081
+ const match = representation.substr(++index).match(EXPONENT_REGEX);
2082
+ if (!match || !match[2])
2083
+ return new Decimal128(NAN_BUFFER);
2084
+ exponent = parseInt(match[0], 10);
2085
+ index = index + match[0].length;
2086
+ }
2087
+ if (representation[index])
2088
+ return new Decimal128(NAN_BUFFER);
2089
+ if (!nDigitsStored) {
2090
+ digits[0] = 0;
2091
+ nDigits = 1;
2092
+ nDigitsStored = 1;
2093
+ significantDigits = 0;
2094
+ }
2095
+ else {
2096
+ lastDigit = nDigitsStored - 1;
2097
+ significantDigits = nDigits;
2098
+ if (significantDigits !== 1) {
2099
+ while (representation[firstNonZero + significantDigits - 1 + Number(sawSign) + Number(sawRadix)] === '0') {
2100
+ significantDigits = significantDigits - 1;
2101
+ }
2102
+ }
2103
+ }
2104
+ if (exponent <= radixPosition && radixPosition > exponent + (1 << 14)) {
2105
+ exponent = EXPONENT_MIN;
2106
+ }
2107
+ else {
2108
+ exponent = exponent - radixPosition;
2109
+ }
2110
+ while (exponent > EXPONENT_MAX) {
2111
+ lastDigit = lastDigit + 1;
2112
+ if (lastDigit >= MAX_DIGITS) {
2113
+ if (significantDigits === 0) {
2114
+ exponent = EXPONENT_MAX;
2115
+ break;
2116
+ }
2117
+ invalidErr(representation, 'overflow');
2118
+ }
2119
+ exponent = exponent - 1;
2120
+ }
2121
+ if (options.allowRounding) {
2122
+ while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
2123
+ if (lastDigit === 0 && significantDigits < nDigitsStored) {
2124
+ exponent = EXPONENT_MIN;
2125
+ significantDigits = 0;
2126
+ break;
2127
+ }
2128
+ if (nDigitsStored < nDigits) {
2129
+ nDigits = nDigits - 1;
2130
+ }
2131
+ else {
2132
+ lastDigit = lastDigit - 1;
2133
+ }
2134
+ if (exponent < EXPONENT_MAX) {
2135
+ exponent = exponent + 1;
2136
+ }
2137
+ else {
2138
+ const digitsString = digits.join('');
2139
+ if (digitsString.match(/^0+$/)) {
2140
+ exponent = EXPONENT_MAX;
2141
+ break;
2142
+ }
2143
+ invalidErr(representation, 'overflow');
2144
+ }
2145
+ }
2146
+ if (lastDigit + 1 < significantDigits) {
2147
+ let endOfString = nDigitsRead;
2148
+ if (sawRadix) {
2149
+ firstNonZero = firstNonZero + 1;
2150
+ endOfString = endOfString + 1;
2151
+ }
2152
+ if (sawSign) {
2153
+ firstNonZero = firstNonZero + 1;
2154
+ endOfString = endOfString + 1;
2155
+ }
2156
+ const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10);
2157
+ let roundBit = 0;
2158
+ if (roundDigit >= 5) {
2159
+ roundBit = 1;
2160
+ if (roundDigit === 5) {
2161
+ roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0;
2162
+ for (let i = firstNonZero + lastDigit + 2; i < endOfString; i++) {
2163
+ if (parseInt(representation[i], 10)) {
2164
+ roundBit = 1;
2165
+ break;
2166
+ }
2167
+ }
2168
+ }
2169
+ }
2170
+ if (roundBit) {
2171
+ let dIdx = lastDigit;
2172
+ for (; dIdx >= 0; dIdx--) {
2173
+ if (++digits[dIdx] > 9) {
2174
+ digits[dIdx] = 0;
2175
+ if (dIdx === 0) {
2176
+ if (exponent < EXPONENT_MAX) {
2177
+ exponent = exponent + 1;
2178
+ digits[dIdx] = 1;
2179
+ }
2180
+ else {
2181
+ return new Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER);
2182
+ }
2183
+ }
2184
+ }
2185
+ else {
2186
+ break;
2187
+ }
2188
+ }
2189
+ }
2190
+ }
2191
+ }
2192
+ else {
2193
+ while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
2194
+ if (lastDigit === 0) {
2195
+ if (significantDigits === 0) {
2196
+ exponent = EXPONENT_MIN;
2197
+ break;
2198
+ }
2199
+ invalidErr(representation, 'exponent underflow');
2200
+ }
2201
+ if (nDigitsStored < nDigits) {
2202
+ if (representation[nDigits - 1 + Number(sawSign) + Number(sawRadix)] !== '0' &&
2203
+ significantDigits !== 0) {
2204
+ invalidErr(representation, 'inexact rounding');
2205
+ }
2206
+ nDigits = nDigits - 1;
2207
+ }
2208
+ else {
2209
+ if (digits[lastDigit] !== 0) {
2210
+ invalidErr(representation, 'inexact rounding');
2211
+ }
2212
+ lastDigit = lastDigit - 1;
2213
+ }
2214
+ if (exponent < EXPONENT_MAX) {
2215
+ exponent = exponent + 1;
2216
+ }
2217
+ else {
2218
+ invalidErr(representation, 'overflow');
2219
+ }
2220
+ }
2221
+ if (lastDigit + 1 < significantDigits) {
2222
+ if (sawRadix) {
2223
+ firstNonZero = firstNonZero + 1;
2224
+ }
2225
+ if (sawSign) {
2226
+ firstNonZero = firstNonZero + 1;
2227
+ }
2228
+ const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10);
2229
+ if (roundDigit !== 0) {
2230
+ invalidErr(representation, 'inexact rounding');
2231
+ }
2232
+ }
2233
+ }
2234
+ significandHigh = Long.fromNumber(0);
2235
+ significandLow = Long.fromNumber(0);
2236
+ if (significantDigits === 0) {
2237
+ significandHigh = Long.fromNumber(0);
2238
+ significandLow = Long.fromNumber(0);
2239
+ }
2240
+ else if (lastDigit < 17) {
2241
+ let dIdx = 0;
2242
+ significandLow = Long.fromNumber(digits[dIdx++]);
2243
+ significandHigh = new Long(0, 0);
2244
+ for (; dIdx <= lastDigit; dIdx++) {
2245
+ significandLow = significandLow.multiply(Long.fromNumber(10));
2246
+ significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
2247
+ }
2248
+ }
2249
+ else {
2250
+ let dIdx = 0;
2251
+ significandHigh = Long.fromNumber(digits[dIdx++]);
2252
+ for (; dIdx <= lastDigit - 17; dIdx++) {
2253
+ significandHigh = significandHigh.multiply(Long.fromNumber(10));
2254
+ significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx]));
2255
+ }
2256
+ significandLow = Long.fromNumber(digits[dIdx++]);
2257
+ for (; dIdx <= lastDigit; dIdx++) {
2258
+ significandLow = significandLow.multiply(Long.fromNumber(10));
2259
+ significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
2260
+ }
2261
+ }
2262
+ const significand = multiply64x2(significandHigh, Long.fromString('100000000000000000'));
2263
+ significand.low = significand.low.add(significandLow);
2264
+ if (lessThan(significand.low, significandLow)) {
2265
+ significand.high = significand.high.add(Long.fromNumber(1));
2266
+ }
2267
+ biasedExponent = exponent + EXPONENT_BIAS;
2268
+ const dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) };
2269
+ if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))) {
2270
+ dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61));
2271
+ dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47)));
2272
+ dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff)));
2273
+ }
2274
+ else {
2275
+ dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
2276
+ dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff)));
2277
+ }
2278
+ dec.low = significand.low;
2279
+ if (isNegative) {
2280
+ dec.high = dec.high.or(Long.fromString('9223372036854775808'));
2281
+ }
2282
+ const buffer = ByteUtils.allocateUnsafe(16);
2283
+ index = 0;
2284
+ buffer[index++] = dec.low.low & 0xff;
2285
+ buffer[index++] = (dec.low.low >> 8) & 0xff;
2286
+ buffer[index++] = (dec.low.low >> 16) & 0xff;
2287
+ buffer[index++] = (dec.low.low >> 24) & 0xff;
2288
+ buffer[index++] = dec.low.high & 0xff;
2289
+ buffer[index++] = (dec.low.high >> 8) & 0xff;
2290
+ buffer[index++] = (dec.low.high >> 16) & 0xff;
2291
+ buffer[index++] = (dec.low.high >> 24) & 0xff;
2292
+ buffer[index++] = dec.high.low & 0xff;
2293
+ buffer[index++] = (dec.high.low >> 8) & 0xff;
2294
+ buffer[index++] = (dec.high.low >> 16) & 0xff;
2295
+ buffer[index++] = (dec.high.low >> 24) & 0xff;
2296
+ buffer[index++] = dec.high.high & 0xff;
2297
+ buffer[index++] = (dec.high.high >> 8) & 0xff;
2298
+ buffer[index++] = (dec.high.high >> 16) & 0xff;
2299
+ buffer[index++] = (dec.high.high >> 24) & 0xff;
2300
+ return new Decimal128(buffer);
2301
+ }
2302
+ toString() {
2303
+ let biased_exponent;
2304
+ let significand_digits = 0;
2305
+ const significand = new Array(36);
2306
+ for (let i = 0; i < significand.length; i++)
2307
+ significand[i] = 0;
2308
+ let index = 0;
2309
+ let is_zero = false;
2310
+ let significand_msb;
2311
+ let significand128 = { parts: [0, 0, 0, 0] };
2312
+ let j, k;
2313
+ const string = [];
2314
+ index = 0;
2315
+ const buffer = this.bytes;
2316
+ const low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
2317
+ const midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
2318
+ const midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
2319
+ const high = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
2320
+ index = 0;
2321
+ const dec = {
2322
+ low: new Long(low, midl),
2323
+ high: new Long(midh, high)
2324
+ };
2325
+ if (dec.high.lessThan(Long.ZERO)) {
2326
+ string.push('-');
2327
+ }
2328
+ const combination = (high >> 26) & COMBINATION_MASK;
2329
+ if (combination >> 3 === 3) {
2330
+ if (combination === COMBINATION_INFINITY) {
2331
+ return string.join('') + 'Infinity';
2332
+ }
2333
+ else if (combination === COMBINATION_NAN) {
2334
+ return 'NaN';
2335
+ }
2336
+ else {
2337
+ biased_exponent = (high >> 15) & EXPONENT_MASK;
2338
+ significand_msb = 0x08 + ((high >> 14) & 0x01);
2339
+ }
2340
+ }
2341
+ else {
2342
+ significand_msb = (high >> 14) & 0x07;
2343
+ biased_exponent = (high >> 17) & EXPONENT_MASK;
2344
+ }
2345
+ const exponent = biased_exponent - EXPONENT_BIAS;
2346
+ significand128.parts[0] = (high & 0x3fff) + ((significand_msb & 0xf) << 14);
2347
+ significand128.parts[1] = midh;
2348
+ significand128.parts[2] = midl;
2349
+ significand128.parts[3] = low;
2350
+ if (significand128.parts[0] === 0 &&
2351
+ significand128.parts[1] === 0 &&
2352
+ significand128.parts[2] === 0 &&
2353
+ significand128.parts[3] === 0) {
2354
+ is_zero = true;
2355
+ }
2356
+ else {
2357
+ for (k = 3; k >= 0; k--) {
2358
+ let least_digits = 0;
2359
+ const result = divideu128(significand128);
2360
+ significand128 = result.quotient;
2361
+ least_digits = result.rem.low;
2362
+ if (!least_digits)
2363
+ continue;
2364
+ for (j = 8; j >= 0; j--) {
2365
+ significand[k * 9 + j] = least_digits % 10;
2366
+ least_digits = Math.floor(least_digits / 10);
2367
+ }
2368
+ }
2369
+ }
2370
+ if (is_zero) {
2371
+ significand_digits = 1;
2372
+ significand[index] = 0;
2373
+ }
2374
+ else {
2375
+ significand_digits = 36;
2376
+ while (!significand[index]) {
2377
+ significand_digits = significand_digits - 1;
2378
+ index = index + 1;
2379
+ }
2380
+ }
2381
+ const scientific_exponent = significand_digits - 1 + exponent;
2382
+ if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) {
2383
+ if (significand_digits > 34) {
2384
+ string.push(`${0}`);
2385
+ if (exponent > 0)
2386
+ string.push(`E+${exponent}`);
2387
+ else if (exponent < 0)
2388
+ string.push(`E${exponent}`);
2389
+ return string.join('');
2390
+ }
2391
+ string.push(`${significand[index++]}`);
2392
+ significand_digits = significand_digits - 1;
2393
+ if (significand_digits) {
2394
+ string.push('.');
2395
+ }
2396
+ for (let i = 0; i < significand_digits; i++) {
2397
+ string.push(`${significand[index++]}`);
2398
+ }
2399
+ string.push('E');
2400
+ if (scientific_exponent > 0) {
2401
+ string.push(`+${scientific_exponent}`);
2402
+ }
2403
+ else {
2404
+ string.push(`${scientific_exponent}`);
2405
+ }
2406
+ }
2407
+ else {
2408
+ if (exponent >= 0) {
2409
+ for (let i = 0; i < significand_digits; i++) {
2410
+ string.push(`${significand[index++]}`);
2411
+ }
2412
+ }
2413
+ else {
2414
+ let radix_position = significand_digits + exponent;
2415
+ if (radix_position > 0) {
2416
+ for (let i = 0; i < radix_position; i++) {
2417
+ string.push(`${significand[index++]}`);
2418
+ }
2419
+ }
2420
+ else {
2421
+ string.push('0');
2422
+ }
2423
+ string.push('.');
2424
+ while (radix_position++ < 0) {
2425
+ string.push('0');
2426
+ }
2427
+ for (let i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) {
2428
+ string.push(`${significand[index++]}`);
2429
+ }
2430
+ }
2431
+ }
2432
+ return string.join('');
2433
+ }
2434
+ toJSON() {
2435
+ return { $numberDecimal: this.toString() };
2436
+ }
2437
+ toExtendedJSON() {
2438
+ return { $numberDecimal: this.toString() };
2439
+ }
2440
+ static fromExtendedJSON(doc) {
2441
+ return Decimal128.fromString(doc.$numberDecimal);
2442
+ }
2443
+ inspect(depth, options, inspect) {
2444
+ inspect ??= defaultInspect;
2445
+ const d128string = inspect(this.toString(), options);
2446
+ return `new Decimal128(${d128string})`;
2447
+ }
2448
+ }
2449
+
2450
+ class Double extends BSONValue {
2451
+ get _bsontype() {
2452
+ return 'Double';
2453
+ }
2454
+ value;
2455
+ constructor(value) {
2456
+ super();
2457
+ if (value instanceof Number) {
2458
+ value = value.valueOf();
2459
+ }
2460
+ this.value = +value;
2461
+ }
2462
+ static fromString(value) {
2463
+ const coercedValue = Number(value);
2464
+ if (value === 'NaN')
2465
+ return new Double(NaN);
2466
+ if (value === 'Infinity')
2467
+ return new Double(Infinity);
2468
+ if (value === '-Infinity')
2469
+ return new Double(-Infinity);
2470
+ if (!Number.isFinite(coercedValue)) {
2471
+ throw new BSONError(`Input: ${value} is not representable as a Double`);
2472
+ }
2473
+ if (value.trim() !== value) {
2474
+ throw new BSONError(`Input: '${value}' contains whitespace`);
2475
+ }
2476
+ if (value === '') {
2477
+ throw new BSONError(`Input is an empty string`);
2478
+ }
2479
+ if (/[^-0-9.+eE]/.test(value)) {
2480
+ throw new BSONError(`Input: '${value}' is not in decimal or exponential notation`);
2481
+ }
2482
+ return new Double(coercedValue);
2483
+ }
2484
+ valueOf() {
2485
+ return this.value;
2486
+ }
2487
+ toJSON() {
2488
+ return this.value;
2489
+ }
2490
+ toString(radix) {
2491
+ return this.value.toString(radix);
2492
+ }
2493
+ toExtendedJSON(options) {
2494
+ if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) {
2495
+ return this.value;
2496
+ }
2497
+ if (Object.is(Math.sign(this.value), -0)) {
2498
+ return { $numberDouble: '-0.0' };
2499
+ }
2500
+ return {
2501
+ $numberDouble: Number.isInteger(this.value) ? this.value.toFixed(1) : this.value.toString()
2502
+ };
2503
+ }
2504
+ static fromExtendedJSON(doc, options) {
2505
+ const doubleValue = parseFloat(doc.$numberDouble);
2506
+ return options && options.relaxed ? doubleValue : new Double(doubleValue);
2507
+ }
2508
+ inspect(depth, options, inspect) {
2509
+ inspect ??= defaultInspect;
2510
+ return `new Double(${inspect(this.value, options)})`;
2511
+ }
2512
+ }
2513
+
2514
+ class Int32 extends BSONValue {
2515
+ get _bsontype() {
2516
+ return 'Int32';
2517
+ }
2518
+ value;
2519
+ constructor(value) {
2520
+ super();
2521
+ if (value instanceof Number) {
2522
+ value = value.valueOf();
2523
+ }
2524
+ this.value = +value | 0;
2525
+ }
2526
+ static fromString(value) {
2527
+ const cleanedValue = removeLeadingZerosAndExplicitPlus(value);
2528
+ const coercedValue = Number(value);
2529
+ if (BSON_INT32_MAX < coercedValue) {
2530
+ throw new BSONError(`Input: '${value}' is larger than the maximum value for Int32`);
2531
+ }
2532
+ else if (BSON_INT32_MIN > coercedValue) {
2533
+ throw new BSONError(`Input: '${value}' is smaller than the minimum value for Int32`);
2534
+ }
2535
+ else if (!Number.isSafeInteger(coercedValue)) {
2536
+ throw new BSONError(`Input: '${value}' is not a safe integer`);
2537
+ }
2538
+ else if (coercedValue.toString() !== cleanedValue) {
2539
+ throw new BSONError(`Input: '${value}' is not a valid Int32 string`);
2540
+ }
2541
+ return new Int32(coercedValue);
2542
+ }
2543
+ valueOf() {
2544
+ return this.value;
2545
+ }
2546
+ toString(radix) {
2547
+ return this.value.toString(radix);
2548
+ }
2549
+ toJSON() {
2550
+ return this.value;
2551
+ }
2552
+ toExtendedJSON(options) {
2553
+ if (options && (options.relaxed || options.legacy))
2554
+ return this.value;
2555
+ return { $numberInt: this.value.toString() };
2556
+ }
2557
+ static fromExtendedJSON(doc, options) {
2558
+ return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt);
2559
+ }
2560
+ inspect(depth, options, inspect) {
2561
+ inspect ??= defaultInspect;
2562
+ return `new Int32(${inspect(this.value, options)})`;
2563
+ }
2564
+ }
2565
+
2566
+ class MaxKey extends BSONValue {
2567
+ get _bsontype() {
2568
+ return 'MaxKey';
2569
+ }
2570
+ toExtendedJSON() {
2571
+ return { $maxKey: 1 };
2572
+ }
2573
+ static fromExtendedJSON() {
2574
+ return new MaxKey();
2575
+ }
2576
+ inspect() {
2577
+ return 'new MaxKey()';
2578
+ }
2579
+ }
2580
+
2581
+ class MinKey extends BSONValue {
2582
+ get _bsontype() {
2583
+ return 'MinKey';
2584
+ }
2585
+ toExtendedJSON() {
2586
+ return { $minKey: 1 };
2587
+ }
2588
+ static fromExtendedJSON() {
2589
+ return new MinKey();
2590
+ }
2591
+ inspect() {
2592
+ return 'new MinKey()';
2593
+ }
2594
+ }
2595
+
2596
+ let PROCESS_UNIQUE = null;
2597
+ const __idCache = new WeakMap();
2598
+ class ObjectId extends BSONValue {
2599
+ get _bsontype() {
2600
+ return 'ObjectId';
2601
+ }
2602
+ static index = Math.floor(Math.random() * 0xffffff);
2603
+ static cacheHexString;
2604
+ buffer;
2605
+ constructor(inputId) {
2606
+ super();
2607
+ let workingId;
2608
+ if (typeof inputId === 'object' && inputId && 'id' in inputId) {
2609
+ if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) {
2610
+ throw new BSONError('Argument passed in must have an id that is of type string or Buffer');
2611
+ }
2612
+ if ('toHexString' in inputId && typeof inputId.toHexString === 'function') {
2613
+ workingId = ByteUtils.fromHex(inputId.toHexString());
2614
+ }
2615
+ else {
2616
+ workingId = inputId.id;
2617
+ }
2618
+ }
2619
+ else {
2620
+ workingId = inputId;
2621
+ }
2622
+ if (workingId == null) {
2623
+ this.buffer = ObjectId.generate();
2624
+ }
2625
+ else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
2626
+ this.buffer = ByteUtils.toLocalBufferType(workingId);
2627
+ }
2628
+ else if (typeof workingId === 'string') {
2629
+ if (ObjectId.validateHexString(workingId)) {
2630
+ this.buffer = ByteUtils.fromHex(workingId);
2631
+ if (ObjectId.cacheHexString) {
2632
+ __idCache.set(this, workingId);
2633
+ }
2634
+ }
2635
+ else {
2636
+ throw new BSONError('input must be a 24 character hex string, 12 byte Uint8Array, or an integer');
2637
+ }
2638
+ }
2639
+ else {
2640
+ throw new BSONError('Argument passed in does not match the accepted types');
2641
+ }
2642
+ }
2643
+ get id() {
2644
+ return this.buffer;
2645
+ }
2646
+ set id(value) {
2647
+ this.buffer = value;
2648
+ if (ObjectId.cacheHexString) {
2649
+ __idCache.set(this, ByteUtils.toHex(value));
2650
+ }
2651
+ }
2652
+ static validateHexString(string) {
2653
+ if (string?.length !== 24)
2654
+ return false;
2655
+ for (let i = 0; i < 24; i++) {
2656
+ const char = string.charCodeAt(i);
2657
+ if ((char >= 48 && char <= 57) ||
2658
+ (char >= 97 && char <= 102) ||
2659
+ (char >= 65 && char <= 70)) {
2660
+ continue;
2661
+ }
2662
+ return false;
2663
+ }
2664
+ return true;
2665
+ }
2666
+ toHexString() {
2667
+ if (ObjectId.cacheHexString) {
2668
+ const __id = __idCache.get(this);
2669
+ if (__id)
2670
+ return __id;
2671
+ }
2672
+ const hexString = ByteUtils.toHex(this.id);
2673
+ if (ObjectId.cacheHexString) {
2674
+ __idCache.set(this, hexString);
2675
+ }
2676
+ return hexString;
2677
+ }
2678
+ static getInc() {
2679
+ return (ObjectId.index = (ObjectId.index + 1) % 0xffffff);
2680
+ }
2681
+ static generate(time) {
2682
+ if ('number' !== typeof time) {
2683
+ time = Math.floor(Date.now() / 1000);
2684
+ }
2685
+ const inc = ObjectId.getInc();
2686
+ const buffer = ByteUtils.allocateUnsafe(12);
2687
+ NumberUtils.setInt32BE(buffer, 0, time);
2688
+ if (PROCESS_UNIQUE === null) {
2689
+ PROCESS_UNIQUE = ByteUtils.randomBytes(5);
2690
+ }
2691
+ buffer[4] = PROCESS_UNIQUE[0];
2692
+ buffer[5] = PROCESS_UNIQUE[1];
2693
+ buffer[6] = PROCESS_UNIQUE[2];
2694
+ buffer[7] = PROCESS_UNIQUE[3];
2695
+ buffer[8] = PROCESS_UNIQUE[4];
2696
+ buffer[11] = inc & 0xff;
2697
+ buffer[10] = (inc >> 8) & 0xff;
2698
+ buffer[9] = (inc >> 16) & 0xff;
2699
+ return buffer;
2700
+ }
2701
+ toString(encoding) {
2702
+ if (encoding === 'base64')
2703
+ return ByteUtils.toBase64(this.id);
2704
+ if (encoding === 'hex')
2705
+ return this.toHexString();
2706
+ return this.toHexString();
2707
+ }
2708
+ toJSON() {
2709
+ return this.toHexString();
2710
+ }
2711
+ static is(variable) {
2712
+ return (variable != null &&
2713
+ typeof variable === 'object' &&
2714
+ '_bsontype' in variable &&
2715
+ variable._bsontype === 'ObjectId');
2716
+ }
2717
+ equals(otherId) {
2718
+ if (otherId === undefined || otherId === null) {
2719
+ return false;
2720
+ }
2721
+ if (ObjectId.is(otherId)) {
2722
+ return (this.buffer[11] === otherId.buffer[11] && ByteUtils.equals(this.buffer, otherId.buffer));
2723
+ }
2724
+ if (typeof otherId === 'string') {
2725
+ return otherId.toLowerCase() === this.toHexString();
2726
+ }
2727
+ if (typeof otherId === 'object' && typeof otherId.toHexString === 'function') {
2728
+ const otherIdString = otherId.toHexString();
2729
+ const thisIdString = this.toHexString();
2730
+ return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
2731
+ }
2732
+ return false;
2733
+ }
2734
+ getTimestamp() {
2735
+ const timestamp = new Date();
2736
+ const time = NumberUtils.getUint32BE(this.buffer, 0);
2737
+ timestamp.setTime(Math.floor(time) * 1000);
2738
+ return timestamp;
2739
+ }
2740
+ static createPk() {
2741
+ return new ObjectId();
2742
+ }
2743
+ serializeInto(uint8array, index) {
2744
+ uint8array[index] = this.buffer[0];
2745
+ uint8array[index + 1] = this.buffer[1];
2746
+ uint8array[index + 2] = this.buffer[2];
2747
+ uint8array[index + 3] = this.buffer[3];
2748
+ uint8array[index + 4] = this.buffer[4];
2749
+ uint8array[index + 5] = this.buffer[5];
2750
+ uint8array[index + 6] = this.buffer[6];
2751
+ uint8array[index + 7] = this.buffer[7];
2752
+ uint8array[index + 8] = this.buffer[8];
2753
+ uint8array[index + 9] = this.buffer[9];
2754
+ uint8array[index + 10] = this.buffer[10];
2755
+ uint8array[index + 11] = this.buffer[11];
2756
+ return 12;
2757
+ }
2758
+ static createFromTime(time) {
2759
+ const buffer = ByteUtils.allocate(12);
2760
+ for (let i = 11; i >= 4; i--)
2761
+ buffer[i] = 0;
2762
+ NumberUtils.setInt32BE(buffer, 0, time);
2763
+ return new ObjectId(buffer);
2764
+ }
2765
+ static createFromHexString(hexString) {
2766
+ if (hexString?.length !== 24) {
2767
+ throw new BSONError('hex string must be 24 characters');
2768
+ }
2769
+ return new ObjectId(ByteUtils.fromHex(hexString));
2770
+ }
2771
+ static createFromBase64(base64) {
2772
+ if (base64?.length !== 16) {
2773
+ throw new BSONError('base64 string must be 16 characters');
2774
+ }
2775
+ return new ObjectId(ByteUtils.fromBase64(base64));
2776
+ }
2777
+ static isValid(id) {
2778
+ if (id == null)
2779
+ return false;
2780
+ if (typeof id === 'string')
2781
+ return ObjectId.validateHexString(id);
2782
+ try {
2783
+ new ObjectId(id);
2784
+ return true;
2785
+ }
2786
+ catch {
2787
+ return false;
2788
+ }
2789
+ }
2790
+ toExtendedJSON() {
2791
+ if (this.toHexString)
2792
+ return { $oid: this.toHexString() };
2793
+ return { $oid: this.toString('hex') };
2794
+ }
2795
+ static fromExtendedJSON(doc) {
2796
+ return new ObjectId(doc.$oid);
2797
+ }
2798
+ isCached() {
2799
+ return ObjectId.cacheHexString && __idCache.has(this);
2800
+ }
2801
+ inspect(depth, options, inspect) {
2802
+ inspect ??= defaultInspect;
2803
+ return `new ObjectId(${inspect(this.toHexString(), options)})`;
2804
+ }
2805
+ }
2806
+
2807
+ function internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined) {
2808
+ let totalLength = 4 + 1;
2809
+ if (Array.isArray(object)) {
2810
+ for (let i = 0; i < object.length; i++) {
2811
+ totalLength += calculateElement(i.toString(), object[i], serializeFunctions, true, ignoreUndefined);
2812
+ }
2813
+ }
2814
+ else {
2815
+ if (typeof object?.toBSON === 'function') {
2816
+ object = object.toBSON();
2817
+ }
2818
+ for (const key of Object.keys(object)) {
2819
+ totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined);
2820
+ }
2821
+ }
2822
+ return totalLength;
2823
+ }
2824
+ function calculateElement(name, value, serializeFunctions = false, isArray = false, ignoreUndefined = false) {
2825
+ if (typeof value?.toBSON === 'function') {
2826
+ value = value.toBSON();
2827
+ }
2828
+ switch (typeof value) {
2829
+ case 'string':
2830
+ return 1 + ByteUtils.utf8ByteLength(name) + 1 + 4 + ByteUtils.utf8ByteLength(value) + 1;
2831
+ case 'number':
2832
+ if (Math.floor(value) === value &&
2833
+ value >= JS_INT_MIN &&
2834
+ value <= JS_INT_MAX) {
2835
+ if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
2836
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (4 + 1);
2837
+ }
2838
+ else {
2839
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
2840
+ }
2841
+ }
2842
+ else {
2843
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
2844
+ }
2845
+ case 'undefined':
2846
+ if (isArray || !ignoreUndefined)
2847
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1;
2848
+ return 0;
2849
+ case 'boolean':
2850
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 1);
2851
+ case 'object':
2852
+ if (value != null &&
2853
+ typeof value._bsontype === 'string' &&
2854
+ value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
2855
+ throw new BSONVersionError();
2856
+ }
2857
+ else if (value == null || value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
2858
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1;
2859
+ }
2860
+ else if (value._bsontype === 'ObjectId') {
2861
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (12 + 1);
2862
+ }
2863
+ else if (value instanceof Date || isDate(value)) {
2864
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
2865
+ }
2866
+ else if (ArrayBuffer.isView(value) ||
2867
+ value instanceof ArrayBuffer ||
2868
+ isAnyArrayBuffer(value)) {
2869
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 4 + 1) + value.byteLength);
2870
+ }
2871
+ else if (value._bsontype === 'Long' ||
2872
+ value._bsontype === 'Double' ||
2873
+ value._bsontype === 'Timestamp') {
2874
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
2875
+ }
2876
+ else if (value._bsontype === 'Decimal128') {
2877
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (16 + 1);
2878
+ }
2879
+ else if (value._bsontype === 'Code') {
2880
+ if (value.scope != null && Object.keys(value.scope).length > 0) {
2881
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2882
+ 1 +
2883
+ 4 +
2884
+ 4 +
2885
+ ByteUtils.utf8ByteLength(value.code.toString()) +
2886
+ 1 +
2887
+ internalCalculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
2888
+ }
2889
+ else {
2890
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2891
+ 1 +
2892
+ 4 +
2893
+ ByteUtils.utf8ByteLength(value.code.toString()) +
2894
+ 1);
2895
+ }
2896
+ }
2897
+ else if (value._bsontype === 'Binary') {
2898
+ const binary = value;
2899
+ if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
2900
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2901
+ (binary.position + 1 + 4 + 1 + 4));
2902
+ }
2903
+ else {
2904
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (binary.position + 1 + 4 + 1));
2905
+ }
2906
+ }
2907
+ else if (value._bsontype === 'Symbol') {
2908
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2909
+ ByteUtils.utf8ByteLength(value.value) +
2910
+ 4 +
2911
+ 1 +
2912
+ 1);
2913
+ }
2914
+ else if (value._bsontype === 'DBRef') {
2915
+ const ordered_values = Object.assign({
2916
+ $ref: value.collection,
2917
+ $id: value.oid
2918
+ }, value.fields);
2919
+ if (value.db != null) {
2920
+ ordered_values['$db'] = value.db;
2921
+ }
2922
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2923
+ 1 +
2924
+ internalCalculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined));
2925
+ }
2926
+ else if (value instanceof RegExp || isRegExp(value)) {
2927
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2928
+ 1 +
2929
+ ByteUtils.utf8ByteLength(value.source) +
2930
+ 1 +
2931
+ (value.global ? 1 : 0) +
2932
+ (value.ignoreCase ? 1 : 0) +
2933
+ (value.multiline ? 1 : 0) +
2934
+ 1);
2935
+ }
2936
+ else if (value._bsontype === 'BSONRegExp') {
2937
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2938
+ 1 +
2939
+ ByteUtils.utf8ByteLength(value.pattern) +
2940
+ 1 +
2941
+ ByteUtils.utf8ByteLength(value.options) +
2942
+ 1);
2943
+ }
2944
+ else {
2945
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2946
+ internalCalculateObjectSize(value, serializeFunctions, ignoreUndefined) +
2947
+ 1);
2948
+ }
2949
+ case 'function':
2950
+ if (serializeFunctions) {
2951
+ return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
2952
+ 1 +
2953
+ 4 +
2954
+ ByteUtils.utf8ByteLength(value.toString()) +
2955
+ 1);
2956
+ }
2957
+ return 0;
2958
+ case 'bigint':
2959
+ return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
2960
+ case 'symbol':
2961
+ return 0;
2962
+ default:
2963
+ throw new BSONError(`Unrecognized JS type: ${typeof value}`);
2964
+ }
2965
+ }
2966
+
2967
+ function alphabetize(str) {
2968
+ return str.split('').sort().join('');
2969
+ }
2970
+ class BSONRegExp extends BSONValue {
2971
+ get _bsontype() {
2972
+ return 'BSONRegExp';
2973
+ }
2974
+ pattern;
2975
+ options;
2976
+ constructor(pattern, options) {
2977
+ super();
2978
+ this.pattern = pattern;
2979
+ this.options = alphabetize(options ?? '');
2980
+ if (this.pattern.indexOf('\x00') !== -1) {
2981
+ throw new BSONError(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);
2982
+ }
2983
+ if (this.options.indexOf('\x00') !== -1) {
2984
+ throw new BSONError(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);
2985
+ }
2986
+ for (let i = 0; i < this.options.length; i++) {
2987
+ if (!(this.options[i] === 'i' ||
2988
+ this.options[i] === 'm' ||
2989
+ this.options[i] === 'x' ||
2990
+ this.options[i] === 'l' ||
2991
+ this.options[i] === 's' ||
2992
+ this.options[i] === 'u')) {
2993
+ throw new BSONError(`The regular expression option [${this.options[i]}] is not supported`);
2994
+ }
2995
+ }
2996
+ }
2997
+ static parseOptions(options) {
2998
+ return options ? options.split('').sort().join('') : '';
2999
+ }
3000
+ toExtendedJSON(options) {
3001
+ options = options || {};
3002
+ if (options.legacy) {
3003
+ return { $regex: this.pattern, $options: this.options };
3004
+ }
3005
+ return { $regularExpression: { pattern: this.pattern, options: this.options } };
3006
+ }
3007
+ static fromExtendedJSON(doc) {
3008
+ if ('$regex' in doc) {
3009
+ if (typeof doc.$regex !== 'string') {
3010
+ if (doc.$regex._bsontype === 'BSONRegExp') {
3011
+ return doc;
3012
+ }
3013
+ }
3014
+ else {
3015
+ return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options));
3016
+ }
3017
+ }
3018
+ if ('$regularExpression' in doc) {
3019
+ return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options));
3020
+ }
3021
+ throw new BSONError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(doc)}`);
3022
+ }
3023
+ inspect(depth, options, inspect) {
3024
+ const stylize = getStylizeFunction(options) ?? (v => v);
3025
+ inspect ??= defaultInspect;
3026
+ const pattern = stylize(inspect(this.pattern), 'regexp');
3027
+ const flags = stylize(inspect(this.options), 'regexp');
3028
+ return `new BSONRegExp(${pattern}, ${flags})`;
3029
+ }
3030
+ }
3031
+
3032
+ class BSONSymbol extends BSONValue {
3033
+ get _bsontype() {
3034
+ return 'BSONSymbol';
3035
+ }
3036
+ value;
3037
+ constructor(value) {
3038
+ super();
3039
+ this.value = value;
3040
+ }
3041
+ valueOf() {
3042
+ return this.value;
3043
+ }
3044
+ toString() {
3045
+ return this.value;
3046
+ }
3047
+ toJSON() {
3048
+ return this.value;
3049
+ }
3050
+ toExtendedJSON() {
3051
+ return { $symbol: this.value };
3052
+ }
3053
+ static fromExtendedJSON(doc) {
3054
+ return new BSONSymbol(doc.$symbol);
3055
+ }
3056
+ inspect(depth, options, inspect) {
3057
+ inspect ??= defaultInspect;
3058
+ return `new BSONSymbol(${inspect(this.value, options)})`;
3059
+ }
3060
+ }
3061
+
3062
+ const LongWithoutOverridesClass = Long;
3063
+ class Timestamp extends LongWithoutOverridesClass {
3064
+ get _bsontype() {
3065
+ return 'Timestamp';
3066
+ }
3067
+ get [bsonType]() {
3068
+ return 'Timestamp';
3069
+ }
3070
+ static MAX_VALUE = Long.MAX_UNSIGNED_VALUE;
3071
+ get i() {
3072
+ return this.low >>> 0;
3073
+ }
3074
+ get t() {
3075
+ return this.high >>> 0;
3076
+ }
3077
+ constructor(low) {
3078
+ if (low == null) {
3079
+ super(0, 0, true);
3080
+ }
3081
+ else if (typeof low === 'bigint') {
3082
+ super(low, true);
3083
+ }
3084
+ else if (Long.isLong(low)) {
3085
+ super(low.low, low.high, true);
3086
+ }
3087
+ else if (typeof low === 'object' && 't' in low && 'i' in low) {
3088
+ if (typeof low.t !== 'number' && (typeof low.t !== 'object' || low.t._bsontype !== 'Int32')) {
3089
+ throw new BSONError('Timestamp constructed from { t, i } must provide t as a number');
3090
+ }
3091
+ if (typeof low.i !== 'number' && (typeof low.i !== 'object' || low.i._bsontype !== 'Int32')) {
3092
+ throw new BSONError('Timestamp constructed from { t, i } must provide i as a number');
3093
+ }
3094
+ const t = Number(low.t);
3095
+ const i = Number(low.i);
3096
+ if (t < 0 || Number.isNaN(t)) {
3097
+ throw new BSONError('Timestamp constructed from { t, i } must provide a positive t');
3098
+ }
3099
+ if (i < 0 || Number.isNaN(i)) {
3100
+ throw new BSONError('Timestamp constructed from { t, i } must provide a positive i');
3101
+ }
3102
+ if (t > 0xffff_ffff) {
3103
+ throw new BSONError('Timestamp constructed from { t, i } must provide t equal or less than uint32 max');
3104
+ }
3105
+ if (i > 0xffff_ffff) {
3106
+ throw new BSONError('Timestamp constructed from { t, i } must provide i equal or less than uint32 max');
3107
+ }
3108
+ super(i, t, true);
3109
+ }
3110
+ else {
3111
+ throw new BSONError('A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }');
3112
+ }
3113
+ }
3114
+ toJSON() {
3115
+ return {
3116
+ $timestamp: this.toString()
3117
+ };
3118
+ }
3119
+ static fromInt(value) {
3120
+ return new Timestamp(Long.fromInt(value, true));
3121
+ }
3122
+ static fromNumber(value) {
3123
+ return new Timestamp(Long.fromNumber(value, true));
3124
+ }
3125
+ static fromBits(lowBits, highBits) {
3126
+ return new Timestamp({ i: lowBits, t: highBits });
3127
+ }
3128
+ static fromString(str, optRadix) {
3129
+ return new Timestamp(Long.fromString(str, true, optRadix));
3130
+ }
3131
+ toExtendedJSON() {
3132
+ return { $timestamp: { t: this.t, i: this.i } };
3133
+ }
3134
+ static fromExtendedJSON(doc) {
3135
+ const i = Long.isLong(doc.$timestamp.i)
3136
+ ? doc.$timestamp.i.getLowBitsUnsigned()
3137
+ : doc.$timestamp.i;
3138
+ const t = Long.isLong(doc.$timestamp.t)
3139
+ ? doc.$timestamp.t.getLowBitsUnsigned()
3140
+ : doc.$timestamp.t;
3141
+ return new Timestamp({ t, i });
3142
+ }
3143
+ inspect(depth, options, inspect) {
3144
+ inspect ??= defaultInspect;
3145
+ const t = inspect(this.t, options);
3146
+ const i = inspect(this.i, options);
3147
+ return `new Timestamp({ t: ${t}, i: ${i} })`;
3148
+ }
3149
+ }
3150
+
3151
+ const JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX);
3152
+ const JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN);
3153
+ function internalDeserialize(buffer, options, isArray) {
3154
+ options = options == null ? {} : options;
3155
+ const index = options && options.index ? options.index : 0;
3156
+ const size = NumberUtils.getInt32LE(buffer, index);
3157
+ if (size < 5) {
3158
+ throw new BSONError(`bson size must be >= 5, is ${size}`);
3159
+ }
3160
+ if (options.allowObjectSmallerThanBufferSize && buffer.length < size) {
3161
+ throw new BSONError(`buffer length ${buffer.length} must be >= bson size ${size}`);
3162
+ }
3163
+ if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) {
3164
+ throw new BSONError(`buffer length ${buffer.length} must === bson size ${size}`);
3165
+ }
3166
+ if (size + index > buffer.byteLength) {
3167
+ throw new BSONError(`(bson size ${size} + options.index ${index} must be <= buffer length ${buffer.byteLength})`);
3168
+ }
3169
+ if (buffer[index + size - 1] !== 0) {
3170
+ throw new BSONError("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");
3171
+ }
3172
+ return deserializeObject(buffer, index, options, isArray);
3173
+ }
3174
+ const allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/;
3175
+ function deserializeObject(buffer, index, options, isArray = false) {
3176
+ const fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw'];
3177
+ const raw = options['raw'] == null ? false : options['raw'];
3178
+ const bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false;
3179
+ const promoteBuffers = options.promoteBuffers ?? false;
3180
+ const promoteLongs = options.promoteLongs ?? true;
3181
+ const promoteValues = options.promoteValues ?? true;
3182
+ const useBigInt64 = options.useBigInt64 ?? false;
3183
+ if (useBigInt64 && !promoteValues) {
3184
+ throw new BSONError('Must either request bigint or Long for int64 deserialization');
3185
+ }
3186
+ if (useBigInt64 && !promoteLongs) {
3187
+ throw new BSONError('Must either request bigint or Long for int64 deserialization');
3188
+ }
3189
+ const validation = options.validation == null ? { utf8: true } : options.validation;
3190
+ let globalUTFValidation = true;
3191
+ let validationSetting;
3192
+ let utf8KeysSet;
3193
+ const utf8ValidatedKeys = validation.utf8;
3194
+ if (typeof utf8ValidatedKeys === 'boolean') {
3195
+ validationSetting = utf8ValidatedKeys;
3196
+ }
3197
+ else {
3198
+ globalUTFValidation = false;
3199
+ const utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) {
3200
+ return utf8ValidatedKeys[key];
3201
+ });
3202
+ if (utf8ValidationValues.length === 0) {
3203
+ throw new BSONError('UTF-8 validation setting cannot be empty');
3204
+ }
3205
+ if (typeof utf8ValidationValues[0] !== 'boolean') {
3206
+ throw new BSONError('Invalid UTF-8 validation option, must specify boolean values');
3207
+ }
3208
+ validationSetting = utf8ValidationValues[0];
3209
+ if (!utf8ValidationValues.every(item => item === validationSetting)) {
3210
+ throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false');
3211
+ }
3212
+ }
3213
+ if (!globalUTFValidation) {
3214
+ utf8KeysSet = new Set();
3215
+ for (const key of Object.keys(utf8ValidatedKeys)) {
3216
+ utf8KeysSet.add(key);
3217
+ }
3218
+ }
3219
+ const startIndex = index;
3220
+ if (buffer.length < 5)
3221
+ throw new BSONError('corrupt bson message < 5 bytes long');
3222
+ const size = NumberUtils.getInt32LE(buffer, index);
3223
+ index += 4;
3224
+ if (size < 5 || size > buffer.length)
3225
+ throw new BSONError('corrupt bson message');
3226
+ const object = isArray ? [] : {};
3227
+ let arrayIndex = 0;
3228
+ let isPossibleDBRef = isArray ? false : null;
3229
+ while (true) {
3230
+ const elementType = buffer[index++];
3231
+ if (elementType === 0)
3232
+ break;
3233
+ let i = index;
3234
+ while (buffer[i] !== 0x00 && i < buffer.length) {
3235
+ i++;
3236
+ }
3237
+ if (i >= buffer.byteLength)
3238
+ throw new BSONError('Bad BSON Document: illegal CString');
3239
+ const name = isArray ? arrayIndex++ : ByteUtils.toUTF8(buffer, index, i, false);
3240
+ let shouldValidateKey = true;
3241
+ if (globalUTFValidation || utf8KeysSet?.has(name)) {
3242
+ shouldValidateKey = validationSetting;
3243
+ }
3244
+ else {
3245
+ shouldValidateKey = !validationSetting;
3246
+ }
3247
+ if (isPossibleDBRef !== false && name[0] === '$') {
3248
+ isPossibleDBRef = allowedDBRefKeys.test(name);
3249
+ }
3250
+ let value;
3251
+ index = i + 1;
3252
+ if (elementType === BSON_DATA_STRING) {
3253
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
3254
+ index += 4;
3255
+ if (stringSize <= 0 ||
3256
+ stringSize > buffer.length - index ||
3257
+ buffer[index + stringSize - 1] !== 0) {
3258
+ throw new BSONError('bad string length in bson');
3259
+ }
3260
+ value = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
3261
+ index = index + stringSize;
3262
+ }
3263
+ else if (elementType === BSON_DATA_OID) {
3264
+ const oid = ByteUtils.allocateUnsafe(12);
3265
+ for (let i = 0; i < 12; i++)
3266
+ oid[i] = buffer[index + i];
3267
+ value = new ObjectId(oid);
3268
+ index = index + 12;
3269
+ }
3270
+ else if (elementType === BSON_DATA_INT && promoteValues === false) {
3271
+ value = new Int32(NumberUtils.getInt32LE(buffer, index));
3272
+ index += 4;
3273
+ }
3274
+ else if (elementType === BSON_DATA_INT) {
3275
+ value = NumberUtils.getInt32LE(buffer, index);
3276
+ index += 4;
3277
+ }
3278
+ else if (elementType === BSON_DATA_NUMBER) {
3279
+ value = NumberUtils.getFloat64LE(buffer, index);
3280
+ index += 8;
3281
+ if (promoteValues === false)
3282
+ value = new Double(value);
3283
+ }
3284
+ else if (elementType === BSON_DATA_DATE) {
3285
+ const lowBits = NumberUtils.getInt32LE(buffer, index);
3286
+ const highBits = NumberUtils.getInt32LE(buffer, index + 4);
3287
+ index += 8;
3288
+ value = new Date(new Long(lowBits, highBits).toNumber());
3289
+ }
3290
+ else if (elementType === BSON_DATA_BOOLEAN) {
3291
+ if (buffer[index] !== 0 && buffer[index] !== 1)
3292
+ throw new BSONError('illegal boolean type value');
3293
+ value = buffer[index++] === 1;
3294
+ }
3295
+ else if (elementType === BSON_DATA_OBJECT) {
3296
+ const _index = index;
3297
+ const objectSize = NumberUtils.getInt32LE(buffer, index);
3298
+ if (objectSize <= 0 || objectSize > buffer.length - index)
3299
+ throw new BSONError('bad embedded document length in bson');
3300
+ if (raw) {
3301
+ value = buffer.subarray(index, index + objectSize);
3302
+ }
3303
+ else {
3304
+ let objectOptions = options;
3305
+ if (!globalUTFValidation) {
3306
+ objectOptions = { ...options, validation: { utf8: shouldValidateKey } };
3307
+ }
3308
+ value = deserializeObject(buffer, _index, objectOptions, false);
3309
+ }
3310
+ index = index + objectSize;
3311
+ }
3312
+ else if (elementType === BSON_DATA_ARRAY) {
3313
+ const _index = index;
3314
+ const objectSize = NumberUtils.getInt32LE(buffer, index);
3315
+ let arrayOptions = options;
3316
+ const stopIndex = index + objectSize;
3317
+ if (fieldsAsRaw && fieldsAsRaw[name]) {
3318
+ arrayOptions = { ...options, raw: true };
3319
+ }
3320
+ if (!globalUTFValidation) {
3321
+ arrayOptions = { ...arrayOptions, validation: { utf8: shouldValidateKey } };
3322
+ }
3323
+ value = deserializeObject(buffer, _index, arrayOptions, true);
3324
+ index = index + objectSize;
3325
+ if (buffer[index - 1] !== 0)
3326
+ throw new BSONError('invalid array terminator byte');
3327
+ if (index !== stopIndex)
3328
+ throw new BSONError('corrupted array bson');
3329
+ }
3330
+ else if (elementType === BSON_DATA_UNDEFINED) {
3331
+ value = undefined;
3332
+ }
3333
+ else if (elementType === BSON_DATA_NULL) {
3334
+ value = null;
3335
+ }
3336
+ else if (elementType === BSON_DATA_LONG) {
3337
+ if (useBigInt64) {
3338
+ value = NumberUtils.getBigInt64LE(buffer, index);
3339
+ index += 8;
3340
+ }
3341
+ else {
3342
+ const lowBits = NumberUtils.getInt32LE(buffer, index);
3343
+ const highBits = NumberUtils.getInt32LE(buffer, index + 4);
3344
+ index += 8;
3345
+ const long = new Long(lowBits, highBits);
3346
+ if (promoteLongs && promoteValues === true) {
3347
+ value =
3348
+ long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG)
3349
+ ? long.toNumber()
3350
+ : long;
3351
+ }
3352
+ else {
3353
+ value = long;
3354
+ }
3355
+ }
3356
+ }
3357
+ else if (elementType === BSON_DATA_DECIMAL128) {
3358
+ const bytes = ByteUtils.allocateUnsafe(16);
3359
+ for (let i = 0; i < 16; i++)
3360
+ bytes[i] = buffer[index + i];
3361
+ index = index + 16;
3362
+ value = new Decimal128(bytes);
3363
+ }
3364
+ else if (elementType === BSON_DATA_BINARY) {
3365
+ let binarySize = NumberUtils.getInt32LE(buffer, index);
3366
+ index += 4;
3367
+ const totalBinarySize = binarySize;
3368
+ const subType = buffer[index++];
3369
+ if (binarySize < 0)
3370
+ throw new BSONError('Negative binary type element size found');
3371
+ if (binarySize > buffer.byteLength)
3372
+ throw new BSONError('Binary type size larger than document size');
3373
+ if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
3374
+ binarySize = NumberUtils.getInt32LE(buffer, index);
3375
+ index += 4;
3376
+ if (binarySize < 0)
3377
+ throw new BSONError('Negative binary type element size found for subtype 0x02');
3378
+ if (binarySize > totalBinarySize - 4)
3379
+ throw new BSONError('Binary type with subtype 0x02 contains too long binary size');
3380
+ if (binarySize < totalBinarySize - 4)
3381
+ throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
3382
+ }
3383
+ if (promoteBuffers && promoteValues) {
3384
+ value = ByteUtils.toLocalBufferType(buffer.subarray(index, index + binarySize));
3385
+ }
3386
+ else {
3387
+ value = new Binary(buffer.subarray(index, index + binarySize), subType);
3388
+ if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
3389
+ value = value.toUUID();
3390
+ }
3391
+ }
3392
+ index = index + binarySize;
3393
+ }
3394
+ else if (elementType === BSON_DATA_REGEXP && bsonRegExp === false) {
3395
+ i = index;
3396
+ while (buffer[i] !== 0x00 && i < buffer.length) {
3397
+ i++;
3398
+ }
3399
+ if (i >= buffer.length)
3400
+ throw new BSONError('Bad BSON Document: illegal CString');
3401
+ const source = ByteUtils.toUTF8(buffer, index, i, false);
3402
+ index = i + 1;
3403
+ i = index;
3404
+ while (buffer[i] !== 0x00 && i < buffer.length) {
3405
+ i++;
3406
+ }
3407
+ if (i >= buffer.length)
3408
+ throw new BSONError('Bad BSON Document: illegal CString');
3409
+ const regExpOptions = ByteUtils.toUTF8(buffer, index, i, false);
3410
+ index = i + 1;
3411
+ const optionsArray = new Array(regExpOptions.length);
3412
+ for (i = 0; i < regExpOptions.length; i++) {
3413
+ switch (regExpOptions[i]) {
3414
+ case 'm':
3415
+ optionsArray[i] = 'm';
3416
+ break;
3417
+ case 's':
3418
+ optionsArray[i] = 'g';
3419
+ break;
3420
+ case 'i':
3421
+ optionsArray[i] = 'i';
3422
+ break;
3423
+ }
3424
+ }
3425
+ value = new RegExp(source, optionsArray.join(''));
3426
+ }
3427
+ else if (elementType === BSON_DATA_REGEXP && bsonRegExp === true) {
3428
+ i = index;
3429
+ while (buffer[i] !== 0x00 && i < buffer.length) {
3430
+ i++;
3431
+ }
3432
+ if (i >= buffer.length)
3433
+ throw new BSONError('Bad BSON Document: illegal CString');
3434
+ const source = ByteUtils.toUTF8(buffer, index, i, false);
3435
+ index = i + 1;
3436
+ i = index;
3437
+ while (buffer[i] !== 0x00 && i < buffer.length) {
3438
+ i++;
3439
+ }
3440
+ if (i >= buffer.length)
3441
+ throw new BSONError('Bad BSON Document: illegal CString');
3442
+ const regExpOptions = ByteUtils.toUTF8(buffer, index, i, false);
3443
+ index = i + 1;
3444
+ value = new BSONRegExp(source, regExpOptions);
3445
+ }
3446
+ else if (elementType === BSON_DATA_SYMBOL) {
3447
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
3448
+ index += 4;
3449
+ if (stringSize <= 0 ||
3450
+ stringSize > buffer.length - index ||
3451
+ buffer[index + stringSize - 1] !== 0) {
3452
+ throw new BSONError('bad string length in bson');
3453
+ }
3454
+ const symbol = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
3455
+ value = promoteValues ? symbol : new BSONSymbol(symbol);
3456
+ index = index + stringSize;
3457
+ }
3458
+ else if (elementType === BSON_DATA_TIMESTAMP) {
3459
+ value = new Timestamp({
3460
+ i: NumberUtils.getUint32LE(buffer, index),
3461
+ t: NumberUtils.getUint32LE(buffer, index + 4)
3462
+ });
3463
+ index += 8;
3464
+ }
3465
+ else if (elementType === BSON_DATA_MIN_KEY) {
3466
+ value = new MinKey();
3467
+ }
3468
+ else if (elementType === BSON_DATA_MAX_KEY) {
3469
+ value = new MaxKey();
3470
+ }
3471
+ else if (elementType === BSON_DATA_CODE) {
3472
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
3473
+ index += 4;
3474
+ if (stringSize <= 0 ||
3475
+ stringSize > buffer.length - index ||
3476
+ buffer[index + stringSize - 1] !== 0) {
3477
+ throw new BSONError('bad string length in bson');
3478
+ }
3479
+ const functionString = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
3480
+ value = new Code(functionString);
3481
+ index = index + stringSize;
3482
+ }
3483
+ else if (elementType === BSON_DATA_CODE_W_SCOPE) {
3484
+ const totalSize = NumberUtils.getInt32LE(buffer, index);
3485
+ index += 4;
3486
+ if (totalSize < 4 + 4 + 4 + 1) {
3487
+ throw new BSONError('code_w_scope total size shorter minimum expected length');
3488
+ }
3489
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
3490
+ index += 4;
3491
+ if (stringSize <= 0 ||
3492
+ stringSize > buffer.length - index ||
3493
+ buffer[index + stringSize - 1] !== 0) {
3494
+ throw new BSONError('bad string length in bson');
3495
+ }
3496
+ const functionString = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
3497
+ index = index + stringSize;
3498
+ const _index = index;
3499
+ const objectSize = NumberUtils.getInt32LE(buffer, index);
3500
+ const scopeObject = deserializeObject(buffer, _index, options, false);
3501
+ index = index + objectSize;
3502
+ if (totalSize < 4 + 4 + objectSize + stringSize) {
3503
+ throw new BSONError('code_w_scope total size is too short, truncating scope');
3504
+ }
3505
+ if (totalSize > 4 + 4 + objectSize + stringSize) {
3506
+ throw new BSONError('code_w_scope total size is too long, clips outer document');
3507
+ }
3508
+ value = new Code(functionString, scopeObject);
3509
+ }
3510
+ else if (elementType === BSON_DATA_DBPOINTER) {
3511
+ const stringSize = NumberUtils.getInt32LE(buffer, index);
3512
+ index += 4;
3513
+ if (stringSize <= 0 ||
3514
+ stringSize > buffer.length - index ||
3515
+ buffer[index + stringSize - 1] !== 0)
3516
+ throw new BSONError('bad string length in bson');
3517
+ const namespace = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
3518
+ index = index + stringSize;
3519
+ const oidBuffer = ByteUtils.allocateUnsafe(12);
3520
+ for (let i = 0; i < 12; i++)
3521
+ oidBuffer[i] = buffer[index + i];
3522
+ const oid = new ObjectId(oidBuffer);
3523
+ index = index + 12;
3524
+ value = new DBRef(namespace, oid);
3525
+ }
3526
+ else {
3527
+ throw new BSONError(`Detected unknown BSON type ${elementType.toString(16)} for fieldname "${name}"`);
3528
+ }
3529
+ if (name === '__proto__') {
3530
+ Object.defineProperty(object, name, {
3531
+ value,
3532
+ writable: true,
3533
+ enumerable: true,
3534
+ configurable: true
3535
+ });
3536
+ }
3537
+ else {
3538
+ object[name] = value;
3539
+ }
3540
+ }
3541
+ if (size !== index - startIndex) {
3542
+ if (isArray)
3543
+ throw new BSONError('corrupt array bson');
3544
+ throw new BSONError('corrupt object bson');
3545
+ }
3546
+ if (!isPossibleDBRef)
3547
+ return object;
3548
+ if (isDBRefLike(object)) {
3549
+ const copy = Object.assign({}, object);
3550
+ delete copy.$ref;
3551
+ delete copy.$id;
3552
+ delete copy.$db;
3553
+ return new DBRef(object.$ref, object.$id, object.$db, copy);
3554
+ }
3555
+ return object;
3556
+ }
3557
+
3558
+ const regexp = /\x00/;
3559
+ const ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
3560
+ function serializeString(buffer, key, value, index) {
3561
+ buffer[index++] = BSON_DATA_STRING;
3562
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3563
+ index = index + numberOfWrittenBytes + 1;
3564
+ buffer[index - 1] = 0;
3565
+ const size = ByteUtils.encodeUTF8Into(buffer, value, index + 4);
3566
+ NumberUtils.setInt32LE(buffer, index, size + 1);
3567
+ index = index + 4 + size;
3568
+ buffer[index++] = 0;
3569
+ return index;
3570
+ }
3571
+ function serializeNumber(buffer, key, value, index) {
3572
+ const isNegativeZero = Object.is(value, -0);
3573
+ const type = !isNegativeZero &&
3574
+ Number.isSafeInteger(value) &&
3575
+ value <= BSON_INT32_MAX &&
3576
+ value >= BSON_INT32_MIN
3577
+ ? BSON_DATA_INT
3578
+ : BSON_DATA_NUMBER;
3579
+ buffer[index++] = type;
3580
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3581
+ index = index + numberOfWrittenBytes;
3582
+ buffer[index++] = 0x00;
3583
+ if (type === BSON_DATA_INT) {
3584
+ index += NumberUtils.setInt32LE(buffer, index, value);
3585
+ }
3586
+ else {
3587
+ index += NumberUtils.setFloat64LE(buffer, index, value);
3588
+ }
3589
+ return index;
3590
+ }
3591
+ function serializeBigInt(buffer, key, value, index) {
3592
+ buffer[index++] = BSON_DATA_LONG;
3593
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3594
+ index += numberOfWrittenBytes;
3595
+ buffer[index++] = 0;
3596
+ index += NumberUtils.setBigInt64LE(buffer, index, value);
3597
+ return index;
3598
+ }
3599
+ function serializeNull(buffer, key, _, index) {
3600
+ buffer[index++] = BSON_DATA_NULL;
3601
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3602
+ index = index + numberOfWrittenBytes;
3603
+ buffer[index++] = 0;
3604
+ return index;
3605
+ }
3606
+ function serializeBoolean(buffer, key, value, index) {
3607
+ buffer[index++] = BSON_DATA_BOOLEAN;
3608
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3609
+ index = index + numberOfWrittenBytes;
3610
+ buffer[index++] = 0;
3611
+ buffer[index++] = value ? 1 : 0;
3612
+ return index;
3613
+ }
3614
+ function serializeDate(buffer, key, value, index) {
3615
+ buffer[index++] = BSON_DATA_DATE;
3616
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3617
+ index = index + numberOfWrittenBytes;
3618
+ buffer[index++] = 0;
3619
+ const dateInMilis = Long.fromNumber(value.getTime());
3620
+ const lowBits = dateInMilis.getLowBits();
3621
+ const highBits = dateInMilis.getHighBits();
3622
+ index += NumberUtils.setInt32LE(buffer, index, lowBits);
3623
+ index += NumberUtils.setInt32LE(buffer, index, highBits);
3624
+ return index;
3625
+ }
3626
+ function serializeRegExp(buffer, key, value, index) {
3627
+ buffer[index++] = BSON_DATA_REGEXP;
3628
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3629
+ index = index + numberOfWrittenBytes;
3630
+ buffer[index++] = 0;
3631
+ if (value.source && value.source.match(regexp) != null) {
3632
+ throw new BSONError('value ' + value.source + ' must not contain null bytes');
3633
+ }
3634
+ index = index + ByteUtils.encodeUTF8Into(buffer, value.source, index);
3635
+ buffer[index++] = 0x00;
3636
+ if (value.ignoreCase)
3637
+ buffer[index++] = 0x69;
3638
+ if (value.global)
3639
+ buffer[index++] = 0x73;
3640
+ if (value.multiline)
3641
+ buffer[index++] = 0x6d;
3642
+ buffer[index++] = 0x00;
3643
+ return index;
3644
+ }
3645
+ function serializeBSONRegExp(buffer, key, value, index) {
3646
+ buffer[index++] = BSON_DATA_REGEXP;
3647
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3648
+ index = index + numberOfWrittenBytes;
3649
+ buffer[index++] = 0;
3650
+ if (value.pattern.match(regexp) != null) {
3651
+ throw new BSONError('pattern ' + value.pattern + ' must not contain null bytes');
3652
+ }
3653
+ index = index + ByteUtils.encodeUTF8Into(buffer, value.pattern, index);
3654
+ buffer[index++] = 0x00;
3655
+ const sortedOptions = value.options.split('').sort().join('');
3656
+ index = index + ByteUtils.encodeUTF8Into(buffer, sortedOptions, index);
3657
+ buffer[index++] = 0x00;
3658
+ return index;
3659
+ }
3660
+ function serializeMinMax(buffer, key, value, index) {
3661
+ if (value === null) {
3662
+ buffer[index++] = BSON_DATA_NULL;
3663
+ }
3664
+ else if (value._bsontype === 'MinKey') {
3665
+ buffer[index++] = BSON_DATA_MIN_KEY;
3666
+ }
3667
+ else {
3668
+ buffer[index++] = BSON_DATA_MAX_KEY;
3669
+ }
3670
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3671
+ index = index + numberOfWrittenBytes;
3672
+ buffer[index++] = 0;
3673
+ return index;
3674
+ }
3675
+ function serializeObjectId(buffer, key, value, index) {
3676
+ buffer[index++] = BSON_DATA_OID;
3677
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3678
+ index = index + numberOfWrittenBytes;
3679
+ buffer[index++] = 0;
3680
+ index += value.serializeInto(buffer, index);
3681
+ return index;
3682
+ }
3683
+ function serializeBuffer(buffer, key, value, index) {
3684
+ buffer[index++] = BSON_DATA_BINARY;
3685
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3686
+ index = index + numberOfWrittenBytes;
3687
+ buffer[index++] = 0;
3688
+ const size = value.length;
3689
+ index += NumberUtils.setInt32LE(buffer, index, size);
3690
+ buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT;
3691
+ if (size <= 16) {
3692
+ for (let i = 0; i < size; i++)
3693
+ buffer[index + i] = value[i];
3694
+ }
3695
+ else {
3696
+ buffer.set(value, index);
3697
+ }
3698
+ index = index + size;
3699
+ return index;
3700
+ }
3701
+ function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path) {
3702
+ if (path.has(value)) {
3703
+ throw new BSONError('Cannot convert circular structure to BSON');
3704
+ }
3705
+ path.add(value);
3706
+ buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
3707
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3708
+ index = index + numberOfWrittenBytes;
3709
+ buffer[index++] = 0;
3710
+ const endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
3711
+ path.delete(value);
3712
+ return endIndex;
3713
+ }
3714
+ function serializeDecimal128(buffer, key, value, index) {
3715
+ buffer[index++] = BSON_DATA_DECIMAL128;
3716
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3717
+ index = index + numberOfWrittenBytes;
3718
+ buffer[index++] = 0;
3719
+ for (let i = 0; i < 16; i++)
3720
+ buffer[index + i] = value.bytes[i];
3721
+ return index + 16;
3722
+ }
3723
+ function serializeLong(buffer, key, value, index) {
3724
+ buffer[index++] =
3725
+ value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP;
3726
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3727
+ index = index + numberOfWrittenBytes;
3728
+ buffer[index++] = 0;
3729
+ const lowBits = value.getLowBits();
3730
+ const highBits = value.getHighBits();
3731
+ index += NumberUtils.setInt32LE(buffer, index, lowBits);
3732
+ index += NumberUtils.setInt32LE(buffer, index, highBits);
3733
+ return index;
3734
+ }
3735
+ function serializeInt32(buffer, key, value, index) {
3736
+ value = value.valueOf();
3737
+ buffer[index++] = BSON_DATA_INT;
3738
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3739
+ index = index + numberOfWrittenBytes;
3740
+ buffer[index++] = 0;
3741
+ index += NumberUtils.setInt32LE(buffer, index, value);
3742
+ return index;
3743
+ }
3744
+ function serializeDouble(buffer, key, value, index) {
3745
+ buffer[index++] = BSON_DATA_NUMBER;
3746
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3747
+ index = index + numberOfWrittenBytes;
3748
+ buffer[index++] = 0;
3749
+ index += NumberUtils.setFloat64LE(buffer, index, value.value);
3750
+ return index;
3751
+ }
3752
+ function serializeFunction(buffer, key, value, index) {
3753
+ buffer[index++] = BSON_DATA_CODE;
3754
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3755
+ index = index + numberOfWrittenBytes;
3756
+ buffer[index++] = 0;
3757
+ const functionString = value.toString();
3758
+ const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
3759
+ NumberUtils.setInt32LE(buffer, index, size);
3760
+ index = index + 4 + size - 1;
3761
+ buffer[index++] = 0;
3762
+ return index;
3763
+ }
3764
+ function serializeCode(buffer, key, value, index, checkKeys = false, depth = 0, serializeFunctions = false, ignoreUndefined = true, path) {
3765
+ if (value.scope && typeof value.scope === 'object') {
3766
+ buffer[index++] = BSON_DATA_CODE_W_SCOPE;
3767
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3768
+ index = index + numberOfWrittenBytes;
3769
+ buffer[index++] = 0;
3770
+ let startIndex = index;
3771
+ const functionString = value.code;
3772
+ index = index + 4;
3773
+ const codeSize = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
3774
+ NumberUtils.setInt32LE(buffer, index, codeSize);
3775
+ buffer[index + 4 + codeSize - 1] = 0;
3776
+ index = index + codeSize + 4;
3777
+ const endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
3778
+ index = endIndex - 1;
3779
+ const totalSize = endIndex - startIndex;
3780
+ startIndex += NumberUtils.setInt32LE(buffer, startIndex, totalSize);
3781
+ buffer[index++] = 0;
3782
+ }
3783
+ else {
3784
+ buffer[index++] = BSON_DATA_CODE;
3785
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3786
+ index = index + numberOfWrittenBytes;
3787
+ buffer[index++] = 0;
3788
+ const functionString = value.code.toString();
3789
+ const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
3790
+ NumberUtils.setInt32LE(buffer, index, size);
3791
+ index = index + 4 + size - 1;
3792
+ buffer[index++] = 0;
3793
+ }
3794
+ return index;
3795
+ }
3796
+ function serializeBinary(buffer, key, value, index) {
3797
+ buffer[index++] = BSON_DATA_BINARY;
3798
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3799
+ index = index + numberOfWrittenBytes;
3800
+ buffer[index++] = 0;
3801
+ const data = value.buffer;
3802
+ let size = value.position;
3803
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY)
3804
+ size = size + 4;
3805
+ index += NumberUtils.setInt32LE(buffer, index, size);
3806
+ buffer[index++] = value.sub_type;
3807
+ if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
3808
+ size = size - 4;
3809
+ index += NumberUtils.setInt32LE(buffer, index, size);
3810
+ }
3811
+ if (value.sub_type === Binary.SUBTYPE_VECTOR) {
3812
+ validateBinaryVector(value);
3813
+ }
3814
+ if (size <= 16) {
3815
+ for (let i = 0; i < size; i++)
3816
+ buffer[index + i] = data[i];
3817
+ }
3818
+ else {
3819
+ buffer.set(data, index);
3820
+ }
3821
+ index = index + value.position;
3822
+ return index;
3823
+ }
3824
+ function serializeSymbol(buffer, key, value, index) {
3825
+ buffer[index++] = BSON_DATA_SYMBOL;
3826
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3827
+ index = index + numberOfWrittenBytes;
3828
+ buffer[index++] = 0;
3829
+ const size = ByteUtils.encodeUTF8Into(buffer, value.value, index + 4) + 1;
3830
+ NumberUtils.setInt32LE(buffer, index, size);
3831
+ index = index + 4 + size - 1;
3832
+ buffer[index++] = 0;
3833
+ return index;
3834
+ }
3835
+ function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path) {
3836
+ buffer[index++] = BSON_DATA_OBJECT;
3837
+ const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
3838
+ index = index + numberOfWrittenBytes;
3839
+ buffer[index++] = 0;
3840
+ let startIndex = index;
3841
+ let output = {
3842
+ $ref: value.collection || value.namespace,
3843
+ $id: value.oid
3844
+ };
3845
+ if (value.db != null) {
3846
+ output.$db = value.db;
3847
+ }
3848
+ output = Object.assign(output, value.fields);
3849
+ const endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions, true, path);
3850
+ const size = endIndex - startIndex;
3851
+ startIndex += NumberUtils.setInt32LE(buffer, index, size);
3852
+ return endIndex;
3853
+ }
3854
+ function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) {
3855
+ if (path == null) {
3856
+ if (object == null) {
3857
+ buffer[0] = 0x05;
3858
+ buffer[1] = 0x00;
3859
+ buffer[2] = 0x00;
3860
+ buffer[3] = 0x00;
3861
+ buffer[4] = 0x00;
3862
+ return 5;
3863
+ }
3864
+ if (Array.isArray(object)) {
3865
+ throw new BSONError('serialize does not support an array as the root input');
3866
+ }
3867
+ if (typeof object !== 'object') {
3868
+ throw new BSONError('serialize does not support non-object as the root input');
3869
+ }
3870
+ else if ('_bsontype' in object && typeof object._bsontype === 'string') {
3871
+ throw new BSONError(`BSON types cannot be serialized as a document`);
3872
+ }
3873
+ else if (isDate(object) ||
3874
+ isRegExp(object) ||
3875
+ isUint8Array(object) ||
3876
+ isAnyArrayBuffer(object)) {
3877
+ throw new BSONError(`date, regexp, typedarray, and arraybuffer cannot be BSON documents`);
3878
+ }
3879
+ path = new Set();
3880
+ }
3881
+ path.add(object);
3882
+ let index = startingIndex + 4;
3883
+ if (Array.isArray(object)) {
3884
+ for (let i = 0; i < object.length; i++) {
3885
+ const key = `${i}`;
3886
+ let value = object[i];
3887
+ if (typeof value?.toBSON === 'function') {
3888
+ value = value.toBSON();
3889
+ }
3890
+ const type = typeof value;
3891
+ if (value === undefined) {
3892
+ index = serializeNull(buffer, key, value, index);
3893
+ }
3894
+ else if (value === null) {
3895
+ index = serializeNull(buffer, key, value, index);
3896
+ }
3897
+ else if (type === 'string') {
3898
+ index = serializeString(buffer, key, value, index);
3899
+ }
3900
+ else if (type === 'number') {
3901
+ index = serializeNumber(buffer, key, value, index);
3902
+ }
3903
+ else if (type === 'bigint') {
3904
+ index = serializeBigInt(buffer, key, value, index);
3905
+ }
3906
+ else if (type === 'boolean') {
3907
+ index = serializeBoolean(buffer, key, value, index);
3908
+ }
3909
+ else if (type === 'object' && value._bsontype == null) {
3910
+ if (value instanceof Date || isDate(value)) {
3911
+ index = serializeDate(buffer, key, value, index);
3912
+ }
3913
+ else if (value instanceof Uint8Array || isUint8Array(value)) {
3914
+ index = serializeBuffer(buffer, key, value, index);
3915
+ }
3916
+ else if (value instanceof RegExp || isRegExp(value)) {
3917
+ index = serializeRegExp(buffer, key, value, index);
3918
+ }
3919
+ else {
3920
+ index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
3921
+ }
3922
+ }
3923
+ else if (type === 'object') {
3924
+ if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
3925
+ throw new BSONVersionError();
3926
+ }
3927
+ else if (value._bsontype === 'ObjectId') {
3928
+ index = serializeObjectId(buffer, key, value, index);
3929
+ }
3930
+ else if (value._bsontype === 'Decimal128') {
3931
+ index = serializeDecimal128(buffer, key, value, index);
3932
+ }
3933
+ else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
3934
+ index = serializeLong(buffer, key, value, index);
3935
+ }
3936
+ else if (value._bsontype === 'Double') {
3937
+ index = serializeDouble(buffer, key, value, index);
3938
+ }
3939
+ else if (value._bsontype === 'Code') {
3940
+ index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
3941
+ }
3942
+ else if (value._bsontype === 'Binary') {
3943
+ index = serializeBinary(buffer, key, value, index);
3944
+ }
3945
+ else if (value._bsontype === 'BSONSymbol') {
3946
+ index = serializeSymbol(buffer, key, value, index);
3947
+ }
3948
+ else if (value._bsontype === 'DBRef') {
3949
+ index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
3950
+ }
3951
+ else if (value._bsontype === 'BSONRegExp') {
3952
+ index = serializeBSONRegExp(buffer, key, value, index);
3953
+ }
3954
+ else if (value._bsontype === 'Int32') {
3955
+ index = serializeInt32(buffer, key, value, index);
3956
+ }
3957
+ else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
3958
+ index = serializeMinMax(buffer, key, value, index);
3959
+ }
3960
+ else if (typeof value._bsontype !== 'undefined') {
3961
+ throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
3962
+ }
3963
+ }
3964
+ else if (type === 'function' && serializeFunctions) {
3965
+ index = serializeFunction(buffer, key, value, index);
3966
+ }
3967
+ }
3968
+ }
3969
+ else if (object instanceof Map || isMap(object)) {
3970
+ const iterator = object.entries();
3971
+ let done = false;
3972
+ while (!done) {
3973
+ const entry = iterator.next();
3974
+ done = !!entry.done;
3975
+ if (done)
3976
+ continue;
3977
+ const key = entry.value ? entry.value[0] : undefined;
3978
+ let value = entry.value ? entry.value[1] : undefined;
3979
+ if (typeof value?.toBSON === 'function') {
3980
+ value = value.toBSON();
3981
+ }
3982
+ const type = typeof value;
3983
+ if (typeof key === 'string' && !ignoreKeys.has(key)) {
3984
+ if (key.match(regexp) != null) {
3985
+ throw new BSONError('key ' + key + ' must not contain null bytes');
3986
+ }
3987
+ if (checkKeys) {
3988
+ if ('$' === key[0]) {
3989
+ throw new BSONError('key ' + key + " must not start with '$'");
3990
+ }
3991
+ else if (key.includes('.')) {
3992
+ throw new BSONError('key ' + key + " must not contain '.'");
3993
+ }
3994
+ }
3995
+ }
3996
+ if (value === undefined) {
3997
+ if (ignoreUndefined === false)
3998
+ index = serializeNull(buffer, key, value, index);
3999
+ }
4000
+ else if (value === null) {
4001
+ index = serializeNull(buffer, key, value, index);
4002
+ }
4003
+ else if (type === 'string') {
4004
+ index = serializeString(buffer, key, value, index);
4005
+ }
4006
+ else if (type === 'number') {
4007
+ index = serializeNumber(buffer, key, value, index);
4008
+ }
4009
+ else if (type === 'bigint') {
4010
+ index = serializeBigInt(buffer, key, value, index);
4011
+ }
4012
+ else if (type === 'boolean') {
4013
+ index = serializeBoolean(buffer, key, value, index);
4014
+ }
4015
+ else if (type === 'object' && value._bsontype == null) {
4016
+ if (value instanceof Date || isDate(value)) {
4017
+ index = serializeDate(buffer, key, value, index);
4018
+ }
4019
+ else if (value instanceof Uint8Array || isUint8Array(value)) {
4020
+ index = serializeBuffer(buffer, key, value, index);
4021
+ }
4022
+ else if (value instanceof RegExp || isRegExp(value)) {
4023
+ index = serializeRegExp(buffer, key, value, index);
4024
+ }
4025
+ else {
4026
+ index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
4027
+ }
4028
+ }
4029
+ else if (type === 'object') {
4030
+ if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
4031
+ throw new BSONVersionError();
4032
+ }
4033
+ else if (value._bsontype === 'ObjectId') {
4034
+ index = serializeObjectId(buffer, key, value, index);
4035
+ }
4036
+ else if (value._bsontype === 'Decimal128') {
4037
+ index = serializeDecimal128(buffer, key, value, index);
4038
+ }
4039
+ else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
4040
+ index = serializeLong(buffer, key, value, index);
4041
+ }
4042
+ else if (value._bsontype === 'Double') {
4043
+ index = serializeDouble(buffer, key, value, index);
4044
+ }
4045
+ else if (value._bsontype === 'Code') {
4046
+ index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
4047
+ }
4048
+ else if (value._bsontype === 'Binary') {
4049
+ index = serializeBinary(buffer, key, value, index);
4050
+ }
4051
+ else if (value._bsontype === 'BSONSymbol') {
4052
+ index = serializeSymbol(buffer, key, value, index);
4053
+ }
4054
+ else if (value._bsontype === 'DBRef') {
4055
+ index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
4056
+ }
4057
+ else if (value._bsontype === 'BSONRegExp') {
4058
+ index = serializeBSONRegExp(buffer, key, value, index);
4059
+ }
4060
+ else if (value._bsontype === 'Int32') {
4061
+ index = serializeInt32(buffer, key, value, index);
4062
+ }
4063
+ else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
4064
+ index = serializeMinMax(buffer, key, value, index);
4065
+ }
4066
+ else if (typeof value._bsontype !== 'undefined') {
4067
+ throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
4068
+ }
4069
+ }
4070
+ else if (type === 'function' && serializeFunctions) {
4071
+ index = serializeFunction(buffer, key, value, index);
4072
+ }
4073
+ }
4074
+ }
4075
+ else {
4076
+ if (typeof object?.toBSON === 'function') {
4077
+ object = object.toBSON();
4078
+ if (object != null && typeof object !== 'object') {
4079
+ throw new BSONError('toBSON function did not return an object');
4080
+ }
4081
+ }
4082
+ for (const key of Object.keys(object)) {
4083
+ let value = object[key];
4084
+ if (typeof value?.toBSON === 'function') {
4085
+ value = value.toBSON();
4086
+ }
4087
+ const type = typeof value;
4088
+ if (typeof key === 'string' && !ignoreKeys.has(key)) {
4089
+ if (key.match(regexp) != null) {
4090
+ throw new BSONError('key ' + key + ' must not contain null bytes');
4091
+ }
4092
+ if (checkKeys) {
4093
+ if ('$' === key[0]) {
4094
+ throw new BSONError('key ' + key + " must not start with '$'");
4095
+ }
4096
+ else if (key.includes('.')) {
4097
+ throw new BSONError('key ' + key + " must not contain '.'");
4098
+ }
4099
+ }
4100
+ }
4101
+ if (value === undefined) {
4102
+ if (ignoreUndefined === false)
4103
+ index = serializeNull(buffer, key, value, index);
4104
+ }
4105
+ else if (value === null) {
4106
+ index = serializeNull(buffer, key, value, index);
4107
+ }
4108
+ else if (type === 'string') {
4109
+ index = serializeString(buffer, key, value, index);
4110
+ }
4111
+ else if (type === 'number') {
4112
+ index = serializeNumber(buffer, key, value, index);
4113
+ }
4114
+ else if (type === 'bigint') {
4115
+ index = serializeBigInt(buffer, key, value, index);
4116
+ }
4117
+ else if (type === 'boolean') {
4118
+ index = serializeBoolean(buffer, key, value, index);
4119
+ }
4120
+ else if (type === 'object' && value._bsontype == null) {
4121
+ if (value instanceof Date || isDate(value)) {
4122
+ index = serializeDate(buffer, key, value, index);
4123
+ }
4124
+ else if (value instanceof Uint8Array || isUint8Array(value)) {
4125
+ index = serializeBuffer(buffer, key, value, index);
4126
+ }
4127
+ else if (value instanceof RegExp || isRegExp(value)) {
4128
+ index = serializeRegExp(buffer, key, value, index);
4129
+ }
4130
+ else {
4131
+ index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
4132
+ }
4133
+ }
4134
+ else if (type === 'object') {
4135
+ if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
4136
+ throw new BSONVersionError();
4137
+ }
4138
+ else if (value._bsontype === 'ObjectId') {
4139
+ index = serializeObjectId(buffer, key, value, index);
4140
+ }
4141
+ else if (value._bsontype === 'Decimal128') {
4142
+ index = serializeDecimal128(buffer, key, value, index);
4143
+ }
4144
+ else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
4145
+ index = serializeLong(buffer, key, value, index);
4146
+ }
4147
+ else if (value._bsontype === 'Double') {
4148
+ index = serializeDouble(buffer, key, value, index);
4149
+ }
4150
+ else if (value._bsontype === 'Code') {
4151
+ index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
4152
+ }
4153
+ else if (value._bsontype === 'Binary') {
4154
+ index = serializeBinary(buffer, key, value, index);
4155
+ }
4156
+ else if (value._bsontype === 'BSONSymbol') {
4157
+ index = serializeSymbol(buffer, key, value, index);
4158
+ }
4159
+ else if (value._bsontype === 'DBRef') {
4160
+ index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
4161
+ }
4162
+ else if (value._bsontype === 'BSONRegExp') {
4163
+ index = serializeBSONRegExp(buffer, key, value, index);
4164
+ }
4165
+ else if (value._bsontype === 'Int32') {
4166
+ index = serializeInt32(buffer, key, value, index);
4167
+ }
4168
+ else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
4169
+ index = serializeMinMax(buffer, key, value, index);
4170
+ }
4171
+ else if (typeof value._bsontype !== 'undefined') {
4172
+ throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
4173
+ }
4174
+ }
4175
+ else if (type === 'function' && serializeFunctions) {
4176
+ index = serializeFunction(buffer, key, value, index);
4177
+ }
4178
+ }
4179
+ }
4180
+ path.delete(object);
4181
+ buffer[index++] = 0x00;
4182
+ const size = index - startingIndex;
4183
+ startingIndex += NumberUtils.setInt32LE(buffer, startingIndex, size);
4184
+ return index;
4185
+ }
4186
+
4187
+ function isBSONType(value) {
4188
+ return (value != null &&
4189
+ typeof value === 'object' &&
4190
+ '_bsontype' in value &&
4191
+ typeof value._bsontype === 'string');
4192
+ }
4193
+ const keysToCodecs = {
4194
+ $oid: ObjectId,
4195
+ $binary: Binary,
4196
+ $uuid: Binary,
4197
+ $symbol: BSONSymbol,
4198
+ $numberInt: Int32,
4199
+ $numberDecimal: Decimal128,
4200
+ $numberDouble: Double,
4201
+ $numberLong: Long,
4202
+ $minKey: MinKey,
4203
+ $maxKey: MaxKey,
4204
+ $regex: BSONRegExp,
4205
+ $regularExpression: BSONRegExp,
4206
+ $timestamp: Timestamp
4207
+ };
4208
+ function deserializeValue(value, options = {}) {
4209
+ if (typeof value === 'number') {
4210
+ const in32BitRange = value <= BSON_INT32_MAX && value >= BSON_INT32_MIN;
4211
+ const in64BitRange = value <= BSON_INT64_MAX && value >= BSON_INT64_MIN;
4212
+ if (options.relaxed || options.legacy) {
4213
+ return value;
4214
+ }
4215
+ if (Number.isInteger(value) && !Object.is(value, -0)) {
4216
+ if (in32BitRange) {
4217
+ return new Int32(value);
4218
+ }
4219
+ if (in64BitRange) {
4220
+ if (options.useBigInt64) {
4221
+ return BigInt(value);
4222
+ }
4223
+ return Long.fromNumber(value);
4224
+ }
4225
+ }
4226
+ return new Double(value);
4227
+ }
4228
+ if (value == null || typeof value !== 'object')
4229
+ return value;
4230
+ if (value.$undefined)
4231
+ return null;
4232
+ const keys = Object.keys(value).filter(k => k.startsWith('$') && value[k] != null);
4233
+ for (let i = 0; i < keys.length; i++) {
4234
+ const c = keysToCodecs[keys[i]];
4235
+ if (c)
4236
+ return c.fromExtendedJSON(value, options);
4237
+ }
4238
+ if (value.$date != null) {
4239
+ const d = value.$date;
4240
+ const date = new Date();
4241
+ if (options.legacy) {
4242
+ if (typeof d === 'number')
4243
+ date.setTime(d);
4244
+ else if (typeof d === 'string')
4245
+ date.setTime(Date.parse(d));
4246
+ else if (typeof d === 'bigint')
4247
+ date.setTime(Number(d));
4248
+ else
4249
+ throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`);
4250
+ }
4251
+ else {
4252
+ if (typeof d === 'string')
4253
+ date.setTime(Date.parse(d));
4254
+ else if (Long.isLong(d))
4255
+ date.setTime(d.toNumber());
4256
+ else if (typeof d === 'number' && options.relaxed)
4257
+ date.setTime(d);
4258
+ else if (typeof d === 'bigint')
4259
+ date.setTime(Number(d));
4260
+ else
4261
+ throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`);
4262
+ }
4263
+ return date;
4264
+ }
4265
+ if (value.$code != null) {
4266
+ const copy = Object.assign({}, value);
4267
+ if (value.$scope) {
4268
+ copy.$scope = deserializeValue(value.$scope);
4269
+ }
4270
+ return Code.fromExtendedJSON(value);
4271
+ }
4272
+ if (isDBRefLike(value) || value.$dbPointer) {
4273
+ const v = value.$ref ? value : value.$dbPointer;
4274
+ if (v instanceof DBRef)
4275
+ return v;
4276
+ const dollarKeys = Object.keys(v).filter(k => k.startsWith('$'));
4277
+ let valid = true;
4278
+ dollarKeys.forEach(k => {
4279
+ if (['$ref', '$id', '$db'].indexOf(k) === -1)
4280
+ valid = false;
4281
+ });
4282
+ if (valid)
4283
+ return DBRef.fromExtendedJSON(v);
4284
+ }
4285
+ return value;
4286
+ }
4287
+ function serializeArray(array, options) {
4288
+ return array.map((v, index) => {
4289
+ options.seenObjects.push({ propertyName: `index ${index}`, obj: null });
4290
+ try {
4291
+ return serializeValue(v, options);
4292
+ }
4293
+ finally {
4294
+ options.seenObjects.pop();
4295
+ }
4296
+ });
4297
+ }
4298
+ function getISOString(date) {
4299
+ const isoStr = date.toISOString();
4300
+ return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z';
4301
+ }
4302
+ function serializeValue(value, options) {
4303
+ if (value instanceof Map || isMap(value)) {
4304
+ const obj = Object.create(null);
4305
+ for (const [k, v] of value) {
4306
+ if (typeof k !== 'string') {
4307
+ throw new BSONError('Can only serialize maps with string keys');
4308
+ }
4309
+ obj[k] = v;
4310
+ }
4311
+ return serializeValue(obj, options);
4312
+ }
4313
+ if ((typeof value === 'object' || typeof value === 'function') && value !== null) {
4314
+ const index = options.seenObjects.findIndex(entry => entry.obj === value);
4315
+ if (index !== -1) {
4316
+ const props = options.seenObjects.map(entry => entry.propertyName);
4317
+ const leadingPart = props
4318
+ .slice(0, index)
4319
+ .map(prop => `${prop} -> `)
4320
+ .join('');
4321
+ const alreadySeen = props[index];
4322
+ const circularPart = ' -> ' +
4323
+ props
4324
+ .slice(index + 1, props.length - 1)
4325
+ .map(prop => `${prop} -> `)
4326
+ .join('');
4327
+ const current = props[props.length - 1];
4328
+ const leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2);
4329
+ const dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1);
4330
+ throw new BSONError('Converting circular structure to EJSON:\n' +
4331
+ ` ${leadingPart}${alreadySeen}${circularPart}${current}\n` +
4332
+ ` ${leadingSpace}\\${dashes}/`);
4333
+ }
4334
+ options.seenObjects[options.seenObjects.length - 1].obj = value;
4335
+ }
4336
+ if (Array.isArray(value))
4337
+ return serializeArray(value, options);
4338
+ if (value === undefined)
4339
+ return options.ignoreUndefined ? undefined : null;
4340
+ if (value instanceof Date || isDate(value)) {
4341
+ const dateNum = value.getTime(), inRange = dateNum > -1 && dateNum < 253402318800000;
4342
+ if (options.legacy) {
4343
+ return options.relaxed && inRange
4344
+ ? { $date: value.getTime() }
4345
+ : { $date: getISOString(value) };
4346
+ }
4347
+ return options.relaxed && inRange
4348
+ ? { $date: getISOString(value) }
4349
+ : { $date: { $numberLong: value.getTime().toString() } };
4350
+ }
4351
+ if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) {
4352
+ if (Number.isInteger(value) && !Object.is(value, -0)) {
4353
+ if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
4354
+ return { $numberInt: value.toString() };
4355
+ }
4356
+ if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) {
4357
+ return { $numberLong: value.toString() };
4358
+ }
4359
+ }
4360
+ return { $numberDouble: Object.is(value, -0) ? '-0.0' : value.toString() };
4361
+ }
4362
+ if (typeof value === 'bigint') {
4363
+ if (!options.relaxed) {
4364
+ return { $numberLong: BigInt.asIntN(64, value).toString() };
4365
+ }
4366
+ return Number(BigInt.asIntN(64, value));
4367
+ }
4368
+ if (value instanceof RegExp || isRegExp(value)) {
4369
+ let flags = value.flags;
4370
+ if (flags === undefined) {
4371
+ const match = value.toString().match(/[gimuy]*$/);
4372
+ if (match) {
4373
+ flags = match[0];
4374
+ }
4375
+ }
4376
+ const rx = new BSONRegExp(value.source, flags);
4377
+ return rx.toExtendedJSON(options);
4378
+ }
4379
+ if (value != null && typeof value === 'object')
4380
+ return serializeDocument(value, options);
4381
+ return value;
4382
+ }
4383
+ const BSON_TYPE_MAPPINGS = {
4384
+ Binary: (o) => new Binary(o.value(), o.sub_type),
4385
+ Code: (o) => new Code(o.code, o.scope),
4386
+ DBRef: (o) => new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields),
4387
+ Decimal128: (o) => new Decimal128(o.bytes),
4388
+ Double: (o) => new Double(o.value),
4389
+ Int32: (o) => new Int32(o.value),
4390
+ Long: (o) => Long.fromBits(o.low != null ? o.low : o.low_, o.low != null ? o.high : o.high_, o.low != null ? o.unsigned : o.unsigned_),
4391
+ MaxKey: () => new MaxKey(),
4392
+ MinKey: () => new MinKey(),
4393
+ ObjectId: (o) => new ObjectId(o),
4394
+ BSONRegExp: (o) => new BSONRegExp(o.pattern, o.options),
4395
+ BSONSymbol: (o) => new BSONSymbol(o.value),
4396
+ Timestamp: (o) => Timestamp.fromBits(o.low, o.high)
4397
+ };
4398
+ function serializeDocument(doc, options) {
4399
+ if (doc == null || typeof doc !== 'object')
4400
+ throw new BSONError('not an object instance');
4401
+ const bsontype = doc._bsontype;
4402
+ if (typeof bsontype === 'undefined') {
4403
+ const _doc = {};
4404
+ for (const name of Object.keys(doc)) {
4405
+ options.seenObjects.push({ propertyName: name, obj: null });
4406
+ try {
4407
+ const value = serializeValue(doc[name], options);
4408
+ if (name === '__proto__') {
4409
+ Object.defineProperty(_doc, name, {
4410
+ value,
4411
+ writable: true,
4412
+ enumerable: true,
4413
+ configurable: true
4414
+ });
4415
+ }
4416
+ else {
4417
+ _doc[name] = value;
4418
+ }
4419
+ }
4420
+ finally {
4421
+ options.seenObjects.pop();
4422
+ }
4423
+ }
4424
+ return _doc;
4425
+ }
4426
+ else if (doc != null &&
4427
+ typeof doc === 'object' &&
4428
+ typeof doc._bsontype === 'string' &&
4429
+ doc[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
4430
+ throw new BSONVersionError();
4431
+ }
4432
+ else if (isBSONType(doc)) {
4433
+ let outDoc = doc;
4434
+ if (typeof outDoc.toExtendedJSON !== 'function') {
4435
+ const mapper = BSON_TYPE_MAPPINGS[doc._bsontype];
4436
+ if (!mapper) {
4437
+ throw new BSONError('Unrecognized or invalid _bsontype: ' + doc._bsontype);
4438
+ }
4439
+ outDoc = mapper(outDoc);
4440
+ }
4441
+ if (bsontype === 'Code' && outDoc.scope) {
4442
+ outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options));
4443
+ }
4444
+ else if (bsontype === 'DBRef' && outDoc.oid) {
4445
+ outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options));
4446
+ }
4447
+ return outDoc.toExtendedJSON(options);
4448
+ }
4449
+ else {
4450
+ throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype);
4451
+ }
4452
+ }
4453
+ function parse(text, options) {
4454
+ const ejsonOptions = {
4455
+ useBigInt64: options?.useBigInt64 ?? false,
4456
+ relaxed: options?.relaxed ?? true,
4457
+ legacy: options?.legacy ?? false
4458
+ };
4459
+ return JSON.parse(text, (key, value) => {
4460
+ if (key.indexOf('\x00') !== -1) {
4461
+ throw new BSONError(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(key)}`);
4462
+ }
4463
+ return deserializeValue(value, ejsonOptions);
4464
+ });
4465
+ }
4466
+ function stringify(value, replacer, space, options) {
4467
+ if (space != null && typeof space === 'object') {
4468
+ options = space;
4469
+ space = 0;
4470
+ }
4471
+ if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) {
4472
+ options = replacer;
4473
+ replacer = undefined;
4474
+ space = 0;
4475
+ }
4476
+ const serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, {
4477
+ seenObjects: [{ propertyName: '(root)', obj: null }]
4478
+ });
4479
+ const doc = serializeValue(value, serializeOptions);
4480
+ return JSON.stringify(doc, replacer, space);
4481
+ }
4482
+ function EJSONserialize(value, options) {
4483
+ options = options || {};
4484
+ return JSON.parse(stringify(value, options));
4485
+ }
4486
+ function EJSONdeserialize(ejson, options) {
4487
+ options = options || {};
4488
+ return parse(JSON.stringify(ejson), options);
4489
+ }
4490
+ const EJSON = Object.create(null);
4491
+ EJSON.parse = parse;
4492
+ EJSON.stringify = stringify;
4493
+ EJSON.serialize = EJSONserialize;
4494
+ EJSON.deserialize = EJSONdeserialize;
4495
+ Object.freeze(EJSON);
4496
+
4497
+ const BSONElementType = {
4498
+ double: 1,
4499
+ string: 2,
4500
+ object: 3,
4501
+ array: 4,
4502
+ binData: 5,
4503
+ undefined: 6,
4504
+ objectId: 7,
4505
+ bool: 8,
4506
+ date: 9,
4507
+ null: 10,
4508
+ regex: 11,
4509
+ dbPointer: 12,
4510
+ javascript: 13,
4511
+ symbol: 14,
4512
+ javascriptWithScope: 15,
4513
+ int: 16,
4514
+ timestamp: 17,
4515
+ long: 18,
4516
+ decimal: 19,
4517
+ minKey: 255,
4518
+ maxKey: 127
4519
+ };
4520
+ function getSize(source, offset) {
4521
+ try {
4522
+ return NumberUtils.getNonnegativeInt32LE(source, offset);
4523
+ }
4524
+ catch (cause) {
4525
+ throw new BSONOffsetError('BSON size cannot be negative', offset, { cause });
4526
+ }
4527
+ }
4528
+ function findNull(bytes, offset) {
4529
+ let nullTerminatorOffset = offset;
4530
+ for (; bytes[nullTerminatorOffset] !== 0x00; nullTerminatorOffset++)
4531
+ ;
4532
+ if (nullTerminatorOffset === bytes.length - 1) {
4533
+ throw new BSONOffsetError('Null terminator not found', offset);
4534
+ }
4535
+ return nullTerminatorOffset;
4536
+ }
4537
+ function parseToElements(bytes, startOffset = 0) {
4538
+ startOffset ??= 0;
4539
+ if (bytes.length < 5) {
4540
+ throw new BSONOffsetError(`Input must be at least 5 bytes, got ${bytes.length} bytes`, startOffset);
4541
+ }
4542
+ const documentSize = getSize(bytes, startOffset);
4543
+ if (documentSize > bytes.length - startOffset) {
4544
+ throw new BSONOffsetError(`Parsed documentSize (${documentSize} bytes) does not match input length (${bytes.length} bytes)`, startOffset);
4545
+ }
4546
+ if (bytes[startOffset + documentSize - 1] !== 0x00) {
4547
+ throw new BSONOffsetError('BSON documents must end in 0x00', startOffset + documentSize);
4548
+ }
4549
+ const elements = [];
4550
+ let offset = startOffset + 4;
4551
+ while (offset <= documentSize + startOffset) {
4552
+ const type = bytes[offset];
4553
+ offset += 1;
4554
+ if (type === 0) {
4555
+ if (offset - startOffset !== documentSize) {
4556
+ throw new BSONOffsetError(`Invalid 0x00 type byte`, offset);
4557
+ }
4558
+ break;
4559
+ }
4560
+ const nameOffset = offset;
4561
+ const nameLength = findNull(bytes, offset) - nameOffset;
4562
+ offset += nameLength + 1;
4563
+ let length;
4564
+ if (type === BSONElementType.double ||
4565
+ type === BSONElementType.long ||
4566
+ type === BSONElementType.date ||
4567
+ type === BSONElementType.timestamp) {
4568
+ length = 8;
4569
+ }
4570
+ else if (type === BSONElementType.int) {
4571
+ length = 4;
4572
+ }
4573
+ else if (type === BSONElementType.objectId) {
4574
+ length = 12;
4575
+ }
4576
+ else if (type === BSONElementType.decimal) {
4577
+ length = 16;
4578
+ }
4579
+ else if (type === BSONElementType.bool) {
4580
+ length = 1;
4581
+ }
4582
+ else if (type === BSONElementType.null ||
4583
+ type === BSONElementType.undefined ||
4584
+ type === BSONElementType.maxKey ||
4585
+ type === BSONElementType.minKey) {
4586
+ length = 0;
4587
+ }
4588
+ else if (type === BSONElementType.regex) {
4589
+ length = findNull(bytes, findNull(bytes, offset) + 1) + 1 - offset;
4590
+ }
4591
+ else if (type === BSONElementType.object ||
4592
+ type === BSONElementType.array ||
4593
+ type === BSONElementType.javascriptWithScope) {
4594
+ length = getSize(bytes, offset);
4595
+ }
4596
+ else if (type === BSONElementType.string ||
4597
+ type === BSONElementType.binData ||
4598
+ type === BSONElementType.dbPointer ||
4599
+ type === BSONElementType.javascript ||
4600
+ type === BSONElementType.symbol) {
4601
+ length = getSize(bytes, offset) + 4;
4602
+ if (type === BSONElementType.binData) {
4603
+ length += 1;
4604
+ }
4605
+ if (type === BSONElementType.dbPointer) {
4606
+ length += 12;
4607
+ }
4608
+ }
4609
+ else {
4610
+ throw new BSONOffsetError(`Invalid 0x${type.toString(16).padStart(2, '0')} type byte`, offset);
4611
+ }
4612
+ if (length > documentSize) {
4613
+ throw new BSONOffsetError('value reports length larger than document', offset);
4614
+ }
4615
+ elements.push([type, nameOffset, nameLength, offset, length]);
4616
+ offset += length;
4617
+ }
4618
+ return elements;
4619
+ }
4620
+
4621
+ const onDemand = Object.create(null);
4622
+ onDemand.parseToElements = parseToElements;
4623
+ onDemand.ByteUtils = ByteUtils;
4624
+ onDemand.NumberUtils = NumberUtils;
4625
+ Object.freeze(onDemand);
4626
+
4627
+ const MAXSIZE = 1024 * 1024 * 17;
4628
+ let buffer = ByteUtils.allocate(MAXSIZE);
4629
+ function setInternalBufferSize(size) {
4630
+ if (buffer.length < size) {
4631
+ buffer = ByteUtils.allocate(size);
4632
+ }
4633
+ }
4634
+ function serialize(object, options = {}) {
4635
+ const checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
4636
+ const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
4637
+ const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
4638
+ const minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
4639
+ if (buffer.length < minInternalBufferSize) {
4640
+ buffer = ByteUtils.allocate(minInternalBufferSize);
4641
+ }
4642
+ const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
4643
+ const finishedBuffer = ByteUtils.allocateUnsafe(serializationIndex);
4644
+ finishedBuffer.set(buffer.subarray(0, serializationIndex), 0);
4645
+ return finishedBuffer;
4646
+ }
4647
+ function serializeWithBufferAndIndex(object, finalBuffer, options = {}) {
4648
+ const checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
4649
+ const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
4650
+ const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
4651
+ const startIndex = typeof options.index === 'number' ? options.index : 0;
4652
+ const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
4653
+ finalBuffer.set(buffer.subarray(0, serializationIndex), startIndex);
4654
+ return startIndex + serializationIndex - 1;
4655
+ }
4656
+ function deserialize(buffer, options = {}) {
4657
+ return internalDeserialize(ByteUtils.toLocalBufferType(buffer), options);
4658
+ }
4659
+ function calculateObjectSize(object, options = {}) {
4660
+ options = options || {};
4661
+ const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
4662
+ const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
4663
+ return internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined);
4664
+ }
4665
+ function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
4666
+ const internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
4667
+ const bufferData = ByteUtils.toLocalBufferType(data);
4668
+ let index = startIndex;
4669
+ for (let i = 0; i < numberOfDocuments; i++) {
4670
+ const size = NumberUtils.getInt32LE(bufferData, index);
4671
+ internalOptions.index = index;
4672
+ documents[docStartIndex + i] = internalDeserialize(bufferData, internalOptions);
4673
+ index = index + size;
4674
+ }
4675
+ return index;
4676
+ }
4677
+
4678
+ var bson = /*#__PURE__*/Object.freeze({
4679
+ __proto__: null,
4680
+ BSONError: BSONError,
4681
+ BSONOffsetError: BSONOffsetError,
4682
+ BSONRegExp: BSONRegExp,
4683
+ BSONRuntimeError: BSONRuntimeError,
4684
+ BSONSymbol: BSONSymbol,
4685
+ BSONType: BSONType,
4686
+ BSONValue: BSONValue,
4687
+ BSONVersionError: BSONVersionError,
4688
+ Binary: Binary,
4689
+ ByteUtils: ByteUtils,
4690
+ Code: Code,
4691
+ DBRef: DBRef,
4692
+ Decimal128: Decimal128,
4693
+ Double: Double,
4694
+ EJSON: EJSON,
4695
+ Int32: Int32,
4696
+ Long: Long,
4697
+ MaxKey: MaxKey,
4698
+ MinKey: MinKey,
4699
+ NumberUtils: NumberUtils,
4700
+ ObjectId: ObjectId,
4701
+ Timestamp: Timestamp,
4702
+ UUID: UUID,
4703
+ bsonType: bsonType,
4704
+ calculateObjectSize: calculateObjectSize,
4705
+ deserialize: deserialize,
4706
+ deserializeStream: deserializeStream,
4707
+ onDemand: onDemand,
4708
+ serialize: serialize,
4709
+ serializeWithBufferAndIndex: serializeWithBufferAndIndex,
4710
+ setInternalBufferSize: setInternalBufferSize
4711
+ });
4712
+
4713
+ exports.BSON = bson;
4714
+ exports.BSONError = BSONError;
4715
+ exports.BSONOffsetError = BSONOffsetError;
4716
+ exports.BSONRegExp = BSONRegExp;
4717
+ exports.BSONRuntimeError = BSONRuntimeError;
4718
+ exports.BSONSymbol = BSONSymbol;
4719
+ exports.BSONType = BSONType;
4720
+ exports.BSONValue = BSONValue;
4721
+ exports.BSONVersionError = BSONVersionError;
4722
+ exports.Binary = Binary;
4723
+ exports.ByteUtils = ByteUtils;
4724
+ exports.Code = Code;
4725
+ exports.DBRef = DBRef;
4726
+ exports.Decimal128 = Decimal128;
4727
+ exports.Double = Double;
4728
+ exports.EJSON = EJSON;
4729
+ exports.Int32 = Int32;
4730
+ exports.Long = Long;
4731
+ exports.MaxKey = MaxKey;
4732
+ exports.MinKey = MinKey;
4733
+ exports.NumberUtils = NumberUtils;
4734
+ exports.ObjectId = ObjectId;
4735
+ exports.Timestamp = Timestamp;
4736
+ exports.UUID = UUID;
4737
+ exports.bsonType = bsonType;
4738
+ exports.calculateObjectSize = calculateObjectSize;
4739
+ exports.deserialize = deserialize;
4740
+ exports.deserializeStream = deserializeStream;
4741
+ exports.onDemand = onDemand;
4742
+ exports.serialize = serialize;
4743
+ exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
4744
+ exports.setInternalBufferSize = setInternalBufferSize;
4745
+ //# sourceMappingURL=bson.cjs.map