@mark1russell7/guidebook-preparedness 0.4.0 → 0.5.1

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/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.4.0",
4
+ "version": "0.5.1",
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",
@@ -57,7 +57,7 @@
57
57
  "dependencies": {
58
58
  "@mark1russell7/guidebook": "0.1.1",
59
59
  "@mark1russell7/guidebook-library": "0.1.1",
60
- "@mark1russell7/guidebook-plans": "0.1.4",
60
+ "@mark1russell7/guidebook-plans": "0.1.6",
61
61
  "@mark1russell7/guidebook-topics": "0.1.1"
62
62
  },
63
63
  "scripts": {
package/src/data/chart.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  // The master chart: one chart for any disaster. A reader starts at a signal, answers at most 2 questions and goes to a tab.
2
+ // A goto with a card also sends the reader to the card of the event in the hazard catalog.
2
3
  // The chart asks for needs, not for kinds of event, so an event that nobody foresaw still has a route.
3
4
  // A broadcast is one source of information. No answer of the chart waits for officials.
4
5
 
@@ -24,7 +25,7 @@ export function tabsOf(cases: readonly string[], cuts: readonly string[]): reado
24
25
  { id: "security", title: "The safety of the people", keys: ["security.civil-unrest", "security.armed-conflict"], phases: ALL, pages: 6 },
25
26
  { id: "group", title: "Contact, the group and trade", keys: ["phone.network", "network.access", "cash.retail", "society.services"], phases: ALL, pages: 6 },
26
27
  { id: "long-term", title: "The long term: 5 weeks to 5 years", keys: cuts, phases: ["P3", "P4", "P5"], pages: 10 },
27
- { id: "hazards", title: "The hazards, case by case", keys: cases, phases: ALL, pages: 24 },
28
+ { id: "catalog", title: "The hazard catalog", keys: cases, phases: ALL, pages: 8 },
28
29
  { id: "appendices", title: "The appendices", keys: [], phases: [], pages: 40 },
29
30
  ];
30
31
  }
@@ -32,13 +33,16 @@ export function tabsOf(cases: readonly string[], cuts: readonly string[]): reado
32
33
  /** The tab of the chart itself. It is the entry of the binder, so no path of the chart goes to it. */
33
34
  export const START_TAB = "start";
34
35
 
36
+ /** The tab of the hazard catalog. An end with a card sends the reader to the card of the event in it. */
37
+ export const CATALOG_TAB = "catalog";
38
+
35
39
  const NEEDS_FIRST = "Do the needs by their danger. Safety comes in minutes, heat and water in hours and days, food in weeks.";
36
40
 
37
- /** The nodes of the master chart: 3 signals, 5 questions and 12 ends. */
41
+ /** The nodes of the master chart: 3 signals, 4 questions and 11 ends. */
38
42
  export const MASTER: readonly ChartNode[] = [
39
43
  // The signals: what a reader sees, hears, smells, feels or learns.
40
44
  { id: "sense", kind: "signal", text: "You see, hear, smell or feel a danger: fire, smoke, gas, shaking, a flash, rising water, a siren or shots.", next: "life" },
41
- { id: "threat", kind: "signal", text: "You learn of a threat that comes: a storm, a flood, a fire, a disease, unrest, an attack or a war.", next: "known" },
45
+ { id: "threat", kind: "signal", text: "You learn of a threat that comes: a storm, a flood, a fire, a disease, unrest, an attack or a war.", next: "place" },
42
46
  { id: "supply", kind: "signal", text: "A supply stops, or help does not come: power, water, sewer, gas, phone, internet, fuel, food, cash, care or the law.", next: "society" },
43
47
 
44
48
  // The questions. Each one has an answer that a reader can see without help.
@@ -47,11 +51,6 @@ export const MASTER: readonly ChartNode[] = [
47
51
  reasoning: "A danger of minutes leaves no time to read. Do the reflex first, then come back to the chart.",
48
52
  answers: [{ label: "Yes", next: "to-72h" }, { label: "No", next: "place" }],
49
53
  },
50
- {
51
- id: "known", kind: "question", text: "Does the hazards tab have a page for this event?", sources: [],
52
- reasoning: "A page for the event gives its special risks. An event with no page still breaks down into needs, so the chart continues.",
53
- answers: [{ label: "Yes", next: "to-hazards" }, { label: "No", next: "place" }],
54
- },
55
54
  {
56
55
  id: "place", kind: "question", text: "Is your place safe to stay in: no fire, gas, flood water, damage, bad air, violence or an illness that spreads?", sources: [],
57
56
  reasoning: "Your place holds your supplies, so stay when it is safe. Go when the place itself is the danger.",
@@ -81,10 +80,9 @@ export const MASTER: readonly ChartNode[] = [
81
80
  },
82
81
 
83
82
  // The ends: each one goes to a tab of the binder.
84
- { id: "to-72h", kind: "goto", text: "Go to the tab: the first 72 hours.", tab: "first-72h" },
85
- { id: "to-hazards", kind: "goto", text: "Go to the page of the event in the hazards tab.", tab: "hazards" },
86
- { id: "to-stay", kind: "goto", text: "Go to the tab: stay.", tab: "stay" },
87
- { id: "to-go", kind: "goto", text: "Go to the tab: go.", tab: "go" },
83
+ { id: "to-72h", kind: "goto", text: "Go to the tab: the first 72 hours. Read the card of the event too.", tab: "first-72h", card: true },
84
+ { id: "to-stay", kind: "goto", text: "Go to the tab: stay. Read the card of the event too.", tab: "stay", card: true },
85
+ { id: "to-go", kind: "goto", text: "Go to the tab: go. Read the card of the event too.", tab: "go", card: true },
88
86
  { id: "to-long", kind: "goto", text: "Go to the tab: the long term.", tab: "long-term" },
89
87
  { id: "to-security", kind: "goto", text: "Go to the tab: the safety of the people.", tab: "security" },
90
88
  { id: "to-heat", kind: "goto", text: "Go to the tab: heat, shelter and power.", tab: "heat" },
@@ -0,0 +1,57 @@
1
+ // The hazard catalog: one row for each case. A row is an index into the master graph, not a plan.
2
+ // It names the signals that the hazard gives, the node where the reader joins the graph, and the card of the facts unique to it.
3
+
4
+ import type { HazardRow, Phase, Step } from "@mark1russell7/guidebook-plans";
5
+
6
+ /** The node where each signal joins the graph. */
7
+ const ENTRY: Readonly<Record<string, string>> = { sense: "life", threat: "place", supply: "society" };
8
+
9
+ /** Each case: its title and its signals. The first signal gives the entry. */
10
+ const TABLE: readonly (readonly [key: string, title: string, signals: readonly string[]])[] = [
11
+ ["met.winter.storm", "Winter storm", ["threat", "supply"]],
12
+ ["met.tropical.hurricane", "Hurricane", ["threat", "sense"]],
13
+ ["met.flood", "Flood", ["sense", "threat"]],
14
+ ["met.heat.extreme", "Extreme heat", ["threat", "supply"]],
15
+ ["met.tornado", "Tornado", ["sense", "threat"]],
16
+ ["geo.earthquake", "Earthquake", ["sense"]],
17
+ ["fire.wildfire", "Wildfire", ["sense", "threat"]],
18
+ ["fire.structure", "Fire in a building", ["sense"]],
19
+ ["infra.power.outage", "Power outage", ["supply"]],
20
+ ["infra.water.outage", "Water outage", ["supply"]],
21
+ ["health.outbreak", "Outbreak of a disease", ["threat"]],
22
+ ["health.medical-emergency", "Medical emergency", ["sense"]],
23
+ ["cbrne.hazardous-materials", "Release of hazardous materials", ["sense", "threat"]],
24
+ ["cbrne.radiological", "Release of radioactive material", ["sense", "threat"]],
25
+ ["civic.ai-collapse", "Collapse driven by AI", ["supply", "threat"]],
26
+ ["health.outbreak.pandemic", "Pandemic", ["threat", "supply"]],
27
+ ["infra.supply-chain.food", "Failure of the food supply", ["supply"]],
28
+ ["infra.power.grid-collapse", "Long collapse of the grid", ["supply"]],
29
+ ["cyber.infrastructure-attack", "Cyberattack on infrastructure", ["supply"]],
30
+ ["civic.economy.collapse", "Financial collapse", ["supply"]],
31
+ ["security.civil-unrest", "Civil unrest", ["sense", "threat"]],
32
+ ["cbrne.nuclear-detonation", "Nuclear detonation", ["sense"]],
33
+ ["security.nuclear-war", "Nuclear war", ["threat", "sense"]],
34
+ ["cbrne.emp", "Electromagnetic pulse", ["supply"]],
35
+ ["geo.space-weather.geomagnetic-storm", "Geomagnetic storm", ["threat", "supply"]],
36
+ ["security.armed-conflict", "Armed conflict", ["threat", "sense"]],
37
+ ];
38
+
39
+ /** The phases of the first actions of a card, in the sequence of their use. */
40
+ const FIRST: readonly Phase[] = ["P0", "P1", "P2"];
41
+
42
+ /**
43
+ * This function gives the rows of the hazard catalog.
44
+ * A card holds the steps of the case with a text that no other case has.
45
+ * These are the first actions, and the steps for a society with no service.
46
+ */
47
+ export function hazardsOf(steps: readonly Step[]): readonly HazardRow[] {
48
+ const cases = new Map<string, Set<string>>();
49
+ for (const step of steps) cases.set(step.do, (cases.get(step.do) ?? new Set()).add(step.on));
50
+ const unique = (step: Step): boolean => (cases.get(step.do)?.size ?? 0) === 1;
51
+ return TABLE.map(([key, title, signals]) => {
52
+ const own = steps.filter((step) => step.on === key && unique(step));
53
+ const first = FIRST.find((phase) => own.some((step) => step.phase === phase));
54
+ const card = own.filter((step) => step.phase === first || (step.society?.includes("none") === true && !step.society.includes("works")));
55
+ return { key, title, signals, entry: ENTRY[signals[0] ?? ""] ?? "", card: card.map((step) => step.id) };
56
+ });
57
+ }
package/src/index.ts CHANGED
@@ -1,14 +1,17 @@
1
1
  // The preparedness content of the guidebook: the sources, the steps and the marked gaps of 12 cases and 12 cuts,
2
2
  // the topics of 12 areas, and the catalog of offline bundles.
3
3
 
4
- import type { Tab } from "@mark1russell7/guidebook-plans";
5
- import { tabsOf } from "./data/chart.ts";
4
+ import { GRAPH_SCHEMA, SOCIETY_STATES } from "@mark1russell7/guidebook-plans";
5
+ import type { HazardRow, MasterGraph, Tab } from "@mark1russell7/guidebook-plans";
6
+ import { CATALOG_TAB, MASTER, START_TAB, tabsOf } from "./data/chart.ts";
7
+ import { hazardsOf } from "./data/hazards.ts";
8
+ import { CASE_STEPS } from "./data/steps.ts";
6
9
  export { CHECKED, SOURCES } from "./data/sources.ts";
7
10
  export { CASE_STEPS, CUT_STEPS, STEPS } from "./data/steps.ts";
8
11
  export { GAPS } from "./data/gaps.ts";
9
12
  export { OPEN_CELLS } from "./data/coverage.ts";
10
13
  export { RULES } from "./data/rules.ts";
11
- export { MASTER, START_TAB } from "./data/chart.ts";
14
+ export { CATALOG_TAB, MASTER, START_TAB } from "./data/chart.ts";
12
15
  export { AREAS, TOPICS } from "./data/topics.ts";
13
16
  export { BUNDLES, BUNDLES_CHECKED, BUNDLE_LEVELS } from "./data/bundles.ts";
14
17
  export { MEDIA_UNITS, MEDIUM_GAPS, MEDIUM_LOSSES } from "./data/media.ts";
@@ -49,3 +52,17 @@ export const NEEDS = ["hydration.drink", "food.energy", "health.medicine", "powe
49
52
  export const SOCIETY_KEY = "society.services";
50
53
 
51
54
  export const TABS: readonly Tab[] = tabsOf([...CASES, ...MORE_CASES], [...CUTS, SOCIETY_KEY]);
55
+
56
+ /** The rows of the hazard catalog: for each case, its signals, its entry node and its card. */
57
+ export const HAZARDS: readonly HazardRow[] = hazardsOf(CASE_STEPS);
58
+
59
+ /** The master graph: the one value that the printed binder and the app read. */
60
+ export const GRAPH: MasterGraph = {
61
+ schema: GRAPH_SCHEMA,
62
+ start: START_TAB,
63
+ catalog: CATALOG_TAB,
64
+ societies: SOCIETY_STATES,
65
+ nodes: MASTER,
66
+ tabs: TABS,
67
+ hazards: HAZARDS,
68
+ };