hide-a-bed 5.2.7 → 6.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (363) hide show
  1. package/.prettierrc +7 -0
  2. package/README.md +270 -218
  3. package/dist/cjs/index.cjs +1952 -0
  4. package/dist/esm/index.mjs +1898 -0
  5. package/docs/.nojekyll +1 -0
  6. package/docs/assets/hierarchy.js +1 -0
  7. package/docs/assets/highlight.css +113 -0
  8. package/docs/assets/icons.js +18 -0
  9. package/docs/assets/icons.svg +1 -0
  10. package/docs/assets/main.js +60 -0
  11. package/docs/assets/navigation.js +1 -0
  12. package/docs/assets/search.js +1 -0
  13. package/docs/assets/style.css +1633 -0
  14. package/docs/classes/QueryBuilder.html +42 -0
  15. package/docs/functions/bindConfig.html +4 -0
  16. package/docs/functions/bulkGet.html +14 -0
  17. package/docs/functions/bulkGetDictionary.html +10 -0
  18. package/docs/functions/bulkRemove.html +12 -0
  19. package/docs/functions/bulkRemoveMap.html +11 -0
  20. package/docs/functions/bulkSave.html +10 -0
  21. package/docs/functions/bulkSaveTransaction.html +23 -0
  22. package/docs/functions/createLock.html +7 -0
  23. package/docs/functions/createQuery.html +1 -0
  24. package/docs/functions/get.html +1 -0
  25. package/docs/functions/getAtRev.html +1 -0
  26. package/docs/functions/getDBInfo.html +10 -0
  27. package/docs/functions/patch.html +8 -0
  28. package/docs/functions/patchDangerously.html +9 -0
  29. package/docs/functions/put.html +1 -0
  30. package/docs/functions/query.html +15 -0
  31. package/docs/functions/queryStream.html +6 -0
  32. package/docs/functions/remove.html +1 -0
  33. package/docs/functions/removeLock.html +6 -0
  34. package/docs/functions/watchDocs.html +9 -0
  35. package/docs/functions/withRetry.html +6 -0
  36. package/docs/hierarchy.html +1 -0
  37. package/docs/index.html +483 -0
  38. package/docs/interfaces/NetworkError.html +6 -0
  39. package/docs/interfaces/NotFoundError.html +10 -0
  40. package/docs/interfaces/RetryOptions.html +10 -0
  41. package/docs/interfaces/RetryableError.html +10 -0
  42. package/docs/interfaces/StandardSchemaV1.FailureResult.html +4 -0
  43. package/docs/interfaces/StandardSchemaV1.Issue.html +6 -0
  44. package/docs/interfaces/StandardSchemaV1.Options.html +3 -0
  45. package/docs/interfaces/StandardSchemaV1.PathSegment.html +4 -0
  46. package/docs/interfaces/StandardSchemaV1.Props.html +10 -0
  47. package/docs/interfaces/StandardSchemaV1.SuccessResult.html +6 -0
  48. package/docs/interfaces/StandardSchemaV1.Types.html +6 -0
  49. package/docs/interfaces/StandardSchemaV1.html +4 -0
  50. package/docs/modules/StandardSchemaV1.html +1 -0
  51. package/docs/modules.html +1 -0
  52. package/docs/types/BoundInstance.html +1 -0
  53. package/docs/types/BulkGetBound.html +2 -0
  54. package/docs/types/BulkGetDictionaryBound.html +1 -0
  55. package/docs/types/BulkGetDictionaryOptions.html +2 -0
  56. package/docs/types/BulkGetDictionaryResult.html +3 -0
  57. package/docs/types/BulkGetOptions.html +3 -0
  58. package/docs/types/BulkGetResponse.html +1 -0
  59. package/docs/types/CouchConfig-1.html +1 -0
  60. package/docs/types/CouchConfig.html +1 -0
  61. package/docs/types/CouchConfigInput.html +1 -0
  62. package/docs/types/CouchDoc-1.html +1 -0
  63. package/docs/types/CouchDoc.html +2 -0
  64. package/docs/types/CouchDocInput.html +2 -0
  65. package/docs/types/GetAtRevBound.html +1 -0
  66. package/docs/types/GetBound.html +1 -0
  67. package/docs/types/GetOptions.html +2 -0
  68. package/docs/types/LockDoc-1.html +1 -0
  69. package/docs/types/LockDoc.html +1 -0
  70. package/docs/types/LockOptions-1.html +1 -0
  71. package/docs/types/LockOptions.html +1 -0
  72. package/docs/types/LockOptionsInput.html +1 -0
  73. package/docs/types/OnInvalidDocAction.html +1 -0
  74. package/docs/types/OnRow.html +1 -0
  75. package/docs/types/QueryBound.html +1 -0
  76. package/docs/types/SimpleViewOptions-1.html +1 -0
  77. package/docs/types/SimpleViewOptions.html +1 -0
  78. package/docs/types/StandardSchemaV1.InferInput.html +2 -0
  79. package/docs/types/StandardSchemaV1.InferOutput.html +2 -0
  80. package/docs/types/StandardSchemaV1.Result.html +2 -0
  81. package/docs/types/ViewQueryResponse-1.html +1 -0
  82. package/docs/types/ViewQueryResponse.html +2 -0
  83. package/docs/types/ViewQueryResponseValidated.html +2 -0
  84. package/docs/types/ViewRow-1.html +1 -0
  85. package/docs/types/ViewRow.html +2 -0
  86. package/docs/types/ViewRowValidated.html +7 -0
  87. package/docs/types/ViewString.html +1 -0
  88. package/docs/types/WatchOptionsInput.html +1 -0
  89. package/docs/types/WatchOptionsSchema-1.html +1 -0
  90. package/docs/types/WatchOptionsSchema.html +1 -0
  91. package/eslint.config.js +15 -0
  92. package/impl/bindConfig.mts +140 -0
  93. package/impl/bulkGet.mts +256 -0
  94. package/impl/bulkGet.test.mts +159 -0
  95. package/impl/bulkRemove.mts +98 -0
  96. package/impl/bulkRemove.test.mts +102 -0
  97. package/impl/bulkSave.mts +286 -0
  98. package/impl/bulkSave.test.mts +319 -0
  99. package/impl/get.mts +137 -0
  100. package/impl/get.test.mts +114 -0
  101. package/impl/getDBInfo.mts +67 -0
  102. package/impl/getDBInfo.test.mts +62 -0
  103. package/impl/patch.mts +134 -0
  104. package/impl/patch.test.mts +142 -0
  105. package/impl/put.mts +56 -0
  106. package/impl/put.test.mts +114 -0
  107. package/impl/query.mts +224 -0
  108. package/impl/query.test.mts +280 -0
  109. package/impl/remove.mts +65 -0
  110. package/impl/remove.test.mts +82 -0
  111. package/impl/retry.mts +66 -0
  112. package/impl/retry.test.mts +77 -0
  113. package/impl/stream.mts +143 -0
  114. package/impl/stream.test.mts +205 -0
  115. package/impl/sugar/lock.mts +103 -0
  116. package/impl/sugar/lock.test.mts +113 -0
  117. package/impl/sugar/{watch.mjs → watch.mts} +56 -22
  118. package/impl/sugar/watch.test.mts +155 -0
  119. package/impl/utils/errors.mts +130 -0
  120. package/impl/utils/errors.test.mts +58 -0
  121. package/impl/utils/logger.mts +62 -0
  122. package/impl/utils/logger.test.mts +129 -0
  123. package/impl/utils/mergeNeedleOpts.mts +16 -0
  124. package/impl/utils/parseRows.mts +117 -0
  125. package/impl/utils/parseRows.test.mts +183 -0
  126. package/impl/utils/queryBuilder.mts +173 -0
  127. package/impl/utils/queryBuilder.test.mts +83 -0
  128. package/impl/utils/queryString.mts +44 -0
  129. package/impl/utils/queryString.test.mts +53 -0
  130. package/impl/{trackedEmitter.mjs → utils/trackedEmitter.mts} +9 -7
  131. package/impl/utils/transactionErrors.mts +71 -0
  132. package/index.mts +82 -0
  133. package/index.test.mts +415 -0
  134. package/package.json +45 -31
  135. package/schema/config.mts +81 -0
  136. package/schema/couch/couch.input.schema.ts +43 -0
  137. package/schema/couch/couch.output.schema.ts +169 -0
  138. package/schema/sugar/lock.mts +18 -0
  139. package/schema/sugar/watch.mts +14 -0
  140. package/schema/util.mts +8 -0
  141. package/tsconfig.json +10 -4
  142. package/tsdown.config.ts +16 -0
  143. package/typedoc.json +4 -0
  144. package/types/output/eslint.config.d.ts +3 -0
  145. package/types/output/eslint.config.d.ts.map +1 -0
  146. package/types/output/impl/bindConfig.d.mts +174 -0
  147. package/types/output/impl/bindConfig.d.mts.map +1 -0
  148. package/types/output/impl/bulkGet.d.mts +75 -0
  149. package/types/output/impl/bulkGet.d.mts.map +1 -0
  150. package/types/output/impl/bulkGet.test.d.mts +2 -0
  151. package/types/output/impl/bulkGet.test.d.mts.map +1 -0
  152. package/types/output/impl/bulkRemove.d.mts +63 -0
  153. package/types/output/impl/bulkRemove.d.mts.map +1 -0
  154. package/types/output/impl/bulkRemove.test.d.mts +2 -0
  155. package/types/output/impl/bulkRemove.test.d.mts.map +1 -0
  156. package/types/output/impl/bulkSave.d.mts +64 -0
  157. package/types/output/impl/bulkSave.d.mts.map +1 -0
  158. package/types/output/impl/bulkSave.test.d.mts +2 -0
  159. package/types/output/impl/bulkSave.test.d.mts.map +1 -0
  160. package/types/output/impl/get.d.mts +20 -0
  161. package/types/output/impl/get.d.mts.map +1 -0
  162. package/types/output/impl/get.test.d.mts +2 -0
  163. package/types/output/impl/get.test.d.mts.map +1 -0
  164. package/types/output/impl/getDBInfo.d.mts +52 -0
  165. package/types/output/impl/getDBInfo.d.mts.map +1 -0
  166. package/types/output/impl/getDBInfo.test.d.mts +2 -0
  167. package/types/output/impl/getDBInfo.test.d.mts.map +1 -0
  168. package/types/output/impl/patch.d.mts +45 -0
  169. package/types/output/impl/patch.d.mts.map +1 -0
  170. package/types/output/impl/patch.test.d.mts +2 -0
  171. package/types/output/impl/patch.test.d.mts.map +1 -0
  172. package/types/output/impl/put.d.mts +5 -0
  173. package/types/output/impl/put.d.mts.map +1 -0
  174. package/types/output/impl/put.test.d.mts +2 -0
  175. package/types/output/impl/put.test.d.mts.map +1 -0
  176. package/types/output/impl/query.d.mts +47 -0
  177. package/types/output/impl/query.d.mts.map +1 -0
  178. package/types/output/impl/query.test.d.mts +2 -0
  179. package/types/output/impl/query.test.d.mts.map +1 -0
  180. package/types/output/impl/remove.d.mts +9 -0
  181. package/types/output/impl/remove.d.mts.map +1 -0
  182. package/types/output/impl/remove.test.d.mts +2 -0
  183. package/types/output/impl/remove.test.d.mts.map +1 -0
  184. package/types/output/impl/retry.d.mts +32 -0
  185. package/types/output/impl/retry.d.mts.map +1 -0
  186. package/types/output/impl/retry.test.d.mts +2 -0
  187. package/types/output/impl/retry.test.d.mts.map +1 -0
  188. package/types/output/impl/stream.d.mts +13 -0
  189. package/types/output/impl/stream.d.mts.map +1 -0
  190. package/types/output/impl/stream.test.d.mts +2 -0
  191. package/types/output/impl/stream.test.d.mts.map +1 -0
  192. package/types/output/impl/sugar/lock.d.mts +24 -0
  193. package/types/output/impl/sugar/lock.d.mts.map +1 -0
  194. package/types/output/impl/sugar/lock.test.d.mts +2 -0
  195. package/types/output/impl/sugar/lock.test.d.mts.map +1 -0
  196. package/types/output/impl/sugar/watch.d.mts +21 -0
  197. package/types/output/impl/sugar/watch.d.mts.map +1 -0
  198. package/types/output/impl/sugar/watch.test.d.mts +2 -0
  199. package/types/output/impl/sugar/watch.test.d.mts.map +1 -0
  200. package/types/output/impl/utils/errors.d.mts +78 -0
  201. package/types/output/impl/utils/errors.d.mts.map +1 -0
  202. package/types/output/impl/utils/errors.test.d.mts +2 -0
  203. package/types/output/impl/utils/errors.test.d.mts.map +1 -0
  204. package/types/output/impl/utils/logger.d.mts +11 -0
  205. package/types/output/impl/utils/logger.d.mts.map +1 -0
  206. package/types/output/impl/utils/logger.test.d.mts +2 -0
  207. package/types/output/impl/utils/logger.test.d.mts.map +1 -0
  208. package/types/output/impl/utils/mergeNeedleOpts.d.mts +53 -0
  209. package/types/output/impl/utils/mergeNeedleOpts.d.mts.map +1 -0
  210. package/types/output/impl/utils/parseRows.d.mts +15 -0
  211. package/types/output/impl/utils/parseRows.d.mts.map +1 -0
  212. package/types/output/impl/utils/parseRows.test.d.mts +2 -0
  213. package/types/output/impl/utils/parseRows.test.d.mts.map +1 -0
  214. package/types/output/impl/utils/queryBuilder.d.mts +68 -0
  215. package/types/output/impl/utils/queryBuilder.d.mts.map +1 -0
  216. package/types/output/impl/utils/queryBuilder.test.d.mts +2 -0
  217. package/types/output/impl/utils/queryBuilder.test.d.mts.map +1 -0
  218. package/types/output/impl/utils/queryString.d.mts +9 -0
  219. package/types/output/impl/utils/queryString.d.mts.map +1 -0
  220. package/types/output/impl/utils/queryString.test.d.mts +2 -0
  221. package/types/output/impl/utils/queryString.test.d.mts.map +1 -0
  222. package/types/output/impl/utils/trackedEmitter.d.mts +7 -0
  223. package/types/output/impl/utils/trackedEmitter.d.mts.map +1 -0
  224. package/{impl → types/output/impl/utils}/transactionErrors.d.mts +16 -31
  225. package/types/output/impl/utils/transactionErrors.d.mts.map +1 -0
  226. package/types/output/index.d.mts +32 -0
  227. package/types/output/index.d.mts.map +1 -0
  228. package/types/output/index.test.d.mts +2 -0
  229. package/types/output/index.test.d.mts.map +1 -0
  230. package/types/output/schema/config.d.mts +90 -0
  231. package/types/output/schema/config.d.mts.map +1 -0
  232. package/types/output/schema/couch/couch.input.schema.d.ts +29 -0
  233. package/types/output/schema/couch/couch.input.schema.d.ts.map +1 -0
  234. package/types/output/schema/couch/couch.output.schema.d.ts +113 -0
  235. package/types/output/schema/couch/couch.output.schema.d.ts.map +1 -0
  236. package/types/output/schema/sugar/lock.d.mts +19 -0
  237. package/types/output/schema/sugar/lock.d.mts.map +1 -0
  238. package/types/output/schema/sugar/watch.d.mts +11 -0
  239. package/types/output/schema/sugar/watch.d.mts.map +1 -0
  240. package/types/output/schema/util.d.mts +85 -0
  241. package/types/output/schema/util.d.mts.map +1 -0
  242. package/types/output/tsdown.config.d.ts +3 -0
  243. package/types/output/tsdown.config.d.ts.map +1 -0
  244. package/types/output/types/standard-schema.d.ts +60 -0
  245. package/types/output/types/standard-schema.d.ts.map +1 -0
  246. package/types/standard-schema.ts +76 -0
  247. package/types/utils.d.ts +1 -0
  248. package/cjs/impl/bulk.cjs +0 -275
  249. package/cjs/impl/changes.cjs +0 -67
  250. package/cjs/impl/crud.cjs +0 -127
  251. package/cjs/impl/errors.cjs +0 -75
  252. package/cjs/impl/logger.cjs +0 -70
  253. package/cjs/impl/patch.cjs +0 -95
  254. package/cjs/impl/query.cjs +0 -116
  255. package/cjs/impl/queryBuilder.cjs +0 -163
  256. package/cjs/impl/retry.cjs +0 -55
  257. package/cjs/impl/stream.cjs +0 -121
  258. package/cjs/impl/sugar/lock.cjs +0 -81
  259. package/cjs/impl/sugar/watch.cjs +0 -159
  260. package/cjs/impl/trackedEmitter.cjs +0 -54
  261. package/cjs/impl/transactionErrors.cjs +0 -70
  262. package/cjs/impl/util.cjs +0 -64
  263. package/cjs/index.cjs +0 -132
  264. package/cjs/integration/changes.cjs +0 -76
  265. package/cjs/integration/disconnect-watch.cjs +0 -52
  266. package/cjs/integration/watch.cjs +0 -59
  267. package/cjs/schema/bind.cjs +0 -59
  268. package/cjs/schema/bulk.cjs +0 -92
  269. package/cjs/schema/changes.cjs +0 -68
  270. package/cjs/schema/config.cjs +0 -48
  271. package/cjs/schema/crud.cjs +0 -77
  272. package/cjs/schema/patch.cjs +0 -53
  273. package/cjs/schema/query.cjs +0 -62
  274. package/cjs/schema/stream.cjs +0 -42
  275. package/cjs/schema/sugar/lock.cjs +0 -59
  276. package/cjs/schema/sugar/watch.cjs +0 -42
  277. package/cjs/schema/util.cjs +0 -39
  278. package/config.json +0 -5
  279. package/docs/compiler.png +0 -0
  280. package/dualmode.config.json +0 -11
  281. package/impl/bulk.d.mts +0 -11
  282. package/impl/bulk.d.mts.map +0 -1
  283. package/impl/bulk.mjs +0 -291
  284. package/impl/changes.d.mts +0 -12
  285. package/impl/changes.d.mts.map +0 -1
  286. package/impl/changes.mjs +0 -53
  287. package/impl/crud.d.mts +0 -7
  288. package/impl/crud.d.mts.map +0 -1
  289. package/impl/crud.mjs +0 -108
  290. package/impl/errors.d.mts +0 -43
  291. package/impl/errors.d.mts.map +0 -1
  292. package/impl/errors.mjs +0 -65
  293. package/impl/logger.d.mts +0 -32
  294. package/impl/logger.d.mts.map +0 -1
  295. package/impl/logger.mjs +0 -59
  296. package/impl/patch.d.mts +0 -6
  297. package/impl/patch.d.mts.map +0 -1
  298. package/impl/patch.mjs +0 -88
  299. package/impl/query.d.mts +0 -195
  300. package/impl/query.d.mts.map +0 -1
  301. package/impl/query.mjs +0 -122
  302. package/impl/queryBuilder.d.mts +0 -154
  303. package/impl/queryBuilder.d.mts.map +0 -1
  304. package/impl/queryBuilder.mjs +0 -175
  305. package/impl/retry.d.mts +0 -2
  306. package/impl/retry.d.mts.map +0 -1
  307. package/impl/retry.mjs +0 -39
  308. package/impl/stream.d.mts +0 -3
  309. package/impl/stream.d.mts.map +0 -1
  310. package/impl/stream.mjs +0 -98
  311. package/impl/sugar/lock.d.mts +0 -5
  312. package/impl/sugar/lock.d.mts.map +0 -1
  313. package/impl/sugar/lock.mjs +0 -70
  314. package/impl/sugar/watch.d.mts +0 -34
  315. package/impl/sugar/watch.d.mts.map +0 -1
  316. package/impl/trackedEmitter.d.mts +0 -8
  317. package/impl/trackedEmitter.d.mts.map +0 -1
  318. package/impl/transactionErrors.d.mts.map +0 -1
  319. package/impl/transactionErrors.mjs +0 -47
  320. package/impl/util.d.mts +0 -3
  321. package/impl/util.d.mts.map +0 -1
  322. package/impl/util.mjs +0 -35
  323. package/index.d.mts +0 -80
  324. package/index.d.mts.map +0 -1
  325. package/index.mjs +0 -141
  326. package/integration/changes.mjs +0 -60
  327. package/integration/disconnect-watch.mjs +0 -36
  328. package/integration/watch.mjs +0 -40
  329. package/log.txt +0 -580
  330. package/schema/bind.d.mts +0 -5461
  331. package/schema/bind.d.mts.map +0 -1
  332. package/schema/bind.mjs +0 -43
  333. package/schema/bulk.d.mts +0 -923
  334. package/schema/bulk.d.mts.map +0 -1
  335. package/schema/bulk.mjs +0 -83
  336. package/schema/changes.d.mts +0 -191
  337. package/schema/changes.d.mts.map +0 -1
  338. package/schema/changes.mjs +0 -59
  339. package/schema/config.d.mts +0 -79
  340. package/schema/config.d.mts.map +0 -1
  341. package/schema/config.mjs +0 -26
  342. package/schema/crud.d.mts +0 -491
  343. package/schema/crud.d.mts.map +0 -1
  344. package/schema/crud.mjs +0 -64
  345. package/schema/patch.d.mts +0 -255
  346. package/schema/patch.d.mts.map +0 -1
  347. package/schema/patch.mjs +0 -42
  348. package/schema/query.d.mts +0 -406
  349. package/schema/query.d.mts.map +0 -1
  350. package/schema/query.mjs +0 -45
  351. package/schema/stream.d.mts +0 -211
  352. package/schema/stream.d.mts.map +0 -1
  353. package/schema/stream.mjs +0 -23
  354. package/schema/sugar/lock.d.mts +0 -238
  355. package/schema/sugar/lock.d.mts.map +0 -1
  356. package/schema/sugar/lock.mjs +0 -50
  357. package/schema/sugar/watch.d.mts +0 -127
  358. package/schema/sugar/watch.d.mts.map +0 -1
  359. package/schema/sugar/watch.mjs +0 -29
  360. package/schema/util.d.mts +0 -160
  361. package/schema/util.d.mts.map +0 -1
  362. package/schema/util.mjs +0 -35
  363. package/types/changes-stream.d.ts +0 -11
@@ -1,34 +0,0 @@
1
- export const watchDocs: (args_0: import("zod").objectInputType<{
2
- throwOnGetNotFound: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
3
- couch: import("zod").ZodString;
4
- bindWithRetry: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
5
- maxRetries: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
6
- initialDelay: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
7
- backoffFactor: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
8
- useConsoleLogger: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
9
- logger: import("zod").ZodOptional<import("zod").ZodUnion<[import("zod").ZodObject<{
10
- error: import("zod").ZodOptional<import("zod").ZodFunction<import("zod").ZodTuple<[import("zod").ZodAny], import("zod").ZodUnknown>, import("zod").ZodVoid>>;
11
- warn: import("zod").ZodOptional<import("zod").ZodFunction<import("zod").ZodTuple<[import("zod").ZodAny], import("zod").ZodUnknown>, import("zod").ZodVoid>>;
12
- info: import("zod").ZodOptional<import("zod").ZodFunction<import("zod").ZodTuple<[import("zod").ZodAny], import("zod").ZodUnknown>, import("zod").ZodVoid>>;
13
- debug: import("zod").ZodOptional<import("zod").ZodFunction<import("zod").ZodTuple<[import("zod").ZodAny], import("zod").ZodUnknown>, import("zod").ZodVoid>>;
14
- }, "strip", import("zod").ZodTypeAny, {
15
- error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
16
- warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
17
- info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
18
- debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
19
- }, {
20
- error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
21
- warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
22
- info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
23
- debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
24
- }>, import("zod").ZodFunction<import("zod").ZodTuple<[import("zod").ZodString, import("zod").ZodAny], import("zod").ZodUnknown>, import("zod").ZodVoid>]>>;
25
- _normalizedLogger: import("zod").ZodOptional<import("zod").ZodAny>;
26
- }, import("zod").ZodTypeAny, "passthrough">, args_1: string | string[], args_2: (args_0: any, ...args: unknown[]) => void, args_3: {
27
- include_docs?: boolean | undefined;
28
- }, ...args: unknown[]) => {
29
- on: (event: string, listener: (args_0: any, ...args: unknown[]) => void) => EventEmitter<[never]>;
30
- removeListener: (event: string, listener: (args_0: any, ...args: unknown[]) => void) => EventEmitter<[never]>;
31
- stop: () => void;
32
- };
33
- import { EventEmitter } from 'events';
34
- //# sourceMappingURL=watch.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"watch.d.mts","sourceRoot":"","sources":["watch.mjs"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiJE;6BAxJ2B,QAAQ"}
@@ -1,8 +0,0 @@
1
- export class TrackedEmitter extends EventEmitter<[never]> {
2
- constructor(options: any);
3
- delay: any;
4
- emit(event: any, ...args: any[]): Promise<any>;
5
- }
6
- export function setupEmitter(config: any): any;
7
- import { EventEmitter } from 'events';
8
- //# sourceMappingURL=trackedEmitter.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trackedEmitter.d.mts","sourceRoot":"","sources":["trackedEmitter.mjs"],"names":[],"mappings":"AAEA;IAEE,0BAGC;IADoB,WAA0B;IAG/C,+CAiBC;CACF;AAEM,+CAGN;6BAhC4B,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"transactionErrors.d.mts","sourceRoot":"","sources":["transactionErrors.mjs"],"names":[],"mappings":"AAAA;IACE;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAM7B;IADC,6BAAsB;CAEzB;AAED;IACE;;OAEG;IACH,4BAFW,MAAM,EAAE,EAMlB;IADC,yBAAoC;CAEvC;AAED;IACE;;OAEG;IACH,wBAFW,KAAK,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,GAAC,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAC,IAAI,CAAA;KAAC,CAAC,EAMpH;IADC;aALqB,OAAO,GAAC,IAAI;aAAO,MAAM,GAAC,IAAI;cAAQ,MAAM,GAAC,IAAI;gBAAU,MAAM,GAAC,IAAI;iBAAW,MAAM,GAAC,IAAI;QAKrF;CAE/B;AAED;IACE;;;;OAIG;IACH,qBAJW,MAAM,iBACN,KAAK,mBACL,KAAK,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,GAAC,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAC,IAAI,CAAA;KAAC,CAAC,EAOpH;IAFC,qBAAkC;IAClC;aANqB,OAAO,GAAC,IAAI;aAAO,MAAM,GAAC,IAAI;cAAQ,MAAM,GAAC,IAAI;gBAAU,MAAM,GAAC,IAAI;iBAAW,MAAM,GAAC,IAAI;QAM3E;CAEzC"}
@@ -1,47 +0,0 @@
1
- export class TransactionSetupError extends Error {
2
- /**
3
- * @param {string} message
4
- * @param {Record<string, any>} details
5
- */
6
- constructor (message, details = {}) {
7
- super(message)
8
- this.name = 'TransactionSetupError'
9
- this.details = details
10
- }
11
- }
12
-
13
- export class TransactionVersionConflictError extends Error {
14
- /**
15
- * @param {string[]} conflictingIds
16
- */
17
- constructor (conflictingIds) {
18
- super(`Revision mismatch for documents: ${conflictingIds.join(', ')}`)
19
- this.name = 'TransactionVersionConflictError'
20
- this.conflictingIds = conflictingIds
21
- }
22
- }
23
-
24
- export class TransactionBulkOperationError extends Error {
25
- /**
26
- * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} failedDocs
27
- */
28
- constructor (failedDocs) {
29
- super(`Failed to save documents: ${failedDocs.map(d => d.id).join(', ')}`)
30
- this.name = 'TransactionBulkOperationError'
31
- this.failedDocs = failedDocs
32
- }
33
- }
34
-
35
- export class TransactionRollbackError extends Error {
36
- /**
37
- * @param {string} message
38
- * @param {Error} originalError
39
- * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} rollbackResults
40
- */
41
- constructor (message, originalError, rollbackResults) {
42
- super(message)
43
- this.name = 'TransactionRollbackError'
44
- this.originalError = originalError
45
- this.rollbackResults = rollbackResults
46
- }
47
- }
package/impl/util.d.mts DELETED
@@ -1,3 +0,0 @@
1
- /** @type { import('../schema/util.mjs').GetDBInfoSchema} */
2
- export const getDBInfo: import("../schema/util.mjs").GetDBInfoSchema;
3
- //# sourceMappingURL=util.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.mts","sourceRoot":"","sources":["util.mjs"],"names":[],"mappings":"AAMA,4DAA4D;AAC5D,wBADY,OAAO,oBAAoB,EAAE,eAAe,CA4BtD"}
package/impl/util.mjs DELETED
@@ -1,35 +0,0 @@
1
- // @ts-check
2
- import needle from 'needle'
3
- import { RetryableError, NotFoundError } from './errors.mjs'
4
- import { createLogger } from './logger.mjs'
5
- import { GetDBInfo } from '../schema/util.mjs'
6
-
7
- /** @type { import('../schema/util.mjs').GetDBInfoSchema} */
8
- export const getDBInfo = GetDBInfo.implement(async (config) => {
9
- const logger = createLogger(config)
10
- const url = `${config.couch}`
11
- const opts = {
12
- json: true,
13
- headers: {
14
- 'Content-Type': 'application/json'
15
- }
16
- }
17
- let resp
18
- try {
19
- resp = await needle('get', url, opts)
20
- } catch (err) {
21
- logger.error('Error during put operation:', err)
22
- RetryableError.handleNetworkError(err)
23
- }
24
-
25
- if (!resp) {
26
- logger.error('No response received from put request')
27
- throw new RetryableError('no response', 503)
28
- }
29
- const result = resp.body
30
- if (RetryableError.isRetryableStatusCode(resp.statusCode)) {
31
- logger.warn(`Retryable status code received: ${resp.statusCode}`)
32
- throw new RetryableError(result.reason || 'retryable error', resp.statusCode)
33
- }
34
- return result
35
- })
package/index.d.mts DELETED
@@ -1,80 +0,0 @@
1
- export type DB = z.infer<typeof BindReturns>;
2
- import { get } from './impl/crud.mjs';
3
- import { getAtRev } from './impl/crud.mjs';
4
- import { put } from './impl/crud.mjs';
5
- import { bulkGet } from './impl/bulk.mjs';
6
- import { bulkSave } from './impl/bulk.mjs';
7
- import { query } from './impl/query.mjs';
8
- import { queryStream } from './impl/stream.mjs';
9
- export namespace schema {
10
- export { CouchConfig };
11
- export { SimpleViewQuery };
12
- export { SimpleViewQueryResponse };
13
- export { SimpleViewQueryStream };
14
- export { OnRow };
15
- export { BulkSave };
16
- export { BulkGet };
17
- export { BulkRemove };
18
- export { BulkGetDictionary };
19
- export { BulkSaveTransaction };
20
- export { CouchGet };
21
- export { CouchPut };
22
- export { CouchDoc };
23
- export { CouchDocResponse };
24
- export { Patch };
25
- export { PatchDangerously };
26
- export { CouchGetAtRev };
27
- export { Bind };
28
- export { Lock };
29
- export { WatchDocs };
30
- export { LockOptions };
31
- export { CreateLock };
32
- export { RemoveLock };
33
- export { Changes };
34
- export { ChangesOptions };
35
- export { ChangesResponse };
36
- export { GetDBInfo };
37
- }
38
- import { getDBInfo } from './impl/util.mjs';
39
- import { patch } from './impl/patch.mjs';
40
- import { patchDangerously } from './impl/patch.mjs';
41
- import { bulkRemove } from './impl/bulk.mjs';
42
- import { bulkGetDictionary } from './impl/bulk.mjs';
43
- import { bulkSaveTransaction } from './impl/bulk.mjs';
44
- /** @type { import('./schema/bind.mjs').BindSchema } */
45
- export const bindConfig: import("./schema/bind.mjs").BindSchema;
46
- import { withRetry } from './impl/retry.mjs';
47
- import { createQuery } from './impl/queryBuilder.mjs';
48
- import { createLock } from './impl/sugar/lock.mjs';
49
- import { removeLock } from './impl/sugar/lock.mjs';
50
- import { z } from 'zod';
51
- import { BindReturns } from './schema/bind.mjs';
52
- import { CouchConfig } from './schema/config.mjs';
53
- import { SimpleViewQuery } from './schema/query.mjs';
54
- import { SimpleViewQueryResponse } from './schema/query.mjs';
55
- import { SimpleViewQueryStream } from './schema/stream.mjs';
56
- import { OnRow } from './schema/stream.mjs';
57
- import { BulkSave } from './schema/bulk.mjs';
58
- import { BulkGet } from './schema/bulk.mjs';
59
- import { BulkRemove } from './schema/bulk.mjs';
60
- import { BulkGetDictionary } from './schema/bulk.mjs';
61
- import { BulkSaveTransaction } from './schema/bulk.mjs';
62
- import { CouchGet } from './schema/crud.mjs';
63
- import { CouchPut } from './schema/crud.mjs';
64
- import { CouchDoc } from './schema/crud.mjs';
65
- import { CouchDocResponse } from './schema/crud.mjs';
66
- import { Patch } from './schema/patch.mjs';
67
- import { PatchDangerously } from './schema/patch.mjs';
68
- import { CouchGetAtRev } from './schema/crud.mjs';
69
- import { Bind } from './schema/bind.mjs';
70
- import { Lock } from './schema/sugar/lock.mjs';
71
- import { WatchDocs } from './schema/sugar/watch.mjs';
72
- import { LockOptions } from './schema/sugar/lock.mjs';
73
- import { CreateLock } from './schema/sugar/lock.mjs';
74
- import { RemoveLock } from './schema/sugar/lock.mjs';
75
- import { Changes } from './schema/changes.mjs';
76
- import { ChangesOptions } from './schema/changes.mjs';
77
- import { ChangesResponse } from './schema/changes.mjs';
78
- import { GetDBInfo } from './schema/util.mjs';
79
- export { get, getAtRev, put, bulkGet, bulkSave, query, queryStream, getDBInfo, patch, patchDangerously, bulkRemove, bulkGetDictionary, bulkSaveTransaction, withRetry, createQuery, createLock, removeLock };
80
- //# sourceMappingURL=index.d.mts.map
package/index.d.mts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mjs"],"names":[],"mappings":"iBAmHe,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC;oBAhHP,iBAAiB;yBAAjB,iBAAiB;oBAAjB,iBAAiB;wBADkC,iBAAiB;yBAAjB,iBAAiB;sBAMjF,kBAAkB;4BACZ,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAErB,iBAAiB;sBANH,kBAAkB;iCAAlB,kBAAkB;2BAH4B,iBAAiB;kCAAjB,iBAAiB;oCAAjB,iBAAiB;AAwFvG,uDAAuD;AACvD,yBADY,OAAO,mBAAmB,EAAE,UAAU,CAuBhD;0BArGwB,kBAAkB;4BAFhB,yBAAyB;2BAJd,uBAAuB;2BAAvB,uBAAuB;kBAL5C,KAAK;4BAqBW,mBAAmB;4BARzB,qBAAqB;gCACQ,oBAAoB;wCAApB,oBAAoB;sCAEhC,qBAAqB;sBAArB,qBAAqB;yBAJoB,mBAAmB;wBAAnB,mBAAmB;2BAAnB,mBAAmB;kCAAnB,mBAAmB;oCAAnB,mBAAmB;yBAQ3B,mBAAmB;yBAAnB,mBAAmB;yBAAnB,mBAAmB;iCAAnB,mBAAmB;sBAHzD,oBAAoB;iCAApB,oBAAoB;8BAGkB,mBAAmB;qBAC/D,mBAAmB;qBAHK,yBAAyB;0BACzD,0BAA0B;4BADM,yBAAyB;2BAAzB,yBAAyB;2BAAzB,yBAAyB;wBAH1B,sBAAsB;+BAAtB,sBAAsB;gCAAtB,sBAAsB;0BAOrD,mBAAmB"}
package/index.mjs DELETED
@@ -1,141 +0,0 @@
1
- // @ts-check */
2
- import { z } from 'zod'
3
- import { bulkGet, bulkSave, bulkRemove, bulkGetDictionary, bulkSaveTransaction } from './impl/bulk.mjs'
4
- import { get, put, getAtRev } from './impl/crud.mjs'
5
- import { changes } from './impl/changes.mjs'
6
- import { patch, patchDangerously } from './impl/patch.mjs'
7
- import { createLock, removeLock } from './impl/sugar/lock.mjs'
8
- import { watchDocs } from './impl/sugar/watch.mjs'
9
- import { query } from './impl/query.mjs'
10
- import { queryStream } from './impl/stream.mjs'
11
- import { createQuery } from './impl/queryBuilder.mjs'
12
- import { getDBInfo } from './impl/util.mjs'
13
- import { withRetry } from './impl/retry.mjs'
14
- import { BulkSave, BulkGet, BulkRemove, BulkGetDictionary, BulkSaveTransaction } from './schema/bulk.mjs'
15
- import { CouchConfig } from './schema/config.mjs'
16
- import { SimpleViewQuery, SimpleViewQueryResponse } from './schema/query.mjs'
17
- import { Changes, ChangesOptions, ChangesResponse } from './schema/changes.mjs'
18
- import { SimpleViewQueryStream, OnRow } from './schema/stream.mjs'
19
- import { Patch, PatchDangerously } from './schema/patch.mjs'
20
- import { Lock, LockOptions, CreateLock, RemoveLock } from './schema/sugar/lock.mjs'
21
- import { WatchDocs } from './schema/sugar/watch.mjs'
22
- import { CouchDoc, CouchDocResponse, CouchPut, CouchGet, CouchGetAtRev } from './schema/crud.mjs'
23
- import { Bind, BindReturns } from './schema/bind.mjs'
24
- import { GetDBInfo } from './schema/util.mjs'
25
-
26
- const schema = {
27
- CouchConfig,
28
- SimpleViewQuery,
29
- SimpleViewQueryResponse,
30
- SimpleViewQueryStream,
31
- OnRow,
32
- BulkSave,
33
- BulkGet,
34
- BulkRemove,
35
- BulkGetDictionary,
36
- BulkSaveTransaction,
37
- CouchGet,
38
- CouchPut,
39
- CouchDoc,
40
- CouchDocResponse,
41
- Patch,
42
- PatchDangerously,
43
- CouchGetAtRev,
44
- Bind,
45
- Lock,
46
- WatchDocs,
47
- LockOptions,
48
- CreateLock,
49
- RemoveLock,
50
- Changes,
51
- ChangesOptions,
52
- ChangesResponse,
53
- GetDBInfo
54
- }
55
- /**
56
- * @param {import('./schema/config.mjs').CouchConfigSchema } config
57
- */
58
- function doBind (config) {
59
- // Default retry options
60
- const retryOptions = {
61
- maxRetries: config.maxRetries ?? 10,
62
- initialDelay: config.initialDelay ?? 1000,
63
- backoffFactor: config.backoffFactor ?? 2
64
- }
65
-
66
- // Create the object without the config property first
67
- const result = {
68
- get: config.bindWithRetry ? withRetry(get.bind(null, config), retryOptions) : get.bind(null, config),
69
- getAtRev: config.bindWithRetry ? withRetry(getAtRev.bind(null, config), retryOptions) : getAtRev.bind(null, config),
70
- put: config.bindWithRetry ? withRetry(put.bind(null, config), retryOptions) : put.bind(null, config),
71
- bulkGet: config.bindWithRetry ? withRetry(bulkGet.bind(null, config), retryOptions) : bulkGet.bind(null, config),
72
- bulkSave: config.bindWithRetry ? withRetry(bulkSave.bind(null, config), retryOptions) : bulkSave.bind(null, config),
73
- query: config.bindWithRetry ? withRetry(query.bind(null, config), retryOptions) : query.bind(null, config),
74
- queryStream: config.bindWithRetry ? withRetry(queryStream.bind(null, config), retryOptions) : queryStream.bind(null, config),
75
- // Sugar Methods
76
- patch: config.bindWithRetry ? withRetry(patch.bind(null, config), retryOptions) : patch.bind(null, config),
77
- patchDangerously: patchDangerously.bind(null, config), // patchDangerously not included in retry
78
- bulkRemove: config.bindWithRetry ? withRetry(bulkRemove.bind(null, config), retryOptions) : bulkRemove.bind(null, config),
79
- bulkGetDictionary: config.bindWithRetry ? withRetry(bulkGetDictionary.bind(null, config), retryOptions) : bulkGetDictionary.bind(null, config),
80
- bulkSaveTransaction: bulkSaveTransaction.bind(null, config),
81
- createLock: createLock.bind(null, config),
82
- removeLock: removeLock.bind(null, config),
83
- watchDocs: watchDocs.bind(null, config),
84
- changes: changes.bind(null, config),
85
- getDBInfo: config.bindWithRetry ? withRetry(getDBInfo.bind(null, config), retryOptions) : getDBInfo.bind(null, config)
86
- }
87
-
88
- return result
89
- }
90
-
91
- /** @type { import('./schema/bind.mjs').BindSchema } */
92
- const bindConfig = Bind.implement((
93
- /** @type { import('./schema/config.mjs').CouchConfigSchema } */
94
- config
95
- ) => {
96
- const parsedConfig = CouchConfig.parse(config)
97
-
98
- /** @type { import('./schema/bind.mjs').BindBaseSchema } funcs */
99
- const funcs = doBind(parsedConfig)
100
-
101
- // Add the options function that returns a new bound instance
102
- // this allows the user to override some options
103
- const reconfig = (
104
- /** @type any */
105
- _overrides
106
- ) => {
107
- // override the config and return doBind again
108
- const newConfig = { ...config, ..._overrides }
109
- return bindConfig(newConfig)
110
- }
111
- /** @type { import('./schema/bind.mjs').BindReturnsSchema } */
112
- const all = { ...funcs, options: reconfig }
113
- return all
114
- })
115
-
116
- /** @typedef { z.infer<typeof BindReturns> } DB */
117
-
118
- export {
119
- get,
120
- getAtRev,
121
- put,
122
- bulkGet,
123
- bulkSave,
124
- query,
125
- queryStream,
126
- schema,
127
- getDBInfo,
128
-
129
- // sugar methods
130
- patch,
131
- patchDangerously,
132
- bulkRemove,
133
- bulkGetDictionary,
134
- bulkSaveTransaction,
135
-
136
- bindConfig,
137
- withRetry,
138
- createQuery,
139
- createLock,
140
- removeLock
141
- }
@@ -1,60 +0,0 @@
1
- import { TrackedEmitter } from '../impl/trackedEmitter.mjs'
2
- import test from 'tap'
3
- import { spawn } from 'child_process'
4
- import { bindConfig } from '../index.mjs'
5
- import needle from 'needle'
6
-
7
- let DB_URL = `https://admin:iEZCEQhVR9PVCmYuZ5Bv@redman-couchdb.staging.brivity.io/testdb`
8
-
9
- const config = {
10
- couch: DB_URL,
11
- bindWithRetry: true,
12
- logger: (level, ...args) => {
13
- console.log(`[${level.toUpperCase()}]`, ...args)
14
- }
15
- }
16
- test.test('changes tests', async t => {
17
- await needle('put', DB_URL)
18
- t.teardown(async () => {
19
- await needle('delete', DB_URL)
20
- })
21
-
22
- const db = bindConfig(config)
23
-
24
- t.test('basic changes feed', t => new Promise(async (resolve) => {
25
- const onChange = (change) => {
26
- t.equal(change.id, 'test-changes-doc', 'change notification received')
27
- changesEmitter.stop()
28
- t.end()
29
- resolve()
30
- }
31
- const changesEmitter = await db.changes(onChange, { since: 'now', feed: 'continuous' })
32
- t.ok(changesEmitter.on, 'changes emitter has on method')
33
- t.ok(changesEmitter.removeListener, 'changes emitter has removeListener method')
34
- t.ok(changesEmitter.stop, 'changes emitter has stop method')
35
- await new Promise((resolve) => setTimeout(resolve, 1000)) // Give it time to start
36
- // Create a document to trigger a change
37
- await db.put({ _id: 'test-changes-doc', data: 'test' })
38
- }))
39
-
40
- t.test('document id', t => new Promise(async (resolve) => {
41
- const opts = {
42
- since: 'now',
43
- include_docs: true,
44
- feed: 'continuous'
45
- }
46
- const onChange = (change) => {
47
- console.log('got a change', change)
48
- if (change.id === 'test-a') {
49
- setTimeout(() => {
50
- resolve()
51
- }, 1000)
52
- }
53
- }
54
- const changesEmitter = await db.changes(onChange, opts)
55
- await new Promise((resolve) => setTimeout(resolve, 4000)) // Give it time to start
56
- // Create a document to trigger a change
57
- await db.put({ _id: 'test-changes-doc-2', data: 'test' })
58
- await db.put({ _id: 'test-a', data: 'test' })
59
- }))
60
- })
@@ -1,36 +0,0 @@
1
- import { watchDocs } from "../impl/sugar/watch.mjs";
2
- import { bindConfig } from '../index.mjs'
3
- import needle from 'needle'
4
-
5
- let DB_URL = `https://admin:iEZCEQhVR9PVCmYuZ5Bv@redman-couchdb.staging.brivity.io/testdb`
6
-
7
- const config = {
8
- couch: DB_URL,
9
- bindWithRetry: true,
10
- logger: (level, ...args) => {
11
- console.log(`[${level.toUpperCase()}]`, ...args)
12
- }
13
- }
14
-
15
- const run = async () => {
16
- await needle('put', DB_URL)
17
- const db = bindConfig(config)
18
- const onChange = (change) => {
19
- console.log(change)
20
- }
21
- const feed = watchDocs(config, 'doc-a-1', onChange, {include_docs: true})
22
- feed.on('end', ({lastSeq}) => {
23
- console.log('ending')
24
- console.log('lastSeq', lastSeq)
25
- })
26
- // wait a while, and then end the watcher
27
- setTimeout(() => {
28
- console.log('stopping...')
29
- feed.stop()
30
- console.log('stopped')
31
- }, 190000)
32
-
33
-
34
- }
35
-
36
- run()
@@ -1,40 +0,0 @@
1
- import { watchDocs } from "../impl/sugar/watch.mjs";
2
- import test from 'tap'
3
- import { bindConfig } from '../index.mjs'
4
- import needle from 'needle'
5
-
6
- let DB_URL = `https://admin:iEZCEQhVR9PVCmYuZ5Bv@redman-couchdb.staging.brivity.io/testdb`
7
-
8
- const config = {
9
- couch: DB_URL,
10
- bindWithRetry: true,
11
- logger: (level, ...args) => {
12
- console.log(`[${level.toUpperCase()}]`, ...args)
13
- }
14
- }
15
- test.test('changes tests', async t => {
16
- await needle('put', DB_URL)
17
- t.teardown(async () => {
18
- await needle('delete', DB_URL)
19
- })
20
-
21
- const db = bindConfig(config)
22
-
23
- t.test('watch a doc', t => new Promise(async (resolve) => {
24
- let feed = null
25
- const onChange = (change) => {
26
- t.equal(change.id, 'doc-a-1')
27
- t.equal(change.doc._id, 'doc-a-1')
28
- t.equal(change.doc.data, 'test')
29
- feed.stop()
30
- resolve()
31
- }
32
- feed = db.watchDocs('doc-a-1', onChange, {include_docs: true})
33
- feed.on('end', ({lastSeq}) => {
34
- console.log('ending')
35
- console.log('lastSeq', lastSeq)
36
- })
37
- await db.put({ _id: 'doc-a-fake-out', data: 'test' }) // we should not see this, because we did not watch it
38
- await db.put({ _id: 'doc-a-1', data: 'test' })
39
- }))
40
- })