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.
Files changed (107) hide show
  1. package/migration_guides/v6.md +70 -0
  2. package/package.json +4 -1
  3. package/docs/.nojekyll +0 -1
  4. package/docs/assets/hierarchy.js +0 -1
  5. package/docs/assets/highlight.css +0 -113
  6. package/docs/assets/icons.js +0 -18
  7. package/docs/assets/icons.svg +0 -1
  8. package/docs/assets/main.js +0 -60
  9. package/docs/assets/navigation.js +0 -1
  10. package/docs/assets/search.js +0 -1
  11. package/docs/assets/style.css +0 -1633
  12. package/docs/classes/QueryBuilder.html +0 -42
  13. package/docs/functions/bindConfig.html +0 -4
  14. package/docs/functions/bulkGet.html +0 -14
  15. package/docs/functions/bulkGetDictionary.html +0 -10
  16. package/docs/functions/bulkRemove.html +0 -12
  17. package/docs/functions/bulkRemoveMap.html +0 -11
  18. package/docs/functions/bulkSave.html +0 -10
  19. package/docs/functions/bulkSaveTransaction.html +0 -23
  20. package/docs/functions/createLock.html +0 -7
  21. package/docs/functions/createQuery.html +0 -1
  22. package/docs/functions/get.html +0 -1
  23. package/docs/functions/getAtRev.html +0 -1
  24. package/docs/functions/getDBInfo.html +0 -10
  25. package/docs/functions/patch.html +0 -8
  26. package/docs/functions/patchDangerously.html +0 -9
  27. package/docs/functions/put.html +0 -1
  28. package/docs/functions/query.html +0 -15
  29. package/docs/functions/queryStream.html +0 -6
  30. package/docs/functions/remove.html +0 -1
  31. package/docs/functions/removeLock.html +0 -6
  32. package/docs/functions/watchDocs.html +0 -9
  33. package/docs/functions/withRetry.html +0 -6
  34. package/docs/hierarchy.html +0 -1
  35. package/docs/index.html +0 -483
  36. package/docs/interfaces/NetworkError.html +0 -6
  37. package/docs/interfaces/NotFoundError.html +0 -10
  38. package/docs/interfaces/RetryOptions.html +0 -10
  39. package/docs/interfaces/RetryableError.html +0 -10
  40. package/docs/interfaces/StandardSchemaV1.FailureResult.html +0 -4
  41. package/docs/interfaces/StandardSchemaV1.Issue.html +0 -6
  42. package/docs/interfaces/StandardSchemaV1.Options.html +0 -3
  43. package/docs/interfaces/StandardSchemaV1.PathSegment.html +0 -4
  44. package/docs/interfaces/StandardSchemaV1.Props.html +0 -10
  45. package/docs/interfaces/StandardSchemaV1.SuccessResult.html +0 -6
  46. package/docs/interfaces/StandardSchemaV1.Types.html +0 -6
  47. package/docs/interfaces/StandardSchemaV1.html +0 -4
  48. package/docs/modules/StandardSchemaV1.html +0 -1
  49. package/docs/modules.html +0 -1
  50. package/docs/types/BoundInstance.html +0 -1
  51. package/docs/types/BulkGetBound.html +0 -2
  52. package/docs/types/BulkGetDictionaryBound.html +0 -1
  53. package/docs/types/BulkGetDictionaryOptions.html +0 -2
  54. package/docs/types/BulkGetDictionaryResult.html +0 -3
  55. package/docs/types/BulkGetOptions.html +0 -3
  56. package/docs/types/BulkGetResponse.html +0 -1
  57. package/docs/types/CouchConfig-1.html +0 -1
  58. package/docs/types/CouchConfig.html +0 -1
  59. package/docs/types/CouchConfigInput.html +0 -1
  60. package/docs/types/CouchDoc-1.html +0 -1
  61. package/docs/types/CouchDoc.html +0 -2
  62. package/docs/types/CouchDocInput.html +0 -2
  63. package/docs/types/GetAtRevBound.html +0 -1
  64. package/docs/types/GetBound.html +0 -1
  65. package/docs/types/GetOptions.html +0 -2
  66. package/docs/types/LockDoc-1.html +0 -1
  67. package/docs/types/LockDoc.html +0 -1
  68. package/docs/types/LockOptions-1.html +0 -1
  69. package/docs/types/LockOptions.html +0 -1
  70. package/docs/types/LockOptionsInput.html +0 -1
  71. package/docs/types/OnInvalidDocAction.html +0 -1
  72. package/docs/types/OnRow.html +0 -1
  73. package/docs/types/QueryBound.html +0 -1
  74. package/docs/types/SimpleViewOptions-1.html +0 -1
  75. package/docs/types/SimpleViewOptions.html +0 -1
  76. package/docs/types/StandardSchemaV1.InferInput.html +0 -2
  77. package/docs/types/StandardSchemaV1.InferOutput.html +0 -2
  78. package/docs/types/StandardSchemaV1.Result.html +0 -2
  79. package/docs/types/ViewQueryResponse-1.html +0 -1
  80. package/docs/types/ViewQueryResponse.html +0 -2
  81. package/docs/types/ViewQueryResponseValidated.html +0 -2
  82. package/docs/types/ViewRow-1.html +0 -1
  83. package/docs/types/ViewRow.html +0 -2
  84. package/docs/types/ViewRowValidated.html +0 -7
  85. package/docs/types/ViewString.html +0 -1
  86. package/docs/types/WatchOptionsInput.html +0 -1
  87. package/docs/types/WatchOptionsSchema-1.html +0 -1
  88. package/docs/types/WatchOptionsSchema.html +0 -1
  89. package/impl/bulkGet.test.mts +0 -159
  90. package/impl/bulkRemove.test.mts +0 -102
  91. package/impl/bulkSave.test.mts +0 -319
  92. package/impl/get.test.mts +0 -114
  93. package/impl/getDBInfo.test.mts +0 -62
  94. package/impl/patch.test.mts +0 -142
  95. package/impl/put.test.mts +0 -114
  96. package/impl/query.test.mts +0 -280
  97. package/impl/remove.test.mts +0 -82
  98. package/impl/retry.test.mts +0 -77
  99. package/impl/stream.test.mts +0 -205
  100. package/impl/sugar/lock.test.mts +0 -113
  101. package/impl/sugar/watch.test.mts +0 -155
  102. package/impl/utils/errors.test.mts +0 -58
  103. package/impl/utils/logger.test.mts +0 -129
  104. package/impl/utils/parseRows.test.mts +0 -183
  105. package/impl/utils/queryBuilder.test.mts +0 -83
  106. package/impl/utils/queryString.test.mts +0 -53
  107. 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
- })