@mark1russell7/market 0.1.6 → 0.1.7
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 +23 -0
- package/build/order-BAbk8QQA.d.ts +106 -0
- package/build/order-BAbk8QQA.d.ts.map +1 -0
- package/build/plan.d.ts +3 -104
- package/build/plan.d.ts.map +1 -1
- package/build/supplies-entry.d.ts +135 -0
- package/build/supplies-entry.d.ts.map +1 -0
- package/build/supplies-entry.js +348 -0
- package/build/supplies-entry.js.map +1 -0
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -136,6 +136,29 @@ order.units; // { JUG: 3, CAN: 3 }
|
|
|
136
136
|
order.stages.map((stage) => stage.spent); // [10, 5]
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
+
## A catalog of supplies
|
|
140
|
+
|
|
141
|
+
The entry `@mark1russell7/market/supplies` has the format and the gate of a catalog of supplies: the products that a household keeps for an emergency. It is an add-on: the core of the package names no supply.
|
|
142
|
+
|
|
143
|
+
- A product has a kind (`water`, `food`, `power`, `light`, `heat`, `first-aid` or `communication`), the resources that one unit gives, its shelf life and, as an option, a part for the offers.
|
|
144
|
+
- Each amount has a cited fact, the definition of the product, or a no read with its reason. A no read is not 0.
|
|
145
|
+
- The facts and their sources are the records of [`@mark1russell7/guidebook`](https://www.npmjs.com/package/@mark1russell7/guidebook). Its gate examines each license and each address.
|
|
146
|
+
- The shelf life of a food is the id of a product of the FoodKeeper data of USDA FSIS. The entry `/foodkeeper` of `@mark1russell7/stock` gives its due rule.
|
|
147
|
+
- The resource codes are the codes of a store of `@mark1russell7/stack-endurance`, for example `water.stored` in `L`.
|
|
148
|
+
- The gate does not examine the joins to other packages. It does not find a FoodKeeper id that is not in `@mark1russell7/stock`, or a resource code that a layer of stores does not have. The code that joins the catalog to stock or to a layer of stores gives those gates. market depends on neither package.
|
|
149
|
+
|
|
150
|
+
| Function | What it does |
|
|
151
|
+
| --- | --- |
|
|
152
|
+
| `checkSupplies(catalog, options)` | It gives the findings of the catalog: the errors of the gate, and a warning for each no read and for each fact or source that no product uses. |
|
|
153
|
+
| `supplyWants(catalog, max)` | It gives the wants of the products with a part, for `buyCandidates`. A product with no part has no offer, so it has no price. |
|
|
154
|
+
| `giftsOf(catalog, id, units)` | It gives the resources of a count of units, each in the unit of its resource. A unit converts exactly, so 1 gal gives 3.785411784 L. |
|
|
155
|
+
|
|
156
|
+
`SUPPLY_CATALOG` is the reference catalog. Its facts come from Ready.gov (FEMA, a US federal work) and from FoodData Central (USDA, CC0 1.0). It has gaps:
|
|
157
|
+
|
|
158
|
+
- The energy of the power bank is no read. The page of the maker gives 24,000 mAh and no Wh, and a charge does not convert to energy without its voltage.
|
|
159
|
+
- The kinds `light`, `heat`, `first-aid` and `communication` have no product yet.
|
|
160
|
+
- The shelf life of commercially bottled water is no read. The source gives no time, so the date on the label applies.
|
|
161
|
+
|
|
139
162
|
## Metered prices
|
|
140
163
|
|
|
141
164
|
A cloud resource has a metered price: a price for each unit of an amount that the provider meters. A metered amount is a `time` (the hours of a machine), a `data-time` (stored data in GiB-months), a `data` (a transfer) or a `count` (requests).
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { a as PartWant, p as Condition, r as Observation } from "./offers-CVUAcRHs.js";
|
|
2
|
+
import { Goal, GreedyStop, Selection } from "@mark1russell7/strategy-search";
|
|
3
|
+
/** One product that a buyer wants: its key, the part that the offers must match, and the largest count of its units. */
|
|
4
|
+
interface ProductWant {
|
|
5
|
+
readonly product: string;
|
|
6
|
+
readonly want: PartWant;
|
|
7
|
+
/** The largest count of units to buy. The default is 1. */
|
|
8
|
+
readonly max?: number | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** One candidate of a buy order: a product, the price of one unit, the largest count of units and the offer. */
|
|
11
|
+
interface BuyCandidate {
|
|
12
|
+
readonly product: string;
|
|
13
|
+
/** The cost of one unit with its shipping, in the currency of the order. */
|
|
14
|
+
readonly price: number;
|
|
15
|
+
readonly max: number;
|
|
16
|
+
/** The `id` of the offer of the price. */
|
|
17
|
+
readonly quote: string;
|
|
18
|
+
}
|
|
19
|
+
/** The candidates of a buy order, and the products that have no usable offer. */
|
|
20
|
+
interface BuyCandidates {
|
|
21
|
+
readonly currency: string;
|
|
22
|
+
readonly candidates: readonly BuyCandidate[];
|
|
23
|
+
readonly unpriced: readonly {
|
|
24
|
+
readonly product: string;
|
|
25
|
+
readonly why: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/** The options of the candidates: the currency and the conditions that the buyer accepts. */
|
|
29
|
+
interface CandidateOptions {
|
|
30
|
+
/** The currency of the prices, a unit of money of `@mark1russell7/quantity`, for example `USD`. */
|
|
31
|
+
readonly currency: string;
|
|
32
|
+
/** The conditions that the buyer accepts. The default is `new` only. */
|
|
33
|
+
readonly conditions?: readonly Condition[] | undefined;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* This function gives a candidate for each product with a usable offer. The price is the cost of one unit with its
|
|
37
|
+
* shipping, from the in-stock offer with the lowest cost, as in `planBuys`. Each unit is one order, so the price is an
|
|
38
|
+
* upper limit of the cost of more units.
|
|
39
|
+
*
|
|
40
|
+
* @param wants - The products, in the order of the result
|
|
41
|
+
* @param observations - The observations of the offers
|
|
42
|
+
* @param options - The currency and the conditions
|
|
43
|
+
* @throws RangeError when the currency is not a unit of money, or when a product is twice in `wants`
|
|
44
|
+
*/
|
|
45
|
+
declare function buyCandidates(wants: readonly ProductWant[], observations: readonly Observation[], options: CandidateOptions): BuyCandidates;
|
|
46
|
+
/** One stage of a buy order: its name and the value of a choice, the most important number first. */
|
|
47
|
+
interface OrderStage {
|
|
48
|
+
readonly name: string;
|
|
49
|
+
/** The value of the units of each product. It is a pure function. */
|
|
50
|
+
readonly value: (units: Selection) => readonly number[];
|
|
51
|
+
}
|
|
52
|
+
/** The options of a buy order. */
|
|
53
|
+
interface OrderOptions {
|
|
54
|
+
/** The money of the order, in the currency of the candidates. */
|
|
55
|
+
readonly budget: number;
|
|
56
|
+
/** The stages, in order. Each stage starts from the units of the stage before it, with the money that is left. */
|
|
57
|
+
readonly stages: readonly OrderStage[];
|
|
58
|
+
/** The goal of each number of a value. Use `min` for a shortfall. The default is `max`. */
|
|
59
|
+
readonly goal?: Goal | undefined;
|
|
60
|
+
/** The units that the buyer has before the order. Their cost is not in the budget. */
|
|
61
|
+
readonly start?: Selection | undefined;
|
|
62
|
+
/** With `false`, each step evaluates each product again. Use it when two products give more together than apart. */
|
|
63
|
+
readonly lazy?: boolean | undefined;
|
|
64
|
+
}
|
|
65
|
+
/** One purchase of a buy order: one unit of a product, its offer and its cost, and its gain in its stage. */
|
|
66
|
+
interface OrderBuy {
|
|
67
|
+
readonly stage: string;
|
|
68
|
+
readonly product: string;
|
|
69
|
+
readonly quote: string;
|
|
70
|
+
readonly cost: number;
|
|
71
|
+
readonly gain: readonly number[];
|
|
72
|
+
}
|
|
73
|
+
/** The result of one stage: the value before and after it, the money that it spends and the reason that it stops. */
|
|
74
|
+
interface OrderStageResult {
|
|
75
|
+
readonly name: string;
|
|
76
|
+
readonly method: "greedy" | "single";
|
|
77
|
+
readonly before: readonly number[];
|
|
78
|
+
readonly after: readonly number[];
|
|
79
|
+
readonly spent: number;
|
|
80
|
+
readonly stop: GreedyStop;
|
|
81
|
+
readonly evaluations: number;
|
|
82
|
+
}
|
|
83
|
+
/** A buy order: the purchases in the order of the choice, the units of each product, and the result of each stage. */
|
|
84
|
+
interface BuyOrder {
|
|
85
|
+
readonly budget: number;
|
|
86
|
+
readonly spent: number;
|
|
87
|
+
readonly buys: readonly OrderBuy[];
|
|
88
|
+
/** The units of each product after the order, with the units of `start`. */
|
|
89
|
+
readonly units: Selection;
|
|
90
|
+
readonly stages: readonly OrderStageResult[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* This function calculates a buy order with a budgeted greedy choice in each stage. Each step buys one unit of the
|
|
94
|
+
* product with the largest gain for each unit of money. The choice is `greedy` of `@mark1russell7/strategy-search`.
|
|
95
|
+
*
|
|
96
|
+
* - A stage starts from the units of the stage before it, and it spends only the money that is left.
|
|
97
|
+
* - A stage can give the best single unit in place of its steps, when that unit has a better value (`method: "single"`).
|
|
98
|
+
*
|
|
99
|
+
* @param candidates - The candidates, from `buyCandidates`
|
|
100
|
+
* @param options - The budget, the stages, the goal and the start
|
|
101
|
+
* @returns The buy order
|
|
102
|
+
* @throws RangeError when the options are bad, or when a value is not a list of finite numbers with one length
|
|
103
|
+
*/
|
|
104
|
+
declare function orderBuys(candidates: readonly BuyCandidate[], options: OrderOptions): BuyOrder;
|
|
105
|
+
export { OrderBuy as a, OrderStageResult as c, orderBuys as d, CandidateOptions as i, ProductWant as l, BuyCandidates as n, OrderOptions as o, BuyOrder as r, OrderStage as s, BuyCandidate as t, buyCandidates as u };
|
|
106
|
+
//# sourceMappingURL=order-BAbk8QQA.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-BAbk8QQA.d.ts","names":[],"sources":["../src/order.ts"],"mappings":";;;UAYiB;WACN;WACA,MAAM;;WAEN;;;UAIM;WACN;;WAEA;WACA;;WAEA;;;UAIM;WACN;WACA,qBAAqB;WACrB;aAA8B;aAA0B;;;;UAIlD;;WAEN;;WAEA,sBAAsB;;;;;;;;;;;;iBAajB,cAAc,gBAAgB,eAAe,uBAAuB,eAAe,SAAS,mBAAmB;;UAiB9G;WACN;;WAEA,QAAQ,OAAO;;;UAIT;;WAEN;;WAEA,iBAAiB;;WAEjB,OAAO;;WAEP,QAAQ;;WAER;;;UAIM;WACN;WACA;WACA;WACA;WACA;;;UAIM;WACN;WACA;WACA;WACA;WACA;WACA,MAAM;WACN;;;UAIM;WACN;WACA;WACA,eAAe;;WAEf,OAAO;WACP,iBAAiB;;;;;;;;;;;;;;iBAeZ,UAAU,qBAAqB,gBAAgB,SAAS,eAAe"}
|
package/build/plan.d.ts
CHANGED
|
@@ -1,109 +1,8 @@
|
|
|
1
1
|
import { a as PartWant, p as Condition, r as Observation } from "./offers-CVUAcRHs.js";
|
|
2
|
+
import { a as OrderBuy, c as OrderStageResult, d as orderBuys, i as CandidateOptions, l as ProductWant, n as BuyCandidates, o as OrderOptions, r as BuyOrder, s as OrderStage, t as BuyCandidate, u as buyCandidates } from "./order-BAbk8QQA.js";
|
|
2
3
|
import { Quantity } from "@mark1russell7/quantity";
|
|
3
4
|
import { z } from "zod";
|
|
4
|
-
import {
|
|
5
|
-
/** One product that a buyer wants: its key, the part that the offers must match, and the largest count of its units. */
|
|
6
|
-
interface ProductWant {
|
|
7
|
-
readonly product: string;
|
|
8
|
-
readonly want: PartWant;
|
|
9
|
-
/** The largest count of units to buy. The default is 1. */
|
|
10
|
-
readonly max?: number | undefined;
|
|
11
|
-
}
|
|
12
|
-
/** One candidate of a buy order: a product, the price of one unit, the largest count of units and the offer. */
|
|
13
|
-
interface BuyCandidate {
|
|
14
|
-
readonly product: string;
|
|
15
|
-
/** The cost of one unit with its shipping, in the currency of the order. */
|
|
16
|
-
readonly price: number;
|
|
17
|
-
readonly max: number;
|
|
18
|
-
/** The `id` of the offer of the price. */
|
|
19
|
-
readonly quote: string;
|
|
20
|
-
}
|
|
21
|
-
/** The candidates of a buy order, and the products that have no usable offer. */
|
|
22
|
-
interface BuyCandidates {
|
|
23
|
-
readonly currency: string;
|
|
24
|
-
readonly candidates: readonly BuyCandidate[];
|
|
25
|
-
readonly unpriced: readonly {
|
|
26
|
-
readonly product: string;
|
|
27
|
-
readonly why: string;
|
|
28
|
-
}[];
|
|
29
|
-
}
|
|
30
|
-
/** The options of the candidates: the currency and the conditions that the buyer accepts. */
|
|
31
|
-
interface CandidateOptions {
|
|
32
|
-
/** The currency of the prices, a unit of money of `@mark1russell7/quantity`, for example `USD`. */
|
|
33
|
-
readonly currency: string;
|
|
34
|
-
/** The conditions that the buyer accepts. The default is `new` only. */
|
|
35
|
-
readonly conditions?: readonly Condition[] | undefined;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* This function gives a candidate for each product with a usable offer. The price is the cost of one unit with its
|
|
39
|
-
* shipping, from the in-stock offer with the lowest cost, as in `planBuys`. Each unit is one order, so the price is an
|
|
40
|
-
* upper limit of the cost of more units.
|
|
41
|
-
*
|
|
42
|
-
* @param wants - The products, in the order of the result
|
|
43
|
-
* @param observations - The observations of the offers
|
|
44
|
-
* @param options - The currency and the conditions
|
|
45
|
-
* @throws RangeError when the currency is not a unit of money, or when a product is twice in `wants`
|
|
46
|
-
*/
|
|
47
|
-
export declare function buyCandidates(wants: readonly ProductWant[], observations: readonly Observation[], options: CandidateOptions): BuyCandidates;
|
|
48
|
-
/** One stage of a buy order: its name and the value of a choice, the most important number first. */
|
|
49
|
-
interface OrderStage {
|
|
50
|
-
readonly name: string;
|
|
51
|
-
/** The value of the units of each product. It is a pure function. */
|
|
52
|
-
readonly value: (units: Selection) => readonly number[];
|
|
53
|
-
}
|
|
54
|
-
/** The options of a buy order. */
|
|
55
|
-
interface OrderOptions {
|
|
56
|
-
/** The money of the order, in the currency of the candidates. */
|
|
57
|
-
readonly budget: number;
|
|
58
|
-
/** The stages, in order. Each stage starts from the units of the stage before it, with the money that is left. */
|
|
59
|
-
readonly stages: readonly OrderStage[];
|
|
60
|
-
/** The goal of each number of a value. Use `min` for a shortfall. The default is `max`. */
|
|
61
|
-
readonly goal?: Goal | undefined;
|
|
62
|
-
/** The units that the buyer has before the order. Their cost is not in the budget. */
|
|
63
|
-
readonly start?: Selection | undefined;
|
|
64
|
-
/** With `false`, each step evaluates each product again. Use it when two products give more together than apart. */
|
|
65
|
-
readonly lazy?: boolean | undefined;
|
|
66
|
-
}
|
|
67
|
-
/** One purchase of a buy order: one unit of a product, its offer and its cost, and its gain in its stage. */
|
|
68
|
-
interface OrderBuy {
|
|
69
|
-
readonly stage: string;
|
|
70
|
-
readonly product: string;
|
|
71
|
-
readonly quote: string;
|
|
72
|
-
readonly cost: number;
|
|
73
|
-
readonly gain: readonly number[];
|
|
74
|
-
}
|
|
75
|
-
/** The result of one stage: the value before and after it, the money that it spends and the reason that it stops. */
|
|
76
|
-
interface OrderStageResult {
|
|
77
|
-
readonly name: string;
|
|
78
|
-
readonly method: "greedy" | "single";
|
|
79
|
-
readonly before: readonly number[];
|
|
80
|
-
readonly after: readonly number[];
|
|
81
|
-
readonly spent: number;
|
|
82
|
-
readonly stop: GreedyStop;
|
|
83
|
-
readonly evaluations: number;
|
|
84
|
-
}
|
|
85
|
-
/** A buy order: the purchases in the order of the choice, the units of each product, and the result of each stage. */
|
|
86
|
-
interface BuyOrder {
|
|
87
|
-
readonly budget: number;
|
|
88
|
-
readonly spent: number;
|
|
89
|
-
readonly buys: readonly OrderBuy[];
|
|
90
|
-
/** The units of each product after the order, with the units of `start`. */
|
|
91
|
-
readonly units: Selection;
|
|
92
|
-
readonly stages: readonly OrderStageResult[];
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* This function calculates a buy order with a budgeted greedy choice in each stage. Each step buys one unit of the
|
|
96
|
-
* product with the largest gain for each unit of money. The choice is `greedy` of `@mark1russell7/strategy-search`.
|
|
97
|
-
*
|
|
98
|
-
* - A stage starts from the units of the stage before it, and it spends only the money that is left.
|
|
99
|
-
* - A stage can give the best single unit in place of its steps, when that unit has a better value (`method: "single"`).
|
|
100
|
-
*
|
|
101
|
-
* @param candidates - The candidates, from `buyCandidates`
|
|
102
|
-
* @param options - The budget, the stages, the goal and the start
|
|
103
|
-
* @returns The buy order
|
|
104
|
-
* @throws RangeError when the options are bad, or when a value is not a list of finite numbers with one length
|
|
105
|
-
*/
|
|
106
|
-
export declare function orderBuys(candidates: readonly BuyCandidate[], options: OrderOptions): BuyOrder;
|
|
5
|
+
import { Objective, SweepCounts } from "@mark1russell7/strategy-search";
|
|
107
6
|
/** The format name of a need record. */
|
|
108
7
|
export declare const NEED_FORMAT = "buy-need/1";
|
|
109
8
|
/** The format name of a plan record. */
|
|
@@ -250,5 +149,5 @@ export interface PlanOptions {
|
|
|
250
149
|
* The function also throws a RangeError when strategy-search refuses the options.
|
|
251
150
|
*/
|
|
252
151
|
export declare function planBuys(need: BuyNeed, observations: readonly Observation[], options?: PlanOptions): BuyPlan;
|
|
253
|
-
export type
|
|
152
|
+
export { type BuyCandidate, type BuyCandidates, type BuyOrder, type CandidateOptions, type OrderBuy, type OrderOptions, type OrderStage, type OrderStageResult, type ProductWant, buyCandidates, orderBuys };
|
|
254
153
|
//# sourceMappingURL=plan.d.ts.map
|
package/build/plan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"plan.d.ts","names":[],"sources":["../src/plan.ts"],"mappings":";;;;;;qBAiBa;;qBAGA;;qBAGA;;qBAGA;;qBAGA;;YAMD;;iBAGK;WACN;WACA,MAAM;;WAEN,QAAQ,SAAS,eAAe;;;iBAI1B;WACN;WACA;;;iBAIM;WACN;WACA,gBAAgB;WAChB,QAAQ;;;;;;iBAOF;WACN;;WAEA;WACA;;WAEA;WACA;WACA;;;iBAIM;WACN;;WAEA;;;iBAIM;WACN,eAAe;WACf;;WAEA;;WAEA,sBAAsB;;WAEtB,SAAS,SAAS,eAAe;WACjC,gBAAgB;WAChB,oBAAoB;WACpB,iBAAiB;;;qBASf,eAAe,EAAE,QAAQ;;;;;;wBAuDtB,aAAa,MAAM;;iBAuDlB;WACN;WACA;WACA;WACA;WACA,MAAM;;;iBAIA;WACN;;WAEA,OAAO;WACP,QAAQ,SAAS;WACjB,gBAAgB;;;iBAIV;;WAEN;WACA;WACA;;;iBAIM;WACN;WACA;WACA;;;iBAIM;WACN,eAAe;;WAEf;WACA;;WAEA;;WAEA;;WAEA;WACA,qBAAqB;WACrB,QAAQ;;WAER,gBAAgB;;WAEhB,iBAAiB;;WAEjB,mBAAmB;;;iBAMb;;WAEN;;WAEA;;WAEA;;;;;;;;;;;;;;;;wBA2BK,SAAS,MAAM,SAAS,uBAAuB,eAAe,UAAS,cAAmB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The catalog of supplies: the format, the gate, the wants of its products and the gifts of their units, and the
|
|
3
|
+
* reference catalog. Each value has a cited fact, the definition of the product, or a no read.
|
|
4
|
+
*/
|
|
5
|
+
import { a as PartWant } from "./offers-CVUAcRHs.js";
|
|
6
|
+
import { l as ProductWant } from "./order-BAbk8QQA.js";
|
|
7
|
+
import { CitedUnit, Finding, FindingCode, GateOptions, Source } from "@mark1russell7/guidebook";
|
|
8
|
+
/** The format of a catalog of supplies. */
|
|
9
|
+
export declare const SUPPLY_FORMAT = "supply-catalog/1";
|
|
10
|
+
/** The kinds of the supplies. */
|
|
11
|
+
export declare const SUPPLY_KINDS: readonly ["water", "food", "power", "light", "heat", "first-aid", "communication"];
|
|
12
|
+
/** A kind of a supply. */
|
|
13
|
+
type SupplyKind = (typeof SUPPLY_KINDS)[number];
|
|
14
|
+
/** A value that no source gives yet. The reason tells what is missing. */
|
|
15
|
+
interface NoRead {
|
|
16
|
+
readonly read: false;
|
|
17
|
+
readonly why: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* An amount with its reason. The reason is a cited fact: the `id` of a unit of the catalog with the use `fact`.
|
|
21
|
+
* Or it is the definition of the product, for example the 1 gal of a jug of 1 gal.
|
|
22
|
+
*/
|
|
23
|
+
type CitedAmount = {
|
|
24
|
+
readonly read: true;
|
|
25
|
+
readonly amount: number;
|
|
26
|
+
readonly unit: string;
|
|
27
|
+
readonly fact: string;
|
|
28
|
+
readonly definition?: never;
|
|
29
|
+
} | {
|
|
30
|
+
readonly read: true;
|
|
31
|
+
readonly amount: number;
|
|
32
|
+
readonly unit: string;
|
|
33
|
+
readonly definition: string;
|
|
34
|
+
readonly fact?: never;
|
|
35
|
+
};
|
|
36
|
+
/** A resource that a supply gives, with its unit, for example `water.stored` in `L`. The codes are the resource codes of a store. */
|
|
37
|
+
interface SupplyResource {
|
|
38
|
+
readonly code: string;
|
|
39
|
+
readonly unit: string;
|
|
40
|
+
readonly title: string;
|
|
41
|
+
}
|
|
42
|
+
/** The gift of one unit of a product: an amount of one resource, or no read. */
|
|
43
|
+
interface SupplyGift {
|
|
44
|
+
readonly resource: string;
|
|
45
|
+
readonly amount: CitedAmount | NoRead;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The shelf life of a product: a cited amount of time, the `id` of a product of the FoodKeeper data of USDA FSIS, or no read.
|
|
49
|
+
* The entry `/foodkeeper` of `@mark1russell7/stock` gives the due rule of a FoodKeeper product.
|
|
50
|
+
*/
|
|
51
|
+
type ShelfLife = CitedAmount | {
|
|
52
|
+
readonly read: true;
|
|
53
|
+
readonly foodKeeper: number;
|
|
54
|
+
} | NoRead;
|
|
55
|
+
/** A product of the catalog. */
|
|
56
|
+
interface SupplyProduct {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly title: string;
|
|
59
|
+
readonly kind: SupplyKind;
|
|
60
|
+
/** The part that the offers of a seller must match. A product with no part has no offer, so it has no price. */
|
|
61
|
+
readonly want?: PartWant | undefined;
|
|
62
|
+
/** The resources that one unit gives. */
|
|
63
|
+
readonly gives: readonly SupplyGift[];
|
|
64
|
+
/** The food energy of one unit, in a unit of energy. A cooking converter gives it. */
|
|
65
|
+
readonly energy?: CitedAmount | NoRead | undefined;
|
|
66
|
+
readonly shelf: ShelfLife;
|
|
67
|
+
}
|
|
68
|
+
/** A catalog of supplies: the sources, the cited facts, the resources and the products. */
|
|
69
|
+
interface SupplyCatalog {
|
|
70
|
+
readonly format: typeof SUPPLY_FORMAT;
|
|
71
|
+
readonly sources: readonly Source[];
|
|
72
|
+
readonly facts: readonly CitedUnit[];
|
|
73
|
+
readonly resources: readonly SupplyResource[];
|
|
74
|
+
readonly products: readonly SupplyProduct[];
|
|
75
|
+
}
|
|
76
|
+
/** The codes of the findings of the catalog gate. */
|
|
77
|
+
export declare const SUPPLY_CODES: readonly ["supplies-format", "supplies-twice", "supplies-kind", "supplies-resource", "supplies-fact", "supplies-amount", "supplies-unit", "supplies-shelf", "supplies-unused", "supplies-no-read", "supplies-no-reason"];
|
|
78
|
+
/** A code of a finding of the catalog gate. */
|
|
79
|
+
type SupplyCode = (typeof SUPPLY_CODES)[number];
|
|
80
|
+
/** A finding of the catalog gate, or of the gate of the facts and their sources. */
|
|
81
|
+
type SupplyFinding = Finding<SupplyCode | FindingCode, "source" | "unit" | "resource" | "product">;
|
|
82
|
+
/**
|
|
83
|
+
* This function examines a catalog. It gives the findings of the sources and the facts (the gate of
|
|
84
|
+
* `@mark1russell7/guidebook`), and the findings of the products:
|
|
85
|
+
*
|
|
86
|
+
* - An error for a product or a resource two times, a kind that is not a supply kind, and a gift of an unknown resource.
|
|
87
|
+
* - An error for a fact that is not a fact of the catalog, and for an amount that is not more than 0.
|
|
88
|
+
* - An error for an amount with no reason, with two reasons, or with a blank definition. A catalog from JSON can have them.
|
|
89
|
+
* - An error for a unit that is not a unit of `@mark1russell7/quantity`.
|
|
90
|
+
* - An error for a unit that does not convert to the unit of its resource.
|
|
91
|
+
* - A warning for each value with no read, and for a no read with a blank reason.
|
|
92
|
+
* - A warning for each fact and each source that no product uses.
|
|
93
|
+
*
|
|
94
|
+
* The function takes a decoded catalog: each record has the fields of its type. Decode a catalog from JSON first, for
|
|
95
|
+
* example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.
|
|
96
|
+
*
|
|
97
|
+
* @param catalog - The catalog
|
|
98
|
+
* @param options - The options of the gate of the sources, for example the date of the gate
|
|
99
|
+
*/
|
|
100
|
+
export declare function checkSupplies(catalog: SupplyCatalog, options?: GateOptions): SupplyFinding[];
|
|
101
|
+
/**
|
|
102
|
+
* This function gives the wants of the products with a part, in the order of the catalog, for `buyCandidates`.
|
|
103
|
+
* A product with no part has no offer, so it is not in the result.
|
|
104
|
+
*
|
|
105
|
+
* @param catalog - The catalog
|
|
106
|
+
* @param max - The largest count of units of a product. The default is 1 for each product
|
|
107
|
+
*/
|
|
108
|
+
export declare function supplyWants(catalog: SupplyCatalog, max?: (product: SupplyProduct) => number): ProductWant[];
|
|
109
|
+
/** The gift of a count of units: an amount in the unit of its resource, or no read. */
|
|
110
|
+
type GiftOf = {
|
|
111
|
+
readonly resource: string;
|
|
112
|
+
readonly read: true;
|
|
113
|
+
readonly amount: number;
|
|
114
|
+
readonly unit: string;
|
|
115
|
+
} | {
|
|
116
|
+
readonly resource: string;
|
|
117
|
+
readonly read: false;
|
|
118
|
+
readonly why: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* This function gives the resources of a count of units of a product, each in the unit of its resource.
|
|
122
|
+
* A gift with no read stays no read: it is not 0.
|
|
123
|
+
*
|
|
124
|
+
* @param catalog - The catalog
|
|
125
|
+
* @param id - The `id` of the product
|
|
126
|
+
* @param units - The count of units
|
|
127
|
+
* @throws RangeError when the count of units is not a finite number of 0 or more
|
|
128
|
+
* @throws RangeError when the catalog has no such product, or a gift of an unknown resource
|
|
129
|
+
* @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of a gift does not convert to the unit of its resource
|
|
130
|
+
*/
|
|
131
|
+
export declare function giftsOf(catalog: SupplyCatalog, id: string, units: number): GiftOf[];
|
|
132
|
+
/** The reference catalog of supplies. A household adds its own products to a copy of it. */
|
|
133
|
+
export declare const SUPPLY_CATALOG: SupplyCatalog;
|
|
134
|
+
export type { CitedAmount, GiftOf, NoRead, ShelfLife, SupplyCatalog, SupplyCode, SupplyFinding, SupplyGift, SupplyKind, SupplyProduct, SupplyResource };
|
|
135
|
+
//# sourceMappingURL=supplies-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supplies-entry.d.ts","names":[],"sources":["../src/supplies.ts","../src/supplies-data.ts"],"mappings":";;;;;;;;qBAaa;;qBAGA;;KAGD,qBAAqB;;UAGhB;WACN;WACA;;;;;;KAOC;WACG;WAAqB;WAAyB;WAAuB;WAAuB;;WAC5F;WAAqB;WAAyB;WAAuB;WAA6B;;;UAGhG;WACN;WACA;WACA;;;UAIM;WACN;WACA,QAAQ,cAAc;;;;;;KAOrB,YAAY;WAAyB;WAAqB;IAAuB;;UAG5E;WACN;WACA;WACA,MAAM;;WAEN,OAAO;;WAEP,gBAAgB;;WAEhB,SAAS,cAAc;WACvB,OAAO;;;UAID;WACN,eAAe;WACf,kBAAkB;WAClB,gBAAgB;WAChB,oBAAoB;WACpB,mBAAmB;;;qBAIjB;;KAeD,qBAAqB;;KAGrB,gBAAgB,QAAQ,aAAa;;;;;;;;;;;;;;;;;;;wBAmCjC,cAAc,SAAS,eAAe,UAAS,cAAmB;;;;;;;;wBAwElE,YAAY,SAAS,eAAe,OAAM,SAAS,2BAAqC;;KAK5F;WAAoB;WAA2B;WAAqB;WAAyB;;WAA4B;WAA2B;WAAsB;;;;;;;;;;;;;wBAatK,QAAQ,SAAS,eAAe,YAAY,gBAAgB;;qBCpN/D,gBAAgB"}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { convertible, quantity, valueIn } from "@mark1russell7/quantity";
|
|
2
|
+
import { checkSources, checkUnits } from "@mark1russell7/guidebook";
|
|
3
|
+
// src/supplies.ts
|
|
4
|
+
/** The format of a catalog of supplies. */
|
|
5
|
+
const SUPPLY_FORMAT = "supply-catalog/1";
|
|
6
|
+
/** The kinds of the supplies. */
|
|
7
|
+
const SUPPLY_KINDS = [
|
|
8
|
+
"water",
|
|
9
|
+
"food",
|
|
10
|
+
"power",
|
|
11
|
+
"light",
|
|
12
|
+
"heat",
|
|
13
|
+
"first-aid",
|
|
14
|
+
"communication"
|
|
15
|
+
];
|
|
16
|
+
/** The codes of the findings of the catalog gate. */
|
|
17
|
+
const SUPPLY_CODES = [
|
|
18
|
+
"supplies-format",
|
|
19
|
+
"supplies-twice",
|
|
20
|
+
"supplies-kind",
|
|
21
|
+
"supplies-resource",
|
|
22
|
+
"supplies-fact",
|
|
23
|
+
"supplies-amount",
|
|
24
|
+
"supplies-unit",
|
|
25
|
+
"supplies-shelf",
|
|
26
|
+
"supplies-unused",
|
|
27
|
+
"supplies-no-read",
|
|
28
|
+
"supplies-no-reason"
|
|
29
|
+
];
|
|
30
|
+
/** This function tells if a text is a unit of `@mark1russell7/quantity`. `convertible` throws for an unknown unit. */
|
|
31
|
+
function known(unit) {
|
|
32
|
+
if (typeof unit !== "string") return false;
|
|
33
|
+
try {
|
|
34
|
+
return convertible(unit, unit);
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** The unit that each food energy converts to. */
|
|
40
|
+
const ENERGY_UNIT = "kcal";
|
|
41
|
+
/** The unit that each shelf life converts to. */
|
|
42
|
+
const SHELF_UNIT = "d";
|
|
43
|
+
/**
|
|
44
|
+
* This function examines a catalog. It gives the findings of the sources and the facts (the gate of
|
|
45
|
+
* `@mark1russell7/guidebook`), and the findings of the products:
|
|
46
|
+
*
|
|
47
|
+
* - An error for a product or a resource two times, a kind that is not a supply kind, and a gift of an unknown resource.
|
|
48
|
+
* - An error for a fact that is not a fact of the catalog, and for an amount that is not more than 0.
|
|
49
|
+
* - An error for an amount with no reason, with two reasons, or with a blank definition. A catalog from JSON can have them.
|
|
50
|
+
* - An error for a unit that is not a unit of `@mark1russell7/quantity`.
|
|
51
|
+
* - An error for a unit that does not convert to the unit of its resource.
|
|
52
|
+
* - A warning for each value with no read, and for a no read with a blank reason.
|
|
53
|
+
* - A warning for each fact and each source that no product uses.
|
|
54
|
+
*
|
|
55
|
+
* The function takes a decoded catalog: each record has the fields of its type. Decode a catalog from JSON first, for
|
|
56
|
+
* example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.
|
|
57
|
+
*
|
|
58
|
+
* @param catalog - The catalog
|
|
59
|
+
* @param options - The options of the gate of the sources, for example the date of the gate
|
|
60
|
+
*/
|
|
61
|
+
function checkSupplies(catalog, options = {}) {
|
|
62
|
+
const out = [...checkSources(catalog.sources, options), ...checkUnits(catalog.facts, catalog.sources, options)];
|
|
63
|
+
const error = (code, record, id, message) => {
|
|
64
|
+
out.push({
|
|
65
|
+
level: "error",
|
|
66
|
+
code,
|
|
67
|
+
record,
|
|
68
|
+
id,
|
|
69
|
+
message
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
const warning = (code, record, id, message) => {
|
|
73
|
+
out.push({
|
|
74
|
+
level: "warning",
|
|
75
|
+
code,
|
|
76
|
+
record,
|
|
77
|
+
id,
|
|
78
|
+
message
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
if (catalog.format !== "supply-catalog/1") error("supplies-format", "product", "", `The format is ${String(catalog.format)}. It must be ${SUPPLY_FORMAT}.`);
|
|
82
|
+
const resources = /* @__PURE__ */ new Map();
|
|
83
|
+
for (const resource of catalog.resources) {
|
|
84
|
+
if (resources.has(resource.code)) error("supplies-twice", "resource", resource.code, `The resource ${resource.code} is two times in the catalog.`);
|
|
85
|
+
if (!known(resource.unit)) error("supplies-unit", "resource", resource.code, `The unit ${String(resource.unit)} of the resource ${resource.code} is not a known unit.`);
|
|
86
|
+
resources.set(resource.code, resource);
|
|
87
|
+
}
|
|
88
|
+
const facts = new Map(catalog.facts.map((fact) => [fact.id, fact]));
|
|
89
|
+
const used = /* @__PURE__ */ new Set();
|
|
90
|
+
/** This function examines one cited amount, and gives the unit check to `units`. */
|
|
91
|
+
const amount = (product, what, value, unit) => {
|
|
92
|
+
if (!value.read) {
|
|
93
|
+
warning("supplies-no-read", "product", product, `The ${what} of the product ${product} is no read: ${String(value.why)}`);
|
|
94
|
+
if (typeof value.why !== "string" || value.why.trim() === "") warning("supplies-no-reason", "product", product, `The no read of the ${what} of the product ${product} has no reason.`);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const reasons = (value.fact === void 0 ? 0 : 1) + (value.definition === void 0 ? 0 : 1);
|
|
98
|
+
if (reasons !== 1) error("supplies-fact", "product", product, `The ${what} of the product ${product} has ${String(reasons)} reasons. It must have a fact or a definition, not the two.`);
|
|
99
|
+
else if (value.definition !== void 0 && (typeof value.definition !== "string" || value.definition.trim() === "")) error("supplies-fact", "product", product, `The definition of the ${what} of the product ${product} is blank.`);
|
|
100
|
+
if (value.fact !== void 0) {
|
|
101
|
+
const fact = facts.get(value.fact);
|
|
102
|
+
if (fact === void 0 || fact.use !== "fact") error("supplies-fact", "product", product, `The ${what} of the product ${product} cites ${value.fact}, and the catalog has no fact with that id.`);
|
|
103
|
+
used.add(value.fact);
|
|
104
|
+
}
|
|
105
|
+
if (!(Number.isFinite(value.amount) && value.amount > 0)) error("supplies-amount", "product", product, `The ${what} of the product ${product} is ${String(value.amount)}. It must be a finite number more than 0.`);
|
|
106
|
+
if (!known(value.unit)) error("supplies-unit", "product", product, `The unit ${String(value.unit)} of the ${what} of the product ${product} is not a known unit.`);
|
|
107
|
+
else if (known(unit) && !convertible(value.unit, unit)) error("supplies-unit", "product", product, `The ${what} of the product ${product} is in ${value.unit}, and ${value.unit} does not convert to ${unit}.`);
|
|
108
|
+
};
|
|
109
|
+
const products = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const product of catalog.products) {
|
|
111
|
+
if (products.has(product.id)) error("supplies-twice", "product", product.id, `The product ${product.id} is two times in the catalog.`);
|
|
112
|
+
products.add(product.id);
|
|
113
|
+
if (!SUPPLY_KINDS.includes(product.kind)) error("supplies-kind", "product", product.id, `The kind ${String(product.kind)} of the product ${product.id} is not a supply kind.`);
|
|
114
|
+
const gifts = /* @__PURE__ */ new Set();
|
|
115
|
+
for (const gift of product.gives) {
|
|
116
|
+
if (gifts.has(gift.resource)) error("supplies-twice", "product", product.id, `The product ${product.id} gives the resource ${gift.resource} two times.`);
|
|
117
|
+
gifts.add(gift.resource);
|
|
118
|
+
const resource = resources.get(gift.resource);
|
|
119
|
+
if (resource === void 0) error("supplies-resource", "product", product.id, `The product ${product.id} gives the resource ${gift.resource}, and the catalog has no such resource.`);
|
|
120
|
+
else amount(product.id, `gift of ${gift.resource}`, gift.amount, resource.unit);
|
|
121
|
+
}
|
|
122
|
+
if (product.energy !== void 0) amount(product.id, "food energy", product.energy, ENERGY_UNIT);
|
|
123
|
+
if ("foodKeeper" in product.shelf) {
|
|
124
|
+
if (!(Number.isSafeInteger(product.shelf.foodKeeper) && product.shelf.foodKeeper > 0)) error("supplies-shelf", "product", product.id, `The FoodKeeper id of the product ${product.id} is ${String(product.shelf.foodKeeper)}. It must be a whole number more than 0.`);
|
|
125
|
+
} else amount(product.id, "shelf life", product.shelf, SHELF_UNIT);
|
|
126
|
+
}
|
|
127
|
+
for (const fact of catalog.facts) if (!used.has(fact.id)) warning("supplies-unused", "unit", fact.id, `No product uses the fact ${fact.id}.`);
|
|
128
|
+
const cited = new Set(catalog.facts.map((fact) => fact.source));
|
|
129
|
+
for (const source of catalog.sources) if (!cited.has(source.id)) warning("supplies-unused", "source", source.id, `No fact cites the source ${source.id}.`);
|
|
130
|
+
return out;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* This function gives the wants of the products with a part, in the order of the catalog, for `buyCandidates`.
|
|
134
|
+
* A product with no part has no offer, so it is not in the result.
|
|
135
|
+
*
|
|
136
|
+
* @param catalog - The catalog
|
|
137
|
+
* @param max - The largest count of units of a product. The default is 1 for each product
|
|
138
|
+
*/
|
|
139
|
+
function supplyWants(catalog, max = () => 1) {
|
|
140
|
+
return catalog.products.flatMap((product) => product.want === void 0 ? [] : [{
|
|
141
|
+
product: product.id,
|
|
142
|
+
want: product.want,
|
|
143
|
+
max: max(product)
|
|
144
|
+
}]);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* This function gives the resources of a count of units of a product, each in the unit of its resource.
|
|
148
|
+
* A gift with no read stays no read: it is not 0.
|
|
149
|
+
*
|
|
150
|
+
* @param catalog - The catalog
|
|
151
|
+
* @param id - The `id` of the product
|
|
152
|
+
* @param units - The count of units
|
|
153
|
+
* @throws RangeError when the count of units is not a finite number of 0 or more
|
|
154
|
+
* @throws RangeError when the catalog has no such product, or a gift of an unknown resource
|
|
155
|
+
* @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of a gift does not convert to the unit of its resource
|
|
156
|
+
*/
|
|
157
|
+
function giftsOf(catalog, id, units) {
|
|
158
|
+
if (!(Number.isFinite(units) && units >= 0)) throw new RangeError(`The count of units is ${String(units)}. It must be a finite number of 0 or more.`);
|
|
159
|
+
const product = catalog.products.find((each) => each.id === id);
|
|
160
|
+
if (product === void 0) throw new RangeError(`The catalog has no product ${id}.`);
|
|
161
|
+
return product.gives.map((gift) => {
|
|
162
|
+
const resource = catalog.resources.find((each) => each.code === gift.resource);
|
|
163
|
+
if (resource === void 0) throw new RangeError(`The product ${id} gives the resource ${gift.resource}, and the catalog has no such resource.`);
|
|
164
|
+
if (!gift.amount.read) return {
|
|
165
|
+
resource: gift.resource,
|
|
166
|
+
read: false,
|
|
167
|
+
why: gift.amount.why
|
|
168
|
+
};
|
|
169
|
+
return {
|
|
170
|
+
resource: gift.resource,
|
|
171
|
+
read: true,
|
|
172
|
+
amount: units * valueIn(quantity(gift.amount.amount, gift.amount.unit), resource.unit),
|
|
173
|
+
unit: resource.unit
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
// src/supplies-data.ts
|
|
178
|
+
const CHECKED = "2026-11-22";
|
|
179
|
+
/** The reference catalog of supplies. A household adds its own products to a copy of it. */
|
|
180
|
+
const SUPPLY_CATALOG = {
|
|
181
|
+
format: SUPPLY_FORMAT,
|
|
182
|
+
sources: [{
|
|
183
|
+
id: "ready.water",
|
|
184
|
+
title: "Water",
|
|
185
|
+
url: "https://www.ready.gov/water",
|
|
186
|
+
license: "us-public-domain",
|
|
187
|
+
checked: CHECKED,
|
|
188
|
+
by: "FEMA (Ready.gov)"
|
|
189
|
+
}, {
|
|
190
|
+
id: "fdc.sr-legacy",
|
|
191
|
+
title: "FoodData Central, SR Legacy",
|
|
192
|
+
url: "https://fdc.nal.usda.gov/",
|
|
193
|
+
license: "cc0",
|
|
194
|
+
checked: CHECKED,
|
|
195
|
+
by: "USDA Agricultural Research Service"
|
|
196
|
+
}],
|
|
197
|
+
facts: [
|
|
198
|
+
{
|
|
199
|
+
id: "ready.water-replace",
|
|
200
|
+
use: "fact",
|
|
201
|
+
text: "The page tells to replace the stored water that is not commercially bottled each six months.",
|
|
202
|
+
source: "ready.water",
|
|
203
|
+
locator: "Water storage"
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
id: "fdc.rice-white",
|
|
207
|
+
use: "fact",
|
|
208
|
+
text: "The item 168877 (white long-grain rice, raw, enriched) gives 365 kcal in 100 g. Thus 1 kg gives 3650 kcal.",
|
|
209
|
+
source: "fdc.sr-legacy",
|
|
210
|
+
locator: "FDC ID 168877"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: "fdc.oats",
|
|
214
|
+
use: "fact",
|
|
215
|
+
text: "The item 173904 (oats, regular and quick, not fortified, dry) gives 379 kcal in 100 g. Thus 1 kg gives 3790 kcal.",
|
|
216
|
+
source: "fdc.sr-legacy",
|
|
217
|
+
locator: "FDC ID 173904"
|
|
218
|
+
}
|
|
219
|
+
],
|
|
220
|
+
resources: [
|
|
221
|
+
{
|
|
222
|
+
code: "water.stored",
|
|
223
|
+
unit: "L",
|
|
224
|
+
title: "Stored drinking water"
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
code: "food.grain-dry",
|
|
228
|
+
unit: "kg",
|
|
229
|
+
title: "Dry grain, to cook with water and fuel"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
code: "energy.battery",
|
|
233
|
+
unit: "Wh",
|
|
234
|
+
title: "Energy in a battery"
|
|
235
|
+
}
|
|
236
|
+
],
|
|
237
|
+
products: [
|
|
238
|
+
{
|
|
239
|
+
id: "water.jug-1gal",
|
|
240
|
+
title: "Drinking water, commercially bottled, in a jug of 1 gal",
|
|
241
|
+
kind: "water",
|
|
242
|
+
gives: [{
|
|
243
|
+
resource: "water.stored",
|
|
244
|
+
amount: {
|
|
245
|
+
read: true,
|
|
246
|
+
amount: 1,
|
|
247
|
+
unit: "gal",
|
|
248
|
+
definition: "The product is a jug of 1 gal."
|
|
249
|
+
}
|
|
250
|
+
}],
|
|
251
|
+
shelf: {
|
|
252
|
+
read: false,
|
|
253
|
+
why: "The source tells to keep commercially bottled water sealed, and it gives no time. The date on the label applies."
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
id: "water.container-1gal",
|
|
258
|
+
title: "A water container of 1 gal, filled from the tap",
|
|
259
|
+
kind: "water",
|
|
260
|
+
gives: [{
|
|
261
|
+
resource: "water.stored",
|
|
262
|
+
amount: {
|
|
263
|
+
read: true,
|
|
264
|
+
amount: 1,
|
|
265
|
+
unit: "gal",
|
|
266
|
+
definition: "The product is a container of 1 gal."
|
|
267
|
+
}
|
|
268
|
+
}],
|
|
269
|
+
shelf: {
|
|
270
|
+
read: true,
|
|
271
|
+
amount: 6,
|
|
272
|
+
unit: "mo",
|
|
273
|
+
fact: "ready.water-replace"
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
id: "food.rice-white-1kg",
|
|
278
|
+
title: "White long-grain rice, dry, 1 kg",
|
|
279
|
+
kind: "food",
|
|
280
|
+
gives: [{
|
|
281
|
+
resource: "food.grain-dry",
|
|
282
|
+
amount: {
|
|
283
|
+
read: true,
|
|
284
|
+
amount: 1,
|
|
285
|
+
unit: "kg",
|
|
286
|
+
definition: "The product is 1 kg of dry rice."
|
|
287
|
+
}
|
|
288
|
+
}],
|
|
289
|
+
energy: {
|
|
290
|
+
read: true,
|
|
291
|
+
amount: 3650,
|
|
292
|
+
unit: "kcal",
|
|
293
|
+
fact: "fdc.rice-white"
|
|
294
|
+
},
|
|
295
|
+
shelf: {
|
|
296
|
+
read: true,
|
|
297
|
+
foodKeeper: 338
|
|
298
|
+
}
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
id: "food.oats-1kg",
|
|
302
|
+
title: "Rolled oats, dry, 1 kg",
|
|
303
|
+
kind: "food",
|
|
304
|
+
gives: [{
|
|
305
|
+
resource: "food.grain-dry",
|
|
306
|
+
amount: {
|
|
307
|
+
read: true,
|
|
308
|
+
amount: 1,
|
|
309
|
+
unit: "kg",
|
|
310
|
+
definition: "The product is 1 kg of dry oats."
|
|
311
|
+
}
|
|
312
|
+
}],
|
|
313
|
+
energy: {
|
|
314
|
+
read: true,
|
|
315
|
+
amount: 3790,
|
|
316
|
+
unit: "kcal",
|
|
317
|
+
fact: "fdc.oats"
|
|
318
|
+
},
|
|
319
|
+
shelf: {
|
|
320
|
+
read: true,
|
|
321
|
+
foodKeeper: 375
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
{
|
|
325
|
+
id: "power.anker-737",
|
|
326
|
+
title: "Anker 737 Power Bank (PowerCore 24K)",
|
|
327
|
+
kind: "power",
|
|
328
|
+
want: {
|
|
329
|
+
brands: ["Anker"],
|
|
330
|
+
partNumbers: ["A1289"]
|
|
331
|
+
},
|
|
332
|
+
gives: [{
|
|
333
|
+
resource: "energy.battery",
|
|
334
|
+
amount: {
|
|
335
|
+
read: false,
|
|
336
|
+
why: "The page of the maker gives 24,000 mAh and no Wh. A charge does not convert to energy without its voltage."
|
|
337
|
+
}
|
|
338
|
+
}],
|
|
339
|
+
shelf: {
|
|
340
|
+
read: false,
|
|
341
|
+
why: "No source is read yet."
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
]
|
|
345
|
+
};
|
|
346
|
+
export { SUPPLY_CATALOG, SUPPLY_CODES, SUPPLY_FORMAT, SUPPLY_KINDS, checkSupplies, giftsOf, supplyWants };
|
|
347
|
+
|
|
348
|
+
//# sourceMappingURL=supplies-entry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supplies-entry.js","names":[],"sources":["../src/supplies.ts","../src/supplies-data.ts"],"sourcesContent":["import { checkSources, checkUnits, type CitedUnit, type Finding, type FindingCode, type GateOptions, type Source } from \"@mark1russell7/guidebook\";\nimport { convertible, quantity, valueIn } from \"@mark1russell7/quantity\";\nimport type { PartWant } from \"./offers.ts\";\nimport type { ProductWant } from \"./order.ts\";\n\n/*\n * This module is the format and the gate of a catalog of supplies: the products that a household keeps for an\n * emergency, the resource and the amount that one unit gives, and its shelf life. Each value has a cited fact, the\n * definition of the product, or an explicit no read. The facts and their sources are the records of\n * `@mark1russell7/guidebook`, and its gate examines them. The module names no person and no place.\n */\n\n/** The format of a catalog of supplies. */\nexport const SUPPLY_FORMAT = \"supply-catalog/1\";\n\n/** The kinds of the supplies. */\nexport const SUPPLY_KINDS = [\"water\", \"food\", \"power\", \"light\", \"heat\", \"first-aid\", \"communication\"] as const;\n\n/** A kind of a supply. */\nexport type SupplyKind = (typeof SUPPLY_KINDS)[number];\n\n/** A value that no source gives yet. The reason tells what is missing. */\nexport interface NoRead {\n readonly read: false;\n readonly why: string;\n}\n\n/**\n * An amount with its reason. The reason is a cited fact: the `id` of a unit of the catalog with the use `fact`.\n * Or it is the definition of the product, for example the 1 gal of a jug of 1 gal.\n */\nexport type CitedAmount =\n | { readonly read: true; readonly amount: number; readonly unit: string; readonly fact: string; readonly definition?: never }\n | { readonly read: true; readonly amount: number; readonly unit: string; readonly definition: string; readonly fact?: never };\n\n/** A resource that a supply gives, with its unit, for example `water.stored` in `L`. The codes are the resource codes of a store. */\nexport interface SupplyResource {\n readonly code: string;\n readonly unit: string;\n readonly title: string;\n}\n\n/** The gift of one unit of a product: an amount of one resource, or no read. */\nexport interface SupplyGift {\n readonly resource: string;\n readonly amount: CitedAmount | NoRead;\n}\n\n/**\n * The shelf life of a product: a cited amount of time, the `id` of a product of the FoodKeeper data of USDA FSIS, or no read.\n * The entry `/foodkeeper` of `@mark1russell7/stock` gives the due rule of a FoodKeeper product.\n */\nexport type ShelfLife = CitedAmount | { readonly read: true; readonly foodKeeper: number } | NoRead;\n\n/** A product of the catalog. */\nexport interface SupplyProduct {\n readonly id: string;\n readonly title: string;\n readonly kind: SupplyKind;\n /** The part that the offers of a seller must match. A product with no part has no offer, so it has no price. */\n readonly want?: PartWant | undefined;\n /** The resources that one unit gives. */\n readonly gives: readonly SupplyGift[];\n /** The food energy of one unit, in a unit of energy. A cooking converter gives it. */\n readonly energy?: CitedAmount | NoRead | undefined;\n readonly shelf: ShelfLife;\n}\n\n/** A catalog of supplies: the sources, the cited facts, the resources and the products. */\nexport interface SupplyCatalog {\n readonly format: typeof SUPPLY_FORMAT;\n readonly sources: readonly Source[];\n readonly facts: readonly CitedUnit[];\n readonly resources: readonly SupplyResource[];\n readonly products: readonly SupplyProduct[];\n}\n\n/** The codes of the findings of the catalog gate. */\nexport const SUPPLY_CODES = [\n \"supplies-format\",\n \"supplies-twice\",\n \"supplies-kind\",\n \"supplies-resource\",\n \"supplies-fact\",\n \"supplies-amount\",\n \"supplies-unit\",\n \"supplies-shelf\",\n \"supplies-unused\",\n \"supplies-no-read\",\n \"supplies-no-reason\",\n] as const;\n\n/** A code of a finding of the catalog gate. */\nexport type SupplyCode = (typeof SUPPLY_CODES)[number];\n\n/** A finding of the catalog gate, or of the gate of the facts and their sources. */\nexport type SupplyFinding = Finding<SupplyCode | FindingCode, \"source\" | \"unit\" | \"resource\" | \"product\">;\n\n/** This function tells if a text is a unit of `@mark1russell7/quantity`. `convertible` throws for an unknown unit. */\nfunction known(unit: unknown): boolean {\n if (typeof unit !== \"string\") return false;\n try {\n return convertible(unit, unit);\n } catch {\n return false;\n }\n}\n\n/** The unit that each food energy converts to. */\nconst ENERGY_UNIT = \"kcal\";\n/** The unit that each shelf life converts to. */\nconst SHELF_UNIT = \"d\";\n\n/**\n * This function examines a catalog. It gives the findings of the sources and the facts (the gate of\n * `@mark1russell7/guidebook`), and the findings of the products:\n *\n * - An error for a product or a resource two times, a kind that is not a supply kind, and a gift of an unknown resource.\n * - An error for a fact that is not a fact of the catalog, and for an amount that is not more than 0.\n * - An error for an amount with no reason, with two reasons, or with a blank definition. A catalog from JSON can have them.\n * - An error for a unit that is not a unit of `@mark1russell7/quantity`.\n * - An error for a unit that does not convert to the unit of its resource.\n * - A warning for each value with no read, and for a no read with a blank reason.\n * - A warning for each fact and each source that no product uses.\n *\n * The function takes a decoded catalog: each record has the fields of its type. Decode a catalog from JSON first, for\n * example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.\n *\n * @param catalog - The catalog\n * @param options - The options of the gate of the sources, for example the date of the gate\n */\nexport function checkSupplies(catalog: SupplyCatalog, options: GateOptions = {}): SupplyFinding[] {\n const out: SupplyFinding[] = [...checkSources(catalog.sources, options), ...checkUnits(catalog.facts, catalog.sources, options)];\n const error = (code: SupplyCode, record: \"resource\" | \"product\", id: string, message: string): void => {\n out.push({ level: \"error\", code, record, id, message });\n };\n const warning = (code: SupplyCode, record: \"source\" | \"unit\" | \"product\", id: string, message: string): void => {\n out.push({ level: \"warning\", code, record, id, message });\n };\n if (catalog.format !== SUPPLY_FORMAT) error(\"supplies-format\", \"product\", \"\", `The format is ${String(catalog.format)}. It must be ${SUPPLY_FORMAT}.`);\n\n const resources = new Map<string, SupplyResource>();\n for (const resource of catalog.resources) {\n if (resources.has(resource.code)) error(\"supplies-twice\", \"resource\", resource.code, `The resource ${resource.code} is two times in the catalog.`);\n if (!known(resource.unit)) error(\"supplies-unit\", \"resource\", resource.code, `The unit ${String(resource.unit)} of the resource ${resource.code} is not a known unit.`);\n resources.set(resource.code, resource);\n }\n const facts = new Map(catalog.facts.map((fact) => [fact.id, fact]));\n const used = new Set<string>();\n\n /** This function examines one cited amount, and gives the unit check to `units`. */\n const amount = (product: string, what: string, value: CitedAmount | NoRead, unit: string): void => {\n if (!value.read) {\n warning(\"supplies-no-read\", \"product\", product, `The ${what} of the product ${product} is no read: ${String(value.why)}`);\n if (typeof value.why !== \"string\" || value.why.trim() === \"\") warning(\"supplies-no-reason\", \"product\", product, `The no read of the ${what} of the product ${product} has no reason.`);\n return;\n }\n // The type permits one reason only. A catalog from JSON can have no reason, two reasons or a blank definition.\n const reasons = (value.fact === undefined ? 0 : 1) + (value.definition === undefined ? 0 : 1);\n if (reasons !== 1) error(\"supplies-fact\", \"product\", product, `The ${what} of the product ${product} has ${String(reasons)} reasons. It must have a fact or a definition, not the two.`);\n else if (value.definition !== undefined && (typeof value.definition !== \"string\" || value.definition.trim() === \"\")) error(\"supplies-fact\", \"product\", product, `The definition of the ${what} of the product ${product} is blank.`);\n if (value.fact !== undefined) {\n const fact = facts.get(value.fact);\n if (fact === undefined || fact.use !== \"fact\") error(\"supplies-fact\", \"product\", product, `The ${what} of the product ${product} cites ${value.fact}, and the catalog has no fact with that id.`);\n used.add(value.fact);\n }\n if (!(Number.isFinite(value.amount) && value.amount > 0)) error(\"supplies-amount\", \"product\", product, `The ${what} of the product ${product} is ${String(value.amount)}. It must be a finite number more than 0.`);\n if (!known(value.unit)) error(\"supplies-unit\", \"product\", product, `The unit ${String(value.unit)} of the ${what} of the product ${product} is not a known unit.`);\n else if (known(unit) && !convertible(value.unit, unit)) error(\"supplies-unit\", \"product\", product, `The ${what} of the product ${product} is in ${value.unit}, and ${value.unit} does not convert to ${unit}.`);\n };\n\n const products = new Set<string>();\n for (const product of catalog.products) {\n if (products.has(product.id)) error(\"supplies-twice\", \"product\", product.id, `The product ${product.id} is two times in the catalog.`);\n products.add(product.id);\n if (!(SUPPLY_KINDS as readonly string[]).includes(product.kind)) error(\"supplies-kind\", \"product\", product.id, `The kind ${String(product.kind)} of the product ${product.id} is not a supply kind.`);\n const gifts = new Set<string>();\n for (const gift of product.gives) {\n if (gifts.has(gift.resource)) error(\"supplies-twice\", \"product\", product.id, `The product ${product.id} gives the resource ${gift.resource} two times.`);\n gifts.add(gift.resource);\n const resource = resources.get(gift.resource);\n if (resource === undefined) error(\"supplies-resource\", \"product\", product.id, `The product ${product.id} gives the resource ${gift.resource}, and the catalog has no such resource.`);\n else amount(product.id, `gift of ${gift.resource}`, gift.amount, resource.unit);\n }\n if (product.energy !== undefined) amount(product.id, \"food energy\", product.energy, ENERGY_UNIT);\n if (\"foodKeeper\" in product.shelf) {\n if (!(Number.isSafeInteger(product.shelf.foodKeeper) && product.shelf.foodKeeper > 0)) error(\"supplies-shelf\", \"product\", product.id, `The FoodKeeper id of the product ${product.id} is ${String(product.shelf.foodKeeper)}. It must be a whole number more than 0.`);\n } else amount(product.id, \"shelf life\", product.shelf, SHELF_UNIT);\n }\n\n for (const fact of catalog.facts) if (!used.has(fact.id)) warning(\"supplies-unused\", \"unit\", fact.id, `No product uses the fact ${fact.id}.`);\n const cited = new Set(catalog.facts.map((fact) => fact.source));\n for (const source of catalog.sources) if (!cited.has(source.id)) warning(\"supplies-unused\", \"source\", source.id, `No fact cites the source ${source.id}.`);\n return out;\n}\n\n/**\n * This function gives the wants of the products with a part, in the order of the catalog, for `buyCandidates`.\n * A product with no part has no offer, so it is not in the result.\n *\n * @param catalog - The catalog\n * @param max - The largest count of units of a product. The default is 1 for each product\n */\nexport function supplyWants(catalog: SupplyCatalog, max: (product: SupplyProduct) => number = () => 1): ProductWant[] {\n return catalog.products.flatMap((product) => (product.want === undefined ? [] : [{ product: product.id, want: product.want, max: max(product) }]));\n}\n\n/** The gift of a count of units: an amount in the unit of its resource, or no read. */\nexport type GiftOf = { readonly resource: string; readonly read: true; readonly amount: number; readonly unit: string } | { readonly resource: string; readonly read: false; readonly why: string };\n\n/**\n * This function gives the resources of a count of units of a product, each in the unit of its resource.\n * A gift with no read stays no read: it is not 0.\n *\n * @param catalog - The catalog\n * @param id - The `id` of the product\n * @param units - The count of units\n * @throws RangeError when the count of units is not a finite number of 0 or more\n * @throws RangeError when the catalog has no such product, or a gift of an unknown resource\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of a gift does not convert to the unit of its resource\n */\nexport function giftsOf(catalog: SupplyCatalog, id: string, units: number): GiftOf[] {\n if (!(Number.isFinite(units) && units >= 0)) throw new RangeError(`The count of units is ${String(units)}. It must be a finite number of 0 or more.`);\n const product = catalog.products.find((each) => each.id === id);\n if (product === undefined) throw new RangeError(`The catalog has no product ${id}.`);\n return product.gives.map((gift): GiftOf => {\n const resource = catalog.resources.find((each) => each.code === gift.resource);\n if (resource === undefined) throw new RangeError(`The product ${id} gives the resource ${gift.resource}, and the catalog has no such resource.`);\n if (!gift.amount.read) return { resource: gift.resource, read: false, why: gift.amount.why };\n return { resource: gift.resource, read: true, amount: units * valueIn(quantity(gift.amount.amount, gift.amount.unit), resource.unit), unit: resource.unit };\n });\n}\n","import { SUPPLY_FORMAT, type SupplyCatalog } from \"./supplies.ts\";\n\n// The reference catalog of supplies. Each value has a cited fact, the definition of the product, or a no read.\n// Each fact is in own words, not a quote. The shelf life of a food is a product of the FoodKeeper data of USDA FSIS:\n// the entry `/foodkeeper` of `@mark1russell7/stock` gives its due rule, so this catalog does not copy its times.\n\nconst CHECKED = \"2026-11-22\";\n\n/** The reference catalog of supplies. A household adds its own products to a copy of it. */\nexport const SUPPLY_CATALOG: SupplyCatalog = {\n format: SUPPLY_FORMAT,\n sources: [\n { id: \"ready.water\", title: \"Water\", url: \"https://www.ready.gov/water\", license: \"us-public-domain\", checked: CHECKED, by: \"FEMA (Ready.gov)\" },\n { id: \"fdc.sr-legacy\", title: \"FoodData Central, SR Legacy\", url: \"https://fdc.nal.usda.gov/\", license: \"cc0\", checked: CHECKED, by: \"USDA Agricultural Research Service\" },\n ],\n facts: [\n {\n id: \"ready.water-replace\",\n use: \"fact\",\n text: \"The page tells to replace the stored water that is not commercially bottled each six months.\",\n source: \"ready.water\",\n locator: \"Water storage\",\n },\n {\n id: \"fdc.rice-white\",\n use: \"fact\",\n text: \"The item 168877 (white long-grain rice, raw, enriched) gives 365 kcal in 100 g. Thus 1 kg gives 3650 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 168877\",\n },\n {\n id: \"fdc.oats\",\n use: \"fact\",\n text: \"The item 173904 (oats, regular and quick, not fortified, dry) gives 379 kcal in 100 g. Thus 1 kg gives 3790 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 173904\",\n },\n ],\n resources: [\n { code: \"water.stored\", unit: \"L\", title: \"Stored drinking water\" },\n { code: \"food.grain-dry\", unit: \"kg\", title: \"Dry grain, to cook with water and fuel\" },\n { code: \"energy.battery\", unit: \"Wh\", title: \"Energy in a battery\" },\n ],\n products: [\n {\n id: \"water.jug-1gal\",\n title: \"Drinking water, commercially bottled, in a jug of 1 gal\",\n kind: \"water\",\n gives: [{ resource: \"water.stored\", amount: { read: true, amount: 1, unit: \"gal\", definition: \"The product is a jug of 1 gal.\" } }],\n shelf: { read: false, why: \"The source tells to keep commercially bottled water sealed, and it gives no time. The date on the label applies.\" },\n },\n {\n id: \"water.container-1gal\",\n title: \"A water container of 1 gal, filled from the tap\",\n kind: \"water\",\n gives: [{ resource: \"water.stored\", amount: { read: true, amount: 1, unit: \"gal\", definition: \"The product is a container of 1 gal.\" } }],\n shelf: { read: true, amount: 6, unit: \"mo\", fact: \"ready.water-replace\" },\n },\n {\n id: \"food.rice-white-1kg\",\n title: \"White long-grain rice, dry, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.grain-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry rice.\" } }],\n energy: { read: true, amount: 3650, unit: \"kcal\", fact: \"fdc.rice-white\" },\n shelf: { read: true, foodKeeper: 338 },\n },\n {\n id: \"food.oats-1kg\",\n title: \"Rolled oats, dry, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.grain-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry oats.\" } }],\n energy: { read: true, amount: 3790, unit: \"kcal\", fact: \"fdc.oats\" },\n shelf: { read: true, foodKeeper: 375 },\n },\n {\n id: \"power.anker-737\",\n title: \"Anker 737 Power Bank (PowerCore 24K)\",\n kind: \"power\",\n want: { brands: [\"Anker\"], partNumbers: [\"A1289\"] },\n gives: [{ resource: \"energy.battery\", amount: { read: false, why: \"The page of the maker gives 24,000 mAh and no Wh. A charge does not convert to energy without its voltage.\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IAAO,KAAK;GAAmH;EAChJ;EACA;GACE,IAAI;GACJ,OAAO;GACP,MAAM;GACN,OAAO,CAAC;IAAE,UAAU;IAAgB,QAAQ;KAAE,MAAM;KAAM,QAAQ;KAAG,MAAM;KAAO,YAAY;IAAuC;GAAE,CAAC;GACxI,OAAO;IAAE,MAAM;IAAM,QAAQ;IAAG,MAAM;IAAM,MAAM;GAAsB;EAC1E;EACA;GACE,IAAI;GACJ,OAAO;GACP,MAAM;GACN,OAAO,CAAC;IAAE,UAAU;IAAkB,QAAQ;KAAE,MAAM;KAAM,QAAQ;KAAG,MAAM;KAAM,YAAY;IAAmC;GAAE,CAAC;GACrI,QAAQ;IAAE,MAAM;IAAM,QAAQ;IAAM,MAAM;IAAQ,MAAM;GAAiB;GACzE,OAAO;IAAE,MAAM;IAAM,YAAY;GAAI;EACvC;EACA;GACE,IAAI;GACJ,OAAO;GACP,MAAM;GACN,OAAO,CAAC;IAAE,UAAU;IAAkB,QAAQ;KAAE,MAAM;KAAM,QAAQ;KAAG,MAAM;KAAM,YAAY;IAAmC;GAAE,CAAC;GACrI,QAAQ;IAAE,MAAM;IAAM,QAAQ;IAAM,MAAM;IAAQ,MAAM;GAAW;GACnE,OAAO;IAAE,MAAM;IAAM,YAAY;GAAI;EACvC;EACA;GACE,IAAI;GACJ,OAAO;GACP,MAAM;GACN,MAAM;IAAE,QAAQ,CAAC,OAAO;IAAG,aAAa,CAAC,OAAO;GAAE;GAClD,OAAO,CAAC;IAAE,UAAU;IAAkB,QAAQ;KAAE,MAAM;KAAO,KAAK;IAA6G;GAAE,CAAC;GAClL,OAAO;IAAE,MAAM;IAAO,KAAK;GAAyB;EACtD;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/market",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"description": "The records of a market: a product, an offer of a seller and a price reading, with their checks, the GTIN check, match keys, the cost of an order, the storage rules of a source, the best offer of a part, a board of current prices within the terms of each source, a buy plan: the Pareto front of the baskets of a need, and metered prices of cloud resources with tiers, free amounts, terms and their cost.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -39,12 +39,18 @@
|
|
|
39
39
|
"import": "./build/plan.js",
|
|
40
40
|
"default": "./build/plan.js"
|
|
41
41
|
},
|
|
42
|
+
"./supplies": {
|
|
43
|
+
"types": "./build/supplies-entry.d.ts",
|
|
44
|
+
"import": "./build/supplies-entry.js",
|
|
45
|
+
"default": "./build/supplies-entry.js"
|
|
46
|
+
},
|
|
42
47
|
"./package.json": "./package.json"
|
|
43
48
|
},
|
|
44
49
|
"files": [
|
|
45
50
|
"build"
|
|
46
51
|
],
|
|
47
52
|
"dependencies": {
|
|
53
|
+
"@mark1russell7/guidebook": "^0.1.1",
|
|
48
54
|
"@mark1russell7/quantity": "^0.4.0",
|
|
49
55
|
"@mark1russell7/strategy-search": "^0.1.2",
|
|
50
56
|
"@mark1russell7/strategy-space": "^0.1.0",
|