create-exam-cli 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -3
- package/package.json +2 -2
- package/templates/backend/.env +2 -0
- package/templates/backend/node_modules/.bin/bcrypt +16 -0
- package/templates/backend/node_modules/.bin/bcrypt.cmd +17 -0
- package/templates/backend/node_modules/.bin/bcrypt.ps1 +28 -0
- package/templates/backend/node_modules/.bin/nodemon +16 -0
- package/templates/backend/node_modules/.bin/nodemon.cmd +17 -0
- package/templates/backend/node_modules/.bin/nodemon.ps1 +28 -0
- package/templates/backend/node_modules/.bin/nodetouch +16 -0
- package/templates/backend/node_modules/.bin/nodetouch.cmd +17 -0
- package/templates/backend/node_modules/.bin/nodetouch.ps1 +28 -0
- package/templates/backend/node_modules/.bin/semver +16 -0
- package/templates/backend/node_modules/.bin/semver.cmd +17 -0
- package/templates/backend/node_modules/.bin/semver.ps1 +28 -0
- package/templates/backend/node_modules/.package-lock.json +1515 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/LICENSE +22 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/.esm-wrapper.mjs +4 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.d.ts +5 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.js +12 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/browser.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts +3 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js +5 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data-browser.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts +3 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.js +5 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-data.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts +7 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.js +881 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/code-points-src.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts +2 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js +83 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/generate-code-points.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.d.ts +11 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.js +65 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/index.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts +10 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js +32 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/memory-code-points.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.d.ts +10 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.js +15 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/node.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.d.ts +2 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.d.ts.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.js +11 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/dist/util.js.map +1 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/package.json +87 -0
- package/templates/backend/node_modules/@mongodb-js/saslprep/readme.md +29 -0
- package/templates/backend/node_modules/@types/webidl-conversions/LICENSE +21 -0
- package/templates/backend/node_modules/@types/webidl-conversions/README.md +15 -0
- package/templates/backend/node_modules/@types/webidl-conversions/index.d.ts +91 -0
- package/templates/backend/node_modules/@types/webidl-conversions/package.json +30 -0
- package/templates/backend/node_modules/@types/whatwg-url/LICENSE +21 -0
- package/templates/backend/node_modules/@types/whatwg-url/README.md +15 -0
- package/templates/backend/node_modules/@types/whatwg-url/index.d.ts +172 -0
- package/templates/backend/node_modules/@types/whatwg-url/lib/URL-impl.d.ts +22 -0
- package/templates/backend/node_modules/@types/whatwg-url/lib/URL.d.ts +66 -0
- package/templates/backend/node_modules/@types/whatwg-url/lib/URLSearchParams-impl.d.ts +20 -0
- package/templates/backend/node_modules/@types/whatwg-url/lib/URLSearchParams.d.ts +92 -0
- package/templates/backend/node_modules/@types/whatwg-url/package.json +38 -0
- package/templates/backend/node_modules/@types/whatwg-url/webidl2js-wrapper.d.ts +4 -0
- package/templates/backend/node_modules/accepts/HISTORY.md +250 -0
- package/templates/backend/node_modules/accepts/LICENSE +23 -0
- package/templates/backend/node_modules/accepts/README.md +140 -0
- package/templates/backend/node_modules/accepts/index.js +238 -0
- package/templates/backend/node_modules/accepts/package.json +47 -0
- package/templates/backend/node_modules/anymatch/LICENSE +15 -0
- package/templates/backend/node_modules/anymatch/README.md +87 -0
- package/templates/backend/node_modules/anymatch/index.d.ts +20 -0
- package/templates/backend/node_modules/anymatch/index.js +104 -0
- package/templates/backend/node_modules/anymatch/package.json +48 -0
- package/templates/backend/node_modules/balanced-match/LICENSE.md +23 -0
- package/templates/backend/node_modules/balanced-match/README.md +57 -0
- package/templates/backend/node_modules/balanced-match/dist/commonjs/index.d.ts +9 -0
- package/templates/backend/node_modules/balanced-match/dist/commonjs/index.d.ts.map +1 -0
- package/templates/backend/node_modules/balanced-match/dist/commonjs/index.js +59 -0
- package/templates/backend/node_modules/balanced-match/dist/commonjs/index.js.map +1 -0
- package/templates/backend/node_modules/balanced-match/dist/commonjs/package.json +3 -0
- package/templates/backend/node_modules/balanced-match/dist/esm/index.d.ts +9 -0
- package/templates/backend/node_modules/balanced-match/dist/esm/index.d.ts.map +1 -0
- package/templates/backend/node_modules/balanced-match/dist/esm/index.js +54 -0
- package/templates/backend/node_modules/balanced-match/dist/esm/index.js.map +1 -0
- package/templates/backend/node_modules/balanced-match/dist/esm/package.json +3 -0
- package/templates/backend/node_modules/balanced-match/package.json +68 -0
- package/templates/backend/node_modules/bcryptjs/LICENSE +27 -0
- package/templates/backend/node_modules/bcryptjs/README.md +201 -0
- package/templates/backend/node_modules/bcryptjs/bin/bcrypt +23 -0
- package/templates/backend/node_modules/bcryptjs/index.d.ts +3 -0
- package/templates/backend/node_modules/bcryptjs/index.js +1159 -0
- package/templates/backend/node_modules/bcryptjs/package.json +76 -0
- package/templates/backend/node_modules/bcryptjs/types.d.ts +157 -0
- package/templates/backend/node_modules/bcryptjs/umd/index.d.ts +3 -0
- package/templates/backend/node_modules/bcryptjs/umd/index.js +1220 -0
- package/templates/backend/node_modules/bcryptjs/umd/package.json +3 -0
- package/templates/backend/node_modules/bcryptjs/umd/types.d.ts +157 -0
- package/templates/backend/node_modules/binary-extensions/binary-extensions.json +263 -0
- package/templates/backend/node_modules/binary-extensions/binary-extensions.json.d.ts +3 -0
- package/templates/backend/node_modules/binary-extensions/index.d.ts +14 -0
- package/templates/backend/node_modules/binary-extensions/index.js +1 -0
- package/templates/backend/node_modules/binary-extensions/license +10 -0
- package/templates/backend/node_modules/binary-extensions/package.json +40 -0
- package/templates/backend/node_modules/binary-extensions/readme.md +25 -0
- package/templates/backend/node_modules/body-parser/LICENSE +23 -0
- package/templates/backend/node_modules/body-parser/README.md +494 -0
- package/templates/backend/node_modules/body-parser/index.js +71 -0
- package/templates/backend/node_modules/body-parser/lib/read.js +247 -0
- package/templates/backend/node_modules/body-parser/lib/types/json.js +158 -0
- package/templates/backend/node_modules/body-parser/lib/types/raw.js +42 -0
- package/templates/backend/node_modules/body-parser/lib/types/text.js +36 -0
- package/templates/backend/node_modules/body-parser/lib/types/urlencoded.js +142 -0
- package/templates/backend/node_modules/body-parser/lib/utils.js +98 -0
- package/templates/backend/node_modules/body-parser/package.json +52 -0
- package/templates/backend/node_modules/brace-expansion/LICENSE +23 -0
- package/templates/backend/node_modules/brace-expansion/README.md +94 -0
- package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.d.ts +6 -0
- package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
- package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.js +201 -0
- package/templates/backend/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
- package/templates/backend/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
- package/templates/backend/node_modules/brace-expansion/dist/esm/index.d.ts +6 -0
- package/templates/backend/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
- package/templates/backend/node_modules/brace-expansion/dist/esm/index.js +197 -0
- package/templates/backend/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
- package/templates/backend/node_modules/brace-expansion/dist/esm/package.json +3 -0
- package/templates/backend/node_modules/brace-expansion/package.json +64 -0
- package/templates/backend/node_modules/braces/LICENSE +21 -0
- package/templates/backend/node_modules/braces/README.md +586 -0
- package/templates/backend/node_modules/braces/index.js +170 -0
- package/templates/backend/node_modules/braces/lib/compile.js +60 -0
- package/templates/backend/node_modules/braces/lib/constants.js +57 -0
- package/templates/backend/node_modules/braces/lib/expand.js +113 -0
- package/templates/backend/node_modules/braces/lib/parse.js +331 -0
- package/templates/backend/node_modules/braces/lib/stringify.js +32 -0
- package/templates/backend/node_modules/braces/lib/utils.js +122 -0
- package/templates/backend/node_modules/braces/package.json +77 -0
- package/templates/backend/node_modules/bson/LICENSE.md +201 -0
- package/templates/backend/node_modules/bson/README.md +291 -0
- package/templates/backend/node_modules/bson/bson.d.ts +1770 -0
- package/templates/backend/node_modules/bson/etc/prepare.js +19 -0
- package/templates/backend/node_modules/bson/lib/bson.bundle.js +4750 -0
- package/templates/backend/node_modules/bson/lib/bson.bundle.js.map +1 -0
- package/templates/backend/node_modules/bson/lib/bson.cjs +4745 -0
- package/templates/backend/node_modules/bson/lib/bson.cjs.map +1 -0
- package/templates/backend/node_modules/bson/lib/bson.mjs +4712 -0
- package/templates/backend/node_modules/bson/lib/bson.mjs.map +1 -0
- package/templates/backend/node_modules/bson/lib/bson.node.mjs +4712 -0
- package/templates/backend/node_modules/bson/lib/bson.node.mjs.map +1 -0
- package/templates/backend/node_modules/bson/lib/bson.rn.cjs +4755 -0
- package/templates/backend/node_modules/bson/lib/bson.rn.cjs.map +1 -0
- package/templates/backend/node_modules/bson/package.json +118 -0
- package/templates/backend/node_modules/bson/src/binary.ts +751 -0
- package/templates/backend/node_modules/bson/src/bson.ts +255 -0
- package/templates/backend/node_modules/bson/src/bson_value.ts +55 -0
- package/templates/backend/node_modules/bson/src/code.ts +69 -0
- package/templates/backend/node_modules/bson/src/constants.ts +147 -0
- package/templates/backend/node_modules/bson/src/db_ref.ts +128 -0
- package/templates/backend/node_modules/bson/src/decimal128.ts +855 -0
- package/templates/backend/node_modules/bson/src/double.ts +115 -0
- package/templates/backend/node_modules/bson/src/error.ts +105 -0
- package/templates/backend/node_modules/bson/src/extended_json.ts +533 -0
- package/templates/backend/node_modules/bson/src/index.ts +19 -0
- package/templates/backend/node_modules/bson/src/int_32.ts +101 -0
- package/templates/backend/node_modules/bson/src/long.ts +1240 -0
- package/templates/backend/node_modules/bson/src/max_key.ts +31 -0
- package/templates/backend/node_modules/bson/src/min_key.ts +31 -0
- package/templates/backend/node_modules/bson/src/objectid.ts +382 -0
- package/templates/backend/node_modules/bson/src/parse_utf8.ts +35 -0
- package/templates/backend/node_modules/bson/src/parser/calculate_size.ts +218 -0
- package/templates/backend/node_modules/bson/src/parser/deserializer.ts +627 -0
- package/templates/backend/node_modules/bson/src/parser/on_demand/index.ts +32 -0
- package/templates/backend/node_modules/bson/src/parser/on_demand/parse_to_elements.ts +190 -0
- package/templates/backend/node_modules/bson/src/parser/serializer.ts +954 -0
- package/templates/backend/node_modules/bson/src/parser/utils.ts +69 -0
- package/templates/backend/node_modules/bson/src/regexp.ts +114 -0
- package/templates/backend/node_modules/bson/src/symbol.ts +55 -0
- package/templates/backend/node_modules/bson/src/timestamp.ts +176 -0
- package/templates/backend/node_modules/bson/src/utils/byte_utils.ts +80 -0
- package/templates/backend/node_modules/bson/src/utils/latin.ts +104 -0
- package/templates/backend/node_modules/bson/src/utils/node_byte_utils.ts +193 -0
- package/templates/backend/node_modules/bson/src/utils/number_utils.ts +204 -0
- package/templates/backend/node_modules/bson/src/utils/string_utils.ts +44 -0
- package/templates/backend/node_modules/bson/src/utils/web_byte_utils.ts +304 -0
- package/templates/backend/node_modules/buffer-equal-constant-time/.travis.yml +4 -0
- package/templates/backend/node_modules/buffer-equal-constant-time/LICENSE.txt +12 -0
- package/templates/backend/node_modules/buffer-equal-constant-time/README.md +50 -0
- package/templates/backend/node_modules/buffer-equal-constant-time/index.js +41 -0
- package/templates/backend/node_modules/buffer-equal-constant-time/package.json +21 -0
- package/templates/backend/node_modules/buffer-equal-constant-time/test.js +42 -0
- package/templates/backend/node_modules/bytes/History.md +97 -0
- package/templates/backend/node_modules/bytes/LICENSE +23 -0
- package/templates/backend/node_modules/bytes/Readme.md +152 -0
- package/templates/backend/node_modules/bytes/index.js +170 -0
- package/templates/backend/node_modules/bytes/package.json +42 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/.eslintrc +17 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/.nycrc +9 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/CHANGELOG.md +30 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/LICENSE +21 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/README.md +62 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/actualApply.d.ts +1 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/actualApply.js +10 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/applyBind.d.ts +19 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/applyBind.js +10 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/functionApply.d.ts +1 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/functionApply.js +4 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/functionCall.d.ts +1 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/functionCall.js +4 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/index.d.ts +64 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/index.js +15 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/package.json +85 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/reflectApply.d.ts +3 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/reflectApply.js +4 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/test/index.js +63 -0
- package/templates/backend/node_modules/call-bind-apply-helpers/tsconfig.json +9 -0
- package/templates/backend/node_modules/call-bound/.eslintrc +13 -0
- package/templates/backend/node_modules/call-bound/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/call-bound/.nycrc +9 -0
- package/templates/backend/node_modules/call-bound/CHANGELOG.md +42 -0
- package/templates/backend/node_modules/call-bound/LICENSE +21 -0
- package/templates/backend/node_modules/call-bound/README.md +53 -0
- package/templates/backend/node_modules/call-bound/index.d.ts +94 -0
- package/templates/backend/node_modules/call-bound/index.js +19 -0
- package/templates/backend/node_modules/call-bound/package.json +99 -0
- package/templates/backend/node_modules/call-bound/test/index.js +61 -0
- package/templates/backend/node_modules/call-bound/tsconfig.json +10 -0
- package/templates/backend/node_modules/chokidar/LICENSE +21 -0
- package/templates/backend/node_modules/chokidar/README.md +308 -0
- package/templates/backend/node_modules/chokidar/index.js +973 -0
- package/templates/backend/node_modules/chokidar/lib/constants.js +66 -0
- package/templates/backend/node_modules/chokidar/lib/fsevents-handler.js +526 -0
- package/templates/backend/node_modules/chokidar/lib/nodefs-handler.js +654 -0
- package/templates/backend/node_modules/chokidar/package.json +70 -0
- package/templates/backend/node_modules/chokidar/types/index.d.ts +192 -0
- package/templates/backend/node_modules/content-disposition/LICENSE +22 -0
- package/templates/backend/node_modules/content-disposition/README.md +141 -0
- package/templates/backend/node_modules/content-disposition/index.js +536 -0
- package/templates/backend/node_modules/content-disposition/package.json +40 -0
- package/templates/backend/node_modules/content-type/HISTORY.md +29 -0
- package/templates/backend/node_modules/content-type/LICENSE +22 -0
- package/templates/backend/node_modules/content-type/README.md +94 -0
- package/templates/backend/node_modules/content-type/index.js +225 -0
- package/templates/backend/node_modules/content-type/package.json +42 -0
- package/templates/backend/node_modules/cookie/LICENSE +24 -0
- package/templates/backend/node_modules/cookie/README.md +317 -0
- package/templates/backend/node_modules/cookie/SECURITY.md +25 -0
- package/templates/backend/node_modules/cookie/index.js +335 -0
- package/templates/backend/node_modules/cookie/package.json +44 -0
- package/templates/backend/node_modules/cookie-signature/History.md +70 -0
- package/templates/backend/node_modules/cookie-signature/LICENSE +22 -0
- package/templates/backend/node_modules/cookie-signature/Readme.md +23 -0
- package/templates/backend/node_modules/cookie-signature/index.js +47 -0
- package/templates/backend/node_modules/cookie-signature/package.json +24 -0
- package/templates/backend/node_modules/cors/LICENSE +22 -0
- package/templates/backend/node_modules/cors/README.md +277 -0
- package/templates/backend/node_modules/cors/lib/index.js +238 -0
- package/templates/backend/node_modules/cors/package.json +42 -0
- package/templates/backend/node_modules/debug/LICENSE +20 -0
- package/templates/backend/node_modules/debug/README.md +481 -0
- package/templates/backend/node_modules/debug/package.json +64 -0
- package/templates/backend/node_modules/debug/src/browser.js +272 -0
- package/templates/backend/node_modules/debug/src/common.js +292 -0
- package/templates/backend/node_modules/debug/src/index.js +10 -0
- package/templates/backend/node_modules/debug/src/node.js +263 -0
- package/templates/backend/node_modules/depd/History.md +103 -0
- package/templates/backend/node_modules/depd/LICENSE +22 -0
- package/templates/backend/node_modules/depd/Readme.md +280 -0
- package/templates/backend/node_modules/depd/index.js +538 -0
- package/templates/backend/node_modules/depd/lib/browser/index.js +77 -0
- package/templates/backend/node_modules/depd/package.json +45 -0
- package/templates/backend/node_modules/dotenv/CHANGELOG.md +643 -0
- package/templates/backend/node_modules/dotenv/LICENSE +23 -0
- package/templates/backend/node_modules/dotenv/README-es.md +757 -0
- package/templates/backend/node_modules/dotenv/README.md +812 -0
- package/templates/backend/node_modules/dotenv/SECURITY.md +1 -0
- package/templates/backend/node_modules/dotenv/config.d.ts +1 -0
- package/templates/backend/node_modules/dotenv/config.js +9 -0
- package/templates/backend/node_modules/dotenv/lib/cli-options.js +17 -0
- package/templates/backend/node_modules/dotenv/lib/env-options.js +28 -0
- package/templates/backend/node_modules/dotenv/lib/main.d.ts +179 -0
- package/templates/backend/node_modules/dotenv/lib/main.js +423 -0
- package/templates/backend/node_modules/dotenv/package.json +62 -0
- package/templates/backend/node_modules/dotenv/skills/dotenv/SKILL.md +200 -0
- package/templates/backend/node_modules/dotenv/skills/dotenvx/SKILL.md +118 -0
- package/templates/backend/node_modules/dunder-proto/.eslintrc +5 -0
- package/templates/backend/node_modules/dunder-proto/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/dunder-proto/.nycrc +13 -0
- package/templates/backend/node_modules/dunder-proto/CHANGELOG.md +24 -0
- package/templates/backend/node_modules/dunder-proto/LICENSE +21 -0
- package/templates/backend/node_modules/dunder-proto/README.md +54 -0
- package/templates/backend/node_modules/dunder-proto/get.d.ts +5 -0
- package/templates/backend/node_modules/dunder-proto/get.js +30 -0
- package/templates/backend/node_modules/dunder-proto/package.json +76 -0
- package/templates/backend/node_modules/dunder-proto/set.d.ts +5 -0
- package/templates/backend/node_modules/dunder-proto/set.js +35 -0
- package/templates/backend/node_modules/dunder-proto/test/get.js +34 -0
- package/templates/backend/node_modules/dunder-proto/test/index.js +4 -0
- package/templates/backend/node_modules/dunder-proto/test/set.js +50 -0
- package/templates/backend/node_modules/dunder-proto/tsconfig.json +9 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/CODEOWNERS +1 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/LICENSE +201 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/README.md +65 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/package.json +46 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.d.ts +17 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js +187 -0
- package/templates/backend/node_modules/ecdsa-sig-formatter/src/param-bytes-for-alg.js +23 -0
- package/templates/backend/node_modules/ee-first/LICENSE +22 -0
- package/templates/backend/node_modules/ee-first/README.md +80 -0
- package/templates/backend/node_modules/ee-first/index.js +95 -0
- package/templates/backend/node_modules/ee-first/package.json +29 -0
- package/templates/backend/node_modules/encodeurl/LICENSE +22 -0
- package/templates/backend/node_modules/encodeurl/README.md +109 -0
- package/templates/backend/node_modules/encodeurl/index.js +60 -0
- package/templates/backend/node_modules/encodeurl/package.json +40 -0
- package/templates/backend/node_modules/es-define-property/.eslintrc +13 -0
- package/templates/backend/node_modules/es-define-property/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/es-define-property/.nycrc +9 -0
- package/templates/backend/node_modules/es-define-property/CHANGELOG.md +29 -0
- package/templates/backend/node_modules/es-define-property/LICENSE +21 -0
- package/templates/backend/node_modules/es-define-property/README.md +49 -0
- package/templates/backend/node_modules/es-define-property/index.d.ts +3 -0
- package/templates/backend/node_modules/es-define-property/index.js +14 -0
- package/templates/backend/node_modules/es-define-property/package.json +81 -0
- package/templates/backend/node_modules/es-define-property/test/index.js +56 -0
- package/templates/backend/node_modules/es-define-property/tsconfig.json +10 -0
- package/templates/backend/node_modules/es-errors/.eslintrc +5 -0
- package/templates/backend/node_modules/es-errors/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/es-errors/CHANGELOG.md +40 -0
- package/templates/backend/node_modules/es-errors/LICENSE +21 -0
- package/templates/backend/node_modules/es-errors/README.md +55 -0
- package/templates/backend/node_modules/es-errors/eval.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/eval.js +4 -0
- package/templates/backend/node_modules/es-errors/index.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/index.js +4 -0
- package/templates/backend/node_modules/es-errors/package.json +80 -0
- package/templates/backend/node_modules/es-errors/range.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/range.js +4 -0
- package/templates/backend/node_modules/es-errors/ref.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/ref.js +4 -0
- package/templates/backend/node_modules/es-errors/syntax.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/syntax.js +4 -0
- package/templates/backend/node_modules/es-errors/test/index.js +19 -0
- package/templates/backend/node_modules/es-errors/tsconfig.json +49 -0
- package/templates/backend/node_modules/es-errors/type.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/type.js +4 -0
- package/templates/backend/node_modules/es-errors/uri.d.ts +3 -0
- package/templates/backend/node_modules/es-errors/uri.js +4 -0
- package/templates/backend/node_modules/es-object-atoms/.eslintrc +16 -0
- package/templates/backend/node_modules/es-object-atoms/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/es-object-atoms/CHANGELOG.md +37 -0
- package/templates/backend/node_modules/es-object-atoms/LICENSE +21 -0
- package/templates/backend/node_modules/es-object-atoms/README.md +63 -0
- package/templates/backend/node_modules/es-object-atoms/RequireObjectCoercible.d.ts +3 -0
- package/templates/backend/node_modules/es-object-atoms/RequireObjectCoercible.js +11 -0
- package/templates/backend/node_modules/es-object-atoms/ToObject.d.ts +7 -0
- package/templates/backend/node_modules/es-object-atoms/ToObject.js +10 -0
- package/templates/backend/node_modules/es-object-atoms/index.d.ts +3 -0
- package/templates/backend/node_modules/es-object-atoms/index.js +4 -0
- package/templates/backend/node_modules/es-object-atoms/isObject.d.ts +3 -0
- package/templates/backend/node_modules/es-object-atoms/isObject.js +6 -0
- package/templates/backend/node_modules/es-object-atoms/package.json +80 -0
- package/templates/backend/node_modules/es-object-atoms/test/index.js +38 -0
- package/templates/backend/node_modules/es-object-atoms/tsconfig.json +6 -0
- package/templates/backend/node_modules/escape-html/LICENSE +24 -0
- package/templates/backend/node_modules/escape-html/Readme.md +43 -0
- package/templates/backend/node_modules/escape-html/index.js +78 -0
- package/templates/backend/node_modules/escape-html/package.json +24 -0
- package/templates/backend/node_modules/etag/HISTORY.md +83 -0
- package/templates/backend/node_modules/etag/LICENSE +22 -0
- package/templates/backend/node_modules/etag/README.md +159 -0
- package/templates/backend/node_modules/etag/index.js +131 -0
- package/templates/backend/node_modules/etag/package.json +47 -0
- package/templates/backend/node_modules/express/LICENSE +24 -0
- package/templates/backend/node_modules/express/Readme.md +276 -0
- package/templates/backend/node_modules/express/index.js +11 -0
- package/templates/backend/node_modules/express/lib/application.js +631 -0
- package/templates/backend/node_modules/express/lib/express.js +81 -0
- package/templates/backend/node_modules/express/lib/request.js +514 -0
- package/templates/backend/node_modules/express/lib/response.js +1053 -0
- package/templates/backend/node_modules/express/lib/utils.js +271 -0
- package/templates/backend/node_modules/express/lib/view.js +205 -0
- package/templates/backend/node_modules/express/package.json +99 -0
- package/templates/backend/node_modules/fill-range/LICENSE +21 -0
- package/templates/backend/node_modules/fill-range/README.md +237 -0
- package/templates/backend/node_modules/fill-range/index.js +248 -0
- package/templates/backend/node_modules/fill-range/package.json +74 -0
- package/templates/backend/node_modules/finalhandler/HISTORY.md +239 -0
- package/templates/backend/node_modules/finalhandler/LICENSE +22 -0
- package/templates/backend/node_modules/finalhandler/README.md +150 -0
- package/templates/backend/node_modules/finalhandler/index.js +293 -0
- package/templates/backend/node_modules/finalhandler/package.json +47 -0
- package/templates/backend/node_modules/forwarded/HISTORY.md +21 -0
- package/templates/backend/node_modules/forwarded/LICENSE +22 -0
- package/templates/backend/node_modules/forwarded/README.md +57 -0
- package/templates/backend/node_modules/forwarded/index.js +90 -0
- package/templates/backend/node_modules/forwarded/package.json +45 -0
- package/templates/backend/node_modules/fresh/HISTORY.md +80 -0
- package/templates/backend/node_modules/fresh/LICENSE +23 -0
- package/templates/backend/node_modules/fresh/README.md +117 -0
- package/templates/backend/node_modules/fresh/index.js +136 -0
- package/templates/backend/node_modules/fresh/package.json +46 -0
- package/templates/backend/node_modules/function-bind/.eslintrc +21 -0
- package/templates/backend/node_modules/function-bind/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/function-bind/.github/SECURITY.md +3 -0
- package/templates/backend/node_modules/function-bind/.nycrc +13 -0
- package/templates/backend/node_modules/function-bind/CHANGELOG.md +136 -0
- package/templates/backend/node_modules/function-bind/LICENSE +20 -0
- package/templates/backend/node_modules/function-bind/README.md +46 -0
- package/templates/backend/node_modules/function-bind/implementation.js +84 -0
- package/templates/backend/node_modules/function-bind/index.js +5 -0
- package/templates/backend/node_modules/function-bind/package.json +87 -0
- package/templates/backend/node_modules/function-bind/test/.eslintrc +9 -0
- package/templates/backend/node_modules/function-bind/test/index.js +252 -0
- package/templates/backend/node_modules/get-intrinsic/.eslintrc +42 -0
- package/templates/backend/node_modules/get-intrinsic/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/get-intrinsic/.nycrc +9 -0
- package/templates/backend/node_modules/get-intrinsic/CHANGELOG.md +186 -0
- package/templates/backend/node_modules/get-intrinsic/LICENSE +21 -0
- package/templates/backend/node_modules/get-intrinsic/README.md +71 -0
- package/templates/backend/node_modules/get-intrinsic/index.js +378 -0
- package/templates/backend/node_modules/get-intrinsic/package.json +97 -0
- package/templates/backend/node_modules/get-intrinsic/test/GetIntrinsic.js +274 -0
- package/templates/backend/node_modules/get-proto/.eslintrc +10 -0
- package/templates/backend/node_modules/get-proto/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/get-proto/.nycrc +9 -0
- package/templates/backend/node_modules/get-proto/CHANGELOG.md +21 -0
- package/templates/backend/node_modules/get-proto/LICENSE +21 -0
- package/templates/backend/node_modules/get-proto/Object.getPrototypeOf.d.ts +5 -0
- package/templates/backend/node_modules/get-proto/Object.getPrototypeOf.js +6 -0
- package/templates/backend/node_modules/get-proto/README.md +50 -0
- package/templates/backend/node_modules/get-proto/Reflect.getPrototypeOf.d.ts +3 -0
- package/templates/backend/node_modules/get-proto/Reflect.getPrototypeOf.js +4 -0
- package/templates/backend/node_modules/get-proto/index.d.ts +5 -0
- package/templates/backend/node_modules/get-proto/index.js +27 -0
- package/templates/backend/node_modules/get-proto/package.json +81 -0
- package/templates/backend/node_modules/get-proto/test/index.js +68 -0
- package/templates/backend/node_modules/get-proto/tsconfig.json +9 -0
- package/templates/backend/node_modules/glob-parent/CHANGELOG.md +110 -0
- package/templates/backend/node_modules/glob-parent/LICENSE +15 -0
- package/templates/backend/node_modules/glob-parent/README.md +137 -0
- package/templates/backend/node_modules/glob-parent/index.js +42 -0
- package/templates/backend/node_modules/glob-parent/package.json +48 -0
- package/templates/backend/node_modules/gopd/.eslintrc +16 -0
- package/templates/backend/node_modules/gopd/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/gopd/CHANGELOG.md +45 -0
- package/templates/backend/node_modules/gopd/LICENSE +21 -0
- package/templates/backend/node_modules/gopd/README.md +40 -0
- package/templates/backend/node_modules/gopd/gOPD.d.ts +1 -0
- package/templates/backend/node_modules/gopd/gOPD.js +4 -0
- package/templates/backend/node_modules/gopd/index.d.ts +5 -0
- package/templates/backend/node_modules/gopd/index.js +15 -0
- package/templates/backend/node_modules/gopd/package.json +77 -0
- package/templates/backend/node_modules/gopd/test/index.js +36 -0
- package/templates/backend/node_modules/gopd/tsconfig.json +9 -0
- package/templates/backend/node_modules/has-flag/index.js +8 -0
- package/templates/backend/node_modules/has-flag/license +9 -0
- package/templates/backend/node_modules/has-flag/package.json +44 -0
- package/templates/backend/node_modules/has-flag/readme.md +70 -0
- package/templates/backend/node_modules/has-symbols/.eslintrc +11 -0
- package/templates/backend/node_modules/has-symbols/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/has-symbols/.nycrc +9 -0
- package/templates/backend/node_modules/has-symbols/CHANGELOG.md +91 -0
- package/templates/backend/node_modules/has-symbols/LICENSE +21 -0
- package/templates/backend/node_modules/has-symbols/README.md +46 -0
- package/templates/backend/node_modules/has-symbols/index.d.ts +3 -0
- package/templates/backend/node_modules/has-symbols/index.js +14 -0
- package/templates/backend/node_modules/has-symbols/package.json +111 -0
- package/templates/backend/node_modules/has-symbols/shams.d.ts +3 -0
- package/templates/backend/node_modules/has-symbols/shams.js +45 -0
- package/templates/backend/node_modules/has-symbols/test/index.js +22 -0
- package/templates/backend/node_modules/has-symbols/test/shams/core-js.js +29 -0
- package/templates/backend/node_modules/has-symbols/test/shams/get-own-property-symbols.js +29 -0
- package/templates/backend/node_modules/has-symbols/test/tests.js +58 -0
- package/templates/backend/node_modules/has-symbols/tsconfig.json +10 -0
- package/templates/backend/node_modules/hasown/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/hasown/.nycrc +13 -0
- package/templates/backend/node_modules/hasown/CHANGELOG.md +51 -0
- package/templates/backend/node_modules/hasown/LICENSE +21 -0
- package/templates/backend/node_modules/hasown/README.md +40 -0
- package/templates/backend/node_modules/hasown/eslint.config.mjs +6 -0
- package/templates/backend/node_modules/hasown/index.d.ts +4 -0
- package/templates/backend/node_modules/hasown/index.js +8 -0
- package/templates/backend/node_modules/hasown/package.json +92 -0
- package/templates/backend/node_modules/hasown/tsconfig.json +6 -0
- package/templates/backend/node_modules/http-errors/HISTORY.md +186 -0
- package/templates/backend/node_modules/http-errors/LICENSE +23 -0
- package/templates/backend/node_modules/http-errors/README.md +169 -0
- package/templates/backend/node_modules/http-errors/index.js +290 -0
- package/templates/backend/node_modules/http-errors/package.json +54 -0
- package/templates/backend/node_modules/iconv-lite/LICENSE +21 -0
- package/templates/backend/node_modules/iconv-lite/README.md +138 -0
- package/templates/backend/node_modules/iconv-lite/encodings/dbcs-codec.js +532 -0
- package/templates/backend/node_modules/iconv-lite/encodings/dbcs-data.js +185 -0
- package/templates/backend/node_modules/iconv-lite/encodings/index.js +23 -0
- package/templates/backend/node_modules/iconv-lite/encodings/internal.js +218 -0
- package/templates/backend/node_modules/iconv-lite/encodings/sbcs-codec.js +75 -0
- package/templates/backend/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/templates/backend/node_modules/iconv-lite/encodings/sbcs-data.js +178 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/templates/backend/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/templates/backend/node_modules/iconv-lite/encodings/utf16.js +187 -0
- package/templates/backend/node_modules/iconv-lite/encodings/utf32.js +307 -0
- package/templates/backend/node_modules/iconv-lite/encodings/utf7.js +283 -0
- package/templates/backend/node_modules/iconv-lite/lib/bom-handling.js +48 -0
- package/templates/backend/node_modules/iconv-lite/lib/helpers/merge-exports.js +13 -0
- package/templates/backend/node_modules/iconv-lite/lib/index.d.ts +129 -0
- package/templates/backend/node_modules/iconv-lite/lib/index.js +182 -0
- package/templates/backend/node_modules/iconv-lite/lib/streams.js +105 -0
- package/templates/backend/node_modules/iconv-lite/package.json +70 -0
- package/templates/backend/node_modules/iconv-lite/types/encodings.d.ts +423 -0
- package/templates/backend/node_modules/ignore-by-default/LICENSE +14 -0
- package/templates/backend/node_modules/ignore-by-default/README.md +26 -0
- package/templates/backend/node_modules/ignore-by-default/index.js +12 -0
- package/templates/backend/node_modules/ignore-by-default/package.json +34 -0
- package/templates/backend/node_modules/inherits/LICENSE +16 -0
- package/templates/backend/node_modules/inherits/README.md +42 -0
- package/templates/backend/node_modules/inherits/inherits.js +9 -0
- package/templates/backend/node_modules/inherits/inherits_browser.js +27 -0
- package/templates/backend/node_modules/inherits/package.json +29 -0
- package/templates/backend/node_modules/ipaddr.js/LICENSE +19 -0
- package/templates/backend/node_modules/ipaddr.js/README.md +233 -0
- package/templates/backend/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- package/templates/backend/node_modules/ipaddr.js/lib/ipaddr.js +673 -0
- package/templates/backend/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +68 -0
- package/templates/backend/node_modules/ipaddr.js/package.json +35 -0
- package/templates/backend/node_modules/is-binary-path/index.d.ts +17 -0
- package/templates/backend/node_modules/is-binary-path/index.js +7 -0
- package/templates/backend/node_modules/is-binary-path/license +9 -0
- package/templates/backend/node_modules/is-binary-path/package.json +40 -0
- package/templates/backend/node_modules/is-binary-path/readme.md +34 -0
- package/templates/backend/node_modules/is-extglob/LICENSE +21 -0
- package/templates/backend/node_modules/is-extglob/README.md +107 -0
- package/templates/backend/node_modules/is-extglob/index.js +20 -0
- package/templates/backend/node_modules/is-extglob/package.json +69 -0
- package/templates/backend/node_modules/is-glob/LICENSE +21 -0
- package/templates/backend/node_modules/is-glob/README.md +206 -0
- package/templates/backend/node_modules/is-glob/index.js +150 -0
- package/templates/backend/node_modules/is-glob/package.json +81 -0
- package/templates/backend/node_modules/is-number/LICENSE +21 -0
- package/templates/backend/node_modules/is-number/README.md +187 -0
- package/templates/backend/node_modules/is-number/index.js +18 -0
- package/templates/backend/node_modules/is-number/package.json +82 -0
- package/templates/backend/node_modules/is-promise/LICENSE +19 -0
- package/templates/backend/node_modules/is-promise/index.d.ts +2 -0
- package/templates/backend/node_modules/is-promise/index.js +6 -0
- package/templates/backend/node_modules/is-promise/index.mjs +3 -0
- package/templates/backend/node_modules/is-promise/package.json +30 -0
- package/templates/backend/node_modules/is-promise/readme.md +33 -0
- package/templates/backend/node_modules/jsonwebtoken/LICENSE +21 -0
- package/templates/backend/node_modules/jsonwebtoken/README.md +396 -0
- package/templates/backend/node_modules/jsonwebtoken/decode.js +30 -0
- package/templates/backend/node_modules/jsonwebtoken/index.js +8 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/JsonWebTokenError.js +14 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/NotBeforeError.js +13 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/TokenExpiredError.js +13 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/asymmetricKeyDetailsSupported.js +3 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/psSupported.js +3 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/rsaPssKeyDetailsSupported.js +3 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/timespan.js +18 -0
- package/templates/backend/node_modules/jsonwebtoken/lib/validateAsymmetricKey.js +66 -0
- package/templates/backend/node_modules/jsonwebtoken/package.json +70 -0
- package/templates/backend/node_modules/jsonwebtoken/sign.js +253 -0
- package/templates/backend/node_modules/jsonwebtoken/verify.js +263 -0
- package/templates/backend/node_modules/jwa/LICENSE +17 -0
- package/templates/backend/node_modules/jwa/README.md +150 -0
- package/templates/backend/node_modules/jwa/index.js +266 -0
- package/templates/backend/node_modules/jwa/opslevel.yml +6 -0
- package/templates/backend/node_modules/jwa/package.json +37 -0
- package/templates/backend/node_modules/jws/CHANGELOG.md +56 -0
- package/templates/backend/node_modules/jws/LICENSE +17 -0
- package/templates/backend/node_modules/jws/index.js +22 -0
- package/templates/backend/node_modules/jws/lib/data-stream.js +55 -0
- package/templates/backend/node_modules/jws/lib/sign-stream.js +83 -0
- package/templates/backend/node_modules/jws/lib/tostring.js +10 -0
- package/templates/backend/node_modules/jws/lib/verify-stream.js +125 -0
- package/templates/backend/node_modules/jws/opslevel.yml +6 -0
- package/templates/backend/node_modules/jws/package.json +34 -0
- package/templates/backend/node_modules/jws/readme.md +255 -0
- package/templates/backend/node_modules/kareem/CHANGELOG.md +845 -0
- package/templates/backend/node_modules/kareem/LICENSE +202 -0
- package/templates/backend/node_modules/kareem/README.md +385 -0
- package/templates/backend/node_modules/kareem/SECURITY.md +5 -0
- package/templates/backend/node_modules/kareem/index.d.ts +31 -0
- package/templates/backend/node_modules/kareem/index.js +553 -0
- package/templates/backend/node_modules/kareem/package.json +28 -0
- package/templates/backend/node_modules/lodash.includes/LICENSE +47 -0
- package/templates/backend/node_modules/lodash.includes/README.md +18 -0
- package/templates/backend/node_modules/lodash.includes/index.js +745 -0
- package/templates/backend/node_modules/lodash.includes/package.json +17 -0
- package/templates/backend/node_modules/lodash.isboolean/LICENSE +22 -0
- package/templates/backend/node_modules/lodash.isboolean/README.md +18 -0
- package/templates/backend/node_modules/lodash.isboolean/index.js +70 -0
- package/templates/backend/node_modules/lodash.isboolean/package.json +17 -0
- package/templates/backend/node_modules/lodash.isinteger/LICENSE +47 -0
- package/templates/backend/node_modules/lodash.isinteger/README.md +18 -0
- package/templates/backend/node_modules/lodash.isinteger/index.js +265 -0
- package/templates/backend/node_modules/lodash.isinteger/package.json +17 -0
- package/templates/backend/node_modules/lodash.isnumber/LICENSE +22 -0
- package/templates/backend/node_modules/lodash.isnumber/README.md +18 -0
- package/templates/backend/node_modules/lodash.isnumber/index.js +79 -0
- package/templates/backend/node_modules/lodash.isnumber/package.json +17 -0
- package/templates/backend/node_modules/lodash.isplainobject/LICENSE +47 -0
- package/templates/backend/node_modules/lodash.isplainobject/README.md +18 -0
- package/templates/backend/node_modules/lodash.isplainobject/index.js +139 -0
- package/templates/backend/node_modules/lodash.isplainobject/package.json +17 -0
- package/templates/backend/node_modules/lodash.isstring/LICENSE +22 -0
- package/templates/backend/node_modules/lodash.isstring/README.md +18 -0
- package/templates/backend/node_modules/lodash.isstring/index.js +95 -0
- package/templates/backend/node_modules/lodash.isstring/package.json +17 -0
- package/templates/backend/node_modules/lodash.once/LICENSE +47 -0
- package/templates/backend/node_modules/lodash.once/README.md +18 -0
- package/templates/backend/node_modules/lodash.once/index.js +294 -0
- package/templates/backend/node_modules/lodash.once/package.json +17 -0
- package/templates/backend/node_modules/math-intrinsics/.eslintrc +16 -0
- package/templates/backend/node_modules/math-intrinsics/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/math-intrinsics/CHANGELOG.md +24 -0
- package/templates/backend/node_modules/math-intrinsics/LICENSE +21 -0
- package/templates/backend/node_modules/math-intrinsics/README.md +50 -0
- package/templates/backend/node_modules/math-intrinsics/abs.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/abs.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/constants/maxArrayLength.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/constants/maxArrayLength.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/constants/maxSafeInteger.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/constants/maxSafeInteger.js +5 -0
- package/templates/backend/node_modules/math-intrinsics/constants/maxValue.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/constants/maxValue.js +5 -0
- package/templates/backend/node_modules/math-intrinsics/floor.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/floor.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/isFinite.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/isFinite.js +12 -0
- package/templates/backend/node_modules/math-intrinsics/isInteger.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/isInteger.js +16 -0
- package/templates/backend/node_modules/math-intrinsics/isNaN.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/isNaN.js +6 -0
- package/templates/backend/node_modules/math-intrinsics/isNegativeZero.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/isNegativeZero.js +6 -0
- package/templates/backend/node_modules/math-intrinsics/max.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/max.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/min.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/min.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/mod.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/mod.js +9 -0
- package/templates/backend/node_modules/math-intrinsics/package.json +86 -0
- package/templates/backend/node_modules/math-intrinsics/pow.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/pow.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/round.d.ts +1 -0
- package/templates/backend/node_modules/math-intrinsics/round.js +4 -0
- package/templates/backend/node_modules/math-intrinsics/sign.d.ts +3 -0
- package/templates/backend/node_modules/math-intrinsics/sign.js +11 -0
- package/templates/backend/node_modules/math-intrinsics/test/index.js +192 -0
- package/templates/backend/node_modules/math-intrinsics/tsconfig.json +3 -0
- package/templates/backend/node_modules/media-typer/HISTORY.md +50 -0
- package/templates/backend/node_modules/media-typer/LICENSE +22 -0
- package/templates/backend/node_modules/media-typer/README.md +93 -0
- package/templates/backend/node_modules/media-typer/index.js +143 -0
- package/templates/backend/node_modules/media-typer/package.json +33 -0
- package/templates/backend/node_modules/memory-pager/.travis.yml +4 -0
- package/templates/backend/node_modules/memory-pager/LICENSE +21 -0
- package/templates/backend/node_modules/memory-pager/README.md +65 -0
- package/templates/backend/node_modules/memory-pager/index.js +160 -0
- package/templates/backend/node_modules/memory-pager/package.json +24 -0
- package/templates/backend/node_modules/memory-pager/test.js +80 -0
- package/templates/backend/node_modules/merge-descriptors/index.d.ts +11 -0
- package/templates/backend/node_modules/merge-descriptors/index.js +26 -0
- package/templates/backend/node_modules/merge-descriptors/license +11 -0
- package/templates/backend/node_modules/merge-descriptors/package.json +50 -0
- package/templates/backend/node_modules/merge-descriptors/readme.md +55 -0
- package/templates/backend/node_modules/mime-db/HISTORY.md +541 -0
- package/templates/backend/node_modules/mime-db/LICENSE +23 -0
- package/templates/backend/node_modules/mime-db/README.md +109 -0
- package/templates/backend/node_modules/mime-db/db.json +9342 -0
- package/templates/backend/node_modules/mime-db/index.js +12 -0
- package/templates/backend/node_modules/mime-db/package.json +56 -0
- package/templates/backend/node_modules/mime-types/HISTORY.md +428 -0
- package/templates/backend/node_modules/mime-types/LICENSE +23 -0
- package/templates/backend/node_modules/mime-types/README.md +126 -0
- package/templates/backend/node_modules/mime-types/index.js +211 -0
- package/templates/backend/node_modules/mime-types/mimeScore.js +57 -0
- package/templates/backend/node_modules/mime-types/package.json +49 -0
- package/templates/backend/node_modules/minimatch/LICENSE.md +55 -0
- package/templates/backend/node_modules/minimatch/README.md +528 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/ast.d.ts +22 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/ast.js +845 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/escape.js +30 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/index.d.ts +174 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/index.js +1127 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/package.json +3 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
- package/templates/backend/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
- package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
- package/templates/backend/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/ast.d.ts +22 -0
- package/templates/backend/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/ast.js +841 -0
- package/templates/backend/node_modules/minimatch/dist/esm/ast.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
- package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
- package/templates/backend/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
- package/templates/backend/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/escape.js +26 -0
- package/templates/backend/node_modules/minimatch/dist/esm/escape.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/index.d.ts +174 -0
- package/templates/backend/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/index.js +1114 -0
- package/templates/backend/node_modules/minimatch/dist/esm/index.js.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/package.json +3 -0
- package/templates/backend/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
- package/templates/backend/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
- package/templates/backend/node_modules/minimatch/dist/esm/unescape.js +34 -0
- package/templates/backend/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
- package/templates/backend/node_modules/minimatch/package.json +73 -0
- package/templates/backend/node_modules/mongodb/LICENSE.md +201 -0
- package/templates/backend/node_modules/mongodb/README.md +366 -0
- package/templates/backend/node_modules/mongodb/etc/prepare.js +12 -0
- package/templates/backend/node_modules/mongodb/lib/admin.js +136 -0
- package/templates/backend/node_modules/mongodb/lib/admin.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/bson.js +106 -0
- package/templates/backend/node_modules/mongodb/lib/bson.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/bulk/common.js +835 -0
- package/templates/backend/node_modules/mongodb/lib/bulk/common.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/bulk/ordered.js +67 -0
- package/templates/backend/node_modules/mongodb/lib/bulk/ordered.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/bulk/unordered.js +92 -0
- package/templates/backend/node_modules/mongodb/lib/bulk/unordered.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/change_stream.js +517 -0
- package/templates/backend/node_modules/mongodb/lib/change_stream.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js +281 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/auto_encrypter.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/client_encryption.js +607 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/client_encryption.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/errors.js +138 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/errors.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js +85 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/mongocryptd_manager.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/aws.js +23 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/aws.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/azure.js +132 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/azure.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/gcp.js +16 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/gcp.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/index.js +43 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/providers/index.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/state_machine.js +427 -0
- package/templates/backend/node_modules/mongodb/lib/client-side-encryption/state_machine.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/auth_provider.js +51 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/auth_provider.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws4.js +161 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws4.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js +103 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/aws_temporary_credentials.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/gssapi.js +152 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/gssapi.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js +169 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongo_credentials.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js +129 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_aws.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js +84 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/automated_callback_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js +62 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/azure_machine_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js +141 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/callback_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js +44 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/command_builders.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js +39 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/gcp_machine_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js +122 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/human_callback_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js +32 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/k8s_machine_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js +52 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_cache.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js +23 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc/token_machine_workflow.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js +73 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/mongodb_oidc.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/plain.js +26 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/plain.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/providers.js +22 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/providers.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/scram.js +267 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/scram.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/x509.js +36 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/auth/x509.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/command_monitoring_events.js +223 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/command_monitoring_events.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/commands.js +542 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/commands.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connect.js +398 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connect.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connection.js +574 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connection.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool.js +558 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool_events.js +190 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/connection_pool_events.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/errors.js +108 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/errors.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/handshake/client_metadata.js +241 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/handshake/client_metadata.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/metrics.js +62 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/metrics.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/stream_description.js +70 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/stream_description.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/compression.js +179 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/compression.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/constants.js +21 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/constants.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js +111 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_data.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js +222 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/on_demand/document.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/responses.js +315 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/responses.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/shared.js +35 -0
- package/templates/backend/node_modules/mongodb/lib/cmap/wire_protocol/shared.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/collection.js +751 -0
- package/templates/backend/node_modules/mongodb/lib/collection.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/connection_string.js +1106 -0
- package/templates/backend/node_modules/mongodb/lib/connection_string.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/constants.js +170 -0
- package/templates/backend/node_modules/mongodb/lib/constants.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/abstract_cursor.js +924 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/abstract_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/aggregation_cursor.js +164 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/aggregation_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/change_stream_cursor.js +104 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/change_stream_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/client_bulk_write_cursor.js +52 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/client_bulk_write_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/explainable_cursor.js +36 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/explainable_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/find_cursor.js +399 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/find_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/list_collections_cursor.js +34 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/list_collections_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/list_indexes_cursor.js +32 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/list_indexes_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js +14 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/list_search_indexes_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/run_command_cursor.js +94 -0
- package/templates/backend/node_modules/mongodb/lib/cursor/run_command_cursor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/db.js +419 -0
- package/templates/backend/node_modules/mongodb/lib/db.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/deps.js +112 -0
- package/templates/backend/node_modules/mongodb/lib/deps.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/encrypter.js +106 -0
- package/templates/backend/node_modules/mongodb/lib/encrypter.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/error.js +1380 -0
- package/templates/backend/node_modules/mongodb/lib/error.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/explain.js +59 -0
- package/templates/backend/node_modules/mongodb/lib/explain.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/gridfs/download.js +306 -0
- package/templates/backend/node_modules/mongodb/lib/gridfs/download.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/gridfs/index.js +164 -0
- package/templates/backend/node_modules/mongodb/lib/gridfs/index.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/gridfs/upload.js +358 -0
- package/templates/backend/node_modules/mongodb/lib/gridfs/upload.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/index.js +193 -0
- package/templates/backend/node_modules/mongodb/lib/index.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_client.js +557 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_client.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_client_auth_providers.js +80 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_client_auth_providers.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_logger.js +655 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_logger.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_types.js +56 -0
- package/templates/backend/node_modules/mongodb/lib/mongo_types.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/aggregate.js +90 -0
- package/templates/backend/node_modules/mongodb/lib/operations/aggregate.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js +51 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/client_bulk_write.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js +340 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/command_builder.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/common.js +3 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/common.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/executor.js +120 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/executor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js +204 -0
- package/templates/backend/node_modules/mongodb/lib/operations/client_bulk_write/results_merger.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/command.js +83 -0
- package/templates/backend/node_modules/mongodb/lib/operations/command.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/count.js +45 -0
- package/templates/backend/node_modules/mongodb/lib/operations/count.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/create_collection.js +109 -0
- package/templates/backend/node_modules/mongodb/lib/operations/create_collection.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/delete.js +125 -0
- package/templates/backend/node_modules/mongodb/lib/operations/delete.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/distinct.js +61 -0
- package/templates/backend/node_modules/mongodb/lib/operations/distinct.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/drop.js +93 -0
- package/templates/backend/node_modules/mongodb/lib/operations/drop.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/end_sessions.js +34 -0
- package/templates/backend/node_modules/mongodb/lib/operations/end_sessions.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/estimated_document_count.js +41 -0
- package/templates/backend/node_modules/mongodb/lib/operations/estimated_document_count.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/execute_operation.js +312 -0
- package/templates/backend/node_modules/mongodb/lib/operations/execute_operation.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/find.js +148 -0
- package/templates/backend/node_modules/mongodb/lib/operations/find.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/find_and_modify.js +158 -0
- package/templates/backend/node_modules/mongodb/lib/operations/find_and_modify.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/get_more.js +62 -0
- package/templates/backend/node_modules/mongodb/lib/operations/get_more.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/indexes.js +186 -0
- package/templates/backend/node_modules/mongodb/lib/operations/indexes.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/insert.js +70 -0
- package/templates/backend/node_modules/mongodb/lib/operations/insert.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/kill_cursors.js +43 -0
- package/templates/backend/node_modules/mongodb/lib/operations/kill_cursors.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/list_collections.js +53 -0
- package/templates/backend/node_modules/mongodb/lib/operations/list_collections.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/list_databases.js +40 -0
- package/templates/backend/node_modules/mongodb/lib/operations/list_databases.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/operation.js +103 -0
- package/templates/backend/node_modules/mongodb/lib/operations/operation.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/profiling_level.js +43 -0
- package/templates/backend/node_modules/mongodb/lib/operations/profiling_level.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/remove_user.js +27 -0
- package/templates/backend/node_modules/mongodb/lib/operations/remove_user.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/rename.js +38 -0
- package/templates/backend/node_modules/mongodb/lib/operations/rename.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/run_command.js +47 -0
- package/templates/backend/node_modules/mongodb/lib/operations/run_command.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/create.js +33 -0
- package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/create.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/drop.js +43 -0
- package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/drop.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/update.js +35 -0
- package/templates/backend/node_modules/mongodb/lib/operations/search_indexes/update.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/set_profiling_level.js +53 -0
- package/templates/backend/node_modules/mongodb/lib/operations/set_profiling_level.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/stats.js +27 -0
- package/templates/backend/node_modules/mongodb/lib/operations/stats.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/update.js +188 -0
- package/templates/backend/node_modules/mongodb/lib/operations/update.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/operations/validate_collection.js +37 -0
- package/templates/backend/node_modules/mongodb/lib/operations/validate_collection.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/read_concern.js +73 -0
- package/templates/backend/node_modules/mongodb/lib/read_concern.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/read_preference.js +191 -0
- package/templates/backend/node_modules/mongodb/lib/read_preference.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/runtime_adapters.js +32 -0
- package/templates/backend/node_modules/mongodb/lib/runtime_adapters.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/common.js +49 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/common.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/events.js +146 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/events.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/monitor.js +544 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/monitor.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server.js +404 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server_description.js +204 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server_description.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server_selection.js +294 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server_selection.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server_selection_events.js +85 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/server_selection_events.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/srv_polling.js +108 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/srv_polling.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/topology.js +654 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/topology.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/topology_description.js +383 -0
- package/templates/backend/node_modules/mongodb/lib/sdam/topology_description.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sessions.js +937 -0
- package/templates/backend/node_modules/mongodb/lib/sessions.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/sort.js +103 -0
- package/templates/backend/node_modules/mongodb/lib/sort.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/timeout.js +296 -0
- package/templates/backend/node_modules/mongodb/lib/timeout.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/transactions.js +135 -0
- package/templates/backend/node_modules/mongodb/lib/transactions.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/utils.js +1155 -0
- package/templates/backend/node_modules/mongodb/lib/utils.js.map +1 -0
- package/templates/backend/node_modules/mongodb/lib/write_concern.js +100 -0
- package/templates/backend/node_modules/mongodb/lib/write_concern.js.map +1 -0
- package/templates/backend/node_modules/mongodb/mongodb.d.ts +9061 -0
- package/templates/backend/node_modules/mongodb/package.json +182 -0
- package/templates/backend/node_modules/mongodb/src/admin.ts +173 -0
- package/templates/backend/node_modules/mongodb/src/bson.ts +172 -0
- package/templates/backend/node_modules/mongodb/src/bulk/common.ts +1251 -0
- package/templates/backend/node_modules/mongodb/src/bulk/ordered.ts +83 -0
- package/templates/backend/node_modules/mongodb/src/bulk/unordered.ts +115 -0
- package/templates/backend/node_modules/mongodb/src/change_stream.ts +1165 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/auto_encrypter.ts +475 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/client_encryption.ts +1148 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/errors.ts +144 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/mongocryptd_manager.ts +100 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/aws.ts +33 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/azure.ts +181 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/gcp.ts +16 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/providers/index.ts +207 -0
- package/templates/backend/node_modules/mongodb/src/client-side-encryption/state_machine.ts +651 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/auth_provider.ts +77 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/aws4.ts +207 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/aws_temporary_credentials.ts +129 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/gssapi.ts +206 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongo_credentials.ts +292 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_aws.ts +179 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/automated_callback_workflow.ts +88 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts +73 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/callback_workflow.ts +188 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/command_builders.ts +53 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts +46 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/human_callback_workflow.ts +141 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts +31 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_cache.ts +62 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc/token_machine_workflow.ts +22 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/mongodb_oidc.ts +185 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/plain.ts +25 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/providers.ts +22 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/scram.ts +371 -0
- package/templates/backend/node_modules/mongodb/src/cmap/auth/x509.ts +43 -0
- package/templates/backend/node_modules/mongodb/src/cmap/command_monitoring_events.ts +316 -0
- package/templates/backend/node_modules/mongodb/src/cmap/commands.ts +807 -0
- package/templates/backend/node_modules/mongodb/src/cmap/connect.ts +538 -0
- package/templates/backend/node_modules/mongodb/src/cmap/connection.ts +938 -0
- package/templates/backend/node_modules/mongodb/src/cmap/connection_pool.ts +831 -0
- package/templates/backend/node_modules/mongodb/src/cmap/connection_pool_events.ts +300 -0
- package/templates/backend/node_modules/mongodb/src/cmap/errors.ts +119 -0
- package/templates/backend/node_modules/mongodb/src/cmap/handshake/client_metadata.ts +353 -0
- package/templates/backend/node_modules/mongodb/src/cmap/metrics.ts +58 -0
- package/templates/backend/node_modules/mongodb/src/cmap/stream_description.ts +96 -0
- package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/compression.ts +215 -0
- package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/constants.ts +17 -0
- package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/on_data.ts +139 -0
- package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/on_demand/document.ts +356 -0
- package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/responses.ts +393 -0
- package/templates/backend/node_modules/mongodb/src/cmap/wire_protocol/shared.ts +48 -0
- package/templates/backend/node_modules/mongodb/src/collection.ts +1314 -0
- package/templates/backend/node_modules/mongodb/src/connection_string.ts +1315 -0
- package/templates/backend/node_modules/mongodb/src/constants.ts +176 -0
- package/templates/backend/node_modules/mongodb/src/cursor/abstract_cursor.ts +1247 -0
- package/templates/backend/node_modules/mongodb/src/cursor/aggregation_cursor.ts +245 -0
- package/templates/backend/node_modules/mongodb/src/cursor/change_stream_cursor.ts +171 -0
- package/templates/backend/node_modules/mongodb/src/cursor/client_bulk_write_cursor.ts +83 -0
- package/templates/backend/node_modules/mongodb/src/cursor/explainable_cursor.ts +51 -0
- package/templates/backend/node_modules/mongodb/src/cursor/find_cursor.ts +497 -0
- package/templates/backend/node_modules/mongodb/src/cursor/list_collections_cursor.ts +50 -0
- package/templates/backend/node_modules/mongodb/src/cursor/list_indexes_cursor.ts +37 -0
- package/templates/backend/node_modules/mongodb/src/cursor/list_search_indexes_cursor.ts +20 -0
- package/templates/backend/node_modules/mongodb/src/cursor/run_command_cursor.ts +178 -0
- package/templates/backend/node_modules/mongodb/src/db.ts +621 -0
- package/templates/backend/node_modules/mongodb/src/deps.ts +227 -0
- package/templates/backend/node_modules/mongodb/src/encrypter.ts +127 -0
- package/templates/backend/node_modules/mongodb/src/error.ts +1567 -0
- package/templates/backend/node_modules/mongodb/src/explain.ts +124 -0
- package/templates/backend/node_modules/mongodb/src/gridfs/download.ts +483 -0
- package/templates/backend/node_modules/mongodb/src/gridfs/index.ts +264 -0
- package/templates/backend/node_modules/mongodb/src/gridfs/upload.ts +538 -0
- package/templates/backend/node_modules/mongodb/src/index.ts +634 -0
- package/templates/backend/node_modules/mongodb/src/mongo_client.ts +1179 -0
- package/templates/backend/node_modules/mongodb/src/mongo_client_auth_providers.ts +87 -0
- package/templates/backend/node_modules/mongodb/src/mongo_logger.ts +1081 -0
- package/templates/backend/node_modules/mongodb/src/mongo_types.ts +678 -0
- package/templates/backend/node_modules/mongodb/src/operations/aggregate.ts +153 -0
- package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/client_bulk_write.ts +72 -0
- package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/command_builder.ts +487 -0
- package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/common.ts +276 -0
- package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/executor.ts +149 -0
- package/templates/backend/node_modules/mongodb/src/operations/client_bulk_write/results_merger.ts +260 -0
- package/templates/backend/node_modules/mongodb/src/operations/command.ts +171 -0
- package/templates/backend/node_modules/mongodb/src/operations/count.ts +74 -0
- package/templates/backend/node_modules/mongodb/src/operations/create_collection.ts +218 -0
- package/templates/backend/node_modules/mongodb/src/operations/delete.ts +183 -0
- package/templates/backend/node_modules/mongodb/src/operations/distinct.ts +92 -0
- package/templates/backend/node_modules/mongodb/src/operations/drop.ts +130 -0
- package/templates/backend/node_modules/mongodb/src/operations/end_sessions.ts +44 -0
- package/templates/backend/node_modules/mongodb/src/operations/estimated_document_count.ts +61 -0
- package/templates/backend/node_modules/mongodb/src/operations/execute_operation.ts +420 -0
- package/templates/backend/node_modules/mongodb/src/operations/find.ts +254 -0
- package/templates/backend/node_modules/mongodb/src/operations/find_and_modify.ts +319 -0
- package/templates/backend/node_modules/mongodb/src/operations/get_more.ts +108 -0
- package/templates/backend/node_modules/mongodb/src/operations/indexes.ts +418 -0
- package/templates/backend/node_modules/mongodb/src/operations/insert.ts +108 -0
- package/templates/backend/node_modules/mongodb/src/operations/kill_cursors.ts +64 -0
- package/templates/backend/node_modules/mongodb/src/operations/list_collections.ts +108 -0
- package/templates/backend/node_modules/mongodb/src/operations/list_databases.ts +68 -0
- package/templates/backend/node_modules/mongodb/src/operations/operation.ts +189 -0
- package/templates/backend/node_modules/mongodb/src/operations/profiling_level.ts +46 -0
- package/templates/backend/node_modules/mongodb/src/operations/remove_user.ts +36 -0
- package/templates/backend/node_modules/mongodb/src/operations/rename.ts +60 -0
- package/templates/backend/node_modules/mongodb/src/operations/run_command.ts +79 -0
- package/templates/backend/node_modules/mongodb/src/operations/search_indexes/create.ts +56 -0
- package/templates/backend/node_modules/mongodb/src/operations/search_indexes/drop.ts +58 -0
- package/templates/backend/node_modules/mongodb/src/operations/search_indexes/update.ts +45 -0
- package/templates/backend/node_modules/mongodb/src/operations/set_profiling_level.ts +74 -0
- package/templates/backend/node_modules/mongodb/src/operations/stats.ts +37 -0
- package/templates/backend/node_modules/mongodb/src/operations/update.ts +318 -0
- package/templates/backend/node_modules/mongodb/src/operations/validate_collection.ts +50 -0
- package/templates/backend/node_modules/mongodb/src/read_concern.ts +88 -0
- package/templates/backend/node_modules/mongodb/src/read_preference.ts +256 -0
- package/templates/backend/node_modules/mongodb/src/runtime_adapters.ts +64 -0
- package/templates/backend/node_modules/mongodb/src/sdam/common.ts +74 -0
- package/templates/backend/node_modules/mongodb/src/sdam/events.ts +219 -0
- package/templates/backend/node_modules/mongodb/src/sdam/monitor.ts +771 -0
- package/templates/backend/node_modules/mongodb/src/sdam/server.ts +595 -0
- package/templates/backend/node_modules/mongodb/src/sdam/server_description.ts +297 -0
- package/templates/backend/node_modules/mongodb/src/sdam/server_selection.ts +415 -0
- package/templates/backend/node_modules/mongodb/src/sdam/server_selection_events.ts +142 -0
- package/templates/backend/node_modules/mongodb/src/sdam/srv_polling.ts +146 -0
- package/templates/backend/node_modules/mongodb/src/sdam/topology.ts +1103 -0
- package/templates/backend/node_modules/mongodb/src/sdam/topology_description.ts +548 -0
- package/templates/backend/node_modules/mongodb/src/sessions.ts +1288 -0
- package/templates/backend/node_modules/mongodb/src/sort.ts +141 -0
- package/templates/backend/node_modules/mongodb/src/timeout.ts +405 -0
- package/templates/backend/node_modules/mongodb/src/transactions.ts +181 -0
- package/templates/backend/node_modules/mongodb/src/utils.ts +1429 -0
- package/templates/backend/node_modules/mongodb/src/write_concern.ts +183 -0
- package/templates/backend/node_modules/mongodb/tsconfig.json +46 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/.esm-wrapper.mjs +6 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/LICENSE +192 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/README.md +25 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/lib/index.d.ts +63 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/lib/index.js +239 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/lib/index.js.map +1 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/lib/redact.d.ts +7 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/lib/redact.js +97 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/lib/redact.js.map +1 -0
- package/templates/backend/node_modules/mongodb-connection-string-url/package.json +71 -0
- package/templates/backend/node_modules/mongoose/LICENSE.md +22 -0
- package/templates/backend/node_modules/mongoose/README.md +395 -0
- package/templates/backend/node_modules/mongoose/SECURITY.md +1 -0
- package/templates/backend/node_modules/mongoose/eslint.config.mjs +198 -0
- package/templates/backend/node_modules/mongoose/index.js +64 -0
- package/templates/backend/node_modules/mongoose/lib/aggregate.js +1226 -0
- package/templates/backend/node_modules/mongoose/lib/cast/bigint.js +46 -0
- package/templates/backend/node_modules/mongoose/lib/cast/boolean.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/cast/date.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/cast/decimal128.js +39 -0
- package/templates/backend/node_modules/mongoose/lib/cast/double.js +50 -0
- package/templates/backend/node_modules/mongoose/lib/cast/int32.js +36 -0
- package/templates/backend/node_modules/mongoose/lib/cast/number.js +42 -0
- package/templates/backend/node_modules/mongoose/lib/cast/objectid.js +29 -0
- package/templates/backend/node_modules/mongoose/lib/cast/string.js +37 -0
- package/templates/backend/node_modules/mongoose/lib/cast/uuid.js +35 -0
- package/templates/backend/node_modules/mongoose/lib/cast.js +436 -0
- package/templates/backend/node_modules/mongoose/lib/collection.js +321 -0
- package/templates/backend/node_modules/mongoose/lib/connection.js +1853 -0
- package/templates/backend/node_modules/mongoose/lib/connectionState.js +26 -0
- package/templates/backend/node_modules/mongoose/lib/constants.js +73 -0
- package/templates/backend/node_modules/mongoose/lib/cursor/aggregationCursor.js +466 -0
- package/templates/backend/node_modules/mongoose/lib/cursor/changeStream.js +218 -0
- package/templates/backend/node_modules/mongoose/lib/cursor/queryCursor.js +625 -0
- package/templates/backend/node_modules/mongoose/lib/document.js +5693 -0
- package/templates/backend/node_modules/mongoose/lib/driver.js +15 -0
- package/templates/backend/node_modules/mongoose/lib/drivers/SPEC.md +4 -0
- package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/bulkWriteResult.js +5 -0
- package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/collection.js +426 -0
- package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/connection.js +519 -0
- package/templates/backend/node_modules/mongoose/lib/drivers/node-mongodb-native/index.js +10 -0
- package/templates/backend/node_modules/mongoose/lib/error/browserMissingSchema.js +29 -0
- package/templates/backend/node_modules/mongoose/lib/error/bulkSaveIncompleteError.js +44 -0
- package/templates/backend/node_modules/mongoose/lib/error/bulkWriteError.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/error/cast.js +167 -0
- package/templates/backend/node_modules/mongoose/lib/error/createCollectionsError.js +26 -0
- package/templates/backend/node_modules/mongoose/lib/error/divergentArray.js +40 -0
- package/templates/backend/node_modules/mongoose/lib/error/eachAsyncMultiError.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/error/index.js +237 -0
- package/templates/backend/node_modules/mongoose/lib/error/invalidSchemaOption.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/error/messages.js +48 -0
- package/templates/backend/node_modules/mongoose/lib/error/missingSchema.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/error/mongooseError.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/error/notFound.js +47 -0
- package/templates/backend/node_modules/mongoose/lib/error/objectExpected.js +31 -0
- package/templates/backend/node_modules/mongoose/lib/error/objectParameter.js +31 -0
- package/templates/backend/node_modules/mongoose/lib/error/overwriteModel.js +31 -0
- package/templates/backend/node_modules/mongoose/lib/error/parallelSave.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/error/parallelValidate.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/error/serverSelection.js +62 -0
- package/templates/backend/node_modules/mongoose/lib/error/setOptionError.js +103 -0
- package/templates/backend/node_modules/mongoose/lib/error/strict.js +35 -0
- package/templates/backend/node_modules/mongoose/lib/error/strictPopulate.js +31 -0
- package/templates/backend/node_modules/mongoose/lib/error/syncIndexes.js +30 -0
- package/templates/backend/node_modules/mongoose/lib/error/validation.js +97 -0
- package/templates/backend/node_modules/mongoose/lib/error/validator.js +100 -0
- package/templates/backend/node_modules/mongoose/lib/error/version.js +38 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/aggregate/prepareDiscriminatorPipeline.js +39 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/aggregate/stringifyFunctionOperators.js +50 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/arrayDepth.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/buildMiddlewareFilter.js +24 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/clone.js +236 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/common.js +127 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/cursor/eachAsync.js +225 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/applyEmbeddedDiscriminators.js +36 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/areDiscriminatorValuesEqual.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/checkEmbeddedDiscriminatorKeyProjection.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/getConstructor.js +29 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/getDiscriminatorByValue.js +28 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/getSchemaDiscriminatorByValue.js +27 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/discriminator/mergeDiscriminatorSchema.js +96 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/applyDefaults.js +132 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/applyTimestamps.js +106 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/applyVirtuals.js +147 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/cleanModifiedSubpaths.js +45 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/compile.js +241 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/getDeepestSubdocumentForPath.js +38 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/getEmbeddedDiscriminatorPath.js +53 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/handleSpreadDoc.js +35 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/document/isInPathsToSave.js +24 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/each.js +25 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/error/combinePathErrors.js +22 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/firstKey.js +8 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/get.js +65 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/getConstructorName.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/getDefaultBulkwriteResult.js +18 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/getFunctionName.js +10 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/immediate.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/applySchemaCollation.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/decorateDiscriminatorIndexOptions.js +14 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/getRelatedIndexes.js +63 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isDefaultIdIndex.js +18 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isIndexEqual.js +95 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isIndexSpecEqual.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isTextIndex.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/indexes/isTimeseriesIndex.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isAsyncFunction.js +9 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isBsonType.js +15 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isMongooseObject.js +22 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isObject.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isPOJO.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isPromise.js +6 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/isSimpleValidator.js +22 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/minimize.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/applyDefaultsToPOJO.js +52 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/applyHooks.js +151 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/applyMethods.js +70 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/applyStaticHooks.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/applyStatics.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/castBulkWrite.js +322 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/decorateBulkWriteResult.js +8 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/discriminator.js +265 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/model/pushNestedArrayPaths.js +15 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/omitUndefined.js +20 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/once.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/parallelLimit.js +37 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/path/parentPaths.js +18 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/path/setDottedPath.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/pluralize.js +95 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/assignRawDocsToIdStructure.js +129 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/assignVals.js +360 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/createPopulateQueryFilter.js +97 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/getModelsMapForPopulate.js +894 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/getSchemaTypes.js +229 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/getVirtual.js +103 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/leanPopulateMap.js +7 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/lookupLocalFields.js +40 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/markArraySubdocsPopulated.js +49 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/modelNamesFromRefPath.js +74 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/removeDeselectedForeignField.js +31 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/setPopulatedVirtualValue.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/skipPopulateValue.js +10 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/populate/validateRef.js +19 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/printJestWarning.js +21 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/processConnectionOptions.js +65 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/applyProjection.js +83 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/hasIncludedChildren.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isDefiningProjection.js +18 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isExclusive.js +37 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isInclusive.js +39 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isNestedProjection.js +8 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isPathExcluded.js +40 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isPathSelectedInclusive.js +28 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/isSubpath.js +14 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/projection/parseProjection.js +38 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/applyGlobalOption.js +29 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/cast$expr.js +287 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/castFilterPath.js +54 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/castUpdate.js +647 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/getEmbeddedDiscriminatorPath.js +103 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/handleImmutable.js +44 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/handleReadPreferenceAliases.js +23 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/hasDollarKeys.js +23 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/isOperator.js +14 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/sanitizeFilter.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/sanitizeProjection.js +14 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/selectPopulatedFields.js +62 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/trusted.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/query/validOps.js +3 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/addAutoId.js +7 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyBuiltinPlugins.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyPlugins.js +55 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyReadConcern.js +20 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/applyWriteConcern.js +39 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/cleanPositionalOperators.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/getIndexes.js +171 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/getKeysInSchemaOrder.js +28 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/getPath.js +43 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/getSubdocumentStrictValue.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/handleIdOption.js +20 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/handleTimestampOption.js +24 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/idGetter.js +34 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schema/merge.js +36 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/schematype/handleImmutable.js +50 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/setDefaultsOnInsert.js +174 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/specialProperties.js +3 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/symbols.js +20 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/timers.js +3 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/timestamps/setDocumentTimestamps.js +26 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/timestamps/setupTimestamps.js +132 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/topology/allServersUnknown.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/topology/isAtlas.js +31 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/topology/isSSLError.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/applyTimestampsToChildren.js +193 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/applyTimestampsToUpdate.js +131 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/castArrayFilters.js +113 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/decorateUpdateWithVersionKey.js +35 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/modifiedPaths.js +33 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/moveImmutableProperties.js +53 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/removeUnusedArrayFilters.js +37 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/update/updatedPathsByArrayFilter.js +27 -0
- package/templates/backend/node_modules/mongoose/lib/helpers/updateValidators.js +186 -0
- package/templates/backend/node_modules/mongoose/lib/index.js +17 -0
- package/templates/backend/node_modules/mongoose/lib/internal.js +46 -0
- package/templates/backend/node_modules/mongoose/lib/model.js +5202 -0
- package/templates/backend/node_modules/mongoose/lib/modifiedPathsSnapshot.js +9 -0
- package/templates/backend/node_modules/mongoose/lib/mongoose.js +1435 -0
- package/templates/backend/node_modules/mongoose/lib/options/populateOptions.js +36 -0
- package/templates/backend/node_modules/mongoose/lib/options/propertyOptions.js +8 -0
- package/templates/backend/node_modules/mongoose/lib/options/saveOptions.js +16 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaArrayOptions.js +78 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaBufferOptions.js +38 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaDateOptions.js +71 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaDocumentArrayOptions.js +91 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaMapOptions.js +43 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaNumberOptions.js +101 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaObjectIdOptions.js +64 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaStringOptions.js +138 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaSubdocumentOptions.js +89 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaTypeOptions.js +258 -0
- package/templates/backend/node_modules/mongoose/lib/options/schemaUnionOptions.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/options/virtualOptions.js +164 -0
- package/templates/backend/node_modules/mongoose/lib/options.js +18 -0
- package/templates/backend/node_modules/mongoose/lib/plugins/index.js +5 -0
- package/templates/backend/node_modules/mongoose/lib/plugins/saveSubdocs.js +94 -0
- package/templates/backend/node_modules/mongoose/lib/plugins/sharding.js +101 -0
- package/templates/backend/node_modules/mongoose/lib/plugins/trackTransaction.js +89 -0
- package/templates/backend/node_modules/mongoose/lib/query.js +5845 -0
- package/templates/backend/node_modules/mongoose/lib/queryHelpers.js +396 -0
- package/templates/backend/node_modules/mongoose/lib/schema/array.js +700 -0
- package/templates/backend/node_modules/mongoose/lib/schema/bigint.js +280 -0
- package/templates/backend/node_modules/mongoose/lib/schema/boolean.js +330 -0
- package/templates/backend/node_modules/mongoose/lib/schema/buffer.js +341 -0
- package/templates/backend/node_modules/mongoose/lib/schema/date.js +465 -0
- package/templates/backend/node_modules/mongoose/lib/schema/decimal128.js +261 -0
- package/templates/backend/node_modules/mongoose/lib/schema/documentArray.js +664 -0
- package/templates/backend/node_modules/mongoose/lib/schema/documentArrayElement.js +136 -0
- package/templates/backend/node_modules/mongoose/lib/schema/double.js +244 -0
- package/templates/backend/node_modules/mongoose/lib/schema/index.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/schema/int32.js +287 -0
- package/templates/backend/node_modules/mongoose/lib/schema/map.js +194 -0
- package/templates/backend/node_modules/mongoose/lib/schema/mixed.js +146 -0
- package/templates/backend/node_modules/mongoose/lib/schema/number.js +508 -0
- package/templates/backend/node_modules/mongoose/lib/schema/objectId.js +331 -0
- package/templates/backend/node_modules/mongoose/lib/schema/operators/bitwise.js +38 -0
- package/templates/backend/node_modules/mongoose/lib/schema/operators/exists.js +12 -0
- package/templates/backend/node_modules/mongoose/lib/schema/operators/geospatial.js +107 -0
- package/templates/backend/node_modules/mongoose/lib/schema/operators/helpers.js +32 -0
- package/templates/backend/node_modules/mongoose/lib/schema/operators/text.js +39 -0
- package/templates/backend/node_modules/mongoose/lib/schema/operators/type.js +20 -0
- package/templates/backend/node_modules/mongoose/lib/schema/string.js +731 -0
- package/templates/backend/node_modules/mongoose/lib/schema/subdocument.js +434 -0
- package/templates/backend/node_modules/mongoose/lib/schema/symbols.js +5 -0
- package/templates/backend/node_modules/mongoose/lib/schema/union.js +163 -0
- package/templates/backend/node_modules/mongoose/lib/schema/uuid.js +303 -0
- package/templates/backend/node_modules/mongoose/lib/schema.js +3244 -0
- package/templates/backend/node_modules/mongoose/lib/schemaType.js +1928 -0
- package/templates/backend/node_modules/mongoose/lib/stateMachine.js +229 -0
- package/templates/backend/node_modules/mongoose/lib/types/array/index.js +119 -0
- package/templates/backend/node_modules/mongoose/lib/types/array/isMongooseArray.js +5 -0
- package/templates/backend/node_modules/mongoose/lib/types/array/methods/index.js +1095 -0
- package/templates/backend/node_modules/mongoose/lib/types/arraySubdocument.js +208 -0
- package/templates/backend/node_modules/mongoose/lib/types/buffer.js +294 -0
- package/templates/backend/node_modules/mongoose/lib/types/decimal128.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/types/documentArray/index.js +113 -0
- package/templates/backend/node_modules/mongoose/lib/types/documentArray/isMongooseDocumentArray.js +5 -0
- package/templates/backend/node_modules/mongoose/lib/types/documentArray/methods/index.js +415 -0
- package/templates/backend/node_modules/mongoose/lib/types/double.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/types/index.js +23 -0
- package/templates/backend/node_modules/mongoose/lib/types/map.js +368 -0
- package/templates/backend/node_modules/mongoose/lib/types/objectid.js +41 -0
- package/templates/backend/node_modules/mongoose/lib/types/subdocument.js +443 -0
- package/templates/backend/node_modules/mongoose/lib/types/uuid.js +13 -0
- package/templates/backend/node_modules/mongoose/lib/utils.js +1064 -0
- package/templates/backend/node_modules/mongoose/lib/validOptions.js +43 -0
- package/templates/backend/node_modules/mongoose/lib/virtualType.js +204 -0
- package/templates/backend/node_modules/mongoose/package.json +139 -0
- package/templates/backend/node_modules/mongoose/tstyche.json +7 -0
- package/templates/backend/node_modules/mongoose/types/aggregate.d.ts +185 -0
- package/templates/backend/node_modules/mongoose/types/augmentations.d.ts +9 -0
- package/templates/backend/node_modules/mongoose/types/callback.d.ts +8 -0
- package/templates/backend/node_modules/mongoose/types/collection.d.ts +49 -0
- package/templates/backend/node_modules/mongoose/types/connection.d.ts +297 -0
- package/templates/backend/node_modules/mongoose/types/cursor.d.ts +67 -0
- package/templates/backend/node_modules/mongoose/types/document.d.ts +328 -0
- package/templates/backend/node_modules/mongoose/types/error.d.ts +143 -0
- package/templates/backend/node_modules/mongoose/types/expressions.d.ts +3053 -0
- package/templates/backend/node_modules/mongoose/types/helpers.d.ts +32 -0
- package/templates/backend/node_modules/mongoose/types/index.d.ts +1161 -0
- package/templates/backend/node_modules/mongoose/types/indexes.d.ts +97 -0
- package/templates/backend/node_modules/mongoose/types/inferhydrateddoctype.d.ts +135 -0
- package/templates/backend/node_modules/mongoose/types/inferrawdoctype.d.ts +185 -0
- package/templates/backend/node_modules/mongoose/types/inferschematype.d.ts +387 -0
- package/templates/backend/node_modules/mongoose/types/middlewares.d.ts +66 -0
- package/templates/backend/node_modules/mongoose/types/models.d.ts +1265 -0
- package/templates/backend/node_modules/mongoose/types/mongooseoptions.d.ts +232 -0
- package/templates/backend/node_modules/mongoose/types/pipelinestage.d.ts +334 -0
- package/templates/backend/node_modules/mongoose/types/populate.d.ts +97 -0
- package/templates/backend/node_modules/mongoose/types/query.d.ts +982 -0
- package/templates/backend/node_modules/mongoose/types/schemaoptions.d.ts +284 -0
- package/templates/backend/node_modules/mongoose/types/schematypes.d.ts +667 -0
- package/templates/backend/node_modules/mongoose/types/session.d.ts +32 -0
- package/templates/backend/node_modules/mongoose/types/types.d.ts +109 -0
- package/templates/backend/node_modules/mongoose/types/utility.d.ts +175 -0
- package/templates/backend/node_modules/mongoose/types/validation.d.ts +39 -0
- package/templates/backend/node_modules/mongoose/types/virtuals.d.ts +14 -0
- package/templates/backend/node_modules/mpath/.travis.yml +9 -0
- package/templates/backend/node_modules/mpath/History.md +88 -0
- package/templates/backend/node_modules/mpath/LICENSE +22 -0
- package/templates/backend/node_modules/mpath/README.md +278 -0
- package/templates/backend/node_modules/mpath/SECURITY.md +5 -0
- package/templates/backend/node_modules/mpath/index.js +3 -0
- package/templates/backend/node_modules/mpath/lib/index.js +336 -0
- package/templates/backend/node_modules/mpath/lib/stringToParts.js +48 -0
- package/templates/backend/node_modules/mpath/package.json +144 -0
- package/templates/backend/node_modules/mpath/test/.eslintrc.yml +4 -0
- package/templates/backend/node_modules/mpath/test/index.js +1879 -0
- package/templates/backend/node_modules/mpath/test/stringToParts.js +30 -0
- package/templates/backend/node_modules/mquery/.github/ISSUE_TEMPLATE.md +11 -0
- package/templates/backend/node_modules/mquery/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- package/templates/backend/node_modules/mquery/History.md +393 -0
- package/templates/backend/node_modules/mquery/LICENSE +22 -0
- package/templates/backend/node_modules/mquery/README.md +1387 -0
- package/templates/backend/node_modules/mquery/SECURITY.md +1 -0
- package/templates/backend/node_modules/mquery/lib/collection/collection.js +47 -0
- package/templates/backend/node_modules/mquery/lib/collection/index.js +13 -0
- package/templates/backend/node_modules/mquery/lib/collection/node.js +128 -0
- package/templates/backend/node_modules/mquery/lib/env.js +22 -0
- package/templates/backend/node_modules/mquery/lib/mquery.js +2748 -0
- package/templates/backend/node_modules/mquery/lib/permissions.js +93 -0
- package/templates/backend/node_modules/mquery/lib/utils.js +297 -0
- package/templates/backend/node_modules/mquery/package.json +35 -0
- package/templates/backend/node_modules/ms/index.js +162 -0
- package/templates/backend/node_modules/ms/license.md +21 -0
- package/templates/backend/node_modules/ms/package.json +38 -0
- package/templates/backend/node_modules/ms/readme.md +59 -0
- package/templates/backend/node_modules/negotiator/HISTORY.md +114 -0
- package/templates/backend/node_modules/negotiator/LICENSE +24 -0
- package/templates/backend/node_modules/negotiator/README.md +212 -0
- package/templates/backend/node_modules/negotiator/index.js +83 -0
- package/templates/backend/node_modules/negotiator/lib/charset.js +169 -0
- package/templates/backend/node_modules/negotiator/lib/encoding.js +205 -0
- package/templates/backend/node_modules/negotiator/lib/language.js +179 -0
- package/templates/backend/node_modules/negotiator/lib/mediaType.js +294 -0
- package/templates/backend/node_modules/negotiator/package.json +43 -0
- package/templates/backend/node_modules/nodemon/.prettierrc.json +3 -0
- package/templates/backend/node_modules/nodemon/LICENSE +21 -0
- package/templates/backend/node_modules/nodemon/README.md +439 -0
- package/templates/backend/node_modules/nodemon/bin/nodemon.js +16 -0
- package/templates/backend/node_modules/nodemon/bin/windows-kill.exe +0 -0
- package/templates/backend/node_modules/nodemon/doc/cli/authors.txt +8 -0
- package/templates/backend/node_modules/nodemon/doc/cli/config.txt +44 -0
- package/templates/backend/node_modules/nodemon/doc/cli/help.txt +29 -0
- package/templates/backend/node_modules/nodemon/doc/cli/logo.txt +20 -0
- package/templates/backend/node_modules/nodemon/doc/cli/options.txt +36 -0
- package/templates/backend/node_modules/nodemon/doc/cli/topics.txt +8 -0
- package/templates/backend/node_modules/nodemon/doc/cli/usage.txt +3 -0
- package/templates/backend/node_modules/nodemon/doc/cli/whoami.txt +9 -0
- package/templates/backend/node_modules/nodemon/index.d.ts +124 -0
- package/templates/backend/node_modules/nodemon/jsconfig.json +7 -0
- package/templates/backend/node_modules/nodemon/lib/cli/index.js +49 -0
- package/templates/backend/node_modules/nodemon/lib/cli/parse.js +230 -0
- package/templates/backend/node_modules/nodemon/lib/config/command.js +43 -0
- package/templates/backend/node_modules/nodemon/lib/config/defaults.js +34 -0
- package/templates/backend/node_modules/nodemon/lib/config/exec.js +240 -0
- package/templates/backend/node_modules/nodemon/lib/config/index.js +93 -0
- package/templates/backend/node_modules/nodemon/lib/config/load.js +225 -0
- package/templates/backend/node_modules/nodemon/lib/help/index.js +27 -0
- package/templates/backend/node_modules/nodemon/lib/index.js +1 -0
- package/templates/backend/node_modules/nodemon/lib/monitor/index.js +4 -0
- package/templates/backend/node_modules/nodemon/lib/monitor/match.js +288 -0
- package/templates/backend/node_modules/nodemon/lib/monitor/run.js +562 -0
- package/templates/backend/node_modules/nodemon/lib/monitor/signals.js +34 -0
- package/templates/backend/node_modules/nodemon/lib/monitor/watch.js +244 -0
- package/templates/backend/node_modules/nodemon/lib/nodemon.js +317 -0
- package/templates/backend/node_modules/nodemon/lib/rules/add.js +89 -0
- package/templates/backend/node_modules/nodemon/lib/rules/index.js +53 -0
- package/templates/backend/node_modules/nodemon/lib/rules/parse.js +43 -0
- package/templates/backend/node_modules/nodemon/lib/spawn.js +74 -0
- package/templates/backend/node_modules/nodemon/lib/utils/bus.js +44 -0
- package/templates/backend/node_modules/nodemon/lib/utils/clone.js +40 -0
- package/templates/backend/node_modules/nodemon/lib/utils/colour.js +26 -0
- package/templates/backend/node_modules/nodemon/lib/utils/index.js +103 -0
- package/templates/backend/node_modules/nodemon/lib/utils/log.js +82 -0
- package/templates/backend/node_modules/nodemon/lib/utils/merge.js +47 -0
- package/templates/backend/node_modules/nodemon/lib/version.js +100 -0
- package/templates/backend/node_modules/nodemon/package.json +78 -0
- package/templates/backend/node_modules/normalize-path/LICENSE +21 -0
- package/templates/backend/node_modules/normalize-path/README.md +127 -0
- package/templates/backend/node_modules/normalize-path/index.js +35 -0
- package/templates/backend/node_modules/normalize-path/package.json +77 -0
- package/templates/backend/node_modules/object-assign/index.js +90 -0
- package/templates/backend/node_modules/object-assign/license +21 -0
- package/templates/backend/node_modules/object-assign/package.json +42 -0
- package/templates/backend/node_modules/object-assign/readme.md +61 -0
- package/templates/backend/node_modules/object-inspect/.eslintrc +53 -0
- package/templates/backend/node_modules/object-inspect/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/object-inspect/.nycrc +13 -0
- package/templates/backend/node_modules/object-inspect/CHANGELOG.md +424 -0
- package/templates/backend/node_modules/object-inspect/LICENSE +21 -0
- package/templates/backend/node_modules/object-inspect/example/all.js +23 -0
- package/templates/backend/node_modules/object-inspect/example/circular.js +6 -0
- package/templates/backend/node_modules/object-inspect/example/fn.js +5 -0
- package/templates/backend/node_modules/object-inspect/example/inspect.js +10 -0
- package/templates/backend/node_modules/object-inspect/index.js +544 -0
- package/templates/backend/node_modules/object-inspect/package-support.json +20 -0
- package/templates/backend/node_modules/object-inspect/package.json +105 -0
- package/templates/backend/node_modules/object-inspect/readme.markdown +84 -0
- package/templates/backend/node_modules/object-inspect/test/bigint.js +58 -0
- package/templates/backend/node_modules/object-inspect/test/browser/dom.js +15 -0
- package/templates/backend/node_modules/object-inspect/test/circular.js +16 -0
- package/templates/backend/node_modules/object-inspect/test/deep.js +12 -0
- package/templates/backend/node_modules/object-inspect/test/element.js +53 -0
- package/templates/backend/node_modules/object-inspect/test/err.js +48 -0
- package/templates/backend/node_modules/object-inspect/test/fakes.js +29 -0
- package/templates/backend/node_modules/object-inspect/test/fn.js +76 -0
- package/templates/backend/node_modules/object-inspect/test/global.js +17 -0
- package/templates/backend/node_modules/object-inspect/test/has.js +15 -0
- package/templates/backend/node_modules/object-inspect/test/holes.js +15 -0
- package/templates/backend/node_modules/object-inspect/test/indent-option.js +271 -0
- package/templates/backend/node_modules/object-inspect/test/inspect.js +139 -0
- package/templates/backend/node_modules/object-inspect/test/lowbyte.js +12 -0
- package/templates/backend/node_modules/object-inspect/test/number.js +58 -0
- package/templates/backend/node_modules/object-inspect/test/quoteStyle.js +26 -0
- package/templates/backend/node_modules/object-inspect/test/toStringTag.js +40 -0
- package/templates/backend/node_modules/object-inspect/test/undef.js +12 -0
- package/templates/backend/node_modules/object-inspect/test/values.js +261 -0
- package/templates/backend/node_modules/object-inspect/test-core-js.js +26 -0
- package/templates/backend/node_modules/object-inspect/util.inspect.js +1 -0
- package/templates/backend/node_modules/on-finished/HISTORY.md +98 -0
- package/templates/backend/node_modules/on-finished/LICENSE +23 -0
- package/templates/backend/node_modules/on-finished/README.md +162 -0
- package/templates/backend/node_modules/on-finished/index.js +234 -0
- package/templates/backend/node_modules/on-finished/package.json +39 -0
- package/templates/backend/node_modules/once/LICENSE +15 -0
- package/templates/backend/node_modules/once/README.md +79 -0
- package/templates/backend/node_modules/once/once.js +42 -0
- package/templates/backend/node_modules/once/package.json +33 -0
- package/templates/backend/node_modules/parseurl/HISTORY.md +58 -0
- package/templates/backend/node_modules/parseurl/LICENSE +24 -0
- package/templates/backend/node_modules/parseurl/README.md +133 -0
- package/templates/backend/node_modules/parseurl/index.js +158 -0
- package/templates/backend/node_modules/parseurl/package.json +40 -0
- package/templates/backend/node_modules/path-to-regexp/LICENSE +21 -0
- package/templates/backend/node_modules/path-to-regexp/Readme.md +224 -0
- package/templates/backend/node_modules/path-to-regexp/dist/index.d.ts +147 -0
- package/templates/backend/node_modules/path-to-regexp/dist/index.js +431 -0
- package/templates/backend/node_modules/path-to-regexp/dist/index.js.map +1 -0
- package/templates/backend/node_modules/path-to-regexp/package.json +64 -0
- package/templates/backend/node_modules/picomatch/LICENSE +21 -0
- package/templates/backend/node_modules/picomatch/README.md +716 -0
- package/templates/backend/node_modules/picomatch/index.js +3 -0
- package/templates/backend/node_modules/picomatch/lib/constants.js +184 -0
- package/templates/backend/node_modules/picomatch/lib/parse.js +1392 -0
- package/templates/backend/node_modules/picomatch/lib/picomatch.js +342 -0
- package/templates/backend/node_modules/picomatch/lib/scan.js +391 -0
- package/templates/backend/node_modules/picomatch/lib/utils.js +64 -0
- package/templates/backend/node_modules/picomatch/package.json +81 -0
- package/templates/backend/node_modules/proxy-addr/HISTORY.md +161 -0
- package/templates/backend/node_modules/proxy-addr/LICENSE +22 -0
- package/templates/backend/node_modules/proxy-addr/README.md +139 -0
- package/templates/backend/node_modules/proxy-addr/index.js +327 -0
- package/templates/backend/node_modules/proxy-addr/package.json +47 -0
- package/templates/backend/node_modules/pstree.remy/.travis.yml +8 -0
- package/templates/backend/node_modules/pstree.remy/LICENSE +7 -0
- package/templates/backend/node_modules/pstree.remy/README.md +26 -0
- package/templates/backend/node_modules/pstree.remy/lib/index.js +37 -0
- package/templates/backend/node_modules/pstree.remy/lib/tree.js +37 -0
- package/templates/backend/node_modules/pstree.remy/lib/utils.js +53 -0
- package/templates/backend/node_modules/pstree.remy/package.json +33 -0
- package/templates/backend/node_modules/pstree.remy/tests/fixtures/index.js +13 -0
- package/templates/backend/node_modules/pstree.remy/tests/fixtures/out1 +10 -0
- package/templates/backend/node_modules/pstree.remy/tests/fixtures/out2 +29 -0
- package/templates/backend/node_modules/pstree.remy/tests/index.test.js +51 -0
- package/templates/backend/node_modules/punycode/LICENSE-MIT.txt +20 -0
- package/templates/backend/node_modules/punycode/README.md +148 -0
- package/templates/backend/node_modules/punycode/package.json +58 -0
- package/templates/backend/node_modules/punycode/punycode.es6.js +444 -0
- package/templates/backend/node_modules/punycode/punycode.js +443 -0
- package/templates/backend/node_modules/qs/.editorconfig +46 -0
- package/templates/backend/node_modules/qs/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/qs/.github/SECURITY.md +11 -0
- package/templates/backend/node_modules/qs/.github/THREAT_MODEL.md +78 -0
- package/templates/backend/node_modules/qs/.nycrc +13 -0
- package/templates/backend/node_modules/qs/CHANGELOG.md +822 -0
- package/templates/backend/node_modules/qs/LICENSE.md +29 -0
- package/templates/backend/node_modules/qs/README.md +758 -0
- package/templates/backend/node_modules/qs/dist/qs.js +141 -0
- package/templates/backend/node_modules/qs/eslint.config.mjs +57 -0
- package/templates/backend/node_modules/qs/lib/formats.js +23 -0
- package/templates/backend/node_modules/qs/lib/index.js +11 -0
- package/templates/backend/node_modules/qs/lib/parse.js +403 -0
- package/templates/backend/node_modules/qs/lib/stringify.js +363 -0
- package/templates/backend/node_modules/qs/lib/utils.js +342 -0
- package/templates/backend/node_modules/qs/package.json +94 -0
- package/templates/backend/node_modules/qs/test/empty-keys-cases.js +267 -0
- package/templates/backend/node_modules/qs/test/parse.js +1703 -0
- package/templates/backend/node_modules/qs/test/stringify.js +1448 -0
- package/templates/backend/node_modules/qs/test/utils.js +432 -0
- package/templates/backend/node_modules/range-parser/HISTORY.md +56 -0
- package/templates/backend/node_modules/range-parser/LICENSE +23 -0
- package/templates/backend/node_modules/range-parser/README.md +84 -0
- package/templates/backend/node_modules/range-parser/index.js +162 -0
- package/templates/backend/node_modules/range-parser/package.json +44 -0
- package/templates/backend/node_modules/raw-body/LICENSE +22 -0
- package/templates/backend/node_modules/raw-body/README.md +223 -0
- package/templates/backend/node_modules/raw-body/index.d.ts +85 -0
- package/templates/backend/node_modules/raw-body/index.js +336 -0
- package/templates/backend/node_modules/raw-body/package.json +46 -0
- package/templates/backend/node_modules/readdirp/LICENSE +21 -0
- package/templates/backend/node_modules/readdirp/README.md +122 -0
- package/templates/backend/node_modules/readdirp/index.d.ts +43 -0
- package/templates/backend/node_modules/readdirp/index.js +287 -0
- package/templates/backend/node_modules/readdirp/package.json +122 -0
- package/templates/backend/node_modules/router/HISTORY.md +228 -0
- package/templates/backend/node_modules/router/LICENSE +23 -0
- package/templates/backend/node_modules/router/README.md +416 -0
- package/templates/backend/node_modules/router/index.js +748 -0
- package/templates/backend/node_modules/router/lib/layer.js +247 -0
- package/templates/backend/node_modules/router/lib/route.js +242 -0
- package/templates/backend/node_modules/router/package.json +44 -0
- package/templates/backend/node_modules/safe-buffer/LICENSE +21 -0
- package/templates/backend/node_modules/safe-buffer/README.md +584 -0
- package/templates/backend/node_modules/safe-buffer/index.d.ts +187 -0
- package/templates/backend/node_modules/safe-buffer/index.js +65 -0
- package/templates/backend/node_modules/safe-buffer/package.json +51 -0
- package/templates/backend/node_modules/safer-buffer/LICENSE +21 -0
- package/templates/backend/node_modules/safer-buffer/Porting-Buffer.md +268 -0
- package/templates/backend/node_modules/safer-buffer/Readme.md +156 -0
- package/templates/backend/node_modules/safer-buffer/dangerous.js +58 -0
- package/templates/backend/node_modules/safer-buffer/package.json +34 -0
- package/templates/backend/node_modules/safer-buffer/safer.js +77 -0
- package/templates/backend/node_modules/safer-buffer/tests.js +406 -0
- package/templates/backend/node_modules/semver/LICENSE +15 -0
- package/templates/backend/node_modules/semver/README.md +680 -0
- package/templates/backend/node_modules/semver/bin/semver.js +195 -0
- package/templates/backend/node_modules/semver/classes/comparator.js +143 -0
- package/templates/backend/node_modules/semver/classes/index.js +7 -0
- package/templates/backend/node_modules/semver/classes/range.js +557 -0
- package/templates/backend/node_modules/semver/classes/semver.js +333 -0
- package/templates/backend/node_modules/semver/functions/clean.js +8 -0
- package/templates/backend/node_modules/semver/functions/cmp.js +54 -0
- package/templates/backend/node_modules/semver/functions/coerce.js +62 -0
- package/templates/backend/node_modules/semver/functions/compare-build.js +9 -0
- package/templates/backend/node_modules/semver/functions/compare-loose.js +5 -0
- package/templates/backend/node_modules/semver/functions/compare.js +7 -0
- package/templates/backend/node_modules/semver/functions/diff.js +60 -0
- package/templates/backend/node_modules/semver/functions/eq.js +5 -0
- package/templates/backend/node_modules/semver/functions/gt.js +5 -0
- package/templates/backend/node_modules/semver/functions/gte.js +5 -0
- package/templates/backend/node_modules/semver/functions/inc.js +21 -0
- package/templates/backend/node_modules/semver/functions/lt.js +5 -0
- package/templates/backend/node_modules/semver/functions/lte.js +5 -0
- package/templates/backend/node_modules/semver/functions/major.js +5 -0
- package/templates/backend/node_modules/semver/functions/minor.js +5 -0
- package/templates/backend/node_modules/semver/functions/neq.js +5 -0
- package/templates/backend/node_modules/semver/functions/parse.js +18 -0
- package/templates/backend/node_modules/semver/functions/patch.js +5 -0
- package/templates/backend/node_modules/semver/functions/prerelease.js +8 -0
- package/templates/backend/node_modules/semver/functions/rcompare.js +5 -0
- package/templates/backend/node_modules/semver/functions/rsort.js +5 -0
- package/templates/backend/node_modules/semver/functions/satisfies.js +12 -0
- package/templates/backend/node_modules/semver/functions/sort.js +5 -0
- package/templates/backend/node_modules/semver/functions/truncate.js +48 -0
- package/templates/backend/node_modules/semver/functions/valid.js +8 -0
- package/templates/backend/node_modules/semver/index.js +93 -0
- package/templates/backend/node_modules/semver/internal/constants.js +37 -0
- package/templates/backend/node_modules/semver/internal/debug.js +11 -0
- package/templates/backend/node_modules/semver/internal/identifiers.js +29 -0
- package/templates/backend/node_modules/semver/internal/lrucache.js +42 -0
- package/templates/backend/node_modules/semver/internal/parse-options.js +17 -0
- package/templates/backend/node_modules/semver/internal/re.js +223 -0
- package/templates/backend/node_modules/semver/package.json +78 -0
- package/templates/backend/node_modules/semver/preload.js +4 -0
- package/templates/backend/node_modules/semver/range.bnf +17 -0
- package/templates/backend/node_modules/semver/ranges/gtr.js +6 -0
- package/templates/backend/node_modules/semver/ranges/intersects.js +9 -0
- package/templates/backend/node_modules/semver/ranges/ltr.js +6 -0
- package/templates/backend/node_modules/semver/ranges/max-satisfying.js +27 -0
- package/templates/backend/node_modules/semver/ranges/min-satisfying.js +26 -0
- package/templates/backend/node_modules/semver/ranges/min-version.js +63 -0
- package/templates/backend/node_modules/semver/ranges/outside.js +82 -0
- package/templates/backend/node_modules/semver/ranges/simplify.js +49 -0
- package/templates/backend/node_modules/semver/ranges/subset.js +249 -0
- package/templates/backend/node_modules/semver/ranges/to-comparators.js +10 -0
- package/templates/backend/node_modules/semver/ranges/valid.js +13 -0
- package/templates/backend/node_modules/send/LICENSE +23 -0
- package/templates/backend/node_modules/send/README.md +317 -0
- package/templates/backend/node_modules/send/index.js +997 -0
- package/templates/backend/node_modules/send/package.json +63 -0
- package/templates/backend/node_modules/serve-static/LICENSE +25 -0
- package/templates/backend/node_modules/serve-static/README.md +253 -0
- package/templates/backend/node_modules/serve-static/index.js +208 -0
- package/templates/backend/node_modules/serve-static/package.json +44 -0
- package/templates/backend/node_modules/setprototypeof/LICENSE +13 -0
- package/templates/backend/node_modules/setprototypeof/README.md +31 -0
- package/templates/backend/node_modules/setprototypeof/index.d.ts +2 -0
- package/templates/backend/node_modules/setprototypeof/index.js +17 -0
- package/templates/backend/node_modules/setprototypeof/package.json +38 -0
- package/templates/backend/node_modules/setprototypeof/test/index.js +24 -0
- package/templates/backend/node_modules/side-channel/.editorconfig +9 -0
- package/templates/backend/node_modules/side-channel/.eslintrc +12 -0
- package/templates/backend/node_modules/side-channel/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/side-channel/.nycrc +13 -0
- package/templates/backend/node_modules/side-channel/CHANGELOG.md +110 -0
- package/templates/backend/node_modules/side-channel/LICENSE +21 -0
- package/templates/backend/node_modules/side-channel/README.md +61 -0
- package/templates/backend/node_modules/side-channel/index.d.ts +14 -0
- package/templates/backend/node_modules/side-channel/index.js +43 -0
- package/templates/backend/node_modules/side-channel/package.json +85 -0
- package/templates/backend/node_modules/side-channel/test/index.js +104 -0
- package/templates/backend/node_modules/side-channel/tsconfig.json +9 -0
- package/templates/backend/node_modules/side-channel-list/.editorconfig +9 -0
- package/templates/backend/node_modules/side-channel-list/.eslintrc +11 -0
- package/templates/backend/node_modules/side-channel-list/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/side-channel-list/.nycrc +13 -0
- package/templates/backend/node_modules/side-channel-list/CHANGELOG.md +36 -0
- package/templates/backend/node_modules/side-channel-list/LICENSE +21 -0
- package/templates/backend/node_modules/side-channel-list/README.md +62 -0
- package/templates/backend/node_modules/side-channel-list/index.d.ts +13 -0
- package/templates/backend/node_modules/side-channel-list/index.js +111 -0
- package/templates/backend/node_modules/side-channel-list/list.d.ts +14 -0
- package/templates/backend/node_modules/side-channel-list/package.json +77 -0
- package/templates/backend/node_modules/side-channel-list/test/index.js +154 -0
- package/templates/backend/node_modules/side-channel-list/tsconfig.json +9 -0
- package/templates/backend/node_modules/side-channel-map/.editorconfig +9 -0
- package/templates/backend/node_modules/side-channel-map/.eslintrc +11 -0
- package/templates/backend/node_modules/side-channel-map/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/side-channel-map/.nycrc +13 -0
- package/templates/backend/node_modules/side-channel-map/CHANGELOG.md +22 -0
- package/templates/backend/node_modules/side-channel-map/LICENSE +21 -0
- package/templates/backend/node_modules/side-channel-map/README.md +62 -0
- package/templates/backend/node_modules/side-channel-map/index.d.ts +15 -0
- package/templates/backend/node_modules/side-channel-map/index.js +68 -0
- package/templates/backend/node_modules/side-channel-map/package.json +80 -0
- package/templates/backend/node_modules/side-channel-map/test/index.js +114 -0
- package/templates/backend/node_modules/side-channel-map/tsconfig.json +9 -0
- package/templates/backend/node_modules/side-channel-weakmap/.editorconfig +9 -0
- package/templates/backend/node_modules/side-channel-weakmap/.eslintrc +12 -0
- package/templates/backend/node_modules/side-channel-weakmap/.github/FUNDING.yml +12 -0
- package/templates/backend/node_modules/side-channel-weakmap/.nycrc +13 -0
- package/templates/backend/node_modules/side-channel-weakmap/CHANGELOG.md +28 -0
- package/templates/backend/node_modules/side-channel-weakmap/LICENSE +21 -0
- package/templates/backend/node_modules/side-channel-weakmap/README.md +62 -0
- package/templates/backend/node_modules/side-channel-weakmap/index.d.ts +15 -0
- package/templates/backend/node_modules/side-channel-weakmap/index.js +84 -0
- package/templates/backend/node_modules/side-channel-weakmap/package.json +87 -0
- package/templates/backend/node_modules/side-channel-weakmap/test/index.js +114 -0
- package/templates/backend/node_modules/side-channel-weakmap/tsconfig.json +9 -0
- package/templates/backend/node_modules/sift/MIT-LICENSE.txt +20 -0
- package/templates/backend/node_modules/sift/README.md +465 -0
- package/templates/backend/node_modules/sift/es/index.js +632 -0
- package/templates/backend/node_modules/sift/es/index.js.map +1 -0
- package/templates/backend/node_modules/sift/es5m/index.js +743 -0
- package/templates/backend/node_modules/sift/es5m/index.js.map +1 -0
- package/templates/backend/node_modules/sift/index.d.ts +4 -0
- package/templates/backend/node_modules/sift/index.js +4 -0
- package/templates/backend/node_modules/sift/lib/core.d.ts +116 -0
- package/templates/backend/node_modules/sift/lib/index.d.ts +6 -0
- package/templates/backend/node_modules/sift/lib/index.js +781 -0
- package/templates/backend/node_modules/sift/lib/index.js.map +1 -0
- package/templates/backend/node_modules/sift/lib/operations.d.ts +88 -0
- package/templates/backend/node_modules/sift/lib/utils.d.ts +11 -0
- package/templates/backend/node_modules/sift/package.json +61 -0
- package/templates/backend/node_modules/sift/sift.csp.min.js +778 -0
- package/templates/backend/node_modules/sift/sift.csp.min.js.map +1 -0
- package/templates/backend/node_modules/sift/sift.min.js +2 -0
- package/templates/backend/node_modules/sift/sift.min.js.map +1 -0
- package/templates/backend/node_modules/sift/src/core.ts +494 -0
- package/templates/backend/node_modules/sift/src/index.ts +54 -0
- package/templates/backend/node_modules/sift/src/operations.ts +422 -0
- package/templates/backend/node_modules/sift/src/utils.ts +74 -0
- package/templates/backend/node_modules/simple-update-notifier/LICENSE +21 -0
- package/templates/backend/node_modules/simple-update-notifier/README.md +82 -0
- package/templates/backend/node_modules/simple-update-notifier/build/index.d.ts +13 -0
- package/templates/backend/node_modules/simple-update-notifier/build/index.js +210 -0
- package/templates/backend/node_modules/simple-update-notifier/package.json +100 -0
- package/templates/backend/node_modules/simple-update-notifier/src/borderedText.ts +12 -0
- package/templates/backend/node_modules/simple-update-notifier/src/cache.spec.ts +17 -0
- package/templates/backend/node_modules/simple-update-notifier/src/cache.ts +44 -0
- package/templates/backend/node_modules/simple-update-notifier/src/getDistVersion.spec.ts +35 -0
- package/templates/backend/node_modules/simple-update-notifier/src/getDistVersion.ts +29 -0
- package/templates/backend/node_modules/simple-update-notifier/src/hasNewVersion.spec.ts +82 -0
- package/templates/backend/node_modules/simple-update-notifier/src/hasNewVersion.ts +40 -0
- package/templates/backend/node_modules/simple-update-notifier/src/index.spec.ts +27 -0
- package/templates/backend/node_modules/simple-update-notifier/src/index.ts +34 -0
- package/templates/backend/node_modules/simple-update-notifier/src/isNpmOrYarn.ts +12 -0
- package/templates/backend/node_modules/simple-update-notifier/src/types.ts +8 -0
- package/templates/backend/node_modules/sparse-bitfield/.travis.yml +6 -0
- package/templates/backend/node_modules/sparse-bitfield/LICENSE +21 -0
- package/templates/backend/node_modules/sparse-bitfield/README.md +62 -0
- package/templates/backend/node_modules/sparse-bitfield/index.js +95 -0
- package/templates/backend/node_modules/sparse-bitfield/package.json +27 -0
- package/templates/backend/node_modules/sparse-bitfield/test.js +79 -0
- package/templates/backend/node_modules/statuses/HISTORY.md +87 -0
- package/templates/backend/node_modules/statuses/LICENSE +23 -0
- package/templates/backend/node_modules/statuses/README.md +139 -0
- package/templates/backend/node_modules/statuses/codes.json +65 -0
- package/templates/backend/node_modules/statuses/index.js +146 -0
- package/templates/backend/node_modules/statuses/package.json +49 -0
- package/templates/backend/node_modules/supports-color/browser.js +5 -0
- package/templates/backend/node_modules/supports-color/index.js +131 -0
- package/templates/backend/node_modules/supports-color/license +9 -0
- package/templates/backend/node_modules/supports-color/package.json +53 -0
- package/templates/backend/node_modules/supports-color/readme.md +66 -0
- package/templates/backend/node_modules/to-regex-range/LICENSE +21 -0
- package/templates/backend/node_modules/to-regex-range/README.md +305 -0
- package/templates/backend/node_modules/to-regex-range/index.js +288 -0
- package/templates/backend/node_modules/to-regex-range/package.json +88 -0
- package/templates/backend/node_modules/toidentifier/HISTORY.md +9 -0
- package/templates/backend/node_modules/toidentifier/LICENSE +21 -0
- package/templates/backend/node_modules/toidentifier/README.md +61 -0
- package/templates/backend/node_modules/toidentifier/index.js +32 -0
- package/templates/backend/node_modules/toidentifier/package.json +38 -0
- package/templates/backend/node_modules/touch/LICENSE +15 -0
- package/templates/backend/node_modules/touch/README.md +52 -0
- package/templates/backend/node_modules/touch/bin/nodetouch.js +112 -0
- package/templates/backend/node_modules/touch/index.js +224 -0
- package/templates/backend/node_modules/touch/package.json +25 -0
- package/templates/backend/node_modules/tr46/LICENSE.md +21 -0
- package/templates/backend/node_modules/tr46/README.md +76 -0
- package/templates/backend/node_modules/tr46/index.js +344 -0
- package/templates/backend/node_modules/tr46/lib/mappingTable.json +1 -0
- package/templates/backend/node_modules/tr46/lib/regexes.js +29 -0
- package/templates/backend/node_modules/tr46/lib/statusMapping.js +9 -0
- package/templates/backend/node_modules/tr46/package.json +44 -0
- package/templates/backend/node_modules/type-is/HISTORY.md +292 -0
- package/templates/backend/node_modules/type-is/LICENSE +23 -0
- package/templates/backend/node_modules/type-is/README.md +198 -0
- package/templates/backend/node_modules/type-is/index.js +240 -0
- package/templates/backend/node_modules/type-is/node_modules/content-type/LICENSE +22 -0
- package/templates/backend/node_modules/type-is/node_modules/content-type/README.md +69 -0
- package/templates/backend/node_modules/type-is/node_modules/content-type/dist/index.d.ts +26 -0
- package/templates/backend/node_modules/type-is/node_modules/content-type/dist/index.js +170 -0
- package/templates/backend/node_modules/type-is/node_modules/content-type/dist/index.js.map +1 -0
- package/templates/backend/node_modules/type-is/node_modules/content-type/package.json +52 -0
- package/templates/backend/node_modules/type-is/package.json +51 -0
- package/templates/backend/node_modules/undefsafe/.github/workflows/release.yml +25 -0
- package/templates/backend/node_modules/undefsafe/.jscsrc +13 -0
- package/templates/backend/node_modules/undefsafe/.jshintrc +16 -0
- package/templates/backend/node_modules/undefsafe/.travis.yml +18 -0
- package/templates/backend/node_modules/undefsafe/LICENSE +22 -0
- package/templates/backend/node_modules/undefsafe/README.md +63 -0
- package/templates/backend/node_modules/undefsafe/example.js +14 -0
- package/templates/backend/node_modules/undefsafe/lib/undefsafe.js +125 -0
- package/templates/backend/node_modules/undefsafe/package.json +34 -0
- package/templates/backend/node_modules/unpipe/HISTORY.md +4 -0
- package/templates/backend/node_modules/unpipe/LICENSE +22 -0
- package/templates/backend/node_modules/unpipe/README.md +43 -0
- package/templates/backend/node_modules/unpipe/index.js +69 -0
- package/templates/backend/node_modules/unpipe/package.json +27 -0
- package/templates/backend/node_modules/vary/HISTORY.md +39 -0
- package/templates/backend/node_modules/vary/LICENSE +22 -0
- package/templates/backend/node_modules/vary/README.md +101 -0
- package/templates/backend/node_modules/vary/index.js +149 -0
- package/templates/backend/node_modules/vary/package.json +43 -0
- package/templates/backend/node_modules/webidl-conversions/LICENSE.md +12 -0
- package/templates/backend/node_modules/webidl-conversions/README.md +99 -0
- package/templates/backend/node_modules/webidl-conversions/lib/index.js +450 -0
- package/templates/backend/node_modules/webidl-conversions/package.json +35 -0
- package/templates/backend/node_modules/whatwg-url/LICENSE.txt +21 -0
- package/templates/backend/node_modules/whatwg-url/README.md +106 -0
- package/templates/backend/node_modules/whatwg-url/index.js +27 -0
- package/templates/backend/node_modules/whatwg-url/lib/Function.js +42 -0
- package/templates/backend/node_modules/whatwg-url/lib/URL-impl.js +233 -0
- package/templates/backend/node_modules/whatwg-url/lib/URL.js +499 -0
- package/templates/backend/node_modules/whatwg-url/lib/URLSearchParams-impl.js +135 -0
- package/templates/backend/node_modules/whatwg-url/lib/URLSearchParams.js +505 -0
- package/templates/backend/node_modules/whatwg-url/lib/VoidFunction.js +26 -0
- package/templates/backend/node_modules/whatwg-url/lib/encoding.js +16 -0
- package/templates/backend/node_modules/whatwg-url/lib/infra.js +26 -0
- package/templates/backend/node_modules/whatwg-url/lib/percent-encoding.js +142 -0
- package/templates/backend/node_modules/whatwg-url/lib/url-state-machine.js +1274 -0
- package/templates/backend/node_modules/whatwg-url/lib/urlencoded.js +89 -0
- package/templates/backend/node_modules/whatwg-url/lib/utils.js +190 -0
- package/templates/backend/node_modules/whatwg-url/package.json +53 -0
- package/templates/backend/node_modules/whatwg-url/webidl2js-wrapper.js +7 -0
- package/templates/backend/node_modules/wrappy/LICENSE +15 -0
- package/templates/backend/node_modules/wrappy/README.md +36 -0
- package/templates/backend/node_modules/wrappy/package.json +29 -0
- package/templates/backend/node_modules/wrappy/wrappy.js +33 -0
- package/templates/backend/package-lock.json +1543 -0
- package/templates/backend/package.json +22 -0
- package/templates/backend/server.js +131 -0
- package/templates/frontend/README.md +18 -0
- package/templates/frontend/eslint.config.js +21 -0
- package/templates/frontend/index.html +13 -0
- package/templates/frontend/package-lock.json +3136 -0
- package/templates/frontend/package.json +34 -0
- package/templates/frontend/public/favicon.svg +1 -0
- package/templates/frontend/public/icons.svg +24 -0
- package/templates/frontend/src/App.css +184 -0
- package/templates/frontend/src/App.jsx +17 -0
- package/templates/frontend/src/admin.jsx +29 -0
- package/templates/frontend/src/assets/hero.png +0 -0
- package/templates/frontend/src/assets/react.svg +1 -0
- package/templates/frontend/src/assets/vite.svg +1 -0
- package/templates/frontend/src/auth/login.jsx +82 -0
- package/templates/frontend/src/auth/logout.jsx +17 -0
- package/templates/frontend/src/auth/signup.jsx +137 -0
- package/templates/frontend/src/index.css +1 -0
- package/templates/frontend/src/main.jsx +10 -0
- package/templates/frontend/vite.config.js +12 -0
|
@@ -0,0 +1,4750 @@
|
|
|
1
|
+
var BSON = (function (exports) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const TypedArrayPrototypeGetSymbolToStringTag = (() => {
|
|
5
|
+
const g = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), Symbol.toStringTag).get;
|
|
6
|
+
return (value) => g.call(value);
|
|
7
|
+
})();
|
|
8
|
+
function isUint8Array(value) {
|
|
9
|
+
return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8Array';
|
|
10
|
+
}
|
|
11
|
+
function isAnyArrayBuffer(value) {
|
|
12
|
+
return (typeof value === 'object' &&
|
|
13
|
+
value != null &&
|
|
14
|
+
Symbol.toStringTag in value &&
|
|
15
|
+
(value[Symbol.toStringTag] === 'ArrayBuffer' ||
|
|
16
|
+
value[Symbol.toStringTag] === 'SharedArrayBuffer'));
|
|
17
|
+
}
|
|
18
|
+
function isRegExp(regexp) {
|
|
19
|
+
return regexp instanceof RegExp || Object.prototype.toString.call(regexp) === '[object RegExp]';
|
|
20
|
+
}
|
|
21
|
+
function isMap(value) {
|
|
22
|
+
return (typeof value === 'object' &&
|
|
23
|
+
value != null &&
|
|
24
|
+
Symbol.toStringTag in value &&
|
|
25
|
+
value[Symbol.toStringTag] === 'Map');
|
|
26
|
+
}
|
|
27
|
+
function isDate(date) {
|
|
28
|
+
return date instanceof Date || Object.prototype.toString.call(date) === '[object Date]';
|
|
29
|
+
}
|
|
30
|
+
function defaultInspect(x, _options) {
|
|
31
|
+
return JSON.stringify(x, (k, v) => {
|
|
32
|
+
if (typeof v === 'bigint') {
|
|
33
|
+
return { $numberLong: `${v}` };
|
|
34
|
+
}
|
|
35
|
+
else if (isMap(v)) {
|
|
36
|
+
return Object.fromEntries(v);
|
|
37
|
+
}
|
|
38
|
+
return v;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function getStylizeFunction(options) {
|
|
42
|
+
const stylizeExists = options != null &&
|
|
43
|
+
typeof options === 'object' &&
|
|
44
|
+
'stylize' in options &&
|
|
45
|
+
typeof options.stylize === 'function';
|
|
46
|
+
if (stylizeExists) {
|
|
47
|
+
return options.stylize;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const BSON_MAJOR_VERSION = 7;
|
|
52
|
+
const BSON_VERSION_SYMBOL = Symbol.for('@@mdb.bson.version');
|
|
53
|
+
const BSON_INT32_MAX = 0x7fffffff;
|
|
54
|
+
const BSON_INT32_MIN = -2147483648;
|
|
55
|
+
const BSON_INT64_MAX = Math.pow(2, 63) - 1;
|
|
56
|
+
const BSON_INT64_MIN = -Math.pow(2, 63);
|
|
57
|
+
const JS_INT_MAX = Math.pow(2, 53);
|
|
58
|
+
const JS_INT_MIN = -Math.pow(2, 53);
|
|
59
|
+
const BSON_DATA_NUMBER = 1;
|
|
60
|
+
const BSON_DATA_STRING = 2;
|
|
61
|
+
const BSON_DATA_OBJECT = 3;
|
|
62
|
+
const BSON_DATA_ARRAY = 4;
|
|
63
|
+
const BSON_DATA_BINARY = 5;
|
|
64
|
+
const BSON_DATA_UNDEFINED = 6;
|
|
65
|
+
const BSON_DATA_OID = 7;
|
|
66
|
+
const BSON_DATA_BOOLEAN = 8;
|
|
67
|
+
const BSON_DATA_DATE = 9;
|
|
68
|
+
const BSON_DATA_NULL = 10;
|
|
69
|
+
const BSON_DATA_REGEXP = 11;
|
|
70
|
+
const BSON_DATA_DBPOINTER = 12;
|
|
71
|
+
const BSON_DATA_CODE = 13;
|
|
72
|
+
const BSON_DATA_SYMBOL = 14;
|
|
73
|
+
const BSON_DATA_CODE_W_SCOPE = 15;
|
|
74
|
+
const BSON_DATA_INT = 16;
|
|
75
|
+
const BSON_DATA_TIMESTAMP = 17;
|
|
76
|
+
const BSON_DATA_LONG = 18;
|
|
77
|
+
const BSON_DATA_DECIMAL128 = 19;
|
|
78
|
+
const BSON_DATA_MIN_KEY = 0xff;
|
|
79
|
+
const BSON_DATA_MAX_KEY = 0x7f;
|
|
80
|
+
const BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
|
81
|
+
const BSON_BINARY_SUBTYPE_UUID_NEW = 4;
|
|
82
|
+
const BSONType = Object.freeze({
|
|
83
|
+
double: 1,
|
|
84
|
+
string: 2,
|
|
85
|
+
object: 3,
|
|
86
|
+
array: 4,
|
|
87
|
+
binData: 5,
|
|
88
|
+
undefined: 6,
|
|
89
|
+
objectId: 7,
|
|
90
|
+
bool: 8,
|
|
91
|
+
date: 9,
|
|
92
|
+
null: 10,
|
|
93
|
+
regex: 11,
|
|
94
|
+
dbPointer: 12,
|
|
95
|
+
javascript: 13,
|
|
96
|
+
symbol: 14,
|
|
97
|
+
javascriptWithScope: 15,
|
|
98
|
+
int: 16,
|
|
99
|
+
timestamp: 17,
|
|
100
|
+
long: 18,
|
|
101
|
+
decimal: 19,
|
|
102
|
+
minKey: -1,
|
|
103
|
+
maxKey: 127
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
class BSONError extends Error {
|
|
107
|
+
get bsonError() {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
get name() {
|
|
111
|
+
return 'BSONError';
|
|
112
|
+
}
|
|
113
|
+
constructor(message, options) {
|
|
114
|
+
super(message, options);
|
|
115
|
+
}
|
|
116
|
+
static isBSONError(value) {
|
|
117
|
+
return (value != null &&
|
|
118
|
+
typeof value === 'object' &&
|
|
119
|
+
'bsonError' in value &&
|
|
120
|
+
value.bsonError === true &&
|
|
121
|
+
'name' in value &&
|
|
122
|
+
'message' in value &&
|
|
123
|
+
'stack' in value);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
class BSONVersionError extends BSONError {
|
|
127
|
+
get name() {
|
|
128
|
+
return 'BSONVersionError';
|
|
129
|
+
}
|
|
130
|
+
constructor() {
|
|
131
|
+
super(`Unsupported BSON version, bson types must be from bson ${BSON_MAJOR_VERSION}.x.x`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
class BSONRuntimeError extends BSONError {
|
|
135
|
+
get name() {
|
|
136
|
+
return 'BSONRuntimeError';
|
|
137
|
+
}
|
|
138
|
+
constructor(message) {
|
|
139
|
+
super(message);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class BSONOffsetError extends BSONError {
|
|
143
|
+
get name() {
|
|
144
|
+
return 'BSONOffsetError';
|
|
145
|
+
}
|
|
146
|
+
offset;
|
|
147
|
+
constructor(message, offset, options) {
|
|
148
|
+
super(`${message}. offset: ${offset}`, options);
|
|
149
|
+
this.offset = offset;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let TextDecoderFatal;
|
|
154
|
+
let TextDecoderNonFatal;
|
|
155
|
+
function parseUtf8(buffer, start, end, fatal) {
|
|
156
|
+
if (fatal) {
|
|
157
|
+
TextDecoderFatal ??= new TextDecoder('utf8', { fatal: true });
|
|
158
|
+
try {
|
|
159
|
+
return TextDecoderFatal.decode(buffer.subarray(start, end));
|
|
160
|
+
}
|
|
161
|
+
catch (cause) {
|
|
162
|
+
throw new BSONError('Invalid UTF-8 string in BSON document', { cause });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
TextDecoderNonFatal ??= new TextDecoder('utf8', { fatal: false });
|
|
166
|
+
return TextDecoderNonFatal.decode(buffer.subarray(start, end));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function tryReadBasicLatin(uint8array, start, end) {
|
|
170
|
+
if (uint8array.length === 0) {
|
|
171
|
+
return '';
|
|
172
|
+
}
|
|
173
|
+
const stringByteLength = end - start;
|
|
174
|
+
if (stringByteLength === 0) {
|
|
175
|
+
return '';
|
|
176
|
+
}
|
|
177
|
+
if (stringByteLength > 20) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
if (stringByteLength === 1 && uint8array[start] < 128) {
|
|
181
|
+
return String.fromCharCode(uint8array[start]);
|
|
182
|
+
}
|
|
183
|
+
if (stringByteLength === 2 && uint8array[start] < 128 && uint8array[start + 1] < 128) {
|
|
184
|
+
return String.fromCharCode(uint8array[start]) + String.fromCharCode(uint8array[start + 1]);
|
|
185
|
+
}
|
|
186
|
+
if (stringByteLength === 3 &&
|
|
187
|
+
uint8array[start] < 128 &&
|
|
188
|
+
uint8array[start + 1] < 128 &&
|
|
189
|
+
uint8array[start + 2] < 128) {
|
|
190
|
+
return (String.fromCharCode(uint8array[start]) +
|
|
191
|
+
String.fromCharCode(uint8array[start + 1]) +
|
|
192
|
+
String.fromCharCode(uint8array[start + 2]));
|
|
193
|
+
}
|
|
194
|
+
const latinBytes = [];
|
|
195
|
+
for (let i = start; i < end; i++) {
|
|
196
|
+
const byte = uint8array[i];
|
|
197
|
+
if (byte > 127) {
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
latinBytes.push(byte);
|
|
201
|
+
}
|
|
202
|
+
return String.fromCharCode(...latinBytes);
|
|
203
|
+
}
|
|
204
|
+
function tryWriteBasicLatin(destination, source, offset) {
|
|
205
|
+
if (source.length === 0)
|
|
206
|
+
return 0;
|
|
207
|
+
if (source.length > 25)
|
|
208
|
+
return null;
|
|
209
|
+
if (destination.length - offset < source.length)
|
|
210
|
+
return null;
|
|
211
|
+
for (let charOffset = 0, destinationOffset = offset; charOffset < source.length; charOffset++, destinationOffset++) {
|
|
212
|
+
const char = source.charCodeAt(charOffset);
|
|
213
|
+
if (char > 127)
|
|
214
|
+
return null;
|
|
215
|
+
destination[destinationOffset] = char;
|
|
216
|
+
}
|
|
217
|
+
return source.length;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function nodejsMathRandomBytes(byteLength) {
|
|
221
|
+
return nodeJsByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
|
|
222
|
+
}
|
|
223
|
+
function nodejsSecureRandomBytes(byteLength) {
|
|
224
|
+
return crypto.getRandomValues(nodeJsByteUtils.allocate(byteLength));
|
|
225
|
+
}
|
|
226
|
+
const nodejsRandomBytes = (() => {
|
|
227
|
+
const { crypto } = globalThis;
|
|
228
|
+
if (crypto != null && typeof crypto.getRandomValues === 'function') {
|
|
229
|
+
return nodejsSecureRandomBytes;
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
return nodejsMathRandomBytes;
|
|
233
|
+
}
|
|
234
|
+
})();
|
|
235
|
+
const nodeJsByteUtils = {
|
|
236
|
+
isUint8Array: isUint8Array,
|
|
237
|
+
toLocalBufferType(potentialBuffer) {
|
|
238
|
+
if (Buffer.isBuffer(potentialBuffer)) {
|
|
239
|
+
return potentialBuffer;
|
|
240
|
+
}
|
|
241
|
+
if (ArrayBuffer.isView(potentialBuffer)) {
|
|
242
|
+
return Buffer.from(potentialBuffer.buffer, potentialBuffer.byteOffset, potentialBuffer.byteLength);
|
|
243
|
+
}
|
|
244
|
+
const stringTag = potentialBuffer?.[Symbol.toStringTag] ?? Object.prototype.toString.call(potentialBuffer);
|
|
245
|
+
if (stringTag === 'ArrayBuffer' ||
|
|
246
|
+
stringTag === 'SharedArrayBuffer' ||
|
|
247
|
+
stringTag === '[object ArrayBuffer]' ||
|
|
248
|
+
stringTag === '[object SharedArrayBuffer]') {
|
|
249
|
+
return Buffer.from(potentialBuffer);
|
|
250
|
+
}
|
|
251
|
+
throw new BSONError(`Cannot create Buffer from the passed potentialBuffer.`);
|
|
252
|
+
},
|
|
253
|
+
allocate(size) {
|
|
254
|
+
return Buffer.alloc(size);
|
|
255
|
+
},
|
|
256
|
+
allocateUnsafe(size) {
|
|
257
|
+
return Buffer.allocUnsafe(size);
|
|
258
|
+
},
|
|
259
|
+
compare(a, b) {
|
|
260
|
+
return nodeJsByteUtils.toLocalBufferType(a).compare(b);
|
|
261
|
+
},
|
|
262
|
+
concat(list) {
|
|
263
|
+
return Buffer.concat(list);
|
|
264
|
+
},
|
|
265
|
+
copy(source, target, targetStart, sourceStart, sourceEnd) {
|
|
266
|
+
return nodeJsByteUtils
|
|
267
|
+
.toLocalBufferType(source)
|
|
268
|
+
.copy(target, targetStart ?? 0, sourceStart ?? 0, sourceEnd ?? source.length);
|
|
269
|
+
},
|
|
270
|
+
equals(a, b) {
|
|
271
|
+
return nodeJsByteUtils.toLocalBufferType(a).equals(b);
|
|
272
|
+
},
|
|
273
|
+
fromNumberArray(array) {
|
|
274
|
+
return Buffer.from(array);
|
|
275
|
+
},
|
|
276
|
+
fromBase64(base64) {
|
|
277
|
+
return Buffer.from(base64, 'base64');
|
|
278
|
+
},
|
|
279
|
+
fromUTF8(utf8) {
|
|
280
|
+
return Buffer.from(utf8, 'utf8');
|
|
281
|
+
},
|
|
282
|
+
toBase64(buffer) {
|
|
283
|
+
return nodeJsByteUtils.toLocalBufferType(buffer).toString('base64');
|
|
284
|
+
},
|
|
285
|
+
fromISO88591(codePoints) {
|
|
286
|
+
return Buffer.from(codePoints, 'binary');
|
|
287
|
+
},
|
|
288
|
+
toISO88591(buffer) {
|
|
289
|
+
return nodeJsByteUtils.toLocalBufferType(buffer).toString('binary');
|
|
290
|
+
},
|
|
291
|
+
fromHex(hex) {
|
|
292
|
+
return Buffer.from(hex, 'hex');
|
|
293
|
+
},
|
|
294
|
+
toHex(buffer) {
|
|
295
|
+
return nodeJsByteUtils.toLocalBufferType(buffer).toString('hex');
|
|
296
|
+
},
|
|
297
|
+
toUTF8(buffer, start, end, fatal) {
|
|
298
|
+
const basicLatin = end - start <= 20 ? tryReadBasicLatin(buffer, start, end) : null;
|
|
299
|
+
if (basicLatin != null) {
|
|
300
|
+
return basicLatin;
|
|
301
|
+
}
|
|
302
|
+
const string = nodeJsByteUtils.toLocalBufferType(buffer).toString('utf8', start, end);
|
|
303
|
+
if (fatal) {
|
|
304
|
+
for (let i = 0; i < string.length; i++) {
|
|
305
|
+
if (string.charCodeAt(i) === 0xfffd) {
|
|
306
|
+
parseUtf8(buffer, start, end, true);
|
|
307
|
+
break;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return string;
|
|
312
|
+
},
|
|
313
|
+
utf8ByteLength(input) {
|
|
314
|
+
return Buffer.byteLength(input, 'utf8');
|
|
315
|
+
},
|
|
316
|
+
encodeUTF8Into(buffer, source, byteOffset) {
|
|
317
|
+
const latinBytesWritten = tryWriteBasicLatin(buffer, source, byteOffset);
|
|
318
|
+
if (latinBytesWritten != null) {
|
|
319
|
+
return latinBytesWritten;
|
|
320
|
+
}
|
|
321
|
+
return nodeJsByteUtils.toLocalBufferType(buffer).write(source, byteOffset, undefined, 'utf8');
|
|
322
|
+
},
|
|
323
|
+
randomBytes: nodejsRandomBytes,
|
|
324
|
+
swap32(buffer) {
|
|
325
|
+
return nodeJsByteUtils.toLocalBufferType(buffer).swap32();
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
function isReactNative() {
|
|
330
|
+
const { navigator } = globalThis;
|
|
331
|
+
return typeof navigator === 'object' && navigator.product === 'ReactNative';
|
|
332
|
+
}
|
|
333
|
+
function webMathRandomBytes(byteLength) {
|
|
334
|
+
if (byteLength < 0) {
|
|
335
|
+
throw new RangeError(`The argument 'byteLength' is invalid. Received ${byteLength}`);
|
|
336
|
+
}
|
|
337
|
+
return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
|
|
338
|
+
}
|
|
339
|
+
const webRandomBytes = (() => {
|
|
340
|
+
const { crypto } = globalThis;
|
|
341
|
+
if (crypto != null && typeof crypto.getRandomValues === 'function') {
|
|
342
|
+
return (byteLength) => {
|
|
343
|
+
return crypto.getRandomValues(webByteUtils.allocate(byteLength));
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
if (isReactNative()) {
|
|
348
|
+
const { console } = globalThis;
|
|
349
|
+
console?.warn?.('BSON: For React Native please polyfill crypto.getRandomValues, e.g. using: https://www.npmjs.com/package/react-native-get-random-values.');
|
|
350
|
+
}
|
|
351
|
+
return webMathRandomBytes;
|
|
352
|
+
}
|
|
353
|
+
})();
|
|
354
|
+
const HEX_DIGIT = /(\d|[a-f])/i;
|
|
355
|
+
const webByteUtils = {
|
|
356
|
+
isUint8Array: isUint8Array,
|
|
357
|
+
toLocalBufferType(potentialUint8array) {
|
|
358
|
+
const stringTag = potentialUint8array?.[Symbol.toStringTag] ??
|
|
359
|
+
Object.prototype.toString.call(potentialUint8array);
|
|
360
|
+
if (stringTag === 'Uint8Array') {
|
|
361
|
+
return potentialUint8array;
|
|
362
|
+
}
|
|
363
|
+
if (ArrayBuffer.isView(potentialUint8array)) {
|
|
364
|
+
return new Uint8Array(potentialUint8array.buffer.slice(potentialUint8array.byteOffset, potentialUint8array.byteOffset + potentialUint8array.byteLength));
|
|
365
|
+
}
|
|
366
|
+
if (stringTag === 'ArrayBuffer' ||
|
|
367
|
+
stringTag === 'SharedArrayBuffer' ||
|
|
368
|
+
stringTag === '[object ArrayBuffer]' ||
|
|
369
|
+
stringTag === '[object SharedArrayBuffer]') {
|
|
370
|
+
return new Uint8Array(potentialUint8array);
|
|
371
|
+
}
|
|
372
|
+
throw new BSONError(`Cannot make a Uint8Array from passed potentialBuffer.`);
|
|
373
|
+
},
|
|
374
|
+
allocate(size) {
|
|
375
|
+
if (typeof size !== 'number') {
|
|
376
|
+
throw new TypeError(`The "size" argument must be of type number. Received ${String(size)}`);
|
|
377
|
+
}
|
|
378
|
+
return new Uint8Array(size);
|
|
379
|
+
},
|
|
380
|
+
allocateUnsafe(size) {
|
|
381
|
+
return webByteUtils.allocate(size);
|
|
382
|
+
},
|
|
383
|
+
compare(uint8Array, otherUint8Array) {
|
|
384
|
+
if (uint8Array === otherUint8Array)
|
|
385
|
+
return 0;
|
|
386
|
+
const len = Math.min(uint8Array.length, otherUint8Array.length);
|
|
387
|
+
for (let i = 0; i < len; i++) {
|
|
388
|
+
if (uint8Array[i] < otherUint8Array[i])
|
|
389
|
+
return -1;
|
|
390
|
+
if (uint8Array[i] > otherUint8Array[i])
|
|
391
|
+
return 1;
|
|
392
|
+
}
|
|
393
|
+
if (uint8Array.length < otherUint8Array.length)
|
|
394
|
+
return -1;
|
|
395
|
+
if (uint8Array.length > otherUint8Array.length)
|
|
396
|
+
return 1;
|
|
397
|
+
return 0;
|
|
398
|
+
},
|
|
399
|
+
concat(uint8Arrays) {
|
|
400
|
+
if (uint8Arrays.length === 0)
|
|
401
|
+
return webByteUtils.allocate(0);
|
|
402
|
+
let totalLength = 0;
|
|
403
|
+
for (const uint8Array of uint8Arrays) {
|
|
404
|
+
totalLength += uint8Array.length;
|
|
405
|
+
}
|
|
406
|
+
const result = webByteUtils.allocate(totalLength);
|
|
407
|
+
let offset = 0;
|
|
408
|
+
for (const uint8Array of uint8Arrays) {
|
|
409
|
+
result.set(uint8Array, offset);
|
|
410
|
+
offset += uint8Array.length;
|
|
411
|
+
}
|
|
412
|
+
return result;
|
|
413
|
+
},
|
|
414
|
+
copy(source, target, targetStart, sourceStart, sourceEnd) {
|
|
415
|
+
if (sourceEnd !== undefined && sourceEnd < 0) {
|
|
416
|
+
throw new RangeError(`The value of "sourceEnd" is out of range. It must be >= 0. Received ${sourceEnd}`);
|
|
417
|
+
}
|
|
418
|
+
sourceEnd = sourceEnd ?? source.length;
|
|
419
|
+
if (sourceStart !== undefined && (sourceStart < 0 || sourceStart > sourceEnd)) {
|
|
420
|
+
throw new RangeError(`The value of "sourceStart" is out of range. It must be >= 0 and <= ${sourceEnd}. Received ${sourceStart}`);
|
|
421
|
+
}
|
|
422
|
+
sourceStart = sourceStart ?? 0;
|
|
423
|
+
if (targetStart !== undefined && targetStart < 0) {
|
|
424
|
+
throw new RangeError(`The value of "targetStart" is out of range. It must be >= 0. Received ${targetStart}`);
|
|
425
|
+
}
|
|
426
|
+
targetStart = targetStart ?? 0;
|
|
427
|
+
const srcSlice = source.subarray(sourceStart, sourceEnd);
|
|
428
|
+
const maxLen = Math.min(srcSlice.length, target.length - targetStart);
|
|
429
|
+
if (maxLen <= 0) {
|
|
430
|
+
return 0;
|
|
431
|
+
}
|
|
432
|
+
target.set(srcSlice.subarray(0, maxLen), targetStart);
|
|
433
|
+
return maxLen;
|
|
434
|
+
},
|
|
435
|
+
equals(uint8Array, otherUint8Array) {
|
|
436
|
+
if (uint8Array.byteLength !== otherUint8Array.byteLength) {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
for (let i = 0; i < uint8Array.byteLength; i++) {
|
|
440
|
+
if (uint8Array[i] !== otherUint8Array[i]) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
return true;
|
|
445
|
+
},
|
|
446
|
+
fromNumberArray(array) {
|
|
447
|
+
return Uint8Array.from(array);
|
|
448
|
+
},
|
|
449
|
+
fromBase64(base64) {
|
|
450
|
+
return Uint8Array.from(atob(base64), c => c.charCodeAt(0));
|
|
451
|
+
},
|
|
452
|
+
fromUTF8(utf8) {
|
|
453
|
+
return new TextEncoder().encode(utf8);
|
|
454
|
+
},
|
|
455
|
+
toBase64(uint8array) {
|
|
456
|
+
return btoa(webByteUtils.toISO88591(uint8array));
|
|
457
|
+
},
|
|
458
|
+
fromISO88591(codePoints) {
|
|
459
|
+
return Uint8Array.from(codePoints, c => c.charCodeAt(0) & 0xff);
|
|
460
|
+
},
|
|
461
|
+
toISO88591(uint8array) {
|
|
462
|
+
return Array.from(Uint16Array.from(uint8array), b => String.fromCharCode(b)).join('');
|
|
463
|
+
},
|
|
464
|
+
fromHex(hex) {
|
|
465
|
+
const evenLengthHex = hex.length % 2 === 0 ? hex : hex.slice(0, hex.length - 1);
|
|
466
|
+
const buffer = [];
|
|
467
|
+
for (let i = 0; i < evenLengthHex.length; i += 2) {
|
|
468
|
+
const firstDigit = evenLengthHex[i];
|
|
469
|
+
const secondDigit = evenLengthHex[i + 1];
|
|
470
|
+
if (!HEX_DIGIT.test(firstDigit)) {
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
if (!HEX_DIGIT.test(secondDigit)) {
|
|
474
|
+
break;
|
|
475
|
+
}
|
|
476
|
+
const hexDigit = Number.parseInt(`${firstDigit}${secondDigit}`, 16);
|
|
477
|
+
buffer.push(hexDigit);
|
|
478
|
+
}
|
|
479
|
+
return Uint8Array.from(buffer);
|
|
480
|
+
},
|
|
481
|
+
toHex(uint8array) {
|
|
482
|
+
return Array.from(uint8array, byte => byte.toString(16).padStart(2, '0')).join('');
|
|
483
|
+
},
|
|
484
|
+
toUTF8(uint8array, start, end, fatal) {
|
|
485
|
+
const basicLatin = end - start <= 20 ? tryReadBasicLatin(uint8array, start, end) : null;
|
|
486
|
+
if (basicLatin != null) {
|
|
487
|
+
return basicLatin;
|
|
488
|
+
}
|
|
489
|
+
return parseUtf8(uint8array, start, end, fatal);
|
|
490
|
+
},
|
|
491
|
+
utf8ByteLength(input) {
|
|
492
|
+
return new TextEncoder().encode(input).byteLength;
|
|
493
|
+
},
|
|
494
|
+
encodeUTF8Into(uint8array, source, byteOffset) {
|
|
495
|
+
const bytes = new TextEncoder().encode(source);
|
|
496
|
+
uint8array.set(bytes, byteOffset);
|
|
497
|
+
return bytes.byteLength;
|
|
498
|
+
},
|
|
499
|
+
randomBytes: webRandomBytes,
|
|
500
|
+
swap32(buffer) {
|
|
501
|
+
if (buffer.length % 4 !== 0) {
|
|
502
|
+
throw new RangeError('Buffer size must be a multiple of 32-bits');
|
|
503
|
+
}
|
|
504
|
+
for (let i = 0; i < buffer.length; i += 4) {
|
|
505
|
+
const byte0 = buffer[i];
|
|
506
|
+
const byte1 = buffer[i + 1];
|
|
507
|
+
const byte2 = buffer[i + 2];
|
|
508
|
+
const byte3 = buffer[i + 3];
|
|
509
|
+
buffer[i] = byte3;
|
|
510
|
+
buffer[i + 1] = byte2;
|
|
511
|
+
buffer[i + 2] = byte1;
|
|
512
|
+
buffer[i + 3] = byte0;
|
|
513
|
+
}
|
|
514
|
+
return buffer;
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
const hasGlobalBuffer = typeof Buffer === 'function' && Buffer.prototype?._isBuffer !== true;
|
|
519
|
+
const ByteUtils = hasGlobalBuffer ? nodeJsByteUtils : webByteUtils;
|
|
520
|
+
|
|
521
|
+
const bsonType = Symbol.for('@@mdb.bson.type');
|
|
522
|
+
class BSONValue {
|
|
523
|
+
get [bsonType]() {
|
|
524
|
+
return this._bsontype;
|
|
525
|
+
}
|
|
526
|
+
get [BSON_VERSION_SYMBOL]() {
|
|
527
|
+
return BSON_MAJOR_VERSION;
|
|
528
|
+
}
|
|
529
|
+
[Symbol.for('nodejs.util.inspect.custom')](depth, options, inspect) {
|
|
530
|
+
return this.inspect(depth, options, inspect);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const FLOAT = new Float64Array(1);
|
|
535
|
+
const FLOAT_BYTES = new Uint8Array(FLOAT.buffer, 0, 8);
|
|
536
|
+
FLOAT[0] = -1;
|
|
537
|
+
const isBigEndian = FLOAT_BYTES[7] === 0;
|
|
538
|
+
const NumberUtils = {
|
|
539
|
+
isBigEndian,
|
|
540
|
+
getNonnegativeInt32LE(source, offset) {
|
|
541
|
+
if (source[offset + 3] > 127) {
|
|
542
|
+
throw new RangeError(`Size cannot be negative at offset: ${offset}`);
|
|
543
|
+
}
|
|
544
|
+
return (source[offset] |
|
|
545
|
+
(source[offset + 1] << 8) |
|
|
546
|
+
(source[offset + 2] << 16) |
|
|
547
|
+
(source[offset + 3] << 24));
|
|
548
|
+
},
|
|
549
|
+
getInt32LE(source, offset) {
|
|
550
|
+
return (source[offset] |
|
|
551
|
+
(source[offset + 1] << 8) |
|
|
552
|
+
(source[offset + 2] << 16) |
|
|
553
|
+
(source[offset + 3] << 24));
|
|
554
|
+
},
|
|
555
|
+
getUint32LE(source, offset) {
|
|
556
|
+
return (source[offset] +
|
|
557
|
+
source[offset + 1] * 256 +
|
|
558
|
+
source[offset + 2] * 65536 +
|
|
559
|
+
source[offset + 3] * 16777216);
|
|
560
|
+
},
|
|
561
|
+
getUint32BE(source, offset) {
|
|
562
|
+
return (source[offset + 3] +
|
|
563
|
+
source[offset + 2] * 256 +
|
|
564
|
+
source[offset + 1] * 65536 +
|
|
565
|
+
source[offset] * 16777216);
|
|
566
|
+
},
|
|
567
|
+
getBigInt64LE(source, offset) {
|
|
568
|
+
const hi = BigInt(source[offset + 4] +
|
|
569
|
+
source[offset + 5] * 256 +
|
|
570
|
+
source[offset + 6] * 65536 +
|
|
571
|
+
(source[offset + 7] << 24));
|
|
572
|
+
const lo = BigInt(source[offset] +
|
|
573
|
+
source[offset + 1] * 256 +
|
|
574
|
+
source[offset + 2] * 65536 +
|
|
575
|
+
source[offset + 3] * 16777216);
|
|
576
|
+
return (hi << 32n) + lo;
|
|
577
|
+
},
|
|
578
|
+
getFloat64LE: isBigEndian
|
|
579
|
+
? (source, offset) => {
|
|
580
|
+
FLOAT_BYTES[7] = source[offset];
|
|
581
|
+
FLOAT_BYTES[6] = source[offset + 1];
|
|
582
|
+
FLOAT_BYTES[5] = source[offset + 2];
|
|
583
|
+
FLOAT_BYTES[4] = source[offset + 3];
|
|
584
|
+
FLOAT_BYTES[3] = source[offset + 4];
|
|
585
|
+
FLOAT_BYTES[2] = source[offset + 5];
|
|
586
|
+
FLOAT_BYTES[1] = source[offset + 6];
|
|
587
|
+
FLOAT_BYTES[0] = source[offset + 7];
|
|
588
|
+
return FLOAT[0];
|
|
589
|
+
}
|
|
590
|
+
: (source, offset) => {
|
|
591
|
+
FLOAT_BYTES[0] = source[offset];
|
|
592
|
+
FLOAT_BYTES[1] = source[offset + 1];
|
|
593
|
+
FLOAT_BYTES[2] = source[offset + 2];
|
|
594
|
+
FLOAT_BYTES[3] = source[offset + 3];
|
|
595
|
+
FLOAT_BYTES[4] = source[offset + 4];
|
|
596
|
+
FLOAT_BYTES[5] = source[offset + 5];
|
|
597
|
+
FLOAT_BYTES[6] = source[offset + 6];
|
|
598
|
+
FLOAT_BYTES[7] = source[offset + 7];
|
|
599
|
+
return FLOAT[0];
|
|
600
|
+
},
|
|
601
|
+
setInt32BE(destination, offset, value) {
|
|
602
|
+
destination[offset + 3] = value;
|
|
603
|
+
value >>>= 8;
|
|
604
|
+
destination[offset + 2] = value;
|
|
605
|
+
value >>>= 8;
|
|
606
|
+
destination[offset + 1] = value;
|
|
607
|
+
value >>>= 8;
|
|
608
|
+
destination[offset] = value;
|
|
609
|
+
return 4;
|
|
610
|
+
},
|
|
611
|
+
setInt32LE(destination, offset, value) {
|
|
612
|
+
destination[offset] = value;
|
|
613
|
+
value >>>= 8;
|
|
614
|
+
destination[offset + 1] = value;
|
|
615
|
+
value >>>= 8;
|
|
616
|
+
destination[offset + 2] = value;
|
|
617
|
+
value >>>= 8;
|
|
618
|
+
destination[offset + 3] = value;
|
|
619
|
+
return 4;
|
|
620
|
+
},
|
|
621
|
+
setBigInt64LE(destination, offset, value) {
|
|
622
|
+
const mask32bits = 0xffffffffn;
|
|
623
|
+
let lo = Number(value & mask32bits);
|
|
624
|
+
destination[offset] = lo;
|
|
625
|
+
lo >>= 8;
|
|
626
|
+
destination[offset + 1] = lo;
|
|
627
|
+
lo >>= 8;
|
|
628
|
+
destination[offset + 2] = lo;
|
|
629
|
+
lo >>= 8;
|
|
630
|
+
destination[offset + 3] = lo;
|
|
631
|
+
let hi = Number((value >> 32n) & mask32bits);
|
|
632
|
+
destination[offset + 4] = hi;
|
|
633
|
+
hi >>= 8;
|
|
634
|
+
destination[offset + 5] = hi;
|
|
635
|
+
hi >>= 8;
|
|
636
|
+
destination[offset + 6] = hi;
|
|
637
|
+
hi >>= 8;
|
|
638
|
+
destination[offset + 7] = hi;
|
|
639
|
+
return 8;
|
|
640
|
+
},
|
|
641
|
+
setFloat64LE: isBigEndian
|
|
642
|
+
? (destination, offset, value) => {
|
|
643
|
+
FLOAT[0] = value;
|
|
644
|
+
destination[offset] = FLOAT_BYTES[7];
|
|
645
|
+
destination[offset + 1] = FLOAT_BYTES[6];
|
|
646
|
+
destination[offset + 2] = FLOAT_BYTES[5];
|
|
647
|
+
destination[offset + 3] = FLOAT_BYTES[4];
|
|
648
|
+
destination[offset + 4] = FLOAT_BYTES[3];
|
|
649
|
+
destination[offset + 5] = FLOAT_BYTES[2];
|
|
650
|
+
destination[offset + 6] = FLOAT_BYTES[1];
|
|
651
|
+
destination[offset + 7] = FLOAT_BYTES[0];
|
|
652
|
+
return 8;
|
|
653
|
+
}
|
|
654
|
+
: (destination, offset, value) => {
|
|
655
|
+
FLOAT[0] = value;
|
|
656
|
+
destination[offset] = FLOAT_BYTES[0];
|
|
657
|
+
destination[offset + 1] = FLOAT_BYTES[1];
|
|
658
|
+
destination[offset + 2] = FLOAT_BYTES[2];
|
|
659
|
+
destination[offset + 3] = FLOAT_BYTES[3];
|
|
660
|
+
destination[offset + 4] = FLOAT_BYTES[4];
|
|
661
|
+
destination[offset + 5] = FLOAT_BYTES[5];
|
|
662
|
+
destination[offset + 6] = FLOAT_BYTES[6];
|
|
663
|
+
destination[offset + 7] = FLOAT_BYTES[7];
|
|
664
|
+
return 8;
|
|
665
|
+
}
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
class Binary extends BSONValue {
|
|
669
|
+
get _bsontype() {
|
|
670
|
+
return 'Binary';
|
|
671
|
+
}
|
|
672
|
+
static BSON_BINARY_SUBTYPE_DEFAULT = 0;
|
|
673
|
+
static BUFFER_SIZE = 256;
|
|
674
|
+
static SUBTYPE_DEFAULT = 0;
|
|
675
|
+
static SUBTYPE_FUNCTION = 1;
|
|
676
|
+
static SUBTYPE_BYTE_ARRAY = 2;
|
|
677
|
+
static SUBTYPE_UUID_OLD = 3;
|
|
678
|
+
static SUBTYPE_UUID = 4;
|
|
679
|
+
static SUBTYPE_MD5 = 5;
|
|
680
|
+
static SUBTYPE_ENCRYPTED = 6;
|
|
681
|
+
static SUBTYPE_COLUMN = 7;
|
|
682
|
+
static SUBTYPE_SENSITIVE = 8;
|
|
683
|
+
static SUBTYPE_VECTOR = 9;
|
|
684
|
+
static SUBTYPE_USER_DEFINED = 128;
|
|
685
|
+
static VECTOR_TYPE = Object.freeze({
|
|
686
|
+
Int8: 0x03,
|
|
687
|
+
Float32: 0x27,
|
|
688
|
+
PackedBit: 0x10
|
|
689
|
+
});
|
|
690
|
+
buffer;
|
|
691
|
+
sub_type;
|
|
692
|
+
position;
|
|
693
|
+
constructor(buffer, subType) {
|
|
694
|
+
super();
|
|
695
|
+
if (!(buffer == null) &&
|
|
696
|
+
typeof buffer === 'string' &&
|
|
697
|
+
!ArrayBuffer.isView(buffer) &&
|
|
698
|
+
!isAnyArrayBuffer(buffer) &&
|
|
699
|
+
!Array.isArray(buffer)) {
|
|
700
|
+
throw new BSONError('Binary can only be constructed from Uint8Array or number[]');
|
|
701
|
+
}
|
|
702
|
+
this.sub_type = subType ?? Binary.BSON_BINARY_SUBTYPE_DEFAULT;
|
|
703
|
+
if (buffer == null) {
|
|
704
|
+
this.buffer = ByteUtils.allocate(Binary.BUFFER_SIZE);
|
|
705
|
+
this.position = 0;
|
|
706
|
+
}
|
|
707
|
+
else {
|
|
708
|
+
this.buffer = Array.isArray(buffer)
|
|
709
|
+
? ByteUtils.fromNumberArray(buffer)
|
|
710
|
+
: ByteUtils.toLocalBufferType(buffer);
|
|
711
|
+
this.position = this.buffer.byteLength;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
put(byteValue) {
|
|
715
|
+
if (typeof byteValue === 'string' && byteValue.length !== 1) {
|
|
716
|
+
throw new BSONError('only accepts single character String');
|
|
717
|
+
}
|
|
718
|
+
else if (typeof byteValue !== 'number' && byteValue.length !== 1)
|
|
719
|
+
throw new BSONError('only accepts single character Uint8Array or Array');
|
|
720
|
+
let decodedByte;
|
|
721
|
+
if (typeof byteValue === 'string') {
|
|
722
|
+
decodedByte = byteValue.charCodeAt(0);
|
|
723
|
+
}
|
|
724
|
+
else if (typeof byteValue === 'number') {
|
|
725
|
+
decodedByte = byteValue;
|
|
726
|
+
}
|
|
727
|
+
else {
|
|
728
|
+
decodedByte = byteValue[0];
|
|
729
|
+
}
|
|
730
|
+
if (decodedByte < 0 || decodedByte > 255) {
|
|
731
|
+
throw new BSONError('only accepts number in a valid unsigned byte range 0-255');
|
|
732
|
+
}
|
|
733
|
+
if (this.buffer.byteLength > this.position) {
|
|
734
|
+
this.buffer[this.position++] = decodedByte;
|
|
735
|
+
}
|
|
736
|
+
else {
|
|
737
|
+
const newSpace = ByteUtils.allocate(Binary.BUFFER_SIZE + this.buffer.length);
|
|
738
|
+
newSpace.set(this.buffer, 0);
|
|
739
|
+
this.buffer = newSpace;
|
|
740
|
+
this.buffer[this.position++] = decodedByte;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
write(sequence, offset) {
|
|
744
|
+
offset = typeof offset === 'number' ? offset : this.position;
|
|
745
|
+
if (this.buffer.byteLength < offset + sequence.length) {
|
|
746
|
+
const newSpace = ByteUtils.allocate(this.buffer.byteLength + sequence.length);
|
|
747
|
+
newSpace.set(this.buffer, 0);
|
|
748
|
+
this.buffer = newSpace;
|
|
749
|
+
}
|
|
750
|
+
if (ArrayBuffer.isView(sequence)) {
|
|
751
|
+
this.buffer.set(ByteUtils.toLocalBufferType(sequence), offset);
|
|
752
|
+
this.position =
|
|
753
|
+
offset + sequence.byteLength > this.position ? offset + sequence.length : this.position;
|
|
754
|
+
}
|
|
755
|
+
else if (typeof sequence === 'string') {
|
|
756
|
+
throw new BSONError('input cannot be string');
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
read(position, length) {
|
|
760
|
+
length = length && length > 0 ? length : this.position;
|
|
761
|
+
const end = position + length;
|
|
762
|
+
return this.buffer.subarray(position, end > this.position ? this.position : end);
|
|
763
|
+
}
|
|
764
|
+
value() {
|
|
765
|
+
return this.buffer.length === this.position
|
|
766
|
+
? this.buffer
|
|
767
|
+
: this.buffer.subarray(0, this.position);
|
|
768
|
+
}
|
|
769
|
+
length() {
|
|
770
|
+
return this.position;
|
|
771
|
+
}
|
|
772
|
+
toJSON() {
|
|
773
|
+
return ByteUtils.toBase64(this.buffer.subarray(0, this.position));
|
|
774
|
+
}
|
|
775
|
+
toString(encoding) {
|
|
776
|
+
if (encoding === 'hex')
|
|
777
|
+
return ByteUtils.toHex(this.buffer.subarray(0, this.position));
|
|
778
|
+
if (encoding === 'base64')
|
|
779
|
+
return ByteUtils.toBase64(this.buffer.subarray(0, this.position));
|
|
780
|
+
if (encoding === 'utf8' || encoding === 'utf-8')
|
|
781
|
+
return ByteUtils.toUTF8(this.buffer, 0, this.position, false);
|
|
782
|
+
return ByteUtils.toUTF8(this.buffer, 0, this.position, false);
|
|
783
|
+
}
|
|
784
|
+
toExtendedJSON(options) {
|
|
785
|
+
options = options || {};
|
|
786
|
+
if (this.sub_type === Binary.SUBTYPE_VECTOR) {
|
|
787
|
+
validateBinaryVector(this);
|
|
788
|
+
}
|
|
789
|
+
const base64String = ByteUtils.toBase64(this.buffer);
|
|
790
|
+
const subType = Number(this.sub_type).toString(16);
|
|
791
|
+
if (options.legacy) {
|
|
792
|
+
return {
|
|
793
|
+
$binary: base64String,
|
|
794
|
+
$type: subType.length === 1 ? '0' + subType : subType
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
return {
|
|
798
|
+
$binary: {
|
|
799
|
+
base64: base64String,
|
|
800
|
+
subType: subType.length === 1 ? '0' + subType : subType
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
toUUID() {
|
|
805
|
+
if (this.sub_type === Binary.SUBTYPE_UUID) {
|
|
806
|
+
return new UUID(this.buffer.subarray(0, this.position));
|
|
807
|
+
}
|
|
808
|
+
throw new BSONError(`Binary sub_type "${this.sub_type}" is not supported for converting to UUID. Only "${Binary.SUBTYPE_UUID}" is currently supported.`);
|
|
809
|
+
}
|
|
810
|
+
static createFromHexString(hex, subType) {
|
|
811
|
+
return new Binary(ByteUtils.fromHex(hex), subType);
|
|
812
|
+
}
|
|
813
|
+
static createFromBase64(base64, subType) {
|
|
814
|
+
return new Binary(ByteUtils.fromBase64(base64), subType);
|
|
815
|
+
}
|
|
816
|
+
static fromExtendedJSON(doc, options) {
|
|
817
|
+
options = options || {};
|
|
818
|
+
let data;
|
|
819
|
+
let type;
|
|
820
|
+
if ('$binary' in doc) {
|
|
821
|
+
if (options.legacy && typeof doc.$binary === 'string' && '$type' in doc) {
|
|
822
|
+
type = doc.$type ? parseInt(doc.$type, 16) : 0;
|
|
823
|
+
data = ByteUtils.fromBase64(doc.$binary);
|
|
824
|
+
}
|
|
825
|
+
else {
|
|
826
|
+
if (typeof doc.$binary !== 'string') {
|
|
827
|
+
type = doc.$binary.subType ? parseInt(doc.$binary.subType, 16) : 0;
|
|
828
|
+
data = ByteUtils.fromBase64(doc.$binary.base64);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
else if ('$uuid' in doc) {
|
|
833
|
+
type = 4;
|
|
834
|
+
data = UUID.bytesFromString(doc.$uuid);
|
|
835
|
+
}
|
|
836
|
+
if (!data) {
|
|
837
|
+
throw new BSONError(`Unexpected Binary Extended JSON format ${JSON.stringify(doc)}`);
|
|
838
|
+
}
|
|
839
|
+
return type === BSON_BINARY_SUBTYPE_UUID_NEW ? new UUID(data) : new Binary(data, type);
|
|
840
|
+
}
|
|
841
|
+
inspect(depth, options, inspect) {
|
|
842
|
+
inspect ??= defaultInspect;
|
|
843
|
+
const base64 = ByteUtils.toBase64(this.buffer.subarray(0, this.position));
|
|
844
|
+
const base64Arg = inspect(base64, options);
|
|
845
|
+
const subTypeArg = inspect(this.sub_type, options);
|
|
846
|
+
return `Binary.createFromBase64(${base64Arg}, ${subTypeArg})`;
|
|
847
|
+
}
|
|
848
|
+
toInt8Array() {
|
|
849
|
+
if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
|
|
850
|
+
throw new BSONError('Binary sub_type is not Vector');
|
|
851
|
+
}
|
|
852
|
+
if (this.buffer[0] !== Binary.VECTOR_TYPE.Int8) {
|
|
853
|
+
throw new BSONError('Binary datatype field is not Int8');
|
|
854
|
+
}
|
|
855
|
+
validateBinaryVector(this);
|
|
856
|
+
return new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
|
|
857
|
+
}
|
|
858
|
+
toFloat32Array() {
|
|
859
|
+
if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
|
|
860
|
+
throw new BSONError('Binary sub_type is not Vector');
|
|
861
|
+
}
|
|
862
|
+
if (this.buffer[0] !== Binary.VECTOR_TYPE.Float32) {
|
|
863
|
+
throw new BSONError('Binary datatype field is not Float32');
|
|
864
|
+
}
|
|
865
|
+
validateBinaryVector(this);
|
|
866
|
+
const floatBytes = new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
|
|
867
|
+
if (NumberUtils.isBigEndian)
|
|
868
|
+
ByteUtils.swap32(floatBytes);
|
|
869
|
+
return new Float32Array(floatBytes.buffer);
|
|
870
|
+
}
|
|
871
|
+
toPackedBits() {
|
|
872
|
+
if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
|
|
873
|
+
throw new BSONError('Binary sub_type is not Vector');
|
|
874
|
+
}
|
|
875
|
+
if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
|
|
876
|
+
throw new BSONError('Binary datatype field is not packed bit');
|
|
877
|
+
}
|
|
878
|
+
validateBinaryVector(this);
|
|
879
|
+
return new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
|
|
880
|
+
}
|
|
881
|
+
toBits() {
|
|
882
|
+
if (this.sub_type !== Binary.SUBTYPE_VECTOR) {
|
|
883
|
+
throw new BSONError('Binary sub_type is not Vector');
|
|
884
|
+
}
|
|
885
|
+
if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
|
|
886
|
+
throw new BSONError('Binary datatype field is not packed bit');
|
|
887
|
+
}
|
|
888
|
+
validateBinaryVector(this);
|
|
889
|
+
const byteCount = this.length() - 2;
|
|
890
|
+
const bitCount = byteCount * 8 - this.buffer[1];
|
|
891
|
+
const bits = new Int8Array(bitCount);
|
|
892
|
+
for (let bitOffset = 0; bitOffset < bits.length; bitOffset++) {
|
|
893
|
+
const byteOffset = (bitOffset / 8) | 0;
|
|
894
|
+
const byte = this.buffer[byteOffset + 2];
|
|
895
|
+
const shift = 7 - (bitOffset % 8);
|
|
896
|
+
const bit = (byte >> shift) & 1;
|
|
897
|
+
bits[bitOffset] = bit;
|
|
898
|
+
}
|
|
899
|
+
return bits;
|
|
900
|
+
}
|
|
901
|
+
static fromInt8Array(array) {
|
|
902
|
+
const buffer = ByteUtils.allocate(array.byteLength + 2);
|
|
903
|
+
buffer[0] = Binary.VECTOR_TYPE.Int8;
|
|
904
|
+
buffer[1] = 0;
|
|
905
|
+
const intBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
906
|
+
buffer.set(intBytes, 2);
|
|
907
|
+
const bin = new this(buffer, this.SUBTYPE_VECTOR);
|
|
908
|
+
validateBinaryVector(bin);
|
|
909
|
+
return bin;
|
|
910
|
+
}
|
|
911
|
+
static fromFloat32Array(array) {
|
|
912
|
+
const binaryBytes = ByteUtils.allocate(array.byteLength + 2);
|
|
913
|
+
binaryBytes[0] = Binary.VECTOR_TYPE.Float32;
|
|
914
|
+
binaryBytes[1] = 0;
|
|
915
|
+
const floatBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
916
|
+
binaryBytes.set(floatBytes, 2);
|
|
917
|
+
if (NumberUtils.isBigEndian)
|
|
918
|
+
ByteUtils.swap32(new Uint8Array(binaryBytes.buffer, 2));
|
|
919
|
+
const bin = new this(binaryBytes, this.SUBTYPE_VECTOR);
|
|
920
|
+
validateBinaryVector(bin);
|
|
921
|
+
return bin;
|
|
922
|
+
}
|
|
923
|
+
static fromPackedBits(array, padding = 0) {
|
|
924
|
+
const buffer = ByteUtils.allocate(array.byteLength + 2);
|
|
925
|
+
buffer[0] = Binary.VECTOR_TYPE.PackedBit;
|
|
926
|
+
buffer[1] = padding;
|
|
927
|
+
buffer.set(array, 2);
|
|
928
|
+
const bin = new this(buffer, this.SUBTYPE_VECTOR);
|
|
929
|
+
validateBinaryVector(bin);
|
|
930
|
+
return bin;
|
|
931
|
+
}
|
|
932
|
+
static fromBits(bits) {
|
|
933
|
+
const byteLength = (bits.length + 7) >>> 3;
|
|
934
|
+
const bytes = new Uint8Array(byteLength + 2);
|
|
935
|
+
bytes[0] = Binary.VECTOR_TYPE.PackedBit;
|
|
936
|
+
const remainder = bits.length % 8;
|
|
937
|
+
bytes[1] = remainder === 0 ? 0 : 8 - remainder;
|
|
938
|
+
for (let bitOffset = 0; bitOffset < bits.length; bitOffset++) {
|
|
939
|
+
const byteOffset = bitOffset >>> 3;
|
|
940
|
+
const bit = bits[bitOffset];
|
|
941
|
+
if (bit !== 0 && bit !== 1) {
|
|
942
|
+
throw new BSONError(`Invalid bit value at ${bitOffset}: must be 0 or 1, found ${bits[bitOffset]}`);
|
|
943
|
+
}
|
|
944
|
+
if (bit === 0)
|
|
945
|
+
continue;
|
|
946
|
+
const shift = 7 - (bitOffset % 8);
|
|
947
|
+
bytes[byteOffset + 2] |= bit << shift;
|
|
948
|
+
}
|
|
949
|
+
return new this(bytes, Binary.SUBTYPE_VECTOR);
|
|
950
|
+
}
|
|
951
|
+
}
|
|
952
|
+
function validateBinaryVector(vector) {
|
|
953
|
+
if (vector.sub_type !== Binary.SUBTYPE_VECTOR)
|
|
954
|
+
return;
|
|
955
|
+
const size = vector.position;
|
|
956
|
+
const datatype = vector.buffer[0];
|
|
957
|
+
const padding = vector.buffer[1];
|
|
958
|
+
if ((datatype === Binary.VECTOR_TYPE.Float32 || datatype === Binary.VECTOR_TYPE.Int8) &&
|
|
959
|
+
padding !== 0) {
|
|
960
|
+
throw new BSONError('Invalid Vector: padding must be zero for int8 and float32 vectors');
|
|
961
|
+
}
|
|
962
|
+
if (datatype === Binary.VECTOR_TYPE.Float32) {
|
|
963
|
+
if (size !== 0 && size - 2 !== 0 && (size - 2) % 4 !== 0) {
|
|
964
|
+
throw new BSONError('Invalid Vector: Float32 vector must contain a multiple of 4 bytes');
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
if (datatype === Binary.VECTOR_TYPE.PackedBit && padding !== 0 && size === 2) {
|
|
968
|
+
throw new BSONError('Invalid Vector: padding must be zero for packed bit vectors that are empty');
|
|
969
|
+
}
|
|
970
|
+
if (datatype === Binary.VECTOR_TYPE.PackedBit && padding > 7) {
|
|
971
|
+
throw new BSONError(`Invalid Vector: padding must be a value between 0 and 7. found: ${padding}`);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
const UUID_BYTE_LENGTH = 16;
|
|
975
|
+
const UUID_WITHOUT_DASHES = /^[0-9A-F]{32}$/i;
|
|
976
|
+
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;
|
|
977
|
+
class UUID extends Binary {
|
|
978
|
+
constructor(input) {
|
|
979
|
+
let bytes;
|
|
980
|
+
if (input == null) {
|
|
981
|
+
bytes = UUID.generate();
|
|
982
|
+
}
|
|
983
|
+
else if (input instanceof UUID) {
|
|
984
|
+
bytes = ByteUtils.toLocalBufferType(new Uint8Array(input.buffer));
|
|
985
|
+
}
|
|
986
|
+
else if (ArrayBuffer.isView(input) && input.byteLength === UUID_BYTE_LENGTH) {
|
|
987
|
+
bytes = ByteUtils.toLocalBufferType(input);
|
|
988
|
+
}
|
|
989
|
+
else if (typeof input === 'string') {
|
|
990
|
+
bytes = UUID.bytesFromString(input);
|
|
991
|
+
}
|
|
992
|
+
else {
|
|
993
|
+
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).');
|
|
994
|
+
}
|
|
995
|
+
super(bytes, BSON_BINARY_SUBTYPE_UUID_NEW);
|
|
996
|
+
}
|
|
997
|
+
get id() {
|
|
998
|
+
return this.buffer;
|
|
999
|
+
}
|
|
1000
|
+
set id(value) {
|
|
1001
|
+
this.buffer = value;
|
|
1002
|
+
}
|
|
1003
|
+
toHexString(includeDashes = true) {
|
|
1004
|
+
if (includeDashes) {
|
|
1005
|
+
return [
|
|
1006
|
+
ByteUtils.toHex(this.buffer.subarray(0, 4)),
|
|
1007
|
+
ByteUtils.toHex(this.buffer.subarray(4, 6)),
|
|
1008
|
+
ByteUtils.toHex(this.buffer.subarray(6, 8)),
|
|
1009
|
+
ByteUtils.toHex(this.buffer.subarray(8, 10)),
|
|
1010
|
+
ByteUtils.toHex(this.buffer.subarray(10, 16))
|
|
1011
|
+
].join('-');
|
|
1012
|
+
}
|
|
1013
|
+
return ByteUtils.toHex(this.buffer);
|
|
1014
|
+
}
|
|
1015
|
+
toString(encoding) {
|
|
1016
|
+
if (encoding === 'hex')
|
|
1017
|
+
return ByteUtils.toHex(this.id);
|
|
1018
|
+
if (encoding === 'base64')
|
|
1019
|
+
return ByteUtils.toBase64(this.id);
|
|
1020
|
+
return this.toHexString();
|
|
1021
|
+
}
|
|
1022
|
+
toJSON() {
|
|
1023
|
+
return this.toHexString();
|
|
1024
|
+
}
|
|
1025
|
+
equals(otherId) {
|
|
1026
|
+
if (!otherId) {
|
|
1027
|
+
return false;
|
|
1028
|
+
}
|
|
1029
|
+
if (otherId instanceof UUID) {
|
|
1030
|
+
return ByteUtils.equals(otherId.id, this.id);
|
|
1031
|
+
}
|
|
1032
|
+
try {
|
|
1033
|
+
return ByteUtils.equals(new UUID(otherId).id, this.id);
|
|
1034
|
+
}
|
|
1035
|
+
catch {
|
|
1036
|
+
return false;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
toBinary() {
|
|
1040
|
+
return new Binary(this.id, Binary.SUBTYPE_UUID);
|
|
1041
|
+
}
|
|
1042
|
+
static generate() {
|
|
1043
|
+
const bytes = ByteUtils.randomBytes(UUID_BYTE_LENGTH);
|
|
1044
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40;
|
|
1045
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
1046
|
+
return bytes;
|
|
1047
|
+
}
|
|
1048
|
+
static isValid(input) {
|
|
1049
|
+
if (!input) {
|
|
1050
|
+
return false;
|
|
1051
|
+
}
|
|
1052
|
+
if (typeof input === 'string') {
|
|
1053
|
+
return UUID.isValidUUIDString(input);
|
|
1054
|
+
}
|
|
1055
|
+
if (isUint8Array(input)) {
|
|
1056
|
+
return input.byteLength === UUID_BYTE_LENGTH;
|
|
1057
|
+
}
|
|
1058
|
+
return (input._bsontype === 'Binary' &&
|
|
1059
|
+
input.sub_type === this.SUBTYPE_UUID &&
|
|
1060
|
+
input.buffer.byteLength === 16);
|
|
1061
|
+
}
|
|
1062
|
+
static createFromHexString(hexString) {
|
|
1063
|
+
const buffer = UUID.bytesFromString(hexString);
|
|
1064
|
+
return new UUID(buffer);
|
|
1065
|
+
}
|
|
1066
|
+
static createFromBase64(base64) {
|
|
1067
|
+
return new UUID(ByteUtils.fromBase64(base64));
|
|
1068
|
+
}
|
|
1069
|
+
static bytesFromString(representation) {
|
|
1070
|
+
if (!UUID.isValidUUIDString(representation)) {
|
|
1071
|
+
throw new BSONError('UUID string representation must be 32 hex digits or canonical hyphenated representation');
|
|
1072
|
+
}
|
|
1073
|
+
return ByteUtils.fromHex(representation.replace(/-/g, ''));
|
|
1074
|
+
}
|
|
1075
|
+
static isValidUUIDString(representation) {
|
|
1076
|
+
return UUID_WITHOUT_DASHES.test(representation) || UUID_WITH_DASHES.test(representation);
|
|
1077
|
+
}
|
|
1078
|
+
inspect(depth, options, inspect) {
|
|
1079
|
+
inspect ??= defaultInspect;
|
|
1080
|
+
return `new UUID(${inspect(this.toHexString(), options)})`;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
class Code extends BSONValue {
|
|
1085
|
+
get _bsontype() {
|
|
1086
|
+
return 'Code';
|
|
1087
|
+
}
|
|
1088
|
+
code;
|
|
1089
|
+
scope;
|
|
1090
|
+
constructor(code, scope) {
|
|
1091
|
+
super();
|
|
1092
|
+
this.code = code.toString();
|
|
1093
|
+
this.scope = scope ?? null;
|
|
1094
|
+
}
|
|
1095
|
+
toJSON() {
|
|
1096
|
+
if (this.scope != null) {
|
|
1097
|
+
return { code: this.code, scope: this.scope };
|
|
1098
|
+
}
|
|
1099
|
+
return { code: this.code };
|
|
1100
|
+
}
|
|
1101
|
+
toExtendedJSON() {
|
|
1102
|
+
if (this.scope) {
|
|
1103
|
+
return { $code: this.code, $scope: this.scope };
|
|
1104
|
+
}
|
|
1105
|
+
return { $code: this.code };
|
|
1106
|
+
}
|
|
1107
|
+
static fromExtendedJSON(doc) {
|
|
1108
|
+
return new Code(doc.$code, doc.$scope);
|
|
1109
|
+
}
|
|
1110
|
+
inspect(depth, options, inspect) {
|
|
1111
|
+
inspect ??= defaultInspect;
|
|
1112
|
+
let parametersString = inspect(this.code, options);
|
|
1113
|
+
const multiLineFn = parametersString.includes('\n');
|
|
1114
|
+
if (this.scope != null) {
|
|
1115
|
+
parametersString += `,${multiLineFn ? '\n' : ' '}${inspect(this.scope, options)}`;
|
|
1116
|
+
}
|
|
1117
|
+
const endingNewline = multiLineFn && this.scope === null;
|
|
1118
|
+
return `new Code(${multiLineFn ? '\n' : ''}${parametersString}${endingNewline ? '\n' : ''})`;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
function isDBRefLike(value) {
|
|
1123
|
+
return (value != null &&
|
|
1124
|
+
typeof value === 'object' &&
|
|
1125
|
+
'$id' in value &&
|
|
1126
|
+
value.$id != null &&
|
|
1127
|
+
'$ref' in value &&
|
|
1128
|
+
typeof value.$ref === 'string' &&
|
|
1129
|
+
(!('$db' in value) || ('$db' in value && typeof value.$db === 'string')));
|
|
1130
|
+
}
|
|
1131
|
+
class DBRef extends BSONValue {
|
|
1132
|
+
get _bsontype() {
|
|
1133
|
+
return 'DBRef';
|
|
1134
|
+
}
|
|
1135
|
+
collection;
|
|
1136
|
+
oid;
|
|
1137
|
+
db;
|
|
1138
|
+
fields;
|
|
1139
|
+
constructor(collection, oid, db, fields) {
|
|
1140
|
+
super();
|
|
1141
|
+
const parts = collection.split('.');
|
|
1142
|
+
if (parts.length === 2) {
|
|
1143
|
+
db = parts.shift();
|
|
1144
|
+
collection = parts.shift();
|
|
1145
|
+
}
|
|
1146
|
+
this.collection = collection;
|
|
1147
|
+
this.oid = oid;
|
|
1148
|
+
this.db = db;
|
|
1149
|
+
this.fields = fields || {};
|
|
1150
|
+
}
|
|
1151
|
+
get namespace() {
|
|
1152
|
+
return this.collection;
|
|
1153
|
+
}
|
|
1154
|
+
set namespace(value) {
|
|
1155
|
+
this.collection = value;
|
|
1156
|
+
}
|
|
1157
|
+
toJSON() {
|
|
1158
|
+
const o = Object.assign({
|
|
1159
|
+
$ref: this.collection,
|
|
1160
|
+
$id: this.oid
|
|
1161
|
+
}, this.fields);
|
|
1162
|
+
if (this.db != null)
|
|
1163
|
+
o.$db = this.db;
|
|
1164
|
+
return o;
|
|
1165
|
+
}
|
|
1166
|
+
toExtendedJSON(options) {
|
|
1167
|
+
options = options || {};
|
|
1168
|
+
let o = {
|
|
1169
|
+
$ref: this.collection,
|
|
1170
|
+
$id: this.oid
|
|
1171
|
+
};
|
|
1172
|
+
if (options.legacy) {
|
|
1173
|
+
return o;
|
|
1174
|
+
}
|
|
1175
|
+
if (this.db)
|
|
1176
|
+
o.$db = this.db;
|
|
1177
|
+
o = Object.assign(o, this.fields);
|
|
1178
|
+
return o;
|
|
1179
|
+
}
|
|
1180
|
+
static fromExtendedJSON(doc) {
|
|
1181
|
+
const copy = Object.assign({}, doc);
|
|
1182
|
+
delete copy.$ref;
|
|
1183
|
+
delete copy.$id;
|
|
1184
|
+
delete copy.$db;
|
|
1185
|
+
return new DBRef(doc.$ref, doc.$id, doc.$db, copy);
|
|
1186
|
+
}
|
|
1187
|
+
inspect(depth, options, inspect) {
|
|
1188
|
+
inspect ??= defaultInspect;
|
|
1189
|
+
const args = [
|
|
1190
|
+
inspect(this.namespace, options),
|
|
1191
|
+
inspect(this.oid, options),
|
|
1192
|
+
...(this.db ? [inspect(this.db, options)] : []),
|
|
1193
|
+
...(Object.keys(this.fields).length > 0 ? [inspect(this.fields, options)] : [])
|
|
1194
|
+
];
|
|
1195
|
+
args[1] = inspect === defaultInspect ? `new ObjectId(${args[1]})` : args[1];
|
|
1196
|
+
return `new DBRef(${args.join(', ')})`;
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
function removeLeadingZerosAndExplicitPlus(str) {
|
|
1201
|
+
if (str === '') {
|
|
1202
|
+
return str;
|
|
1203
|
+
}
|
|
1204
|
+
let startIndex = 0;
|
|
1205
|
+
const isNegative = str[startIndex] === '-';
|
|
1206
|
+
const isExplicitlyPositive = str[startIndex] === '+';
|
|
1207
|
+
if (isExplicitlyPositive || isNegative) {
|
|
1208
|
+
startIndex += 1;
|
|
1209
|
+
}
|
|
1210
|
+
let foundInsignificantZero = false;
|
|
1211
|
+
for (; startIndex < str.length && str[startIndex] === '0'; ++startIndex) {
|
|
1212
|
+
foundInsignificantZero = true;
|
|
1213
|
+
}
|
|
1214
|
+
if (!foundInsignificantZero) {
|
|
1215
|
+
return isExplicitlyPositive ? str.slice(1) : str;
|
|
1216
|
+
}
|
|
1217
|
+
return `${isNegative ? '-' : ''}${str.length === startIndex ? '0' : str.slice(startIndex)}`;
|
|
1218
|
+
}
|
|
1219
|
+
function validateStringCharacters(str, radix) {
|
|
1220
|
+
radix = radix ?? 10;
|
|
1221
|
+
const validCharacters = '0123456789abcdefghijklmnopqrstuvwxyz'.slice(0, radix);
|
|
1222
|
+
const regex = new RegExp(`[^-+${validCharacters}]`, 'i');
|
|
1223
|
+
return regex.test(str) ? false : str;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
let wasm = undefined;
|
|
1227
|
+
try {
|
|
1228
|
+
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;
|
|
1229
|
+
}
|
|
1230
|
+
catch {
|
|
1231
|
+
}
|
|
1232
|
+
const TWO_PWR_16_DBL = 1 << 16;
|
|
1233
|
+
const TWO_PWR_24_DBL = 1 << 24;
|
|
1234
|
+
const TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;
|
|
1235
|
+
const TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;
|
|
1236
|
+
const TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;
|
|
1237
|
+
const INT_CACHE = {};
|
|
1238
|
+
const UINT_CACHE = {};
|
|
1239
|
+
const MAX_INT64_STRING_LENGTH = 20;
|
|
1240
|
+
const DECIMAL_REG_EX = /^(\+?0|(\+|-)?[1-9][0-9]*)$/;
|
|
1241
|
+
class Long extends BSONValue {
|
|
1242
|
+
get _bsontype() {
|
|
1243
|
+
return 'Long';
|
|
1244
|
+
}
|
|
1245
|
+
get __isLong__() {
|
|
1246
|
+
return true;
|
|
1247
|
+
}
|
|
1248
|
+
high;
|
|
1249
|
+
low;
|
|
1250
|
+
unsigned;
|
|
1251
|
+
constructor(lowOrValue = 0, highOrUnsigned, unsigned) {
|
|
1252
|
+
super();
|
|
1253
|
+
const unsignedBool = typeof highOrUnsigned === 'boolean' ? highOrUnsigned : Boolean(unsigned);
|
|
1254
|
+
const high = typeof highOrUnsigned === 'number' ? highOrUnsigned : 0;
|
|
1255
|
+
const res = typeof lowOrValue === 'string'
|
|
1256
|
+
? Long.fromString(lowOrValue, unsignedBool)
|
|
1257
|
+
: typeof lowOrValue === 'bigint'
|
|
1258
|
+
? Long.fromBigInt(lowOrValue, unsignedBool)
|
|
1259
|
+
: { low: lowOrValue | 0, high: high | 0, unsigned: unsignedBool };
|
|
1260
|
+
this.low = res.low;
|
|
1261
|
+
this.high = res.high;
|
|
1262
|
+
this.unsigned = res.unsigned;
|
|
1263
|
+
}
|
|
1264
|
+
static TWO_PWR_24 = Long.fromInt(TWO_PWR_24_DBL);
|
|
1265
|
+
static MAX_UNSIGNED_VALUE = Long.fromBits(0xffffffff | 0, 0xffffffff | 0, true);
|
|
1266
|
+
static ZERO = Long.fromInt(0);
|
|
1267
|
+
static UZERO = Long.fromInt(0, true);
|
|
1268
|
+
static ONE = Long.fromInt(1);
|
|
1269
|
+
static UONE = Long.fromInt(1, true);
|
|
1270
|
+
static NEG_ONE = Long.fromInt(-1);
|
|
1271
|
+
static MAX_VALUE = Long.fromBits(0xffffffff | 0, 0x7fffffff | 0, false);
|
|
1272
|
+
static MIN_VALUE = Long.fromBits(0, 0x80000000 | 0, false);
|
|
1273
|
+
static fromBits(lowBits, highBits, unsigned) {
|
|
1274
|
+
return new Long(lowBits, highBits, unsigned);
|
|
1275
|
+
}
|
|
1276
|
+
static fromInt(value, unsigned) {
|
|
1277
|
+
let obj, cachedObj, cache;
|
|
1278
|
+
if (unsigned) {
|
|
1279
|
+
value >>>= 0;
|
|
1280
|
+
if ((cache = 0 <= value && value < 256)) {
|
|
1281
|
+
cachedObj = UINT_CACHE[value];
|
|
1282
|
+
if (cachedObj)
|
|
1283
|
+
return cachedObj;
|
|
1284
|
+
}
|
|
1285
|
+
obj = Long.fromBits(value, (value | 0) < 0 ? -1 : 0, true);
|
|
1286
|
+
if (cache)
|
|
1287
|
+
UINT_CACHE[value] = obj;
|
|
1288
|
+
return obj;
|
|
1289
|
+
}
|
|
1290
|
+
else {
|
|
1291
|
+
value |= 0;
|
|
1292
|
+
if ((cache = -128 <= value && value < 128)) {
|
|
1293
|
+
cachedObj = INT_CACHE[value];
|
|
1294
|
+
if (cachedObj)
|
|
1295
|
+
return cachedObj;
|
|
1296
|
+
}
|
|
1297
|
+
obj = Long.fromBits(value, value < 0 ? -1 : 0, false);
|
|
1298
|
+
if (cache)
|
|
1299
|
+
INT_CACHE[value] = obj;
|
|
1300
|
+
return obj;
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
static fromNumber(value, unsigned) {
|
|
1304
|
+
if (isNaN(value))
|
|
1305
|
+
return unsigned ? Long.UZERO : Long.ZERO;
|
|
1306
|
+
if (unsigned) {
|
|
1307
|
+
if (value < 0)
|
|
1308
|
+
return Long.UZERO;
|
|
1309
|
+
if (value >= TWO_PWR_64_DBL)
|
|
1310
|
+
return Long.MAX_UNSIGNED_VALUE;
|
|
1311
|
+
}
|
|
1312
|
+
else {
|
|
1313
|
+
if (value <= -TWO_PWR_63_DBL)
|
|
1314
|
+
return Long.MIN_VALUE;
|
|
1315
|
+
if (value + 1 >= TWO_PWR_63_DBL)
|
|
1316
|
+
return Long.MAX_VALUE;
|
|
1317
|
+
}
|
|
1318
|
+
if (value < 0)
|
|
1319
|
+
return Long.fromNumber(-value, unsigned).neg();
|
|
1320
|
+
return Long.fromBits(value % TWO_PWR_32_DBL | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);
|
|
1321
|
+
}
|
|
1322
|
+
static fromBigInt(value, unsigned) {
|
|
1323
|
+
const FROM_BIGINT_BIT_MASK = 0xffffffffn;
|
|
1324
|
+
const FROM_BIGINT_BIT_SHIFT = 32n;
|
|
1325
|
+
return new Long(Number(value & FROM_BIGINT_BIT_MASK), Number((value >> FROM_BIGINT_BIT_SHIFT) & FROM_BIGINT_BIT_MASK), unsigned);
|
|
1326
|
+
}
|
|
1327
|
+
static _fromString(str, unsigned, radix) {
|
|
1328
|
+
if (str.length === 0)
|
|
1329
|
+
throw new BSONError('empty string');
|
|
1330
|
+
if (radix < 2 || 36 < radix)
|
|
1331
|
+
throw new BSONError('radix');
|
|
1332
|
+
let p;
|
|
1333
|
+
if ((p = str.indexOf('-')) > 0)
|
|
1334
|
+
throw new BSONError('interior hyphen');
|
|
1335
|
+
else if (p === 0) {
|
|
1336
|
+
return Long._fromString(str.substring(1), unsigned, radix).neg();
|
|
1337
|
+
}
|
|
1338
|
+
const radixToPower = Long.fromNumber(Math.pow(radix, 8));
|
|
1339
|
+
let result = Long.ZERO;
|
|
1340
|
+
for (let i = 0; i < str.length; i += 8) {
|
|
1341
|
+
const size = Math.min(8, str.length - i), value = parseInt(str.substring(i, i + size), radix);
|
|
1342
|
+
if (size < 8) {
|
|
1343
|
+
const power = Long.fromNumber(Math.pow(radix, size));
|
|
1344
|
+
result = result.mul(power).add(Long.fromNumber(value));
|
|
1345
|
+
}
|
|
1346
|
+
else {
|
|
1347
|
+
result = result.mul(radixToPower);
|
|
1348
|
+
result = result.add(Long.fromNumber(value));
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
result.unsigned = unsigned;
|
|
1352
|
+
return result;
|
|
1353
|
+
}
|
|
1354
|
+
static fromStringStrict(str, unsignedOrRadix, radix) {
|
|
1355
|
+
let unsigned = false;
|
|
1356
|
+
if (typeof unsignedOrRadix === 'number') {
|
|
1357
|
+
((radix = unsignedOrRadix), (unsignedOrRadix = false));
|
|
1358
|
+
}
|
|
1359
|
+
else {
|
|
1360
|
+
unsigned = !!unsignedOrRadix;
|
|
1361
|
+
}
|
|
1362
|
+
radix ??= 10;
|
|
1363
|
+
if (str.trim() !== str) {
|
|
1364
|
+
throw new BSONError(`Input: '${str}' contains leading and/or trailing whitespace`);
|
|
1365
|
+
}
|
|
1366
|
+
if (!validateStringCharacters(str, radix)) {
|
|
1367
|
+
throw new BSONError(`Input: '${str}' contains invalid characters for radix: ${radix}`);
|
|
1368
|
+
}
|
|
1369
|
+
const cleanedStr = removeLeadingZerosAndExplicitPlus(str);
|
|
1370
|
+
const result = Long._fromString(cleanedStr, unsigned, radix);
|
|
1371
|
+
if (result.toString(radix).toLowerCase() !== cleanedStr.toLowerCase()) {
|
|
1372
|
+
throw new BSONError(`Input: ${str} is not representable as ${result.unsigned ? 'an unsigned' : 'a signed'} 64-bit Long ${radix != null ? `with radix: ${radix}` : ''}`);
|
|
1373
|
+
}
|
|
1374
|
+
return result;
|
|
1375
|
+
}
|
|
1376
|
+
static fromString(str, unsignedOrRadix, radix) {
|
|
1377
|
+
let unsigned = false;
|
|
1378
|
+
if (typeof unsignedOrRadix === 'number') {
|
|
1379
|
+
((radix = unsignedOrRadix), (unsignedOrRadix = false));
|
|
1380
|
+
}
|
|
1381
|
+
else {
|
|
1382
|
+
unsigned = !!unsignedOrRadix;
|
|
1383
|
+
}
|
|
1384
|
+
radix ??= 10;
|
|
1385
|
+
if (str === 'NaN' && radix < 24) {
|
|
1386
|
+
return Long.ZERO;
|
|
1387
|
+
}
|
|
1388
|
+
else if ((str === 'Infinity' || str === '+Infinity' || str === '-Infinity') && radix < 35) {
|
|
1389
|
+
return Long.ZERO;
|
|
1390
|
+
}
|
|
1391
|
+
return Long._fromString(str, unsigned, radix);
|
|
1392
|
+
}
|
|
1393
|
+
static fromBytes(bytes, unsigned, le) {
|
|
1394
|
+
return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);
|
|
1395
|
+
}
|
|
1396
|
+
static fromBytesLE(bytes, unsigned) {
|
|
1397
|
+
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);
|
|
1398
|
+
}
|
|
1399
|
+
static fromBytesBE(bytes, unsigned) {
|
|
1400
|
+
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);
|
|
1401
|
+
}
|
|
1402
|
+
static isLong(value) {
|
|
1403
|
+
return (value != null &&
|
|
1404
|
+
typeof value === 'object' &&
|
|
1405
|
+
'__isLong__' in value &&
|
|
1406
|
+
value.__isLong__ === true);
|
|
1407
|
+
}
|
|
1408
|
+
static fromValue(val, unsigned) {
|
|
1409
|
+
if (typeof val === 'number')
|
|
1410
|
+
return Long.fromNumber(val, unsigned);
|
|
1411
|
+
if (typeof val === 'string')
|
|
1412
|
+
return Long.fromString(val, unsigned);
|
|
1413
|
+
return Long.fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);
|
|
1414
|
+
}
|
|
1415
|
+
add(addend) {
|
|
1416
|
+
if (!Long.isLong(addend))
|
|
1417
|
+
addend = Long.fromValue(addend);
|
|
1418
|
+
const a48 = this.high >>> 16;
|
|
1419
|
+
const a32 = this.high & 0xffff;
|
|
1420
|
+
const a16 = this.low >>> 16;
|
|
1421
|
+
const a00 = this.low & 0xffff;
|
|
1422
|
+
const b48 = addend.high >>> 16;
|
|
1423
|
+
const b32 = addend.high & 0xffff;
|
|
1424
|
+
const b16 = addend.low >>> 16;
|
|
1425
|
+
const b00 = addend.low & 0xffff;
|
|
1426
|
+
let c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
|
1427
|
+
c00 += a00 + b00;
|
|
1428
|
+
c16 += c00 >>> 16;
|
|
1429
|
+
c00 &= 0xffff;
|
|
1430
|
+
c16 += a16 + b16;
|
|
1431
|
+
c32 += c16 >>> 16;
|
|
1432
|
+
c16 &= 0xffff;
|
|
1433
|
+
c32 += a32 + b32;
|
|
1434
|
+
c48 += c32 >>> 16;
|
|
1435
|
+
c32 &= 0xffff;
|
|
1436
|
+
c48 += a48 + b48;
|
|
1437
|
+
c48 &= 0xffff;
|
|
1438
|
+
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
|
|
1439
|
+
}
|
|
1440
|
+
and(other) {
|
|
1441
|
+
if (!Long.isLong(other))
|
|
1442
|
+
other = Long.fromValue(other);
|
|
1443
|
+
return Long.fromBits(this.low & other.low, this.high & other.high, this.unsigned);
|
|
1444
|
+
}
|
|
1445
|
+
compare(other) {
|
|
1446
|
+
if (!Long.isLong(other))
|
|
1447
|
+
other = Long.fromValue(other);
|
|
1448
|
+
if (this.eq(other))
|
|
1449
|
+
return 0;
|
|
1450
|
+
const thisNeg = this.isNegative(), otherNeg = other.isNegative();
|
|
1451
|
+
if (thisNeg && !otherNeg)
|
|
1452
|
+
return -1;
|
|
1453
|
+
if (!thisNeg && otherNeg)
|
|
1454
|
+
return 1;
|
|
1455
|
+
if (!this.unsigned)
|
|
1456
|
+
return this.sub(other).isNegative() ? -1 : 1;
|
|
1457
|
+
return other.high >>> 0 > this.high >>> 0 ||
|
|
1458
|
+
(other.high === this.high && other.low >>> 0 > this.low >>> 0)
|
|
1459
|
+
? -1
|
|
1460
|
+
: 1;
|
|
1461
|
+
}
|
|
1462
|
+
comp(other) {
|
|
1463
|
+
return this.compare(other);
|
|
1464
|
+
}
|
|
1465
|
+
divide(divisor) {
|
|
1466
|
+
if (!Long.isLong(divisor))
|
|
1467
|
+
divisor = Long.fromValue(divisor);
|
|
1468
|
+
if (divisor.isZero())
|
|
1469
|
+
throw new BSONError('division by zero');
|
|
1470
|
+
if (wasm) {
|
|
1471
|
+
if (!this.unsigned &&
|
|
1472
|
+
this.high === -2147483648 &&
|
|
1473
|
+
divisor.low === -1 &&
|
|
1474
|
+
divisor.high === -1) {
|
|
1475
|
+
return this;
|
|
1476
|
+
}
|
|
1477
|
+
const low = (this.unsigned ? wasm.div_u : wasm.div_s)(this.low, this.high, divisor.low, divisor.high);
|
|
1478
|
+
return Long.fromBits(low, wasm.get_high(), this.unsigned);
|
|
1479
|
+
}
|
|
1480
|
+
if (this.isZero())
|
|
1481
|
+
return this.unsigned ? Long.UZERO : Long.ZERO;
|
|
1482
|
+
let approx, rem, res;
|
|
1483
|
+
if (!this.unsigned) {
|
|
1484
|
+
if (this.eq(Long.MIN_VALUE)) {
|
|
1485
|
+
if (divisor.eq(Long.ONE) || divisor.eq(Long.NEG_ONE))
|
|
1486
|
+
return Long.MIN_VALUE;
|
|
1487
|
+
else if (divisor.eq(Long.MIN_VALUE))
|
|
1488
|
+
return Long.ONE;
|
|
1489
|
+
else {
|
|
1490
|
+
const halfThis = this.shr(1);
|
|
1491
|
+
approx = halfThis.div(divisor).shl(1);
|
|
1492
|
+
if (approx.eq(Long.ZERO)) {
|
|
1493
|
+
return divisor.isNegative() ? Long.ONE : Long.NEG_ONE;
|
|
1494
|
+
}
|
|
1495
|
+
else {
|
|
1496
|
+
rem = this.sub(divisor.mul(approx));
|
|
1497
|
+
res = approx.add(rem.div(divisor));
|
|
1498
|
+
return res;
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
}
|
|
1502
|
+
else if (divisor.eq(Long.MIN_VALUE))
|
|
1503
|
+
return this.unsigned ? Long.UZERO : Long.ZERO;
|
|
1504
|
+
if (this.isNegative()) {
|
|
1505
|
+
if (divisor.isNegative())
|
|
1506
|
+
return this.neg().div(divisor.neg());
|
|
1507
|
+
return this.neg().div(divisor).neg();
|
|
1508
|
+
}
|
|
1509
|
+
else if (divisor.isNegative())
|
|
1510
|
+
return this.div(divisor.neg()).neg();
|
|
1511
|
+
res = Long.ZERO;
|
|
1512
|
+
}
|
|
1513
|
+
else {
|
|
1514
|
+
if (!divisor.unsigned)
|
|
1515
|
+
divisor = divisor.toUnsigned();
|
|
1516
|
+
if (divisor.gt(this))
|
|
1517
|
+
return Long.UZERO;
|
|
1518
|
+
if (divisor.gt(this.shru(1)))
|
|
1519
|
+
return Long.UONE;
|
|
1520
|
+
res = Long.UZERO;
|
|
1521
|
+
}
|
|
1522
|
+
rem = this;
|
|
1523
|
+
while (rem.gte(divisor)) {
|
|
1524
|
+
approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));
|
|
1525
|
+
const log2 = Math.ceil(Math.log(approx) / Math.LN2);
|
|
1526
|
+
const delta = log2 <= 48 ? 1 : Math.pow(2, log2 - 48);
|
|
1527
|
+
let approxRes = Long.fromNumber(approx);
|
|
1528
|
+
let approxRem = approxRes.mul(divisor);
|
|
1529
|
+
while (approxRem.isNegative() || approxRem.gt(rem)) {
|
|
1530
|
+
approx -= delta;
|
|
1531
|
+
approxRes = Long.fromNumber(approx, this.unsigned);
|
|
1532
|
+
approxRem = approxRes.mul(divisor);
|
|
1533
|
+
}
|
|
1534
|
+
if (approxRes.isZero())
|
|
1535
|
+
approxRes = Long.ONE;
|
|
1536
|
+
res = res.add(approxRes);
|
|
1537
|
+
rem = rem.sub(approxRem);
|
|
1538
|
+
}
|
|
1539
|
+
return res;
|
|
1540
|
+
}
|
|
1541
|
+
div(divisor) {
|
|
1542
|
+
return this.divide(divisor);
|
|
1543
|
+
}
|
|
1544
|
+
equals(other) {
|
|
1545
|
+
if (!Long.isLong(other))
|
|
1546
|
+
other = Long.fromValue(other);
|
|
1547
|
+
if (this.unsigned !== other.unsigned && this.high >>> 31 === 1 && other.high >>> 31 === 1)
|
|
1548
|
+
return false;
|
|
1549
|
+
return this.high === other.high && this.low === other.low;
|
|
1550
|
+
}
|
|
1551
|
+
eq(other) {
|
|
1552
|
+
return this.equals(other);
|
|
1553
|
+
}
|
|
1554
|
+
getHighBits() {
|
|
1555
|
+
return this.high;
|
|
1556
|
+
}
|
|
1557
|
+
getHighBitsUnsigned() {
|
|
1558
|
+
return this.high >>> 0;
|
|
1559
|
+
}
|
|
1560
|
+
getLowBits() {
|
|
1561
|
+
return this.low;
|
|
1562
|
+
}
|
|
1563
|
+
getLowBitsUnsigned() {
|
|
1564
|
+
return this.low >>> 0;
|
|
1565
|
+
}
|
|
1566
|
+
getNumBitsAbs() {
|
|
1567
|
+
if (this.isNegative()) {
|
|
1568
|
+
return this.eq(Long.MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();
|
|
1569
|
+
}
|
|
1570
|
+
const val = this.high !== 0 ? this.high : this.low;
|
|
1571
|
+
let bit;
|
|
1572
|
+
for (bit = 31; bit > 0; bit--)
|
|
1573
|
+
if ((val & (1 << bit)) !== 0)
|
|
1574
|
+
break;
|
|
1575
|
+
return this.high !== 0 ? bit + 33 : bit + 1;
|
|
1576
|
+
}
|
|
1577
|
+
greaterThan(other) {
|
|
1578
|
+
return this.comp(other) > 0;
|
|
1579
|
+
}
|
|
1580
|
+
gt(other) {
|
|
1581
|
+
return this.greaterThan(other);
|
|
1582
|
+
}
|
|
1583
|
+
greaterThanOrEqual(other) {
|
|
1584
|
+
return this.comp(other) >= 0;
|
|
1585
|
+
}
|
|
1586
|
+
gte(other) {
|
|
1587
|
+
return this.greaterThanOrEqual(other);
|
|
1588
|
+
}
|
|
1589
|
+
ge(other) {
|
|
1590
|
+
return this.greaterThanOrEqual(other);
|
|
1591
|
+
}
|
|
1592
|
+
isEven() {
|
|
1593
|
+
return (this.low & 1) === 0;
|
|
1594
|
+
}
|
|
1595
|
+
isNegative() {
|
|
1596
|
+
return !this.unsigned && this.high < 0;
|
|
1597
|
+
}
|
|
1598
|
+
isOdd() {
|
|
1599
|
+
return (this.low & 1) === 1;
|
|
1600
|
+
}
|
|
1601
|
+
isPositive() {
|
|
1602
|
+
return this.unsigned || this.high >= 0;
|
|
1603
|
+
}
|
|
1604
|
+
isZero() {
|
|
1605
|
+
return this.high === 0 && this.low === 0;
|
|
1606
|
+
}
|
|
1607
|
+
lessThan(other) {
|
|
1608
|
+
return this.comp(other) < 0;
|
|
1609
|
+
}
|
|
1610
|
+
lt(other) {
|
|
1611
|
+
return this.lessThan(other);
|
|
1612
|
+
}
|
|
1613
|
+
lessThanOrEqual(other) {
|
|
1614
|
+
return this.comp(other) <= 0;
|
|
1615
|
+
}
|
|
1616
|
+
lte(other) {
|
|
1617
|
+
return this.lessThanOrEqual(other);
|
|
1618
|
+
}
|
|
1619
|
+
modulo(divisor) {
|
|
1620
|
+
if (!Long.isLong(divisor))
|
|
1621
|
+
divisor = Long.fromValue(divisor);
|
|
1622
|
+
if (wasm) {
|
|
1623
|
+
const low = (this.unsigned ? wasm.rem_u : wasm.rem_s)(this.low, this.high, divisor.low, divisor.high);
|
|
1624
|
+
return Long.fromBits(low, wasm.get_high(), this.unsigned);
|
|
1625
|
+
}
|
|
1626
|
+
return this.sub(this.div(divisor).mul(divisor));
|
|
1627
|
+
}
|
|
1628
|
+
mod(divisor) {
|
|
1629
|
+
return this.modulo(divisor);
|
|
1630
|
+
}
|
|
1631
|
+
rem(divisor) {
|
|
1632
|
+
return this.modulo(divisor);
|
|
1633
|
+
}
|
|
1634
|
+
multiply(multiplier) {
|
|
1635
|
+
if (this.isZero())
|
|
1636
|
+
return Long.ZERO;
|
|
1637
|
+
if (!Long.isLong(multiplier))
|
|
1638
|
+
multiplier = Long.fromValue(multiplier);
|
|
1639
|
+
if (wasm) {
|
|
1640
|
+
const low = wasm.mul(this.low, this.high, multiplier.low, multiplier.high);
|
|
1641
|
+
return Long.fromBits(low, wasm.get_high(), this.unsigned);
|
|
1642
|
+
}
|
|
1643
|
+
if (multiplier.isZero())
|
|
1644
|
+
return Long.ZERO;
|
|
1645
|
+
if (this.eq(Long.MIN_VALUE))
|
|
1646
|
+
return multiplier.isOdd() ? Long.MIN_VALUE : Long.ZERO;
|
|
1647
|
+
if (multiplier.eq(Long.MIN_VALUE))
|
|
1648
|
+
return this.isOdd() ? Long.MIN_VALUE : Long.ZERO;
|
|
1649
|
+
if (this.isNegative()) {
|
|
1650
|
+
if (multiplier.isNegative())
|
|
1651
|
+
return this.neg().mul(multiplier.neg());
|
|
1652
|
+
else
|
|
1653
|
+
return this.neg().mul(multiplier).neg();
|
|
1654
|
+
}
|
|
1655
|
+
else if (multiplier.isNegative())
|
|
1656
|
+
return this.mul(multiplier.neg()).neg();
|
|
1657
|
+
if (this.lt(Long.TWO_PWR_24) && multiplier.lt(Long.TWO_PWR_24))
|
|
1658
|
+
return Long.fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);
|
|
1659
|
+
const a48 = this.high >>> 16;
|
|
1660
|
+
const a32 = this.high & 0xffff;
|
|
1661
|
+
const a16 = this.low >>> 16;
|
|
1662
|
+
const a00 = this.low & 0xffff;
|
|
1663
|
+
const b48 = multiplier.high >>> 16;
|
|
1664
|
+
const b32 = multiplier.high & 0xffff;
|
|
1665
|
+
const b16 = multiplier.low >>> 16;
|
|
1666
|
+
const b00 = multiplier.low & 0xffff;
|
|
1667
|
+
let c48 = 0, c32 = 0, c16 = 0, c00 = 0;
|
|
1668
|
+
c00 += a00 * b00;
|
|
1669
|
+
c16 += c00 >>> 16;
|
|
1670
|
+
c00 &= 0xffff;
|
|
1671
|
+
c16 += a16 * b00;
|
|
1672
|
+
c32 += c16 >>> 16;
|
|
1673
|
+
c16 &= 0xffff;
|
|
1674
|
+
c16 += a00 * b16;
|
|
1675
|
+
c32 += c16 >>> 16;
|
|
1676
|
+
c16 &= 0xffff;
|
|
1677
|
+
c32 += a32 * b00;
|
|
1678
|
+
c48 += c32 >>> 16;
|
|
1679
|
+
c32 &= 0xffff;
|
|
1680
|
+
c32 += a16 * b16;
|
|
1681
|
+
c48 += c32 >>> 16;
|
|
1682
|
+
c32 &= 0xffff;
|
|
1683
|
+
c32 += a00 * b32;
|
|
1684
|
+
c48 += c32 >>> 16;
|
|
1685
|
+
c32 &= 0xffff;
|
|
1686
|
+
c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;
|
|
1687
|
+
c48 &= 0xffff;
|
|
1688
|
+
return Long.fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);
|
|
1689
|
+
}
|
|
1690
|
+
mul(multiplier) {
|
|
1691
|
+
return this.multiply(multiplier);
|
|
1692
|
+
}
|
|
1693
|
+
negate() {
|
|
1694
|
+
if (!this.unsigned && this.eq(Long.MIN_VALUE))
|
|
1695
|
+
return Long.MIN_VALUE;
|
|
1696
|
+
return this.not().add(Long.ONE);
|
|
1697
|
+
}
|
|
1698
|
+
neg() {
|
|
1699
|
+
return this.negate();
|
|
1700
|
+
}
|
|
1701
|
+
not() {
|
|
1702
|
+
return Long.fromBits(~this.low, ~this.high, this.unsigned);
|
|
1703
|
+
}
|
|
1704
|
+
notEquals(other) {
|
|
1705
|
+
return !this.equals(other);
|
|
1706
|
+
}
|
|
1707
|
+
neq(other) {
|
|
1708
|
+
return this.notEquals(other);
|
|
1709
|
+
}
|
|
1710
|
+
ne(other) {
|
|
1711
|
+
return this.notEquals(other);
|
|
1712
|
+
}
|
|
1713
|
+
or(other) {
|
|
1714
|
+
if (!Long.isLong(other))
|
|
1715
|
+
other = Long.fromValue(other);
|
|
1716
|
+
return Long.fromBits(this.low | other.low, this.high | other.high, this.unsigned);
|
|
1717
|
+
}
|
|
1718
|
+
shiftLeft(numBits) {
|
|
1719
|
+
if (Long.isLong(numBits))
|
|
1720
|
+
numBits = numBits.toInt();
|
|
1721
|
+
if ((numBits &= 63) === 0)
|
|
1722
|
+
return this;
|
|
1723
|
+
else if (numBits < 32)
|
|
1724
|
+
return Long.fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);
|
|
1725
|
+
else
|
|
1726
|
+
return Long.fromBits(0, this.low << (numBits - 32), this.unsigned);
|
|
1727
|
+
}
|
|
1728
|
+
shl(numBits) {
|
|
1729
|
+
return this.shiftLeft(numBits);
|
|
1730
|
+
}
|
|
1731
|
+
shiftRight(numBits) {
|
|
1732
|
+
if (Long.isLong(numBits))
|
|
1733
|
+
numBits = numBits.toInt();
|
|
1734
|
+
if ((numBits &= 63) === 0)
|
|
1735
|
+
return this;
|
|
1736
|
+
else if (numBits < 32)
|
|
1737
|
+
return Long.fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);
|
|
1738
|
+
else
|
|
1739
|
+
return Long.fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);
|
|
1740
|
+
}
|
|
1741
|
+
shr(numBits) {
|
|
1742
|
+
return this.shiftRight(numBits);
|
|
1743
|
+
}
|
|
1744
|
+
shiftRightUnsigned(numBits) {
|
|
1745
|
+
if (Long.isLong(numBits))
|
|
1746
|
+
numBits = numBits.toInt();
|
|
1747
|
+
numBits &= 63;
|
|
1748
|
+
if (numBits === 0)
|
|
1749
|
+
return this;
|
|
1750
|
+
else {
|
|
1751
|
+
const high = this.high;
|
|
1752
|
+
if (numBits < 32) {
|
|
1753
|
+
const low = this.low;
|
|
1754
|
+
return Long.fromBits((low >>> numBits) | (high << (32 - numBits)), high >>> numBits, this.unsigned);
|
|
1755
|
+
}
|
|
1756
|
+
else if (numBits === 32)
|
|
1757
|
+
return Long.fromBits(high, 0, this.unsigned);
|
|
1758
|
+
else
|
|
1759
|
+
return Long.fromBits(high >>> (numBits - 32), 0, this.unsigned);
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
shr_u(numBits) {
|
|
1763
|
+
return this.shiftRightUnsigned(numBits);
|
|
1764
|
+
}
|
|
1765
|
+
shru(numBits) {
|
|
1766
|
+
return this.shiftRightUnsigned(numBits);
|
|
1767
|
+
}
|
|
1768
|
+
subtract(subtrahend) {
|
|
1769
|
+
if (!Long.isLong(subtrahend))
|
|
1770
|
+
subtrahend = Long.fromValue(subtrahend);
|
|
1771
|
+
return this.add(subtrahend.neg());
|
|
1772
|
+
}
|
|
1773
|
+
sub(subtrahend) {
|
|
1774
|
+
return this.subtract(subtrahend);
|
|
1775
|
+
}
|
|
1776
|
+
toInt() {
|
|
1777
|
+
return this.unsigned ? this.low >>> 0 : this.low;
|
|
1778
|
+
}
|
|
1779
|
+
toNumber() {
|
|
1780
|
+
if (this.unsigned)
|
|
1781
|
+
return (this.high >>> 0) * TWO_PWR_32_DBL + (this.low >>> 0);
|
|
1782
|
+
return this.high * TWO_PWR_32_DBL + (this.low >>> 0);
|
|
1783
|
+
}
|
|
1784
|
+
toBigInt() {
|
|
1785
|
+
return BigInt(this.toString());
|
|
1786
|
+
}
|
|
1787
|
+
toBytes(le) {
|
|
1788
|
+
return le ? this.toBytesLE() : this.toBytesBE();
|
|
1789
|
+
}
|
|
1790
|
+
toBytesLE() {
|
|
1791
|
+
const hi = this.high, lo = this.low;
|
|
1792
|
+
return [
|
|
1793
|
+
lo & 0xff,
|
|
1794
|
+
(lo >>> 8) & 0xff,
|
|
1795
|
+
(lo >>> 16) & 0xff,
|
|
1796
|
+
lo >>> 24,
|
|
1797
|
+
hi & 0xff,
|
|
1798
|
+
(hi >>> 8) & 0xff,
|
|
1799
|
+
(hi >>> 16) & 0xff,
|
|
1800
|
+
hi >>> 24
|
|
1801
|
+
];
|
|
1802
|
+
}
|
|
1803
|
+
toBytesBE() {
|
|
1804
|
+
const hi = this.high, lo = this.low;
|
|
1805
|
+
return [
|
|
1806
|
+
hi >>> 24,
|
|
1807
|
+
(hi >>> 16) & 0xff,
|
|
1808
|
+
(hi >>> 8) & 0xff,
|
|
1809
|
+
hi & 0xff,
|
|
1810
|
+
lo >>> 24,
|
|
1811
|
+
(lo >>> 16) & 0xff,
|
|
1812
|
+
(lo >>> 8) & 0xff,
|
|
1813
|
+
lo & 0xff
|
|
1814
|
+
];
|
|
1815
|
+
}
|
|
1816
|
+
toSigned() {
|
|
1817
|
+
if (!this.unsigned)
|
|
1818
|
+
return this;
|
|
1819
|
+
return Long.fromBits(this.low, this.high, false);
|
|
1820
|
+
}
|
|
1821
|
+
toString(radix) {
|
|
1822
|
+
radix = radix || 10;
|
|
1823
|
+
if (radix < 2 || 36 < radix)
|
|
1824
|
+
throw new BSONError('radix');
|
|
1825
|
+
if (this.isZero())
|
|
1826
|
+
return '0';
|
|
1827
|
+
if (this.isNegative()) {
|
|
1828
|
+
if (this.eq(Long.MIN_VALUE)) {
|
|
1829
|
+
const radixLong = Long.fromNumber(radix), div = this.div(radixLong), rem1 = div.mul(radixLong).sub(this);
|
|
1830
|
+
return div.toString(radix) + rem1.toInt().toString(radix);
|
|
1831
|
+
}
|
|
1832
|
+
else
|
|
1833
|
+
return '-' + this.neg().toString(radix);
|
|
1834
|
+
}
|
|
1835
|
+
const radixToPower = Long.fromNumber(Math.pow(radix, 6), this.unsigned);
|
|
1836
|
+
let rem = this;
|
|
1837
|
+
let result = '';
|
|
1838
|
+
while (true) {
|
|
1839
|
+
const remDiv = rem.div(radixToPower);
|
|
1840
|
+
const intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0;
|
|
1841
|
+
let digits = intval.toString(radix);
|
|
1842
|
+
rem = remDiv;
|
|
1843
|
+
if (rem.isZero()) {
|
|
1844
|
+
return digits + result;
|
|
1845
|
+
}
|
|
1846
|
+
else {
|
|
1847
|
+
while (digits.length < 6)
|
|
1848
|
+
digits = '0' + digits;
|
|
1849
|
+
result = '' + digits + result;
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
}
|
|
1853
|
+
toUnsigned() {
|
|
1854
|
+
if (this.unsigned)
|
|
1855
|
+
return this;
|
|
1856
|
+
return Long.fromBits(this.low, this.high, true);
|
|
1857
|
+
}
|
|
1858
|
+
xor(other) {
|
|
1859
|
+
if (!Long.isLong(other))
|
|
1860
|
+
other = Long.fromValue(other);
|
|
1861
|
+
return Long.fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);
|
|
1862
|
+
}
|
|
1863
|
+
eqz() {
|
|
1864
|
+
return this.isZero();
|
|
1865
|
+
}
|
|
1866
|
+
le(other) {
|
|
1867
|
+
return this.lessThanOrEqual(other);
|
|
1868
|
+
}
|
|
1869
|
+
toExtendedJSON(options) {
|
|
1870
|
+
if (options && options.relaxed)
|
|
1871
|
+
return this.toNumber();
|
|
1872
|
+
return { $numberLong: this.toString() };
|
|
1873
|
+
}
|
|
1874
|
+
static fromExtendedJSON(doc, options) {
|
|
1875
|
+
const { useBigInt64 = false, relaxed = true } = { ...options };
|
|
1876
|
+
if (doc.$numberLong.length > MAX_INT64_STRING_LENGTH) {
|
|
1877
|
+
throw new BSONError('$numberLong string is too long');
|
|
1878
|
+
}
|
|
1879
|
+
if (!DECIMAL_REG_EX.test(doc.$numberLong)) {
|
|
1880
|
+
throw new BSONError(`$numberLong string "${doc.$numberLong}" is in an invalid format`);
|
|
1881
|
+
}
|
|
1882
|
+
if (useBigInt64) {
|
|
1883
|
+
const bigIntResult = BigInt(doc.$numberLong);
|
|
1884
|
+
return BigInt.asIntN(64, bigIntResult);
|
|
1885
|
+
}
|
|
1886
|
+
const longResult = Long.fromString(doc.$numberLong);
|
|
1887
|
+
if (relaxed) {
|
|
1888
|
+
return longResult.toNumber();
|
|
1889
|
+
}
|
|
1890
|
+
return longResult;
|
|
1891
|
+
}
|
|
1892
|
+
inspect(depth, options, inspect) {
|
|
1893
|
+
inspect ??= defaultInspect;
|
|
1894
|
+
const longVal = inspect(this.toString(), options);
|
|
1895
|
+
const unsignedVal = this.unsigned ? `, ${inspect(this.unsigned, options)}` : '';
|
|
1896
|
+
return `new Long(${longVal}${unsignedVal})`;
|
|
1897
|
+
}
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const PARSE_STRING_REGEXP = /^(\+|-)?(\d+|(\d*\.\d*))?(E|e)?([-+])?(\d+)?$/;
|
|
1901
|
+
const PARSE_INF_REGEXP = /^(\+|-)?(Infinity|inf)$/i;
|
|
1902
|
+
const PARSE_NAN_REGEXP = /^(\+|-)?NaN$/i;
|
|
1903
|
+
const EXPONENT_MAX = 6111;
|
|
1904
|
+
const EXPONENT_MIN = -6176;
|
|
1905
|
+
const EXPONENT_BIAS = 6176;
|
|
1906
|
+
const MAX_DIGITS = 34;
|
|
1907
|
+
const NAN_BUFFER = ByteUtils.fromNumberArray([
|
|
1908
|
+
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
1909
|
+
].reverse());
|
|
1910
|
+
const INF_NEGATIVE_BUFFER = ByteUtils.fromNumberArray([
|
|
1911
|
+
0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
1912
|
+
].reverse());
|
|
1913
|
+
const INF_POSITIVE_BUFFER = ByteUtils.fromNumberArray([
|
|
1914
|
+
0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
1915
|
+
].reverse());
|
|
1916
|
+
const EXPONENT_REGEX = /^([-+])?(\d+)?$/;
|
|
1917
|
+
const COMBINATION_MASK = 0x1f;
|
|
1918
|
+
const EXPONENT_MASK = 0x3fff;
|
|
1919
|
+
const COMBINATION_INFINITY = 30;
|
|
1920
|
+
const COMBINATION_NAN = 31;
|
|
1921
|
+
function isDigit(value) {
|
|
1922
|
+
return !isNaN(parseInt(value, 10));
|
|
1923
|
+
}
|
|
1924
|
+
function divideu128(value) {
|
|
1925
|
+
const DIVISOR = Long.fromNumber(1000 * 1000 * 1000);
|
|
1926
|
+
let _rem = Long.fromNumber(0);
|
|
1927
|
+
if (!value.parts[0] && !value.parts[1] && !value.parts[2] && !value.parts[3]) {
|
|
1928
|
+
return { quotient: value, rem: _rem };
|
|
1929
|
+
}
|
|
1930
|
+
for (let i = 0; i <= 3; i++) {
|
|
1931
|
+
_rem = _rem.shiftLeft(32);
|
|
1932
|
+
_rem = _rem.add(new Long(value.parts[i], 0));
|
|
1933
|
+
value.parts[i] = _rem.div(DIVISOR).low;
|
|
1934
|
+
_rem = _rem.modulo(DIVISOR);
|
|
1935
|
+
}
|
|
1936
|
+
return { quotient: value, rem: _rem };
|
|
1937
|
+
}
|
|
1938
|
+
function multiply64x2(left, right) {
|
|
1939
|
+
if (!left && !right) {
|
|
1940
|
+
return { high: Long.fromNumber(0), low: Long.fromNumber(0) };
|
|
1941
|
+
}
|
|
1942
|
+
const leftHigh = left.shiftRightUnsigned(32);
|
|
1943
|
+
const leftLow = new Long(left.getLowBits(), 0);
|
|
1944
|
+
const rightHigh = right.shiftRightUnsigned(32);
|
|
1945
|
+
const rightLow = new Long(right.getLowBits(), 0);
|
|
1946
|
+
let productHigh = leftHigh.multiply(rightHigh);
|
|
1947
|
+
let productMid = leftHigh.multiply(rightLow);
|
|
1948
|
+
const productMid2 = leftLow.multiply(rightHigh);
|
|
1949
|
+
let productLow = leftLow.multiply(rightLow);
|
|
1950
|
+
productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
|
|
1951
|
+
productMid = new Long(productMid.getLowBits(), 0)
|
|
1952
|
+
.add(productMid2)
|
|
1953
|
+
.add(productLow.shiftRightUnsigned(32));
|
|
1954
|
+
productHigh = productHigh.add(productMid.shiftRightUnsigned(32));
|
|
1955
|
+
productLow = productMid.shiftLeft(32).add(new Long(productLow.getLowBits(), 0));
|
|
1956
|
+
return { high: productHigh, low: productLow };
|
|
1957
|
+
}
|
|
1958
|
+
function lessThan(left, right) {
|
|
1959
|
+
const uhleft = left.high >>> 0;
|
|
1960
|
+
const uhright = right.high >>> 0;
|
|
1961
|
+
if (uhleft < uhright) {
|
|
1962
|
+
return true;
|
|
1963
|
+
}
|
|
1964
|
+
else if (uhleft === uhright) {
|
|
1965
|
+
const ulleft = left.low >>> 0;
|
|
1966
|
+
const ulright = right.low >>> 0;
|
|
1967
|
+
if (ulleft < ulright)
|
|
1968
|
+
return true;
|
|
1969
|
+
}
|
|
1970
|
+
return false;
|
|
1971
|
+
}
|
|
1972
|
+
function invalidErr(string, message) {
|
|
1973
|
+
throw new BSONError(`"${string}" is not a valid Decimal128 string - ${message}`);
|
|
1974
|
+
}
|
|
1975
|
+
class Decimal128 extends BSONValue {
|
|
1976
|
+
get _bsontype() {
|
|
1977
|
+
return 'Decimal128';
|
|
1978
|
+
}
|
|
1979
|
+
bytes;
|
|
1980
|
+
constructor(bytes) {
|
|
1981
|
+
super();
|
|
1982
|
+
if (typeof bytes === 'string') {
|
|
1983
|
+
this.bytes = Decimal128.fromString(bytes).bytes;
|
|
1984
|
+
}
|
|
1985
|
+
else if (bytes instanceof Uint8Array || isUint8Array(bytes)) {
|
|
1986
|
+
if (bytes.byteLength !== 16) {
|
|
1987
|
+
throw new BSONError('Decimal128 must take a Buffer of 16 bytes');
|
|
1988
|
+
}
|
|
1989
|
+
this.bytes = bytes;
|
|
1990
|
+
}
|
|
1991
|
+
else {
|
|
1992
|
+
throw new BSONError('Decimal128 must take a Buffer or string');
|
|
1993
|
+
}
|
|
1994
|
+
}
|
|
1995
|
+
static fromString(representation) {
|
|
1996
|
+
return Decimal128._fromString(representation, { allowRounding: false });
|
|
1997
|
+
}
|
|
1998
|
+
static fromStringWithRounding(representation) {
|
|
1999
|
+
return Decimal128._fromString(representation, { allowRounding: true });
|
|
2000
|
+
}
|
|
2001
|
+
static _fromString(representation, options) {
|
|
2002
|
+
let isNegative = false;
|
|
2003
|
+
let sawSign = false;
|
|
2004
|
+
let sawRadix = false;
|
|
2005
|
+
let foundNonZero = false;
|
|
2006
|
+
let significantDigits = 0;
|
|
2007
|
+
let nDigitsRead = 0;
|
|
2008
|
+
let nDigits = 0;
|
|
2009
|
+
let radixPosition = 0;
|
|
2010
|
+
let firstNonZero = 0;
|
|
2011
|
+
const digits = [0];
|
|
2012
|
+
let nDigitsStored = 0;
|
|
2013
|
+
let digitsInsert = 0;
|
|
2014
|
+
let lastDigit = 0;
|
|
2015
|
+
let exponent = 0;
|
|
2016
|
+
let significandHigh = new Long(0, 0);
|
|
2017
|
+
let significandLow = new Long(0, 0);
|
|
2018
|
+
let biasedExponent = 0;
|
|
2019
|
+
let index = 0;
|
|
2020
|
+
if (representation.length >= 7000) {
|
|
2021
|
+
throw new BSONError('' + representation + ' not a valid Decimal128 string');
|
|
2022
|
+
}
|
|
2023
|
+
const stringMatch = representation.match(PARSE_STRING_REGEXP);
|
|
2024
|
+
const infMatch = representation.match(PARSE_INF_REGEXP);
|
|
2025
|
+
const nanMatch = representation.match(PARSE_NAN_REGEXP);
|
|
2026
|
+
if ((!stringMatch && !infMatch && !nanMatch) || representation.length === 0) {
|
|
2027
|
+
throw new BSONError('' + representation + ' not a valid Decimal128 string');
|
|
2028
|
+
}
|
|
2029
|
+
if (stringMatch) {
|
|
2030
|
+
const unsignedNumber = stringMatch[2];
|
|
2031
|
+
const e = stringMatch[4];
|
|
2032
|
+
const expSign = stringMatch[5];
|
|
2033
|
+
const expNumber = stringMatch[6];
|
|
2034
|
+
if (e && expNumber === undefined)
|
|
2035
|
+
invalidErr(representation, 'missing exponent power');
|
|
2036
|
+
if (e && unsignedNumber === undefined)
|
|
2037
|
+
invalidErr(representation, 'missing exponent base');
|
|
2038
|
+
if (e === undefined && (expSign || expNumber)) {
|
|
2039
|
+
invalidErr(representation, 'missing e before exponent');
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
if (representation[index] === '+' || representation[index] === '-') {
|
|
2043
|
+
sawSign = true;
|
|
2044
|
+
isNegative = representation[index++] === '-';
|
|
2045
|
+
}
|
|
2046
|
+
if (!isDigit(representation[index]) && representation[index] !== '.') {
|
|
2047
|
+
if (representation[index] === 'i' || representation[index] === 'I') {
|
|
2048
|
+
return new Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER);
|
|
2049
|
+
}
|
|
2050
|
+
else if (representation[index] === 'N') {
|
|
2051
|
+
return new Decimal128(NAN_BUFFER);
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
while (isDigit(representation[index]) || representation[index] === '.') {
|
|
2055
|
+
if (representation[index] === '.') {
|
|
2056
|
+
if (sawRadix)
|
|
2057
|
+
invalidErr(representation, 'contains multiple periods');
|
|
2058
|
+
sawRadix = true;
|
|
2059
|
+
index = index + 1;
|
|
2060
|
+
continue;
|
|
2061
|
+
}
|
|
2062
|
+
if (nDigitsStored < MAX_DIGITS) {
|
|
2063
|
+
if (representation[index] !== '0' || foundNonZero) {
|
|
2064
|
+
if (!foundNonZero) {
|
|
2065
|
+
firstNonZero = nDigitsRead;
|
|
2066
|
+
}
|
|
2067
|
+
foundNonZero = true;
|
|
2068
|
+
digits[digitsInsert++] = parseInt(representation[index], 10);
|
|
2069
|
+
nDigitsStored = nDigitsStored + 1;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
if (foundNonZero)
|
|
2073
|
+
nDigits = nDigits + 1;
|
|
2074
|
+
if (sawRadix)
|
|
2075
|
+
radixPosition = radixPosition + 1;
|
|
2076
|
+
nDigitsRead = nDigitsRead + 1;
|
|
2077
|
+
index = index + 1;
|
|
2078
|
+
}
|
|
2079
|
+
if (sawRadix && !nDigitsRead)
|
|
2080
|
+
throw new BSONError('' + representation + ' not a valid Decimal128 string');
|
|
2081
|
+
if (representation[index] === 'e' || representation[index] === 'E') {
|
|
2082
|
+
const match = representation.substr(++index).match(EXPONENT_REGEX);
|
|
2083
|
+
if (!match || !match[2])
|
|
2084
|
+
return new Decimal128(NAN_BUFFER);
|
|
2085
|
+
exponent = parseInt(match[0], 10);
|
|
2086
|
+
index = index + match[0].length;
|
|
2087
|
+
}
|
|
2088
|
+
if (representation[index])
|
|
2089
|
+
return new Decimal128(NAN_BUFFER);
|
|
2090
|
+
if (!nDigitsStored) {
|
|
2091
|
+
digits[0] = 0;
|
|
2092
|
+
nDigits = 1;
|
|
2093
|
+
nDigitsStored = 1;
|
|
2094
|
+
significantDigits = 0;
|
|
2095
|
+
}
|
|
2096
|
+
else {
|
|
2097
|
+
lastDigit = nDigitsStored - 1;
|
|
2098
|
+
significantDigits = nDigits;
|
|
2099
|
+
if (significantDigits !== 1) {
|
|
2100
|
+
while (representation[firstNonZero + significantDigits - 1 + Number(sawSign) + Number(sawRadix)] === '0') {
|
|
2101
|
+
significantDigits = significantDigits - 1;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
if (exponent <= radixPosition && radixPosition > exponent + (1 << 14)) {
|
|
2106
|
+
exponent = EXPONENT_MIN;
|
|
2107
|
+
}
|
|
2108
|
+
else {
|
|
2109
|
+
exponent = exponent - radixPosition;
|
|
2110
|
+
}
|
|
2111
|
+
while (exponent > EXPONENT_MAX) {
|
|
2112
|
+
lastDigit = lastDigit + 1;
|
|
2113
|
+
if (lastDigit >= MAX_DIGITS) {
|
|
2114
|
+
if (significantDigits === 0) {
|
|
2115
|
+
exponent = EXPONENT_MAX;
|
|
2116
|
+
break;
|
|
2117
|
+
}
|
|
2118
|
+
invalidErr(representation, 'overflow');
|
|
2119
|
+
}
|
|
2120
|
+
exponent = exponent - 1;
|
|
2121
|
+
}
|
|
2122
|
+
if (options.allowRounding) {
|
|
2123
|
+
while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
|
|
2124
|
+
if (lastDigit === 0 && significantDigits < nDigitsStored) {
|
|
2125
|
+
exponent = EXPONENT_MIN;
|
|
2126
|
+
significantDigits = 0;
|
|
2127
|
+
break;
|
|
2128
|
+
}
|
|
2129
|
+
if (nDigitsStored < nDigits) {
|
|
2130
|
+
nDigits = nDigits - 1;
|
|
2131
|
+
}
|
|
2132
|
+
else {
|
|
2133
|
+
lastDigit = lastDigit - 1;
|
|
2134
|
+
}
|
|
2135
|
+
if (exponent < EXPONENT_MAX) {
|
|
2136
|
+
exponent = exponent + 1;
|
|
2137
|
+
}
|
|
2138
|
+
else {
|
|
2139
|
+
const digitsString = digits.join('');
|
|
2140
|
+
if (digitsString.match(/^0+$/)) {
|
|
2141
|
+
exponent = EXPONENT_MAX;
|
|
2142
|
+
break;
|
|
2143
|
+
}
|
|
2144
|
+
invalidErr(representation, 'overflow');
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
if (lastDigit + 1 < significantDigits) {
|
|
2148
|
+
let endOfString = nDigitsRead;
|
|
2149
|
+
if (sawRadix) {
|
|
2150
|
+
firstNonZero = firstNonZero + 1;
|
|
2151
|
+
endOfString = endOfString + 1;
|
|
2152
|
+
}
|
|
2153
|
+
if (sawSign) {
|
|
2154
|
+
firstNonZero = firstNonZero + 1;
|
|
2155
|
+
endOfString = endOfString + 1;
|
|
2156
|
+
}
|
|
2157
|
+
const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10);
|
|
2158
|
+
let roundBit = 0;
|
|
2159
|
+
if (roundDigit >= 5) {
|
|
2160
|
+
roundBit = 1;
|
|
2161
|
+
if (roundDigit === 5) {
|
|
2162
|
+
roundBit = digits[lastDigit] % 2 === 1 ? 1 : 0;
|
|
2163
|
+
for (let i = firstNonZero + lastDigit + 2; i < endOfString; i++) {
|
|
2164
|
+
if (parseInt(representation[i], 10)) {
|
|
2165
|
+
roundBit = 1;
|
|
2166
|
+
break;
|
|
2167
|
+
}
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
if (roundBit) {
|
|
2172
|
+
let dIdx = lastDigit;
|
|
2173
|
+
for (; dIdx >= 0; dIdx--) {
|
|
2174
|
+
if (++digits[dIdx] > 9) {
|
|
2175
|
+
digits[dIdx] = 0;
|
|
2176
|
+
if (dIdx === 0) {
|
|
2177
|
+
if (exponent < EXPONENT_MAX) {
|
|
2178
|
+
exponent = exponent + 1;
|
|
2179
|
+
digits[dIdx] = 1;
|
|
2180
|
+
}
|
|
2181
|
+
else {
|
|
2182
|
+
return new Decimal128(isNegative ? INF_NEGATIVE_BUFFER : INF_POSITIVE_BUFFER);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
else {
|
|
2187
|
+
break;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
else {
|
|
2194
|
+
while (exponent < EXPONENT_MIN || nDigitsStored < nDigits) {
|
|
2195
|
+
if (lastDigit === 0) {
|
|
2196
|
+
if (significantDigits === 0) {
|
|
2197
|
+
exponent = EXPONENT_MIN;
|
|
2198
|
+
break;
|
|
2199
|
+
}
|
|
2200
|
+
invalidErr(representation, 'exponent underflow');
|
|
2201
|
+
}
|
|
2202
|
+
if (nDigitsStored < nDigits) {
|
|
2203
|
+
if (representation[nDigits - 1 + Number(sawSign) + Number(sawRadix)] !== '0' &&
|
|
2204
|
+
significantDigits !== 0) {
|
|
2205
|
+
invalidErr(representation, 'inexact rounding');
|
|
2206
|
+
}
|
|
2207
|
+
nDigits = nDigits - 1;
|
|
2208
|
+
}
|
|
2209
|
+
else {
|
|
2210
|
+
if (digits[lastDigit] !== 0) {
|
|
2211
|
+
invalidErr(representation, 'inexact rounding');
|
|
2212
|
+
}
|
|
2213
|
+
lastDigit = lastDigit - 1;
|
|
2214
|
+
}
|
|
2215
|
+
if (exponent < EXPONENT_MAX) {
|
|
2216
|
+
exponent = exponent + 1;
|
|
2217
|
+
}
|
|
2218
|
+
else {
|
|
2219
|
+
invalidErr(representation, 'overflow');
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
if (lastDigit + 1 < significantDigits) {
|
|
2223
|
+
if (sawRadix) {
|
|
2224
|
+
firstNonZero = firstNonZero + 1;
|
|
2225
|
+
}
|
|
2226
|
+
if (sawSign) {
|
|
2227
|
+
firstNonZero = firstNonZero + 1;
|
|
2228
|
+
}
|
|
2229
|
+
const roundDigit = parseInt(representation[firstNonZero + lastDigit + 1], 10);
|
|
2230
|
+
if (roundDigit !== 0) {
|
|
2231
|
+
invalidErr(representation, 'inexact rounding');
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
significandHigh = Long.fromNumber(0);
|
|
2236
|
+
significandLow = Long.fromNumber(0);
|
|
2237
|
+
if (significantDigits === 0) {
|
|
2238
|
+
significandHigh = Long.fromNumber(0);
|
|
2239
|
+
significandLow = Long.fromNumber(0);
|
|
2240
|
+
}
|
|
2241
|
+
else if (lastDigit < 17) {
|
|
2242
|
+
let dIdx = 0;
|
|
2243
|
+
significandLow = Long.fromNumber(digits[dIdx++]);
|
|
2244
|
+
significandHigh = new Long(0, 0);
|
|
2245
|
+
for (; dIdx <= lastDigit; dIdx++) {
|
|
2246
|
+
significandLow = significandLow.multiply(Long.fromNumber(10));
|
|
2247
|
+
significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
else {
|
|
2251
|
+
let dIdx = 0;
|
|
2252
|
+
significandHigh = Long.fromNumber(digits[dIdx++]);
|
|
2253
|
+
for (; dIdx <= lastDigit - 17; dIdx++) {
|
|
2254
|
+
significandHigh = significandHigh.multiply(Long.fromNumber(10));
|
|
2255
|
+
significandHigh = significandHigh.add(Long.fromNumber(digits[dIdx]));
|
|
2256
|
+
}
|
|
2257
|
+
significandLow = Long.fromNumber(digits[dIdx++]);
|
|
2258
|
+
for (; dIdx <= lastDigit; dIdx++) {
|
|
2259
|
+
significandLow = significandLow.multiply(Long.fromNumber(10));
|
|
2260
|
+
significandLow = significandLow.add(Long.fromNumber(digits[dIdx]));
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
const significand = multiply64x2(significandHigh, Long.fromString('100000000000000000'));
|
|
2264
|
+
significand.low = significand.low.add(significandLow);
|
|
2265
|
+
if (lessThan(significand.low, significandLow)) {
|
|
2266
|
+
significand.high = significand.high.add(Long.fromNumber(1));
|
|
2267
|
+
}
|
|
2268
|
+
biasedExponent = exponent + EXPONENT_BIAS;
|
|
2269
|
+
const dec = { low: Long.fromNumber(0), high: Long.fromNumber(0) };
|
|
2270
|
+
if (significand.high.shiftRightUnsigned(49).and(Long.fromNumber(1)).equals(Long.fromNumber(1))) {
|
|
2271
|
+
dec.high = dec.high.or(Long.fromNumber(0x3).shiftLeft(61));
|
|
2272
|
+
dec.high = dec.high.or(Long.fromNumber(biasedExponent).and(Long.fromNumber(0x3fff).shiftLeft(47)));
|
|
2273
|
+
dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x7fffffffffff)));
|
|
2274
|
+
}
|
|
2275
|
+
else {
|
|
2276
|
+
dec.high = dec.high.or(Long.fromNumber(biasedExponent & 0x3fff).shiftLeft(49));
|
|
2277
|
+
dec.high = dec.high.or(significand.high.and(Long.fromNumber(0x1ffffffffffff)));
|
|
2278
|
+
}
|
|
2279
|
+
dec.low = significand.low;
|
|
2280
|
+
if (isNegative) {
|
|
2281
|
+
dec.high = dec.high.or(Long.fromString('9223372036854775808'));
|
|
2282
|
+
}
|
|
2283
|
+
const buffer = ByteUtils.allocateUnsafe(16);
|
|
2284
|
+
index = 0;
|
|
2285
|
+
buffer[index++] = dec.low.low & 0xff;
|
|
2286
|
+
buffer[index++] = (dec.low.low >> 8) & 0xff;
|
|
2287
|
+
buffer[index++] = (dec.low.low >> 16) & 0xff;
|
|
2288
|
+
buffer[index++] = (dec.low.low >> 24) & 0xff;
|
|
2289
|
+
buffer[index++] = dec.low.high & 0xff;
|
|
2290
|
+
buffer[index++] = (dec.low.high >> 8) & 0xff;
|
|
2291
|
+
buffer[index++] = (dec.low.high >> 16) & 0xff;
|
|
2292
|
+
buffer[index++] = (dec.low.high >> 24) & 0xff;
|
|
2293
|
+
buffer[index++] = dec.high.low & 0xff;
|
|
2294
|
+
buffer[index++] = (dec.high.low >> 8) & 0xff;
|
|
2295
|
+
buffer[index++] = (dec.high.low >> 16) & 0xff;
|
|
2296
|
+
buffer[index++] = (dec.high.low >> 24) & 0xff;
|
|
2297
|
+
buffer[index++] = dec.high.high & 0xff;
|
|
2298
|
+
buffer[index++] = (dec.high.high >> 8) & 0xff;
|
|
2299
|
+
buffer[index++] = (dec.high.high >> 16) & 0xff;
|
|
2300
|
+
buffer[index++] = (dec.high.high >> 24) & 0xff;
|
|
2301
|
+
return new Decimal128(buffer);
|
|
2302
|
+
}
|
|
2303
|
+
toString() {
|
|
2304
|
+
let biased_exponent;
|
|
2305
|
+
let significand_digits = 0;
|
|
2306
|
+
const significand = new Array(36);
|
|
2307
|
+
for (let i = 0; i < significand.length; i++)
|
|
2308
|
+
significand[i] = 0;
|
|
2309
|
+
let index = 0;
|
|
2310
|
+
let is_zero = false;
|
|
2311
|
+
let significand_msb;
|
|
2312
|
+
let significand128 = { parts: [0, 0, 0, 0] };
|
|
2313
|
+
let j, k;
|
|
2314
|
+
const string = [];
|
|
2315
|
+
index = 0;
|
|
2316
|
+
const buffer = this.bytes;
|
|
2317
|
+
const low = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
|
|
2318
|
+
const midl = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
|
|
2319
|
+
const midh = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
|
|
2320
|
+
const high = buffer[index++] | (buffer[index++] << 8) | (buffer[index++] << 16) | (buffer[index++] << 24);
|
|
2321
|
+
index = 0;
|
|
2322
|
+
const dec = {
|
|
2323
|
+
low: new Long(low, midl),
|
|
2324
|
+
high: new Long(midh, high)
|
|
2325
|
+
};
|
|
2326
|
+
if (dec.high.lessThan(Long.ZERO)) {
|
|
2327
|
+
string.push('-');
|
|
2328
|
+
}
|
|
2329
|
+
const combination = (high >> 26) & COMBINATION_MASK;
|
|
2330
|
+
if (combination >> 3 === 3) {
|
|
2331
|
+
if (combination === COMBINATION_INFINITY) {
|
|
2332
|
+
return string.join('') + 'Infinity';
|
|
2333
|
+
}
|
|
2334
|
+
else if (combination === COMBINATION_NAN) {
|
|
2335
|
+
return 'NaN';
|
|
2336
|
+
}
|
|
2337
|
+
else {
|
|
2338
|
+
biased_exponent = (high >> 15) & EXPONENT_MASK;
|
|
2339
|
+
significand_msb = 0x08 + ((high >> 14) & 0x01);
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
else {
|
|
2343
|
+
significand_msb = (high >> 14) & 0x07;
|
|
2344
|
+
biased_exponent = (high >> 17) & EXPONENT_MASK;
|
|
2345
|
+
}
|
|
2346
|
+
const exponent = biased_exponent - EXPONENT_BIAS;
|
|
2347
|
+
significand128.parts[0] = (high & 0x3fff) + ((significand_msb & 0xf) << 14);
|
|
2348
|
+
significand128.parts[1] = midh;
|
|
2349
|
+
significand128.parts[2] = midl;
|
|
2350
|
+
significand128.parts[3] = low;
|
|
2351
|
+
if (significand128.parts[0] === 0 &&
|
|
2352
|
+
significand128.parts[1] === 0 &&
|
|
2353
|
+
significand128.parts[2] === 0 &&
|
|
2354
|
+
significand128.parts[3] === 0) {
|
|
2355
|
+
is_zero = true;
|
|
2356
|
+
}
|
|
2357
|
+
else {
|
|
2358
|
+
for (k = 3; k >= 0; k--) {
|
|
2359
|
+
let least_digits = 0;
|
|
2360
|
+
const result = divideu128(significand128);
|
|
2361
|
+
significand128 = result.quotient;
|
|
2362
|
+
least_digits = result.rem.low;
|
|
2363
|
+
if (!least_digits)
|
|
2364
|
+
continue;
|
|
2365
|
+
for (j = 8; j >= 0; j--) {
|
|
2366
|
+
significand[k * 9 + j] = least_digits % 10;
|
|
2367
|
+
least_digits = Math.floor(least_digits / 10);
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
if (is_zero) {
|
|
2372
|
+
significand_digits = 1;
|
|
2373
|
+
significand[index] = 0;
|
|
2374
|
+
}
|
|
2375
|
+
else {
|
|
2376
|
+
significand_digits = 36;
|
|
2377
|
+
while (!significand[index]) {
|
|
2378
|
+
significand_digits = significand_digits - 1;
|
|
2379
|
+
index = index + 1;
|
|
2380
|
+
}
|
|
2381
|
+
}
|
|
2382
|
+
const scientific_exponent = significand_digits - 1 + exponent;
|
|
2383
|
+
if (scientific_exponent >= 34 || scientific_exponent <= -7 || exponent > 0) {
|
|
2384
|
+
if (significand_digits > 34) {
|
|
2385
|
+
string.push(`${0}`);
|
|
2386
|
+
if (exponent > 0)
|
|
2387
|
+
string.push(`E+${exponent}`);
|
|
2388
|
+
else if (exponent < 0)
|
|
2389
|
+
string.push(`E${exponent}`);
|
|
2390
|
+
return string.join('');
|
|
2391
|
+
}
|
|
2392
|
+
string.push(`${significand[index++]}`);
|
|
2393
|
+
significand_digits = significand_digits - 1;
|
|
2394
|
+
if (significand_digits) {
|
|
2395
|
+
string.push('.');
|
|
2396
|
+
}
|
|
2397
|
+
for (let i = 0; i < significand_digits; i++) {
|
|
2398
|
+
string.push(`${significand[index++]}`);
|
|
2399
|
+
}
|
|
2400
|
+
string.push('E');
|
|
2401
|
+
if (scientific_exponent > 0) {
|
|
2402
|
+
string.push(`+${scientific_exponent}`);
|
|
2403
|
+
}
|
|
2404
|
+
else {
|
|
2405
|
+
string.push(`${scientific_exponent}`);
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
else {
|
|
2409
|
+
if (exponent >= 0) {
|
|
2410
|
+
for (let i = 0; i < significand_digits; i++) {
|
|
2411
|
+
string.push(`${significand[index++]}`);
|
|
2412
|
+
}
|
|
2413
|
+
}
|
|
2414
|
+
else {
|
|
2415
|
+
let radix_position = significand_digits + exponent;
|
|
2416
|
+
if (radix_position > 0) {
|
|
2417
|
+
for (let i = 0; i < radix_position; i++) {
|
|
2418
|
+
string.push(`${significand[index++]}`);
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
else {
|
|
2422
|
+
string.push('0');
|
|
2423
|
+
}
|
|
2424
|
+
string.push('.');
|
|
2425
|
+
while (radix_position++ < 0) {
|
|
2426
|
+
string.push('0');
|
|
2427
|
+
}
|
|
2428
|
+
for (let i = 0; i < significand_digits - Math.max(radix_position - 1, 0); i++) {
|
|
2429
|
+
string.push(`${significand[index++]}`);
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
return string.join('');
|
|
2434
|
+
}
|
|
2435
|
+
toJSON() {
|
|
2436
|
+
return { $numberDecimal: this.toString() };
|
|
2437
|
+
}
|
|
2438
|
+
toExtendedJSON() {
|
|
2439
|
+
return { $numberDecimal: this.toString() };
|
|
2440
|
+
}
|
|
2441
|
+
static fromExtendedJSON(doc) {
|
|
2442
|
+
return Decimal128.fromString(doc.$numberDecimal);
|
|
2443
|
+
}
|
|
2444
|
+
inspect(depth, options, inspect) {
|
|
2445
|
+
inspect ??= defaultInspect;
|
|
2446
|
+
const d128string = inspect(this.toString(), options);
|
|
2447
|
+
return `new Decimal128(${d128string})`;
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
class Double extends BSONValue {
|
|
2452
|
+
get _bsontype() {
|
|
2453
|
+
return 'Double';
|
|
2454
|
+
}
|
|
2455
|
+
value;
|
|
2456
|
+
constructor(value) {
|
|
2457
|
+
super();
|
|
2458
|
+
if (value instanceof Number) {
|
|
2459
|
+
value = value.valueOf();
|
|
2460
|
+
}
|
|
2461
|
+
this.value = +value;
|
|
2462
|
+
}
|
|
2463
|
+
static fromString(value) {
|
|
2464
|
+
const coercedValue = Number(value);
|
|
2465
|
+
if (value === 'NaN')
|
|
2466
|
+
return new Double(NaN);
|
|
2467
|
+
if (value === 'Infinity')
|
|
2468
|
+
return new Double(Infinity);
|
|
2469
|
+
if (value === '-Infinity')
|
|
2470
|
+
return new Double(-Infinity);
|
|
2471
|
+
if (!Number.isFinite(coercedValue)) {
|
|
2472
|
+
throw new BSONError(`Input: ${value} is not representable as a Double`);
|
|
2473
|
+
}
|
|
2474
|
+
if (value.trim() !== value) {
|
|
2475
|
+
throw new BSONError(`Input: '${value}' contains whitespace`);
|
|
2476
|
+
}
|
|
2477
|
+
if (value === '') {
|
|
2478
|
+
throw new BSONError(`Input is an empty string`);
|
|
2479
|
+
}
|
|
2480
|
+
if (/[^-0-9.+eE]/.test(value)) {
|
|
2481
|
+
throw new BSONError(`Input: '${value}' is not in decimal or exponential notation`);
|
|
2482
|
+
}
|
|
2483
|
+
return new Double(coercedValue);
|
|
2484
|
+
}
|
|
2485
|
+
valueOf() {
|
|
2486
|
+
return this.value;
|
|
2487
|
+
}
|
|
2488
|
+
toJSON() {
|
|
2489
|
+
return this.value;
|
|
2490
|
+
}
|
|
2491
|
+
toString(radix) {
|
|
2492
|
+
return this.value.toString(radix);
|
|
2493
|
+
}
|
|
2494
|
+
toExtendedJSON(options) {
|
|
2495
|
+
if (options && (options.legacy || (options.relaxed && isFinite(this.value)))) {
|
|
2496
|
+
return this.value;
|
|
2497
|
+
}
|
|
2498
|
+
if (Object.is(Math.sign(this.value), -0)) {
|
|
2499
|
+
return { $numberDouble: '-0.0' };
|
|
2500
|
+
}
|
|
2501
|
+
return {
|
|
2502
|
+
$numberDouble: Number.isInteger(this.value) ? this.value.toFixed(1) : this.value.toString()
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
static fromExtendedJSON(doc, options) {
|
|
2506
|
+
const doubleValue = parseFloat(doc.$numberDouble);
|
|
2507
|
+
return options && options.relaxed ? doubleValue : new Double(doubleValue);
|
|
2508
|
+
}
|
|
2509
|
+
inspect(depth, options, inspect) {
|
|
2510
|
+
inspect ??= defaultInspect;
|
|
2511
|
+
return `new Double(${inspect(this.value, options)})`;
|
|
2512
|
+
}
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
class Int32 extends BSONValue {
|
|
2516
|
+
get _bsontype() {
|
|
2517
|
+
return 'Int32';
|
|
2518
|
+
}
|
|
2519
|
+
value;
|
|
2520
|
+
constructor(value) {
|
|
2521
|
+
super();
|
|
2522
|
+
if (value instanceof Number) {
|
|
2523
|
+
value = value.valueOf();
|
|
2524
|
+
}
|
|
2525
|
+
this.value = +value | 0;
|
|
2526
|
+
}
|
|
2527
|
+
static fromString(value) {
|
|
2528
|
+
const cleanedValue = removeLeadingZerosAndExplicitPlus(value);
|
|
2529
|
+
const coercedValue = Number(value);
|
|
2530
|
+
if (BSON_INT32_MAX < coercedValue) {
|
|
2531
|
+
throw new BSONError(`Input: '${value}' is larger than the maximum value for Int32`);
|
|
2532
|
+
}
|
|
2533
|
+
else if (BSON_INT32_MIN > coercedValue) {
|
|
2534
|
+
throw new BSONError(`Input: '${value}' is smaller than the minimum value for Int32`);
|
|
2535
|
+
}
|
|
2536
|
+
else if (!Number.isSafeInteger(coercedValue)) {
|
|
2537
|
+
throw new BSONError(`Input: '${value}' is not a safe integer`);
|
|
2538
|
+
}
|
|
2539
|
+
else if (coercedValue.toString() !== cleanedValue) {
|
|
2540
|
+
throw new BSONError(`Input: '${value}' is not a valid Int32 string`);
|
|
2541
|
+
}
|
|
2542
|
+
return new Int32(coercedValue);
|
|
2543
|
+
}
|
|
2544
|
+
valueOf() {
|
|
2545
|
+
return this.value;
|
|
2546
|
+
}
|
|
2547
|
+
toString(radix) {
|
|
2548
|
+
return this.value.toString(radix);
|
|
2549
|
+
}
|
|
2550
|
+
toJSON() {
|
|
2551
|
+
return this.value;
|
|
2552
|
+
}
|
|
2553
|
+
toExtendedJSON(options) {
|
|
2554
|
+
if (options && (options.relaxed || options.legacy))
|
|
2555
|
+
return this.value;
|
|
2556
|
+
return { $numberInt: this.value.toString() };
|
|
2557
|
+
}
|
|
2558
|
+
static fromExtendedJSON(doc, options) {
|
|
2559
|
+
return options && options.relaxed ? parseInt(doc.$numberInt, 10) : new Int32(doc.$numberInt);
|
|
2560
|
+
}
|
|
2561
|
+
inspect(depth, options, inspect) {
|
|
2562
|
+
inspect ??= defaultInspect;
|
|
2563
|
+
return `new Int32(${inspect(this.value, options)})`;
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
|
|
2567
|
+
class MaxKey extends BSONValue {
|
|
2568
|
+
get _bsontype() {
|
|
2569
|
+
return 'MaxKey';
|
|
2570
|
+
}
|
|
2571
|
+
toExtendedJSON() {
|
|
2572
|
+
return { $maxKey: 1 };
|
|
2573
|
+
}
|
|
2574
|
+
static fromExtendedJSON() {
|
|
2575
|
+
return new MaxKey();
|
|
2576
|
+
}
|
|
2577
|
+
inspect() {
|
|
2578
|
+
return 'new MaxKey()';
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2582
|
+
class MinKey extends BSONValue {
|
|
2583
|
+
get _bsontype() {
|
|
2584
|
+
return 'MinKey';
|
|
2585
|
+
}
|
|
2586
|
+
toExtendedJSON() {
|
|
2587
|
+
return { $minKey: 1 };
|
|
2588
|
+
}
|
|
2589
|
+
static fromExtendedJSON() {
|
|
2590
|
+
return new MinKey();
|
|
2591
|
+
}
|
|
2592
|
+
inspect() {
|
|
2593
|
+
return 'new MinKey()';
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
|
|
2597
|
+
let PROCESS_UNIQUE = null;
|
|
2598
|
+
const __idCache = new WeakMap();
|
|
2599
|
+
class ObjectId extends BSONValue {
|
|
2600
|
+
get _bsontype() {
|
|
2601
|
+
return 'ObjectId';
|
|
2602
|
+
}
|
|
2603
|
+
static index = Math.floor(Math.random() * 0xffffff);
|
|
2604
|
+
static cacheHexString;
|
|
2605
|
+
buffer;
|
|
2606
|
+
constructor(inputId) {
|
|
2607
|
+
super();
|
|
2608
|
+
let workingId;
|
|
2609
|
+
if (typeof inputId === 'object' && inputId && 'id' in inputId) {
|
|
2610
|
+
if (typeof inputId.id !== 'string' && !ArrayBuffer.isView(inputId.id)) {
|
|
2611
|
+
throw new BSONError('Argument passed in must have an id that is of type string or Buffer');
|
|
2612
|
+
}
|
|
2613
|
+
if ('toHexString' in inputId && typeof inputId.toHexString === 'function') {
|
|
2614
|
+
workingId = ByteUtils.fromHex(inputId.toHexString());
|
|
2615
|
+
}
|
|
2616
|
+
else {
|
|
2617
|
+
workingId = inputId.id;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
else {
|
|
2621
|
+
workingId = inputId;
|
|
2622
|
+
}
|
|
2623
|
+
if (workingId == null) {
|
|
2624
|
+
this.buffer = ObjectId.generate();
|
|
2625
|
+
}
|
|
2626
|
+
else if (ArrayBuffer.isView(workingId) && workingId.byteLength === 12) {
|
|
2627
|
+
this.buffer = ByteUtils.toLocalBufferType(workingId);
|
|
2628
|
+
}
|
|
2629
|
+
else if (typeof workingId === 'string') {
|
|
2630
|
+
if (ObjectId.validateHexString(workingId)) {
|
|
2631
|
+
this.buffer = ByteUtils.fromHex(workingId);
|
|
2632
|
+
if (ObjectId.cacheHexString) {
|
|
2633
|
+
__idCache.set(this, workingId);
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
else {
|
|
2637
|
+
throw new BSONError('input must be a 24 character hex string, 12 byte Uint8Array, or an integer');
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
else {
|
|
2641
|
+
throw new BSONError('Argument passed in does not match the accepted types');
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
get id() {
|
|
2645
|
+
return this.buffer;
|
|
2646
|
+
}
|
|
2647
|
+
set id(value) {
|
|
2648
|
+
this.buffer = value;
|
|
2649
|
+
if (ObjectId.cacheHexString) {
|
|
2650
|
+
__idCache.set(this, ByteUtils.toHex(value));
|
|
2651
|
+
}
|
|
2652
|
+
}
|
|
2653
|
+
static validateHexString(string) {
|
|
2654
|
+
if (string?.length !== 24)
|
|
2655
|
+
return false;
|
|
2656
|
+
for (let i = 0; i < 24; i++) {
|
|
2657
|
+
const char = string.charCodeAt(i);
|
|
2658
|
+
if ((char >= 48 && char <= 57) ||
|
|
2659
|
+
(char >= 97 && char <= 102) ||
|
|
2660
|
+
(char >= 65 && char <= 70)) {
|
|
2661
|
+
continue;
|
|
2662
|
+
}
|
|
2663
|
+
return false;
|
|
2664
|
+
}
|
|
2665
|
+
return true;
|
|
2666
|
+
}
|
|
2667
|
+
toHexString() {
|
|
2668
|
+
if (ObjectId.cacheHexString) {
|
|
2669
|
+
const __id = __idCache.get(this);
|
|
2670
|
+
if (__id)
|
|
2671
|
+
return __id;
|
|
2672
|
+
}
|
|
2673
|
+
const hexString = ByteUtils.toHex(this.id);
|
|
2674
|
+
if (ObjectId.cacheHexString) {
|
|
2675
|
+
__idCache.set(this, hexString);
|
|
2676
|
+
}
|
|
2677
|
+
return hexString;
|
|
2678
|
+
}
|
|
2679
|
+
static getInc() {
|
|
2680
|
+
return (ObjectId.index = (ObjectId.index + 1) % 0xffffff);
|
|
2681
|
+
}
|
|
2682
|
+
static generate(time) {
|
|
2683
|
+
if ('number' !== typeof time) {
|
|
2684
|
+
time = Math.floor(Date.now() / 1000);
|
|
2685
|
+
}
|
|
2686
|
+
const inc = ObjectId.getInc();
|
|
2687
|
+
const buffer = ByteUtils.allocateUnsafe(12);
|
|
2688
|
+
NumberUtils.setInt32BE(buffer, 0, time);
|
|
2689
|
+
if (PROCESS_UNIQUE === null) {
|
|
2690
|
+
PROCESS_UNIQUE = ByteUtils.randomBytes(5);
|
|
2691
|
+
}
|
|
2692
|
+
buffer[4] = PROCESS_UNIQUE[0];
|
|
2693
|
+
buffer[5] = PROCESS_UNIQUE[1];
|
|
2694
|
+
buffer[6] = PROCESS_UNIQUE[2];
|
|
2695
|
+
buffer[7] = PROCESS_UNIQUE[3];
|
|
2696
|
+
buffer[8] = PROCESS_UNIQUE[4];
|
|
2697
|
+
buffer[11] = inc & 0xff;
|
|
2698
|
+
buffer[10] = (inc >> 8) & 0xff;
|
|
2699
|
+
buffer[9] = (inc >> 16) & 0xff;
|
|
2700
|
+
return buffer;
|
|
2701
|
+
}
|
|
2702
|
+
toString(encoding) {
|
|
2703
|
+
if (encoding === 'base64')
|
|
2704
|
+
return ByteUtils.toBase64(this.id);
|
|
2705
|
+
if (encoding === 'hex')
|
|
2706
|
+
return this.toHexString();
|
|
2707
|
+
return this.toHexString();
|
|
2708
|
+
}
|
|
2709
|
+
toJSON() {
|
|
2710
|
+
return this.toHexString();
|
|
2711
|
+
}
|
|
2712
|
+
static is(variable) {
|
|
2713
|
+
return (variable != null &&
|
|
2714
|
+
typeof variable === 'object' &&
|
|
2715
|
+
'_bsontype' in variable &&
|
|
2716
|
+
variable._bsontype === 'ObjectId');
|
|
2717
|
+
}
|
|
2718
|
+
equals(otherId) {
|
|
2719
|
+
if (otherId === undefined || otherId === null) {
|
|
2720
|
+
return false;
|
|
2721
|
+
}
|
|
2722
|
+
if (ObjectId.is(otherId)) {
|
|
2723
|
+
return (this.buffer[11] === otherId.buffer[11] && ByteUtils.equals(this.buffer, otherId.buffer));
|
|
2724
|
+
}
|
|
2725
|
+
if (typeof otherId === 'string') {
|
|
2726
|
+
return otherId.toLowerCase() === this.toHexString();
|
|
2727
|
+
}
|
|
2728
|
+
if (typeof otherId === 'object' && typeof otherId.toHexString === 'function') {
|
|
2729
|
+
const otherIdString = otherId.toHexString();
|
|
2730
|
+
const thisIdString = this.toHexString();
|
|
2731
|
+
return typeof otherIdString === 'string' && otherIdString.toLowerCase() === thisIdString;
|
|
2732
|
+
}
|
|
2733
|
+
return false;
|
|
2734
|
+
}
|
|
2735
|
+
getTimestamp() {
|
|
2736
|
+
const timestamp = new Date();
|
|
2737
|
+
const time = NumberUtils.getUint32BE(this.buffer, 0);
|
|
2738
|
+
timestamp.setTime(Math.floor(time) * 1000);
|
|
2739
|
+
return timestamp;
|
|
2740
|
+
}
|
|
2741
|
+
static createPk() {
|
|
2742
|
+
return new ObjectId();
|
|
2743
|
+
}
|
|
2744
|
+
serializeInto(uint8array, index) {
|
|
2745
|
+
uint8array[index] = this.buffer[0];
|
|
2746
|
+
uint8array[index + 1] = this.buffer[1];
|
|
2747
|
+
uint8array[index + 2] = this.buffer[2];
|
|
2748
|
+
uint8array[index + 3] = this.buffer[3];
|
|
2749
|
+
uint8array[index + 4] = this.buffer[4];
|
|
2750
|
+
uint8array[index + 5] = this.buffer[5];
|
|
2751
|
+
uint8array[index + 6] = this.buffer[6];
|
|
2752
|
+
uint8array[index + 7] = this.buffer[7];
|
|
2753
|
+
uint8array[index + 8] = this.buffer[8];
|
|
2754
|
+
uint8array[index + 9] = this.buffer[9];
|
|
2755
|
+
uint8array[index + 10] = this.buffer[10];
|
|
2756
|
+
uint8array[index + 11] = this.buffer[11];
|
|
2757
|
+
return 12;
|
|
2758
|
+
}
|
|
2759
|
+
static createFromTime(time) {
|
|
2760
|
+
const buffer = ByteUtils.allocate(12);
|
|
2761
|
+
for (let i = 11; i >= 4; i--)
|
|
2762
|
+
buffer[i] = 0;
|
|
2763
|
+
NumberUtils.setInt32BE(buffer, 0, time);
|
|
2764
|
+
return new ObjectId(buffer);
|
|
2765
|
+
}
|
|
2766
|
+
static createFromHexString(hexString) {
|
|
2767
|
+
if (hexString?.length !== 24) {
|
|
2768
|
+
throw new BSONError('hex string must be 24 characters');
|
|
2769
|
+
}
|
|
2770
|
+
return new ObjectId(ByteUtils.fromHex(hexString));
|
|
2771
|
+
}
|
|
2772
|
+
static createFromBase64(base64) {
|
|
2773
|
+
if (base64?.length !== 16) {
|
|
2774
|
+
throw new BSONError('base64 string must be 16 characters');
|
|
2775
|
+
}
|
|
2776
|
+
return new ObjectId(ByteUtils.fromBase64(base64));
|
|
2777
|
+
}
|
|
2778
|
+
static isValid(id) {
|
|
2779
|
+
if (id == null)
|
|
2780
|
+
return false;
|
|
2781
|
+
if (typeof id === 'string')
|
|
2782
|
+
return ObjectId.validateHexString(id);
|
|
2783
|
+
try {
|
|
2784
|
+
new ObjectId(id);
|
|
2785
|
+
return true;
|
|
2786
|
+
}
|
|
2787
|
+
catch {
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
toExtendedJSON() {
|
|
2792
|
+
if (this.toHexString)
|
|
2793
|
+
return { $oid: this.toHexString() };
|
|
2794
|
+
return { $oid: this.toString('hex') };
|
|
2795
|
+
}
|
|
2796
|
+
static fromExtendedJSON(doc) {
|
|
2797
|
+
return new ObjectId(doc.$oid);
|
|
2798
|
+
}
|
|
2799
|
+
isCached() {
|
|
2800
|
+
return ObjectId.cacheHexString && __idCache.has(this);
|
|
2801
|
+
}
|
|
2802
|
+
inspect(depth, options, inspect) {
|
|
2803
|
+
inspect ??= defaultInspect;
|
|
2804
|
+
return `new ObjectId(${inspect(this.toHexString(), options)})`;
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
function internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined) {
|
|
2809
|
+
let totalLength = 4 + 1;
|
|
2810
|
+
if (Array.isArray(object)) {
|
|
2811
|
+
for (let i = 0; i < object.length; i++) {
|
|
2812
|
+
totalLength += calculateElement(i.toString(), object[i], serializeFunctions, true, ignoreUndefined);
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
else {
|
|
2816
|
+
if (typeof object?.toBSON === 'function') {
|
|
2817
|
+
object = object.toBSON();
|
|
2818
|
+
}
|
|
2819
|
+
for (const key of Object.keys(object)) {
|
|
2820
|
+
totalLength += calculateElement(key, object[key], serializeFunctions, false, ignoreUndefined);
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
return totalLength;
|
|
2824
|
+
}
|
|
2825
|
+
function calculateElement(name, value, serializeFunctions = false, isArray = false, ignoreUndefined = false) {
|
|
2826
|
+
if (typeof value?.toBSON === 'function') {
|
|
2827
|
+
value = value.toBSON();
|
|
2828
|
+
}
|
|
2829
|
+
switch (typeof value) {
|
|
2830
|
+
case 'string':
|
|
2831
|
+
return 1 + ByteUtils.utf8ByteLength(name) + 1 + 4 + ByteUtils.utf8ByteLength(value) + 1;
|
|
2832
|
+
case 'number':
|
|
2833
|
+
if (Math.floor(value) === value &&
|
|
2834
|
+
value >= JS_INT_MIN &&
|
|
2835
|
+
value <= JS_INT_MAX) {
|
|
2836
|
+
if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
|
|
2837
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (4 + 1);
|
|
2838
|
+
}
|
|
2839
|
+
else {
|
|
2840
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
else {
|
|
2844
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2845
|
+
}
|
|
2846
|
+
case 'undefined':
|
|
2847
|
+
if (isArray || !ignoreUndefined)
|
|
2848
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1;
|
|
2849
|
+
return 0;
|
|
2850
|
+
case 'boolean':
|
|
2851
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 1);
|
|
2852
|
+
case 'object':
|
|
2853
|
+
if (value != null &&
|
|
2854
|
+
typeof value._bsontype === 'string' &&
|
|
2855
|
+
value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
2856
|
+
throw new BSONVersionError();
|
|
2857
|
+
}
|
|
2858
|
+
else if (value == null || value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
2859
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + 1;
|
|
2860
|
+
}
|
|
2861
|
+
else if (value._bsontype === 'ObjectId') {
|
|
2862
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (12 + 1);
|
|
2863
|
+
}
|
|
2864
|
+
else if (value instanceof Date || isDate(value)) {
|
|
2865
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2866
|
+
}
|
|
2867
|
+
else if (ArrayBuffer.isView(value) ||
|
|
2868
|
+
value instanceof ArrayBuffer ||
|
|
2869
|
+
isAnyArrayBuffer(value)) {
|
|
2870
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (1 + 4 + 1) + value.byteLength);
|
|
2871
|
+
}
|
|
2872
|
+
else if (value._bsontype === 'Long' ||
|
|
2873
|
+
value._bsontype === 'Double' ||
|
|
2874
|
+
value._bsontype === 'Timestamp') {
|
|
2875
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2876
|
+
}
|
|
2877
|
+
else if (value._bsontype === 'Decimal128') {
|
|
2878
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (16 + 1);
|
|
2879
|
+
}
|
|
2880
|
+
else if (value._bsontype === 'Code') {
|
|
2881
|
+
if (value.scope != null && Object.keys(value.scope).length > 0) {
|
|
2882
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2883
|
+
1 +
|
|
2884
|
+
4 +
|
|
2885
|
+
4 +
|
|
2886
|
+
ByteUtils.utf8ByteLength(value.code.toString()) +
|
|
2887
|
+
1 +
|
|
2888
|
+
internalCalculateObjectSize(value.scope, serializeFunctions, ignoreUndefined));
|
|
2889
|
+
}
|
|
2890
|
+
else {
|
|
2891
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2892
|
+
1 +
|
|
2893
|
+
4 +
|
|
2894
|
+
ByteUtils.utf8ByteLength(value.code.toString()) +
|
|
2895
|
+
1);
|
|
2896
|
+
}
|
|
2897
|
+
}
|
|
2898
|
+
else if (value._bsontype === 'Binary') {
|
|
2899
|
+
const binary = value;
|
|
2900
|
+
if (binary.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
|
|
2901
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2902
|
+
(binary.position + 1 + 4 + 1 + 4));
|
|
2903
|
+
}
|
|
2904
|
+
else {
|
|
2905
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (binary.position + 1 + 4 + 1));
|
|
2906
|
+
}
|
|
2907
|
+
}
|
|
2908
|
+
else if (value._bsontype === 'Symbol') {
|
|
2909
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2910
|
+
ByteUtils.utf8ByteLength(value.value) +
|
|
2911
|
+
4 +
|
|
2912
|
+
1 +
|
|
2913
|
+
1);
|
|
2914
|
+
}
|
|
2915
|
+
else if (value._bsontype === 'DBRef') {
|
|
2916
|
+
const ordered_values = Object.assign({
|
|
2917
|
+
$ref: value.collection,
|
|
2918
|
+
$id: value.oid
|
|
2919
|
+
}, value.fields);
|
|
2920
|
+
if (value.db != null) {
|
|
2921
|
+
ordered_values['$db'] = value.db;
|
|
2922
|
+
}
|
|
2923
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2924
|
+
1 +
|
|
2925
|
+
internalCalculateObjectSize(ordered_values, serializeFunctions, ignoreUndefined));
|
|
2926
|
+
}
|
|
2927
|
+
else if (value instanceof RegExp || isRegExp(value)) {
|
|
2928
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2929
|
+
1 +
|
|
2930
|
+
ByteUtils.utf8ByteLength(value.source) +
|
|
2931
|
+
1 +
|
|
2932
|
+
(value.global ? 1 : 0) +
|
|
2933
|
+
(value.ignoreCase ? 1 : 0) +
|
|
2934
|
+
(value.multiline ? 1 : 0) +
|
|
2935
|
+
1);
|
|
2936
|
+
}
|
|
2937
|
+
else if (value._bsontype === 'BSONRegExp') {
|
|
2938
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2939
|
+
1 +
|
|
2940
|
+
ByteUtils.utf8ByteLength(value.pattern) +
|
|
2941
|
+
1 +
|
|
2942
|
+
ByteUtils.utf8ByteLength(value.options) +
|
|
2943
|
+
1);
|
|
2944
|
+
}
|
|
2945
|
+
else {
|
|
2946
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2947
|
+
internalCalculateObjectSize(value, serializeFunctions, ignoreUndefined) +
|
|
2948
|
+
1);
|
|
2949
|
+
}
|
|
2950
|
+
case 'function':
|
|
2951
|
+
if (serializeFunctions) {
|
|
2952
|
+
return ((name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) +
|
|
2953
|
+
1 +
|
|
2954
|
+
4 +
|
|
2955
|
+
ByteUtils.utf8ByteLength(value.toString()) +
|
|
2956
|
+
1);
|
|
2957
|
+
}
|
|
2958
|
+
return 0;
|
|
2959
|
+
case 'bigint':
|
|
2960
|
+
return (name != null ? ByteUtils.utf8ByteLength(name) + 1 : 0) + (8 + 1);
|
|
2961
|
+
case 'symbol':
|
|
2962
|
+
return 0;
|
|
2963
|
+
default:
|
|
2964
|
+
throw new BSONError(`Unrecognized JS type: ${typeof value}`);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
|
|
2968
|
+
function alphabetize(str) {
|
|
2969
|
+
return str.split('').sort().join('');
|
|
2970
|
+
}
|
|
2971
|
+
class BSONRegExp extends BSONValue {
|
|
2972
|
+
get _bsontype() {
|
|
2973
|
+
return 'BSONRegExp';
|
|
2974
|
+
}
|
|
2975
|
+
pattern;
|
|
2976
|
+
options;
|
|
2977
|
+
constructor(pattern, options) {
|
|
2978
|
+
super();
|
|
2979
|
+
this.pattern = pattern;
|
|
2980
|
+
this.options = alphabetize(options ?? '');
|
|
2981
|
+
if (this.pattern.indexOf('\x00') !== -1) {
|
|
2982
|
+
throw new BSONError(`BSON Regex patterns cannot contain null bytes, found: ${JSON.stringify(this.pattern)}`);
|
|
2983
|
+
}
|
|
2984
|
+
if (this.options.indexOf('\x00') !== -1) {
|
|
2985
|
+
throw new BSONError(`BSON Regex options cannot contain null bytes, found: ${JSON.stringify(this.options)}`);
|
|
2986
|
+
}
|
|
2987
|
+
for (let i = 0; i < this.options.length; i++) {
|
|
2988
|
+
if (!(this.options[i] === 'i' ||
|
|
2989
|
+
this.options[i] === 'm' ||
|
|
2990
|
+
this.options[i] === 'x' ||
|
|
2991
|
+
this.options[i] === 'l' ||
|
|
2992
|
+
this.options[i] === 's' ||
|
|
2993
|
+
this.options[i] === 'u')) {
|
|
2994
|
+
throw new BSONError(`The regular expression option [${this.options[i]}] is not supported`);
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
static parseOptions(options) {
|
|
2999
|
+
return options ? options.split('').sort().join('') : '';
|
|
3000
|
+
}
|
|
3001
|
+
toExtendedJSON(options) {
|
|
3002
|
+
options = options || {};
|
|
3003
|
+
if (options.legacy) {
|
|
3004
|
+
return { $regex: this.pattern, $options: this.options };
|
|
3005
|
+
}
|
|
3006
|
+
return { $regularExpression: { pattern: this.pattern, options: this.options } };
|
|
3007
|
+
}
|
|
3008
|
+
static fromExtendedJSON(doc) {
|
|
3009
|
+
if ('$regex' in doc) {
|
|
3010
|
+
if (typeof doc.$regex !== 'string') {
|
|
3011
|
+
if (doc.$regex._bsontype === 'BSONRegExp') {
|
|
3012
|
+
return doc;
|
|
3013
|
+
}
|
|
3014
|
+
}
|
|
3015
|
+
else {
|
|
3016
|
+
return new BSONRegExp(doc.$regex, BSONRegExp.parseOptions(doc.$options));
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
if ('$regularExpression' in doc) {
|
|
3020
|
+
return new BSONRegExp(doc.$regularExpression.pattern, BSONRegExp.parseOptions(doc.$regularExpression.options));
|
|
3021
|
+
}
|
|
3022
|
+
throw new BSONError(`Unexpected BSONRegExp EJSON object form: ${JSON.stringify(doc)}`);
|
|
3023
|
+
}
|
|
3024
|
+
inspect(depth, options, inspect) {
|
|
3025
|
+
const stylize = getStylizeFunction(options) ?? (v => v);
|
|
3026
|
+
inspect ??= defaultInspect;
|
|
3027
|
+
const pattern = stylize(inspect(this.pattern), 'regexp');
|
|
3028
|
+
const flags = stylize(inspect(this.options), 'regexp');
|
|
3029
|
+
return `new BSONRegExp(${pattern}, ${flags})`;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
class BSONSymbol extends BSONValue {
|
|
3034
|
+
get _bsontype() {
|
|
3035
|
+
return 'BSONSymbol';
|
|
3036
|
+
}
|
|
3037
|
+
value;
|
|
3038
|
+
constructor(value) {
|
|
3039
|
+
super();
|
|
3040
|
+
this.value = value;
|
|
3041
|
+
}
|
|
3042
|
+
valueOf() {
|
|
3043
|
+
return this.value;
|
|
3044
|
+
}
|
|
3045
|
+
toString() {
|
|
3046
|
+
return this.value;
|
|
3047
|
+
}
|
|
3048
|
+
toJSON() {
|
|
3049
|
+
return this.value;
|
|
3050
|
+
}
|
|
3051
|
+
toExtendedJSON() {
|
|
3052
|
+
return { $symbol: this.value };
|
|
3053
|
+
}
|
|
3054
|
+
static fromExtendedJSON(doc) {
|
|
3055
|
+
return new BSONSymbol(doc.$symbol);
|
|
3056
|
+
}
|
|
3057
|
+
inspect(depth, options, inspect) {
|
|
3058
|
+
inspect ??= defaultInspect;
|
|
3059
|
+
return `new BSONSymbol(${inspect(this.value, options)})`;
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
|
|
3063
|
+
const LongWithoutOverridesClass = Long;
|
|
3064
|
+
class Timestamp extends LongWithoutOverridesClass {
|
|
3065
|
+
get _bsontype() {
|
|
3066
|
+
return 'Timestamp';
|
|
3067
|
+
}
|
|
3068
|
+
get [bsonType]() {
|
|
3069
|
+
return 'Timestamp';
|
|
3070
|
+
}
|
|
3071
|
+
static MAX_VALUE = Long.MAX_UNSIGNED_VALUE;
|
|
3072
|
+
get i() {
|
|
3073
|
+
return this.low >>> 0;
|
|
3074
|
+
}
|
|
3075
|
+
get t() {
|
|
3076
|
+
return this.high >>> 0;
|
|
3077
|
+
}
|
|
3078
|
+
constructor(low) {
|
|
3079
|
+
if (low == null) {
|
|
3080
|
+
super(0, 0, true);
|
|
3081
|
+
}
|
|
3082
|
+
else if (typeof low === 'bigint') {
|
|
3083
|
+
super(low, true);
|
|
3084
|
+
}
|
|
3085
|
+
else if (Long.isLong(low)) {
|
|
3086
|
+
super(low.low, low.high, true);
|
|
3087
|
+
}
|
|
3088
|
+
else if (typeof low === 'object' && 't' in low && 'i' in low) {
|
|
3089
|
+
if (typeof low.t !== 'number' && (typeof low.t !== 'object' || low.t._bsontype !== 'Int32')) {
|
|
3090
|
+
throw new BSONError('Timestamp constructed from { t, i } must provide t as a number');
|
|
3091
|
+
}
|
|
3092
|
+
if (typeof low.i !== 'number' && (typeof low.i !== 'object' || low.i._bsontype !== 'Int32')) {
|
|
3093
|
+
throw new BSONError('Timestamp constructed from { t, i } must provide i as a number');
|
|
3094
|
+
}
|
|
3095
|
+
const t = Number(low.t);
|
|
3096
|
+
const i = Number(low.i);
|
|
3097
|
+
if (t < 0 || Number.isNaN(t)) {
|
|
3098
|
+
throw new BSONError('Timestamp constructed from { t, i } must provide a positive t');
|
|
3099
|
+
}
|
|
3100
|
+
if (i < 0 || Number.isNaN(i)) {
|
|
3101
|
+
throw new BSONError('Timestamp constructed from { t, i } must provide a positive i');
|
|
3102
|
+
}
|
|
3103
|
+
if (t > 0xffff_ffff) {
|
|
3104
|
+
throw new BSONError('Timestamp constructed from { t, i } must provide t equal or less than uint32 max');
|
|
3105
|
+
}
|
|
3106
|
+
if (i > 0xffff_ffff) {
|
|
3107
|
+
throw new BSONError('Timestamp constructed from { t, i } must provide i equal or less than uint32 max');
|
|
3108
|
+
}
|
|
3109
|
+
super(i, t, true);
|
|
3110
|
+
}
|
|
3111
|
+
else {
|
|
3112
|
+
throw new BSONError('A Timestamp can only be constructed with: bigint, Long, or { t: number; i: number }');
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
toJSON() {
|
|
3116
|
+
return {
|
|
3117
|
+
$timestamp: this.toString()
|
|
3118
|
+
};
|
|
3119
|
+
}
|
|
3120
|
+
static fromInt(value) {
|
|
3121
|
+
return new Timestamp(Long.fromInt(value, true));
|
|
3122
|
+
}
|
|
3123
|
+
static fromNumber(value) {
|
|
3124
|
+
return new Timestamp(Long.fromNumber(value, true));
|
|
3125
|
+
}
|
|
3126
|
+
static fromBits(lowBits, highBits) {
|
|
3127
|
+
return new Timestamp({ i: lowBits, t: highBits });
|
|
3128
|
+
}
|
|
3129
|
+
static fromString(str, optRadix) {
|
|
3130
|
+
return new Timestamp(Long.fromString(str, true, optRadix));
|
|
3131
|
+
}
|
|
3132
|
+
toExtendedJSON() {
|
|
3133
|
+
return { $timestamp: { t: this.t, i: this.i } };
|
|
3134
|
+
}
|
|
3135
|
+
static fromExtendedJSON(doc) {
|
|
3136
|
+
const i = Long.isLong(doc.$timestamp.i)
|
|
3137
|
+
? doc.$timestamp.i.getLowBitsUnsigned()
|
|
3138
|
+
: doc.$timestamp.i;
|
|
3139
|
+
const t = Long.isLong(doc.$timestamp.t)
|
|
3140
|
+
? doc.$timestamp.t.getLowBitsUnsigned()
|
|
3141
|
+
: doc.$timestamp.t;
|
|
3142
|
+
return new Timestamp({ t, i });
|
|
3143
|
+
}
|
|
3144
|
+
inspect(depth, options, inspect) {
|
|
3145
|
+
inspect ??= defaultInspect;
|
|
3146
|
+
const t = inspect(this.t, options);
|
|
3147
|
+
const i = inspect(this.i, options);
|
|
3148
|
+
return `new Timestamp({ t: ${t}, i: ${i} })`;
|
|
3149
|
+
}
|
|
3150
|
+
}
|
|
3151
|
+
|
|
3152
|
+
const JS_INT_MAX_LONG = Long.fromNumber(JS_INT_MAX);
|
|
3153
|
+
const JS_INT_MIN_LONG = Long.fromNumber(JS_INT_MIN);
|
|
3154
|
+
function internalDeserialize(buffer, options, isArray) {
|
|
3155
|
+
options = options == null ? {} : options;
|
|
3156
|
+
const index = options && options.index ? options.index : 0;
|
|
3157
|
+
const size = NumberUtils.getInt32LE(buffer, index);
|
|
3158
|
+
if (size < 5) {
|
|
3159
|
+
throw new BSONError(`bson size must be >= 5, is ${size}`);
|
|
3160
|
+
}
|
|
3161
|
+
if (options.allowObjectSmallerThanBufferSize && buffer.length < size) {
|
|
3162
|
+
throw new BSONError(`buffer length ${buffer.length} must be >= bson size ${size}`);
|
|
3163
|
+
}
|
|
3164
|
+
if (!options.allowObjectSmallerThanBufferSize && buffer.length !== size) {
|
|
3165
|
+
throw new BSONError(`buffer length ${buffer.length} must === bson size ${size}`);
|
|
3166
|
+
}
|
|
3167
|
+
if (size + index > buffer.byteLength) {
|
|
3168
|
+
throw new BSONError(`(bson size ${size} + options.index ${index} must be <= buffer length ${buffer.byteLength})`);
|
|
3169
|
+
}
|
|
3170
|
+
if (buffer[index + size - 1] !== 0) {
|
|
3171
|
+
throw new BSONError("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");
|
|
3172
|
+
}
|
|
3173
|
+
return deserializeObject(buffer, index, options, isArray);
|
|
3174
|
+
}
|
|
3175
|
+
const allowedDBRefKeys = /^\$ref$|^\$id$|^\$db$/;
|
|
3176
|
+
function deserializeObject(buffer, index, options, isArray = false) {
|
|
3177
|
+
const fieldsAsRaw = options['fieldsAsRaw'] == null ? null : options['fieldsAsRaw'];
|
|
3178
|
+
const raw = options['raw'] == null ? false : options['raw'];
|
|
3179
|
+
const bsonRegExp = typeof options['bsonRegExp'] === 'boolean' ? options['bsonRegExp'] : false;
|
|
3180
|
+
const promoteBuffers = options.promoteBuffers ?? false;
|
|
3181
|
+
const promoteLongs = options.promoteLongs ?? true;
|
|
3182
|
+
const promoteValues = options.promoteValues ?? true;
|
|
3183
|
+
const useBigInt64 = options.useBigInt64 ?? false;
|
|
3184
|
+
if (useBigInt64 && !promoteValues) {
|
|
3185
|
+
throw new BSONError('Must either request bigint or Long for int64 deserialization');
|
|
3186
|
+
}
|
|
3187
|
+
if (useBigInt64 && !promoteLongs) {
|
|
3188
|
+
throw new BSONError('Must either request bigint or Long for int64 deserialization');
|
|
3189
|
+
}
|
|
3190
|
+
const validation = options.validation == null ? { utf8: true } : options.validation;
|
|
3191
|
+
let globalUTFValidation = true;
|
|
3192
|
+
let validationSetting;
|
|
3193
|
+
let utf8KeysSet;
|
|
3194
|
+
const utf8ValidatedKeys = validation.utf8;
|
|
3195
|
+
if (typeof utf8ValidatedKeys === 'boolean') {
|
|
3196
|
+
validationSetting = utf8ValidatedKeys;
|
|
3197
|
+
}
|
|
3198
|
+
else {
|
|
3199
|
+
globalUTFValidation = false;
|
|
3200
|
+
const utf8ValidationValues = Object.keys(utf8ValidatedKeys).map(function (key) {
|
|
3201
|
+
return utf8ValidatedKeys[key];
|
|
3202
|
+
});
|
|
3203
|
+
if (utf8ValidationValues.length === 0) {
|
|
3204
|
+
throw new BSONError('UTF-8 validation setting cannot be empty');
|
|
3205
|
+
}
|
|
3206
|
+
if (typeof utf8ValidationValues[0] !== 'boolean') {
|
|
3207
|
+
throw new BSONError('Invalid UTF-8 validation option, must specify boolean values');
|
|
3208
|
+
}
|
|
3209
|
+
validationSetting = utf8ValidationValues[0];
|
|
3210
|
+
if (!utf8ValidationValues.every(item => item === validationSetting)) {
|
|
3211
|
+
throw new BSONError('Invalid UTF-8 validation option - keys must be all true or all false');
|
|
3212
|
+
}
|
|
3213
|
+
}
|
|
3214
|
+
if (!globalUTFValidation) {
|
|
3215
|
+
utf8KeysSet = new Set();
|
|
3216
|
+
for (const key of Object.keys(utf8ValidatedKeys)) {
|
|
3217
|
+
utf8KeysSet.add(key);
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
const startIndex = index;
|
|
3221
|
+
if (buffer.length < 5)
|
|
3222
|
+
throw new BSONError('corrupt bson message < 5 bytes long');
|
|
3223
|
+
const size = NumberUtils.getInt32LE(buffer, index);
|
|
3224
|
+
index += 4;
|
|
3225
|
+
if (size < 5 || size > buffer.length)
|
|
3226
|
+
throw new BSONError('corrupt bson message');
|
|
3227
|
+
const object = isArray ? [] : {};
|
|
3228
|
+
let arrayIndex = 0;
|
|
3229
|
+
let isPossibleDBRef = isArray ? false : null;
|
|
3230
|
+
while (true) {
|
|
3231
|
+
const elementType = buffer[index++];
|
|
3232
|
+
if (elementType === 0)
|
|
3233
|
+
break;
|
|
3234
|
+
let i = index;
|
|
3235
|
+
while (buffer[i] !== 0x00 && i < buffer.length) {
|
|
3236
|
+
i++;
|
|
3237
|
+
}
|
|
3238
|
+
if (i >= buffer.byteLength)
|
|
3239
|
+
throw new BSONError('Bad BSON Document: illegal CString');
|
|
3240
|
+
const name = isArray ? arrayIndex++ : ByteUtils.toUTF8(buffer, index, i, false);
|
|
3241
|
+
let shouldValidateKey = true;
|
|
3242
|
+
if (globalUTFValidation || utf8KeysSet?.has(name)) {
|
|
3243
|
+
shouldValidateKey = validationSetting;
|
|
3244
|
+
}
|
|
3245
|
+
else {
|
|
3246
|
+
shouldValidateKey = !validationSetting;
|
|
3247
|
+
}
|
|
3248
|
+
if (isPossibleDBRef !== false && name[0] === '$') {
|
|
3249
|
+
isPossibleDBRef = allowedDBRefKeys.test(name);
|
|
3250
|
+
}
|
|
3251
|
+
let value;
|
|
3252
|
+
index = i + 1;
|
|
3253
|
+
if (elementType === BSON_DATA_STRING) {
|
|
3254
|
+
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
3255
|
+
index += 4;
|
|
3256
|
+
if (stringSize <= 0 ||
|
|
3257
|
+
stringSize > buffer.length - index ||
|
|
3258
|
+
buffer[index + stringSize - 1] !== 0) {
|
|
3259
|
+
throw new BSONError('bad string length in bson');
|
|
3260
|
+
}
|
|
3261
|
+
value = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
|
|
3262
|
+
index = index + stringSize;
|
|
3263
|
+
}
|
|
3264
|
+
else if (elementType === BSON_DATA_OID) {
|
|
3265
|
+
const oid = ByteUtils.allocateUnsafe(12);
|
|
3266
|
+
for (let i = 0; i < 12; i++)
|
|
3267
|
+
oid[i] = buffer[index + i];
|
|
3268
|
+
value = new ObjectId(oid);
|
|
3269
|
+
index = index + 12;
|
|
3270
|
+
}
|
|
3271
|
+
else if (elementType === BSON_DATA_INT && promoteValues === false) {
|
|
3272
|
+
value = new Int32(NumberUtils.getInt32LE(buffer, index));
|
|
3273
|
+
index += 4;
|
|
3274
|
+
}
|
|
3275
|
+
else if (elementType === BSON_DATA_INT) {
|
|
3276
|
+
value = NumberUtils.getInt32LE(buffer, index);
|
|
3277
|
+
index += 4;
|
|
3278
|
+
}
|
|
3279
|
+
else if (elementType === BSON_DATA_NUMBER) {
|
|
3280
|
+
value = NumberUtils.getFloat64LE(buffer, index);
|
|
3281
|
+
index += 8;
|
|
3282
|
+
if (promoteValues === false)
|
|
3283
|
+
value = new Double(value);
|
|
3284
|
+
}
|
|
3285
|
+
else if (elementType === BSON_DATA_DATE) {
|
|
3286
|
+
const lowBits = NumberUtils.getInt32LE(buffer, index);
|
|
3287
|
+
const highBits = NumberUtils.getInt32LE(buffer, index + 4);
|
|
3288
|
+
index += 8;
|
|
3289
|
+
value = new Date(new Long(lowBits, highBits).toNumber());
|
|
3290
|
+
}
|
|
3291
|
+
else if (elementType === BSON_DATA_BOOLEAN) {
|
|
3292
|
+
if (buffer[index] !== 0 && buffer[index] !== 1)
|
|
3293
|
+
throw new BSONError('illegal boolean type value');
|
|
3294
|
+
value = buffer[index++] === 1;
|
|
3295
|
+
}
|
|
3296
|
+
else if (elementType === BSON_DATA_OBJECT) {
|
|
3297
|
+
const _index = index;
|
|
3298
|
+
const objectSize = NumberUtils.getInt32LE(buffer, index);
|
|
3299
|
+
if (objectSize <= 0 || objectSize > buffer.length - index)
|
|
3300
|
+
throw new BSONError('bad embedded document length in bson');
|
|
3301
|
+
if (raw) {
|
|
3302
|
+
value = buffer.subarray(index, index + objectSize);
|
|
3303
|
+
}
|
|
3304
|
+
else {
|
|
3305
|
+
let objectOptions = options;
|
|
3306
|
+
if (!globalUTFValidation) {
|
|
3307
|
+
objectOptions = { ...options, validation: { utf8: shouldValidateKey } };
|
|
3308
|
+
}
|
|
3309
|
+
value = deserializeObject(buffer, _index, objectOptions, false);
|
|
3310
|
+
}
|
|
3311
|
+
index = index + objectSize;
|
|
3312
|
+
}
|
|
3313
|
+
else if (elementType === BSON_DATA_ARRAY) {
|
|
3314
|
+
const _index = index;
|
|
3315
|
+
const objectSize = NumberUtils.getInt32LE(buffer, index);
|
|
3316
|
+
let arrayOptions = options;
|
|
3317
|
+
const stopIndex = index + objectSize;
|
|
3318
|
+
if (fieldsAsRaw && fieldsAsRaw[name]) {
|
|
3319
|
+
arrayOptions = { ...options, raw: true };
|
|
3320
|
+
}
|
|
3321
|
+
if (!globalUTFValidation) {
|
|
3322
|
+
arrayOptions = { ...arrayOptions, validation: { utf8: shouldValidateKey } };
|
|
3323
|
+
}
|
|
3324
|
+
value = deserializeObject(buffer, _index, arrayOptions, true);
|
|
3325
|
+
index = index + objectSize;
|
|
3326
|
+
if (buffer[index - 1] !== 0)
|
|
3327
|
+
throw new BSONError('invalid array terminator byte');
|
|
3328
|
+
if (index !== stopIndex)
|
|
3329
|
+
throw new BSONError('corrupted array bson');
|
|
3330
|
+
}
|
|
3331
|
+
else if (elementType === BSON_DATA_UNDEFINED) {
|
|
3332
|
+
value = undefined;
|
|
3333
|
+
}
|
|
3334
|
+
else if (elementType === BSON_DATA_NULL) {
|
|
3335
|
+
value = null;
|
|
3336
|
+
}
|
|
3337
|
+
else if (elementType === BSON_DATA_LONG) {
|
|
3338
|
+
if (useBigInt64) {
|
|
3339
|
+
value = NumberUtils.getBigInt64LE(buffer, index);
|
|
3340
|
+
index += 8;
|
|
3341
|
+
}
|
|
3342
|
+
else {
|
|
3343
|
+
const lowBits = NumberUtils.getInt32LE(buffer, index);
|
|
3344
|
+
const highBits = NumberUtils.getInt32LE(buffer, index + 4);
|
|
3345
|
+
index += 8;
|
|
3346
|
+
const long = new Long(lowBits, highBits);
|
|
3347
|
+
if (promoteLongs && promoteValues === true) {
|
|
3348
|
+
value =
|
|
3349
|
+
long.lessThanOrEqual(JS_INT_MAX_LONG) && long.greaterThanOrEqual(JS_INT_MIN_LONG)
|
|
3350
|
+
? long.toNumber()
|
|
3351
|
+
: long;
|
|
3352
|
+
}
|
|
3353
|
+
else {
|
|
3354
|
+
value = long;
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
else if (elementType === BSON_DATA_DECIMAL128) {
|
|
3359
|
+
const bytes = ByteUtils.allocateUnsafe(16);
|
|
3360
|
+
for (let i = 0; i < 16; i++)
|
|
3361
|
+
bytes[i] = buffer[index + i];
|
|
3362
|
+
index = index + 16;
|
|
3363
|
+
value = new Decimal128(bytes);
|
|
3364
|
+
}
|
|
3365
|
+
else if (elementType === BSON_DATA_BINARY) {
|
|
3366
|
+
let binarySize = NumberUtils.getInt32LE(buffer, index);
|
|
3367
|
+
index += 4;
|
|
3368
|
+
const totalBinarySize = binarySize;
|
|
3369
|
+
const subType = buffer[index++];
|
|
3370
|
+
if (binarySize < 0)
|
|
3371
|
+
throw new BSONError('Negative binary type element size found');
|
|
3372
|
+
if (binarySize > buffer.byteLength)
|
|
3373
|
+
throw new BSONError('Binary type size larger than document size');
|
|
3374
|
+
if (subType === Binary.SUBTYPE_BYTE_ARRAY) {
|
|
3375
|
+
binarySize = NumberUtils.getInt32LE(buffer, index);
|
|
3376
|
+
index += 4;
|
|
3377
|
+
if (binarySize < 0)
|
|
3378
|
+
throw new BSONError('Negative binary type element size found for subtype 0x02');
|
|
3379
|
+
if (binarySize > totalBinarySize - 4)
|
|
3380
|
+
throw new BSONError('Binary type with subtype 0x02 contains too long binary size');
|
|
3381
|
+
if (binarySize < totalBinarySize - 4)
|
|
3382
|
+
throw new BSONError('Binary type with subtype 0x02 contains too short binary size');
|
|
3383
|
+
}
|
|
3384
|
+
if (promoteBuffers && promoteValues) {
|
|
3385
|
+
value = ByteUtils.toLocalBufferType(buffer.subarray(index, index + binarySize));
|
|
3386
|
+
}
|
|
3387
|
+
else {
|
|
3388
|
+
value = new Binary(buffer.subarray(index, index + binarySize), subType);
|
|
3389
|
+
if (subType === BSON_BINARY_SUBTYPE_UUID_NEW && UUID.isValid(value)) {
|
|
3390
|
+
value = value.toUUID();
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
index = index + binarySize;
|
|
3394
|
+
}
|
|
3395
|
+
else if (elementType === BSON_DATA_REGEXP && bsonRegExp === false) {
|
|
3396
|
+
i = index;
|
|
3397
|
+
while (buffer[i] !== 0x00 && i < buffer.length) {
|
|
3398
|
+
i++;
|
|
3399
|
+
}
|
|
3400
|
+
if (i >= buffer.length)
|
|
3401
|
+
throw new BSONError('Bad BSON Document: illegal CString');
|
|
3402
|
+
const source = ByteUtils.toUTF8(buffer, index, i, false);
|
|
3403
|
+
index = i + 1;
|
|
3404
|
+
i = index;
|
|
3405
|
+
while (buffer[i] !== 0x00 && i < buffer.length) {
|
|
3406
|
+
i++;
|
|
3407
|
+
}
|
|
3408
|
+
if (i >= buffer.length)
|
|
3409
|
+
throw new BSONError('Bad BSON Document: illegal CString');
|
|
3410
|
+
const regExpOptions = ByteUtils.toUTF8(buffer, index, i, false);
|
|
3411
|
+
index = i + 1;
|
|
3412
|
+
const optionsArray = new Array(regExpOptions.length);
|
|
3413
|
+
for (i = 0; i < regExpOptions.length; i++) {
|
|
3414
|
+
switch (regExpOptions[i]) {
|
|
3415
|
+
case 'm':
|
|
3416
|
+
optionsArray[i] = 'm';
|
|
3417
|
+
break;
|
|
3418
|
+
case 's':
|
|
3419
|
+
optionsArray[i] = 'g';
|
|
3420
|
+
break;
|
|
3421
|
+
case 'i':
|
|
3422
|
+
optionsArray[i] = 'i';
|
|
3423
|
+
break;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
value = new RegExp(source, optionsArray.join(''));
|
|
3427
|
+
}
|
|
3428
|
+
else if (elementType === BSON_DATA_REGEXP && bsonRegExp === true) {
|
|
3429
|
+
i = index;
|
|
3430
|
+
while (buffer[i] !== 0x00 && i < buffer.length) {
|
|
3431
|
+
i++;
|
|
3432
|
+
}
|
|
3433
|
+
if (i >= buffer.length)
|
|
3434
|
+
throw new BSONError('Bad BSON Document: illegal CString');
|
|
3435
|
+
const source = ByteUtils.toUTF8(buffer, index, i, false);
|
|
3436
|
+
index = i + 1;
|
|
3437
|
+
i = index;
|
|
3438
|
+
while (buffer[i] !== 0x00 && i < buffer.length) {
|
|
3439
|
+
i++;
|
|
3440
|
+
}
|
|
3441
|
+
if (i >= buffer.length)
|
|
3442
|
+
throw new BSONError('Bad BSON Document: illegal CString');
|
|
3443
|
+
const regExpOptions = ByteUtils.toUTF8(buffer, index, i, false);
|
|
3444
|
+
index = i + 1;
|
|
3445
|
+
value = new BSONRegExp(source, regExpOptions);
|
|
3446
|
+
}
|
|
3447
|
+
else if (elementType === BSON_DATA_SYMBOL) {
|
|
3448
|
+
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
3449
|
+
index += 4;
|
|
3450
|
+
if (stringSize <= 0 ||
|
|
3451
|
+
stringSize > buffer.length - index ||
|
|
3452
|
+
buffer[index + stringSize - 1] !== 0) {
|
|
3453
|
+
throw new BSONError('bad string length in bson');
|
|
3454
|
+
}
|
|
3455
|
+
const symbol = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
|
|
3456
|
+
value = promoteValues ? symbol : new BSONSymbol(symbol);
|
|
3457
|
+
index = index + stringSize;
|
|
3458
|
+
}
|
|
3459
|
+
else if (elementType === BSON_DATA_TIMESTAMP) {
|
|
3460
|
+
value = new Timestamp({
|
|
3461
|
+
i: NumberUtils.getUint32LE(buffer, index),
|
|
3462
|
+
t: NumberUtils.getUint32LE(buffer, index + 4)
|
|
3463
|
+
});
|
|
3464
|
+
index += 8;
|
|
3465
|
+
}
|
|
3466
|
+
else if (elementType === BSON_DATA_MIN_KEY) {
|
|
3467
|
+
value = new MinKey();
|
|
3468
|
+
}
|
|
3469
|
+
else if (elementType === BSON_DATA_MAX_KEY) {
|
|
3470
|
+
value = new MaxKey();
|
|
3471
|
+
}
|
|
3472
|
+
else if (elementType === BSON_DATA_CODE) {
|
|
3473
|
+
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
3474
|
+
index += 4;
|
|
3475
|
+
if (stringSize <= 0 ||
|
|
3476
|
+
stringSize > buffer.length - index ||
|
|
3477
|
+
buffer[index + stringSize - 1] !== 0) {
|
|
3478
|
+
throw new BSONError('bad string length in bson');
|
|
3479
|
+
}
|
|
3480
|
+
const functionString = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
|
|
3481
|
+
value = new Code(functionString);
|
|
3482
|
+
index = index + stringSize;
|
|
3483
|
+
}
|
|
3484
|
+
else if (elementType === BSON_DATA_CODE_W_SCOPE) {
|
|
3485
|
+
const totalSize = NumberUtils.getInt32LE(buffer, index);
|
|
3486
|
+
index += 4;
|
|
3487
|
+
if (totalSize < 4 + 4 + 4 + 1) {
|
|
3488
|
+
throw new BSONError('code_w_scope total size shorter minimum expected length');
|
|
3489
|
+
}
|
|
3490
|
+
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
3491
|
+
index += 4;
|
|
3492
|
+
if (stringSize <= 0 ||
|
|
3493
|
+
stringSize > buffer.length - index ||
|
|
3494
|
+
buffer[index + stringSize - 1] !== 0) {
|
|
3495
|
+
throw new BSONError('bad string length in bson');
|
|
3496
|
+
}
|
|
3497
|
+
const functionString = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
|
|
3498
|
+
index = index + stringSize;
|
|
3499
|
+
const _index = index;
|
|
3500
|
+
const objectSize = NumberUtils.getInt32LE(buffer, index);
|
|
3501
|
+
const scopeObject = deserializeObject(buffer, _index, options, false);
|
|
3502
|
+
index = index + objectSize;
|
|
3503
|
+
if (totalSize < 4 + 4 + objectSize + stringSize) {
|
|
3504
|
+
throw new BSONError('code_w_scope total size is too short, truncating scope');
|
|
3505
|
+
}
|
|
3506
|
+
if (totalSize > 4 + 4 + objectSize + stringSize) {
|
|
3507
|
+
throw new BSONError('code_w_scope total size is too long, clips outer document');
|
|
3508
|
+
}
|
|
3509
|
+
value = new Code(functionString, scopeObject);
|
|
3510
|
+
}
|
|
3511
|
+
else if (elementType === BSON_DATA_DBPOINTER) {
|
|
3512
|
+
const stringSize = NumberUtils.getInt32LE(buffer, index);
|
|
3513
|
+
index += 4;
|
|
3514
|
+
if (stringSize <= 0 ||
|
|
3515
|
+
stringSize > buffer.length - index ||
|
|
3516
|
+
buffer[index + stringSize - 1] !== 0)
|
|
3517
|
+
throw new BSONError('bad string length in bson');
|
|
3518
|
+
const namespace = ByteUtils.toUTF8(buffer, index, index + stringSize - 1, shouldValidateKey);
|
|
3519
|
+
index = index + stringSize;
|
|
3520
|
+
const oidBuffer = ByteUtils.allocateUnsafe(12);
|
|
3521
|
+
for (let i = 0; i < 12; i++)
|
|
3522
|
+
oidBuffer[i] = buffer[index + i];
|
|
3523
|
+
const oid = new ObjectId(oidBuffer);
|
|
3524
|
+
index = index + 12;
|
|
3525
|
+
value = new DBRef(namespace, oid);
|
|
3526
|
+
}
|
|
3527
|
+
else {
|
|
3528
|
+
throw new BSONError(`Detected unknown BSON type ${elementType.toString(16)} for fieldname "${name}"`);
|
|
3529
|
+
}
|
|
3530
|
+
if (name === '__proto__') {
|
|
3531
|
+
Object.defineProperty(object, name, {
|
|
3532
|
+
value,
|
|
3533
|
+
writable: true,
|
|
3534
|
+
enumerable: true,
|
|
3535
|
+
configurable: true
|
|
3536
|
+
});
|
|
3537
|
+
}
|
|
3538
|
+
else {
|
|
3539
|
+
object[name] = value;
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
if (size !== index - startIndex) {
|
|
3543
|
+
if (isArray)
|
|
3544
|
+
throw new BSONError('corrupt array bson');
|
|
3545
|
+
throw new BSONError('corrupt object bson');
|
|
3546
|
+
}
|
|
3547
|
+
if (!isPossibleDBRef)
|
|
3548
|
+
return object;
|
|
3549
|
+
if (isDBRefLike(object)) {
|
|
3550
|
+
const copy = Object.assign({}, object);
|
|
3551
|
+
delete copy.$ref;
|
|
3552
|
+
delete copy.$id;
|
|
3553
|
+
delete copy.$db;
|
|
3554
|
+
return new DBRef(object.$ref, object.$id, object.$db, copy);
|
|
3555
|
+
}
|
|
3556
|
+
return object;
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
const regexp = /\x00/;
|
|
3560
|
+
const ignoreKeys = new Set(['$db', '$ref', '$id', '$clusterTime']);
|
|
3561
|
+
function serializeString(buffer, key, value, index) {
|
|
3562
|
+
buffer[index++] = BSON_DATA_STRING;
|
|
3563
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3564
|
+
index = index + numberOfWrittenBytes + 1;
|
|
3565
|
+
buffer[index - 1] = 0;
|
|
3566
|
+
const size = ByteUtils.encodeUTF8Into(buffer, value, index + 4);
|
|
3567
|
+
NumberUtils.setInt32LE(buffer, index, size + 1);
|
|
3568
|
+
index = index + 4 + size;
|
|
3569
|
+
buffer[index++] = 0;
|
|
3570
|
+
return index;
|
|
3571
|
+
}
|
|
3572
|
+
function serializeNumber(buffer, key, value, index) {
|
|
3573
|
+
const isNegativeZero = Object.is(value, -0);
|
|
3574
|
+
const type = !isNegativeZero &&
|
|
3575
|
+
Number.isSafeInteger(value) &&
|
|
3576
|
+
value <= BSON_INT32_MAX &&
|
|
3577
|
+
value >= BSON_INT32_MIN
|
|
3578
|
+
? BSON_DATA_INT
|
|
3579
|
+
: BSON_DATA_NUMBER;
|
|
3580
|
+
buffer[index++] = type;
|
|
3581
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3582
|
+
index = index + numberOfWrittenBytes;
|
|
3583
|
+
buffer[index++] = 0x00;
|
|
3584
|
+
if (type === BSON_DATA_INT) {
|
|
3585
|
+
index += NumberUtils.setInt32LE(buffer, index, value);
|
|
3586
|
+
}
|
|
3587
|
+
else {
|
|
3588
|
+
index += NumberUtils.setFloat64LE(buffer, index, value);
|
|
3589
|
+
}
|
|
3590
|
+
return index;
|
|
3591
|
+
}
|
|
3592
|
+
function serializeBigInt(buffer, key, value, index) {
|
|
3593
|
+
buffer[index++] = BSON_DATA_LONG;
|
|
3594
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3595
|
+
index += numberOfWrittenBytes;
|
|
3596
|
+
buffer[index++] = 0;
|
|
3597
|
+
index += NumberUtils.setBigInt64LE(buffer, index, value);
|
|
3598
|
+
return index;
|
|
3599
|
+
}
|
|
3600
|
+
function serializeNull(buffer, key, _, index) {
|
|
3601
|
+
buffer[index++] = BSON_DATA_NULL;
|
|
3602
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3603
|
+
index = index + numberOfWrittenBytes;
|
|
3604
|
+
buffer[index++] = 0;
|
|
3605
|
+
return index;
|
|
3606
|
+
}
|
|
3607
|
+
function serializeBoolean(buffer, key, value, index) {
|
|
3608
|
+
buffer[index++] = BSON_DATA_BOOLEAN;
|
|
3609
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3610
|
+
index = index + numberOfWrittenBytes;
|
|
3611
|
+
buffer[index++] = 0;
|
|
3612
|
+
buffer[index++] = value ? 1 : 0;
|
|
3613
|
+
return index;
|
|
3614
|
+
}
|
|
3615
|
+
function serializeDate(buffer, key, value, index) {
|
|
3616
|
+
buffer[index++] = BSON_DATA_DATE;
|
|
3617
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3618
|
+
index = index + numberOfWrittenBytes;
|
|
3619
|
+
buffer[index++] = 0;
|
|
3620
|
+
const dateInMilis = Long.fromNumber(value.getTime());
|
|
3621
|
+
const lowBits = dateInMilis.getLowBits();
|
|
3622
|
+
const highBits = dateInMilis.getHighBits();
|
|
3623
|
+
index += NumberUtils.setInt32LE(buffer, index, lowBits);
|
|
3624
|
+
index += NumberUtils.setInt32LE(buffer, index, highBits);
|
|
3625
|
+
return index;
|
|
3626
|
+
}
|
|
3627
|
+
function serializeRegExp(buffer, key, value, index) {
|
|
3628
|
+
buffer[index++] = BSON_DATA_REGEXP;
|
|
3629
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3630
|
+
index = index + numberOfWrittenBytes;
|
|
3631
|
+
buffer[index++] = 0;
|
|
3632
|
+
if (value.source && value.source.match(regexp) != null) {
|
|
3633
|
+
throw new BSONError('value ' + value.source + ' must not contain null bytes');
|
|
3634
|
+
}
|
|
3635
|
+
index = index + ByteUtils.encodeUTF8Into(buffer, value.source, index);
|
|
3636
|
+
buffer[index++] = 0x00;
|
|
3637
|
+
if (value.ignoreCase)
|
|
3638
|
+
buffer[index++] = 0x69;
|
|
3639
|
+
if (value.global)
|
|
3640
|
+
buffer[index++] = 0x73;
|
|
3641
|
+
if (value.multiline)
|
|
3642
|
+
buffer[index++] = 0x6d;
|
|
3643
|
+
buffer[index++] = 0x00;
|
|
3644
|
+
return index;
|
|
3645
|
+
}
|
|
3646
|
+
function serializeBSONRegExp(buffer, key, value, index) {
|
|
3647
|
+
buffer[index++] = BSON_DATA_REGEXP;
|
|
3648
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3649
|
+
index = index + numberOfWrittenBytes;
|
|
3650
|
+
buffer[index++] = 0;
|
|
3651
|
+
if (value.pattern.match(regexp) != null) {
|
|
3652
|
+
throw new BSONError('pattern ' + value.pattern + ' must not contain null bytes');
|
|
3653
|
+
}
|
|
3654
|
+
index = index + ByteUtils.encodeUTF8Into(buffer, value.pattern, index);
|
|
3655
|
+
buffer[index++] = 0x00;
|
|
3656
|
+
const sortedOptions = value.options.split('').sort().join('');
|
|
3657
|
+
index = index + ByteUtils.encodeUTF8Into(buffer, sortedOptions, index);
|
|
3658
|
+
buffer[index++] = 0x00;
|
|
3659
|
+
return index;
|
|
3660
|
+
}
|
|
3661
|
+
function serializeMinMax(buffer, key, value, index) {
|
|
3662
|
+
if (value === null) {
|
|
3663
|
+
buffer[index++] = BSON_DATA_NULL;
|
|
3664
|
+
}
|
|
3665
|
+
else if (value._bsontype === 'MinKey') {
|
|
3666
|
+
buffer[index++] = BSON_DATA_MIN_KEY;
|
|
3667
|
+
}
|
|
3668
|
+
else {
|
|
3669
|
+
buffer[index++] = BSON_DATA_MAX_KEY;
|
|
3670
|
+
}
|
|
3671
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3672
|
+
index = index + numberOfWrittenBytes;
|
|
3673
|
+
buffer[index++] = 0;
|
|
3674
|
+
return index;
|
|
3675
|
+
}
|
|
3676
|
+
function serializeObjectId(buffer, key, value, index) {
|
|
3677
|
+
buffer[index++] = BSON_DATA_OID;
|
|
3678
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3679
|
+
index = index + numberOfWrittenBytes;
|
|
3680
|
+
buffer[index++] = 0;
|
|
3681
|
+
index += value.serializeInto(buffer, index);
|
|
3682
|
+
return index;
|
|
3683
|
+
}
|
|
3684
|
+
function serializeBuffer(buffer, key, value, index) {
|
|
3685
|
+
buffer[index++] = BSON_DATA_BINARY;
|
|
3686
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3687
|
+
index = index + numberOfWrittenBytes;
|
|
3688
|
+
buffer[index++] = 0;
|
|
3689
|
+
const size = value.length;
|
|
3690
|
+
index += NumberUtils.setInt32LE(buffer, index, size);
|
|
3691
|
+
buffer[index++] = BSON_BINARY_SUBTYPE_DEFAULT;
|
|
3692
|
+
if (size <= 16) {
|
|
3693
|
+
for (let i = 0; i < size; i++)
|
|
3694
|
+
buffer[index + i] = value[i];
|
|
3695
|
+
}
|
|
3696
|
+
else {
|
|
3697
|
+
buffer.set(value, index);
|
|
3698
|
+
}
|
|
3699
|
+
index = index + size;
|
|
3700
|
+
return index;
|
|
3701
|
+
}
|
|
3702
|
+
function serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path) {
|
|
3703
|
+
if (path.has(value)) {
|
|
3704
|
+
throw new BSONError('Cannot convert circular structure to BSON');
|
|
3705
|
+
}
|
|
3706
|
+
path.add(value);
|
|
3707
|
+
buffer[index++] = Array.isArray(value) ? BSON_DATA_ARRAY : BSON_DATA_OBJECT;
|
|
3708
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3709
|
+
index = index + numberOfWrittenBytes;
|
|
3710
|
+
buffer[index++] = 0;
|
|
3711
|
+
const endIndex = serializeInto(buffer, value, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
|
|
3712
|
+
path.delete(value);
|
|
3713
|
+
return endIndex;
|
|
3714
|
+
}
|
|
3715
|
+
function serializeDecimal128(buffer, key, value, index) {
|
|
3716
|
+
buffer[index++] = BSON_DATA_DECIMAL128;
|
|
3717
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3718
|
+
index = index + numberOfWrittenBytes;
|
|
3719
|
+
buffer[index++] = 0;
|
|
3720
|
+
for (let i = 0; i < 16; i++)
|
|
3721
|
+
buffer[index + i] = value.bytes[i];
|
|
3722
|
+
return index + 16;
|
|
3723
|
+
}
|
|
3724
|
+
function serializeLong(buffer, key, value, index) {
|
|
3725
|
+
buffer[index++] =
|
|
3726
|
+
value._bsontype === 'Long' ? BSON_DATA_LONG : BSON_DATA_TIMESTAMP;
|
|
3727
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3728
|
+
index = index + numberOfWrittenBytes;
|
|
3729
|
+
buffer[index++] = 0;
|
|
3730
|
+
const lowBits = value.getLowBits();
|
|
3731
|
+
const highBits = value.getHighBits();
|
|
3732
|
+
index += NumberUtils.setInt32LE(buffer, index, lowBits);
|
|
3733
|
+
index += NumberUtils.setInt32LE(buffer, index, highBits);
|
|
3734
|
+
return index;
|
|
3735
|
+
}
|
|
3736
|
+
function serializeInt32(buffer, key, value, index) {
|
|
3737
|
+
value = value.valueOf();
|
|
3738
|
+
buffer[index++] = BSON_DATA_INT;
|
|
3739
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3740
|
+
index = index + numberOfWrittenBytes;
|
|
3741
|
+
buffer[index++] = 0;
|
|
3742
|
+
index += NumberUtils.setInt32LE(buffer, index, value);
|
|
3743
|
+
return index;
|
|
3744
|
+
}
|
|
3745
|
+
function serializeDouble(buffer, key, value, index) {
|
|
3746
|
+
buffer[index++] = BSON_DATA_NUMBER;
|
|
3747
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3748
|
+
index = index + numberOfWrittenBytes;
|
|
3749
|
+
buffer[index++] = 0;
|
|
3750
|
+
index += NumberUtils.setFloat64LE(buffer, index, value.value);
|
|
3751
|
+
return index;
|
|
3752
|
+
}
|
|
3753
|
+
function serializeFunction(buffer, key, value, index) {
|
|
3754
|
+
buffer[index++] = BSON_DATA_CODE;
|
|
3755
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3756
|
+
index = index + numberOfWrittenBytes;
|
|
3757
|
+
buffer[index++] = 0;
|
|
3758
|
+
const functionString = value.toString();
|
|
3759
|
+
const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
3760
|
+
NumberUtils.setInt32LE(buffer, index, size);
|
|
3761
|
+
index = index + 4 + size - 1;
|
|
3762
|
+
buffer[index++] = 0;
|
|
3763
|
+
return index;
|
|
3764
|
+
}
|
|
3765
|
+
function serializeCode(buffer, key, value, index, checkKeys = false, depth = 0, serializeFunctions = false, ignoreUndefined = true, path) {
|
|
3766
|
+
if (value.scope && typeof value.scope === 'object') {
|
|
3767
|
+
buffer[index++] = BSON_DATA_CODE_W_SCOPE;
|
|
3768
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3769
|
+
index = index + numberOfWrittenBytes;
|
|
3770
|
+
buffer[index++] = 0;
|
|
3771
|
+
let startIndex = index;
|
|
3772
|
+
const functionString = value.code;
|
|
3773
|
+
index = index + 4;
|
|
3774
|
+
const codeSize = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
3775
|
+
NumberUtils.setInt32LE(buffer, index, codeSize);
|
|
3776
|
+
buffer[index + 4 + codeSize - 1] = 0;
|
|
3777
|
+
index = index + codeSize + 4;
|
|
3778
|
+
const endIndex = serializeInto(buffer, value.scope, checkKeys, index, depth + 1, serializeFunctions, ignoreUndefined, path);
|
|
3779
|
+
index = endIndex - 1;
|
|
3780
|
+
const totalSize = endIndex - startIndex;
|
|
3781
|
+
startIndex += NumberUtils.setInt32LE(buffer, startIndex, totalSize);
|
|
3782
|
+
buffer[index++] = 0;
|
|
3783
|
+
}
|
|
3784
|
+
else {
|
|
3785
|
+
buffer[index++] = BSON_DATA_CODE;
|
|
3786
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3787
|
+
index = index + numberOfWrittenBytes;
|
|
3788
|
+
buffer[index++] = 0;
|
|
3789
|
+
const functionString = value.code.toString();
|
|
3790
|
+
const size = ByteUtils.encodeUTF8Into(buffer, functionString, index + 4) + 1;
|
|
3791
|
+
NumberUtils.setInt32LE(buffer, index, size);
|
|
3792
|
+
index = index + 4 + size - 1;
|
|
3793
|
+
buffer[index++] = 0;
|
|
3794
|
+
}
|
|
3795
|
+
return index;
|
|
3796
|
+
}
|
|
3797
|
+
function serializeBinary(buffer, key, value, index) {
|
|
3798
|
+
buffer[index++] = BSON_DATA_BINARY;
|
|
3799
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3800
|
+
index = index + numberOfWrittenBytes;
|
|
3801
|
+
buffer[index++] = 0;
|
|
3802
|
+
const data = value.buffer;
|
|
3803
|
+
let size = value.position;
|
|
3804
|
+
if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY)
|
|
3805
|
+
size = size + 4;
|
|
3806
|
+
index += NumberUtils.setInt32LE(buffer, index, size);
|
|
3807
|
+
buffer[index++] = value.sub_type;
|
|
3808
|
+
if (value.sub_type === Binary.SUBTYPE_BYTE_ARRAY) {
|
|
3809
|
+
size = size - 4;
|
|
3810
|
+
index += NumberUtils.setInt32LE(buffer, index, size);
|
|
3811
|
+
}
|
|
3812
|
+
if (value.sub_type === Binary.SUBTYPE_VECTOR) {
|
|
3813
|
+
validateBinaryVector(value);
|
|
3814
|
+
}
|
|
3815
|
+
if (size <= 16) {
|
|
3816
|
+
for (let i = 0; i < size; i++)
|
|
3817
|
+
buffer[index + i] = data[i];
|
|
3818
|
+
}
|
|
3819
|
+
else {
|
|
3820
|
+
buffer.set(data, index);
|
|
3821
|
+
}
|
|
3822
|
+
index = index + value.position;
|
|
3823
|
+
return index;
|
|
3824
|
+
}
|
|
3825
|
+
function serializeSymbol(buffer, key, value, index) {
|
|
3826
|
+
buffer[index++] = BSON_DATA_SYMBOL;
|
|
3827
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3828
|
+
index = index + numberOfWrittenBytes;
|
|
3829
|
+
buffer[index++] = 0;
|
|
3830
|
+
const size = ByteUtils.encodeUTF8Into(buffer, value.value, index + 4) + 1;
|
|
3831
|
+
NumberUtils.setInt32LE(buffer, index, size);
|
|
3832
|
+
index = index + 4 + size - 1;
|
|
3833
|
+
buffer[index++] = 0;
|
|
3834
|
+
return index;
|
|
3835
|
+
}
|
|
3836
|
+
function serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path) {
|
|
3837
|
+
buffer[index++] = BSON_DATA_OBJECT;
|
|
3838
|
+
const numberOfWrittenBytes = ByteUtils.encodeUTF8Into(buffer, key, index);
|
|
3839
|
+
index = index + numberOfWrittenBytes;
|
|
3840
|
+
buffer[index++] = 0;
|
|
3841
|
+
let startIndex = index;
|
|
3842
|
+
let output = {
|
|
3843
|
+
$ref: value.collection || value.namespace,
|
|
3844
|
+
$id: value.oid
|
|
3845
|
+
};
|
|
3846
|
+
if (value.db != null) {
|
|
3847
|
+
output.$db = value.db;
|
|
3848
|
+
}
|
|
3849
|
+
output = Object.assign(output, value.fields);
|
|
3850
|
+
const endIndex = serializeInto(buffer, output, false, index, depth + 1, serializeFunctions, true, path);
|
|
3851
|
+
const size = endIndex - startIndex;
|
|
3852
|
+
startIndex += NumberUtils.setInt32LE(buffer, index, size);
|
|
3853
|
+
return endIndex;
|
|
3854
|
+
}
|
|
3855
|
+
function serializeInto(buffer, object, checkKeys, startingIndex, depth, serializeFunctions, ignoreUndefined, path) {
|
|
3856
|
+
if (path == null) {
|
|
3857
|
+
if (object == null) {
|
|
3858
|
+
buffer[0] = 0x05;
|
|
3859
|
+
buffer[1] = 0x00;
|
|
3860
|
+
buffer[2] = 0x00;
|
|
3861
|
+
buffer[3] = 0x00;
|
|
3862
|
+
buffer[4] = 0x00;
|
|
3863
|
+
return 5;
|
|
3864
|
+
}
|
|
3865
|
+
if (Array.isArray(object)) {
|
|
3866
|
+
throw new BSONError('serialize does not support an array as the root input');
|
|
3867
|
+
}
|
|
3868
|
+
if (typeof object !== 'object') {
|
|
3869
|
+
throw new BSONError('serialize does not support non-object as the root input');
|
|
3870
|
+
}
|
|
3871
|
+
else if ('_bsontype' in object && typeof object._bsontype === 'string') {
|
|
3872
|
+
throw new BSONError(`BSON types cannot be serialized as a document`);
|
|
3873
|
+
}
|
|
3874
|
+
else if (isDate(object) ||
|
|
3875
|
+
isRegExp(object) ||
|
|
3876
|
+
isUint8Array(object) ||
|
|
3877
|
+
isAnyArrayBuffer(object)) {
|
|
3878
|
+
throw new BSONError(`date, regexp, typedarray, and arraybuffer cannot be BSON documents`);
|
|
3879
|
+
}
|
|
3880
|
+
path = new Set();
|
|
3881
|
+
}
|
|
3882
|
+
path.add(object);
|
|
3883
|
+
let index = startingIndex + 4;
|
|
3884
|
+
if (Array.isArray(object)) {
|
|
3885
|
+
for (let i = 0; i < object.length; i++) {
|
|
3886
|
+
const key = `${i}`;
|
|
3887
|
+
let value = object[i];
|
|
3888
|
+
if (typeof value?.toBSON === 'function') {
|
|
3889
|
+
value = value.toBSON();
|
|
3890
|
+
}
|
|
3891
|
+
const type = typeof value;
|
|
3892
|
+
if (value === undefined) {
|
|
3893
|
+
index = serializeNull(buffer, key, value, index);
|
|
3894
|
+
}
|
|
3895
|
+
else if (value === null) {
|
|
3896
|
+
index = serializeNull(buffer, key, value, index);
|
|
3897
|
+
}
|
|
3898
|
+
else if (type === 'string') {
|
|
3899
|
+
index = serializeString(buffer, key, value, index);
|
|
3900
|
+
}
|
|
3901
|
+
else if (type === 'number') {
|
|
3902
|
+
index = serializeNumber(buffer, key, value, index);
|
|
3903
|
+
}
|
|
3904
|
+
else if (type === 'bigint') {
|
|
3905
|
+
index = serializeBigInt(buffer, key, value, index);
|
|
3906
|
+
}
|
|
3907
|
+
else if (type === 'boolean') {
|
|
3908
|
+
index = serializeBoolean(buffer, key, value, index);
|
|
3909
|
+
}
|
|
3910
|
+
else if (type === 'object' && value._bsontype == null) {
|
|
3911
|
+
if (value instanceof Date || isDate(value)) {
|
|
3912
|
+
index = serializeDate(buffer, key, value, index);
|
|
3913
|
+
}
|
|
3914
|
+
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
3915
|
+
index = serializeBuffer(buffer, key, value, index);
|
|
3916
|
+
}
|
|
3917
|
+
else if (value instanceof RegExp || isRegExp(value)) {
|
|
3918
|
+
index = serializeRegExp(buffer, key, value, index);
|
|
3919
|
+
}
|
|
3920
|
+
else {
|
|
3921
|
+
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
else if (type === 'object') {
|
|
3925
|
+
if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
3926
|
+
throw new BSONVersionError();
|
|
3927
|
+
}
|
|
3928
|
+
else if (value._bsontype === 'ObjectId') {
|
|
3929
|
+
index = serializeObjectId(buffer, key, value, index);
|
|
3930
|
+
}
|
|
3931
|
+
else if (value._bsontype === 'Decimal128') {
|
|
3932
|
+
index = serializeDecimal128(buffer, key, value, index);
|
|
3933
|
+
}
|
|
3934
|
+
else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
|
|
3935
|
+
index = serializeLong(buffer, key, value, index);
|
|
3936
|
+
}
|
|
3937
|
+
else if (value._bsontype === 'Double') {
|
|
3938
|
+
index = serializeDouble(buffer, key, value, index);
|
|
3939
|
+
}
|
|
3940
|
+
else if (value._bsontype === 'Code') {
|
|
3941
|
+
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
3942
|
+
}
|
|
3943
|
+
else if (value._bsontype === 'Binary') {
|
|
3944
|
+
index = serializeBinary(buffer, key, value, index);
|
|
3945
|
+
}
|
|
3946
|
+
else if (value._bsontype === 'BSONSymbol') {
|
|
3947
|
+
index = serializeSymbol(buffer, key, value, index);
|
|
3948
|
+
}
|
|
3949
|
+
else if (value._bsontype === 'DBRef') {
|
|
3950
|
+
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
|
|
3951
|
+
}
|
|
3952
|
+
else if (value._bsontype === 'BSONRegExp') {
|
|
3953
|
+
index = serializeBSONRegExp(buffer, key, value, index);
|
|
3954
|
+
}
|
|
3955
|
+
else if (value._bsontype === 'Int32') {
|
|
3956
|
+
index = serializeInt32(buffer, key, value, index);
|
|
3957
|
+
}
|
|
3958
|
+
else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
3959
|
+
index = serializeMinMax(buffer, key, value, index);
|
|
3960
|
+
}
|
|
3961
|
+
else if (typeof value._bsontype !== 'undefined') {
|
|
3962
|
+
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
else if (type === 'function' && serializeFunctions) {
|
|
3966
|
+
index = serializeFunction(buffer, key, value, index);
|
|
3967
|
+
}
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
else if (object instanceof Map || isMap(object)) {
|
|
3971
|
+
const iterator = object.entries();
|
|
3972
|
+
let done = false;
|
|
3973
|
+
while (!done) {
|
|
3974
|
+
const entry = iterator.next();
|
|
3975
|
+
done = !!entry.done;
|
|
3976
|
+
if (done)
|
|
3977
|
+
continue;
|
|
3978
|
+
const key = entry.value ? entry.value[0] : undefined;
|
|
3979
|
+
let value = entry.value ? entry.value[1] : undefined;
|
|
3980
|
+
if (typeof value?.toBSON === 'function') {
|
|
3981
|
+
value = value.toBSON();
|
|
3982
|
+
}
|
|
3983
|
+
const type = typeof value;
|
|
3984
|
+
if (typeof key === 'string' && !ignoreKeys.has(key)) {
|
|
3985
|
+
if (key.match(regexp) != null) {
|
|
3986
|
+
throw new BSONError('key ' + key + ' must not contain null bytes');
|
|
3987
|
+
}
|
|
3988
|
+
if (checkKeys) {
|
|
3989
|
+
if ('$' === key[0]) {
|
|
3990
|
+
throw new BSONError('key ' + key + " must not start with '$'");
|
|
3991
|
+
}
|
|
3992
|
+
else if (key.includes('.')) {
|
|
3993
|
+
throw new BSONError('key ' + key + " must not contain '.'");
|
|
3994
|
+
}
|
|
3995
|
+
}
|
|
3996
|
+
}
|
|
3997
|
+
if (value === undefined) {
|
|
3998
|
+
if (ignoreUndefined === false)
|
|
3999
|
+
index = serializeNull(buffer, key, value, index);
|
|
4000
|
+
}
|
|
4001
|
+
else if (value === null) {
|
|
4002
|
+
index = serializeNull(buffer, key, value, index);
|
|
4003
|
+
}
|
|
4004
|
+
else if (type === 'string') {
|
|
4005
|
+
index = serializeString(buffer, key, value, index);
|
|
4006
|
+
}
|
|
4007
|
+
else if (type === 'number') {
|
|
4008
|
+
index = serializeNumber(buffer, key, value, index);
|
|
4009
|
+
}
|
|
4010
|
+
else if (type === 'bigint') {
|
|
4011
|
+
index = serializeBigInt(buffer, key, value, index);
|
|
4012
|
+
}
|
|
4013
|
+
else if (type === 'boolean') {
|
|
4014
|
+
index = serializeBoolean(buffer, key, value, index);
|
|
4015
|
+
}
|
|
4016
|
+
else if (type === 'object' && value._bsontype == null) {
|
|
4017
|
+
if (value instanceof Date || isDate(value)) {
|
|
4018
|
+
index = serializeDate(buffer, key, value, index);
|
|
4019
|
+
}
|
|
4020
|
+
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
4021
|
+
index = serializeBuffer(buffer, key, value, index);
|
|
4022
|
+
}
|
|
4023
|
+
else if (value instanceof RegExp || isRegExp(value)) {
|
|
4024
|
+
index = serializeRegExp(buffer, key, value, index);
|
|
4025
|
+
}
|
|
4026
|
+
else {
|
|
4027
|
+
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
4028
|
+
}
|
|
4029
|
+
}
|
|
4030
|
+
else if (type === 'object') {
|
|
4031
|
+
if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
4032
|
+
throw new BSONVersionError();
|
|
4033
|
+
}
|
|
4034
|
+
else if (value._bsontype === 'ObjectId') {
|
|
4035
|
+
index = serializeObjectId(buffer, key, value, index);
|
|
4036
|
+
}
|
|
4037
|
+
else if (value._bsontype === 'Decimal128') {
|
|
4038
|
+
index = serializeDecimal128(buffer, key, value, index);
|
|
4039
|
+
}
|
|
4040
|
+
else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
|
|
4041
|
+
index = serializeLong(buffer, key, value, index);
|
|
4042
|
+
}
|
|
4043
|
+
else if (value._bsontype === 'Double') {
|
|
4044
|
+
index = serializeDouble(buffer, key, value, index);
|
|
4045
|
+
}
|
|
4046
|
+
else if (value._bsontype === 'Code') {
|
|
4047
|
+
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
4048
|
+
}
|
|
4049
|
+
else if (value._bsontype === 'Binary') {
|
|
4050
|
+
index = serializeBinary(buffer, key, value, index);
|
|
4051
|
+
}
|
|
4052
|
+
else if (value._bsontype === 'BSONSymbol') {
|
|
4053
|
+
index = serializeSymbol(buffer, key, value, index);
|
|
4054
|
+
}
|
|
4055
|
+
else if (value._bsontype === 'DBRef') {
|
|
4056
|
+
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
|
|
4057
|
+
}
|
|
4058
|
+
else if (value._bsontype === 'BSONRegExp') {
|
|
4059
|
+
index = serializeBSONRegExp(buffer, key, value, index);
|
|
4060
|
+
}
|
|
4061
|
+
else if (value._bsontype === 'Int32') {
|
|
4062
|
+
index = serializeInt32(buffer, key, value, index);
|
|
4063
|
+
}
|
|
4064
|
+
else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
4065
|
+
index = serializeMinMax(buffer, key, value, index);
|
|
4066
|
+
}
|
|
4067
|
+
else if (typeof value._bsontype !== 'undefined') {
|
|
4068
|
+
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
4069
|
+
}
|
|
4070
|
+
}
|
|
4071
|
+
else if (type === 'function' && serializeFunctions) {
|
|
4072
|
+
index = serializeFunction(buffer, key, value, index);
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
else {
|
|
4077
|
+
if (typeof object?.toBSON === 'function') {
|
|
4078
|
+
object = object.toBSON();
|
|
4079
|
+
if (object != null && typeof object !== 'object') {
|
|
4080
|
+
throw new BSONError('toBSON function did not return an object');
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
for (const key of Object.keys(object)) {
|
|
4084
|
+
let value = object[key];
|
|
4085
|
+
if (typeof value?.toBSON === 'function') {
|
|
4086
|
+
value = value.toBSON();
|
|
4087
|
+
}
|
|
4088
|
+
const type = typeof value;
|
|
4089
|
+
if (typeof key === 'string' && !ignoreKeys.has(key)) {
|
|
4090
|
+
if (key.match(regexp) != null) {
|
|
4091
|
+
throw new BSONError('key ' + key + ' must not contain null bytes');
|
|
4092
|
+
}
|
|
4093
|
+
if (checkKeys) {
|
|
4094
|
+
if ('$' === key[0]) {
|
|
4095
|
+
throw new BSONError('key ' + key + " must not start with '$'");
|
|
4096
|
+
}
|
|
4097
|
+
else if (key.includes('.')) {
|
|
4098
|
+
throw new BSONError('key ' + key + " must not contain '.'");
|
|
4099
|
+
}
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
if (value === undefined) {
|
|
4103
|
+
if (ignoreUndefined === false)
|
|
4104
|
+
index = serializeNull(buffer, key, value, index);
|
|
4105
|
+
}
|
|
4106
|
+
else if (value === null) {
|
|
4107
|
+
index = serializeNull(buffer, key, value, index);
|
|
4108
|
+
}
|
|
4109
|
+
else if (type === 'string') {
|
|
4110
|
+
index = serializeString(buffer, key, value, index);
|
|
4111
|
+
}
|
|
4112
|
+
else if (type === 'number') {
|
|
4113
|
+
index = serializeNumber(buffer, key, value, index);
|
|
4114
|
+
}
|
|
4115
|
+
else if (type === 'bigint') {
|
|
4116
|
+
index = serializeBigInt(buffer, key, value, index);
|
|
4117
|
+
}
|
|
4118
|
+
else if (type === 'boolean') {
|
|
4119
|
+
index = serializeBoolean(buffer, key, value, index);
|
|
4120
|
+
}
|
|
4121
|
+
else if (type === 'object' && value._bsontype == null) {
|
|
4122
|
+
if (value instanceof Date || isDate(value)) {
|
|
4123
|
+
index = serializeDate(buffer, key, value, index);
|
|
4124
|
+
}
|
|
4125
|
+
else if (value instanceof Uint8Array || isUint8Array(value)) {
|
|
4126
|
+
index = serializeBuffer(buffer, key, value, index);
|
|
4127
|
+
}
|
|
4128
|
+
else if (value instanceof RegExp || isRegExp(value)) {
|
|
4129
|
+
index = serializeRegExp(buffer, key, value, index);
|
|
4130
|
+
}
|
|
4131
|
+
else {
|
|
4132
|
+
index = serializeObject(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
4133
|
+
}
|
|
4134
|
+
}
|
|
4135
|
+
else if (type === 'object') {
|
|
4136
|
+
if (value[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
4137
|
+
throw new BSONVersionError();
|
|
4138
|
+
}
|
|
4139
|
+
else if (value._bsontype === 'ObjectId') {
|
|
4140
|
+
index = serializeObjectId(buffer, key, value, index);
|
|
4141
|
+
}
|
|
4142
|
+
else if (value._bsontype === 'Decimal128') {
|
|
4143
|
+
index = serializeDecimal128(buffer, key, value, index);
|
|
4144
|
+
}
|
|
4145
|
+
else if (value._bsontype === 'Long' || value._bsontype === 'Timestamp') {
|
|
4146
|
+
index = serializeLong(buffer, key, value, index);
|
|
4147
|
+
}
|
|
4148
|
+
else if (value._bsontype === 'Double') {
|
|
4149
|
+
index = serializeDouble(buffer, key, value, index);
|
|
4150
|
+
}
|
|
4151
|
+
else if (value._bsontype === 'Code') {
|
|
4152
|
+
index = serializeCode(buffer, key, value, index, checkKeys, depth, serializeFunctions, ignoreUndefined, path);
|
|
4153
|
+
}
|
|
4154
|
+
else if (value._bsontype === 'Binary') {
|
|
4155
|
+
index = serializeBinary(buffer, key, value, index);
|
|
4156
|
+
}
|
|
4157
|
+
else if (value._bsontype === 'BSONSymbol') {
|
|
4158
|
+
index = serializeSymbol(buffer, key, value, index);
|
|
4159
|
+
}
|
|
4160
|
+
else if (value._bsontype === 'DBRef') {
|
|
4161
|
+
index = serializeDBRef(buffer, key, value, index, depth, serializeFunctions, path);
|
|
4162
|
+
}
|
|
4163
|
+
else if (value._bsontype === 'BSONRegExp') {
|
|
4164
|
+
index = serializeBSONRegExp(buffer, key, value, index);
|
|
4165
|
+
}
|
|
4166
|
+
else if (value._bsontype === 'Int32') {
|
|
4167
|
+
index = serializeInt32(buffer, key, value, index);
|
|
4168
|
+
}
|
|
4169
|
+
else if (value._bsontype === 'MinKey' || value._bsontype === 'MaxKey') {
|
|
4170
|
+
index = serializeMinMax(buffer, key, value, index);
|
|
4171
|
+
}
|
|
4172
|
+
else if (typeof value._bsontype !== 'undefined') {
|
|
4173
|
+
throw new BSONError(`Unrecognized or invalid _bsontype: ${String(value._bsontype)}`);
|
|
4174
|
+
}
|
|
4175
|
+
}
|
|
4176
|
+
else if (type === 'function' && serializeFunctions) {
|
|
4177
|
+
index = serializeFunction(buffer, key, value, index);
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
path.delete(object);
|
|
4182
|
+
buffer[index++] = 0x00;
|
|
4183
|
+
const size = index - startingIndex;
|
|
4184
|
+
startingIndex += NumberUtils.setInt32LE(buffer, startingIndex, size);
|
|
4185
|
+
return index;
|
|
4186
|
+
}
|
|
4187
|
+
|
|
4188
|
+
function isBSONType(value) {
|
|
4189
|
+
return (value != null &&
|
|
4190
|
+
typeof value === 'object' &&
|
|
4191
|
+
'_bsontype' in value &&
|
|
4192
|
+
typeof value._bsontype === 'string');
|
|
4193
|
+
}
|
|
4194
|
+
const keysToCodecs = {
|
|
4195
|
+
$oid: ObjectId,
|
|
4196
|
+
$binary: Binary,
|
|
4197
|
+
$uuid: Binary,
|
|
4198
|
+
$symbol: BSONSymbol,
|
|
4199
|
+
$numberInt: Int32,
|
|
4200
|
+
$numberDecimal: Decimal128,
|
|
4201
|
+
$numberDouble: Double,
|
|
4202
|
+
$numberLong: Long,
|
|
4203
|
+
$minKey: MinKey,
|
|
4204
|
+
$maxKey: MaxKey,
|
|
4205
|
+
$regex: BSONRegExp,
|
|
4206
|
+
$regularExpression: BSONRegExp,
|
|
4207
|
+
$timestamp: Timestamp
|
|
4208
|
+
};
|
|
4209
|
+
function deserializeValue(value, options = {}) {
|
|
4210
|
+
if (typeof value === 'number') {
|
|
4211
|
+
const in32BitRange = value <= BSON_INT32_MAX && value >= BSON_INT32_MIN;
|
|
4212
|
+
const in64BitRange = value <= BSON_INT64_MAX && value >= BSON_INT64_MIN;
|
|
4213
|
+
if (options.relaxed || options.legacy) {
|
|
4214
|
+
return value;
|
|
4215
|
+
}
|
|
4216
|
+
if (Number.isInteger(value) && !Object.is(value, -0)) {
|
|
4217
|
+
if (in32BitRange) {
|
|
4218
|
+
return new Int32(value);
|
|
4219
|
+
}
|
|
4220
|
+
if (in64BitRange) {
|
|
4221
|
+
if (options.useBigInt64) {
|
|
4222
|
+
return BigInt(value);
|
|
4223
|
+
}
|
|
4224
|
+
return Long.fromNumber(value);
|
|
4225
|
+
}
|
|
4226
|
+
}
|
|
4227
|
+
return new Double(value);
|
|
4228
|
+
}
|
|
4229
|
+
if (value == null || typeof value !== 'object')
|
|
4230
|
+
return value;
|
|
4231
|
+
if (value.$undefined)
|
|
4232
|
+
return null;
|
|
4233
|
+
const keys = Object.keys(value).filter(k => k.startsWith('$') && value[k] != null);
|
|
4234
|
+
for (let i = 0; i < keys.length; i++) {
|
|
4235
|
+
const c = keysToCodecs[keys[i]];
|
|
4236
|
+
if (c)
|
|
4237
|
+
return c.fromExtendedJSON(value, options);
|
|
4238
|
+
}
|
|
4239
|
+
if (value.$date != null) {
|
|
4240
|
+
const d = value.$date;
|
|
4241
|
+
const date = new Date();
|
|
4242
|
+
if (options.legacy) {
|
|
4243
|
+
if (typeof d === 'number')
|
|
4244
|
+
date.setTime(d);
|
|
4245
|
+
else if (typeof d === 'string')
|
|
4246
|
+
date.setTime(Date.parse(d));
|
|
4247
|
+
else if (typeof d === 'bigint')
|
|
4248
|
+
date.setTime(Number(d));
|
|
4249
|
+
else
|
|
4250
|
+
throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`);
|
|
4251
|
+
}
|
|
4252
|
+
else {
|
|
4253
|
+
if (typeof d === 'string')
|
|
4254
|
+
date.setTime(Date.parse(d));
|
|
4255
|
+
else if (Long.isLong(d))
|
|
4256
|
+
date.setTime(d.toNumber());
|
|
4257
|
+
else if (typeof d === 'number' && options.relaxed)
|
|
4258
|
+
date.setTime(d);
|
|
4259
|
+
else if (typeof d === 'bigint')
|
|
4260
|
+
date.setTime(Number(d));
|
|
4261
|
+
else
|
|
4262
|
+
throw new BSONRuntimeError(`Unrecognized type for EJSON date: ${typeof d}`);
|
|
4263
|
+
}
|
|
4264
|
+
return date;
|
|
4265
|
+
}
|
|
4266
|
+
if (value.$code != null) {
|
|
4267
|
+
const copy = Object.assign({}, value);
|
|
4268
|
+
if (value.$scope) {
|
|
4269
|
+
copy.$scope = deserializeValue(value.$scope);
|
|
4270
|
+
}
|
|
4271
|
+
return Code.fromExtendedJSON(value);
|
|
4272
|
+
}
|
|
4273
|
+
if (isDBRefLike(value) || value.$dbPointer) {
|
|
4274
|
+
const v = value.$ref ? value : value.$dbPointer;
|
|
4275
|
+
if (v instanceof DBRef)
|
|
4276
|
+
return v;
|
|
4277
|
+
const dollarKeys = Object.keys(v).filter(k => k.startsWith('$'));
|
|
4278
|
+
let valid = true;
|
|
4279
|
+
dollarKeys.forEach(k => {
|
|
4280
|
+
if (['$ref', '$id', '$db'].indexOf(k) === -1)
|
|
4281
|
+
valid = false;
|
|
4282
|
+
});
|
|
4283
|
+
if (valid)
|
|
4284
|
+
return DBRef.fromExtendedJSON(v);
|
|
4285
|
+
}
|
|
4286
|
+
return value;
|
|
4287
|
+
}
|
|
4288
|
+
function serializeArray(array, options) {
|
|
4289
|
+
return array.map((v, index) => {
|
|
4290
|
+
options.seenObjects.push({ propertyName: `index ${index}`, obj: null });
|
|
4291
|
+
try {
|
|
4292
|
+
return serializeValue(v, options);
|
|
4293
|
+
}
|
|
4294
|
+
finally {
|
|
4295
|
+
options.seenObjects.pop();
|
|
4296
|
+
}
|
|
4297
|
+
});
|
|
4298
|
+
}
|
|
4299
|
+
function getISOString(date) {
|
|
4300
|
+
const isoStr = date.toISOString();
|
|
4301
|
+
return date.getUTCMilliseconds() !== 0 ? isoStr : isoStr.slice(0, -5) + 'Z';
|
|
4302
|
+
}
|
|
4303
|
+
function serializeValue(value, options) {
|
|
4304
|
+
if (value instanceof Map || isMap(value)) {
|
|
4305
|
+
const obj = Object.create(null);
|
|
4306
|
+
for (const [k, v] of value) {
|
|
4307
|
+
if (typeof k !== 'string') {
|
|
4308
|
+
throw new BSONError('Can only serialize maps with string keys');
|
|
4309
|
+
}
|
|
4310
|
+
obj[k] = v;
|
|
4311
|
+
}
|
|
4312
|
+
return serializeValue(obj, options);
|
|
4313
|
+
}
|
|
4314
|
+
if ((typeof value === 'object' || typeof value === 'function') && value !== null) {
|
|
4315
|
+
const index = options.seenObjects.findIndex(entry => entry.obj === value);
|
|
4316
|
+
if (index !== -1) {
|
|
4317
|
+
const props = options.seenObjects.map(entry => entry.propertyName);
|
|
4318
|
+
const leadingPart = props
|
|
4319
|
+
.slice(0, index)
|
|
4320
|
+
.map(prop => `${prop} -> `)
|
|
4321
|
+
.join('');
|
|
4322
|
+
const alreadySeen = props[index];
|
|
4323
|
+
const circularPart = ' -> ' +
|
|
4324
|
+
props
|
|
4325
|
+
.slice(index + 1, props.length - 1)
|
|
4326
|
+
.map(prop => `${prop} -> `)
|
|
4327
|
+
.join('');
|
|
4328
|
+
const current = props[props.length - 1];
|
|
4329
|
+
const leadingSpace = ' '.repeat(leadingPart.length + alreadySeen.length / 2);
|
|
4330
|
+
const dashes = '-'.repeat(circularPart.length + (alreadySeen.length + current.length) / 2 - 1);
|
|
4331
|
+
throw new BSONError('Converting circular structure to EJSON:\n' +
|
|
4332
|
+
` ${leadingPart}${alreadySeen}${circularPart}${current}\n` +
|
|
4333
|
+
` ${leadingSpace}\\${dashes}/`);
|
|
4334
|
+
}
|
|
4335
|
+
options.seenObjects[options.seenObjects.length - 1].obj = value;
|
|
4336
|
+
}
|
|
4337
|
+
if (Array.isArray(value))
|
|
4338
|
+
return serializeArray(value, options);
|
|
4339
|
+
if (value === undefined)
|
|
4340
|
+
return options.ignoreUndefined ? undefined : null;
|
|
4341
|
+
if (value instanceof Date || isDate(value)) {
|
|
4342
|
+
const dateNum = value.getTime(), inRange = dateNum > -1 && dateNum < 253402318800000;
|
|
4343
|
+
if (options.legacy) {
|
|
4344
|
+
return options.relaxed && inRange
|
|
4345
|
+
? { $date: value.getTime() }
|
|
4346
|
+
: { $date: getISOString(value) };
|
|
4347
|
+
}
|
|
4348
|
+
return options.relaxed && inRange
|
|
4349
|
+
? { $date: getISOString(value) }
|
|
4350
|
+
: { $date: { $numberLong: value.getTime().toString() } };
|
|
4351
|
+
}
|
|
4352
|
+
if (typeof value === 'number' && (!options.relaxed || !isFinite(value))) {
|
|
4353
|
+
if (Number.isInteger(value) && !Object.is(value, -0)) {
|
|
4354
|
+
if (value >= BSON_INT32_MIN && value <= BSON_INT32_MAX) {
|
|
4355
|
+
return { $numberInt: value.toString() };
|
|
4356
|
+
}
|
|
4357
|
+
if (value >= BSON_INT64_MIN && value <= BSON_INT64_MAX) {
|
|
4358
|
+
return { $numberLong: value.toString() };
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
return { $numberDouble: Object.is(value, -0) ? '-0.0' : value.toString() };
|
|
4362
|
+
}
|
|
4363
|
+
if (typeof value === 'bigint') {
|
|
4364
|
+
if (!options.relaxed) {
|
|
4365
|
+
return { $numberLong: BigInt.asIntN(64, value).toString() };
|
|
4366
|
+
}
|
|
4367
|
+
return Number(BigInt.asIntN(64, value));
|
|
4368
|
+
}
|
|
4369
|
+
if (value instanceof RegExp || isRegExp(value)) {
|
|
4370
|
+
let flags = value.flags;
|
|
4371
|
+
if (flags === undefined) {
|
|
4372
|
+
const match = value.toString().match(/[gimuy]*$/);
|
|
4373
|
+
if (match) {
|
|
4374
|
+
flags = match[0];
|
|
4375
|
+
}
|
|
4376
|
+
}
|
|
4377
|
+
const rx = new BSONRegExp(value.source, flags);
|
|
4378
|
+
return rx.toExtendedJSON(options);
|
|
4379
|
+
}
|
|
4380
|
+
if (value != null && typeof value === 'object')
|
|
4381
|
+
return serializeDocument(value, options);
|
|
4382
|
+
return value;
|
|
4383
|
+
}
|
|
4384
|
+
const BSON_TYPE_MAPPINGS = {
|
|
4385
|
+
Binary: (o) => new Binary(o.value(), o.sub_type),
|
|
4386
|
+
Code: (o) => new Code(o.code, o.scope),
|
|
4387
|
+
DBRef: (o) => new DBRef(o.collection || o.namespace, o.oid, o.db, o.fields),
|
|
4388
|
+
Decimal128: (o) => new Decimal128(o.bytes),
|
|
4389
|
+
Double: (o) => new Double(o.value),
|
|
4390
|
+
Int32: (o) => new Int32(o.value),
|
|
4391
|
+
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_),
|
|
4392
|
+
MaxKey: () => new MaxKey(),
|
|
4393
|
+
MinKey: () => new MinKey(),
|
|
4394
|
+
ObjectId: (o) => new ObjectId(o),
|
|
4395
|
+
BSONRegExp: (o) => new BSONRegExp(o.pattern, o.options),
|
|
4396
|
+
BSONSymbol: (o) => new BSONSymbol(o.value),
|
|
4397
|
+
Timestamp: (o) => Timestamp.fromBits(o.low, o.high)
|
|
4398
|
+
};
|
|
4399
|
+
function serializeDocument(doc, options) {
|
|
4400
|
+
if (doc == null || typeof doc !== 'object')
|
|
4401
|
+
throw new BSONError('not an object instance');
|
|
4402
|
+
const bsontype = doc._bsontype;
|
|
4403
|
+
if (typeof bsontype === 'undefined') {
|
|
4404
|
+
const _doc = {};
|
|
4405
|
+
for (const name of Object.keys(doc)) {
|
|
4406
|
+
options.seenObjects.push({ propertyName: name, obj: null });
|
|
4407
|
+
try {
|
|
4408
|
+
const value = serializeValue(doc[name], options);
|
|
4409
|
+
if (name === '__proto__') {
|
|
4410
|
+
Object.defineProperty(_doc, name, {
|
|
4411
|
+
value,
|
|
4412
|
+
writable: true,
|
|
4413
|
+
enumerable: true,
|
|
4414
|
+
configurable: true
|
|
4415
|
+
});
|
|
4416
|
+
}
|
|
4417
|
+
else {
|
|
4418
|
+
_doc[name] = value;
|
|
4419
|
+
}
|
|
4420
|
+
}
|
|
4421
|
+
finally {
|
|
4422
|
+
options.seenObjects.pop();
|
|
4423
|
+
}
|
|
4424
|
+
}
|
|
4425
|
+
return _doc;
|
|
4426
|
+
}
|
|
4427
|
+
else if (doc != null &&
|
|
4428
|
+
typeof doc === 'object' &&
|
|
4429
|
+
typeof doc._bsontype === 'string' &&
|
|
4430
|
+
doc[BSON_VERSION_SYMBOL] !== BSON_MAJOR_VERSION) {
|
|
4431
|
+
throw new BSONVersionError();
|
|
4432
|
+
}
|
|
4433
|
+
else if (isBSONType(doc)) {
|
|
4434
|
+
let outDoc = doc;
|
|
4435
|
+
if (typeof outDoc.toExtendedJSON !== 'function') {
|
|
4436
|
+
const mapper = BSON_TYPE_MAPPINGS[doc._bsontype];
|
|
4437
|
+
if (!mapper) {
|
|
4438
|
+
throw new BSONError('Unrecognized or invalid _bsontype: ' + doc._bsontype);
|
|
4439
|
+
}
|
|
4440
|
+
outDoc = mapper(outDoc);
|
|
4441
|
+
}
|
|
4442
|
+
if (bsontype === 'Code' && outDoc.scope) {
|
|
4443
|
+
outDoc = new Code(outDoc.code, serializeValue(outDoc.scope, options));
|
|
4444
|
+
}
|
|
4445
|
+
else if (bsontype === 'DBRef' && outDoc.oid) {
|
|
4446
|
+
outDoc = new DBRef(serializeValue(outDoc.collection, options), serializeValue(outDoc.oid, options), serializeValue(outDoc.db, options), serializeValue(outDoc.fields, options));
|
|
4447
|
+
}
|
|
4448
|
+
return outDoc.toExtendedJSON(options);
|
|
4449
|
+
}
|
|
4450
|
+
else {
|
|
4451
|
+
throw new BSONError('_bsontype must be a string, but was: ' + typeof bsontype);
|
|
4452
|
+
}
|
|
4453
|
+
}
|
|
4454
|
+
function parse(text, options) {
|
|
4455
|
+
const ejsonOptions = {
|
|
4456
|
+
useBigInt64: options?.useBigInt64 ?? false,
|
|
4457
|
+
relaxed: options?.relaxed ?? true,
|
|
4458
|
+
legacy: options?.legacy ?? false
|
|
4459
|
+
};
|
|
4460
|
+
return JSON.parse(text, (key, value) => {
|
|
4461
|
+
if (key.indexOf('\x00') !== -1) {
|
|
4462
|
+
throw new BSONError(`BSON Document field names cannot contain null bytes, found: ${JSON.stringify(key)}`);
|
|
4463
|
+
}
|
|
4464
|
+
return deserializeValue(value, ejsonOptions);
|
|
4465
|
+
});
|
|
4466
|
+
}
|
|
4467
|
+
function stringify(value, replacer, space, options) {
|
|
4468
|
+
if (space != null && typeof space === 'object') {
|
|
4469
|
+
options = space;
|
|
4470
|
+
space = 0;
|
|
4471
|
+
}
|
|
4472
|
+
if (replacer != null && typeof replacer === 'object' && !Array.isArray(replacer)) {
|
|
4473
|
+
options = replacer;
|
|
4474
|
+
replacer = undefined;
|
|
4475
|
+
space = 0;
|
|
4476
|
+
}
|
|
4477
|
+
const serializeOptions = Object.assign({ relaxed: true, legacy: false }, options, {
|
|
4478
|
+
seenObjects: [{ propertyName: '(root)', obj: null }]
|
|
4479
|
+
});
|
|
4480
|
+
const doc = serializeValue(value, serializeOptions);
|
|
4481
|
+
return JSON.stringify(doc, replacer, space);
|
|
4482
|
+
}
|
|
4483
|
+
function EJSONserialize(value, options) {
|
|
4484
|
+
options = options || {};
|
|
4485
|
+
return JSON.parse(stringify(value, options));
|
|
4486
|
+
}
|
|
4487
|
+
function EJSONdeserialize(ejson, options) {
|
|
4488
|
+
options = options || {};
|
|
4489
|
+
return parse(JSON.stringify(ejson), options);
|
|
4490
|
+
}
|
|
4491
|
+
const EJSON = Object.create(null);
|
|
4492
|
+
EJSON.parse = parse;
|
|
4493
|
+
EJSON.stringify = stringify;
|
|
4494
|
+
EJSON.serialize = EJSONserialize;
|
|
4495
|
+
EJSON.deserialize = EJSONdeserialize;
|
|
4496
|
+
Object.freeze(EJSON);
|
|
4497
|
+
|
|
4498
|
+
const BSONElementType = {
|
|
4499
|
+
double: 1,
|
|
4500
|
+
string: 2,
|
|
4501
|
+
object: 3,
|
|
4502
|
+
array: 4,
|
|
4503
|
+
binData: 5,
|
|
4504
|
+
undefined: 6,
|
|
4505
|
+
objectId: 7,
|
|
4506
|
+
bool: 8,
|
|
4507
|
+
date: 9,
|
|
4508
|
+
null: 10,
|
|
4509
|
+
regex: 11,
|
|
4510
|
+
dbPointer: 12,
|
|
4511
|
+
javascript: 13,
|
|
4512
|
+
symbol: 14,
|
|
4513
|
+
javascriptWithScope: 15,
|
|
4514
|
+
int: 16,
|
|
4515
|
+
timestamp: 17,
|
|
4516
|
+
long: 18,
|
|
4517
|
+
decimal: 19,
|
|
4518
|
+
minKey: 255,
|
|
4519
|
+
maxKey: 127
|
|
4520
|
+
};
|
|
4521
|
+
function getSize(source, offset) {
|
|
4522
|
+
try {
|
|
4523
|
+
return NumberUtils.getNonnegativeInt32LE(source, offset);
|
|
4524
|
+
}
|
|
4525
|
+
catch (cause) {
|
|
4526
|
+
throw new BSONOffsetError('BSON size cannot be negative', offset, { cause });
|
|
4527
|
+
}
|
|
4528
|
+
}
|
|
4529
|
+
function findNull(bytes, offset) {
|
|
4530
|
+
let nullTerminatorOffset = offset;
|
|
4531
|
+
for (; bytes[nullTerminatorOffset] !== 0x00; nullTerminatorOffset++)
|
|
4532
|
+
;
|
|
4533
|
+
if (nullTerminatorOffset === bytes.length - 1) {
|
|
4534
|
+
throw new BSONOffsetError('Null terminator not found', offset);
|
|
4535
|
+
}
|
|
4536
|
+
return nullTerminatorOffset;
|
|
4537
|
+
}
|
|
4538
|
+
function parseToElements(bytes, startOffset = 0) {
|
|
4539
|
+
startOffset ??= 0;
|
|
4540
|
+
if (bytes.length < 5) {
|
|
4541
|
+
throw new BSONOffsetError(`Input must be at least 5 bytes, got ${bytes.length} bytes`, startOffset);
|
|
4542
|
+
}
|
|
4543
|
+
const documentSize = getSize(bytes, startOffset);
|
|
4544
|
+
if (documentSize > bytes.length - startOffset) {
|
|
4545
|
+
throw new BSONOffsetError(`Parsed documentSize (${documentSize} bytes) does not match input length (${bytes.length} bytes)`, startOffset);
|
|
4546
|
+
}
|
|
4547
|
+
if (bytes[startOffset + documentSize - 1] !== 0x00) {
|
|
4548
|
+
throw new BSONOffsetError('BSON documents must end in 0x00', startOffset + documentSize);
|
|
4549
|
+
}
|
|
4550
|
+
const elements = [];
|
|
4551
|
+
let offset = startOffset + 4;
|
|
4552
|
+
while (offset <= documentSize + startOffset) {
|
|
4553
|
+
const type = bytes[offset];
|
|
4554
|
+
offset += 1;
|
|
4555
|
+
if (type === 0) {
|
|
4556
|
+
if (offset - startOffset !== documentSize) {
|
|
4557
|
+
throw new BSONOffsetError(`Invalid 0x00 type byte`, offset);
|
|
4558
|
+
}
|
|
4559
|
+
break;
|
|
4560
|
+
}
|
|
4561
|
+
const nameOffset = offset;
|
|
4562
|
+
const nameLength = findNull(bytes, offset) - nameOffset;
|
|
4563
|
+
offset += nameLength + 1;
|
|
4564
|
+
let length;
|
|
4565
|
+
if (type === BSONElementType.double ||
|
|
4566
|
+
type === BSONElementType.long ||
|
|
4567
|
+
type === BSONElementType.date ||
|
|
4568
|
+
type === BSONElementType.timestamp) {
|
|
4569
|
+
length = 8;
|
|
4570
|
+
}
|
|
4571
|
+
else if (type === BSONElementType.int) {
|
|
4572
|
+
length = 4;
|
|
4573
|
+
}
|
|
4574
|
+
else if (type === BSONElementType.objectId) {
|
|
4575
|
+
length = 12;
|
|
4576
|
+
}
|
|
4577
|
+
else if (type === BSONElementType.decimal) {
|
|
4578
|
+
length = 16;
|
|
4579
|
+
}
|
|
4580
|
+
else if (type === BSONElementType.bool) {
|
|
4581
|
+
length = 1;
|
|
4582
|
+
}
|
|
4583
|
+
else if (type === BSONElementType.null ||
|
|
4584
|
+
type === BSONElementType.undefined ||
|
|
4585
|
+
type === BSONElementType.maxKey ||
|
|
4586
|
+
type === BSONElementType.minKey) {
|
|
4587
|
+
length = 0;
|
|
4588
|
+
}
|
|
4589
|
+
else if (type === BSONElementType.regex) {
|
|
4590
|
+
length = findNull(bytes, findNull(bytes, offset) + 1) + 1 - offset;
|
|
4591
|
+
}
|
|
4592
|
+
else if (type === BSONElementType.object ||
|
|
4593
|
+
type === BSONElementType.array ||
|
|
4594
|
+
type === BSONElementType.javascriptWithScope) {
|
|
4595
|
+
length = getSize(bytes, offset);
|
|
4596
|
+
}
|
|
4597
|
+
else if (type === BSONElementType.string ||
|
|
4598
|
+
type === BSONElementType.binData ||
|
|
4599
|
+
type === BSONElementType.dbPointer ||
|
|
4600
|
+
type === BSONElementType.javascript ||
|
|
4601
|
+
type === BSONElementType.symbol) {
|
|
4602
|
+
length = getSize(bytes, offset) + 4;
|
|
4603
|
+
if (type === BSONElementType.binData) {
|
|
4604
|
+
length += 1;
|
|
4605
|
+
}
|
|
4606
|
+
if (type === BSONElementType.dbPointer) {
|
|
4607
|
+
length += 12;
|
|
4608
|
+
}
|
|
4609
|
+
}
|
|
4610
|
+
else {
|
|
4611
|
+
throw new BSONOffsetError(`Invalid 0x${type.toString(16).padStart(2, '0')} type byte`, offset);
|
|
4612
|
+
}
|
|
4613
|
+
if (length > documentSize) {
|
|
4614
|
+
throw new BSONOffsetError('value reports length larger than document', offset);
|
|
4615
|
+
}
|
|
4616
|
+
elements.push([type, nameOffset, nameLength, offset, length]);
|
|
4617
|
+
offset += length;
|
|
4618
|
+
}
|
|
4619
|
+
return elements;
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4622
|
+
const onDemand = Object.create(null);
|
|
4623
|
+
onDemand.parseToElements = parseToElements;
|
|
4624
|
+
onDemand.ByteUtils = ByteUtils;
|
|
4625
|
+
onDemand.NumberUtils = NumberUtils;
|
|
4626
|
+
Object.freeze(onDemand);
|
|
4627
|
+
|
|
4628
|
+
const MAXSIZE = 1024 * 1024 * 17;
|
|
4629
|
+
let buffer = ByteUtils.allocate(MAXSIZE);
|
|
4630
|
+
function setInternalBufferSize(size) {
|
|
4631
|
+
if (buffer.length < size) {
|
|
4632
|
+
buffer = ByteUtils.allocate(size);
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
function serialize(object, options = {}) {
|
|
4636
|
+
const checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
|
|
4637
|
+
const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
4638
|
+
const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
4639
|
+
const minInternalBufferSize = typeof options.minInternalBufferSize === 'number' ? options.minInternalBufferSize : MAXSIZE;
|
|
4640
|
+
if (buffer.length < minInternalBufferSize) {
|
|
4641
|
+
buffer = ByteUtils.allocate(minInternalBufferSize);
|
|
4642
|
+
}
|
|
4643
|
+
const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
|
|
4644
|
+
const finishedBuffer = ByteUtils.allocateUnsafe(serializationIndex);
|
|
4645
|
+
finishedBuffer.set(buffer.subarray(0, serializationIndex), 0);
|
|
4646
|
+
return finishedBuffer;
|
|
4647
|
+
}
|
|
4648
|
+
function serializeWithBufferAndIndex(object, finalBuffer, options = {}) {
|
|
4649
|
+
const checkKeys = typeof options.checkKeys === 'boolean' ? options.checkKeys : false;
|
|
4650
|
+
const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
4651
|
+
const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
4652
|
+
const startIndex = typeof options.index === 'number' ? options.index : 0;
|
|
4653
|
+
const serializationIndex = serializeInto(buffer, object, checkKeys, 0, 0, serializeFunctions, ignoreUndefined, null);
|
|
4654
|
+
finalBuffer.set(buffer.subarray(0, serializationIndex), startIndex);
|
|
4655
|
+
return startIndex + serializationIndex - 1;
|
|
4656
|
+
}
|
|
4657
|
+
function deserialize(buffer, options = {}) {
|
|
4658
|
+
return internalDeserialize(ByteUtils.toLocalBufferType(buffer), options);
|
|
4659
|
+
}
|
|
4660
|
+
function calculateObjectSize(object, options = {}) {
|
|
4661
|
+
options = options || {};
|
|
4662
|
+
const serializeFunctions = typeof options.serializeFunctions === 'boolean' ? options.serializeFunctions : false;
|
|
4663
|
+
const ignoreUndefined = typeof options.ignoreUndefined === 'boolean' ? options.ignoreUndefined : true;
|
|
4664
|
+
return internalCalculateObjectSize(object, serializeFunctions, ignoreUndefined);
|
|
4665
|
+
}
|
|
4666
|
+
function deserializeStream(data, startIndex, numberOfDocuments, documents, docStartIndex, options) {
|
|
4667
|
+
const internalOptions = Object.assign({ allowObjectSmallerThanBufferSize: true, index: 0 }, options);
|
|
4668
|
+
const bufferData = ByteUtils.toLocalBufferType(data);
|
|
4669
|
+
let index = startIndex;
|
|
4670
|
+
for (let i = 0; i < numberOfDocuments; i++) {
|
|
4671
|
+
const size = NumberUtils.getInt32LE(bufferData, index);
|
|
4672
|
+
internalOptions.index = index;
|
|
4673
|
+
documents[docStartIndex + i] = internalDeserialize(bufferData, internalOptions);
|
|
4674
|
+
index = index + size;
|
|
4675
|
+
}
|
|
4676
|
+
return index;
|
|
4677
|
+
}
|
|
4678
|
+
|
|
4679
|
+
var bson = /*#__PURE__*/Object.freeze({
|
|
4680
|
+
__proto__: null,
|
|
4681
|
+
BSONError: BSONError,
|
|
4682
|
+
BSONOffsetError: BSONOffsetError,
|
|
4683
|
+
BSONRegExp: BSONRegExp,
|
|
4684
|
+
BSONRuntimeError: BSONRuntimeError,
|
|
4685
|
+
BSONSymbol: BSONSymbol,
|
|
4686
|
+
BSONType: BSONType,
|
|
4687
|
+
BSONValue: BSONValue,
|
|
4688
|
+
BSONVersionError: BSONVersionError,
|
|
4689
|
+
Binary: Binary,
|
|
4690
|
+
ByteUtils: ByteUtils,
|
|
4691
|
+
Code: Code,
|
|
4692
|
+
DBRef: DBRef,
|
|
4693
|
+
Decimal128: Decimal128,
|
|
4694
|
+
Double: Double,
|
|
4695
|
+
EJSON: EJSON,
|
|
4696
|
+
Int32: Int32,
|
|
4697
|
+
Long: Long,
|
|
4698
|
+
MaxKey: MaxKey,
|
|
4699
|
+
MinKey: MinKey,
|
|
4700
|
+
NumberUtils: NumberUtils,
|
|
4701
|
+
ObjectId: ObjectId,
|
|
4702
|
+
Timestamp: Timestamp,
|
|
4703
|
+
UUID: UUID,
|
|
4704
|
+
bsonType: bsonType,
|
|
4705
|
+
calculateObjectSize: calculateObjectSize,
|
|
4706
|
+
deserialize: deserialize,
|
|
4707
|
+
deserializeStream: deserializeStream,
|
|
4708
|
+
onDemand: onDemand,
|
|
4709
|
+
serialize: serialize,
|
|
4710
|
+
serializeWithBufferAndIndex: serializeWithBufferAndIndex,
|
|
4711
|
+
setInternalBufferSize: setInternalBufferSize
|
|
4712
|
+
});
|
|
4713
|
+
|
|
4714
|
+
exports.BSON = bson;
|
|
4715
|
+
exports.BSONError = BSONError;
|
|
4716
|
+
exports.BSONOffsetError = BSONOffsetError;
|
|
4717
|
+
exports.BSONRegExp = BSONRegExp;
|
|
4718
|
+
exports.BSONRuntimeError = BSONRuntimeError;
|
|
4719
|
+
exports.BSONSymbol = BSONSymbol;
|
|
4720
|
+
exports.BSONType = BSONType;
|
|
4721
|
+
exports.BSONValue = BSONValue;
|
|
4722
|
+
exports.BSONVersionError = BSONVersionError;
|
|
4723
|
+
exports.Binary = Binary;
|
|
4724
|
+
exports.ByteUtils = ByteUtils;
|
|
4725
|
+
exports.Code = Code;
|
|
4726
|
+
exports.DBRef = DBRef;
|
|
4727
|
+
exports.Decimal128 = Decimal128;
|
|
4728
|
+
exports.Double = Double;
|
|
4729
|
+
exports.EJSON = EJSON;
|
|
4730
|
+
exports.Int32 = Int32;
|
|
4731
|
+
exports.Long = Long;
|
|
4732
|
+
exports.MaxKey = MaxKey;
|
|
4733
|
+
exports.MinKey = MinKey;
|
|
4734
|
+
exports.NumberUtils = NumberUtils;
|
|
4735
|
+
exports.ObjectId = ObjectId;
|
|
4736
|
+
exports.Timestamp = Timestamp;
|
|
4737
|
+
exports.UUID = UUID;
|
|
4738
|
+
exports.bsonType = bsonType;
|
|
4739
|
+
exports.calculateObjectSize = calculateObjectSize;
|
|
4740
|
+
exports.deserialize = deserialize;
|
|
4741
|
+
exports.deserializeStream = deserializeStream;
|
|
4742
|
+
exports.onDemand = onDemand;
|
|
4743
|
+
exports.serialize = serialize;
|
|
4744
|
+
exports.serializeWithBufferAndIndex = serializeWithBufferAndIndex;
|
|
4745
|
+
exports.setInternalBufferSize = setInternalBufferSize;
|
|
4746
|
+
|
|
4747
|
+
return exports;
|
|
4748
|
+
|
|
4749
|
+
})({});
|
|
4750
|
+
//# sourceMappingURL=bson.bundle.js.map
|