udp-schema 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 +30 -0
- package/dist/helpers.d.ts +17 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +22 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/step-01.schema.d.ts +108 -0
- package/dist/step-01.schema.d.ts.map +1 -0
- package/dist/step-01.schema.js +102 -0
- package/dist/step-01.schema.js.map +1 -0
- package/dist/step-02.schema.d.ts +28 -0
- package/dist/step-02.schema.d.ts.map +1 -0
- package/dist/step-02.schema.js +33 -0
- package/dist/step-02.schema.js.map +1 -0
- package/dist/step-03.schema.d.ts +262 -0
- package/dist/step-03.schema.d.ts.map +1 -0
- package/dist/step-03.schema.js +66 -0
- package/dist/step-03.schema.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# udp-schema
|
|
2
|
+
|
|
3
|
+
Shared Zod validation schemas for the **User Detailed Profile** feature.
|
|
4
|
+
|
|
5
|
+
Used by both `survey-frontend` and `survey-backend` so that field names,
|
|
6
|
+
validation rules, and inferred TypeScript types are always in sync.
|
|
7
|
+
|
|
8
|
+
## Schemas
|
|
9
|
+
|
|
10
|
+
| Export | Description |
|
|
11
|
+
|--------|-------------|
|
|
12
|
+
| `step01OnboardingSchema` | Step 1 – profile, photo, languages, Aadhaar |
|
|
13
|
+
| `step02ContactDetailsSchema` | Step 2 – WhatsApp, social media, emergency contact |
|
|
14
|
+
| `step03ResidenceSchema` | Step 3 – domicile, current & permanent address |
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { step01OnboardingSchema, type Step01OnboardingInput } from 'udp-schema';
|
|
20
|
+
|
|
21
|
+
const parsed = step01OnboardingSchema.parse(reqBody);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Development
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install
|
|
28
|
+
npm run build # compiles to dist/
|
|
29
|
+
npm run type-check
|
|
30
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper utilities for Zod schema preprocessing.
|
|
3
|
+
*
|
|
4
|
+
* @module udp-schema/helpers
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Converts empty / whitespace-only strings to `undefined`
|
|
9
|
+
* so Zod `.optional()` treats them as "not provided".
|
|
10
|
+
*/
|
|
11
|
+
export declare const emptyStringToUndefined: (value: unknown) => unknown;
|
|
12
|
+
/**
|
|
13
|
+
* Optional trimmed string with 100-char max.
|
|
14
|
+
* Empty strings are coerced to `undefined`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const optionalTrimmedString: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
17
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,OAAO,OAAO,KAAG,OAKvD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,yEAGjC,CAAC"}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared helper utilities for Zod schema preprocessing.
|
|
3
|
+
*
|
|
4
|
+
* @module udp-schema/helpers
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
/**
|
|
8
|
+
* Converts empty / whitespace-only strings to `undefined`
|
|
9
|
+
* so Zod `.optional()` treats them as "not provided".
|
|
10
|
+
*/
|
|
11
|
+
export const emptyStringToUndefined = (value) => {
|
|
12
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Optional trimmed string with 100-char max.
|
|
19
|
+
* Empty strings are coerced to `undefined`.
|
|
20
|
+
*/
|
|
21
|
+
export const optionalTrimmedString = z.preprocess(emptyStringToUndefined, z.string().trim().max(100).optional());
|
|
22
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAc,EAAW,EAAE;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,UAAU,CAC/C,sBAAsB,EACtB,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CACtC,CAAC","sourcesContent":["/**\n * Shared helper utilities for Zod schema preprocessing.\n *\n * @module udp-schema/helpers\n */\n\nimport { z } from 'zod';\n\n/**\n * Converts empty / whitespace-only strings to `undefined`\n * so Zod `.optional()` treats them as \"not provided\".\n */\nexport const emptyStringToUndefined = (value: unknown): unknown => {\n if (typeof value === 'string' && value.trim() === '') {\n return undefined;\n }\n return value;\n};\n\n/**\n * Optional trimmed string with 100-char max.\n * Empty strings are coerced to `undefined`.\n */\nexport const optionalTrimmedString = z.preprocess(\n emptyStringToUndefined,\n z.string().trim().max(100).optional(),\n);\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* udp-schema — Shared Zod schemas for User Detailed Profile
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth consumed by both survey-frontend and survey-backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema
|
|
7
|
+
*/
|
|
8
|
+
export { emptyStringToUndefined, optionalTrimmedString } from './helpers.js';
|
|
9
|
+
export { assistedBySurveyorSchema, languageValueSchema, profilePhotoSchema, type Step01OnboardingFormInput, type Step01OnboardingInput, secondaryLanguageItemSchema, step01OnboardingSchema, } from './step-01.schema.js';
|
|
10
|
+
export { optionalUrlSchema, type Step02ContactDetailsInput, step02ContactDetailsSchema, } from './step-02.schema.js';
|
|
11
|
+
export { type AddressInput, addressSchema, areaRefSchema, type Step03ResidenceInput, step03ResidenceSchema, } from './step-03.schema.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,iBAAiB,EACjB,KAAK,yBAAyB,EAC9B,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EACL,KAAK,YAAY,EACjB,aAAa,EACb,aAAa,EACb,KAAK,oBAAoB,EACzB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* udp-schema — Shared Zod schemas for User Detailed Profile
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth consumed by both survey-frontend and survey-backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema
|
|
7
|
+
*/
|
|
8
|
+
// Helpers
|
|
9
|
+
export { emptyStringToUndefined, optionalTrimmedString } from './helpers.js';
|
|
10
|
+
// Step 01 — Profile Onboarding
|
|
11
|
+
export { assistedBySurveyorSchema, languageValueSchema, profilePhotoSchema, secondaryLanguageItemSchema, step01OnboardingSchema, } from './step-01.schema.js';
|
|
12
|
+
// Step 02 — Contact Details
|
|
13
|
+
export { optionalUrlSchema, step02ContactDetailsSchema, } from './step-02.schema.js';
|
|
14
|
+
// Step 03 — Residence / Address
|
|
15
|
+
export { addressSchema, areaRefSchema, step03ResidenceSchema, } from './step-03.schema.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,UAAU;AACV,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE7E,+BAA+B;AAC/B,OAAO,EACL,wBAAwB,EACxB,mBAAmB,EACnB,kBAAkB,EAGlB,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,4BAA4B;AAC5B,OAAO,EACL,iBAAiB,EAEjB,0BAA0B,GAC3B,MAAM,qBAAqB,CAAC;AAE7B,gCAAgC;AAChC,OAAO,EAEL,aAAa,EACb,aAAa,EAEb,qBAAqB,GACtB,MAAM,qBAAqB,CAAC","sourcesContent":["/**\n * udp-schema — Shared Zod schemas for User Detailed Profile\n *\n * Single source of truth consumed by both survey-frontend and survey-backend.\n *\n * @module udp-schema\n */\n\n// Helpers\nexport { emptyStringToUndefined, optionalTrimmedString } from './helpers.js';\n\n// Step 01 — Profile Onboarding\nexport {\n assistedBySurveyorSchema,\n languageValueSchema,\n profilePhotoSchema,\n type Step01OnboardingFormInput,\n type Step01OnboardingInput,\n secondaryLanguageItemSchema,\n step01OnboardingSchema,\n} from './step-01.schema.js';\n\n// Step 02 — Contact Details\nexport {\n optionalUrlSchema,\n type Step02ContactDetailsInput,\n step02ContactDetailsSchema,\n} from './step-02.schema.js';\n\n// Step 03 — Residence / Address\nexport {\n type AddressInput,\n addressSchema,\n areaRefSchema,\n type Step03ResidenceInput,\n step03ResidenceSchema,\n} from './step-03.schema.js';\n"]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 01 — Profile Onboarding Schema
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth used by both frontend and backend.
|
|
5
|
+
* Field names match the MongoDB document keys exactly.
|
|
6
|
+
*
|
|
7
|
+
* @module udp-schema/step-01
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/** Language value (code / nativeName / englishName / script). */
|
|
11
|
+
export declare const languageValueSchema: z.ZodObject<{
|
|
12
|
+
code: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
13
|
+
nativeName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
14
|
+
englishName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
15
|
+
script: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
/** One entry in the secondaryLanguages array. */
|
|
18
|
+
export declare const secondaryLanguageItemSchema: z.ZodObject<{
|
|
19
|
+
language: z.ZodObject<{
|
|
20
|
+
code: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
21
|
+
nativeName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
22
|
+
englishName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
23
|
+
script: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
fluency: z.ZodEnum<{
|
|
26
|
+
basic: "basic";
|
|
27
|
+
conversational: "conversational";
|
|
28
|
+
professional: "professional";
|
|
29
|
+
native: "native";
|
|
30
|
+
}>;
|
|
31
|
+
canSpeak: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
canRead: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
canWrite: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
/**
|
|
36
|
+
* Profile photo — accepts either:
|
|
37
|
+
* • a plain URL string (returned by backend on prefill)
|
|
38
|
+
* • an upload-result object (sent after fresh upload)
|
|
39
|
+
*/
|
|
40
|
+
export declare const profilePhotoSchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
41
|
+
assetId: z.ZodOptional<z.ZodString>;
|
|
42
|
+
url: z.ZodOptional<z.ZodString>;
|
|
43
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
44
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strip>]>>;
|
|
46
|
+
/** Surveyor who assisted with the form. */
|
|
47
|
+
export declare const assistedBySurveyorSchema: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
surveyorId: z.ZodOptional<z.ZodString>;
|
|
49
|
+
displayName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
50
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
selected: "selected";
|
|
52
|
+
manual: "manual";
|
|
53
|
+
}>>;
|
|
54
|
+
}, z.core.$strip>>;
|
|
55
|
+
export declare const step01OnboardingSchema: z.ZodObject<{
|
|
56
|
+
email: z.ZodString;
|
|
57
|
+
firstName: z.ZodString;
|
|
58
|
+
middleName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
59
|
+
lastName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
60
|
+
gender: z.ZodOptional<z.ZodEnum<{
|
|
61
|
+
male: "male";
|
|
62
|
+
female: "female";
|
|
63
|
+
other: "other";
|
|
64
|
+
prefer_not: "prefer_not";
|
|
65
|
+
}>>;
|
|
66
|
+
dateOfBirth: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodCoercedDate<unknown>>>;
|
|
67
|
+
aadhaarNumber: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
68
|
+
profilePhotoUrl: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
69
|
+
assetId: z.ZodOptional<z.ZodString>;
|
|
70
|
+
url: z.ZodOptional<z.ZodString>;
|
|
71
|
+
mimeType: z.ZodOptional<z.ZodString>;
|
|
72
|
+
sizeBytes: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, z.core.$strip>]>>;
|
|
74
|
+
assistedBySurveyor: z.ZodOptional<z.ZodObject<{
|
|
75
|
+
surveyorId: z.ZodOptional<z.ZodString>;
|
|
76
|
+
displayName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
77
|
+
source: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
selected: "selected";
|
|
79
|
+
manual: "manual";
|
|
80
|
+
}>>;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
primaryLanguage: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
code: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
84
|
+
nativeName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
85
|
+
englishName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
86
|
+
script: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
secondaryLanguages: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
89
|
+
language: z.ZodObject<{
|
|
90
|
+
code: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
91
|
+
nativeName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
92
|
+
englishName: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
93
|
+
script: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodOptional<z.ZodString>>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
fluency: z.ZodEnum<{
|
|
96
|
+
basic: "basic";
|
|
97
|
+
conversational: "conversational";
|
|
98
|
+
professional: "professional";
|
|
99
|
+
native: "native";
|
|
100
|
+
}>;
|
|
101
|
+
canSpeak: z.ZodOptional<z.ZodBoolean>;
|
|
102
|
+
canRead: z.ZodOptional<z.ZodBoolean>;
|
|
103
|
+
canWrite: z.ZodOptional<z.ZodBoolean>;
|
|
104
|
+
}, z.core.$strip>>>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
export type Step01OnboardingInput = z.infer<typeof step01OnboardingSchema>;
|
|
107
|
+
export type Step01OnboardingFormInput = z.input<typeof step01OnboardingSchema>;
|
|
108
|
+
//# sourceMappingURL=step-01.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-01.schema.d.ts","sourceRoot":"","sources":["../src/step-01.schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,iEAAiE;AACjE,eAAO,MAAM,mBAAmB;;;;;iBAU7B,CAAC;AAEJ,iDAAiD;AACjD,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;iBAMtC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;;oBAUlB,CAAC;AAEd,2CAA2C;AAC3C,eAAO,MAAM,wBAAwB;;;;;;;kBAMxB,CAAC;AAId,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAgDjC,CAAC;AAIH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC3E,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 01 — Profile Onboarding Schema
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth used by both frontend and backend.
|
|
5
|
+
* Field names match the MongoDB document keys exactly.
|
|
6
|
+
*
|
|
7
|
+
* @module udp-schema/step-01
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { emptyStringToUndefined, optionalTrimmedString } from './helpers.js';
|
|
11
|
+
// ─── Sub-schemas ────────────────────────────────────────
|
|
12
|
+
/** Language value (code / nativeName / englishName / script). */
|
|
13
|
+
export const languageValueSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
code: optionalTrimmedString,
|
|
16
|
+
nativeName: optionalTrimmedString,
|
|
17
|
+
englishName: optionalTrimmedString,
|
|
18
|
+
script: optionalTrimmedString,
|
|
19
|
+
})
|
|
20
|
+
.refine((v) => Boolean(v.code || v.nativeName || v.englishName), 'Language must include at least code, native name, or english name');
|
|
21
|
+
/** One entry in the secondaryLanguages array. */
|
|
22
|
+
export const secondaryLanguageItemSchema = z.object({
|
|
23
|
+
language: languageValueSchema,
|
|
24
|
+
fluency: z.enum(['basic', 'conversational', 'professional', 'native']),
|
|
25
|
+
canSpeak: z.boolean().optional(),
|
|
26
|
+
canRead: z.boolean().optional(),
|
|
27
|
+
canWrite: z.boolean().optional(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Profile photo — accepts either:
|
|
31
|
+
* • a plain URL string (returned by backend on prefill)
|
|
32
|
+
* • an upload-result object (sent after fresh upload)
|
|
33
|
+
*/
|
|
34
|
+
export const profilePhotoSchema = z
|
|
35
|
+
.union([
|
|
36
|
+
z.string(),
|
|
37
|
+
z.object({
|
|
38
|
+
assetId: z.string().trim().optional(),
|
|
39
|
+
url: z.string().trim().optional(),
|
|
40
|
+
mimeType: z.string().trim().optional(),
|
|
41
|
+
sizeBytes: z.number().min(0).optional(),
|
|
42
|
+
}),
|
|
43
|
+
])
|
|
44
|
+
.optional();
|
|
45
|
+
/** Surveyor who assisted with the form. */
|
|
46
|
+
export const assistedBySurveyorSchema = z
|
|
47
|
+
.object({
|
|
48
|
+
surveyorId: z.string().optional(),
|
|
49
|
+
displayName: optionalTrimmedString,
|
|
50
|
+
source: z.enum(['selected', 'manual']).optional(),
|
|
51
|
+
})
|
|
52
|
+
.optional();
|
|
53
|
+
// ─── Main step-01 schema ────────────────────────────────
|
|
54
|
+
export const step01OnboardingSchema = z.object({
|
|
55
|
+
email: z.string().trim().toLowerCase().email('Enter a valid email address'),
|
|
56
|
+
firstName: z
|
|
57
|
+
.string()
|
|
58
|
+
.trim()
|
|
59
|
+
.min(1, 'First name is required')
|
|
60
|
+
.max(50, 'First name must be at most 50 characters'),
|
|
61
|
+
middleName: optionalTrimmedString,
|
|
62
|
+
lastName: optionalTrimmedString,
|
|
63
|
+
gender: z.enum(['male', 'female', 'other', 'prefer_not']).optional(),
|
|
64
|
+
dateOfBirth: z.preprocess(emptyStringToUndefined, z.coerce.date().optional()),
|
|
65
|
+
aadhaarNumber: z.preprocess((value) => {
|
|
66
|
+
const normalized = emptyStringToUndefined(value);
|
|
67
|
+
if (typeof normalized === 'string') {
|
|
68
|
+
return normalized.replace(/\D/g, '');
|
|
69
|
+
}
|
|
70
|
+
return normalized;
|
|
71
|
+
}, z
|
|
72
|
+
.string()
|
|
73
|
+
.regex(/^\d{12}$/, 'Aadhaar must be exactly 12 digits')
|
|
74
|
+
.optional()),
|
|
75
|
+
profilePhotoUrl: profilePhotoSchema,
|
|
76
|
+
assistedBySurveyor: assistedBySurveyorSchema,
|
|
77
|
+
primaryLanguage: languageValueSchema.optional(),
|
|
78
|
+
secondaryLanguages: z
|
|
79
|
+
.array(secondaryLanguageItemSchema)
|
|
80
|
+
.max(5, 'You can add up to 5 secondary languages')
|
|
81
|
+
.optional()
|
|
82
|
+
.superRefine((items, context) => {
|
|
83
|
+
if (!items)
|
|
84
|
+
return;
|
|
85
|
+
const seenCodes = new Map();
|
|
86
|
+
items.forEach((item, index) => {
|
|
87
|
+
const code = item.language.code?.toLowerCase();
|
|
88
|
+
if (!code)
|
|
89
|
+
return;
|
|
90
|
+
if (seenCodes.has(code)) {
|
|
91
|
+
context.addIssue({
|
|
92
|
+
code: 'custom',
|
|
93
|
+
path: [index, 'language', 'code'],
|
|
94
|
+
message: 'Duplicate secondary language is not allowed',
|
|
95
|
+
});
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
seenCodes.set(code, index);
|
|
99
|
+
});
|
|
100
|
+
}),
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=step-01.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-01.schema.js","sourceRoot":"","sources":["../src/step-01.schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAE7E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QACvC,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC,EACD,CAAC;SACE,MAAM,EAAE;SACR,KAAK,CAAC,UAAU,EAAE,mCAAmC,CAAC;SACtD,QAAQ,EAAE,CACd;IACD,eAAe,EAAE,kBAAkB;IACnC,kBAAkB,EAAE,wBAAwB;IAC5C,eAAe,EAAE,mBAAmB,CAAC,QAAQ,EAAE;IAC/C,kBAAkB,EAAE,CAAC;SAClB,KAAK,CAAC,2BAA2B,CAAC;SAClC,GAAG,CAAC,CAAC,EAAE,yCAAyC,CAAC;SACjD,QAAQ,EAAE;SACV,WAAW,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;QAC9B,IAAI,CAAC,KAAK;YAAE,OAAO;QACnB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC;YAC/C,IAAI,CAAC,IAAI;gBAAE,OAAO;YAClB,IAAI,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACxB,OAAO,CAAC,QAAQ,CAAC;oBACf,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,CAAC;oBACjC,OAAO,EAAE,6CAA6C;iBACvD,CAAC,CAAC;gBACH,OAAO;YACT,CAAC;YACD,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;CACL,CAAC,CAAC","sourcesContent":["/**\n * Step 01 — Profile Onboarding Schema\n *\n * Single source of truth used by both frontend and backend.\n * Field names match the MongoDB document keys exactly.\n *\n * @module udp-schema/step-01\n */\n\nimport { z } from 'zod';\nimport { emptyStringToUndefined, optionalTrimmedString } from './helpers.js';\n\n// ─── Sub-schemas ────────────────────────────────────────\n\n/** Language value (code / nativeName / englishName / script). */\nexport const languageValueSchema = z\n .object({\n code: optionalTrimmedString,\n nativeName: optionalTrimmedString,\n englishName: optionalTrimmedString,\n script: optionalTrimmedString,\n })\n .refine(\n (v) => Boolean(v.code || v.nativeName || v.englishName),\n 'Language must include at least code, native name, or english name',\n );\n\n/** One entry in the secondaryLanguages array. */\nexport const secondaryLanguageItemSchema = z.object({\n language: languageValueSchema,\n fluency: z.enum(['basic', 'conversational', 'professional', 'native']),\n canSpeak: z.boolean().optional(),\n canRead: z.boolean().optional(),\n canWrite: z.boolean().optional(),\n});\n\n/**\n * Profile photo — accepts either:\n * • a plain URL string (returned by backend on prefill)\n * • an upload-result object (sent after fresh upload)\n */\nexport const profilePhotoSchema = z\n .union([\n z.string(),\n z.object({\n assetId: z.string().trim().optional(),\n url: z.string().trim().optional(),\n mimeType: z.string().trim().optional(),\n sizeBytes: z.number().min(0).optional(),\n }),\n ])\n .optional();\n\n/** Surveyor who assisted with the form. */\nexport const assistedBySurveyorSchema = z\n .object({\n surveyorId: z.string().optional(),\n displayName: optionalTrimmedString,\n source: z.enum(['selected', 'manual']).optional(),\n })\n .optional();\n\n// ─── Main step-01 schema ────────────────────────────────\n\nexport const step01OnboardingSchema = z.object({\n email: z.string().trim().toLowerCase().email('Enter a valid email address'),\n firstName: z\n .string()\n .trim()\n .min(1, 'First name is required')\n .max(50, 'First name must be at most 50 characters'),\n middleName: optionalTrimmedString,\n lastName: optionalTrimmedString,\n gender: z.enum(['male', 'female', 'other', 'prefer_not']).optional(),\n dateOfBirth: z.preprocess(emptyStringToUndefined, z.coerce.date().optional()),\n aadhaarNumber: z.preprocess(\n (value) => {\n const normalized = emptyStringToUndefined(value);\n if (typeof normalized === 'string') {\n return normalized.replace(/\\D/g, '');\n }\n return normalized;\n },\n z\n .string()\n .regex(/^\\d{12}$/, 'Aadhaar must be exactly 12 digits')\n .optional(),\n ),\n profilePhotoUrl: profilePhotoSchema,\n assistedBySurveyor: assistedBySurveyorSchema,\n primaryLanguage: languageValueSchema.optional(),\n secondaryLanguages: z\n .array(secondaryLanguageItemSchema)\n .max(5, 'You can add up to 5 secondary languages')\n .optional()\n .superRefine((items, context) => {\n if (!items) return;\n const seenCodes = new Map<string, number>();\n items.forEach((item, index) => {\n const code = item.language.code?.toLowerCase();\n if (!code) return;\n if (seenCodes.has(code)) {\n context.addIssue({\n code: 'custom',\n path: [index, 'language', 'code'],\n message: 'Duplicate secondary language is not allowed',\n });\n return;\n }\n seenCodes.set(code, index);\n });\n }),\n});\n\n// ─── Inferred types ─────────────────────────────────────\n\nexport type Step01OnboardingInput = z.infer<typeof step01OnboardingSchema>;\nexport type Step01OnboardingFormInput = z.input<typeof step01OnboardingSchema>;\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 02 — Contact Details Schema
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth used by both frontend and backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema/step-02
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
/** Accepts a valid URL, an empty string, or undefined. */
|
|
10
|
+
export declare const optionalUrlSchema: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">, z.ZodUndefined]>;
|
|
11
|
+
export declare const step02ContactDetailsSchema: z.ZodObject<{
|
|
12
|
+
whatsappSameAsPrimary: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
+
whatsappNumber: z.ZodOptional<z.ZodString>;
|
|
14
|
+
socialMedia: z.ZodObject<{
|
|
15
|
+
facebook: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">, z.ZodUndefined]>;
|
|
16
|
+
twitter: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">, z.ZodUndefined]>;
|
|
17
|
+
instagram: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">, z.ZodUndefined]>;
|
|
18
|
+
linkedin: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">, z.ZodUndefined]>;
|
|
19
|
+
youtube: z.ZodUnion<readonly [z.ZodString, z.ZodLiteral<"">, z.ZodUndefined]>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
emergencyContact: z.ZodObject<{
|
|
22
|
+
contactName: z.ZodOptional<z.ZodString>;
|
|
23
|
+
contactRelation: z.ZodOptional<z.ZodString>;
|
|
24
|
+
contactPhone: z.ZodOptional<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type Step02ContactDetailsInput = z.infer<typeof step02ContactDetailsSchema>;
|
|
28
|
+
//# sourceMappingURL=step-02.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-02.schema.d.ts","sourceRoot":"","sources":["../src/step-02.schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,sEAI5B,CAAC;AAIH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;iBAerC,CAAC;AAIH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 02 — Contact Details Schema
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth used by both frontend and backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema/step-02
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
// ─── Sub-schemas ────────────────────────────────────────
|
|
10
|
+
/** Accepts a valid URL, an empty string, or undefined. */
|
|
11
|
+
export const optionalUrlSchema = z.union([
|
|
12
|
+
z.string().url('Enter a valid URL'),
|
|
13
|
+
z.literal(''),
|
|
14
|
+
z.undefined(),
|
|
15
|
+
]);
|
|
16
|
+
// ─── Main step-02 schema ────────────────────────────────
|
|
17
|
+
export const step02ContactDetailsSchema = z.object({
|
|
18
|
+
whatsappSameAsPrimary: z.boolean().optional(),
|
|
19
|
+
whatsappNumber: z.string().trim().optional(),
|
|
20
|
+
socialMedia: z.object({
|
|
21
|
+
facebook: optionalUrlSchema,
|
|
22
|
+
twitter: optionalUrlSchema,
|
|
23
|
+
instagram: optionalUrlSchema,
|
|
24
|
+
linkedin: optionalUrlSchema,
|
|
25
|
+
youtube: optionalUrlSchema,
|
|
26
|
+
}),
|
|
27
|
+
emergencyContact: z.object({
|
|
28
|
+
contactName: z.string().trim().optional(),
|
|
29
|
+
contactRelation: z.string().trim().optional(),
|
|
30
|
+
contactPhone: z.string().trim().optional(),
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=step-02.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-02.schema.js","sourceRoot":"","sources":["../src/step-02.schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,2DAA2D;AAE3D,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC;IACvC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACnC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACb,CAAC,CAAC,SAAS,EAAE;CACd,CAAC,CAAC;AAEH,2DAA2D;AAE3D,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAAC;IACjD,qBAAqB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC7C,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,QAAQ,EAAE,iBAAiB;QAC3B,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,iBAAiB;QAC5B,QAAQ,EAAE,iBAAiB;QAC3B,OAAO,EAAE,iBAAiB;KAC3B,CAAC;IACF,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC;QACzB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;QACzC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;QAC7C,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;KAC3C,CAAC;CACH,CAAC,CAAC","sourcesContent":["/**\n * Step 02 — Contact Details Schema\n *\n * Single source of truth used by both frontend and backend.\n *\n * @module udp-schema/step-02\n */\n\nimport { z } from 'zod';\n\n// ─── Sub-schemas ────────────────────────────────────────\n\n/** Accepts a valid URL, an empty string, or undefined. */\nexport const optionalUrlSchema = z.union([\n z.string().url('Enter a valid URL'),\n z.literal(''),\n z.undefined(),\n]);\n\n// ─── Main step-02 schema ────────────────────────────────\n\nexport const step02ContactDetailsSchema = z.object({\n whatsappSameAsPrimary: z.boolean().optional(),\n whatsappNumber: z.string().trim().optional(),\n socialMedia: z.object({\n facebook: optionalUrlSchema,\n twitter: optionalUrlSchema,\n instagram: optionalUrlSchema,\n linkedin: optionalUrlSchema,\n youtube: optionalUrlSchema,\n }),\n emergencyContact: z.object({\n contactName: z.string().trim().optional(),\n contactRelation: z.string().trim().optional(),\n contactPhone: z.string().trim().optional(),\n }),\n});\n\n// ─── Inferred types ─────────────────────────────────────\n\nexport type Step02ContactDetailsInput = z.infer<typeof step02ContactDetailsSchema>;\n"]}
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 03 — Residence / Address Schema
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth used by both frontend and backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema/step-03
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
/**
|
|
10
|
+
* Area entity reference — accepts:
|
|
11
|
+
* • `{ _id, name }` — existing area entity selected in frontend
|
|
12
|
+
* • `{ name }` — custom / manually entered
|
|
13
|
+
* • raw string — legacy ObjectId stored in DB
|
|
14
|
+
*/
|
|
15
|
+
export declare const areaRefSchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
16
|
+
_id: z.ZodString;
|
|
17
|
+
name: z.ZodString;
|
|
18
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
21
|
+
/** Full address block (current or permanent). */
|
|
22
|
+
export declare const addressSchema: z.ZodObject<{
|
|
23
|
+
country: z.ZodOptional<z.ZodString>;
|
|
24
|
+
state: z.ZodOptional<z.ZodString>;
|
|
25
|
+
areaType: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
RURAL: "RURAL";
|
|
27
|
+
URBAN: "URBAN";
|
|
28
|
+
}>>;
|
|
29
|
+
division: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
30
|
+
_id: z.ZodString;
|
|
31
|
+
name: z.ZodString;
|
|
32
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
35
|
+
district: z.ZodOptional<z.ZodString>;
|
|
36
|
+
tehsil: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
37
|
+
_id: z.ZodString;
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
40
|
+
name: z.ZodString;
|
|
41
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
42
|
+
block: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
43
|
+
_id: z.ZodString;
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
48
|
+
gramPanchayat: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
49
|
+
_id: z.ZodString;
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
52
|
+
name: z.ZodString;
|
|
53
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
54
|
+
village: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
55
|
+
_id: z.ZodString;
|
|
56
|
+
name: z.ZodString;
|
|
57
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
60
|
+
hamlet: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
61
|
+
_id: z.ZodString;
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
64
|
+
name: z.ZodString;
|
|
65
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
66
|
+
ruralWard: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
67
|
+
_id: z.ZodString;
|
|
68
|
+
name: z.ZodString;
|
|
69
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
72
|
+
urbanBody: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
73
|
+
_id: z.ZodString;
|
|
74
|
+
name: z.ZodString;
|
|
75
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
78
|
+
urbanWard: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
79
|
+
_id: z.ZodString;
|
|
80
|
+
name: z.ZodString;
|
|
81
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
82
|
+
name: z.ZodString;
|
|
83
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
84
|
+
locality: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
85
|
+
_id: z.ZodString;
|
|
86
|
+
name: z.ZodString;
|
|
87
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
90
|
+
housePlotDetails: z.ZodOptional<z.ZodString>;
|
|
91
|
+
pincode: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
92
|
+
landmark: z.ZodOptional<z.ZodString>;
|
|
93
|
+
directions: z.ZodOptional<z.ZodString>;
|
|
94
|
+
latitude: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
95
|
+
longitude: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
export declare const step03ResidenceSchema: z.ZodObject<{
|
|
98
|
+
domicileSource: z.ZodOptional<z.ZodEnum<{
|
|
99
|
+
BIRTH_PLACE: "BIRTH_PLACE";
|
|
100
|
+
HOME_NATIVE_PLACE: "HOME_NATIVE_PLACE";
|
|
101
|
+
ANCESTRAL_NATIVE_PLACE: "ANCESTRAL_NATIVE_PLACE";
|
|
102
|
+
}>>;
|
|
103
|
+
birthPlace: z.ZodOptional<z.ZodString>;
|
|
104
|
+
homeNativePlace: z.ZodOptional<z.ZodString>;
|
|
105
|
+
ancestralNativePlace: z.ZodOptional<z.ZodString>;
|
|
106
|
+
yearsAtCurrentAddress: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
107
|
+
sameAsCurrentAddress: z.ZodOptional<z.ZodBoolean>;
|
|
108
|
+
currentAddress: z.ZodObject<{
|
|
109
|
+
country: z.ZodOptional<z.ZodString>;
|
|
110
|
+
state: z.ZodOptional<z.ZodString>;
|
|
111
|
+
areaType: z.ZodOptional<z.ZodEnum<{
|
|
112
|
+
RURAL: "RURAL";
|
|
113
|
+
URBAN: "URBAN";
|
|
114
|
+
}>>;
|
|
115
|
+
division: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
116
|
+
_id: z.ZodString;
|
|
117
|
+
name: z.ZodString;
|
|
118
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
119
|
+
name: z.ZodString;
|
|
120
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
121
|
+
district: z.ZodOptional<z.ZodString>;
|
|
122
|
+
tehsil: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
123
|
+
_id: z.ZodString;
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
126
|
+
name: z.ZodString;
|
|
127
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
128
|
+
block: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
129
|
+
_id: z.ZodString;
|
|
130
|
+
name: z.ZodString;
|
|
131
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
132
|
+
name: z.ZodString;
|
|
133
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
134
|
+
gramPanchayat: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
135
|
+
_id: z.ZodString;
|
|
136
|
+
name: z.ZodString;
|
|
137
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
138
|
+
name: z.ZodString;
|
|
139
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
140
|
+
village: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
141
|
+
_id: z.ZodString;
|
|
142
|
+
name: z.ZodString;
|
|
143
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
144
|
+
name: z.ZodString;
|
|
145
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
146
|
+
hamlet: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
147
|
+
_id: z.ZodString;
|
|
148
|
+
name: z.ZodString;
|
|
149
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
150
|
+
name: z.ZodString;
|
|
151
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
152
|
+
ruralWard: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
153
|
+
_id: z.ZodString;
|
|
154
|
+
name: z.ZodString;
|
|
155
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
156
|
+
name: z.ZodString;
|
|
157
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
158
|
+
urbanBody: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
159
|
+
_id: z.ZodString;
|
|
160
|
+
name: z.ZodString;
|
|
161
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
162
|
+
name: z.ZodString;
|
|
163
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
164
|
+
urbanWard: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
165
|
+
_id: z.ZodString;
|
|
166
|
+
name: z.ZodString;
|
|
167
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
168
|
+
name: z.ZodString;
|
|
169
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
170
|
+
locality: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
171
|
+
_id: z.ZodString;
|
|
172
|
+
name: z.ZodString;
|
|
173
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
174
|
+
name: z.ZodString;
|
|
175
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
176
|
+
housePlotDetails: z.ZodOptional<z.ZodString>;
|
|
177
|
+
pincode: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
178
|
+
landmark: z.ZodOptional<z.ZodString>;
|
|
179
|
+
directions: z.ZodOptional<z.ZodString>;
|
|
180
|
+
latitude: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
181
|
+
longitude: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
182
|
+
}, z.core.$strip>;
|
|
183
|
+
permanentAddress: z.ZodObject<{
|
|
184
|
+
country: z.ZodOptional<z.ZodString>;
|
|
185
|
+
state: z.ZodOptional<z.ZodString>;
|
|
186
|
+
areaType: z.ZodOptional<z.ZodEnum<{
|
|
187
|
+
RURAL: "RURAL";
|
|
188
|
+
URBAN: "URBAN";
|
|
189
|
+
}>>;
|
|
190
|
+
division: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
191
|
+
_id: z.ZodString;
|
|
192
|
+
name: z.ZodString;
|
|
193
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
194
|
+
name: z.ZodString;
|
|
195
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
196
|
+
district: z.ZodOptional<z.ZodString>;
|
|
197
|
+
tehsil: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
198
|
+
_id: z.ZodString;
|
|
199
|
+
name: z.ZodString;
|
|
200
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
201
|
+
name: z.ZodString;
|
|
202
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
203
|
+
block: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
204
|
+
_id: z.ZodString;
|
|
205
|
+
name: z.ZodString;
|
|
206
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
207
|
+
name: z.ZodString;
|
|
208
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
209
|
+
gramPanchayat: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
210
|
+
_id: z.ZodString;
|
|
211
|
+
name: z.ZodString;
|
|
212
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
213
|
+
name: z.ZodString;
|
|
214
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
215
|
+
village: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
216
|
+
_id: z.ZodString;
|
|
217
|
+
name: z.ZodString;
|
|
218
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
219
|
+
name: z.ZodString;
|
|
220
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
221
|
+
hamlet: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
222
|
+
_id: z.ZodString;
|
|
223
|
+
name: z.ZodString;
|
|
224
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
225
|
+
name: z.ZodString;
|
|
226
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
227
|
+
ruralWard: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
228
|
+
_id: z.ZodString;
|
|
229
|
+
name: z.ZodString;
|
|
230
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
231
|
+
name: z.ZodString;
|
|
232
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
233
|
+
urbanBody: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
234
|
+
_id: z.ZodString;
|
|
235
|
+
name: z.ZodString;
|
|
236
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
237
|
+
name: z.ZodString;
|
|
238
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
239
|
+
urbanWard: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
240
|
+
_id: z.ZodString;
|
|
241
|
+
name: z.ZodString;
|
|
242
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
243
|
+
name: z.ZodString;
|
|
244
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
245
|
+
locality: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
246
|
+
_id: z.ZodString;
|
|
247
|
+
name: z.ZodString;
|
|
248
|
+
}, z.core.$loose>, z.ZodObject<{
|
|
249
|
+
name: z.ZodString;
|
|
250
|
+
}, z.core.$loose>, z.ZodString]>>;
|
|
251
|
+
housePlotDetails: z.ZodOptional<z.ZodString>;
|
|
252
|
+
pincode: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
|
|
253
|
+
landmark: z.ZodOptional<z.ZodString>;
|
|
254
|
+
directions: z.ZodOptional<z.ZodString>;
|
|
255
|
+
latitude: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
256
|
+
longitude: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
257
|
+
}, z.core.$strip>;
|
|
258
|
+
addressNotes: z.ZodOptional<z.ZodString>;
|
|
259
|
+
}, z.core.$strip>;
|
|
260
|
+
export type Step03ResidenceInput = z.infer<typeof step03ResidenceSchema>;
|
|
261
|
+
export type AddressInput = z.infer<typeof addressSchema>;
|
|
262
|
+
//# sourceMappingURL=step-03.schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-03.schema.d.ts","sourceRoot":"","sources":["../src/step-03.schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;GAKG;AACH,eAAO,MAAM,aAAa;;;;;iCAMb,CAAC;AAEd,iDAAiD;AACjD,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA6BxB,CAAC;AAIH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAUhC,CAAC;AAIH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACzE,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Step 03 — Residence / Address Schema
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth used by both frontend and backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema/step-03
|
|
7
|
+
*/
|
|
8
|
+
import { z } from 'zod';
|
|
9
|
+
// ─── Sub-schemas ────────────────────────────────────────
|
|
10
|
+
/**
|
|
11
|
+
* Area entity reference — accepts:
|
|
12
|
+
* • `{ _id, name }` — existing area entity selected in frontend
|
|
13
|
+
* • `{ name }` — custom / manually entered
|
|
14
|
+
* • raw string — legacy ObjectId stored in DB
|
|
15
|
+
*/
|
|
16
|
+
export const areaRefSchema = z
|
|
17
|
+
.union([
|
|
18
|
+
z.object({ _id: z.string(), name: z.string().trim().min(1) }).passthrough(),
|
|
19
|
+
z.object({ name: z.string().trim().min(1) }).passthrough(),
|
|
20
|
+
z.string().trim().min(1),
|
|
21
|
+
])
|
|
22
|
+
.optional();
|
|
23
|
+
/** Full address block (current or permanent). */
|
|
24
|
+
export const addressSchema = z.object({
|
|
25
|
+
country: z.string().trim().optional(),
|
|
26
|
+
state: z.string().trim().optional(),
|
|
27
|
+
areaType: z.enum(['RURAL', 'URBAN']).optional(),
|
|
28
|
+
division: areaRefSchema,
|
|
29
|
+
district: z.string().trim().optional(),
|
|
30
|
+
tehsil: areaRefSchema,
|
|
31
|
+
// Rural
|
|
32
|
+
block: areaRefSchema,
|
|
33
|
+
gramPanchayat: areaRefSchema,
|
|
34
|
+
village: areaRefSchema,
|
|
35
|
+
hamlet: areaRefSchema,
|
|
36
|
+
ruralWard: areaRefSchema,
|
|
37
|
+
// Urban
|
|
38
|
+
urbanBody: areaRefSchema,
|
|
39
|
+
urbanWard: areaRefSchema,
|
|
40
|
+
locality: areaRefSchema,
|
|
41
|
+
// Details
|
|
42
|
+
housePlotDetails: z.string().trim().optional(),
|
|
43
|
+
pincode: z
|
|
44
|
+
.string()
|
|
45
|
+
.trim()
|
|
46
|
+
.regex(/^\d{6}$/, 'Pincode must be 6 digits')
|
|
47
|
+
.optional()
|
|
48
|
+
.or(z.literal('')),
|
|
49
|
+
landmark: z.string().trim().optional(),
|
|
50
|
+
directions: z.string().trim().optional(),
|
|
51
|
+
latitude: z.coerce.number().min(-90).max(90).optional(),
|
|
52
|
+
longitude: z.coerce.number().min(-180).max(180).optional(),
|
|
53
|
+
});
|
|
54
|
+
// ─── Main step-03 schema ────────────────────────────────
|
|
55
|
+
export const step03ResidenceSchema = z.object({
|
|
56
|
+
domicileSource: z.enum(['BIRTH_PLACE', 'HOME_NATIVE_PLACE', 'ANCESTRAL_NATIVE_PLACE']).optional(),
|
|
57
|
+
birthPlace: z.string().trim().optional(),
|
|
58
|
+
homeNativePlace: z.string().trim().optional(),
|
|
59
|
+
ancestralNativePlace: z.string().trim().optional(),
|
|
60
|
+
yearsAtCurrentAddress: z.coerce.number().min(0).max(120).optional(),
|
|
61
|
+
sameAsCurrentAddress: z.boolean().optional(),
|
|
62
|
+
currentAddress: addressSchema,
|
|
63
|
+
permanentAddress: addressSchema,
|
|
64
|
+
addressNotes: z.string().trim().optional(),
|
|
65
|
+
});
|
|
66
|
+
//# sourceMappingURL=step-03.schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-03.schema.js","sourceRoot":"","sources":["../src/step-03.schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,2DAA2D;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC;KAC3B,KAAK,CAAC;IACL,CAAC,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE;IAC3E,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,E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\n * Single source of truth used by both frontend and backend.\n *\n * @module udp-schema/step-03\n */\n\nimport { z } from 'zod';\n\n// ─── Sub-schemas ────────────────────────────────────────\n\n/**\n * Area entity reference — accepts:\n * • `{ _id, name }` — existing area entity selected in frontend\n * • `{ name }` — custom / manually entered\n * • raw string — legacy ObjectId stored in DB\n */\nexport const areaRefSchema = z\n .union([\n z.object({ _id: z.string(), name: z.string().trim().min(1) }).passthrough(),\n z.object({ name: z.string().trim().min(1) }).passthrough(),\n z.string().trim().min(1),\n ])\n .optional();\n\n/** Full address block (current or permanent). */\nexport const addressSchema = z.object({\n country: z.string().trim().optional(),\n state: z.string().trim().optional(),\n areaType: z.enum(['RURAL', 'URBAN']).optional(),\n division: areaRefSchema,\n district: z.string().trim().optional(),\n tehsil: areaRefSchema,\n // Rural\n block: areaRefSchema,\n gramPanchayat: areaRefSchema,\n village: areaRefSchema,\n hamlet: areaRefSchema,\n ruralWard: areaRefSchema,\n // Urban\n urbanBody: areaRefSchema,\n urbanWard: areaRefSchema,\n locality: areaRefSchema,\n // Details\n housePlotDetails: z.string().trim().optional(),\n pincode: z\n .string()\n .trim()\n .regex(/^\\d{6}$/, 'Pincode must be 6 digits')\n .optional()\n .or(z.literal('')),\n landmark: z.string().trim().optional(),\n directions: z.string().trim().optional(),\n latitude: z.coerce.number().min(-90).max(90).optional(),\n longitude: z.coerce.number().min(-180).max(180).optional(),\n});\n\n// ─── Main step-03 schema ────────────────────────────────\n\nexport const step03ResidenceSchema = z.object({\n domicileSource: z.enum(['BIRTH_PLACE', 'HOME_NATIVE_PLACE', 'ANCESTRAL_NATIVE_PLACE']).optional(),\n birthPlace: z.string().trim().optional(),\n homeNativePlace: z.string().trim().optional(),\n ancestralNativePlace: z.string().trim().optional(),\n yearsAtCurrentAddress: z.coerce.number().min(0).max(120).optional(),\n sameAsCurrentAddress: z.boolean().optional(),\n currentAddress: addressSchema,\n permanentAddress: addressSchema,\n addressNotes: z.string().trim().optional(),\n});\n\n// ─── Inferred types ─────────────────────────────────────\n\nexport type Step03ResidenceInput = z.infer<typeof step03ResidenceSchema>;\nexport type AddressInput = z.infer<typeof addressSchema>;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "udp-schema",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared Zod schemas for User Detailed Profile (frontend + backend).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc -p tsconfig.json",
|
|
23
|
+
"type-check": "tsc --noEmit",
|
|
24
|
+
"lint": "biome lint .",
|
|
25
|
+
"format": "biome format --write .",
|
|
26
|
+
"check": "npm run type-check && biome check --write .",
|
|
27
|
+
"check:staged": "biome check --staged --write --no-errors-on-unmatched",
|
|
28
|
+
"prepublishOnly": "npm run build && npm run check"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"zod",
|
|
32
|
+
"schema",
|
|
33
|
+
"user-detailed-profile",
|
|
34
|
+
"udp",
|
|
35
|
+
"typescript"
|
|
36
|
+
],
|
|
37
|
+
"author": "Hari",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@biomejs/biome": "^2.4.2",
|
|
44
|
+
"@types/node": "^24.10.1",
|
|
45
|
+
"typescript": "^5.9.3",
|
|
46
|
+
"zod": "^4.1.13"
|
|
47
|
+
}
|
|
48
|
+
}
|