policyengine-household-wizard 0.4.0 → 0.5.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/README.md +29 -0
- package/dist/draft-BI_Gnew1.cjs +1 -0
- package/dist/draft-DF6lMn4k.js +88 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +34 -33
- package/dist/us-household/samples/index.d.ts +38 -0
- package/dist/us-household/samples/index.d.ts.map +1 -0
- package/dist/us-household-samples.cjs +1 -0
- package/dist/us-household-samples.d.ts +1 -0
- package/dist/us-household-samples.js +61 -0
- package/dist/us-household.cjs +1 -1
- package/dist/us-household.js +239 -313
- package/package.json +6 -1
- package/src/us-household/samples/catalog.json +1 -0
- package/src/us-household/samples/index.ts +124 -0
package/README.md
CHANGED
|
@@ -74,6 +74,35 @@ See [`docs/api.md`](docs/api.md) for wizard navigation and focus APIs, [`docs/uk
|
|
|
74
74
|
for the UK household model, and [`docs/migration.md`](docs/migration.md)
|
|
75
75
|
for migrating from each app's local wizard.
|
|
76
76
|
|
|
77
|
+
## Start with a US sample household
|
|
78
|
+
|
|
79
|
+
Load the sample catalog when someone asks for an example. Users can edit
|
|
80
|
+
the example with the same controls they use to enter their own household.
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
const { drawUsSampleHousehold, getUsSampleHousehold } = await import('policyengine-household-wizard/us-household/samples');
|
|
84
|
+
const example = drawUsSampleHousehold({ stateCode: 'VA' });
|
|
85
|
+
const another = drawUsSampleHousehold({ stateCode: 'VA', excludeId: example.id });
|
|
86
|
+
const reopened = getUsSampleHousehold(example.id);
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The generator draws profiles from PolicyEngine's calibrated synthetic US
|
|
90
|
+
population, `populace_us_2024`, in proportion to eligible household weights
|
|
91
|
+
within each state. Omit `stateCode` to draw across states in proportion
|
|
92
|
+
to their eligible household weights.
|
|
93
|
+
An explicit redraw skips all copies of the previous profile in its state
|
|
94
|
+
when another profile is available. Use a slot ID only with the catalog release that produced it.
|
|
95
|
+
|
|
96
|
+
The draft carries source-year amounts and the sampled state. Each person's
|
|
97
|
+
tax-dependent role, disability and full-time college student flags, wages,
|
|
98
|
+
self-employment income, Social Security retirement benefits and taxable
|
|
99
|
+
private pension stay with that person. The draft leaves ZIP, county and
|
|
100
|
+
program participation unset. `example.provenance` identifies the dataset,
|
|
101
|
+
build, source year, and source link. See [the catalog methods](docs/us-sample-households.md)
|
|
102
|
+
for its inputs and coverage. Apps that model another policy year
|
|
103
|
+
should show both years. For repeatable draws, pass `random: () => number`
|
|
104
|
+
returning a value in `[0, 1)`.
|
|
105
|
+
|
|
77
106
|
## US childcare expenses
|
|
78
107
|
|
|
79
108
|
Set optional `draft.childcareExpenses` to annual household childcare costs
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const u=new Date().getUTCFullYear(),d="adult",D="dependent";function x(e,t){const n=t==="adult"?d:D,l=new Set(e.map(p=>p.id));let o=`${n}-1`,r=1;for(;l.has(o);)r+=1,o=`${n}-${r}`;return o}function E(e=u){return{state:null,county:null,zip:null,maritalStatus:null,people:[],year:e}}function P(e){return{state:e.state,county:e.county,zip:e.zip,maritalStatus:e.maritalStatus,year:e.year,childcareExpenses:e.childcareExpenses,extras:e.extras?structuredClone(e.extras):void 0,people:e.people.map(t=>({...t,extras:t.extras?structuredClone(t.extras):void 0}))}}function s(e,t=[],n={}){return{id:n.id??x(t,e),kind:e,age:n.age??null,...n}}function a(e,t,n={}){const l=s(t,e.people,n);return{...e,people:[...e.people,l]}}function i(e,t){return{...e,people:e.people.filter(n=>n.id!==t)}}function g(e,t,n){return{...e,people:e.people.map(l=>l.id===t?{...l,...n}:l)}}function c(e){return e.people.filter(t=>t.kind==="adult")}function f(e){return e.people.filter(t=>t.kind==="dependent")}function h(e,t){if(t===e.maritalStatus)return e;const n=c(e);let l={...e,maritalStatus:t};if(t==="married"&&n.length<2)l=a(l,"adult");else if(t==="single"&&n.length>1){const o=n.slice(1);for(const r of o)l=i(l,r.id)}return l}exports.DEFAULT_HOUSEHOLD_YEAR=u;exports.addPerson=a;exports.applyMaritalStatusChange=h;exports.cloneDraft=P;exports.createBlankDraft=E;exports.createPerson=s;exports.getAdults=c;exports.getDependents=f;exports.removePerson=i;exports.updatePerson=g;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
const r = (/* @__PURE__ */ new Date()).getUTCFullYear(), a = "adult", i = "dependent";
|
|
2
|
+
function c(e, n) {
|
|
3
|
+
const t = n === "adult" ? a : i, l = new Set(e.map((u) => u.id));
|
|
4
|
+
let s = `${t}-1`, o = 1;
|
|
5
|
+
for (; l.has(s); )
|
|
6
|
+
o += 1, s = `${t}-${o}`;
|
|
7
|
+
return s;
|
|
8
|
+
}
|
|
9
|
+
function D(e = r) {
|
|
10
|
+
return {
|
|
11
|
+
state: null,
|
|
12
|
+
county: null,
|
|
13
|
+
zip: null,
|
|
14
|
+
maritalStatus: null,
|
|
15
|
+
people: [],
|
|
16
|
+
year: e
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function E(e) {
|
|
20
|
+
return {
|
|
21
|
+
state: e.state,
|
|
22
|
+
county: e.county,
|
|
23
|
+
zip: e.zip,
|
|
24
|
+
maritalStatus: e.maritalStatus,
|
|
25
|
+
year: e.year,
|
|
26
|
+
childcareExpenses: e.childcareExpenses,
|
|
27
|
+
extras: e.extras ? structuredClone(e.extras) : void 0,
|
|
28
|
+
people: e.people.map((n) => ({
|
|
29
|
+
...n,
|
|
30
|
+
extras: n.extras ? structuredClone(n.extras) : void 0
|
|
31
|
+
}))
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function p(e, n = [], t = {}) {
|
|
35
|
+
return {
|
|
36
|
+
id: t.id ?? c(n, e),
|
|
37
|
+
kind: e,
|
|
38
|
+
age: t.age ?? null,
|
|
39
|
+
...t
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function d(e, n, t = {}) {
|
|
43
|
+
const l = p(n, e.people, t);
|
|
44
|
+
return { ...e, people: [...e.people, l] };
|
|
45
|
+
}
|
|
46
|
+
function x(e, n) {
|
|
47
|
+
return { ...e, people: e.people.filter((t) => t.id !== n) };
|
|
48
|
+
}
|
|
49
|
+
function P(e, n, t) {
|
|
50
|
+
return {
|
|
51
|
+
...e,
|
|
52
|
+
people: e.people.map(
|
|
53
|
+
(l) => l.id === n ? { ...l, ...t } : l
|
|
54
|
+
)
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function g(e) {
|
|
58
|
+
return e.people.filter((n) => n.kind === "adult");
|
|
59
|
+
}
|
|
60
|
+
function f(e) {
|
|
61
|
+
return e.people.filter((n) => n.kind === "dependent");
|
|
62
|
+
}
|
|
63
|
+
function h(e, n) {
|
|
64
|
+
if (n === e.maritalStatus)
|
|
65
|
+
return e;
|
|
66
|
+
const t = g(e);
|
|
67
|
+
let l = { ...e, maritalStatus: n };
|
|
68
|
+
if (n === "married" && t.length < 2)
|
|
69
|
+
l = d(l, "adult");
|
|
70
|
+
else if (n === "single" && t.length > 1) {
|
|
71
|
+
const s = t.slice(1);
|
|
72
|
+
for (const o of s)
|
|
73
|
+
l = x(l, o.id);
|
|
74
|
+
}
|
|
75
|
+
return l;
|
|
76
|
+
}
|
|
77
|
+
export {
|
|
78
|
+
r as D,
|
|
79
|
+
d as a,
|
|
80
|
+
h as b,
|
|
81
|
+
E as c,
|
|
82
|
+
D as d,
|
|
83
|
+
p as e,
|
|
84
|
+
f,
|
|
85
|
+
g,
|
|
86
|
+
x as r,
|
|
87
|
+
P as u
|
|
88
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./WizardReviewList-DhLx8Bla.cjs"),t=require("./draft-BI_Gnew1.cjs"),e=require("./us-household.cjs"),a=require("./index-BfoPBFne.cjs");exports.WizardNavigation=o.WizardNavigation;exports.WizardOptionCard=o.WizardOptionCard;exports.WizardProgress=o.WizardProgress;exports.WizardReviewList=o.WizardReviewList;exports.useWizardStepFocus=o.useWizardStepFocus;exports.useWizardSteps=o.useWizardSteps;exports.DEFAULT_HOUSEHOLD_YEAR=t.DEFAULT_HOUSEHOLD_YEAR;exports.addPerson=t.addPerson;exports.applyMaritalStatusChange=t.applyMaritalStatusChange;exports.cloneDraft=t.cloneDraft;exports.createBlankDraft=t.createBlankDraft;exports.createPerson=t.createPerson;exports.getAdults=t.getAdults;exports.getDependents=t.getDependents;exports.removePerson=t.removePerson;exports.updatePerson=t.updatePerson;exports.US_STATES=e.US_STATES;exports.deserializeDraft=e.deserializeDraft;exports.getCountiesByState=e.getCountiesByState;exports.getCountyName=e.getCountyName;exports.getStateFromZip=e.getStateFromZip;exports.getStateName=e.getStateName;exports.isComplete=e.isComplete;exports.isCountyCode=e.isCountyCode;exports.isUSStateCode=e.isUSStateCode;exports.normalizeLegacyDraft=e.normalizeLegacyDraft;exports.resolveCountyCode=e.resolveCountyCode;exports.serializeDraft=e.serializeDraft;exports.validate=e.validate;exports.NOT_A_TIPPED_OCCUPATION=a.NOT_A_TIPPED_OCCUPATION;exports.TIPPED_OCCUPATIONS=a.TIPPED_OCCUPATIONS;exports.getTippedOccupation=a.getTippedOccupation;exports.isTippedOccupationCode=a.isTippedOccupationCode;exports.toTippedOccupationCode=a.toTippedOccupationCode;exports.toV1HouseholdPayload=a.toV1HouseholdPayload;exports.toV1HouseholdSituation=a.toV1HouseholdSituation;
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { W as t, a as
|
|
2
|
-
import {
|
|
3
|
-
import { N as
|
|
1
|
+
import { W as t, a as s, b as o, c as r, u as i, d } from "./WizardReviewList-oY1HqmLw.js";
|
|
2
|
+
import { D as n, a as u, b as C, c, d as l, e as S, g, f as P, r as T, u as D } from "./draft-DF6lMn4k.js";
|
|
3
|
+
import { US_STATES as f, deserializeDraft as m, getCountiesByState as z, getCountyName as y, getStateFromZip as A, getStateName as N, isComplete as W, isCountyCode as _, isUSStateCode as E, normalizeLegacyDraft as U, resolveCountyCode as v, serializeDraft as x, validate as H } from "./us-household.js";
|
|
4
|
+
import { N as L, T as b, g as h, i as F, a as B, b as R, c as V } from "./index-DoD0AXHz.js";
|
|
4
5
|
export {
|
|
5
6
|
n as DEFAULT_HOUSEHOLD_YEAR,
|
|
6
7
|
L as NOT_A_TIPPED_OCCUPATION,
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
b as TIPPED_OCCUPATIONS,
|
|
9
|
+
f as US_STATES,
|
|
9
10
|
t as WizardNavigation,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
11
|
+
s as WizardOptionCard,
|
|
12
|
+
o as WizardProgress,
|
|
13
|
+
r as WizardReviewList,
|
|
14
|
+
u as addPerson,
|
|
15
|
+
C as applyMaritalStatusChange,
|
|
16
|
+
c as cloneDraft,
|
|
17
|
+
l as createBlankDraft,
|
|
18
|
+
S as createPerson,
|
|
19
|
+
m as deserializeDraft,
|
|
20
|
+
g as getAdults,
|
|
21
|
+
z as getCountiesByState,
|
|
22
|
+
y as getCountyName,
|
|
23
|
+
P as getDependents,
|
|
24
|
+
A as getStateFromZip,
|
|
25
|
+
N as getStateName,
|
|
26
|
+
h as getTippedOccupation,
|
|
27
|
+
W as isComplete,
|
|
28
|
+
_ as isCountyCode,
|
|
28
29
|
F as isTippedOccupationCode,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
E as isUSStateCode,
|
|
31
|
+
U as normalizeLegacyDraft,
|
|
32
|
+
T as removePerson,
|
|
33
|
+
v as resolveCountyCode,
|
|
34
|
+
x as serializeDraft,
|
|
35
|
+
B as toTippedOccupationCode,
|
|
36
|
+
R as toV1HouseholdPayload,
|
|
37
|
+
V as toV1HouseholdSituation,
|
|
38
|
+
D as updatePerson,
|
|
39
|
+
i as useWizardStepFocus,
|
|
39
40
|
d as useWizardSteps,
|
|
40
41
|
H as validate
|
|
41
42
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { USHouseholdDraft } from '../types.js';
|
|
2
|
+
export interface DrawUsSampleHouseholdOptions {
|
|
3
|
+
/** Omit to draw across states. State codes use two uppercase letters. */
|
|
4
|
+
stateCode?: string;
|
|
5
|
+
/** Skip copies of the previous profile in its state when another profile is available. */
|
|
6
|
+
excludeId?: string;
|
|
7
|
+
/** Returns a number from zero inclusive to one exclusive. */
|
|
8
|
+
random?: () => number;
|
|
9
|
+
}
|
|
10
|
+
export interface UsSampleHousehold {
|
|
11
|
+
/** A catalog slot local to this release, suitable for excludeId. */
|
|
12
|
+
id: string;
|
|
13
|
+
stateCode: string;
|
|
14
|
+
draft: USHouseholdDraft;
|
|
15
|
+
provenance: {
|
|
16
|
+
dataset: string;
|
|
17
|
+
buildId: string;
|
|
18
|
+
year: number;
|
|
19
|
+
url: string;
|
|
20
|
+
sha256: string;
|
|
21
|
+
policyengineVersion: string;
|
|
22
|
+
policyengineUsVersion: string;
|
|
23
|
+
sourceHouseholds: number;
|
|
24
|
+
eligibleHouseholds: number;
|
|
25
|
+
totalWeight: number;
|
|
26
|
+
eligibleWeight: number;
|
|
27
|
+
drawsPerState: number;
|
|
28
|
+
seed: number;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Draw an editable household from the calibrated populace_us_2024 dataset in its source year.
|
|
33
|
+
* ZIP, county and other facts outside the projection stay unset.
|
|
34
|
+
*/
|
|
35
|
+
export declare function drawUsSampleHousehold({ stateCode, excludeId, random, }?: DrawUsSampleHouseholdOptions): UsSampleHousehold;
|
|
36
|
+
/** Reopen a sample from this catalog release, or return undefined for an unknown ID. */
|
|
37
|
+
export declare function getUsSampleHousehold(id: string): UsSampleHousehold | undefined;
|
|
38
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/us-household/samples/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAkC,MAAM,UAAU,CAAC;AAGjF,MAAM,WAAW,4BAA4B;IAC3C,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,MAAM,CAAC;QACf,mBAAmB,EAAE,MAAM,CAAC;QAC5B,qBAAqB,EAAE,MAAM,CAAC;QAC9B,gBAAgB,EAAE,MAAM,CAAC;QACzB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,WAAW,EAAE,MAAM,CAAC;QACpB,cAAc,EAAE,MAAM,CAAC;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAuCD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,SAAS,EACT,SAAS,EACT,MAAoB,GACrB,GAAE,4BAAiC,GAAG,iBAAiB,CAqBvD;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS,CAG9E"}
|