hide-a-bed 6.0.0-beta.0 → 6.0.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/migration_guides/v6.md +70 -0
- package/package.json +4 -1
- package/docs/.nojekyll +0 -1
- package/docs/assets/hierarchy.js +0 -1
- package/docs/assets/highlight.css +0 -113
- package/docs/assets/icons.js +0 -18
- package/docs/assets/icons.svg +0 -1
- package/docs/assets/main.js +0 -60
- package/docs/assets/navigation.js +0 -1
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1633
- package/docs/classes/QueryBuilder.html +0 -42
- package/docs/functions/bindConfig.html +0 -4
- package/docs/functions/bulkGet.html +0 -14
- package/docs/functions/bulkGetDictionary.html +0 -10
- package/docs/functions/bulkRemove.html +0 -12
- package/docs/functions/bulkRemoveMap.html +0 -11
- package/docs/functions/bulkSave.html +0 -10
- package/docs/functions/bulkSaveTransaction.html +0 -23
- package/docs/functions/createLock.html +0 -7
- package/docs/functions/createQuery.html +0 -1
- package/docs/functions/get.html +0 -1
- package/docs/functions/getAtRev.html +0 -1
- package/docs/functions/getDBInfo.html +0 -10
- package/docs/functions/patch.html +0 -8
- package/docs/functions/patchDangerously.html +0 -9
- package/docs/functions/put.html +0 -1
- package/docs/functions/query.html +0 -15
- package/docs/functions/queryStream.html +0 -6
- package/docs/functions/remove.html +0 -1
- package/docs/functions/removeLock.html +0 -6
- package/docs/functions/watchDocs.html +0 -9
- package/docs/functions/withRetry.html +0 -6
- package/docs/hierarchy.html +0 -1
- package/docs/index.html +0 -483
- package/docs/interfaces/NetworkError.html +0 -6
- package/docs/interfaces/NotFoundError.html +0 -10
- package/docs/interfaces/RetryOptions.html +0 -10
- package/docs/interfaces/RetryableError.html +0 -10
- package/docs/interfaces/StandardSchemaV1.FailureResult.html +0 -4
- package/docs/interfaces/StandardSchemaV1.Issue.html +0 -6
- package/docs/interfaces/StandardSchemaV1.Options.html +0 -3
- package/docs/interfaces/StandardSchemaV1.PathSegment.html +0 -4
- package/docs/interfaces/StandardSchemaV1.Props.html +0 -10
- package/docs/interfaces/StandardSchemaV1.SuccessResult.html +0 -6
- package/docs/interfaces/StandardSchemaV1.Types.html +0 -6
- package/docs/interfaces/StandardSchemaV1.html +0 -4
- package/docs/modules/StandardSchemaV1.html +0 -1
- package/docs/modules.html +0 -1
- package/docs/types/BoundInstance.html +0 -1
- package/docs/types/BulkGetBound.html +0 -2
- package/docs/types/BulkGetDictionaryBound.html +0 -1
- package/docs/types/BulkGetDictionaryOptions.html +0 -2
- package/docs/types/BulkGetDictionaryResult.html +0 -3
- package/docs/types/BulkGetOptions.html +0 -3
- package/docs/types/BulkGetResponse.html +0 -1
- package/docs/types/CouchConfig-1.html +0 -1
- package/docs/types/CouchConfig.html +0 -1
- package/docs/types/CouchConfigInput.html +0 -1
- package/docs/types/CouchDoc-1.html +0 -1
- package/docs/types/CouchDoc.html +0 -2
- package/docs/types/CouchDocInput.html +0 -2
- package/docs/types/GetAtRevBound.html +0 -1
- package/docs/types/GetBound.html +0 -1
- package/docs/types/GetOptions.html +0 -2
- package/docs/types/LockDoc-1.html +0 -1
- package/docs/types/LockDoc.html +0 -1
- package/docs/types/LockOptions-1.html +0 -1
- package/docs/types/LockOptions.html +0 -1
- package/docs/types/LockOptionsInput.html +0 -1
- package/docs/types/OnInvalidDocAction.html +0 -1
- package/docs/types/OnRow.html +0 -1
- package/docs/types/QueryBound.html +0 -1
- package/docs/types/SimpleViewOptions-1.html +0 -1
- package/docs/types/SimpleViewOptions.html +0 -1
- package/docs/types/StandardSchemaV1.InferInput.html +0 -2
- package/docs/types/StandardSchemaV1.InferOutput.html +0 -2
- package/docs/types/StandardSchemaV1.Result.html +0 -2
- package/docs/types/ViewQueryResponse-1.html +0 -1
- package/docs/types/ViewQueryResponse.html +0 -2
- package/docs/types/ViewQueryResponseValidated.html +0 -2
- package/docs/types/ViewRow-1.html +0 -1
- package/docs/types/ViewRow.html +0 -2
- package/docs/types/ViewRowValidated.html +0 -7
- package/docs/types/ViewString.html +0 -1
- package/docs/types/WatchOptionsInput.html +0 -1
- package/docs/types/WatchOptionsSchema-1.html +0 -1
- package/docs/types/WatchOptionsSchema.html +0 -1
- package/impl/bulkGet.test.mts +0 -159
- package/impl/bulkRemove.test.mts +0 -102
- package/impl/bulkSave.test.mts +0 -319
- package/impl/get.test.mts +0 -114
- package/impl/getDBInfo.test.mts +0 -62
- package/impl/patch.test.mts +0 -142
- package/impl/put.test.mts +0 -114
- package/impl/query.test.mts +0 -280
- package/impl/remove.test.mts +0 -82
- package/impl/retry.test.mts +0 -77
- package/impl/stream.test.mts +0 -205
- package/impl/sugar/lock.test.mts +0 -113
- package/impl/sugar/watch.test.mts +0 -155
- package/impl/utils/errors.test.mts +0 -58
- package/impl/utils/logger.test.mts +0 -129
- package/impl/utils/parseRows.test.mts +0 -183
- package/impl/utils/queryBuilder.test.mts +0 -83
- package/impl/utils/queryString.test.mts +0 -53
- package/index.test.mts +0 -415
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import test, { suite } from 'node:test'
|
|
3
|
-
import { z } from 'zod'
|
|
4
|
-
import { parseRows } from './parseRows.mts'
|
|
5
|
-
|
|
6
|
-
const docSchema = z.looseObject({
|
|
7
|
-
_id: z.string(),
|
|
8
|
-
count: z.number()
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
const keySchema = z.number()
|
|
12
|
-
|
|
13
|
-
const valueSchema = z.looseObject({
|
|
14
|
-
rev: z.string()
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
suite('parseRows', () => {
|
|
18
|
-
test('throws when rows is not an array', async () => {
|
|
19
|
-
await assert.rejects(
|
|
20
|
-
() =>
|
|
21
|
-
parseRows(
|
|
22
|
-
{},
|
|
23
|
-
{
|
|
24
|
-
docSchema,
|
|
25
|
-
keySchema,
|
|
26
|
-
valueSchema,
|
|
27
|
-
onInvalidDoc: 'throw'
|
|
28
|
-
}
|
|
29
|
-
),
|
|
30
|
-
err => err instanceof Error && err.message === 'invalid rows format'
|
|
31
|
-
)
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
test('parses rows and validates documents', async () => {
|
|
35
|
-
const rows = [
|
|
36
|
-
{
|
|
37
|
-
id: 'doc-valid',
|
|
38
|
-
key: 1,
|
|
39
|
-
value: { rev: '1-abc' },
|
|
40
|
-
doc: {
|
|
41
|
-
_id: 'doc-valid',
|
|
42
|
-
count: 42
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
id: 'doc-missing',
|
|
47
|
-
key: 2,
|
|
48
|
-
error: 'not_found',
|
|
49
|
-
doc: null,
|
|
50
|
-
value: { rev: '1-missing' }
|
|
51
|
-
}
|
|
52
|
-
]
|
|
53
|
-
|
|
54
|
-
const result = await parseRows(rows, {
|
|
55
|
-
docSchema,
|
|
56
|
-
keySchema,
|
|
57
|
-
valueSchema,
|
|
58
|
-
onInvalidDoc: 'throw'
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
assert.strictEqual(result.length, 2)
|
|
62
|
-
const [valid, missing] = result
|
|
63
|
-
assert.strictEqual(valid?.id, 'doc-valid')
|
|
64
|
-
assert.strictEqual(valid?.doc?.count, 42)
|
|
65
|
-
assert.strictEqual(valid?.key, 1)
|
|
66
|
-
assert.strictEqual(valid?.value?.rev, '1-abc')
|
|
67
|
-
assert.strictEqual(missing?.id, 'doc-missing')
|
|
68
|
-
assert.strictEqual(missing?.error, 'not_found')
|
|
69
|
-
assert.strictEqual(missing?.key, 2)
|
|
70
|
-
assert.strictEqual(missing?.value?.rev, '1-missing')
|
|
71
|
-
assert.strictEqual(missing?.doc, null)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('skips invalid documents when requested', async () => {
|
|
75
|
-
const rows = [
|
|
76
|
-
{
|
|
77
|
-
id: 'doc-valid',
|
|
78
|
-
key: 1,
|
|
79
|
-
value: { rev: '1-valid' },
|
|
80
|
-
doc: {
|
|
81
|
-
_id: 'doc-valid',
|
|
82
|
-
count: 7
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
id: 'doc-invalid',
|
|
87
|
-
key: 2,
|
|
88
|
-
value: { rev: '1-invalid' },
|
|
89
|
-
doc: {
|
|
90
|
-
_id: 'doc-invalid',
|
|
91
|
-
count: 'nope'
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
]
|
|
95
|
-
|
|
96
|
-
const result = await parseRows(rows, {
|
|
97
|
-
docSchema,
|
|
98
|
-
keySchema,
|
|
99
|
-
valueSchema,
|
|
100
|
-
onInvalidDoc: 'skip'
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
assert.strictEqual(result.length, 1)
|
|
104
|
-
assert.strictEqual(result[0]?.id, 'doc-valid')
|
|
105
|
-
assert.strictEqual(result[0]?.doc?.count, 7)
|
|
106
|
-
assert.strictEqual(result[0]?.key, 1)
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test('throws when a document fails validation with onInvalidDoc=throw', async () => {
|
|
110
|
-
const rows = [
|
|
111
|
-
{
|
|
112
|
-
id: 'doc-invalid',
|
|
113
|
-
key: 1,
|
|
114
|
-
value: { rev: '1-invalid' },
|
|
115
|
-
doc: {
|
|
116
|
-
_id: 'doc-invalid',
|
|
117
|
-
count: 'nope'
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
]
|
|
121
|
-
|
|
122
|
-
await assert.rejects(
|
|
123
|
-
() =>
|
|
124
|
-
parseRows(rows, {
|
|
125
|
-
docSchema,
|
|
126
|
-
keySchema,
|
|
127
|
-
valueSchema,
|
|
128
|
-
onInvalidDoc: 'throw'
|
|
129
|
-
}),
|
|
130
|
-
err => Array.isArray(err)
|
|
131
|
-
)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
test('throws when key fails validation', async () => {
|
|
135
|
-
const rows = [
|
|
136
|
-
{
|
|
137
|
-
id: 'doc-valid',
|
|
138
|
-
key: 'invalid',
|
|
139
|
-
value: { rev: '1-valid' },
|
|
140
|
-
doc: {
|
|
141
|
-
_id: 'doc-valid',
|
|
142
|
-
count: 7
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
]
|
|
146
|
-
|
|
147
|
-
await assert.rejects(
|
|
148
|
-
() =>
|
|
149
|
-
parseRows(rows, {
|
|
150
|
-
docSchema,
|
|
151
|
-
keySchema,
|
|
152
|
-
valueSchema,
|
|
153
|
-
onInvalidDoc: 'throw'
|
|
154
|
-
}),
|
|
155
|
-
err => Array.isArray(err)
|
|
156
|
-
)
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
test('throws when value fails validation', async () => {
|
|
160
|
-
const rows = [
|
|
161
|
-
{
|
|
162
|
-
id: 'doc-valid',
|
|
163
|
-
key: 1,
|
|
164
|
-
value: { rev: 123 },
|
|
165
|
-
doc: {
|
|
166
|
-
_id: 'doc-valid',
|
|
167
|
-
count: 7
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
]
|
|
171
|
-
|
|
172
|
-
await assert.rejects(
|
|
173
|
-
() =>
|
|
174
|
-
parseRows(rows, {
|
|
175
|
-
docSchema,
|
|
176
|
-
keySchema,
|
|
177
|
-
valueSchema,
|
|
178
|
-
onInvalidDoc: 'throw'
|
|
179
|
-
}),
|
|
180
|
-
err => Array.isArray(err)
|
|
181
|
-
)
|
|
182
|
-
})
|
|
183
|
-
})
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import test, { suite } from 'node:test'
|
|
3
|
-
import { QueryBuilder, createQuery } from './queryBuilder.mts'
|
|
4
|
-
|
|
5
|
-
suite('QueryBuilder', () => {
|
|
6
|
-
test('build returns populated options', () => {
|
|
7
|
-
const options = new QueryBuilder()
|
|
8
|
-
.descending(false)
|
|
9
|
-
.endkey_docid('end-doc')
|
|
10
|
-
.endkey(['range-end'])
|
|
11
|
-
.group(false)
|
|
12
|
-
.group_level(2)
|
|
13
|
-
.include_docs(true)
|
|
14
|
-
.inclusive_end(false)
|
|
15
|
-
.key('primary')
|
|
16
|
-
.keys(['k1', { foo: 'bar' }])
|
|
17
|
-
.limit(10)
|
|
18
|
-
.reduce(false)
|
|
19
|
-
.skip(5)
|
|
20
|
-
.sorted(false)
|
|
21
|
-
.stable(true)
|
|
22
|
-
.startkey(['range-start'])
|
|
23
|
-
.startkey_docid('start-doc')
|
|
24
|
-
.update('lazy')
|
|
25
|
-
.update_seq(true)
|
|
26
|
-
.build()
|
|
27
|
-
|
|
28
|
-
assert.deepStrictEqual(options, {
|
|
29
|
-
descending: false,
|
|
30
|
-
endkey_docid: 'end-doc',
|
|
31
|
-
endkey: ['range-end'],
|
|
32
|
-
group: false,
|
|
33
|
-
group_level: 2,
|
|
34
|
-
include_docs: true,
|
|
35
|
-
inclusive_end: false,
|
|
36
|
-
key: 'primary',
|
|
37
|
-
keys: ['k1', { foo: 'bar' }],
|
|
38
|
-
limit: 10,
|
|
39
|
-
reduce: false,
|
|
40
|
-
skip: 5,
|
|
41
|
-
sorted: false,
|
|
42
|
-
stable: true,
|
|
43
|
-
startkey: ['range-start'],
|
|
44
|
-
startkey_docid: 'start-doc',
|
|
45
|
-
update: 'lazy',
|
|
46
|
-
update_seq: true
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
test('alias methods map to canonical fields', () => {
|
|
51
|
-
const options = new QueryBuilder()
|
|
52
|
-
.endKey(['alias-end'])
|
|
53
|
-
.startKey(['alias-start'])
|
|
54
|
-
.end_key_doc_id('alias-end-doc')
|
|
55
|
-
.start_key_doc_id('alias-start-doc')
|
|
56
|
-
.end_key(['duplicate-end'])
|
|
57
|
-
.start_key(['duplicate-start'])
|
|
58
|
-
.build()
|
|
59
|
-
|
|
60
|
-
assert.deepStrictEqual(options, {
|
|
61
|
-
endkey: ['duplicate-end'],
|
|
62
|
-
startkey: ['duplicate-start'],
|
|
63
|
-
endkey_docid: 'alias-end-doc',
|
|
64
|
-
startkey_docid: 'alias-start-doc'
|
|
65
|
-
})
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
test('build returns a defensive copy', () => {
|
|
69
|
-
const builder = new QueryBuilder().limit(5)
|
|
70
|
-
const first = builder.build()
|
|
71
|
-
first.limit = 42
|
|
72
|
-
|
|
73
|
-
const second = builder.build()
|
|
74
|
-
|
|
75
|
-
assert.notStrictEqual(first, second)
|
|
76
|
-
assert.strictEqual(second.limit, 5)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test('createQuery returns a builder instance', () => {
|
|
80
|
-
const builder = createQuery()
|
|
81
|
-
assert.ok(builder instanceof QueryBuilder)
|
|
82
|
-
})
|
|
83
|
-
})
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import assert from 'node:assert/strict'
|
|
2
|
-
import test, { suite } from 'node:test'
|
|
3
|
-
import { queryString } from './queryString.mts'
|
|
4
|
-
import type { ViewOptions } from '../../schema/couch/couch.input.schema.ts'
|
|
5
|
-
|
|
6
|
-
const keysToQuote: Array<keyof ViewOptions> = [
|
|
7
|
-
'endkey_docid',
|
|
8
|
-
'endkey',
|
|
9
|
-
'key',
|
|
10
|
-
'keys',
|
|
11
|
-
'startkey',
|
|
12
|
-
'startkey_docid',
|
|
13
|
-
'update'
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
suite('queryString', () => {
|
|
17
|
-
test('queryString quotes string values for KEYS_TO_QUOTE except keys array', () => {
|
|
18
|
-
const encodedByKey = new Map<string, string | null>()
|
|
19
|
-
|
|
20
|
-
for (const key of keysToQuote) {
|
|
21
|
-
if (key === 'keys') continue
|
|
22
|
-
const optionValue: ViewOptions = {
|
|
23
|
-
[key]: key === 'update' ? 'lazy' : 'banana'
|
|
24
|
-
} as ViewOptions
|
|
25
|
-
const encoded = queryString(optionValue)
|
|
26
|
-
const params = new URLSearchParams(encoded)
|
|
27
|
-
encodedByKey.set(key as string, params.get(key as string))
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
assert.deepEqual(Object.fromEntries(encodedByKey), {
|
|
31
|
-
endkey_docid: '"banana"',
|
|
32
|
-
endkey: '"banana"',
|
|
33
|
-
key: '"banana"',
|
|
34
|
-
startkey: '"banana"',
|
|
35
|
-
startkey_docid: '"banana"',
|
|
36
|
-
update: '"lazy"'
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test('queryString leaves primitive options outside KEYS_TO_QUOTE unchanged', () => {
|
|
41
|
-
const encoded = queryString({ descending: true })
|
|
42
|
-
const params = new URLSearchParams(encoded)
|
|
43
|
-
assert.equal(params.get('descending'), 'true')
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
test('queryString stringifies array values for keys option', () => {
|
|
47
|
-
const encoded = queryString({
|
|
48
|
-
keys: ['alpha', null, 42, {}, { foo: 'bar' }]
|
|
49
|
-
})
|
|
50
|
-
const params = new URLSearchParams(encoded)
|
|
51
|
-
assert.equal(params.get('keys'), '["alpha",null,42,{}, {"foo":"bar"}]'.replace(' ', ''))
|
|
52
|
-
})
|
|
53
|
-
})
|