@joystick.js/db-canary 0.0.0-canary.2209

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (354) hide show
  1. package/.build/getFilesToBuild.js +26 -0
  2. package/.build/getPlatformSafeFilePath.js +6 -0
  3. package/.build/getPlatformSafePath.js +6 -0
  4. package/.build/index.js +88 -0
  5. package/.build/isWindows.js +3 -0
  6. package/API_KEY +1 -0
  7. package/README.md +1821 -0
  8. package/data/data.mdb +0 -0
  9. package/data/lock.mdb +0 -0
  10. package/dist/client/database.js +1 -0
  11. package/dist/client/index.js +1 -0
  12. package/dist/server/cluster/index.js +1 -0
  13. package/dist/server/cluster/master.js +20 -0
  14. package/dist/server/cluster/worker.js +1 -0
  15. package/dist/server/index.js +1 -0
  16. package/dist/server/lib/api_key_manager.js +9 -0
  17. package/dist/server/lib/auth_manager.js +1 -0
  18. package/dist/server/lib/auto_index_manager.js +1 -0
  19. package/dist/server/lib/backup_manager.js +1 -0
  20. package/dist/server/lib/connection_manager.js +1 -0
  21. package/dist/server/lib/disk_utils.js +2 -0
  22. package/dist/server/lib/http_server.js +405 -0
  23. package/dist/server/lib/index_manager.js +1 -0
  24. package/dist/server/lib/load_settings.js +1 -0
  25. package/dist/server/lib/logger.js +1 -0
  26. package/dist/server/lib/op_types.js +1 -0
  27. package/dist/server/lib/operation_dispatcher.js +1 -0
  28. package/dist/server/lib/operations/admin.js +1 -0
  29. package/dist/server/lib/operations/bulk_write.js +1 -0
  30. package/dist/server/lib/operations/create_index.js +1 -0
  31. package/dist/server/lib/operations/delete_one.js +1 -0
  32. package/dist/server/lib/operations/drop_index.js +1 -0
  33. package/dist/server/lib/operations/find.js +1 -0
  34. package/dist/server/lib/operations/find_one.js +1 -0
  35. package/dist/server/lib/operations/get_indexes.js +1 -0
  36. package/dist/server/lib/operations/insert_one.js +1 -0
  37. package/dist/server/lib/operations/update_one.js +1 -0
  38. package/dist/server/lib/performance_monitor.js +1 -0
  39. package/dist/server/lib/query_engine.js +1 -0
  40. package/dist/server/lib/recovery_manager.js +1 -0
  41. package/dist/server/lib/replication_manager.js +1 -0
  42. package/dist/server/lib/safe_json_parse.js +1 -0
  43. package/dist/server/lib/send_response.js +1 -0
  44. package/dist/server/lib/tcp_protocol.js +1 -0
  45. package/dist/server/lib/write_forwarder.js +1 -0
  46. package/dist/server/lib/write_queue.js +1 -0
  47. package/increment_version.js +3 -0
  48. package/logs/.013e15b54597d05db4b4b53ecc37b10c92a72927-audit.json +20 -0
  49. package/logs/.02de550a67ea0f5961faa2dfd458a4d06f59ebd1-audit.json +20 -0
  50. package/logs/.03494ba24eb3c72214b4068a77d54b8993bee651-audit.json +20 -0
  51. package/logs/.06309ec60b339be1259a7993dd09c732f8907fbc-audit.json +20 -0
  52. package/logs/.0663a04dcfa17285661e5e1b8cfa51f41523b210-audit.json +20 -0
  53. package/logs/.0f06e6c4c9b824622729e13927587479e5060391-audit.json +20 -0
  54. package/logs/.16ccf58682ecb22b3e3ec63f0da1b7fe9be56528-audit.json +20 -0
  55. package/logs/.1fa1a5d02f496474b1ab473524c65c984146a9ad-audit.json +20 -0
  56. package/logs/.2223c0ae3bea6f0d62c62b1d319cc8634856abb7-audit.json +20 -0
  57. package/logs/.23dc79ffda3e083665e6f5993f59397adcbf4a46-audit.json +20 -0
  58. package/logs/.28104f49b03906b189eefd1cd462cb46c3c0af22-audit.json +20 -0
  59. package/logs/.29cdbf13808abe6a0ce70ee2f2efdd680ce3fd8e-audit.json +20 -0
  60. package/logs/.2a9889afd071f77f41f5170d08703a0afca866b7-audit.json +20 -0
  61. package/logs/.2acec3d1940a2bbed487528b703ee5948959a599-audit.json +20 -0
  62. package/logs/.2fb60ff326338c02bfedbcd0e936444e4a216750-audit.json +20 -0
  63. package/logs/.318fc7a19530d76a345f030f7cad00dda15300e7-audit.json +20 -0
  64. package/logs/.3cf27043e19085f908cedc7701e6d013463208ee-audit.json +25 -0
  65. package/logs/.3d90d785415817fc443402843b7c95f8371adc9b-audit.json +20 -0
  66. package/logs/.4074bca620375f72966fc52dfd439577727671e5-audit.json +20 -0
  67. package/logs/.40eecf018417ea80a70ea8ec7a3cc9406bc6334b-audit.json +20 -0
  68. package/logs/.50e974f1ef7c365fca6a1251b2e2c2252914cb5e-audit.json +20 -0
  69. package/logs/.52cb7d9e4223cf26ba36006ac26b949a97c7923c-audit.json +20 -0
  70. package/logs/.54befcdb84c15aad980705a31bcc9f555c3577ab-audit.json +20 -0
  71. package/logs/.57dfb70e22eddb84db2e3c0ceeefac5c0b9baffa-audit.json +20 -0
  72. package/logs/.5f0b24705a1eaad4eca4968f2d86f91b3f9be683-audit.json +20 -0
  73. package/logs/.61ba98fdda7db58576b382fee07904e5db1169d6-audit.json +20 -0
  74. package/logs/.6235017727ef6b199d569a99d6aa8c8e80a1b475-audit.json +20 -0
  75. package/logs/.63db16193699219489d218a1ddea5dde3750cae4-audit.json +20 -0
  76. package/logs/.64fb67dfe14149c9eef728d79bf30a54da809c60-audit.json +20 -0
  77. package/logs/.669137453368987c1f311b5345342527afb54e50-audit.json +20 -0
  78. package/logs/.7a71f8c89ea28ae266d356aeff6306e876a30fbb-audit.json +20 -0
  79. package/logs/.7afbaa90fe9dc3a7d682676f9bb79f9a1b1fd9a6-audit.json +20 -0
  80. package/logs/.7ca29e322cd05327035de850099e7610864f2347-audit.json +20 -0
  81. package/logs/.83335ab3347e449dae03455a110aaf7f120d4802-audit.json +20 -0
  82. package/logs/.8c2487b5fd445d2c8e5c483c80b9fa99bbf1ca58-audit.json +20 -0
  83. package/logs/.8c8b9dc386922c9f3b4c13251af7052aac1d24c0-audit.json +20 -0
  84. package/logs/.8d6155d94640c4863301ae0fee5e4e7372a21446-audit.json +20 -0
  85. package/logs/.944a3119a243deea7c8270d5d9e582bb1d0eaa10-audit.json +20 -0
  86. package/logs/.9816a845c30fb2909f3b26a23eeb3538ebcad5db-audit.json +20 -0
  87. package/logs/.9dc08784e38b865488177c26d4af5934555e0323-audit.json +20 -0
  88. package/logs/.9dd27d2e0e454ac0a37600206d1cac5493b0d7ee-audit.json +20 -0
  89. package/logs/.a3d486feeac7654c59b547de96600e8849a06d4f-audit.json +20 -0
  90. package/logs/.a5b811f4def22250f86cc18870d7c4573625df22-audit.json +20 -0
  91. package/logs/.a61648eb5f830e0b6f508ac35e4f8f629d2ad4c7-audit.json +20 -0
  92. package/logs/.a89016d507045771b4b5a65656944a9c0f1e528b-audit.json +20 -0
  93. package/logs/.a99bee160a1c590be959af46bacc02724803f691-audit.json +20 -0
  94. package/logs/.ada7906d6243fd7da802f03d86c4ae5dd9df6236-audit.json +20 -0
  95. package/logs/.b518339ee942143b6af983af167f5bbb6983b4de-audit.json +20 -0
  96. package/logs/.b51b124b166d53c9519017856ea610d61d65fabe-audit.json +20 -0
  97. package/logs/.b7a6aee19f58e55633d5e4a3709041c47dfff975-audit.json +20 -0
  98. package/logs/.bd7a8a6ba9c55d557a4867ab53f02e3ec2e1553d-audit.json +20 -0
  99. package/logs/.c1435dafe453b169d6392b25065f3cf4ab6fbb21-audit.json +20 -0
  100. package/logs/.c17e1ce043109f77dc2f0e2aa290a9d1ed842c03-audit.json +20 -0
  101. package/logs/.ca62637ce9540e5a38a2fbedb2115febb6ad308a-audit.json +15 -0
  102. package/logs/.ccee67b9c176967f8977071409a41f5cb5cd6ad4-audit.json +20 -0
  103. package/logs/.db24043417ea79a6f14cd947476399e53930b48d-audit.json +20 -0
  104. package/logs/.e0f12acccb57829f5f33712bb2e2607ecd808147-audit.json +20 -0
  105. package/logs/.e9b6cc33d0bbd2e644c4e2bf44d177f850016557-audit.json +20 -0
  106. package/logs/.f15291d434808e3bdca7963ccd2e73893be027e6-audit.json +20 -0
  107. package/logs/.f4bdf9e21ef84f8a3fae3ffb32bbc39275991351-audit.json +15 -0
  108. package/logs/.fbac3aefac1e81b4230df5aa50667cb90d51024f-audit.json +20 -0
  109. package/logs/.fcfd495c0a9169db243f4a4f21878ee02b76413c-audit.json +20 -0
  110. package/logs/admin-2025-09-12.log +580 -0
  111. package/logs/admin-2025-09-15.log +283 -0
  112. package/logs/admin-error-2025-09-12.log +22 -0
  113. package/logs/admin-error-2025-09-15.log +10 -0
  114. package/logs/api_key_manager-2025-09-12.log +658 -0
  115. package/logs/api_key_manager-2025-09-15.log +295 -0
  116. package/logs/api_key_manager-error-2025-09-12.log +0 -0
  117. package/logs/api_key_manager-error-2025-09-15.log +0 -0
  118. package/logs/auth_manager-2025-09-12.log +4432 -0
  119. package/logs/auth_manager-2025-09-15.log +2000 -0
  120. package/logs/auth_manager-error-2025-09-12.log +11 -0
  121. package/logs/auth_manager-error-2025-09-15.log +5 -0
  122. package/logs/auto_index_manager-2025-09-12.log +84 -0
  123. package/logs/auto_index_manager-2025-09-15.log +45 -0
  124. package/logs/auto_index_manager-error-2025-09-12.log +6 -0
  125. package/logs/auto_index_manager-error-2025-09-15.log +0 -0
  126. package/logs/backup_manager-2025-09-12.log +198 -0
  127. package/logs/backup_manager-2025-09-15.log +90 -0
  128. package/logs/backup_manager-error-2025-09-12.log +198 -0
  129. package/logs/backup_manager-error-2025-09-15.log +90 -0
  130. package/logs/bulk_write-2025-09-12.log +66 -0
  131. package/logs/bulk_write-2025-09-15.log +38 -0
  132. package/logs/bulk_write-error-2025-09-12.log +0 -0
  133. package/logs/bulk_write-error-2025-09-15.log +0 -0
  134. package/logs/connection_manager-2025-09-12.log +2412 -0
  135. package/logs/connection_manager-2025-09-15.log +1132 -0
  136. package/logs/connection_manager-error-2025-09-12.log +0 -0
  137. package/logs/connection_manager-error-2025-09-15.log +0 -0
  138. package/logs/create_index-2025-09-12.log +302 -0
  139. package/logs/create_index-2025-09-15.log +158 -0
  140. package/logs/create_index-error-2025-09-12.log +30 -0
  141. package/logs/create_index-error-2025-09-15.log +13 -0
  142. package/logs/delete_one-2025-09-12.log +73 -0
  143. package/logs/delete_one-2025-09-15.log +43 -0
  144. package/logs/delete_one-error-2025-09-12.log +0 -0
  145. package/logs/delete_one-error-2025-09-15.log +0 -0
  146. package/logs/disk_utils-2025-09-12.log +4954 -0
  147. package/logs/disk_utils-2025-09-15.log +2446 -0
  148. package/logs/disk_utils-error-2025-09-12.log +0 -0
  149. package/logs/disk_utils-error-2025-09-15.log +0 -0
  150. package/logs/drop_index-2025-09-12.log +41 -0
  151. package/logs/drop_index-2025-09-15.log +23 -0
  152. package/logs/drop_index-error-2025-09-12.log +11 -0
  153. package/logs/drop_index-error-2025-09-15.log +5 -0
  154. package/logs/find-2025-09-12.log +1050 -0
  155. package/logs/find-2025-09-15.log +592 -0
  156. package/logs/find-error-2025-09-12.log +1 -0
  157. package/logs/find-error-2025-09-15.log +0 -0
  158. package/logs/find_one-2025-09-12.log +425 -0
  159. package/logs/find_one-2025-09-15.log +264 -0
  160. package/logs/find_one-error-2025-09-12.log +5 -0
  161. package/logs/find_one-error-2025-09-15.log +0 -0
  162. package/logs/get_indexes-2025-09-12.log +84 -0
  163. package/logs/get_indexes-2025-09-15.log +56 -0
  164. package/logs/get_indexes-error-2025-09-12.log +6 -0
  165. package/logs/get_indexes-error-2025-09-15.log +0 -0
  166. package/logs/http_server-2025-09-12.log +2772 -0
  167. package/logs/http_server-2025-09-15.log +1276 -0
  168. package/logs/http_server-error-2025-09-12.log +212 -0
  169. package/logs/http_server-error-2025-09-15.log +44 -0
  170. package/logs/index_manager-2025-09-12.log +5031 -0
  171. package/logs/index_manager-2025-09-15.log +2909 -0
  172. package/logs/index_manager-error-2025-09-12.log +80 -0
  173. package/logs/index_manager-error-2025-09-15.log +38 -0
  174. package/logs/insert_one-2025-09-12.log +2181 -0
  175. package/logs/insert_one-2025-09-15.log +1293 -0
  176. package/logs/insert_one-error-2025-09-12.log +0 -0
  177. package/logs/insert_one-error-2025-09-15.log +0 -0
  178. package/logs/master-2025-09-12.log +1882 -0
  179. package/logs/master-2025-09-15.log +910 -0
  180. package/logs/master-error-2025-09-12.log +80 -0
  181. package/logs/master-error-2025-09-15.log +0 -0
  182. package/logs/operation_dispatcher-2025-09-12.log +751 -0
  183. package/logs/operation_dispatcher-2025-09-15.log +359 -0
  184. package/logs/operation_dispatcher-error-2025-09-12.log +33 -0
  185. package/logs/operation_dispatcher-error-2025-09-15.log +11 -0
  186. package/logs/performance_monitor-2025-09-12.log +14889 -0
  187. package/logs/performance_monitor-2025-09-15.log +6803 -0
  188. package/logs/performance_monitor-error-2025-09-12.log +0 -0
  189. package/logs/performance_monitor-error-2025-09-15.log +0 -0
  190. package/logs/query_engine-2025-09-12.log +5310 -0
  191. package/logs/query_engine-2025-09-15.log +2639 -0
  192. package/logs/query_engine-error-2025-09-12.log +0 -0
  193. package/logs/query_engine-error-2025-09-15.log +0 -0
  194. package/logs/recovery_manager-2025-09-12.log +462 -0
  195. package/logs/recovery_manager-2025-09-15.log +210 -0
  196. package/logs/recovery_manager-error-2025-09-12.log +22 -0
  197. package/logs/recovery_manager-error-2025-09-15.log +10 -0
  198. package/logs/replication-2025-09-12.log +1923 -0
  199. package/logs/replication-2025-09-15.log +917 -0
  200. package/logs/replication-error-2025-09-12.log +33 -0
  201. package/logs/replication-error-2025-09-15.log +15 -0
  202. package/logs/server-2025-09-12.log +2601 -0
  203. package/logs/server-2025-09-15.log +1191 -0
  204. package/logs/server-error-2025-09-12.log +0 -0
  205. package/logs/server-error-2025-09-15.log +0 -0
  206. package/logs/tcp_protocol-2025-09-12.log +22 -0
  207. package/logs/tcp_protocol-2025-09-15.log +10 -0
  208. package/logs/tcp_protocol-error-2025-09-12.log +22 -0
  209. package/logs/tcp_protocol-error-2025-09-15.log +10 -0
  210. package/logs/test-2025-09-12.log +0 -0
  211. package/logs/test-2025-09-15.log +0 -0
  212. package/logs/test-error-2025-09-12.log +0 -0
  213. package/logs/test-error-2025-09-15.log +0 -0
  214. package/logs/update_one-2025-09-12.log +173 -0
  215. package/logs/update_one-2025-09-15.log +118 -0
  216. package/logs/update_one-error-2025-09-12.log +0 -0
  217. package/logs/update_one-error-2025-09-15.log +0 -0
  218. package/logs/worker-2025-09-12.log +1457 -0
  219. package/logs/worker-2025-09-15.log +695 -0
  220. package/logs/worker-error-2025-09-12.log +0 -0
  221. package/logs/worker-error-2025-09-15.log +0 -0
  222. package/logs/write_forwarder-2025-09-12.log +1956 -0
  223. package/logs/write_forwarder-2025-09-15.log +932 -0
  224. package/logs/write_forwarder-error-2025-09-12.log +66 -0
  225. package/logs/write_forwarder-error-2025-09-15.log +30 -0
  226. package/logs/write_queue-2025-09-12.log +612 -0
  227. package/logs/write_queue-2025-09-15.log +301 -0
  228. package/logs/write_queue-error-2025-09-12.log +184 -0
  229. package/logs/write_queue-error-2025-09-15.log +83 -0
  230. package/package.json +48 -0
  231. package/prompts/01-core-infrastructure.md +56 -0
  232. package/prompts/02-secondary-indexing.md +65 -0
  233. package/prompts/03-write-serialization.md +63 -0
  234. package/prompts/04-enhanced-authentication.md +75 -0
  235. package/prompts/05-comprehensive-admin-operations.md +75 -0
  236. package/prompts/06-backup-and-restore-system.md +106 -0
  237. package/prompts/07-production-safety-features.md +107 -0
  238. package/prompts/08-tcp-client-library.md +121 -0
  239. package/prompts/09-api-method-chaining.md +134 -0
  240. package/prompts/10-automatic-index-creation.md +223 -0
  241. package/prompts/11-operation-naming-consistency.md +268 -0
  242. package/prompts/12-tcp-replication-system.md +333 -0
  243. package/prompts/13-master-read-write-operations.md +57 -0
  244. package/prompts/14-index-upsert-operations.md +68 -0
  245. package/prompts/15-client-api-return-types.md +81 -0
  246. package/prompts/16-server-setup-ui.md +97 -0
  247. package/prompts/17-emergency-password-change.md +108 -0
  248. package/prompts/18-joystick-framework-integration.md +116 -0
  249. package/prompts/19-api-key-authentication-system.md +137 -0
  250. package/prompts/20-configurable-server-port.md +105 -0
  251. package/prompts/21-multi-database-support.md +161 -0
  252. package/prompts/FULL_TEXT_SEARCH.md +293 -0
  253. package/prompts/PROMPTS.md +158 -0
  254. package/prompts/README.md +221 -0
  255. package/prompts/TYPESCRIPT_GENERATION.md +179 -0
  256. package/src/client/database.js +166 -0
  257. package/src/client/index.js +752 -0
  258. package/src/server/cluster/index.js +53 -0
  259. package/src/server/cluster/master.js +774 -0
  260. package/src/server/cluster/worker.js +537 -0
  261. package/src/server/index.js +540 -0
  262. package/src/server/lib/api_key_manager.js +473 -0
  263. package/src/server/lib/auth_manager.js +375 -0
  264. package/src/server/lib/auto_index_manager.js +681 -0
  265. package/src/server/lib/backup_manager.js +650 -0
  266. package/src/server/lib/connection_manager.js +218 -0
  267. package/src/server/lib/disk_utils.js +118 -0
  268. package/src/server/lib/http_server.js +1165 -0
  269. package/src/server/lib/index_manager.js +756 -0
  270. package/src/server/lib/load_settings.js +143 -0
  271. package/src/server/lib/logger.js +135 -0
  272. package/src/server/lib/op_types.js +29 -0
  273. package/src/server/lib/operation_dispatcher.js +268 -0
  274. package/src/server/lib/operations/admin.js +808 -0
  275. package/src/server/lib/operations/bulk_write.js +367 -0
  276. package/src/server/lib/operations/create_index.js +68 -0
  277. package/src/server/lib/operations/delete_one.js +114 -0
  278. package/src/server/lib/operations/drop_index.js +58 -0
  279. package/src/server/lib/operations/find.js +340 -0
  280. package/src/server/lib/operations/find_one.js +319 -0
  281. package/src/server/lib/operations/get_indexes.js +52 -0
  282. package/src/server/lib/operations/insert_one.js +113 -0
  283. package/src/server/lib/operations/update_one.js +225 -0
  284. package/src/server/lib/performance_monitor.js +313 -0
  285. package/src/server/lib/query_engine.js +243 -0
  286. package/src/server/lib/recovery_manager.js +388 -0
  287. package/src/server/lib/replication_manager.js +727 -0
  288. package/src/server/lib/safe_json_parse.js +21 -0
  289. package/src/server/lib/send_response.js +47 -0
  290. package/src/server/lib/tcp_protocol.js +130 -0
  291. package/src/server/lib/write_forwarder.js +636 -0
  292. package/src/server/lib/write_queue.js +335 -0
  293. package/test_data/data.mdb +0 -0
  294. package/test_data/lock.mdb +0 -0
  295. package/tests/client/index.test.js +1232 -0
  296. package/tests/server/cluster/cluster.test.js +248 -0
  297. package/tests/server/cluster/master_read_write_operations.test.js +577 -0
  298. package/tests/server/index.test.js +651 -0
  299. package/tests/server/integration/authentication_integration.test.js +294 -0
  300. package/tests/server/integration/auto_indexing_integration.test.js +268 -0
  301. package/tests/server/integration/backup_integration.test.js +513 -0
  302. package/tests/server/integration/indexing_integration.test.js +126 -0
  303. package/tests/server/integration/production_safety_integration.test.js +358 -0
  304. package/tests/server/integration/replication_integration.test.js +227 -0
  305. package/tests/server/integration/write_serialization_integration.test.js +246 -0
  306. package/tests/server/lib/api_key_manager.test.js +516 -0
  307. package/tests/server/lib/auth_manager.test.js +317 -0
  308. package/tests/server/lib/auto_index_manager.test.js +275 -0
  309. package/tests/server/lib/backup_manager.test.js +238 -0
  310. package/tests/server/lib/connection_manager.test.js +221 -0
  311. package/tests/server/lib/disk_utils.test.js +63 -0
  312. package/tests/server/lib/http_server.test.js +389 -0
  313. package/tests/server/lib/index_manager.test.js +301 -0
  314. package/tests/server/lib/load_settings.test.js +107 -0
  315. package/tests/server/lib/load_settings_port_config.test.js +243 -0
  316. package/tests/server/lib/logger.test.js +282 -0
  317. package/tests/server/lib/operations/admin.test.js +638 -0
  318. package/tests/server/lib/operations/bulk_write.test.js +128 -0
  319. package/tests/server/lib/operations/create_index.test.js +138 -0
  320. package/tests/server/lib/operations/delete_one.test.js +52 -0
  321. package/tests/server/lib/operations/drop_index.test.js +72 -0
  322. package/tests/server/lib/operations/find.test.js +93 -0
  323. package/tests/server/lib/operations/find_one.test.js +91 -0
  324. package/tests/server/lib/operations/get_indexes.test.js +87 -0
  325. package/tests/server/lib/operations/insert_one.test.js +42 -0
  326. package/tests/server/lib/operations/update_one.test.js +89 -0
  327. package/tests/server/lib/performance_monitor.test.js +185 -0
  328. package/tests/server/lib/query_engine.test.js +46 -0
  329. package/tests/server/lib/recovery_manager.test.js +414 -0
  330. package/tests/server/lib/replication_manager.test.js +202 -0
  331. package/tests/server/lib/safe_json_parse.test.js +45 -0
  332. package/tests/server/lib/send_response.test.js +155 -0
  333. package/tests/server/lib/tcp_protocol.test.js +169 -0
  334. package/tests/server/lib/write_forwarder.test.js +258 -0
  335. package/tests/server/lib/write_queue.test.js +255 -0
  336. package/tsconfig.json +30 -0
  337. package/types/client/index.d.ts +447 -0
  338. package/types/server/cluster/index.d.ts +28 -0
  339. package/types/server/cluster/master.d.ts +115 -0
  340. package/types/server/cluster/worker.d.ts +1 -0
  341. package/types/server/lib/auth_manager.d.ts +13 -0
  342. package/types/server/lib/backup_manager.d.ts +43 -0
  343. package/types/server/lib/connection_manager.d.ts +15 -0
  344. package/types/server/lib/disk_utils.d.ts +3 -0
  345. package/types/server/lib/index_manager.d.ts +24 -0
  346. package/types/server/lib/load_settings.d.ts +4 -0
  347. package/types/server/lib/logger.d.ts +44 -0
  348. package/types/server/lib/op_types.d.ts +6 -0
  349. package/types/server/lib/performance_monitor.d.ts +68 -0
  350. package/types/server/lib/query_engine.d.ts +10 -0
  351. package/types/server/lib/safe_json_parse.d.ts +7 -0
  352. package/types/server/lib/send_response.d.ts +3 -0
  353. package/types/server/lib/tcp_protocol.d.ts +12 -0
  354. package/types/server/lib/write_queue.d.ts +2 -0
@@ -0,0 +1,134 @@
1
+ # Task 9: API Method Chaining Enhancement
2
+
3
+ ## Overview
4
+ Update the client API to chain methods off of `collection()` instead of passing collection names as the first argument. This will provide a more intuitive and fluent API interface.
5
+
6
+ ## Current State
7
+ The current API requires passing collection names as the first argument:
8
+ ```javascript
9
+ await client.insert_one('users', { name: 'John' });
10
+ await client.find_one('users', { name: 'John' });
11
+ await client.update_one('users', { name: 'John' }, { $set: { age: 30 } });
12
+ ```
13
+
14
+ ## Target State
15
+ The new API should allow method chaining off a collection reference:
16
+ ```javascript
17
+ await client.collection('users').insert_one({ name: 'John' });
18
+ await client.collection('users').find_one({ name: 'John' });
19
+ await client.collection('users').update_one({ name: 'John' }, { $set: { age: 30 } });
20
+ ```
21
+
22
+ ## Requirements
23
+
24
+ ### 1. Collection Method
25
+ - Add `collection(name)` method to client that returns a collection interface
26
+ - Collection interface should provide all CRUD operations
27
+ - Maintain backward compatibility with existing API
28
+
29
+ ### 2. Collection Interface Methods
30
+ The collection interface should provide:
31
+ - `insert_one(document, options)`
32
+ - `find_one(filter, options)`
33
+ - `find(filter, options)`
34
+ - `update_one(filter, update, options)`
35
+ - `delete_one(filter, options)`
36
+ - `bulk_write(operations, options)`
37
+ - `create_index(field, options)`
38
+ - `drop_index(field)`
39
+ - `get_indexes()`
40
+
41
+ ### 3. Backward Compatibility
42
+ - Keep existing methods working (don't break existing code)
43
+ - Both APIs should work simultaneously
44
+ - No deprecation warnings initially
45
+
46
+ ### 4. Implementation Details
47
+ - Collection interface should reuse existing client methods internally
48
+ - No duplication of protocol logic
49
+ - Maintain same error handling and response formats
50
+ - Support all existing options and parameters
51
+
52
+ ## Technical Specifications
53
+
54
+ ### Collection Class Structure
55
+ ```javascript
56
+ class Collection {
57
+ constructor(client, collection_name) {
58
+ this.client = client;
59
+ this.collection_name = collection_name;
60
+ }
61
+
62
+ async insert_one(document, options = {}) {
63
+ return this.client.insert_one(this.collection_name, document, options);
64
+ }
65
+
66
+ // ... other methods
67
+ }
68
+ ```
69
+
70
+ ### Client Integration
71
+ ```javascript
72
+ // In client class
73
+ collection(name) {
74
+ return new Collection(this, name);
75
+ }
76
+ ```
77
+
78
+ ## Testing Requirements
79
+
80
+ ### Unit Tests
81
+ - Test collection method returns proper interface
82
+ - Test all collection methods delegate correctly
83
+ - Test error handling propagation
84
+ - Test options passing
85
+
86
+ ### Integration Tests
87
+ - Test both old and new API styles work
88
+ - Test complex operations with method chaining
89
+ - Test error scenarios with chained methods
90
+ - Test performance impact (should be minimal)
91
+
92
+ ### Backward Compatibility Tests
93
+ - Ensure all existing tests continue to pass
94
+ - Test mixed usage of both API styles
95
+ - Verify no breaking changes
96
+
97
+ ## Implementation Steps
98
+
99
+ 1. **Create Collection Class**
100
+ - Implement collection interface class
101
+ - Add all required methods that delegate to client
102
+
103
+ 2. **Update Client Class**
104
+ - Add `collection(name)` method
105
+ - Ensure proper instantiation of Collection class
106
+
107
+ 3. **Update Type Definitions**
108
+ - Add TypeScript definitions for Collection class
109
+ - Update client interface to include collection method
110
+
111
+ 4. **Add Tests**
112
+ - Comprehensive test suite for new API
113
+ - Backward compatibility verification tests
114
+
115
+ 5. **Update Documentation**
116
+ - Update README.md with new API examples
117
+ - Add migration guide for users wanting to switch
118
+
119
+ ## Success Criteria
120
+
121
+ - [ ] Collection method returns functional interface
122
+ - [ ] All CRUD operations work through collection interface
123
+ - [ ] Existing API continues to work unchanged
124
+ - [ ] All existing tests pass
125
+ - [ ] New comprehensive test suite passes
126
+ - [ ] TypeScript definitions updated
127
+ - [ ] Documentation updated with examples
128
+
129
+ ## Notes
130
+
131
+ - This change improves developer experience without breaking existing code
132
+ - The fluent interface is more intuitive and follows modern API design patterns
133
+ - Implementation should be lightweight with minimal performance overhead
134
+ - Consider adding IDE autocomplete benefits through proper TypeScript definitions
@@ -0,0 +1,223 @@
1
+ # Task 10: Automatic Index Creation
2
+
3
+ ## Overview
4
+ Implement automatic index creation based on query patterns to optimize database performance without requiring manual index management. The system should intelligently create indexes for frequently queried fields.
5
+
6
+ ## Current State
7
+ - Indexes must be created manually using `create_index()`
8
+ - No automatic optimization based on query patterns
9
+ - Users must anticipate which fields need indexing
10
+ - Performance degrades on unindexed queries
11
+
12
+ ## Target State
13
+ - Automatic index creation based on query frequency and patterns
14
+ - Configurable thresholds for automatic index creation
15
+ - Smart index recommendations and creation
16
+ - Minimal performance impact from monitoring
17
+
18
+ ## Requirements
19
+
20
+ ### 1. Query Pattern Monitoring
21
+ - Track query patterns and field usage frequency
22
+ - Monitor query performance metrics
23
+ - Identify slow queries that would benefit from indexes
24
+ - Store query statistics in memory with configurable retention
25
+
26
+ ### 2. Automatic Index Creation Logic
27
+ - Create indexes automatically when query frequency exceeds threshold
28
+ - Consider query performance impact (slow queries get priority)
29
+ - Avoid creating redundant or unnecessary indexes
30
+ - Respect maximum index limits per collection
31
+
32
+ ### 3. Configuration Options
33
+ - Enable/disable automatic indexing globally
34
+ - Configure frequency thresholds for index creation
35
+ - Set performance thresholds (query time) for index creation
36
+ - Configure maximum automatic indexes per collection
37
+ - Whitelist/blacklist fields for automatic indexing
38
+
39
+ ### 4. Index Management
40
+ - Track automatically created indexes separately from manual ones
41
+ - Provide ability to remove automatic indexes
42
+ - Monitor index usage and remove unused automatic indexes
43
+ - Prevent automatic removal of manually created indexes
44
+
45
+ ## Technical Specifications
46
+
47
+ ### Query Monitoring Structure
48
+ ```javascript
49
+ const query_stats = {
50
+ collection_name: {
51
+ field_name: {
52
+ query_count: 0,
53
+ total_time_ms: 0,
54
+ avg_time_ms: 0,
55
+ last_queried: Date,
56
+ slow_query_count: 0
57
+ }
58
+ }
59
+ };
60
+ ```
61
+
62
+ ### Configuration Schema
63
+ ```json
64
+ {
65
+ "auto_indexing": {
66
+ "enabled": true,
67
+ "frequency_threshold": 100,
68
+ "performance_threshold_ms": 50,
69
+ "max_auto_indexes_per_collection": 10,
70
+ "monitoring_window_hours": 24,
71
+ "cleanup_unused_after_hours": 168,
72
+ "excluded_fields": ["_id", "created_at"],
73
+ "included_collections": ["*"],
74
+ "excluded_collections": []
75
+ }
76
+ }
77
+ ```
78
+
79
+ ### Auto Index Metadata
80
+ ```javascript
81
+ const auto_index_metadata = {
82
+ collection_name: {
83
+ field_name: {
84
+ created_at: Date,
85
+ query_count_at_creation: 0,
86
+ avg_performance_improvement_ms: 0,
87
+ last_used: Date,
88
+ usage_count: 0,
89
+ auto_created: true
90
+ }
91
+ }
92
+ };
93
+ ```
94
+
95
+ ## Implementation Details
96
+
97
+ ### 1. Query Interceptor
98
+ - Intercept all find operations to collect statistics
99
+ - Measure query execution time
100
+ - Track field usage in query filters
101
+ - Update query statistics in real-time
102
+
103
+ ### 2. Index Decision Engine
104
+ - Analyze query statistics periodically
105
+ - Apply thresholds to determine index candidates
106
+ - Check for existing indexes to avoid duplicates
107
+ - Create indexes asynchronously to avoid blocking queries
108
+
109
+ ### 3. Index Lifecycle Management
110
+ - Track index usage after creation
111
+ - Monitor performance improvements
112
+ - Remove unused automatic indexes after configured period
113
+ - Provide admin interface for index management
114
+
115
+ ### 4. Performance Considerations
116
+ - Minimal overhead for query monitoring
117
+ - Asynchronous index creation
118
+ - Configurable monitoring granularity
119
+ - Memory-efficient statistics storage
120
+
121
+ ## Testing Requirements
122
+
123
+ ### Unit Tests
124
+ - Query statistics collection accuracy
125
+ - Index decision logic with various thresholds
126
+ - Configuration validation and defaults
127
+ - Index metadata management
128
+
129
+ ### Integration Tests
130
+ - End-to-end automatic index creation flow
131
+ - Performance improvement verification
132
+ - Index cleanup and removal
133
+ - Configuration changes during runtime
134
+
135
+ ### Performance Tests
136
+ - Monitoring overhead measurement
137
+ - Index creation impact on concurrent operations
138
+ - Memory usage with large query statistics
139
+ - Cleanup performance with many automatic indexes
140
+
141
+ ## Implementation Steps
142
+
143
+ 1. **Query Monitoring Infrastructure**
144
+ - Add query interceptor to track field usage
145
+ - Implement statistics collection and storage
146
+ - Add performance timing measurements
147
+
148
+ 2. **Configuration System**
149
+ - Add auto-indexing configuration to settings
150
+ - Implement configuration validation
151
+ - Add runtime configuration updates
152
+
153
+ 3. **Index Decision Engine**
154
+ - Implement threshold-based decision logic
155
+ - Add index candidate evaluation
156
+ - Create asynchronous index creation system
157
+
158
+ 4. **Index Lifecycle Management**
159
+ - Track automatic vs manual indexes
160
+ - Implement usage monitoring
161
+ - Add cleanup for unused indexes
162
+
163
+ 5. **Admin Interface**
164
+ - Add endpoints for viewing auto-index status
165
+ - Provide manual control over automatic indexes
166
+ - Add query statistics viewing
167
+
168
+ 6. **Testing and Optimization**
169
+ - Comprehensive test suite
170
+ - Performance optimization
171
+ - Memory usage optimization
172
+
173
+ ## API Extensions
174
+
175
+ ### New Admin Operations
176
+ ```javascript
177
+ // Get auto-indexing statistics
178
+ await client.get_auto_index_stats();
179
+
180
+ // Get query statistics
181
+ await client.get_query_stats(collection_name);
182
+
183
+ // Force index evaluation
184
+ await client.evaluate_auto_indexes(collection_name);
185
+
186
+ // Remove automatic indexes
187
+ await client.remove_auto_indexes(collection_name, field_names);
188
+
189
+ // Configure auto-indexing
190
+ await client.configure_auto_indexing(config);
191
+ ```
192
+
193
+ ### Configuration Updates
194
+ ```javascript
195
+ // Enable/disable auto-indexing
196
+ await client.update_settings({
197
+ auto_indexing: {
198
+ enabled: true,
199
+ frequency_threshold: 50
200
+ }
201
+ });
202
+ ```
203
+
204
+ ## Success Criteria
205
+
206
+ - [ ] Query patterns are accurately monitored
207
+ - [ ] Indexes are automatically created based on thresholds
208
+ - [ ] Performance improvements are measurable
209
+ - [ ] Configuration system works correctly
210
+ - [ ] Unused automatic indexes are cleaned up
211
+ - [ ] Admin interface provides visibility and control
212
+ - [ ] Minimal performance overhead from monitoring
213
+ - [ ] All existing tests continue to pass
214
+ - [ ] Comprehensive test coverage for new features
215
+
216
+ ## Notes
217
+
218
+ - Start with conservative thresholds to avoid over-indexing
219
+ - Consider field cardinality when creating indexes (avoid low-cardinality fields)
220
+ - Monitor memory usage of query statistics
221
+ - Provide clear documentation on configuration options
222
+ - Consider adding machine learning for more intelligent index decisions in future versions
223
+ - Ensure automatic indexes don't interfere with manual index management
@@ -0,0 +1,268 @@
1
+ # Task 11: Operation Naming Consistency
2
+
3
+ ## Overview
4
+ Standardize the operation object structure to use snake_case naming (like `insert_one`) instead of camelCase (like `insertOne`) for consistency across the entire codebase and API. This task assumes Task 9 has been completed and only the chained API exists.
5
+
6
+ ## Current State (After Task 9)
7
+ - Only chained API exists: `client.collection('users').insert_one()`
8
+ - Traditional API has been removed/deprecated
9
+ - Mixed naming conventions still exist in operation objects
10
+ - Bulk operations use camelCase (`insertOne`, `updateOne`, `deleteOne`)
11
+ - Client methods use snake_case (`insert_one`, `update_one`, `delete_one`)
12
+ - Inconsistency creates confusion and maintenance issues
13
+
14
+ ## Target State
15
+ - Consistent snake_case naming throughout the entire system
16
+ - All operation objects use snake_case field names
17
+ - Protocol messages use snake_case consistently
18
+ - Chained API uses consistent naming in all operations
19
+
20
+ ## Requirements
21
+
22
+ ### 1. Operation Object Structure Updates
23
+ - Change all camelCase operation names to snake_case
24
+ - Update bulk_write operation structures for chained API
25
+ - Maintain backward compatibility during transition
26
+ - Update all internal operation handling
27
+
28
+ ### 2. Protocol Message Consistency
29
+ - Ensure all TCP protocol messages use snake_case
30
+ - Update message serialization/deserialization
31
+ - Maintain protocol version compatibility
32
+ - Update operation type constants
33
+
34
+ ### 3. Chained API Consistency
35
+ - Ensure collection interface uses snake_case consistently
36
+ - Update bulk operation structures for chained API
37
+ - Align all collection methods with naming convention
38
+ - Update TypeScript definitions for collection interface
39
+
40
+ ## Technical Specifications
41
+
42
+ ### Current Chained API (After Task 9, Mixed Naming)
43
+ ```javascript
44
+ // Collection methods (consistent snake_case)
45
+ await client.collection('users').insert_one(document);
46
+ await client.collection('users').update_one(filter, update);
47
+ await client.collection('users').delete_one(filter);
48
+
49
+ // Bulk operations (inconsistent camelCase)
50
+ await client.collection('users').bulk_write([
51
+ { insertOne: { document: { name: 'John' } } }, // camelCase - inconsistent
52
+ { updateOne: { filter: {}, update: {} } }, // camelCase - inconsistent
53
+ { deleteOne: { filter: {} } } // camelCase - inconsistent
54
+ ]);
55
+ ```
56
+
57
+ ### Target Chained API (Consistent snake_case)
58
+ ```javascript
59
+ // Collection methods (consistent snake_case)
60
+ await client.collection('users').insert_one(document);
61
+ await client.collection('users').update_one(filter, update);
62
+ await client.collection('users').delete_one(filter);
63
+
64
+ // Bulk operations (consistent snake_case)
65
+ await client.collection('users').bulk_write([
66
+ { insert_one: { document: { name: 'John' } } }, // snake_case - consistent
67
+ { update_one: { filter: {}, update: {} } }, // snake_case - consistent
68
+ { delete_one: { filter: {} } } // snake_case - consistent
69
+ ]);
70
+ ```
71
+
72
+ ### Collection Interface (From Task 9)
73
+ ```javascript
74
+ class Collection {
75
+ constructor(client, collection_name) {
76
+ this.client = client;
77
+ this.collection_name = collection_name;
78
+ }
79
+
80
+ // CRUD methods (already snake_case)
81
+ async insert_one(document, options = {}) {
82
+ return this.client.insert_one(this.collection_name, document, options);
83
+ }
84
+
85
+ async find_one(filter, options = {}) {
86
+ return this.client.find_one(this.collection_name, filter, options);
87
+ }
88
+
89
+ async find(filter, options = {}) {
90
+ return this.client.find(this.collection_name, filter, options);
91
+ }
92
+
93
+ async update_one(filter, update, options = {}) {
94
+ return this.client.update_one(this.collection_name, filter, update, options);
95
+ }
96
+
97
+ async delete_one(filter, options = {}) {
98
+ return this.client.delete_one(this.collection_name, filter, options);
99
+ }
100
+
101
+ // Bulk operations
102
+ async bulk_write(operations, options = {}) {
103
+ return this.client.bulk_write(this.collection_name, operations, options);
104
+ }
105
+
106
+ // Index methods (already snake_case)
107
+ async create_index(field, options = {}) {
108
+ return this.client.create_index(this.collection_name, field, options);
109
+ }
110
+
111
+ async drop_index(field) {
112
+ return this.client.drop_index(this.collection_name, field);
113
+ }
114
+
115
+ async get_indexes() {
116
+ return this.client.get_indexes(this.collection_name);
117
+ }
118
+ }
119
+ ```
120
+
121
+ ### Operation Type Constants
122
+ ```javascript
123
+ // Current (mixed)
124
+ const OP_TYPES = {
125
+ INSERT_ONE: 'insert_one',
126
+ BULK_WRITE: 'bulk_write',
127
+ // But bulk operations use: insertOne, updateOne, deleteOne
128
+ };
129
+
130
+ // Target (consistent)
131
+ const OP_TYPES = {
132
+ INSERT_ONE: 'insert_one',
133
+ UPDATE_ONE: 'update_one',
134
+ DELETE_ONE: 'delete_one',
135
+ BULK_WRITE: 'bulk_write'
136
+ };
137
+ ```
138
+
139
+ ## Implementation Details
140
+
141
+ ### 1. Operation Handler Updates
142
+ - Update bulk_write operation parsing for chained API
143
+ - Modify operation type recognition to handle snake_case
144
+ - Update all operation processors
145
+ - Ensure error messages use consistent naming
146
+
147
+ ### 2. Protocol Message Updates
148
+ - Update TCP protocol message structures
149
+ - Modify serialization/deserialization logic
150
+ - Update protocol documentation
151
+ - Maintain version compatibility
152
+
153
+ ### 3. Backward Compatibility Layer
154
+ - Support both naming conventions temporarily
155
+ - Add deprecation warnings for camelCase operations
156
+ - Plan migration timeline for complete snake_case adoption
157
+
158
+ ## Testing Requirements
159
+
160
+ ### Unit Tests
161
+ - Test operation name recognition with both conventions
162
+ - Verify bulk operation parsing with new naming
163
+ - Test protocol message serialization/deserialization
164
+ - Validate error handling with consistent naming
165
+
166
+ ### Integration Tests
167
+ - Test bulk operations with new naming through collection interface
168
+ - Verify client-server communication with updated protocol
169
+ - Test backward compatibility with old naming
170
+ - Test all collection methods with consistent naming
171
+
172
+ ### Collection Interface Tests
173
+ - Test bulk_write method with new operation naming
174
+ - Verify error handling in collection interface
175
+ - Validate TypeScript definitions for collection interface
176
+
177
+ ## Implementation Steps
178
+
179
+ 1. **Update Operation Constants**
180
+ - Standardize all operation type constants to snake_case
181
+ - Update operation type mappings
182
+ - Add backward compatibility mappings
183
+
184
+ 2. **Update Bulk Operation Parsing**
185
+ - Modify bulk_write operation parser
186
+ - Add support for both naming conventions
187
+ - Add deprecation warnings for camelCase
188
+
189
+ 3. **Update Protocol Messages**
190
+ - Ensure all protocol messages use snake_case
191
+ - Update message validation
192
+ - Maintain protocol version compatibility
193
+
194
+ 4. **Update TypeScript Definitions**
195
+ - Update Collection interface definitions
196
+ - Ensure consistent naming in type definitions
197
+
198
+ 5. **Add Migration Support**
199
+ - Create operation name translation utilities
200
+ - Add configuration for naming convention preference
201
+ - Implement gradual migration path
202
+
203
+ ## API Examples
204
+
205
+ ### Basic Collection Operations (Already Consistent)
206
+ ```javascript
207
+ const users = client.collection('users');
208
+
209
+ await users.insert_one({ name: 'John', age: 30 });
210
+ const user = await users.find_one({ name: 'John' });
211
+ await users.update_one({ name: 'John' }, { $set: { age: 31 } });
212
+ await users.delete_one({ name: 'John' });
213
+ ```
214
+
215
+ ### Bulk Operations (Updated for Consistency)
216
+ ```javascript
217
+ const users = client.collection('users');
218
+
219
+ // Before (inconsistent)
220
+ await users.bulk_write([
221
+ { insertOne: { document: { name: 'John' } } },
222
+ { updateOne: { filter: { name: 'Jane' }, update: { $set: { age: 25 } } } },
223
+ { deleteOne: { filter: { name: 'Bob' } } }
224
+ ]);
225
+
226
+ // After (consistent)
227
+ await users.bulk_write([
228
+ { insert_one: { document: { name: 'John' } } },
229
+ { update_one: { filter: { name: 'Jane' }, update: { $set: { age: 25 } } } },
230
+ { delete_one: { filter: { name: 'Bob' } } }
231
+ ]);
232
+ ```
233
+
234
+ ### Index Operations (Already Consistent)
235
+ ```javascript
236
+ const users = client.collection('users');
237
+
238
+ await users.create_index('email', { unique: true });
239
+ const indexes = await users.get_indexes();
240
+ await users.drop_index('email');
241
+ ```
242
+
243
+ ## Success Criteria
244
+
245
+ - [ ] All operation objects use consistent snake_case naming
246
+ - [ ] Protocol messages use snake_case throughout
247
+ - [ ] Collection interface maintains snake_case consistency
248
+ - [ ] Backward compatibility works during transition
249
+ - [ ] Deprecation warnings are properly displayed
250
+ - [ ] All existing tests pass with new naming
251
+ - [ ] New tests cover both naming conventions
252
+ - [ ] TypeScript definitions are updated for collection interface
253
+ - [ ] Documentation reflects consistent naming
254
+ - [ ] Migration path is clear and functional
255
+
256
+ ## Dependencies
257
+
258
+ - **Task 9**: API Method Chaining Enhancement must be completed first
259
+ - This task assumes only the chained API exists after Task 9
260
+
261
+ ## Notes
262
+
263
+ - This change improves code consistency and maintainability
264
+ - The transition should be gradual to avoid breaking existing applications
265
+ - Clear communication about the change is essential
266
+ - Consider providing automated migration tools for applications using old bulk operation naming
267
+ - Monitor community feedback during the transition period
268
+ - Ensure all team members understand the new naming convention