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
@@ -0,0 +1,64 @@
1
+ import { BulkSaveResponse, type CouchDocInput } from '../schema/couch/couch.output.schema.ts';
2
+ import type { CouchConfigInput } from '../schema/config.mts';
3
+ /**
4
+ * Bulk saves documents to CouchDB using the _bulk_docs endpoint.
5
+ *
6
+ * @see
7
+ * https://docs.couchdb.org/en/stable/api/database/bulk-api.html#db-bulk-docs
8
+ *
9
+ * @param {CouchConfigInput} config - The CouchDB configuration.
10
+ * @param {CouchDocInput[]} docs - An array of documents to save.
11
+ * @returns {Promise<BulkSaveResponse>} - The response from CouchDB after the bulk save operation.
12
+ *
13
+ * @throws {RetryableError} When a retryable HTTP status code is encountered or no response is received.
14
+ * @throws {Error} When CouchDB returns a non-retryable error payload.
15
+ */
16
+ export declare const bulkSave: (config: CouchConfigInput, docs: CouchDocInput[]) => Promise<{
17
+ ok?: boolean | null | undefined;
18
+ id?: string | null | undefined;
19
+ rev?: string | null | undefined;
20
+ error?: string | null | undefined;
21
+ reason?: string | null | undefined;
22
+ }[]>;
23
+ /**
24
+ * Performs a bulk save of documents within a transaction context.
25
+ *
26
+ * @remarks
27
+ * This operation ensures that either all documents are saved successfully, or none are, maintaining data consistency.
28
+ * If any document fails to save, the operation will attempt to roll back all changes.
29
+ *
30
+ * The transactionId has to be unique for the lifetime of the app. It is used to prevent two processes from executing the same transaction. It is up to you to craft a transactionId that uniquely represents this transaction, and that also is the same if another process tries to generate it.
31
+ *
32
+ * Exceptions to handle:
33
+ *
34
+ * `TransactionSetupError` Thrown if the transaction document cannot be created. Usually because it already exists
35
+ * `TransactionVersionConflictError` Thrown if there are version conflicts with existing documents.
36
+ * `TransactionBulkOperationError` Thrown if the bulk save operation fails for some documents.
37
+ * `TransactionRollbackError` Thrown if the rollback operation fails after a transaction failure.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * const docsToSave = [
42
+ * { _id: 'doc1', foo: 'bar' },
43
+ * { _id: 'doc2', foo: 'baz' }
44
+ * ];
45
+ *
46
+ * try {
47
+ * const results = await bulkSaveTransaction(config, 'unique-transaction-id', docsToSave);
48
+ * console.log('Bulk save successful:', results);
49
+ * } catch (error) {
50
+ * console.error('Bulk save transaction failed:', error);
51
+ * }
52
+ * ```
53
+ *
54
+ * @param {CouchConfigInput} config - The CouchDB configuration.
55
+ * @param {string} transactionId - A unique identifier for the transaction.
56
+ * @param {CouchDocInput[]} docs - An array of documents to save.
57
+ * @returns {Promise<BulkSaveResponse>} - The transaction save results.
58
+ * @throws {TransactionSetupError} When the transaction document cannot be created.
59
+ * @throws {TransactionVersionConflictError} When there are version conflicts with existing documents.
60
+ * @throws {TransactionBulkOperationError} When the bulk save operation fails for some documents.
61
+ * @throws {TransactionRollbackError} When the rollback operation fails after a transaction failure.
62
+ */
63
+ export declare const bulkSaveTransaction: (config: CouchConfigInput, transactionId: string, docs: CouchDocInput[]) => Promise<BulkSaveResponse>;
64
+ //# sourceMappingURL=bulkSave.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkSave.d.mts","sourceRoot":"","sources":["../../../impl/bulkSave.mts"],"names":[],"mappings":"AAWA,OAAO,EACL,gBAAgB,EAEhB,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAK5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,GAAU,QAAQ,gBAAgB,EAAE,MAAM,aAAa,EAAE;;;;;;IAuC7E,CAAA;AAYD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,gBAAgB,EACxB,eAAe,MAAM,EACrB,MAAM,aAAa,EAAE,KACpB,OAAO,CAAC,gBAAgB,CA4J1B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bulkSave.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkSave.test.d.mts","sourceRoot":"","sources":["../../../impl/bulkSave.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import type { CouchConfigInput } from '../schema/config.mts';
3
+ import type { StandardSchemaV1 } from '../types/standard-schema.ts';
4
+ import { CouchDoc } from '../schema/couch/couch.output.schema.ts';
5
+ export type GetOptions<DocSchema extends StandardSchemaV1> = {
6
+ validate?: {
7
+ docSchema?: DocSchema;
8
+ };
9
+ };
10
+ export declare const CouchGetOptions: z.ZodObject<{
11
+ rev: z.ZodOptional<z.ZodString>;
12
+ validate: z.ZodOptional<z.ZodObject<{
13
+ docSchema: z.ZodOptional<z.ZodCustom<unknown, unknown>>;
14
+ }, z.core.$strip>>;
15
+ }, z.core.$strip>;
16
+ export declare function get<DocSchema extends StandardSchemaV1 = typeof CouchDoc>(config: CouchConfigInput, id: string, options?: GetOptions<DocSchema>): Promise<StandardSchemaV1.InferOutput<DocSchema> | null>;
17
+ export type GetBound = <DocSchema extends StandardSchemaV1 = typeof CouchDoc>(id: string, options?: GetOptions<DocSchema>) => Promise<StandardSchemaV1.InferOutput<DocSchema> | null>;
18
+ export declare function getAtRev<DocSchema extends StandardSchemaV1>(config: CouchConfigInput, id: string, rev: string, options?: GetOptions<DocSchema>): Promise<StandardSchemaV1.InferOutput<DocSchema> | null>;
19
+ export type GetAtRevBound = <DocSchema extends StandardSchemaV1 = typeof CouchDoc>(id: string, rev: string, options?: GetOptions<DocSchema> | undefined) => Promise<StandardSchemaV1.InferOutput<DocSchema> | null>;
20
+ //# sourceMappingURL=get.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.mts","sourceRoot":"","sources":["../../../impl/get.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AACnE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@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.test.d.mts","sourceRoot":"","sources":["../../../impl/get.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ import { type CouchConfigInput } from '../schema/config.mts';
2
+ /**
3
+ * Fetches and returns CouchDB database information.
4
+ *
5
+ * @see {@link https://docs.couchdb.org/en/stable/api/database/common.html#get--db | CouchDB API Documentation}
6
+ *
7
+ * @param configInput - The CouchDB configuration input.
8
+ * @returns A promise that resolves to the CouchDB database information.
9
+ * @throws {RetryableError} `RetryableError` If a retryable error occurs during the request.
10
+ * @throws {Error} `Error` For other non-retryable errors.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import { getDBInfo } from './impl/getDBInfo.mts';
15
+ *
16
+ * const config = { couch: 'http://localhost:5984/my-database' };
17
+ *
18
+ * getDBInfo(config)
19
+ * .then(info => {
20
+ * console.log('Database Info:', info);
21
+ * })
22
+ * .catch(err => {
23
+ * console.error('Error fetching database info:', err);
24
+ * });
25
+ * ```
26
+ */
27
+ export declare const getDBInfo: (configInput: CouchConfigInput) => Promise<{
28
+ [x: string]: unknown;
29
+ db_name: string;
30
+ cluster?: {
31
+ n?: number | undefined;
32
+ q?: number | undefined;
33
+ r?: number | undefined;
34
+ w?: number | undefined;
35
+ } | undefined;
36
+ compact_running?: boolean | undefined;
37
+ disk_format_version?: number | undefined;
38
+ doc_count?: number | undefined;
39
+ doc_del_count?: number | undefined;
40
+ instance_start_time?: string | undefined;
41
+ purge_seq?: string | undefined;
42
+ sizes?: {
43
+ active?: number | undefined;
44
+ external?: number | undefined;
45
+ file?: number | undefined;
46
+ } | undefined;
47
+ update_seq?: string | number | undefined;
48
+ props?: {
49
+ partitioned?: boolean | undefined;
50
+ } | undefined;
51
+ }>;
52
+ //# sourceMappingURL=getDBInfo.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDBInfo.d.mts","sourceRoot":"","sources":["../../../impl/getDBInfo.mts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAGzE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,SAAS,GAAU,aAAa,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;EAkC5D,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getDBInfo.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getDBInfo.test.d.mts","sourceRoot":"","sources":["../../../impl/getDBInfo.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,45 @@
1
+ import { type CouchConfigInput } from '../schema/config.mts';
2
+ import { z } from 'zod';
3
+ declare const PatchProperties: z.ZodObject<{
4
+ _rev: z.ZodString;
5
+ }, z.core.$loose>;
6
+ /**
7
+ * Patch a CouchDB document by merging provided properties.
8
+ * Validates that the _rev matches before applying the patch.
9
+ *
10
+ * @param configInput - CouchDB configuration
11
+ * @param id - Document ID to patch
12
+ * @param _properties - Properties to merge into the document (must include _rev)
13
+ * @returns The result of the put operation
14
+ *
15
+ * @throws Error if the _rev does not match or other errors occur
16
+ */
17
+ export declare const patch: (configInput: CouchConfigInput, id: string, _properties: z.infer<typeof PatchProperties>) => Promise<{
18
+ statusCode: number;
19
+ ok?: boolean | undefined;
20
+ error?: string | undefined;
21
+ id?: string | undefined;
22
+ rev?: string | undefined;
23
+ }>;
24
+ /**
25
+ * Patch a CouchDB document by merging provided properties.
26
+ * This function will retry on conflicts using an exponential backoff strategy.
27
+ *
28
+ * @remarks patchDangerously can clobber data. It will retry even if a conflict happens. There are some use cases for this, but you have been warned, hence the name.
29
+ *
30
+ * @param configInput - CouchDB configuration
31
+ * @param id - Document ID to patch
32
+ * @param properties - Properties to merge into the document
33
+ * @returns The result of the put operation or an error if max retries are exceeded
34
+ *
35
+ * @throws Error if max retries are exceeded or other errors occur
36
+ */
37
+ export declare const patchDangerously: (configInput: CouchConfigInput, id: string, properties: Record<string, unknown>) => Promise<{
38
+ statusCode: number;
39
+ ok?: boolean | undefined;
40
+ error?: string | undefined;
41
+ id?: string | undefined;
42
+ rev?: string | undefined;
43
+ } | undefined>;
44
+ export {};
45
+ //# sourceMappingURL=patch.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch.d.mts","sourceRoot":"","sources":["../../../impl/patch.mts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,QAAA,MAAM,eAAe;;iBAIiB,CAAA;AAEtC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAChB,aAAa,gBAAgB,EAC7B,IAAI,MAAM,EACV,aAAa,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC;;;;;;EAsB7C,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB,GAC3B,aAAa,gBAAgB,EAC7B,IAAI,MAAM,EACV,YAAY,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;cAkEpC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=patch.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch.test.d.mts","sourceRoot":"","sources":["../../../impl/patch.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { type CouchConfigInput } from '../schema/config.mts';
2
+ import { CouchPutResponse, type CouchDoc } from '../schema/couch/couch.output.schema.ts';
3
+ import { z } from 'zod';
4
+ export declare const put: (configInput: CouchConfigInput, doc: CouchDoc) => Promise<z.infer<typeof CouchPutResponse>>;
5
+ //# sourceMappingURL=put.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"put.d.mts","sourceRoot":"","sources":["../../../impl/put.mts"],"names":[],"mappings":"AAIA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAE,gBAAgB,EAAE,KAAK,QAAQ,EAAE,MAAM,wCAAwC,CAAA;AACxF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,GAAG,GACd,aAAa,gBAAgB,EAC7B,KAAK,QAAQ,KACZ,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CA4C1C,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=put.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"put.test.d.mts","sourceRoot":"","sources":["../../../impl/put.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ import { type CouchConfigInput } from '../schema/config.mts';
2
+ import { ZodAny, ZodNever } from 'zod';
3
+ import { ViewOptions, type ViewString } from '../schema/couch/couch.input.schema.ts';
4
+ import type { CouchDoc, ViewQueryResponseValidated } from '../schema/couch/couch.output.schema.ts';
5
+ import type { StandardSchemaV1 } from '../types/standard-schema.ts';
6
+ import { type OnInvalidDocAction } from './utils/parseRows.mts';
7
+ export declare function query<DocSchema extends StandardSchemaV1 = typeof CouchDoc, KeySchema extends StandardSchemaV1 = ZodAny, ValueSchema extends StandardSchemaV1 = ZodAny>(config: CouchConfigInput, view: ViewString, options: ViewOptions & {
8
+ include_docs: true;
9
+ validate?: {
10
+ onInvalidDoc?: OnInvalidDocAction;
11
+ docSchema?: DocSchema;
12
+ keySchema?: KeySchema;
13
+ valueSchema?: ValueSchema;
14
+ };
15
+ }): Promise<ViewQueryResponseValidated<DocSchema, KeySchema, ValueSchema>>;
16
+ export declare function query<DocSchema extends StandardSchemaV1 = ZodNever, KeySchema extends StandardSchemaV1 = ZodAny, ValueSchema extends StandardSchemaV1 = ZodAny>(config: CouchConfigInput, view: ViewString, options: ViewOptions & {
17
+ include_docs?: false | undefined;
18
+ validate?: {
19
+ onInvalidDoc?: OnInvalidDocAction;
20
+ docSchema?: DocSchema;
21
+ keySchema?: KeySchema;
22
+ valueSchema?: ValueSchema;
23
+ };
24
+ }): Promise<ViewQueryResponseValidated<ZodNever, KeySchema, ValueSchema>>;
25
+ export declare function query(config: CouchConfigInput, view: ViewString, options?: ViewOptions): Promise<ViewQueryResponseValidated<ZodNever, ZodAny, ZodAny>>;
26
+ export type QueryBound = {
27
+ <DocSchema extends StandardSchemaV1 = typeof CouchDoc, KeySchema extends StandardSchemaV1 = ZodAny, ValueSchema extends StandardSchemaV1 = ZodAny>(view: ViewString, options: ViewOptions & {
28
+ include_docs: true;
29
+ validate?: {
30
+ onInvalidDoc?: OnInvalidDocAction;
31
+ docSchema?: DocSchema;
32
+ keySchema?: KeySchema;
33
+ valueSchema?: ValueSchema;
34
+ };
35
+ }): Promise<ViewQueryResponseValidated<DocSchema, KeySchema, ValueSchema>>;
36
+ <DocSchema extends StandardSchemaV1 = ZodNever, KeySchema extends StandardSchemaV1 = ZodAny, ValueSchema extends StandardSchemaV1 = ZodAny>(view: ViewString, options: ViewOptions & {
37
+ include_docs?: false | undefined;
38
+ validate?: {
39
+ onInvalidDoc?: OnInvalidDocAction;
40
+ docSchema?: DocSchema;
41
+ keySchema?: KeySchema;
42
+ valueSchema?: ValueSchema;
43
+ };
44
+ }): Promise<ViewQueryResponseValidated<ZodNever, KeySchema, ValueSchema>>;
45
+ (view: ViewString, options?: ViewOptions): Promise<ViewQueryResponseValidated<ZodNever, ZodAny, ZodAny>>;
46
+ };
47
+ //# sourceMappingURL=query.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.d.mts","sourceRoot":"","sources":["../../../impl/query.mts"],"names":[],"mappings":"AAGA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACzE,OAAO,EAAK,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAA;AAIzC,OAAO,EAAE,WAAW,EAAE,KAAK,UAAU,EAAE,M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CAAA;IACxE,CACE,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,0BAA0B,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CACjE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=query.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.test.d.mts","sourceRoot":"","sources":["../../../impl/query.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,9 @@
1
+ import { type CouchConfigInput } from '../schema/config.mts';
2
+ export declare const remove: (configInput: CouchConfigInput, id: string, rev: string) => Promise<{
3
+ statusCode: number;
4
+ ok?: boolean | undefined;
5
+ error?: string | undefined;
6
+ id?: string | undefined;
7
+ rev?: string | undefined;
8
+ }>;
9
+ //# sourceMappingURL=remove.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.mts","sourceRoot":"","sources":["../../../impl/remove.mts"],"names":[],"mappings":"AAKA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEzE,eAAO,MAAM,MAAM,GAAU,aAAa,gBAAgB,EAAE,IAAI,MAAM,EAAE,KAAK,MAAM;;;;;;EAyDlF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remove.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.test.d.mts","sourceRoot":"","sources":["../../../impl/remove.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Settings that control how retry attempts are scheduled.
3
+ */
4
+ export interface RetryOptions {
5
+ /**
6
+ * Maximum number of retry attempts before rethrowing the original error.
7
+ */
8
+ maxRetries?: number;
9
+ /**
10
+ * Initial wait duration in milliseconds before attempting the first retry.
11
+ */
12
+ initialDelay?: number;
13
+ /**
14
+ * Multiplier applied to the delay after each retry to implement exponential backoff.
15
+ */
16
+ backoffFactor?: number;
17
+ /**
18
+ * Upper bound, in milliseconds, for the delay between retries.
19
+ */
20
+ maxDelay?: number;
21
+ }
22
+ type MaybePromise<T> = PromiseLike<T> | T;
23
+ /**
24
+ * Wrap an async-capable function with retry semantics that respect {@link RetryableError}.
25
+ * @typeParam Fn - The function signature to decorate with retry handling.
26
+ * @param fn The function to invoke with retry support.
27
+ * @param options Retry tuning parameters.
28
+ * @returns A function mirroring `fn` that automatically retries on {@link RetryableError}.
29
+ */
30
+ export declare function withRetry<Fn extends (...args: any[]) => MaybePromise<any>>(fn: Fn, options?: RetryOptions): (...args: Parameters<Fn>) => Promise<Awaited<ReturnType<Fn>>>;
31
+ export {};
32
+ //# sourceMappingURL=retry.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.mts","sourceRoot":"","sources":["../../../impl/retry.mts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,KAAK,YAAY,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;AAEzC;;;;;;GAMG;AAEH,wBAAgB,SAAS,CAAC,EAAE,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,CAAC,GAAG,CAAC,EACxE,EAAE,EAAE,EAAE,EACN,OAAO,GAAE,YAAiB,GACzB,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CA2B/D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=retry.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.test.d.mts","sourceRoot":"","sources":["../../../impl/retry.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { type CouchConfigInput } from '../schema/config.mts';
2
+ import type { ViewRow } from '../schema/couch/couch.output.schema.ts';
3
+ import type { ViewOptions } from '../schema/couch/couch.input.schema.ts';
4
+ export type OnRow = (row: ViewRow) => void;
5
+ /**
6
+ * Execute a CouchDB view query and stream rows as they are received.
7
+ * @param rawConfig CouchDB configuration
8
+ * @param view The CouchDB view to query
9
+ * @param options Query options
10
+ * @param onRow Callback invoked for each row received
11
+ */
12
+ export declare function queryStream(rawConfig: CouchConfigInput, view: string, options: ViewOptions | undefined, onRow: OnRow): Promise<void>;
13
+ //# sourceMappingURL=stream.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.mts","sourceRoot":"","sources":["../../../impl/stream.mts"],"names":[],"mappings":"AAMA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAKzE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AAOxE,MAAM,MAAM,KAAK,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAA;AAG1C;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,WAAW,GAAG,SAAS,EAChC,KAAK,EAAE,KAAK,GACX,OAAO,CAAC,IAAI,CAAC,CA4Gf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stream.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.test.d.mts","sourceRoot":"","sources":["../../../impl/stream.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { LockOptions } from '../../schema/sugar/lock.mts';
2
+ import { type CouchConfigInput } from '../../schema/config.mts';
3
+ /**
4
+ * Create a lock document for the specified document ID.
5
+ * Returns true if the lock was created, false if locking is disabled or a conflict occurred.
6
+ *
7
+ * @param configInput CouchDB configuration
8
+ * @param docId The document ID to lock
9
+ * @param lockOptions Locking options
10
+ *
11
+ * @return True if the lock was created, false otherwise
12
+ */
13
+ export declare function createLock(configInput: CouchConfigInput, docId: string, lockOptions: LockOptions): Promise<boolean>;
14
+ /**
15
+ * Remove the lock document for the specified document ID if owned by the caller.
16
+ *
17
+ * @param configInput CouchDB configuration
18
+ * @param docId The document ID to unlock
19
+ * @param lockOptions Locking options
20
+ *
21
+ * @return Promise that resolves when the unlock operation is complete
22
+ */
23
+ export declare function removeLock(configInput: CouchConfigInput, docId: string, lockOptions: LockOptions): Promise<void>;
24
+ //# sourceMappingURL=lock.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.d.mts","sourceRoot":"","sources":["../../../../impl/sugar/lock.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAIzD,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG5E;;;;;;;;;GASG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,gBAAgB,EAC7B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,OAAO,CAAC,CAgClB;AAED;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,gBAAgB,EAC7B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,IAAI,CAAC,CAkCf"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=lock.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lock.test.d.mts","sourceRoot":"","sources":["../../../../impl/sugar/lock.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { EventEmitter } from 'events';
2
+ import { type WatchOptionsInput } from '../../schema/sugar/watch.mts';
3
+ import { type CouchConfigInput } from '../../schema/config.mts';
4
+ /**
5
+ * Watch for changes to specified document IDs in CouchDB.
6
+ * Calls the onChange callback for each change detected.
7
+ * Returns an emitter with methods to listen for events and stop watching.
8
+ *
9
+ * @param configInput CouchDB configuration
10
+ * @param docIds Document ID or array of document IDs to watch
11
+ * @param onChange Callback function called on each change
12
+ * @param optionsInput Watch options
13
+ *
14
+ * @return WatchEmitter with methods to manage the watch
15
+ */
16
+ export declare function watchDocs(configInput: CouchConfigInput, docIds: string | string[], onChange: (change: any) => void, optionsInput?: WatchOptionsInput): {
17
+ on: (event: string, listener: EventListener) => EventEmitter<[never]>;
18
+ removeListener: (event: string, listener: EventListener) => EventEmitter<[never]>;
19
+ stop: () => void;
20
+ };
21
+ //# sourceMappingURL=watch.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.mts","sourceRoot":"","sources":["../../../../impl/sugar/watch.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAGrC,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAGnF,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,yBAAyB,CAAA;AAEhC;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CACvB,WAAW,EAAE,gBAAgB,EAC7B,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,EAEzB,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,EAC/B,YAAY,GAAE,iBAAsB;gBAkJtB,MAAM,YAAY,aAAa;4BACnB,MAAM,YAAY,aAAa;;EAU1D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=watch.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.test.d.mts","sourceRoot":"","sources":["../../../../impl/sugar/watch.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Represents a network-level error emitted by Node.js or libraries such as `needle`.
3
+ *
4
+ * @public
5
+ */
6
+ export interface NetworkError {
7
+ /**
8
+ * Machine-readable error code describing the network failure.
9
+ */
10
+ code: string;
11
+ /**
12
+ * Optional human-readable message supplied by the underlying library.
13
+ */
14
+ message?: string;
15
+ }
16
+ /**
17
+ * Error thrown when a requested CouchDB document cannot be found.
18
+ *
19
+ * @remarks
20
+ * The `docId` property exposes the identifier that triggered the failure, which is
21
+ * helpful for logging and retry strategies.
22
+ *
23
+ * @public
24
+ */
25
+ export declare class NotFoundError extends Error {
26
+ /**
27
+ * Identifier of the missing document.
28
+ */
29
+ readonly docId: string;
30
+ /**
31
+ * Creates a new {@link NotFoundError} instance.
32
+ *
33
+ * @param docId - The identifier of the document that was not found.
34
+ * @param message - Optional custom error message.
35
+ */
36
+ constructor(docId: string, message?: string);
37
+ }
38
+ /**
39
+ * Error signalling that an operation can be retried due to transient conditions.
40
+ *
41
+ * @remarks
42
+ * Use `RetryableError.isRetryableStatusCode` and `RetryableError.handleNetworkError`
43
+ * to detect when a failure should trigger retry logic.
44
+ *
45
+ * @public
46
+ */
47
+ export declare class RetryableError extends Error {
48
+ /**
49
+ * HTTP status code associated with the retryable failure, when available.
50
+ */
51
+ readonly statusCode?: number;
52
+ /**
53
+ * Creates a new {@link RetryableError} instance.
54
+ *
55
+ * @param message - Detailed description of the failure.
56
+ * @param statusCode - Optional HTTP status code corresponding to the failure.
57
+ */
58
+ constructor(message: string, statusCode?: number);
59
+ /**
60
+ * Determines whether the provided status code should be treated as retryable.
61
+ *
62
+ * @param statusCode - HTTP status code returned by CouchDB.
63
+ *
64
+ * @returns `true` if the status code is considered retryable; otherwise `false`.
65
+ */
66
+ static isRetryableStatusCode(statusCode: number | undefined): statusCode is number;
67
+ /**
68
+ * Converts low-level network errors into {@link RetryableError} instances when possible.
69
+ *
70
+ * @param err - The error thrown by the underlying HTTP client.
71
+ *
72
+ * @throws {@link RetryableError} When the error maps to a retryable network condition.
73
+ * @throws {*} Re-throws the original error when it cannot be mapped.
74
+ */
75
+ static handleNetworkError(err: unknown): never;
76
+ }
77
+ export declare function isConflictError(err: unknown): boolean;
78
+ //# sourceMappingURL=errors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../../../../impl/utils/errors.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAuBD;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IAEtB;;;;;OAKG;gBACS,KAAK,EAAE,MAAM,EAAE,OAAO,SAAuB;CAK1D;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,KAAK;IACvC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAE5B;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAMhD;;;;;;OAMG;IACH,MAAM,CAAC,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,IAAI,MAAM;IAKlF;;;;;;;OAOG;IACH,MAAM,CAAC,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK;CAU/C;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAIrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=errors.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.test.d.mts","sourceRoot":"","sources":["../../../../impl/utils/errors.test.mts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import type { CouchConfigInput } from '../../schema/config.mts';
2
+ type LoggerMethod = (...args: unknown[]) => void;
3
+ export type Logger = {
4
+ error: LoggerMethod;
5
+ warn: LoggerMethod;
6
+ info: LoggerMethod;
7
+ debug: LoggerMethod;
8
+ };
9
+ export declare function createLogger(config: CouchConfigInput): Logger;
10
+ export {};
11
+ //# sourceMappingURL=logger.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["../../../../impl/utils/logger.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE/D,KAAK,YAAY,GAAG,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAEhD,MAAM,MAAM,MAAM,GAAG;IACnB,KAAK,EAAE,YAAY,CAAA;IACnB,IAAI,EAAE,YAAY,CAAA;IAClB,IAAI,EAAE,YAAY,CAAA;IAClB,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AAoBD,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgC7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=logger.test.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.test.d.mts","sourceRoot":"","sources":["../../../../impl/utils/logger.test.mts"],"names":[],"mappings":""}