hide-a-bed 4.0.3 → 4.1.2

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 (65) hide show
  1. package/README.md +304 -73
  2. package/cjs/impl/bulk.cjs +158 -10
  3. package/cjs/impl/crud.cjs +19 -12
  4. package/cjs/impl/errors.cjs +12 -0
  5. package/cjs/impl/patch.cjs +19 -0
  6. package/cjs/impl/queryBuilder.cjs +99 -0
  7. package/cjs/impl/stream.cjs +12 -1
  8. package/cjs/impl/trackedEmitter.cjs +54 -0
  9. package/cjs/impl/transactionErrors.cjs +70 -0
  10. package/cjs/index.cjs +21 -5
  11. package/cjs/schema/bind.cjs +4 -0
  12. package/cjs/schema/bulk.cjs +35 -11
  13. package/cjs/schema/config.cjs +1 -0
  14. package/cjs/schema/crud.cjs +23 -1
  15. package/cjs/schema/patch.cjs +17 -2
  16. package/cjs/schema/query.cjs +2 -1
  17. package/config.json +5 -0
  18. package/impl/bulk.d.mts +4 -0
  19. package/impl/bulk.d.mts.map +1 -1
  20. package/impl/bulk.mjs +200 -13
  21. package/impl/crud.d.mts +2 -0
  22. package/impl/crud.d.mts.map +1 -1
  23. package/impl/crud.mjs +25 -15
  24. package/impl/errors.d.mts +8 -0
  25. package/impl/errors.d.mts.map +1 -1
  26. package/impl/errors.mjs +12 -0
  27. package/impl/patch.d.mts +2 -0
  28. package/impl/patch.d.mts.map +1 -1
  29. package/impl/patch.mjs +22 -1
  30. package/impl/query.d.mts +18 -9
  31. package/impl/query.d.mts.map +1 -1
  32. package/impl/queryBuilder.d.mts +94 -0
  33. package/impl/queryBuilder.d.mts.map +1 -0
  34. package/impl/queryBuilder.mjs +99 -0
  35. package/impl/stream.d.mts.map +1 -1
  36. package/impl/stream.mjs +12 -1
  37. package/impl/trackedEmitter.d.mts +8 -0
  38. package/impl/trackedEmitter.d.mts.map +1 -0
  39. package/impl/trackedEmitter.mjs +33 -0
  40. package/impl/transactionErrors.d.mts +57 -0
  41. package/impl/transactionErrors.d.mts.map +1 -0
  42. package/impl/transactionErrors.mjs +47 -0
  43. package/index.d.mts +18 -3
  44. package/index.d.mts.map +1 -1
  45. package/index.mjs +42 -11
  46. package/package.json +9 -4
  47. package/schema/bind.d.mts +382 -45
  48. package/schema/bind.d.mts.map +1 -1
  49. package/schema/bind.mjs +6 -2
  50. package/schema/bulk.d.mts +559 -16
  51. package/schema/bulk.d.mts.map +1 -1
  52. package/schema/bulk.mjs +40 -10
  53. package/schema/config.d.mts.map +1 -1
  54. package/schema/config.mjs +1 -0
  55. package/schema/crud.d.mts +240 -15
  56. package/schema/crud.d.mts.map +1 -1
  57. package/schema/crud.mjs +27 -1
  58. package/schema/patch.d.mts +138 -2
  59. package/schema/patch.d.mts.map +1 -1
  60. package/schema/patch.mjs +22 -2
  61. package/schema/query.d.mts +62 -30
  62. package/schema/query.d.mts.map +1 -1
  63. package/schema/query.mjs +4 -1
  64. package/schema/stream.d.mts +18 -9
  65. package/schema/stream.d.mts.map +1 -1
@@ -0,0 +1,99 @@
1
+ // @ts-check
2
+
3
+ /**
4
+ * @typedef {Object} QueryOptions
5
+ * @property {any} [key] - Exact key to match
6
+ * @property {any} [startkey] - Start of key range
7
+ * @property {any} [endkey] - End of key range
8
+ * @property {boolean} [reduce] - Whether to use reduce function
9
+ * @property {boolean} [group] - Whether to group results
10
+ * @property {number} [group_level] - Level at which to group
11
+ * @property {string} [stale] - Stale parameter value
12
+ * @property {number} [limit] - Max number of results
13
+ */
14
+
15
+ export class QueryBuilder {
16
+ /** @type {QueryOptions} */
17
+ #options = {}
18
+
19
+ /**
20
+ * @param {any} key
21
+ * @returns {QueryBuilder}
22
+ */
23
+ key (key) {
24
+ this.#options.key = key
25
+ return this
26
+ }
27
+
28
+ /**
29
+ * @param {any} startkey
30
+ * @returns {QueryBuilder}
31
+ */
32
+ startKey (startkey) {
33
+ this.#options.startkey = startkey
34
+ return this
35
+ }
36
+
37
+ /**
38
+ * @param {any} endkey
39
+ * @returns {QueryBuilder}
40
+ */
41
+ endKey (endkey) {
42
+ this.#options.endkey = endkey
43
+ return this
44
+ }
45
+
46
+ /**
47
+ * @param {boolean} reduce
48
+ * @returns {QueryBuilder}
49
+ */
50
+ reduce (reduce = true) {
51
+ this.#options.reduce = reduce
52
+ return this
53
+ }
54
+
55
+ /**
56
+ * @param {boolean} group
57
+ * @returns {QueryBuilder}
58
+ */
59
+ group (group = true) {
60
+ this.#options.group = group
61
+ return this
62
+ }
63
+
64
+ /**
65
+ * @param {number} level
66
+ * @returns {QueryBuilder}
67
+ */
68
+ groupLevel (level) {
69
+ this.#options.group_level = level
70
+ return this
71
+ }
72
+
73
+ /**
74
+ * @param {string} stale
75
+ * @returns {QueryBuilder}
76
+ */
77
+ stale (stale) {
78
+ this.#options.stale = stale
79
+ return this
80
+ }
81
+
82
+ /**
83
+ * @param {number} limit
84
+ * @returns {QueryBuilder}
85
+ */
86
+ limit (limit) {
87
+ this.#options.limit = limit
88
+ return this
89
+ }
90
+
91
+ /**
92
+ * @returns {QueryOptions}
93
+ */
94
+ build () {
95
+ return { ...this.#options }
96
+ }
97
+ }
98
+
99
+ export const createQuery = () => new QueryBuilder()
@@ -1 +1 @@
1
- {"version":3,"file":"stream.d.mts","sourceRoot":"","sources":["stream.mjs"],"names":[],"mappings":"AAQA,uFAAuF;AACvF,0BADY,OAAO,sBAAsB,EAAE,2BAA2B,CA2DpE"}
1
+ {"version":3,"file":"stream.d.mts","sourceRoot":"","sources":["stream.mjs"],"names":[],"mappings":"AASA,uFAAuF;AACvF,0BADY,OAAO,sBAAsB,EAAE,2BAA2B,CAqEpE"}
package/impl/stream.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // @ts-check
2
2
  import needle from 'needle'
3
+ import { CouchConfig } from '../schema/config.mjs'
3
4
  import { queryString } from './query.mjs'
4
5
  import { RetryableError } from './errors.mjs'
5
6
  import { createLogger } from './logger.mjs'
@@ -7,11 +8,16 @@ import { createLogger } from './logger.mjs'
7
8
  import JSONStream from 'JSONStream'
8
9
 
9
10
  /** @type { import('../schema/stream.mjs').SimpleViewQueryStreamSchema } queryStream */
10
- export const queryStream = (config, view, options, onRow) => new Promise((resolve, reject) => {
11
+ export const queryStream = (rawConfig, view, options, onRow) => new Promise((resolve, reject) => {
12
+ const config = CouchConfig.parse(rawConfig)
13
+ const logger = createLogger(config)
14
+ logger.info(`Starting view query stream: ${view}`)
15
+ logger.debug('Query options:', options)
11
16
 
12
17
  if (!options) options = {}
13
18
 
14
19
  const qs = queryString(options, ['key', 'startkey', 'endkey', 'reduce', 'group', 'group_level', 'stale', 'limit'])
20
+ logger.debug('Generated query string:', qs)
15
21
  const url = `${config.couch}/${view}?${qs.toString()}`
16
22
  const opts = {
17
23
  json: true,
@@ -30,6 +36,7 @@ export const queryStream = (config, view, options, onRow) => new Promise((resolv
30
36
  })
31
37
 
32
38
  streamer.on('error', /** @param {Error} err */ err => {
39
+ logger.error('Stream parsing error:', err)
33
40
  reject(new Error(`Stream parsing error: ${err.message}`))
34
41
  })
35
42
 
@@ -42,19 +49,23 @@ export const queryStream = (config, view, options, onRow) => new Promise((resolv
42
49
  })
43
50
 
44
51
  streamer.on('end', () => {
52
+ logger.info(`Stream completed, processed ${rowCount} rows`)
45
53
  resolve(undefined) // all work should be done in the stream
46
54
  })
47
55
 
48
56
  const req = needle.get(url, opts)
49
57
 
50
58
  req.on('response', response => {
59
+ logger.debug(`Received response with status code: ${response.statusCode}`)
51
60
  if (RetryableError.isRetryableStatusCode(response.statusCode)) {
61
+ logger.warn(`Retryable status code received: ${response.statusCode}`)
52
62
  reject(new RetryableError('retryable error during stream query', response.statusCode))
53
63
  // req.abort()
54
64
  }
55
65
  })
56
66
 
57
67
  req.on('error', err => {
68
+ logger.error('Network error during stream query:', err)
58
69
  try {
59
70
  RetryableError.handleNetworkError(err)
60
71
  } catch (retryErr) {
@@ -0,0 +1,8 @@
1
+ export class TrackedEmitter extends EventEmitter<[never]> {
2
+ constructor(options: any);
3
+ delay: any;
4
+ emit(event: any, ...args: any[]): Promise<any>;
5
+ }
6
+ export function setupEmitter(config: any): any;
7
+ import { EventEmitter } from 'events';
8
+ //# sourceMappingURL=trackedEmitter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackedEmitter.d.mts","sourceRoot":"","sources":["trackedEmitter.mjs"],"names":[],"mappings":"AAEA;IAEE,0BAGC;IADoB,WAA0B;IAG/C,+CAiBC;CACF;AAEM,+CAGN;6BAhC4B,QAAQ"}
@@ -0,0 +1,33 @@
1
+ import { EventEmitter } from 'events'
2
+
3
+ export class TrackedEmitter extends EventEmitter {
4
+ // create a constructor with some options
5
+ constructor (options) {
6
+ super(options)
7
+ if (options.delay) this.delay = options.delay
8
+ }
9
+
10
+ emit (event, ...args) {
11
+ const listeners = this.listeners(event)
12
+ let completed = 0
13
+
14
+ return new Promise((resolve) => {
15
+ if (!listeners || listeners.length === 0) {
16
+ return resolve() // no listeners? no delay
17
+ }
18
+ listeners.forEach((listener) => {
19
+ listener(...args)
20
+ completed++
21
+ if (completed === listeners.length) {
22
+ if (!this.delay) resolve()
23
+ setTimeout(resolve, this.delay)
24
+ }
25
+ })
26
+ })
27
+ }
28
+ }
29
+
30
+ export const setupEmitter = (config) => {
31
+ if (!config._emitter) return ({ emit: async () => {} })
32
+ return config._emitter
33
+ }
@@ -0,0 +1,57 @@
1
+ export class TransactionSetupError extends Error {
2
+ /**
3
+ * @param {string} message
4
+ * @param {Record<string, any>} details
5
+ */
6
+ constructor(message: string, details?: Record<string, any>);
7
+ details: Record<string, any>;
8
+ }
9
+ export class TransactionVersionConflictError extends Error {
10
+ /**
11
+ * @param {string[]} conflictingIds
12
+ */
13
+ constructor(conflictingIds: string[]);
14
+ conflictingIds: string[];
15
+ }
16
+ export class TransactionBulkOperationError extends Error {
17
+ /**
18
+ * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} failedDocs
19
+ */
20
+ constructor(failedDocs: Array<{
21
+ ok?: boolean | null;
22
+ id?: string | null;
23
+ rev?: string | null;
24
+ error?: string | null;
25
+ reason?: string | null;
26
+ }>);
27
+ failedDocs: {
28
+ ok?: boolean | null;
29
+ id?: string | null;
30
+ rev?: string | null;
31
+ error?: string | null;
32
+ reason?: string | null;
33
+ }[];
34
+ }
35
+ export class TransactionRollbackError extends Error {
36
+ /**
37
+ * @param {string} message
38
+ * @param {Error} originalError
39
+ * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} rollbackResults
40
+ */
41
+ constructor(message: string, originalError: Error, rollbackResults: Array<{
42
+ ok?: boolean | null;
43
+ id?: string | null;
44
+ rev?: string | null;
45
+ error?: string | null;
46
+ reason?: string | null;
47
+ }>);
48
+ originalError: Error;
49
+ rollbackResults: {
50
+ ok?: boolean | null;
51
+ id?: string | null;
52
+ rev?: string | null;
53
+ error?: string | null;
54
+ reason?: string | null;
55
+ }[];
56
+ }
57
+ //# sourceMappingURL=transactionErrors.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionErrors.d.mts","sourceRoot":"","sources":["transactionErrors.mjs"],"names":[],"mappings":"AAAA;IACE;;;OAGG;IACH,qBAHW,MAAM,YACN,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAM7B;IADC,6BAAsB;CAEzB;AAED;IACE;;OAEG;IACH,4BAFW,MAAM,EAAE,EAMlB;IADC,yBAAoC;CAEvC;AAED;IACE;;OAEG;IACH,wBAFW,KAAK,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,GAAC,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAC,IAAI,CAAA;KAAC,CAAC,EAMpH;IADC;aALqB,OAAO,GAAC,IAAI;aAAO,MAAM,GAAC,IAAI;cAAQ,MAAM,GAAC,IAAI;gBAAU,MAAM,GAAC,IAAI;iBAAW,MAAM,GAAC,IAAI;QAKrF;CAE/B;AAED;IACE;;;;OAIG;IACH,qBAJW,MAAM,iBACN,KAAK,mBACL,KAAK,CAAC;QAAC,EAAE,CAAC,EAAE,OAAO,GAAC,IAAI,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAC,IAAI,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAC,IAAI,CAAA;KAAC,CAAC,EAOpH;IAFC,qBAAkC;IAClC;aANqB,OAAO,GAAC,IAAI;aAAO,MAAM,GAAC,IAAI;cAAQ,MAAM,GAAC,IAAI;gBAAU,MAAM,GAAC,IAAI;iBAAW,MAAM,GAAC,IAAI;QAM3E;CAEzC"}
@@ -0,0 +1,47 @@
1
+ export class TransactionSetupError extends Error {
2
+ /**
3
+ * @param {string} message
4
+ * @param {Record<string, any>} details
5
+ */
6
+ constructor (message, details = {}) {
7
+ super(message)
8
+ this.name = 'TransactionSetupError'
9
+ this.details = details
10
+ }
11
+ }
12
+
13
+ export class TransactionVersionConflictError extends Error {
14
+ /**
15
+ * @param {string[]} conflictingIds
16
+ */
17
+ constructor (conflictingIds) {
18
+ super(`Revision mismatch for documents: ${conflictingIds.join(', ')}`)
19
+ this.name = 'TransactionVersionConflictError'
20
+ this.conflictingIds = conflictingIds
21
+ }
22
+ }
23
+
24
+ export class TransactionBulkOperationError extends Error {
25
+ /**
26
+ * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} failedDocs
27
+ */
28
+ constructor (failedDocs) {
29
+ super(`Failed to save documents: ${failedDocs.map(d => d.id).join(', ')}`)
30
+ this.name = 'TransactionBulkOperationError'
31
+ this.failedDocs = failedDocs
32
+ }
33
+ }
34
+
35
+ export class TransactionRollbackError extends Error {
36
+ /**
37
+ * @param {string} message
38
+ * @param {Error} originalError
39
+ * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} rollbackResults
40
+ */
41
+ constructor (message, originalError, rollbackResults) {
42
+ super(message)
43
+ this.name = 'TransactionRollbackError'
44
+ this.originalError = originalError
45
+ this.rollbackResults = rollbackResults
46
+ }
47
+ }
package/index.d.mts CHANGED
@@ -1,9 +1,8 @@
1
1
  import { get } from './impl/crud.mjs';
2
+ import { getAtRev } from './impl/crud.mjs';
2
3
  import { put } from './impl/crud.mjs';
3
- import { patch } from './impl/patch.mjs';
4
4
  import { bulkGet } from './impl/bulk.mjs';
5
5
  import { bulkSave } from './impl/bulk.mjs';
6
- import { bulkRemove } from './impl/bulk.mjs';
7
6
  import { query } from './impl/query.mjs';
8
7
  import { queryStream } from './impl/stream.mjs';
9
8
  export namespace schema {
@@ -15,15 +14,26 @@ export namespace schema {
15
14
  export { BulkSave };
16
15
  export { BulkGet };
17
16
  export { BulkRemove };
17
+ export { BulkGetDictionary };
18
+ export { BulkSaveTransaction };
18
19
  export { CouchGet };
19
20
  export { CouchPut };
20
21
  export { CouchDoc };
21
22
  export { CouchDocResponse };
22
23
  export { Patch };
24
+ export { PatchDangerously };
25
+ export { CouchGetAtRev };
26
+ export { Bind };
23
27
  }
28
+ import { patch } from './impl/patch.mjs';
29
+ import { patchDangerously } from './impl/patch.mjs';
30
+ import { bulkRemove } from './impl/bulk.mjs';
31
+ import { bulkGetDictionary } from './impl/bulk.mjs';
32
+ import { bulkSaveTransaction } from './impl/bulk.mjs';
24
33
  /** @type { import('./schema/bind.mjs').BindSchema } */
25
34
  export const bindConfig: import("./schema/bind.mjs").BindSchema;
26
35
  import { withRetry } from './impl/retry.mjs';
36
+ import { createQuery } from './impl/queryBuilder.mjs';
27
37
  import { CouchConfig } from './schema/config.mjs';
28
38
  import { SimpleViewQuery } from './schema/query.mjs';
29
39
  import { SimpleViewQueryResponse } from './schema/query.mjs';
@@ -32,10 +42,15 @@ import { OnRow } from './schema/stream.mjs';
32
42
  import { BulkSave } from './schema/bulk.mjs';
33
43
  import { BulkGet } from './schema/bulk.mjs';
34
44
  import { BulkRemove } from './schema/bulk.mjs';
45
+ import { BulkGetDictionary } from './schema/bulk.mjs';
46
+ import { BulkSaveTransaction } from './schema/bulk.mjs';
35
47
  import { CouchGet } from './schema/crud.mjs';
36
48
  import { CouchPut } from './schema/crud.mjs';
37
49
  import { CouchDoc } from './schema/crud.mjs';
38
50
  import { CouchDocResponse } from './schema/crud.mjs';
39
51
  import { Patch } from './schema/patch.mjs';
40
- export { get, put, patch, bulkGet, bulkSave, bulkRemove, query, queryStream, withRetry };
52
+ import { PatchDangerously } from './schema/patch.mjs';
53
+ import { CouchGetAtRev } from './schema/crud.mjs';
54
+ import { Bind } from './schema/bind.mjs';
55
+ export { get, getAtRev, put, bulkGet, bulkSave, query, queryStream, patch, patchDangerously, bulkRemove, bulkGetDictionary, bulkSaveTransaction, withRetry, createQuery };
41
56
  //# sourceMappingURL=index.d.mts.map
package/index.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mjs"],"names":[],"mappings":"oBAEyB,iBAAiB;oBAAjB,iBAAiB;sBACpB,kBAAkB;wBAFM,iBAAiB;yBAAjB,iBAAiB;2BAAjB,iBAAiB;sBAGzC,kBAAkB;4BACZ,mBAAmB;;;;;;;;;;;;;;;;AA0B/C,uDAAuD;AACvD,yBADY,OAAO,mBAAmB,EAAE,UAAU,CAsBhD;0BA/CwB,kBAAkB;4BAEhB,qBAAqB;gCACQ,oBAAoB;wCAApB,oBAAoB;sCAChC,qBAAqB;sBAArB,qBAAqB;yBAHpB,mBAAmB;wBAAnB,mBAAmB;2BAAnB,mBAAmB;yBAKF,mBAAmB;yBAAnB,mBAAmB;yBAAnB,mBAAmB;iCAAnB,mBAAmB;sBAD5D,oBAAoB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mjs"],"names":[],"mappings":"oBAEmC,iBAAiB;yBAAjB,iBAAiB;oBAAjB,iBAAiB;wBADkC,iBAAiB;yBAAjB,iBAAiB;sBAGjF,kBAAkB;4BACZ,mBAAmB;;;;;;;;;;;;;;;;;;;;;sBAFP,kBAAkB;iCAAlB,kBAAkB;2BAF4B,iBAAiB;kCAAjB,iBAAiB;oCAAjB,iBAAiB;AAoCvG,uDAAuD;AACvD,yBADY,OAAO,mBAAmB,EAAE,UAAU,CA2BhD;0BAzDwB,kBAAkB;4BADhB,yBAAyB;4BAGzB,qBAAqB;gCACQ,oBAAoB;wCAApB,oBAAoB;sCAChC,qBAAqB;sBAArB,qBAAqB;yBAHoB,mBAAmB;wBAAnB,mBAAmB;2BAAnB,mBAAmB;kCAAnB,mBAAmB;oCAAnB,mBAAmB;yBAK3B,mBAAmB;yBAAnB,mBAAmB;yBAAnB,mBAAmB;iCAAnB,mBAAmB;sBADzD,oBAAoB;iCAApB,oBAAoB;8BACkB,mBAAmB;qBAC5E,mBAAmB"}
package/index.mjs CHANGED
@@ -1,16 +1,17 @@
1
1
  // @ts-check */
2
- import { bulkGet, bulkSave, bulkRemove } from './impl/bulk.mjs'
3
- import { get, put } from './impl/crud.mjs'
4
- import { patch } from './impl/patch.mjs'
2
+ import { bulkGet, bulkSave, bulkRemove, bulkGetDictionary, bulkSaveTransaction } from './impl/bulk.mjs'
3
+ import { get, put, getAtRev } from './impl/crud.mjs'
4
+ import { patch, patchDangerously } from './impl/patch.mjs'
5
5
  import { query } from './impl/query.mjs'
6
6
  import { queryStream } from './impl/stream.mjs'
7
+ import { createQuery } from './impl/queryBuilder.mjs'
7
8
  import { withRetry } from './impl/retry.mjs'
8
- import { BulkSave, BulkGet, BulkRemove } from './schema/bulk.mjs'
9
+ import { BulkSave, BulkGet, BulkRemove, BulkGetDictionary, BulkSaveTransaction } from './schema/bulk.mjs'
9
10
  import { CouchConfig } from './schema/config.mjs'
10
11
  import { SimpleViewQuery, SimpleViewQueryResponse } from './schema/query.mjs'
11
12
  import { SimpleViewQueryStream, OnRow } from './schema/stream.mjs'
12
- import { Patch } from './schema/patch.mjs'
13
- import { CouchDoc, CouchDocResponse, CouchPut, CouchGet } from './schema/crud.mjs'
13
+ import { Patch, PatchDangerously } from './schema/patch.mjs'
14
+ import { CouchDoc, CouchDocResponse, CouchPut, CouchGet, CouchGetAtRev } from './schema/crud.mjs'
14
15
  import { Bind } from './schema/bind.mjs'
15
16
 
16
17
  const schema = {
@@ -22,11 +23,16 @@ const schema = {
22
23
  BulkSave,
23
24
  BulkGet,
24
25
  BulkRemove,
26
+ BulkGetDictionary,
27
+ BulkSaveTransaction,
25
28
  CouchGet,
26
29
  CouchPut,
27
30
  CouchDoc,
28
31
  CouchDocResponse,
29
- Patch
32
+ Patch,
33
+ PatchDangerously,
34
+ CouchGetAtRev,
35
+ Bind
30
36
  }
31
37
 
32
38
  /** @type { import('./schema/bind.mjs').BindSchema } */
@@ -43,14 +49,39 @@ const bindConfig = Bind.implement((
43
49
 
44
50
  return {
45
51
  get: config.bindWithRetry ? withRetry(get.bind(null, config), retryOptions) : get.bind(null, config),
52
+ getAtRev: config.bindWithRetry ? withRetry(getAtRev.bind(null, config), retryOptions) : getAtRev.bind(null, config),
46
53
  put: config.bindWithRetry ? withRetry(put.bind(null, config), retryOptions) : put.bind(null, config),
47
- patch: patch.bind(null, config), // patch not included in retry
48
54
  bulkGet: config.bindWithRetry ? withRetry(bulkGet.bind(null, config), retryOptions) : bulkGet.bind(null, config),
49
55
  bulkSave: config.bindWithRetry ? withRetry(bulkSave.bind(null, config), retryOptions) : bulkSave.bind(null, config),
50
- bulkRemove: config.bindWithRetry ? withRetry(bulkRemove.bind(null, config), retryOptions) : bulkRemove.bind(null, config),
51
56
  query: config.bindWithRetry ? withRetry(query.bind(null, config), retryOptions) : query.bind(null, config),
52
- queryStream: config.bindWithRetry ? withRetry(queryStream.bind(null, config), retryOptions) : queryStream.bind(null, config)
57
+ queryStream: config.bindWithRetry ? withRetry(queryStream.bind(null, config), retryOptions) : queryStream.bind(null, config),
58
+ // Sugar Methods
59
+ patch: config.bindWithRetry ? withRetry(patch.bind(null, config), retryOptions) : patch.bind(null, config),
60
+ patchDangerously: patchDangerously.bind(null, config), // patchDangerously not included in retry
61
+ bulkRemove: config.bindWithRetry ? withRetry(bulkRemove.bind(null, config), retryOptions) : bulkRemove.bind(null, config),
62
+ bulkGetDictionary: config.bindWithRetry ? withRetry(bulkGetDictionary.bind(null, config), retryOptions) : bulkGetDictionary.bind(null, config),
63
+ bulkSaveTransaction: bulkSaveTransaction.bind(null, config)
53
64
  }
54
65
  })
55
66
 
56
- export { get, put, patch, bulkGet, bulkSave, bulkRemove, query, queryStream, schema, bindConfig, withRetry }
67
+ export {
68
+ get,
69
+ getAtRev,
70
+ put,
71
+ bulkGet,
72
+ bulkSave,
73
+ query,
74
+ queryStream,
75
+ schema,
76
+
77
+ // sugar methods
78
+ patch,
79
+ patchDangerously,
80
+ bulkRemove,
81
+ bulkGetDictionary,
82
+ bulkSaveTransaction,
83
+
84
+ bindConfig,
85
+ withRetry,
86
+ createQuery
87
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hide-a-bed",
3
- "version": "4.0.3",
3
+ "version": "4.1.2",
4
4
  "description": "An abstraction over couchdb calls that includes easy mock/stubs with pouchdb",
5
5
  "module": "index.mjs",
6
6
  "main": "cjs/index.cjs",
@@ -11,12 +11,13 @@
11
11
  "default": "./cjs/index.cjs"
12
12
  },
13
13
  "scripts": {
14
- "clean": "(find . -name \"*.mts\" -type f -delete || true) && (find . -name \"*.map\" -type f -delete || true)",
14
+ "clean": "(find . -name \"*.mts\" -type f -delete || true) && (find . -name \"*.map\" -type f -delete || true) && (find . -name \"log.txt\" -type f -delete || true)",
15
15
  "build": "npm run clean && tsc && npm run build:cjs",
16
16
  "build:cjs": "rm -rf cjs && node build/build.mjs",
17
- "test": "standard && tape tests/*.mjs",
17
+ "test": "node test/test.mjs",
18
18
  "lint:fix": "standard --fix",
19
- "prepublish": "npm run build"
19
+ "prepublish": "npm run build",
20
+ "full": "npm run lint:fix && npm run build && npm run clean"
20
21
  },
21
22
  "repository": {
22
23
  "type": "git",
@@ -43,7 +44,11 @@
43
44
  "@types/needle": "^3.3.0",
44
45
  "esbuild": "^0.24.2",
45
46
  "glob": "^11.0.0",
47
+ "install": "^0.13.0",
48
+ "npm": "^11.1.0",
49
+ "pouchdb-server": "^4.2.0",
46
50
  "standard": "17.1.0",
51
+ "tap": "^21.0.2",
47
52
  "tape": "5.8.1",
48
53
  "typescript": "5.6.2"
49
54
  },