@kuckit/contracts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/user.d.ts
4
+
5
+ /**
6
+ * User DTO schema for API responses
7
+ */
8
+ declare const zUserDTO: z.ZodObject<{
9
+ id: z.ZodString;
10
+ name: z.ZodString;
11
+ email: z.ZodString;
12
+ emailVerified: z.ZodBoolean;
13
+ createdAt: z.ZodString;
14
+ updatedAt: z.ZodString;
15
+ }, z.core.$strip>;
16
+ type UserDTO = z.infer<typeof zUserDTO>;
17
+ /**
18
+ * Map domain User to UserDTO
19
+ */
20
+ declare const toUserDTO: (user: {
21
+ id: string;
22
+ name: string;
23
+ email: string;
24
+ emailVerified: boolean;
25
+ createdAt: Date;
26
+ updatedAt: Date;
27
+ }) => UserDTO;
28
+ //#endregion
29
+ export { type UserDTO, toUserDTO, zUserDTO };
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/user.ts
4
+ /**
5
+ * User DTO schema for API responses
6
+ */
7
+ const zUserDTO = z.object({
8
+ id: z.string(),
9
+ name: z.string(),
10
+ email: z.string().email(),
11
+ emailVerified: z.boolean(),
12
+ createdAt: z.string().datetime(),
13
+ updatedAt: z.string().datetime()
14
+ });
15
+ /**
16
+ * Map domain User to UserDTO
17
+ */
18
+ const toUserDTO = (user) => ({
19
+ id: user.id,
20
+ name: user.name,
21
+ email: user.email,
22
+ emailVerified: user.emailVerified,
23
+ createdAt: user.createdAt.toISOString(),
24
+ updatedAt: user.updatedAt.toISOString()
25
+ });
26
+
27
+ //#endregion
28
+ export { toUserDTO, zUserDTO };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@kuckit/contracts",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "main": "src/index.ts",
6
+ "types": "src/index.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./src/index.ts",
13
+ "default": "./src/index.ts"
14
+ },
15
+ "./*": {
16
+ "types": "./src/*.ts",
17
+ "default": "./src/*.ts"
18
+ }
19
+ },
20
+ "publishConfig": {
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ },
28
+ "./*": {
29
+ "types": "./dist/*.d.ts",
30
+ "default": "./dist/*.js"
31
+ }
32
+ }
33
+ },
34
+ "scripts": {
35
+ "build": "tsdown"
36
+ },
37
+ "dependencies": {
38
+ "zod": "catalog:"
39
+ },
40
+ "devDependencies": {
41
+ "tsdown": "catalog:"
42
+ },
43
+ "peerDependencies": {
44
+ "typescript": "^5"
45
+ }
46
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { zUserDTO, toUserDTO, type UserDTO } from './user'