udp-schema 0.1.2 → 0.1.4

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.
@@ -1 +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;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;oBAiBlB,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"}
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;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;oBAgBlB,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"}
@@ -34,8 +34,7 @@ export const secondaryLanguageItemSchema = z.object({
34
34
  */
35
35
  export const profilePhotoSchema = z
36
36
  .union([
37
- z
38
- .object({
37
+ z.object({
39
38
  name: z.string().optional(),
40
39
  type: z.string().optional(),
41
40
  size: z.number().min(0).optional(),
@@ -1 +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,2DAA2D;AAE3D,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,IAAI,EAAE,qBAAqB;IAC3B,UAAU,EAAE,qBAAqB;IACjC,WAAW,EAAE,qBAAqB;IAClC,MAAM,EAAE,qBAAqB;CAC9B,CAAC;KACD,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,WAAW,CAAC,EACvD,mEAAmE,CACpE,CAAC;AAEJ,iDAAiD;AACjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE,mBAAmB;IAC7B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,CAA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AAmB,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 * • a File-like object (frontend pre-upload state)\n */\nexport const profilePhotoSchema = z\n .union([\n z\n .object({\n name: z.string().optional(),\n type: z.string().optional(),\n size: z.number().min(0).optional(),\n lastModified: z.number().min(0).optional(),\n }),\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"]}
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,2DAA2D;AAE3D,iEAAiE;AACjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,CAAC;IACN,IAAI,EAAE,qBAAqB;IAC3B,UAAU,EAAE,qBAAqB;IACjC,WAAW,EAAE,qBAAqB;IAClC,MAAM,EAAE,qBAAqB;CAC9B,CAAC;KACD,MAAM,CACL,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,WAAW,CAAC,EACvD,mEAAmE,CACpE,CAAC;AAEJ,iDAAiD;AACjD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,QAAQ,EAAE,mBAAmB;IAC7B,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;IACtE,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAChC,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B,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 * • a File-like object (frontend pre-upload state)\n */\nexport const profilePhotoSchema = z\n .union([\n z.object({\n name: z.string().optional(),\n type: z.string().optional(),\n size: z.number().min(0).optional(),\n lastModified: z.number().min(0).optional(),\n }),\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"]}
@@ -21,7 +21,12 @@ export declare const areaRefSchema: z.ZodOptional<z.ZodUnion<readonly [z.ZodObje
21
21
  /** Full address block (current or permanent). */
22
22
  export declare const addressSchema: z.ZodObject<{
23
23
  country: z.ZodOptional<z.ZodString>;
24
- state: z.ZodOptional<z.ZodString>;
24
+ state: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
25
+ _id: z.ZodString;
26
+ name: z.ZodString;
27
+ }, z.core.$loose>, z.ZodObject<{
28
+ name: z.ZodString;
29
+ }, z.core.$loose>, z.ZodString]>>;
25
30
  areaType: z.ZodOptional<z.ZodEnum<{
26
31
  RURAL: "RURAL";
27
32
  URBAN: "URBAN";
@@ -32,7 +37,12 @@ export declare const addressSchema: z.ZodObject<{
32
37
  }, z.core.$loose>, z.ZodObject<{
33
38
  name: z.ZodString;
34
39
  }, z.core.$loose>, z.ZodString]>>;
35
- district: z.ZodOptional<z.ZodString>;
40
+ district: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
41
+ _id: z.ZodString;
42
+ name: z.ZodString;
43
+ }, z.core.$loose>, z.ZodObject<{
44
+ name: z.ZodString;
45
+ }, z.core.$loose>, z.ZodString]>>;
36
46
  tehsil: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
37
47
  _id: z.ZodString;
38
48
  name: z.ZodString;
@@ -107,7 +117,12 @@ export declare const step03ResidenceSchema: z.ZodObject<{
107
117
  sameAsCurrentAddress: z.ZodOptional<z.ZodBoolean>;
108
118
  currentAddress: z.ZodObject<{
109
119
  country: z.ZodOptional<z.ZodString>;
110
- state: z.ZodOptional<z.ZodString>;
120
+ state: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
121
+ _id: z.ZodString;
122
+ name: z.ZodString;
123
+ }, z.core.$loose>, z.ZodObject<{
124
+ name: z.ZodString;
125
+ }, z.core.$loose>, z.ZodString]>>;
111
126
  areaType: z.ZodOptional<z.ZodEnum<{
112
127
  RURAL: "RURAL";
113
128
  URBAN: "URBAN";
@@ -118,7 +133,12 @@ export declare const step03ResidenceSchema: z.ZodObject<{
118
133
  }, z.core.$loose>, z.ZodObject<{
119
134
  name: z.ZodString;
120
135
  }, z.core.$loose>, z.ZodString]>>;
121
- district: z.ZodOptional<z.ZodString>;
136
+ district: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
137
+ _id: z.ZodString;
138
+ name: z.ZodString;
139
+ }, z.core.$loose>, z.ZodObject<{
140
+ name: z.ZodString;
141
+ }, z.core.$loose>, z.ZodString]>>;
122
142
  tehsil: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
123
143
  _id: z.ZodString;
124
144
  name: z.ZodString;
@@ -182,7 +202,12 @@ export declare const step03ResidenceSchema: z.ZodObject<{
182
202
  }, z.core.$strip>;
183
203
  permanentAddress: z.ZodObject<{
184
204
  country: z.ZodOptional<z.ZodString>;
185
- state: z.ZodOptional<z.ZodString>;
205
+ state: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
206
+ _id: z.ZodString;
207
+ name: z.ZodString;
208
+ }, z.core.$loose>, z.ZodObject<{
209
+ name: z.ZodString;
210
+ }, z.core.$loose>, z.ZodString]>>;
186
211
  areaType: z.ZodOptional<z.ZodEnum<{
187
212
  RURAL: "RURAL";
188
213
  URBAN: "URBAN";
@@ -193,7 +218,12 @@ export declare const step03ResidenceSchema: z.ZodObject<{
193
218
  }, z.core.$loose>, z.ZodObject<{
194
219
  name: z.ZodString;
195
220
  }, z.core.$loose>, z.ZodString]>>;
196
- district: z.ZodOptional<z.ZodString>;
221
+ district: 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]>>;
197
227
  tehsil: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
198
228
  _id: z.ZodString;
199
229
  name: z.ZodString;
@@ -1 +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"}
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"}
@@ -23,10 +23,10 @@ export const areaRefSchema = z
23
23
  /** Full address block (current or permanent). */
24
24
  export const addressSchema = z.object({
25
25
  country: z.string().trim().optional(),
26
- state: z.string().trim().optional(),
26
+ state: areaRefSchema,
27
27
  areaType: z.enum(['RURAL', 'URBAN']).optional(),
28
28
  division: areaRefSchema,
29
- district: z.string().trim().optional(),
29
+ district: areaRefSchema,
30
30
  tehsil: areaRefSchema,
31
31
  // Rural
32
32
  block: areaRefSchema,
@@ -1 +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,C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AM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * Step 03 — Residence / Address Schema\n *\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"]}
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,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE;IAC1D,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;CACzB,CAAC;KACD,QAAQ,EAAE,CAAC;AAEd,iDAAiD;AACjD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IACrC,KAAK,EAAE,aAAa;IACpB,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC/C,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,aAAa;IACvB,MAAM,EA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AE;IACxC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAC7C,oBAAoB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;IAClD,qBAAqB,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IACnE,oBAAoB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC5C,cAAc,EAAE,aAAa;IAC7B,gBAAgB,EAAE,aAAa;IAC/B,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE;CAC3C,CAAC,CAAC","sourcesContent":["/**\n * Step 03 — Residence / Address Schema\n *\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: areaRefSchema,\n areaType: z.enum(['RURAL', 'URBAN']).optional(),\n division: areaRefSchema,\n district: areaRefSchema,\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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "udp-schema",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Shared Zod schemas for User Detailed Profile (frontend + backend).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",