policyengine-household-wizard 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.
Files changed (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +116 -0
  3. package/dist/WizardReviewList-De9RTK_4.js +245 -0
  4. package/dist/WizardReviewList-tfP9LcqU.cjs +1 -0
  5. package/dist/index.cjs +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +35 -0
  9. package/dist/primitives/WizardNavigation.d.ts +19 -0
  10. package/dist/primitives/WizardNavigation.d.ts.map +1 -0
  11. package/dist/primitives/WizardOptionCard.d.ts +9 -0
  12. package/dist/primitives/WizardOptionCard.d.ts.map +1 -0
  13. package/dist/primitives/WizardProgress.d.ts +8 -0
  14. package/dist/primitives/WizardProgress.d.ts.map +1 -0
  15. package/dist/primitives/WizardReviewList.d.ts +14 -0
  16. package/dist/primitives/WizardReviewList.d.ts.map +1 -0
  17. package/dist/primitives/index.d.ts +11 -0
  18. package/dist/primitives/index.d.ts.map +1 -0
  19. package/dist/primitives/types.d.ts +30 -0
  20. package/dist/primitives/types.d.ts.map +1 -0
  21. package/dist/primitives/useWizardSteps.d.ts +3 -0
  22. package/dist/primitives/useWizardSteps.d.ts.map +1 -0
  23. package/dist/primitives.cjs +1 -0
  24. package/dist/primitives.d.ts +1 -0
  25. package/dist/primitives.js +8 -0
  26. package/dist/us-household/adapters/index.d.ts +2 -0
  27. package/dist/us-household/adapters/index.d.ts.map +1 -0
  28. package/dist/us-household/adapters/v1Payload.d.ts +68 -0
  29. package/dist/us-household/adapters/v1Payload.d.ts.map +1 -0
  30. package/dist/us-household/counties.d.ts +25 -0
  31. package/dist/us-household/counties.d.ts.map +1 -0
  32. package/dist/us-household/draft.d.ts +28 -0
  33. package/dist/us-household/draft.d.ts.map +1 -0
  34. package/dist/us-household/index.d.ts +9 -0
  35. package/dist/us-household/index.d.ts.map +1 -0
  36. package/dist/us-household/normalize.d.ts +11 -0
  37. package/dist/us-household/normalize.d.ts.map +1 -0
  38. package/dist/us-household/serialize.d.ts +4 -0
  39. package/dist/us-household/serialize.d.ts.map +1 -0
  40. package/dist/us-household/states.d.ts +15 -0
  41. package/dist/us-household/states.d.ts.map +1 -0
  42. package/dist/us-household/types.d.ts +80 -0
  43. package/dist/us-household/types.d.ts.map +1 -0
  44. package/dist/us-household/validate.d.ts +13 -0
  45. package/dist/us-household/validate.d.ts.map +1 -0
  46. package/dist/us-household-adapters.cjs +1 -0
  47. package/dist/us-household-adapters.d.ts +1 -0
  48. package/dist/us-household-adapters.js +92 -0
  49. package/dist/us-household.cjs +1 -0
  50. package/dist/us-household.d.ts +1 -0
  51. package/dist/us-household.js +556 -0
  52. package/package.json +76 -0
  53. package/src/index.ts +2 -0
  54. package/src/primitives/WizardNavigation.tsx +85 -0
  55. package/src/primitives/WizardOptionCard.tsx +55 -0
  56. package/src/primitives/WizardProgress.tsx +50 -0
  57. package/src/primitives/WizardReviewList.tsx +73 -0
  58. package/src/primitives/index.ts +15 -0
  59. package/src/primitives/types.ts +32 -0
  60. package/src/primitives/useWizardSteps.ts +150 -0
  61. package/src/styles.css +183 -0
  62. package/src/us-household/adapters/index.ts +15 -0
  63. package/src/us-household/adapters/v1Payload.ts +213 -0
  64. package/src/us-household/counties.ts +96 -0
  65. package/src/us-household/data/counties-by-state.json +12802 -0
  66. package/src/us-household/draft.ts +130 -0
  67. package/src/us-household/index.ts +59 -0
  68. package/src/us-household/normalize.ts +251 -0
  69. package/src/us-household/serialize.ts +153 -0
  70. package/src/us-household/states.ts +168 -0
  71. package/src/us-household/types.ts +82 -0
  72. package/src/us-household/validate.ts +129 -0
@@ -0,0 +1,68 @@
1
+ import type { USHouseholdDraft } from '../types';
2
+ /**
3
+ * The shape of a PolicyEngine US "situation" / household-creation payload at
4
+ * the wire level. Variables are year-keyed; person/group keys are arbitrary
5
+ * strings (callers pick them).
6
+ */
7
+ export type V1ValueMap = Record<string, number | string | boolean | null>;
8
+ export type V1FieldValue = V1ValueMap | string[] | undefined;
9
+ /**
10
+ * A person record carries only year-keyed variable maps. `members` belongs on
11
+ * group records, never on people.
12
+ */
13
+ export type V1PersonRecord = Record<string, V1ValueMap | undefined>;
14
+ /**
15
+ * A group record always carries `members` plus zero-or-more year-keyed
16
+ * variable maps.
17
+ */
18
+ export type V1GroupRecord = {
19
+ members: string[];
20
+ } & Record<string, V1FieldValue>;
21
+ export type V1EntityRecord = V1PersonRecord | V1GroupRecord;
22
+ export type V1PersonCollection = Record<string, V1PersonRecord>;
23
+ export type V1GroupCollection = Record<string, V1GroupRecord>;
24
+ /** @deprecated Prefer V1PersonCollection or V1GroupCollection. */
25
+ export type V1EntityCollection = Record<string, V1EntityRecord>;
26
+ export interface V1HouseholdSituation {
27
+ people: V1PersonCollection;
28
+ families?: V1GroupCollection;
29
+ marital_units?: V1GroupCollection;
30
+ tax_units?: V1GroupCollection;
31
+ spm_units?: V1GroupCollection;
32
+ households?: V1GroupCollection;
33
+ }
34
+ /**
35
+ * Matches policyengine-app-v2's `V1HouseholdCreateEnvelope` so `fromUSDraft`
36
+ * adapters can pass the envelope straight into `Household.fromV1CreationPayload`.
37
+ */
38
+ export interface V1HouseholdEnvelope {
39
+ country_id: 'us';
40
+ label?: string | null;
41
+ data: V1HouseholdSituation;
42
+ }
43
+ export interface ToV1PayloadOptions {
44
+ /**
45
+ * Optional override for group keys. Defaults to short, lower-case keys
46
+ * (`"household"`, `"tax_unit"`, etc.). Pass `"verbose"` for `"your household"`
47
+ * style names compatible with app-v2's builder.
48
+ */
49
+ groupKeyStyle?: 'short' | 'verbose';
50
+ /**
51
+ * If true, attaches member ids to the marital unit. Off by default because
52
+ * cliff-watch and other consumers send `marital_units: {}` and have it work.
53
+ */
54
+ includeMaritalUnit?: boolean;
55
+ /**
56
+ * Optional label for the envelope. Surfaces as `label` on the V1
57
+ * creation/metadata response.
58
+ */
59
+ label?: string | null;
60
+ }
61
+ export declare function toV1HouseholdPayload(draft: USHouseholdDraft, options?: ToV1PayloadOptions): V1HouseholdEnvelope;
62
+ /**
63
+ * Convenience that returns just the inner `V1HouseholdSituation` — useful for
64
+ * callers that POST to `/calculate` or otherwise need the situation directly
65
+ * without the envelope wrapper.
66
+ */
67
+ export declare function toV1HouseholdSituation(draft: USHouseholdDraft, options?: ToV1PayloadOptions): V1HouseholdSituation;
68
+ //# sourceMappingURL=v1Payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"v1Payload.d.ts","sourceRoot":"","sources":["../../../src/us-household/adapters/v1Payload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAIjB,MAAM,UAAU,CAAC;AAElB;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;AAE7D;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAC,CAAC;AAEpE;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEjF,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,aAAa,CAAC;AAC5D,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAChE,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAC9D,kEAAkE;AAClE,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEhE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IAC7B,aAAa,CAAC,EAAE,iBAAiB,CAAC;IAClC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,IAAI,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,oBAAoB,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAyED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,kBAAuB,GAC/B,mBAAmB,CAuDrB;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,kBAAuB,GAC/B,oBAAoB,CAEtB"}
@@ -0,0 +1,25 @@
1
+ export interface County {
2
+ /** PolicyEngine US county enum code (e.g. "ALAMEDA_COUNTY_CA"). */
3
+ code: string;
4
+ /** Display name without the trailing state segment (e.g. "Alameda County"). */
5
+ name: string;
6
+ }
7
+ declare const DATA: Record<string, County[]>;
8
+ /**
9
+ * Counties grouped by two-letter state code, sorted by name. The data ships
10
+ * inline with the package so the wizard can render a county dropdown without
11
+ * any network call.
12
+ *
13
+ * To refresh from PolicyEngine US metadata, run `bun run regenerate-counties`.
14
+ */
15
+ export declare function getCountiesByState(stateCode: string | null | undefined): County[];
16
+ export declare function isCountyCode(value: unknown): value is string;
17
+ export declare function getCountyName(code: string | null | undefined): string | null;
18
+ /**
19
+ * Resolve a free-text county name (legacy input shape used by Coverage Compass
20
+ * and others) to a PolicyEngine county code. Matching is case-insensitive and
21
+ * ignores common suffixes like "County", "Parish", "Borough".
22
+ */
23
+ export declare function resolveCountyCode(stateCode: string | null | undefined, countyInput: string | null | undefined): string | null;
24
+ export { DATA as _rawCountyData };
25
+ //# sourceMappingURL=counties.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"counties.d.ts","sourceRoot":"","sources":["../../src/us-household/counties.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM;IACrB,mEAAmE;IACnE,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;CACd;AAED,QAAA,MAAM,IAAI,EAAsB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAAE,CAKjF;AAyBD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE5D;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAY5E;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACrC,MAAM,GAAG,IAAI,CAmBf;AAED,OAAO,EAAE,IAAI,IAAI,cAAc,EAAE,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { USHouseholdDraft, USPersonDraft, USPersonKind } from './types';
2
+ export declare const DEFAULT_HOUSEHOLD_YEAR: number;
3
+ /**
4
+ * Returns a draft with no defaults for state, ages, or marital status. The
5
+ * wizard must explicitly capture each of these before the household is valid.
6
+ *
7
+ * `year` defaults to the current UTC year so calculations have a target period;
8
+ * apps that want a fixed year can pass one in.
9
+ */
10
+ export declare function createBlankDraft(year?: number): USHouseholdDraft;
11
+ /**
12
+ * Returns a deep clone of an existing draft. Used by apps that want to keep an
13
+ * "edit baseline" separate from the in-progress draft.
14
+ */
15
+ export declare function cloneDraft(draft: USHouseholdDraft): USHouseholdDraft;
16
+ export declare function createPerson(kind: USPersonKind, existingPeople?: USPersonDraft[], partial?: Partial<USPersonDraft>): USPersonDraft;
17
+ export declare function addPerson(draft: USHouseholdDraft, kind: USPersonKind, partial?: Partial<USPersonDraft>): USHouseholdDraft;
18
+ export declare function removePerson(draft: USHouseholdDraft, personId: string): USHouseholdDraft;
19
+ export declare function updatePerson(draft: USHouseholdDraft, personId: string, changes: Partial<USPersonDraft>): USHouseholdDraft;
20
+ export declare function getAdults(draft: USHouseholdDraft): USPersonDraft[];
21
+ export declare function getDependents(draft: USHouseholdDraft): USPersonDraft[];
22
+ /**
23
+ * Reconcile the people array with the chosen marital status. Switching to
24
+ * "married" with one adult adds a partner; switching to "single" with two or
25
+ * more adults removes the trailing adults beyond the first.
26
+ */
27
+ export declare function applyMaritalStatusChange(draft: USHouseholdDraft, maritalStatus: USHouseholdDraft['maritalStatus']): USHouseholdDraft;
28
+ //# sourceMappingURL=draft.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"draft.d.ts","sourceRoot":"","sources":["../../src/us-household/draft.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE7E,eAAO,MAAM,sBAAsB,QAA8B,CAAC;AAiBlE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAA+B,GAAG,gBAAgB,CASxF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAapE;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,YAAY,EAClB,cAAc,GAAE,aAAa,EAAO,EACpC,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,aAAa,CAOf;AAED,wBAAgB,SAAS,CACvB,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,YAAY,EAClB,OAAO,GAAE,OAAO,CAAC,aAAa,CAAM,GACnC,gBAAgB,CAGlB;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAExF;AAED,wBAAgB,YAAY,CAC1B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAC9B,gBAAgB,CAOlB;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa,EAAE,CAElE;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,aAAa,EAAE,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,gBAAgB,EACvB,aAAa,EAAE,gBAAgB,CAAC,eAAe,CAAC,GAC/C,gBAAgB,CAkBlB"}
@@ -0,0 +1,9 @@
1
+ export type { USHouseholdDraft, USMaritalStatus, USPersonDraft, USPersonFlags, USPersonIncomes, USPersonKind, ValidationIssue, ValidationResult, } from './types';
2
+ export { DEFAULT_HOUSEHOLD_YEAR, createBlankDraft, cloneDraft, createPerson, addPerson, removePerson, updatePerson, getAdults, getDependents, applyMaritalStatusChange, } from './draft';
3
+ export { normalizeLegacyDraft } from './normalize';
4
+ export { validate, isComplete, type ValidateOptions } from './validate';
5
+ export { serializeDraft, deserializeDraft } from './serialize';
6
+ export { US_STATES, isUSStateCode, getStateName, getStateFromZip, type USState, } from './states';
7
+ export { getCountiesByState, getCountyName, isCountyCode, resolveCountyCode, type County, } from './counties';
8
+ export { toV1HouseholdPayload, toV1HouseholdSituation, type V1HouseholdEnvelope, type V1HouseholdSituation, type V1ValueMap, type V1FieldValue, type V1PersonRecord, type V1GroupRecord, type V1PersonCollection, type V1GroupCollection, type V1EntityRecord, type V1EntityCollection, type ToV1PayloadOptions, } from './adapters/v1Payload';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/us-household/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,wBAAwB,GACzB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EACZ,eAAe,EACf,KAAK,OAAO,GACb,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { USHouseholdDraft } from './types';
2
+ /**
3
+ * Best-effort normalization from legacy household shapes (cliff-watch's people
4
+ * array, Coverage Compass's flat fields, ad-hoc test fixtures) into the shared
5
+ * draft contract. Unknown fields are dropped silently; apps that need to keep
6
+ * extras should hand-edit the result.
7
+ */
8
+ export declare function normalizeLegacyDraft(raw: unknown, options?: {
9
+ year?: number;
10
+ }): USHouseholdDraft;
11
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/us-household/normalize.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EAIjB,MAAM,SAAS,CAAC;AAyIjB;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9B,gBAAgB,CAgGlB"}
@@ -0,0 +1,4 @@
1
+ import type { USHouseholdDraft } from './types';
2
+ export declare function serializeDraft(draft: USHouseholdDraft): string;
3
+ export declare function deserializeDraft(query: string | URLSearchParams): USHouseholdDraft;
4
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/us-household/serialize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,SAAS,CAAC;AA6F/D,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAW9D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,gBAAgB,CA6ClF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * US states and territories supported by PolicyEngine US.
3
+ *
4
+ * Codes match the `state_code` enum in the PolicyEngine US country model so the
5
+ * draft's `state` field can be passed through to API payloads unchanged.
6
+ */
7
+ export interface USState {
8
+ code: string;
9
+ name: string;
10
+ }
11
+ export declare const US_STATES: ReadonlyArray<USState>;
12
+ export declare function isUSStateCode(value: unknown): value is string;
13
+ export declare function getStateName(code: string | null | undefined): string | null;
14
+ export declare function getStateFromZip(zip: string | null | undefined): string | null;
15
+ //# sourceMappingURL=states.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"states.d.ts","sourceRoot":"","sources":["../../src/us-household/states.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,eAAO,MAAM,SAAS,EAAE,aAAa,CAAC,OAAO,CAoD5C,CAAC;AAOF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAE7D;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAK3E;AAoED,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAoB7E"}
@@ -0,0 +1,80 @@
1
+ export type USMaritalStatus = 'single' | 'married';
2
+ export type USPersonKind = 'adult' | 'dependent';
3
+ /**
4
+ * Person-level fields that the wizard surfaces uniformly across apps. Apps that
5
+ * do not collect a flag should leave it `undefined`; the adapters treat
6
+ * `undefined` differently from `false` (omitted vs. explicitly set).
7
+ */
8
+ export interface USPersonFlags {
9
+ isDisabled?: boolean;
10
+ isBlind?: boolean;
11
+ isFullTimeStudent?: boolean;
12
+ isPregnant?: boolean;
13
+ needsCare?: boolean;
14
+ }
15
+ export interface USPersonIncomes {
16
+ /** Wages and salaries; "employment_income" in PolicyEngine US. */
17
+ employmentIncome?: number;
18
+ selfEmploymentIncome?: number;
19
+ socialSecurityIncome?: number;
20
+ ssiAmount?: number;
21
+ ssdiAmount?: number;
22
+ pensionIncome?: number;
23
+ dividendIncome?: number;
24
+ taxableInterestIncome?: number;
25
+ rentalIncome?: number;
26
+ unemploymentCompensation?: number;
27
+ childSupportReceived?: number;
28
+ miscellaneousIncome?: number;
29
+ }
30
+ export interface USPersonDraft extends USPersonFlags, USPersonIncomes {
31
+ /** Stable identifier — used as the person key in the API payload. */
32
+ id: string;
33
+ kind: USPersonKind;
34
+ /** Age in whole years. `null` means the user has not entered a value yet. */
35
+ age: number | null;
36
+ /** Optional human-friendly label for review screens. */
37
+ label?: string;
38
+ /**
39
+ * App-controlled fields the wizard core does not understand. Adapters that
40
+ * own the app's payload can read this map; the shared US adapters ignore it.
41
+ */
42
+ extras?: Record<string, unknown>;
43
+ }
44
+ export interface USHouseholdDraft {
45
+ /** Two-letter state code (e.g. "CA"). `null` means the user has not picked. */
46
+ state: string | null;
47
+ /** PolicyEngine county enum code (e.g. "ALAMEDA_COUNTY_CA"). */
48
+ county: string | null;
49
+ /** Optional ZIP code captured at intake. Used to derive `state` when set. */
50
+ zip: string | null;
51
+ /**
52
+ * Marital status — explicitly NOT filing status. Apps that need a filing
53
+ * status must derive it (e.g. from presence of dependents).
54
+ */
55
+ maritalStatus: USMaritalStatus | null;
56
+ /**
57
+ * People in the household. Adults and dependents share the same shape; kind
58
+ * differentiates them. Order is significant for UI labels ("Adult 1", etc.).
59
+ */
60
+ people: USPersonDraft[];
61
+ /** Year the household is being modeled for. */
62
+ year: number;
63
+ /** App-controlled household-level fields ignored by the shared adapters. */
64
+ extras?: Record<string, unknown>;
65
+ }
66
+ export interface ValidationIssue {
67
+ /** Stable identifier for the rule (e.g. "state.required"). */
68
+ code: string;
69
+ /** Path into the draft (dotted), e.g. "state" or "people[1].age". */
70
+ path: string;
71
+ message: string;
72
+ }
73
+ export type ValidationResult = {
74
+ ok: true;
75
+ issues: never[];
76
+ } | {
77
+ ok: false;
78
+ issues: ValidationIssue[];
79
+ };
80
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/us-household/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,SAAS,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,WAAW,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa,EAAE,eAAe;IACnE,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,6EAA6E;IAC7E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,gBAAgB;IAC/B,+EAA+E;IAC/E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gEAAgE;IAChE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,6EAA6E;IAC7E,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB;;;OAGG;IACH,aAAa,EAAE,eAAe,GAAG,IAAI,CAAC;IACtC;;;OAGG;IACH,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,KAAK,EAAE,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAE,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { USHouseholdDraft, ValidationResult } from './types';
2
+ export interface ValidateOptions {
3
+ /**
4
+ * If true, require a county selection in addition to state. Apps where the
5
+ * county affects results (e.g. local taxes) can opt into this.
6
+ */
7
+ requireCounty?: boolean;
8
+ /** If true, require every person to have an age set. Defaults to true. */
9
+ requireAges?: boolean;
10
+ }
11
+ export declare function validate(draft: USHouseholdDraft, options?: ValidateOptions): ValidationResult;
12
+ export declare function isComplete(draft: USHouseholdDraft, options?: ValidateOptions): boolean;
13
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/us-household/validate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAmB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEnF,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAgB,QAAQ,CACtB,KAAK,EAAE,gBAAgB,EACvB,OAAO,GAAE,eAAoB,GAC5B,gBAAgB,CA2GlB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAE1F"}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v={household:"household",family:"family",taxUnit:"tax_unit",spmUnit:"spm_unit",maritalUnit:"marital_unit"},I={household:"your household",family:"your family",taxUnit:"your tax unit",spmUnit:"your household",maritalUnit:"your marital unit"},S={isDisabled:"is_disabled",isBlind:"is_blind",isFullTimeStudent:"is_full_time_student",isPregnant:"is_pregnant",needsCare:"is_incapable_of_self_care"},U={employmentIncome:"employment_income",selfEmploymentIncome:"self_employment_income",socialSecurityIncome:"social_security",ssiAmount:"ssi",ssdiAmount:"social_security_disability",pensionIncome:"taxable_pension_income",dividendIncome:"qualified_dividend_income",taxableInterestIncome:"taxable_interest_income",rentalIncome:"rental_income",unemploymentCompensation:"unemployment_compensation",childSupportReceived:"child_support_received",miscellaneousIncome:"miscellaneous_income"};function s(e,i){return{[e]:i}}function x(e,i){const n={};e.age!==null&&e.age!==void 0&&(n.age=s(i,e.age)),e.kind==="dependent"&&(n.is_tax_unit_dependent=s(i,!0));for(const[l,a]of Object.entries(S)){const t=e[l];t!==void 0&&(n[a]=s(i,t))}for(const[l,a]of Object.entries(U)){const t=e[l];t!=null&&(n[a]=s(i,t))}return n}function p(e,i={}){const{groupKeyStyle:n="short",includeMaritalUnit:l=!1,label:a=null}=i,t=n==="verbose"?I:v,m=String(e.year),u=e.people.map(o=>o.id),d={};for(const o of e.people)d[o.id]=x(o,m);const c={members:[...u]};e.state&&(c.state_name=s(m,e.state)),e.county&&(c.county=s(m,e.county));const y={[t.family]:{members:[...u]}},f={[t.taxUnit]:{members:[...u]}},b={[t.spmUnit]:{members:[...u]}},h={[t.household]:c},_={};if(l){const o=e.people.filter(r=>r.kind==="adult");_[t.maritalUnit]={members:o.slice(0,2).map(r=>r.id)}}return{country_id:"us",label:a,data:{people:d,families:y,marital_units:_,tax_units:f,spm_units:b,households:h}}}function g(e,i={}){return p(e,i).data}exports.toV1HouseholdPayload=p;exports.toV1HouseholdSituation=g;
@@ -0,0 +1 @@
1
+ export * from './us-household/adapters/index';
@@ -0,0 +1,92 @@
1
+ const h = {
2
+ household: "household",
3
+ family: "family",
4
+ taxUnit: "tax_unit",
5
+ spmUnit: "spm_unit",
6
+ maritalUnit: "marital_unit"
7
+ }, I = {
8
+ household: "your household",
9
+ family: "your family",
10
+ taxUnit: "your tax unit",
11
+ spmUnit: "your household",
12
+ // app-v2 uses the same label for SPM unit
13
+ maritalUnit: "your marital unit"
14
+ }, U = {
15
+ isDisabled: "is_disabled",
16
+ isBlind: "is_blind",
17
+ isFullTimeStudent: "is_full_time_student",
18
+ isPregnant: "is_pregnant",
19
+ needsCare: "is_incapable_of_self_care"
20
+ }, v = {
21
+ employmentIncome: "employment_income",
22
+ selfEmploymentIncome: "self_employment_income",
23
+ socialSecurityIncome: "social_security",
24
+ ssiAmount: "ssi",
25
+ ssdiAmount: "social_security_disability",
26
+ pensionIncome: "taxable_pension_income",
27
+ dividendIncome: "qualified_dividend_income",
28
+ taxableInterestIncome: "taxable_interest_income",
29
+ rentalIncome: "rental_income",
30
+ unemploymentCompensation: "unemployment_compensation",
31
+ childSupportReceived: "child_support_received",
32
+ miscellaneousIncome: "miscellaneous_income"
33
+ };
34
+ function s(e, n) {
35
+ return { [e]: n };
36
+ }
37
+ function x(e, n) {
38
+ const i = {};
39
+ e.age !== null && e.age !== void 0 && (i.age = s(n, e.age)), e.kind === "dependent" && (i.is_tax_unit_dependent = s(n, !0));
40
+ for (const [l, a] of Object.entries(U)) {
41
+ const t = e[l];
42
+ t !== void 0 && (i[a] = s(n, t));
43
+ }
44
+ for (const [l, a] of Object.entries(v)) {
45
+ const t = e[l];
46
+ t != null && (i[a] = s(n, t));
47
+ }
48
+ return i;
49
+ }
50
+ function S(e, n = {}) {
51
+ const { groupKeyStyle: i = "short", includeMaritalUnit: l = !1, label: a = null } = n, t = i === "verbose" ? I : h, c = String(e.year), m = e.people.map((o) => o.id), d = {};
52
+ for (const o of e.people)
53
+ d[o.id] = x(o, c);
54
+ const u = {
55
+ members: [...m]
56
+ };
57
+ e.state && (u.state_name = s(c, e.state)), e.county && (u.county = s(c, e.county));
58
+ const p = {
59
+ [t.family]: { members: [...m] }
60
+ }, y = {
61
+ [t.taxUnit]: { members: [...m] }
62
+ }, f = {
63
+ [t.spmUnit]: { members: [...m] }
64
+ }, b = {
65
+ [t.household]: u
66
+ }, _ = {};
67
+ if (l) {
68
+ const o = e.people.filter((r) => r.kind === "adult");
69
+ _[t.maritalUnit] = {
70
+ members: o.slice(0, 2).map((r) => r.id)
71
+ };
72
+ }
73
+ return {
74
+ country_id: "us",
75
+ label: a,
76
+ data: {
77
+ people: d,
78
+ families: p,
79
+ marital_units: _,
80
+ tax_units: y,
81
+ spm_units: f,
82
+ households: b
83
+ }
84
+ };
85
+ }
86
+ function g(e, n = {}) {
87
+ return S(e, n).data;
88
+ }
89
+ export {
90
+ S as toV1HouseholdPayload,
91
+ g as toV1HouseholdSituation
92
+ };