constants.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. export const SYSTEM_NAMESPACE_COLLECTION = 'system.namespaces';
  2. export const SYSTEM_INDEX_COLLECTION = 'system.indexes';
  3. export const SYSTEM_PROFILE_COLLECTION = 'system.profile';
  4. export const SYSTEM_USER_COLLECTION = 'system.users';
  5. export const SYSTEM_COMMAND_COLLECTION = '$cmd';
  6. export const SYSTEM_JS_COLLECTION = 'system.js';
  7. // events
  8. export const ERROR = 'error' as const;
  9. export const TIMEOUT = 'timeout' as const;
  10. export const CLOSE = 'close' as const;
  11. export const OPEN = 'open' as const;
  12. export const CONNECT = 'connect' as const;
  13. export const CLOSED = 'closed' as const;
  14. export const ENDED = 'ended' as const;
  15. export const MESSAGE = 'message' as const;
  16. export const PINNED = 'pinned' as const;
  17. export const UNPINNED = 'unpinned' as const;
  18. export const DESCRIPTION_RECEIVED = 'descriptionReceived';
  19. export const SERVER_OPENING = 'serverOpening' as const;
  20. export const SERVER_CLOSED = 'serverClosed' as const;
  21. export const SERVER_DESCRIPTION_CHANGED = 'serverDescriptionChanged' as const;
  22. export const TOPOLOGY_OPENING = 'topologyOpening' as const;
  23. export const TOPOLOGY_CLOSED = 'topologyClosed' as const;
  24. export const TOPOLOGY_DESCRIPTION_CHANGED = 'topologyDescriptionChanged' as const;
  25. /** @internal */
  26. export const CONNECTION_POOL_CREATED = 'connectionPoolCreated' as const;
  27. /** @internal */
  28. export const CONNECTION_POOL_CLOSED = 'connectionPoolClosed' as const;
  29. /** @internal */
  30. export const CONNECTION_POOL_CLEARED = 'connectionPoolCleared' as const;
  31. /** @internal */
  32. export const CONNECTION_POOL_READY = 'connectionPoolReady' as const;
  33. /** @internal */
  34. export const CONNECTION_CREATED = 'connectionCreated' as const;
  35. /** @internal */
  36. export const CONNECTION_READY = 'connectionReady' as const;
  37. /** @internal */
  38. export const CONNECTION_CLOSED = 'connectionClosed' as const;
  39. /** @internal */
  40. export const CONNECTION_CHECK_OUT_STARTED = 'connectionCheckOutStarted' as const;
  41. /** @internal */
  42. export const CONNECTION_CHECK_OUT_FAILED = 'connectionCheckOutFailed' as const;
  43. /** @internal */
  44. export const CONNECTION_CHECKED_OUT = 'connectionCheckedOut' as const;
  45. /** @internal */
  46. export const CONNECTION_CHECKED_IN = 'connectionCheckedIn' as const;
  47. export const CLUSTER_TIME_RECEIVED = 'clusterTimeReceived' as const;
  48. export const COMMAND_STARTED = 'commandStarted' as const;
  49. export const COMMAND_SUCCEEDED = 'commandSucceeded' as const;
  50. export const COMMAND_FAILED = 'commandFailed' as const;
  51. export const SERVER_HEARTBEAT_STARTED = 'serverHeartbeatStarted' as const;
  52. export const SERVER_HEARTBEAT_SUCCEEDED = 'serverHeartbeatSucceeded' as const;
  53. export const SERVER_HEARTBEAT_FAILED = 'serverHeartbeatFailed' as const;
  54. export const RESPONSE = 'response' as const;
  55. export const MORE = 'more' as const;
  56. export const INIT = 'init' as const;
  57. export const CHANGE = 'change' as const;
  58. export const END = 'end' as const;
  59. export const RESUME_TOKEN_CHANGED = 'resumeTokenChanged' as const;
  60. /** @public */
  61. export const HEARTBEAT_EVENTS = Object.freeze([
  62. SERVER_HEARTBEAT_STARTED,
  63. SERVER_HEARTBEAT_SUCCEEDED,
  64. SERVER_HEARTBEAT_FAILED
  65. ] as const);
  66. /** @public */
  67. export const CMAP_EVENTS = Object.freeze([
  68. CONNECTION_POOL_CREATED,
  69. CONNECTION_POOL_READY,
  70. CONNECTION_POOL_CLEARED,
  71. CONNECTION_POOL_CLOSED,
  72. CONNECTION_CREATED,
  73. CONNECTION_READY,
  74. CONNECTION_CLOSED,
  75. CONNECTION_CHECK_OUT_STARTED,
  76. CONNECTION_CHECK_OUT_FAILED,
  77. CONNECTION_CHECKED_OUT,
  78. CONNECTION_CHECKED_IN
  79. ] as const);
  80. /** @public */
  81. export const TOPOLOGY_EVENTS = Object.freeze([
  82. SERVER_OPENING,
  83. SERVER_CLOSED,
  84. SERVER_DESCRIPTION_CHANGED,
  85. TOPOLOGY_OPENING,
  86. TOPOLOGY_CLOSED,
  87. TOPOLOGY_DESCRIPTION_CHANGED,
  88. ERROR,
  89. TIMEOUT,
  90. CLOSE
  91. ] as const);
  92. /** @public */
  93. export const APM_EVENTS = Object.freeze([
  94. COMMAND_STARTED,
  95. COMMAND_SUCCEEDED,
  96. COMMAND_FAILED
  97. ] as const);
  98. /**
  99. * All events that we relay to the `Topology`
  100. * @internal
  101. */
  102. export const SERVER_RELAY_EVENTS = Object.freeze([
  103. SERVER_HEARTBEAT_STARTED,
  104. SERVER_HEARTBEAT_SUCCEEDED,
  105. SERVER_HEARTBEAT_FAILED,
  106. COMMAND_STARTED,
  107. COMMAND_SUCCEEDED,
  108. COMMAND_FAILED,
  109. ...CMAP_EVENTS
  110. ] as const);
  111. /**
  112. * All events we listen to from `Server` instances, but do not forward to the client
  113. * @internal
  114. */
  115. export const LOCAL_SERVER_EVENTS = Object.freeze([
  116. CONNECT,
  117. DESCRIPTION_RECEIVED,
  118. CLOSED,
  119. ENDED
  120. ] as const);
  121. /** @public */
  122. export const MONGO_CLIENT_EVENTS = Object.freeze([
  123. ...CMAP_EVENTS,
  124. ...APM_EVENTS,
  125. ...TOPOLOGY_EVENTS,
  126. ...HEARTBEAT_EVENTS
  127. ] as const);
  128. /**
  129. * @internal
  130. * The legacy hello command that was deprecated in MongoDB 5.0.
  131. */
  132. export const LEGACY_HELLO_COMMAND = 'ismaster';
  133. /**
  134. * @internal
  135. * The legacy hello command that was deprecated in MongoDB 5.0.
  136. */
  137. export const LEGACY_HELLO_COMMAND_CAMEL_CASE = 'isMaster';