udp-schema 0.3.0 → 1.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/field-helpers.d.ts +18 -31
- package/dist/field-helpers.d.ts.map +1 -1
- package/dist/field-helpers.js +56 -51
- package/dist/field-helpers.js.map +1 -1
- package/dist/field-meta.d.ts +14 -34
- package/dist/field-meta.d.ts.map +1 -1
- package/dist/field-meta.js +13 -1991
- package/dist/field-meta.js.map +1 -1
- package/dist/index.d.ts +19 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +30 -35
- package/dist/index.js.map +1 -1
- package/dist/onboarding-config.d.ts +44 -0
- package/dist/onboarding-config.d.ts.map +1 -0
- package/dist/onboarding-config.js +705 -0
- package/dist/onboarding-config.js.map +1 -0
- package/dist/profile-fields/01-profile.d.ts +264 -0
- package/dist/profile-fields/01-profile.d.ts.map +1 -0
- package/dist/profile-fields/01-profile.js +113 -0
- package/dist/profile-fields/01-profile.js.map +1 -0
- package/dist/profile-fields/02-political.d.ts +133 -0
- package/dist/profile-fields/02-political.d.ts.map +1 -0
- package/dist/profile-fields/02-political.js +42 -0
- package/dist/profile-fields/02-political.js.map +1 -0
- package/dist/profile-fields/03-electoral.d.ts +46 -0
- package/dist/profile-fields/03-electoral.d.ts.map +1 -0
- package/dist/profile-fields/03-electoral.js +21 -0
- package/dist/profile-fields/03-electoral.js.map +1 -0
- package/dist/profile-fields/04-leadership.d.ts +34 -0
- package/dist/profile-fields/04-leadership.d.ts.map +1 -0
- package/dist/profile-fields/04-leadership.js +22 -0
- package/dist/profile-fields/04-leadership.js.map +1 -0
- package/dist/profile-fields/05-psychological.d.ts +58 -0
- package/dist/profile-fields/05-psychological.d.ts.map +1 -0
- package/dist/profile-fields/05-psychological.js +20 -0
- package/dist/profile-fields/05-psychological.js.map +1 -0
- package/dist/profile-fields/06-education.d.ts +28 -0
- package/dist/profile-fields/06-education.d.ts.map +1 -0
- package/dist/profile-fields/06-education.js +23 -0
- package/dist/profile-fields/06-education.js.map +1 -0
- package/dist/profile-fields/07-employment.d.ts +75 -0
- package/dist/profile-fields/07-employment.d.ts.map +1 -0
- package/dist/profile-fields/07-employment.js +32 -0
- package/dist/profile-fields/07-employment.js.map +1 -0
- package/dist/profile-fields/08-neurodiversity.d.ts +100 -0
- package/dist/profile-fields/08-neurodiversity.d.ts.map +1 -0
- package/dist/profile-fields/08-neurodiversity.js +39 -0
- package/dist/profile-fields/08-neurodiversity.js.map +1 -0
- package/dist/profile-fields/09-health.d.ts +89 -0
- package/dist/profile-fields/09-health.d.ts.map +1 -0
- package/dist/profile-fields/09-health.js +38 -0
- package/dist/profile-fields/09-health.js.map +1 -0
- package/dist/profile-fields/10-worldview.d.ts +75 -0
- package/dist/profile-fields/10-worldview.d.ts.map +1 -0
- package/dist/profile-fields/10-worldview.js +41 -0
- package/dist/profile-fields/10-worldview.js.map +1 -0
- package/dist/profile-fields/11-residence.d.ts +3 -0
- package/dist/profile-fields/11-residence.d.ts.map +1 -0
- package/dist/profile-fields/11-residence.js +11 -0
- package/dist/profile-fields/11-residence.js.map +1 -0
- package/dist/profile-fields/12-household.d.ts +90 -0
- package/dist/profile-fields/12-household.d.ts.map +1 -0
- package/dist/profile-fields/12-household.js +37 -0
- package/dist/profile-fields/12-household.js.map +1 -0
- package/dist/profile-fields/index.d.ts +22 -0
- package/dist/profile-fields/index.d.ts.map +1 -0
- package/dist/profile-fields/index.js +47 -0
- package/dist/profile-fields/index.js.map +1 -0
- package/dist/profile-fields/types.d.ts +66 -0
- package/dist/profile-fields/types.d.ts.map +1 -0
- package/dist/profile-fields/types.js +8 -0
- package/dist/profile-fields/types.js.map +1 -0
- package/dist/progress-fields.d.ts +21 -3
- package/dist/progress-fields.d.ts.map +1 -1
- package/dist/progress-fields.js +97 -94
- package/dist/progress-fields.js.map +1 -1
- package/dist/step-01.schema.d.ts +84 -111
- package/dist/step-01.schema.d.ts.map +1 -1
- package/dist/step-01.schema.js +94 -101
- package/dist/step-01.schema.js.map +1 -1
- package/dist/step-02.schema.d.ts +31 -21
- package/dist/step-02.schema.d.ts.map +1 -1
- package/dist/step-02.schema.js +34 -27
- package/dist/step-02.schema.js.map +1 -1
- package/dist/step-03.schema.d.ts +24 -300
- package/dist/step-03.schema.d.ts.map +1 -1
- package/dist/step-03.schema.js +17 -60
- package/dist/step-03.schema.js.map +1 -1
- package/dist/step-04.schema.d.ts +56 -50
- package/dist/step-04.schema.d.ts.map +1 -1
- package/dist/step-04.schema.js +44 -43
- package/dist/step-04.schema.js.map +1 -1
- package/dist/step-05.schema.d.ts +13 -52
- package/dist/step-05.schema.d.ts.map +1 -1
- package/dist/step-05.schema.js +19 -40
- package/dist/step-05.schema.js.map +1 -1
- package/dist/step-06.schema.d.ts +101 -117
- package/dist/step-06.schema.d.ts.map +1 -1
- package/dist/step-06.schema.js +70 -75
- package/dist/step-06.schema.js.map +1 -1
- package/dist/step-07.schema.d.ts +44 -95
- package/dist/step-07.schema.d.ts.map +1 -1
- package/dist/step-07.schema.js +37 -78
- package/dist/step-07.schema.js.map +1 -1
- package/dist/step-08.schema.d.ts +31 -44
- package/dist/step-08.schema.d.ts.map +1 -1
- package/dist/step-08.schema.js +29 -48
- package/dist/step-08.schema.js.map +1 -1
- package/dist/step-09.schema.d.ts +48 -85
- package/dist/step-09.schema.d.ts.map +1 -1
- package/dist/step-09.schema.js +28 -120
- package/dist/step-09.schema.js.map +1 -1
- package/dist/step-10.schema.d.ts +32 -86
- package/dist/step-10.schema.d.ts.map +1 -1
- package/dist/step-10.schema.js +44 -120
- package/dist/step-10.schema.js.map +1 -1
- package/dist/step-11.schema.d.ts +36 -92
- package/dist/step-11.schema.d.ts.map +1 -1
- package/dist/step-11.schema.js +32 -111
- package/dist/step-11.schema.js.map +1 -1
- package/dist/step-12.schema.d.ts +56 -93
- package/dist/step-12.schema.d.ts.map +1 -1
- package/dist/step-12.schema.js +57 -133
- package/dist/step-12.schema.js.map +1 -1
- package/package.json +1 -1
package/dist/field-helpers.d.ts
CHANGED
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convenience helpers for accessing UDP field metadata.
|
|
2
|
+
* Convenience helpers for accessing UDP field metadata and step schemas.
|
|
3
3
|
*
|
|
4
|
-
* Mirrors the dating-schema
|
|
5
|
-
* pre-built lookup maps with
|
|
4
|
+
* Mirrors the dating-schema field-helpers.ts pattern:
|
|
5
|
+
* pre-built lookup maps with getFieldOptions() and getFieldMeta().
|
|
6
6
|
*
|
|
7
7
|
* @module udp-schema/field-helpers
|
|
8
8
|
*/
|
|
9
|
-
import
|
|
9
|
+
import type { z } from 'zod';
|
|
10
|
+
import type { FieldOption, ProfileField } from './profile-fields/types.js';
|
|
10
11
|
/**
|
|
11
|
-
* Get the `{ value, label }` options array for a
|
|
12
|
+
* Get the `{ value, label, description }` options array for a field by its key.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* ```ts
|
|
15
|
-
* import {
|
|
16
|
-
* const opts =
|
|
17
|
-
* // → [{ value: '
|
|
16
|
+
* import { getFieldOptions } from 'udp-schema';
|
|
17
|
+
* const opts = getFieldOptions('gender');
|
|
18
|
+
* // → [{ value: 'man', label: 'Man' }, { value: 'woman', label: 'Woman' }, ...]
|
|
18
19
|
* ```
|
|
19
20
|
*/
|
|
20
|
-
export declare function
|
|
21
|
+
export declare function getFieldOptions(fieldKey: string): readonly FieldOption[];
|
|
21
22
|
/**
|
|
22
|
-
* Get full field metadata (label, step,
|
|
23
|
+
* Get full field metadata (label, description, step, type, options, etc.) by key.
|
|
23
24
|
*
|
|
24
25
|
* @example
|
|
25
26
|
* ```ts
|
|
26
|
-
* import {
|
|
27
|
-
* const meta =
|
|
28
|
-
* // → { key: '
|
|
27
|
+
* import { getFieldMeta } from 'udp-schema';
|
|
28
|
+
* const meta = getFieldMeta('familyReligion');
|
|
29
|
+
* // → { key: 'familyReligion', label: 'Family Religion', type: 'single_select', step: 1, options: [...], ... }
|
|
29
30
|
* ```
|
|
30
31
|
*/
|
|
31
|
-
export declare function
|
|
32
|
+
export declare function getFieldMeta(fieldKey: string): ProfileField | undefined;
|
|
32
33
|
/**
|
|
33
|
-
* Get
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```ts
|
|
37
|
-
* import { getUdpStepFields } from 'udp-schema';
|
|
38
|
-
* const step5Fields = getUdpStepFields(5);
|
|
39
|
-
* // → [{ key: 'desireToBeLeader', ... }, { key: 'desiredPoliticalPosition', ... }, ...]
|
|
40
|
-
* ```
|
|
34
|
+
* Get the Zod schema for a given step number.
|
|
35
|
+
* Use `.partial().parse(data)` for sub-step saves.
|
|
41
36
|
*/
|
|
42
|
-
export declare function
|
|
37
|
+
export declare function getStepSchema(stepNumber: number): z.ZodObject<any> | undefined;
|
|
43
38
|
/**
|
|
44
39
|
* Get the list of field keys that are immutable after volunteer approval.
|
|
45
|
-
* These fields can only be changed by a volunteer in survey-mode once approved.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```ts
|
|
49
|
-
* import { getImmutableFields } from 'udp-schema';
|
|
50
|
-
* const locked = getImmutableFields();
|
|
51
|
-
* // → ['firstName', 'middleName', 'lastName', 'gender', 'dateOfBirth', 'phonePrimary']
|
|
52
|
-
* ```
|
|
53
40
|
*/
|
|
54
41
|
export declare function getImmutableFields(): readonly string[];
|
|
55
42
|
//# sourceMappingURL=field-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-helpers.d.ts","sourceRoot":"","sources":["../src/field-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"field-helpers.d.ts","sourceRoot":"","sources":["../src/field-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AA8B3E;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAExE;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEvE;AAoBD;;;GAGG;AAEH,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,SAAS,CAE9E;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,SAAS,MAAM,EAAE,CAEtD"}
|
package/dist/field-helpers.js
CHANGED
|
@@ -1,85 +1,90 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Convenience helpers for accessing UDP field metadata.
|
|
2
|
+
* Convenience helpers for accessing UDP field metadata and step schemas.
|
|
3
3
|
*
|
|
4
|
-
* Mirrors the dating-schema
|
|
5
|
-
* pre-built lookup maps with
|
|
4
|
+
* Mirrors the dating-schema field-helpers.ts pattern:
|
|
5
|
+
* pre-built lookup maps with getFieldOptions() and getFieldMeta().
|
|
6
6
|
*
|
|
7
7
|
* @module udp-schema/field-helpers
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
9
|
+
import { allFieldGroups } from './profile-fields/index.js';
|
|
10
|
+
import { step01ProfileSchema } from './step-01.schema.js';
|
|
11
|
+
import { step02PoliticalSchema } from './step-02.schema.js';
|
|
12
|
+
import { step03ElectoralSchema } from './step-03.schema.js';
|
|
13
|
+
import { step04LeadershipSchema } from './step-04.schema.js';
|
|
14
|
+
import { step05PsychologicalSchema } from './step-05.schema.js';
|
|
15
|
+
import { step06EducationSchema } from './step-06.schema.js';
|
|
16
|
+
import { step07EmploymentSchema } from './step-07.schema.js';
|
|
17
|
+
import { step08NeurodiversitySchema } from './step-08.schema.js';
|
|
18
|
+
import { step09HealthSchema } from './step-09.schema.js';
|
|
19
|
+
import { step10WorldViewSchema } from './step-10.schema.js';
|
|
20
|
+
import { step11ResidenceSchema } from './step-11.schema.js';
|
|
21
|
+
import { step12HouseholdSchema } from './step-12.schema.js';
|
|
22
|
+
// ─── Pre-built lookup maps (like dating-schema) ────────────────────────────
|
|
11
23
|
const optionsMap = new Map();
|
|
12
24
|
const fieldMap = new Map();
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
if (meta.immutable) {
|
|
21
|
-
immutableFieldKeys.push(meta.key);
|
|
22
|
-
}
|
|
23
|
-
const existing = stepFieldsMap.get(meta.step);
|
|
24
|
-
if (existing) {
|
|
25
|
-
existing.push(meta);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
stepFieldsMap.set(meta.step, [meta]);
|
|
25
|
+
for (const group of allFieldGroups) {
|
|
26
|
+
for (const field of group.fields) {
|
|
27
|
+
fieldMap.set(field.key, field);
|
|
28
|
+
if ('options' in field && Array.isArray(field.options)) {
|
|
29
|
+
optionsMap.set(field.key, field.options);
|
|
30
|
+
}
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
// ───
|
|
33
|
+
// ─── Field metadata helpers (like dating-schema) ────────────────────────────
|
|
32
34
|
/**
|
|
33
|
-
* Get the `{ value, label }` options array for a
|
|
35
|
+
* Get the `{ value, label, description }` options array for a field by its key.
|
|
34
36
|
*
|
|
35
37
|
* @example
|
|
36
38
|
* ```ts
|
|
37
|
-
* import {
|
|
38
|
-
* const opts =
|
|
39
|
-
* // → [{ value: '
|
|
39
|
+
* import { getFieldOptions } from 'udp-schema';
|
|
40
|
+
* const opts = getFieldOptions('gender');
|
|
41
|
+
* // → [{ value: 'man', label: 'Man' }, { value: 'woman', label: 'Woman' }, ...]
|
|
40
42
|
* ```
|
|
41
43
|
*/
|
|
42
|
-
export function
|
|
44
|
+
export function getFieldOptions(fieldKey) {
|
|
43
45
|
return optionsMap.get(fieldKey) ?? [];
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
|
-
* Get full field metadata (label, step,
|
|
48
|
+
* Get full field metadata (label, description, step, type, options, etc.) by key.
|
|
47
49
|
*
|
|
48
50
|
* @example
|
|
49
51
|
* ```ts
|
|
50
|
-
* import {
|
|
51
|
-
* const meta =
|
|
52
|
-
* // → { key: '
|
|
52
|
+
* import { getFieldMeta } from 'udp-schema';
|
|
53
|
+
* const meta = getFieldMeta('familyReligion');
|
|
54
|
+
* // → { key: 'familyReligion', label: 'Family Religion', type: 'single_select', step: 1, options: [...], ... }
|
|
53
55
|
* ```
|
|
54
56
|
*/
|
|
55
|
-
export function
|
|
57
|
+
export function getFieldMeta(fieldKey) {
|
|
56
58
|
return fieldMap.get(fieldKey);
|
|
57
59
|
}
|
|
60
|
+
// ─── Step Schema Registry ───────────────────────────────────────────────────
|
|
61
|
+
// biome-ignore lint/suspicious/noExplicitAny: Zod schema types vary per step
|
|
62
|
+
const STEP_SCHEMAS = {
|
|
63
|
+
1: step01ProfileSchema,
|
|
64
|
+
2: step02PoliticalSchema,
|
|
65
|
+
3: step03ElectoralSchema,
|
|
66
|
+
4: step04LeadershipSchema,
|
|
67
|
+
5: step05PsychologicalSchema,
|
|
68
|
+
6: step06EducationSchema,
|
|
69
|
+
7: step07EmploymentSchema,
|
|
70
|
+
8: step08NeurodiversitySchema,
|
|
71
|
+
9: step09HealthSchema,
|
|
72
|
+
10: step10WorldViewSchema,
|
|
73
|
+
11: step11ResidenceSchema,
|
|
74
|
+
12: step12HouseholdSchema,
|
|
75
|
+
};
|
|
58
76
|
/**
|
|
59
|
-
* Get
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* import { getUdpStepFields } from 'udp-schema';
|
|
64
|
-
* const step5Fields = getUdpStepFields(5);
|
|
65
|
-
* // → [{ key: 'desireToBeLeader', ... }, { key: 'desiredPoliticalPosition', ... }, ...]
|
|
66
|
-
* ```
|
|
77
|
+
* Get the Zod schema for a given step number.
|
|
78
|
+
* Use `.partial().parse(data)` for sub-step saves.
|
|
67
79
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
80
|
+
// biome-ignore lint/suspicious/noExplicitAny: Zod schema types vary per step
|
|
81
|
+
export function getStepSchema(stepNumber) {
|
|
82
|
+
return STEP_SCHEMAS[stepNumber];
|
|
70
83
|
}
|
|
71
84
|
/**
|
|
72
85
|
* Get the list of field keys that are immutable after volunteer approval.
|
|
73
|
-
* These fields can only be changed by a volunteer in survey-mode once approved.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* import { getImmutableFields } from 'udp-schema';
|
|
78
|
-
* const locked = getImmutableFields();
|
|
79
|
-
* // → ['firstName', 'middleName', 'lastName', 'gender', 'dateOfBirth', 'phonePrimary']
|
|
80
|
-
* ```
|
|
81
86
|
*/
|
|
82
87
|
export function getImmutableFields() {
|
|
83
|
-
return
|
|
88
|
+
return ['firstName', 'middleName', 'lastName', 'gender', 'dateOfBirth'];
|
|
84
89
|
}
|
|
85
90
|
//# sourceMappingURL=field-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-helpers.js","sourceRoot":"","sources":["../src/field-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"field-helpers.js","sourceRoot":"","sources":["../src/field-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,8EAA8E;AAE9E,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkC,CAAC;AAC7D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAwB,CAAC;AAEjD,KAAK,MAAM,KAAK,IAAI,cAAc,EAAE,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACjC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,IAAI,SAAS,IAAI,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;YACvD,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;AACH,CAAC;AAED,+EAA+E;AAE/E;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;AACxC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB;IAC3C,OAAO,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAED,+EAA+E;AAE/E,6EAA6E;AAC7E,MAAM,YAAY,GAAqC;IACrD,CAAC,EAAE,mBAAmB;IACtB,CAAC,EAAE,qBAAqB;IACxB,CAAC,EAAE,qBAAqB;IACxB,CAAC,EAAE,sBAAsB;IACzB,CAAC,EAAE,yBAAyB;IAC5B,CAAC,EAAE,qBAAqB;IACxB,CAAC,EAAE,sBAAsB;IACzB,CAAC,EAAE,0BAA0B;IAC7B,CAAC,EAAE,kBAAkB;IACrB,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,qBAAqB;IACzB,EAAE,EAAE,qBAAqB;CAC1B,CAAC;AAEF;;;GAGG;AACH,6EAA6E;AAC7E,MAAM,UAAU,aAAa,CAAC,UAAkB;IAC9C,OAAO,YAAY,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;AAC1E,CAAC","sourcesContent":["/**\n * Convenience helpers for accessing UDP field metadata and step schemas.\n *\n * Mirrors the dating-schema field-helpers.ts pattern:\n * pre-built lookup maps with getFieldOptions() and getFieldMeta().\n *\n * @module udp-schema/field-helpers\n */\n\nimport type { z } from 'zod';\nimport { allFieldGroups } from './profile-fields/index.js';\nimport type { FieldOption, ProfileField } from './profile-fields/types.js';\nimport { step01ProfileSchema } from './step-01.schema.js';\nimport { step02PoliticalSchema } from './step-02.schema.js';\nimport { step03ElectoralSchema } from './step-03.schema.js';\nimport { step04LeadershipSchema } from './step-04.schema.js';\nimport { step05PsychologicalSchema } from './step-05.schema.js';\nimport { step06EducationSchema } from './step-06.schema.js';\nimport { step07EmploymentSchema } from './step-07.schema.js';\nimport { step08NeurodiversitySchema } from './step-08.schema.js';\nimport { step09HealthSchema } from './step-09.schema.js';\nimport { step10WorldViewSchema } from './step-10.schema.js';\nimport { step11ResidenceSchema } from './step-11.schema.js';\nimport { step12HouseholdSchema } from './step-12.schema.js';\n\n// ─── Pre-built lookup maps (like dating-schema) ────────────────────────────\n\nconst optionsMap = new Map<string, readonly FieldOption[]>();\nconst fieldMap = new Map<string, ProfileField>();\n\nfor (const group of allFieldGroups) {\n for (const field of group.fields) {\n fieldMap.set(field.key, field);\n if ('options' in field && Array.isArray(field.options)) {\n optionsMap.set(field.key, field.options);\n }\n }\n}\n\n// ─── Field metadata helpers (like dating-schema) ────────────────────────────\n\n/**\n * Get the `{ value, label, description }` options array for a field by its key.\n *\n * @example\n * ```ts\n * import { getFieldOptions } from 'udp-schema';\n * const opts = getFieldOptions('gender');\n * // → [{ value: 'man', label: 'Man' }, { value: 'woman', label: 'Woman' }, ...]\n * ```\n */\nexport function getFieldOptions(fieldKey: string): readonly FieldOption[] {\n return optionsMap.get(fieldKey) ?? [];\n}\n\n/**\n * Get full field metadata (label, description, step, type, options, etc.) by key.\n *\n * @example\n * ```ts\n * import { getFieldMeta } from 'udp-schema';\n * const meta = getFieldMeta('familyReligion');\n * // → { key: 'familyReligion', label: 'Family Religion', type: 'single_select', step: 1, options: [...], ... }\n * ```\n */\nexport function getFieldMeta(fieldKey: string): ProfileField | undefined {\n return fieldMap.get(fieldKey);\n}\n\n// ─── Step Schema Registry ───────────────────────────────────────────────────\n\n// biome-ignore lint/suspicious/noExplicitAny: Zod schema types vary per step\nconst STEP_SCHEMAS: Record<number, z.ZodObject<any>> = {\n 1: step01ProfileSchema,\n 2: step02PoliticalSchema,\n 3: step03ElectoralSchema,\n 4: step04LeadershipSchema,\n 5: step05PsychologicalSchema,\n 6: step06EducationSchema,\n 7: step07EmploymentSchema,\n 8: step08NeurodiversitySchema,\n 9: step09HealthSchema,\n 10: step10WorldViewSchema,\n 11: step11ResidenceSchema,\n 12: step12HouseholdSchema,\n};\n\n/**\n * Get the Zod schema for a given step number.\n * Use `.partial().parse(data)` for sub-step saves.\n */\n// biome-ignore lint/suspicious/noExplicitAny: Zod schema types vary per step\nexport function getStepSchema(stepNumber: number): z.ZodObject<any> | undefined {\n return STEP_SCHEMAS[stepNumber];\n}\n\n/**\n * Get the list of field keys that are immutable after volunteer approval.\n */\nexport function getImmutableFields(): readonly string[] {\n return ['firstName', 'middleName', 'lastName', 'gender', 'dateOfBirth'];\n}\n"]}
|
package/dist/field-meta.d.ts
CHANGED
|
@@ -1,40 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* UDP Field Metadata
|
|
3
|
-
* ==================
|
|
4
|
-
* Single source of truth for field-level metadata across all 14 UDP steps.
|
|
5
|
-
* Both frontend and backend import this — NO hardcoded option arrays elsewhere.
|
|
2
|
+
* UDP Field Metadata — backward-compatible re-exports from profile-fields.
|
|
6
3
|
*
|
|
7
|
-
*
|
|
4
|
+
* This file re-exports option arrays under SCREAMING_CASE names for
|
|
5
|
+
* backward compatibility with existing frontend imports.
|
|
6
|
+
* New code should import directly from profile-fields.
|
|
8
7
|
*
|
|
9
8
|
* @module udp-schema/field-meta
|
|
10
9
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** i18n key for the field label */
|
|
22
|
-
labelKey: string;
|
|
23
|
-
/** i18n key for help text / description */
|
|
24
|
-
descriptionKey?: string;
|
|
25
|
-
/** Component type hint (matches frontend FieldComponentType) */
|
|
26
|
-
component: string;
|
|
27
|
-
/** Options for select / radio / multiCheckbox / genderSelector fields */
|
|
28
|
-
options?: readonly UdpFieldOption[];
|
|
29
|
-
/** Whether the field is required to complete the step */
|
|
30
|
-
required?: boolean;
|
|
31
|
-
/** i18n key for the toast shown after saving this field's step */
|
|
32
|
-
successMessageKey?: string;
|
|
33
|
-
/**
|
|
34
|
-
* If true, this field is locked after first volunteer approval.
|
|
35
|
-
* Only a volunteer (survey-mode) can change it once locked.
|
|
36
|
-
*/
|
|
37
|
-
immutable?: boolean;
|
|
38
|
-
}
|
|
39
|
-
export declare const UDP_FIELD_META: Record<string, UdpFieldMeta>;
|
|
10
|
+
export type { FieldOption as UdpFieldOption } from './profile-fields/types.js';
|
|
11
|
+
export { genderOptions as GENDER_OPTIONS, religionOptions as RELIGION_OPTIONS, languageOptions as LANGUAGE_OPTIONS, reservationOptions as RESERVATION_STATUS_OPTIONS, minorityOptions as MINORITY_STATUS_OPTIONS, } from './profile-fields/01-profile.js';
|
|
12
|
+
export { politicalSpectrumOptions as POLITICAL_SPECTRUM_OPTIONS, partyOptions as PARTY_OPTIONS, civicEngagementOptions as CIVIC_ENGAGEMENT_OPTIONS, } from './profile-fields/02-political.js';
|
|
13
|
+
export { votingIssueOptions as VOTING_ISSUES_OPTIONS } from './profile-fields/03-electoral.js';
|
|
14
|
+
export { leadershipSkillsetOptions as LEADERSHIP_SKILLSET_OPTIONS } from './profile-fields/04-leadership.js';
|
|
15
|
+
export { qualificationOptions as QUALIFICATION_OPTIONS } from './profile-fields/06-education.js';
|
|
16
|
+
export { neurodiversityConditionOptions as NEURODIVERSITY_CONDITIONS_OPTIONS, sensoryPreferenceOptions as SENSORY_PREFERENCES_OPTIONS, supportNeedOptions as SUPPORT_NEEDS_OPTIONS, } from './profile-fields/08-neurodiversity.js';
|
|
17
|
+
export { disabilityOptions as DISABILITY_STATUS_OPTIONS, substanceUseOptions as SUBSTANCE_USE_OPTIONS, } from './profile-fields/09-health.js';
|
|
18
|
+
export { lgbtqStatementOptions as LGBTQ_STATEMENTS_OPTIONS, transgenderStatementOptions as TRANSGENDER_STATEMENTS_OPTIONS, casteDiscriminationPlaceOptions as CASTE_DISCRIMINATION_PLACES_OPTIONS, } from './profile-fields/10-worldview.js';
|
|
19
|
+
export { familyMemberOptions as FAMILY_MEMBERS_OPTIONS, digitalAccessOptions as DIGITAL_ACCESS_OPTIONS, } from './profile-fields/12-household.js';
|
|
40
20
|
//# sourceMappingURL=field-meta.d.ts.map
|
package/dist/field-meta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-meta.d.ts","sourceRoot":"","sources":["../src/field-meta.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"field-meta.d.ts","sourceRoot":"","sources":["../src/field-meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,eAAe,IAAI,gBAAgB,EACnC,eAAe,IAAI,gBAAgB,EACnC,kBAAkB,IAAI,0BAA0B,EAChD,eAAe,IAAI,uBAAuB,GAC3C,MAAM,gCAAgC,CAAC;AAExC,OAAO,EACL,wBAAwB,IAAI,0BAA0B,EACtD,YAAY,IAAI,aAAa,EAC7B,sBAAsB,IAAI,wBAAwB,GACnD,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,kBAAkB,IAAI,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE/F,OAAO,EAAE,yBAAyB,IAAI,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AAE7G,OAAO,EAAE,oBAAoB,IAAI,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEjG,OAAO,EACL,8BAA8B,IAAI,iCAAiC,EACnE,wBAAwB,IAAI,2BAA2B,EACvD,kBAAkB,IAAI,qBAAqB,GAC5C,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EACL,iBAAiB,IAAI,yBAAyB,EAC9C,mBAAmB,IAAI,qBAAqB,GAC7C,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EACL,qBAAqB,IAAI,wBAAwB,EACjD,2BAA2B,IAAI,8BAA8B,EAC7D,+BAA+B,IAAI,mCAAmC,GACvE,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,IAAI,sBAAsB,EAC7C,oBAAoB,IAAI,sBAAsB,GAC/C,MAAM,kCAAkC,CAAC"}
|