@mark1russell7/stack-needs 0.2.0 → 0.3.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 +2 -3
- package/build/index.d.ts +6 -13
- package/build/index.d.ts.map +1 -1
- package/build/index.js +3 -6
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -10,7 +10,6 @@ Each function is a plain function with no clock, no network and no file.
|
|
|
10
10
|
|
|
11
11
|
| Record | What it tells |
|
|
12
12
|
| --- | --- |
|
|
13
|
-
| `HashedSource` | A source of `@mark1russell7/guidebook` (an id, a title, a URL, a license and the date of the check), with the SHA-256 hash of the file. |
|
|
14
13
|
| `CalorieTable` | A table of estimated calorie needs from one source, with the place of the tables in the source. |
|
|
15
14
|
| `CalorieRow` | A sex, a range of ages in months, and the need of each activity level, or one need for all levels. |
|
|
16
15
|
| `CalorieChange` | A stage (for example `pregnancy-2`), a sex, and the change of the daily need at that stage, with the condition of the source. |
|
|
@@ -25,9 +24,9 @@ Each function is a plain function with no clock, no network and no file.
|
|
|
25
24
|
4. A stage of pregnancy or lactation is an input of a person record. `calorieNeed` adds the change of the stage to the need of the row. A stage that the table does not have for the sex of the record is an error, not a no read. Thus the option `leave-out` cannot remove a pregnant person from a draw. One stage holds for each day of a call. For a period that crosses stages, the planner selects the stage, for example the stage with the largest change.
|
|
26
25
|
5. The package has no cooking converter. No cited source gives the water and the fuel to cook 1 kg of dry food.
|
|
27
26
|
|
|
28
|
-
`checkCalorieTable` is the gate of a table. It gives the findings of `checkSources` of `@mark1russell7/guidebook` for the source
|
|
27
|
+
`checkCalorieTable` is the gate of a table. It gives the findings of `checkSources` of `@mark1russell7/guidebook` for the source, also for a hash that is not 64 lowercase hexadecimal digits (`bad-sha256`). For the rows, it refuses two rows of one sex with ages in common, and a need that is not above 0 in `kcal/d`. The rows of each sex also cover each month with no gap, from the first row to an open last row (`needs-gap`). Each change has a stage, a title, a sex of the table and a finite value in `kcal/d`. Each stage and sex has one change at most (`needs-change`).
|
|
29
28
|
|
|
30
|
-
The
|
|
29
|
+
The source of a table is the `Source` of `@mark1russell7/guidebook`, with its field `sha256`. Before 0.3.0, the package had its own type `HashedSource` and the code `needs-hash`.
|
|
31
30
|
|
|
32
31
|
## A first look
|
|
33
32
|
|
package/build/index.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import { Quantity } from "@mark1russell7/quantity";
|
|
2
2
|
import { Finding, FindingCode, GateOptions, Source } from "@mark1russell7/guidebook";
|
|
3
3
|
import { BuyListEnergy, SupplyCatalog } from "@mark1russell7/market/supplies";
|
|
4
|
-
/**
|
|
5
|
-
* A source of a table: a source of `@mark1russell7/guidebook`, with the SHA-256 hash of the file of the read.
|
|
6
|
-
* The hash has 64 lowercase hexadecimal digits. A page with no fixed file has no hash.
|
|
7
|
-
*/
|
|
8
|
-
export type HashedSource = Source & {
|
|
9
|
-
readonly sha256?: string;
|
|
10
|
-
};
|
|
11
4
|
/** The activity levels of the table, as the source names them: sedentary, moderately active and active. */
|
|
12
5
|
export declare const ACTIVITY_LEVELS: readonly ["sedentary", "moderately-active", "active"];
|
|
13
6
|
/** An activity level of the table. */
|
|
@@ -59,7 +52,7 @@ export interface CalorieTable {
|
|
|
59
52
|
/** The id, for example `dga.2020-2025:calorie-needs`. */
|
|
60
53
|
readonly id: string;
|
|
61
54
|
readonly title: string;
|
|
62
|
-
readonly source:
|
|
55
|
+
readonly source: Source;
|
|
63
56
|
/** The place of the tables in the source: the tables and their pages. */
|
|
64
57
|
readonly locator: string;
|
|
65
58
|
/** The rows of the table. The age ranges of the rows of one sex do not overlap. */
|
|
@@ -144,15 +137,14 @@ export declare function calorieChange(table: CalorieTable, sex: CalorieSex, stag
|
|
|
144
137
|
*/
|
|
145
138
|
export declare function calorieNeed(table: CalorieTable, persons: readonly Person[], level: ActivityLevel, days: number): CalorieNeedTotal;
|
|
146
139
|
/** The source of the calorie table: the PDF of the Dietary Guidelines for Americans, 2020-2025, 9th Edition. It is a work of the United States federal government. */
|
|
147
|
-
export declare const DGA_SOURCE:
|
|
140
|
+
export declare const DGA_SOURCE: Source;
|
|
148
141
|
/** The table of estimated calorie needs of the Dietary Guidelines for Americans, 2020-2025: 68 rows, 34 for each sex, and 5 changes of pregnancy and lactation. */
|
|
149
142
|
export declare const DGA_CALORIES: CalorieTable;
|
|
150
143
|
/** The tables of estimated calorie needs, one record for each source. */
|
|
151
144
|
export declare const CALORIE_TABLES: readonly CalorieTable[];
|
|
152
145
|
/**
|
|
153
|
-
* These are the codes of the gate of the rows
|
|
146
|
+
* These are the codes of the gate of the rows. Each code is an error. The gate of the sources of `@mark1russell7/guidebook` gives its own codes.
|
|
154
147
|
*
|
|
155
|
-
* - `needs-hash`: the hash of the source is not 64 lowercase hexadecimal digits.
|
|
156
148
|
* - `needs-row`: a row has no age or a wrong sex. Or its range of months is not a range of whole numbers of 0 or more.
|
|
157
149
|
* - `needs-overlap`: two rows of one sex have ages in common.
|
|
158
150
|
* - `needs-gap`: the rows of one sex do not cover each month with no gap, from the first row to an open last row.
|
|
@@ -161,7 +153,7 @@ export declare const CALORIE_TABLES: readonly CalorieTable[];
|
|
|
161
153
|
* change has its stage and sex. Or its value is not a finite number in a unit of energy for each day. Or its sum with
|
|
162
154
|
* the smallest need of its sex is not above 0.
|
|
163
155
|
*/
|
|
164
|
-
export declare const NEEDS_CODES: readonly ["needs-
|
|
156
|
+
export declare const NEEDS_CODES: readonly ["needs-row", "needs-overlap", "needs-gap", "needs-value", "needs-change"];
|
|
165
157
|
/** A code of the gate of a table of calorie needs. */
|
|
166
158
|
export type NeedsCode = (typeof NEEDS_CODES)[number];
|
|
167
159
|
/** A finding of the gate of a table of calorie needs: a finding of the gate of the sources, or a finding of a row. */
|
|
@@ -170,7 +162,8 @@ export type NeedsFinding = Finding<NeedsCode | FindingCode, "source" | "unit" |
|
|
|
170
162
|
* This function gives each finding of a table of calorie needs. A list with no error tells that the gate passes.
|
|
171
163
|
*
|
|
172
164
|
* - The findings of the source come from `checkSources` of `@mark1russell7/guidebook`, with the options of the call.
|
|
173
|
-
* - The
|
|
165
|
+
* - The hash of the source is part of the gate of the sources (`bad-sha256`).
|
|
166
|
+
* - The rows have the codes of `NEEDS_CODES`.
|
|
174
167
|
*
|
|
175
168
|
* The findings are in the order of the table. The function is pure.
|
|
176
169
|
*
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/calorie.ts","../src/data.ts","../src/check.ts","../src/uses.ts","../src/household.ts"],"mappings":";;;;qBAQa;;YAGD,wBAAwB;;qBAGvB;;YAGD,qBAAqB;;;;;YAMrB;WAAyB,QAAQ,SAAS,OAAO,eAAe;WAAqB;;WAA4B,MAAM;WAAmB;;;iBAGrI;WACN,KAAK;;WAEL;;WAEA;;WAEA;WACA,MAAM;;;;;;iBAOA;;WAEN;;WAEA;;WAEA,KAAK;;WAEL,QAAQ;;WAER;;;iBAIM;;WAEN;WACA;WACA,QAAQ;;WAER;;WAEA,eAAe;;WAEf,mBAAmB;;;iBAIb;WACN,KAAK;;WAEL;WACA;;WAEA,QAAQ;;WAER;;;YAIC;WACG,QAAQ;WAAiB;WAAqB,OAAO;WAAwB;WAAsB;WAAqC,MAAM;;WAC9I,QAAQ;WAAiB;WAAsB;;;iBAG7C;;WAEN,gBAAgB;;WAEhB;;WAEA,MAAM;;WAEN;;;wBASK,gBAAgB,iBAAiB,SAAS;;;;;;;;wBAW1C,WAAW,OAAO,cAAc,KAAK,YAAY,oBAAoB;;;;;;;;wBAWrE,cAAc,OAAO,cAAc,KAAK,YAAY,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;wBA0BpE,YAAY,OAAO,cAAc,kBAAkB,UAAU,OAAO,eAAe,eAAe;;qBCzIrG,YAAY;;qBAiBZ,cAAc;;qBAqFd,yBAAyB;;;;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
|
-
* These are the codes of the gate of the rows
|
|
629
|
+
* These are the codes of the gate of the rows. Each code is an error. The gate of the sources of `@mark1russell7/guidebook` gives its own codes.
|
|
630
630
|
*
|
|
631
|
-
* - `needs-hash`: the hash of the source is not 64 lowercase hexadecimal digits.
|
|
632
631
|
* - `needs-row`: a row has no age or a wrong sex. Or its range of months is not a range of whole numbers of 0 or more.
|
|
633
632
|
* - `needs-overlap`: two rows of one sex have ages in common.
|
|
634
633
|
* - `needs-gap`: the rows of one sex do not cover each month with no gap, from the first row to an open last row.
|
|
@@ -638,7 +637,6 @@ const CALORIE_TABLES = [DGA_CALORIES];
|
|
|
638
637
|
* the smallest need of its sex is not above 0.
|
|
639
638
|
*/
|
|
640
639
|
const NEEDS_CODES = [
|
|
641
|
-
"needs-hash",
|
|
642
640
|
"needs-row",
|
|
643
641
|
"needs-overlap",
|
|
644
642
|
"needs-gap",
|
|
@@ -658,7 +656,8 @@ function goodNeed(need, positive = true) {
|
|
|
658
656
|
* This function gives each finding of a table of calorie needs. A list with no error tells that the gate passes.
|
|
659
657
|
*
|
|
660
658
|
* - The findings of the source come from `checkSources` of `@mark1russell7/guidebook`, with the options of the call.
|
|
661
|
-
* - The
|
|
659
|
+
* - The hash of the source is part of the gate of the sources (`bad-sha256`).
|
|
660
|
+
* - The rows have the codes of `NEEDS_CODES`.
|
|
662
661
|
*
|
|
663
662
|
* The findings are in the order of the table. The function is pure.
|
|
664
663
|
*
|
|
@@ -676,8 +675,6 @@ function checkCalorieTable(table, options) {
|
|
|
676
675
|
message
|
|
677
676
|
});
|
|
678
677
|
};
|
|
679
|
-
const { sha256 } = table.source;
|
|
680
|
-
if (sha256 !== void 0 && !/^[0-9a-f]{64}$/u.test(sha256)) add("needs-hash", "source", table.source.id, `The hash of the source "${table.source.id}" is not 64 lowercase hexadecimal digits.`);
|
|
681
678
|
const whole = (value) => value === void 0 || Number.isSafeInteger(value) && value >= 0;
|
|
682
679
|
const range = (row) => whole(row.from) && whole(row.to) && (row.to === void 0 || row.to >= row.from);
|
|
683
680
|
const idOf = (index) => `${table.id}.rows[${String(index)}]`;
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/calorie.ts","../src/data.ts","../src/check.ts","../src/uses.ts","../src/household.ts"],"sourcesContent":["import { quantity, valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport type { HashedSource } from \"./source.ts\";\n\n// The energy need of the persons of a household, from a cited table of estimated calorie needs.\n// The package names no person. The persons and their activity level are input data.\n// A person record has a sex, an age in months and a count. Each table finds its own row from its own age ranges.\n\n/** The activity levels of the table, as the source names them: sedentary, moderately active and active. */\nexport const ACTIVITY_LEVELS: readonly [\"sedentary\", \"moderately-active\", \"active\"] = [\"sedentary\", \"moderately-active\", \"active\"];\n\n/** An activity level of the table. */\nexport type ActivityLevel = (typeof ACTIVITY_LEVELS)[number];\n\n/** The sexes of the table. */\nexport const CALORIE_SEXES: readonly [\"female\", \"male\"] = [\"female\", \"male\"];\n\n/** A sex of the table. */\nexport type CalorieSex = (typeof CALORIE_SEXES)[number];\n\n/**\n * The estimated calorie need of one person of a row for each day. A row gives a need for each activity level, or one need for all levels.\n * The table of the toddlers gives one need for each age and sex only. Each need has a unit of energy for each day, for example `{ \"value\": 2000, \"unit\": \"kcal/d\" }`.\n */\nexport type CalorieNeed = { readonly levels: Readonly<Record<ActivityLevel, Quantity>>; readonly each?: never } | { readonly each: Quantity; readonly levels?: never };\n\n/** A row of a table of calorie needs: a sex, a range of ages in months, and the need. */\nexport interface CalorieRow {\n readonly sex: CalorieSex;\n /** The age as the source names it, for example `19-20` (years) or `21 through 23 months`. */\n readonly age: string;\n /** The first age of the row, in whole months. */\n readonly from: number;\n /** The last age of the row, in whole months. Without it, the row applies to each larger age. */\n readonly to?: number | undefined;\n readonly need: CalorieNeed;\n}\n\n/**\n * A change of the daily need of a person at a stage, for example the second trimester of a pregnancy. The change adds\n * to the need of the row of the person. It can be 0.\n */\nexport interface CalorieChange {\n /** The id of the stage, for example `pregnancy-2`. */\n readonly stage: string;\n /** The stage as the source names it, for example `Pregnancy: 2nd trimester`. */\n readonly title: string;\n /** The sex of the persons of the stage. */\n readonly sex: CalorieSex;\n /** The change of the need for each day, in a unit of energy for each day, for example `{ \"value\": 340, \"unit\": \"kcal/d\" }`. */\n readonly change: Quantity;\n /** The condition of the source for the change, for example a healthy weight before the pregnancy. */\n readonly condition?: string | undefined;\n}\n\n/** A table of estimated calorie needs from one source. */\nexport interface CalorieTable {\n /** The id, for example `dga.2020-2025:calorie-needs`. */\n readonly id: string;\n readonly title: string;\n readonly source: HashedSource;\n /** The place of the tables in the source: the tables and their pages. */\n readonly locator: string;\n /** The rows of the table. The age ranges of the rows of one sex do not overlap. */\n readonly rows: readonly CalorieRow[];\n /** The changes of the need at each stage. The stage and the sex of each change are unique. */\n readonly changes?: readonly CalorieChange[] | undefined;\n}\n\n/** A group of persons of the same sex and age, and their count. */\nexport interface Person {\n readonly sex: CalorieSex;\n /** The age, in whole months, for example 420 for 35 years. */\n readonly ageMonths: number;\n readonly count: number;\n /** The activity level of the persons. Without it, the level of the call applies. */\n readonly level?: ActivityLevel | undefined;\n /** The stage of the persons, for example `pregnancy-2`: the stage of a change of the table. Without it, no change applies. */\n readonly stage?: string | undefined;\n}\n\n/** The need of one person record for the days, or no read when the table has no row for the age. */\nexport type CalorieNeedLine =\n | { readonly person: Person; readonly read: true; readonly level: ActivityLevel; readonly row: string; readonly stage?: string | undefined; readonly need: Quantity }\n | { readonly person: Person; readonly read: false; readonly why: string };\n\n/** The energy need of the persons of a household for a count of days. */\nexport interface CalorieNeedTotal {\n /** The need of each person record, in the order of the input. */\n readonly lines: readonly CalorieNeedLine[];\n /** True when each line has a read. When it is false, `need` is a lower limit. */\n readonly read: boolean;\n /** The sum of the needs of the lines with a read, in `kcal`. */\n readonly need: Quantity;\n /** The count of the persons of all the records, also of the records with no read. */\n readonly persons: number;\n}\n\n/** The unit of each food energy. */\nconst ENERGY_UNIT = \"kcal\";\n/** The unit of each daily need. */\nconst DAILY_UNIT = \"kcal/d\";\n\n/** This function tells if a value is an activity level of the table. */\nexport function isActivityLevel(level: unknown): level is ActivityLevel {\n return (ACTIVITY_LEVELS as readonly unknown[]).includes(level);\n}\n\n/**\n * This function gives the row of a table for a sex and an age in months, or `undefined` when the table has no row.\n *\n * @param table - The table of calorie needs\n * @param sex - The sex\n * @param ageMonths - The age, in whole months\n */\nexport function calorieRow(table: CalorieTable, sex: CalorieSex, ageMonths: number): CalorieRow | undefined {\n return table.rows.find((row) => row.sex === sex && ageMonths >= row.from && (row.to === undefined || ageMonths <= row.to));\n}\n\n/**\n * This function gives the change of a table for a sex and a stage, or `undefined` when the table has no such change.\n *\n * @param table - The table of calorie needs\n * @param sex - The sex\n * @param stage - The id of the stage, for example `pregnancy-2`\n */\nexport function calorieChange(table: CalorieTable, sex: CalorieSex, stage: string): CalorieChange | undefined {\n return table.changes?.find((change) => change.sex === sex && change.stage === stage);\n}\n\n/**\n * This function gives the energy need of the persons of a household for a count of days, in `kcal`.\n * It adds the need of each person at the activity level of that person. The table finds the row of each person from the age.\n *\n * - An age with no row in the table gives a line with no read, for example 6 months. Then the total is a lower limit.\n * - The table of the toddlers gives one need for each age and sex. Thus the level does not change the need of a toddler.\n * - A record with a stage adds the change of the stage to the need of its row, for example 340 kcal/d in the second trimester.\n * - One stage holds for each day of the call. For a period that crosses stages, the planner selects the stage, for example the stage with the largest change.\n *\n * The activity level is an explicit input. This package has no default level. The planner selects it, also for the worst case of a long power cut.\n * In that case, work can make the level higher, for example the carry of water. The function is pure.\n *\n * @param table - The table of calorie needs\n * @param persons - The person records of the household: a sex, an age in months, a count and, as an option, a level\n * @param level - The activity level of each record with no level of its own\n * @param days - The count of days, a finite number of 0 or more\n * @throws RangeError when a count of persons or an age is not a whole number of 0 or more, or when the household has no person\n * @throws RangeError when a level is not a level of the table, or when a sex is not a sex of the table\n * @throws RangeError when the count of days is not a finite number of 0 or more\n * @throws RangeError when the table has no change for the stage and the sex of a record\n * @throws RangeError when the daily need of a record, with the change of its stage, is not above 0\n */\nexport function calorieNeed(table: CalorieTable, persons: readonly Person[], level: ActivityLevel, days: number): CalorieNeedTotal {\n if (!(Number.isFinite(days) && days >= 0)) throw new RangeError(`The count of days is ${String(days)}. It must be a finite number of 0 or more.`);\n if (!isActivityLevel(level)) throw new RangeError(`The activity level ${String(level)} is not a level of the table.`);\n let count = 0;\n const lines = persons.map((person): CalorieNeedLine => {\n const name = `${String(person.sex)} of ${String(person.ageMonths)} months`;\n if (!(Number.isSafeInteger(person.count) && person.count >= 0)) throw new RangeError(`The count of the persons ${name} is ${String(person.count)}. It must be a whole number of 0 or more.`);\n if (!(Number.isSafeInteger(person.ageMonths) && person.ageMonths >= 0)) throw new RangeError(`The age of the persons ${name} is not a whole number of months of 0 or more.`);\n if (!(CALORIE_SEXES as readonly unknown[]).includes(person.sex)) throw new RangeError(`The sex ${String(person.sex)} is not a sex of the table.`);\n const own = person.level ?? level;\n if (!isActivityLevel(own)) throw new RangeError(`The activity level ${String(own)} of the persons ${name} is not a level of the table.`);\n // A stage that the table does not have is an error, not a no read: the option leave-out would remove the persons from a draw.\n const change = person.stage === undefined ? undefined : calorieChange(table, person.sex, person.stage);\n if (person.stage !== undefined && change === undefined) throw new RangeError(`The table ${table.id} has no change for the stage ${String(person.stage)} of the persons ${name}.`);\n count += person.count;\n const row = calorieRow(table, person.sex, person.ageMonths);\n if (row === undefined) return { person, read: false, why: `The table ${table.id} has no row for a ${name}.` };\n const daily = valueIn(row.need.levels === undefined ? row.need.each : row.need.levels[own], DAILY_UNIT) + (change === undefined ? 0 : valueIn(change.change, DAILY_UNIT));\n if (!(daily > 0)) throw new RangeError(`The daily need of the persons ${name} at the stage ${String(person.stage)} is ${String(daily)} kcal/d. It must be above 0.`);\n const line = { person, read: true as const, level: own, row: row.age, need: quantity(person.count * daily * days, ENERGY_UNIT) };\n return change === undefined ? line : { ...line, stage: change.stage };\n });\n if (count === 0) throw new RangeError(\"The household has no person.\");\n const total = lines.reduce((sum, line) => sum + (line.read ? line.need.value : 0), 0);\n return { lines, read: lines.every((line) => line.read), need: quantity(total, ENERGY_UNIT), persons: count };\n}\n","import type { CalorieChange, CalorieNeed, CalorieTable } from \"./calorie.ts\";\nimport type { HashedSource } from \"./source.ts\";\n\n// The estimated calorie needs of the Dietary Guidelines for Americans, 2020-2025. Each value is from the tables of\n// Appendix 2 of the PDF, read on 2026-11-22. A calorie of the source is a food calorie, thus 1 kcal. The source gives\n// each need for a reference height and weight, to keep the weight of a person. A person can need more or less.\n// The rows of the toddlers are at 12, 15, 18 and 21 through 23 months. Each row here covers the months up to the next row.\n// The changes of pregnancy and lactation are from Table A2-3. The source gives them for women with a healthy weight before\n// the pregnancy.\n// The 2025-2030 edition of the guidelines (read on 2026-11-24) has no table of calorie needs. It sends the reader to the\n// DRI calculator of the USDA. Its daily servings by calorie level start at a calorie level and do not give a need. So\n// this table stays the table of the 2020-2025 edition.\n\n/** The source of the calorie table: the PDF of the Dietary Guidelines for Americans, 2020-2025, 9th Edition. It is a work of the United States federal government. */\nexport const DGA_SOURCE: HashedSource = {\n id: \"dga-2020-2025\",\n title: \"Dietary Guidelines for Americans, 2020-2025, 9th Edition\",\n url: \"https://www.dietaryguidelines.gov/sites/default/files/2020-12/Dietary_Guidelines_for_Americans_2020-2025.pdf\",\n license: \"us-public-domain\",\n checked: \"2026-11-22\",\n by: \"U.S. Department of Agriculture and U.S. Department of Health and Human Services\",\n sha256: \"ceea04ce1a7c13a95a170f3548ed3926ad6dd49599bd730fb58bc9c02711d16e\",\n};\n\nconst day = (value: number): { readonly value: number; readonly unit: string } => ({ value, unit: \"kcal/d\" });\nconst levels = (sedentary: number, moderate: number, active: number): CalorieNeed => ({ levels: { sedentary: day(sedentary), \"moderately-active\": day(moderate), active: day(active) } });\nconst each = (value: number): CalorieNeed => ({ each: day(value) });\nconst HEALTHY = \"For women with a healthy weight before the pregnancy. Other women ask their health care provider.\";\nconst change = (stage: string, title: string, value: number): CalorieChange => ({ stage, title, sex: \"female\", change: day(value), condition: HEALTHY });\n\n/** The table of estimated calorie needs of the Dietary Guidelines for Americans, 2020-2025: 68 rows, 34 for each sex, and 5 changes of pregnancy and lactation. */\nexport const DGA_CALORIES: CalorieTable = {\n id: \"dga.2020-2025:calorie-needs\",\n title: \"Dietary Guidelines for Americans, 2020-2025: Estimated Calorie Needs\",\n source: DGA_SOURCE,\n locator: \"Appendix 2: Table A2-1 (ages 12 through 23 months, page 139), Table A2-2 (ages 2 and older, pages 140 and 141) and Table A2-3 (pregnancy and lactation, page 141)\",\n changes: [\n change(\"pregnancy-1\", \"Pregnancy: 1st trimester\", 0),\n change(\"pregnancy-2\", \"Pregnancy: 2nd trimester\", 340),\n change(\"pregnancy-3\", \"Pregnancy: 3rd trimester\", 452),\n change(\"lactation-1\", \"Lactation: 1st 6 months\", 330),\n change(\"lactation-2\", \"Lactation: 2nd 6 months\", 400),\n ],\n rows: [\n { sex: \"female\", age: \"12 months\", from: 12, to: 14, need: each(800) },\n { sex: \"female\", age: \"15 months\", from: 15, to: 17, need: each(800) },\n { sex: \"female\", age: \"18 months\", from: 18, to: 20, need: each(900) },\n { sex: \"female\", age: \"21 through 23 months\", from: 21, to: 23, need: each(1000) },\n { sex: \"female\", age: \"2\", from: 24, to: 35, need: levels(1000, 1000, 1000) },\n { sex: \"female\", age: \"3\", from: 36, to: 47, need: levels(1000, 1200, 1400) },\n { sex: \"female\", age: \"4\", from: 48, to: 59, need: levels(1200, 1400, 1400) },\n { sex: \"female\", age: \"5\", from: 60, to: 71, need: levels(1200, 1400, 1600) },\n { sex: \"female\", age: \"6\", from: 72, to: 83, need: levels(1200, 1400, 1600) },\n { sex: \"female\", age: \"7\", from: 84, to: 95, need: levels(1200, 1600, 1800) },\n { sex: \"female\", age: \"8\", from: 96, to: 107, need: levels(1400, 1600, 1800) },\n { sex: \"female\", age: \"9\", from: 108, to: 119, need: levels(1400, 1600, 1800) },\n { sex: \"female\", age: \"10\", from: 120, to: 131, need: levels(1400, 1800, 2000) },\n { sex: \"female\", age: \"11\", from: 132, to: 143, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"12\", from: 144, to: 155, need: levels(1600, 2000, 2200) },\n { sex: \"female\", age: \"13\", from: 156, to: 167, need: levels(1600, 2000, 2200) },\n { sex: \"female\", age: \"14\", from: 168, to: 179, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"15\", from: 180, to: 191, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"16\", from: 192, to: 203, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"17\", from: 204, to: 215, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"18\", from: 216, to: 227, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"19-20\", from: 228, to: 251, need: levels(2000, 2200, 2400) },\n { sex: \"female\", age: \"21-25\", from: 252, to: 311, need: levels(2000, 2200, 2400) },\n { sex: \"female\", age: \"26-30\", from: 312, to: 371, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"31-35\", from: 372, to: 431, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"36-40\", from: 432, to: 491, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"41-45\", from: 492, to: 551, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"46-50\", from: 552, to: 611, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"51-55\", from: 612, to: 671, need: levels(1600, 1800, 2200) },\n { sex: \"female\", age: \"56-60\", from: 672, to: 731, need: levels(1600, 1800, 2200) },\n { sex: \"female\", age: \"61-65\", from: 732, to: 791, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"66-70\", from: 792, to: 851, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"71-75\", from: 852, to: 911, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"76 and up\", from: 912, need: levels(1600, 1800, 2000) },\n { sex: \"male\", age: \"12 months\", from: 12, to: 14, need: each(800) },\n { sex: \"male\", age: \"15 months\", from: 15, to: 17, need: each(900) },\n { sex: \"male\", age: \"18 months\", from: 18, to: 20, need: each(1000) },\n { sex: \"male\", age: \"21 through 23 months\", from: 21, to: 23, need: each(1000) },\n { sex: \"male\", age: \"2\", from: 24, to: 35, need: levels(1000, 1000, 1000) },\n { sex: \"male\", age: \"3\", from: 36, to: 47, need: levels(1000, 1400, 1400) },\n { sex: \"male\", age: \"4\", from: 48, to: 59, need: levels(1200, 1400, 1600) },\n { sex: \"male\", age: \"5\", from: 60, to: 71, need: levels(1200, 1400, 1600) },\n { sex: \"male\", age: \"6\", from: 72, to: 83, need: levels(1400, 1600, 1800) },\n { sex: \"male\", age: \"7\", from: 84, to: 95, need: levels(1400, 1600, 1800) },\n { sex: \"male\", age: \"8\", from: 96, to: 107, need: levels(1400, 1600, 2000) },\n { sex: \"male\", age: \"9\", from: 108, to: 119, need: levels(1600, 1800, 2000) },\n { sex: \"male\", age: \"10\", from: 120, to: 131, need: levels(1600, 1800, 2200) },\n { sex: \"male\", age: \"11\", from: 132, to: 143, need: levels(1800, 2000, 2200) },\n { sex: \"male\", age: \"12\", from: 144, to: 155, need: levels(1800, 2200, 2400) },\n { sex: \"male\", age: \"13\", from: 156, to: 167, need: levels(2000, 2200, 2600) },\n { sex: \"male\", age: \"14\", from: 168, to: 179, need: levels(2000, 2400, 2800) },\n { sex: \"male\", age: \"15\", from: 180, to: 191, need: levels(2200, 2600, 3000) },\n { sex: \"male\", age: \"16\", from: 192, to: 203, need: levels(2400, 2800, 3200) },\n { sex: \"male\", age: \"17\", from: 204, to: 215, need: levels(2400, 2800, 3200) },\n { sex: \"male\", age: \"18\", from: 216, to: 227, need: levels(2400, 2800, 3200) },\n { sex: \"male\", age: \"19-20\", from: 228, to: 251, need: levels(2600, 2800, 3000) },\n { sex: \"male\", age: \"21-25\", from: 252, to: 311, need: levels(2400, 2800, 3000) },\n { sex: \"male\", age: \"26-30\", from: 312, to: 371, need: levels(2400, 2600, 3000) },\n { sex: \"male\", age: \"31-35\", from: 372, to: 431, need: levels(2400, 2600, 3000) },\n { sex: \"male\", age: \"36-40\", from: 432, to: 491, need: levels(2400, 2600, 2800) },\n { sex: \"male\", age: \"41-45\", from: 492, to: 551, need: levels(2200, 2600, 2800) },\n { sex: \"male\", age: \"46-50\", from: 552, to: 611, need: levels(2200, 2400, 2800) },\n { sex: \"male\", age: \"51-55\", from: 612, to: 671, need: levels(2200, 2400, 2800) },\n { sex: \"male\", age: \"56-60\", from: 672, to: 731, need: levels(2200, 2400, 2600) },\n { sex: \"male\", age: \"61-65\", from: 732, to: 791, need: levels(2000, 2400, 2600) },\n { sex: \"male\", age: \"66-70\", from: 792, to: 851, need: levels(2000, 2200, 2600) },\n { sex: \"male\", age: \"71-75\", from: 852, to: 911, need: levels(2000, 2200, 2600) },\n { sex: \"male\", age: \"76 and up\", from: 912, need: levels(2000, 2200, 2400) },\n ],\n};\n\n/** The tables of estimated calorie needs, one record for each source. */\nexport const CALORIE_TABLES: readonly CalorieTable[] = [DGA_CALORIES];\n","import { checkSources, type Finding, type FindingCode, type GateOptions } from \"@mark1russell7/guidebook\";\nimport { valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport { ACTIVITY_LEVELS, CALORIE_SEXES, type CalorieRow, type CalorieTable } from \"./calorie.ts\";\n\n// The gate of a table of calorie needs: the gate of the sources of guidebook, the form of the hash, and the rows.\n\n/**\n * These are the codes of the gate of the rows and the hash. Each code is an error. The gate of the sources of `@mark1russell7/guidebook` gives its own codes.\n *\n * - `needs-hash`: the hash of the source is not 64 lowercase hexadecimal digits.\n * - `needs-row`: a row has no age or a wrong sex. Or its range of months is not a range of whole numbers of 0 or more.\n * - `needs-overlap`: two rows of one sex have ages in common.\n * - `needs-gap`: the rows of one sex do not cover each month with no gap, from the first row to an open last row.\n * - `needs-value`: a need is not a finite number above 0 in a unit of energy for each day.\n * - `needs-change`: a change has no stage, no title or a wrong sex, or a stage with a space at an end. Or a different\n * change has its stage and sex. Or its value is not a finite number in a unit of energy for each day. Or its sum with\n * the smallest need of its sex is not above 0.\n */\nexport const NEEDS_CODES: readonly [\"needs-hash\", \"needs-row\", \"needs-overlap\", \"needs-gap\", \"needs-value\", \"needs-change\"] = [\"needs-hash\", \"needs-row\", \"needs-overlap\", \"needs-gap\", \"needs-value\", \"needs-change\"];\n\n/** A code of the gate of a table of calorie needs. */\nexport type NeedsCode = (typeof NEEDS_CODES)[number];\n\n/** A finding of the gate of a table of calorie needs: a finding of the gate of the sources, or a finding of a row. */\nexport type NeedsFinding = Finding<NeedsCode | FindingCode, \"source\" | \"unit\" | \"row\" | \"change\">;\n\n/** This function tells if a need is a finite number in a unit of energy for each day, and above 0 when `positive` is true. */\nfunction goodNeed(need: Quantity, positive = true): boolean {\n try {\n const value = valueIn(need, \"kcal/d\");\n return Number.isFinite(value) && (!positive || value > 0);\n } catch {\n return false;\n }\n}\n\n/**\n * This function gives each finding of a table of calorie needs. A list with no error tells that the gate passes.\n *\n * - The findings of the source come from `checkSources` of `@mark1russell7/guidebook`, with the options of the call.\n * - The form of the hash and the rows have the codes of `NEEDS_CODES`.\n *\n * The findings are in the order of the table. The function is pure.\n *\n * @param table - The table of calorie needs\n * @param options - The options of the gate of the sources, for example the date of the gate\n */\nexport function checkCalorieTable(table: CalorieTable, options?: GateOptions): NeedsFinding[] {\n const findings: NeedsFinding[] = [...checkSources([table.source], options)];\n const add = (code: NeedsCode, record: \"source\" | \"row\" | \"change\", id: string, message: string): void => {\n findings.push({ level: \"error\", code, record, id, message });\n };\n const { sha256 } = table.source;\n if (sha256 !== undefined && !/^[0-9a-f]{64}$/u.test(sha256)) add(\"needs-hash\", \"source\", table.source.id, `The hash of the source \"${table.source.id}\" is not 64 lowercase hexadecimal digits.`);\n\n const whole = (value: number | undefined): boolean => value === undefined || (Number.isSafeInteger(value) && value >= 0);\n const range = (row: CalorieRow): boolean => whole(row.from) && whole(row.to) && (row.to === undefined || row.to >= row.from);\n const idOf = (index: number): string => `${table.id}.rows[${String(index)}]`;\n table.rows.forEach((row, index) => {\n const id = idOf(index);\n if (row.age.trim() === \"\" || !(CALORIE_SEXES as readonly unknown[]).includes(row.sex)) add(\"needs-row\", \"row\", id, `The row \"${id}\" has no age or a sex that is not a sex of the table.`);\n if (!range(row)) add(\"needs-row\", \"row\", id, `The row \"${id}\" has a range of months that is not a range of whole numbers of 0 or more.`);\n const needs = row.need.levels === undefined ? [row.need.each] : ACTIVITY_LEVELS.map((level) => row.need.levels?.[level]);\n if (!needs.every((need) => need !== undefined && goodNeed(need))) add(\"needs-value\", \"row\", id, `The row \"${id}\" has a need that is not a number above 0 in kcal/d.`);\n for (const other of table.rows.slice(0, index)) {\n if (other.sex !== row.sex) continue;\n if (row.from <= (other.to ?? Infinity) && other.from <= (row.to ?? Infinity)) add(\"needs-overlap\", \"row\", id, `The row \"${id}\" (${row.sex}, ${row.age}) has ages in common with the row ${other.age}.`);\n }\n });\n\n // The rows of each sex, in the order of their first month, cover each month with no gap to an open last row. A row with a bad range has its own finding.\n for (const sex of CALORIE_SEXES) {\n const rows = table.rows.map((row, index) => ({ row, index })).filter(({ row }) => row.sex === sex && range(row));\n rows.sort((a, b) => a.row.from - b.row.from);\n rows.slice(1).forEach(({ row, index }, at) => {\n const before = rows[at]?.row.to;\n if (before !== undefined && row.from > before + 1) add(\"needs-gap\", \"row\", idOf(index), `The table has no row of a ${sex} for the months ${String(before + 1)} to ${String(row.from - 1)}.`);\n });\n const last = rows.at(-1);\n if (last !== undefined && last.row.to !== undefined) add(\"needs-gap\", \"row\", idOf(last.index), `The last row of a ${sex} ends at ${String(last.row.to)} months. It is not an open row.`);\n }\n\n // The changes: a stage, a title and a sex of the table, one change for each stage and sex, and a finite value.\n // A change with the smallest need of its sex stays above 0. A row with a bad need has its own finding.\n const smallest = (sex: string): number =>\n Math.min(\n ...table.rows\n .filter((row) => row.sex === sex)\n .flatMap((row) => (row.need.levels === undefined ? [row.need.each] : ACTIVITY_LEVELS.map((level) => row.need.levels?.[level])))\n .filter((need): need is Quantity => need !== undefined && goodNeed(need))\n .map((need) => valueIn(need, \"kcal/d\")),\n );\n const seen = new Set<string>();\n (table.changes ?? []).forEach((change, index) => {\n const id = `${table.id}.changes[${String(index)}]`;\n const stage = typeof change.stage === \"string\" ? change.stage.trim() : \"\";\n const title = typeof change.title === \"string\" ? change.title.trim() : \"\";\n if (stage === \"\" || stage !== change.stage || title === \"\" || !(CALORIE_SEXES as readonly unknown[]).includes(change.sex)) add(\"needs-change\", \"change\", id, `The change \"${id}\" has no stage, no title, a stage with a space at an end or a sex that is not a sex of the table.`);\n else if (seen.has(`${change.sex} ${stage}`)) add(\"needs-change\", \"change\", id, `The change \"${id}\" has the stage ${stage} of a ${change.sex}, and a different change has it too.`);\n seen.add(`${String(change.sex)} ${stage}`);\n if (!goodNeed(change.change, false)) add(\"needs-change\", \"change\", id, `The change \"${id}\" has a value that is not a finite number in kcal/d.`);\n else if (smallest(change.sex) + valueIn(change.change, \"kcal/d\") <= 0) add(\"needs-change\", \"change\", id, `The change \"${id}\" makes the smallest need of a ${change.sex} 0 or less.`);\n });\n return findings;\n}\n\n/** This function tells if a list of findings has an error. */\nexport function hasNeedsError(findings: readonly NeedsFinding[]): boolean {\n return findings.some((finding) => finding.level === \"error\");\n}\n","import type { Finding } from \"@mark1russell7/guidebook\";\nimport type { SupplyCatalog } from \"@mark1russell7/market/supplies\";\nimport { valueIn } from \"@mark1russell7/quantity\";\n\n// The uses and the supply parts of the needs, and the gate of their joins with the reference lists.\n// An add-on does not import a different add-on. Thus the reference lists are parameters, and a test joins the real lists.\n\n/** The code of the need of the food draw: food energy, in `kcal` for each day. */\nexport const FOOD_NEED = \"food.energy\";\n\n/** The code of the need of drinking water, in `L` for each day. */\nexport const WATER_NEED = \"hydration.drink\";\n\n/** The resource of the food to eat with no water and no fuel, in `kcal`. It has a direct use for the food draw. */\nexport const NO_COOK = \"food.no-cook\";\n\n/** The resource of the stored drinking water, in `L`. It has a direct use for the water need. */\nexport const STORED_WATER = \"water.stored\";\n\n/** The direct use of a resource for a need: 1 unit of the resource gives `amount` of the need. */\nexport interface FragmentDirectUse {\n readonly resource: string;\n readonly need: string;\n readonly amount: number;\n}\n\n/**\n * The default reference part that supplies each need when no case stops it, by the code of the need.\n * The parts are `id` values of `SUPPLY_PARTS` of `@mark1russell7/stack-hazards`. A household with a well gives a different part.\n * The type has the exact keys. The annotation replaces `as const`, because the package has isolated declarations.\n */\nexport const NEED_SUPPLIES: { readonly \"hydration.drink\": \"water.main\"; readonly \"food.energy\": \"food.retail\" } = {\n \"hydration.drink\": \"water.main\",\n \"food.energy\": \"food.retail\",\n};\n\n/**\n * The direct uses of the resources of the buy list. Each use gives 1 unit of its need for each unit of its resource.\n *\n * - 1 L of stored drinking water gives 1 L of drink. This is a definition, not a read.\n * - 1 kcal of food to eat with no water and no fuel gives 1 kcal of food energy.\n *\n * These records have the form of `DirectUse` of `@mark1russell7/stack-endurance`.\n */\nexport const DIRECT_USES: readonly FragmentDirectUse[] = [\n { resource: STORED_WATER, need: WATER_NEED, amount: 1 },\n { resource: NO_COOK, need: FOOD_NEED, amount: 1 },\n];\n\n/**\n * These are the codes of the join gate. Each code is an error.\n *\n * - `join-use-resource`: a direct use names a resource that is not in the catalog.\n * - `join-use-need`: a direct use names a need that is not in the reference needs.\n * - `join-use-unit`: the unit of the resource of a direct use does not convert to the unit of its need.\n * - `join-use-amount`: the amount of a direct use is not the factor from the unit of its resource to the unit of its need.\n * - `join-supply-need`: a supply names a need that is not in the reference needs.\n * - `join-supply-part`: a supply names a part that is not in the reference parts.\n */\nexport const JOIN_CODES: readonly [\"join-use-resource\", \"join-use-need\", \"join-use-unit\", \"join-use-amount\", \"join-supply-need\", \"join-supply-part\"] = [\n \"join-use-resource\",\n \"join-use-need\",\n \"join-use-unit\",\n \"join-use-amount\",\n \"join-supply-need\",\n \"join-supply-part\",\n];\n\n/** A code of the join gate. */\nexport type JoinCode = (typeof JOIN_CODES)[number];\n\n/**\n * A finding of the join gate, in the form of a finding of `@mark1russell7/guidebook`. Each finding of the gate is an error.\n * The record is `use` for a direct use, with the resource of the use as its `id`. It is `supply` for a supply, with the need as its `id`.\n */\nexport type JoinFinding = Finding<JoinCode, \"use\" | \"supply\">;\n\n/** This function gives the factor from a unit to a different unit, or `undefined` when the units do not convert. */\nfunction factorOf(from: string, to: string): number | undefined {\n try {\n const factor = valueIn({ value: 1, unit: from }, to);\n return Number.isFinite(factor) ? factor : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A reference need: its code and its unit. Each record of `NEEDS` of `@mark1russell7/alerts` has this form. */\nexport interface ReferenceNeed {\n readonly code: string;\n readonly unit: string;\n}\n\n/** A reference part: its `id`. Each record of `SUPPLY_PARTS` of `@mark1russell7/stack-hazards` has this form. */\nexport interface ReferencePart {\n readonly id: string;\n}\n\n/** The reference lists of the join gate. */\nexport interface JoinReferences {\n /** The reference needs, for example `NEEDS` of `@mark1russell7/alerts`. */\n readonly needs: readonly ReferenceNeed[];\n /** The reference parts, for example `SUPPLY_PARTS` of `@mark1russell7/stack-hazards`. */\n readonly parts: readonly ReferencePart[];\n}\n\n/**\n * This function examines the joins of a catalog, the direct uses and the supply parts with the reference lists.\n *\n * - The resource of each direct use is a resource of the catalog, and its need is a reference need.\n * - The unit of the resource of each direct use converts to the unit of its need.\n * - The amount of each direct use is the factor of that conversion. A direct use is a definition, so a different rate is a converter with a cited source.\n * - Each supply names a reference need and a reference part.\n *\n * The findings are in the order of the uses, then in the order of the supplies. The function is pure.\n *\n * @param catalog - The catalog of supplies of `@mark1russell7/market`\n * @param uses - The direct uses, for example `DIRECT_USES`\n * @param supplies - The part that supplies each need, by the code of the need, for example `NEED_SUPPLIES`\n * @param references - The reference needs and the reference parts\n * @returns The findings of the joins. An empty list is a pass.\n */\nexport function checkJoins(\n catalog: SupplyCatalog,\n uses: readonly FragmentDirectUse[],\n supplies: Readonly<Record<string, string>>,\n references: JoinReferences,\n): JoinFinding[] {\n const findings: JoinFinding[] = [];\n const add = (code: JoinCode, record: \"use\" | \"supply\", id: string, message: string): void => {\n findings.push({ level: \"error\", code, record, id, message });\n };\n const units = new Map(catalog.resources.map((resource) => [resource.code, resource.unit] as const));\n const needs = new Map(references.needs.map((need) => [need.code, need.unit] as const));\n for (const use of uses) {\n const unit = units.get(use.resource);\n const needUnit = needs.get(use.need);\n if (unit === undefined) add(\"join-use-resource\", \"use\", use.resource, `The direct use of ${use.resource} names no resource of the catalog.`);\n if (needUnit === undefined) add(\"join-use-need\", \"use\", use.resource, `The direct use of ${use.resource} names the need ${use.need}, which is not a reference need.`);\n if (unit === undefined || needUnit === undefined) continue;\n const factor = factorOf(unit, needUnit);\n if (factor === undefined) {\n add(\"join-use-unit\", \"use\", use.resource, `The direct use of ${use.resource} for ${use.need} takes ${unit}, which does not convert to ${needUnit}.`);\n } else if (use.amount !== factor) {\n add(\n \"join-use-amount\",\n \"use\",\n use.resource,\n `The direct use of ${use.resource} for ${use.need} gives ${String(use.amount)} ${needUnit} for each ${unit}, not ${String(factor)}. A direct use is a definition: a different rate is a converter with a cited source.`,\n );\n }\n }\n const parts = new Set(references.parts.map((part) => part.id));\n for (const [need, part] of Object.entries(supplies)) {\n if (!needs.has(need)) add(\"join-supply-need\", \"supply\", need, `The supply of ${need} names no reference need.`);\n if (!parts.has(part)) add(\"join-supply-part\", \"supply\", need, `The supply of ${need} names the part ${part}, which is not a reference part.`);\n }\n return findings;\n}\n","import { buyListEnergy, giftsOf, type BuyListEnergy, type SupplyCatalog } from \"@mark1russell7/market/supplies\";\nimport { calorieNeed, type ActivityLevel, type CalorieNeedTotal, type CalorieTable, type Person } from \"./calorie.ts\";\nimport { DGA_CALORIES } from \"./data.ts\";\nimport { DIRECT_USES, FOOD_NEED, NEED_SUPPLIES, type FragmentDirectUse } from \"./uses.ts\";\n\n// The join of a household and a buy list into a fragment of an endurance layer: one draw of food energy and the stores of the list.\n// The records have the form of the records of `@mark1russell7/stack-endurance`. An add-on does not import a different add-on, so the form is a copy.\n// A test assigns the layer to `EnduranceLayer` of stack-endurance. That test is the type gate of the copy.\n// The fragment has no converter. No cited source gives the water and the fuel to cook 1 kg of dry food, and a number with no source is not data.\n\n/** A resource of a store, with its unit. */\nexport interface FragmentResource {\n readonly code: string;\n readonly unit: string;\n}\n\n/** A store of the buy list: an amount of one resource, in its unit. */\nexport interface FragmentStore {\n readonly id: string;\n readonly resource: string;\n readonly amount: number;\n}\n\n/** The food draw: the food energy of the persons of the draw for each day. */\nexport interface FragmentDraw {\n readonly need: string;\n readonly level: string;\n /** The food energy of the persons of the draw for each day, in `kcal`. It is above 0. */\n readonly perDay: number;\n /** The count of the persons of the draw. */\n readonly users: number;\n readonly supply: string;\n}\n\n/** A fragment of an endurance layer, with the form of `EnduranceLayer` of `@mark1russell7/stack-endurance`. It has no converter. */\nexport interface HouseholdFragment {\n /** The format of an endurance layer, `endurance/1`. */\n readonly schema: \"endurance/1\";\n readonly levels: readonly string[];\n readonly resources: readonly FragmentResource[];\n readonly stores: readonly FragmentStore[];\n readonly draws: readonly FragmentDraw[];\n readonly direct: readonly FragmentDirectUse[];\n}\n\n/** The action for the persons with no row in the table. The only action is `leave-out`. */\nexport type NoRowAction = \"leave-out\";\n\n/** The inputs of the household fragment. */\nexport interface HouseholdFragmentInput {\n /** The person records of the household. */\n readonly persons: readonly Person[];\n /** The activity level of each person record with no level of its own. It has no default. */\n readonly activity: ActivityLevel;\n /** The catalog of supplies of `@mark1russell7/market`. */\n readonly catalog: SupplyCatalog;\n /** The count of units of each product of the buy list, by the `id` of the product. */\n readonly units: Readonly<Record<string, number>>;\n /** The `id` of the part of the stack that supplies the food when no case stops it. The default is `NEED_SUPPLIES[\"food.energy\"]`, `food.retail`. */\n readonly supply?: string | undefined;\n /** The direct uses. The fragment takes each use for the need `food.energy`. The default is `DIRECT_USES`. */\n readonly uses?: readonly FragmentDirectUse[] | undefined;\n /** The level of the food draw. It is one of the levels of the joined layer. */\n readonly level: string;\n /** The levels of the fragment. The default is no levels: a different fragment of the stack gives them. */\n readonly levels?: readonly string[] | undefined;\n /** The table of calorie needs. The default is `DGA_CALORIES`. */\n readonly table?: CalorieTable | undefined;\n /** The start of the `id` of each store. The default is `buy`. */\n readonly prefix?: string | undefined;\n /**\n * The action for the persons with no row in the table. Without it, a person with no row gives no layer.\n * With `leave-out`, the draw has no need of those persons, and the result lists them.\n */\n readonly noRow?: NoRowAction | undefined;\n}\n\n/** A gift of the buy list with no read. The fragment has no store for it. A no read is not 0. */\nexport interface GiftNoRead {\n readonly product: string;\n readonly resource: string;\n readonly why: string;\n}\n\n/** The parts of the result that do not change with the draw. */\nexport interface HouseholdStoresResult {\n /** The food energy of each product of the buy list. A caller gets the energy of the dry food for its converters from it. */\n readonly energy: BuyListEnergy;\n /** The gifts of the buy list with no read. */\n readonly noReads: readonly GiftNoRead[];\n /** True when each gift of the buy list has a read. When it is false, the stores are a lower limit. */\n readonly storesRead: boolean;\n}\n\n/** The household fragment with its draw. The draw is exact for its users. */\nexport interface HouseholdFragmentRead extends HouseholdStoresResult {\n readonly layer: HouseholdFragment;\n /**\n * The food energy of the household for one day, with a line for each person record. Its `read` covers the whole\n * household. It is false when a person is left out, or when a record with count 0 has no row. The flag of the draw\n * is `needRead`.\n */\n readonly need: CalorieNeedTotal;\n /** This field is true: the draw has a read for each of its users. */\n readonly needRead: true;\n /** The persons with no row that the option `leave-out` left out of the draw. With no option, the list is empty. */\n readonly leftOut: readonly Person[];\n}\n\n/** No household fragment: the draw has no read. A low rate gives too many days, so the function gives no layer. */\nexport interface HouseholdFragmentNoRead extends HouseholdStoresResult {\n readonly layer: undefined;\n /** The food energy of the household for one day. It is `undefined` when the household has no person. */\n readonly need: CalorieNeedTotal | undefined;\n readonly needRead: false;\n /** The persons with no row in the table. */\n readonly noRow: readonly Person[];\n /** The reason for no layer. */\n readonly why: string;\n}\n\n/** The household fragment, or a no read of the draw. Both have the reads of the buy list. */\nexport type HouseholdFragmentResult = HouseholdFragmentRead | HouseholdFragmentNoRead;\n\n/** This function gives the stores of the buy list, its resources and its gifts with no read. */\nfunction buyListStores(\n input: HouseholdFragmentInput,\n foodUses: readonly FragmentDirectUse[],\n): { stores: FragmentStore[]; resources: FragmentResource[]; parts: HouseholdStoresResult } {\n const { catalog, units } = input;\n const energy = buyListEnergy(catalog, units);\n const unitOf = new Map(catalog.resources.map((resource) => [resource.code, resource.unit]));\n for (const use of foodUses) {\n if (unitOf.get(use.resource) !== \"kcal\") throw new RangeError(`The catalog has no resource \"${use.resource}\" in kcal for the food use.`);\n }\n const prefix = input.prefix ?? \"buy\";\n const stores: FragmentStore[] = [];\n const noReads: GiftNoRead[] = [];\n for (const [product, count] of Object.entries(units)) {\n for (const gift of giftsOf(catalog, product, count)) {\n if (!gift.read) noReads.push({ product, resource: gift.resource, why: gift.why });\n else if (gift.amount > 0) stores.push({ id: `${prefix}:${product}:${gift.resource}`, resource: gift.resource, amount: gift.amount });\n }\n }\n const codes = [...new Set([...stores.map((store) => store.resource), ...foodUses.map((use) => use.resource)])];\n const resources = codes.map((code) => ({ code, unit: unitOf.get(code) ?? \"\" }));\n return { stores, resources, parts: { energy, noReads, storesRead: noReads.length === 0 } };\n}\n\n/**\n * This function joins a household and a buy list into a fragment of an endurance layer.\n *\n * - The fragment has one draw of food energy. Its rate is the need of the persons for one day, and its users are the persons.\n * - Each gift of the buy list with a read is one store, with the `id` `<prefix>:<product>:<resource>`. A gift with no read has no store.\n * - The direct uses are the food uses: each use of `uses` for the need `food.energy`. The default `DIRECT_USES` gives `food.no-cook`, 1 kcal for each kcal.\n * - The resources are the resources of the stores and of the food uses, with the units of the catalog.\n * - The supply part of the draw is `supply`. Its default is the part of `NEED_SUPPLIES` for `food.energy`.\n * - The fragment has no converter. A caller adds converters for the dry food, with the water and the fuel of each run.\n *\n * A person with no row in the table gives no layer, because a low rate gives too many days.\n * The option `noRow: \"leave-out\"` leaves those persons out of the draw. A draw of 0 kcal gives no layer.\n * The function is pure.\n *\n * @param input - The persons, the activity level, the catalog and the buy list, the supply part and the level of the draw\n * @returns The fragment or a no read of the draw, with the energy of the list and the gifts with no read\n * @throws RangeError for the errors of `calorieNeed`, `giftsOf` and `buyListEnergy`, except a household with no person\n * @throws RangeError when the catalog has no resource in `kcal` for a food use\n */\nexport function householdFragment(input: HouseholdFragmentInput): HouseholdFragmentResult {\n const foodUses = (input.uses ?? DIRECT_USES).filter((use) => use.need === FOOD_NEED);\n const { stores, resources, parts } = buyListStores(input, foodUses);\n if (input.persons.every((person) => person.count === 0)) {\n return { ...parts, layer: undefined, need: undefined, needRead: false, noRow: [], why: \"The household has no person, so the draw is 0 kcal.\" };\n }\n const need = calorieNeed(input.table ?? DGA_CALORIES, input.persons, input.activity, 1);\n const noRow: Person[] = [];\n let users = 0;\n for (const line of need.lines) {\n if (line.read) users += line.person.count;\n else if (line.person.count > 0) noRow.push(line.person);\n }\n if (noRow.length > 0 && input.noRow !== \"leave-out\") {\n return { ...parts, layer: undefined, need, needRead: false, noRow, why: `The table has no row for ${String(noRow.length)} person records. The option noRow: \"leave-out\" leaves them out of the draw.` };\n }\n if (users === 0 || need.need.value <= 0) {\n return { ...parts, layer: undefined, need, needRead: false, noRow, why: \"No person of the draw has a row in the table, so the draw is 0 kcal.\" };\n }\n const draw: FragmentDraw = { need: FOOD_NEED, level: input.level, perDay: need.need.value, users, supply: input.supply ?? NEED_SUPPLIES[FOOD_NEED] };\n return {\n ...parts,\n layer: {\n schema: \"endurance/1\",\n levels: [...(input.levels ?? [])],\n resources,\n stores,\n draws: [draw],\n direct: foodUses.map((use) => ({ ...use })),\n },\n need,\n needRead: true,\n leftOut: noRow,\n };\n}\n"],"mappings":";;;;;AAQA,MAAa,kBAAyE;CAAC;CAAa;CAAqB;AAAQ;;AAMjI,MAAa,gBAA6C,CAAC,UAAU,MAAM;;AAoF3E,MAAM,cAAc;;AAEpB,MAAM,aAAa;;AAGnB,SAAgB,gBAAgB,OAAwC;CACtE,OAAQ,gBAAuC,SAAS,KAAK;AAC/D;;;;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U;EAAO;EAAO,KAAK,4BAA4B,OAAO,MAAM,MAAM,EAAE;CAA6E;CAExM,IAAI,UAAU,KAAK,KAAK,KAAK,SAAS,GACpC,OAAO;EAAE,GAAG;EAAO,OAAO,KAAA;EAAW;EAAM,UAAU;EAAO;EAAO,KAAK;CAAuE;CAEjJ,MAAM,OAAqB;EAAE,MAAM;EAAW,OAAO,MAAM;EAAO,QAAQ,KAAK,KAAK;EAAO;EAAO,QAAQ,MAAM,UAAU,cAAA;CAAyB;CACnJ,OAAO;EACL,GAAG;EACH,OAAO;GACL,QAAQ;GACR,QAAQ,CAAC,GAAI,MAAM,UAAU,CAAC,CAAE;GAChC;GACA;GACA,OAAO,CAAC,IAAI;GACZ,QAAQ,SAAS,KAAK,SAAS,EAAE,GAAG,IAAI,EAAE;EAC5C;EACA;EACA,UAAU;EACV,SAAS;CACX;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/calorie.ts","../src/data.ts","../src/check.ts","../src/uses.ts","../src/household.ts"],"sourcesContent":["import { quantity, valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport type { Source } from \"@mark1russell7/guidebook\";\n\n// The energy need of the persons of a household, from a cited table of estimated calorie needs.\n// The package names no person. The persons and their activity level are input data.\n// A person record has a sex, an age in months and a count. Each table finds its own row from its own age ranges.\n\n/** The activity levels of the table, as the source names them: sedentary, moderately active and active. */\nexport const ACTIVITY_LEVELS: readonly [\"sedentary\", \"moderately-active\", \"active\"] = [\"sedentary\", \"moderately-active\", \"active\"];\n\n/** An activity level of the table. */\nexport type ActivityLevel = (typeof ACTIVITY_LEVELS)[number];\n\n/** The sexes of the table. */\nexport const CALORIE_SEXES: readonly [\"female\", \"male\"] = [\"female\", \"male\"];\n\n/** A sex of the table. */\nexport type CalorieSex = (typeof CALORIE_SEXES)[number];\n\n/**\n * The estimated calorie need of one person of a row for each day. A row gives a need for each activity level, or one need for all levels.\n * The table of the toddlers gives one need for each age and sex only. Each need has a unit of energy for each day, for example `{ \"value\": 2000, \"unit\": \"kcal/d\" }`.\n */\nexport type CalorieNeed = { readonly levels: Readonly<Record<ActivityLevel, Quantity>>; readonly each?: never } | { readonly each: Quantity; readonly levels?: never };\n\n/** A row of a table of calorie needs: a sex, a range of ages in months, and the need. */\nexport interface CalorieRow {\n readonly sex: CalorieSex;\n /** The age as the source names it, for example `19-20` (years) or `21 through 23 months`. */\n readonly age: string;\n /** The first age of the row, in whole months. */\n readonly from: number;\n /** The last age of the row, in whole months. Without it, the row applies to each larger age. */\n readonly to?: number | undefined;\n readonly need: CalorieNeed;\n}\n\n/**\n * A change of the daily need of a person at a stage, for example the second trimester of a pregnancy. The change adds\n * to the need of the row of the person. It can be 0.\n */\nexport interface CalorieChange {\n /** The id of the stage, for example `pregnancy-2`. */\n readonly stage: string;\n /** The stage as the source names it, for example `Pregnancy: 2nd trimester`. */\n readonly title: string;\n /** The sex of the persons of the stage. */\n readonly sex: CalorieSex;\n /** The change of the need for each day, in a unit of energy for each day, for example `{ \"value\": 340, \"unit\": \"kcal/d\" }`. */\n readonly change: Quantity;\n /** The condition of the source for the change, for example a healthy weight before the pregnancy. */\n readonly condition?: string | undefined;\n}\n\n/** A table of estimated calorie needs from one source. */\nexport interface CalorieTable {\n /** The id, for example `dga.2020-2025:calorie-needs`. */\n readonly id: string;\n readonly title: string;\n readonly source: Source;\n /** The place of the tables in the source: the tables and their pages. */\n readonly locator: string;\n /** The rows of the table. The age ranges of the rows of one sex do not overlap. */\n readonly rows: readonly CalorieRow[];\n /** The changes of the need at each stage. The stage and the sex of each change are unique. */\n readonly changes?: readonly CalorieChange[] | undefined;\n}\n\n/** A group of persons of the same sex and age, and their count. */\nexport interface Person {\n readonly sex: CalorieSex;\n /** The age, in whole months, for example 420 for 35 years. */\n readonly ageMonths: number;\n readonly count: number;\n /** The activity level of the persons. Without it, the level of the call applies. */\n readonly level?: ActivityLevel | undefined;\n /** The stage of the persons, for example `pregnancy-2`: the stage of a change of the table. Without it, no change applies. */\n readonly stage?: string | undefined;\n}\n\n/** The need of one person record for the days, or no read when the table has no row for the age. */\nexport type CalorieNeedLine =\n | { readonly person: Person; readonly read: true; readonly level: ActivityLevel; readonly row: string; readonly stage?: string | undefined; readonly need: Quantity }\n | { readonly person: Person; readonly read: false; readonly why: string };\n\n/** The energy need of the persons of a household for a count of days. */\nexport interface CalorieNeedTotal {\n /** The need of each person record, in the order of the input. */\n readonly lines: readonly CalorieNeedLine[];\n /** True when each line has a read. When it is false, `need` is a lower limit. */\n readonly read: boolean;\n /** The sum of the needs of the lines with a read, in `kcal`. */\n readonly need: Quantity;\n /** The count of the persons of all the records, also of the records with no read. */\n readonly persons: number;\n}\n\n/** The unit of each food energy. */\nconst ENERGY_UNIT = \"kcal\";\n/** The unit of each daily need. */\nconst DAILY_UNIT = \"kcal/d\";\n\n/** This function tells if a value is an activity level of the table. */\nexport function isActivityLevel(level: unknown): level is ActivityLevel {\n return (ACTIVITY_LEVELS as readonly unknown[]).includes(level);\n}\n\n/**\n * This function gives the row of a table for a sex and an age in months, or `undefined` when the table has no row.\n *\n * @param table - The table of calorie needs\n * @param sex - The sex\n * @param ageMonths - The age, in whole months\n */\nexport function calorieRow(table: CalorieTable, sex: CalorieSex, ageMonths: number): CalorieRow | undefined {\n return table.rows.find((row) => row.sex === sex && ageMonths >= row.from && (row.to === undefined || ageMonths <= row.to));\n}\n\n/**\n * This function gives the change of a table for a sex and a stage, or `undefined` when the table has no such change.\n *\n * @param table - The table of calorie needs\n * @param sex - The sex\n * @param stage - The id of the stage, for example `pregnancy-2`\n */\nexport function calorieChange(table: CalorieTable, sex: CalorieSex, stage: string): CalorieChange | undefined {\n return table.changes?.find((change) => change.sex === sex && change.stage === stage);\n}\n\n/**\n * This function gives the energy need of the persons of a household for a count of days, in `kcal`.\n * It adds the need of each person at the activity level of that person. The table finds the row of each person from the age.\n *\n * - An age with no row in the table gives a line with no read, for example 6 months. Then the total is a lower limit.\n * - The table of the toddlers gives one need for each age and sex. Thus the level does not change the need of a toddler.\n * - A record with a stage adds the change of the stage to the need of its row, for example 340 kcal/d in the second trimester.\n * - One stage holds for each day of the call. For a period that crosses stages, the planner selects the stage, for example the stage with the largest change.\n *\n * The activity level is an explicit input. This package has no default level. The planner selects it, also for the worst case of a long power cut.\n * In that case, work can make the level higher, for example the carry of water. The function is pure.\n *\n * @param table - The table of calorie needs\n * @param persons - The person records of the household: a sex, an age in months, a count and, as an option, a level\n * @param level - The activity level of each record with no level of its own\n * @param days - The count of days, a finite number of 0 or more\n * @throws RangeError when a count of persons or an age is not a whole number of 0 or more, or when the household has no person\n * @throws RangeError when a level is not a level of the table, or when a sex is not a sex of the table\n * @throws RangeError when the count of days is not a finite number of 0 or more\n * @throws RangeError when the table has no change for the stage and the sex of a record\n * @throws RangeError when the daily need of a record, with the change of its stage, is not above 0\n */\nexport function calorieNeed(table: CalorieTable, persons: readonly Person[], level: ActivityLevel, days: number): CalorieNeedTotal {\n if (!(Number.isFinite(days) && days >= 0)) throw new RangeError(`The count of days is ${String(days)}. It must be a finite number of 0 or more.`);\n if (!isActivityLevel(level)) throw new RangeError(`The activity level ${String(level)} is not a level of the table.`);\n let count = 0;\n const lines = persons.map((person): CalorieNeedLine => {\n const name = `${String(person.sex)} of ${String(person.ageMonths)} months`;\n if (!(Number.isSafeInteger(person.count) && person.count >= 0)) throw new RangeError(`The count of the persons ${name} is ${String(person.count)}. It must be a whole number of 0 or more.`);\n if (!(Number.isSafeInteger(person.ageMonths) && person.ageMonths >= 0)) throw new RangeError(`The age of the persons ${name} is not a whole number of months of 0 or more.`);\n if (!(CALORIE_SEXES as readonly unknown[]).includes(person.sex)) throw new RangeError(`The sex ${String(person.sex)} is not a sex of the table.`);\n const own = person.level ?? level;\n if (!isActivityLevel(own)) throw new RangeError(`The activity level ${String(own)} of the persons ${name} is not a level of the table.`);\n // A stage that the table does not have is an error, not a no read: the option leave-out would remove the persons from a draw.\n const change = person.stage === undefined ? undefined : calorieChange(table, person.sex, person.stage);\n if (person.stage !== undefined && change === undefined) throw new RangeError(`The table ${table.id} has no change for the stage ${String(person.stage)} of the persons ${name}.`);\n count += person.count;\n const row = calorieRow(table, person.sex, person.ageMonths);\n if (row === undefined) return { person, read: false, why: `The table ${table.id} has no row for a ${name}.` };\n const daily = valueIn(row.need.levels === undefined ? row.need.each : row.need.levels[own], DAILY_UNIT) + (change === undefined ? 0 : valueIn(change.change, DAILY_UNIT));\n if (!(daily > 0)) throw new RangeError(`The daily need of the persons ${name} at the stage ${String(person.stage)} is ${String(daily)} kcal/d. It must be above 0.`);\n const line = { person, read: true as const, level: own, row: row.age, need: quantity(person.count * daily * days, ENERGY_UNIT) };\n return change === undefined ? line : { ...line, stage: change.stage };\n });\n if (count === 0) throw new RangeError(\"The household has no person.\");\n const total = lines.reduce((sum, line) => sum + (line.read ? line.need.value : 0), 0);\n return { lines, read: lines.every((line) => line.read), need: quantity(total, ENERGY_UNIT), persons: count };\n}\n","import type { CalorieChange, CalorieNeed, CalorieTable } from \"./calorie.ts\";\nimport type { Source } from \"@mark1russell7/guidebook\";\n\n// The estimated calorie needs of the Dietary Guidelines for Americans, 2020-2025. Each value is from the tables of\n// Appendix 2 of the PDF, read on 2026-11-22. A calorie of the source is a food calorie, thus 1 kcal. The source gives\n// each need for a reference height and weight, to keep the weight of a person. A person can need more or less.\n// The rows of the toddlers are at 12, 15, 18 and 21 through 23 months. Each row here covers the months up to the next row.\n// The changes of pregnancy and lactation are from Table A2-3. The source gives them for women with a healthy weight before\n// the pregnancy.\n// The 2025-2030 edition of the guidelines (read on 2026-11-24) has no table of calorie needs. It sends the reader to the\n// DRI calculator of the USDA. Its daily servings by calorie level start at a calorie level and do not give a need. So\n// this table stays the table of the 2020-2025 edition.\n\n/** The source of the calorie table: the PDF of the Dietary Guidelines for Americans, 2020-2025, 9th Edition. It is a work of the United States federal government. */\nexport const DGA_SOURCE: Source = {\n id: \"dga-2020-2025\",\n title: \"Dietary Guidelines for Americans, 2020-2025, 9th Edition\",\n url: \"https://www.dietaryguidelines.gov/sites/default/files/2020-12/Dietary_Guidelines_for_Americans_2020-2025.pdf\",\n license: \"us-public-domain\",\n checked: \"2026-11-22\",\n by: \"U.S. Department of Agriculture and U.S. Department of Health and Human Services\",\n sha256: \"ceea04ce1a7c13a95a170f3548ed3926ad6dd49599bd730fb58bc9c02711d16e\",\n};\n\nconst day = (value: number): { readonly value: number; readonly unit: string } => ({ value, unit: \"kcal/d\" });\nconst levels = (sedentary: number, moderate: number, active: number): CalorieNeed => ({ levels: { sedentary: day(sedentary), \"moderately-active\": day(moderate), active: day(active) } });\nconst each = (value: number): CalorieNeed => ({ each: day(value) });\nconst HEALTHY = \"For women with a healthy weight before the pregnancy. Other women ask their health care provider.\";\nconst change = (stage: string, title: string, value: number): CalorieChange => ({ stage, title, sex: \"female\", change: day(value), condition: HEALTHY });\n\n/** The table of estimated calorie needs of the Dietary Guidelines for Americans, 2020-2025: 68 rows, 34 for each sex, and 5 changes of pregnancy and lactation. */\nexport const DGA_CALORIES: CalorieTable = {\n id: \"dga.2020-2025:calorie-needs\",\n title: \"Dietary Guidelines for Americans, 2020-2025: Estimated Calorie Needs\",\n source: DGA_SOURCE,\n locator: \"Appendix 2: Table A2-1 (ages 12 through 23 months, page 139), Table A2-2 (ages 2 and older, pages 140 and 141) and Table A2-3 (pregnancy and lactation, page 141)\",\n changes: [\n change(\"pregnancy-1\", \"Pregnancy: 1st trimester\", 0),\n change(\"pregnancy-2\", \"Pregnancy: 2nd trimester\", 340),\n change(\"pregnancy-3\", \"Pregnancy: 3rd trimester\", 452),\n change(\"lactation-1\", \"Lactation: 1st 6 months\", 330),\n change(\"lactation-2\", \"Lactation: 2nd 6 months\", 400),\n ],\n rows: [\n { sex: \"female\", age: \"12 months\", from: 12, to: 14, need: each(800) },\n { sex: \"female\", age: \"15 months\", from: 15, to: 17, need: each(800) },\n { sex: \"female\", age: \"18 months\", from: 18, to: 20, need: each(900) },\n { sex: \"female\", age: \"21 through 23 months\", from: 21, to: 23, need: each(1000) },\n { sex: \"female\", age: \"2\", from: 24, to: 35, need: levels(1000, 1000, 1000) },\n { sex: \"female\", age: \"3\", from: 36, to: 47, need: levels(1000, 1200, 1400) },\n { sex: \"female\", age: \"4\", from: 48, to: 59, need: levels(1200, 1400, 1400) },\n { sex: \"female\", age: \"5\", from: 60, to: 71, need: levels(1200, 1400, 1600) },\n { sex: \"female\", age: \"6\", from: 72, to: 83, need: levels(1200, 1400, 1600) },\n { sex: \"female\", age: \"7\", from: 84, to: 95, need: levels(1200, 1600, 1800) },\n { sex: \"female\", age: \"8\", from: 96, to: 107, need: levels(1400, 1600, 1800) },\n { sex: \"female\", age: \"9\", from: 108, to: 119, need: levels(1400, 1600, 1800) },\n { sex: \"female\", age: \"10\", from: 120, to: 131, need: levels(1400, 1800, 2000) },\n { sex: \"female\", age: \"11\", from: 132, to: 143, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"12\", from: 144, to: 155, need: levels(1600, 2000, 2200) },\n { sex: \"female\", age: \"13\", from: 156, to: 167, need: levels(1600, 2000, 2200) },\n { sex: \"female\", age: \"14\", from: 168, to: 179, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"15\", from: 180, to: 191, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"16\", from: 192, to: 203, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"17\", from: 204, to: 215, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"18\", from: 216, to: 227, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"19-20\", from: 228, to: 251, need: levels(2000, 2200, 2400) },\n { sex: \"female\", age: \"21-25\", from: 252, to: 311, need: levels(2000, 2200, 2400) },\n { sex: \"female\", age: \"26-30\", from: 312, to: 371, need: levels(1800, 2000, 2400) },\n { sex: \"female\", age: \"31-35\", from: 372, to: 431, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"36-40\", from: 432, to: 491, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"41-45\", from: 492, to: 551, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"46-50\", from: 552, to: 611, need: levels(1800, 2000, 2200) },\n { sex: \"female\", age: \"51-55\", from: 612, to: 671, need: levels(1600, 1800, 2200) },\n { sex: \"female\", age: \"56-60\", from: 672, to: 731, need: levels(1600, 1800, 2200) },\n { sex: \"female\", age: \"61-65\", from: 732, to: 791, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"66-70\", from: 792, to: 851, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"71-75\", from: 852, to: 911, need: levels(1600, 1800, 2000) },\n { sex: \"female\", age: \"76 and up\", from: 912, need: levels(1600, 1800, 2000) },\n { sex: \"male\", age: \"12 months\", from: 12, to: 14, need: each(800) },\n { sex: \"male\", age: \"15 months\", from: 15, to: 17, need: each(900) },\n { sex: \"male\", age: \"18 months\", from: 18, to: 20, need: each(1000) },\n { sex: \"male\", age: \"21 through 23 months\", from: 21, to: 23, need: each(1000) },\n { sex: \"male\", age: \"2\", from: 24, to: 35, need: levels(1000, 1000, 1000) },\n { sex: \"male\", age: \"3\", from: 36, to: 47, need: levels(1000, 1400, 1400) },\n { sex: \"male\", age: \"4\", from: 48, to: 59, need: levels(1200, 1400, 1600) },\n { sex: \"male\", age: \"5\", from: 60, to: 71, need: levels(1200, 1400, 1600) },\n { sex: \"male\", age: \"6\", from: 72, to: 83, need: levels(1400, 1600, 1800) },\n { sex: \"male\", age: \"7\", from: 84, to: 95, need: levels(1400, 1600, 1800) },\n { sex: \"male\", age: \"8\", from: 96, to: 107, need: levels(1400, 1600, 2000) },\n { sex: \"male\", age: \"9\", from: 108, to: 119, need: levels(1600, 1800, 2000) },\n { sex: \"male\", age: \"10\", from: 120, to: 131, need: levels(1600, 1800, 2200) },\n { sex: \"male\", age: \"11\", from: 132, to: 143, need: levels(1800, 2000, 2200) },\n { sex: \"male\", age: \"12\", from: 144, to: 155, need: levels(1800, 2200, 2400) },\n { sex: \"male\", age: \"13\", from: 156, to: 167, need: levels(2000, 2200, 2600) },\n { sex: \"male\", age: \"14\", from: 168, to: 179, need: levels(2000, 2400, 2800) },\n { sex: \"male\", age: \"15\", from: 180, to: 191, need: levels(2200, 2600, 3000) },\n { sex: \"male\", age: \"16\", from: 192, to: 203, need: levels(2400, 2800, 3200) },\n { sex: \"male\", age: \"17\", from: 204, to: 215, need: levels(2400, 2800, 3200) },\n { sex: \"male\", age: \"18\", from: 216, to: 227, need: levels(2400, 2800, 3200) },\n { sex: \"male\", age: \"19-20\", from: 228, to: 251, need: levels(2600, 2800, 3000) },\n { sex: \"male\", age: \"21-25\", from: 252, to: 311, need: levels(2400, 2800, 3000) },\n { sex: \"male\", age: \"26-30\", from: 312, to: 371, need: levels(2400, 2600, 3000) },\n { sex: \"male\", age: \"31-35\", from: 372, to: 431, need: levels(2400, 2600, 3000) },\n { sex: \"male\", age: \"36-40\", from: 432, to: 491, need: levels(2400, 2600, 2800) },\n { sex: \"male\", age: \"41-45\", from: 492, to: 551, need: levels(2200, 2600, 2800) },\n { sex: \"male\", age: \"46-50\", from: 552, to: 611, need: levels(2200, 2400, 2800) },\n { sex: \"male\", age: \"51-55\", from: 612, to: 671, need: levels(2200, 2400, 2800) },\n { sex: \"male\", age: \"56-60\", from: 672, to: 731, need: levels(2200, 2400, 2600) },\n { sex: \"male\", age: \"61-65\", from: 732, to: 791, need: levels(2000, 2400, 2600) },\n { sex: \"male\", age: \"66-70\", from: 792, to: 851, need: levels(2000, 2200, 2600) },\n { sex: \"male\", age: \"71-75\", from: 852, to: 911, need: levels(2000, 2200, 2600) },\n { sex: \"male\", age: \"76 and up\", from: 912, need: levels(2000, 2200, 2400) },\n ],\n};\n\n/** The tables of estimated calorie needs, one record for each source. */\nexport const CALORIE_TABLES: readonly CalorieTable[] = [DGA_CALORIES];\n","import { checkSources, type Finding, type FindingCode, type GateOptions } from \"@mark1russell7/guidebook\";\nimport { valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport { ACTIVITY_LEVELS, CALORIE_SEXES, type CalorieRow, type CalorieTable } from \"./calorie.ts\";\n\n// The gate of a table of calorie needs: the gate of the sources of guidebook, and the rows.\n\n/**\n * These are the codes of the gate of the rows. Each code is an error. The gate of the sources of `@mark1russell7/guidebook` gives its own codes.\n *\n * - `needs-row`: a row has no age or a wrong sex. Or its range of months is not a range of whole numbers of 0 or more.\n * - `needs-overlap`: two rows of one sex have ages in common.\n * - `needs-gap`: the rows of one sex do not cover each month with no gap, from the first row to an open last row.\n * - `needs-value`: a need is not a finite number above 0 in a unit of energy for each day.\n * - `needs-change`: a change has no stage, no title or a wrong sex, or a stage with a space at an end. Or a different\n * change has its stage and sex. Or its value is not a finite number in a unit of energy for each day. Or its sum with\n * the smallest need of its sex is not above 0.\n */\nexport const NEEDS_CODES: readonly [\"needs-row\", \"needs-overlap\", \"needs-gap\", \"needs-value\", \"needs-change\"] = [\"needs-row\", \"needs-overlap\", \"needs-gap\", \"needs-value\", \"needs-change\"];\n\n/** A code of the gate of a table of calorie needs. */\nexport type NeedsCode = (typeof NEEDS_CODES)[number];\n\n/** A finding of the gate of a table of calorie needs: a finding of the gate of the sources, or a finding of a row. */\nexport type NeedsFinding = Finding<NeedsCode | FindingCode, \"source\" | \"unit\" | \"row\" | \"change\">;\n\n/** This function tells if a need is a finite number in a unit of energy for each day, and above 0 when `positive` is true. */\nfunction goodNeed(need: Quantity, positive = true): boolean {\n try {\n const value = valueIn(need, \"kcal/d\");\n return Number.isFinite(value) && (!positive || value > 0);\n } catch {\n return false;\n }\n}\n\n/**\n * This function gives each finding of a table of calorie needs. A list with no error tells that the gate passes.\n *\n * - The findings of the source come from `checkSources` of `@mark1russell7/guidebook`, with the options of the call.\n * - The hash of the source is part of the gate of the sources (`bad-sha256`).\n * - The rows have the codes of `NEEDS_CODES`.\n *\n * The findings are in the order of the table. The function is pure.\n *\n * @param table - The table of calorie needs\n * @param options - The options of the gate of the sources, for example the date of the gate\n */\nexport function checkCalorieTable(table: CalorieTable, options?: GateOptions): NeedsFinding[] {\n const findings: NeedsFinding[] = [...checkSources([table.source], options)];\n const add = (code: NeedsCode, record: \"source\" | \"row\" | \"change\", id: string, message: string): void => {\n findings.push({ level: \"error\", code, record, id, message });\n };\n\n const whole = (value: number | undefined): boolean => value === undefined || (Number.isSafeInteger(value) && value >= 0);\n const range = (row: CalorieRow): boolean => whole(row.from) && whole(row.to) && (row.to === undefined || row.to >= row.from);\n const idOf = (index: number): string => `${table.id}.rows[${String(index)}]`;\n table.rows.forEach((row, index) => {\n const id = idOf(index);\n if (row.age.trim() === \"\" || !(CALORIE_SEXES as readonly unknown[]).includes(row.sex)) add(\"needs-row\", \"row\", id, `The row \"${id}\" has no age or a sex that is not a sex of the table.`);\n if (!range(row)) add(\"needs-row\", \"row\", id, `The row \"${id}\" has a range of months that is not a range of whole numbers of 0 or more.`);\n const needs = row.need.levels === undefined ? [row.need.each] : ACTIVITY_LEVELS.map((level) => row.need.levels?.[level]);\n if (!needs.every((need) => need !== undefined && goodNeed(need))) add(\"needs-value\", \"row\", id, `The row \"${id}\" has a need that is not a number above 0 in kcal/d.`);\n for (const other of table.rows.slice(0, index)) {\n if (other.sex !== row.sex) continue;\n if (row.from <= (other.to ?? Infinity) && other.from <= (row.to ?? Infinity)) add(\"needs-overlap\", \"row\", id, `The row \"${id}\" (${row.sex}, ${row.age}) has ages in common with the row ${other.age}.`);\n }\n });\n\n // The rows of each sex, in the order of their first month, cover each month with no gap to an open last row. A row with a bad range has its own finding.\n for (const sex of CALORIE_SEXES) {\n const rows = table.rows.map((row, index) => ({ row, index })).filter(({ row }) => row.sex === sex && range(row));\n rows.sort((a, b) => a.row.from - b.row.from);\n rows.slice(1).forEach(({ row, index }, at) => {\n const before = rows[at]?.row.to;\n if (before !== undefined && row.from > before + 1) add(\"needs-gap\", \"row\", idOf(index), `The table has no row of a ${sex} for the months ${String(before + 1)} to ${String(row.from - 1)}.`);\n });\n const last = rows.at(-1);\n if (last !== undefined && last.row.to !== undefined) add(\"needs-gap\", \"row\", idOf(last.index), `The last row of a ${sex} ends at ${String(last.row.to)} months. It is not an open row.`);\n }\n\n // The changes: a stage, a title and a sex of the table, one change for each stage and sex, and a finite value.\n // A change with the smallest need of its sex stays above 0. A row with a bad need has its own finding.\n const smallest = (sex: string): number =>\n Math.min(\n ...table.rows\n .filter((row) => row.sex === sex)\n .flatMap((row) => (row.need.levels === undefined ? [row.need.each] : ACTIVITY_LEVELS.map((level) => row.need.levels?.[level])))\n .filter((need): need is Quantity => need !== undefined && goodNeed(need))\n .map((need) => valueIn(need, \"kcal/d\")),\n );\n const seen = new Set<string>();\n (table.changes ?? []).forEach((change, index) => {\n const id = `${table.id}.changes[${String(index)}]`;\n const stage = typeof change.stage === \"string\" ? change.stage.trim() : \"\";\n const title = typeof change.title === \"string\" ? change.title.trim() : \"\";\n if (stage === \"\" || stage !== change.stage || title === \"\" || !(CALORIE_SEXES as readonly unknown[]).includes(change.sex)) add(\"needs-change\", \"change\", id, `The change \"${id}\" has no stage, no title, a stage with a space at an end or a sex that is not a sex of the table.`);\n else if (seen.has(`${change.sex} ${stage}`)) add(\"needs-change\", \"change\", id, `The change \"${id}\" has the stage ${stage} of a ${change.sex}, and a different change has it too.`);\n seen.add(`${String(change.sex)} ${stage}`);\n if (!goodNeed(change.change, false)) add(\"needs-change\", \"change\", id, `The change \"${id}\" has a value that is not a finite number in kcal/d.`);\n else if (smallest(change.sex) + valueIn(change.change, \"kcal/d\") <= 0) add(\"needs-change\", \"change\", id, `The change \"${id}\" makes the smallest need of a ${change.sex} 0 or less.`);\n });\n return findings;\n}\n\n/** This function tells if a list of findings has an error. */\nexport function hasNeedsError(findings: readonly NeedsFinding[]): boolean {\n return findings.some((finding) => finding.level === \"error\");\n}\n","import type { Finding } from \"@mark1russell7/guidebook\";\nimport type { SupplyCatalog } from \"@mark1russell7/market/supplies\";\nimport { valueIn } from \"@mark1russell7/quantity\";\n\n// The uses and the supply parts of the needs, and the gate of their joins with the reference lists.\n// An add-on does not import a different add-on. Thus the reference lists are parameters, and a test joins the real lists.\n\n/** The code of the need of the food draw: food energy, in `kcal` for each day. */\nexport const FOOD_NEED = \"food.energy\";\n\n/** The code of the need of drinking water, in `L` for each day. */\nexport const WATER_NEED = \"hydration.drink\";\n\n/** The resource of the food to eat with no water and no fuel, in `kcal`. It has a direct use for the food draw. */\nexport const NO_COOK = \"food.no-cook\";\n\n/** The resource of the stored drinking water, in `L`. It has a direct use for the water need. */\nexport const STORED_WATER = \"water.stored\";\n\n/** The direct use of a resource for a need: 1 unit of the resource gives `amount` of the need. */\nexport interface FragmentDirectUse {\n readonly resource: string;\n readonly need: string;\n readonly amount: number;\n}\n\n/**\n * The default reference part that supplies each need when no case stops it, by the code of the need.\n * The parts are `id` values of `SUPPLY_PARTS` of `@mark1russell7/stack-hazards`. A household with a well gives a different part.\n * The type has the exact keys. The annotation replaces `as const`, because the package has isolated declarations.\n */\nexport const NEED_SUPPLIES: { readonly \"hydration.drink\": \"water.main\"; readonly \"food.energy\": \"food.retail\" } = {\n \"hydration.drink\": \"water.main\",\n \"food.energy\": \"food.retail\",\n};\n\n/**\n * The direct uses of the resources of the buy list. Each use gives 1 unit of its need for each unit of its resource.\n *\n * - 1 L of stored drinking water gives 1 L of drink. This is a definition, not a read.\n * - 1 kcal of food to eat with no water and no fuel gives 1 kcal of food energy.\n *\n * These records have the form of `DirectUse` of `@mark1russell7/stack-endurance`.\n */\nexport const DIRECT_USES: readonly FragmentDirectUse[] = [\n { resource: STORED_WATER, need: WATER_NEED, amount: 1 },\n { resource: NO_COOK, need: FOOD_NEED, amount: 1 },\n];\n\n/**\n * These are the codes of the join gate. Each code is an error.\n *\n * - `join-use-resource`: a direct use names a resource that is not in the catalog.\n * - `join-use-need`: a direct use names a need that is not in the reference needs.\n * - `join-use-unit`: the unit of the resource of a direct use does not convert to the unit of its need.\n * - `join-use-amount`: the amount of a direct use is not the factor from the unit of its resource to the unit of its need.\n * - `join-supply-need`: a supply names a need that is not in the reference needs.\n * - `join-supply-part`: a supply names a part that is not in the reference parts.\n */\nexport const JOIN_CODES: readonly [\"join-use-resource\", \"join-use-need\", \"join-use-unit\", \"join-use-amount\", \"join-supply-need\", \"join-supply-part\"] = [\n \"join-use-resource\",\n \"join-use-need\",\n \"join-use-unit\",\n \"join-use-amount\",\n \"join-supply-need\",\n \"join-supply-part\",\n];\n\n/** A code of the join gate. */\nexport type JoinCode = (typeof JOIN_CODES)[number];\n\n/**\n * A finding of the join gate, in the form of a finding of `@mark1russell7/guidebook`. Each finding of the gate is an error.\n * The record is `use` for a direct use, with the resource of the use as its `id`. It is `supply` for a supply, with the need as its `id`.\n */\nexport type JoinFinding = Finding<JoinCode, \"use\" | \"supply\">;\n\n/** This function gives the factor from a unit to a different unit, or `undefined` when the units do not convert. */\nfunction factorOf(from: string, to: string): number | undefined {\n try {\n const factor = valueIn({ value: 1, unit: from }, to);\n return Number.isFinite(factor) ? factor : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** A reference need: its code and its unit. Each record of `NEEDS` of `@mark1russell7/alerts` has this form. */\nexport interface ReferenceNeed {\n readonly code: string;\n readonly unit: string;\n}\n\n/** A reference part: its `id`. Each record of `SUPPLY_PARTS` of `@mark1russell7/stack-hazards` has this form. */\nexport interface ReferencePart {\n readonly id: string;\n}\n\n/** The reference lists of the join gate. */\nexport interface JoinReferences {\n /** The reference needs, for example `NEEDS` of `@mark1russell7/alerts`. */\n readonly needs: readonly ReferenceNeed[];\n /** The reference parts, for example `SUPPLY_PARTS` of `@mark1russell7/stack-hazards`. */\n readonly parts: readonly ReferencePart[];\n}\n\n/**\n * This function examines the joins of a catalog, the direct uses and the supply parts with the reference lists.\n *\n * - The resource of each direct use is a resource of the catalog, and its need is a reference need.\n * - The unit of the resource of each direct use converts to the unit of its need.\n * - The amount of each direct use is the factor of that conversion. A direct use is a definition, so a different rate is a converter with a cited source.\n * - Each supply names a reference need and a reference part.\n *\n * The findings are in the order of the uses, then in the order of the supplies. The function is pure.\n *\n * @param catalog - The catalog of supplies of `@mark1russell7/market`\n * @param uses - The direct uses, for example `DIRECT_USES`\n * @param supplies - The part that supplies each need, by the code of the need, for example `NEED_SUPPLIES`\n * @param references - The reference needs and the reference parts\n * @returns The findings of the joins. An empty list is a pass.\n */\nexport function checkJoins(\n catalog: SupplyCatalog,\n uses: readonly FragmentDirectUse[],\n supplies: Readonly<Record<string, string>>,\n references: JoinReferences,\n): JoinFinding[] {\n const findings: JoinFinding[] = [];\n const add = (code: JoinCode, record: \"use\" | \"supply\", id: string, message: string): void => {\n findings.push({ level: \"error\", code, record, id, message });\n };\n const units = new Map(catalog.resources.map((resource) => [resource.code, resource.unit] as const));\n const needs = new Map(references.needs.map((need) => [need.code, need.unit] as const));\n for (const use of uses) {\n const unit = units.get(use.resource);\n const needUnit = needs.get(use.need);\n if (unit === undefined) add(\"join-use-resource\", \"use\", use.resource, `The direct use of ${use.resource} names no resource of the catalog.`);\n if (needUnit === undefined) add(\"join-use-need\", \"use\", use.resource, `The direct use of ${use.resource} names the need ${use.need}, which is not a reference need.`);\n if (unit === undefined || needUnit === undefined) continue;\n const factor = factorOf(unit, needUnit);\n if (factor === undefined) {\n add(\"join-use-unit\", \"use\", use.resource, `The direct use of ${use.resource} for ${use.need} takes ${unit}, which does not convert to ${needUnit}.`);\n } else if (use.amount !== factor) {\n add(\n \"join-use-amount\",\n \"use\",\n use.resource,\n `The direct use of ${use.resource} for ${use.need} gives ${String(use.amount)} ${needUnit} for each ${unit}, not ${String(factor)}. A direct use is a definition: a different rate is a converter with a cited source.`,\n );\n }\n }\n const parts = new Set(references.parts.map((part) => part.id));\n for (const [need, part] of Object.entries(supplies)) {\n if (!needs.has(need)) add(\"join-supply-need\", \"supply\", need, `The supply of ${need} names no reference need.`);\n if (!parts.has(part)) add(\"join-supply-part\", \"supply\", need, `The supply of ${need} names the part ${part}, which is not a reference part.`);\n }\n return findings;\n}\n","import { buyListEnergy, giftsOf, type BuyListEnergy, type SupplyCatalog } from \"@mark1russell7/market/supplies\";\nimport { calorieNeed, type ActivityLevel, type CalorieNeedTotal, type CalorieTable, type Person } from \"./calorie.ts\";\nimport { DGA_CALORIES } from \"./data.ts\";\nimport { DIRECT_USES, FOOD_NEED, NEED_SUPPLIES, type FragmentDirectUse } from \"./uses.ts\";\n\n// The join of a household and a buy list into a fragment of an endurance layer: one draw of food energy and the stores of the list.\n// The records have the form of the records of `@mark1russell7/stack-endurance`. An add-on does not import a different add-on, so the form is a copy.\n// A test assigns the layer to `EnduranceLayer` of stack-endurance. That test is the type gate of the copy.\n// The fragment has no converter. No cited source gives the water and the fuel to cook 1 kg of dry food, and a number with no source is not data.\n\n/** A resource of a store, with its unit. */\nexport interface FragmentResource {\n readonly code: string;\n readonly unit: string;\n}\n\n/** A store of the buy list: an amount of one resource, in its unit. */\nexport interface FragmentStore {\n readonly id: string;\n readonly resource: string;\n readonly amount: number;\n}\n\n/** The food draw: the food energy of the persons of the draw for each day. */\nexport interface FragmentDraw {\n readonly need: string;\n readonly level: string;\n /** The food energy of the persons of the draw for each day, in `kcal`. It is above 0. */\n readonly perDay: number;\n /** The count of the persons of the draw. */\n readonly users: number;\n readonly supply: string;\n}\n\n/** A fragment of an endurance layer, with the form of `EnduranceLayer` of `@mark1russell7/stack-endurance`. It has no converter. */\nexport interface HouseholdFragment {\n /** The format of an endurance layer, `endurance/1`. */\n readonly schema: \"endurance/1\";\n readonly levels: readonly string[];\n readonly resources: readonly FragmentResource[];\n readonly stores: readonly FragmentStore[];\n readonly draws: readonly FragmentDraw[];\n readonly direct: readonly FragmentDirectUse[];\n}\n\n/** The action for the persons with no row in the table. The only action is `leave-out`. */\nexport type NoRowAction = \"leave-out\";\n\n/** The inputs of the household fragment. */\nexport interface HouseholdFragmentInput {\n /** The person records of the household. */\n readonly persons: readonly Person[];\n /** The activity level of each person record with no level of its own. It has no default. */\n readonly activity: ActivityLevel;\n /** The catalog of supplies of `@mark1russell7/market`. */\n readonly catalog: SupplyCatalog;\n /** The count of units of each product of the buy list, by the `id` of the product. */\n readonly units: Readonly<Record<string, number>>;\n /** The `id` of the part of the stack that supplies the food when no case stops it. The default is `NEED_SUPPLIES[\"food.energy\"]`, `food.retail`. */\n readonly supply?: string | undefined;\n /** The direct uses. The fragment takes each use for the need `food.energy`. The default is `DIRECT_USES`. */\n readonly uses?: readonly FragmentDirectUse[] | undefined;\n /** The level of the food draw. It is one of the levels of the joined layer. */\n readonly level: string;\n /** The levels of the fragment. The default is no levels: a different fragment of the stack gives them. */\n readonly levels?: readonly string[] | undefined;\n /** The table of calorie needs. The default is `DGA_CALORIES`. */\n readonly table?: CalorieTable | undefined;\n /** The start of the `id` of each store. The default is `buy`. */\n readonly prefix?: string | undefined;\n /**\n * The action for the persons with no row in the table. Without it, a person with no row gives no layer.\n * With `leave-out`, the draw has no need of those persons, and the result lists them.\n */\n readonly noRow?: NoRowAction | undefined;\n}\n\n/** A gift of the buy list with no read. The fragment has no store for it. A no read is not 0. */\nexport interface GiftNoRead {\n readonly product: string;\n readonly resource: string;\n readonly why: string;\n}\n\n/** The parts of the result that do not change with the draw. */\nexport interface HouseholdStoresResult {\n /** The food energy of each product of the buy list. A caller gets the energy of the dry food for its converters from it. */\n readonly energy: BuyListEnergy;\n /** The gifts of the buy list with no read. */\n readonly noReads: readonly GiftNoRead[];\n /** True when each gift of the buy list has a read. When it is false, the stores are a lower limit. */\n readonly storesRead: boolean;\n}\n\n/** The household fragment with its draw. The draw is exact for its users. */\nexport interface HouseholdFragmentRead extends HouseholdStoresResult {\n readonly layer: HouseholdFragment;\n /**\n * The food energy of the household for one day, with a line for each person record. Its `read` covers the whole\n * household. It is false when a person is left out, or when a record with count 0 has no row. The flag of the draw\n * is `needRead`.\n */\n readonly need: CalorieNeedTotal;\n /** This field is true: the draw has a read for each of its users. */\n readonly needRead: true;\n /** The persons with no row that the option `leave-out` left out of the draw. With no option, the list is empty. */\n readonly leftOut: readonly Person[];\n}\n\n/** No household fragment: the draw has no read. A low rate gives too many days, so the function gives no layer. */\nexport interface HouseholdFragmentNoRead extends HouseholdStoresResult {\n readonly layer: undefined;\n /** The food energy of the household for one day. It is `undefined` when the household has no person. */\n readonly need: CalorieNeedTotal | undefined;\n readonly needRead: false;\n /** The persons with no row in the table. */\n readonly noRow: readonly Person[];\n /** The reason for no layer. */\n readonly why: string;\n}\n\n/** The household fragment, or a no read of the draw. Both have the reads of the buy list. */\nexport type HouseholdFragmentResult = HouseholdFragmentRead | HouseholdFragmentNoRead;\n\n/** This function gives the stores of the buy list, its resources and its gifts with no read. */\nfunction buyListStores(\n input: HouseholdFragmentInput,\n foodUses: readonly FragmentDirectUse[],\n): { stores: FragmentStore[]; resources: FragmentResource[]; parts: HouseholdStoresResult } {\n const { catalog, units } = input;\n const energy = buyListEnergy(catalog, units);\n const unitOf = new Map(catalog.resources.map((resource) => [resource.code, resource.unit]));\n for (const use of foodUses) {\n if (unitOf.get(use.resource) !== \"kcal\") throw new RangeError(`The catalog has no resource \"${use.resource}\" in kcal for the food use.`);\n }\n const prefix = input.prefix ?? \"buy\";\n const stores: FragmentStore[] = [];\n const noReads: GiftNoRead[] = [];\n for (const [product, count] of Object.entries(units)) {\n for (const gift of giftsOf(catalog, product, count)) {\n if (!gift.read) noReads.push({ product, resource: gift.resource, why: gift.why });\n else if (gift.amount > 0) stores.push({ id: `${prefix}:${product}:${gift.resource}`, resource: gift.resource, amount: gift.amount });\n }\n }\n const codes = [...new Set([...stores.map((store) => store.resource), ...foodUses.map((use) => use.resource)])];\n const resources = codes.map((code) => ({ code, unit: unitOf.get(code) ?? \"\" }));\n return { stores, resources, parts: { energy, noReads, storesRead: noReads.length === 0 } };\n}\n\n/**\n * This function joins a household and a buy list into a fragment of an endurance layer.\n *\n * - The fragment has one draw of food energy. Its rate is the need of the persons for one day, and its users are the persons.\n * - Each gift of the buy list with a read is one store, with the `id` `<prefix>:<product>:<resource>`. A gift with no read has no store.\n * - The direct uses are the food uses: each use of `uses` for the need `food.energy`. The default `DIRECT_USES` gives `food.no-cook`, 1 kcal for each kcal.\n * - The resources are the resources of the stores and of the food uses, with the units of the catalog.\n * - The supply part of the draw is `supply`. Its default is the part of `NEED_SUPPLIES` for `food.energy`.\n * - The fragment has no converter. A caller adds converters for the dry food, with the water and the fuel of each run.\n *\n * A person with no row in the table gives no layer, because a low rate gives too many days.\n * The option `noRow: \"leave-out\"` leaves those persons out of the draw. A draw of 0 kcal gives no layer.\n * The function is pure.\n *\n * @param input - The persons, the activity level, the catalog and the buy list, the supply part and the level of the draw\n * @returns The fragment or a no read of the draw, with the energy of the list and the gifts with no read\n * @throws RangeError for the errors of `calorieNeed`, `giftsOf` and `buyListEnergy`, except a household with no person\n * @throws RangeError when the catalog has no resource in `kcal` for a food use\n */\nexport function householdFragment(input: HouseholdFragmentInput): HouseholdFragmentResult {\n const foodUses = (input.uses ?? DIRECT_USES).filter((use) => use.need === FOOD_NEED);\n const { stores, resources, parts } = buyListStores(input, foodUses);\n if (input.persons.every((person) => person.count === 0)) {\n return { ...parts, layer: undefined, need: undefined, needRead: false, noRow: [], why: \"The household has no person, so the draw is 0 kcal.\" };\n }\n const need = calorieNeed(input.table ?? DGA_CALORIES, input.persons, input.activity, 1);\n const noRow: Person[] = [];\n let users = 0;\n for (const line of need.lines) {\n if (line.read) users += line.person.count;\n else if (line.person.count > 0) noRow.push(line.person);\n }\n if (noRow.length > 0 && input.noRow !== \"leave-out\") {\n return { ...parts, layer: undefined, need, needRead: false, noRow, why: `The table has no row for ${String(noRow.length)} person records. The option noRow: \"leave-out\" leaves them out of the draw.` };\n }\n if (users === 0 || need.need.value <= 0) {\n return { ...parts, layer: undefined, need, needRead: false, noRow, why: \"No person of the draw has a row in the table, so the draw is 0 kcal.\" };\n }\n const draw: FragmentDraw = { need: FOOD_NEED, level: input.level, perDay: need.need.value, users, supply: input.supply ?? NEED_SUPPLIES[FOOD_NEED] };\n return {\n ...parts,\n layer: {\n schema: \"endurance/1\",\n levels: [...(input.levels ?? [])],\n resources,\n stores,\n draws: [draw],\n direct: foodUses.map((use) => ({ ...use })),\n },\n need,\n needR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AS,KAAK,MAAM,UAAU,aACtC,OAAO;EAAE,GAAG;EAAO,OAAO,KAAA;EAAW;EAAM,UAAU;EAAO;EAAO,KAAK,4BAA4B,OAAO,MAAM,MAAM,EAAE;CAA6E;CAExM,IAAI,UAAU,KAAK,KAAK,KAAK,SAAS,GACpC,OAAO;EAAE,GAAG;EAAO,OAAO,KAAA;EAAW;EAAM,UAAU;EAAO;EAAO,KAAK;CAAuE;CAEjJ,MAAM,OAAqB;EAAE,MAAM;EAAW,OAAO,MAAM;EAAO,QAAQ,KAAK,KAAK;EAAO;EAAO,QAAQ,MAAM,UAAU,cAAA;CAAyB;CACnJ,OAAO;EACL,GAAG;EACH,OAAO;GACL,QAAQ;GACR,QAAQ,CAAC,GAAI,MAAM,UAAU,CAAC,CAAE;GAChC;GACA;GACA,OAAO,CAAC,IAAI;GACZ,QAAQ,SAAS,KAAK,SAAS,EAAE,GAAG,IAAI,EAAE;EAC5C;EACA;EACA,UAAU;EACV,SAAS;CACX;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/stack-needs",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "The need rates of draws as reference data: the daily food energy of each person by age, sex and activity, from the Dietary Guidelines for Americans, with its source. An add-on of system-stack.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@mark1russell7/guidebook": "^0.
|
|
41
|
+
"@mark1russell7/guidebook": "^0.3.0",
|
|
42
42
|
"@mark1russell7/market": "^0.3.1",
|
|
43
43
|
"@mark1russell7/quantity": "^0.4.4"
|
|
44
44
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@mark1russell7/alerts": "^0.1.5",
|
|
47
47
|
"@mark1russell7/cue": "^2.0.0",
|
|
48
48
|
"@mark1russell7/stack-endurance": "0.6.3",
|
|
49
|
-
"@mark1russell7/stack-hazards": "0.
|
|
49
|
+
"@mark1russell7/stack-hazards": "0.3.0",
|
|
50
50
|
"@types/node": "^26.6.5",
|
|
51
51
|
"@vitest/coverage-v8": "^5.0.3",
|
|
52
52
|
"fast-check": "^4.10.2",
|