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
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const MergeNeedleOpts: z.ZodFunction<z.ZodTuple<readonly [z.ZodObject<{
|
|
3
|
+
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
4
|
+
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
5
|
+
couch: z.ZodString;
|
|
6
|
+
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
+
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
8
|
+
error: z.ZodOptional<z.ZodFunction<z.ZodArray<z.ZodAny>, z.ZodVoid>>;
|
|
9
|
+
warn: z.ZodOptional<z.ZodFunction<z.ZodArray<z.ZodAny>, z.ZodVoid>>;
|
|
10
|
+
info: z.ZodOptional<z.ZodFunction<z.ZodArray<z.ZodAny>, z.ZodVoid>>;
|
|
11
|
+
debug: z.ZodOptional<z.ZodFunction<z.ZodArray<z.ZodAny>, z.ZodVoid>>;
|
|
12
|
+
}, z.core.$strip>, z.ZodFunction<z.ZodArray<z.ZodAny>, z.ZodVoid>]>>;
|
|
13
|
+
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
14
|
+
needleOpts: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
json: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
compressed: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
follow_max: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
follow_set_cookie: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
follow_set_referer: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
follow: z.ZodOptional<z.ZodNumber>;
|
|
21
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
read_timeout: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
parse_response: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
decode: z.ZodOptional<z.ZodBoolean>;
|
|
25
|
+
parse_cookies: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
cookies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
27
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
28
|
+
auth: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
auto: "auto";
|
|
30
|
+
digest: "digest";
|
|
31
|
+
basic: "basic";
|
|
32
|
+
}>>;
|
|
33
|
+
username: z.ZodOptional<z.ZodString>;
|
|
34
|
+
password: z.ZodOptional<z.ZodString>;
|
|
35
|
+
proxy: z.ZodOptional<z.ZodString>;
|
|
36
|
+
agent: z.ZodOptional<z.ZodAny>;
|
|
37
|
+
rejectUnauthorized: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
output: z.ZodOptional<z.ZodString>;
|
|
39
|
+
parse: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
multipart: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
open_timeout: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
response_timeout: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
keepAlive: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
}, z.core.$strip>>;
|
|
45
|
+
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
46
|
+
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
47
|
+
'~emitter': z.ZodOptional<z.ZodAny>;
|
|
48
|
+
'~normalizedLogger': z.ZodOptional<z.ZodAny>;
|
|
49
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
50
|
+
json: z.ZodBoolean;
|
|
51
|
+
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
52
|
+
parse_response: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
}, z.core.$strip>], null>, z.ZodObject<{
|
|
54
|
+
json: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
compressed: z.ZodOptional<z.ZodBoolean>;
|
|
56
|
+
follow_max: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
follow_set_cookie: z.ZodOptional<z.ZodBoolean>;
|
|
58
|
+
follow_set_referer: z.ZodOptional<z.ZodBoolean>;
|
|
59
|
+
follow: z.ZodOptional<z.ZodNumber>;
|
|
60
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
61
|
+
read_timeout: z.ZodOptional<z.ZodNumber>;
|
|
62
|
+
parse_response: z.ZodOptional<z.ZodBoolean>;
|
|
63
|
+
decode: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
parse_cookies: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
cookies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
66
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
67
|
+
auth: z.ZodOptional<z.ZodEnum<{
|
|
68
|
+
auto: "auto";
|
|
69
|
+
digest: "digest";
|
|
70
|
+
basic: "basic";
|
|
71
|
+
}>>;
|
|
72
|
+
username: z.ZodOptional<z.ZodString>;
|
|
73
|
+
password: z.ZodOptional<z.ZodString>;
|
|
74
|
+
proxy: z.ZodOptional<z.ZodString>;
|
|
75
|
+
agent: z.ZodOptional<z.ZodAny>;
|
|
76
|
+
rejectUnauthorized: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
output: z.ZodOptional<z.ZodString>;
|
|
78
|
+
parse: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
multipart: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
open_timeout: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
response_timeout: z.ZodOptional<z.ZodNumber>;
|
|
82
|
+
keepAlive: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
export type MergeNeedleOptsSchema = z.infer<typeof MergeNeedleOpts>;
|
|
85
|
+
//# sourceMappingURL=util.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.mts","sourceRoot":"","sources":["../../../schema/util.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAG1B,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsdown.config.d.ts","sourceRoot":"","sources":["../../tsdown.config.ts"],"names":[],"mappings":";AAEA,wBAaE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/** The Standard Schema interface. */
|
|
2
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
3
|
+
/** The Standard Schema properties. */
|
|
4
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>;
|
|
5
|
+
}
|
|
6
|
+
export declare namespace StandardSchemaV1 {
|
|
7
|
+
/** The Standard Schema properties interface. */
|
|
8
|
+
interface Props<Input = unknown, Output = Input> {
|
|
9
|
+
/** The version number of the standard. */
|
|
10
|
+
readonly version: 1;
|
|
11
|
+
/** The vendor name of the schema library. */
|
|
12
|
+
readonly vendor: string;
|
|
13
|
+
/** Validates unknown input values. */
|
|
14
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
15
|
+
/** Inferred types associated with the schema. */
|
|
16
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
17
|
+
}
|
|
18
|
+
/** The result interface of the validate function. */
|
|
19
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
20
|
+
/** The result interface if validation succeeds. */
|
|
21
|
+
interface SuccessResult<Output> {
|
|
22
|
+
/** The typed output value. */
|
|
23
|
+
readonly value: Output;
|
|
24
|
+
/** A falsy value for `issues` indicates success. */
|
|
25
|
+
readonly issues?: undefined;
|
|
26
|
+
}
|
|
27
|
+
interface Options {
|
|
28
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
29
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/** The result interface if validation fails. */
|
|
32
|
+
interface FailureResult {
|
|
33
|
+
/** The issues of failed validation. */
|
|
34
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
35
|
+
}
|
|
36
|
+
/** The issue interface of the failure output. */
|
|
37
|
+
interface Issue {
|
|
38
|
+
/** The error message of the issue. */
|
|
39
|
+
readonly message: string;
|
|
40
|
+
/** The path of the issue, if any. */
|
|
41
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
42
|
+
}
|
|
43
|
+
/** The path segment interface of the issue. */
|
|
44
|
+
interface PathSegment {
|
|
45
|
+
/** The key representing a path segment. */
|
|
46
|
+
readonly key: PropertyKey;
|
|
47
|
+
}
|
|
48
|
+
/** The Standard Schema types interface. */
|
|
49
|
+
interface Types<Input = unknown, Output = Input> {
|
|
50
|
+
/** The input type of the schema. */
|
|
51
|
+
readonly input: Input;
|
|
52
|
+
/** The output type of the schema. */
|
|
53
|
+
readonly output: Output;
|
|
54
|
+
}
|
|
55
|
+
/** Infers the input type of a Standard Schema. */
|
|
56
|
+
type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['input'];
|
|
57
|
+
/** Infers the output type of a Standard Schema. */
|
|
58
|
+
type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema['~standard']['types']>['output'];
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../../standard-schema.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,MAAM,WAAW,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;IAC/D,sCAAsC;IACtC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;CAC5D;AAED,MAAM,CAAC,OAAO,WAAW,gBAAgB,CAAC;IACxC,gDAAgD;IAChD,UAAiB,KAAK,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;QACpD,0CAA0C;QAC1C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;QACnB,6CAA6C;QAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;QACvB,sCAAsC;QACtC,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,GAAG,SAAS,KAC3C,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;QAC7C,iDAAiD;QACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAA;KAClD;IAED,qDAAqD;IACrD,KAAY,MAAM,CAAC,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,GAAG,aAAa,CAAA;IAElE,mDAAmD;IACnD,UAAiB,aAAa,CAAC,MAAM;QACnC,8BAA8B;QAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;QACtB,oDAAoD;QACpD,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAA;KAC5B;IAED,UAAiB,OAAO;QACtB,6EAA6E;QAC7E,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAA;KAC9D;IAED,gDAAgD;IAChD,UAAiB,aAAa;QAC5B,uCAAuC;QACvC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,KAAK,CAAC,CAAA;KACtC;IAED,iDAAiD;IACjD,UAAiB,KAAK;QACpB,sCAAsC;QACtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;QACxB,qCAAqC;QACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,WAAW,GAAG,WAAW,CAAC,GAAG,SAAS,CAAA;KACrE;IAED,+CAA+C;IAC/C,UAAiB,WAAW;QAC1B,2CAA2C;QAC3C,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAA;KAC1B;IAED,2CAA2C;IAC3C,UAAiB,KAAK,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK;QACpD,oCAAoC;QACpC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;QACrB,qCAAqC;QACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KACxB;IAED,kDAAkD;IAClD,KAAY,UAAU,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACnE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC7B,CAAC,OAAO,CAAC,CAAA;IAEV,mDAAmD;IACnD,KAAY,WAAW,CAAC,MAAM,SAAS,gBAAgB,IAAI,WAAW,CACpE,MAAM,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAC7B,CAAC,QAAQ,CAAC,CAAA;CACZ"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** The Standard Schema interface. */
|
|
2
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
3
|
+
/** The Standard Schema properties. */
|
|
4
|
+
readonly '~standard': StandardSchemaV1.Props<Input, Output>
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export declare namespace StandardSchemaV1 {
|
|
8
|
+
/** The Standard Schema properties interface. */
|
|
9
|
+
export interface Props<Input = unknown, Output = Input> {
|
|
10
|
+
/** The version number of the standard. */
|
|
11
|
+
readonly version: 1
|
|
12
|
+
/** The vendor name of the schema library. */
|
|
13
|
+
readonly vendor: string
|
|
14
|
+
/** Validates unknown input values. */
|
|
15
|
+
readonly validate: (
|
|
16
|
+
value: unknown,
|
|
17
|
+
options?: StandardSchemaV1.Options | undefined
|
|
18
|
+
) => Result<Output> | Promise<Result<Output>>
|
|
19
|
+
/** Inferred types associated with the schema. */
|
|
20
|
+
readonly types?: Types<Input, Output> | undefined
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The result interface of the validate function. */
|
|
24
|
+
export type Result<Output> = SuccessResult<Output> | FailureResult
|
|
25
|
+
|
|
26
|
+
/** The result interface if validation succeeds. */
|
|
27
|
+
export interface SuccessResult<Output> {
|
|
28
|
+
/** The typed output value. */
|
|
29
|
+
readonly value: Output
|
|
30
|
+
/** A falsy value for `issues` indicates success. */
|
|
31
|
+
readonly issues?: undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface Options {
|
|
35
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
36
|
+
readonly libraryOptions?: Record<string, unknown> | undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The result interface if validation fails. */
|
|
40
|
+
export interface FailureResult {
|
|
41
|
+
/** The issues of failed validation. */
|
|
42
|
+
readonly issues: ReadonlyArray<Issue>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The issue interface of the failure output. */
|
|
46
|
+
export interface Issue {
|
|
47
|
+
/** The error message of the issue. */
|
|
48
|
+
readonly message: string
|
|
49
|
+
/** The path of the issue, if any. */
|
|
50
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The path segment interface of the issue. */
|
|
54
|
+
export interface PathSegment {
|
|
55
|
+
/** The key representing a path segment. */
|
|
56
|
+
readonly key: PropertyKey
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The Standard Schema types interface. */
|
|
60
|
+
export interface Types<Input = unknown, Output = Input> {
|
|
61
|
+
/** The input type of the schema. */
|
|
62
|
+
readonly input: Input
|
|
63
|
+
/** The output type of the schema. */
|
|
64
|
+
readonly output: Output
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Infers the input type of a Standard Schema. */
|
|
68
|
+
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<
|
|
69
|
+
Schema['~standard']['types']
|
|
70
|
+
>['input']
|
|
71
|
+
|
|
72
|
+
/** Infers the output type of a Standard Schema. */
|
|
73
|
+
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<
|
|
74
|
+
Schema['~standard']['types']
|
|
75
|
+
>['output']
|
|
76
|
+
}
|
package/types/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never
|
package/cjs/impl/bulk.cjs
DELETED
|
@@ -1,275 +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 bulk_exports = {};
|
|
30
|
-
__export(bulk_exports, {
|
|
31
|
-
bulkGet: () => bulkGet,
|
|
32
|
-
bulkGetDictionary: () => bulkGetDictionary,
|
|
33
|
-
bulkRemove: () => bulkRemove,
|
|
34
|
-
bulkSave: () => bulkSave,
|
|
35
|
-
bulkSaveTransaction: () => bulkSaveTransaction
|
|
36
|
-
});
|
|
37
|
-
module.exports = __toCommonJS(bulk_exports);
|
|
38
|
-
var import_needle = __toESM(require("needle"), 1);
|
|
39
|
-
var import_bulk = require("../schema/bulk.cjs");
|
|
40
|
-
var import_retry = require("./retry.cjs");
|
|
41
|
-
var import_crud = require("./crud.cjs");
|
|
42
|
-
var import_errors = require("./errors.cjs");
|
|
43
|
-
var import_transactionErrors = require("./transactionErrors.cjs");
|
|
44
|
-
var import_logger = require("./logger.cjs");
|
|
45
|
-
var import_crud2 = require("../schema/crud.cjs");
|
|
46
|
-
var import_trackedEmitter = require("./trackedEmitter.cjs");
|
|
47
|
-
const bulkSave = import_bulk.BulkSave.implement(async (config, docs) => {
|
|
48
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
49
|
-
if (!docs) {
|
|
50
|
-
logger.warn("bulkSave called with no docs");
|
|
51
|
-
return { ok: false, error: "noDocs", reason: "no docs provided" };
|
|
52
|
-
}
|
|
53
|
-
if (!docs.length) {
|
|
54
|
-
logger.warn("bulkSave called with empty docs array");
|
|
55
|
-
return { ok: false, error: "noDocs", reason: "no docs provided" };
|
|
56
|
-
}
|
|
57
|
-
logger.info(`Starting bulk save of ${docs.length} documents`);
|
|
58
|
-
const url = `${config.couch}/_bulk_docs`;
|
|
59
|
-
const body = { docs };
|
|
60
|
-
const opts = {
|
|
61
|
-
json: true,
|
|
62
|
-
headers: {
|
|
63
|
-
"Content-Type": "application/json"
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
let resp;
|
|
67
|
-
try {
|
|
68
|
-
resp = await (0, import_needle.default)("post", url, body, opts);
|
|
69
|
-
} catch (err) {
|
|
70
|
-
logger.error("Network error during bulk save:", err);
|
|
71
|
-
import_errors.RetryableError.handleNetworkError(err);
|
|
72
|
-
}
|
|
73
|
-
if (!resp) {
|
|
74
|
-
logger.error("No response received from bulk save request");
|
|
75
|
-
throw new import_errors.RetryableError("no response", 503);
|
|
76
|
-
}
|
|
77
|
-
if (import_errors.RetryableError.isRetryableStatusCode(resp.statusCode)) {
|
|
78
|
-
logger.warn(`Retryable status code received: ${resp.statusCode}`);
|
|
79
|
-
throw new import_errors.RetryableError("retryable error during bulk save", resp.statusCode);
|
|
80
|
-
}
|
|
81
|
-
if (resp.statusCode !== 201) {
|
|
82
|
-
logger.error(`Unexpected status code: ${resp.statusCode}`);
|
|
83
|
-
throw new Error("could not save");
|
|
84
|
-
}
|
|
85
|
-
const results = resp?.body || [];
|
|
86
|
-
return results;
|
|
87
|
-
});
|
|
88
|
-
const bulkGet = import_bulk.BulkGet.implement(async (config, ids) => {
|
|
89
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
90
|
-
const keys = ids;
|
|
91
|
-
logger.info(`Starting bulk get for ${keys.length} documents`);
|
|
92
|
-
const url = `${config.couch}/_all_docs?include_docs=true`;
|
|
93
|
-
const payload = { keys };
|
|
94
|
-
const opts = {
|
|
95
|
-
json: true,
|
|
96
|
-
headers: {
|
|
97
|
-
"Content-Type": "application/json"
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
let resp;
|
|
101
|
-
try {
|
|
102
|
-
resp = await (0, import_needle.default)("post", url, payload, opts);
|
|
103
|
-
} catch (err) {
|
|
104
|
-
logger.error("Network error during bulk get:", err);
|
|
105
|
-
import_errors.RetryableError.handleNetworkError(err);
|
|
106
|
-
}
|
|
107
|
-
if (!resp) {
|
|
108
|
-
logger.error("No response received from bulk get request");
|
|
109
|
-
throw new import_errors.RetryableError("no response", 503);
|
|
110
|
-
}
|
|
111
|
-
if (import_errors.RetryableError.isRetryableStatusCode(resp.statusCode)) {
|
|
112
|
-
logger.warn(`Retryable status code received: ${resp.statusCode}`);
|
|
113
|
-
throw new import_errors.RetryableError("retryable error during bulk get", resp.statusCode);
|
|
114
|
-
}
|
|
115
|
-
if (resp.statusCode !== 200) {
|
|
116
|
-
logger.error(`Unexpected status code: ${resp.statusCode}`);
|
|
117
|
-
throw new Error("could not fetch");
|
|
118
|
-
}
|
|
119
|
-
const body = resp.body;
|
|
120
|
-
return body;
|
|
121
|
-
});
|
|
122
|
-
const bulkRemove = import_bulk.BulkRemove.implement(async (config, ids) => {
|
|
123
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
124
|
-
logger.info(`Starting bulk remove for ${ids.length} documents`);
|
|
125
|
-
const resp = await bulkGet(config, ids);
|
|
126
|
-
const toRemove = [];
|
|
127
|
-
resp.rows.forEach((row) => {
|
|
128
|
-
if (!row.doc) return;
|
|
129
|
-
try {
|
|
130
|
-
const d = import_crud2.CouchDoc.parse(row.doc);
|
|
131
|
-
d._deleted = true;
|
|
132
|
-
toRemove.push(d);
|
|
133
|
-
} catch (e) {
|
|
134
|
-
logger.warn(`Invalid document structure in bulk remove: ${row.id}`, e);
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
if (!toRemove.length) return [];
|
|
138
|
-
const result = await bulkSave(config, toRemove);
|
|
139
|
-
return result;
|
|
140
|
-
});
|
|
141
|
-
const bulkGetDictionary = import_bulk.BulkGetDictionary.implement(async (config, ids) => {
|
|
142
|
-
const resp = await bulkGet(config, ids);
|
|
143
|
-
const results = { found: {}, notFound: {} };
|
|
144
|
-
resp.rows.forEach(
|
|
145
|
-
/** @param { import('../schema/query.mjs').ViewRowSchema } row */
|
|
146
|
-
(row) => {
|
|
147
|
-
if (!row.key) return;
|
|
148
|
-
if (row.error) {
|
|
149
|
-
results.notFound[row.key] = row;
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
try {
|
|
153
|
-
const doc = import_crud2.CouchDoc.parse(row.doc);
|
|
154
|
-
results.found[doc._id] = doc;
|
|
155
|
-
} catch (e) {
|
|
156
|
-
results.notFound[row.key] = row;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
return results;
|
|
161
|
-
});
|
|
162
|
-
const bulkSaveTransaction = import_bulk.BulkSaveTransaction.implement(async (config, transactionId, docs) => {
|
|
163
|
-
const emitter = (0, import_trackedEmitter.setupEmitter)(config);
|
|
164
|
-
const logger = (0, import_logger.createLogger)(config);
|
|
165
|
-
const retryOptions = {
|
|
166
|
-
maxRetries: config.maxRetries ?? 10,
|
|
167
|
-
initialDelay: config.initialDelay ?? 1e3,
|
|
168
|
-
backoffFactor: config.backoffFactor ?? 2
|
|
169
|
-
};
|
|
170
|
-
const _put = config.bindWithRetry ? (0, import_retry.withRetry)(import_crud.put.bind(null, config), retryOptions) : import_crud.put.bind(null, config);
|
|
171
|
-
logger.info(`Starting bulk save transaction ${transactionId} for ${docs.length} documents`);
|
|
172
|
-
const txnDoc = {
|
|
173
|
-
_id: `txn:${transactionId}`,
|
|
174
|
-
_rev: null,
|
|
175
|
-
type: "transaction",
|
|
176
|
-
status: "pending",
|
|
177
|
-
changes: docs,
|
|
178
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
179
|
-
};
|
|
180
|
-
let txnresp = await _put(txnDoc);
|
|
181
|
-
logger.debug("Transaction document created:", txnDoc, txnresp);
|
|
182
|
-
await emitter.emit("transaction-created", { txnresp, txnDoc });
|
|
183
|
-
if (txnresp.error) {
|
|
184
|
-
throw new import_transactionErrors.TransactionSetupError("Failed to create transaction document", {
|
|
185
|
-
error: txnresp.error,
|
|
186
|
-
response: txnresp.body
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
const existingDocs = await bulkGetDictionary(config, docs.map((d) => d._id));
|
|
190
|
-
logger.debug("Fetched current revisions of documents:", existingDocs);
|
|
191
|
-
await emitter.emit("transaction-revs-fetched", existingDocs);
|
|
192
|
-
const revErrors = [];
|
|
193
|
-
docs.forEach((d) => {
|
|
194
|
-
if (existingDocs.found[d._id] && existingDocs.found[d._id]._rev !== d._rev) revErrors.push(d._id);
|
|
195
|
-
if (existingDocs.notFound[d._id] && d._rev) revErrors.push(d._id);
|
|
196
|
-
});
|
|
197
|
-
if (revErrors.length > 0) {
|
|
198
|
-
throw new import_transactionErrors.TransactionVersionConflictError(revErrors);
|
|
199
|
-
}
|
|
200
|
-
logger.debug("Checked document revisions:", existingDocs);
|
|
201
|
-
await emitter.emit("transaction-revs-checked", existingDocs);
|
|
202
|
-
const providedDocsById = {};
|
|
203
|
-
docs.forEach((d) => {
|
|
204
|
-
if (!d._id) return;
|
|
205
|
-
providedDocsById[d._id] = d;
|
|
206
|
-
});
|
|
207
|
-
const newDocsToRollback = [];
|
|
208
|
-
const potentialExistingDocsToRollack = [];
|
|
209
|
-
const failedDocs = [];
|
|
210
|
-
try {
|
|
211
|
-
logger.info("Transaction started:", txnDoc);
|
|
212
|
-
await emitter.emit("transaction-started", txnDoc);
|
|
213
|
-
const results = await bulkSave(config, docs);
|
|
214
|
-
logger.info("Transaction updates applied:", results);
|
|
215
|
-
await emitter.emit("transaction-updates-applied", results);
|
|
216
|
-
results.forEach((r) => {
|
|
217
|
-
if (!r.id) return;
|
|
218
|
-
if (!r.error) {
|
|
219
|
-
if (existingDocs.notFound[r.id]) newDocsToRollback.push(r);
|
|
220
|
-
if (existingDocs.found[r.id]) potentialExistingDocsToRollack.push(r);
|
|
221
|
-
} else {
|
|
222
|
-
failedDocs.push(r);
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
if (failedDocs.length > 0) {
|
|
226
|
-
throw new import_transactionErrors.TransactionBulkOperationError(failedDocs);
|
|
227
|
-
}
|
|
228
|
-
txnDoc.status = "completed";
|
|
229
|
-
txnDoc._rev = txnresp.rev;
|
|
230
|
-
txnresp = await _put(txnDoc);
|
|
231
|
-
logger.info("Transaction completed:", txnDoc);
|
|
232
|
-
await emitter.emit("transaction-completed", { txnresp, txnDoc });
|
|
233
|
-
if (txnresp.statusCode !== 201) {
|
|
234
|
-
logger.error("Failed to update transaction status to completed");
|
|
235
|
-
}
|
|
236
|
-
return results;
|
|
237
|
-
} catch (error) {
|
|
238
|
-
logger.error("Transaction failed, attempting rollback:", error);
|
|
239
|
-
const toRollback = [];
|
|
240
|
-
potentialExistingDocsToRollack.forEach((row) => {
|
|
241
|
-
if (!row.id || !row.rev) return;
|
|
242
|
-
const doc = existingDocs.found[row.id];
|
|
243
|
-
doc._rev = row.rev;
|
|
244
|
-
toRollback.push(doc);
|
|
245
|
-
});
|
|
246
|
-
newDocsToRollback.forEach((d) => {
|
|
247
|
-
if (!d.id || !d.rev) return;
|
|
248
|
-
const before = JSON.parse(JSON.stringify(providedDocsById[d.id]));
|
|
249
|
-
before._rev = d.rev;
|
|
250
|
-
before._deleted = true;
|
|
251
|
-
toRollback.push(before);
|
|
252
|
-
});
|
|
253
|
-
const bulkRollbackResult = await bulkSave(config, toRollback);
|
|
254
|
-
let status = "rolled_back";
|
|
255
|
-
bulkRollbackResult.forEach((r) => {
|
|
256
|
-
if (r.error) status = "rollback_failed";
|
|
257
|
-
});
|
|
258
|
-
logger.warn("Transaction rolled back:", { bulkRollbackResult, status });
|
|
259
|
-
await emitter.emit("transaction-rolled-back", { bulkRollbackResult, status });
|
|
260
|
-
txnDoc.status = status;
|
|
261
|
-
txnDoc._rev = txnresp.rev;
|
|
262
|
-
txnresp = await _put(txnDoc);
|
|
263
|
-
logger.warn("Transaction rollback status updated:", txnDoc);
|
|
264
|
-
await emitter.emit("transaction-rolled-back-status", { txnresp, txnDoc });
|
|
265
|
-
if (txnresp.statusCode !== 201) {
|
|
266
|
-
logger.error("Failed to update transaction status to rolled_back");
|
|
267
|
-
}
|
|
268
|
-
throw new import_transactionErrors.TransactionRollbackError(
|
|
269
|
-
"Transaction failed and rollback was unsuccessful",
|
|
270
|
-
/** @type {Error} */
|
|
271
|
-
error,
|
|
272
|
-
bulkRollbackResult
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
});
|
package/cjs/impl/changes.cjs
DELETED
|
@@ -1,67 +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 changes_exports = {};
|
|
30
|
-
__export(changes_exports, {
|
|
31
|
-
changes: () => changes
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(changes_exports);
|
|
34
|
-
var import_needle = __toESM(require("needle"), 1);
|
|
35
|
-
var import_events = require("events");
|
|
36
|
-
var import_changes = require("../schema/changes.cjs");
|
|
37
|
-
var import_changes_stream = __toESM(require("changes-stream"), 1);
|
|
38
|
-
const changes = import_changes.Changes.implement(async (config, onChange, options = {}) => {
|
|
39
|
-
const emitter = new import_events.EventEmitter();
|
|
40
|
-
options.db = config.couch;
|
|
41
|
-
if (options.since && options.since === "now") {
|
|
42
|
-
const opts = {
|
|
43
|
-
json: true,
|
|
44
|
-
headers: {
|
|
45
|
-
"Content-Type": "application/json"
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const resp = await (0, import_needle.default)("get", config.couch, opts);
|
|
49
|
-
options.since = resp.body.update_seq;
|
|
50
|
-
}
|
|
51
|
-
const changes2 = (0, import_changes_stream.default)(options);
|
|
52
|
-
changes2.on("readable", () => {
|
|
53
|
-
const change = changes2.read();
|
|
54
|
-
if (change.results && Array.isArray(change.results)) {
|
|
55
|
-
change.results.forEach((c) => emitter.emit("change", c));
|
|
56
|
-
} else emitter.emit("change", change);
|
|
57
|
-
});
|
|
58
|
-
emitter.on("change", onChange);
|
|
59
|
-
return {
|
|
60
|
-
on: (event, listener) => emitter.on(event, listener),
|
|
61
|
-
removeListener: (event, listener) => emitter.removeListener(event, listener),
|
|
62
|
-
stop: () => {
|
|
63
|
-
changes2.destroy();
|
|
64
|
-
emitter.removeAllListeners();
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
});
|