@sakshi8624/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.
@@ -0,0 +1,23 @@
1
+ import z from 'zod';
2
+ export declare const signupSchema: z.ZodObject<{
3
+ username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4
+ password: z.ZodString;
5
+ name: z.ZodString;
6
+ }, z.z.core.$strip>;
7
+ export declare const signinSchema: z.ZodObject<{
8
+ username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
9
+ password: z.ZodString;
10
+ }, z.z.core.$strip>;
11
+ export declare const createBlogSchema: z.ZodObject<{
12
+ title: z.ZodString;
13
+ content: z.ZodString;
14
+ }, z.z.core.$strip>;
15
+ export declare const updateBlogSchema: z.ZodObject<{
16
+ title: z.ZodString;
17
+ content: z.ZodString;
18
+ }, z.z.core.$strip>;
19
+ export type SignupInput = z.infer<typeof signupSchema>;
20
+ export type SigninInput = z.infer<typeof signinSchema>;
21
+ export type CreateBlogInput = z.infer<typeof createBlogSchema>;
22
+ export type UpdateBlogSchema = z.infer<typeof updateBlogSchema>;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,eAAO,MAAM,YAAY;;;;mBA6BvB,CAAC;AAEH,eAAO,MAAM,YAAY;;;mBAUvB,CAAC;AAMH,eAAO,MAAM,gBAAgB;;;mBAG3B,CAAA;AAGF,eAAO,MAAM,gBAAgB;;;mBAG3B,CAAA;AAGF,MAAM,MAAM,WAAW,GAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA;AACpD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AACvD,MAAM,MAAM,eAAe,GAAC,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AAC5D,MAAM,MAAM,gBAAgB,GAAC,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,50 @@
1
+ import z from 'zod';
2
+ export const signupSchema = z.object({
3
+ username: z
4
+ .string({ error: "Username is required" })
5
+ .trim()
6
+ .min(3, { message: "Username must be at least 3 characters long" })
7
+ .max(20, { message: "Username cannot exceed 20 characters" })
8
+ .regex(/^[a-zA-Z0-9_]+$/, {
9
+ message: "Username can only contain letters, numbers, and underscores",
10
+ })
11
+ .transform((val) => val.toLowerCase()), // Automatically normalizes to lowercase
12
+ password: z
13
+ .string({ error: "Password is required" })
14
+ .min(8, { message: "Password must be at least 8 characters long" })
15
+ .max(100, { message: "Password is too long" })
16
+ // Security regex guarantees: 1 uppercase, 1 lowercase, 1 number, and 1 special char
17
+ .regex(/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/, {
18
+ message: "Password must include at least one uppercase letter, one lowercase letter, one number, and one special character",
19
+ }),
20
+ name: z
21
+ .string({ error: "Name is required" })
22
+ .trim()
23
+ .min(2, { message: "Name must be at least 2 characters long" })
24
+ .max(50, { message: "Name cannot exceed 50 characters" })
25
+ // Prevents code injections or random symbols, allowing spaces and hyphens for real names
26
+ .regex(/^[a-zA-Z\s\-']+$/, {
27
+ message: "Name can only contain letters, spaces, hyphens, or apostrophes",
28
+ }),
29
+ });
30
+ export const signinSchema = z.object({
31
+ username: z
32
+ .string({ error: "Username is required" })
33
+ .trim()
34
+ .min(1, { message: "Username cannot be empty" })
35
+ .transform((val) => val.toLowerCase()), // Keeps normalization consistent with signup
36
+ password: z
37
+ .string({ error: "Password is required" })
38
+ .min(1, { message: "Password cannot be empty" }),
39
+ });
40
+ //type inference in zod... good for frontend to figure out the types
41
+ //but should be in another module-common
42
+ export const createBlogSchema = z.object({
43
+ title: z.string().min(1, { message: "title is required" }).max(50, { message: "title is too long" }),
44
+ content: z.string().min(1, { message: "content is required" }).max(500, { message: "content is too long" })
45
+ });
46
+ export const updateBlogSchema = z.object({
47
+ title: z.string().min(1, { message: "title is required" }).max(50, { message: "title is too long" }),
48
+ content: z.string().min(1, { message: "content is required" }).max(500, { message: "content is too long" })
49
+ });
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAC;AAEpB,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IACnC,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;SACzC,IAAI,EAAE;SACN,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,6CAA6C,EAAE,CAAC;SAClE,GAAG,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;SAC5D,KAAK,CAAC,iBAAiB,EAAE;QACxB,OAAO,EAAE,6DAA6D;KACvE,CAAC;SACD,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,wCAAwC;IAElF,QAAQ,EAAE,CAAC;SACR,MAAM,CAAC,EAAE,KAAK,EAAE,sBAAsB,EAAE,CAAC;SACzC,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,6CAA6C,EAAE,CAAC;SAClE,GAAG,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAAC;QAC9C,oFAAoF;SACnF,KAAK,CAAC,sEAAsE,EAAE;QAC7E,OAAO,EAAE,kHAAkH;KAC5H,CAAC;IAEJ,IAAI,EAAE,CAAC;SACJ,MAAM,CAAC,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;SACrC,IAAI,EAAE;SACN,GAAG,CA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AAC,MAAM,CAAC;IACrC,KAAK,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAC,EAAC,OAAO,EAAC,mBAAmB,EAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAC,EAAC,OAAO,EAAC,mBAAmB,EAAC,CAAC;IAC3F,OAAO,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAC,EAAC,OAAO,EAAC,qBAAqB,EAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAC,EAAC,OAAO,EAAC,qBAAqB,EAAC,CAAC;CACnG,CAAC,CAAA"}
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@sakshi8624/common",
3
+ "version": "1.0.0",
4
+ "main": "dist/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.4.3"
15
+ }
16
+ }
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.2"}