udp-schema 1.1.0 → 2.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/dist/helpers.d.ts +33 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +60 -0
- package/dist/helpers.js.map +1 -0
- package/dist/index.d.ts +16 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -7
- package/dist/index.js.map +1 -1
- package/dist/onboarding-form.d.ts +485 -0
- package/dist/onboarding-form.d.ts.map +1 -0
- package/dist/onboarding-form.js +69 -0
- package/dist/onboarding-form.js.map +1 -0
- package/dist/profile-fields/01-profile.d.ts.map +1 -1
- package/dist/profile-fields/01-profile.js +168 -23
- package/dist/profile-fields/01-profile.js.map +1 -1
- package/dist/profile-fields/02-political.d.ts.map +1 -1
- package/dist/profile-fields/02-political.js +119 -28
- package/dist/profile-fields/02-political.js.map +1 -1
- package/dist/profile-fields/03-electoral.d.ts.map +1 -1
- package/dist/profile-fields/03-electoral.js +83 -13
- package/dist/profile-fields/03-electoral.js.map +1 -1
- package/dist/profile-fields/04-leadership.d.ts.map +1 -1
- package/dist/profile-fields/04-leadership.js +131 -14
- package/dist/profile-fields/04-leadership.js.map +1 -1
- package/dist/profile-fields/05-psychological.d.ts.map +1 -1
- package/dist/profile-fields/05-psychological.js +41 -12
- package/dist/profile-fields/05-psychological.js.map +1 -1
- package/dist/profile-fields/06-education.d.ts.map +1 -1
- package/dist/profile-fields/06-education.js +128 -15
- package/dist/profile-fields/06-education.js.map +1 -1
- package/dist/profile-fields/07-employment.d.ts.map +1 -1
- package/dist/profile-fields/07-employment.js +99 -19
- package/dist/profile-fields/07-employment.js.map +1 -1
- package/dist/profile-fields/08-neurodiversity.d.ts.map +1 -1
- package/dist/profile-fields/08-neurodiversity.js +128 -21
- package/dist/profile-fields/08-neurodiversity.js.map +1 -1
- package/dist/profile-fields/09-health.d.ts.map +1 -1
- package/dist/profile-fields/09-health.js +141 -19
- package/dist/profile-fields/09-health.js.map +1 -1
- package/dist/profile-fields/10-worldview.d.ts.map +1 -1
- package/dist/profile-fields/10-worldview.js +112 -13
- package/dist/profile-fields/10-worldview.js.map +1 -1
- package/dist/profile-fields/11-residence.d.ts.map +1 -1
- package/dist/profile-fields/11-residence.js +39 -5
- package/dist/profile-fields/11-residence.js.map +1 -1
- package/dist/profile-fields/12-household.d.ts.map +1 -1
- package/dist/profile-fields/12-household.js +175 -25
- package/dist/profile-fields/12-household.js.map +1 -1
- package/dist/profile-fields/index.d.ts +8 -8
- package/dist/profile-fields/index.d.ts.map +1 -1
- package/dist/profile-fields/index.js +8 -8
- package/dist/profile-fields/index.js.map +1 -1
- package/dist/validation.d.ts +18 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +186 -0
- package/dist/validation.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UDP Shared Helpers — single source of truth for utility functions.
|
|
3
|
+
*
|
|
4
|
+
* Used by both frontend and backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema/helpers
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Calculate age from an ISO date string (YYYY-MM-DD or Date-parseable).
|
|
10
|
+
*
|
|
11
|
+
* @returns Age in years, or null if invalid.
|
|
12
|
+
*/
|
|
13
|
+
export declare function calcAge(dob: string | Date | undefined | null): number | null;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a single-select field's current value to its display label.
|
|
16
|
+
*
|
|
17
|
+
* Uses getFieldOptions() from profile-fields for O(1) option lookup.
|
|
18
|
+
* Falls back to the raw value if no option found.
|
|
19
|
+
*
|
|
20
|
+
* @param fieldKey - The field key (e.g., "gender", "familyReligion")
|
|
21
|
+
* @param value - The current value (e.g., "man", "hindu")
|
|
22
|
+
* @returns Display label string, or undefined if no value
|
|
23
|
+
*/
|
|
24
|
+
export declare function labelFor(fieldKey: string, value: unknown): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a multi-select field's current values to display labels.
|
|
27
|
+
*
|
|
28
|
+
* @param fieldKey - The field key
|
|
29
|
+
* @param values - Array of selected values
|
|
30
|
+
* @returns Array of display labels, or undefined if empty
|
|
31
|
+
*/
|
|
32
|
+
export declare function labelsFor(fieldKey: string, values: unknown): string[] | undefined;
|
|
33
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAS5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAOjF"}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UDP Shared Helpers — single source of truth for utility functions.
|
|
3
|
+
*
|
|
4
|
+
* Used by both frontend and backend.
|
|
5
|
+
*
|
|
6
|
+
* @module udp-schema/helpers
|
|
7
|
+
*/
|
|
8
|
+
import { getFieldOptions } from './field-helpers.js';
|
|
9
|
+
/**
|
|
10
|
+
* Calculate age from an ISO date string (YYYY-MM-DD or Date-parseable).
|
|
11
|
+
*
|
|
12
|
+
* @returns Age in years, or null if invalid.
|
|
13
|
+
*/
|
|
14
|
+
export function calcAge(dob) {
|
|
15
|
+
if (!dob)
|
|
16
|
+
return null;
|
|
17
|
+
const d = typeof dob === 'string' ? new Date(dob) : dob;
|
|
18
|
+
if (Number.isNaN(d.getTime()))
|
|
19
|
+
return null;
|
|
20
|
+
const today = new Date();
|
|
21
|
+
let age = today.getFullYear() - d.getFullYear();
|
|
22
|
+
const m = today.getMonth() - d.getMonth();
|
|
23
|
+
if (m < 0 || (m === 0 && today.getDate() < d.getDate()))
|
|
24
|
+
age--;
|
|
25
|
+
return age;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a single-select field's current value to its display label.
|
|
29
|
+
*
|
|
30
|
+
* Uses getFieldOptions() from profile-fields for O(1) option lookup.
|
|
31
|
+
* Falls back to the raw value if no option found.
|
|
32
|
+
*
|
|
33
|
+
* @param fieldKey - The field key (e.g., "gender", "familyReligion")
|
|
34
|
+
* @param value - The current value (e.g., "man", "hindu")
|
|
35
|
+
* @returns Display label string, or undefined if no value
|
|
36
|
+
*/
|
|
37
|
+
export function labelFor(fieldKey, value) {
|
|
38
|
+
if (!value || typeof value !== 'string')
|
|
39
|
+
return undefined;
|
|
40
|
+
const options = getFieldOptions(fieldKey);
|
|
41
|
+
const opt = options.find((o) => o.value === value);
|
|
42
|
+
return opt ? opt.label : value;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a multi-select field's current values to display labels.
|
|
46
|
+
*
|
|
47
|
+
* @param fieldKey - The field key
|
|
48
|
+
* @param values - Array of selected values
|
|
49
|
+
* @returns Array of display labels, or undefined if empty
|
|
50
|
+
*/
|
|
51
|
+
export function labelsFor(fieldKey, values) {
|
|
52
|
+
if (!Array.isArray(values) || values.length === 0)
|
|
53
|
+
return undefined;
|
|
54
|
+
const options = getFieldOptions(fieldKey);
|
|
55
|
+
return values.map((v) => {
|
|
56
|
+
const opt = options.find((o) => o.value === v);
|
|
57
|
+
return opt ? opt.label : v;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":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C;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB,EAAE,MAAe;IACzD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IACpE,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE;QAC9B,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;QAC5D,OAAO,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * UDP Shared Helpers — single source of truth for utility functions.\n *\n * Used by both frontend and backend.\n *\n * @module udp-schema/helpers\n */\n\nimport { getFieldOptions } from './field-helpers.js';\nimport type { FieldOption } from './profile-fields/types.js';\n\n/**\n * Calculate age from an ISO date string (YYYY-MM-DD or Date-parseable).\n *\n * @returns Age in years, or null if invalid.\n */\nexport function calcAge(dob: string | Date | undefined | null): number | null {\n if (!dob) return null;\n const d = typeof dob === 'string' ? new Date(dob) : dob;\n if (Number.isNaN(d.getTime())) return null;\n const today = new Date();\n let age = today.getFullYear() - d.getFullYear();\n const m = today.getMonth() - d.getMonth();\n if (m < 0 || (m === 0 && today.getDate() < d.getDate())) age--;\n return age;\n}\n\n/**\n * Resolve a single-select field's current value to its display label.\n *\n * Uses getFieldOptions() from profile-fields for O(1) option lookup.\n * Falls back to the raw value if no option found.\n *\n * @param fieldKey - The field key (e.g., \"gender\", \"familyReligion\")\n * @param value - The current value (e.g., \"man\", \"hindu\")\n * @returns Display label string, or undefined if no value\n */\nexport function labelFor(fieldKey: string, value: unknown): string | undefined {\n if (!value || typeof value !== 'string') return undefined;\n const options = getFieldOptions(fieldKey);\n const opt = options.find((o: FieldOption) => o.value === value);\n return opt ? opt.label : value;\n}\n\n/**\n * Resolve a multi-select field's current values to display labels.\n *\n * @param fieldKey - The field key\n * @param values - Array of selected values\n * @returns Array of display labels, or undefined if empty\n */\nexport function labelsFor(fieldKey: string, values: unknown): string[] | undefined {\n if (!Array.isArray(values) || values.length === 0) return undefined;\n const options = getFieldOptions(fieldKey);\n return values.map((v: string) => {\n const opt = options.find((o: FieldOption) => o.value === v);\n return opt ? opt.label : v;\n });\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* udp-schema — Shared
|
|
2
|
+
* udp-schema — Shared schemas for User Detailed Profile (v2)
|
|
3
3
|
*
|
|
4
4
|
* Single source of truth consumed by both reform frontends and reform-backend.
|
|
5
5
|
* 12-step "1 question per screen" architecture.
|
|
6
6
|
*
|
|
7
|
+
* Follows the same pattern as dating-schema:
|
|
8
|
+
* - profile-fields/ with rich FieldGroup definitions
|
|
9
|
+
* - getFieldOptions() / getFieldMeta() for runtime introspection
|
|
10
|
+
* - Unified onboarding form schema (udpOnboardingFormSchema)
|
|
11
|
+
* - Validation (canProceed) exported for frontend + backend
|
|
12
|
+
* - Helpers (calcAge, labelFor, labelsFor) shared across codebases
|
|
13
|
+
* - Onboarding-config for step grouping
|
|
14
|
+
* - Zod step schemas for per-step validation
|
|
15
|
+
* - Progress tracking (per-step + overall)
|
|
16
|
+
*
|
|
7
17
|
* @module udp-schema
|
|
8
18
|
*/
|
|
9
|
-
export {
|
|
19
|
+
export { udpOnboardingFormSchema, type OnboardingFormData, } from './onboarding-form.js';
|
|
20
|
+
export { canProceed } from './validation.js';
|
|
21
|
+
export { calcAge, labelFor, labelsFor } from './helpers.js';
|
|
22
|
+
export { allFieldGroups, type BaseField, casteDiscriminationPlaceOptions, civicEngagementOptions, dietOptions, digitalAccessOptions, disabilityOptions, education, electoralBehaviour, employment, employmentStatusOptions, type FieldGroup, type FieldOption, familyMemberOptions, genderOptions, healthLifestyle, household, householdIncomeOptions, incomeRangeOptions, languageOptions, leadershipAmbitions, leadershipSkillsetOptions, lgbtqStatementOptions, type MultiSelectField, mbtiOptions, minorityOptions, type NumberField, neurodiversity, neurodiversityConditionOptions, type ProfileField, partyOptions, politicalAssociation, politicalSpectrumOptions, profile, psychologicalAssessment, qualificationOptions, religionOptions, reservationOptions, residence, type SelectField, sensoryPreferenceOptions, shiftOptions, substanceUseOptions, supportNeedOptions, type TextField, transgenderStatementOptions, votingIssueOptions, worldView, } from './profile-fields/index.js';
|
|
10
23
|
export { getFieldMeta, getFieldOptions, getImmutableFields, getStepSchema, } from './field-helpers.js';
|
|
11
24
|
export { getUdpOnboardingFieldConfig, UDP_ONBOARDING_FIELDS, UDP_ONBOARDING_STEP_GROUPS, UDP_TOTAL_MAIN_STEPS, UDP_TOTAL_SUB_STEPS, type UdpOnboardingFieldConfig, type UdpOnboardingStepGroup, } from './onboarding-config.js';
|
|
12
25
|
export { calculateOverallProgress as calculateUdpOverallProgress, calculateStepProgress as calculateUdpStepProgress, getNestedValue, isFieldFilled, UDP_PROGRESS_FIELDS, UDP_TOTAL_STEPS, } from './progress-fields.js';
|
|
@@ -15,13 +28,12 @@ export { type Step02PoliticalInput, step02PoliticalSchema } from './step-02.sche
|
|
|
15
28
|
export { type Step03ElectoralInput, step03ElectoralSchema } from './step-03.schema.js';
|
|
16
29
|
export { type Step04LeadershipInput, step04LeadershipSchema } from './step-04.schema.js';
|
|
17
30
|
export { type Step05PsychologicalInput, step05PsychologicalSchema } from './step-05.schema.js';
|
|
18
|
-
export {
|
|
31
|
+
export { type CertificateEntryInput, certificateEntrySchema, type DegreeEntryInput, degreeEntrySchema, type Step06EducationInput, step06EducationSchema, } from './step-06.schema.js';
|
|
19
32
|
export { type Step07EmploymentInput, step07EmploymentSchema } from './step-07.schema.js';
|
|
20
33
|
export { type Step08NeurodiversityInput, step08NeurodiversitySchema } from './step-08.schema.js';
|
|
21
34
|
export { type Step09HealthInput, step09HealthSchema } from './step-09.schema.js';
|
|
22
35
|
export { type Step10WorldViewInput, step10WorldViewSchema } from './step-10.schema.js';
|
|
23
36
|
export { type SimplifiedAddressInput, type Step11ResidenceInput, simplifiedAddressSchema, step11ResidenceSchema, } from './step-11.schema.js';
|
|
24
37
|
export { type Step12HouseholdInput, step12HouseholdSchema } from './step-12.schema.js';
|
|
25
|
-
export { type UdpFieldOption, GENDER_OPTIONS, RELIGION_OPTIONS, LANGUAGE_OPTIONS, RESERVATION_STATUS_OPTIONS, MINORITY_STATUS_OPTIONS, POLITICAL_SPECTRUM_OPTIONS, PARTY_OPTIONS, CIVIC_ENGAGEMENT_OPTIONS, VOTING_ISSUES_OPTIONS, LEADERSHIP_SKILLSET_OPTIONS, QUALIFICATION_OPTIONS, NEURODIVERSITY_CONDITIONS_OPTIONS, SENSORY_PREFERENCES_OPTIONS, SUPPORT_NEEDS_OPTIONS, DISABILITY_STATUS_OPTIONS, SUBSTANCE_USE_OPTIONS, LGBTQ_STATEMENTS_OPTIONS, TRANSGENDER_STATEMENTS_OPTIONS, CASTE_DISCRIMINATION_PLACES_OPTIONS, FAMILY_MEMBERS_OPTIONS, DIGITAL_ACCESS_OPTIONS, } from './field-meta.js';
|
|
26
38
|
export { emptyStringToUndefined, optionalPhoneSchema, optionalTrimmedString, optionalYearSchema, } from './zod-helpers.js';
|
|
27
39
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EACL,uBAAuB,EACvB,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAC;AA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Single source of truth consumed by both reform frontends and reform-backend.
|
|
5
5
|
* 12-step "1 question per screen" architecture.
|
|
6
6
|
*
|
|
7
|
+
* Follows the same pattern as dating-schema:
|
|
8
|
+
* - profile-fields/ with rich FieldGroup definitions
|
|
9
|
+
* - getFieldOptions() / getFieldMeta() for runtime introspection
|
|
10
|
+
* - Unified onboarding form schema (udpOnboardingFormSchema)
|
|
11
|
+
* - Validation (canProceed) exported for frontend + backend
|
|
12
|
+
* - Helpers (calcAge, labelFor, labelsFor) shared across codebases
|
|
13
|
+
* - Onboarding-config for step grouping
|
|
14
|
+
* - Zod step schemas for per-step validation
|
|
15
|
+
* - Progress tracking (per-step + overall)
|
|
16
|
+
*
|
|
7
17
|
* @module udp-schema
|
|
8
18
|
*/
|
|
19
|
+
// ─── Unified Form Schema (like dating's onboardingFormSchema) ───────────────
|
|
20
|
+
export { udpOnboardingFormSchema, } from './onboarding-form.js';
|
|
21
|
+
// ─── Validation (single source of truth — used by frontend + backend) ───────
|
|
22
|
+
export { canProceed } from './validation.js';
|
|
23
|
+
// ─── Shared Helpers ─────────────────────────────────────────────────────────
|
|
24
|
+
export { calcAge, labelFor, labelsFor } from './helpers.js';
|
|
9
25
|
// ─── Profile Fields (rich metadata — like dating-schema) ────────────────────
|
|
10
26
|
export {
|
|
11
27
|
// Field groups
|
|
12
|
-
allFieldGroups,
|
|
13
|
-
// Option arrays (with descriptions)
|
|
14
|
-
genderOptions,
|
|
15
|
-
// ─── Field Helpers (like dating-schema
|
|
28
|
+
allFieldGroups, casteDiscriminationPlaceOptions, civicEngagementOptions, dietOptions, digitalAccessOptions, disabilityOptions, education, electoralBehaviour, employment, employmentStatusOptions, familyMemberOptions,
|
|
29
|
+
// Option arrays (with labels + descriptions)
|
|
30
|
+
genderOptions, healthLifestyle, household, householdIncomeOptions, incomeRangeOptions, languageOptions, leadershipAmbitions, leadershipSkillsetOptions, lgbtqStatementOptions, mbtiOptions, minorityOptions, neurodiversity, neurodiversityConditionOptions, partyOptions, politicalAssociation, politicalSpectrumOptions, profile, psychologicalAssessment, qualificationOptions, religionOptions, reservationOptions, residence, sensoryPreferenceOptions, shiftOptions, substanceUseOptions, supportNeedOptions, transgenderStatementOptions, votingIssueOptions, worldView, } from './profile-fields/index.js';
|
|
31
|
+
// ─── Field Helpers (like dating-schema) ─────────────────────────────────────
|
|
16
32
|
export { getFieldMeta, getFieldOptions, getImmutableFields, getStepSchema, } from './field-helpers.js';
|
|
17
33
|
// ─── Onboarding Configuration ───────────────────────────────────────────────
|
|
18
34
|
export { getUdpOnboardingFieldConfig, UDP_ONBOARDING_FIELDS, UDP_ONBOARDING_STEP_GROUPS, UDP_TOTAL_MAIN_STEPS, UDP_TOTAL_SUB_STEPS, } from './onboarding-config.js';
|
|
@@ -31,8 +47,6 @@ export { step09HealthSchema } from './step-09.schema.js';
|
|
|
31
47
|
export { step10WorldViewSchema } from './step-10.schema.js';
|
|
32
48
|
export { simplifiedAddressSchema, step11ResidenceSchema, } from './step-11.schema.js';
|
|
33
49
|
export { step12HouseholdSchema } from './step-12.schema.js';
|
|
34
|
-
// ─── Backward-compatible SCREAMING_CASE exports (from field-meta.ts) ────────
|
|
35
|
-
export { GENDER_OPTIONS, RELIGION_OPTIONS, LANGUAGE_OPTIONS, RESERVATION_STATUS_OPTIONS, MINORITY_STATUS_OPTIONS, POLITICAL_SPECTRUM_OPTIONS, PARTY_OPTIONS, CIVIC_ENGAGEMENT_OPTIONS, VOTING_ISSUES_OPTIONS, LEADERSHIP_SKILLSET_OPTIONS, QUALIFICATION_OPTIONS, NEURODIVERSITY_CONDITIONS_OPTIONS, SENSORY_PREFERENCES_OPTIONS, SUPPORT_NEEDS_OPTIONS, DISABILITY_STATUS_OPTIONS, SUBSTANCE_USE_OPTIONS, LGBTQ_STATEMENTS_OPTIONS, TRANSGENDER_STATEMENTS_OPTIONS, CASTE_DISCRIMINATION_PLACES_OPTIONS, FAMILY_MEMBERS_OPTIONS, DIGITAL_ACCESS_OPTIONS, } from './field-meta.js';
|
|
36
50
|
// ─── Zod Helpers ────────────────────────────────────────────────────────────
|
|
37
51
|
export { emptyStringToUndefined, optionalPhoneSchema, optionalTrimmedString, optionalYearSchema, } from './zod-helpers.js';
|
|
38
52
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,+EAA+E;AAE/E,OAAO,EACL,uBAAuB,GAExB,MAAM,sBAAsB,CAAC;AAE9B,+EAA+E;AAE/E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,+EAA+E;AAE/E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE5D,+EAA+E;AAE/E,OAAO;AACL,eAAe;AACf,cAAc,EAGd,+BAA+B,EAC/B,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,SAAS,EACT,kBAAkB,EAClB,UAAU,EACV,uBAAuB,EAGvB,mBAAmB;AACnB,6CAA6C;AAC7C,aAAa,EACb,eAAe,EACf,SAAS,EACT,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,EAErB,WAAW,EACX,eAAe,EAEf,cAAc,EACd,8BAA8B,EAE9B,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,OAAO,EACP,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,SAAS,EAET,wBAAwB,EACxB,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAElB,2BAA2B,EAC3B,kBAAkB,EAClB,SAAS,GACV,MAAM,2BAA2B,CAAC;AAEnC,+EAA+E;AAE/E,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Profile (v2)\n *\n * Single source of truth consumed by both reform frontends and reform-backend.\n * 12-step \"1 question per screen\" architecture.\n *\n * Follows the same pattern as dating-schema:\n * - profile-fields/ with rich FieldGroup definitions\n * - getFieldOptions() / getFieldMeta() for runtime introspection\n * - Unified onboarding form schema (udpOnboardingFormSchema)\n * - Validation (canProceed) exported for frontend + backend\n * - Helpers (calcAge, labelFor, labelsFor) shared across codebases\n * - Onboarding-config for step grouping\n * - Zod step schemas for per-step validation\n * - Progress tracking (per-step + overall)\n *\n * @module udp-schema\n */\n\n// ─── Unified Form Schema (like dating's onboardingFormSchema) ───────────────\n\nexport {\n udpOnboardingFormSchema,\n type OnboardingFormData,\n} from './onboarding-form.js';\n\n// ─── Validation (single source of truth — used by frontend + backend) ───────\n\nexport { canProceed } from './validation.js';\n\n// ─── Shared Helpers ─────────────────────────────────────────────────────────\n\nexport { calcAge, labelFor, labelsFor } from './helpers.js';\n\n// ─── Profile Fields (rich metadata — like dating-schema) ────────────────────\n\nexport {\n // Field groups\n allFieldGroups,\n // Types\n type BaseField,\n casteDiscriminationPlaceOptions,\n civicEngagementOptions,\n dietOptions,\n digitalAccessOptions,\n disabilityOptions,\n education,\n electoralBehaviour,\n employment,\n employmentStatusOptions,\n type FieldGroup,\n type FieldOption,\n familyMemberOptions,\n // Option arrays (with labels + descriptions)\n genderOptions,\n healthLifestyle,\n household,\n householdIncomeOptions,\n incomeRangeOptions,\n languageOptions,\n leadershipAmbitions,\n leadershipSkillsetOptions,\n lgbtqStatementOptions,\n type MultiSelectField,\n mbtiOptions,\n minorityOptions,\n type NumberField,\n neurodiversity,\n neurodiversityConditionOptions,\n type ProfileField,\n partyOptions,\n politicalAssociation,\n politicalSpectrumOptions,\n profile,\n psychologicalAssessment,\n qualificationOptions,\n religionOptions,\n reservationOptions,\n residence,\n type SelectField,\n sensoryPreferenceOptions,\n shiftOptions,\n substanceUseOptions,\n supportNeedOptions,\n type TextField,\n transgenderStatementOptions,\n votingIssueOptions,\n worldView,\n} from './profile-fields/index.js';\n\n// ─── Field Helpers (like dating-schema) ─────────────────────────────────────\n\nexport {\n getFieldMeta,\n getFieldOptions,\n getImmutableFields,\n getStepSchema,\n} from './field-helpers.js';\n\n// ─── Onboarding Configuration ───────────────────────────────────────────────\n\nexport {\n getUdpOnboardingFieldConfig,\n UDP_ONBOARDING_FIELDS,\n UDP_ONBOARDING_STEP_GROUPS,\n UDP_TOTAL_MAIN_STEPS,\n UDP_TOTAL_SUB_STEPS,\n type UdpOnboardingFieldConfig,\n type UdpOnboardingStepGroup,\n} from './onboarding-config.js';\n\n// ─── Progress Fields ────────────────────────────────────────────────────────\n\nexport {\n calculateOverallProgress as calculateUdpOverallProgress,\n calculateStepProgress as calculateUdpStepProgress,\n getNestedValue,\n isFieldFilled,\n UDP_PROGRESS_FIELDS,\n UDP_TOTAL_STEPS,\n} from './progress-fields.js';\n\n// ─── Step Schemas (Zod validation) ──────────────────────────────────────────\n\nexport { type Step01ProfileInput, step01ProfileSchema } from './step-01.schema.js';\nexport { type Step02PoliticalInput, step02PoliticalSchema } from './step-02.schema.js';\nexport { type Step03ElectoralInput, step03ElectoralSchema } from './step-03.schema.js';\nexport { type Step04LeadershipInput, step04LeadershipSchema } from './step-04.schema.js';\nexport { type Step05PsychologicalInput, step05PsychologicalSchema } from './step-05.schema.js';\nexport {\n type CertificateEntryInput,\n certificateEntrySchema,\n type DegreeEntryInput,\n degreeEntrySchema,\n type Step06EducationInput,\n step06EducationSchema,\n} from './step-06.schema.js';\nexport { type Step07EmploymentInput, step07EmploymentSchema } from './step-07.schema.js';\nexport { type Step08NeurodiversityInput, step08NeurodiversitySchema } from './step-08.schema.js';\nexport { type Step09HealthInput, step09HealthSchema } from './step-09.schema.js';\nexport { type Step10WorldViewInput, step10WorldViewSchema } from './step-10.schema.js';\nexport {\n type SimplifiedAddressInput,\n type Step11ResidenceInput,\n simplifiedAddressSchema,\n step11ResidenceSchema,\n} from './step-11.schema.js';\nexport { type Step12HouseholdInput, step12HouseholdSchema } from './step-12.schema.js';\n\n// ─── Zod Helpers ────────────────────────────────────────────────────────────\n\nexport {\n emptyStringToUndefined,\n optionalPhoneSchema,\n optionalTrimmedString,\n optionalYearSchema,\n} from './zod-helpers.js';\n"]}
|