hide-a-bed 4.0.1 → 4.0.3
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/cjs/impl/bulk.cjs +1 -8
- package/cjs/impl/logger.cjs +19 -10
- package/cjs/impl/patch.cjs +21 -2
- package/cjs/impl/query.cjs +18 -2
- package/cjs/impl/stream.cjs +10 -2
- package/cjs/index.cjs +1 -0
- package/cjs/schema/config.cjs +1 -0
- package/cjs/schema/stream.cjs +1 -1
- package/impl/bulk.d.mts +7 -0
- package/impl/bulk.d.mts.map +1 -0
- package/impl/bulk.mjs +4 -12
- package/impl/crud.d.mts +5 -0
- package/impl/crud.d.mts.map +1 -0
- package/impl/crud.mjs +7 -7
- package/impl/errors.d.mts +35 -0
- package/impl/errors.d.mts.map +1 -0
- package/impl/errors.mjs +11 -11
- package/impl/logger.d.mts +32 -0
- package/impl/logger.d.mts.map +1 -0
- package/impl/logger.mjs +1 -1
- package/impl/patch.d.mts +4 -0
- package/impl/patch.d.mts.map +1 -0
- package/impl/patch.mjs +6 -7
- package/impl/query.d.mts +173 -0
- package/impl/query.d.mts.map +1 -0
- package/impl/query.mjs +1 -5
- package/impl/retry.d.mts +2 -0
- package/impl/retry.d.mts.map +1 -0
- package/impl/retry.mjs +3 -3
- package/impl/stream.d.mts +3 -0
- package/impl/stream.d.mts.map +1 -0
- package/impl/stream.mjs +9 -25
- package/index.d.mts +41 -0
- package/index.d.mts.map +1 -0
- package/index.mjs +1 -1
- package/package.json +1 -1
- package/schema/bind.d.mts +473 -0
- package/schema/bind.d.mts.map +1 -0
- package/schema/bulk.d.mts +367 -0
- package/schema/bulk.d.mts.map +1 -0
- package/schema/bulk.mjs +2 -2
- package/schema/config.d.mts +79 -0
- package/schema/config.d.mts.map +1 -0
- package/schema/config.mjs +2 -2
- package/schema/crud.d.mts +266 -0
- package/schema/crud.d.mts.map +1 -0
- package/schema/patch.d.mts +119 -0
- package/schema/patch.d.mts.map +1 -0
- package/schema/query.d.mts +365 -0
- package/schema/query.d.mts.map +1 -0
- package/schema/query.mjs +1 -1
- package/schema/stream.d.mts +196 -0
- package/schema/stream.d.mts.map +1 -0
package/impl/query.d.mts
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {{ [key: string]: any }} options - The options object containing query parameters.
|
|
3
|
+
* @param {string[]} params - The list of parameter names to include in the query string.
|
|
4
|
+
*/
|
|
5
|
+
export function queryString(options: {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
}, params: string[]): string;
|
|
8
|
+
/** @type { z.infer<SimpleViewQuery> } query */
|
|
9
|
+
export const query: z.infer<z.ZodFunction<z.ZodTuple<[z.ZodObject<{
|
|
10
|
+
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
11
|
+
couch: z.ZodString;
|
|
12
|
+
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
13
|
+
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
14
|
+
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
15
|
+
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
16
|
+
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
17
|
+
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
18
|
+
error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
19
|
+
warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
20
|
+
info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
21
|
+
debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
24
|
+
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
25
|
+
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
26
|
+
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
29
|
+
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
30
|
+
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
31
|
+
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
32
|
+
}>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
|
|
33
|
+
_normalizedLogger: z.ZodOptional<z.ZodAny>;
|
|
34
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
35
|
+
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
36
|
+
couch: z.ZodString;
|
|
37
|
+
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
38
|
+
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
39
|
+
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
40
|
+
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
41
|
+
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
42
|
+
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
43
|
+
error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
44
|
+
warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
45
|
+
info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
46
|
+
debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
49
|
+
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
50
|
+
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
51
|
+
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
52
|
+
}, {
|
|
53
|
+
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
54
|
+
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
55
|
+
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
56
|
+
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
57
|
+
}>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
|
|
58
|
+
_normalizedLogger: z.ZodOptional<z.ZodAny>;
|
|
59
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
60
|
+
throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
61
|
+
couch: z.ZodString;
|
|
62
|
+
bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
63
|
+
maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
64
|
+
initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
65
|
+
backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
66
|
+
useConsoleLogger: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
67
|
+
logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
|
|
68
|
+
error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
69
|
+
warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
70
|
+
info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
71
|
+
debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
74
|
+
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
75
|
+
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
76
|
+
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
79
|
+
warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
80
|
+
info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
81
|
+
debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
|
|
82
|
+
}>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
|
|
83
|
+
_normalizedLogger: z.ZodOptional<z.ZodAny>;
|
|
84
|
+
}, z.ZodTypeAny, "passthrough">>, z.ZodString, z.ZodOptional<z.ZodObject<{
|
|
85
|
+
startkey: z.ZodOptional<z.ZodAny>;
|
|
86
|
+
endkey: z.ZodOptional<z.ZodAny>;
|
|
87
|
+
descending: z.ZodOptional<z.ZodBoolean>;
|
|
88
|
+
skip: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
key: z.ZodOptional<z.ZodAny>;
|
|
91
|
+
include_docs: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
reduce: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
group: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
group_level: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
}, "strip", z.ZodTypeAny, {
|
|
96
|
+
startkey?: any;
|
|
97
|
+
endkey?: any;
|
|
98
|
+
descending?: boolean | undefined;
|
|
99
|
+
skip?: number | undefined;
|
|
100
|
+
limit?: number | undefined;
|
|
101
|
+
key?: any;
|
|
102
|
+
include_docs?: boolean | undefined;
|
|
103
|
+
reduce?: boolean | undefined;
|
|
104
|
+
group?: boolean | undefined;
|
|
105
|
+
group_level?: number | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
startkey?: any;
|
|
108
|
+
endkey?: any;
|
|
109
|
+
descending?: boolean | undefined;
|
|
110
|
+
skip?: number | undefined;
|
|
111
|
+
limit?: number | undefined;
|
|
112
|
+
key?: any;
|
|
113
|
+
include_docs?: boolean | undefined;
|
|
114
|
+
reduce?: boolean | undefined;
|
|
115
|
+
group?: boolean | undefined;
|
|
116
|
+
group_level?: number | undefined;
|
|
117
|
+
}>>], z.ZodUnknown>, z.ZodPromise<z.ZodObject<{
|
|
118
|
+
error: z.ZodOptional<z.ZodString>;
|
|
119
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
120
|
+
id: z.ZodOptional<z.ZodString>;
|
|
121
|
+
key: z.ZodNullable<z.ZodAny>;
|
|
122
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
123
|
+
doc: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
124
|
+
}, "strip", z.ZodTypeAny, {
|
|
125
|
+
id?: string | undefined;
|
|
126
|
+
key?: any;
|
|
127
|
+
value?: any;
|
|
128
|
+
doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
129
|
+
}, {
|
|
130
|
+
id?: string | undefined;
|
|
131
|
+
key?: any;
|
|
132
|
+
value?: any;
|
|
133
|
+
doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
134
|
+
}>, "many">;
|
|
135
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
136
|
+
error: z.ZodOptional<z.ZodString>;
|
|
137
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
138
|
+
id: z.ZodOptional<z.ZodString>;
|
|
139
|
+
key: z.ZodNullable<z.ZodAny>;
|
|
140
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
141
|
+
doc: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
id?: string | undefined;
|
|
144
|
+
key?: any;
|
|
145
|
+
value?: any;
|
|
146
|
+
doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
147
|
+
}, {
|
|
148
|
+
id?: string | undefined;
|
|
149
|
+
key?: any;
|
|
150
|
+
value?: any;
|
|
151
|
+
doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
152
|
+
}>, "many">;
|
|
153
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
154
|
+
error: z.ZodOptional<z.ZodString>;
|
|
155
|
+
rows: z.ZodArray<z.ZodObject<{
|
|
156
|
+
id: z.ZodOptional<z.ZodString>;
|
|
157
|
+
key: z.ZodNullable<z.ZodAny>;
|
|
158
|
+
value: z.ZodNullable<z.ZodAny>;
|
|
159
|
+
doc: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
|
|
160
|
+
}, "strip", z.ZodTypeAny, {
|
|
161
|
+
id?: string | undefined;
|
|
162
|
+
key?: any;
|
|
163
|
+
value?: any;
|
|
164
|
+
doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
id?: string | undefined;
|
|
167
|
+
key?: any;
|
|
168
|
+
value?: any;
|
|
169
|
+
doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
|
|
170
|
+
}>, "many">;
|
|
171
|
+
}, z.ZodTypeAny, "passthrough">>>>>;
|
|
172
|
+
import { z } from 'zod';
|
|
173
|
+
//# sourceMappingURL=query.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query.d.mts","sourceRoot":"","sources":["query.mjs"],"names":[],"mappings":"AA6DA;;;GAGG;AACH,qCAHW;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,UACtB,MAAM,EAAE,UAoBlB;AAxED,+CAA+C;AAC/C,oBADY,CAAC,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAAiB,CAgDlC;kBAzDgB,KAAK"}
|
package/impl/query.mjs
CHANGED
|
@@ -43,7 +43,7 @@ export const query = SimpleViewQuery.implement(async (config, view, options) =>
|
|
|
43
43
|
|
|
44
44
|
/** @type { z.infer<SimpleViewQueryResponse> } body */
|
|
45
45
|
const body = results.body
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
if (RetryableError.isRetryableStatusCode(results.statusCode)) {
|
|
48
48
|
logger.warn(`Retryable status code received: ${results.statusCode}`)
|
|
49
49
|
throw new RetryableError(body.error || 'retryable error during query', results.statusCode)
|
|
@@ -64,10 +64,6 @@ export const query = SimpleViewQuery.implement(async (config, view, options) =>
|
|
|
64
64
|
* @param {string[]} params - The list of parameter names to include in the query string.
|
|
65
65
|
*/
|
|
66
66
|
export function queryString (options, params) {
|
|
67
|
-
const logger = createLogger({ useConsoleLogger: false })
|
|
68
|
-
logger.debug('Building query string with options:', options)
|
|
69
|
-
logger.debug('Allowed params:', params)
|
|
70
|
-
|
|
71
67
|
const parts = Object.keys(options).map(key => {
|
|
72
68
|
let value = options[key]
|
|
73
69
|
if (includes(params, key)) {
|
package/impl/retry.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.mts","sourceRoot":"","sources":["retry.mjs"],"names":[],"mappings":"AAGA,mFAmCC"}
|
package/impl/retry.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { RetryableError } from './errors.mjs'
|
|
2
2
|
import { sleep } from './patch.mjs'
|
|
3
3
|
|
|
4
|
-
export function withRetry(fn, options = {}) {
|
|
4
|
+
export function withRetry (fn, options = {}) {
|
|
5
5
|
const {
|
|
6
6
|
maxRetries = 3,
|
|
7
7
|
initialDelay = 1000, // 1 second
|
|
8
|
-
backoffFactor = 2
|
|
8
|
+
backoffFactor = 2 // exponential backoff multiplier
|
|
9
9
|
} = options
|
|
10
10
|
|
|
11
11
|
return async (...args) => {
|
|
@@ -17,7 +17,7 @@ export function withRetry(fn, options = {}) {
|
|
|
17
17
|
return await fn(...args)
|
|
18
18
|
} catch (error) {
|
|
19
19
|
lastError = error
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
// Only retry if it's a RetryableError
|
|
22
22
|
if (!(error instanceof RetryableError)) {
|
|
23
23
|
throw error
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.mts","sourceRoot":"","sources":["stream.mjs"],"names":[],"mappings":"AAQA,uFAAuF;AACvF,0BADY,OAAO,sBAAsB,EAAE,2BAA2B,CA2DpE"}
|
package/impl/stream.mjs
CHANGED
|
@@ -6,16 +6,12 @@ import { createLogger } from './logger.mjs'
|
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
import JSONStream from 'JSONStream'
|
|
8
8
|
|
|
9
|
-
/** @type { import('../schema/stream.mjs').SimpleViewQueryStreamSchema } */
|
|
9
|
+
/** @type { import('../schema/stream.mjs').SimpleViewQueryStreamSchema } queryStream */
|
|
10
10
|
export const queryStream = (config, view, options, onRow) => new Promise((resolve, reject) => {
|
|
11
|
-
|
|
12
|
-
logger.info(`Starting stream query for view: ${view}`)
|
|
13
|
-
|
|
11
|
+
|
|
14
12
|
if (!options) options = {}
|
|
15
|
-
logger.debug('Stream query options:', options)
|
|
16
13
|
|
|
17
14
|
const qs = queryString(options, ['key', 'startkey', 'endkey', 'reduce', 'group', 'group_level', 'stale', 'limit'])
|
|
18
|
-
logger.debug('Generated query string:', qs)
|
|
19
15
|
const url = `${config.couch}/${view}?${qs.toString()}`
|
|
20
16
|
const opts = {
|
|
21
17
|
json: true,
|
|
@@ -26,53 +22,42 @@ export const queryStream = (config, view, options, onRow) => new Promise((resolv
|
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
const streamer = JSONStream.parse('rows.*')
|
|
29
|
-
|
|
25
|
+
|
|
30
26
|
let rowCount = 0
|
|
31
|
-
streamer.on('data', row => {
|
|
27
|
+
streamer.on('data', /** @param {object} row */ row => {
|
|
32
28
|
rowCount++
|
|
33
29
|
onRow(row)
|
|
34
30
|
})
|
|
35
|
-
|
|
31
|
+
|
|
36
32
|
streamer.on('error', /** @param {Error} err */ err => {
|
|
37
|
-
logger.error('Stream parsing error:', err)
|
|
38
33
|
reject(new Error(`Stream parsing error: ${err.message}`))
|
|
39
34
|
})
|
|
40
|
-
|
|
35
|
+
|
|
41
36
|
streamer.on('done', /** @param {Error|null} err */ err => {
|
|
42
|
-
if (err) {
|
|
43
|
-
logger.error('Stream done with error:', err)
|
|
44
|
-
}
|
|
45
37
|
try {
|
|
46
38
|
RetryableError.handleNetworkError(err)
|
|
47
39
|
} catch (e) {
|
|
48
|
-
logger.error('Retryable error in stream:', e)
|
|
49
40
|
reject(e)
|
|
50
41
|
}
|
|
51
42
|
})
|
|
52
|
-
|
|
43
|
+
|
|
53
44
|
streamer.on('end', () => {
|
|
54
|
-
logger.info(`Stream completed successfully, processed ${rowCount} rows`)
|
|
55
45
|
resolve(undefined) // all work should be done in the stream
|
|
56
46
|
})
|
|
57
|
-
|
|
47
|
+
|
|
58
48
|
const req = needle.get(url, opts)
|
|
59
|
-
|
|
49
|
+
|
|
60
50
|
req.on('response', response => {
|
|
61
|
-
logger.debug(`Received response with status code: ${response.statusCode}`)
|
|
62
51
|
if (RetryableError.isRetryableStatusCode(response.statusCode)) {
|
|
63
|
-
logger.warn(`Retryable status code received: ${response.statusCode}`)
|
|
64
52
|
reject(new RetryableError('retryable error during stream query', response.statusCode))
|
|
65
53
|
// req.abort()
|
|
66
|
-
return
|
|
67
54
|
}
|
|
68
55
|
})
|
|
69
56
|
|
|
70
57
|
req.on('error', err => {
|
|
71
|
-
logger.error('Request error:', err)
|
|
72
58
|
try {
|
|
73
59
|
RetryableError.handleNetworkError(err)
|
|
74
60
|
} catch (retryErr) {
|
|
75
|
-
logger.error('Retryable error in request:', retryErr)
|
|
76
61
|
reject(retryErr)
|
|
77
62
|
return
|
|
78
63
|
}
|
|
@@ -80,5 +65,4 @@ export const queryStream = (config, view, options, onRow) => new Promise((resolv
|
|
|
80
65
|
})
|
|
81
66
|
|
|
82
67
|
req.pipe(streamer)
|
|
83
|
-
|
|
84
68
|
})
|
package/index.d.mts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { get } from './impl/crud.mjs';
|
|
2
|
+
import { put } from './impl/crud.mjs';
|
|
3
|
+
import { patch } from './impl/patch.mjs';
|
|
4
|
+
import { bulkGet } from './impl/bulk.mjs';
|
|
5
|
+
import { bulkSave } from './impl/bulk.mjs';
|
|
6
|
+
import { bulkRemove } from './impl/bulk.mjs';
|
|
7
|
+
import { query } from './impl/query.mjs';
|
|
8
|
+
import { queryStream } from './impl/stream.mjs';
|
|
9
|
+
export namespace schema {
|
|
10
|
+
export { CouchConfig };
|
|
11
|
+
export { SimpleViewQuery };
|
|
12
|
+
export { SimpleViewQueryResponse };
|
|
13
|
+
export { SimpleViewQueryStream };
|
|
14
|
+
export { OnRow };
|
|
15
|
+
export { BulkSave };
|
|
16
|
+
export { BulkGet };
|
|
17
|
+
export { BulkRemove };
|
|
18
|
+
export { CouchGet };
|
|
19
|
+
export { CouchPut };
|
|
20
|
+
export { CouchDoc };
|
|
21
|
+
export { CouchDocResponse };
|
|
22
|
+
export { Patch };
|
|
23
|
+
}
|
|
24
|
+
/** @type { import('./schema/bind.mjs').BindSchema } */
|
|
25
|
+
export const bindConfig: import("./schema/bind.mjs").BindSchema;
|
|
26
|
+
import { withRetry } from './impl/retry.mjs';
|
|
27
|
+
import { CouchConfig } from './schema/config.mjs';
|
|
28
|
+
import { SimpleViewQuery } from './schema/query.mjs';
|
|
29
|
+
import { SimpleViewQueryResponse } from './schema/query.mjs';
|
|
30
|
+
import { SimpleViewQueryStream } from './schema/stream.mjs';
|
|
31
|
+
import { OnRow } from './schema/stream.mjs';
|
|
32
|
+
import { BulkSave } from './schema/bulk.mjs';
|
|
33
|
+
import { BulkGet } from './schema/bulk.mjs';
|
|
34
|
+
import { BulkRemove } from './schema/bulk.mjs';
|
|
35
|
+
import { CouchGet } from './schema/crud.mjs';
|
|
36
|
+
import { CouchPut } from './schema/crud.mjs';
|
|
37
|
+
import { CouchDoc } from './schema/crud.mjs';
|
|
38
|
+
import { CouchDocResponse } from './schema/crud.mjs';
|
|
39
|
+
import { Patch } from './schema/patch.mjs';
|
|
40
|
+
export { get, put, patch, bulkGet, bulkSave, bulkRemove, query, queryStream, withRetry };
|
|
41
|
+
//# sourceMappingURL=index.d.mts.map
|
package/index.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mjs"],"names":[],"mappings":"oBAEyB,iBAAiB;oBAAjB,iBAAiB;sBACpB,kBAAkB;wBAFM,iBAAiB;yBAAjB,iBAAiB;2BAAjB,iBAAiB;sBAGzC,kBAAkB;4BACZ,mBAAmB;;;;;;;;;;;;;;;;AA0B/C,uDAAuD;AACvD,yBADY,OAAO,mBAAmB,EAAE,UAAU,CAsBhD;0BA/CwB,kBAAkB;4BAEhB,qBAAqB;gCACQ,oBAAoB;wCAApB,oBAAoB;sCAChC,qBAAqB;sBAArB,qBAAqB;yBAHpB,mBAAmB;wBAAnB,mBAAmB;2BAAnB,mBAAmB;yBAKF,mBAAmB;yBAAnB,mBAAmB;yBAAnB,mBAAmB;iCAAnB,mBAAmB;sBAD5D,oBAAoB"}
|
package/index.mjs
CHANGED
|
@@ -49,7 +49,7 @@ const bindConfig = Bind.implement((
|
|
|
49
49
|
bulkSave: config.bindWithRetry ? withRetry(bulkSave.bind(null, config), retryOptions) : bulkSave.bind(null, config),
|
|
50
50
|
bulkRemove: config.bindWithRetry ? withRetry(bulkRemove.bind(null, config), retryOptions) : bulkRemove.bind(null, config),
|
|
51
51
|
query: config.bindWithRetry ? withRetry(query.bind(null, config), retryOptions) : query.bind(null, config),
|
|
52
|
-
queryStream: config.bindWithRetry? withRetry(queryStream.bind(null, config), retryOptions) : queryStream.bind(null, config)
|
|
52
|
+
queryStream: config.bindWithRetry ? withRetry(queryStream.bind(null, config), retryOptions) : queryStream.bind(null, config)
|
|
53
53
|
}
|
|
54
54
|
})
|
|
55
55
|
|