create-mern-omar 1.1.0 → 1.2.0

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