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/index.mts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createQuery } from './impl/utils/queryBuilder.mts'
|
|
2
|
+
import { QueryBuilder } from './impl/utils/queryBuilder.mts'
|
|
3
|
+
import { bindConfig } from './impl/bindConfig.mts'
|
|
4
|
+
import { withRetry } from './impl/retry.mts'
|
|
5
|
+
import { bulkGet, bulkGetDictionary } from './impl/bulkGet.mts'
|
|
6
|
+
import { getAtRev, get } from './impl/get.mts'
|
|
7
|
+
import { queryStream } from './impl/stream.mts'
|
|
8
|
+
import { patch, patchDangerously } from './impl/patch.mts'
|
|
9
|
+
import { put } from './impl/put.mts'
|
|
10
|
+
import { remove } from './impl/remove.mts'
|
|
11
|
+
import { bulkSave, bulkSaveTransaction } from './impl/bulkSave.mts'
|
|
12
|
+
import { query } from './impl/query.mts'
|
|
13
|
+
import { getDBInfo } from './impl/getDBInfo.mts'
|
|
14
|
+
import { bulkRemove, bulkRemoveMap } from './impl/bulkRemove.mts'
|
|
15
|
+
import { createLock, removeLock } from './impl/sugar/lock.mts'
|
|
16
|
+
import { watchDocs } from './impl/sugar/watch.mts'
|
|
17
|
+
|
|
18
|
+
export {
|
|
19
|
+
get,
|
|
20
|
+
getAtRev,
|
|
21
|
+
put,
|
|
22
|
+
remove,
|
|
23
|
+
bulkGet,
|
|
24
|
+
bulkSave,
|
|
25
|
+
query,
|
|
26
|
+
queryStream,
|
|
27
|
+
getDBInfo,
|
|
28
|
+
|
|
29
|
+
// sugar methods
|
|
30
|
+
patch,
|
|
31
|
+
patchDangerously,
|
|
32
|
+
bulkRemove,
|
|
33
|
+
bulkRemoveMap,
|
|
34
|
+
bulkGetDictionary,
|
|
35
|
+
bulkSaveTransaction,
|
|
36
|
+
watchDocs,
|
|
37
|
+
|
|
38
|
+
// binding
|
|
39
|
+
bindConfig,
|
|
40
|
+
withRetry,
|
|
41
|
+
|
|
42
|
+
// utils
|
|
43
|
+
QueryBuilder,
|
|
44
|
+
createQuery,
|
|
45
|
+
createLock,
|
|
46
|
+
removeLock
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export type {
|
|
50
|
+
BulkGetBound,
|
|
51
|
+
BulkGetDictionaryBound,
|
|
52
|
+
BulkGetDictionaryOptions,
|
|
53
|
+
BulkGetDictionaryResult,
|
|
54
|
+
BulkGetOptions,
|
|
55
|
+
BulkGetResponse
|
|
56
|
+
} from './impl/bulkGet.mts'
|
|
57
|
+
export type { OnInvalidDocAction } from './impl/utils/parseRows.mts'
|
|
58
|
+
export type { GetOptions, GetBound, GetAtRevBound } from './impl/get.mts'
|
|
59
|
+
export type { QueryBound } from './impl/query.mts'
|
|
60
|
+
export type {
|
|
61
|
+
ViewString,
|
|
62
|
+
ViewOptions as SimpleViewOptions
|
|
63
|
+
} from './schema/couch/couch.input.schema.ts'
|
|
64
|
+
export type {
|
|
65
|
+
ViewRow,
|
|
66
|
+
CouchDoc,
|
|
67
|
+
CouchDocInput,
|
|
68
|
+
ViewQueryResponse,
|
|
69
|
+
ViewQueryResponseValidated,
|
|
70
|
+
ViewRowValidated
|
|
71
|
+
} from './schema/couch/couch.output.schema.ts'
|
|
72
|
+
export type { RetryOptions } from './impl/retry.mts'
|
|
73
|
+
export type { NetworkError, RetryableError, NotFoundError } from './impl/utils/errors.mts'
|
|
74
|
+
export type { OnRow } from './impl/stream.mts'
|
|
75
|
+
export type { CouchConfig, CouchConfigInput } from './schema/config.mts'
|
|
76
|
+
export type { LockOptions, LockOptionsInput, LockDoc } from './schema/sugar/lock.mts'
|
|
77
|
+
export type {
|
|
78
|
+
WatchOptions as WatchOptionsSchema,
|
|
79
|
+
WatchOptionsInput
|
|
80
|
+
} from './schema/sugar/watch.mts'
|
|
81
|
+
export type { BoundInstance } from './impl/bindConfig.mts'
|
|
82
|
+
export type { StandardSchemaV1 } from './types/standard-schema.ts'
|
package/index.test.mts
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
import assert from 'node:assert/strict'
|
|
2
|
+
import test, { suite } from 'node:test'
|
|
3
|
+
import { TrackedEmitter } from './impl/utils/trackedEmitter.mts'
|
|
4
|
+
import { bulkSaveTransaction, get } from './index.mts'
|
|
5
|
+
import { bindConfig } from './impl/bindConfig.mts'
|
|
6
|
+
import z from 'zod'
|
|
7
|
+
import { TEST_DB_URL } from './test/setup-db.mts'
|
|
8
|
+
import {
|
|
9
|
+
TransactionRollbackError,
|
|
10
|
+
TransactionVersionConflictError
|
|
11
|
+
} from './impl/utils/transactionErrors.mts'
|
|
12
|
+
|
|
13
|
+
const config: Parameters<typeof get>[0] = {
|
|
14
|
+
couch: TEST_DB_URL,
|
|
15
|
+
bindWithRetry: true,
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
logger: (level: string, ...args: any[]) => {
|
|
18
|
+
console.log(`[${level.toUpperCase()}]`, ...args)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
suite('Database Tests', () => {
|
|
23
|
+
test('full db tests', async t => {
|
|
24
|
+
const db = bindConfig(config)
|
|
25
|
+
const test_doc_id = `test-doc-${Date.now()}`
|
|
26
|
+
|
|
27
|
+
await t.test('simple get/put', async () => {
|
|
28
|
+
const doc = await db.put({ _id: test_doc_id, data: 'hello world' })
|
|
29
|
+
assert.ok(doc.ok, 'Document created')
|
|
30
|
+
const fetched = await db.get(test_doc_id)
|
|
31
|
+
assert.strictEqual(fetched?.data, 'hello world', 'Fetched document matches')
|
|
32
|
+
})
|
|
33
|
+
await t.test('get with no document', async () => {
|
|
34
|
+
const notThereDoc = await get(config, 'test-doc-not-there')
|
|
35
|
+
assert.strictEqual(notThereDoc, null)
|
|
36
|
+
})
|
|
37
|
+
await t.test('override config with different options', async () => {
|
|
38
|
+
try {
|
|
39
|
+
await db.options({ throwOnGetNotFound: true }).get('test-doc-not-there-override')
|
|
40
|
+
assert.fail('should have thrown')
|
|
41
|
+
} catch (e: unknown) {
|
|
42
|
+
if (!(e instanceof Error)) throw e
|
|
43
|
+
console.error(e)
|
|
44
|
+
assert.strictEqual(e.name, 'NotFoundError')
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
await t.test('get with no document and throwOnGetNotFound', async () => {
|
|
48
|
+
const _config = { couch: TEST_DB_URL, throwOnGetNotFound: true }
|
|
49
|
+
try {
|
|
50
|
+
await get(_config, 'test-doc-not-there')
|
|
51
|
+
assert.fail('should have thrown')
|
|
52
|
+
} catch (e: unknown) {
|
|
53
|
+
if (!(e instanceof Error)) throw e
|
|
54
|
+
console.log(e.message)
|
|
55
|
+
assert.strictEqual(e.name, 'NotFoundError')
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
await t.test('put with bad rev', async () => {
|
|
59
|
+
const doc = { _id: 'notThereDoc', _rev: '32-does-not-compute' }
|
|
60
|
+
const notThereDoc = await db.put(doc)
|
|
61
|
+
assert.ok(!notThereDoc.ok)
|
|
62
|
+
assert.strictEqual(notThereDoc.error, 'conflict')
|
|
63
|
+
console.log(notThereDoc)
|
|
64
|
+
})
|
|
65
|
+
await t.test('bulk get, including one doc that does not exist', async () => {
|
|
66
|
+
const results = await db.bulkGet([test_doc_id, 'notThereDoc'])
|
|
67
|
+
assert.strictEqual(results.rows?.length, 2, 'two rows returned')
|
|
68
|
+
assert.strictEqual(results.rows[0].id, test_doc_id)
|
|
69
|
+
assert.strictEqual(results.rows[1].error, 'not_found')
|
|
70
|
+
console.log(results)
|
|
71
|
+
})
|
|
72
|
+
await t.test('bulk get validates docs with schema', async () => {
|
|
73
|
+
const schema_doc_id = `schema-doc-${Date.now()}`
|
|
74
|
+
await db.put({ _id: schema_doc_id, kind: 'example', data: 'hello' })
|
|
75
|
+
|
|
76
|
+
const schema = z.looseObject({
|
|
77
|
+
_id: z.string(),
|
|
78
|
+
kind: z.literal('example'),
|
|
79
|
+
data: z.string()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
const validated = await db.bulkGet([schema_doc_id], {
|
|
83
|
+
validate: {
|
|
84
|
+
docSchema: schema
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
assert.strictEqual(validated.rows[0].doc?.kind, 'example', 'doc schema applied')
|
|
88
|
+
|
|
89
|
+
await assert.rejects(
|
|
90
|
+
async () =>
|
|
91
|
+
db.bulkGet([schema_doc_id], {
|
|
92
|
+
validate: {
|
|
93
|
+
docSchema: z.object({
|
|
94
|
+
_id: z.string(),
|
|
95
|
+
data: z.number()
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
}),
|
|
99
|
+
(err: unknown) => Array.isArray(err)
|
|
100
|
+
)
|
|
101
|
+
})
|
|
102
|
+
await t.test('get validates docs with schema', async () => {
|
|
103
|
+
const docId = `get-schema-doc-${Date.now()}`
|
|
104
|
+
const { rev } = await db.put({
|
|
105
|
+
_id: docId,
|
|
106
|
+
kind: 'example',
|
|
107
|
+
data: 'hello'
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const schema = z.looseObject({
|
|
111
|
+
_id: z.string(),
|
|
112
|
+
kind: z.literal('example'),
|
|
113
|
+
data: z.string()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const validated = await db.get(docId, {
|
|
117
|
+
validate: {
|
|
118
|
+
docSchema: schema
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
assert.strictEqual(validated?.kind, 'example', 'doc schema applied to get')
|
|
122
|
+
|
|
123
|
+
const atRev = await db.getAtRev(docId, rev!, {
|
|
124
|
+
validate: {
|
|
125
|
+
docSchema: schema
|
|
126
|
+
}
|
|
127
|
+
})
|
|
128
|
+
assert.strictEqual(atRev?.data, 'hello', 'getAtRev also validates doc schema')
|
|
129
|
+
|
|
130
|
+
await assert.rejects(
|
|
131
|
+
async () =>
|
|
132
|
+
get(config, docId, {
|
|
133
|
+
validate: {
|
|
134
|
+
docSchema: z.object({
|
|
135
|
+
_id: z.string(),
|
|
136
|
+
data: z.number()
|
|
137
|
+
})
|
|
138
|
+
}
|
|
139
|
+
}),
|
|
140
|
+
(err: unknown) => Array.isArray(err) && err[0].message.includes('Invalid input:')
|
|
141
|
+
)
|
|
142
|
+
})
|
|
143
|
+
let _rev: string | null | undefined = null
|
|
144
|
+
const [doc_a, doc_b, doc_rollback] = ['a', 'b', 'rollback'].map(
|
|
145
|
+
x => `rev-test-doc-${x}-${Date.now()}`
|
|
146
|
+
)
|
|
147
|
+
await t.test('a transaction', async () => {
|
|
148
|
+
const docs = [{ _id: doc_a, data: 'something' }]
|
|
149
|
+
const resp = await bulkSaveTransaction(config, `transaction-${Date.now()}`, docs)
|
|
150
|
+
assert.strictEqual(resp.length, 1, 'one response')
|
|
151
|
+
assert.strictEqual(resp[0].ok, true, 'response ok')
|
|
152
|
+
_rev = resp[0].rev
|
|
153
|
+
assert.ok(resp)
|
|
154
|
+
})
|
|
155
|
+
await t.test('a transaction with a bad initial rev', async () => {
|
|
156
|
+
try {
|
|
157
|
+
const docs = [
|
|
158
|
+
{ _id: doc_a, data: 'something' },
|
|
159
|
+
{ _id: doc_b, data: 'new doc' }
|
|
160
|
+
]
|
|
161
|
+
await bulkSaveTransaction(config, 'random-1', docs)
|
|
162
|
+
assert.fail('should have thrown')
|
|
163
|
+
} catch (e) {
|
|
164
|
+
assert.ok(e)
|
|
165
|
+
}
|
|
166
|
+
})
|
|
167
|
+
let b_rev: string | null | undefined = null
|
|
168
|
+
await t.test('a new and an existing doc', async () => {
|
|
169
|
+
const docs = [
|
|
170
|
+
{ _id: doc_a, data: 'something', _rev },
|
|
171
|
+
{ _id: doc_b, data: 'new doc' }
|
|
172
|
+
]
|
|
173
|
+
const resp = await bulkSaveTransaction(config, `transaction-${Date.now()}`, docs)
|
|
174
|
+
assert.ok(resp)
|
|
175
|
+
assert.strictEqual(resp.length, 2, 'one response')
|
|
176
|
+
assert.strictEqual(resp[0].ok, true, 'response ok')
|
|
177
|
+
_rev = resp[0].rev
|
|
178
|
+
b_rev = resp[1].rev
|
|
179
|
+
assert.strictEqual(resp[1].ok, true, 'response ok')
|
|
180
|
+
assert.ok(resp[0].rev?.startsWith('2-'), 'second rev saved')
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
await t.test(
|
|
184
|
+
'testing a rollback where one doc was interfered with in the transaction',
|
|
185
|
+
async () => {
|
|
186
|
+
const _config = config
|
|
187
|
+
const emitter = new TrackedEmitter({ delay: 300 })
|
|
188
|
+
config['~emitter'] = emitter
|
|
189
|
+
const docs = [
|
|
190
|
+
{ _id: doc_a, data: 'before-rollback', _rev }, // this doc gets interfered with in-between commit - so will be 'interfered'
|
|
191
|
+
{ _id: doc_rollback, data: 'new doc' }, // this doc will get removed
|
|
192
|
+
{ _id: doc_b, _rev: b_rev, data: 'should-not-be' } // this will not be committed. result will be from b doc above 'new doc'
|
|
193
|
+
]
|
|
194
|
+
const transactionId = `transaction-${Date.now()}`
|
|
195
|
+
emitter.on('transaction-started', async txnDoc => {
|
|
196
|
+
assert.strictEqual(txnDoc._id, `txn:${transactionId}`, 'transaction id matches')
|
|
197
|
+
// lets change something!
|
|
198
|
+
docs[0].data = 'interfered'
|
|
199
|
+
const interfereResp = await db.put(docs[0])
|
|
200
|
+
assert.ok(interfereResp.ok, 'interfered with the transaction')
|
|
201
|
+
})
|
|
202
|
+
try {
|
|
203
|
+
await bulkSaveTransaction(_config, transactionId, docs)
|
|
204
|
+
assert.fail('should have thrown')
|
|
205
|
+
} catch (e: unknown) {
|
|
206
|
+
if (!(e instanceof TransactionRollbackError)) throw e
|
|
207
|
+
assert.ok(e)
|
|
208
|
+
console.log(e)
|
|
209
|
+
assert.strictEqual(e.name, 'TransactionRollbackError', 'correct error type thrown')
|
|
210
|
+
|
|
211
|
+
// lets make sure doc a has data from before, and
|
|
212
|
+
const finalDocs = await db.bulkGet([doc_a, doc_rollback, doc_b])
|
|
213
|
+
assert.strictEqual(finalDocs.rows?.length, 3, 'two rows returned')
|
|
214
|
+
assert.strictEqual(
|
|
215
|
+
finalDocs.rows[0].doc?.data,
|
|
216
|
+
'interfered',
|
|
217
|
+
'doc has the interfered data'
|
|
218
|
+
)
|
|
219
|
+
assert.ok(!finalDocs.rows[1].doc, 'doc b was deleted, and not saved')
|
|
220
|
+
assert.strictEqual(finalDocs.rows[2].doc?.data, 'new doc', 'doc b was rolled back')
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
await t.test('TransactionVersionConflictError test', async () => {
|
|
225
|
+
const conflict_doc_id = `conflict-doc-${Date.now()}`
|
|
226
|
+
const transactionId = `txn:conflict-error-${Date.now()}`
|
|
227
|
+
// First create a doc
|
|
228
|
+
await db.put({ _id: conflict_doc_id, data: 'original' })
|
|
229
|
+
// Then try to update it with wrong rev
|
|
230
|
+
try {
|
|
231
|
+
await bulkSaveTransaction(config, transactionId, [
|
|
232
|
+
{ _id: conflict_doc_id, _rev: 'wrong-rev', data: 'new' }
|
|
233
|
+
])
|
|
234
|
+
assert.fail('should have thrown TransactionVersionConflictError')
|
|
235
|
+
} catch (e: unknown) {
|
|
236
|
+
if (!(e instanceof TransactionVersionConflictError)) throw e
|
|
237
|
+
assert.strictEqual(e.name, 'TransactionVersionConflictError', 'correct error type thrown')
|
|
238
|
+
assert.deepStrictEqual(e.conflictingIds, [conflict_doc_id], 'includes conflicting doc ids')
|
|
239
|
+
}
|
|
240
|
+
})
|
|
241
|
+
await t.test('TransactionVersionConflictError test 2, new doc with _rev', async () => {
|
|
242
|
+
try {
|
|
243
|
+
const transactionId = `txn:conflict-error-2-${Date.now()}`
|
|
244
|
+
// Try to update a doc that doesn't exist with a rev
|
|
245
|
+
await bulkSaveTransaction(config, transactionId, [
|
|
246
|
+
{ _id: 'nonexistent', _rev: '1-abc', data: 'test' }
|
|
247
|
+
])
|
|
248
|
+
assert.fail('should have thrown TransactionVersionConflictError')
|
|
249
|
+
} catch (e: unknown) {
|
|
250
|
+
if (!(e instanceof TransactionVersionConflictError)) throw e
|
|
251
|
+
assert.strictEqual(e.name, 'TransactionVersionConflictError', 'correct error type thrown')
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
|
|
255
|
+
await t.test('locking tests', async t => {
|
|
256
|
+
const lockOptions = {
|
|
257
|
+
enableLocking: true,
|
|
258
|
+
username: 'testUser'
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Test successful lock creation
|
|
262
|
+
const lockDocId = `doc-to-lock-${Date.now()}`
|
|
263
|
+
await t.test('create lock', async () => {
|
|
264
|
+
const locked = await db.createLock(lockDocId, lockOptions)
|
|
265
|
+
assert.ok(locked, 'Lock was created successfully')
|
|
266
|
+
|
|
267
|
+
// Verify lock document exists
|
|
268
|
+
const lockDoc = await db.get(`lock-${lockDocId}`)
|
|
269
|
+
assert.ok(lockDoc, 'Lock document exists')
|
|
270
|
+
assert.strictEqual(lockDoc.type, 'lock', 'Document is a lock')
|
|
271
|
+
assert.strictEqual(lockDoc.locks, lockDocId, 'Correct document is locked')
|
|
272
|
+
assert.strictEqual(lockDoc.lockedBy, 'testUser', 'Lock owned by correct user')
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
// Test lock conflict
|
|
276
|
+
await t.test('lock conflict', async () => {
|
|
277
|
+
const locked = await db.createLock(lockDocId, lockOptions)
|
|
278
|
+
assert.ok(!locked, 'Second lock attempt failed')
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
// Test unlock
|
|
282
|
+
await t.test('unlock document', async () => {
|
|
283
|
+
await db.removeLock(lockDocId, lockOptions)
|
|
284
|
+
const lockDoc = await db.get(`lock-${lockDocId}`)
|
|
285
|
+
assert.ok(!lockDoc, 'Lock document was removed')
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
// Test unlock by different user
|
|
289
|
+
await t.test('unlock by different user', async () => {
|
|
290
|
+
// Create lock as testUser
|
|
291
|
+
await db.createLock(lockDocId, lockOptions)
|
|
292
|
+
|
|
293
|
+
// Try to unlock as different user
|
|
294
|
+
const differentUserOptions = {
|
|
295
|
+
...lockOptions,
|
|
296
|
+
username: 'differentUser'
|
|
297
|
+
}
|
|
298
|
+
await db.removeLock(lockDocId, differentUserOptions)
|
|
299
|
+
|
|
300
|
+
// Verify lock still exists
|
|
301
|
+
const lockDoc = await db.get(`lock-${lockDocId}`)
|
|
302
|
+
assert.ok(lockDoc, 'Lock still exists')
|
|
303
|
+
assert.strictEqual(lockDoc.lockedBy, 'testUser', 'Lock still owned by original user')
|
|
304
|
+
})
|
|
305
|
+
|
|
306
|
+
// Test with locking disabled
|
|
307
|
+
await t.test('disabled locking', async () => {
|
|
308
|
+
const disabledOptions = {
|
|
309
|
+
...lockOptions,
|
|
310
|
+
enableLocking: false
|
|
311
|
+
}
|
|
312
|
+
const locked = await db.createLock('doc-to-lock-2', disabledOptions)
|
|
313
|
+
assert.ok(locked, 'Lock creation returns true when disabled')
|
|
314
|
+
|
|
315
|
+
const lockDoc = await db.get('lock-doc-to-lock-2')
|
|
316
|
+
assert.ok(!lockDoc, 'No lock document created when disabled')
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
await t.test('empty keys on bulkGet', async () => {
|
|
320
|
+
const results = await db.bulkGet([])
|
|
321
|
+
console.log(results)
|
|
322
|
+
assert.deepStrictEqual(results.rows, [], 'empty array returns empty object')
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
await t.test('get db info', async () => {
|
|
326
|
+
const results = await db.getDBInfo()
|
|
327
|
+
assert.ok(results)
|
|
328
|
+
assert.strictEqual(results.db_name, 'hide-a-bed-test-db')
|
|
329
|
+
})
|
|
330
|
+
})
|
|
331
|
+
await t.test('bulkRemove', async () => {
|
|
332
|
+
const results = await db.bulkRemove(['test-doc-never51'])
|
|
333
|
+
assert.ok(results)
|
|
334
|
+
assert.strictEqual(results.length, 0) // not an actual doc
|
|
335
|
+
|
|
336
|
+
const remove_doc_id = `test-doc-remove-51-${Date.now()}`
|
|
337
|
+
const doc = await db.put({ _id: remove_doc_id, data: 'hello world' })
|
|
338
|
+
assert.ok(doc.ok, 'Document created')
|
|
339
|
+
const results2 = await db.bulkRemove([remove_doc_id])
|
|
340
|
+
assert.ok(results2)
|
|
341
|
+
assert.strictEqual(results2.length, 1)
|
|
342
|
+
})
|
|
343
|
+
await t.test('bulkRemoveMap', async () => {
|
|
344
|
+
const results = await db.bulkRemoveMap(['test-doc-never52'])
|
|
345
|
+
assert.ok(results)
|
|
346
|
+
assert.strictEqual(results.length, 0) // not an actual doc
|
|
347
|
+
|
|
348
|
+
const remove_doc_id = `test-doc-remove-52-${Date.now()}`
|
|
349
|
+
const doc = await db.put({ _id: remove_doc_id, data: 'hello world' })
|
|
350
|
+
assert.ok(doc.ok, 'Document created')
|
|
351
|
+
const results2 = await db.bulkRemoveMap([remove_doc_id])
|
|
352
|
+
assert.ok(results2)
|
|
353
|
+
assert.strictEqual(results2.length, 1)
|
|
354
|
+
})
|
|
355
|
+
await t.test('bulk save', async () => {
|
|
356
|
+
const doc_a_id = `bulk-save-doc-a-${Date.now()}`
|
|
357
|
+
// make sure docs with no id are accepted
|
|
358
|
+
const docs = [{ first: true }, { _id: doc_a_id, second: true }]
|
|
359
|
+
const results = await db.bulkSave(docs)
|
|
360
|
+
assert.strictEqual(results.length, 2, 'two rows returned')
|
|
361
|
+
assert.ok(results[0].id)
|
|
362
|
+
assert.strictEqual(results[1].id, doc_a_id, 'id matches')
|
|
363
|
+
})
|
|
364
|
+
await t.test('a view query with only keys', async () => {
|
|
365
|
+
const docs = [
|
|
366
|
+
{ _id: `query-1-${Date.now()}` },
|
|
367
|
+
{ _id: `query-2-${Date.now()}`, included: true },
|
|
368
|
+
{ _id: `query-3-${Date.now()}` }
|
|
369
|
+
]
|
|
370
|
+
// create a view
|
|
371
|
+
await db.put({
|
|
372
|
+
_id: '_design/test',
|
|
373
|
+
views: {
|
|
374
|
+
test: {
|
|
375
|
+
map: 'function(doc) { if (!doc.included) return; emit(doc._id, null); }'
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
})
|
|
379
|
+
await db.bulkSave(docs)
|
|
380
|
+
const queryResults = await db.query('_design/test/_view/test', {
|
|
381
|
+
keys: [docs[1]._id]
|
|
382
|
+
})
|
|
383
|
+
assert.strictEqual(queryResults.rows?.length, 1, 'one row returned')
|
|
384
|
+
assert.strictEqual(queryResults.rows[0].key, docs[1]._id, 'key matches')
|
|
385
|
+
})
|
|
386
|
+
await t.test('all docs query', async () => {
|
|
387
|
+
const query_results = await db.query('_all_docs', {})
|
|
388
|
+
assert.ok(query_results.rows)
|
|
389
|
+
})
|
|
390
|
+
await t.test('not found doc', async () => {
|
|
391
|
+
// should not throw
|
|
392
|
+
const notFound = await db.get('never-51st')
|
|
393
|
+
console.log('found status', notFound)
|
|
394
|
+
})
|
|
395
|
+
|
|
396
|
+
await t.test('remove test', async () => {
|
|
397
|
+
// First create a document to delete
|
|
398
|
+
const remove_doc_id = `delete-test-doc-${Date.now()}`
|
|
399
|
+
const doc = await db.put({ _id: remove_doc_id, data: 'to be deleted' })
|
|
400
|
+
assert.ok(doc.ok, 'Document created successfully')
|
|
401
|
+
|
|
402
|
+
// Verify the document exists
|
|
403
|
+
const fetchedDoc = await db.get(remove_doc_id)
|
|
404
|
+
assert.strictEqual(fetchedDoc?.data, 'to be deleted', 'Document exists and has correct data')
|
|
405
|
+
|
|
406
|
+
// Delete the document
|
|
407
|
+
const deleteResult = await db.remove(remove_doc_id, fetchedDoc._rev as string)
|
|
408
|
+
assert.ok(deleteResult.ok, 'Document deleted successfully')
|
|
409
|
+
|
|
410
|
+
// Verify the document no longer exists
|
|
411
|
+
const deletedDoc = await db.get(remove_doc_id)
|
|
412
|
+
assert.strictEqual(deletedDoc, null, 'Document was successfully deleted')
|
|
413
|
+
})
|
|
414
|
+
})
|
|
415
|
+
})
|
package/package.json
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hide-a-bed",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-beta.0",
|
|
4
4
|
"description": "An abstraction over couchdb calls that includes easy mock/stubs with pouchdb",
|
|
5
|
-
"module": "index.mjs",
|
|
6
|
-
"main": "cjs/index.cjs",
|
|
7
5
|
"type": "module",
|
|
8
|
-
"
|
|
6
|
+
"main": "./dist/cjs/index.cjs",
|
|
7
|
+
"module": "./dist/esm/index.mjs",
|
|
8
|
+
"types": "./types/output/index.d.mts",
|
|
9
9
|
"exports": {
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"default": "./dist/cjs/index.cjs",
|
|
11
|
+
"types": "./types/output/index.d.mts",
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./types/output/index.d.mts",
|
|
14
|
+
"default": "./dist/cjs/index.cjs"
|
|
15
|
+
},
|
|
16
|
+
"import": {
|
|
17
|
+
"types": "./types/output/index.d.mts",
|
|
18
|
+
"default": "./dist/esm/index.mjs"
|
|
19
|
+
}
|
|
13
20
|
},
|
|
14
21
|
"scripts": {
|
|
15
|
-
"clean": "rm -rf
|
|
16
|
-
"build": "npm run clean && tsc &&
|
|
17
|
-
"build:
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
22
|
+
"clean": "rm -rf types/output && rm -rf dist && (find . -name \"log.txt\" -type f -delete || true)",
|
|
23
|
+
"build": "npm run clean && tsc && tsdown",
|
|
24
|
+
"build:docs": "typedoc ./index.mts",
|
|
25
|
+
"dev": "typedoc --watch ./index.mts & npx -y serve ./docs",
|
|
26
|
+
"test": "node --test --test-global-setup ./test/setup.mts",
|
|
27
|
+
"test:watch": "node --test --watch --test-global-setup ./test/setup.mts",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"lint:fix": "eslint . --fix",
|
|
30
|
+
"format": "prettier --write .",
|
|
31
|
+
"format:check": "prettier --check .",
|
|
32
|
+
"typecheck": "tsc --noEmit",
|
|
33
|
+
"typecheck:watch": "tsc --noEmit --watch",
|
|
34
|
+
"prepublishOnly": "npm run build",
|
|
21
35
|
"full": "npm run lint:fix && npm run build && npm run clean"
|
|
22
36
|
},
|
|
23
37
|
"repository": {
|
|
@@ -35,27 +49,27 @@
|
|
|
35
49
|
},
|
|
36
50
|
"homepage": "https://github.com/ryanramage/hide-a-bed#readme",
|
|
37
51
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"zod": "^3.22.4"
|
|
52
|
+
"needle": "3.3.1",
|
|
53
|
+
"stream-chain": "3.4.0",
|
|
54
|
+
"stream-json": "1.9.1",
|
|
55
|
+
"zod": "4.2.1"
|
|
43
56
|
},
|
|
44
57
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
"@types/needle": "
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"pouchdb-server": "
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"typescript": "5.
|
|
58
|
+
"@eslint/js": "9.39.2",
|
|
59
|
+
"@types/needle": "3.3.0",
|
|
60
|
+
"@types/node": "22.19.3",
|
|
61
|
+
"@types/stream-json": "1.7.8",
|
|
62
|
+
"eslint": "9.39.2",
|
|
63
|
+
"globals": "16.5.0",
|
|
64
|
+
"pouchdb-server": "4.2.0",
|
|
65
|
+
"prettier": "3.7.4",
|
|
66
|
+
"tsdown": "0.18.1",
|
|
67
|
+
"typedoc": "0.28.15",
|
|
68
|
+
"typescript": "5.9.3",
|
|
69
|
+
"typescript-eslint": "8.50.1"
|
|
56
70
|
},
|
|
57
71
|
"volta": {
|
|
58
|
-
"node": "
|
|
59
|
-
"npm": "
|
|
72
|
+
"node": "24.12.0",
|
|
73
|
+
"npm": "11.6.2"
|
|
60
74
|
}
|
|
61
75
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod'
|
|
2
|
+
import type { StandardSchemaV1 } from '../types/standard-schema.ts'
|
|
3
|
+
|
|
4
|
+
const anyArgs = z.array(z.any())
|
|
5
|
+
|
|
6
|
+
const LoggerSchema = z
|
|
7
|
+
.object({
|
|
8
|
+
error: z.function({ input: anyArgs, output: z.void() }).optional(),
|
|
9
|
+
warn: z.function({ input: anyArgs, output: z.void() }).optional(),
|
|
10
|
+
info: z.function({ input: anyArgs, output: z.void() }).optional(),
|
|
11
|
+
debug: z.function({ input: anyArgs, output: z.void() }).optional()
|
|
12
|
+
})
|
|
13
|
+
.or(z.function({ input: anyArgs, output: z.void() }))
|
|
14
|
+
|
|
15
|
+
export const NeedleBaseOptions = z.object({
|
|
16
|
+
json: z.boolean(),
|
|
17
|
+
headers: z.record(z.string(), z.string()),
|
|
18
|
+
parse_response: z.boolean().optional()
|
|
19
|
+
})
|
|
20
|
+
export type NeedleBaseOptionsSchema = z.infer<typeof NeedleBaseOptions>
|
|
21
|
+
|
|
22
|
+
export const NeedleOptions = z.object({
|
|
23
|
+
json: z.boolean().optional(),
|
|
24
|
+
compressed: z.boolean().optional(),
|
|
25
|
+
follow_max: z.number().optional(),
|
|
26
|
+
follow_set_cookie: z.boolean().optional(),
|
|
27
|
+
follow_set_referer: z.boolean().optional(),
|
|
28
|
+
follow: z.number().optional(),
|
|
29
|
+
timeout: z.number().optional(),
|
|
30
|
+
read_timeout: z.number().optional(),
|
|
31
|
+
parse_response: z.boolean().optional(),
|
|
32
|
+
decode: z.boolean().optional(),
|
|
33
|
+
parse_cookies: z.boolean().optional(),
|
|
34
|
+
cookies: z.record(z.string(), z.string()).optional(),
|
|
35
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
36
|
+
auth: z.enum(['auto', 'digest', 'basic']).optional(),
|
|
37
|
+
username: z.string().optional(),
|
|
38
|
+
password: z.string().optional(),
|
|
39
|
+
proxy: z.string().optional(),
|
|
40
|
+
agent: z.any().optional(),
|
|
41
|
+
rejectUnauthorized: z.boolean().optional(),
|
|
42
|
+
output: z.string().optional(),
|
|
43
|
+
parse: z.boolean().optional(),
|
|
44
|
+
multipart: z.boolean().optional(),
|
|
45
|
+
open_timeout: z.number().optional(),
|
|
46
|
+
response_timeout: z.number().optional(),
|
|
47
|
+
keepAlive: z.boolean().optional()
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
export const CouchConfig = z
|
|
51
|
+
.strictObject({
|
|
52
|
+
backoffFactor: z.number().optional().default(2).describe('multiplier for exponential backoff'),
|
|
53
|
+
bindWithRetry: z.boolean().optional().default(true).describe('should we bind with retry'),
|
|
54
|
+
couch: z.string().describe('the url of the couch db'),
|
|
55
|
+
initialDelay: z
|
|
56
|
+
.number()
|
|
57
|
+
.optional()
|
|
58
|
+
.default(1000)
|
|
59
|
+
.describe('initial retry delay in milliseconds'),
|
|
60
|
+
logger: LoggerSchema.optional().describe(
|
|
61
|
+
'logging interface supporting winston-like or simple function interface'
|
|
62
|
+
),
|
|
63
|
+
maxRetries: z.number().optional().default(3).describe('maximum number of retry attempts'),
|
|
64
|
+
needleOpts: NeedleOptions.optional(),
|
|
65
|
+
throwOnGetNotFound: z
|
|
66
|
+
.boolean()
|
|
67
|
+
.optional()
|
|
68
|
+
.default(false)
|
|
69
|
+
.describe('if a get is 404 should we throw or return undefined'),
|
|
70
|
+
useConsoleLogger: z
|
|
71
|
+
.boolean()
|
|
72
|
+
.optional()
|
|
73
|
+
.default(false)
|
|
74
|
+
.describe('turn on console as a fallback logger'),
|
|
75
|
+
'~emitter': z.any().optional().describe('emitter for events'),
|
|
76
|
+
'~normalizedLogger': z.any().optional() // Internal property for caching normalized logger
|
|
77
|
+
})
|
|
78
|
+
.describe('The std config object')
|
|
79
|
+
|
|
80
|
+
export type CouchConfig = StandardSchemaV1.InferOutput<typeof CouchConfig>
|
|
81
|
+
export type CouchConfigInput = StandardSchemaV1.InferInput<typeof CouchConfig>
|