constants.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /** @internal */
  2. export const BSON_MAJOR_VERSION = 5 as const;
  3. /** @internal */
  4. export const BSON_INT32_MAX = 0x7fffffff;
  5. /** @internal */
  6. export const BSON_INT32_MIN = -0x80000000;
  7. /** @internal */
  8. export const BSON_INT64_MAX = Math.pow(2, 63) - 1;
  9. /** @internal */
  10. export const BSON_INT64_MIN = -Math.pow(2, 63);
  11. /**
  12. * Any integer up to 2^53 can be precisely represented by a double.
  13. * @internal
  14. */
  15. export const JS_INT_MAX = Math.pow(2, 53);
  16. /**
  17. * Any integer down to -2^53 can be precisely represented by a double.
  18. * @internal
  19. */
  20. export const JS_INT_MIN = -Math.pow(2, 53);
  21. /** Number BSON Type @internal */
  22. export const BSON_DATA_NUMBER = 1;
  23. /** String BSON Type @internal */
  24. export const BSON_DATA_STRING = 2;
  25. /** Object BSON Type @internal */
  26. export const BSON_DATA_OBJECT = 3;
  27. /** Array BSON Type @internal */
  28. export const BSON_DATA_ARRAY = 4;
  29. /** Binary BSON Type @internal */
  30. export const BSON_DATA_BINARY = 5;
  31. /** Binary BSON Type @internal */
  32. export const BSON_DATA_UNDEFINED = 6;
  33. /** ObjectId BSON Type @internal */
  34. export const BSON_DATA_OID = 7;
  35. /** Boolean BSON Type @internal */
  36. export const BSON_DATA_BOOLEAN = 8;
  37. /** Date BSON Type @internal */
  38. export const BSON_DATA_DATE = 9;
  39. /** null BSON Type @internal */
  40. export const BSON_DATA_NULL = 10;
  41. /** RegExp BSON Type @internal */
  42. export const BSON_DATA_REGEXP = 11;
  43. /** Code BSON Type @internal */
  44. export const BSON_DATA_DBPOINTER = 12;
  45. /** Code BSON Type @internal */
  46. export const BSON_DATA_CODE = 13;
  47. /** Symbol BSON Type @internal */
  48. export const BSON_DATA_SYMBOL = 14;
  49. /** Code with Scope BSON Type @internal */
  50. export const BSON_DATA_CODE_W_SCOPE = 15;
  51. /** 32 bit Integer BSON Type @internal */
  52. export const BSON_DATA_INT = 16;
  53. /** Timestamp BSON Type @internal */
  54. export const BSON_DATA_TIMESTAMP = 17;
  55. /** Long BSON Type @internal */
  56. export const BSON_DATA_LONG = 18;
  57. /** Decimal128 BSON Type @internal */
  58. export const BSON_DATA_DECIMAL128 = 19;
  59. /** MinKey BSON Type @internal */
  60. export const BSON_DATA_MIN_KEY = 0xff;
  61. /** MaxKey BSON Type @internal */
  62. export const BSON_DATA_MAX_KEY = 0x7f;
  63. /** Binary Default Type @internal */
  64. export const BSON_BINARY_SUBTYPE_DEFAULT = 0;
  65. /** Binary Function Type @internal */
  66. export const BSON_BINARY_SUBTYPE_FUNCTION = 1;
  67. /** Binary Byte Array Type @internal */
  68. export const BSON_BINARY_SUBTYPE_BYTE_ARRAY = 2;
  69. /** Binary Deprecated UUID Type @deprecated Please use BSON_BINARY_SUBTYPE_UUID_NEW @internal */
  70. export const BSON_BINARY_SUBTYPE_UUID = 3;
  71. /** Binary UUID Type @internal */
  72. export const BSON_BINARY_SUBTYPE_UUID_NEW = 4;
  73. /** Binary MD5 Type @internal */
  74. export const BSON_BINARY_SUBTYPE_MD5 = 5;
  75. /** Encrypted BSON type @internal */
  76. export const BSON_BINARY_SUBTYPE_ENCRYPTED = 6;
  77. /** Column BSON type @internal */
  78. export const BSON_BINARY_SUBTYPE_COLUMN = 7;
  79. /** Binary User Defined Type @internal */
  80. export const BSON_BINARY_SUBTYPE_USER_DEFINED = 128;
  81. /** @public */
  82. export 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. } as const);
  105. /** @public */
  106. export type BSONType = (typeof BSONType)[keyof typeof BSONType];