hide-a-bed 3.0.1 → 4.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 (67) hide show
  1. package/README.md +104 -0
  2. package/cjs/impl/bulk.cjs +55 -6
  3. package/cjs/impl/crud.cjs +57 -7
  4. package/cjs/impl/errors.cjs +63 -0
  5. package/cjs/impl/logger.cjs +61 -0
  6. package/cjs/impl/patch.cjs +10 -5
  7. package/cjs/impl/query.cjs +11 -1
  8. package/cjs/impl/retry.cjs +54 -0
  9. package/cjs/impl/stream.cjs +48 -7
  10. package/cjs/index.cjs +26 -2
  11. package/cjs/schema/bind.cjs +40 -0
  12. package/cjs/schema/bulk.cjs +14 -0
  13. package/cjs/schema/config.cjs +20 -1
  14. package/cjs/schema/crud.cjs +9 -1
  15. package/cjs/schema/patch.cjs +6 -6
  16. package/cjs/schema/query.cjs +28 -19
  17. package/cjs/schema/stream.cjs +42 -0
  18. package/impl/bulk.d.mts.map +1 -1
  19. package/impl/bulk.mjs +58 -6
  20. package/impl/crud.d.mts +4 -9
  21. package/impl/crud.d.mts.map +1 -1
  22. package/impl/crud.mjs +67 -6
  23. package/impl/errors.d.mts +35 -0
  24. package/impl/errors.d.mts.map +1 -0
  25. package/impl/errors.mjs +53 -0
  26. package/impl/logger.d.mts +32 -0
  27. package/impl/logger.d.mts.map +1 -0
  28. package/impl/logger.mjs +59 -0
  29. package/impl/patch.d.mts +3 -1
  30. package/impl/patch.d.mts.map +1 -1
  31. package/impl/patch.mjs +36 -4
  32. package/impl/query.d.mts +66 -0
  33. package/impl/query.d.mts.map +1 -1
  34. package/impl/query.mjs +38 -2
  35. package/impl/retry.d.mts +2 -0
  36. package/impl/retry.d.mts.map +1 -0
  37. package/impl/retry.mjs +39 -0
  38. package/impl/stream.d.mts +2 -1
  39. package/impl/stream.d.mts.map +1 -1
  40. package/impl/stream.mjs +72 -17
  41. package/index.d.mts +8 -3
  42. package/index.d.mts.map +1 -1
  43. package/index.mjs +32 -3
  44. package/package.json +1 -1
  45. package/schema/bind.d.mts +470 -0
  46. package/schema/bind.d.mts.map +1 -0
  47. package/schema/bind.mjs +21 -0
  48. package/schema/bulk.d.mts +258 -0
  49. package/schema/bulk.d.mts.map +1 -1
  50. package/schema/bulk.mjs +17 -0
  51. package/schema/config.d.mts +67 -0
  52. package/schema/config.d.mts.map +1 -1
  53. package/schema/config.mjs +22 -1
  54. package/schema/crud.d.mts +177 -0
  55. package/schema/crud.d.mts.map +1 -1
  56. package/schema/crud.mjs +12 -0
  57. package/schema/patch.d.mts +88 -19
  58. package/schema/patch.d.mts.map +1 -1
  59. package/schema/patch.mjs +10 -6
  60. package/schema/query.d.mts +211 -0
  61. package/schema/query.d.mts.map +1 -1
  62. package/schema/query.mjs +30 -18
  63. package/schema/stream.d.mts +193 -0
  64. package/schema/stream.d.mts.map +1 -0
  65. package/schema/stream.mjs +23 -0
  66. package/build/build.mjs +0 -16
  67. package/build/build.rewrite-imports.mjs +0 -14
package/schema/query.mjs CHANGED
@@ -1,29 +1,41 @@
1
1
  import { z } from 'zod'
2
2
  import { CouchConfig } from './config.mjs'
3
3
 
4
+ export const ViewRow = z.object({
5
+ id: z.string().optional(),
6
+ key: z.any().nullable(),
7
+ value: z.any().nullable(),
8
+ doc: z.object({}).passthrough().optional()
9
+ })
4
10
  export const SimpleViewQueryResponse = z.object({
5
11
  error: z.string().optional().describe('if something is wrong'),
6
- rows: z.array(z.object({
7
- id: z.string().optional(),
8
- key: z.any().nullable(),
9
- value: z.any().nullable(),
10
- doc: z.object({}).passthrough().optional()
11
- }))
12
+ rows: z.array(ViewRow),
12
13
  }).passthrough()
14
+ /** @typedef { z.infer<typeof SimpleViewQueryResponse> } SimpleViewQueryResponseSchema */
15
+
16
+ export const SimpleViewOptions = z.object({
17
+ startkey: z.any().optional(),
18
+ endkey: z.any().optional(),
19
+ descending: z.boolean().optional().describe('sort results descending'),
20
+ skip: z.number().positive().optional().describe('skip this many rows'),
21
+ limit: z.number().positive().optional().describe('limit the results to this many rows'),
22
+ key: z.any().optional(),
23
+ include_docs: z.boolean().optional().describe('join the id to the doc and return it'),
24
+ reduce: z.boolean().optional().describe('reduce the results'),
25
+ group: z.boolean().optional().describe('group the results'),
26
+ group_level: z.number().positive().optional().describe('group the results at this level')
27
+ }).optional().describe('query options')
28
+ /** @typedef { z.infer<typeof SimpleViewOptions> } SimpleViewOptionsSchema */
13
29
 
14
30
  export const SimpleViewQuery = z.function().args(
15
31
  CouchConfig,
16
32
  z.string().describe('the view name'),
17
- z.object({
18
- startkey: z.any().optional(),
19
- endkey: z.any().optional(),
20
- descending: z.boolean().optional().describe('sort results descending'),
21
- skip: z.number().positive().optional().describe('skip this many rows'),
22
- limit: z.number().positive().optional().describe('limit the results to this many rows'),
23
- key: z.any().optional(),
24
- include_docs: z.boolean().optional().describe('join the id to the doc and return it'),
25
- reduce: z.boolean().optional().describe('reduce the results'),
26
- group: z.boolean().optional().describe('group the results'),
27
- group_level: z.number().positive().optional().describe('group the results at this level')
28
- }).optional().describe('query options')
33
+ SimpleViewOptions
34
+ ).returns(z.promise(SimpleViewQueryResponse))
35
+ /** @typedef { z.infer<typeof SimpleViewQuery> } SimpleViewQuerySchema */
36
+
37
+ export const SimpleViewQueryBound = z.function().args(
38
+ z.string().describe('the view name'),
39
+ SimpleViewOptions
29
40
  ).returns(z.promise(SimpleViewQueryResponse))
41
+ /** @typedef { z.infer<typeof SimpleViewQueryBound> } SimpleViewQueryBoundSchema */
@@ -0,0 +1,193 @@
1
+ export const OnRow: z.ZodFunction<z.ZodTuple<[z.ZodObject<{
2
+ id: z.ZodOptional<z.ZodString>;
3
+ key: z.ZodNullable<z.ZodAny>;
4
+ value: z.ZodNullable<z.ZodAny>;
5
+ doc: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ id?: string | undefined;
8
+ key?: any;
9
+ value?: any;
10
+ doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
11
+ }, {
12
+ id?: string | undefined;
13
+ key?: any;
14
+ value?: any;
15
+ doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
16
+ }>], z.ZodUnknown>, z.ZodUndefined>;
17
+ /** @typedef { z.infer<typeof OnRow> } OnRowSchema */
18
+ export const SimpleViewQueryStream: z.ZodFunction<z.ZodTuple<[z.ZodObject<{
19
+ throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
20
+ couch: z.ZodString;
21
+ bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
22
+ maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
23
+ initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
24
+ backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
25
+ logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
26
+ error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
27
+ warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
28
+ info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
29
+ debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
30
+ }, "strip", z.ZodTypeAny, {
31
+ error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
32
+ warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
33
+ info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
34
+ debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
35
+ }, {
36
+ error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
37
+ warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
38
+ info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
39
+ debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
40
+ }>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
41
+ _normalizedLogger: z.ZodOptional<z.ZodAny>;
42
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
43
+ throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
44
+ couch: z.ZodString;
45
+ bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
46
+ maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
47
+ initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
48
+ backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
49
+ logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
50
+ error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
51
+ warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
52
+ info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
53
+ debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
54
+ }, "strip", z.ZodTypeAny, {
55
+ error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
56
+ warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
57
+ info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
58
+ debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
59
+ }, {
60
+ error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
61
+ warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
62
+ info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
63
+ debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
64
+ }>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
65
+ _normalizedLogger: z.ZodOptional<z.ZodAny>;
66
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
67
+ throwOnGetNotFound: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
68
+ couch: z.ZodString;
69
+ bindWithRetry: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
70
+ maxRetries: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
71
+ initialDelay: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
72
+ backoffFactor: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
73
+ logger: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
74
+ error: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
75
+ warn: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
76
+ info: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
77
+ debug: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodVoid>>;
78
+ }, "strip", z.ZodTypeAny, {
79
+ error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
80
+ warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
81
+ info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
82
+ debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
83
+ }, {
84
+ error?: ((args_0: any, ...args: unknown[]) => void) | undefined;
85
+ warn?: ((args_0: any, ...args: unknown[]) => void) | undefined;
86
+ info?: ((args_0: any, ...args: unknown[]) => void) | undefined;
87
+ debug?: ((args_0: any, ...args: unknown[]) => void) | undefined;
88
+ }>, z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodAny], z.ZodUnknown>, z.ZodVoid>]>>;
89
+ _normalizedLogger: z.ZodOptional<z.ZodAny>;
90
+ }, z.ZodTypeAny, "passthrough">>, z.ZodString, z.ZodOptional<z.ZodObject<{
91
+ startkey: z.ZodOptional<z.ZodAny>;
92
+ endkey: z.ZodOptional<z.ZodAny>;
93
+ descending: z.ZodOptional<z.ZodBoolean>;
94
+ skip: z.ZodOptional<z.ZodNumber>;
95
+ limit: z.ZodOptional<z.ZodNumber>;
96
+ key: z.ZodOptional<z.ZodAny>;
97
+ include_docs: z.ZodOptional<z.ZodBoolean>;
98
+ reduce: z.ZodOptional<z.ZodBoolean>;
99
+ group: z.ZodOptional<z.ZodBoolean>;
100
+ group_level: z.ZodOptional<z.ZodNumber>;
101
+ }, "strip", z.ZodTypeAny, {
102
+ startkey?: any;
103
+ endkey?: any;
104
+ descending?: boolean | undefined;
105
+ skip?: number | undefined;
106
+ limit?: number | undefined;
107
+ key?: any;
108
+ include_docs?: boolean | undefined;
109
+ reduce?: boolean | undefined;
110
+ group?: boolean | undefined;
111
+ group_level?: number | undefined;
112
+ }, {
113
+ startkey?: any;
114
+ endkey?: any;
115
+ descending?: boolean | undefined;
116
+ skip?: number | undefined;
117
+ limit?: number | undefined;
118
+ key?: any;
119
+ include_docs?: boolean | undefined;
120
+ reduce?: boolean | undefined;
121
+ group?: boolean | undefined;
122
+ group_level?: number | undefined;
123
+ }>>, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
124
+ id: z.ZodOptional<z.ZodString>;
125
+ key: z.ZodNullable<z.ZodAny>;
126
+ value: z.ZodNullable<z.ZodAny>;
127
+ doc: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
128
+ }, "strip", z.ZodTypeAny, {
129
+ id?: string | undefined;
130
+ key?: any;
131
+ value?: any;
132
+ doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
133
+ }, {
134
+ id?: string | undefined;
135
+ key?: any;
136
+ value?: any;
137
+ doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
138
+ }>], z.ZodUnknown>, z.ZodUndefined>], z.ZodUnknown>, z.ZodPromise<z.ZodUndefined>>;
139
+ /** @typedef { z.infer<typeof SimpleViewQueryStream> } SimpleViewQueryStreamSchema */
140
+ export const SimpleViewQueryStreamBound: z.ZodFunction<z.ZodTuple<[z.ZodString, z.ZodOptional<z.ZodObject<{
141
+ startkey: z.ZodOptional<z.ZodAny>;
142
+ endkey: z.ZodOptional<z.ZodAny>;
143
+ descending: z.ZodOptional<z.ZodBoolean>;
144
+ skip: z.ZodOptional<z.ZodNumber>;
145
+ limit: z.ZodOptional<z.ZodNumber>;
146
+ key: z.ZodOptional<z.ZodAny>;
147
+ include_docs: z.ZodOptional<z.ZodBoolean>;
148
+ reduce: z.ZodOptional<z.ZodBoolean>;
149
+ group: z.ZodOptional<z.ZodBoolean>;
150
+ group_level: z.ZodOptional<z.ZodNumber>;
151
+ }, "strip", z.ZodTypeAny, {
152
+ startkey?: any;
153
+ endkey?: any;
154
+ descending?: boolean | undefined;
155
+ skip?: number | undefined;
156
+ limit?: number | undefined;
157
+ key?: any;
158
+ include_docs?: boolean | undefined;
159
+ reduce?: boolean | undefined;
160
+ group?: boolean | undefined;
161
+ group_level?: number | undefined;
162
+ }, {
163
+ startkey?: any;
164
+ endkey?: any;
165
+ descending?: boolean | undefined;
166
+ skip?: number | undefined;
167
+ limit?: number | undefined;
168
+ key?: any;
169
+ include_docs?: boolean | undefined;
170
+ reduce?: boolean | undefined;
171
+ group?: boolean | undefined;
172
+ group_level?: number | undefined;
173
+ }>>, z.ZodFunction<z.ZodTuple<[z.ZodObject<{
174
+ id: z.ZodOptional<z.ZodString>;
175
+ key: z.ZodNullable<z.ZodAny>;
176
+ value: z.ZodNullable<z.ZodAny>;
177
+ doc: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
178
+ }, "strip", z.ZodTypeAny, {
179
+ id?: string | undefined;
180
+ key?: any;
181
+ value?: any;
182
+ doc?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
183
+ }, {
184
+ id?: string | undefined;
185
+ key?: any;
186
+ value?: any;
187
+ doc?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
188
+ }>], z.ZodUnknown>, z.ZodUndefined>], z.ZodUnknown>, z.ZodPromise<z.ZodUndefined>>;
189
+ export type OnRowSchema = z.infer<typeof OnRow>;
190
+ export type SimpleViewQueryStreamSchema = z.infer<typeof SimpleViewQueryStream>;
191
+ export type SimpleViewQueryStreamBoundSchema = z.infer<typeof SimpleViewQueryStreamBound>;
192
+ import { z } from 'zod';
193
+ //# sourceMappingURL=stream.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stream.d.mts","sourceRoot":"","sources":["stream.mjs"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;oCAEwB;AACxB,qDAAqD;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mFAKmC;AACnC,qFAAqF;AAErF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mFAImC;0BAdpB,CAAC,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC;0CAQrB,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC;+CAOrC,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC;kBAtBvC,KAAK"}
@@ -0,0 +1,23 @@
1
+ import { z } from 'zod'
2
+ import { CouchConfig } from './config.mjs'
3
+ import { SimpleViewOptions, ViewRow } from './query.mjs'
4
+
5
+ export const OnRow = z.function().args(
6
+ ViewRow
7
+ )
8
+ /** @typedef { z.infer<typeof OnRow> } OnRowSchema */
9
+
10
+ export const SimpleViewQueryStream = z.function().args(
11
+ CouchConfig,
12
+ z.string().describe('the view name'),
13
+ SimpleViewOptions,
14
+ OnRow
15
+ ).returns(z.promise(z.undefined()))
16
+ /** @typedef { z.infer<typeof SimpleViewQueryStream> } SimpleViewQueryStreamSchema */
17
+
18
+ export const SimpleViewQueryStreamBound = z.function().args(
19
+ z.string().describe('the view name'),
20
+ SimpleViewOptions,
21
+ OnRow
22
+ ).returns(z.promise(z.undefined()))
23
+ /** @typedef { z.infer<typeof SimpleViewQueryStreamBound> } SimpleViewQueryStreamBoundSchema */
package/build/build.mjs DELETED
@@ -1,16 +0,0 @@
1
- import esbuild from 'esbuild'
2
- import { globSync } from 'glob'
3
- import { RewriteImportsPlugin } from './build.rewrite-imports.mjs'
4
-
5
- esbuild
6
- .build({
7
- entryPoints: globSync('./**/*.mjs', {
8
- ignore: ['./node_modules/**/*', './tests/**/*', './build/**/*']
9
- }),
10
- outdir: 'cjs',
11
- format: 'cjs',
12
- outExtension: { '.js': '.cjs' },
13
- bundle: false,
14
- plugins: [new RewriteImportsPlugin()]
15
- })
16
- .catch(() => process.exit(1))
@@ -1,14 +0,0 @@
1
- import fs from 'fs'
2
-
3
- export class RewriteImportsPlugin {
4
- name = 'rewrite-imports'
5
-
6
- setup (build) {
7
- build.onLoad({ filter: /\.mjs$/ }, async (args) => {
8
- const contents = fs
9
- .readFileSync(args.path, 'utf8')
10
- .replace(/(from\s+['"].*?)\.mjs(['"])/g, '$1.cjs$2')
11
- return { contents, loader: 'js' }
12
- })
13
- }
14
- }