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.
- package/.prettierrc +7 -0
- package/README.md +270 -218
- package/dist/cjs/index.cjs +1952 -0
- package/dist/esm/index.mjs +1898 -0
- package/docs/.nojekyll +1 -0
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/highlight.css +113 -0
- package/docs/assets/icons.js +18 -0
- package/docs/assets/icons.svg +1 -0
- package/docs/assets/main.js +60 -0
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -0
- package/docs/assets/style.css +1633 -0
- package/docs/classes/QueryBuilder.html +42 -0
- package/docs/functions/bindConfig.html +4 -0
- package/docs/functions/bulkGet.html +14 -0
- package/docs/functions/bulkGetDictionary.html +10 -0
- package/docs/functions/bulkRemove.html +12 -0
- package/docs/functions/bulkRemoveMap.html +11 -0
- package/docs/functions/bulkSave.html +10 -0
- package/docs/functions/bulkSaveTransaction.html +23 -0
- package/docs/functions/createLock.html +7 -0
- package/docs/functions/createQuery.html +1 -0
- package/docs/functions/get.html +1 -0
- package/docs/functions/getAtRev.html +1 -0
- package/docs/functions/getDBInfo.html +10 -0
- package/docs/functions/patch.html +8 -0
- package/docs/functions/patchDangerously.html +9 -0
- package/docs/functions/put.html +1 -0
- package/docs/functions/query.html +15 -0
- package/docs/functions/queryStream.html +6 -0
- package/docs/functions/remove.html +1 -0
- package/docs/functions/removeLock.html +6 -0
- package/docs/functions/watchDocs.html +9 -0
- package/docs/functions/withRetry.html +6 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +483 -0
- package/docs/interfaces/NetworkError.html +6 -0
- package/docs/interfaces/NotFoundError.html +10 -0
- package/docs/interfaces/RetryOptions.html +10 -0
- package/docs/interfaces/RetryableError.html +10 -0
- package/docs/interfaces/StandardSchemaV1.FailureResult.html +4 -0
- package/docs/interfaces/StandardSchemaV1.Issue.html +6 -0
- package/docs/interfaces/StandardSchemaV1.Options.html +3 -0
- package/docs/interfaces/StandardSchemaV1.PathSegment.html +4 -0
- package/docs/interfaces/StandardSchemaV1.Props.html +10 -0
- package/docs/interfaces/StandardSchemaV1.SuccessResult.html +6 -0
- package/docs/interfaces/StandardSchemaV1.Types.html +6 -0
- package/docs/interfaces/StandardSchemaV1.html +4 -0
- package/docs/modules/StandardSchemaV1.html +1 -0
- package/docs/modules.html +1 -0
- package/docs/types/BoundInstance.html +1 -0
- package/docs/types/BulkGetBound.html +2 -0
- package/docs/types/BulkGetDictionaryBound.html +1 -0
- package/docs/types/BulkGetDictionaryOptions.html +2 -0
- package/docs/types/BulkGetDictionaryResult.html +3 -0
- package/docs/types/BulkGetOptions.html +3 -0
- package/docs/types/BulkGetResponse.html +1 -0
- package/docs/types/CouchConfig-1.html +1 -0
- package/docs/types/CouchConfig.html +1 -0
- package/docs/types/CouchConfigInput.html +1 -0
- package/docs/types/CouchDoc-1.html +1 -0
- package/docs/types/CouchDoc.html +2 -0
- package/docs/types/CouchDocInput.html +2 -0
- package/docs/types/GetAtRevBound.html +1 -0
- package/docs/types/GetBound.html +1 -0
- package/docs/types/GetOptions.html +2 -0
- package/docs/types/LockDoc-1.html +1 -0
- package/docs/types/LockDoc.html +1 -0
- package/docs/types/LockOptions-1.html +1 -0
- package/docs/types/LockOptions.html +1 -0
- package/docs/types/LockOptionsInput.html +1 -0
- package/docs/types/OnInvalidDocAction.html +1 -0
- package/docs/types/OnRow.html +1 -0
- package/docs/types/QueryBound.html +1 -0
- package/docs/types/SimpleViewOptions-1.html +1 -0
- package/docs/types/SimpleViewOptions.html +1 -0
- package/docs/types/StandardSchemaV1.InferInput.html +2 -0
- package/docs/types/StandardSchemaV1.InferOutput.html +2 -0
- package/docs/types/StandardSchemaV1.Result.html +2 -0
- package/docs/types/ViewQueryResponse-1.html +1 -0
- package/docs/types/ViewQueryResponse.html +2 -0
- package/docs/types/ViewQueryResponseValidated.html +2 -0
- package/docs/types/ViewRow-1.html +1 -0
- package/docs/types/ViewRow.html +2 -0
- package/docs/types/ViewRowValidated.html +7 -0
- package/docs/types/ViewString.html +1 -0
- package/docs/types/WatchOptionsInput.html +1 -0
- package/docs/types/WatchOptionsSchema-1.html +1 -0
- package/docs/types/WatchOptionsSchema.html +1 -0
- package/eslint.config.js +15 -0
- package/impl/bindConfig.mts +140 -0
- package/impl/bulkGet.mts +256 -0
- package/impl/bulkGet.test.mts +159 -0
- package/impl/bulkRemove.mts +98 -0
- package/impl/bulkRemove.test.mts +102 -0
- package/impl/bulkSave.mts +286 -0
- package/impl/bulkSave.test.mts +319 -0
- package/impl/get.mts +137 -0
- package/impl/get.test.mts +114 -0
- package/impl/getDBInfo.mts +67 -0
- package/impl/getDBInfo.test.mts +62 -0
- package/impl/patch.mts +134 -0
- package/impl/patch.test.mts +142 -0
- package/impl/put.mts +56 -0
- package/impl/put.test.mts +114 -0
- package/impl/query.mts +224 -0
- package/impl/query.test.mts +280 -0
- package/impl/remove.mts +65 -0
- package/impl/remove.test.mts +82 -0
- package/impl/retry.mts +66 -0
- package/impl/retry.test.mts +77 -0
- package/impl/stream.mts +143 -0
- package/impl/stream.test.mts +205 -0
- package/impl/sugar/lock.mts +103 -0
- package/impl/sugar/lock.test.mts +113 -0
- package/impl/sugar/{watch.mjs → watch.mts} +56 -22
- package/impl/sugar/watch.test.mts +155 -0
- package/impl/utils/errors.mts +130 -0
- package/impl/utils/errors.test.mts +58 -0
- package/impl/utils/logger.mts +62 -0
- package/impl/utils/logger.test.mts +129 -0
- package/impl/utils/mergeNeedleOpts.mts +16 -0
- package/impl/utils/parseRows.mts +117 -0
- package/impl/utils/parseRows.test.mts +183 -0
- package/impl/utils/queryBuilder.mts +173 -0
- package/impl/utils/queryBuilder.test.mts +83 -0
- package/impl/utils/queryString.mts +44 -0
- package/impl/utils/queryString.test.mts +53 -0
- package/impl/{trackedEmitter.mjs → utils/trackedEmitter.mts} +9 -7
- package/impl/utils/transactionErrors.mts +71 -0
- package/index.mts +82 -0
- package/index.test.mts +415 -0
- package/package.json +45 -31
- package/schema/config.mts +81 -0
- package/schema/couch/couch.input.schema.ts +43 -0
- package/schema/couch/couch.output.schema.ts +169 -0
- package/schema/sugar/lock.mts +18 -0
- package/schema/sugar/watch.mts +14 -0
- package/schema/util.mts +8 -0
- package/tsconfig.json +10 -4
- package/tsdown.config.ts +16 -0
- package/typedoc.json +4 -0
- package/types/output/eslint.config.d.ts +3 -0
- package/types/output/eslint.config.d.ts.map +1 -0
- package/types/output/impl/bindConfig.d.mts +174 -0
- package/types/output/impl/bindConfig.d.mts.map +1 -0
- package/types/output/impl/bulkGet.d.mts +75 -0
- package/types/output/impl/bulkGet.d.mts.map +1 -0
- package/types/output/impl/bulkGet.test.d.mts +2 -0
- package/types/output/impl/bulkGet.test.d.mts.map +1 -0
- package/types/output/impl/bulkRemove.d.mts +63 -0
- package/types/output/impl/bulkRemove.d.mts.map +1 -0
- package/types/output/impl/bulkRemove.test.d.mts +2 -0
- package/types/output/impl/bulkRemove.test.d.mts.map +1 -0
- package/types/output/impl/bulkSave.d.mts +64 -0
- package/types/output/impl/bulkSave.d.mts.map +1 -0
- package/types/output/impl/bulkSave.test.d.mts +2 -0
- package/types/output/impl/bulkSave.test.d.mts.map +1 -0
- package/types/output/impl/get.d.mts +20 -0
- package/types/output/impl/get.d.mts.map +1 -0
- package/types/output/impl/get.test.d.mts +2 -0
- package/types/output/impl/get.test.d.mts.map +1 -0
- package/types/output/impl/getDBInfo.d.mts +52 -0
- package/types/output/impl/getDBInfo.d.mts.map +1 -0
- package/types/output/impl/getDBInfo.test.d.mts +2 -0
- package/types/output/impl/getDBInfo.test.d.mts.map +1 -0
- package/types/output/impl/patch.d.mts +45 -0
- package/types/output/impl/patch.d.mts.map +1 -0
- package/types/output/impl/patch.test.d.mts +2 -0
- package/types/output/impl/patch.test.d.mts.map +1 -0
- package/types/output/impl/put.d.mts +5 -0
- package/types/output/impl/put.d.mts.map +1 -0
- package/types/output/impl/put.test.d.mts +2 -0
- package/types/output/impl/put.test.d.mts.map +1 -0
- package/types/output/impl/query.d.mts +47 -0
- package/types/output/impl/query.d.mts.map +1 -0
- package/types/output/impl/query.test.d.mts +2 -0
- package/types/output/impl/query.test.d.mts.map +1 -0
- package/types/output/impl/remove.d.mts +9 -0
- package/types/output/impl/remove.d.mts.map +1 -0
- package/types/output/impl/remove.test.d.mts +2 -0
- package/types/output/impl/remove.test.d.mts.map +1 -0
- package/types/output/impl/retry.d.mts +32 -0
- package/types/output/impl/retry.d.mts.map +1 -0
- package/types/output/impl/retry.test.d.mts +2 -0
- package/types/output/impl/retry.test.d.mts.map +1 -0
- package/types/output/impl/stream.d.mts +13 -0
- package/types/output/impl/stream.d.mts.map +1 -0
- package/types/output/impl/stream.test.d.mts +2 -0
- package/types/output/impl/stream.test.d.mts.map +1 -0
- package/types/output/impl/sugar/lock.d.mts +24 -0
- package/types/output/impl/sugar/lock.d.mts.map +1 -0
- package/types/output/impl/sugar/lock.test.d.mts +2 -0
- package/types/output/impl/sugar/lock.test.d.mts.map +1 -0
- package/types/output/impl/sugar/watch.d.mts +21 -0
- package/types/output/impl/sugar/watch.d.mts.map +1 -0
- package/types/output/impl/sugar/watch.test.d.mts +2 -0
- package/types/output/impl/sugar/watch.test.d.mts.map +1 -0
- package/types/output/impl/utils/errors.d.mts +78 -0
- package/types/output/impl/utils/errors.d.mts.map +1 -0
- package/types/output/impl/utils/errors.test.d.mts +2 -0
- package/types/output/impl/utils/errors.test.d.mts.map +1 -0
- package/types/output/impl/utils/logger.d.mts +11 -0
- package/types/output/impl/utils/logger.d.mts.map +1 -0
- package/types/output/impl/utils/logger.test.d.mts +2 -0
- package/types/output/impl/utils/logger.test.d.mts.map +1 -0
- package/types/output/impl/utils/mergeNeedleOpts.d.mts +53 -0
- package/types/output/impl/utils/mergeNeedleOpts.d.mts.map +1 -0
- package/types/output/impl/utils/parseRows.d.mts +15 -0
- package/types/output/impl/utils/parseRows.d.mts.map +1 -0
- package/types/output/impl/utils/parseRows.test.d.mts +2 -0
- package/types/output/impl/utils/parseRows.test.d.mts.map +1 -0
- package/types/output/impl/utils/queryBuilder.d.mts +68 -0
- package/types/output/impl/utils/queryBuilder.d.mts.map +1 -0
- package/types/output/impl/utils/queryBuilder.test.d.mts +2 -0
- package/types/output/impl/utils/queryBuilder.test.d.mts.map +1 -0
- package/types/output/impl/utils/queryString.d.mts +9 -0
- package/types/output/impl/utils/queryString.d.mts.map +1 -0
- package/types/output/impl/utils/queryString.test.d.mts +2 -0
- package/types/output/impl/utils/queryString.test.d.mts.map +1 -0
- package/types/output/impl/utils/trackedEmitter.d.mts +7 -0
- package/types/output/impl/utils/trackedEmitter.d.mts.map +1 -0
- package/{impl → types/output/impl/utils}/transactionErrors.d.mts +16 -31
- package/types/output/impl/utils/transactionErrors.d.mts.map +1 -0
- package/types/output/index.d.mts +32 -0
- package/types/output/index.d.mts.map +1 -0
- package/types/output/index.test.d.mts +2 -0
- package/types/output/index.test.d.mts.map +1 -0
- package/types/output/schema/config.d.mts +90 -0
- package/types/output/schema/config.d.mts.map +1 -0
- package/types/output/schema/couch/couch.input.schema.d.ts +29 -0
- package/types/output/schema/couch/couch.input.schema.d.ts.map +1 -0
- package/types/output/schema/couch/couch.output.schema.d.ts +113 -0
- package/types/output/schema/couch/couch.output.schema.d.ts.map +1 -0
- package/types/output/schema/sugar/lock.d.mts +19 -0
- package/types/output/schema/sugar/lock.d.mts.map +1 -0
- package/types/output/schema/sugar/watch.d.mts +11 -0
- package/types/output/schema/sugar/watch.d.mts.map +1 -0
- package/types/output/schema/util.d.mts +85 -0
- package/types/output/schema/util.d.mts.map +1 -0
- package/types/output/tsdown.config.d.ts +3 -0
- package/types/output/tsdown.config.d.ts.map +1 -0
- package/types/output/types/standard-schema.d.ts +60 -0
- package/types/output/types/standard-schema.d.ts.map +1 -0
- package/types/standard-schema.ts +76 -0
- package/types/utils.d.ts +1 -0
- package/cjs/impl/bulk.cjs +0 -275
- package/cjs/impl/changes.cjs +0 -67
- package/cjs/impl/crud.cjs +0 -127
- package/cjs/impl/errors.cjs +0 -75
- package/cjs/impl/logger.cjs +0 -70
- package/cjs/impl/patch.cjs +0 -95
- package/cjs/impl/query.cjs +0 -116
- package/cjs/impl/queryBuilder.cjs +0 -163
- package/cjs/impl/retry.cjs +0 -55
- package/cjs/impl/stream.cjs +0 -121
- package/cjs/impl/sugar/lock.cjs +0 -81
- package/cjs/impl/sugar/watch.cjs +0 -159
- package/cjs/impl/trackedEmitter.cjs +0 -54
- package/cjs/impl/transactionErrors.cjs +0 -70
- package/cjs/impl/util.cjs +0 -64
- package/cjs/index.cjs +0 -132
- package/cjs/integration/changes.cjs +0 -76
- package/cjs/integration/disconnect-watch.cjs +0 -52
- package/cjs/integration/watch.cjs +0 -59
- package/cjs/schema/bind.cjs +0 -59
- package/cjs/schema/bulk.cjs +0 -92
- package/cjs/schema/changes.cjs +0 -68
- package/cjs/schema/config.cjs +0 -48
- package/cjs/schema/crud.cjs +0 -77
- package/cjs/schema/patch.cjs +0 -53
- package/cjs/schema/query.cjs +0 -62
- package/cjs/schema/stream.cjs +0 -42
- package/cjs/schema/sugar/lock.cjs +0 -59
- package/cjs/schema/sugar/watch.cjs +0 -42
- package/cjs/schema/util.cjs +0 -39
- package/config.json +0 -5
- package/docs/compiler.png +0 -0
- package/dualmode.config.json +0 -11
- package/impl/bulk.d.mts +0 -11
- package/impl/bulk.d.mts.map +0 -1
- package/impl/bulk.mjs +0 -291
- package/impl/changes.d.mts +0 -12
- package/impl/changes.d.mts.map +0 -1
- package/impl/changes.mjs +0 -53
- package/impl/crud.d.mts +0 -7
- package/impl/crud.d.mts.map +0 -1
- package/impl/crud.mjs +0 -108
- package/impl/errors.d.mts +0 -43
- package/impl/errors.d.mts.map +0 -1
- package/impl/errors.mjs +0 -65
- package/impl/logger.d.mts +0 -32
- package/impl/logger.d.mts.map +0 -1
- package/impl/logger.mjs +0 -59
- package/impl/patch.d.mts +0 -6
- package/impl/patch.d.mts.map +0 -1
- package/impl/patch.mjs +0 -88
- package/impl/query.d.mts +0 -195
- package/impl/query.d.mts.map +0 -1
- package/impl/query.mjs +0 -122
- package/impl/queryBuilder.d.mts +0 -154
- package/impl/queryBuilder.d.mts.map +0 -1
- package/impl/queryBuilder.mjs +0 -175
- package/impl/retry.d.mts +0 -2
- package/impl/retry.d.mts.map +0 -1
- package/impl/retry.mjs +0 -39
- package/impl/stream.d.mts +0 -3
- package/impl/stream.d.mts.map +0 -1
- package/impl/stream.mjs +0 -98
- package/impl/sugar/lock.d.mts +0 -5
- package/impl/sugar/lock.d.mts.map +0 -1
- package/impl/sugar/lock.mjs +0 -70
- package/impl/sugar/watch.d.mts +0 -34
- package/impl/sugar/watch.d.mts.map +0 -1
- package/impl/trackedEmitter.d.mts +0 -8
- package/impl/trackedEmitter.d.mts.map +0 -1
- package/impl/transactionErrors.d.mts.map +0 -1
- package/impl/transactionErrors.mjs +0 -47
- package/impl/util.d.mts +0 -3
- package/impl/util.d.mts.map +0 -1
- package/impl/util.mjs +0 -35
- package/index.d.mts +0 -80
- package/index.d.mts.map +0 -1
- package/index.mjs +0 -141
- package/integration/changes.mjs +0 -60
- package/integration/disconnect-watch.mjs +0 -36
- package/integration/watch.mjs +0 -40
- package/log.txt +0 -580
- package/schema/bind.d.mts +0 -5461
- package/schema/bind.d.mts.map +0 -1
- package/schema/bind.mjs +0 -43
- package/schema/bulk.d.mts +0 -923
- package/schema/bulk.d.mts.map +0 -1
- package/schema/bulk.mjs +0 -83
- package/schema/changes.d.mts +0 -191
- package/schema/changes.d.mts.map +0 -1
- package/schema/changes.mjs +0 -59
- package/schema/config.d.mts +0 -79
- package/schema/config.d.mts.map +0 -1
- package/schema/config.mjs +0 -26
- package/schema/crud.d.mts +0 -491
- package/schema/crud.d.mts.map +0 -1
- package/schema/crud.mjs +0 -64
- package/schema/patch.d.mts +0 -255
- package/schema/patch.d.mts.map +0 -1
- package/schema/patch.mjs +0 -42
- package/schema/query.d.mts +0 -406
- package/schema/query.d.mts.map +0 -1
- package/schema/query.mjs +0 -45
- package/schema/stream.d.mts +0 -211
- package/schema/stream.d.mts.map +0 -1
- package/schema/stream.mjs +0 -23
- package/schema/sugar/lock.d.mts +0 -238
- package/schema/sugar/lock.d.mts.map +0 -1
- package/schema/sugar/lock.mjs +0 -50
- package/schema/sugar/watch.d.mts +0 -127
- package/schema/sugar/watch.d.mts.map +0 -1
- package/schema/sugar/watch.mjs +0 -29
- package/schema/util.d.mts +0 -160
- package/schema/util.d.mts.map +0 -1
- package/schema/util.mjs +0 -35
- package/types/changes-stream.d.ts +0 -11
package/impl/changes.mjs
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import needle from 'needle'
|
|
3
|
-
import { EventEmitter } from 'events'
|
|
4
|
-
import { Changes } from '../schema/changes.mjs'
|
|
5
|
-
|
|
6
|
-
/** @typedef {{
|
|
7
|
-
* seq: string|number,
|
|
8
|
-
* id: string,
|
|
9
|
-
* changes: Array<{rev: string}>,
|
|
10
|
-
* deleted?: boolean,
|
|
11
|
-
* doc?: any
|
|
12
|
-
* }} ChangeInfo */
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
import ChangesStream from 'changes-stream'
|
|
15
|
-
|
|
16
|
-
/** @type { import('../schema/changes.mjs').ChangesSchema } */
|
|
17
|
-
export const changes = Changes.implement(async (config, onChange, options = {}) => {
|
|
18
|
-
const emitter = new EventEmitter()
|
|
19
|
-
options.db = config.couch
|
|
20
|
-
if (options.since && options.since === 'now') {
|
|
21
|
-
const opts = {
|
|
22
|
-
json: true,
|
|
23
|
-
headers: {
|
|
24
|
-
'Content-Type': 'application/json'
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
// request the GET on config.couch and get the update_seq
|
|
28
|
-
const resp = await needle('get', config.couch, opts)
|
|
29
|
-
options.since = resp.body.update_seq
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const changes = ChangesStream(options)
|
|
33
|
-
|
|
34
|
-
changes.on('readable', () => {
|
|
35
|
-
const change = changes.read()
|
|
36
|
-
if (change.results && Array.isArray(change.results)) {
|
|
37
|
-
// emit each one seperate
|
|
38
|
-
change.results.forEach((/** @type {ChangeInfo} */ c) => emitter.emit('change', c))
|
|
39
|
-
} else emitter.emit('change', change)
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
// Bind the provided change listener
|
|
43
|
-
emitter.on('change', onChange)
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
on: (event, listener) => emitter.on(event, listener),
|
|
47
|
-
removeListener: (event, listener) => emitter.removeListener(event, listener),
|
|
48
|
-
stop: () => {
|
|
49
|
-
changes.destroy()
|
|
50
|
-
emitter.removeAllListeners()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
})
|
package/impl/crud.d.mts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** @type { import('../schema/crud.mjs').CouchGetSchema } */
|
|
2
|
-
export const get: import("../schema/crud.mjs").CouchGetSchema;
|
|
3
|
-
/** @type { import('../schema/crud.mjs').CouchGetAtRevSchema } */
|
|
4
|
-
export const getAtRev: import("../schema/crud.mjs").CouchGetAtRevSchema;
|
|
5
|
-
/** @type { import('../schema/crud.mjs').CouchPutSchema } */
|
|
6
|
-
export const put: import("../schema/crud.mjs").CouchPutSchema;
|
|
7
|
-
//# sourceMappingURL=crud.d.mts.map
|
package/impl/crud.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crud.d.mts","sourceRoot":"","sources":["crud.mjs"],"names":[],"mappings":"AAoDA,4DAA4D;AAC5D,kBADY,OAAO,oBAAoB,EAAE,cAAc,CAIrD;AAEF,iEAAiE;AACjE,uBADY,OAAO,oBAAoB,EAAE,mBAAmB,CAI1D;AAEF,4DAA4D;AAC5D,kBADY,OAAO,oBAAoB,EAAE,cAAc,CA2CrD"}
|
package/impl/crud.mjs
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
import needle from 'needle'
|
|
3
|
-
import { CouchGet, CouchPut, CouchGetWithOptions, CouchGetAtRev } from '../schema/crud.mjs'
|
|
4
|
-
import { RetryableError, NotFoundError } from './errors.mjs'
|
|
5
|
-
import { createLogger } from './logger.mjs'
|
|
6
|
-
|
|
7
|
-
/** @type { import('../schema/crud.mjs').CouchGetWithOptionsSchema } */
|
|
8
|
-
const _getWithOptions = CouchGetWithOptions.implement(async (config, id, getOpts) => {
|
|
9
|
-
const logger = createLogger(config)
|
|
10
|
-
const rev = getOpts?.rev
|
|
11
|
-
const path = rev ? `${id}?rev=${rev}` : id
|
|
12
|
-
const url = `${config.couch}/${path}`
|
|
13
|
-
const opts = {
|
|
14
|
-
json: true,
|
|
15
|
-
headers: {
|
|
16
|
-
'Content-Type': 'application/json'
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
logger.info(`Getting document with id: ${id}, rev ${rev || 'latest'}`)
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const resp = await needle('get', url, opts)
|
|
23
|
-
if (!resp) {
|
|
24
|
-
logger.error('No response received from get request')
|
|
25
|
-
throw new RetryableError('no response', 503)
|
|
26
|
-
}
|
|
27
|
-
const result = resp?.body || {}
|
|
28
|
-
if (resp.statusCode === 404) {
|
|
29
|
-
if (config.throwOnGetNotFound) {
|
|
30
|
-
logger.warn(`Document not found (throwing error): ${id}, rev ${rev || 'latest'}`)
|
|
31
|
-
throw new NotFoundError(id, result.reason || 'not_found')
|
|
32
|
-
} else {
|
|
33
|
-
logger.debug(`Document not found (returning undefined): ${id}, rev ${rev || 'latest'}`)
|
|
34
|
-
return null
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
if (RetryableError.isRetryableStatusCode(resp.statusCode)) {
|
|
38
|
-
logger.warn(`Retryable status code received: ${resp.statusCode}`)
|
|
39
|
-
throw new RetryableError(result.reason || 'retryable error', resp.statusCode)
|
|
40
|
-
}
|
|
41
|
-
if (resp.statusCode !== 200) {
|
|
42
|
-
logger.error(`Unexpected status code: ${resp.statusCode}`)
|
|
43
|
-
throw new Error(result.reason || 'failed')
|
|
44
|
-
}
|
|
45
|
-
logger.info(`Successfully retrieved document: ${id}, rev ${rev || 'latest'}`)
|
|
46
|
-
return result
|
|
47
|
-
} catch (err) {
|
|
48
|
-
logger.error('Error during get operation:', err)
|
|
49
|
-
RetryableError.handleNetworkError(err)
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
/** @type { import('../schema/crud.mjs').CouchGetSchema } */
|
|
54
|
-
export const get = CouchGet.implement(async (config, id) => {
|
|
55
|
-
const getOptions = {}
|
|
56
|
-
return _getWithOptions(config, id, getOptions)
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
/** @type { import('../schema/crud.mjs').CouchGetAtRevSchema } */
|
|
60
|
-
export const getAtRev = CouchGetAtRev.implement(async (config, id, rev) => {
|
|
61
|
-
const getOptions = { rev }
|
|
62
|
-
return _getWithOptions(config, id, getOptions)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
/** @type { import('../schema/crud.mjs').CouchPutSchema } */
|
|
66
|
-
export const put = CouchPut.implement(async (config, doc) => {
|
|
67
|
-
const logger = createLogger(config)
|
|
68
|
-
const url = `${config.couch}/${doc._id}`
|
|
69
|
-
const body = doc
|
|
70
|
-
const opts = {
|
|
71
|
-
json: true,
|
|
72
|
-
headers: {
|
|
73
|
-
'Content-Type': 'application/json'
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
logger.info(`Putting document with id: ${doc._id}`)
|
|
78
|
-
let resp
|
|
79
|
-
try {
|
|
80
|
-
resp = await needle('put', url, body, opts)
|
|
81
|
-
} catch (err) {
|
|
82
|
-
logger.error('Error during put operation:', err)
|
|
83
|
-
RetryableError.handleNetworkError(err)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!resp) {
|
|
87
|
-
logger.error('No response received from put request')
|
|
88
|
-
throw new RetryableError('no response', 503)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const result = resp?.body || {}
|
|
92
|
-
result.statusCode = resp.statusCode
|
|
93
|
-
|
|
94
|
-
if (resp.statusCode === 409) {
|
|
95
|
-
logger.warn(`Conflict detected for document: ${doc._id}`)
|
|
96
|
-
result.ok = false
|
|
97
|
-
result.error = 'conflict'
|
|
98
|
-
return result
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (RetryableError.isRetryableStatusCode(resp.statusCode)) {
|
|
102
|
-
logger.warn(`Retryable status code received: ${resp.statusCode}`)
|
|
103
|
-
throw new RetryableError(result.reason || 'retryable error', resp.statusCode)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
logger.info(`Successfully saved document: ${doc._id}`)
|
|
107
|
-
return result
|
|
108
|
-
})
|
package/impl/errors.d.mts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} NetworkError
|
|
3
|
-
* @property {string} code - The error code
|
|
4
|
-
* @property {string} [message] - Optional error message
|
|
5
|
-
*/
|
|
6
|
-
export class NotFoundError extends Error {
|
|
7
|
-
/**
|
|
8
|
-
* @param {string} docId - The ID of the document that wasn't found
|
|
9
|
-
* @param {string} [message] - Optional error message
|
|
10
|
-
*/
|
|
11
|
-
constructor(docId: string, message?: string | undefined);
|
|
12
|
-
docId: string;
|
|
13
|
-
}
|
|
14
|
-
export class RetryableError extends Error {
|
|
15
|
-
/**
|
|
16
|
-
* @param {number|undefined} statusCode - The HTTP status code to check
|
|
17
|
-
* @returns {boolean} Whether the status code is retryable
|
|
18
|
-
*/
|
|
19
|
-
static isRetryableStatusCode(statusCode: number | undefined): boolean;
|
|
20
|
-
/**
|
|
21
|
-
* @param {NetworkError | unknown} err - The network error to handle
|
|
22
|
-
* @throws {RetryableError} If the error is retryable
|
|
23
|
-
* @throws {Error} If the error is not retryable
|
|
24
|
-
*/
|
|
25
|
-
static handleNetworkError(err: NetworkError | unknown): void;
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} message - The error message
|
|
28
|
-
* @param {number|undefined} statusCode - The HTTP status code
|
|
29
|
-
*/
|
|
30
|
-
constructor(message: string, statusCode: number | undefined);
|
|
31
|
-
statusCode: number | undefined;
|
|
32
|
-
}
|
|
33
|
-
export type NetworkError = {
|
|
34
|
-
/**
|
|
35
|
-
* - The error code
|
|
36
|
-
*/
|
|
37
|
-
code: string;
|
|
38
|
-
/**
|
|
39
|
-
* - Optional error message
|
|
40
|
-
*/
|
|
41
|
-
message?: string | undefined;
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=errors.d.mts.map
|
package/impl/errors.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["errors.mjs"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH;IACE;;;OAGG;IACH,mBAHW,MAAM,gCAOhB;IADC,cAAkB;CAErB;AAED;IAWE;;;OAGG;IACH,yCAHW,MAAM,GAAC,SAAS,GACd,OAAO,CAKnB;IAED;;;;OAIG;IACH,+BAJW,YAAY,GAAG,OAAO,QAsBhC;IA1CD;;;OAGG;IACH,qBAHW,MAAM,cACN,MAAM,GAAC,SAAS,EAM1B;IADC,+BAA4B;CAoC/B;;;;;UA5Da,MAAM"}
|
package/impl/errors.mjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @typedef {Object} NetworkError
|
|
5
|
-
* @property {string} code - The error code
|
|
6
|
-
* @property {string} [message] - Optional error message
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export class NotFoundError extends Error {
|
|
10
|
-
/**
|
|
11
|
-
* @param {string} docId - The ID of the document that wasn't found
|
|
12
|
-
* @param {string} [message] - Optional error message
|
|
13
|
-
*/
|
|
14
|
-
constructor (docId, message = 'Document not found') {
|
|
15
|
-
super(message)
|
|
16
|
-
this.name = 'NotFoundError'
|
|
17
|
-
this.docId = docId
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class RetryableError extends Error {
|
|
22
|
-
/**
|
|
23
|
-
* @param {string} message - The error message
|
|
24
|
-
* @param {number|undefined} statusCode - The HTTP status code
|
|
25
|
-
*/
|
|
26
|
-
constructor (message, statusCode) {
|
|
27
|
-
super(message)
|
|
28
|
-
this.name = 'RetryableError'
|
|
29
|
-
this.statusCode = statusCode
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @param {number|undefined} statusCode - The HTTP status code to check
|
|
34
|
-
* @returns {boolean} Whether the status code is retryable
|
|
35
|
-
*/
|
|
36
|
-
static isRetryableStatusCode (statusCode) {
|
|
37
|
-
if (statusCode === undefined) return false
|
|
38
|
-
return [408, 429, 500, 502, 503, 504].includes(statusCode)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param {NetworkError | unknown} err - The network error to handle
|
|
43
|
-
* @throws {RetryableError} If the error is retryable
|
|
44
|
-
* @throws {Error} If the error is not retryable
|
|
45
|
-
*/
|
|
46
|
-
static handleNetworkError (err) {
|
|
47
|
-
/** @type {Record<string, number>} */
|
|
48
|
-
const networkErrors = {
|
|
49
|
-
ECONNREFUSED: 503,
|
|
50
|
-
ECONNRESET: 503,
|
|
51
|
-
ETIMEDOUT: 503,
|
|
52
|
-
ENETUNREACH: 503,
|
|
53
|
-
ENOTFOUND: 503,
|
|
54
|
-
EPIPE: 503,
|
|
55
|
-
EHOSTUNREACH: 503,
|
|
56
|
-
ESOCKETTIMEDOUT: 503
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Type guard for NetworkError shape
|
|
60
|
-
if (typeof err === 'object' && err !== null && 'code' in err && typeof err.code === 'string' && networkErrors[err.code]) {
|
|
61
|
-
throw new RetryableError(`Network error: ${err.code}`, networkErrors[err.code])
|
|
62
|
-
}
|
|
63
|
-
throw err
|
|
64
|
-
}
|
|
65
|
-
}
|
package/impl/logger.d.mts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} Logger
|
|
3
|
-
* @property {(...args: any[]) => void} error - Log error messages
|
|
4
|
-
* @property {(...args: any[]) => void} warn - Log warning messages
|
|
5
|
-
* @property {(...args: any[]) => void} info - Log info messages
|
|
6
|
-
* @property {(...args: any[]) => void} debug - Log debug messages
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Creates a unified logger interface that works with both function and object-style loggers
|
|
10
|
-
* @param {import('../schema/config.mjs').CouchConfigSchema} config
|
|
11
|
-
* @returns {Logger} Normalized logger interface
|
|
12
|
-
*/
|
|
13
|
-
export function createLogger(config: import("../schema/config.mjs").CouchConfigSchema): Logger;
|
|
14
|
-
export type Logger = {
|
|
15
|
-
/**
|
|
16
|
-
* - Log error messages
|
|
17
|
-
*/
|
|
18
|
-
error: (...args: any[]) => void;
|
|
19
|
-
/**
|
|
20
|
-
* - Log warning messages
|
|
21
|
-
*/
|
|
22
|
-
warn: (...args: any[]) => void;
|
|
23
|
-
/**
|
|
24
|
-
* - Log info messages
|
|
25
|
-
*/
|
|
26
|
-
info: (...args: any[]) => void;
|
|
27
|
-
/**
|
|
28
|
-
* - Log debug messages
|
|
29
|
-
*/
|
|
30
|
-
debug: (...args: any[]) => void;
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=logger.d.mts.map
|
package/impl/logger.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.mts","sourceRoot":"","sources":["logger.mjs"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;GAIG;AACH,qCAHW,OAAO,sBAAsB,EAAE,iBAAiB,GAC9C,MAAM,CA+ClB;;;;;WAxDa,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;;;;UACxB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;;;;UACxB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI;;;;WACxB,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI"}
|
package/impl/logger.mjs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {Object} Logger
|
|
3
|
-
* @property {(...args: any[]) => void} error - Log error messages
|
|
4
|
-
* @property {(...args: any[]) => void} warn - Log warning messages
|
|
5
|
-
* @property {(...args: any[]) => void} info - Log info messages
|
|
6
|
-
* @property {(...args: any[]) => void} debug - Log debug messages
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Creates a unified logger interface that works with both function and object-style loggers
|
|
11
|
-
* @param {import('../schema/config.mjs').CouchConfigSchema} config
|
|
12
|
-
* @returns {Logger} Normalized logger interface
|
|
13
|
-
*/
|
|
14
|
-
export function createLogger (config) {
|
|
15
|
-
// Return cached logger if it exists
|
|
16
|
-
if (config._normalizedLogger) {
|
|
17
|
-
return config._normalizedLogger
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// If no logger provided, use console if useConsoleLogger is set, otherwise return no-op logger
|
|
21
|
-
if (!config.logger) {
|
|
22
|
-
if (config.useConsoleLogger) {
|
|
23
|
-
config._normalizedLogger = {
|
|
24
|
-
error: (...args) => console.error(...args),
|
|
25
|
-
warn: (...args) => console.warn(...args),
|
|
26
|
-
info: (...args) => console.info(...args),
|
|
27
|
-
debug: (...args) => console.debug(...args)
|
|
28
|
-
}
|
|
29
|
-
} else {
|
|
30
|
-
config._normalizedLogger = {
|
|
31
|
-
error: () => {},
|
|
32
|
-
warn: () => {},
|
|
33
|
-
info: () => {},
|
|
34
|
-
debug: () => {}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return config._normalizedLogger
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// If logger is a function, wrap it to provide object interface
|
|
41
|
-
if (typeof config.logger === 'function') {
|
|
42
|
-
config._normalizedLogger = {
|
|
43
|
-
error: (...args) => config.logger('error', ...args),
|
|
44
|
-
warn: (...args) => config.logger('warn', ...args),
|
|
45
|
-
info: (...args) => config.logger('info', ...args),
|
|
46
|
-
debug: (...args) => config.logger('debug', ...args)
|
|
47
|
-
}
|
|
48
|
-
return config._normalizedLogger
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// If logger is an object, use its methods or provide no-ops for missing ones
|
|
52
|
-
config._normalizedLogger = {
|
|
53
|
-
error: config.logger.error || (() => {}),
|
|
54
|
-
warn: config.logger.warn || (() => {}),
|
|
55
|
-
info: config.logger.info || (() => {}),
|
|
56
|
-
debug: config.logger.debug || (() => {})
|
|
57
|
-
}
|
|
58
|
-
return config._normalizedLogger
|
|
59
|
-
}
|
package/impl/patch.d.mts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export function sleep(ms: any): Promise<any>;
|
|
2
|
-
/** @type { import('../schema/patch.mjs').PatchSchema } */
|
|
3
|
-
export const patch: import("../schema/patch.mjs").PatchSchema;
|
|
4
|
-
/** @type { import('../schema/patch.mjs').PatchDangerouslySchema } */
|
|
5
|
-
export const patchDangerously: import("../schema/patch.mjs").PatchDangerouslySchema;
|
|
6
|
-
//# sourceMappingURL=patch.d.mts.map
|
package/impl/patch.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.mts","sourceRoot":"","sources":["patch.mjs"],"names":[],"mappings":"AAIO,6CAAmE;AAE1E,0DAA0D;AAC1D,oBADY,OAAO,qBAAqB,EAAE,WAAW,CAmBnD;AAEF,qEAAqE;AACrE,+BADY,OAAO,qBAAqB,EAAE,sBAAsB,CA4D9D"}
|
package/impl/patch.mjs
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { get, put } from './crud.mjs'
|
|
2
|
-
import { Patch, PatchDangerously } from '../schema/patch.mjs'
|
|
3
|
-
import { createLogger } from './logger.mjs'
|
|
4
|
-
|
|
5
|
-
export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
|
6
|
-
|
|
7
|
-
/** @type { import('../schema/patch.mjs').PatchSchema } */
|
|
8
|
-
export const patch = Patch.implement(async (config, id, properties) => {
|
|
9
|
-
const logger = createLogger(config)
|
|
10
|
-
|
|
11
|
-
logger.info(`Starting patch operation for document ${id}`)
|
|
12
|
-
logger.debug('Patch properties:', properties)
|
|
13
|
-
const doc = await get(config, id)
|
|
14
|
-
if (doc._rev !== properties._rev) {
|
|
15
|
-
const result = {}
|
|
16
|
-
result.ok = false
|
|
17
|
-
result.error = 'conflict'
|
|
18
|
-
result.statusCode = 409
|
|
19
|
-
return result
|
|
20
|
-
}
|
|
21
|
-
const updatedDoc = { ...doc, ...properties }
|
|
22
|
-
logger.debug('Merged document:', updatedDoc)
|
|
23
|
-
const result = await put(config, updatedDoc)
|
|
24
|
-
logger.info(`Successfully patched document ${id}, rev: ${result.rev}`)
|
|
25
|
-
return result
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
/** @type { import('../schema/patch.mjs').PatchDangerouslySchema } */
|
|
29
|
-
export const patchDangerously = PatchDangerously.implement(async (config, id, properties) => {
|
|
30
|
-
const logger = createLogger(config)
|
|
31
|
-
const maxRetries = config.maxRetries || 5
|
|
32
|
-
let delay = config.initialDelay || 1000
|
|
33
|
-
let attempts = 0
|
|
34
|
-
|
|
35
|
-
logger.info(`Starting patch operation for document ${id}`)
|
|
36
|
-
logger.debug('Patch properties:', properties)
|
|
37
|
-
|
|
38
|
-
while (attempts <= maxRetries) {
|
|
39
|
-
logger.debug(`Attempt ${attempts + 1} of ${maxRetries + 1}`)
|
|
40
|
-
try {
|
|
41
|
-
const doc = await get(config, id)
|
|
42
|
-
if (!doc) {
|
|
43
|
-
logger.warn(`Document ${id} not found`)
|
|
44
|
-
return { ok: false, statusCode: 404, error: 'not_found' }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const updatedDoc = { ...doc, ...properties }
|
|
48
|
-
logger.debug('Merged document:', updatedDoc)
|
|
49
|
-
|
|
50
|
-
const result = await put(config, updatedDoc)
|
|
51
|
-
|
|
52
|
-
// Check if the response indicates a conflict
|
|
53
|
-
if (result.ok) {
|
|
54
|
-
logger.info(`Successfully patched document ${id}, rev: ${result.rev}`)
|
|
55
|
-
return result
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// If not ok, treat as conflict and retry
|
|
59
|
-
attempts++
|
|
60
|
-
if (attempts > maxRetries) {
|
|
61
|
-
logger.error(`Failed to patch ${id} after ${maxRetries} attempts`)
|
|
62
|
-
throw new Error(`Failed to patch after ${maxRetries} attempts`)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
logger.warn(`Conflict detected for ${id}, retrying (attempt ${attempts})`)
|
|
66
|
-
await sleep(delay)
|
|
67
|
-
delay *= config.backoffFactor
|
|
68
|
-
logger.debug(`Next retry delay: ${delay}ms`)
|
|
69
|
-
} catch (err) {
|
|
70
|
-
if (err.message === 'not_found') {
|
|
71
|
-
logger.warn(`Document ${id} not found during patch operation`)
|
|
72
|
-
return { ok: false, statusCode: 404, error: 'not_found' }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Handle other errors (network, etc)
|
|
76
|
-
attempts++
|
|
77
|
-
if (attempts > maxRetries) {
|
|
78
|
-
const error = `Failed to patch after ${maxRetries} attempts: ${err.message}`
|
|
79
|
-
logger.error(error)
|
|
80
|
-
return { ok: false, statusCode: 500, error }
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
logger.warn(`Error during patch attempt ${attempts}: ${err.message}`)
|
|
84
|
-
await sleep(delay)
|
|
85
|
-
logger.debug(`Retrying after ${delay}ms`)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
})
|
package/impl/query.d.mts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {{ [key: string]: any }} options - The options object containing query parameters.
|
|
3
|
-
* @param {string[]} params - The list of parameter names to include in the query string.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @param {{ [key: string]: any }} options
|
|
7
|
-
* @param {string[]} params
|
|
8
|
-
* @returns {string}
|
|
9
|
-
*/
|
|
10
|
-
export function queryString(options: {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
} | undefined, params: string[]): string;
|
|
13
|
-
/**
|
|
14
|
-
* @type { z.infer<SimpleViewQuery> }
|
|
15
|
-
* @param {import('../schema/config.mjs').CouchConfigSchema} config
|
|
16
|
-
* @param {string} view
|
|
17
|
-
* @param {import('../schema/query.mjs').SimpleViewOptionsSchema} [options]
|
|
18
|
-
*/
|
|
19
|
-
export const query: z.infer<z.ZodFunction<z.ZodTuple<[z.ZodObject<{
|
|
20
|
-
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
21
|
-
couch: z.ZodString;
|
|
22
|
-
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
23
|
-
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
24
|
-
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
25
|
-
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
26
|
-
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
27
|
-
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
28
|
-
error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
29
|
-
warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
30
|
-
info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
31
|
-
debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
32
|
-
}, "strip", z.ZodTypeAny, {
|
|
33
|
-
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
34
|
-
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
35
|
-
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
36
|
-
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
37
|
-
}, {
|
|
38
|
-
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
39
|
-
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
40
|
-
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
41
|
-
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
42
|
-
}>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
|
|
43
|
-
_normalizedLogger: z.ZodOptional<z.ZodAny>;
|
|
44
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
45
|
-
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
46
|
-
couch: z.ZodString;
|
|
47
|
-
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
48
|
-
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
49
|
-
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
50
|
-
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
51
|
-
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
52
|
-
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
53
|
-
error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
54
|
-
warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
55
|
-
info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
56
|
-
debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
57
|
-
}, "strip", z.ZodTypeAny, {
|
|
58
|
-
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
59
|
-
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
60
|
-
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
61
|
-
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
62
|
-
}, {
|
|
63
|
-
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
64
|
-
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
65
|
-
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
66
|
-
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
67
|
-
}>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
|
|
68
|
-
_normalizedLogger: z.ZodOptional<z.ZodAny>;
|
|
69
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
70
|
-
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
71
|
-
couch: z.ZodString;
|
|
72
|
-
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
73
|
-
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
74
|
-
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
75
|
-
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
76
|
-
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
77
|
-
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
78
|
-
error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
79
|
-
warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
80
|
-
info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
81
|
-
debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
82
|
-
}, "strip", z.ZodTypeAny, {
|
|
83
|
-
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
84
|
-
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
85
|
-
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
86
|
-
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
87
|
-
}, {
|
|
88
|
-
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
89
|
-
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
90
|
-
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
91
|
-
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
92
|
-
}>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
|
|
93
|
-
_normalizedLogger: z.ZodOptional<z.ZodAny>;
|
|
94
|
-
}, z.ZodTypeAny, "passthrough">>, z.ZodString, z.ZodOptional<z.ZodObject<{
|
|
95
|
-
startkey: z.ZodOptional<z.ZodAny>;
|
|
96
|
-
endkey: z.ZodOptional<z.ZodAny>;
|
|
97
|
-
descending: z.ZodOptional<z.ZodBoolean>;
|
|
98
|
-
skip: z.ZodOptional<z.ZodNumber>;
|
|
99
|
-
limit: z.ZodOptional<z.ZodNumber>;
|
|
100
|
-
key: z.ZodOptional<z.ZodAny>;
|
|
101
|
-
keys: z.ZodOptional<z.ZodArray<z.ZodAny, "many">>;
|
|
102
|
-
include_docs: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
-
reduce: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
-
group: z.ZodOptional<z.ZodBoolean>;
|
|
105
|
-
group_level: z.ZodOptional<z.ZodNumber>;
|
|
106
|
-
}, "strip", z.ZodTypeAny, {
|
|
107
|
-
startkey?: any;
|
|
108
|
-
endkey?: any;
|
|
109
|
-
descending?: boolean | undefined;
|
|
110
|
-
skip?: number | undefined;
|
|
111
|
-
limit?: number | undefined;
|
|
112
|
-
key?: any;
|
|
113
|
-
keys?: any[] | undefined;
|
|
114
|
-
include_docs?: boolean | undefined;
|
|
115
|
-
reduce?: boolean | undefined;
|
|
116
|
-
group?: boolean | undefined;
|
|
117
|
-
group_level?: number | undefined;
|
|
118
|
-
}, {
|
|
119
|
-
startkey?: any;
|
|
120
|
-
endkey?: any;
|
|
121
|
-
descending?: boolean | undefined;
|
|
122
|
-
skip?: number | undefined;
|
|
123
|
-
limit?: number | undefined;
|
|
124
|
-
key?: any;
|
|
125
|
-
keys?: any[] | undefined;
|
|
126
|
-
include_docs?: boolean | undefined;
|
|
127
|
-
reduce?: boolean | undefined;
|
|
128
|
-
group?: boolean | undefined;
|
|
129
|
-
group_level?: number | undefined;
|
|
130
|
-
}>>], z.ZodUnknown>, z.ZodPromise<z.ZodObject<{
|
|
131
|
-
error: z.ZodOptional<z.ZodString>;
|
|
132
|
-
rows: z.ZodArray<z.ZodObject<{
|
|
133
|
-
id: z.ZodOptional<z.ZodString>;
|
|
134
|
-
key: z.ZodNullable<z.ZodAny>;
|
|
135
|
-
value: z.ZodNullable<z.ZodAny>;
|
|
136
|
-
doc: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>>>;
|
|
137
|
-
error: z.ZodOptional<z.ZodString>;
|
|
138
|
-
}, "strip", z.ZodTypeAny, {
|
|
139
|
-
id?: string | undefined;
|
|
140
|
-
key?: any;
|
|
141
|
-
value?: any;
|
|
142
|
-
doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
143
|
-
error?: string | undefined;
|
|
144
|
-
}, {
|
|
145
|
-
id?: string | undefined;
|
|
146
|
-
key?: any;
|
|
147
|
-
value?: any;
|
|
148
|
-
doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
149
|
-
error?: string | undefined;
|
|
150
|
-
}>, "many">;
|
|
151
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
152
|
-
error: z.ZodOptional<z.ZodString>;
|
|
153
|
-
rows: z.ZodArray<z.ZodObject<{
|
|
154
|
-
id: z.ZodOptional<z.ZodString>;
|
|
155
|
-
key: z.ZodNullable<z.ZodAny>;
|
|
156
|
-
value: z.ZodNullable<z.ZodAny>;
|
|
157
|
-
doc: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>>>;
|
|
158
|
-
error: z.ZodOptional<z.ZodString>;
|
|
159
|
-
}, "strip", z.ZodTypeAny, {
|
|
160
|
-
id?: string | undefined;
|
|
161
|
-
key?: any;
|
|
162
|
-
value?: any;
|
|
163
|
-
doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
164
|
-
error?: string | undefined;
|
|
165
|
-
}, {
|
|
166
|
-
id?: string | undefined;
|
|
167
|
-
key?: any;
|
|
168
|
-
value?: any;
|
|
169
|
-
doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
170
|
-
error?: string | undefined;
|
|
171
|
-
}>, "many">;
|
|
172
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
173
|
-
error: z.ZodOptional<z.ZodString>;
|
|
174
|
-
rows: z.ZodArray<z.ZodObject<{
|
|
175
|
-
id: z.ZodOptional<z.ZodString>;
|
|
176
|
-
key: z.ZodNullable<z.ZodAny>;
|
|
177
|
-
value: z.ZodNullable<z.ZodAny>;
|
|
178
|
-
doc: z.ZodOptional<z.ZodNullable<z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>>>;
|
|
179
|
-
error: z.ZodOptional<z.ZodString>;
|
|
180
|
-
}, "strip", z.ZodTypeAny, {
|
|
181
|
-
id?: string | undefined;
|
|
182
|
-
key?: any;
|
|
183
|
-
value?: any;
|
|
184
|
-
doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
185
|
-
error?: string | undefined;
|
|
186
|
-
}, {
|
|
187
|
-
id?: string | undefined;
|
|
188
|
-
key?: any;
|
|
189
|
-
value?: any;
|
|
190
|
-
doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | null | undefined;
|
|
191
|
-
error?: string | undefined;
|
|
192
|
-
}>, "many">;
|
|
193
|
-
}, z.ZodTypeAny, "passthrough">>>>>;
|
|
194
|
-
import { z } from 'zod';
|
|
195
|
-
//# sourceMappingURL=query.d.mts.map
|