policyengine-household-wizard 0.2.0 → 0.4.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 (80) hide show
  1. package/README.md +30 -4
  2. package/dist/{index-B_OXaS4a.cjs → index-BfoPBFne.cjs} +1 -1
  3. package/dist/index-CIL8FXNR.cjs +1 -0
  4. package/dist/{index-DWM0giHt.js → index-DoD0AXHz.js} +72 -70
  5. package/dist/index-fgLnXugs.js +225 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.js +1 -1
  9. package/dist/primitives/index.d.ts +12 -12
  10. package/dist/primitives/useWizardSteps.d.ts +1 -1
  11. package/dist/primitives.d.ts +1 -1
  12. package/dist/uk-household/adapters/householdImpactRequest.d.ts +91 -0
  13. package/dist/uk-household/adapters/householdImpactRequest.d.ts.map +1 -0
  14. package/dist/uk-household/adapters/index.d.ts +2 -0
  15. package/dist/uk-household/adapters/index.d.ts.map +1 -0
  16. package/dist/uk-household/children.d.ts +18 -0
  17. package/dist/uk-household/children.d.ts.map +1 -0
  18. package/dist/uk-household/codes.d.ts +22 -0
  19. package/dist/uk-household/codes.d.ts.map +1 -0
  20. package/dist/uk-household/defaults.d.ts +56 -0
  21. package/dist/uk-household/defaults.d.ts.map +1 -0
  22. package/dist/uk-household/draft.d.ts +37 -0
  23. package/dist/uk-household/draft.d.ts.map +1 -0
  24. package/dist/uk-household/index.d.ts +10 -0
  25. package/dist/uk-household/index.d.ts.map +1 -0
  26. package/dist/uk-household/serialize.d.ts +4 -0
  27. package/dist/uk-household/serialize.d.ts.map +1 -0
  28. package/dist/uk-household/statePension.d.ts +42 -0
  29. package/dist/uk-household/statePension.d.ts.map +1 -0
  30. package/dist/uk-household/types.d.ts +134 -0
  31. package/dist/uk-household/types.d.ts.map +1 -0
  32. package/dist/uk-household/validate.d.ts +59 -0
  33. package/dist/uk-household/validate.d.ts.map +1 -0
  34. package/dist/uk-household-adapters.cjs +1 -0
  35. package/dist/uk-household-adapters.d.ts +1 -0
  36. package/dist/uk-household-adapters.js +5 -0
  37. package/dist/uk-household.cjs +1 -0
  38. package/dist/uk-household.d.ts +1 -0
  39. package/dist/uk-household.js +220 -0
  40. package/dist/us-household/adapters/index.d.ts +1 -1
  41. package/dist/us-household/adapters/v1Payload.d.ts +1 -1
  42. package/dist/us-household/adapters/v1Payload.d.ts.map +1 -1
  43. package/dist/us-household/draft.d.ts +1 -1
  44. package/dist/us-household/draft.d.ts.map +1 -1
  45. package/dist/us-household/index.d.ts +9 -9
  46. package/dist/us-household/normalize.d.ts +1 -1
  47. package/dist/us-household/normalize.d.ts.map +1 -1
  48. package/dist/us-household/serialize.d.ts +1 -1
  49. package/dist/us-household/serialize.d.ts.map +1 -1
  50. package/dist/us-household/types.d.ts +9 -14
  51. package/dist/us-household/types.d.ts.map +1 -1
  52. package/dist/us-household/validate.d.ts +1 -1
  53. package/dist/us-household/validate.d.ts.map +1 -1
  54. package/dist/us-household-adapters.cjs +1 -1
  55. package/dist/us-household-adapters.d.ts +1 -1
  56. package/dist/us-household-adapters.js +1 -1
  57. package/dist/us-household.cjs +1 -1
  58. package/dist/us-household.d.ts +1 -1
  59. package/dist/us-household.js +213 -200
  60. package/dist/validation.d.ts +16 -0
  61. package/dist/validation.d.ts.map +1 -0
  62. package/package.json +13 -2
  63. package/src/uk-household/adapters/householdImpactRequest.ts +164 -0
  64. package/src/uk-household/adapters/index.ts +9 -0
  65. package/src/uk-household/children.ts +23 -0
  66. package/src/uk-household/codes.ts +67 -0
  67. package/src/uk-household/defaults.ts +101 -0
  68. package/src/uk-household/draft.ts +138 -0
  69. package/src/uk-household/index.ts +75 -0
  70. package/src/uk-household/serialize.ts +189 -0
  71. package/src/uk-household/statePension.ts +69 -0
  72. package/src/uk-household/types.ts +159 -0
  73. package/src/uk-household/validate.ts +190 -0
  74. package/src/us-household/adapters/v1Payload.ts +4 -0
  75. package/src/us-household/draft.ts +1 -0
  76. package/src/us-household/normalize.ts +3 -0
  77. package/src/us-household/serialize.ts +6 -0
  78. package/src/us-household/types.ts +9 -11
  79. package/src/us-household/validate.ts +15 -0
  80. package/src/validation.ts +12 -0
@@ -202,20 +202,18 @@ export interface USHouseholdDraft {
202
202
  * differentiates them. Order is significant for UI labels ("Adult 1", etc.).
203
203
  */
204
204
  people: USPersonDraft[];
205
+ /**
206
+ * Annual household childcare costs before childcare subsidies, in dollars.
207
+ * The V1 adapter sends this total once as the SPM-unit input
208
+ * `spm_unit_pre_subsidy_childcare_expenses`; the model allocates costs among
209
+ * children and subtracts subsidies. Do not repeat the total for each child.
210
+ * Leave unset when the app does not ask about childcare costs.
211
+ */
212
+ childcareExpenses?: number;
205
213
  /** Year the household is being modeled for. */
206
214
  year: number;
207
215
  /** App-controlled household-level fields ignored by the shared adapters. */
208
216
  extras?: Record<string, unknown>;
209
217
  }
210
218
 
211
- export interface ValidationIssue {
212
- /** Stable identifier for the rule (e.g. "state.required"). */
213
- code: string;
214
- /** Path into the draft (dotted), e.g. "state" or "people[1].age". */
215
- path: string;
216
- message: string;
217
- }
218
-
219
- export type ValidationResult =
220
- | { ok: true; issues: never[] }
221
- | { ok: false; issues: ValidationIssue[] };
219
+ export type { ValidationIssue, ValidationResult } from '../validation';
@@ -47,6 +47,21 @@ export function validate(
47
47
  const { requireCounty = false, requireAges = true } = options;
48
48
  const issues: ValidationIssue[] = [];
49
49
 
50
+ const childcare = toAmount(draft.childcareExpenses);
51
+ if (draft.childcareExpenses != null && childcare === undefined) {
52
+ issues.push({
53
+ code: 'childcareExpenses.invalid',
54
+ path: 'childcareExpenses',
55
+ message: 'Childcare expenses must be a finite amount.',
56
+ });
57
+ } else if (childcare !== undefined && childcare < 0) {
58
+ issues.push({
59
+ code: 'childcareExpenses.negative',
60
+ path: 'childcareExpenses',
61
+ message: 'Childcare expenses cannot be negative.',
62
+ });
63
+ }
64
+
50
65
  if (!draft.state) {
51
66
  issues.push({
52
67
  code: 'state.required',
@@ -0,0 +1,12 @@
1
+ /** One problem `validate()` found in a draft. Shared by the country models. */
2
+ export interface ValidationIssue {
3
+ /** Stable identifier for the rule (e.g. "state.required"). */
4
+ code: string;
5
+ /** Path into the draft (dotted), e.g. "state" or "people[1].age". */
6
+ path: string;
7
+ message: string;
8
+ }
9
+
10
+ export type ValidationResult =
11
+ | { ok: true; issues: never[] }
12
+ | { ok: false; issues: ValidationIssue[] };