hide-a-bed 2.1.0 → 3.0.1

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 (46) hide show
  1. package/build/build.mjs +16 -0
  2. package/build/build.rewrite-imports.mjs +14 -0
  3. package/cjs/impl/bulk.cjs +77 -0
  4. package/cjs/impl/crud.cjs +64 -0
  5. package/cjs/impl/patch.cjs +52 -0
  6. package/cjs/impl/query.cjs +72 -0
  7. package/cjs/impl/stream.cjs +49 -0
  8. package/cjs/index.cjs +54 -0
  9. package/cjs/schema/bulk.cjs +50 -0
  10. package/cjs/schema/config.cjs +27 -0
  11. package/cjs/schema/crud.cjs +47 -0
  12. package/cjs/schema/patch.cjs +38 -0
  13. package/cjs/schema/query.cjs +51 -0
  14. package/impl/bulk.d.mts +7 -0
  15. package/impl/bulk.d.mts.map +1 -0
  16. package/impl/bulk.mjs +19 -10
  17. package/impl/crud.d.mts +10 -0
  18. package/impl/crud.d.mts.map +1 -0
  19. package/impl/patch.d.mts +2 -0
  20. package/impl/patch.d.mts.map +1 -0
  21. package/impl/patch.mjs +3 -3
  22. package/impl/query.d.mts +104 -0
  23. package/impl/query.d.mts.map +1 -0
  24. package/impl/query.mjs +4 -0
  25. package/impl/stream.d.mts +2 -0
  26. package/impl/stream.d.mts.map +1 -0
  27. package/impl/stream.mjs +10 -1
  28. package/index.d.mts +34 -0
  29. package/index.d.mts.map +1 -0
  30. package/index.mjs +2 -3
  31. package/package.json +28 -3
  32. package/schema/bulk.d.mts +100 -0
  33. package/schema/bulk.d.mts.map +1 -0
  34. package/schema/bulk.mjs +6 -3
  35. package/schema/config.d.mts +9 -0
  36. package/schema/config.d.mts.map +1 -0
  37. package/schema/crud.d.mts +83 -0
  38. package/schema/crud.d.mts.map +1 -0
  39. package/schema/crud.mjs +1 -0
  40. package/schema/patch.d.mts +47 -0
  41. package/schema/patch.d.mts.map +1 -0
  42. package/schema/patch.mjs +1 -1
  43. package/schema/query.d.mts +151 -0
  44. package/schema/query.d.mts.map +1 -0
  45. package/schema/query.mjs +0 -1
  46. package/tsconfig.json +13 -0
@@ -0,0 +1,16 @@
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))
@@ -0,0 +1,14 @@
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
+ }
@@ -0,0 +1,77 @@
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 bulk_exports = {};
30
+ __export(bulk_exports, {
31
+ bulkGet: () => bulkGet,
32
+ bulkRemove: () => bulkRemove,
33
+ bulkSave: () => bulkSave
34
+ });
35
+ module.exports = __toCommonJS(bulk_exports);
36
+ var import_needle = __toESM(require("needle"), 1);
37
+ var import_bulk = require("../schema/bulk.cjs");
38
+ const opts = {
39
+ json: true,
40
+ headers: {
41
+ "Content-Type": "application/json"
42
+ }
43
+ };
44
+ const bulkSave = import_bulk.BulkSave.implement(async (config, docs) => {
45
+ if (!docs) return { ok: false, error: "noDocs", reason: "no docs provided" };
46
+ if (!docs.length) return { ok: false, error: "noDocs", reason: "no docs provided" };
47
+ const url = `${config.couch}/_bulk_docs`;
48
+ const body = { docs };
49
+ const resp = await (0, import_needle.default)("post", url, body, opts);
50
+ if (resp.statusCode !== 201) throw new Error("could not save");
51
+ const results = resp?.body || [];
52
+ return results;
53
+ });
54
+ const bulkGet = import_bulk.BulkGet.implement(async (config, ids) => {
55
+ const keys = ids;
56
+ const url = `${config.couch}/_all_docs?include_docs=true`;
57
+ const body = { keys };
58
+ const resp = await (0, import_needle.default)("post", url, body, opts);
59
+ if (resp.statusCode !== 200) throw new Error("could not fetch");
60
+ const rows = resp?.body?.rows || [];
61
+ const docs = [];
62
+ rows.forEach((r) => {
63
+ if (r.error) return;
64
+ if (!r.key) return;
65
+ if (!r.doc) return;
66
+ const doc = r.doc;
67
+ docs.push(doc);
68
+ });
69
+ return docs;
70
+ });
71
+ const bulkRemove = import_bulk.BulkRemove.implement(async (config, ids) => {
72
+ const docs = await bulkGet(config, ids);
73
+ docs.forEach((d) => {
74
+ d._deleted = true;
75
+ });
76
+ return bulkSave(config, docs);
77
+ });
@@ -0,0 +1,64 @@
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 crud_exports = {};
30
+ __export(crud_exports, {
31
+ get: () => get,
32
+ put: () => put
33
+ });
34
+ module.exports = __toCommonJS(crud_exports);
35
+ var import_needle = __toESM(require("needle"), 1);
36
+ var import_crud = require("../schema/crud.cjs");
37
+ const opts = {
38
+ json: true,
39
+ headers: {
40
+ "Content-Type": "application/json"
41
+ }
42
+ };
43
+ const get = import_crud.CouchGet.implement(async (config, id) => {
44
+ const url = `${config.couch}/${id}`;
45
+ const resp = await (0, import_needle.default)("get", url, opts);
46
+ if (resp.statusCode === 404) return null;
47
+ const result = resp?.body || {};
48
+ if (resp.statusCode !== 200) {
49
+ throw new Error(result.reason || "failed");
50
+ }
51
+ return result;
52
+ });
53
+ const put = import_crud.CouchPut.implement(async (config, doc) => {
54
+ const url = `${config.couch}/${doc._id}`;
55
+ const body = doc;
56
+ const resp = await (0, import_needle.default)("put", url, body, opts);
57
+ const result = resp?.body || {};
58
+ result.statusCode = resp.statusCode;
59
+ if (resp.statusCode === 409) {
60
+ result.ok = false;
61
+ result.error = "conflict";
62
+ }
63
+ return result;
64
+ });
@@ -0,0 +1,52 @@
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
+ });
23
+ module.exports = __toCommonJS(patch_exports);
24
+ var import_crud = require("./crud.cjs");
25
+ var import_patch = require("../schema/patch.cjs");
26
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
27
+ const patch = import_patch.CouchPatch.implement(async (config, id, properties) => {
28
+ const maxRetries = config.retries || 5;
29
+ const delay = config.delay || 1e3;
30
+ let attempts = 0;
31
+ while (attempts <= maxRetries) {
32
+ try {
33
+ const doc = await (0, import_crud.get)(config, id);
34
+ const updatedDoc = { ...doc, ...properties };
35
+ const result = await (0, import_crud.put)(config, updatedDoc);
36
+ if (result.ok) {
37
+ return result;
38
+ }
39
+ attempts++;
40
+ if (attempts > maxRetries) {
41
+ throw new Error(`Failed to patch after ${maxRetries} attempts`);
42
+ }
43
+ await sleep(delay);
44
+ } catch (err) {
45
+ attempts++;
46
+ if (attempts > maxRetries) {
47
+ throw new Error(`Failed to patch after ${maxRetries} attempts: ${err.message}`);
48
+ }
49
+ await sleep(delay);
50
+ }
51
+ }
52
+ });
@@ -0,0 +1,72 @@
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 query_exports = {};
30
+ __export(query_exports, {
31
+ query: () => query,
32
+ queryString: () => queryString
33
+ });
34
+ module.exports = __toCommonJS(query_exports);
35
+ var import_zod = require("zod");
36
+ var import_needle = __toESM(require("needle"), 1);
37
+ var import_query = require("../schema/query.cjs");
38
+ var import_lodash = __toESM(require("lodash"), 1);
39
+ const { includes } = import_lodash.default;
40
+ const query = import_query.SimpleViewQuery.implement(async (config, view, options) => {
41
+ const qs = queryString(options, ["key", "startkey", "endkey", "reduce", "group", "group_level", "stale", "limit"]);
42
+ const opts = {
43
+ json: true,
44
+ headers: {
45
+ "Content-Type": "application/json"
46
+ }
47
+ };
48
+ const url = `${config.couch}/${view}?${qs.toString()}`;
49
+ const results = await (0, import_needle.default)("get", url, opts);
50
+ const body = results.body;
51
+ if (body.error) throw new Error(body.error);
52
+ return body;
53
+ });
54
+ function queryString(options, params) {
55
+ const parts = Object.keys(options).map((key) => {
56
+ let value = options[key];
57
+ if (includes(params, key)) {
58
+ if (typeof value === "string" && key !== "stale") value = `"${value}"`;
59
+ if (Array.isArray(value)) {
60
+ value = "[" + value.map((i) => {
61
+ if (i === null) return "null";
62
+ if (typeof i === "string") return `"${i}"`;
63
+ if (typeof i === "object" && Object.keys(i).length === 0) return "{}";
64
+ if (typeof i === "object") return JSON.stringify(i);
65
+ return i;
66
+ }).join(",") + "]";
67
+ }
68
+ }
69
+ return `${key}=${value}`;
70
+ });
71
+ return parts.join("&");
72
+ }
@@ -0,0 +1,49 @@
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_query = require("./query.cjs");
36
+ var import_JSONStream = __toESM(require("JSONStream"), 1);
37
+ const queryStream = (config, view, options) => new Promise((resolve, reject) => {
38
+ if (!options) options = {};
39
+ const { onRow, ...rest } = options;
40
+ const qs = (0, import_query.queryString)(rest, ["key", "startkey", "endkey", "reduce", "group", "group_level", "stale", "limit"]);
41
+ const url = `${config.couch}/${view}?${qs.toString()}`;
42
+ const streamer = import_JSONStream.default.parse("rows.*");
43
+ streamer.on("data", onRow);
44
+ streamer.on("end", (err) => {
45
+ if (err) return reject(err);
46
+ resolve(null);
47
+ });
48
+ import_needle.default.get(url).pipe(streamer);
49
+ });
package/cjs/index.cjs ADDED
@@ -0,0 +1,54 @@
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
+ bulkGet: () => import_bulk.bulkGet,
22
+ bulkRemove: () => import_bulk.bulkRemove,
23
+ bulkSave: () => import_bulk.bulkSave,
24
+ get: () => import_crud.get,
25
+ patch: () => import_patch.patch,
26
+ put: () => import_crud.put,
27
+ query: () => import_query.query,
28
+ queryStream: () => import_stream.queryStream,
29
+ schema: () => schema
30
+ });
31
+ module.exports = __toCommonJS(index_exports);
32
+ var import_bulk = require("./impl/bulk.cjs");
33
+ var import_crud = require("./impl/crud.cjs");
34
+ var import_patch = require("./impl/patch.cjs");
35
+ var import_query = require("./impl/query.cjs");
36
+ var import_stream = require("./impl/stream.cjs");
37
+ var import_bulk2 = require("./schema/bulk.cjs");
38
+ var import_config = require("./schema/config.cjs");
39
+ var import_query2 = require("./schema/query.cjs");
40
+ var import_patch2 = require("./schema/patch.cjs");
41
+ var import_crud2 = require("./schema/crud.cjs");
42
+ const schema = {
43
+ CouchConfig: import_config.CouchConfig,
44
+ SimpleViewQuery: import_query2.SimpleViewQuery,
45
+ SimpleViewQueryResponse: import_query2.SimpleViewQueryResponse,
46
+ BulkSave: import_bulk2.BulkSave,
47
+ BulkGet: import_bulk2.BulkGet,
48
+ CouchGet: import_crud2.CouchGet,
49
+ CouchPut: import_crud2.CouchPut,
50
+ CouchDoc: import_crud2.CouchDoc,
51
+ CouchDocResponse: import_crud2.CouchDocResponse,
52
+ PatchConfig: import_patch2.PatchConfig,
53
+ Patch: import_patch2.Patch
54
+ };
@@ -0,0 +1,50 @@
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
+ BulkRemove: () => BulkRemove,
23
+ BulkSave: () => BulkSave,
24
+ BulkSaveResponseSchema: () => BulkSaveResponseSchema
25
+ });
26
+ module.exports = __toCommonJS(bulk_exports);
27
+ var import_zod = require("zod");
28
+ var import_config = require("./config.cjs");
29
+ var import_crud = require("./crud.cjs");
30
+ const BulkSaveResponseSchema = import_zod.z.array(import_zod.z.object({
31
+ ok: import_zod.z.boolean().nullish(),
32
+ id: import_zod.z.string().nullish(),
33
+ rev: import_zod.z.string().nullish(),
34
+ error: import_zod.z.string().nullish().describe("if an error occured, one word reason, eg conflict"),
35
+ reason: import_zod.z.string().nullish().describe("a full error message")
36
+ }));
37
+ const BulkSave = import_zod.z.function().args(
38
+ import_config.CouchConfig,
39
+ import_zod.z.array(import_zod.z.object({
40
+ _id: import_zod.z.string()
41
+ }).passthrough())
42
+ ).returns(import_zod.z.promise(BulkSaveResponseSchema));
43
+ const BulkGet = import_zod.z.function().args(
44
+ import_config.CouchConfig,
45
+ import_zod.z.array(import_zod.z.string().describe("the ids to get"))
46
+ ).returns(import_zod.z.promise(import_zod.z.array(import_crud.CouchDoc)));
47
+ const BulkRemove = import_zod.z.function().args(
48
+ import_config.CouchConfig,
49
+ import_zod.z.array(import_zod.z.string().describe("the ids to delete"))
50
+ ).returns(import_zod.z.promise(BulkSaveResponseSchema));
@@ -0,0 +1,27 @@
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 CouchConfig = import_zod.z.object({
26
+ couch: import_zod.z.string().describe("the url of the couch db")
27
+ }).passthrough().describe("The std config object");
@@ -0,0 +1,47 @@
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
+ CouchPut: () => CouchPut
25
+ });
26
+ module.exports = __toCommonJS(crud_exports);
27
+ var import_zod = require("zod");
28
+ var import_config = require("./config.cjs");
29
+ const CouchDoc = import_zod.z.object({
30
+ _id: import_zod.z.string().describe("the couch doc id"),
31
+ _rev: import_zod.z.string().optional().describe("the doc revision")
32
+ }).passthrough();
33
+ const CouchDocResponse = import_zod.z.object({
34
+ ok: import_zod.z.boolean().optional().describe("did the request succeed"),
35
+ error: import_zod.z.string().optional().describe("the error message, if did not succed"),
36
+ statusCode: import_zod.z.number(),
37
+ id: import_zod.z.string().optional().describe("the couch doc id"),
38
+ rev: import_zod.z.string().optional().describe("the new rev of the doc")
39
+ });
40
+ const CouchPut = import_zod.z.function().args(
41
+ import_config.CouchConfig,
42
+ CouchDoc
43
+ ).returns(import_zod.z.promise(CouchDocResponse));
44
+ const CouchGet = import_zod.z.function().args(
45
+ import_config.CouchConfig,
46
+ import_zod.z.string().describe("the couch doc id")
47
+ ).returns(import_zod.z.promise(CouchDoc.nullable()));
@@ -0,0 +1,38 @@
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
+ PatchConfig: () => PatchConfig,
23
+ PatchProperties: () => PatchProperties
24
+ });
25
+ module.exports = __toCommonJS(patch_exports);
26
+ var import_zod = require("zod");
27
+ var import_config = require("./config.cjs");
28
+ var import_crud = require("./crud.cjs");
29
+ const PatchConfig = import_config.CouchConfig.extend({
30
+ retries: import_zod.z.number().min(0).max(100).optional(),
31
+ delay: import_zod.z.number().min(0).optional()
32
+ });
33
+ const PatchProperties = import_zod.z.record(import_zod.z.string(), import_zod.z.any());
34
+ const Patch = import_zod.z.function().args(
35
+ PatchConfig,
36
+ import_zod.z.string().describe("the couch doc id"),
37
+ PatchProperties
38
+ ).returns(import_zod.z.promise(import_crud.CouchDocResponse));
@@ -0,0 +1,51 @@
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 query_exports = {};
20
+ __export(query_exports, {
21
+ SimpleViewQuery: () => SimpleViewQuery,
22
+ SimpleViewQueryResponse: () => SimpleViewQueryResponse
23
+ });
24
+ module.exports = __toCommonJS(query_exports);
25
+ var import_zod = require("zod");
26
+ var import_config = require("./config.cjs");
27
+ const SimpleViewQueryResponse = import_zod.z.object({
28
+ error: import_zod.z.string().optional().describe("if something is wrong"),
29
+ rows: import_zod.z.array(import_zod.z.object({
30
+ id: import_zod.z.string().optional(),
31
+ key: import_zod.z.any().nullable(),
32
+ value: import_zod.z.any().nullable(),
33
+ doc: import_zod.z.object({}).passthrough().optional()
34
+ }))
35
+ }).passthrough();
36
+ const SimpleViewQuery = import_zod.z.function().args(
37
+ import_config.CouchConfig,
38
+ import_zod.z.string().describe("the view name"),
39
+ import_zod.z.object({
40
+ startkey: import_zod.z.any().optional(),
41
+ endkey: import_zod.z.any().optional(),
42
+ descending: import_zod.z.boolean().optional().describe("sort results descending"),
43
+ skip: import_zod.z.number().positive().optional().describe("skip this many rows"),
44
+ limit: import_zod.z.number().positive().optional().describe("limit the results to this many rows"),
45
+ key: import_zod.z.any().optional(),
46
+ include_docs: import_zod.z.boolean().optional().describe("join the id to the doc and return it"),
47
+ reduce: import_zod.z.boolean().optional().describe("reduce the results"),
48
+ group: import_zod.z.boolean().optional().describe("group the results"),
49
+ group_level: import_zod.z.number().positive().optional().describe("group the results at this level")
50
+ }).optional().describe("query options")
51
+ ).returns(import_zod.z.promise(SimpleViewQueryResponse));
@@ -0,0 +1,7 @@
1
+ /** @type { import('../schema/bulk.mjs').BulkSaveSchema } */
2
+ export const bulkSave: import("../schema/bulk.mjs").BulkSaveSchema;
3
+ /** @type { import('../schema/bulk.mjs').BulkGetSchema } */
4
+ export const bulkGet: import("../schema/bulk.mjs").BulkGetSchema;
5
+ /** @type { import('../schema/bulk.mjs').BulkRemoveSchema } */
6
+ export const bulkRemove: import("../schema/bulk.mjs").BulkRemoveSchema;
7
+ //# sourceMappingURL=bulk.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk.d.mts","sourceRoot":"","sources":["bulk.mjs"],"names":[],"mappings":"AAWA,4DAA4D;AAC5D,uBADY,OAAO,oBAAoB,EAAE,cAAc,CAWrD;AAEF,2DAA2D;AAC3D,sBADY,OAAO,oBAAoB,EAAE,aAAa,CAqBpD;AAEF,8DAA8D;AAC9D,yBADY,OAAO,oBAAoB,EAAE,gBAAgB,CAKvD"}