hide-a-bed 5.2.8 → 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 +46 -32
- 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/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/cjs/impl/retry.cjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var retry_exports = {};
|
|
20
|
-
__export(retry_exports, {
|
|
21
|
-
withRetry: () => withRetry
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(retry_exports);
|
|
24
|
-
var import_errors = require("./errors.cjs");
|
|
25
|
-
var import_patch = require("./patch.cjs");
|
|
26
|
-
function withRetry(fn, options = {}) {
|
|
27
|
-
const {
|
|
28
|
-
maxRetries = 3,
|
|
29
|
-
initialDelay = 1e3,
|
|
30
|
-
// 1 second
|
|
31
|
-
backoffFactor = 2,
|
|
32
|
-
// exponential backoff multiplier
|
|
33
|
-
maxDelay = 3e4
|
|
34
|
-
// 30 seconds max delay
|
|
35
|
-
} = options;
|
|
36
|
-
return async (...args) => {
|
|
37
|
-
let delay = initialDelay;
|
|
38
|
-
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
39
|
-
try {
|
|
40
|
-
const result = await fn(...args);
|
|
41
|
-
return result;
|
|
42
|
-
} catch (error) {
|
|
43
|
-
if (!(error instanceof import_errors.RetryableError)) {
|
|
44
|
-
throw error;
|
|
45
|
-
}
|
|
46
|
-
if (attempt === maxRetries) {
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
const nextDelay = Math.min(delay, maxDelay);
|
|
50
|
-
await (0, import_patch.sleep)(nextDelay);
|
|
51
|
-
delay *= backoffFactor;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
package/cjs/impl/stream.cjs
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var stream_exports = {};
|
|
30
|
-
__export(stream_exports, {
|
|
31
|
-
queryStream: () => queryStream
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(stream_exports);
|
|
34
|
-
var import_needle = __toESM(require("needle"), 1);
|
|
35
|
-
var import_config = require("../schema/config.cjs");
|
|
36
|
-
var import_query = require("./query.cjs");
|
|
37
|
-
var import_errors = require("./errors.cjs");
|
|
38
|
-
var import_logger = require("./logger.cjs");
|
|
39
|
-
var import_JSONStream = __toESM(require("JSONStream"), 1);
|
|
40
|
-
const queryStream = (rawConfig, view, options, onRow) => new Promise((resolve, reject) => {
|
|
41
|
-
const config = import_config.CouchConfig.parse(rawConfig);
|
|
42
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
43
|
-
logger.info(`Starting view query stream: ${view}`);
|
|
44
|
-
logger.debug("Query options:", options);
|
|
45
|
-
if (!options) options = {};
|
|
46
|
-
let method = "GET";
|
|
47
|
-
let payload = null;
|
|
48
|
-
let qs = (0, import_query.queryString)(options, ["key", "startkey", "endkey", "reduce", "group", "group_level", "stale", "limit"]);
|
|
49
|
-
logger.debug("Generated query string:", qs);
|
|
50
|
-
if (typeof options.keys !== "undefined") {
|
|
51
|
-
const MAX_URL_LENGTH = 2e3;
|
|
52
|
-
const keysAsString = `keys=${encodeURIComponent(JSON.stringify(options.keys))}`;
|
|
53
|
-
if (keysAsString.length + qs.length + 1 <= MAX_URL_LENGTH) {
|
|
54
|
-
qs += (qs[0] === "?" ? "&" : "?") + keysAsString;
|
|
55
|
-
} else {
|
|
56
|
-
method = "POST";
|
|
57
|
-
payload = { keys: options.keys };
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const url = `${config.couch}/${view}?${qs.toString()}`;
|
|
61
|
-
const opts = {
|
|
62
|
-
json: true,
|
|
63
|
-
headers: {
|
|
64
|
-
"Content-Type": "application/json"
|
|
65
|
-
},
|
|
66
|
-
parse_response: false
|
|
67
|
-
// Keep as stream
|
|
68
|
-
};
|
|
69
|
-
const streamer = import_JSONStream.default.parse("rows.*");
|
|
70
|
-
let rowCount = 0;
|
|
71
|
-
streamer.on(
|
|
72
|
-
"data",
|
|
73
|
-
/** @param {object} row */
|
|
74
|
-
(row) => {
|
|
75
|
-
rowCount++;
|
|
76
|
-
onRow(row);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
streamer.on(
|
|
80
|
-
"error",
|
|
81
|
-
/** @param {Error} err */
|
|
82
|
-
(err) => {
|
|
83
|
-
logger.error("Stream parsing error:", err);
|
|
84
|
-
reject(new Error(`Stream parsing error: ${err.message}`));
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
streamer.on(
|
|
88
|
-
"done",
|
|
89
|
-
/** @param {Error|null} err */
|
|
90
|
-
(err) => {
|
|
91
|
-
try {
|
|
92
|
-
import_errors.RetryableError.handleNetworkError(err);
|
|
93
|
-
} catch (e) {
|
|
94
|
-
reject(e);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
streamer.on("end", () => {
|
|
99
|
-
logger.info(`Stream completed, processed ${rowCount} rows`);
|
|
100
|
-
resolve(void 0);
|
|
101
|
-
});
|
|
102
|
-
const req = method === "GET" ? import_needle.default.get(url, opts) : import_needle.default.post(url, payload, opts);
|
|
103
|
-
req.on("response", (response) => {
|
|
104
|
-
logger.debug(`Received response with status code: ${response.statusCode}`);
|
|
105
|
-
if (import_errors.RetryableError.isRetryableStatusCode(response.statusCode)) {
|
|
106
|
-
logger.warn(`Retryable status code received: ${response.statusCode}`);
|
|
107
|
-
reject(new import_errors.RetryableError("retryable error during stream query", response.statusCode));
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
req.on("error", (err) => {
|
|
111
|
-
logger.error("Network error during stream query:", err);
|
|
112
|
-
try {
|
|
113
|
-
import_errors.RetryableError.handleNetworkError(err);
|
|
114
|
-
} catch (retryErr) {
|
|
115
|
-
reject(retryErr);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
reject(err);
|
|
119
|
-
});
|
|
120
|
-
req.pipe(streamer);
|
|
121
|
-
});
|
package/cjs/impl/sugar/lock.cjs
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var lock_exports = {};
|
|
20
|
-
__export(lock_exports, {
|
|
21
|
-
createLock: () => createLock,
|
|
22
|
-
removeLock: () => removeLock
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(lock_exports);
|
|
25
|
-
var import_lock = require("../../schema/sugar/lock.cjs");
|
|
26
|
-
var import_crud = require("../crud.cjs");
|
|
27
|
-
var import_logger = require("../logger.cjs");
|
|
28
|
-
const createLock = import_lock.CreateLock.implement(async (config, docId, options) => {
|
|
29
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
30
|
-
if (!options.enableLocking) {
|
|
31
|
-
logger.debug("Locking disabled, returning true");
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
const _id = `lock-${docId}`;
|
|
35
|
-
const lock = {
|
|
36
|
-
_id,
|
|
37
|
-
type: "lock",
|
|
38
|
-
locks: docId,
|
|
39
|
-
lockedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
40
|
-
lockedBy: options.username
|
|
41
|
-
};
|
|
42
|
-
try {
|
|
43
|
-
const result = await (0, import_crud.put)(config, lock);
|
|
44
|
-
logger.info(`Lock created for ${docId} by ${options.username}`);
|
|
45
|
-
return result.ok === true;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
if (error.status === 409) {
|
|
48
|
-
logger.warn(`Lock conflict for ${docId} - already locked`);
|
|
49
|
-
} else {
|
|
50
|
-
logger.error(`Error creating lock for ${docId}:`, error);
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const removeLock = import_lock.RemoveLock.implement(async (config, docId, options) => {
|
|
56
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
57
|
-
if (!options.enableLocking) {
|
|
58
|
-
logger.debug("Locking disabled, skipping unlock");
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
if (!docId) {
|
|
62
|
-
logger.warn("No docId provided for unlock");
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const _id = `lock-${docId}`;
|
|
66
|
-
const existingLock = await (0, import_crud.get)(config, _id);
|
|
67
|
-
if (!existingLock) {
|
|
68
|
-
logger.debug(`No lock found for ${docId}`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (existingLock.lockedBy !== options.username) {
|
|
72
|
-
logger.warn(`Cannot remove lock for ${docId} - owned by ${existingLock.lockedBy}`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
await (0, import_crud.put)(config, { ...existingLock, _deleted: true });
|
|
77
|
-
logger.info(`Lock removed for ${docId}`);
|
|
78
|
-
} catch (error) {
|
|
79
|
-
logger.error(`Error removing lock for ${docId}:`, error);
|
|
80
|
-
}
|
|
81
|
-
});
|
package/cjs/impl/sugar/watch.cjs
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var watch_exports = {};
|
|
30
|
-
__export(watch_exports, {
|
|
31
|
-
watchDocs: () => watchDocs
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(watch_exports);
|
|
34
|
-
var import_needle = __toESM(require("needle"), 1);
|
|
35
|
-
var import_events = require("events");
|
|
36
|
-
var import_errors = require("../errors.cjs");
|
|
37
|
-
var import_logger = require("../logger.cjs");
|
|
38
|
-
var import_patch = require("../patch.cjs");
|
|
39
|
-
var import_watch = require("../../schema/sugar/watch.cjs");
|
|
40
|
-
const watchDocs = import_watch.WatchDocs.implement((config, docIds, onChange, options = {}) => {
|
|
41
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
42
|
-
const emitter = new import_events.EventEmitter();
|
|
43
|
-
let lastSeq = "now";
|
|
44
|
-
let stopping = false;
|
|
45
|
-
let retryCount = 0;
|
|
46
|
-
let currentRequest = null;
|
|
47
|
-
const maxRetries = options.maxRetries || 10;
|
|
48
|
-
const initialDelay = options.initialDelay || 1e3;
|
|
49
|
-
const maxDelay = options.maxDelay || 3e4;
|
|
50
|
-
const _docIds = Array.isArray(docIds) ? docIds : [docIds];
|
|
51
|
-
if (_docIds.length === 0) throw new Error("docIds must be a non-empty array");
|
|
52
|
-
if (_docIds.length > 100) throw new Error("docIds must be an array of 100 or fewer elements");
|
|
53
|
-
const connect = async () => {
|
|
54
|
-
if (stopping) return;
|
|
55
|
-
const feed = "continuous";
|
|
56
|
-
const includeDocs = options.include_docs ?? false;
|
|
57
|
-
const ids = _docIds.join('","');
|
|
58
|
-
const url = `${config.couch}/_changes?feed=${feed}&since=${lastSeq}&include_docs=${includeDocs}&filter=_doc_ids&doc_ids=["${ids}"]`;
|
|
59
|
-
const opts = {
|
|
60
|
-
headers: { "Content-Type": "application/json" },
|
|
61
|
-
parse_response: false
|
|
62
|
-
};
|
|
63
|
-
let buffer = "";
|
|
64
|
-
currentRequest = import_needle.default.get(url, opts);
|
|
65
|
-
currentRequest.on("data", (chunk) => {
|
|
66
|
-
buffer += chunk.toString();
|
|
67
|
-
const lines = buffer.split("\n");
|
|
68
|
-
buffer = lines.pop() || "";
|
|
69
|
-
for (const line of lines) {
|
|
70
|
-
if (line.trim()) {
|
|
71
|
-
try {
|
|
72
|
-
const change = JSON.parse(line);
|
|
73
|
-
if (!change.id) return null;
|
|
74
|
-
logger.debug(`Change detected, watching [${_docIds}]`, change);
|
|
75
|
-
lastSeq = change.seq || change.last_seq;
|
|
76
|
-
emitter.emit("change", change);
|
|
77
|
-
} catch (err) {
|
|
78
|
-
logger.error("Error parsing change:", err, "Line:", line);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
currentRequest.on("response", (response) => {
|
|
84
|
-
logger.debug(`Received response with status code, watching [${_docIds}]: ${response.statusCode}`);
|
|
85
|
-
if (import_errors.RetryableError.isRetryableStatusCode(response.statusCode)) {
|
|
86
|
-
logger.warn(`Retryable status code received: ${response.statusCode}`);
|
|
87
|
-
currentRequest.abort();
|
|
88
|
-
handleReconnect();
|
|
89
|
-
} else {
|
|
90
|
-
retryCount = 0;
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
currentRequest.on("error", async (err) => {
|
|
94
|
-
if (stopping) {
|
|
95
|
-
logger.info("stopping in progress, ignore stream error");
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
logger.error(`Network error during stream, watching [${_docIds}]:`, err.toString());
|
|
99
|
-
try {
|
|
100
|
-
import_errors.RetryableError.handleNetworkError(err);
|
|
101
|
-
} catch (filteredError) {
|
|
102
|
-
if (filteredError instanceof import_errors.RetryableError) {
|
|
103
|
-
logger.info(`Retryable error, watching [${_docIds}]:`, filteredError.toString());
|
|
104
|
-
handleReconnect();
|
|
105
|
-
} else {
|
|
106
|
-
logger.error(`Non-retryable error, watching [${_docIds}]`, filteredError.toString());
|
|
107
|
-
emitter.emit("error", filteredError);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
currentRequest.on("end", () => {
|
|
112
|
-
if (buffer.trim()) {
|
|
113
|
-
try {
|
|
114
|
-
const change = JSON.parse(buffer);
|
|
115
|
-
logger.debug("Final change detected:", change);
|
|
116
|
-
emitter.emit("change", change);
|
|
117
|
-
} catch (err) {
|
|
118
|
-
logger.error("Error parsing final change:", err);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
logger.info("Stream completed. Last seen seq: ", lastSeq);
|
|
122
|
-
emitter.emit("end", { lastSeq });
|
|
123
|
-
if (!stopping) {
|
|
124
|
-
handleReconnect();
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
const handleReconnect = async () => {
|
|
129
|
-
if (stopping || retryCount >= maxRetries) {
|
|
130
|
-
if (retryCount >= maxRetries) {
|
|
131
|
-
logger.error(`Max retries (${maxRetries}) reached, giving up`);
|
|
132
|
-
emitter.emit("error", new Error("Max retries reached"));
|
|
133
|
-
}
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
const delay = Math.min(initialDelay * Math.pow(2, retryCount), maxDelay);
|
|
137
|
-
retryCount++;
|
|
138
|
-
logger.info(`Attempting to reconnect in ${delay}ms (attempt ${retryCount} of ${maxRetries})`);
|
|
139
|
-
await (0, import_patch.sleep)(delay);
|
|
140
|
-
try {
|
|
141
|
-
connect();
|
|
142
|
-
} catch (err) {
|
|
143
|
-
logger.error("Error during reconnection:", err);
|
|
144
|
-
handleReconnect();
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
connect();
|
|
148
|
-
emitter.on("change", onChange);
|
|
149
|
-
return {
|
|
150
|
-
on: (event, listener) => emitter.on(event, listener),
|
|
151
|
-
removeListener: (event, listener) => emitter.removeListener(event, listener),
|
|
152
|
-
stop: () => {
|
|
153
|
-
stopping = true;
|
|
154
|
-
if (currentRequest) currentRequest.abort();
|
|
155
|
-
emitter.emit("end", { lastSeq });
|
|
156
|
-
emitter.removeAllListeners();
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
});
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var trackedEmitter_exports = {};
|
|
20
|
-
__export(trackedEmitter_exports, {
|
|
21
|
-
TrackedEmitter: () => TrackedEmitter,
|
|
22
|
-
setupEmitter: () => setupEmitter
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(trackedEmitter_exports);
|
|
25
|
-
var import_events = require("events");
|
|
26
|
-
class TrackedEmitter extends import_events.EventEmitter {
|
|
27
|
-
// create a constructor with some options
|
|
28
|
-
constructor(options) {
|
|
29
|
-
super(options);
|
|
30
|
-
if (options.delay) this.delay = options.delay;
|
|
31
|
-
}
|
|
32
|
-
emit(event, ...args) {
|
|
33
|
-
const listeners = this.listeners(event);
|
|
34
|
-
let completed = 0;
|
|
35
|
-
return new Promise((resolve) => {
|
|
36
|
-
if (!listeners || listeners.length === 0) {
|
|
37
|
-
return resolve();
|
|
38
|
-
}
|
|
39
|
-
listeners.forEach((listener) => {
|
|
40
|
-
listener(...args);
|
|
41
|
-
completed++;
|
|
42
|
-
if (completed === listeners.length) {
|
|
43
|
-
if (!this.delay) resolve();
|
|
44
|
-
setTimeout(resolve, this.delay);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
const setupEmitter = (config) => {
|
|
51
|
-
if (!config._emitter) return { emit: async () => {
|
|
52
|
-
} };
|
|
53
|
-
return config._emitter;
|
|
54
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var transactionErrors_exports = {};
|
|
20
|
-
__export(transactionErrors_exports, {
|
|
21
|
-
TransactionBulkOperationError: () => TransactionBulkOperationError,
|
|
22
|
-
TransactionRollbackError: () => TransactionRollbackError,
|
|
23
|
-
TransactionSetupError: () => TransactionSetupError,
|
|
24
|
-
TransactionVersionConflictError: () => TransactionVersionConflictError
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(transactionErrors_exports);
|
|
27
|
-
class TransactionSetupError extends Error {
|
|
28
|
-
/**
|
|
29
|
-
* @param {string} message
|
|
30
|
-
* @param {Record<string, any>} details
|
|
31
|
-
*/
|
|
32
|
-
constructor(message, details = {}) {
|
|
33
|
-
super(message);
|
|
34
|
-
this.name = "TransactionSetupError";
|
|
35
|
-
this.details = details;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
class TransactionVersionConflictError extends Error {
|
|
39
|
-
/**
|
|
40
|
-
* @param {string[]} conflictingIds
|
|
41
|
-
*/
|
|
42
|
-
constructor(conflictingIds) {
|
|
43
|
-
super(`Revision mismatch for documents: ${conflictingIds.join(", ")}`);
|
|
44
|
-
this.name = "TransactionVersionConflictError";
|
|
45
|
-
this.conflictingIds = conflictingIds;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
class TransactionBulkOperationError extends Error {
|
|
49
|
-
/**
|
|
50
|
-
* @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} failedDocs
|
|
51
|
-
*/
|
|
52
|
-
constructor(failedDocs) {
|
|
53
|
-
super(`Failed to save documents: ${failedDocs.map((d) => d.id).join(", ")}`);
|
|
54
|
-
this.name = "TransactionBulkOperationError";
|
|
55
|
-
this.failedDocs = failedDocs;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
class TransactionRollbackError extends Error {
|
|
59
|
-
/**
|
|
60
|
-
* @param {string} message
|
|
61
|
-
* @param {Error} originalError
|
|
62
|
-
* @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} rollbackResults
|
|
63
|
-
*/
|
|
64
|
-
constructor(message, originalError, rollbackResults) {
|
|
65
|
-
super(message);
|
|
66
|
-
this.name = "TransactionRollbackError";
|
|
67
|
-
this.originalError = originalError;
|
|
68
|
-
this.rollbackResults = rollbackResults;
|
|
69
|
-
}
|
|
70
|
-
}
|
package/cjs/impl/util.cjs
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var util_exports = {};
|
|
30
|
-
__export(util_exports, {
|
|
31
|
-
getDBInfo: () => getDBInfo
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(util_exports);
|
|
34
|
-
var import_needle = __toESM(require("needle"), 1);
|
|
35
|
-
var import_errors = require("./errors.cjs");
|
|
36
|
-
var import_logger = require("./logger.cjs");
|
|
37
|
-
var import_util = require("../schema/util.cjs");
|
|
38
|
-
const getDBInfo = import_util.GetDBInfo.implement(async (config) => {
|
|
39
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
40
|
-
const url = `${config.couch}`;
|
|
41
|
-
const opts = {
|
|
42
|
-
json: true,
|
|
43
|
-
headers: {
|
|
44
|
-
"Content-Type": "application/json"
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
let resp;
|
|
48
|
-
try {
|
|
49
|
-
resp = await (0, import_needle.default)("get", url, opts);
|
|
50
|
-
} catch (err) {
|
|
51
|
-
logger.error("Error during put operation:", err);
|
|
52
|
-
import_errors.RetryableError.handleNetworkError(err);
|
|
53
|
-
}
|
|
54
|
-
if (!resp) {
|
|
55
|
-
logger.error("No response received from put request");
|
|
56
|
-
throw new import_errors.RetryableError("no response", 503);
|
|
57
|
-
}
|
|
58
|
-
const result = resp.body;
|
|
59
|
-
if (import_errors.RetryableError.isRetryableStatusCode(resp.statusCode)) {
|
|
60
|
-
logger.warn(`Retryable status code received: ${resp.statusCode}`);
|
|
61
|
-
throw new import_errors.RetryableError(result.reason || "retryable error", resp.statusCode);
|
|
62
|
-
}
|
|
63
|
-
return result;
|
|
64
|
-
});
|