@anakincodewalker/common 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.
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +66 -0
- package/dist/index.js.map +1 -0
- package/package.json +16 -0
- package/src/index.ts +93 -0
- package/tsconfig.json +44 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const signupInput: z.ZodObject<{
|
|
3
|
+
name: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type signupType = z.infer<typeof signupInput>;
|
|
6
|
+
export declare const signinInput: z.ZodObject<{
|
|
7
|
+
email: z.ZodString;
|
|
8
|
+
password: z.ZodString;
|
|
9
|
+
}, z.core.$strict>;
|
|
10
|
+
export type signinType = z.infer<typeof signinInput>;
|
|
11
|
+
export declare const createPostInput: z.ZodObject<{
|
|
12
|
+
title: z.ZodString;
|
|
13
|
+
content: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type createPostType = z.infer<typeof createPostInput>;
|
|
16
|
+
export declare const updatePostInput: z.ZodObject<{
|
|
17
|
+
title: z.ZodOptional<z.ZodString>;
|
|
18
|
+
content: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type updatePostType = z.infer<typeof updatePostInput>;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAO,WAAW;;iBAWvB,CAAC;AAIH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAIpD,eAAO,MAAM,WAAW;;;kBAwBb,CAAC;AAEV,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAKtD,eAAO,MAAM,eAAe;;;iBAY1B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;AAI5D,eAAO,MAAM,eAAe;;;iBAc1B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
console.log("hi");
|
|
3
|
+
export const signupInput = z.object({
|
|
4
|
+
name: z
|
|
5
|
+
.string()
|
|
6
|
+
.trim()
|
|
7
|
+
.min(3, { message: "Name must be at least 3 characters long" })
|
|
8
|
+
.max(30, { message: "Name must be at most 30 characters long" })
|
|
9
|
+
.regex(/^[a-zA-Z\s]+$/, {
|
|
10
|
+
message: "Name can only contain letters and spaces",
|
|
11
|
+
})
|
|
12
|
+
.optional(),
|
|
13
|
+
});
|
|
14
|
+
export const signinInput = z.object({
|
|
15
|
+
email: z
|
|
16
|
+
.string()
|
|
17
|
+
.trim()
|
|
18
|
+
.email({ message: "Invalid email address" }),
|
|
19
|
+
password: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(8, { message: "Password must be at least 8 characters long" })
|
|
22
|
+
.max(64, { message: "Password must be at most 64 characters long" })
|
|
23
|
+
.regex(/[A-Z]/, {
|
|
24
|
+
message: "Password must contain at least one uppercase letter",
|
|
25
|
+
})
|
|
26
|
+
.regex(/[a-z]/, {
|
|
27
|
+
message: "Password must contain at least one lowercase letter",
|
|
28
|
+
})
|
|
29
|
+
.regex(/[0-9]/, {
|
|
30
|
+
message: "Password must contain at least one number",
|
|
31
|
+
})
|
|
32
|
+
.regex(/[@$!%*?&#]/, {
|
|
33
|
+
message: "Password must contain at least one special character",
|
|
34
|
+
}),
|
|
35
|
+
})
|
|
36
|
+
.strict();
|
|
37
|
+
export const createPostInput = z.object({
|
|
38
|
+
title: z
|
|
39
|
+
.string()
|
|
40
|
+
.trim()
|
|
41
|
+
.min(1, { message: "Title cannot be empty" })
|
|
42
|
+
.max(120, { message: "Title cannot exceed 120 characters" }),
|
|
43
|
+
content: z
|
|
44
|
+
.string()
|
|
45
|
+
.trim()
|
|
46
|
+
.min(1, { message: "Content cannot be empty" })
|
|
47
|
+
.max(10_000, { message: "Content is too long" }),
|
|
48
|
+
});
|
|
49
|
+
export const updatePostInput = z.object({
|
|
50
|
+
title: z
|
|
51
|
+
.string()
|
|
52
|
+
.trim()
|
|
53
|
+
.min(1, { message: "Title cannot be empty" })
|
|
54
|
+
.max(120, { message: "Title cannot exceed 120 characters" })
|
|
55
|
+
.optional(),
|
|
56
|
+
content: z
|
|
57
|
+
.string()
|
|
58
|
+
.trim()
|
|
59
|
+
.min(1, { message: "Content cannot be empty" })
|
|
60
|
+
.max(10_000, { message: "Content is too long" })
|
|
61
|
+
.optional(),
|
|
62
|
+
});
|
|
63
|
+
// strict -- no thing extra allowed.
|
|
64
|
+
// passthorugh -- extra fields allowed.
|
|
65
|
+
//optional makes fields optional
|
|
66
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB,MAAM,CAAC,MAAO,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAEjC,IAAI,EAAE,CAAC;SACN,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;SAC9D,GAAG,CAAC,EAA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O,EAAE,qBAAqB,EAAE,CAAC;CACnD,CAAC,CAAC;AAMH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,CAAC;SACP,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,uBAAuB,EAAE,CAAC;SAC5C,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC;SAC3D,QAAQ,EAAE;IAEb,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,yBAAyB,EAAE,CAAC;SAC9C,GAAG,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAC;SAC/C,QAAQ,EAAE;CACd,CAAC,CAAC;AAKH,qCAAqC;AACrC,yCAAyC;AACzC,gCAAgC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@anakincodewalker/common",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [],
|
|
10
|
+
"author": "",
|
|
11
|
+
"license": "ISC",
|
|
12
|
+
"description": "",
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"zod": "^4.3.6"
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
export const signupInput = z.object({
|
|
4
|
+
|
|
5
|
+
name: z
|
|
6
|
+
.string()
|
|
7
|
+
.trim()
|
|
8
|
+
.min(3, { message: "Name must be at least 3 characters long" })
|
|
9
|
+
.max(30, { message: "Name must be at most 30 characters long" })
|
|
10
|
+
.regex(/^[a-zA-Z\s]+$/, {
|
|
11
|
+
message: "Name can only contain letters and spaces",
|
|
12
|
+
})
|
|
13
|
+
.optional(),
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// jo v signupInput ka type hai infer kro usko or signuptype mai daal do
|
|
17
|
+
// will update , accordingly agar schema mai change karoge to..
|
|
18
|
+
export type signupType = z.infer<typeof signupInput>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
export const signinInput = z.object({
|
|
23
|
+
|
|
24
|
+
email: z
|
|
25
|
+
.string()
|
|
26
|
+
.trim()
|
|
27
|
+
.email({ message: "Invalid email address" }),
|
|
28
|
+
|
|
29
|
+
password: z
|
|
30
|
+
.string()
|
|
31
|
+
.min(8, { message: "Password must be at least 8 characters long" })
|
|
32
|
+
.max(64, { message: "Password must be at most 64 characters long" })
|
|
33
|
+
.regex(/[A-Z]/, {
|
|
34
|
+
message: "Password must contain at least one uppercase letter",
|
|
35
|
+
})
|
|
36
|
+
.regex(/[a-z]/, {
|
|
37
|
+
message: "Password must contain at least one lowercase letter",
|
|
38
|
+
})
|
|
39
|
+
.regex(/[0-9]/, {
|
|
40
|
+
message: "Password must contain at least one number",
|
|
41
|
+
})
|
|
42
|
+
.regex(/[@$!%*?&#]/, {
|
|
43
|
+
message: "Password must contain at least one special character",
|
|
44
|
+
}),
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
47
|
+
|
|
48
|
+
export type signinType = z.infer<typeof signinInput>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
export const createPostInput = z.object({
|
|
54
|
+
title: z
|
|
55
|
+
.string()
|
|
56
|
+
.trim()
|
|
57
|
+
.min(1, { message: "Title cannot be empty" })
|
|
58
|
+
.max(120, { message: "Title cannot exceed 120 characters" }),
|
|
59
|
+
|
|
60
|
+
content: z
|
|
61
|
+
.string()
|
|
62
|
+
.trim()
|
|
63
|
+
.min(1, { message: "Content cannot be empty" })
|
|
64
|
+
.max(10_000, { message: "Content is too long" }),
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export type createPostType = z.infer<typeof createPostInput>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export const updatePostInput = z.object({
|
|
72
|
+
title: z
|
|
73
|
+
.string()
|
|
74
|
+
.trim()
|
|
75
|
+
.min(1, { message: "Title cannot be empty" })
|
|
76
|
+
.max(120, { message: "Title cannot exceed 120 characters" })
|
|
77
|
+
.optional(),
|
|
78
|
+
|
|
79
|
+
content: z
|
|
80
|
+
.string()
|
|
81
|
+
.trim()
|
|
82
|
+
.min(1, { message: "Content cannot be empty" })
|
|
83
|
+
.max(10_000, { message: "Content is too long" })
|
|
84
|
+
.optional(),
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export type updatePostType = z.infer<typeof updatePostInput>
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
// strict -- no thing extra allowed.
|
|
91
|
+
// passthorugh -- extra fields allowed.
|
|
92
|
+
//optional makes fields optional
|
|
93
|
+
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "nodenext",
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"types": [],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
// "noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"strict": true,
|
|
37
|
+
"jsx": "react-jsx",
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"isolatedModules": true,
|
|
40
|
+
"noUncheckedSideEffectImports": true,
|
|
41
|
+
"moduleDetection": "force",
|
|
42
|
+
"skipLibCheck": true,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["./src/index.ts"],"version":"5.9.3"}
|