@mark1russell7/guidebook-preparedness 0.7.23 → 0.7.24
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/build/index.d.ts.map +1 -1
- package/build/index.js +24 -4
- package/build/index.js.map +1 -1
- package/package.json +7 -5
- package/src/data/steps.ts +25 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/guidebook-preparedness",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.24",
|
|
5
5
|
"description": "The preparedness content of the guidebook: cited sources, the steps and marked gaps of 12 cases and 6 cuts, 40 topics in 12 areas, and the catalog of offline bundles.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"guidebook",
|
|
@@ -47,18 +47,20 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@mark1russell7/cue": "^2.0.0",
|
|
50
|
+
"@mark1russell7/ste-lint": "^0.4.0",
|
|
51
|
+
"@mark1russell7/vex-domains": "^0.20.2",
|
|
50
52
|
"@types/node": "^26.6.5",
|
|
51
53
|
"@vitest/coverage-v8": "^5.0.3",
|
|
52
|
-
"typescript": "^7.0.2",
|
|
53
|
-
"vitest": "^5.0.3",
|
|
54
54
|
"tsdown": "^0.23.7",
|
|
55
|
-
"
|
|
55
|
+
"typescript": "^7.0.2",
|
|
56
|
+
"vitest": "^5.0.3"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
59
|
"@mark1russell7/guidebook": "0.2.0",
|
|
59
60
|
"@mark1russell7/guidebook-library": "0.2.1",
|
|
60
61
|
"@mark1russell7/guidebook-plans": "0.3.1",
|
|
61
|
-
"@mark1russell7/guidebook-topics": "0.1.2"
|
|
62
|
+
"@mark1russell7/guidebook-topics": "0.1.2",
|
|
63
|
+
"@mark1russell7/vex": "^0.20.2"
|
|
62
64
|
},
|
|
63
65
|
"scripts": {
|
|
64
66
|
"build": "tsdown",
|
package/src/data/steps.ts
CHANGED
|
@@ -2,23 +2,42 @@
|
|
|
2
2
|
// The steps are full from `ready` to `P3`. `P4` and `P5` are an outline. Each cell with no step has a marked gap in `gaps.ts`.
|
|
3
3
|
|
|
4
4
|
import type { Phase, Society, Step } from "@mark1russell7/guidebook-plans";
|
|
5
|
+
import { app, key, lit, ref, serialize } from "@mark1russell7/vex";
|
|
6
|
+
import type { Expr } from "@mark1russell7/vex";
|
|
5
7
|
|
|
6
8
|
/** One row of a key: the phase, a short name, the action, the sources and the needs that the step protects. */
|
|
7
|
-
/** The more fields of a row: the needs that the step protects, its reasoning,
|
|
8
|
-
type More = { readonly needs?: readonly string[]; readonly reasoning?: string; readonly society?: readonly Society[] };
|
|
9
|
+
/** The more fields of a row: the needs that the step protects, its reasoning, the states of society that it is for, and its condition. */
|
|
10
|
+
type More = { readonly needs?: readonly string[]; readonly reasoning?: string; readonly society?: readonly Society[]; readonly when?: string };
|
|
9
11
|
type Row = readonly [phase: Phase, name: string, action: string, sources: readonly string[], more?: readonly string[] | More];
|
|
10
12
|
|
|
11
13
|
/** This function makes the steps of a key from its rows. The order of a step is its position among the rows of its phase. */
|
|
12
14
|
function stepsOf(on: string, rows: readonly Row[]): Step[] {
|
|
13
15
|
const count = new Map<Phase, number>();
|
|
14
16
|
return rows.map(([phase, name, action, sources, more = []]) => {
|
|
15
|
-
const { needs = [], reasoning, society } = Array.isArray(more) ? { needs: more as readonly string[] } : (more as More);
|
|
17
|
+
const { needs = [], reasoning, society, when } = Array.isArray(more) ? { needs: more as readonly string[] } : (more as More);
|
|
16
18
|
const order = (count.get(phase) ?? 0) + 1;
|
|
17
19
|
count.set(phase, order);
|
|
18
|
-
return { id: `${on}.${phase}.${name}`, on, phase, needs, do: action, order, sources, ...(reasoning === undefined ? {} : { reasoning }), ...(society === undefined ? {} : { society }) };
|
|
20
|
+
return { id: `${on}.${phase}.${name}`, on, phase, needs, do: action, order, sources, ...(reasoning === undefined ? {} : { reasoning }), ...(society === undefined ? {} : { society }), ...(when === undefined ? {} : { when }) };
|
|
19
21
|
});
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
/**
|
|
25
|
+
* This function gives the JSON form of a condition `when`: a Vex program over the live keys.
|
|
26
|
+
* Each live key has the field `stopped`, and a stopped key with a known start has the field `hours`.
|
|
27
|
+
* A step gets a `when` only if the live keys decide its condition. A condition that a person sees (a smell, the weather) gets no `when`.
|
|
28
|
+
*/
|
|
29
|
+
function condition(expr: Expr): string {
|
|
30
|
+
const text = serialize(expr);
|
|
31
|
+
if (!text.ok) throw new Error("the condition does not serialize");
|
|
32
|
+
return text.value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The expression that is true when the live key `part` is stopped. */
|
|
36
|
+
const stopped = (part: string): Expr => ref(["stopped"], [key(part)]);
|
|
37
|
+
|
|
38
|
+
/** The expression that is true when the live key `part` is stopped for more than `hours` hours. */
|
|
39
|
+
const stoppedOver = (part: string, hours: number): Expr => app("and", stopped(part), app("gt", ref(["hours"], [key(part)]), lit(hours)));
|
|
40
|
+
|
|
22
41
|
const DRINK = "hydration.drink";
|
|
23
42
|
const FOOD = "food.energy";
|
|
24
43
|
const MEDICINE = "health.medicine";
|
|
@@ -311,7 +330,7 @@ export const CASE_STEPS: readonly Step[] = [
|
|
|
311
330
|
["P0", "friend-account", "If a message from the account of a friend seems strange, ask the friend in a different way.", ["fi-72h-cyber"]],
|
|
312
331
|
["P0", "no-send", "Do not send money, gift cards or cryptocurrency to a person that you know only online or by phone.", ["ic3-genai"]],
|
|
313
332
|
["P1", "sources", "Get news from more than one source: the phone alerts, the radio, the television and the persons near you.", ["ready-alerts"], { reasoning: "Each source can stop or be wrong. A fact that two sources agree on is more certain." }],
|
|
314
|
-
["P1", "radio-info", "If the phone and data networks stop, get the news from the public radio on batteries.", ["fi-72h-info"]],
|
|
333
|
+
["P1", "radio-info", "If the phone and data networks stop, get the news from the public radio on batteries.", ["fi-72h-info"], { when: condition(app("and", stopped("phone.network"), stopped("network.access"))) }],
|
|
315
334
|
["P1", "phone-lines", "Use the phone only when necessary, so that the lines stay open.", ["fi-72h-shelter"]],
|
|
316
335
|
["P1", "who-says", "Before you believe a report, find who wrote it, and find a second source that agrees.", ["fi-72h-info"]],
|
|
317
336
|
["P1", "no-rumours", "Do not pass on a report that does not seem true.", ["fi-72h-info"]],
|
|
@@ -627,7 +646,7 @@ export const CUT_STEPS: readonly Step[] = [
|
|
|
627
646
|
["P2", "food-40", "Discard food that is at 40 °F or higher for two hours or more.", ["ready-power"], [FOOD]],
|
|
628
647
|
["P2", "extreme", "If the heat or the cold is extreme, go to a community place that has power.", ["ready-power"]],
|
|
629
648
|
["P2", "refuel", "Let a generator cool before you add fuel.", ["ready-power"]],
|
|
630
|
-
["P2", "medicine", "After more than one day with no power, discard refrigerated medicine, unless its label tells otherwise.", ["ready-power"], [MEDICINE]],
|
|
649
|
+
["P2", "medicine", "After more than one day with no power, discard refrigerated medicine, unless its label tells otherwise.", ["ready-power"], { needs: [MEDICINE], when: condition(stoppedOver("power.grid", 24)) }],
|
|
631
650
|
["P3", "doubt", "Discard food with an unusual odor, color or texture. When in doubt, throw it out.", ["ready-power"], [FOOD]],
|
|
632
651
|
["P3", "lifesaving", "If a refrigerated medicine keeps you alive and you have no replacement, use it until you get a new supply.", ["fda-drugs"], [MEDICINE]],
|
|
633
652
|
["P3", "few-loads", "Use the stored power only for light, the radio, the phones and medical devices.", [], { needs: [POWER], reasoning: "Heat and cooking empty stored power fast. Small loads make it last for weeks.", society: NONE }],
|