@mark1russell7/market 0.1.5 → 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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"records-DU5uvTYJ.js","names":[],"sources":["../src/gtin.ts","../src/identifiers.ts","../src/price.ts","../src/offers.ts","../src/records.ts"],"sourcesContent":["/**\n * This module reads the GTIN of a product: a GTIN-8, a UPC-A (12 digits), an EAN-13 or a GTIN-14.\n * The last digit is a check digit. The sum of the other digits, with the weights 3 and 1 from the right, gives it.\n */\n\nconst LENGTHS: ReadonlySet<number> = new Set([8, 12, 13, 14]);\n\n/**\n * This function gives the check digit of the digits of a GTIN without its last digit.\n *\n * @throws RangeError when the text has a character that is not a digit, or no character.\n */\nexport function gtinCheckDigit(body: string): number {\n if (!/^\\d+$/.test(body)) throw new RangeError(`The text ${JSON.stringify(body)} is not a string of digits.`);\n let total = 0;\n for (let i = 0; i < body.length; i += 1) {\n const digit = body.charCodeAt(body.length - 1 - i) - 48;\n total += i % 2 === 0 ? digit * 3 : digit;\n }\n return (10 - (total % 10)) % 10;\n}\n\n/**\n * This function gives the GTIN-14 form of a GTIN, or null. It removes the spaces and the hyphens first.\n * It refuses a length other than 8, 12, 13 or 14 digits, a wrong check digit, and a GTIN of zeros only.\n */\nexport function parseGtin(text: string): string | null {\n const digits = text.replace(/[\\s-]/g, \"\");\n if (!/^\\d+$/.test(digits) || !LENGTHS.has(digits.length) || /^0+$/.test(digits)) return null;\n if (gtinCheckDigit(digits.slice(0, -1)) !== Number(digits.slice(-1))) return null;\n return digits.padStart(14, \"0\");\n}\n","import { parseGtin } from \"./gtin.ts\";\n\n/** A part number of a maker: the brand, and the number that the maker gives to the part. */\nexport interface PartNumber {\n readonly brand: string;\n readonly partNumber: string;\n}\n\n/** The identifiers of a product or of an offer. */\nexport interface Identifiers {\n readonly gtins: readonly string[];\n readonly partNumbers: readonly PartNumber[];\n}\n\n/**\n * This function folds a brand or a part number for a comparison. The result has only capital letters A to Z\n * and digits. Thus `MZ-V8V1T0B/AM` and `mzv8v1t0bam` fold to one text.\n */\nexport function foldCode(text: string): string {\n return text.normalize(\"NFKD\").toUpperCase().replace(/[^A-Z0-9]/g, \"\");\n}\n\n/**\n * This function gives the match keys of a record, sorted and with no copy. A key is `gtin:` with the GTIN-14,\n * or `part:` with the folded brand and part number. Two records with a key in common name one product.\n * The function ignores a GTIN that is not valid, and a part number whose brand or number folds to no text.\n */\nexport function matchKeys(identifiers: Identifiers): string[] {\n const keys = new Set<string>();\n for (const text of identifiers.gtins) {\n const gtin = parseGtin(text);\n if (gtin !== null) keys.add(`gtin:${gtin}`);\n }\n for (const { brand, partNumber } of identifiers.partNumbers) {\n const folded = [foldCode(brand), foldCode(partNumber)];\n if (folded.every((part) => part !== \"\")) keys.add(`part:${folded.join(\"/\")}`);\n }\n return [...keys].sort();\n}\n","import { add, scale, type Quantity } from \"@mark1russell7/quantity\";\nimport type { PriceReading } from \"./records.ts\";\n\n/**\n * This function gives the unit price for an order of `count` units. The price of the largest break at or\n * below the count applies, or the price of the reading when no break applies.\n *\n * @throws RangeError when the count is not a whole number, or when it is less than the minimum of the reading.\n */\nexport function unitPriceFor(reading: PriceReading, count: number): Quantity {\n const minimum = reading.minimumQuantity ?? 1;\n if (!Number.isSafeInteger(count) || count < minimum) {\n throw new RangeError(`The count ${count} is not a whole number of ${minimum} or more.`);\n }\n let price: Quantity = reading.price;\n for (const entry of reading.priceBreaks ?? []) if (entry.quantity <= count) price = entry.unitPrice;\n return price;\n}\n\n/**\n * This function gives the cost of an order of `count` units with its shipping, or null when the shipping\n * cost is not known. The cost is exact, and the function does not round it to the cent.\n *\n * @throws RangeError when the count is not a whole number, or when it is less than the minimum of the reading.\n */\nexport function costOf(reading: PriceReading, count: number): Quantity | null {\n const goods = scale(unitPriceFor(reading, count), count);\n switch (reading.shipping.kind) {\n case \"free\":\n return goods;\n case \"fixed\":\n return add(goods, reading.shipping.cost);\n default:\n return null;\n }\n}\n","import { compare, convert, convertible, kindOf, scale, UnitError, type Quantity } from \"@mark1russell7/quantity\";\nimport { foldCode } from \"./identifiers.ts\";\nimport { costOf, unitPriceFor } from \"./price.ts\";\nimport type { Condition, Offer, PriceReading } from \"./records.ts\";\n\n/** One offer of a source, and its price reading at one instant. */\nexport interface Observation {\n readonly offer: Offer;\n readonly reading: PriceReading;\n}\n\n/**\n * This record names a part that a buyer wants: the names of its maker, and its part numbers. A seller can write\n * the brand of one maker in more than one form, so the want has a list of names.\n */\nexport interface PartWant {\n /** The names of the maker, as the sellers write the brand. */\n readonly brands: readonly string[];\n /** The part numbers of the maker. A part number of an offer matches when it starts with one of them, after the fold. */\n readonly partNumbers: readonly string[];\n}\n\n/**\n * This function tells if an offer is an offer of the part. One part number of the offer must have a brand of the\n * want and start with a part number of the want. `foldCode` folds each text before the comparison. A part number\n * of another maker does not match: many makers use short numbers like `A1383`.\n */\nexport function offersPart(offer: Pick<Offer, \"partNumbers\">, want: PartWant): boolean {\n const brands = new Set(want.brands.map(foldCode).filter((brand) => brand !== \"\"));\n const parts = want.partNumbers.map(foldCode).filter((part) => part !== \"\");\n return offer.partNumbers.some(({ brand, partNumber }) => {\n const folded = foldCode(partNumber);\n return brands.has(foldCode(brand)) && parts.some((part) => folded.startsWith(part));\n });\n}\n\n/**\n * This function gives the latest observation of each offer, in the order of the offer ids. When two readings of\n * one offer have the same instant, the later one in the list applies.\n */\nexport function latestObservations(observations: readonly Observation[]): Observation[] {\n const latest = new Map<string, Observation>();\n for (const each of observations) {\n const seen = latest.get(each.offer.id);\n if (seen === undefined || Date.parse(seen.reading.at) <= Date.parse(each.reading.at)) latest.set(each.offer.id, each);\n }\n return [...latest.values()].sort((a, b) => order(a.offer.id, b.offer.id));\n}\n\n/** This function gives the latest observation of each offer of the part, in the order of the offer ids. */\nexport function offersOfPart(observations: readonly Observation[], want: PartWant): Observation[] {\n return latestObservations(observations.filter((each) => offersPart(each.offer, want)));\n}\n\n/** This record is one offer that a buyer can choose, with the price of an order in the currency of the buyer. */\nexport interface OfferChoice {\n readonly observation: Observation;\n /** The unit price for the count, times the count. */\n readonly goods: Quantity;\n /** The goods and the shipping, or null when the shipping cost is not known. */\n readonly cost: Quantity | null;\n /** True when the availability is `in-stock` or `low-stock`. */\n readonly inStock: boolean;\n}\n\n/** These options change the choice of an offer. */\nexport interface BestOfferOptions {\n /** The currency of the prices, a unit of money of `@mark1russell7/quantity`, for example `USD`. An offer with a price in another currency is skipped. */\n readonly currency: string;\n /** The count of units of the order. The default is 1. */\n readonly count?: number;\n /** The conditions that the buyer accepts. The default is `new` only. */\n readonly conditions?: readonly Condition[];\n}\n\n/** This record is the choice of an offer: the best offer, each offer in the order of the price, and each skipped offer. */\nexport interface BestOffer {\n /** The offer with the lowest price that is in stock, or else the offer with the lowest price, or null with no offer. */\n readonly best: OfferChoice | null;\n /** The offers, from the lowest price of the goods. Equal prices go in the order of the cost, then of the offer id. */\n readonly offers: readonly OfferChoice[];\n /** The offers that the choice skipped, each with the reason. */\n readonly skipped: readonly { readonly offerId: string; readonly why: string }[];\n}\n\n/**\n * This function chooses the offer to buy from the latest observation of each offer. It skips an offer with a\n * condition that the buyer does not accept, a price in another currency, or a minimum above the count.\n *\n * @throws RangeError when the count is not a whole number of 1 or more, or when the currency is not a unit of money.\n */\nexport function bestOffer(observations: readonly Observation[], options: BestOfferOptions): BestOffer {\n const { currency, count = 1, conditions = [\"new\"] } = options;\n if (!Number.isSafeInteger(count) || count < 1) throw new RangeError(`The count ${count} is not a whole number of 1 or more.`);\n if (!isMoney(currency)) throw new RangeError(`The currency ${currency} is not a unit of money of @mark1russell7/quantity.`);\n const accepted = new Set<Condition>(conditions);\n const offers: OfferChoice[] = [];\n const skipped: { offerId: string; why: string }[] = [];\n for (const observation of latestObservations(observations)) {\n const { offer, reading } = observation;\n const minimum = reading.minimumQuantity ?? 1;\n if (!accepted.has(offer.condition)) skipped.push({ offerId: offer.id, why: `The condition ${offer.condition} is not a condition that the buyer accepts.` });\n else if (!converts(reading.price.unit, currency)) skipped.push({ offerId: offer.id, why: `The price is in ${reading.price.unit}, not in ${currency}.` });\n else if (count < minimum) skipped.push({ offerId: offer.id, why: `The minimum order is ${minimum} units, more than the count ${count}.` });\n else {\n const goods = convert(scale(unitPriceFor(reading, count), count), currency);\n // A shipping cost in another currency is not known in the currency of the buyer.\n const shipping = reading.shipping.kind !== \"fixed\" || converts(reading.shipping.cost.unit, currency);\n const total = shipping ? costOf(reading, count) : null;\n const cost = total === null ? null : convert(total, currency);\n const inStock = reading.availability === \"in-stock\" || reading.availability === \"low-stock\";\n offers.push({ observation, goods, cost, inStock });\n }\n }\n offers.sort((a, b) => compare(a.goods, b.goods) || byCost(a.cost, b.cost) || order(a.observation.offer.id, b.observation.offer.id));\n const best = offers.find((choice) => choice.inStock) ?? offers[0] ?? null;\n return { best, offers, skipped };\n}\n\n/** This function tells if a unit is a unit of money that the quantity package knows. */\nfunction isMoney(unit: string): boolean {\n try {\n return kindOf(unit) === \"money\";\n } catch (error) {\n if (error instanceof UnitError) return false;\n throw error;\n }\n}\n\n/** This function tells if an amount in one unit converts to another unit. A unit that the quantity package does not know does not convert. */\nfunction converts(from: string, to: string): boolean {\n try {\n return convertible(from, to);\n } catch (error) {\n if (error instanceof UnitError) return false;\n throw error;\n }\n}\n\n/** This function orders two costs. A known cost comes before a cost that is not known. */\nfunction byCost(a: Quantity | null, b: Quantity | null): number {\n if (a === null || b === null) return a === b ? 0 : a === null ? 1 : -1;\n return compare(a, b);\n}\n\n/** This function orders two texts by their code units, so the order does not depend on the locale. */\nfunction order(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** The offer to buy for one count of a part, or the reason that no offer is usable. */\nexport type Priced = { readonly ok: true; readonly offerId: string; readonly cost: Quantity } | { readonly ok: false; readonly why: string };\n\n/**\n * This function chooses the offer to buy for a count of a part: the in-stock offer with the lowest cost, with the\n * shipping. An offer with a cost that is not known is not usable. Equal costs keep the order of `bestOffer`.\n */\nexport function priceOf(observations: readonly Observation[], count: number, need: { readonly currency: string; readonly conditions?: readonly Condition[] | undefined }): Priced {\n const choice = bestOffer(observations, { currency: need.currency, count, ...(need.conditions === undefined ? {} : { conditions: need.conditions }) });\n let pick: (OfferChoice & { readonly cost: Quantity }) | undefined;\n for (const offer of choice.offers) {\n const cost = offer.cost;\n if (offer.inStock && cost !== null && (pick === undefined || compare(cost, pick.cost) < 0)) pick = { ...offer, cost };\n }\n if (pick !== undefined) return { ok: true, offerId: pick.observation.offer.id, cost: pick.cost };\n if (choice.offers.length > 0) return { ok: false, why: `No offer of ${String(count)} units is in stock with a known cost.` };\n const first = choice.skipped[0];\n return { ok: false, why: first === undefined ? \"No offer matches the part.\" : `No offer is usable. The first offer that the choice skipped: ${first.why}` };\n}\n","import type { Quantity } from \"@mark1russell7/quantity\";\nimport { quantitySchema } from \"@mark1russell7/quantity/schema\";\nimport { z } from \"zod\";\nimport { parseGtin } from \"./gtin.ts\";\nimport type { PartNumber } from \"./identifiers.ts\";\n\n/**\n * The conditions of an offer. A source maps its own condition to one of them, and it keeps its own text in\n * the field `grade` of the offer.\n */\nexport const CONDITIONS = [\"new\", \"open-box\", \"refurbished\", \"used\", \"for-parts\", \"unknown\"] as const;\n/** The condition of an offer. */\nexport type Condition = (typeof CONDITIONS)[number];\n\n/** The states of the stock of an offer at the time of a reading. */\nexport const AVAILABILITIES = [\"in-stock\", \"low-stock\", \"out-of-stock\", \"preorder\", \"unknown\"] as const;\n/** The state of the stock of an offer. */\nexport type Availability = (typeof AVAILABILITIES)[number];\n\n/** The buying formats of an offer. In an auction, the price of a reading is the current bid. */\nexport const FORMATS = [\"fixed-price\", \"auction\"] as const;\n/** The buying format of an offer. */\nexport type Format = (typeof FORMATS)[number];\n\n/** One specification of a product as text. */\nexport interface Spec {\n readonly name: string;\n readonly value: string;\n}\n\n/** The feedback of a seller: the percent of good feedback, and the count of the feedback. */\nexport interface Rating {\n readonly percent: number;\n readonly count: number;\n}\n\n/** A seller of an offer. A source gives some of these fields, or none. */\nexport interface Seller {\n readonly id?: string | undefined;\n readonly name?: string | undefined;\n readonly rating?: Rating | undefined;\n}\n\n/** A product of the catalog: one thing that a person can buy, with its identifiers and its specifications. */\nexport interface Product {\n readonly id: string;\n readonly title: string;\n readonly brand?: string | undefined;\n readonly category?: readonly string[] | undefined;\n readonly gtins: readonly string[];\n readonly partNumbers: readonly PartNumber[];\n readonly specs: readonly Spec[];\n}\n\n/** An offer of a seller: one product at one seller, with the identifiers that the source gives. */\nexport interface Offer {\n readonly id: string;\n readonly source: string;\n readonly sourceId: string;\n readonly productId?: string | undefined;\n readonly title: string;\n readonly url?: string | undefined;\n readonly seller: Seller;\n readonly condition: Condition;\n readonly grade?: string | undefined;\n readonly format: Format;\n readonly endsAt?: string | undefined;\n readonly gtins: readonly string[];\n readonly partNumbers: readonly PartNumber[];\n readonly specs: readonly Spec[];\n}\n\n/** The shipping of a reading. A calculated cost depends on the address of the buyer. */\nexport type Shipping =\n | { readonly kind: \"free\" }\n | { readonly kind: \"fixed\"; readonly cost: Quantity }\n | { readonly kind: \"calculated\" }\n | { readonly kind: \"unknown\" };\n\n/** A price break of a reading: the unit price for an order of `quantity` units or more. */\nexport interface PriceBreak {\n readonly quantity: number;\n readonly unitPrice: Quantity;\n}\n\n/** A price reading: the state of one offer at one instant. */\nexport interface PriceReading {\n readonly offerId: string;\n readonly at: string;\n readonly price: Quantity;\n readonly listPrice?: Quantity | undefined;\n readonly shipping: Shipping;\n readonly availability: Availability;\n readonly available?: number | undefined;\n readonly minimumQuantity?: number | undefined;\n readonly priceBreaks?: readonly PriceBreak[] | undefined;\n}\n\n/** This schema accepts a text with a character that is not a space, and with no space at an end. */\nexport const textSchema: z.ZodType<string> = z\n .string()\n .refine((text) => text !== \"\" && text === text.trim(), \"The text is empty, or it has a space at an end.\");\n\n/** This schema accepts the name of a source: small letters, digits and hyphens, with a letter first. */\nexport const sourceSchema: z.ZodType<string> = z\n .string()\n .regex(/^[a-z][a-z0-9-]*$/, \"The name of a source has small letters, digits and hyphens, with a letter first.\");\n\n/** This schema accepts a GTIN in its GTIN-14 form, with a correct check digit. `parseGtin` gives this form. */\nexport const gtinSchema: z.ZodType<string> = z\n .string()\n .refine((text) => /^\\d{14}$/.test(text) && parseGtin(text) === text, \"The GTIN is not a GTIN-14 with a correct check digit.\");\n\n/** This schema accepts an amount of money of zero or more, for example `{ \"value\": 129.99, \"unit\": \"USD\" }`. */\nexport const moneySchema: z.ZodType<Quantity, Quantity> = quantitySchema(\"money\", { nonnegative: true });\n\n/** This schema accepts an instant in UTC in the ISO 8601 form, for example `2026-11-12T18:00:00Z`. */\nexport const instantSchema: z.ZodType<string> = z.iso.datetime();\n\n/** This schema accepts a part number of a maker. */\nexport const partNumberSchema: z.ZodType<PartNumber> = z.strictObject({ brand: textSchema, partNumber: textSchema });\n\n/** This schema accepts one specification as text, for example `{ \"name\": \"Capacity\", \"value\": \"1 TB\" }`. */\nexport const specSchema: z.ZodType<Spec> = z.strictObject({ name: textSchema, value: textSchema });\n\n/** This schema accepts a seller. A rating is the percent of good feedback and the count of the feedback. */\nexport const sellerSchema: z.ZodType<Seller> = z.strictObject({\n id: textSchema.optional(),\n name: textSchema.optional(),\n rating: z.strictObject({ percent: z.number().min(0).max(100), count: z.int().nonnegative() }).optional(),\n});\n\n/** This schema accepts a product: one thing that a person can buy, with its identifiers and its specifications. */\nexport const productSchema: z.ZodType<Product> = z.strictObject({\n id: textSchema,\n title: textSchema,\n brand: textSchema.optional(),\n category: z.array(textSchema).optional(),\n gtins: z.array(gtinSchema),\n partNumbers: z.array(partNumberSchema),\n specs: z.array(specSchema),\n});\n\n/** This function gives the id of an offer: the name of its source, a colon, and the id at the source. */\nexport function offerId(source: string, sourceId: string): string {\n return `${source}:${sourceId}`;\n}\n\n/** This function gives the name of the source of an offer id: the text before the first colon. */\nexport function sourceOfOffer(id: string): string {\n const colon = id.indexOf(\":\");\n if (colon <= 0) throw new RangeError(`The offer id ${JSON.stringify(id)} has no source.`);\n return id.slice(0, colon);\n}\n\n/**\n * This schema accepts an offer: one product at one seller. The offer has the identifiers that the source gives.\n * `productId` names the product of the catalog after a match.\n */\nexport const offerSchema: z.ZodType<Offer> = z\n .strictObject({\n id: textSchema,\n source: sourceSchema,\n sourceId: textSchema,\n productId: textSchema.optional(),\n title: textSchema,\n url: z.url({ protocol: /^https$/ }).optional(),\n seller: sellerSchema,\n condition: z.enum(CONDITIONS),\n grade: textSchema.optional(),\n format: z.enum(FORMATS),\n endsAt: instantSchema.optional(),\n gtins: z.array(gtinSchema),\n partNumbers: z.array(partNumberSchema),\n specs: z.array(specSchema),\n })\n .refine((offer) => offer.id === offerId(offer.source, offer.sourceId), {\n message: \"The id of an offer is its source and its source id, with a colon between them.\",\n path: [\"id\"],\n });\n\n/** This schema accepts the shipping of a reading. A calculated cost depends on the address of the buyer. */\nexport const shippingSchema: z.ZodType<Shipping> = z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"free\") }),\n z.strictObject({ kind: z.literal(\"fixed\"), cost: moneySchema }),\n z.strictObject({ kind: z.literal(\"calculated\") }),\n z.strictObject({ kind: z.literal(\"unknown\") }),\n]);\n\n/** This schema accepts a price break: the unit price for an order of `quantity` units or more. */\nexport const priceBreakSchema: z.ZodType<PriceBreak> = z.strictObject({ quantity: z.int().min(2), unitPrice: moneySchema });\n\n/**\n * This schema accepts a price reading: the state of one offer at one instant. `price` is the unit price for an\n * order of `minimumQuantity` units, or of one unit. The quantities of the breaks increase, and each is more\n * than the minimum.\n */\nexport const priceReadingSchema: z.ZodType<PriceReading> = z\n .strictObject({\n offerId: textSchema,\n at: instantSchema,\n price: moneySchema,\n listPrice: moneySchema.optional(),\n shipping: shippingSchema,\n availability: z.enum(AVAILABILITIES),\n available: z.int().nonnegative().optional(),\n minimumQuantity: z.int().min(1).optional(),\n priceBreaks: z.array(priceBreakSchema).optional(),\n })\n .superRefine((reading, context) => {\n let last = reading.minimumQuantity ?? 1;\n for (const [index, entry] of (reading.priceBreaks ?? []).entries()) {\n if (entry.quantity <= last) {\n context.addIssue({\n code: \"custom\",\n message: `The break ${index} has the quantity ${entry.quantity}, which is not more than ${last}.`,\n path: [\"priceBreaks\", index, \"quantity\"],\n });\n }\n last = Math.max(last, entry.quantity);\n }\n const { availability, available } = reading;\n if (available === undefined || availability === \"unknown\" || availability === \"preorder\") return;\n if ((availability === \"out-of-stock\") !== (available === 0)) {\n context.addIssue({\n code: \"custom\",\n message: `The availability ${availability} does not agree with the count ${available}.`,\n path: [\"available\"],\n });\n }\n });\n"],"mappings":";;;;;;;;AAKA,MAAM,0BAA+B,IAAI,IAAI;CAAC;CAAG;CAAI;CAAI;AAAE,CAAC;;;;;;AAO5D,SAAgB,eAAe,MAAsB;CACnD,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI,WAAW,YAAY,KAAK,UAAU,IAAI,EAAE,4BAA4B;CAC3G,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;EACvC,MAAM,QAAQ,KAAK,WAAW,KAAK,SAAS,IAAI,CAAC,IAAI;EACrD,SAAS,IAAI,MAAM,IAAI,QAAQ,IAAI;CACrC;CACA,QAAQ,KAAM,QAAQ,MAAO;AAC/B;;;;;AAMA,SAAgB,UAAU,MAA6B;CACrD,MAAM,SAAS,KAAK,QAAQ,UAAU,EAAE;CACxC,IAAI,CAAC,QAAQ,KAAK,MAAM,KAAK,CAAC,QAAQ,IAAI,OAAO,MAAM,KAAK,OAAO,KAAK,MAAM,GAAG,OAAO;CACxF,IAAI,eAAe,OAAO,MAAM,GAAG,EAAE,CAAC,MAAM,OAAO,OAAO,MAAM,EAAE,CAAC,GAAG,OAAO;CAC7E,OAAO,OAAO,SAAS,IAAI,GAAG;AAChC;;;;;;ACbA,SAAgB,SAAS,MAAsB;CAC7C,OAAO,KAAK,UAAU,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,QAAQ,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S;CACzC,aAAa,EAAE,MAAM,gBAAgB,CAAC,CAAC,SAAS;AAClD,CAAC,CAAC,CACD,aAAa,SAAS,YAAY;CACjC,IAAI,OAAO,QAAQ,mBAAmB;CACtC,KAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,eAAe,CAAC,EAAA,CAAG,QAAQ,GAAG;EAClE,IAAI,MAAM,YAAY,MACpB,QAAQ,SAAS;GACf,MAAM;GACN,SAAS,aAAa,MAAM,oBAAoB,MAAM,SAAS,2BAA2B,KAAK;GAC/F,MAAM;IAAC;IAAe;IAAO;GAAU;EACzC,CAAC;EAEH,OAAO,KAAK,IAAI,MAAM,MAAM,QAAQ;CACtC;CACA,MAAM,EAAE,cAAc,cAAc;CACpC,IAAI,cAAc,KAAA,KAAa,iBAAiB,aAAa,iBAAiB,YAAY;CAC1F,IAAK,iBAAiB,oBAAqB,cAAc,IACvD,QAAQ,SAAS;EACf,MAAM;EACN,SAAS,oBAAoB,aAAa,iCAAiC,UAAU;EACrF,MAAM,CAAC,WAAW;CACpB,CAAC;AAEL,CAAC"}
@@ -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.\" } }],\n shelf: { read: false, why: \"No source is read yet.\" },\n },\n ],\n};\n"],"mappings":";;;;AAaA,MAAa,gBAAgB;;AAG7B,MAAa,eAAe;CAAC;CAAS;CAAQ;CAAS;CAAS;CAAQ;CAAa;AAAe;;AA8DpG,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AASA,SAAS,MAAM,MAAwB;CACrC,IAAI,OAAO,SAAS,UAAU,OAAO;CACrC,IAAI;EACF,OAAO,YAAY,MAAM,IAAI;CAC/B,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,MAAM,cAAc;;AAEpB,MAAM,aA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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.5",
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,14 +39,20 @@
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
- "@mark1russell7/strategy-search": "^0.1.0",
55
+ "@mark1russell7/strategy-search": "^0.1.2",
50
56
  "@mark1russell7/strategy-space": "^0.1.0",
51
57
  "@mark1russell7/vex": "^0.19.1",
52
58
  "@mark1russell7/vex-domains": "^0.19.1",