hide-a-bed 7.0.0 → 7.1.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/README.md +167 -145
- package/dist/cjs/index.cjs +48 -2
- package/dist/esm/index.mjs +48 -3
- package/impl/bindConfig.mts +72 -60
- package/impl/headDB.mts +55 -0
- package/impl/utils/errors.mts +189 -158
- package/impl/utils/fetch.mts +102 -93
- package/impl/utils/queryString.mts +1 -2
- package/index.mts +56 -41
- package/package.json +1 -1
- package/types/output/impl/bindConfig.d.mts +16 -14
- package/types/output/impl/bindConfig.d.mts.map +1 -1
- package/types/output/impl/headDB.d.mts +13 -0
- package/types/output/impl/headDB.d.mts.map +1 -0
- package/types/output/impl/headDB.test.d.mts +2 -0
- package/types/output/impl/headDB.test.d.mts.map +1 -0
- 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/impl/utils/queryString.d.mts.map +1 -1
- package/types/output/index.d.mts +35 -34
- package/types/output/index.d.mts.map +1 -1
package/impl/utils/fetch.mts
CHANGED
|
@@ -1,89 +1,92 @@
|
|
|
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
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
};
|
|
48
49
|
|
|
49
50
|
const JSON_HEADERS = {
|
|
50
|
-
|
|
51
|
-
} as const
|
|
51
|
+
"Content-Type": "application/json",
|
|
52
|
+
} as const;
|
|
52
53
|
|
|
53
54
|
const hasHeader = (headers: Record<string, string>, name: string) => {
|
|
54
|
-
const expected = name.toLowerCase()
|
|
55
|
-
return Object.keys(headers).some(
|
|
56
|
-
|
|
55
|
+
const expected = name.toLowerCase();
|
|
56
|
+
return Object.keys(headers).some(
|
|
57
|
+
(header) => header.toLowerCase() === expected,
|
|
58
|
+
);
|
|
59
|
+
};
|
|
57
60
|
|
|
58
61
|
const toBasicAuthHeader = ({ username, password }: FetchAuth) => {
|
|
59
|
-
const token = Buffer.from(`${username}:${password}`).toString(
|
|
60
|
-
return `Basic ${token}
|
|
61
|
-
}
|
|
62
|
+
const token = Buffer.from(`${username}:${password}`).toString("base64");
|
|
63
|
+
return `Basic ${token}`;
|
|
64
|
+
};
|
|
62
65
|
|
|
63
66
|
const prepareRequest = (options: FetchRequestOptions) => {
|
|
64
|
-
const auth = options.auth
|
|
65
|
-
const headers = { ...(options.headers ?? {}) }
|
|
67
|
+
const auth = options.auth;
|
|
68
|
+
const headers = { ...(options.headers ?? {}) };
|
|
66
69
|
|
|
67
|
-
if (auth && !hasHeader(headers,
|
|
68
|
-
headers.Authorization = toBasicAuthHeader(auth)
|
|
70
|
+
if (auth && !hasHeader(headers, "Authorization")) {
|
|
71
|
+
headers.Authorization = toBasicAuthHeader(auth);
|
|
69
72
|
}
|
|
70
73
|
|
|
71
|
-
return { headers }
|
|
72
|
-
}
|
|
74
|
+
return { headers };
|
|
75
|
+
};
|
|
73
76
|
|
|
74
77
|
const isAbortError = (err: unknown): err is DOMException => {
|
|
75
|
-
return err instanceof DOMException && err.name ===
|
|
76
|
-
}
|
|
78
|
+
return err instanceof DOMException && err.name === "AbortError";
|
|
79
|
+
};
|
|
77
80
|
|
|
78
81
|
const isTimeoutError = (err: unknown): err is DOMException => {
|
|
79
|
-
return err instanceof DOMException && err.name ===
|
|
80
|
-
}
|
|
82
|
+
return err instanceof DOMException && err.name === "TimeoutError";
|
|
83
|
+
};
|
|
81
84
|
|
|
82
85
|
const encodeBody = (body: FetchBody): NativeFetchBody | undefined => {
|
|
83
|
-
if (body == null) return undefined
|
|
86
|
+
if (body == null) return undefined;
|
|
84
87
|
|
|
85
88
|
if (
|
|
86
|
-
typeof body ===
|
|
89
|
+
typeof body === "string" ||
|
|
87
90
|
body instanceof ArrayBuffer ||
|
|
88
91
|
ArrayBuffer.isView(body) ||
|
|
89
92
|
body instanceof Blob ||
|
|
@@ -91,83 +94,89 @@ const encodeBody = (body: FetchBody): NativeFetchBody | undefined => {
|
|
|
91
94
|
body instanceof URLSearchParams ||
|
|
92
95
|
body instanceof ReadableStream
|
|
93
96
|
) {
|
|
94
|
-
return body as NativeFetchBody
|
|
97
|
+
return body as NativeFetchBody;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
|
-
return JSON.stringify(body)
|
|
98
|
-
}
|
|
100
|
+
return JSON.stringify(body);
|
|
101
|
+
};
|
|
99
102
|
|
|
100
103
|
const parseJsonResponse = async (response: Response): Promise<unknown> => {
|
|
101
104
|
if (response.status === 204 || response.status === 205) {
|
|
102
|
-
return null
|
|
105
|
+
return null;
|
|
103
106
|
}
|
|
104
107
|
|
|
105
|
-
const text = await response.text()
|
|
108
|
+
const text = await response.text();
|
|
106
109
|
|
|
107
|
-
if (text.trim() ===
|
|
108
|
-
return null
|
|
110
|
+
if (text.trim() === "") {
|
|
111
|
+
return null;
|
|
109
112
|
}
|
|
110
113
|
|
|
111
114
|
try {
|
|
112
|
-
return JSON.parse(text)
|
|
115
|
+
return JSON.parse(text);
|
|
113
116
|
} catch (err) {
|
|
114
117
|
if (response.ok) {
|
|
115
|
-
throw err
|
|
118
|
+
throw err;
|
|
116
119
|
}
|
|
117
120
|
|
|
118
|
-
return text
|
|
121
|
+
return text;
|
|
119
122
|
}
|
|
120
|
-
}
|
|
123
|
+
};
|
|
121
124
|
|
|
122
125
|
export async function fetchCouchJson<TBody = unknown>(
|
|
123
|
-
options: FetchRequestOptions
|
|
126
|
+
options: FetchRequestOptions,
|
|
124
127
|
): Promise<FetchResult<TBody>> {
|
|
125
|
-
let response: Response
|
|
126
|
-
const { headers } = prepareRequest(options)
|
|
127
|
-
const { signal, timedOut } = composeAbortSignal(
|
|
128
|
+
let response: Response;
|
|
129
|
+
const { headers } = prepareRequest(options);
|
|
130
|
+
const { signal, timedOut } = composeAbortSignal(
|
|
131
|
+
options.signal,
|
|
132
|
+
options.request,
|
|
133
|
+
);
|
|
128
134
|
|
|
129
135
|
try {
|
|
130
136
|
response = await fetch(options.url, {
|
|
131
137
|
method: options.method,
|
|
132
138
|
headers: {
|
|
133
139
|
...JSON_HEADERS,
|
|
134
|
-
...headers
|
|
140
|
+
...headers,
|
|
135
141
|
},
|
|
136
142
|
body: encodeBody(options.body),
|
|
137
143
|
signal,
|
|
138
|
-
dispatcher: options.request?.dispatcher
|
|
139
|
-
})
|
|
144
|
+
dispatcher: options.request?.dispatcher,
|
|
145
|
+
});
|
|
140
146
|
} catch (err) {
|
|
141
147
|
if (timedOut() || isTimeoutError(err)) {
|
|
142
|
-
throw new RetryableError(
|
|
143
|
-
category:
|
|
148
|
+
throw new RetryableError("Request timed out", 503, {
|
|
149
|
+
category: "network",
|
|
144
150
|
cause: err,
|
|
145
|
-
operation: options.operation
|
|
146
|
-
})
|
|
151
|
+
operation: options.operation,
|
|
152
|
+
});
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
if (isAbortError(err)) {
|
|
150
|
-
throw err
|
|
156
|
+
throw err;
|
|
151
157
|
}
|
|
152
158
|
|
|
153
|
-
RetryableError.handleNetworkError(err, options.operation)
|
|
159
|
+
RetryableError.handleNetworkError(err, options.operation);
|
|
154
160
|
}
|
|
155
161
|
|
|
156
|
-
const body = (await parseJsonResponse(response)) as TBody
|
|
162
|
+
const body = (await parseJsonResponse(response)) as TBody;
|
|
157
163
|
|
|
158
164
|
return {
|
|
159
165
|
body,
|
|
160
166
|
headers: response.headers,
|
|
161
|
-
statusCode: response.status
|
|
162
|
-
}
|
|
167
|
+
statusCode: response.status,
|
|
168
|
+
};
|
|
163
169
|
}
|
|
164
170
|
|
|
165
171
|
export async function fetchCouchStream(
|
|
166
|
-
options: FetchRequestOptions
|
|
172
|
+
options: FetchRequestOptions,
|
|
167
173
|
): Promise<FetchResult<ReadableStream<Uint8Array> | null>> {
|
|
168
|
-
let response: Response
|
|
169
|
-
const { headers } = prepareRequest(options)
|
|
170
|
-
const { signal, timedOut } = composeAbortSignal(
|
|
174
|
+
let response: Response;
|
|
175
|
+
const { headers } = prepareRequest(options);
|
|
176
|
+
const { signal, timedOut } = composeAbortSignal(
|
|
177
|
+
options.signal,
|
|
178
|
+
options.request,
|
|
179
|
+
);
|
|
171
180
|
|
|
172
181
|
try {
|
|
173
182
|
response = await fetch(options.url, {
|
|
@@ -175,27 +184,27 @@ export async function fetchCouchStream(
|
|
|
175
184
|
headers,
|
|
176
185
|
body: encodeBody(options.body),
|
|
177
186
|
signal,
|
|
178
|
-
dispatcher: options.request?.dispatcher
|
|
179
|
-
})
|
|
187
|
+
dispatcher: options.request?.dispatcher,
|
|
188
|
+
});
|
|
180
189
|
} catch (err) {
|
|
181
190
|
if (timedOut() || isTimeoutError(err)) {
|
|
182
|
-
throw new RetryableError(
|
|
183
|
-
category:
|
|
191
|
+
throw new RetryableError("Request timed out", 503, {
|
|
192
|
+
category: "network",
|
|
184
193
|
cause: err,
|
|
185
|
-
operation: options.operation
|
|
186
|
-
})
|
|
194
|
+
operation: options.operation,
|
|
195
|
+
});
|
|
187
196
|
}
|
|
188
197
|
|
|
189
198
|
if (isAbortError(err)) {
|
|
190
|
-
throw err
|
|
199
|
+
throw err;
|
|
191
200
|
}
|
|
192
201
|
|
|
193
|
-
RetryableError.handleNetworkError(err, options.operation)
|
|
202
|
+
RetryableError.handleNetworkError(err, options.operation);
|
|
194
203
|
}
|
|
195
204
|
|
|
196
205
|
return {
|
|
197
206
|
body: response.body,
|
|
198
207
|
headers: response.headers,
|
|
199
|
-
statusCode: response.status
|
|
200
|
-
}
|
|
208
|
+
statusCode: response.status,
|
|
209
|
+
};
|
|
201
210
|
}
|
package/index.mts
CHANGED
|
@@ -1,19 +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 {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
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";
|
|
17
18
|
|
|
18
19
|
export {
|
|
19
20
|
get,
|
|
@@ -25,6 +26,7 @@ export {
|
|
|
25
26
|
query,
|
|
26
27
|
queryStream,
|
|
27
28
|
getDBInfo,
|
|
29
|
+
headDB,
|
|
28
30
|
|
|
29
31
|
// sugar methods
|
|
30
32
|
patch,
|
|
@@ -43,8 +45,8 @@ export {
|
|
|
43
45
|
QueryBuilder,
|
|
44
46
|
createQuery,
|
|
45
47
|
createLock,
|
|
46
|
-
removeLock
|
|
47
|
-
}
|
|
48
|
+
removeLock,
|
|
49
|
+
};
|
|
48
50
|
|
|
49
51
|
export {
|
|
50
52
|
ConflictError,
|
|
@@ -52,8 +54,8 @@ export {
|
|
|
52
54
|
NotFoundError,
|
|
53
55
|
OperationError,
|
|
54
56
|
RetryableError,
|
|
55
|
-
ValidationError
|
|
56
|
-
} from
|
|
57
|
+
ValidationError,
|
|
58
|
+
} from "./impl/utils/errors.mts";
|
|
57
59
|
|
|
58
60
|
export type {
|
|
59
61
|
BulkGetBound,
|
|
@@ -61,39 +63,52 @@ export type {
|
|
|
61
63
|
BulkGetDictionaryOptions,
|
|
62
64
|
BulkGetDictionaryResult,
|
|
63
65
|
BulkGetOptions,
|
|
64
|
-
BulkGetResponse
|
|
65
|
-
} from
|
|
66
|
-
export type { OnInvalidDocAction } from
|
|
67
|
-
export type { GetOptions, GetBound, GetAtRevBound } from
|
|
68
|
-
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";
|
|
69
71
|
export type {
|
|
70
72
|
ViewString,
|
|
71
|
-
ViewOptions as SimpleViewOptions
|
|
72
|
-
} from
|
|
73
|
+
ViewOptions as SimpleViewOptions,
|
|
74
|
+
} from "./schema/couch/couch.input.schema.ts";
|
|
73
75
|
export type {
|
|
74
76
|
ViewRow,
|
|
75
77
|
CouchDoc,
|
|
76
78
|
CouchDocInput,
|
|
77
79
|
ViewQueryResponse,
|
|
78
80
|
ViewQueryResponseValidated,
|
|
79
|
-
ViewRowValidated
|
|
80
|
-
} from
|
|
81
|
-
export type { RetryOptions } from
|
|
81
|
+
ViewRowValidated,
|
|
82
|
+
} from "./schema/couch/couch.output.schema.ts";
|
|
83
|
+
export type { RetryOptions } from "./impl/retry.mts";
|
|
82
84
|
export type {
|
|
83
85
|
ErrorCategory,
|
|
84
86
|
ErrorOperation,
|
|
85
87
|
HideABedErrorOptions,
|
|
86
88
|
NetworkError,
|
|
87
|
-
ValidationErrorOptions
|
|
88
|
-
} from
|
|
89
|
-
export type { OnRow } from
|
|
90
|
-
export type {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
ValidationErrorOptions,
|
|
90
|
+
} from "./impl/utils/errors.mts";
|
|
91
|
+
export type { OnRow } from "./impl/stream.mts";
|
|
92
|
+
export type {
|
|
93
|
+
CouchAuth,
|
|
94
|
+
CouchAuthInput,
|
|
95
|
+
CouchConfig,
|
|
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";
|
|
94
109
|
export type {
|
|
95
110
|
WatchOptions as WatchOptionsSchema,
|
|
96
|
-
WatchOptionsInput
|
|
97
|
-
} from
|
|
98
|
-
export type { BoundInstance } from
|
|
99
|
-
export type { StandardSchemaV1 } from
|
|
111
|
+
WatchOptionsInput,
|
|
112
|
+
} from "./schema/sugar/watch.mts";
|
|
113
|
+
export type { BoundInstance } from "./impl/bindConfig.mts";
|
|
114
|
+
export type { StandardSchemaV1 } from "./types/standard-schema.ts";
|
package/package.json
CHANGED
|
@@ -1,17 +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 {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
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";
|
|
15
16
|
type BoundConfigMethod<T> = T extends (...args: infer Args) => infer Result ? Args extends [unknown, ...infer Rest] ? (...args: Rest) => Result : never : never;
|
|
16
17
|
type BoundMethods = {
|
|
17
18
|
bulkGet: BulkGetBound;
|
|
@@ -24,6 +25,7 @@ type BoundMethods = {
|
|
|
24
25
|
bulkSave: BoundConfigMethod<typeof bulkSave>;
|
|
25
26
|
bulkSaveTransaction: BoundConfigMethod<typeof bulkSaveTransaction>;
|
|
26
27
|
getDBInfo: BoundConfigMethod<typeof getDBInfo>;
|
|
28
|
+
headDB: BoundConfigMethod<typeof headDB>;
|
|
27
29
|
patch: BoundConfigMethod<typeof patch>;
|
|
28
30
|
patchDangerously: BoundConfigMethod<typeof patchDangerously>;
|
|
29
31
|
put: BoundConfigMethod<typeof put>;
|
|
@@ -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":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CouchConfigInput } from "../schema/config.mts";
|
|
2
|
+
/**
|
|
3
|
+
* Performs a health check against the target CouchDB database using `HEAD /{db}`.
|
|
4
|
+
*
|
|
5
|
+
* @see {@link https://docs.couchdb.org/en/stable/api/database/common.html#head--db | CouchDB API Documentation}
|
|
6
|
+
*
|
|
7
|
+
* @param configInput - The CouchDB configuration input.
|
|
8
|
+
* @returns A promise that resolves to `true` when the database responds successfully.
|
|
9
|
+
* @throws {RetryableError} `RetryableError` If a retryable error occurs during the request.
|
|
10
|
+
* @throws {OperationError} For other non-retryable response failures.
|
|
11
|
+
*/
|
|
12
|
+
export declare const headDB: (configInput: CouchConfigInput) => Promise<true>;
|
|
13
|
+
//# sourceMappingURL=headDB.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headDB.d.mts","sourceRoot":"","sources":["../../../impl/headDB.mts"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAK1E;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM,GAAU,aAAa,gBAAgB,KAAG,OAAO,CAAC,IAAI,CAqCxE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headDB.test.d.mts","sourceRoot":"","sources":["../../../impl/headDB.test.mts"],"names":[],"mappings":""}
|
|
@@ -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 }: ResponseErrorOptions): HideABedError;
|
|
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
|