@clipboard-health/contract-core 0.1.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.
package/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # @clipboard-health/contract-core <!-- omit from toc -->
2
+
3
+ Core schemas for Clipboard Health's API contracts.
4
+
5
+ ## Table of contents <!-- omit from toc -->
6
+
7
+ - [Install](#install)
8
+ - [Usage](#usage)
9
+ - [Local development commands](#local-development-commands)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install @clipboard-health/contract-core
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ## Local development commands
20
+
21
+ See [`package.json`](./package.json) `scripts` for a list of commands.
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@clipboard-health/contract-core",
3
+ "description": "Core schemas for Clipboard Health's API contracts.",
4
+ "version": "0.1.0",
5
+ "dependencies": {
6
+ "tslib": "2.8.0",
7
+ "zod": "3.23.8"
8
+ },
9
+ "devDependencies": {
10
+ "@clipboard-health/testing-core": "0.1.0"
11
+ },
12
+ "keywords": [],
13
+ "license": "MIT",
14
+ "main": "./src/index.js",
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "type": "commonjs",
19
+ "typings": "./src/index.d.ts",
20
+ "types": "./src/index.d.ts"
21
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./lib/schemas";
package/src/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./lib/schemas"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/contract-core/src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B"}
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * @see {@link https://jsonapi.org/format/#error-objects Error Objects}
4
+ */
5
+ declare const apiError: z.ZodObject<{
6
+ code: z.ZodString;
7
+ detail: z.ZodOptional<z.ZodString>;
8
+ id: z.ZodString;
9
+ status: z.ZodString;
10
+ title: z.ZodString;
11
+ }, "strip", z.ZodTypeAny, {
12
+ code: string;
13
+ id: string;
14
+ status: string;
15
+ title: string;
16
+ detail?: string | undefined;
17
+ }, {
18
+ code: string;
19
+ id: string;
20
+ status: string;
21
+ title: string;
22
+ detail?: string | undefined;
23
+ }>;
24
+ /**
25
+ * @see {@link https://jsonapi.org/format/#errors Errors}
26
+ */
27
+ export declare const apiErrors: z.ZodObject<{
28
+ errors: z.ZodArray<z.ZodObject<{
29
+ code: z.ZodString;
30
+ detail: z.ZodOptional<z.ZodString>;
31
+ id: z.ZodString;
32
+ status: z.ZodString;
33
+ title: z.ZodString;
34
+ }, "strip", z.ZodTypeAny, {
35
+ code: string;
36
+ id: string;
37
+ status: string;
38
+ title: string;
39
+ detail?: string | undefined;
40
+ }, {
41
+ code: string;
42
+ id: string;
43
+ status: string;
44
+ title: string;
45
+ detail?: string | undefined;
46
+ }>, "many">;
47
+ }, "strip", z.ZodTypeAny, {
48
+ errors: {
49
+ code: string;
50
+ id: string;
51
+ status: string;
52
+ title: string;
53
+ detail?: string | undefined;
54
+ }[];
55
+ }, {
56
+ errors: {
57
+ code: string;
58
+ id: string;
59
+ status: string;
60
+ title: string;
61
+ detail?: string | undefined;
62
+ }[];
63
+ }>;
64
+ /**
65
+ * @see {@link https://jsonapi.org/format/#error-objects Error Objects}
66
+ */
67
+ export type ApiError = z.infer<typeof apiError>;
68
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiErrors = void 0;
4
+ const zod_1 = require("zod");
5
+ const nonEmptyString_1 = require("./nonEmptyString");
6
+ /**
7
+ * @see {@link https://jsonapi.org/format/#error-objects Error Objects}
8
+ */
9
+ const apiError = zod_1.z.object({
10
+ code: nonEmptyString_1.nonEmptyString,
11
+ detail: zod_1.z.string().optional(),
12
+ id: nonEmptyString_1.nonEmptyString,
13
+ status: nonEmptyString_1.nonEmptyString,
14
+ title: nonEmptyString_1.nonEmptyString,
15
+ });
16
+ /**
17
+ * @see {@link https://jsonapi.org/format/#errors Errors}
18
+ */
19
+ exports.apiErrors = zod_1.z.object({
20
+ errors: apiError.array().min(0).max(100),
21
+ });
22
+ //# sourceMappingURL=apiError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apiError.js","sourceRoot":"","sources":["../../../../../../packages/contract-core/src/lib/schemas/apiError.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,qDAAkD;AAElD;;GAEG;AACH,MAAM,QAAQ,GAAG,OAAC,CAAC,MAAM,CAAC;IACxB,IAAI,EAAE,+BAAc;IACpB,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,EAAE,EAAE,+BAAc;IAClB,MAAM,EAAE,+BAAc;IACtB,KAAK,EAAE,+BAAc;CACtB,CAAC,CAAC;AAEH;;GAEG;AACU,QAAA,SAAS,GAAG,OAAC,CAAC,MAAM,CAAC;IAChC,MAAM,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;CACzC,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * A Zod schema for use with boolean query parameters since `z.coerce.boolean()` treats any truthy
4
+ * value as `true`.
5
+ *
6
+ * `.transform((value) => value === "true")` causes inference issues in controllers.
7
+ */
8
+ export declare const booleanString: z.ZodEnum<["true", "false"]>;
9
+ export type BooleanString = z.infer<typeof booleanString>;
10
+ export declare function toBoolean(value: BooleanString): boolean;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.booleanString = void 0;
4
+ exports.toBoolean = toBoolean;
5
+ const zod_1 = require("zod");
6
+ /**
7
+ * A Zod schema for use with boolean query parameters since `z.coerce.boolean()` treats any truthy
8
+ * value as `true`.
9
+ *
10
+ * `.transform((value) => value === "true")` causes inference issues in controllers.
11
+ */
12
+ exports.booleanString = zod_1.z.enum(["true", "false"]);
13
+ function toBoolean(value) {
14
+ return value === "true";
15
+ }
16
+ //# sourceMappingURL=booleanString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"booleanString.js","sourceRoot":"","sources":["../../../../../../packages/contract-core/src/lib/schemas/booleanString.ts"],"names":[],"mappings":";;;AAYA,8BAEC;AAdD,6BAAwB;AAExB;;;;;GAKG;AACU,QAAA,aAAa,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAIvD,SAAgB,SAAS,CAAC,KAAoB;IAC5C,OAAO,KAAK,KAAK,MAAM,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./apiError";
2
+ export * from "./booleanString";
3
+ export * from "./nonEmptyString";
4
+ export * from "./uuid";
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./apiError"), exports);
5
+ tslib_1.__exportStar(require("./booleanString"), exports);
6
+ tslib_1.__exportStar(require("./nonEmptyString"), exports);
7
+ tslib_1.__exportStar(require("./uuid"), exports);
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/contract-core/src/lib/schemas/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,0DAAgC;AAChC,2DAAiC;AACjC,iDAAuB"}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * A non-empty string Zod schema.
4
+ */
5
+ export declare const nonEmptyString: z.ZodString;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nonEmptyString = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * A non-empty string Zod schema.
7
+ */
8
+ exports.nonEmptyString = zod_1.z.string().min(1);
9
+ //# sourceMappingURL=nonEmptyString.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nonEmptyString.js","sourceRoot":"","sources":["../../../../../../packages/contract-core/src/lib/schemas/nonEmptyString.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;GAEG;AACU,QAAA,cAAc,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Regular expressions from
4
+ * {@link https://github.com/nestjs/nest/blob/master/packages/common/pipes/parse-uuid.pipe.ts}.
5
+ */
6
+ export declare const uuid: z.ZodString;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uuid = void 0;
4
+ const zod_1 = require("zod");
5
+ /**
6
+ * Regular expressions from
7
+ * {@link https://github.com/nestjs/nest/blob/master/packages/common/pipes/parse-uuid.pipe.ts}.
8
+ */
9
+ exports.uuid = zod_1.z
10
+ .string()
11
+ .trim()
12
+ // eslint-disable-next-line unicorn/better-regex
13
+ .regex(/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i);
14
+ //# sourceMappingURL=uuid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.js","sourceRoot":"","sources":["../../../../../../packages/contract-core/src/lib/schemas/uuid.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB;;;GAGG;AACU,QAAA,IAAI,GAAG,OAAC;KAClB,MAAM,EAAE;KACR,IAAI,EAAE;IACP,gDAAgD;KAC/C,KAAK,CAAC,iEAAiE,CAAC,CAAC"}