hide-a-bed 4.2.0 → 5.0.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 (75) hide show
  1. package/README.md +175 -14
  2. package/impl/changes.mjs +53 -0
  3. package/impl/errors.mjs +1 -1
  4. package/impl/query.mjs +14 -6
  5. package/impl/stream.mjs +2 -2
  6. package/impl/sugar/lock.mjs +70 -0
  7. package/impl/sugar/watch.mjs +154 -0
  8. package/index.mjs +23 -3
  9. package/integration/changes.mjs +60 -0
  10. package/integration/disconnect-watch.mjs +36 -0
  11. package/integration/watch.mjs +40 -0
  12. package/log.txt +84 -0
  13. package/package.json +3 -2
  14. package/schema/bind.mjs +8 -1
  15. package/schema/changes.mjs +59 -0
  16. package/schema/sugar/lock.mjs +50 -0
  17. package/schema/sugar/watch.mjs +29 -0
  18. package/types/changes-stream.d.ts +11 -0
  19. package/cjs/impl/bulk.cjs +0 -267
  20. package/cjs/impl/crud.cjs +0 -121
  21. package/cjs/impl/errors.cjs +0 -75
  22. package/cjs/impl/logger.cjs +0 -70
  23. package/cjs/impl/patch.cjs +0 -95
  24. package/cjs/impl/query.cjs +0 -110
  25. package/cjs/impl/queryBuilder.cjs +0 -99
  26. package/cjs/impl/retry.cjs +0 -54
  27. package/cjs/impl/stream.cjs +0 -121
  28. package/cjs/impl/trackedEmitter.cjs +0 -54
  29. package/cjs/impl/transactionErrors.cjs +0 -70
  30. package/cjs/index.cjs +0 -95
  31. package/cjs/schema/bind.cjs +0 -44
  32. package/cjs/schema/bulk.cjs +0 -88
  33. package/cjs/schema/config.cjs +0 -48
  34. package/cjs/schema/crud.cjs +0 -77
  35. package/cjs/schema/patch.cjs +0 -53
  36. package/cjs/schema/query.cjs +0 -62
  37. package/cjs/schema/stream.cjs +0 -42
  38. package/impl/bulk.d.mts +0 -11
  39. package/impl/bulk.d.mts.map +0 -1
  40. package/impl/crud.d.mts +0 -7
  41. package/impl/crud.d.mts.map +0 -1
  42. package/impl/errors.d.mts +0 -43
  43. package/impl/errors.d.mts.map +0 -1
  44. package/impl/logger.d.mts +0 -32
  45. package/impl/logger.d.mts.map +0 -1
  46. package/impl/patch.d.mts +0 -6
  47. package/impl/patch.d.mts.map +0 -1
  48. package/impl/query.d.mts +0 -195
  49. package/impl/query.d.mts.map +0 -1
  50. package/impl/queryBuilder.d.mts +0 -94
  51. package/impl/queryBuilder.d.mts.map +0 -1
  52. package/impl/retry.d.mts +0 -2
  53. package/impl/retry.d.mts.map +0 -1
  54. package/impl/stream.d.mts +0 -3
  55. package/impl/stream.d.mts.map +0 -1
  56. package/impl/trackedEmitter.d.mts +0 -8
  57. package/impl/trackedEmitter.d.mts.map +0 -1
  58. package/impl/transactionErrors.d.mts +0 -57
  59. package/impl/transactionErrors.d.mts.map +0 -1
  60. package/index.d.mts +0 -56
  61. package/index.d.mts.map +0 -1
  62. package/schema/bind.d.mts +0 -820
  63. package/schema/bind.d.mts.map +0 -1
  64. package/schema/bulk.d.mts +0 -910
  65. package/schema/bulk.d.mts.map +0 -1
  66. package/schema/config.d.mts +0 -79
  67. package/schema/config.d.mts.map +0 -1
  68. package/schema/crud.d.mts +0 -491
  69. package/schema/crud.d.mts.map +0 -1
  70. package/schema/patch.d.mts +0 -255
  71. package/schema/patch.d.mts.map +0 -1
  72. package/schema/query.d.mts +0 -406
  73. package/schema/query.d.mts.map +0 -1
  74. package/schema/stream.d.mts +0 -211
  75. package/schema/stream.d.mts.map +0 -1
@@ -1,121 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var stream_exports = {};
30
- __export(stream_exports, {
31
- queryStream: () => queryStream
32
- });
33
- module.exports = __toCommonJS(stream_exports);
34
- var import_needle = __toESM(require("needle"), 1);
35
- var import_config = require("../schema/config.cjs");
36
- var import_query = require("./query.cjs");
37
- var import_errors = require("./errors.cjs");
38
- var import_logger = require("./logger.cjs");
39
- var import_JSONStream = __toESM(require("JSONStream"), 1);
40
- const queryStream = (rawConfig, view, options, onRow) => new Promise((resolve, reject) => {
41
- const config = import_config.CouchConfig.parse(rawConfig);
42
- const logger = (0, import_logger.createLogger)(config);
43
- logger.info(`Starting view query stream: ${view}`);
44
- logger.debug("Query options:", options);
45
- if (!options) options = {};
46
- let method = "GET";
47
- let payload = null;
48
- let qs = (0, import_query.queryString)(options, ["key", "startkey", "endkey", "reduce", "group", "group_level", "stale", "limit"]);
49
- logger.debug("Generated query string:", qs);
50
- if (typeof options.keys !== "undefined") {
51
- const MAX_URL_LENGTH = 2e3;
52
- const keysAsString = `keys=${encodeURIComponent(JSON.stringify(options.keys))}`;
53
- if (keysAsString.length + qs.length + 1 <= MAX_URL_LENGTH) {
54
- qs += (qs[0] === "?" ? "&" : "?") + keysAsString;
55
- } else {
56
- method = "POST";
57
- payload = { keys: options.keys };
58
- }
59
- }
60
- const url = `${config.couch}/${view}?${qs.toString()}`;
61
- const opts = {
62
- json: true,
63
- headers: {
64
- "Content-Type": "application/json"
65
- },
66
- parse_response: false
67
- // Keep as stream
68
- };
69
- const streamer = import_JSONStream.default.parse("rows.*");
70
- let rowCount = 0;
71
- streamer.on(
72
- "data",
73
- /** @param {object} row */
74
- (row) => {
75
- rowCount++;
76
- onRow(row);
77
- }
78
- );
79
- streamer.on(
80
- "error",
81
- /** @param {Error} err */
82
- (err) => {
83
- logger.error("Stream parsing error:", err);
84
- reject(new Error(`Stream parsing error: ${err.message}`));
85
- }
86
- );
87
- streamer.on(
88
- "done",
89
- /** @param {Error|null} err */
90
- (err) => {
91
- try {
92
- import_errors.RetryableError.handleNetworkError(err);
93
- } catch (e) {
94
- reject(e);
95
- }
96
- }
97
- );
98
- streamer.on("end", () => {
99
- logger.info(`Stream completed, processed ${rowCount} rows`);
100
- resolve(void 0);
101
- });
102
- const req = method === "GET" ? import_needle.default.get(url, opts) : import_needle.default.post(url, payload, opts);
103
- req.on("response", (response) => {
104
- logger.debug(`Received response with status code: ${response.statusCode}`);
105
- if (import_errors.RetryableError.isRetryableStatusCode(response.statusCode)) {
106
- logger.warn(`Retryable status code received: ${response.statusCode}`);
107
- reject(new import_errors.RetryableError("retryable error during stream query", response.statusCode));
108
- }
109
- });
110
- req.on("error", (err) => {
111
- logger.error("Network error during stream query:", err);
112
- try {
113
- import_errors.RetryableError.handleNetworkError(err);
114
- } catch (retryErr) {
115
- reject(retryErr);
116
- return;
117
- }
118
- reject(err);
119
- });
120
- req.pipe(streamer);
121
- });
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var trackedEmitter_exports = {};
20
- __export(trackedEmitter_exports, {
21
- TrackedEmitter: () => TrackedEmitter,
22
- setupEmitter: () => setupEmitter
23
- });
24
- module.exports = __toCommonJS(trackedEmitter_exports);
25
- var import_events = require("events");
26
- class TrackedEmitter extends import_events.EventEmitter {
27
- // create a constructor with some options
28
- constructor(options) {
29
- super(options);
30
- if (options.delay) this.delay = options.delay;
31
- }
32
- emit(event, ...args) {
33
- const listeners = this.listeners(event);
34
- let completed = 0;
35
- return new Promise((resolve) => {
36
- if (!listeners || listeners.length === 0) {
37
- return resolve();
38
- }
39
- listeners.forEach((listener) => {
40
- listener(...args);
41
- completed++;
42
- if (completed === listeners.length) {
43
- if (!this.delay) resolve();
44
- setTimeout(resolve, this.delay);
45
- }
46
- });
47
- });
48
- }
49
- }
50
- const setupEmitter = (config) => {
51
- if (!config._emitter) return { emit: async () => {
52
- } };
53
- return config._emitter;
54
- };
@@ -1,70 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var transactionErrors_exports = {};
20
- __export(transactionErrors_exports, {
21
- TransactionBulkOperationError: () => TransactionBulkOperationError,
22
- TransactionRollbackError: () => TransactionRollbackError,
23
- TransactionSetupError: () => TransactionSetupError,
24
- TransactionVersionConflictError: () => TransactionVersionConflictError
25
- });
26
- module.exports = __toCommonJS(transactionErrors_exports);
27
- class TransactionSetupError extends Error {
28
- /**
29
- * @param {string} message
30
- * @param {Record<string, any>} details
31
- */
32
- constructor(message, details = {}) {
33
- super(message);
34
- this.name = "TransactionSetupError";
35
- this.details = details;
36
- }
37
- }
38
- class TransactionVersionConflictError extends Error {
39
- /**
40
- * @param {string[]} conflictingIds
41
- */
42
- constructor(conflictingIds) {
43
- super(`Revision mismatch for documents: ${conflictingIds.join(", ")}`);
44
- this.name = "TransactionVersionConflictError";
45
- this.conflictingIds = conflictingIds;
46
- }
47
- }
48
- class TransactionBulkOperationError extends Error {
49
- /**
50
- * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} failedDocs
51
- */
52
- constructor(failedDocs) {
53
- super(`Failed to save documents: ${failedDocs.map((d) => d.id).join(", ")}`);
54
- this.name = "TransactionBulkOperationError";
55
- this.failedDocs = failedDocs;
56
- }
57
- }
58
- class TransactionRollbackError extends Error {
59
- /**
60
- * @param {string} message
61
- * @param {Error} originalError
62
- * @param {Array<{ok?: boolean|null, id?: string|null, rev?: string|null, error?: string|null, reason?: string|null}>} rollbackResults
63
- */
64
- constructor(message, originalError, rollbackResults) {
65
- super(message);
66
- this.name = "TransactionRollbackError";
67
- this.originalError = originalError;
68
- this.rollbackResults = rollbackResults;
69
- }
70
- }
package/cjs/index.cjs DELETED
@@ -1,95 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var index_exports = {};
20
- __export(index_exports, {
21
- bindConfig: () => bindConfig,
22
- bulkGet: () => import_bulk.bulkGet,
23
- bulkGetDictionary: () => import_bulk.bulkGetDictionary,
24
- bulkRemove: () => import_bulk.bulkRemove,
25
- bulkSave: () => import_bulk.bulkSave,
26
- bulkSaveTransaction: () => import_bulk.bulkSaveTransaction,
27
- createQuery: () => import_queryBuilder.createQuery,
28
- get: () => import_crud.get,
29
- getAtRev: () => import_crud.getAtRev,
30
- patch: () => import_patch.patch,
31
- patchDangerously: () => import_patch.patchDangerously,
32
- put: () => import_crud.put,
33
- query: () => import_query.query,
34
- queryStream: () => import_stream.queryStream,
35
- schema: () => schema,
36
- withRetry: () => import_retry.withRetry
37
- });
38
- module.exports = __toCommonJS(index_exports);
39
- var import_bulk = require("./impl/bulk.cjs");
40
- var import_crud = require("./impl/crud.cjs");
41
- var import_patch = require("./impl/patch.cjs");
42
- var import_query = require("./impl/query.cjs");
43
- var import_stream = require("./impl/stream.cjs");
44
- var import_queryBuilder = require("./impl/queryBuilder.cjs");
45
- var import_retry = require("./impl/retry.cjs");
46
- var import_bulk2 = require("./schema/bulk.cjs");
47
- var import_config = require("./schema/config.cjs");
48
- var import_query2 = require("./schema/query.cjs");
49
- var import_stream2 = require("./schema/stream.cjs");
50
- var import_patch2 = require("./schema/patch.cjs");
51
- var import_crud2 = require("./schema/crud.cjs");
52
- var import_bind = require("./schema/bind.cjs");
53
- const schema = {
54
- CouchConfig: import_config.CouchConfig,
55
- SimpleViewQuery: import_query2.SimpleViewQuery,
56
- SimpleViewQueryResponse: import_query2.SimpleViewQueryResponse,
57
- SimpleViewQueryStream: import_stream2.SimpleViewQueryStream,
58
- OnRow: import_stream2.OnRow,
59
- BulkSave: import_bulk2.BulkSave,
60
- BulkGet: import_bulk2.BulkGet,
61
- BulkRemove: import_bulk2.BulkRemove,
62
- BulkGetDictionary: import_bulk2.BulkGetDictionary,
63
- BulkSaveTransaction: import_bulk2.BulkSaveTransaction,
64
- CouchGet: import_crud2.CouchGet,
65
- CouchPut: import_crud2.CouchPut,
66
- CouchDoc: import_crud2.CouchDoc,
67
- CouchDocResponse: import_crud2.CouchDocResponse,
68
- Patch: import_patch2.Patch,
69
- PatchDangerously: import_patch2.PatchDangerously,
70
- CouchGetAtRev: import_crud2.CouchGetAtRev,
71
- Bind: import_bind.Bind
72
- };
73
- const bindConfig = import_bind.Bind.implement((config) => {
74
- const retryOptions = {
75
- maxRetries: config.maxRetries ?? 10,
76
- initialDelay: config.initialDelay ?? 1e3,
77
- backoffFactor: config.backoffFactor ?? 2
78
- };
79
- return {
80
- get: config.bindWithRetry ? (0, import_retry.withRetry)(import_crud.get.bind(null, config), retryOptions) : import_crud.get.bind(null, config),
81
- getAtRev: config.bindWithRetry ? (0, import_retry.withRetry)(import_crud.getAtRev.bind(null, config), retryOptions) : import_crud.getAtRev.bind(null, config),
82
- put: config.bindWithRetry ? (0, import_retry.withRetry)(import_crud.put.bind(null, config), retryOptions) : import_crud.put.bind(null, config),
83
- bulkGet: config.bindWithRetry ? (0, import_retry.withRetry)(import_bulk.bulkGet.bind(null, config), retryOptions) : import_bulk.bulkGet.bind(null, config),
84
- bulkSave: config.bindWithRetry ? (0, import_retry.withRetry)(import_bulk.bulkSave.bind(null, config), retryOptions) : import_bulk.bulkSave.bind(null, config),
85
- query: config.bindWithRetry ? (0, import_retry.withRetry)(import_query.query.bind(null, config), retryOptions) : import_query.query.bind(null, config),
86
- queryStream: config.bindWithRetry ? (0, import_retry.withRetry)(import_stream.queryStream.bind(null, config), retryOptions) : import_stream.queryStream.bind(null, config),
87
- // Sugar Methods
88
- patch: config.bindWithRetry ? (0, import_retry.withRetry)(import_patch.patch.bind(null, config), retryOptions) : import_patch.patch.bind(null, config),
89
- patchDangerously: import_patch.patchDangerously.bind(null, config),
90
- // patchDangerously not included in retry
91
- bulkRemove: config.bindWithRetry ? (0, import_retry.withRetry)(import_bulk.bulkRemove.bind(null, config), retryOptions) : import_bulk.bulkRemove.bind(null, config),
92
- bulkGetDictionary: config.bindWithRetry ? (0, import_retry.withRetry)(import_bulk.bulkGetDictionary.bind(null, config), retryOptions) : import_bulk.bulkGetDictionary.bind(null, config),
93
- bulkSaveTransaction: import_bulk.bulkSaveTransaction.bind(null, config)
94
- };
95
- });
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var bind_exports = {};
20
- __export(bind_exports, {
21
- Bind: () => Bind
22
- });
23
- module.exports = __toCommonJS(bind_exports);
24
- var import_zod = require("zod");
25
- var import_config = require("./config.cjs");
26
- var import_bulk = require("./bulk.cjs");
27
- var import_crud = require("./crud.cjs");
28
- var import_patch = require("./patch.cjs");
29
- var import_query = require("./query.cjs");
30
- var import_stream = require("./stream.cjs");
31
- const BindReturns = import_zod.z.object({
32
- bulkGet: import_bulk.BulkGetBound,
33
- bulkSave: import_bulk.BulkSaveBound,
34
- bulkRemove: import_bulk.BulkRemoveBound,
35
- bulkGetDictionary: import_bulk.BulkGetDictionaryBound,
36
- bulkSaveTransaction: import_bulk.BulkSaveTransactionBound,
37
- get: import_crud.CouchGetBound,
38
- getAtRev: import_crud.CouchGetAtRevBound,
39
- put: import_crud.CouchPutBound,
40
- patch: import_patch.PatchBound,
41
- query: import_query.SimpleViewQueryBound,
42
- queryStream: import_stream.SimpleViewQueryStreamBound
43
- });
44
- const Bind = import_zod.z.function().args(import_config.CouchConfig).returns(BindReturns);
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var bulk_exports = {};
20
- __export(bulk_exports, {
21
- BulkGet: () => BulkGet,
22
- BulkGetBound: () => BulkGetBound,
23
- BulkGetDictionary: () => BulkGetDictionary,
24
- BulkGetDictionaryBound: () => BulkGetDictionaryBound,
25
- BulkGetDictionaryResponse: () => BulkGetDictionaryResponse,
26
- BulkRemove: () => BulkRemove,
27
- BulkRemoveBound: () => BulkRemoveBound,
28
- BulkSave: () => BulkSave,
29
- BulkSaveBound: () => BulkSaveBound,
30
- BulkSaveResponseSchema: () => BulkSaveResponseSchema,
31
- BulkSaveRow: () => BulkSaveRow,
32
- BulkSaveTransaction: () => BulkSaveTransaction,
33
- BulkSaveTransactionBound: () => BulkSaveTransactionBound
34
- });
35
- module.exports = __toCommonJS(bulk_exports);
36
- var import_zod = require("zod");
37
- var import_config = require("./config.cjs");
38
- var import_query = require("./query.cjs");
39
- var import_crud = require("./crud.cjs");
40
- const BulkSaveRow = import_zod.z.object({
41
- ok: import_zod.z.boolean().nullish(),
42
- id: import_zod.z.string().nullish(),
43
- rev: import_zod.z.string().nullish(),
44
- error: import_zod.z.string().nullish().describe("if an error occured, one word reason, eg conflict"),
45
- reason: import_zod.z.string().nullish().describe("a full error message")
46
- });
47
- const BulkSaveResponseSchema = import_zod.z.array(BulkSaveRow);
48
- const BulkSave = import_zod.z.function().args(
49
- import_config.CouchConfig,
50
- import_zod.z.array(import_crud.CouchDoc)
51
- ).returns(import_zod.z.promise(BulkSaveResponseSchema));
52
- const BulkSaveBound = import_zod.z.function().args(
53
- import_zod.z.array(import_crud.CouchDoc)
54
- ).returns(import_zod.z.promise(BulkSaveResponseSchema));
55
- const BulkGet = import_zod.z.function().args(
56
- import_config.CouchConfig,
57
- import_zod.z.array(import_zod.z.string().describe("the ids to get"))
58
- ).returns(import_zod.z.promise(import_query.SimpleViewQueryResponse));
59
- const BulkGetBound = import_zod.z.function().args(
60
- import_zod.z.array(import_zod.z.string().describe("the ids to get"))
61
- ).returns(import_zod.z.promise(import_query.SimpleViewQueryResponse));
62
- const BulkRemove = import_zod.z.function().args(
63
- import_config.CouchConfig,
64
- import_zod.z.array(import_zod.z.string().describe("the ids to delete"))
65
- ).returns(import_zod.z.promise(BulkSaveResponseSchema));
66
- const BulkRemoveBound = import_zod.z.function().args(
67
- import_zod.z.array(import_zod.z.string().describe("the ids to delete"))
68
- ).returns(import_zod.z.promise(BulkSaveResponseSchema));
69
- const BulkGetDictionaryResponse = import_zod.z.object({
70
- found: import_zod.z.record(import_zod.z.string(), import_crud.CouchDoc),
71
- notFound: import_zod.z.record(import_zod.z.string(), import_query.ViewRow)
72
- });
73
- const BulkGetDictionary = import_zod.z.function().args(
74
- import_config.CouchConfig,
75
- import_zod.z.array(import_zod.z.string().describe("the ids to get"))
76
- ).returns(import_zod.z.promise(BulkGetDictionaryResponse));
77
- const BulkGetDictionaryBound = import_zod.z.function().args(
78
- import_zod.z.array(import_zod.z.string().describe("the ids to get"))
79
- ).returns(import_zod.z.promise(BulkGetDictionaryResponse));
80
- const BulkSaveTransaction = import_zod.z.function().args(
81
- import_config.CouchConfig,
82
- import_zod.z.string().describe("transaction id"),
83
- import_zod.z.array(import_crud.CouchDoc)
84
- ).returns(import_zod.z.promise(BulkSaveResponseSchema));
85
- const BulkSaveTransactionBound = import_zod.z.function().args(
86
- import_zod.z.string().describe("transaction id"),
87
- import_zod.z.array(import_crud.CouchDoc)
88
- ).returns(import_zod.z.promise(BulkSaveResponseSchema));
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var config_exports = {};
20
- __export(config_exports, {
21
- CouchConfig: () => CouchConfig
22
- });
23
- module.exports = __toCommonJS(config_exports);
24
- var import_zod = require("zod");
25
- const LoggerSchema = import_zod.z.object({
26
- error: import_zod.z.function().args(import_zod.z.any()).returns(import_zod.z.void()).optional(),
27
- warn: import_zod.z.function().args(import_zod.z.any()).returns(import_zod.z.void()).optional(),
28
- info: import_zod.z.function().args(import_zod.z.any()).returns(import_zod.z.void()).optional(),
29
- debug: import_zod.z.function().args(import_zod.z.any()).returns(import_zod.z.void()).optional()
30
- }).or(import_zod.z.function().args(
31
- import_zod.z.string(),
32
- // level
33
- import_zod.z.any()
34
- // message/args
35
- ).returns(import_zod.z.void()));
36
- const CouchConfig = import_zod.z.object({
37
- throwOnGetNotFound: import_zod.z.boolean().optional().default(false).describe("if a get is 404 should we throw or return undefined"),
38
- couch: import_zod.z.string().describe("the url of the couch db"),
39
- bindWithRetry: import_zod.z.boolean().optional().default(true).describe("should we bind with retry"),
40
- maxRetries: import_zod.z.number().optional().default(3).describe("maximum number of retry attempts"),
41
- initialDelay: import_zod.z.number().optional().default(1e3).describe("initial retry delay in milliseconds"),
42
- backoffFactor: import_zod.z.number().optional().default(2).describe("multiplier for exponential backoff"),
43
- useConsoleLogger: import_zod.z.boolean().optional().default(false).describe("turn on console as a fallback logger"),
44
- logger: LoggerSchema.optional().describe("logging interface supporting winston-like or simple function interface"),
45
- // _emitter: z.any().optional().describe('emitter for events'),
46
- _normalizedLogger: import_zod.z.any().optional()
47
- // Internal property for caching normalized logger
48
- }).passthrough().describe("The std config object");
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var crud_exports = {};
20
- __export(crud_exports, {
21
- CouchDoc: () => CouchDoc,
22
- CouchDocResponse: () => CouchDocResponse,
23
- CouchGet: () => CouchGet,
24
- CouchGetAtRev: () => CouchGetAtRev,
25
- CouchGetAtRevBound: () => CouchGetAtRevBound,
26
- CouchGetBound: () => CouchGetBound,
27
- CouchGetOptions: () => CouchGetOptions,
28
- CouchGetWithOptions: () => CouchGetWithOptions,
29
- CouchPut: () => CouchPut,
30
- CouchPutBound: () => CouchPutBound
31
- });
32
- module.exports = __toCommonJS(crud_exports);
33
- var import_zod = require("zod");
34
- var import_config = require("./config.cjs");
35
- const CouchDoc = import_zod.z.object({
36
- _id: import_zod.z.string().describe("the couch doc id"),
37
- _rev: import_zod.z.string().optional().nullish().describe("the doc revision"),
38
- _deleted: import_zod.z.boolean().optional().describe("is the doc deleted")
39
- }).passthrough();
40
- const CouchDocResponse = import_zod.z.object({
41
- ok: import_zod.z.boolean().optional().describe("did the request succeed"),
42
- error: import_zod.z.string().optional().describe("the error message, if did not succed"),
43
- statusCode: import_zod.z.number(),
44
- id: import_zod.z.string().optional().describe("the couch doc id"),
45
- rev: import_zod.z.string().optional().describe("the new rev of the doc")
46
- });
47
- const CouchPut = import_zod.z.function().args(
48
- import_config.CouchConfig,
49
- CouchDoc
50
- ).returns(import_zod.z.promise(CouchDocResponse));
51
- const CouchPutBound = import_zod.z.function().args(
52
- CouchDoc
53
- ).returns(import_zod.z.promise(CouchDocResponse));
54
- const CouchGet = import_zod.z.function().args(
55
- import_config.CouchConfig,
56
- import_zod.z.string().describe("the couch doc id")
57
- ).returns(import_zod.z.promise(CouchDoc.nullable()));
58
- const CouchGetBound = import_zod.z.function().args(
59
- import_zod.z.string().describe("the couch doc id")
60
- ).returns(import_zod.z.promise(CouchDoc.nullable()));
61
- const CouchGetAtRev = import_zod.z.function().args(
62
- import_config.CouchConfig,
63
- import_zod.z.string().describe("the couch doc id"),
64
- import_zod.z.string().describe("the rev")
65
- ).returns(import_zod.z.promise(CouchDoc.nullable()));
66
- const CouchGetAtRevBound = import_zod.z.function().args(
67
- import_zod.z.string().describe("the couch doc id"),
68
- import_zod.z.string().describe("the rev")
69
- ).returns(import_zod.z.promise(CouchDoc.nullable()));
70
- const CouchGetOptions = import_zod.z.object({
71
- rev: import_zod.z.string().optional().describe("the couch doc revision")
72
- });
73
- const CouchGetWithOptions = import_zod.z.function().args(
74
- import_config.CouchConfig,
75
- import_zod.z.string().describe("the couch doc id"),
76
- CouchGetOptions
77
- ).returns(import_zod.z.promise(CouchDoc.nullable()));
@@ -1,53 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var patch_exports = {};
20
- __export(patch_exports, {
21
- Patch: () => Patch,
22
- PatchBound: () => PatchBound,
23
- PatchDangerously: () => PatchDangerously,
24
- PatchDangerouslyBound: () => PatchDangerouslyBound,
25
- PatchProperties: () => PatchProperties,
26
- StrictPatchProperties: () => StrictPatchProperties
27
- });
28
- module.exports = __toCommonJS(patch_exports);
29
- var import_zod = require("zod");
30
- var import_config = require("./config.cjs");
31
- var import_crud = require("./crud.cjs");
32
- const PatchProperties = import_zod.z.record(import_zod.z.string(), import_zod.z.any());
33
- const StrictPatchProperties = import_zod.z.object({
34
- _rev: import_zod.z.string()
35
- }).and(PatchProperties);
36
- const Patch = import_zod.z.function().args(
37
- import_config.CouchConfig,
38
- import_zod.z.string().describe("the couch doc id"),
39
- StrictPatchProperties
40
- ).returns(import_zod.z.promise(import_crud.CouchDocResponse));
41
- const PatchBound = import_zod.z.function().args(
42
- import_zod.z.string().describe("the couch doc id"),
43
- StrictPatchProperties
44
- ).returns(import_zod.z.promise(import_crud.CouchDocResponse));
45
- const PatchDangerously = import_zod.z.function().args(
46
- import_config.CouchConfig,
47
- import_zod.z.string().describe("the couch doc id"),
48
- PatchProperties
49
- ).returns(import_zod.z.promise(import_crud.CouchDocResponse));
50
- const PatchDangerouslyBound = import_zod.z.function().args(
51
- import_zod.z.string().describe("the couch doc id"),
52
- PatchProperties
53
- ).returns(import_zod.z.promise(import_crud.CouchDocResponse));