hide-a-bed 7.1.0 → 7.1.1
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/README.md +148 -156
- package/impl/bindConfig.mts +62 -69
- package/impl/headDB.mts +28 -28
- package/impl/utils/errors.mts +159 -189
- package/impl/utils/fetch.mts +94 -102
- package/index.mts +42 -55
- package/package.json +2 -2
- package/types/output/impl/bindConfig.d.mts +15 -15
- package/types/output/impl/bindConfig.d.mts.map +1 -1
- package/types/output/impl/headDB.d.mts +1 -1
- package/types/output/impl/headDB.d.mts.map +1 -1
- package/types/output/impl/utils/errors.d.mts +12 -12
- package/types/output/impl/utils/errors.d.mts.map +1 -1
- package/types/output/impl/utils/fetch.d.mts +4 -4
- package/types/output/impl/utils/fetch.d.mts.map +1 -1
- package/types/output/index.d.mts +35 -35
- package/types/output/index.d.mts.map +1 -1
package/impl/utils/fetch.mts
CHANGED
|
@@ -1,92 +1,90 @@
|
|
|
1
|
-
import { RetryableError } from
|
|
2
|
-
import type { RequestOptions } from
|
|
3
|
-
import { composeAbortSignal } from
|
|
1
|
+
import { RetryableError } from './errors.mts'
|
|
2
|
+
import type { RequestOptions } from '../../schema/request.mts'
|
|
3
|
+
import { composeAbortSignal } from './request.mts'
|
|
4
4
|
|
|
5
|
-
export type HttpMethod =
|
|
5
|
+
export type HttpMethod = 'DELETE' | 'GET' | 'HEAD' | 'POST' | 'PUT'
|
|
6
6
|
|
|
7
|
-
type NativeFetchBody = RequestInit[
|
|
7
|
+
type NativeFetchBody = RequestInit['body']
|
|
8
8
|
|
|
9
9
|
export type FetchBody =
|
|
10
10
|
| NativeFetchBody
|
|
11
11
|
| Record<string, unknown>
|
|
12
12
|
| Array<unknown>
|
|
13
13
|
| null
|
|
14
|
-
| undefined
|
|
14
|
+
| undefined
|
|
15
15
|
|
|
16
16
|
export type FetchAuth = {
|
|
17
|
-
password: string
|
|
18
|
-
username: string
|
|
19
|
-
}
|
|
17
|
+
password: string
|
|
18
|
+
username: string
|
|
19
|
+
}
|
|
20
20
|
|
|
21
21
|
export type FetchResult<TBody> = {
|
|
22
|
-
body: TBody
|
|
23
|
-
headers: Headers
|
|
24
|
-
statusCode: number
|
|
25
|
-
}
|
|
22
|
+
body: TBody
|
|
23
|
+
headers: Headers
|
|
24
|
+
statusCode: number
|
|
25
|
+
}
|
|
26
26
|
|
|
27
27
|
export type FetchRequestOptions = {
|
|
28
|
-
auth?: FetchAuth
|
|
29
|
-
body?: FetchBody
|
|
30
|
-
headers?: Record<string, string
|
|
31
|
-
method: HttpMethod
|
|
28
|
+
auth?: FetchAuth
|
|
29
|
+
body?: FetchBody
|
|
30
|
+
headers?: Record<string, string>
|
|
31
|
+
method: HttpMethod
|
|
32
32
|
operation?:
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
request?: RequestOptions
|
|
46
|
-
signal?: AbortSignal
|
|
47
|
-
url: string | URL
|
|
48
|
-
}
|
|
33
|
+
| 'get'
|
|
34
|
+
| 'getAtRev'
|
|
35
|
+
| 'getDBInfo'
|
|
36
|
+
| 'headDB'
|
|
37
|
+
| 'patch'
|
|
38
|
+
| 'patchDangerously'
|
|
39
|
+
| 'put'
|
|
40
|
+
| 'query'
|
|
41
|
+
| 'queryStream'
|
|
42
|
+
| 'remove'
|
|
43
|
+
| 'request'
|
|
44
|
+
| 'watchDocs'
|
|
45
|
+
request?: RequestOptions
|
|
46
|
+
signal?: AbortSignal
|
|
47
|
+
url: string | URL
|
|
48
|
+
}
|
|
49
49
|
|
|
50
50
|
const JSON_HEADERS = {
|
|
51
|
-
|
|
52
|
-
} as const
|
|
51
|
+
'Content-Type': 'application/json'
|
|
52
|
+
} as const
|
|
53
53
|
|
|
54
54
|
const hasHeader = (headers: Record<string, string>, name: string) => {
|
|
55
|
-
const expected = name.toLowerCase()
|
|
56
|
-
return Object.keys(headers).some(
|
|
57
|
-
|
|
58
|
-
);
|
|
59
|
-
};
|
|
55
|
+
const expected = name.toLowerCase()
|
|
56
|
+
return Object.keys(headers).some(header => header.toLowerCase() === expected)
|
|
57
|
+
}
|
|
60
58
|
|
|
61
59
|
const toBasicAuthHeader = ({ username, password }: FetchAuth) => {
|
|
62
|
-
const token = Buffer.from(`${username}:${password}`).toString(
|
|
63
|
-
return `Basic ${token}
|
|
64
|
-
}
|
|
60
|
+
const token = Buffer.from(`${username}:${password}`).toString('base64')
|
|
61
|
+
return `Basic ${token}`
|
|
62
|
+
}
|
|
65
63
|
|
|
66
64
|
const prepareRequest = (options: FetchRequestOptions) => {
|
|
67
|
-
const auth = options.auth
|
|
68
|
-
const headers = { ...(options.headers ?? {}) }
|
|
65
|
+
const auth = options.auth
|
|
66
|
+
const headers = { ...(options.headers ?? {}) }
|
|
69
67
|
|
|
70
|
-
if (auth && !hasHeader(headers,
|
|
71
|
-
headers.Authorization = toBasicAuthHeader(auth)
|
|
68
|
+
if (auth && !hasHeader(headers, 'Authorization')) {
|
|
69
|
+
headers.Authorization = toBasicAuthHeader(auth)
|
|
72
70
|
}
|
|
73
71
|
|
|
74
|
-
return { headers }
|
|
75
|
-
}
|
|
72
|
+
return { headers }
|
|
73
|
+
}
|
|
76
74
|
|
|
77
75
|
const isAbortError = (err: unknown): err is DOMException => {
|
|
78
|
-
return err instanceof DOMException && err.name ===
|
|
79
|
-
}
|
|
76
|
+
return err instanceof DOMException && err.name === 'AbortError'
|
|
77
|
+
}
|
|
80
78
|
|
|
81
79
|
const isTimeoutError = (err: unknown): err is DOMException => {
|
|
82
|
-
return err instanceof DOMException && err.name ===
|
|
83
|
-
}
|
|
80
|
+
return err instanceof DOMException && err.name === 'TimeoutError'
|
|
81
|
+
}
|
|
84
82
|
|
|
85
83
|
const encodeBody = (body: FetchBody): NativeFetchBody | undefined => {
|
|
86
|
-
if (body == null) return undefined
|
|
84
|
+
if (body == null) return undefined
|
|
87
85
|
|
|
88
86
|
if (
|
|
89
|
-
typeof body ===
|
|
87
|
+
typeof body === 'string' ||
|
|
90
88
|
body instanceof ArrayBuffer ||
|
|
91
89
|
ArrayBuffer.isView(body) ||
|
|
92
90
|
body instanceof Blob ||
|
|
@@ -94,89 +92,83 @@ const encodeBody = (body: FetchBody): NativeFetchBody | undefined => {
|
|
|
94
92
|
body instanceof URLSearchParams ||
|
|
95
93
|
body instanceof ReadableStream
|
|
96
94
|
) {
|
|
97
|
-
return body as NativeFetchBody
|
|
95
|
+
return body as NativeFetchBody
|
|
98
96
|
}
|
|
99
97
|
|
|
100
|
-
return JSON.stringify(body)
|
|
101
|
-
}
|
|
98
|
+
return JSON.stringify(body)
|
|
99
|
+
}
|
|
102
100
|
|
|
103
101
|
const parseJsonResponse = async (response: Response): Promise<unknown> => {
|
|
104
102
|
if (response.status === 204 || response.status === 205) {
|
|
105
|
-
return null
|
|
103
|
+
return null
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
const text = await response.text()
|
|
106
|
+
const text = await response.text()
|
|
109
107
|
|
|
110
|
-
if (text.trim() ===
|
|
111
|
-
return null
|
|
108
|
+
if (text.trim() === '') {
|
|
109
|
+
return null
|
|
112
110
|
}
|
|
113
111
|
|
|
114
112
|
try {
|
|
115
|
-
return JSON.parse(text)
|
|
113
|
+
return JSON.parse(text)
|
|
116
114
|
} catch (err) {
|
|
117
115
|
if (response.ok) {
|
|
118
|
-
throw err
|
|
116
|
+
throw err
|
|
119
117
|
}
|
|
120
118
|
|
|
121
|
-
return text
|
|
119
|
+
return text
|
|
122
120
|
}
|
|
123
|
-
}
|
|
121
|
+
}
|
|
124
122
|
|
|
125
123
|
export async function fetchCouchJson<TBody = unknown>(
|
|
126
|
-
options: FetchRequestOptions
|
|
124
|
+
options: FetchRequestOptions
|
|
127
125
|
): Promise<FetchResult<TBody>> {
|
|
128
|
-
let response: Response
|
|
129
|
-
const { headers } = prepareRequest(options)
|
|
130
|
-
const { signal, timedOut } = composeAbortSignal(
|
|
131
|
-
options.signal,
|
|
132
|
-
options.request,
|
|
133
|
-
);
|
|
126
|
+
let response: Response
|
|
127
|
+
const { headers } = prepareRequest(options)
|
|
128
|
+
const { signal, timedOut } = composeAbortSignal(options.signal, options.request)
|
|
134
129
|
|
|
135
130
|
try {
|
|
136
131
|
response = await fetch(options.url, {
|
|
137
132
|
method: options.method,
|
|
138
133
|
headers: {
|
|
139
134
|
...JSON_HEADERS,
|
|
140
|
-
...headers
|
|
135
|
+
...headers
|
|
141
136
|
},
|
|
142
137
|
body: encodeBody(options.body),
|
|
143
138
|
signal,
|
|
144
|
-
dispatcher: options.request?.dispatcher
|
|
145
|
-
})
|
|
139
|
+
dispatcher: options.request?.dispatcher
|
|
140
|
+
})
|
|
146
141
|
} catch (err) {
|
|
147
142
|
if (timedOut() || isTimeoutError(err)) {
|
|
148
|
-
throw new RetryableError(
|
|
149
|
-
category:
|
|
143
|
+
throw new RetryableError('Request timed out', 503, {
|
|
144
|
+
category: 'network',
|
|
150
145
|
cause: err,
|
|
151
|
-
operation: options.operation
|
|
152
|
-
})
|
|
146
|
+
operation: options.operation
|
|
147
|
+
})
|
|
153
148
|
}
|
|
154
149
|
|
|
155
150
|
if (isAbortError(err)) {
|
|
156
|
-
throw err
|
|
151
|
+
throw err
|
|
157
152
|
}
|
|
158
153
|
|
|
159
|
-
RetryableError.handleNetworkError(err, options.operation)
|
|
154
|
+
RetryableError.handleNetworkError(err, options.operation)
|
|
160
155
|
}
|
|
161
156
|
|
|
162
|
-
const body = (await parseJsonResponse(response)) as TBody
|
|
157
|
+
const body = (await parseJsonResponse(response)) as TBody
|
|
163
158
|
|
|
164
159
|
return {
|
|
165
160
|
body,
|
|
166
161
|
headers: response.headers,
|
|
167
|
-
statusCode: response.status
|
|
168
|
-
}
|
|
162
|
+
statusCode: response.status
|
|
163
|
+
}
|
|
169
164
|
}
|
|
170
165
|
|
|
171
166
|
export async function fetchCouchStream(
|
|
172
|
-
options: FetchRequestOptions
|
|
167
|
+
options: FetchRequestOptions
|
|
173
168
|
): Promise<FetchResult<ReadableStream<Uint8Array> | null>> {
|
|
174
|
-
let response: Response
|
|
175
|
-
const { headers } = prepareRequest(options)
|
|
176
|
-
const { signal, timedOut } = composeAbortSignal(
|
|
177
|
-
options.signal,
|
|
178
|
-
options.request,
|
|
179
|
-
);
|
|
169
|
+
let response: Response
|
|
170
|
+
const { headers } = prepareRequest(options)
|
|
171
|
+
const { signal, timedOut } = composeAbortSignal(options.signal, options.request)
|
|
180
172
|
|
|
181
173
|
try {
|
|
182
174
|
response = await fetch(options.url, {
|
|
@@ -184,27 +176,27 @@ export async function fetchCouchStream(
|
|
|
184
176
|
headers,
|
|
185
177
|
body: encodeBody(options.body),
|
|
186
178
|
signal,
|
|
187
|
-
dispatcher: options.request?.dispatcher
|
|
188
|
-
})
|
|
179
|
+
dispatcher: options.request?.dispatcher
|
|
180
|
+
})
|
|
189
181
|
} catch (err) {
|
|
190
182
|
if (timedOut() || isTimeoutError(err)) {
|
|
191
|
-
throw new RetryableError(
|
|
192
|
-
category:
|
|
183
|
+
throw new RetryableError('Request timed out', 503, {
|
|
184
|
+
category: 'network',
|
|
193
185
|
cause: err,
|
|
194
|
-
operation: options.operation
|
|
195
|
-
})
|
|
186
|
+
operation: options.operation
|
|
187
|
+
})
|
|
196
188
|
}
|
|
197
189
|
|
|
198
190
|
if (isAbortError(err)) {
|
|
199
|
-
throw err
|
|
191
|
+
throw err
|
|
200
192
|
}
|
|
201
193
|
|
|
202
|
-
RetryableError.handleNetworkError(err, options.operation)
|
|
194
|
+
RetryableError.handleNetworkError(err, options.operation)
|
|
203
195
|
}
|
|
204
196
|
|
|
205
197
|
return {
|
|
206
198
|
body: response.body,
|
|
207
199
|
headers: response.headers,
|
|
208
|
-
statusCode: response.status
|
|
209
|
-
}
|
|
200
|
+
statusCode: response.status
|
|
201
|
+
}
|
|
210
202
|
}
|
package/index.mts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { createQuery } from
|
|
2
|
-
import { QueryBuilder } from
|
|
3
|
-
import { bindConfig } from
|
|
4
|
-
import { withRetry } from
|
|
5
|
-
import { bulkGet, bulkGetDictionary } from
|
|
6
|
-
import { getAtRev, get } from
|
|
7
|
-
import { queryStream } from
|
|
8
|
-
import { patch, patchDangerously } from
|
|
9
|
-
import { put } from
|
|
10
|
-
import { remove } from
|
|
11
|
-
import { bulkSave, bulkSaveTransaction } from
|
|
12
|
-
import { query } from
|
|
13
|
-
import { getDBInfo } from
|
|
14
|
-
import { headDB } from
|
|
15
|
-
import { bulkRemove, bulkRemoveMap } from
|
|
16
|
-
import { createLock, removeLock } from
|
|
17
|
-
import { watchDocs } from
|
|
1
|
+
import { createQuery } from './impl/utils/queryBuilder.mts'
|
|
2
|
+
import { QueryBuilder } from './impl/utils/queryBuilder.mts'
|
|
3
|
+
import { bindConfig } from './impl/bindConfig.mts'
|
|
4
|
+
import { withRetry } from './impl/retry.mts'
|
|
5
|
+
import { bulkGet, bulkGetDictionary } from './impl/bulkGet.mts'
|
|
6
|
+
import { getAtRev, get } from './impl/get.mts'
|
|
7
|
+
import { queryStream } from './impl/stream.mts'
|
|
8
|
+
import { patch, patchDangerously } from './impl/patch.mts'
|
|
9
|
+
import { put } from './impl/put.mts'
|
|
10
|
+
import { remove } from './impl/remove.mts'
|
|
11
|
+
import { bulkSave, bulkSaveTransaction } from './impl/bulkSave.mts'
|
|
12
|
+
import { query } from './impl/query.mts'
|
|
13
|
+
import { getDBInfo } from './impl/getDBInfo.mts'
|
|
14
|
+
import { headDB } from './impl/headDB.mts'
|
|
15
|
+
import { bulkRemove, bulkRemoveMap } from './impl/bulkRemove.mts'
|
|
16
|
+
import { createLock, removeLock } from './impl/sugar/lock.mts'
|
|
17
|
+
import { watchDocs } from './impl/sugar/watch.mts'
|
|
18
18
|
|
|
19
19
|
export {
|
|
20
20
|
get,
|
|
@@ -45,8 +45,8 @@ export {
|
|
|
45
45
|
QueryBuilder,
|
|
46
46
|
createQuery,
|
|
47
47
|
createLock,
|
|
48
|
-
removeLock
|
|
49
|
-
}
|
|
48
|
+
removeLock
|
|
49
|
+
}
|
|
50
50
|
|
|
51
51
|
export {
|
|
52
52
|
ConflictError,
|
|
@@ -54,8 +54,8 @@ export {
|
|
|
54
54
|
NotFoundError,
|
|
55
55
|
OperationError,
|
|
56
56
|
RetryableError,
|
|
57
|
-
ValidationError
|
|
58
|
-
} from
|
|
57
|
+
ValidationError
|
|
58
|
+
} from './impl/utils/errors.mts'
|
|
59
59
|
|
|
60
60
|
export type {
|
|
61
61
|
BulkGetBound,
|
|
@@ -63,52 +63,39 @@ export type {
|
|
|
63
63
|
BulkGetDictionaryOptions,
|
|
64
64
|
BulkGetDictionaryResult,
|
|
65
65
|
BulkGetOptions,
|
|
66
|
-
BulkGetResponse
|
|
67
|
-
} from
|
|
68
|
-
export type { OnInvalidDocAction } from
|
|
69
|
-
export type { GetOptions, GetBound, GetAtRevBound } from
|
|
70
|
-
export type { QueryBound } from
|
|
66
|
+
BulkGetResponse
|
|
67
|
+
} from './impl/bulkGet.mts'
|
|
68
|
+
export type { OnInvalidDocAction } from './impl/utils/parseRows.mts'
|
|
69
|
+
export type { GetOptions, GetBound, GetAtRevBound } from './impl/get.mts'
|
|
70
|
+
export type { QueryBound } from './impl/query.mts'
|
|
71
71
|
export type {
|
|
72
72
|
ViewString,
|
|
73
|
-
ViewOptions as SimpleViewOptions
|
|
74
|
-
} from
|
|
73
|
+
ViewOptions as SimpleViewOptions
|
|
74
|
+
} from './schema/couch/couch.input.schema.ts'
|
|
75
75
|
export type {
|
|
76
76
|
ViewRow,
|
|
77
77
|
CouchDoc,
|
|
78
78
|
CouchDocInput,
|
|
79
79
|
ViewQueryResponse,
|
|
80
80
|
ViewQueryResponseValidated,
|
|
81
|
-
ViewRowValidated
|
|
82
|
-
} from
|
|
83
|
-
export type { RetryOptions } from
|
|
81
|
+
ViewRowValidated
|
|
82
|
+
} from './schema/couch/couch.output.schema.ts'
|
|
83
|
+
export type { RetryOptions } from './impl/retry.mts'
|
|
84
84
|
export type {
|
|
85
85
|
ErrorCategory,
|
|
86
86
|
ErrorOperation,
|
|
87
87
|
HideABedErrorOptions,
|
|
88
88
|
NetworkError,
|
|
89
|
-
ValidationErrorOptions
|
|
90
|
-
} from
|
|
91
|
-
export type { OnRow } from
|
|
92
|
-
export type {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
CouchConfigInput,
|
|
97
|
-
} from "./schema/config.mts";
|
|
98
|
-
export type {
|
|
99
|
-
Dispatcher,
|
|
100
|
-
RequestOptions,
|
|
101
|
-
RequestOptionsInput,
|
|
102
|
-
} from "./schema/request.mts";
|
|
103
|
-
export type {
|
|
104
|
-
LockOptions,
|
|
105
|
-
LockOptionsInput,
|
|
106
|
-
LockDoc,
|
|
107
|
-
} from "./schema/sugar/lock.mts";
|
|
108
|
-
export type { WatchHandle, WatchListener } from "./impl/sugar/watch.mts";
|
|
89
|
+
ValidationErrorOptions
|
|
90
|
+
} from './impl/utils/errors.mts'
|
|
91
|
+
export type { OnRow } from './impl/stream.mts'
|
|
92
|
+
export type { CouchAuth, CouchAuthInput, CouchConfig, CouchConfigInput } from './schema/config.mts'
|
|
93
|
+
export type { Dispatcher, RequestOptions, RequestOptionsInput } from './schema/request.mts'
|
|
94
|
+
export type { LockOptions, LockOptionsInput, LockDoc } from './schema/sugar/lock.mts'
|
|
95
|
+
export type { WatchHandle, WatchListener } from './impl/sugar/watch.mts'
|
|
109
96
|
export type {
|
|
110
97
|
WatchOptions as WatchOptionsSchema,
|
|
111
|
-
WatchOptionsInput
|
|
112
|
-
} from
|
|
113
|
-
export type { BoundInstance } from
|
|
114
|
-
export type { StandardSchemaV1 } from
|
|
98
|
+
WatchOptionsInput
|
|
99
|
+
} from './schema/sugar/watch.mts'
|
|
100
|
+
export type { BoundInstance } from './impl/bindConfig.mts'
|
|
101
|
+
export type { StandardSchemaV1 } from './types/standard-schema.ts'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hide-a-bed",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.1",
|
|
4
4
|
"description": "An abstraction over couchdb calls that includes easy mock/stubs with pouchdb",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"couchdb",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"format:check": "oxfmt --check .",
|
|
49
49
|
"typecheck": "tsc --noEmit",
|
|
50
50
|
"typecheck:watch": "tsc --noEmit --watch",
|
|
51
|
-
"prepublishOnly": "npm run build",
|
|
51
|
+
"prepublishOnly": "npm test && npm run build",
|
|
52
52
|
"validate": "npm run format:check && npm run lint && npm run typecheck",
|
|
53
53
|
"full": "npm run lint:fix && npm run build && npm run clean"
|
|
54
54
|
},
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type z from
|
|
2
|
-
import { CouchConfig, type CouchConfigInput } from
|
|
3
|
-
import { type BulkGetBound, type BulkGetDictionaryBound } from
|
|
4
|
-
import { type GetBound, type GetAtRevBound } from
|
|
5
|
-
import { queryStream } from
|
|
6
|
-
import { patch, patchDangerously } from
|
|
7
|
-
import { put } from
|
|
8
|
-
import type { QueryBound } from
|
|
9
|
-
import { bulkRemove, bulkRemoveMap } from
|
|
10
|
-
import { bulkSave, bulkSaveTransaction } from
|
|
11
|
-
import { getDBInfo } from
|
|
12
|
-
import { headDB } from
|
|
13
|
-
import { remove } from
|
|
14
|
-
import { createLock, removeLock } from
|
|
15
|
-
import { watchDocs } from
|
|
1
|
+
import type z from 'zod';
|
|
2
|
+
import { CouchConfig, type CouchConfigInput } from '../schema/config.mts';
|
|
3
|
+
import { type BulkGetBound, type BulkGetDictionaryBound } from './bulkGet.mts';
|
|
4
|
+
import { type GetBound, type GetAtRevBound } from './get.mts';
|
|
5
|
+
import { queryStream } from './stream.mts';
|
|
6
|
+
import { patch, patchDangerously } from './patch.mts';
|
|
7
|
+
import { put } from './put.mts';
|
|
8
|
+
import type { QueryBound } from './query.mts';
|
|
9
|
+
import { bulkRemove, bulkRemoveMap } from './bulkRemove.mts';
|
|
10
|
+
import { bulkSave, bulkSaveTransaction } from './bulkSave.mts';
|
|
11
|
+
import { getDBInfo } from './getDBInfo.mts';
|
|
12
|
+
import { headDB } from './headDB.mts';
|
|
13
|
+
import { remove } from './remove.mts';
|
|
14
|
+
import { createLock, removeLock } from './sugar/lock.mts';
|
|
15
|
+
import { watchDocs } from './sugar/watch.mts';
|
|
16
16
|
type BoundConfigMethod<T> = T extends (...args: infer Args) => infer Result ? Args extends [unknown, ...infer Rest] ? (...args: Rest) => Result : never : never;
|
|
17
17
|
type BoundMethods = {
|
|
18
18
|
bulkGet: BulkGetBound;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindConfig.d.mts","sourceRoot":"","sources":["../../../impl/bindConfig.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"bindConfig.d.mts","sourceRoot":"","sources":["../../../impl/bindConfig.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAEzE,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,sBAAsB,EAE5B,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAiB,MAAM,WAAW,CAAA;AAC5E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAC/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,EAAE,UA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C,OAAO,gBAAgB,CAAC,CAAA;IAC5D,GAAG,EAAE,iBAAiB,CAAC,OAAO,GAAG,CAAC,CAAA;IAClC,WAAW,EAAE,iBAAiB,CAAC,OAAO,WAAW,CAAC,CAAA;IAClD,MAAM,EAAE,iBAAiB,CAAC,OAAO,MAAM,CAAC,CAAA;IACxC,UAAU,EAAE,iBAAiB,CAAC,OAAO,UAAU,CAAC,CAAA;IAChD,UAAU,EAAE,iBAAiB,CAAC,OAAO,UAAU,CAAC,CAAA;IAChD,SAAS,EAAE,iBAAiB,CAAC,OAAO,SAAS,CAAC,CAAA;CAC/C,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG;IACzC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC,GAAG,aAAa,CAAA;CACxE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,QAAQ,gBAAgB,KAAG,aAcrD,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAC/E,IAAI,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,EAC3D,MAAM,EAAE,WAAW,UAYpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headDB.d.mts","sourceRoot":"","sources":["../../../impl/headDB.mts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"headDB.d.mts","sourceRoot":"","sources":["../../../impl/headDB.mts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAKzE;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GAAU,aAAa,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAqCxE,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StandardSchemaV1 } from
|
|
1
|
+
import type { StandardSchemaV1 } from '../../types/standard-schema.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Represents a network-level error emitted by Node.js or HTTP client libraries.
|
|
4
4
|
*
|
|
@@ -14,8 +14,8 @@ export interface NetworkError {
|
|
|
14
14
|
*/
|
|
15
15
|
message?: string;
|
|
16
16
|
}
|
|
17
|
-
export type ErrorCategory =
|
|
18
|
-
export type ErrorOperation =
|
|
17
|
+
export type ErrorCategory = 'conflict' | 'network' | 'not_found' | 'operation' | 'retryable' | 'validation' | 'transaction';
|
|
18
|
+
export type ErrorOperation = 'get' | 'getAtRev' | 'getDBInfo' | 'headDB' | 'patch' | 'patchDangerously' | 'put' | 'query' | 'queryStream' | 'remove' | 'request' | 'watchDocs';
|
|
19
19
|
export declare const hasStatusCode: (error: unknown) => error is {
|
|
20
20
|
statusCode: number;
|
|
21
21
|
};
|
|
@@ -50,7 +50,7 @@ export declare class HideABedError extends Error {
|
|
|
50
50
|
readonly statusCode?: number;
|
|
51
51
|
constructor(message: string, options: HideABedErrorOptions);
|
|
52
52
|
}
|
|
53
|
-
export type ValidationErrorOptions = Omit<Partial<HideABedErrorOptions>,
|
|
53
|
+
export type ValidationErrorOptions = Omit<Partial<HideABedErrorOptions>, 'category' | 'retryable'> & {
|
|
54
54
|
issues: ReadonlyArray<StandardSchemaV1.Issue>;
|
|
55
55
|
message?: string;
|
|
56
56
|
};
|
|
@@ -64,7 +64,7 @@ export type ValidationErrorOptions = Omit<Partial<HideABedErrorOptions>, "catego
|
|
|
64
64
|
* @public
|
|
65
65
|
*/
|
|
66
66
|
export declare class NotFoundError extends HideABedError {
|
|
67
|
-
constructor(docId: string, options?: Omit<Partial<HideABedErrorOptions>,
|
|
67
|
+
constructor(docId: string, options?: Omit<Partial<HideABedErrorOptions>, 'category' | 'docId' | 'retryable'> & {
|
|
68
68
|
message?: string;
|
|
69
69
|
});
|
|
70
70
|
}
|
|
@@ -74,7 +74,7 @@ export declare class NotFoundError extends HideABedError {
|
|
|
74
74
|
* @public
|
|
75
75
|
*/
|
|
76
76
|
export declare class ConflictError extends HideABedError {
|
|
77
|
-
constructor(docId: string, options?: Omit<Partial<HideABedErrorOptions>,
|
|
77
|
+
constructor(docId: string, options?: Omit<Partial<HideABedErrorOptions>, 'category' | 'docId' | 'retryable'> & {
|
|
78
78
|
message?: string;
|
|
79
79
|
});
|
|
80
80
|
}
|
|
@@ -84,8 +84,8 @@ export declare class ConflictError extends HideABedError {
|
|
|
84
84
|
* @public
|
|
85
85
|
*/
|
|
86
86
|
export declare class OperationError extends HideABedError {
|
|
87
|
-
constructor(message: string, options?: Omit<Partial<HideABedErrorOptions>,
|
|
88
|
-
category?: Extract<ErrorCategory,
|
|
87
|
+
constructor(message: string, options?: Omit<Partial<HideABedErrorOptions>, 'category' | 'retryable'> & {
|
|
88
|
+
category?: Extract<ErrorCategory, 'operation' | 'transaction'>;
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
@@ -94,7 +94,7 @@ export declare class OperationError extends HideABedError {
|
|
|
94
94
|
* @public
|
|
95
95
|
*/
|
|
96
96
|
export declare class ValidationError extends HideABedError {
|
|
97
|
-
readonly issues: ValidationErrorOptions[
|
|
97
|
+
readonly issues: ValidationErrorOptions['issues'];
|
|
98
98
|
constructor(options: ValidationErrorOptions);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -107,8 +107,8 @@ export declare class ValidationError extends HideABedError {
|
|
|
107
107
|
* @public
|
|
108
108
|
*/
|
|
109
109
|
export declare class RetryableError extends HideABedError {
|
|
110
|
-
constructor(message: string, statusCode?: number, options?: Omit<Partial<HideABedErrorOptions>,
|
|
111
|
-
category?: Extract<ErrorCategory,
|
|
110
|
+
constructor(message: string, statusCode?: number, options?: Omit<Partial<HideABedErrorOptions>, 'category' | 'retryable' | 'statusCode'> & {
|
|
111
|
+
category?: Extract<ErrorCategory, 'network' | 'retryable'>;
|
|
112
112
|
});
|
|
113
113
|
/**
|
|
114
114
|
* Determines whether the provided status code should be treated as retryable.
|
|
@@ -136,7 +136,7 @@ type ResponseErrorOptions = {
|
|
|
136
136
|
operation: ErrorOperation;
|
|
137
137
|
statusCode?: number;
|
|
138
138
|
};
|
|
139
|
-
export declare function createResponseError({ body, defaultMessage, docId, notFoundMessage, operation, statusCode
|
|
139
|
+
export declare function createResponseError({ body, defaultMessage, docId, notFoundMessage, operation, statusCode }: ResponseErrorOptions): HideABedError;
|
|
140
140
|
export declare function isConflictError(err: unknown): boolean;
|
|
141
141
|
export {};
|
|
142
142
|
//# sourceMappingURL=errors.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../../../../impl/utils/errors.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"errors.d.mts","sourceRoot":"","sources":["../../../../impl/utils/errors.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAGtE;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAA;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAMD,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,SAAS,GACT,WAAW,GACX,WAAW,GACX,WAAW,GACX,YAAY,GACZ,aAAa,CAAA;AAEjB,MAAM,MAAM,cAAc,GACtB,KAAK,GACL,UAAU,GACV,WAAW,GACX,QAAQ,GACR,OAAO,GACP,kBAAkB,GAClB,KAAK,GACL,OAAO,GACP,aAAa,GACb,QAAQ,GACR,SAAS,GACT,WAAW,CAAA;AAsCf,eAAO,MAAM,aAAa,GAAI,OAAO,O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AE,SAAS,GAAE,cAA0B,GAAG,KAAK;CAgBtF;AAED,KAAK,oBAAoB,GAAG;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,MAAM,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,EAAE,cAAc,CAAA;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAYD,wBAAgB,mBAAmB,CAAC,EAClC,IAAI,EACJ,cAAc,EACd,KAAK,EACL,eAAe,EACf,SAAS,EACT,UAAU,EACX,EAAE,oBAAoB,GAAG,aAAa,CAwCtC;AAED,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAKrD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { RequestOptions } from
|
|
2
|
-
export type HttpMethod =
|
|
3
|
-
type NativeFetchBody = RequestInit[
|
|
1
|
+
import type { RequestOptions } from '../../schema/request.mts';
|
|
2
|
+
export type HttpMethod = 'DELETE' | 'GET' | 'HEAD' | 'POST' | 'PUT';
|
|
3
|
+
type NativeFetchBody = RequestInit['body'];
|
|
4
4
|
export type FetchBody = NativeFetchBody | Record<string, unknown> | Array<unknown> | null | undefined;
|
|
5
5
|
export type FetchAuth = {
|
|
6
6
|
password: string;
|
|
@@ -16,7 +16,7 @@ export type FetchRequestOptions = {
|
|
|
16
16
|
body?: FetchBody;
|
|
17
17
|
headers?: Record<string, string>;
|
|
18
18
|
method: HttpMethod;
|
|
19
|
-
operation?:
|
|
19
|
+
operation?: 'get' | 'getAtRev' | 'getDBInfo' | 'headDB' | 'patch' | 'patchDangerously' | 'put' | 'query' | 'queryStream' | 'remove' | 'request' | 'watchDocs';
|
|
20
20
|
request?: RequestOptions;
|
|
21
21
|
signal?: AbortSignal;
|
|
22
22
|
url: string | URL;
|