@mark1russell7/stack-endurance 0.8.27 → 0.8.29

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.
@@ -0,0 +1,382 @@
1
+ import { t as ENDURANCE_SCHEMA } from "./layer-a3Fr70Uh.js";
2
+ import { CUT_BOUNDS, bandFault, countsFault, curveFault, curveFault as curveFault$1, dayNumber, intervalFault, isCutBound, joinRecords, joinSetting } from "@mark1russell7/system-stack";
3
+ import { stronglyConnectedComponents } from "@mark1russell7/collections/graph";
4
+ import { canonicalJson } from "@mark1russell7/rigor-generators";
5
+ // src/converter.ts
6
+ /** This function gives the amount of each resource that one run of a converter takes. Two lines of one resource add. */
7
+ function inputsOf(converter) {
8
+ const out = /* @__PURE__ */ new Map();
9
+ for (const input of converter.takes) if (input.amount > 0) out.set(input.resource, (out.get(input.resource) ?? 0) + input.amount);
10
+ return out;
11
+ }
12
+ /**
13
+ * This function tells if a converter is a source (M2-solar): it takes nothing, and it has a limit `perDay` more than 0.
14
+ * Its runs of a day are lost when no draw uses them. Thus a take uses a source before a store.
15
+ */
16
+ function isSource(converter) {
17
+ if (!(converter.perDay !== void 0 && converter.perDay > 0)) return false;
18
+ for (const input of converter.takes) if (input.amount > 0) return false;
19
+ return true;
20
+ }
21
+ /**
22
+ * This function tells if a converter can run in a case. Its device works, it takes a resource or it is a source, and it
23
+ * gives an amount more than 0.
24
+ */
25
+ function canRun(converter, stoppedParts) {
26
+ return converter.gives.amount > 0 && (inputsOf(converter).size > 0 || isSource(converter)) && (converter.device === void 0 || !stoppedParts.has(converter.device));
27
+ }
28
+ /**
29
+ * This function gives the key of the device-days that a converter uses. The converters of one device share one key.
30
+ * A converter with no device has a key of its own.
31
+ */
32
+ function deviceKey(converter) {
33
+ return converter.device === void 0 ? `converter:${converter.id}` : `device:${converter.device}`;
34
+ }
35
+ /** This function gives the need that a converter gives, or `undefined` when it gives a resource. */
36
+ function giftNeed(converter) {
37
+ return "need" in converter.gives ? converter.gives.need : void 0;
38
+ }
39
+ /** This function gives the resource that a converter gives, or `undefined` when it gives a need. */
40
+ function giftResource(converter) {
41
+ return "resource" in converter.gives ? converter.gives.resource : void 0;
42
+ }
43
+ /** This function gives the shares `monthly` of each device key of the converters with a limit and shares (M2-solar). */
44
+ function monthlyShares(converters) {
45
+ const out = /* @__PURE__ */ new Map();
46
+ for (const converter of converters) if (converter.monthly !== void 0 && converter.perDay !== void 0) out.set(deviceKey(converter), converter.monthly);
47
+ return out;
48
+ }
49
+ /** This function gives the share of the device-days of a key in a month: its share `monthly`, or 1. */
50
+ function shareOf(shares, key, month) {
51
+ return shares.get(key)?.[month] ?? 1;
52
+ }
53
+ // src/check.ts
54
+ /**
55
+ * These are the codes of the gate. Each code is an error, except `endurance-device-mix`, `endurance-no-way` and `endurance-cut-no-curve`, which are warnings.
56
+ *
57
+ * - `endurance-twice`: two or more records of one list have one key. A key is a level, a resource, a store, a need, a converter or a case.
58
+ * The key of a prior is its case and its place. A converter takes each resource on one line, and a case cuts each part one time.
59
+ * - `endurance-level-unknown`: the level of a draw is not a level of the layer.
60
+ * - `endurance-resource-unknown`: a store, a use or a converter names a resource that the layer does not have.
61
+ * - `endurance-part-unknown`: a supply, a device, the part of a store or a cut is not a part of the base stack.
62
+ * - `endurance-range`: an amount, a rate, a count or a factor is not a finite number of 0 or more. Or a reach is not from 0 to 1.
63
+ * - `endurance-date`: a date is not a date `YYYY-MM-DD`.
64
+ * - `endurance-converter-empty`: a converter takes nothing and has no limit `perDay` more than 0, or it gives an amount of 0.
65
+ * A converter with a limit can take nothing: it is a source, for example a solar panel. Since 0.8.20 (M2-solar).
66
+ * - `endurance-curve`: a survival curve does not start at `[0, 1]`, or it does not end at a chance of 0.
67
+ * Or its days do not increase, or its chance increases.
68
+ * Or the band or the counts of a cut do not agree with its curve (`bandFault`, `countsFault`), or the cut has them and no curve.
69
+ * - `endurance-bound`: the bound of a cut is not a value of `CUT_BOUNDS` of the core. Since 0.8.4.
70
+ * - `endurance-prior-case`: a prior names a case that the layer does not have.
71
+ * - `endurance-cycle`: converters make a resource from itself, through one converter or a chain. One fault names each cycle.
72
+ * - `endurance-devices`: two converters of one device give two different counts of devices.
73
+ * - `endurance-device-mix` (warning): a device has a converter with a limit `perDay` and a converter with no limit. The
74
+ * converter with no limit uses no device-days, so its runs do not reduce the runs of the limited converter.
75
+ * - `endurance-no-way` (warning): a draw has no direct use and no converter, so it holds 0 days when its supply stops.
76
+ * - `endurance-cut-no-curve` (warning): a cut has no curve of its duration. The draws whose stop it can be part of are no read in the shortfall.
77
+ * - `endurance-season`: the season of a converter has a day that is not `MM-DD`. Or its delay or its shelf life is not more than 0.
78
+ * Or its count of sowings is not a finite number of 0 or more. Or the converter with a season gives a need, or it has
79
+ * `perDay` or `devices`. Since 0.8.16 (M2-grow).
80
+ * - `endurance-monthly`: the shares `monthly` of a converter are not 12 numbers from 0 to 1. Or the converter has
81
+ * `monthly` and no `perDay`, or a season. Or two converters of one device have different shares. Since 0.8.20 (M2-solar).
82
+ * - `endurance-capacity`: the capacity of a store is not a finite number more than 0, or it is less than the amount.
83
+ * Or a store with a capacity has a due date. Or a resource has a store with a capacity and a store with no capacity.
84
+ * Since 0.8.21 (M2-solar-charge).
85
+ */
86
+ const ENDURANCE_CODES = [
87
+ "endurance-twice",
88
+ "endurance-level-unknown",
89
+ "endurance-resource-unknown",
90
+ "endurance-part-unknown",
91
+ "endurance-range",
92
+ "endurance-date",
93
+ "endurance-converter-empty",
94
+ "endurance-curve",
95
+ "endurance-bound",
96
+ "endurance-prior-case",
97
+ "endurance-cycle",
98
+ "endurance-devices",
99
+ "endurance-device-mix",
100
+ "endurance-no-way",
101
+ "endurance-cut-no-curve",
102
+ "endurance-season",
103
+ "endurance-monthly",
104
+ "endurance-capacity"
105
+ ];
106
+ /**
107
+ * This function gives each fault of an endurance layer. With a base stack, it also examines the `id` of each part. A list with no error tells that the gate passes.
108
+ *
109
+ * The faults are in the order of the layer. The function is pure.
110
+ *
111
+ * @param layer - The endurance layer
112
+ * @param stack - The base stack, with the layer. With no stack, the gate does not examine the parts.
113
+ * @returns The faults
114
+ */
115
+ function checkEndurance(layer, stack) {
116
+ const faults = [];
117
+ const add = (level, code, at, message) => {
118
+ faults.push({
119
+ level,
120
+ code,
121
+ at,
122
+ message
123
+ });
124
+ };
125
+ const once = (what, keys) => {
126
+ const seen = /* @__PURE__ */ new Set();
127
+ for (const key of keys) {
128
+ if (seen.has(key)) add("error", "endurance-twice", key, `Two or more ${what} have the key "${key}".`);
129
+ seen.add(key);
130
+ }
131
+ };
132
+ const range = (at, what, value) => {
133
+ if (!(Number.isFinite(value) && value >= 0)) add("error", "endurance-range", at, `The ${what} of "${at}" is ${String(value)}. It must be a finite number of 0 or more.`);
134
+ };
135
+ const date = (at, value) => {
136
+ if (dayNumber(value) === void 0) add("error", "endurance-date", at, `The date "${value}" of "${at}" is not a date YYYY-MM-DD.`);
137
+ };
138
+ const parts = stack === void 0 ? void 0 : new Set(stack.parts.map((part) => part.id));
139
+ const part = (at, what, id) => {
140
+ if (parts !== void 0 && id !== void 0 && !parts.has(id)) add("error", "endurance-part-unknown", at, `The ${what} "${id}" of "${at}" is not a part of the stack.`);
141
+ };
142
+ const resources = new Set(layer.resources.map((resource) => resource.code));
143
+ const resource = (at, code) => {
144
+ if (!resources.has(code)) add("error", "endurance-resource-unknown", at, `The resource "${code}" of "${at}" is not a resource of the layer.`);
145
+ };
146
+ const direct = layer.direct ?? [];
147
+ const converters = layer.converters ?? [];
148
+ const cases = layer.cases ?? [];
149
+ const priors = layer.priors ?? [];
150
+ once("levels", layer.levels);
151
+ once("resources", layer.resources.map((item) => item.code));
152
+ once("stores", layer.stores.map((store) => store.id));
153
+ once("draws", layer.draws.map((draw) => draw.need));
154
+ once("converters", converters.map((converter) => converter.id));
155
+ once("cases", cases.map((item) => item.case));
156
+ once("priors", priors.map((prior) => `${prior.case}@${prior.place}`));
157
+ for (const store of layer.stores) {
158
+ resource(store.id, store.resource);
159
+ range(store.id, "amount", store.amount);
160
+ if (store.due !== void 0) date(store.id, store.due);
161
+ part(store.id, "part", store.part);
162
+ if (store.capacity !== void 0) {
163
+ if (!(Number.isFinite(store.capacity) && store.capacity > 0 && store.capacity >= store.amount)) add("error", "endurance-capacity", store.id, `The capacity of "${store.id}" is ${String(store.capacity)}. It must be a finite number more than 0, and not less than the amount.`);
164
+ if (store.due !== void 0) add("error", "endurance-capacity", store.id, `The store "${store.id}" has a capacity and a due date. A store with a charge has no due date.`);
165
+ }
166
+ }
167
+ for (const code of new Set(layer.stores.map((store) => store.resource))) {
168
+ const all = layer.stores.filter((store) => store.resource === code);
169
+ const charged = all.filter((store) => store.capacity !== void 0);
170
+ if (charged.length > 0 && charged.length < all.length) add("error", "endurance-capacity", code, `The resource "${code}" has a store with a capacity and a store with no capacity. Its stores all have a capacity, or none has one.`);
171
+ }
172
+ const levels = new Set(layer.levels);
173
+ for (const draw of layer.draws) {
174
+ if (!levels.has(draw.level)) add("error", "endurance-level-unknown", draw.need, `The level "${draw.level}" of the draw "${draw.need}" is not a level of the layer.`);
175
+ range(draw.need, "rate", draw.perDay);
176
+ if (draw.users !== void 0) range(draw.need, "count of users", draw.users);
177
+ part(draw.need, "supply", draw.supply);
178
+ if (!(direct.some((use) => use.need === draw.need) || converters.some((converter) => giftNeed(converter) === draw.need))) add("warning", "endurance-no-way", draw.need, `The draw "${draw.need}" has no direct use and no converter. It holds 0 days when its supply stops.`);
179
+ }
180
+ for (const use of direct) {
181
+ const at = `${use.resource}>${use.need}`;
182
+ resource(at, use.resource);
183
+ range(at, "amount", use.amount);
184
+ }
185
+ for (const converter of converters) {
186
+ once(`resources of the converter "${converter.id}"`, converter.takes.map((input) => input.resource));
187
+ for (const input of converter.takes) {
188
+ resource(converter.id, input.resource);
189
+ range(converter.id, "amount", input.amount);
190
+ }
191
+ range(converter.id, "amount", converter.gives.amount);
192
+ const made = giftResource(converter);
193
+ if (made !== void 0) resource(converter.id, made);
194
+ if (!(converter.perDay !== void 0 && converter.perDay > 0) && !converter.takes.some((input) => input.amount > 0) || converter.gives.amount === 0) add("error", "endurance-converter-empty", converter.id, `The converter "${converter.id}" takes nothing, or it gives nothing.`);
195
+ part(converter.id, "device", converter.device);
196
+ if (converter.perDay !== void 0) range(converter.id, "rate perDay", converter.perDay);
197
+ if (converter.devices !== void 0 && !(Number.isSafeInteger(converter.devices) && converter.devices >= 1)) add("error", "endurance-range", converter.id, `The count of devices of "${converter.id}" is ${String(converter.devices)}. It must be a whole number of 1 or more.`);
198
+ if (converter.season !== void 0) for (const message of seasonFaults(converter)) add("error", "endurance-season", converter.id, message);
199
+ for (const message of monthlyFaults(converter)) add("error", "endurance-monthly", converter.id, message);
200
+ }
201
+ const shares = /* @__PURE__ */ new Map();
202
+ for (const converter of converters) {
203
+ if (converter.device === void 0 || converter.perDay === void 0) continue;
204
+ const seen = shares.get(converter.device);
205
+ if (seen === void 0) shares.set(converter.device, converter);
206
+ else if (!sameShares(seen.monthly, converter.monthly)) add("error", "endurance-monthly", converter.id, `The converter "${converter.id}" and the converter "${seen.id}" of the device "${converter.device}" have different shares monthly. The converters of one device have the same shares.`);
207
+ }
208
+ const counts = /* @__PURE__ */ new Map();
209
+ for (const converter of converters) {
210
+ if (converter.device === void 0) continue;
211
+ const count = converter.devices ?? 1;
212
+ const seen = counts.get(converter.device);
213
+ if (seen !== void 0 && seen !== count) add("error", "endurance-devices", converter.id, `The converter "${converter.id}" gives the count ${String(count)} for the device "${converter.device}". An other converter gives the count ${String(seen)}.`);
214
+ if (seen === void 0) counts.set(converter.device, count);
215
+ }
216
+ const mixed = /* @__PURE__ */ new Set();
217
+ for (const converter of converters) {
218
+ const device = converter.device;
219
+ if (device === void 0 || converter.perDay !== void 0 || mixed.has(device)) continue;
220
+ const limited = converters.find((other) => other.device === device && other.perDay !== void 0);
221
+ if (limited === void 0) continue;
222
+ mixed.add(device);
223
+ add("warning", "endurance-device-mix", converter.id, `The device "${device}" has the limited converter "${limited.id}" and the converter "${converter.id}" with no limit. "${converter.id}" uses no device-days.`);
224
+ }
225
+ const caseCodes = new Set(cases.map((item) => item.case));
226
+ for (const item of cases) {
227
+ once(`cuts of the case "${item.case}"`, item.cuts.map((cut) => cut.part));
228
+ for (const cut of item.cuts) {
229
+ const at = `${item.case}/${cut.part}`;
230
+ part(at, "cut", cut.part);
231
+ if (cut.bound !== void 0 && !isCutBound(cut.bound)) add("error", "endurance-bound", at, `The bound of the cut "${at}" is ${JSON.stringify(cut.bound)}. It must be one of ${CUT_BOUNDS.join(", ")}.`);
232
+ if (cut.duration === void 0) {
233
+ add("warning", "endurance-cut-no-curve", at, `The cut "${at}" has no curve of its duration, so the draws that it can stop are no read.`);
234
+ if (cut.band !== void 0) add("error", "endurance-curve", at, `The cut "${at}" has a band and no curve of its duration.`);
235
+ if (cut.counts !== void 0) add("error", "endurance-curve", at, `The cut "${at}" has counts and no curve of its duration.`);
236
+ continue;
237
+ }
238
+ const fault = curveFault$1(cut.duration);
239
+ if (fault !== void 0) add("error", "endurance-curve", at, `The duration of the cut "${at}": ${fault}`);
240
+ const band = cut.band === void 0 || fault !== void 0 ? void 0 : bandFault(cut.duration, cut.band);
241
+ if (band !== void 0) add("error", "endurance-curve", at, `The band of the cut "${at}": ${band}`);
242
+ const counts = cut.counts === void 0 || fault !== void 0 ? void 0 : countsFault(cut.duration, cut.counts);
243
+ if (counts !== void 0) add("error", "endurance-curve", at, `The counts of the cut "${at}": ${counts}`);
244
+ }
245
+ for (const [need, factor] of Object.entries(item.factors ?? {})) range(`${item.case}/${need}`, "factor", factor);
246
+ if (item.leadSeconds !== void 0) range(item.case, "lead time", item.leadSeconds);
247
+ }
248
+ for (const cycle of resourceCycles(converters)) {
249
+ const [first = ""] = cycle;
250
+ const names = cycle.map((code) => `"${code}"`).join(", ");
251
+ add("error", "endurance-cycle", first, `${cycle.length === 1 ? `A converter makes the resource ${names} from itself.` : `Converters make the resources ${names} from each other.`} A chain of converters cannot end.`);
252
+ }
253
+ for (const prior of priors) {
254
+ const at = `${prior.case}@${prior.place}`;
255
+ if (!caseCodes.has(prior.case)) add("error", "endurance-prior-case", at, `The prior "${at}" names the case "${prior.case}", which the layer does not have.`);
256
+ range(at, "count of events in one year", prior.perYear);
257
+ if (!(prior.reach >= 0 && prior.reach <= 1)) add("error", "endurance-range", at, `The reach of "${at}" is ${String(prior.reach)}. It must be from 0 to 1.`);
258
+ date(at, prior.asOf);
259
+ const fault = prior.interval === void 0 ? void 0 : intervalFault(prior.interval);
260
+ if (fault !== void 0) add("error", "endurance-range", at, `The interval of the count of events in one year of "${at}" is not valid. ${fault}`);
261
+ }
262
+ return faults;
263
+ }
264
+ /** This function tells if a text is a day `MM-DD` of a leap year. */
265
+ function isMonthDay(value) {
266
+ return /^\d{2}-\d{2}$/.test(value) && dayNumber(`2000-${value}`) !== void 0;
267
+ }
268
+ /** This function gives the messages of the faults of the season of a converter. */
269
+ function seasonFaults(converter) {
270
+ const season = converter.season;
271
+ if (season === void 0) return [];
272
+ const out = [];
273
+ for (const day of [season.from, season.to]) if (!isMonthDay(day)) out.push(`The season of "${converter.id}" has the day "${day}". It is not a day MM-DD.`);
274
+ if (!(Number.isFinite(season.delayDays) && season.delayDays > 0)) out.push(`The delay of the season of "${converter.id}" is ${String(season.delayDays)}. It must be a finite number of days more than 0.`);
275
+ if (season.shelfDays !== void 0 && !(Number.isFinite(season.shelfDays) && season.shelfDays > 0)) out.push(`The shelf life of the season of "${converter.id}" is ${String(season.shelfDays)}. It must be a finite number of days more than 0.`);
276
+ if (!(Number.isFinite(season.runs) && season.runs >= 0)) out.push(`The runs of the season of "${converter.id}" are ${String(season.runs)}. They must be a finite number of 0 or more.`);
277
+ if (giftResource(converter) === void 0) out.push(`The converter "${converter.id}" has a season and gives a need. A converter with a season gives a resource.`);
278
+ if (converter.perDay !== void 0 || converter.devices !== void 0) out.push(`The converter "${converter.id}" has a season and a limit perDay or devices. A converter with a season has no such limit.`);
279
+ return out;
280
+ }
281
+ /** This function gives the messages of the faults of the shares `monthly` of a converter (M2-solar). */
282
+ function monthlyFaults(converter) {
283
+ const monthly = converter.monthly;
284
+ if (monthly === void 0) return [];
285
+ const out = [];
286
+ if (monthly.length !== 12 || !monthly.every((share) => Number.isFinite(share) && share >= 0 && share <= 1)) out.push(`The shares monthly of "${converter.id}" are not 12 numbers from 0 to 1.`);
287
+ if (converter.perDay === void 0) out.push(`The converter "${converter.id}" has shares monthly and no limit perDay. The shares are parts of the limit.`);
288
+ if (converter.season !== void 0) out.push(`The converter "${converter.id}" has shares monthly and a season. A converter has one or the other.`);
289
+ return out;
290
+ }
291
+ /** This function tells if two lists of shares `monthly` are equal. No list is equal to a list of 12 ones. */
292
+ function sameShares(a, b) {
293
+ const full = (shares) => shares ?? Array.from({ length: 12 }, () => 1);
294
+ const left = full(a);
295
+ const right = full(b);
296
+ return left.length === right.length && left.every((share, index) => share === right[index]);
297
+ }
298
+ /**
299
+ * This function gives each cycle of resources: a resource is made from a resource that a converter makes from it. Each cycle is a list of codes.
300
+ * A converter with a season is not part of a cycle: its harvest comes after its sowing, thus a chain of it ends.
301
+ */
302
+ function resourceCycles(converters) {
303
+ const from = /* @__PURE__ */ new Map();
304
+ for (const converter of converters) {
305
+ const made = giftResource(converter);
306
+ if (made === void 0 || converter.season !== void 0) continue;
307
+ const inputs = from.get(made) ?? /* @__PURE__ */ new Set();
308
+ for (const input of converter.takes) if (input.amount > 0) inputs.add(input.resource);
309
+ from.set(made, inputs);
310
+ }
311
+ const successors = (code) => from.get(code) ?? [];
312
+ return stronglyConnectedComponents(from.keys(), successors).filter((component) => {
313
+ const [only = ""] = component;
314
+ return component.length > 1 || (from.get(only)?.has(only) ?? false);
315
+ });
316
+ }
317
+ /** This function tells if a list of faults has an error. */
318
+ function hasEnduranceError(faults) {
319
+ return faults.some((fault) => fault.level === "error");
320
+ }
321
+ // src/join.ts
322
+ /**
323
+ * This function joins the endurance layers of the fragments of a stack into one layer.
324
+ *
325
+ * - The levels are one setting: each fragment that has levels gives the same list, else the join has a fault.
326
+ * - The records of each list are in the order of the fragments.
327
+ * - Two resources with one code in two fragments join into one resource when their records are equal. A different field is a fault.
328
+ * Its message gives the canonical JSON of the record of each fragment.
329
+ * - A code that one fragment has two times stays in the joined layer. The gate `checkEndurance` finds it.
330
+ * - One key of each other list in two or more fragments is a fault, also when the records are equal.
331
+ * - The key of a direct use is its resource and its need.
332
+ *
333
+ * The function is pure, and it changes no layer. The gate `checkEndurance` examines the joined layer afterward.
334
+ *
335
+ * @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.
336
+ * @returns The joined layer, or the faults of the join.
337
+ */
338
+ function joinEndurance(pieces) {
339
+ const levels = joinSetting(pieces, (layer) => layer.levels.length > 0 ? layer.levels.join("\n") : void 0, "levels");
340
+ const resources = joinRecords(pieces, (layer) => layer.resources, (item) => item.code, "resource", {
341
+ equal: (first, other) => canonicalJson(first) === canonicalJson(other),
342
+ text: canonicalJson
343
+ });
344
+ const stores = joinRecords(pieces, (layer) => layer.stores, (item) => item.id, "store");
345
+ const draws = joinRecords(pieces, (layer) => layer.draws, (item) => item.need, "draw");
346
+ const direct = joinRecords(pieces, (layer) => layer.direct, (item) => `${item.resource}>${item.need}`, "direct use");
347
+ const converters = joinRecords(pieces, (layer) => layer.converters, (item) => item.id, "converter");
348
+ const cases = joinRecords(pieces, (layer) => layer.cases, (item) => item.case, "case");
349
+ const priors = joinRecords(pieces, (layer) => layer.priors, (item) => `${item.case}@${item.place}`, "prior");
350
+ const errors = [
351
+ levels,
352
+ resources,
353
+ stores,
354
+ draws,
355
+ direct,
356
+ converters,
357
+ cases,
358
+ priors
359
+ ].flatMap((join) => join.errors);
360
+ if (errors.length > 0) return {
361
+ ok: false,
362
+ errors
363
+ };
364
+ const has = (key) => pieces.some((piece) => piece.layer[key] !== void 0);
365
+ return {
366
+ ok: true,
367
+ layer: {
368
+ schema: ENDURANCE_SCHEMA,
369
+ levels: levels.value === void 0 ? [] : levels.value.split("\n"),
370
+ resources: resources.items,
371
+ stores: stores.items,
372
+ draws: draws.items,
373
+ ...has("direct") ? { direct: direct.items } : {},
374
+ ...has("converters") ? { converters: converters.items } : {},
375
+ ...has("cases") ? { cases: cases.items } : {},
376
+ ...has("priors") ? { priors: priors.items } : {}
377
+ }
378
+ };
379
+ }
380
+ export { hasEnduranceError as a, giftNeed as c, isSource as d, monthlyShares as f, curveFault as i, giftResource as l, ENDURANCE_CODES as n, canRun as o, shareOf as p, checkEndurance as r, deviceKey as s, joinEndurance as t, inputsOf as u };
381
+
382
+ //# sourceMappingURL=join-NN0eFb6s.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join-NN0eFb6s.js","names":["curveFault"],"sources":["../src/converter.ts","../src/check.ts","../src/join.ts"],"sourcesContent":["import type { Converter } from \"./layer.ts\";\n\n// The internal rules of a converter that the endurance query and the joint days share. The root entry does not give them.\n\n/** This function gives the amount of each resource that one run of a converter takes. Two lines of one resource add. */\nexport function inputsOf(converter: Converter): Map<string, number> {\n const out = new Map<string, number>();\n for (const input of converter.takes) if (input.amount > 0) out.set(input.resource, (out.get(input.resource) ?? 0) + input.amount);\n return out;\n}\n\n/**\n * This function tells if a converter is a source (M2-solar): it takes nothing, and it has a limit `perDay` more than 0.\n * Its runs of a day are lost when no draw uses them. Thus a take uses a source before a store.\n */\nexport function isSource(converter: Converter): boolean {\n if (!(converter.perDay !== undefined && converter.perDay > 0)) return false;\n // The same test as `inputsOf(converter).size === 0`, with no map: the take loops call it.\n for (const input of converter.takes) if (input.amount > 0) return false;\n return true;\n}\n\n/**\n * This function tells if a converter can run in a case. Its device works, it takes a resource or it is a source, and it\n * gives an amount more than 0.\n */\nexport function canRun(converter: Converter, stoppedParts: ReadonlySet<string>): boolean {\n return converter.gives.amount > 0 && (inputsOf(converter).size > 0 || isSource(converter)) && (converter.device === undefined || !stoppedParts.has(converter.device));\n}\n\n/**\n * This function gives the key of the device-days that a converter uses. The converters of one device share one key.\n * A converter with no device has a key of its own.\n */\nexport function deviceKey(converter: Converter): string {\n return converter.device === undefined ? `converter:${converter.id}` : `device:${converter.device}`;\n}\n\n/** This function gives the need that a converter gives, or `undefined` when it gives a resource. */\nexport function giftNeed(converter: Converter): string | undefined {\n return \"need\" in converter.gives ? converter.gives.need : undefined;\n}\n\n/** This function gives the resource that a converter gives, or `undefined` when it gives a need. */\nexport function giftResource(converter: Converter): string | undefined {\n return \"resource\" in converter.gives ? converter.gives.resource : undefined;\n}\n\n/** This function gives the shares `monthly` of each device key of the converters with a limit and shares (M2-solar). */\nexport function monthlyShares(converters: Iterable<Converter>): Map<string, readonly number[]> {\n const out = new Map<string, readonly number[]>();\n for (const converter of converters) if (converter.monthly !== undefined && converter.perDay !== undefined) out.set(deviceKey(converter), converter.monthly);\n return out;\n}\n\n/** This function gives the share of the device-days of a key in a month: its share `monthly`, or 1. */\nexport function shareOf(shares: ReadonlyMap<string, readonly number[]>, key: string, month: number): number {\n return shares.get(key)?.[month] ?? 1;\n}\n","import { stronglyConnectedComponents } from \"@mark1russell7/collections/graph\";\nimport { bandFault, countsFault, CUT_BOUNDS, curveFault, dayNumber, intervalFault, isCutBound, type Fault, type Stack } from \"@mark1russell7/system-stack\";\nimport { giftNeed, giftResource } from \"./converter.ts\";\nimport type { Converter, EnduranceLayer } from \"./layer.ts\";\n\n// The gate of an endurance layer: the meaning of a layer with a correct form, for its base stack.\n\n/**\n * These are the codes of the gate. Each code is an error, except `endurance-device-mix`, `endurance-no-way` and `endurance-cut-no-curve`, which are warnings.\n *\n * - `endurance-twice`: two or more records of one list have one key. A key is a level, a resource, a store, a need, a converter or a case.\n * The key of a prior is its case and its place. A converter takes each resource on one line, and a case cuts each part one time.\n * - `endurance-level-unknown`: the level of a draw is not a level of the layer.\n * - `endurance-resource-unknown`: a store, a use or a converter names a resource that the layer does not have.\n * - `endurance-part-unknown`: a supply, a device, the part of a store or a cut is not a part of the base stack.\n * - `endurance-range`: an amount, a rate, a count or a factor is not a finite number of 0 or more. Or a reach is not from 0 to 1.\n * - `endurance-date`: a date is not a date `YYYY-MM-DD`.\n * - `endurance-converter-empty`: a converter takes nothing and has no limit `perDay` more than 0, or it gives an amount of 0.\n * A converter with a limit can take nothing: it is a source, for example a solar panel. Since 0.8.20 (M2-solar).\n * - `endurance-curve`: a survival curve does not start at `[0, 1]`, or it does not end at a chance of 0.\n * Or its days do not increase, or its chance increases.\n * Or the band or the counts of a cut do not agree with its curve (`bandFault`, `countsFault`), or the cut has them and no curve.\n * - `endurance-bound`: the bound of a cut is not a value of `CUT_BOUNDS` of the core. Since 0.8.4.\n * - `endurance-prior-case`: a prior names a case that the layer does not have.\n * - `endurance-cycle`: converters make a resource from itself, through one converter or a chain. One fault names each cycle.\n * - `endurance-devices`: two converters of one device give two different counts of devices.\n * - `endurance-device-mix` (warning): a device has a converter with a limit `perDay` and a converter with no limit. The\n * converter with no limit uses no device-days, so its runs do not reduce the runs of the limited converter.\n * - `endurance-no-way` (warning): a draw has no direct use and no converter, so it holds 0 days when its supply stops.\n * - `endurance-cut-no-curve` (warning): a cut has no curve of its duration. The draws whose stop it can be part of are no read in the shortfall.\n * - `endurance-season`: the season of a converter has a day that is not `MM-DD`. Or its delay or its shelf life is not more than 0.\n * Or its count of sowings is not a finite number of 0 or more. Or the converter with a season gives a need, or it has\n * `perDay` or `devices`. Since 0.8.16 (M2-grow).\n * - `endurance-monthly`: the shares `monthly` of a converter are not 12 numbers from 0 to 1. Or the converter has\n * `monthly` and no `perDay`, or a season. Or two converters of one device have different shares. Since 0.8.20 (M2-solar).\n * - `endurance-capacity`: the capacity of a store is not a finite number more than 0, or it is less than the amount.\n * Or a store with a capacity has a due date. Or a resource has a store with a capacity and a store with no capacity.\n * Since 0.8.21 (M2-solar-charge).\n */\nexport const ENDURANCE_CODES: readonly [\n \"endurance-twice\",\n \"endurance-level-unknown\",\n \"endurance-resource-unknown\",\n \"endurance-part-unknown\",\n \"endurance-range\",\n \"endurance-date\",\n \"endurance-converter-empty\",\n \"endurance-curve\",\n \"endurance-bound\",\n \"endurance-prior-case\",\n \"endurance-cycle\",\n \"endurance-devices\",\n \"endurance-device-mix\",\n \"endurance-no-way\",\n \"endurance-cut-no-curve\",\n \"endurance-season\",\n \"endurance-monthly\",\n \"endurance-capacity\",\n] = [\n \"endurance-twice\",\n \"endurance-level-unknown\",\n \"endurance-resource-unknown\",\n \"endurance-part-unknown\",\n \"endurance-range\",\n \"endurance-date\",\n \"endurance-converter-empty\",\n \"endurance-curve\",\n \"endurance-bound\",\n \"endurance-prior-case\",\n \"endurance-cycle\",\n \"endurance-devices\",\n \"endurance-device-mix\",\n \"endurance-no-way\",\n \"endurance-cut-no-curve\",\n \"endurance-season\",\n \"endurance-monthly\",\n \"endurance-capacity\",\n];\n\n/** A code of `ENDURANCE_CODES`. */\nexport type EnduranceCode = (typeof ENDURANCE_CODES)[number];\n\n/** A fault of the gate of an endurance layer. */\nexport interface EnduranceFault extends Fault {\n readonly code: EnduranceCode;\n}\n\nexport { curveFault } from \"@mark1russell7/system-stack\";\n\n/**\n * This function gives each fault of an endurance layer. With a base stack, it also examines the `id` of each part. A list with no error tells that the gate passes.\n *\n * The faults are in the order of the layer. The function is pure.\n *\n * @param layer - The endurance layer\n * @param stack - The base stack, with the layer. With no stack, the gate does not examine the parts.\n * @returns The faults\n */\nexport function checkEndurance(layer: EnduranceLayer, stack?: Stack): EnduranceFault[] {\n const faults: EnduranceFault[] = [];\n const add = (level: EnduranceFault[\"level\"], code: EnduranceCode, at: string, message: string): void => {\n faults.push({ level, code, at, message });\n };\n const once = (what: string, keys: readonly string[]): void => {\n const seen = new Set<string>();\n for (const key of keys) {\n if (seen.has(key)) add(\"error\", \"endurance-twice\", key, `Two or more ${what} have the key \"${key}\".`);\n seen.add(key);\n }\n };\n const range = (at: string, what: string, value: number): void => {\n if (!(Number.isFinite(value) && value >= 0)) add(\"error\", \"endurance-range\", at, `The ${what} of \"${at}\" is ${String(value)}. It must be a finite number of 0 or more.`);\n };\n const date = (at: string, value: string): void => {\n if (dayNumber(value) === undefined) add(\"error\", \"endurance-date\", at, `The date \"${value}\" of \"${at}\" is not a date YYYY-MM-DD.`);\n };\n const parts = stack === undefined ? undefined : new Set(stack.parts.map((part) => part.id));\n const part = (at: string, what: string, id: string | undefined): void => {\n if (parts !== undefined && id !== undefined && !parts.has(id)) add(\"error\", \"endurance-part-unknown\", at, `The ${what} \"${id}\" of \"${at}\" is not a part of the stack.`);\n };\n const resources = new Set(layer.resources.map((resource) => resource.code));\n const resource = (at: string, code: string): void => {\n if (!resources.has(code)) add(\"error\", \"endurance-resource-unknown\", at, `The resource \"${code}\" of \"${at}\" is not a resource of the layer.`);\n };\n const direct = layer.direct ?? [];\n const converters = layer.converters ?? [];\n const cases = layer.cases ?? [];\n const priors = layer.priors ?? [];\n\n once(\"levels\", layer.levels);\n once(\"resources\", layer.resources.map((item) => item.code));\n once(\"stores\", layer.stores.map((store) => store.id));\n once(\"draws\", layer.draws.map((draw) => draw.need));\n once(\"converters\", converters.map((converter) => converter.id));\n once(\"cases\", cases.map((item) => item.case));\n once(\"priors\", priors.map((prior) => `${prior.case}@${prior.place}`));\n\n for (const store of layer.stores) {\n resource(store.id, store.resource);\n range(store.id, \"amount\", store.amount);\n if (store.due !== undefined) date(store.id, store.due);\n part(store.id, \"part\", store.part);\n if (store.capacity !== undefined) {\n if (!(Number.isFinite(store.capacity) && store.capacity > 0 && store.capacity >= store.amount)) {\n add(\"error\", \"endurance-capacity\", store.id, `The capacity of \"${store.id}\" is ${String(store.capacity)}. It must be a finite number more than 0, and not less than the amount.`);\n }\n if (store.due !== undefined) add(\"error\", \"endurance-capacity\", store.id, `The store \"${store.id}\" has a capacity and a due date. A store with a charge has no due date.`);\n }\n }\n for (const code of new Set(layer.stores.map((store) => store.resource))) {\n const all = layer.stores.filter((store) => store.resource === code);\n const charged = all.filter((store) => store.capacity !== undefined);\n if (charged.length > 0 && charged.length < all.length) {\n add(\"error\", \"endurance-capacity\", code, `The resource \"${code}\" has a store with a capacity and a store with no capacity. Its stores all have a capacity, or none has one.`);\n }\n }\n const levels = new Set(layer.levels);\n for (const draw of layer.draws) {\n if (!levels.has(draw.level)) add(\"error\", \"endurance-level-unknown\", draw.need, `The level \"${draw.level}\" of the draw \"${draw.need}\" is not a level of the layer.`);\n range(draw.need, \"rate\", draw.perDay);\n if (draw.users !== undefined) range(draw.need, \"count of users\", draw.users);\n part(draw.need, \"supply\", draw.supply);\n const ways = direct.some((use) => use.need === draw.need) || converters.some((converter) => giftNeed(converter) === draw.need);\n if (!ways) add(\"warning\", \"endurance-no-way\", draw.need, `The draw \"${draw.need}\" has no direct use and no converter. It holds 0 days when its supply stops.`);\n }\n for (const use of direct) {\n const at = `${use.resource}>${use.need}`;\n resource(at, use.resource);\n range(at, \"amount\", use.amount);\n }\n for (const converter of converters) {\n once(`resources of the converter \"${converter.id}\"`, converter.takes.map((input) => input.resource));\n for (const input of converter.takes) {\n resource(converter.id, input.resource);\n range(converter.id, \"amount\", input.amount);\n }\n range(converter.id, \"amount\", converter.gives.amount);\n const made = giftResource(converter);\n if (made !== undefined) resource(converter.id, made);\n const source = converter.perDay !== undefined && converter.perDay > 0;\n if ((!source && !converter.takes.some((input) => input.amount > 0)) || converter.gives.amount === 0) add(\"error\", \"endurance-converter-empty\", converter.id, `The converter \"${converter.id}\" takes nothing, or it gives nothing.`);\n part(converter.id, \"device\", converter.device);\n if (converter.perDay !== undefined) range(converter.id, \"rate perDay\", converter.perDay);\n if (converter.devices !== undefined && !(Number.isSafeInteger(converter.devices) && converter.devices >= 1))\n add(\"error\", \"endurance-range\", converter.id, `The count of devices of \"${converter.id}\" is ${String(converter.devices)}. It must be a whole number of 1 or more.`);\n if (converter.season !== undefined) for (const message of seasonFaults(converter)) add(\"error\", \"endurance-season\", converter.id, message);\n for (const message of monthlyFaults(converter)) add(\"error\", \"endurance-monthly\", converter.id, message);\n }\n const shares = new Map<string, Converter>();\n for (const converter of converters) {\n if (converter.device === undefined || converter.perDay === undefined) continue;\n const seen = shares.get(converter.device);\n if (seen === undefined) shares.set(converter.device, converter);\n else if (!sameShares(seen.monthly, converter.monthly))\n add(\"error\", \"endurance-monthly\", converter.id, `The converter \"${converter.id}\" and the converter \"${seen.id}\" of the device \"${converter.device}\" have different shares monthly. The converters of one device have the same shares.`);\n }\n const counts = new Map<string, number>();\n for (const converter of converters) {\n if (converter.device === undefined) continue;\n const count = converter.devices ?? 1;\n const seen = counts.get(converter.device);\n if (seen !== undefined && seen !== count)\n add(\"error\", \"endurance-devices\", converter.id, `The converter \"${converter.id}\" gives the count ${String(count)} for the device \"${converter.device}\". An other converter gives the count ${String(seen)}.`);\n if (seen === undefined) counts.set(converter.device, count);\n }\n // One fault names each device with a limited converter and a converter with no limit, at the first converter with no limit.\n const mixed = new Set<string>();\n for (const converter of converters) {\n const device = converter.device;\n if (device === undefined || converter.perDay !== undefined || mixed.has(device)) continue;\n const limited = converters.find((other) => other.device === device && other.perDay !== undefined);\n if (limited === undefined) continue;\n mixed.add(device);\n add(\"warning\", \"endurance-device-mix\", converter.id, `The device \"${device}\" has the limited converter \"${limited.id}\" and the converter \"${converter.id}\" with no limit. \"${converter.id}\" uses no device-days.`);\n }\n const caseCodes = new Set(cases.map((item) => item.case));\n for (const item of cases) {\n once(`cuts of the case \"${item.case}\"`, item.cuts.map((cut) => cut.part));\n for (const cut of item.cuts) {\n const at = `${item.case}/${cut.part}`;\n part(at, \"cut\", cut.part);\n if (cut.bound !== undefined && !isCutBound(cut.bound))\n add(\"error\", \"endurance-bound\", at, `The bound of the cut \"${at}\" is ${JSON.stringify(cut.bound)}. It must be one of ${CUT_BOUNDS.join(\", \")}.`);\n if (cut.duration === undefined) {\n add(\"warning\", \"endurance-cut-no-curve\", at, `The cut \"${at}\" has no curve of its duration, so the draws that it can stop are no read.`);\n if (cut.band !== undefined) add(\"error\", \"endurance-curve\", at, `The cut \"${at}\" has a band and no curve of its duration.`);\n if (cut.counts !== undefined) add(\"error\", \"endurance-curve\", at, `The cut \"${at}\" has counts and no curve of its duration.`);\n continue;\n }\n const fault = curveFault(cut.duration);\n if (fault !== undefined) add(\"error\", \"endurance-curve\", at, `The duration of the cut \"${at}\": ${fault}`);\n const band = cut.band === undefined || fault !== undefined ? undefined : bandFault(cut.duration, cut.band);\n if (band !== undefined) add(\"error\", \"endurance-curve\", at, `The band of the cut \"${at}\": ${band}`);\n const counts = cut.counts === undefined || fault !== undefined ? undefined : countsFault(cut.duration, cut.counts);\n if (counts !== undefined) add(\"error\", \"endurance-curve\", at, `The counts of the cut \"${at}\": ${counts}`);\n }\n for (const [need, factor] of Object.entries(item.factors ?? {})) range(`${item.case}/${need}`, \"factor\", factor);\n if (item.leadSeconds !== undefined) range(item.case, \"lead time\", item.leadSeconds);\n }\n for (const cycle of resourceCycles(converters)) {\n const [first = \"\"] = cycle;\n const names = cycle.map((code) => `\"${code}\"`).join(\", \");\n const message = cycle.length === 1 ? `A converter makes the resource ${names} from itself.` : `Converters make the resources ${names} from each other.`;\n add(\"error\", \"endurance-cycle\", first, `${message} A chain of converters cannot end.`);\n }\n for (const prior of priors) {\n const at = `${prior.case}@${prior.place}`;\n if (!caseCodes.has(prior.case)) add(\"error\", \"endurance-prior-case\", at, `The prior \"${at}\" names the case \"${prior.case}\", which the layer does not have.`);\n range(at, \"count of events in one year\", prior.perYear);\n if (!(prior.reach >= 0 && prior.reach <= 1)) add(\"error\", \"endurance-range\", at, `The reach of \"${at}\" is ${String(prior.reach)}. It must be from 0 to 1.`);\n date(at, prior.asOf);\n const fault = prior.interval === undefined ? undefined : intervalFault(prior.interval);\n if (fault !== undefined) add(\"error\", \"endurance-range\", at, `The interval of the count of events in one year of \"${at}\" is not valid. ${fault}`);\n }\n return faults;\n}\n\n/** This function tells if a text is a day `MM-DD` of a leap year. */\nfunction isMonthDay(value: string): boolean {\n return /^\\d{2}-\\d{2}$/.test(value) && dayNumber(`2000-${value}`) !== undefined;\n}\n\n/** This function gives the messages of the faults of the season of a converter. */\nfunction seasonFaults(converter: Converter): string[] {\n const season = converter.season;\n if (season === undefined) return [];\n const out: string[] = [];\n for (const day of [season.from, season.to]) if (!isMonthDay(day)) out.push(`The season of \"${converter.id}\" has the day \"${day}\". It is not a day MM-DD.`);\n if (!(Number.isFinite(season.delayDays) && season.delayDays > 0)) out.push(`The delay of the season of \"${converter.id}\" is ${String(season.delayDays)}. It must be a finite number of days more than 0.`);\n if (season.shelfDays !== undefined && !(Number.isFinite(season.shelfDays) && season.shelfDays > 0)) out.push(`The shelf life of the season of \"${converter.id}\" is ${String(season.shelfDays)}. It must be a finite number of days more than 0.`);\n if (!(Number.isFinite(season.runs) && season.runs >= 0)) out.push(`The runs of the season of \"${converter.id}\" are ${String(season.runs)}. They must be a finite number of 0 or more.`);\n if (giftResource(converter) === undefined) out.push(`The converter \"${converter.id}\" has a season and gives a need. A converter with a season gives a resource.`);\n if (converter.perDay !== undefined || converter.devices !== undefined) out.push(`The converter \"${converter.id}\" has a season and a limit perDay or devices. A converter with a season has no such limit.`);\n return out;\n}\n\n/** This function gives the messages of the faults of the shares `monthly` of a converter (M2-solar). */\nfunction monthlyFaults(converter: Converter): string[] {\n const monthly = converter.monthly;\n if (monthly === undefined) return [];\n const out: string[] = [];\n if (monthly.length !== 12 || !monthly.every((share) => Number.isFinite(share) && share >= 0 && share <= 1))\n out.push(`The shares monthly of \"${converter.id}\" are not 12 numbers from 0 to 1.`);\n if (converter.perDay === undefined) out.push(`The converter \"${converter.id}\" has shares monthly and no limit perDay. The shares are parts of the limit.`);\n if (converter.season !== undefined) out.push(`The converter \"${converter.id}\" has shares monthly and a season. A converter has one or the other.`);\n return out;\n}\n\n/** This function tells if two lists of shares `monthly` are equal. No list is equal to a list of 12 ones. */\nfunction sameShares(a: readonly number[] | undefined, b: readonly number[] | undefined): boolean {\n const full = (shares: readonly number[] | undefined): readonly number[] => shares ?? Array.from({ length: 12 }, () => 1);\n const left = full(a);\n const right = full(b);\n return left.length === right.length && left.every((share, index) => share === right[index]);\n}\n\n/**\n * This function gives each cycle of resources: a resource is made from a resource that a converter makes from it. Each cycle is a list of codes.\n * A converter with a season is not part of a cycle: its harvest comes after its sowing, thus a chain of it ends.\n */\nfunction resourceCycles(converters: readonly Converter[]): string[][] {\n const from = new Map<string, Set<string>>();\n for (const converter of converters) {\n const made = giftResource(converter);\n if (made === undefined || converter.season !== undefined) continue;\n const inputs = from.get(made) ?? new Set<string>();\n for (const input of converter.takes) if (input.amount > 0) inputs.add(input.resource);\n from.set(made, inputs);\n }\n const successors = (code: string): Iterable<string> => from.get(code) ?? [];\n return stronglyConnectedComponents(from.keys(), successors).filter((component) => {\n const [only = \"\"] = component;\n return component.length > 1 || (from.get(only)?.has(only) ?? false);\n });\n}\n\n/** This function tells if a list of faults has an error. */\nexport function hasEnduranceError(faults: readonly EnduranceFault[]): boolean {\n return faults.some((fault) => fault.level === \"error\");\n}\n","import { canonicalJson } from \"@mark1russell7/rigor-generators\";\nimport { joinRecords, joinSetting, type LayerParse, type LayerPiece } from \"@mark1russell7/system-stack\";\nimport { ENDURANCE_SCHEMA, type EnduranceLayer } from \"./layer.ts\";\n\n// The join of the endurance layers of the fragments of a stack, for example one file of stores for each owner.\n\n/**\n * This function joins the endurance layers of the fragments of a stack into one layer.\n *\n * - The levels are one setting: each fragment that has levels gives the same list, else the join has a fault.\n * - The records of each list are in the order of the fragments.\n * - Two resources with one code in two fragments join into one resource when their records are equal. A different field is a fault.\n * Its message gives the canonical JSON of the record of each fragment.\n * - A code that one fragment has two times stays in the joined layer. The gate `checkEndurance` finds it.\n * - One key of each other list in two or more fragments is a fault, also when the records are equal.\n * - The key of a direct use is its resource and its need.\n *\n * The function is pure, and it changes no layer. The gate `checkEndurance` examines the joined layer afterward.\n *\n * @param pieces - The layers, with the name of the fragment of each one, in the order of the fragments.\n * @returns The joined layer, or the faults of the join.\n */\nexport function joinEndurance(pieces: readonly LayerPiece<EnduranceLayer>[]): LayerParse<EnduranceLayer> {\n const levels = joinSetting(pieces, (layer) => (layer.levels.length > 0 ? layer.levels.join(\"\\n\") : undefined), \"levels\");\n // Two fragments can declare one resource, for example `water.stored` in `L`. Canonical JSON (RFC 8785) compares the records,\n // so the order of the keys has no effect. The message of a fault gives the canonical JSON of the record of each fragment.\n const resources = joinRecords(pieces, (layer) => layer.resources, (item) => item.code, \"resource\", {\n equal: (first, other) => canonicalJson(first) === canonicalJson(other),\n text: canonicalJson,\n });\n const stores = joinRecords(pieces, (layer) => layer.stores, (item) => item.id, \"store\");\n const draws = joinRecords(pieces, (layer) => layer.draws, (item) => item.need, \"draw\");\n const direct = joinRecords(pieces, (layer) => layer.direct, (item) => `${item.resource}>${item.need}`, \"direct use\");\n const converters = joinRecords(pieces, (layer) => layer.converters, (item) => item.id, \"converter\");\n const cases = joinRecords(pieces, (layer) => layer.cases, (item) => item.case, \"case\");\n const priors = joinRecords(pieces, (layer) => layer.priors, (item) => `${item.case}@${item.place}`, \"prior\");\n const errors = [levels, resources, stores, draws, direct, converters, cases, priors].flatMap((join) => join.errors);\n if (errors.length > 0) return { ok: false, errors };\n const has = (key: \"direct\" | \"converters\" | \"cases\" | \"priors\"): boolean => pieces.some((piece) => piece.layer[key] !== undefined);\n return {\n ok: true,\n layer: {\n schema: ENDURANCE_SCHEMA,\n levels: levels.value === undefined ? [] : levels.value.split(\"\\n\"),\n resources: resources.items,\n stores: stores.items,\n draws: draws.items,\n ...(has(\"direct\") ? { direct: direct.items } : {}),\n ...(has(\"converters\") ? { converters: converters.items } : {}),\n ...(has(\"cases\") ? { cases: cases.items } : {}),\n ...(has(\"priors\") ? { priors: priors.items } : {}),\n },\n };\n}\n"],"mappings":";;;;;;AAKA,SAAgB,SAAS,WAA2C;CAClE,MAAM,sBAAM,IAAI,IAAoB;CACpC,KAAK,MAAM,SAAS,UAAU,OAAO,IAAI,MAAM,SAAS,GAAG,IAAI,IAAI,MAAM,WAAW,IAAI,IAAI,MAAM,QAAQ,KAAK,KAAK,MAAM,MAAM;CAChI,OAAO;AACT;;;;;AAMA,SAAgB,SAAS,WAA+B;CACtD,IAAI,EAAE,UAAU,WAAW,KAAA,KA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,MAAM;CAClH,IAAI,OAAO,SAAS,GAAG,OAAO;EAAE,IAAI;EAAO;CAAO;CAClD,MAAM,OAAO,QAA+D,OAAO,MAAM,UAAU,MAAM,MAAM,SAAS,KAAA,CAAS;CACjI,OAAO;EACL,IAAI;EACJ,OAAO;GACL,QAAQ;GACR,QAAQ,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,OAAO,MAAM,MAAM,IAAI;GACjE,WAAW,UAAU;GACrB,QAAQ,OAAO;GACf,OAAO,MAAM;GACb,GAAI,IAAI,QAAQ,IAAI,EAAE,QAAQ,OAAO,MAAM,IAAI,CAAC;GAChD,GAAI,IAAI,YAAY,IAAI,EAAE,YAAY,WAAW,MAAM,IAAI,CAAC;GAC5D,GAAI,IAAI,OAAO,IAAI,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;GAC7C,GAAI,IAAI,QAAQ,IAAI,EAAE,QAAQ,OAAO,MAAM,IAAI,CAAC;EAClD;CACF;AACF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/stack-endurance",
4
- "version": "0.8.27",
4
+ "version": "0.8.29",
5
5
  "description": "Stores, draws and converters of a system stack: the days that each draw holds when a case cuts its supply, and the shortfall of each level in one year. An add-on of system-stack.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -54,7 +54,7 @@
54
54
  "@mark1russell7/rational": "^0.1.3",
55
55
  "@mark1russell7/rigor-generators": "^0.2.0",
56
56
  "@mark1russell7/rigor-statistics": "^0.2.37",
57
- "@mark1russell7/system-stack": "0.1.17",
57
+ "@mark1russell7/system-stack": "0.1.18",
58
58
  "zod": "^4.6.7"
59
59
  },
60
60
  "devDependencies": {