@mark1russell7/market-sources 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/parse.ts","../src/azure.ts","../src/bls.ts","../src/client.ts","../src/bls-client.ts","../src/bestbuy.ts","../src/digikey.ts","../src/ebay.ts","../src/digikey-client.ts","../src/ebay-client.ts","../src/azure-client.ts","../src/bestbuy-client.ts","../src/plans.ts","../src/providers.ts","../src/plans-client.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KA2BY;WACG;WAAmB,uBAAuB;WAAwB;;WAClE;WAAoB;;;KAGvB,UAAU,QAAQ;WAAwB;;;;;;;KAO1C;WAEG;WACA,uBAAuB;WACvB;WACA;IAEX;;qBCrBS;;qBAGA;;;;;;qBAOA,aAAa;;qBAUb;;qBAGA;;qBAGA;;KAiBD,2BAA2B;;KAG3B,0BAA0B,SAAS;;UAG9B;WACN;WACA;;;;;;;;;;wBAcK,eAAe,QAAQ,aAAa;;wBAwCpC,iBAAiB;;wBAKjB,cAAc;;;;;;wBAwCd,UAAU,wBAAwB;;;;;;;wBAsRlC,uBAAuB,iBAAiB,aAAa;;;;;;;;wBAWrD,2BAA2B,6BAA6B,aAAa;;qBCrcxE;;qBAGA;;qBAIA,WAAW;;qBAUX;;qBAGA;;qBAGA;;UAGI;WACN;WACA;WACA;;WAEA;;;;;;qBASE,sBAAsB;;;;;KAYvB;WACG;WAAmB,iBAAiB;WAAyB;KACvE;WAAqB;;;;;;;;;wBAcV,WACd,2BACA;WAAmB;WAAwB;;WAC/B;WAAyB;WAAsB,SAAS,SAAS;WAAkC;;;;;;;;;;;;;;;;;wBAsCjG,eAAe,eAAe,YAAY,iBAAgB,cAA4B;;qBCpFzF;;;;;;wBAqCG,OAAO,cAAc;;qBCpExB;;;;;;qBAOA;;;;;;qBAOA,WAAW;;qBAQX;;UAGI,iBAAiB,UAAU;WACjC,WAAW,UAAU;WACrB,MAAM,KAAK;;;;;;WAMX,QAAQ;;;UAIF,UAAU,UAAU;;;;;;;;EAQnC,SAAS,kBAAkB,aAAa;aAAmB;aAAwB;KAAe,SAAS,IAAI,QAAQ;;;;;;;;;wBAuBzG,gBAAgB,UAAU,QAAQ,SAAS,iBAAiB,KAAK,UAAU;;qBC5C9E;;;;;qBAMA,gBAAgB;;;;;wBAeb,iBAAiB,oBAAoB,oBAAoB;;;;;;;wBA0GzD,oBAAoB,iBAAiB,aAAa;;;;;;;wBAclD,qBAAqB,iBAAiB,aAAa;;;;;;;;wBAyFnD,oBAAoB,iBAAiB,aAAa;;qBC7OrD;;qBAGA;;;;;qBAMA,eAAe;;;;;;;;wBAsIZ,2BAA2B,iBAAiB,aAAa;;;;;;;;wBAiBzD,0BAA0B,iBAAiB,aAAa;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/parse.ts","../src/azure.ts","../src/bls.ts","../src/client.ts","../src/bls-client.ts","../src/bestbuy.ts","../src/digikey.ts","../src/ebay.ts","../src/digikey-client.ts","../src/ebay-client.ts","../src/azure-client.ts","../src/bestbuy-client.ts","../src/plans.ts","../src/providers.ts","../src/plans-client.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KA2BY;WACG;WAAmB,uBAAuB;WAAwB;;WAClE;WAAoB;;;KAGvB,UAAU,QAAQ;WAAwB;;;;;;;KAO1C;WAEG;WACA,uBAAuB;WACvB;WACA;IAEX;;qBCrBS;;qBAGA;;;;;;qBAOA,aAAa;;qBAUb;;qBAGA;;qBAGA;;KAiBD,2BAA2B;;KAG3B,0BAA0B,SAAS;;UAG9B;WACN;WACA;;;;;;;;;;wBAcK,eAAe,QAAQ,aAAa;;wBAwCpC,iBAAiB;;wBAKjB,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BAAqB,KAAK,cAAc;;qBCX1F;;qBAGA;;;;;;KAOD;WACG;;WACA;WAAuB;WAAwB;;WAC/C;WAAyB;WAAwB;;;UAG/C;WACN;WACA,OAAO,SAAS;WAChB;WACA,QAAQ;;;;;;;UAQF;WACN;WACA,MAAM;WACN;WACA;WACA;WACA;WACA;;;;;;;KAQC;WACG;WAAwB;;WAExB;WACA,MAAM;WACN;WACA;WACA;;;;;;KAOH;WACG;;WACA;WAAsB;;WACtB;WAAuB;WAAuB;;;UAG5C;WACN;WACA;WACA;;;;;;UAOM;WACN;WACA;WACA;WACA;WACA;WACA;WACA,OAAO;WACP,OAAO;WACP;WACA;WACA,SAAS;WACT,cAAc;WACd,iBAAiB;WACjB,gBAAgB;;;UAIV;WACN;WACA;;;;;;qBAsCE,oBAAoB,EAAE,QAAQ;;KA4C/B;WAA8B;WAAmB,UAAU;;WAA4B;WAAoB;;;wBAGvG,kBAAkB,iBAAiB;;;;;wBAenC,YAAY,UAAU,cAAc,MAAM,cAAc;;;;;KAY5D;WACG;WAAuB;;WACvB;;WACA;WAAwB;;;;;;;wBAOvB,aAAa,MAAM,cAAc,iBAAiB,eAAe;;;;;;wBAuJjE,eAAe,UAAU,cAAc,SAAS,aAAa,aAAa;;qBC3Y7E;;qBAGA,aAAa;;;;;;qBAcb,aAAa;;qBAqCb;;qBAGA,cAAc;;;;;;qBAgBd,cAAc;;qBAyCd,yBAAyB;;qBCxHzB;;UAGI,kBAAkB,UAAU;WAClC,WAAW,UAAU;WACrB,MAAM,KAAK;;;UAIL;;WAEN;;;UAIM,WAAW,UAAU;;EAEpC,MAAM,UAAU,cAAc,UAAU,iBAAiB,SAAS,IAAI,QAAQ;;;;;;;wBAiBhE,iBAAiB,UAAU,QAAQ,SAAS,kBAAkB,KAAK,WAAW;;qBC4EjF,uBAAuB"}
|
package/build/index.js
CHANGED
|
@@ -1325,7 +1325,7 @@ function mapItem(item, where, at, notes) {
|
|
|
1325
1325
|
if (title === void 0) return skip("it has no title");
|
|
1326
1326
|
const options = list(item["buyingOptions"]);
|
|
1327
1327
|
const format = formatOf(options);
|
|
1328
|
-
if (format === void 0) return skip(`its buying options ${(options ?? []).map(
|
|
1328
|
+
if (format === void 0) return skip(`its buying options ${(options ?? []).map((option) => typeof option === "string" ? option : show(option)).join(", ")} have no price to pay`);
|
|
1329
1329
|
const endsAt = instant(item["itemEndDate"]);
|
|
1330
1330
|
if (endsAt !== void 0 && Date.parse(endsAt) <= Date.parse(at)) return skip(`the listing ended at ${endsAt}`);
|
|
1331
1331
|
const price = format === "auction" ? convertedAmount(item["currentBidPrice"]) ?? convertedAmount(item["price"]) : convertedAmount(item["price"]);
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["observationOf","shippingOf","specsOf","mapProduct","sellerOf","specsOf","specsOf","statusLine","SOURCE","SOURCE","SOURCE","SOURCE","checkPages"],"sources":["../src/parse.ts","../src/azure.ts","../src/bestbuy.ts","../src/bls.ts","../src/digikey.ts","../src/ebay.ts","../src/providers.ts","../src/client.ts","../src/bls-client.ts","../src/digikey-client.ts","../src/ebay-client.ts","../src/azure-client.ts","../src/bestbuy-client.ts","../src/plans.ts","../src/plans-client.ts","../src/index.ts"],"sourcesContent":["import {\n instantSchema,\n meteredObservationSchema,\n moneySchema,\n offerSchema,\n priceReadingSchema,\n type MeteredObservation,\n type MeteredOffer,\n type MeteredReading,\n type Observation,\n type Offer,\n type PriceReading,\n} from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport { z } from \"zod\";\n\n/** One offer of a source, and its price reading at the instant of the answer. `@mark1russell7/market` has the type. */\nexport type { Observation };\n\n/** One metered offer of a source, and its reading at the instant of the answer. `@mark1russell7/market` has the type. */\nexport type { MeteredObservation };\n\n/**\n * The result of a parser. With `ok`, the answer has the documented shape. Each observation is valid under the\n * schemas of `@mark1russell7/market`, and each note tells why the parser skipped a record or a field. Without\n * `ok`, the answer does not have the documented shape, and `problems` tells why.\n */\nexport type ParseResult =\n | { readonly ok: true; readonly observations: readonly Observation[]; readonly notes: readonly string[] }\n | { readonly ok: false; readonly problems: readonly string[] };\n\n/** The result of a parser for an answer that does not have the documented shape. */\nexport type Refused = Extract<ParseResult, { readonly ok: false }>;\n\n/**\n * The result of a parser of metered prices. With `ok`, each observation is valid under the schemas of\n * `@mark1russell7/market`, and `next` is the link of the next page of the answer, or null. Without `ok`, the\n * answer does not have the documented shape, and `problems` tells why.\n */\nexport type MeteredParseResult =\n | {\n readonly ok: true;\n readonly observations: readonly MeteredObservation[];\n readonly notes: readonly string[];\n readonly next: string | null;\n }\n | Refused;\n\n/** A value that a reader found, or the reason that it found none. */\nexport type Read<T> = { readonly ok: true; readonly value: T } | { readonly ok: false; readonly why: string };\n\n/** This function tells if a JSON value is an object that is not a list. */\nexport function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** This function gives the value at `key` of a JSON object, or undefined when the value is not an object. */\nexport function field(value: unknown, key: string): unknown {\n return isRecord(value) && Object.hasOwn(value, key) ? value[key] : undefined;\n}\n\n/** This function gives the value at a path of keys in a JSON value, or undefined when a step is missing. */\nexport function path(value: unknown, ...keys: readonly string[]): unknown {\n let current = value;\n for (const key of keys) current = field(current, key);\n return current;\n}\n\n/** This function gives a list, or undefined for each other value. A source writes an absent list as null or as no key. */\nexport function list(value: unknown): readonly unknown[] | undefined {\n return Array.isArray(value) ? value : undefined;\n}\n\n/** This function gives a text without spaces at its ends, or undefined for an empty text, null and each other value. */\nexport function text(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed === \"\" ? undefined : trimmed;\n}\n\n/** This function gives a whole number of zero or more, or undefined for each other value. */\nexport function wholeNumber(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;\n}\n\nconst DECIMAL = /^\\d+(\\.\\d+)?$/;\n\n/**\n * This function gives the number of a decimal of zero or more. The decimal is a finite JSON number, or a text with\n * digits, and a point and digits as an option. It refuses an exponent, a sign, a space and a hexadecimal text.\n */\nexport function decimal(value: unknown): number | undefined {\n if (typeof value === \"number\") return Number.isFinite(value) && value >= 0 ? value : undefined;\n if (typeof value !== \"string\" || !DECIMAL.test(value)) return undefined;\n const number = Number(value);\n return Number.isFinite(number) ? number : undefined;\n}\n\n/** This function gives a short JSON text of a value for a note. */\nexport function show(value: unknown): string {\n let shown: string | undefined;\n try {\n shown = JSON.stringify(value);\n } catch {\n shown = undefined;\n }\n if (shown === undefined) return String(typeof value);\n return shown.length > 40 ? `${shown.slice(0, 37)}...` : shown;\n}\n\n/** This function gives an amount of money from an amount and a currency code, or the reason that it is not one. */\nexport function readMoney(amount: unknown, currency: unknown): Read<Quantity> {\n const notDecimal: Read<Quantity> = { ok: false, why: `the amount ${show(amount)} is not a decimal of zero or more` };\n const value = decimal(amount);\n if (value === undefined) return notDecimal;\n const unit = text(currency);\n if (unit === undefined) return { ok: false, why: `the amount ${show(amount)} has no currency` };\n if (!isCurrency(unit)) return { ok: false, why: `the currency ${show(unit)} is not a money unit of @mark1russell7/quantity` };\n const parsed = moneySchema.safeParse({ value, unit });\n return parsed.success ? { ok: true, value: parsed.data } : notDecimal;\n}\n\n/** This function tells if a currency code is a money unit of `@mark1russell7/quantity`. */\nexport function isCurrency(unit: string): boolean {\n return moneySchema.safeParse({ value: 0, unit }).success;\n}\n\nconst httpsSchema = z.url({ protocol: /^https$/ });\n\n/** This function gives an `https` URL, or undefined for each other value. */\nexport function httpsUrl(value: unknown): string | undefined {\n const candidate = text(value);\n return candidate !== undefined && httpsSchema.safeParse(candidate).success ? candidate : undefined;\n}\n\n/** This function gives an instant in UTC in the ISO 8601 form, or undefined for each other value. */\nexport function instant(value: unknown): string | undefined {\n const candidate = text(value);\n return candidate !== undefined && instantSchema.safeParse(candidate).success ? candidate : undefined;\n}\n\n/**\n * This function examines the instant of an answer.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function checkAt(at: string): void {\n if (!instantSchema.safeParse(at).success) {\n throw new RangeError(`The instant ${show(at)} of the answer is not an ISO 8601 instant in UTC.`);\n }\n}\n\n/** This function gives a copy of an object without its keys that have the value undefined. */\nexport function compact<T extends object>(record: T): T {\n return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T;\n}\n\nfunction issues(error: z.ZodError): string {\n return error.issues.map((issue) => `${issue.path.join(\".\") || \"(root)\"}: ${issue.message}`).join(\", \");\n}\n\n/**\n * This function examines an offer and its reading with the schemas of `@mark1russell7/market`. It gives the\n * observation, or it adds a note and gives undefined.\n */\nexport function observe(offer: Offer, reading: PriceReading, notes: string[]): Observation | undefined {\n const checkedOffer = offerSchema.safeParse(compact(offer));\n if (!checkedOffer.success) {\n notes.push(`The offer ${offer.id} is skipped: the schema refuses it (${issues(checkedOffer.error)}).`);\n return undefined;\n }\n const checkedReading = priceReadingSchema.safeParse(compact(reading));\n if (!checkedReading.success) {\n notes.push(`The offer ${offer.id} is skipped: the schema refuses its reading (${issues(checkedReading.error)}).`);\n return undefined;\n }\n return { offer: checkedOffer.data, reading: checkedReading.data };\n}\n\n/**\n * This function examines a metered offer and its reading with the schemas of `@mark1russell7/market`. It gives\n * the observation, or it adds a note and gives undefined.\n */\nexport function observeMetered(offer: MeteredOffer, reading: MeteredReading, notes: string[]): MeteredObservation | undefined {\n const checked = meteredObservationSchema.safeParse({ offer: compact(offer), reading: compact(reading) });\n if (!checked.success) {\n notes.push(`The offer ${offer.id} is skipped: the schema refuses it (${issues(checked.error)}).`);\n return undefined;\n }\n return checked.data;\n}\n\n/** This function gives a result with the observations. An offer that the answer repeats counts once. */\nexport function done(observations: readonly Observation[], notes: readonly string[]): ParseResult {\n const seen = new Set<string>();\n const unique = observations.filter((each) => {\n if (seen.has(each.offer.id)) return false;\n seen.add(each.offer.id);\n return true;\n });\n return { ok: true, observations: unique, notes };\n}\n\n/** This function gives a result for an answer that does not have the documented shape. */\nexport function refused(...problems: readonly string[]): Refused {\n return { ok: false, problems };\n}\n","import {\n meteredKindOf,\n offerId,\n type Meter,\n type MeteredObservation,\n type PriceTerm,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport { canonicalUnit, rationals } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n decimal,\n field,\n isCurrency,\n isRecord,\n list,\n observeMetered,\n refused,\n show,\n text,\n type MeteredParseResult,\n} from \"./parse.ts\";\n\n/** The name of the Azure Retail Prices API as a source of metered offers. */\nexport const AZURE_SOURCE = \"azure\";\n\n/** The provider of the location of each offer of the Azure Retail Prices API. */\nexport const AZURE_PROVIDER = \"azure\";\n\n/**\n * The terms of the Azure Retail Prices API. The API needs no key, and its documentation names tools for internal\n * analysis and price comparison. The Microsoft APIs Terms of Use permit copies only for the use of the\n * application, and they forbid redistribution and resale of the data.\n */\nexport const AZURE_TERMS: SourceTerms = {\n source: AZURE_SOURCE,\n retention: { kind: \"keep\" },\n deleteWhenEnded: false,\n priceModel: true,\n clause:\n \"Azure Retail Prices REST API overview, read on 2026-11-18, and Microsoft APIs Terms of Use of October 2025, sections 3(b)(4) and 3(b)(14): copies only as the application needs them, and no redistribution or resale\",\n};\n\n/** The address of the Azure Retail Prices API. */\nexport const AZURE_PRICES_URL = \"https://prices.azure.com/api/retail/prices\";\n\n/** The version of the API that the request builder asks for. Only this version gives the prices of savings plans. */\nexport const AZURE_API_VERSION = \"2023-01-01-preview\";\n\n/** The fields of a filter of the Azure Retail Prices API, from its documentation. */\nexport const AZURE_FILTER_FIELDS = [\n \"armRegionName\",\n \"location\",\n \"meterId\",\n \"meterName\",\n \"productId\",\n \"skuId\",\n \"productName\",\n \"skuName\",\n \"serviceName\",\n \"serviceId\",\n \"serviceFamily\",\n \"priceType\",\n \"armSkuName\",\n] as const;\n\n/** A field of a filter of the Azure Retail Prices API. */\nexport type AzureFilterField = (typeof AZURE_FILTER_FIELDS)[number];\n\n/** A filter of the Azure Retail Prices API: the value of each field. The API compares each value with its case. */\nexport type AzureFilter = { readonly [Field in AzureFilterField]?: string };\n\n/** A unit of measure of the API: the count of units that one price buys, and the unit of `@mark1russell7/quantity`. */\nexport interface AzureUnit {\n readonly count: number;\n readonly unit: string;\n}\n\n/** The longest value of a field of a filter, in code units. */\nconst FILTER_VALUE_LIMIT = 200;\n\n/**\n * This function gives the URL of a read of the Azure Retail Prices API with a filter. Each field of the filter\n * gives the term `field eq 'value'`, and the terms join with `and`. Without a currency, the API gives US dollars.\n *\n * @throws RangeError when the filter has no field, or a field that the API does not filter. It also throws when a\n * value is empty, has a space at an end, has a control character or has more than 200 characters. A currency that\n * `@mark1russell7/quantity` does not have also gives a `RangeError`.\n */\nexport function azurePricesUrl(filter: AzureFilter, currency?: string): string {\n const fields: readonly string[] = AZURE_FILTER_FIELDS;\n const other = Object.keys(filter).find((name) => !fields.includes(name));\n if (other !== undefined) throw new RangeError(`The API does not filter the field ${show(other)}.`);\n const terms: string[] = [];\n for (const name of AZURE_FILTER_FIELDS) {\n const value: unknown = filter[name];\n if (value === undefined) continue;\n if (\n typeof value !== \"string\" ||\n value === \"\" ||\n value !== value.trim() ||\n value.length > FILTER_VALUE_LIMIT ||\n /[\\u0000-\\u001f\\u007f]/.test(value)\n ) {\n throw new RangeError(\n `The value of the field ${name} is not a text of 1 to ${FILTER_VALUE_LIMIT} characters with no control character and no space at an end.`,\n );\n }\n terms.push(`${name} eq '${value.replaceAll(\"'\", \"''\")}'`);\n }\n if (terms.length === 0) throw new RangeError(\"The filter has no field. A read of each price of Azure is a large crawl.\");\n const query = [`api-version=${AZURE_API_VERSION}`];\n if (currency !== undefined) {\n if (!/^[A-Z]{3}$/.test(currency) || !isCurrency(currency)) {\n throw new RangeError(`The currency ${show(currency)} is not a money unit of @mark1russell7/quantity.`);\n }\n query.push(`currencyCode=${encodeURIComponent(`'${currency}'`)}`);\n }\n query.push(`$filter=${encodeURIComponent(terms.join(\" and \"))}`);\n return `${AZURE_PRICES_URL}?${query.join(\"&\")}`;\n}\n\n/**\n * The pattern of a link to the Azure Retail Prices API: `https`, the host `prices.azure.com`, no port or the port 443,\n * the path `/api/retail/prices` and an optional query. The pattern refuses a user name, a password and a fragment.\n */\nconst AZURE_PRICES_LINK = /^https:\\/\\/prices\\.azure\\.com(?::443)?\\/api\\/retail\\/prices(?:\\?[^#\\s]*)?$/;\n\n/** This function tells if a link goes to the Azure Retail Prices API (`AZURE_PRICES_LINK`). */\nexport function isAzurePricesUrl(link: string): boolean {\n return AZURE_PRICES_LINK.test(link);\n}\n\n/** This function gives the link of the next page of an answer, or null. A link to another address gives null. */\nexport function azureNextPage(answer: unknown): string | null {\n const link = text(field(answer, \"NextPageLink\"));\n return link !== undefined && isAzurePricesUrl(link) ? link : null;\n}\n\n/** The words of an amount in a unit of measure, and their units. A GB of Azure is 2^30 bytes, thus a GiB. */\nconst AMOUNT_WORDS: Readonly<Record<string, string>> = {\n Second: \"s\",\n Seconds: \"s\",\n Minute: \"min\",\n Minutes: \"min\",\n Hour: \"h\",\n Hours: \"h\",\n Day: \"d\",\n Days: \"d\",\n Month: \"mo\",\n Months: \"mo\",\n Year: \"yr\",\n Years: \"yr\",\n KB: \"KiB\",\n KiB: \"KiB\",\n MB: \"MiB\",\n MiB: \"MiB\",\n GB: \"GiB\",\n GiB: \"GiB\",\n TB: \"TiB\",\n TiB: \"TiB\",\n};\n\n/** The words of a time after the slash of a unit of measure, and their units. */\nconst PER_WORDS: Readonly<Record<string, string>> = { Second: \"s\", Minute: \"min\", Hour: \"h\", Day: \"d\", Month: \"mo\", Year: \"yr\" };\n\n/** A unit of measure: a count with `K` or `M`, a word of an amount, and `/` and a time. Only the count is necessary. */\nconst UNIT_OF_MEASURE = /^([1-9][0-9]{0,8})([KM]?)(?: ([A-Za-z]+))?(?:\\/([A-Za-z]+))?$/;\n\n/**\n * This function gives the unit of a unit of measure of the API, or undefined when the parser does not know it. A\n * count with no word gives `{count}`, for example `10K` gives 10,000 of `{count}`. A word of data or time gives\n * its unit, and `/Month` multiplies it by a month. Only `1/Hour` and `1/Month` give a time alone.\n */\nexport function azureUnit(unitOfMeasure: string): AzureUnit | undefined {\n const match = UNIT_OF_MEASURE.exec(unitOfMeasure);\n if (match === null) return undefined;\n const [, digits = \"\", multiplier = \"\", word, per] = match;\n const count = Number(digits) * (multiplier === \"K\" ? 1000 : multiplier === \"M\" ? 1_000_000 : 1);\n const amount = word === undefined ? undefined : AMOUNT_WORDS[word];\n const time = per === undefined ? undefined : PER_WORDS[per];\n if ((word !== undefined && amount === undefined) || (per !== undefined && time === undefined)) return undefined;\n let unit: string;\n if (amount !== undefined) unit = time === undefined ? amount : `${amount}·${time}`;\n else if (time !== undefined && count === 1) unit = time;\n else unit = time === undefined ? \"{count}\" : `{count}·${time}`;\n try {\n meteredKindOf(priceUnit(\"USD\", unit));\n } catch {\n return undefined;\n }\n return { count, unit };\n}\n\nfunction priceUnit(currency: string, unit: string): string {\n return canonicalUnit(unit.includes(\"·\") ? `${currency}/(${unit})` : `${currency}/${unit}`);\n}\n\n/** This function gives the exact price of one unit, from the price of `count` units, as the nearest number. */\nfunction perUnit(price: number, count: number): number {\n return rationals.toNumber(rationals.div(rationals.fromNumber(price), rationals.fromNumber(count)));\n}\n\n/** A row of an answer that the parser read. */\ninterface Row {\n readonly where: string;\n readonly region: string;\n readonly skuId: string;\n readonly meterId: string;\n readonly meterName: string;\n readonly unitOfMeasure: string;\n readonly unit: AzureUnit;\n readonly currency: string;\n readonly start: number;\n readonly price: number;\n readonly type: string;\n readonly title: string;\n readonly spot: boolean;\n readonly specs: readonly Spec[];\n readonly item: Readonly<Record<string, unknown>>;\n}\n\n/** One offer that a row gives: its term, the price of its tier, and the upfront money of a reservation. */\ninterface Variant {\n readonly key: string;\n readonly term: PriceTerm;\n readonly title: string;\n readonly price: number;\n readonly upfront?: number;\n}\n\ninterface MeterDraft {\n readonly meterId: string;\n readonly meterName: string;\n readonly unit: AzureUnit;\n readonly tiers: Map<number, number>;\n problem?: string;\n}\n\ninterface OfferDraft {\n readonly sourceId: string;\n readonly region: string;\n readonly title: string;\n readonly term: PriceTerm;\n readonly specs: readonly Spec[];\n readonly currency: string;\n readonly upfront: number | undefined;\n readonly meters: Map<string, MeterDraft>;\n}\n\n/** The text of a spot term at the end of a SKU name: `Spot`, or `Low Priority` of the older VMs that Azure can end. */\nconst SPOT = /(?:^|\\s)(?:Spot|Low Priority)$/;\n\n/** A term of a reservation or of a savings plan: `1 Year`, `3 Years` or `10 Years`. */\nconst YEARS = /^([1-9][0-9]?) Years?$/;\n\nfunction yearsOf(value: unknown): number | undefined {\n const match = YEARS.exec(text(value) ?? \"\");\n return match?.[1] === undefined ? undefined : Number(match[1]);\n}\n\n/** The fields of a row that each offer keeps as specs. The spec `pricing` adds the key of the term of the offer. */\nconst SPEC_FIELDS = [\"serviceName\", \"serviceFamily\", \"productName\", \"skuName\", \"armSkuName\", \"location\"] as const;\n\nfunction readRow(item: unknown, where: string, notes: string[]): Row | undefined {\n if (!isRecord(item)) {\n notes.push(`The row ${where} is skipped: it is not an object.`);\n return undefined;\n }\n const skuId = text(item[\"skuId\"]);\n const meterId = text(item[\"meterId\"]);\n const meterName = text(item[\"meterName\"]);\n const region = text(item[\"armRegionName\"]) ?? text(item[\"location\"]);\n const product = text(item[\"productName\"]);\n const sku = text(item[\"skuName\"]);\n const type = text(item[\"type\"]);\n if (\n skuId === undefined ||\n meterId === undefined ||\n meterName === undefined ||\n region === undefined ||\n product === undefined ||\n sku === undefined ||\n type === undefined\n ) {\n const fields = { skuId, meterId, meterName, armRegionName: region, productName: product, skuName: sku, type };\n const missing = Object.entries(fields).filter(([, value]) => value === undefined);\n notes.push(`The row ${where} is skipped: it has no ${missing.map(([name]) => name).join(\", \")}.`);\n return undefined;\n }\n const unitOfMeasure = text(item[\"unitOfMeasure\"]) ?? \"\";\n const unit = azureUnit(unitOfMeasure);\n if (unit === undefined) {\n notes.push(`The row ${where} is skipped: the parser does not know the unit of measure ${show(unitOfMeasure)}.`);\n return undefined;\n }\n const currency = text(item[\"currencyCode\"]);\n if (currency === undefined || !isCurrency(currency)) {\n notes.push(`The row ${where} is skipped: the currency ${show(item[\"currencyCode\"])} is not a money unit of @mark1russell7/quantity.`);\n return undefined;\n }\n const start = decimal(item[\"tierMinimumUnits\"]);\n const price = decimal(item[\"retailPrice\"]);\n if (start === undefined || price === undefined) {\n const name = start === undefined ? \"tierMinimumUnits\" : \"retailPrice\";\n notes.push(`The row ${where} is skipped: its ${name} ${show(item[name])} is not a decimal of zero or more.`);\n return undefined;\n }\n const specs: Spec[] = [];\n for (const name of SPEC_FIELDS) {\n const value = text(item[name]);\n if (value !== undefined) specs.push({ name, value });\n }\n const spot = SPOT.test(sku);\n return { where, region, skuId, meterId, meterName, unitOfMeasure, unit, currency, start, price, type, title: `${product}, ${sku}`, spot, specs, item };\n}\n\nfunction variantsOf(row: Row, notes: string[]): Variant[] {\n const base: PriceTerm = row.spot ? { kind: \"spot\" } : { kind: \"on-demand\" };\n if (row.type === \"DevTestConsumption\") return [{ key: \"dev-test\", term: base, title: `${row.title}, Dev/Test`, price: row.price }];\n if (row.type === \"Reservation\") {\n const years = yearsOf(row.item[\"reservationTerm\"]);\n if (years === undefined) {\n notes.push(`The row ${row.where} is skipped: its reservationTerm ${show(row.item[\"reservationTerm\"])} is not a count of years.`);\n return [];\n }\n const term: PriceTerm = { kind: \"committed\", length: { value: years, unit: \"yr\" } };\n return [{ key: `reservation-${years}y`, term, title: `${row.title}, ${years}-year reservation`, price: 0, upfront: row.price }];\n }\n if (row.type !== \"Consumption\") {\n notes.push(`The row ${row.where} is skipped: its type ${show(row.type)} is not a type of the documentation.`);\n return [];\n }\n const variants: Variant[] = [{ key: \"consumption\", term: base, title: row.title, price: row.price }];\n const plans = row.item[\"savingsPlan\"];\n (list(plans) ?? []).forEach((plan, index) => {\n const years = yearsOf(field(plan, \"term\"));\n const price = decimal(field(plan, \"retailPrice\"));\n if (years === undefined || price === undefined) {\n notes.push(`The savings plan ${row.where}.savingsPlan[${index}] is skipped: it has no term in years or no retailPrice.`);\n return;\n }\n const term: PriceTerm = { kind: \"committed\", length: { value: years, unit: \"yr\" } };\n variants.push({ key: `savings-plan-${years}y`, term, title: `${row.title}, ${years}-year savings plan`, price });\n });\n if (plans !== undefined && plans !== null && list(plans) === undefined) {\n notes.push(`The field savingsPlan of the row ${row.where} is not a list, and the parser does not read it.`);\n }\n return variants;\n}\n\nfunction addRow(row: Row, drafts: Map<string, OfferDraft>, notes: string[]): void {\n for (const variant of variantsOf(row, notes)) {\n const sourceId = `${row.region}/${row.skuId}/${variant.key}`;\n let draft = drafts.get(sourceId);\n if (draft === undefined) {\n draft = {\n sourceId,\n region: row.region,\n title: variant.title,\n term: variant.term,\n specs: [...row.specs, { name: \"pricing\", value: variant.key }],\n currency: row.currency,\n upfront: variant.upfront,\n meters: new Map(),\n };\n drafts.set(sourceId, draft);\n } else if (draft.currency !== row.currency) {\n notes.push(`The row ${row.where} is skipped: its currency ${row.currency} is not the currency of the offer ${offerId(AZURE_SOURCE, sourceId)}.`);\n continue;\n } else if (variant.upfront !== undefined) {\n notes.push(`The row ${row.where} is skipped: it repeats the reservation ${offerId(AZURE_SOURCE, sourceId)}.`);\n continue;\n }\n const key = `${row.meterId}\\u0000${row.meterName}\\u0000${row.unitOfMeasure}`;\n let meter = draft.meters.get(key);\n if (meter === undefined) {\n meter = { meterId: row.meterId, meterName: row.meterName, unit: row.unit, tiers: new Map() };\n draft.meters.set(key, meter);\n }\n if (row.start !== 0 && row.unit.count !== 1) {\n meter.problem = `a tier starts at ${row.start} of the unit of measure ${row.unitOfMeasure}, and the documentation does not tell the unit of the start`;\n }\n const known = meter.tiers.get(row.start);\n if (known !== undefined && known !== variant.price) {\n meter.problem = `two rows give the tier at ${row.start} the prices ${known} and ${variant.price}`;\n }\n meter.tiers.set(row.start, variant.price);\n }\n}\n\nfunction meterOf(draft: OfferDraft, meter: MeterDraft, name: string, id: string, notes: string[]): Meter | undefined {\n if (meter.problem !== undefined) {\n notes.push(`The meter ${show(meter.meterName)} of the offer ${id} is skipped: ${meter.problem}.`);\n return undefined;\n }\n const starts = [...meter.tiers.keys()].sort((a, b) => a - b);\n if (starts[0] !== 0) {\n notes.push(`The meter ${show(meter.meterName)} of the offer ${id} is skipped: it has no tier that starts at 0.`);\n return undefined;\n }\n const unitPrice = priceUnit(draft.currency, meter.unit.unit);\n return {\n name,\n tiers: starts.map((start) => ({\n from: { value: start, unit: meter.unit.unit },\n unitPrice: { value: perUnit(meter.tiers.get(start) ?? 0, meter.unit.count), unit: unitPrice },\n })),\n };\n}\n\nfunction observationOf(draft: OfferDraft, at: string, notes: string[]): MeteredObservation | undefined {\n const id = offerId(AZURE_SOURCE, draft.sourceId);\n const names = new Map<string, number>();\n for (const meter of draft.meters.values()) names.set(meter.meterName, (names.get(meter.meterName) ?? 0) + 1);\n const meters: Meter[] = [];\n for (const meter of draft.meters.values()) {\n const name = (names.get(meter.meterName) ?? 0) > 1 ? `${meter.meterName} (${meter.meterId})` : meter.meterName;\n const read = meterOf(draft, meter, name, id, notes);\n if (read !== undefined) meters.push(read);\n }\n if (meters.length === 0) {\n notes.push(`The offer ${id} is skipped: it has no meter with a valid price.`);\n return undefined;\n }\n return observeMetered(\n {\n id,\n source: AZURE_SOURCE,\n sourceId: draft.sourceId,\n title: draft.title,\n location: { provider: AZURE_PROVIDER, region: draft.region },\n term: draft.term,\n specs: [...draft.specs],\n },\n {\n offerId: id,\n at,\n period: { value: 1, unit: \"mo\" },\n meters,\n upfront: draft.upfront === undefined ? undefined : { value: draft.upfront, unit: draft.currency },\n },\n notes,\n );\n}\n\n/**\n * This function reads one page of the Azure Retail Prices API (`GET /api/retail/prices`) at the instant `at`.\n * The prices of one SKU can continue on the next page: `parseAzureRetailPricePages` reads all the pages together.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseAzureRetailPrices(answer: unknown, at: string): MeteredParseResult {\n return parseAzureRetailPricePages([answer], at);\n}\n\n/**\n * This function reads the pages of one read of the Azure Retail Prices API at the instant `at`. Each SKU in a\n * region on a term gives one offer, with a meter for each meter of the SKU. The `next` of the result is the link\n * of the last page.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseAzureRetailPricePages(answers: readonly unknown[], at: string): MeteredParseResult {\n checkAt(at);\n if (answers.length === 0) return refused(\"The read has no page.\");\n const notes: string[] = [];\n const drafts = new Map<string, OfferDraft>();\n const rows: Row[] = [];\n for (const [index, answer] of answers.entries()) {\n const label = answers.length === 1 ? \"The answer\" : `The page ${index + 1}`;\n if (!isRecord(answer)) return refused(`${label} is not an object.`);\n const items = list(answer[\"Items\"]);\n if (items === undefined) return refused(`The field Items of ${label.toLowerCase()} is not a list.`);\n const prefix = answers.length === 1 ? \"\" : `page ${index + 1}, `;\n items.forEach((item, row) => {\n const read = readRow(item, `${prefix}Items[${row}]`, notes);\n if (read !== undefined) rows.push(read);\n });\n }\n for (const row of rows) addRow(row, drafts, notes);\n const observations: MeteredObservation[] = [];\n for (const draft of drafts.values()) {\n const observation = observationOf(draft, at, notes);\n if (observation !== undefined) observations.push(observation);\n }\n const last = answers[answers.length - 1];\n const next = azureNextPage(last);\n const link = field(last, \"NextPageLink\");\n if (next === null && text(link) !== undefined) {\n notes.push(`The link of the next page ${show(link)} does not go to the Azure Retail Prices API, and the result has no link.`);\n }\n return { ok: true, observations, notes, next };\n}\n","import {\n offerId,\n parseGtin,\n type Availability,\n type Condition,\n type PartNumber,\n type Shipping,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n decimal,\n done,\n field,\n httpsUrl,\n isRecord,\n list,\n observe,\n path,\n readMoney,\n refused,\n text,\n type Observation,\n type ParseResult,\n} from \"./parse.ts\";\n\n/** The name of the Best Buy Products API and Open Box API as a source of offers. */\nexport const BEST_BUY_SOURCE = \"bestbuy\";\n\n/**\n * The terms of the Best Buy APIs: a cache keeps the content for 72 hours at most, and nothing analyzes the prices\n * of Best Buy for a third party.\n */\nexport const BEST_BUY_TERMS: SourceTerms = {\n source: BEST_BUY_SOURCE,\n retention: { kind: \"max-age\", age: { value: 72, unit: \"h\" } },\n deleteWhenEnded: false,\n priceModel: false,\n clause: \"Best Buy API terms of 2021-02-23: no store or cache over 72 hours, and no price analysis for a third party\",\n};\n\n/** The US APIs of Best Buy give each price in US dollars, and the answer names no currency. */\nconst CURRENCY = \"USD\";\n\n/**\n * This function gives the condition of a product of the Best Buy Products API. The text `New` gives `new`, a\n * text with `refurbished` gives `refurbished`, and a pre-owned product gives `used`.\n */\nexport function bestBuyCondition(condition: unknown, preowned: unknown): Condition {\n const lower = text(condition)?.toLowerCase();\n if (lower !== undefined && lower.includes(\"refurb\")) return \"refurbished\";\n if (preowned === true || (lower !== undefined && /pre-?owned|used/.test(lower))) return \"used\";\n if (lower === \"new\") return \"new\";\n return \"unknown\";\n}\n\nfunction skuOf(value: unknown): string | undefined {\n if (typeof value === \"number\") return Number.isSafeInteger(value) && value > 0 ? String(value) : undefined;\n const candidate = text(value);\n return candidate !== undefined && /^\\d+$/.test(candidate) ? candidate : undefined;\n}\n\nfunction listPriceOf(regular: unknown, price: Quantity): Quantity | undefined {\n const read = readMoney(regular, CURRENCY);\n return read.ok && read.value.value > price.value ? read.value : undefined;\n}\n\nfunction shippingOf(product: Readonly<Record<string, unknown>>): Shipping {\n if (product[\"freeShipping\"] === true) return { kind: \"free\" };\n const cost = decimal(product[\"shippingCost\"]);\n if (cost === undefined || cost === 0) return { kind: \"unknown\" };\n const money = readMoney(cost, CURRENCY);\n return money.ok ? { kind: \"fixed\", cost: money.value } : { kind: \"unknown\" };\n}\n\nfunction availabilityOf(product: Readonly<Record<string, unknown>>): Availability {\n if (product[\"active\"] === false || product[\"onlineAvailability\"] === false) return \"out-of-stock\";\n const orderable = text(product[\"orderable\"]);\n if (orderable === \"Available\") return \"in-stock\";\n return orderable === undefined && product[\"onlineAvailability\"] === true ? \"in-stock\" : \"unknown\";\n}\n\nfunction specsOf(value: unknown): Spec[] {\n const specs: Spec[] = [];\n for (const detail of list(value) ?? []) {\n const name = text(field(detail, \"name\"));\n const content = text(field(detail, \"value\"));\n if (name !== undefined && content !== undefined) specs.push({ name, value: content });\n }\n return specs;\n}\n\nfunction mapProduct(product: unknown, where: string, at: string, notes: string[]): Observation | undefined {\n if (!isRecord(product)) {\n notes.push(`The product ${where} is skipped: it is not an object.`);\n return undefined;\n }\n const sourceId = skuOf(product[\"sku\"]);\n if (sourceId === undefined) {\n notes.push(`The product ${where} is skipped: it has no sku.`);\n return undefined;\n }\n const id = offerId(BEST_BUY_SOURCE, sourceId);\n const title = text(product[\"name\"]);\n if (title === undefined) {\n notes.push(`The offer ${id} is skipped: it has no name.`);\n return undefined;\n }\n const price = readMoney(product[\"salePrice\"], CURRENCY);\n if (!price.ok) {\n notes.push(`The offer ${id} is skipped: its salePrice is not valid: ${price.why}.`);\n return undefined;\n }\n\n const upc = text(product[\"upc\"]);\n const gtin = upc === undefined ? null : parseGtin(upc);\n if (upc !== undefined && gtin === null) notes.push(`The offer ${id} has no GTIN: ${JSON.stringify(upc)} is not a valid UPC.`);\n const brand = text(product[\"manufacturer\"]);\n const model = text(product[\"modelNumber\"]);\n const partNumbers: PartNumber[] = brand !== undefined && model !== undefined ? [{ brand, partNumber: model }] : [];\n\n return observe(\n {\n id,\n source: BEST_BUY_SOURCE,\n sourceId,\n title,\n url: httpsUrl(product[\"url\"]),\n seller: {},\n condition: bestBuyCondition(product[\"condition\"], product[\"preowned\"]),\n grade: text(product[\"condition\"]),\n format: \"fixed-price\",\n gtins: gtin === null ? [] : [gtin],\n partNumbers,\n specs: specsOf(product[\"details\"]),\n },\n {\n offerId: id,\n at,\n price: price.value,\n listPrice: listPriceOf(product[\"regularPrice\"], price.value),\n shipping: shippingOf(product),\n availability: availabilityOf(product),\n },\n notes,\n );\n}\n\n/**\n * This function reads the answer of one product of the Best Buy Products API (`GET /v1/products/{sku}.json`) at\n * the instant `at`.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseBestBuyProduct(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of the product is not an object.\");\n const notes: string[] = [];\n const observation = mapProduct(answer, \"of the answer\", at, notes);\n return done(observation === undefined ? [] : [observation], notes);\n}\n\n/**\n * This function reads the answer of a search of the Best Buy Products API (`GET /v1/products(...)?format=json`)\n * at the instant `at`. The answer has its products in the list `products`, in the page form and in the cursor form.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseBestBuyProducts(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of the search is not an object.\");\n const products = list(answer[\"products\"]);\n if (products === undefined) return refused(\"The field products of the answer is not a list.\");\n const notes: string[] = [];\n const observations: Observation[] = [];\n products.forEach((product, index) => {\n const observation = mapProduct(product, `products[${index}]`, at, notes);\n if (observation !== undefined) observations.push(observation);\n });\n return done(observations, notes);\n}\n\nfunction availabilityOfOpenBox(offer: unknown): Availability {\n const online = field(offer, \"onlineAvailability\");\n if (online === true) return \"in-stock\";\n return online === false ? \"out-of-stock\" : \"unknown\";\n}\n\nfunction mapOpenBox(result: unknown, where: string, at: string, notes: string[]): Observation[] {\n if (!isRecord(result)) {\n notes.push(`The result ${where} is skipped: it is not an object.`);\n return [];\n }\n const sku = skuOf(result[\"sku\"]);\n if (sku === undefined) {\n notes.push(`The result ${where} is skipped: it has no sku.`);\n return [];\n }\n const title = text(path(result, \"names\", \"title\"));\n if (title === undefined) {\n notes.push(`The result ${where} is skipped: it has no names.title.`);\n return [];\n }\n const url = httpsUrl(path(result, \"links\", \"web\"));\n const observations: Observation[] = [];\n (list(result[\"offers\"]) ?? []).forEach((offer: unknown, index) => {\n const grade = text(field(offer, \"condition\"));\n const listing = text(field(offer, \"listingId\")) ?? grade;\n if (listing === undefined) {\n notes.push(`The offer ${where}.offers[${index}] is skipped: it has no listingId and no condition.`);\n return;\n }\n const sourceId = `${sku}/open-box/${listing}`;\n const id = offerId(BEST_BUY_SOURCE, sourceId);\n const price = readMoney(path(offer, \"prices\", \"current\"), CURRENCY);\n if (!price.ok) {\n notes.push(`The offer ${id} is skipped: its prices.current is not valid: ${price.why}.`);\n return;\n }\n const sellerId = text(field(offer, \"sellerId\"));\n const observation = observe(\n {\n id,\n source: BEST_BUY_SOURCE,\n sourceId,\n title,\n url,\n seller: sellerId === undefined ? {} : { id: sellerId },\n condition: \"open-box\",\n grade,\n format: \"fixed-price\",\n gtins: [],\n partNumbers: [],\n specs: [],\n },\n {\n offerId: id,\n at,\n price: price.value,\n listPrice: listPriceOf(path(offer, \"prices\", \"regular\"), price.value),\n shipping: { kind: \"unknown\" },\n availability: availabilityOfOpenBox(offer),\n },\n notes,\n );\n if (observation !== undefined) observations.push(observation);\n });\n return observations;\n}\n\n/**\n * This function reads the answer of the Best Buy Open Box API (`GET /beta/products/{sku}/openBox`, or a search of\n * `/beta/products/openBox(...)`) at the instant `at`. Each open-box offer of a SKU gives one observation, with the\n * source id `{sku}/open-box/{listingId}`.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseBestBuyOpenBox(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of the Open Box API is not an object.\");\n const results = list(answer[\"results\"]);\n if (results === undefined) {\n const empty = path(answer, \"metadata\", \"resultSet\", \"count\") === 0 && (answer[\"results\"] ?? null) === null;\n return empty ? done([], []) : refused(\"The field results of the answer is not a list.\");\n }\n const notes: string[] = [];\n const observations = results.flatMap((result, index) => mapOpenBox(result, `results[${index}]`, at, notes));\n return done(observations, notes);\n}\n","import { averagePriceId, averagePriceSchema, type AveragePrice, type SourceTerms } from \"@mark1russell7/market\";\nimport { checkAt, compact, decimal, field, list, refused, show, text, type Refused } from \"./parse.ts\";\n\n/*\n * This module reads the average prices of the U.S. Bureau of Labor Statistics (BLS). The CPI program publishes the\n * average price of some foods, fuels and other items each month: the series of the survey AP. The parser reads an\n * answer of version 1 of the BLS Public Data API, which needs no key. The answer gives no title of a series, so the\n * parser takes the item, the area and the unit of each series from a list of known series.\n */\n\n/** The name of the source. */\nexport const BLS_SOURCE = \"bls-ap\";\n\n/** The statement that the terms of the API make necessary for each user of the data. The layer that shows the prices shows it. */\nexport const BLS_STATEMENT =\n \"BLS.gov cannot vouch for the data or analyses derived from these data after the data have been retrieved from BLS.gov.\";\n\n/** The terms of the BLS Public Data API. They set no limit on the time or the use of the data. */\nexport const BLS_TERMS: SourceTerms = {\n source: BLS_SOURCE,\n retention: { kind: \"keep\" },\n deleteWhenEnded: false,\n priceModel: true,\n clause:\n \"BLS Public Data API Terms of Service, last modified 2023-08-30, read on 2026-11-22: no control over the end use, cite the date of the retrieval, give BLS_STATEMENT, and do not change the content\",\n};\n\n/** The address of version 1 of the BLS Public Data API, for one or more series. */\nexport const BLS_API_URL = \"https://api.bls.gov/publicAPI/v1/timeseries/data/\";\n\n/** The most series of one query of version 1. */\nexport const BLS_SERIES_LIMIT = 25;\n\n/** The most years of one query of version 1. */\nexport const BLS_YEAR_LIMIT = 10;\n\n/** A known series of average prices: its id, its item and its area as BLS names them, and the unit of the item. */\nexport interface BlsSeries {\n readonly series: string;\n readonly item: string;\n readonly area: string;\n /** The unit of the amount of the item, a unit of `@mark1russell7/quantity`, for example `lb`. */\n readonly unit: string;\n}\n\nconst US = \"U.S. city average\";\n\n/**\n * The average prices of some dry staples, in the U.S. city average. The titles are from the BLS data viewer of each\n * series, read on 2026-11-22. The series of the Northeast for these items exist, but they have no value since 2023.\n */\nexport const BLS_STAPLES: readonly BlsSeries[] = [\n { series: \"APU0000701312\", item: \"Rice, white, long grain, uncooked, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000701111\", item: \"Flour, white, all purpose, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000714233\", item: \"Beans, dried, any type, all sizes, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000715211\", item: \"Sugar, white, all sizes, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000701322\", item: \"Spaghetti and macaroni, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n];\n\n/**\n * The result of the parser of average prices. With `ok`, each price is valid under `averagePriceSchema`, and each\n * note tells why the parser skipped a value. Without `ok`, the answer does not have the documented shape.\n */\nexport type AverageParseResult =\n | { readonly ok: true; readonly prices: readonly AveragePrice[]; readonly notes: readonly string[] }\n | (Refused & { readonly threshold?: true | undefined });\n\n/** A message of BLS that tells that the daily threshold of the user is reached. */\nconst THRESHOLD = /threshold/i;\n\nconst SERIES_ID = /^[A-Z0-9]{1,30}$/;\n\n/**\n * This function gives the request of version 1 of the API for some series, from a first year to a last year. The\n * API gives the last three years when the request has no years.\n *\n * @throws RangeError when the count of series is not from 1 to `BLS_SERIES_LIMIT`, or when an id is not an id of BLS.\n * It also throws when the years are not whole numbers in order, or when they are more than `BLS_YEAR_LIMIT` years.\n */\nexport function blsRequest(\n series: readonly string[],\n years?: { readonly start: number; readonly end: number },\n): { readonly method: \"POST\"; readonly url: string; readonly headers: Readonly<Record<string, string>>; readonly body: string } {\n if (series.length < 1 || series.length > BLS_SERIES_LIMIT) throw new RangeError(`The count of series is not from 1 to ${BLS_SERIES_LIMIT}.`);\n for (const id of series) if (typeof id !== \"string\" || !SERIES_ID.test(id)) throw new RangeError(`The series ${show(id)} is not an id of BLS.`);\n if (new Set(series).size !== series.length) throw new RangeError(\"A series is two times in the request.\");\n let body: { readonly seriesid: readonly string[]; readonly startyear?: string; readonly endyear?: string } = { seriesid: series };\n if (years !== undefined) {\n const { start, end } = years;\n if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start > end || end - start + 1 > BLS_YEAR_LIMIT) {\n throw new RangeError(`The years are not whole numbers in order, with ${BLS_YEAR_LIMIT} years at most.`);\n }\n body = { seriesid: series, startyear: String(start), endyear: String(end) };\n }\n return { method: \"POST\", url: BLS_API_URL, headers: { accept: \"application/json\", \"content-type\": \"application/json\" }, body: JSON.stringify(body) };\n}\n\nconst MONTH = /^M(0[1-9]|1[0-2])$/;\nconst YEAR = /^\\d{4}$/;\n\n/** This function gives the texts of the footnotes of a value. A footnote with no text is not a footnote. */\nfunction footnotesOf(value: unknown): string[] {\n return (list(value) ?? []).map((note) => text(field(note, \"text\"))).filter((note): note is string => note !== undefined);\n}\n\n/**\n * This function reads an answer of version 1 of the BLS Public Data API for series of average prices.\n *\n * - Each value of a month of a known series becomes an average price, in US dollars for each unit of its item.\n * - A series that is not in `known` gives a note, and no price.\n * - A value that is not a decimal, for example `-` for no data, gives a note. So does a period that is not a month.\n * - Each message of the answer gives a note, for example \"No Data Available\" for a year.\n * - An answer that did not succeed gives problems. When a message names the daily threshold, the result also has\n * `threshold: true`. Then a loop waits for the next day. The documentation does not give the shape of this answer.\n *\n * @param json - The JSON of the answer\n * @param at - The instant of the answer\n * @param known - The known series. The default is `BLS_STAPLES`.\n * @throws RangeError when `at` is not an ISO 8601 instant in UTC\n */\nexport function parseBlsSeries(json: unknown, at: string, known: readonly BlsSeries[] = BLS_STAPLES): AverageParseResult {\n checkAt(at);\n const status = field(json, \"status\");\n const messages = (list(field(json, \"message\")) ?? []).map((message) => text(message)).filter((message): message is string => message !== undefined);\n if (status !== \"REQUEST_SUCCEEDED\") {\n const problems = refused(`The status of the answer is ${show(status)}, not \"REQUEST_SUCCEEDED\".`, ...messages.map((message) => `BLS: ${message}`));\n return messages.some((message) => THRESHOLD.test(message)) ? { ...problems, threshold: true } : problems;\n }\n const series = list(field(field(json, \"Results\"), \"series\"));\n if (series === undefined) return refused(\"The answer has no list Results.series.\");\n const byId = new Map(known.map((each) => [each.series, each]));\n const notes: string[] = messages.map((message) => `BLS: ${message}`);\n const prices: AveragePrice[] = [];\n const seen = new Set<string>();\n for (const entry of series) {\n const id = text(field(entry, \"seriesID\"));\n const meta = id === undefined ? undefined : byId.get(id);\n if (meta === undefined) {\n notes.push(`The series ${show(id)} is skipped: it is not a known series.`);\n continue;\n }\n for (const point of list(field(entry, \"data\")) ?? []) {\n const year = text(field(point, \"year\"));\n const period = text(field(point, \"period\"));\n if (year === undefined || period === undefined || !YEAR.test(year) || !MONTH.test(period)) {\n notes.push(`A value of the series ${meta.series} is skipped: the period ${show(year)} ${show(period)} is not a month.`);\n continue;\n }\n const month = `${year}-${period.slice(1)}`;\n const value = decimal(field(point, \"value\"));\n if (value === undefined) {\n notes.push(`The value of the series ${meta.series} for ${month} is skipped: ${show(field(point, \"value\"))} is not a decimal.`);\n continue;\n }\n const footnotes = footnotesOf(field(point, \"footnotes\"));\n const record = compact({\n id: averagePriceId(BLS_SOURCE, meta.series, month),\n source: BLS_SOURCE,\n series: meta.series,\n item: meta.item,\n area: meta.area,\n period: month,\n price: { value, unit: `USD/${meta.unit}` },\n at,\n footnotes: footnotes.length === 0 ? undefined : footnotes,\n });\n const checked = averagePriceSchema.safeParse(record);\n if (!checked.success) {\n notes.push(`The value of the series ${meta.series} for ${month} is skipped: the schema refuses it.`);\n continue;\n }\n if (seen.has(checked.data.id)) continue;\n seen.add(checked.data.id);\n prices.push(checked.data);\n }\n }\n return { ok: true, prices, notes };\n}\n","import { offerId, type PartNumber, type PriceBreak, type Seller, type SourceTerms, type Spec } from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n done,\n field,\n httpsUrl,\n isCurrency,\n isRecord,\n list,\n observe,\n path,\n readMoney,\n refused,\n show,\n text,\n wholeNumber,\n type Observation,\n type ParseResult,\n} from \"./parse.ts\";\n\n/** The name of the Digi-Key Product Information API v4 as a source of offers. */\nexport const DIGIKEY_SOURCE = \"digikey\";\n\n/** The name of the seller of an offer that Digi-Key ships itself. */\nexport const DIGIKEY_SELLER = \"Digi-Key\";\n\n/**\n * The terms of the Digi-Key Product Information API: nothing makes or updates a database of its data. Thus a\n * reading serves one request, and no store keeps it.\n */\nexport const DIGIKEY_TERMS: SourceTerms = {\n source: DIGIKEY_SOURCE,\n retention: { kind: \"no-store\" },\n deleteWhenEnded: false,\n priceModel: false,\n clause: \"Digi-Key API User Agreement, section 5.1(e): no database of the information\",\n};\n\ninterface Break {\n readonly quantity: number;\n readonly unitPrice: Quantity;\n}\n\nfunction breaksOf(value: unknown, currency: string): Break[] {\n const breaks: Break[] = [];\n for (const entry of list(value) ?? []) {\n const quantity = wholeNumber(field(entry, \"BreakQuantity\"));\n const unitPrice = readMoney(field(entry, \"UnitPrice\"), currency);\n if (quantity === undefined || quantity < 1 || !unitPrice.ok) continue;\n if (!breaks.some((each) => each.quantity === quantity)) breaks.push({ quantity, unitPrice: unitPrice.value });\n }\n return breaks.sort((a, b) => a.quantity - b.quantity);\n}\n\nfunction sellerOf(variation: unknown): Seller {\n if (field(variation, \"MarketPlace\") !== true) return { name: DIGIKEY_SELLER };\n const supplierId = wholeNumber(path(variation, \"Supplier\", \"Id\"));\n const name = text(path(variation, \"Supplier\", \"Name\"));\n return {\n ...(supplierId === undefined ? {} : { id: String(supplierId) }),\n ...(name === undefined ? {} : { name }),\n };\n}\n\nfunction specsOf(product: Readonly<Record<string, unknown>>): Spec[] {\n const specs: Spec[] = [];\n for (const parameter of list(product[\"Parameters\"]) ?? []) {\n const name = text(field(parameter, \"ParameterText\"));\n const value = text(field(parameter, \"ValueText\"));\n if (name !== undefined && value !== undefined) specs.push({ name, value });\n }\n const status = text(path(product, \"ProductStatus\", \"Status\"));\n if (status !== undefined) specs.push({ name: \"Product status\", value: status });\n return specs;\n}\n\nfunction mapProduct(product: unknown, where: string, currency: string, at: string, notes: string[]): Observation[] {\n if (!isRecord(product)) {\n notes.push(`The product ${where} is skipped: it is not an object.`);\n return [];\n }\n const title =\n text(path(product, \"Description\", \"ProductDescription\")) ??\n text(path(product, \"Description\", \"DetailedDescription\")) ??\n text(product[\"ManufacturerProductNumber\"]);\n if (title === undefined) {\n notes.push(`The product ${where} is skipped: it has no description and no part number.`);\n return [];\n }\n const variations = list(product[\"ProductVariations\"]) ?? [];\n if (variations.length === 0) notes.push(`The product ${where} has no ProductVariations, so it gives no offer.`);\n const brand = text(path(product, \"Manufacturer\", \"Name\"));\n const partNumber = text(product[\"ManufacturerProductNumber\"]);\n const partNumbers: PartNumber[] = brand !== undefined && partNumber !== undefined ? [{ brand, partNumber }] : [];\n const specs = specsOf(product);\n const url = httpsUrl(product[\"ProductUrl\"]);\n\n const observations: Observation[] = [];\n variations.forEach((variation: unknown, index) => {\n const sourceId = text(field(variation, \"DigiKeyProductNumber\"));\n if (sourceId === undefined) {\n notes.push(`The variation ${where}.ProductVariations[${index}] is skipped: it has no DigiKeyProductNumber.`);\n return;\n }\n const id = offerId(DIGIKEY_SOURCE, sourceId);\n const breaks = breaksOf(field(variation, \"StandardPricing\"), currency);\n const lowest = breaks[0];\n if (lowest === undefined) {\n notes.push(`The offer ${id} is skipped: it has no valid StandardPricing.`);\n return;\n }\n const minimum = Math.max(wholeNumber(field(variation, \"MinimumOrderQuantity\")) ?? 1, lowest.quantity, 1);\n const price = breaks.filter((each) => each.quantity <= minimum).at(-1) ?? lowest;\n const priceBreaks: PriceBreak[] = breaks.filter((each) => each.quantity > minimum);\n const available = wholeNumber(field(variation, \"QuantityAvailableforPackageType\"));\n const packageType = text(path(variation, \"PackageType\", \"Name\"));\n\n const observation = observe(\n {\n id,\n source: DIGIKEY_SOURCE,\n sourceId,\n title,\n url,\n seller: sellerOf(variation),\n condition: \"new\",\n format: \"fixed-price\",\n gtins: [],\n partNumbers,\n specs: packageType === undefined ? specs : [...specs, { name: \"Package type\", value: packageType }],\n },\n {\n offerId: id,\n at,\n price: price.unitPrice,\n shipping: { kind: \"unknown\" },\n availability: available === undefined ? \"unknown\" : available > 0 ? \"in-stock\" : \"out-of-stock\",\n available,\n minimumQuantity: minimum > 1 ? minimum : undefined,\n priceBreaks: priceBreaks.length > 0 ? priceBreaks : undefined,\n },\n notes,\n );\n if (observation !== undefined) observations.push(observation);\n });\n return observations;\n}\n\nfunction currencyOf(answer: Readonly<Record<string, unknown>>): string | ParseResult {\n const currency = text(path(answer, \"SearchLocaleUsed\", \"Currency\"));\n if (currency === undefined) return refused(\"The answer names no currency in SearchLocaleUsed.Currency.\");\n if (!isCurrency(currency)) {\n return refused(`The currency ${show(currency)} of the answer is not a money unit of @mark1russell7/quantity.`);\n }\n return currency;\n}\n\n/**\n * This function reads the answer of `ProductDetails` of the Digi-Key Product Information API v4\n * (`GET /products/v4/search/{productNumber}/productdetails`) at the instant `at`. Each variation of the\n * product (a package type) gives one observation. The currency comes from `SearchLocaleUsed.Currency`.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseDigiKeyProductDetails(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of ProductDetails is not an object.\");\n const currency = currencyOf(answer);\n if (typeof currency !== \"string\") return currency;\n if (!isRecord(answer[\"Product\"])) return refused(\"The field Product of the answer is not an object.\");\n const notes: string[] = [];\n return done(mapProduct(answer[\"Product\"], \"Product\", currency, at, notes), notes);\n}\n\n/**\n * This function reads the answer of `KeywordSearch` of the Digi-Key Product Information API v4\n * (`POST /products/v4/search/keyword`) at the instant `at`. It reads the lists `Products` and `ExactMatches`,\n * and an offer in both lists counts once.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseDigiKeyKeywordSearch(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of KeywordSearch is not an object.\");\n const currency = currencyOf(answer);\n if (typeof currency !== \"string\") return currency;\n const products = list(answer[\"Products\"]);\n const exact = list(answer[\"ExactMatches\"]);\n if (products === undefined && exact === undefined) return refused(\"The answer has no list Products and no list ExactMatches.\");\n const notes: string[] = [];\n const observations = [\n ...(exact ?? []).flatMap((product, index) => mapProduct(product, `ExactMatches[${index}]`, currency, at, notes)),\n ...(products ?? []).flatMap((product, index) => mapProduct(product, `Products[${index}]`, currency, at, notes)),\n ];\n return done(observations, notes);\n}\n","import {\n offerId,\n parseGtin,\n type Availability,\n type Condition,\n type Format,\n type PartNumber,\n type Seller,\n type Shipping,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n compact,\n decimal,\n done,\n field,\n httpsUrl,\n instant,\n isRecord,\n list,\n observe,\n path,\n readMoney,\n refused,\n text,\n wholeNumber,\n type Observation,\n type ParseResult,\n type Read,\n} from \"./parse.ts\";\n\n/** The name of the eBay Browse API as a source of offers. */\nexport const EBAY_SOURCE = \"ebay\";\n\n/**\n * The terms of the eBay Browse API. A display shows no data older than 6 hours. An application deletes the data of\n * an ended listing, and nothing models the prices of eBay.\n */\nexport const EBAY_TERMS: SourceTerms = {\n source: EBAY_SOURCE,\n retention: { kind: \"max-age\", age: { value: 6, unit: \"h\" } },\n deleteWhenEnded: true,\n priceModel: false,\n clause: \"eBay API License Agreement of 2025-09-03, sections 8.1(b)(1), 8.1(c) and 9.5\",\n};\n\nconst CONDITIONS_BY_ID: ReadonlyMap<string, Condition> = new Map<string, Condition>([\n [\"1000\", \"new\"],\n [\"1500\", \"open-box\"],\n [\"1750\", \"new\"],\n [\"2000\", \"refurbished\"],\n [\"2010\", \"refurbished\"],\n [\"2020\", \"refurbished\"],\n [\"2030\", \"refurbished\"],\n [\"2500\", \"refurbished\"],\n [\"2750\", \"used\"],\n [\"2990\", \"used\"],\n [\"3000\", \"used\"],\n [\"3010\", \"used\"],\n [\"4000\", \"used\"],\n [\"5000\", \"used\"],\n [\"6000\", \"used\"],\n [\"7000\", \"for-parts\"],\n]);\n\n/**\n * This function gives the condition of an eBay condition id, for example `3000` gives `used`. An id that the\n * table of eBay does not have gives `unknown`.\n */\nexport function ebayCondition(conditionId: unknown): Condition {\n const id = typeof conditionId === \"number\" ? String(conditionId) : text(conditionId);\n return (id === undefined ? undefined : CONDITIONS_BY_ID.get(id)) ?? \"unknown\";\n}\n\nconst AVAILABILITY_BY_STATUS: ReadonlyMap<string, Availability> = new Map<string, Availability>([\n [\"IN_STOCK\", \"in-stock\"],\n [\"LIMITED_STOCK\", \"low-stock\"],\n [\"OUT_OF_STOCK\", \"out-of-stock\"],\n]);\n\nconst PLACEHOLDERS = new Set([\"does not apply\", \"n/a\", \"na\"]);\n\nfunction real(value: unknown): string | undefined {\n const candidate = text(value);\n return candidate === undefined || PLACEHOLDERS.has(candidate.toLowerCase()) ? undefined : candidate;\n}\n\nfunction convertedAmount(value: unknown): Read<Quantity> | undefined {\n if (value === undefined || value === null) return undefined;\n return readMoney(field(value, \"value\"), field(value, \"currency\"));\n}\n\nfunction formatOf(options: readonly unknown[] | undefined): Format | undefined {\n if (options === undefined || options.includes(\"FIXED_PRICE\")) return \"fixed-price\";\n return options.includes(\"AUCTION\") ? \"auction\" : undefined;\n}\n\nfunction shippingOf(options: readonly unknown[] | undefined, currency: string): Shipping {\n let cheapest: Quantity | undefined;\n let calculated = false;\n for (const option of options ?? []) {\n const type = text(field(option, \"shippingCostType\"));\n if (type === \"CALCULATED\") calculated = true;\n if (type !== \"FIXED\") continue;\n const cost = convertedAmount(field(option, \"shippingCost\"));\n if (cost === undefined || !cost.ok || cost.value.unit !== currency) continue;\n if (cheapest === undefined || cost.value.value < cheapest.value) cheapest = cost.value;\n }\n if (cheapest !== undefined) return cheapest.value === 0 ? { kind: \"free\" } : { kind: \"fixed\", cost: cheapest };\n return calculated ? { kind: \"calculated\" } : { kind: \"unknown\" };\n}\n\nfunction sellerOf(value: unknown): Seller {\n const percent = decimal(field(value, \"feedbackPercentage\"));\n const count = wholeNumber(field(value, \"feedbackScore\"));\n const rating = percent !== undefined && percent <= 100 && count !== undefined ? { percent, count } : undefined;\n return compact({ id: text(field(value, \"userId\")), name: text(field(value, \"username\")), rating });\n}\n\nfunction specsOf(value: unknown): Spec[] {\n const specs: Spec[] = [];\n for (const aspect of list(value) ?? []) {\n const name = text(field(aspect, \"name\"));\n const content = text(field(aspect, \"value\"));\n if (name !== undefined && content !== undefined) specs.push({ name, value: content });\n }\n return specs;\n}\n\nfunction mapItem(item: unknown, where: string, at: string, notes: string[]): Observation | undefined {\n if (!isRecord(item)) {\n notes.push(`The item ${where} is skipped: it is not an object.`);\n return undefined;\n }\n const sourceId = text(item[\"itemId\"]);\n if (sourceId === undefined) {\n notes.push(`The item ${where} is skipped: it has no itemId.`);\n return undefined;\n }\n const id = offerId(EBAY_SOURCE, sourceId);\n const skip = (why: string): undefined => {\n notes.push(`The offer ${id} is skipped: ${why}.`);\n return undefined;\n };\n\n const title = text(item[\"title\"]);\n if (title === undefined) return skip(\"it has no title\");\n const options = list(item[\"buyingOptions\"]);\n const format = formatOf(options);\n if (format === undefined) return skip(`its buying options ${(options ?? []).map(String).join(\", \")} have no price to pay`);\n const endsAt = instant(item[\"itemEndDate\"]);\n if (endsAt !== undefined && Date.parse(endsAt) <= Date.parse(at)) return skip(`the listing ended at ${endsAt}`);\n\n const price =\n format === \"auction\"\n ? (convertedAmount(item[\"currentBidPrice\"]) ?? convertedAmount(item[\"price\"]))\n : convertedAmount(item[\"price\"]);\n if (price === undefined) return skip(\"it has no price\");\n if (!price.ok) return skip(`its price is not valid: ${price.why}`);\n\n const original = format === \"fixed-price\" ? convertedAmount(path(item, \"marketingPrice\", \"originalPrice\")) : undefined;\n const listPrice =\n original?.ok === true && original.value.unit === price.value.unit && original.value.value > price.value.value\n ? original.value\n : undefined;\n\n const estimate = (list(item[\"estimatedAvailabilities\"]) ?? []).find(isRecord);\n const availability = AVAILABILITY_BY_STATUS.get(text(field(estimate, \"estimatedAvailabilityStatus\")) ?? \"\") ?? \"unknown\";\n let available =\n text(field(estimate, \"availabilityThresholdType\")) === undefined\n ? wholeNumber(field(estimate, \"estimatedAvailableQuantity\"))\n : undefined;\n if (available !== undefined && availability !== \"unknown\" && (availability === \"out-of-stock\") !== (available === 0)) {\n notes.push(`The offer ${id} has no count: the count ${available} does not agree with ${availability}.`);\n available = undefined;\n }\n\n const gtinText = text(item[\"gtin\"]);\n const gtin = gtinText === undefined ? null : parseGtin(gtinText);\n if (gtinText !== undefined && gtin === null && /\\d/.test(gtinText)) {\n notes.push(`The offer ${id} has no GTIN: ${JSON.stringify(gtinText)} is not a valid GTIN.`);\n }\n const brand = real(item[\"brand\"]);\n const mpn = real(item[\"mpn\"]);\n const partNumbers: PartNumber[] = brand !== undefined && mpn !== undefined ? [{ brand, partNumber: mpn }] : [];\n\n return observe(\n {\n id,\n source: EBAY_SOURCE,\n sourceId,\n title,\n url: httpsUrl(item[\"itemWebUrl\"]),\n seller: sellerOf(item[\"seller\"]),\n condition: ebayCondition(item[\"conditionId\"]),\n grade: text(item[\"condition\"]),\n format,\n endsAt,\n gtins: gtin === null ? [] : [gtin],\n partNumbers,\n specs: specsOf(item[\"localizedAspects\"]),\n },\n {\n offerId: id,\n at,\n price: price.value,\n listPrice,\n shipping: shippingOf(list(item[\"shippingOptions\"]), price.value.unit),\n availability,\n available,\n },\n notes,\n );\n}\n\n/**\n * This function reads the answer of `getItem` of the eBay Browse API (`GET /buy/browse/v1/item/{item_id}`)\n * at the instant `at`. It gives one observation, or a note when the item does not map to an offer.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseEbayItem(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of getItem is not an object.\");\n const notes: string[] = [];\n const observation = mapItem(answer, \"of the answer\", at, notes);\n return done(observation === undefined ? [] : [observation], notes);\n}\n\n/**\n * This function reads the answer of `search` of the eBay Browse API (`GET /buy/browse/v1/item_summary/search`)\n * at the instant `at`. An answer with no results has the `total` 0 and no `itemSummaries`, and it gives no\n * observations.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseEbaySearch(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of search is not an object.\");\n const summaries = answer[\"itemSummaries\"];\n if ((summaries === undefined || summaries === null) && answer[\"total\"] === 0) return done([], []);\n if (!Array.isArray(summaries)) return refused(\"The field itemSummaries of the answer is not a list, and total is not 0.\");\n const notes: string[] = [];\n const observations: Observation[] = [];\n summaries.forEach((summary: unknown, index) => {\n const observation = mapItem(summary, `itemSummaries[${index}]`, at, notes);\n if (observation !== undefined) observations.push(observation);\n });\n return done(observations, notes);\n}\n","/**\n * The records of the providers with a plan list. Each record is data for `parsePlanLists` and the plan client. A\n * host can also load a record from a JSON file with `parsePlanProvider`.\n *\n * The terms of these sources are the strictest rules: no stored reading and no price model. The terms pages of\n * these providers refused an automated read on 2026-11-18. A person reads the terms before a rule changes.\n */\nimport type { SourceTerms } from \"@mark1russell7/market\";\nimport type { PlanListRead, PlanProvider } from \"./plans.ts\";\n\n/** The name of the Vultr source. */\nexport const VULTR_SOURCE = \"vultr\";\n\n/** The terms of the Vultr source. A reading serves one request. */\nexport const VULTR_TERMS: SourceTerms = {\n source: VULTR_SOURCE,\n retention: { kind: \"no-store\" },\n deleteWhenEnded: false,\n priceModel: false,\n clause:\n \"Not read: the terms pages of vultr.com refused an automated read on 2026-11-18. The strictest rule holds until a person reads the terms.\",\n};\n\n/**\n * The record of the Vultr plan list (`GET /v2/plans` of the API v2). The API gave the list with no key on\n * 2026-11-18. Each plan lists its regions, and the object `location_cost` has the prices that change with the region.\n * A plan has the on-demand term when `deploy_ondemand` is true, and the preemptible term when `deploy_preemptible` is true.\n */\nexport const VULTR_PLANS: PlanProvider = {\n source: VULTR_SOURCE,\n provider: \"vultr\",\n name: \"Vultr\",\n host: \"api.vultr.com\",\n paceMs: 2000,\n currency: \"USD\",\n terms: VULTR_TERMS,\n plans: { path: \"/v2/plans\", query: { per_page: \"500\" }, items: \"plans\", paging: { kind: \"cursor\", param: \"cursor\", next: \"meta.links.next\" } },\n id: \"id\",\n regions: { kind: \"field\", path: \"locations\" },\n regionPrices: { kind: \"map\", path: \"location_cost\" },\n prices: [\n { key: \"on-demand\", term: { kind: \"on-demand\" }, when: \"deploy_ondemand\", hourly: \"hourly_cost\", monthly: \"monthly_cost\" },\n {\n key: \"spot\",\n term: { kind: \"spot\" },\n when: \"deploy_preemptible\",\n hourly: \"hourly_cost_preemptible\",\n monthly: \"monthly_cost_preemptible\",\n },\n ],\n specs: [\n { name: \"type\", path: \"type\" },\n { name: \"vcpu\", path: \"vcpu_count\" },\n { name: \"memory\", path: \"ram\", unit: \"MiB\" },\n { name: \"disk\", path: \"disk\", unit: \"GB\" },\n { name: \"disk-type\", path: \"disk_type\" },\n { name: \"transfer\", path: \"bandwidth\", unit: \"GB\" },\n { name: \"cpu-vendor\", path: \"cpu_vendor\" },\n { name: \"gpu\", path: \"gpu_type\" },\n { name: \"gpu-count\", path: \"gpu_count\" },\n { name: \"gpu-memory\", path: \"gpu_vram_gb\", unit: \"GB\" },\n ],\n};\n\n/** The name of the Linode source of Akamai Cloud. */\nexport const LINODE_SOURCE = \"linode\";\n\n/** The terms of the Linode source. A reading serves one request. */\nexport const LINODE_TERMS: SourceTerms = {\n source: LINODE_SOURCE,\n retention: { kind: \"no-store\" },\n deleteWhenEnded: false,\n priceModel: false,\n clause:\n \"Not read: the legal pages of akamai.com refused an automated read on 2026-11-18. The API reference tells that these reads need no permissions. The strictest rule holds until a person reads the terms.\",\n};\n\nconst LINODE_PAGES: PlanListRead[\"paging\"] = { kind: \"page\", param: \"page\", pages: \"pages\" };\n\n/**\n * The record of the Linode plan list of Akamai Cloud (`GET /v4/linode/types` of the API v4). The API reference\n * tells that the read needs no permissions. The list of `GET /v4/regions/availability` tells the regions of each\n * plan. The list `region_prices` has the prices that change with the region.\n */\nexport const LINODE_PLANS: PlanProvider = {\n source: LINODE_SOURCE,\n provider: \"linode\",\n name: \"Linode\",\n host: \"api.linode.com\",\n paceMs: 2000,\n currency: \"USD\",\n terms: LINODE_TERMS,\n plans: { path: \"/v4/linode/types\", query: { page_size: \"500\" }, items: \"data\", paging: LINODE_PAGES },\n id: \"id\",\n label: \"label\",\n regions: {\n kind: \"list\",\n read: { path: \"/v4/regions/availability\", query: { page_size: \"500\" }, items: \"data\", paging: LINODE_PAGES },\n plan: \"plan\",\n region: \"region\",\n available: \"available\",\n },\n regionPrices: { kind: \"list\", path: \"region_prices\", id: \"id\" },\n prices: [\n {\n key: \"on-demand\",\n term: { kind: \"on-demand\" },\n hourly: \"price.hourly\",\n monthly: \"price.monthly\",\n regionHourly: \"hourly\",\n regionMonthly: \"monthly\",\n },\n ],\n specs: [\n { name: \"class\", path: \"class\" },\n { name: \"vcpu\", path: \"vcpus\" },\n { name: \"memory\", path: \"memory\", unit: \"MiB\" },\n { name: \"disk\", path: \"disk\", unit: \"MiB\" },\n { name: \"transfer\", path: \"transfer\", unit: \"GB\" },\n { name: \"gpu-count\", path: \"gpus\" },\n { name: \"network-out\", path: \"network_out\", unit: \"Mbps\" },\n ],\n};\n\n/** The record of each provider with a plan list, in the order of the names. */\nexport const PLAN_PROVIDERS: readonly PlanProvider[] = [LINODE_PLANS, VULTR_PLANS];\n","/**\n * The shared parts of the clients of the seller APIs. Each client sends its exchanges with the polite send of\n * `polite-crawler/api`. The scheduler of `polite-crawler` keeps the pace of each host. The reaction to each\n * answer is the reaction of the crawler. This module adds the checks of the inputs of a client and the form body.\n * It also adds the read of an answer with a parser of this package, and the redaction of each message.\n *\n * This module uses no type of a platform: the host of a client gives the transport, the clock and the signal.\n */\nimport { redactSecrets } from \"@mark1russell7/text/redact\";\nimport { statusLine, type Answer, type Send } from \"polite-crawler/api\";\nimport { refused, type ParseResult, type Refused } from \"./parse.ts\";\n\nexport {\n ApiError,\n readGrant,\n send,\n sendWithToken,\n statusLine,\n tokenStore,\n TOKEN_MARGIN_MS,\n} from \"polite-crawler/api\";\nexport type {\n Answer,\n ApiScheduler,\n Exchange,\n Grant,\n Pace,\n Redact,\n Reply,\n Send,\n Signal,\n Tokens,\n Transport,\n} from \"polite-crawler/api\";\n\n/** The text in the place of a secret in a message. */\nexport const SECRET_MARK = \"[secret]\";\n\n/** The longest message of a client, in code units. */\nexport const MESSAGE_LIMIT = 300;\n\n/** A key, a secret or a token is printable ASCII with no space, from 8 to 4096 characters. */\nconst SECRET = /^[!-~]{8,4096}$/;\n\n/**\n * This function examines a key or a secret of a client.\n *\n * @throws RangeError when the value is not printable ASCII with no space, from 8 to 4096 characters. The message\n * names the field, and it does not show the value.\n */\nexport function checkSecret(name: string, value: unknown): void {\n if (typeof value !== \"string\" || !SECRET.test(value)) {\n throw new RangeError(`The field ${name} is not a key: printable ASCII with no space, from 8 to 4096 characters.`);\n }\n}\n\n/**\n * This function examines a value that a client puts in a URL, for example a product number.\n *\n * @throws RangeError when the value is empty, has more than 200 characters, or has a control character.\n */\nexport function checkName(name: string, value: unknown): string {\n if (typeof value !== \"string\" || value.trim() === \"\" || value.length > 200 || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n throw new RangeError(`The field ${name} is not a text of 1 to 200 characters with no control character.`);\n }\n return value.trim();\n}\n\n/**\n * This function puts `SECRET_MARK` in the place of each secret and of its forms in a URL and in a form body.\n * It uses `redactSecrets` of `@mark1russell7/text`. Then it cuts the text to `MESSAGE_LIMIT`. Each client gives\n * it to the send as its `redact`.\n */\nexport function redact(text: string, secrets: readonly string[]): string {\n const out = redactSecrets(text, secrets, { mark: SECRET_MARK });\n return out.length > MESSAGE_LIMIT ? `${out.slice(0, MESSAGE_LIMIT)}…` : out;\n}\n\n/** This function gives the body of a form (`application/x-www-form-urlencoded`) with the fields in their order. */\nexport function formBody(fields: Readonly<Record<string, string>>): string {\n return Object.entries(fields)\n .map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`)\n .join(\"&\");\n}\n\n/** The JSON of an answer, or the problems of an answer that is not a 2xx or not JSON. */\nexport type JsonRead = { readonly ok: true; readonly json: unknown } | Refused;\n\n/**\n * This function reads the JSON of an answer. An answer that is not a 2xx gives a problem with its status line,\n * and no part of its body.\n */\nexport function readJson(answer: Answer, input: Pick<Send, \"source\" | \"what\" | \"secrets\">): JsonRead {\n const { reply } = answer;\n if (reply.status < 200 || reply.status > 299) {\n return refused(redact(`${input.source} answered ${statusLine(reply)} to ${input.what}.`, input.secrets ?? []));\n }\n try {\n return { ok: true, json: JSON.parse(reply.body) as unknown };\n } catch {\n return refused(`The answer of ${input.source} to ${input.what} is not JSON.`);\n }\n}\n\n/**\n * This function reads an answer with a parser of this package at the instant `at`. An answer that is not a 2xx\n * gives a problem with its status line, and no part of its body.\n */\nexport function readAnswer(\n answer: Answer,\n input: Pick<Send, \"source\" | \"what\" | \"secrets\">,\n parse: (json: unknown, at: string) => ParseResult,\n at: string,\n): ParseResult {\n const read = readJson(answer, input);\n return read.ok ? parse(read.json, at) : read;\n}\n\n/** This function gives the instant of a time in milliseconds since the epoch, in the ISO 8601 form in UTC. */\nexport function instantOf(ms: number): string {\n return new Date(ms).toISOString();\n}\n","import { quotaGate, withQuota, type Quota, type QuotaGate } from \"polite-crawler/api\";\nimport { BLS_STAPLES, blsRequest, parseBlsSeries, type AverageParseResult, type BlsSeries } from \"./bls.ts\";\nimport { instantOf, readJson, redact, send, type Exchange, type Pace, type Signal, type Transport } from \"./client.ts\";\n\n/** The host of the BLS Public Data API. */\nexport const BLS_HOST = \"api.bls.gov\";\n\n/**\n * The shortest time between two queries of one pace, 10 seconds. The FAQ of the API gives the row \"Request rate limit:\n * 50 requests per 10 seconds\" for the two versions (https://www.bls.gov/developers/api_faqs.htm). The pace is far\n * under it. The quota `BLS_QUOTA`, not the pace, keeps the count of each day.\n */\nexport const BLS_PACE_MS = 10_000;\n\n/**\n * The quota of version 1 of the API: 25 queries each day to a user with no key. The gate keeps 5 in reserve, so a\n * client sends at most 20 queries in each window. The documentation does not tell when the day of the count starts,\n * thus the window is a rolling 24 hours. It is stricter than each calendar day.\n */\nexport const BLS_QUOTA: Quota = {\n name: \"BLS Public Data API queries\",\n limit: 25,\n reserve: 5,\n window: { kind: \"rolling\", ms: 86_400_000 },\n};\n\n/** The name of the key of `BLS_QUOTA`. Version 1 has no key: the API counts the queries of each address. */\nexport const BLS_QUOTA_KEY = \"bls:v1\";\n\n/** The options of a BLS client. Version 1 of the API needs no key. */\nexport interface BlsClientOptions<S extends Signal> {\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n /**\n * The gate of `BLS_QUOTA`. The default is one gate in memory for each pace, with the clock of the pace. Thus each\n * client of one pace counts in one gate, as the pace keeps one interval for each host. A gate with a shared store\n * counts each process of one address in one record. An example store is `SqliteHostStateStore` of `polite-crawler`.\n */\n readonly quota?: QuotaGate | undefined;\n}\n\n/** A client of the average prices of the BLS Public Data API. */\nexport interface BlsClient<S extends Signal> {\n /**\n * This method reads the average prices of some known series in one query. Without years, the API gives the last\n * three years. The default series are `BLS_STAPLES`.\n *\n * @throws QuotaError of `polite-crawler/api` when the quota refuses the query. Its `resetAt` tells when the gate\n * gives a query again. The client sent nothing.\n */\n averages(series?: readonly BlsSeries[], years?: { readonly start: number; readonly end: number }, signal?: S): Promise<AverageParseResult>;\n}\n\nconst SOURCE = \"BLS Public Data API\";\n\n/** The default gate of each pace. A pace is the pace of the clients of one process, and the API counts each address. */\nconst PACE_GATES = new WeakMap<object, QuotaGate>();\n\nfunction paceGate<S extends Signal>(pace: Pace<S>): QuotaGate {\n const found = PACE_GATES.get(pace);\n if (found !== undefined) return found;\n const gate = quotaGate(BLS_QUOTA, { key: BLS_QUOTA_KEY, now: pace.now });\n PACE_GATES.set(pace, gate);\n return gate;\n}\n\n/**\n * This function makes a client of the average prices of the BLS Public Data API, version 1.\n *\n * - The gate counts each query before the client sends it, and it refuses a query over the quota.\n * - An answer that tells that the daily threshold is reached sets the count to the limit. Then the gate refuses each\n * query until the queries of the window go out of it, 24 hours at most.\n */\nexport function createBlsClient<S extends Signal>(options: BlsClientOptions<S>): BlsClient<S> {\n const { pace, transport } = options;\n const query = withQuota(\n options.quota ?? paceGate(pace),\n async (exchange: Exchange, series: readonly BlsSeries[], signal: S | undefined): Promise<AverageParseResult> => {\n const what = `the average prices of ${series.length} series`;\n const input = { source: SOURCE, host: BLS_HOST, minIntervalMs: BLS_PACE_MS, what, secrets: [], redact, exchange };\n const answer = await send(pace, transport, input, signal);\n const json = readJson(answer, input);\n return json.ok ? parseBlsSeries(json.json, instantOf(pace.now()), series) : json;\n },\n { read: (result) => (!result.ok && result.threshold === true ? { remaining: 0 } : undefined) },\n );\n return {\n async averages(series = BLS_STAPLES, years, signal) {\n // The request is made first: a bad series or bad years throw a RangeError, and the gate counts nothing.\n const exchange = blsRequest(\n series.map((each) => each.series),\n years,\n );\n return await query(exchange, series, signal);\n },\n };\n}\n","import {\n checkName,\n checkSecret,\n formBody,\n instantOf,\n readAnswer,\n readGrant,\n redact,\n send,\n sendWithToken,\n tokenStore,\n type Pace,\n type Signal,\n type Transport,\n} from \"./client.ts\";\nimport { parseDigiKeyKeywordSearch, parseDigiKeyProductDetails } from \"./digikey.ts\";\nimport type { ParseResult } from \"./parse.ts\";\n\n/** The host of the Digi-Key APIs. */\nexport const DIGIKEY_HOST = \"api.digikey.com\";\n\n/** The host of the sandbox of the Digi-Key APIs. Its answers have example data. */\nexport const DIGIKEY_SANDBOX_HOST = \"sandbox-api.digikey.com\";\n\n/** The burst limit of Product Information v4 is 120 requests each minute. Thus the client sends one request each 500 ms at most. */\nexport const DIGIKEY_PACE_MS = 500;\n\n/** The most products of one `KeywordSearch`. */\nexport const DIGIKEY_SEARCH_LIMIT = 50;\n\n/** The locale of the answers: the site, the language and the currency of the prices. */\nexport interface DigiKeyLocale {\n readonly site: string;\n readonly language: string;\n readonly currency: string;\n}\n\n/** The locale of the US site, with prices in US dollars. */\nexport const DIGIKEY_US: DigiKeyLocale = { site: \"US\", language: \"en\", currency: \"USD\" };\n\n/** The options of a Digi-Key client. */\nexport interface DigiKeyClientOptions<S extends Signal> {\n /** The client id of the API application. */\n readonly clientId: string;\n /** The client secret of the API application. */\n readonly clientSecret: string;\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n /** With true, the client uses the sandbox host. */\n readonly sandbox?: boolean | undefined;\n /** The default is `DIGIKEY_US`. */\n readonly locale?: DigiKeyLocale | undefined;\n}\n\n/** A client of the Digi-Key Product Information API v4. Each method gives the result of a parser of this package. */\nexport interface DigiKeyClient<S extends Signal> {\n /** This method reads `ProductDetails` of a Digi-Key or maker product number. */\n productDetails(productNumber: string, signal?: S): Promise<ParseResult>;\n /** This method reads `KeywordSearch` of the keywords, with `limit` products at most (1 to 50, the default 10). */\n keywordSearch(keywords: string, limit?: number, signal?: S): Promise<ParseResult>;\n}\n\nconst SOURCE = \"Digi-Key\";\n\n/**\n * This function makes a client of the Digi-Key Product Information API v4. The client gets a token with the\n * 2-legged OAuth flow (the client credentials grant), and it keeps the token until 1 minute before its end. Each\n * request sends the token, the client id and the locale.\n *\n * @throws RangeError when the client id or the client secret is not a key. The message does not show the value.\n */\nexport function createDigiKeyClient<S extends Signal>(options: DigiKeyClientOptions<S>): DigiKeyClient<S> {\n checkSecret(\"clientId\", options.clientId);\n checkSecret(\"clientSecret\", options.clientSecret);\n const { clientId, clientSecret, pace, transport } = options;\n const host = options.sandbox === true ? DIGIKEY_SANDBOX_HOST : DIGIKEY_HOST;\n const base = `https://${host}`;\n const locale = options.locale ?? DIGIKEY_US;\n const secrets = [clientId, clientSecret];\n const context = { source: SOURCE, host, minIntervalMs: DIGIKEY_PACE_MS, secrets, redact };\n\n const tokens = tokenStore<S>(async (signal) => {\n const issuedAt = pace.now();\n const exchange = {\n method: \"POST\" as const,\n url: `${base}/v1/oauth2/token`,\n headers: { \"content-type\": \"application/x-www-form-urlencoded\", accept: \"application/json\" },\n body: formBody({ client_id: clientId, client_secret: clientSecret, grant_type: \"client_credentials\" }),\n };\n const { reply } = await send(pace, transport, { ...context, what: \"the token\", exchange }, signal);\n return readGrant(reply, SOURCE, issuedAt, secrets, redact);\n }, pace.now);\n\n const headers = (token: string): Readonly<Record<string, string>> => ({\n authorization: `Bearer ${token}`,\n \"x-digikey-client-id\": clientId,\n \"x-digikey-locale-site\": locale.site,\n \"x-digikey-locale-language\": locale.language,\n \"x-digikey-locale-currency\": locale.currency,\n });\n\n return {\n async productDetails(productNumber, signal) {\n const number = checkName(\"productNumber\", productNumber);\n const what = `ProductDetails of ${number}`;\n const exchange = {\n method: \"GET\" as const,\n url: `${base}/products/v4/search/${encodeURIComponent(number)}/productdetails`,\n headers: { accept: \"application/json\" },\n body: null,\n };\n const answer = await sendWithToken(pace, transport, tokens, { ...context, what, exchange }, headers, signal);\n return readAnswer(answer, { ...context, what }, parseDigiKeyProductDetails, instantOf(pace.now()));\n },\n async keywordSearch(keywords, limit = 10, signal) {\n const words = checkName(\"keywords\", keywords);\n if (!Number.isInteger(limit) || limit < 1 || limit > DIGIKEY_SEARCH_LIMIT) {\n throw new RangeError(`The limit is not a whole number from 1 to ${DIGIKEY_SEARCH_LIMIT}.`);\n }\n const what = `KeywordSearch of ${JSON.stringify(words)}`;\n const exchange = {\n method: \"POST\" as const,\n url: `${base}/products/v4/search/keyword`,\n headers: { accept: \"application/json\", \"content-type\": \"application/json\" },\n body: JSON.stringify({ Keywords: words, Limit: limit, Offset: 0 }),\n };\n const answer = await sendWithToken(pace, transport, tokens, { ...context, what, exchange }, headers, signal);\n return readAnswer(answer, { ...context, what }, parseDigiKeyKeywordSearch, instantOf(pace.now()));\n },\n };\n}\n","import {\n checkName,\n checkSecret,\n formBody,\n instantOf,\n readAnswer,\n readGrant,\n redact,\n send,\n sendWithToken,\n tokenStore,\n type Pace,\n type Signal,\n type Transport,\n} from \"./client.ts\";\nimport { parseEbayItem, parseEbaySearch } from \"./ebay.ts\";\nimport type { ParseResult } from \"./parse.ts\";\n\n/** The host of the eBay APIs. */\nexport const EBAY_HOST = \"api.ebay.com\";\n\n/** The host of the sandbox of the eBay APIs. */\nexport const EBAY_SANDBOX_HOST = \"api.sandbox.ebay.com\";\n\n/** The scope of an application token for the Browse API. */\nexport const EBAY_SCOPE = \"https://api.ebay.com/oauth/api_scope\";\n\n/**\n * The client sends one request each second at most: the API interval of the policy of `polite-crawler`. The\n * Browse API documents a count of calls each day, but no pace.\n */\nexport const EBAY_PACE_MS = 1000;\n\n/** The most items of one page of `search`. */\nexport const EBAY_SEARCH_LIMIT = 200;\n\n/** The marketplace of the US. */\nexport const EBAY_US = \"EBAY_US\";\n\n/** The options of an eBay client. */\nexport interface EbayClientOptions<S extends Signal> {\n /** The client id (the App ID) of the application. */\n readonly clientId: string;\n /** The client secret (the Cert ID) of the application. */\n readonly clientSecret: string;\n /** This function encodes a text in UTF-8, and gives its Base64 form. The host gives it, for example with `Buffer`. */\n readonly base64: (text: string) => string;\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n /** With true, the client uses the sandbox host. */\n readonly sandbox?: boolean | undefined;\n /** The marketplace of the answers. The default is `EBAY_US`. */\n readonly marketplace?: string | undefined;\n}\n\n/** A client of the eBay Browse API. Each method gives the result of a parser of this package. */\nexport interface EbayClient<S extends Signal> {\n /** This method reads `getItem` of a RESTful item id, for example `v1|110000000001|0`. */\n item(itemId: string, signal?: S): Promise<ParseResult>;\n /** This method reads one page of `search` of the words, with `limit` items at most (1 to 200, the default 50). */\n search(words: string, limit?: number, signal?: S): Promise<ParseResult>;\n}\n\nconst SOURCE = \"eBay\";\n\nconst ITEM_ID = /^v1\\|\\d{1,20}\\|\\d{1,20}$/;\nconst MARKETPLACE = /^EBAY_[A-Z]{2,4}$/;\n\n/**\n * This function makes a client of the eBay Browse API. The client gets an application token with the client\n * credentials grant, and it keeps the token until 1 minute before its end. Each request sends the token and the\n * marketplace.\n *\n * @throws RangeError when the client id or the client secret is not a key, or the marketplace is not valid.\n */\nexport function createEbayClient<S extends Signal>(options: EbayClientOptions<S>): EbayClient<S> {\n checkSecret(\"clientId\", options.clientId);\n checkSecret(\"clientSecret\", options.clientSecret);\n const marketplace = options.marketplace ?? EBAY_US;\n if (!MARKETPLACE.test(marketplace)) throw new RangeError(`The marketplace ${JSON.stringify(marketplace)} is not an eBay marketplace id.`);\n const { clientId, clientSecret, pace, transport } = options;\n const host = options.sandbox === true ? EBAY_SANDBOX_HOST : EBAY_HOST;\n const base = `https://${host}`;\n const basic = options.base64(`${clientId}:${clientSecret}`);\n const secrets = [clientId, clientSecret, basic];\n const context = { source: SOURCE, host, minIntervalMs: EBAY_PACE_MS, secrets, redact };\n\n const tokens = tokenStore<S>(async (signal) => {\n const issuedAt = pace.now();\n const exchange = {\n method: \"POST\" as const,\n url: `${base}/identity/v1/oauth2/token`,\n headers: {\n authorization: `Basic ${basic}`,\n \"content-type\": \"application/x-www-form-urlencoded\",\n accept: \"application/json\",\n },\n body: formBody({ grant_type: \"client_credentials\", scope: EBAY_SCOPE }),\n };\n const { reply } = await send(pace, transport, { ...context, what: \"the token\", exchange }, signal);\n return readGrant(reply, SOURCE, issuedAt, secrets, redact);\n }, pace.now);\n\n const headers = (token: string): Readonly<Record<string, string>> => ({\n authorization: `Bearer ${token}`,\n \"x-ebay-c-marketplace-id\": marketplace,\n });\n\n const read = async (what: string, url: string, parse: (json: unknown, at: string) => ParseResult, signal?: S) => {\n const exchange = { method: \"GET\" as const, url, headers: { accept: \"application/json\" }, body: null };\n const answer = await sendWithToken(pace, transport, tokens, { ...context, what, exchange }, headers, signal);\n return readAnswer(answer, { ...context, what }, parse, instantOf(pace.now()));\n };\n\n return {\n async item(itemId, signal) {\n const id = checkName(\"itemId\", itemId);\n if (!ITEM_ID.test(id)) throw new RangeError(`The item id ${JSON.stringify(id)} is not a RESTful item id (v1|#|#).`);\n return read(`getItem of ${id}`, `${base}/buy/browse/v1/item/${encodeURIComponent(id)}`, parseEbayItem, signal);\n },\n async search(words, limit = 50, signal) {\n const q = checkName(\"words\", words);\n if (!Number.isInteger(limit) || limit < 1 || limit > EBAY_SEARCH_LIMIT) {\n throw new RangeError(`The limit is not a whole number from 1 to ${EBAY_SEARCH_LIMIT}.`);\n }\n const query = formBody({ q, limit: String(limit) });\n return read(`search of ${JSON.stringify(q)}`, `${base}/buy/browse/v1/item_summary/search?${query}`, parseEbaySearch, signal);\n },\n };\n}\n","import { azureNextPage, azurePricesUrl, isAzurePricesUrl, parseAzureRetailPricePages, type AzureFilter } from \"./azure.ts\";\nimport { instantOf, readJson, redact, send, type Pace, type Signal, type Transport } from \"./client.ts\";\nimport type { MeteredParseResult } from \"./parse.ts\";\n\n/** The host of the Azure Retail Prices API. */\nexport const AZURE_HOST = \"prices.azure.com\";\n\n/**\n * The client sends one request each 6 seconds at most. The documentation gives no limit. But each answer has the\n * headers `x-ms-ratelimit-remaining-retailprices-requests` and `x-ms-ratelimit-retailprices-retry-after: 60`.\n * Thus the client sends 10 requests in 60 seconds at most.\n */\nexport const AZURE_PACE_MS = 6000;\n\n/** The most pages of one read. Each page has 1,000 prices at most. */\nexport const AZURE_PAGE_LIMIT = 10;\n\n/** The options of an Azure Retail Prices client. The API needs no key. */\nexport interface AzureClientOptions<S extends Signal> {\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n}\n\n/** The options of one read of prices. */\nexport interface AzureReadOptions {\n /** The most pages that the read follows, from 1 to `AZURE_PAGE_LIMIT`. The default is 1. */\n readonly pages?: number | undefined;\n /** The currency of the prices, a money unit of `@mark1russell7/quantity`. Without it, the API gives US dollars. */\n readonly currency?: string | undefined;\n}\n\n/** A client of the Azure Retail Prices API. Each method gives the result of `parseAzureRetailPricePages`. */\nexport interface AzureClient<S extends Signal> {\n /** This method reads the prices of a filter: the first page, and the next pages up to the limit of the options. */\n prices(filter: AzureFilter, options?: AzureReadOptions, signal?: S): Promise<MeteredParseResult>;\n /** This method continues a read at the link `next` of a result, with `pages` pages at most. The default is 1. */\n more(next: string, pages?: number, signal?: S): Promise<MeteredParseResult>;\n}\n\nconst SOURCE = \"Azure Retail Prices\";\n\nfunction checkPages(pages: number): number {\n if (!Number.isInteger(pages) || pages < 1 || pages > AZURE_PAGE_LIMIT) {\n throw new RangeError(`The count of pages is not a whole number from 1 to ${AZURE_PAGE_LIMIT}.`);\n }\n return pages;\n}\n\n/**\n * This function makes a client of the Azure Retail Prices API. A read follows the link of the next page of each\n * answer, only to the same API, up to its count of pages. It then reads all the pages together.\n */\nexport function createAzureClient<S extends Signal>(options: AzureClientOptions<S>): AzureClient<S> {\n const { pace, transport } = options;\n\n const read = async (first: string, pages: number, what: string, signal?: S): Promise<MeteredParseResult> => {\n const answers: unknown[] = [];\n let link: string | null = first;\n while (link !== null && answers.length < pages) {\n const page = answers.length + 1;\n const exchange = { method: \"GET\" as const, url: link, headers: { accept: \"application/json\" }, body: null };\n const input = {\n source: SOURCE,\n host: AZURE_HOST,\n minIntervalMs: AZURE_PACE_MS,\n what: page === 1 ? what : `${what}, page ${page}`,\n secrets: [],\n redact,\n exchange,\n };\n const answer = await send(pace, transport, input, signal);\n const json = readJson(answer, input);\n if (!json.ok) return json;\n answers.push(json.json);\n link = azureNextPage(json.json);\n }\n return parseAzureRetailPricePages(answers, instantOf(pace.now()));\n };\n\n return {\n async prices(filter, readOptions = {}, signal) {\n const url = azurePricesUrl(filter, readOptions.currency);\n return read(url, checkPages(readOptions.pages ?? 1), \"the prices of a filter\", signal);\n },\n async more(next, pages = 1, signal) {\n if (typeof next !== \"string\" || !isAzurePricesUrl(next)) {\n throw new RangeError(\"The link is not a link of the Azure Retail Prices API.\");\n }\n return read(next, checkPages(pages), \"the next page of a read\", signal);\n },\n };\n}\n","import { checkName, checkSecret, formBody, instantOf, readAnswer, redact, send, type Pace, type Signal, type Transport } from \"./client.ts\";\nimport { parseBestBuyOpenBox, parseBestBuyProduct, parseBestBuyProducts } from \"./bestbuy.ts\";\nimport type { ParseResult } from \"./parse.ts\";\n\n/** The host of the Best Buy APIs. */\nexport const BEST_BUY_HOST = \"api.bestbuy.com\";\n\n/**\n * The client sends one request each second at most: the API interval of the policy of `polite-crawler`. The\n * documentation of Best Buy gives no pace. It answers 403 when a key passes its limit of calls.\n */\nexport const BEST_BUY_PACE_MS = 1000;\n\n/** The most products of one page of a search. */\nexport const BEST_BUY_PAGE_LIMIT = 100;\n\n/** The options of a Best Buy client. */\nexport interface BestBuyClientOptions<S extends Signal> {\n /** The API key. It goes in the query of each request, and no message has it. */\n readonly apiKey: string;\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n}\n\n/** A client of the Best Buy Products API and Open Box API. Each method gives the result of a parser of this package. */\nexport interface BestBuyClient<S extends Signal> {\n /** This method reads one product of a SKU. */\n product(sku: string, signal?: S): Promise<ParseResult>;\n /** This method reads the first page of a search of the words, with `pageSize` products at most (1 to 100, the default 10). */\n search(words: string, pageSize?: number, signal?: S): Promise<ParseResult>;\n /** This method reads the open-box offers of a SKU. */\n openBox(sku: string, signal?: S): Promise<ParseResult>;\n}\n\nconst SOURCE = \"Best Buy\";\n\nconst SKU = /^\\d{1,12}$/;\nconst WORD = /^[A-Za-z0-9.-]{1,40}$/;\n\nfunction checkSku(sku: string): string {\n const value = checkName(\"sku\", sku);\n if (!SKU.test(value)) throw new RangeError(`The SKU ${JSON.stringify(value)} is not a number of 1 to 12 digits.`);\n return value;\n}\n\n/**\n * This function makes a client of the Best Buy APIs. The API key goes in the query of each request. A 401 or a\n * 403 stops the host for 1 hour, because Best Buy gives a 403 for a key that passed its limit.\n *\n * @throws RangeError when the API key is not a key. The message does not show the value.\n */\nexport function createBestBuyClient<S extends Signal>(options: BestBuyClientOptions<S>): BestBuyClient<S> {\n checkSecret(\"apiKey\", options.apiKey);\n const { apiKey, pace, transport } = options;\n const base = `https://${BEST_BUY_HOST}`;\n const secrets = [apiKey];\n\n const read = async (\n what: string,\n path: string,\n query: Readonly<Record<string, string>>,\n parse: (json: unknown, at: string) => ParseResult,\n signal?: S,\n ) => {\n const exchange = {\n method: \"GET\" as const,\n url: `${base}${path}?${formBody({ ...query, apiKey })}`,\n headers: { accept: \"application/json\" },\n body: null,\n };\n const input = { source: SOURCE, host: BEST_BUY_HOST, minIntervalMs: BEST_BUY_PACE_MS, what, secrets, redact, exchange };\n const answer = await send(pace, transport, input, signal);\n return readAnswer(answer, input, parse, instantOf(pace.now()));\n };\n\n return {\n async product(sku, signal) {\n const id = checkSku(sku);\n return read(`the product ${id}`, `/v1/products/${id}.json`, {}, parseBestBuyProduct, signal);\n },\n async search(words, pageSize = 10, signal) {\n const list = checkName(\"words\", words).split(/\\s+/);\n if (list.length > 10 || !list.every((word) => WORD.test(word))) {\n throw new RangeError(\"The words are not 1 to 10 words of letters, digits, points and hyphens.\");\n }\n if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > BEST_BUY_PAGE_LIMIT) {\n throw new RangeError(`The page size is not a whole number from 1 to ${BEST_BUY_PAGE_LIMIT}.`);\n }\n const filter = list.map((word) => `search=${word}`).join(\"&\");\n const query = { format: \"json\", pageSize: String(pageSize) };\n return read(`the search ${JSON.stringify(list.join(\" \"))}`, `/v1/products(${filter})`, query, parseBestBuyProducts, signal);\n },\n async openBox(sku, signal) {\n const id = checkSku(sku);\n return read(`the open-box offers of ${id}`, `/beta/products/${id}/openBox`, {}, parseBestBuyOpenBox, signal);\n },\n };\n}\n","/**\n * The generic parser of the plan lists of cloud providers. A plan list is an API that gives each plan of virtual\n * machines with its hourly price, its monthly cap and its regions. A `PlanProvider` record tells where the API keeps\n * each value. Thus a new provider is a record of data, and not new code.\n *\n * The parser gives one metered offer for each plan, region and price term. The meter `compute` counts the hours of\n * a month: the hourly price up to the monthly cap, then no price.\n */\nimport {\n offerId,\n priceTermSchema,\n sourceSchema,\n sourceTermsSchema,\n textSchema,\n type Meter,\n type MeteredObservation,\n type PriceTerm,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport { canonicalUnit, rationals } from \"@mark1russell7/quantity\";\nimport { z } from \"zod\";\nimport {\n checkAt,\n decimal,\n field,\n isCurrency,\n isRecord,\n list,\n observeMetered,\n path,\n refused,\n show,\n text,\n wholeNumber,\n type MeteredParseResult,\n type Read,\n} from \"./parse.ts\";\n\n/** The name of the meter of each plan offer. It counts the hours of use in one month. */\nexport const PLAN_METER = \"compute\";\n\n/** The name of the spec that the parser adds to each offer. Its value is the key of the price term. */\nexport const PLAN_PRICING_SPEC = \"pricing\";\n\n/**\n * The paging of a list. With `page`, the query parameter `param` has the number of the page, and the field `pages`\n * of an answer has the count of pages. With `cursor`, the field `next` of an answer has the value of `param` for the\n * next page, and an empty value ends the list.\n */\nexport type PlanPaging =\n | { readonly kind: \"none\" }\n | { readonly kind: \"page\"; readonly param: string; readonly pages: string }\n | { readonly kind: \"cursor\"; readonly param: string; readonly next: string };\n\n/** A list of an API: its path on the host, its query, the field of its items in an answer, and its paging. */\nexport interface PlanListRead {\n readonly path: string;\n readonly query: Readonly<Record<string, string>>;\n readonly items: string;\n readonly paging: PlanPaging;\n}\n\n/**\n * The price of a plan on one term. Each field is a path of names with dots in a plan, for example `price.hourly`.\n * A plan has the term only when the field `when` is `true`. The fields `regionHourly` and `regionMonthly` are the\n * paths in a price of one region. Without them, the paths in the fields `hourly` and `monthly` of the term apply.\n */\nexport interface PlanTerm {\n readonly key: string;\n readonly term: PriceTerm;\n readonly when?: string | undefined;\n readonly hourly: string;\n readonly monthly?: string | undefined;\n readonly regionHourly?: string | undefined;\n readonly regionMonthly?: string | undefined;\n}\n\n/**\n * The regions of each plan. With `field`, a plan has a list of the ids of its regions. With `list`, a different\n * list of the API has one row for each plan and region. The field `available` of a row tells if the provider has\n * the plan in that region.\n */\nexport type PlanRegions =\n | { readonly kind: \"field\"; readonly path: string }\n | {\n readonly kind: \"list\";\n readonly read: PlanListRead;\n readonly plan: string;\n readonly region: string;\n readonly available: string;\n };\n\n/**\n * The prices of a plan that change with the region. With `map`, an object of a plan has a price for each id of a\n * region. With `list`, a list of a plan has prices, each with the id of its region in the field `id`.\n */\nexport type PlanRegionPrices =\n | { readonly kind: \"none\" }\n | { readonly kind: \"map\"; readonly path: string }\n | { readonly kind: \"list\"; readonly path: string; readonly id: string };\n\n/** A spec of each offer: its name, the path of its value in a plan, and the unit that the parser adds to the value. */\nexport interface PlanSpec {\n readonly name: string;\n readonly path: string;\n readonly unit?: string | undefined;\n}\n\n/**\n * The record of a provider with a plan list. The parser and the client read the API with only this record. Each\n * path is a path of names with dots in an answer or in a plan.\n */\nexport interface PlanProvider {\n readonly source: string;\n readonly provider: string;\n readonly name: string;\n readonly host: string;\n readonly paceMs: number;\n readonly currency: string;\n readonly terms: SourceTerms;\n readonly plans: PlanListRead;\n readonly id: string;\n readonly label?: string | undefined;\n readonly regions: PlanRegions;\n readonly regionPrices: PlanRegionPrices;\n readonly prices: readonly PlanTerm[];\n readonly specs: readonly PlanSpec[];\n}\n\n/** The answers of one read of a provider: the pages of its plan list, and the pages of its list of regions. */\nexport interface PlanAnswers {\n readonly plans: readonly unknown[];\n readonly regions?: readonly unknown[] | undefined;\n}\n\nconst dottedSchema = z\n .string()\n .regex(/^[A-Za-z0-9_$-]+(\\.[A-Za-z0-9_$-]+)*$/, \"The path has names of letters, digits, _, $ and -, with a dot between two names.\");\n\nconst paramSchema = z.string().regex(/^[A-Za-z0-9_.-]+$/, \"The name of a query parameter has letters, digits, _, . and -.\");\n\nconst pagingSchema: z.ZodType<PlanPaging> = z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"none\") }),\n z.strictObject({ kind: z.literal(\"page\"), param: paramSchema, pages: dottedSchema }),\n z.strictObject({ kind: z.literal(\"cursor\"), param: paramSchema, next: dottedSchema }),\n]);\n\nconst listReadSchema: z.ZodType<PlanListRead> = z.strictObject({\n path: z.string().regex(/^\\/[A-Za-z0-9._~/-]*$/, \"The path of a list starts with a slash, and it has no query.\"),\n query: z.record(paramSchema, z.string()),\n items: dottedSchema,\n paging: pagingSchema,\n});\n\nconst termSchema: z.ZodType<PlanTerm> = z.strictObject({\n key: sourceSchema,\n term: priceTermSchema,\n when: dottedSchema.optional(),\n hourly: dottedSchema,\n monthly: dottedSchema.optional(),\n regionHourly: dottedSchema.optional(),\n regionMonthly: dottedSchema.optional(),\n});\n\nconst HOST = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/;\n\n/**\n * This schema accepts the record of a provider with a plan list. The terms are the terms of the source of the\n * record. Each price term has its own key, and each spec has its own name. The name `pricing` is for the parser.\n */\nexport const planProviderSchema: z.ZodType<PlanProvider> = z\n .strictObject({\n source: sourceSchema,\n provider: textSchema,\n name: textSchema,\n host: z.string().regex(HOST, \"The host is a DNS name with small letters, digits, hyphens and dots.\"),\n paceMs: z.number().int().min(1),\n currency: z.string().refine(isCurrency, \"The currency is not a money unit of @mark1russell7/quantity.\"),\n terms: sourceTermsSchema,\n plans: listReadSchema,\n id: dottedSchema,\n label: dottedSchema.optional(),\n regions: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"field\"), path: dottedSchema }),\n z.strictObject({\n kind: z.literal(\"list\"),\n read: listReadSchema,\n plan: dottedSchema,\n region: dottedSchema,\n available: dottedSchema,\n }),\n ]),\n regionPrices: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"none\") }),\n z.strictObject({ kind: z.literal(\"map\"), path: dottedSchema }),\n z.strictObject({ kind: z.literal(\"list\"), path: dottedSchema, id: dottedSchema }),\n ]),\n prices: z.array(termSchema).min(1),\n specs: z.array(z.strictObject({ name: textSchema, path: dottedSchema, unit: textSchema.optional() })),\n })\n .superRefine((record, context) => {\n if (record.terms.source !== record.source) {\n context.addIssue({ code: \"custom\", message: `The terms are the terms of ${record.terms.source}, and not of ${record.source}.`, path: [\"terms\", \"source\"] });\n }\n const keys = record.prices.map((price) => price.key);\n if (new Set(keys).size !== keys.length) context.addIssue({ code: \"custom\", message: \"Two price terms have one key.\", path: [\"prices\"] });\n const names = record.specs.map((spec) => spec.name);\n if (new Set(names).size !== names.length) context.addIssue({ code: \"custom\", message: \"Two specs have one name.\", path: [\"specs\"] });\n if (names.includes(PLAN_PRICING_SPEC)) {\n context.addIssue({ code: \"custom\", message: `The spec name ${PLAN_PRICING_SPEC} is for the parser.`, path: [\"specs\"] });\n }\n });\n\n/** The result of a check of a provider record. */\nexport type PlanProviderRead = { readonly ok: true; readonly provider: PlanProvider } | { readonly ok: false; readonly problems: readonly string[] };\n\n/** This function examines a provider record, for example a record from a JSON file. */\nexport function parsePlanProvider(value: unknown): PlanProviderRead {\n const checked = planProviderSchema.safeParse(value);\n if (checked.success) return { ok: true, provider: checked.data };\n return { ok: false, problems: checked.error.issues.map((issue) => `${issue.path.join(\".\") || \"record\"}: ${issue.message}`) };\n}\n\n/** This function gives the value at a path of names with dots, or undefined. */\nfunction dig(value: unknown, dotted: string): unknown {\n return path(value, ...dotted.split(\".\"));\n}\n\n/**\n * This function gives the address of one page of a list of a provider. `after` is the value of the paging parameter\n * of the page. Without it, the address is the address of the first page.\n */\nexport function planListUrl(provider: PlanProvider, read: PlanListRead, after?: string): string {\n const { paging } = read;\n const pairs = Object.entries(read.query).filter(([name]) => paging.kind === \"none\" || after === undefined || name !== paging.param);\n if (after !== undefined && paging.kind !== \"none\") pairs.push([paging.param, after]);\n const search = pairs.map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join(\"&\");\n return `https://${provider.host}${read.path}${search === \"\" ? \"\" : `?${search}`}`;\n}\n\n/**\n * The page after an answer. The kind `next` has the value of the paging parameter of the next page. The kind `end`\n * tells that the answer is the last page. The kind `fault` tells that the answer has no valid paging field.\n */\nexport type PlanNextPage =\n | { readonly kind: \"next\"; readonly after: string }\n | { readonly kind: \"end\" }\n | { readonly kind: \"fault\"; readonly why: string };\n\n/**\n * This function gives the page after an answer. `page` is the number of the page of the answer, from 1. A paging\n * field that is missing or of a wrong type gives a fault, not the end. A part of a list gives wrong offers. A cursor\n * of empty text or null is the end.\n */\nexport function planNextPage(read: PlanListRead, answer: unknown, page: number): PlanNextPage {\n const { paging } = read;\n if (paging.kind === \"none\") return { kind: \"end\" };\n if (paging.kind === \"page\") {\n const raw = dig(answer, paging.pages);\n const pages = wholeNumber(raw);\n if (pages === undefined) return { kind: \"fault\", why: `The count of pages ${show(raw)} at ${show(paging.pages)} is not a whole number.` };\n return page < pages ? { kind: \"next\", after: String(page + 1) } : { kind: \"end\" };\n }\n const raw = dig(answer, paging.next);\n if (raw === null || (typeof raw === \"string\" && raw.trim() === \"\")) return { kind: \"end\" };\n if (typeof raw !== \"string\") return { kind: \"fault\", why: `The cursor ${show(raw)} at ${show(paging.next)} is not text or null.` };\n // The cursor is opaque, so it goes back with no change.\n return { kind: \"next\", after: raw };\n}\n\nfunction itemsOf(pages: readonly unknown[], read: PlanListRead, what: string): Read<readonly unknown[]> {\n const items: unknown[] = [];\n for (const [index, page] of pages.entries()) {\n const found = list(dig(page, read.items));\n if (found === undefined) return { ok: false, why: `The page ${index + 1} of the ${what} has no list at ${show(read.items)}.` };\n items.push(...found);\n }\n return { ok: true, value: items };\n}\n\n/** This function gives the available regions of each plan id from the rows of a list of regions. */\nfunction availability(\n rows: readonly unknown[],\n regions: Extract<PlanRegions, { kind: \"list\" }>,\n notes: string[],\n): ReadonlyMap<string, readonly string[]> {\n const map = new Map<string, string[]>();\n let bad = 0;\n let off = 0;\n for (const row of rows) {\n const plan = text(dig(row, regions.plan));\n const region = text(dig(row, regions.region));\n const available = dig(row, regions.available);\n if (plan === undefined || region === undefined || typeof available !== \"boolean\") {\n bad += 1;\n continue;\n }\n if (!available) {\n off += 1;\n continue;\n }\n const found = map.get(plan);\n if (found === undefined) map.set(plan, [region]);\n else if (!found.includes(region)) found.push(region);\n }\n if (bad > 0) notes.push(`${bad} rows of the list of regions are skipped: each has no plan, no region or no ${show(regions.available)} of true or false.`);\n if (off > 0) notes.push(`${off} pairs of a plan and a region are not available.`);\n return map;\n}\n\nfunction regionsOfItem(item: unknown, at: string): readonly string[] {\n const ids = (list(dig(item, at)) ?? []).map(text).filter((id): id is string => id !== undefined);\n return [...new Set(ids)];\n}\n\n/** This function gives the price object of one region of a plan, or undefined when the plan has no price for that region. */\nfunction regionPrice(item: unknown, prices: PlanRegionPrices, region: string): unknown {\n if (prices.kind === \"none\") return undefined;\n const found = dig(item, prices.path);\n if (prices.kind === \"map\") return isRecord(found) ? field(found, region) : undefined;\n return (list(found) ?? []).find((row) => text(dig(row, prices.id)) === region);\n}\n\n/** This function reads a price: the value at the path of the price of the region, else the value at the path of the plan. */\nfunction priceOf(item: unknown, region: unknown, itemPath: string | undefined, regionPath: string | undefined): unknown {\n if (itemPath === undefined) return undefined;\n const fromRegion = region === undefined ? undefined : dig(region, regionPath ?? itemPath);\n return fromRegion ?? dig(item, itemPath);\n}\n\n/** This function gives the meter of an hourly price with a monthly cap. Above the cap, an hour has no price. */\nfunction computeMeter(currency: string, hourly: number, monthly: number | undefined): Meter {\n const unit = canonicalUnit(`${currency}/h`);\n const tiers = [{ from: { value: 0, unit: \"h\" }, unitPrice: { value: hourly, unit } }];\n if (monthly !== undefined && monthly > 0 && hourly > 0) {\n const cap = rationals.toNumber(rationals.div(rationals.fromNumber(monthly), rationals.fromNumber(hourly)));\n tiers.push({ from: { value: cap, unit: \"h\" }, unitPrice: { value: 0, unit } });\n }\n return { name: PLAN_METER, tiers };\n}\n\nfunction specsOf(item: unknown, provider: PlanProvider, key: string): Spec[] {\n const specs: Spec[] = [];\n for (const spec of provider.specs) {\n const value = dig(item, spec.path);\n const shown = typeof value === \"number\" && Number.isFinite(value) ? String(value) : text(value);\n if (shown === undefined) continue;\n specs.push({ name: spec.name, value: spec.unit === undefined ? shown : `${shown} ${spec.unit}` });\n }\n specs.push({ name: PLAN_PRICING_SPEC, value: key });\n return specs;\n}\n\n/** This function reads one price term of one plan in one region. */\nfunction observationOf(\n provider: PlanProvider,\n item: unknown,\n plan: { readonly id: string; readonly title: string },\n term: PlanTerm,\n region: string,\n at: string,\n notes: string[],\n): MeteredObservation | undefined {\n const sourceId = `${plan.id}/${region}/${term.key}`;\n const id = offerId(provider.source, sourceId);\n const price = regionPrice(item, provider.regionPrices, region);\n const rawHourly = priceOf(item, price, term.hourly, term.regionHourly);\n const hourly = decimal(rawHourly);\n if (hourly === undefined) {\n notes.push(`The offer ${id} is skipped: its hourly price ${show(rawHourly)} is not a number of 0 or more.`);\n return undefined;\n }\n const rawMonthly = priceOf(item, price, term.monthly, term.regionMonthly);\n const monthly = rawMonthly === undefined || rawMonthly === null ? undefined : decimal(rawMonthly);\n if (rawMonthly !== undefined && rawMonthly !== null && monthly === undefined) {\n notes.push(`The offer ${id} is skipped: its monthly price ${show(rawMonthly)} is not a number of 0 or more.`);\n return undefined;\n }\n // An hourly meter of price 0 cannot give a monthly price, and the offer would look free.\n if (hourly === 0 && monthly !== undefined && monthly > 0) {\n notes.push(`The offer ${id} is skipped: its hourly price is 0 and its monthly price is ${String(monthly)}.`);\n return undefined;\n }\n // A monthly price of 0 cannot be a cap above an hourly price, so the meter has no cap. The note shows the fault of the data.\n if (hourly > 0 && monthly === 0) notes.push(`The offer ${id} has no monthly cap: its monthly price is 0 and its hourly price is ${String(hourly)}.`);\n return observeMetered(\n {\n id,\n source: provider.source,\n sourceId,\n title: plan.title,\n location: { provider: provider.provider, region },\n term: term.term,\n specs: specsOf(item, provider, term.key),\n },\n { offerId: id, at, period: { value: 1, unit: \"mo\" }, meters: [computeMeter(provider.currency, hourly, monthly)] },\n notes,\n );\n}\n\n/**\n * This function reads the answers of a plan list at the instant `at`. It gives one metered offer for each plan,\n * available region and price term. A provider with regions of the kind `list` needs the pages of that list. The\n * result has no link of a next page: the client reads each page of a list before the parse.\n */\nexport function parsePlanLists(provider: PlanProvider, answers: PlanAnswers, at: string): MeteredParseResult {\n checkAt(at);\n const notes: string[] = [];\n const items = itemsOf(answers.plans, provider.plans, \"plan list\");\n if (!items.ok) return refused(items.why);\n const { regions } = provider;\n let available: ReadonlyMap<string, readonly string[]> | undefined;\n if (regions.kind === \"list\") {\n if (answers.regions === undefined || answers.regions.length === 0) {\n return refused(`The provider ${provider.source} reads its regions from a list, and the answers have no page of that list.`);\n }\n const rows = itemsOf(answers.regions, regions.read, \"list of regions\");\n if (!rows.ok) return refused(rows.why);\n available = availability(rows.value, regions, notes);\n }\n const observations: MeteredObservation[] = [];\n const seen = new Set<string>();\n for (const [index, item] of items.value.entries()) {\n const planId = text(dig(item, provider.id));\n if (planId === undefined) {\n notes.push(`The plan ${index + 1} is skipped: it has no text at ${show(provider.id)}.`);\n continue;\n }\n const label = provider.label === undefined ? undefined : text(dig(item, provider.label));\n const plan = { id: planId, title: `${provider.name} ${label ?? planId}` };\n const places = regions.kind === \"field\" ? regionsOfItem(item, regions.path) : (available?.get(planId) ?? []);\n if (places.length === 0) {\n notes.push(`The plan ${planId} has no offer: it has no available region.`);\n continue;\n }\n for (const term of provider.prices) {\n if (term.when !== undefined && dig(item, term.when) !== true) continue;\n for (const region of places) {\n const observation = observationOf(provider, item, plan, term, region, at, notes);\n if (observation === undefined || seen.has(observation.offer.id)) continue;\n seen.add(observation.offer.id);\n observations.push(observation);\n }\n }\n }\n return { ok: true, observations, notes, next: null };\n}\n","import { instantOf, readJson, redact, send, type Pace, type Signal, type Transport } from \"./client.ts\";\nimport { refused, type MeteredParseResult, type Refused } from \"./parse.ts\";\nimport { parsePlanLists, parsePlanProvider, planListUrl, planNextPage, type PlanListRead, type PlanProvider } from \"./plans.ts\";\n\n/** The most pages of one list in one read. */\nexport const PLAN_PAGE_LIMIT = 20;\n\n/** The options of a plan client. The plan lists of the records of this package need no key. */\nexport interface PlanClientOptions<S extends Signal> {\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n}\n\n/** The options of one read of a provider. */\nexport interface PlanReadOptions {\n /** The most pages of each list, from 1 to `PLAN_PAGE_LIMIT`. The default is `PLAN_PAGE_LIMIT`. */\n readonly pages?: number | undefined;\n}\n\n/** A client of the plan lists of providers. */\nexport interface PlanClient<S extends Signal> {\n /** This method reads each page of the lists of a provider, and gives the result of `parsePlanLists`. */\n plans(provider: PlanProvider, options?: PlanReadOptions, signal?: S): Promise<MeteredParseResult>;\n}\n\nfunction checkPages(pages: number): number {\n if (!Number.isInteger(pages) || pages < 1 || pages > PLAN_PAGE_LIMIT) {\n throw new RangeError(`The count of pages is not a whole number from 1 to ${PLAN_PAGE_LIMIT}.`);\n }\n return pages;\n}\n\ntype Pages = { readonly ok: true; readonly pages: readonly unknown[] } | Refused;\n\n/**\n * This function makes a client of the plan lists of providers. Each address comes from the provider record. An\n * answer gives only the number or the cursor of the next page. A read refuses a list with more pages than the limit,\n * because a part of a list gives wrong regions.\n */\nexport function createPlanClient<S extends Signal>(options: PlanClientOptions<S>): PlanClient<S> {\n const { pace, transport } = options;\n\n const readList = async (provider: PlanProvider, read: PlanListRead, what: string, limit: number, signal?: S): Promise<Pages> => {\n const pages: unknown[] = [];\n let after: string | undefined;\n while (pages.length < limit) {\n const page = pages.length + 1;\n const exchange = { method: \"GET\" as const, url: planListUrl(provider, read, after), headers: { accept: \"application/json\" }, body: null };\n const input = {\n source: provider.name,\n host: provider.host,\n minIntervalMs: provider.paceMs,\n what: page === 1 ? what : `${what}, page ${page}`,\n secrets: [],\n redact,\n exchange,\n };\n const answer = await send(pace, transport, input, signal);\n const json = readJson(answer, input);\n if (!json.ok) return json;\n pages.push(json.json);\n const next = planNextPage(read, json.json, page);\n if (next.kind === \"end\") return { ok: true, pages };\n if (next.kind === \"fault\") return refused(`The read stops at the page ${page} of ${what}. ${next.why}`);\n if (next.after === after) return refused(`The read stops: ${what} gives the cursor of its page ${page} again.`);\n after = next.after;\n }\n return refused(`The read stops: ${what} has more pages than the limit of ${limit}.`);\n };\n\n return {\n async plans(provider, readOptions = {}, signal) {\n const checked = parsePlanProvider(provider);\n if (!checked.ok) throw new RangeError(`The provider record is not valid: ${checked.problems.join(\" \")}`);\n const limit = checkPages(readOptions.pages ?? PLAN_PAGE_LIMIT);\n const record = checked.provider;\n const plans = await readList(record, record.plans, \"the plan list\", limit, signal);\n if (!plans.ok) return plans;\n let regions: readonly unknown[] | undefined;\n if (record.regions.kind === \"list\") {\n const read = await readList(record, record.regions.read, \"the list of regions\", limit, signal);\n if (!read.ok) return read;\n regions = read.pages;\n }\n return parsePlanLists(record, { plans: plans.pages, regions }, instantOf(pace.now()));\n },\n };\n}\n","/**\n * The adapters of the sellers of a market. Each parser reads the answer of an official API at one instant, and\n * gives the current offers and price readings as records of `@mark1russell7/market`. A parser keeps no store,\n * and it sends no request. Each source also has the terms of its API. The Azure parser gives the metered prices\n * of cloud resources as metered offers. The plan parser reads the plan list of each provider record as metered offers.\n * The BLS parser reads the average prices of the Consumer Price Index as average prices of `@mark1russell7/market`.\n *\n * Each client sends the requests of one API through a transport that its host gives. The scheduler of\n * `polite-crawler/api` keeps the pace of each host. A client keeps no store, and no message of a client has a key.\n */\nimport type { SourceTerms } from \"@mark1russell7/market\";\nimport { AZURE_TERMS } from \"./azure.ts\";\nimport { BEST_BUY_TERMS } from \"./bestbuy.ts\";\nimport { BLS_TERMS } from \"./bls.ts\";\nimport { DIGIKEY_TERMS } from \"./digikey.ts\";\nimport { EBAY_TERMS } from \"./ebay.ts\";\nimport { LINODE_TERMS, VULTR_TERMS } from \"./providers.ts\";\n\nexport {\n AZURE_API_VERSION,\n AZURE_FILTER_FIELDS,\n AZURE_PRICES_URL,\n AZURE_PROVIDER,\n AZURE_SOURCE,\n AZURE_TERMS,\n azureNextPage,\n azurePricesUrl,\n azureUnit,\n isAzurePricesUrl,\n parseAzureRetailPricePages,\n parseAzureRetailPrices,\n type AzureFilter,\n type AzureFilterField,\n type AzureUnit,\n} from \"./azure.ts\";\nexport {\n BLS_API_URL,\n BLS_SERIES_LIMIT,\n BLS_SOURCE,\n BLS_STAPLES,\n BLS_STATEMENT,\n BLS_TERMS,\n BLS_YEAR_LIMIT,\n blsRequest,\n parseBlsSeries,\n type AverageParseResult,\n type BlsSeries,\n} from \"./bls.ts\";\nexport { BLS_HOST, BLS_PACE_MS, BLS_QUOTA, BLS_QUOTA_KEY, createBlsClient, type BlsClient, type BlsClientOptions } from \"./bls-client.ts\";\nexport {\n BEST_BUY_SOURCE,\n BEST_BUY_TERMS,\n bestBuyCondition,\n parseBestBuyOpenBox,\n parseBestBuyProduct,\n parseBestBuyProducts,\n} from \"./bestbuy.ts\";\nexport {\n DIGIKEY_SELLER,\n DIGIKEY_SOURCE,\n DIGIKEY_TERMS,\n parseDigiKeyKeywordSearch,\n parseDigiKeyProductDetails,\n} from \"./digikey.ts\";\nexport { EBAY_SOURCE, EBAY_TERMS, ebayCondition, parseEbayItem, parseEbaySearch } from \"./ebay.ts\";\nexport type { MeteredObservation, MeteredParseResult, Observation, ParseResult } from \"./parse.ts\";\nexport { ApiError, SECRET_MARK, redact } from \"./client.ts\";\nexport type { ApiScheduler, Exchange, Pace, Reply, Signal, Transport } from \"./client.ts\";\nexport {\n DIGIKEY_HOST,\n DIGIKEY_PACE_MS,\n DIGIKEY_SANDBOX_HOST,\n DIGIKEY_SEARCH_LIMIT,\n DIGIKEY_US,\n createDigiKeyClient,\n} from \"./digikey-client.ts\";\nexport type { DigiKeyClient, DigiKeyClientOptions, DigiKeyLocale } from \"./digikey-client.ts\";\nexport {\n EBAY_HOST,\n EBAY_PACE_MS,\n EBAY_SANDBOX_HOST,\n EBAY_SCOPE,\n EBAY_SEARCH_LIMIT,\n EBAY_US,\n createEbayClient,\n} from \"./ebay-client.ts\";\nexport type { EbayClient, EbayClientOptions } from \"./ebay-client.ts\";\nexport { AZURE_HOST, AZURE_PACE_MS, AZURE_PAGE_LIMIT, createAzureClient } from \"./azure-client.ts\";\nexport type { AzureClient, AzureClientOptions, AzureReadOptions } from \"./azure-client.ts\";\nexport { BEST_BUY_HOST, BEST_BUY_PACE_MS, BEST_BUY_PAGE_LIMIT, createBestBuyClient } from \"./bestbuy-client.ts\";\nexport type { BestBuyClient, BestBuyClientOptions } from \"./bestbuy-client.ts\";\nexport {\n PLAN_METER,\n PLAN_PRICING_SPEC,\n parsePlanLists,\n parsePlanProvider,\n planListUrl,\n planNextPage,\n planProviderSchema,\n type PlanAnswers,\n type PlanListRead,\n type PlanNextPage,\n type PlanPaging,\n type PlanProvider,\n type PlanProviderRead,\n type PlanRegionPrices,\n type PlanRegions,\n type PlanSpec,\n type PlanTerm,\n} from \"./plans.ts\";\nexport { LINODE_PLANS, LINODE_SOURCE, LINODE_TERMS, PLAN_PROVIDERS, VULTR_PLANS, VULTR_SOURCE, VULTR_TERMS } from \"./providers.ts\";\nexport { PLAN_PAGE_LIMIT, createPlanClient } from \"./plans-client.ts\";\nexport type { PlanClient, PlanClientOptions, PlanReadOptions } from \"./plans-client.ts\";\n\n/** The terms of each source of this package: the sellers in the order of the hand crawl, then Azure, then the plan lists. */\nexport const SOURCE_TERMS: readonly SourceTerms[] = [EBAY_TERMS, BEST_BUY_TERMS, DIGIKEY_TERMS, AZURE_TERMS, LINODE_TERMS, VULTR_TERMS, BLS_TERMS];\n"],"mappings":";;;;;;;AAoDA,SAAgB,SAAS,OAA4D;CACnF,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;;AAGA,SAAgB,MAAM,OAAgB,KAAsB;CAC1D,OAAO,SAAS,KAAK,KAAK,OAAO,OAAO,OAAO,GAAG,IAAI,MAAM,OAAO,KAAA;AACrE;;AAGA,SAAgB,KAAK,OAAgB,GAAG,MAAkC;CACxE,IAAI,UAAU;CACd,KAAK,MAAM,OAAO,MAAM,UAAU,MAAM,SAAS,GAAG;CACpD,OAAO;AACT;;AAGA,SAAgB,KAAK,OAAgD;CACnE,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,KAAA;AACxC;;AAGA,SAAgB,KAAK,OAAoC;CACvD,IAAI,OAAO,UAAU,UAAU,OAAO,KAAA;CACtC,MAAM,UAAU,MAAM,KAAK;CAC3B,OAAO,YAAY,KAAK,KAAA,IAAY;AACtC;;AAGA,SAAgB,YAAY,OAAoC;CAC9D,OAAO,OAAO,UAAU,YAAY,OAAO,cAAc,KAAK,KAAK,SAAS,IAAI,QAAQ,KAAA;AAC1F;AAEA,MAAM,UAAU;;;;;AAMhB,SAAgB,QAAQ,OAAoC;CAC1D,IAAI,OAAO,UAAU,UAAU,OAAO,OAAO,SAAS,KAAK,KAAK,SAAS,IAAI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O,MAAM;GAAO;EAAQ,GAAG,UAAU,KAAK,IAAI,CAAC,CAAC;CACtF,EACF;AACF;;;AC4BA,MAAa,eAAuC;CAAC;CAAY;CAAgB;CAAe;CAAa;CAAc;CAAa;AAAS"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["observationOf","shippingOf","specsOf","mapProduct","sellerOf","specsOf","specsOf","statusLine","SOURCE","SOURCE","SOURCE","SOURCE","checkPages"],"sources":["../src/parse.ts","../src/azure.ts","../src/bestbuy.ts","../src/bls.ts","../src/digikey.ts","../src/ebay.ts","../src/providers.ts","../src/client.ts","../src/bls-client.ts","../src/digikey-client.ts","../src/ebay-client.ts","../src/azure-client.ts","../src/bestbuy-client.ts","../src/plans.ts","../src/plans-client.ts","../src/index.ts"],"sourcesContent":["import {\n instantSchema,\n meteredObservationSchema,\n moneySchema,\n offerSchema,\n priceReadingSchema,\n type MeteredObservation,\n type MeteredOffer,\n type MeteredReading,\n type Observation,\n type Offer,\n type PriceReading,\n} from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport { z } from \"zod\";\n\n/** One offer of a source, and its price reading at the instant of the answer. `@mark1russell7/market` has the type. */\nexport type { Observation };\n\n/** One metered offer of a source, and its reading at the instant of the answer. `@mark1russell7/market` has the type. */\nexport type { MeteredObservation };\n\n/**\n * The result of a parser. With `ok`, the answer has the documented shape. Each observation is valid under the\n * schemas of `@mark1russell7/market`, and each note tells why the parser skipped a record or a field. Without\n * `ok`, the answer does not have the documented shape, and `problems` tells why.\n */\nexport type ParseResult =\n | { readonly ok: true; readonly observations: readonly Observation[]; readonly notes: readonly string[] }\n | { readonly ok: false; readonly problems: readonly string[] };\n\n/** The result of a parser for an answer that does not have the documented shape. */\nexport type Refused = Extract<ParseResult, { readonly ok: false }>;\n\n/**\n * The result of a parser of metered prices. With `ok`, each observation is valid under the schemas of\n * `@mark1russell7/market`, and `next` is the link of the next page of the answer, or null. Without `ok`, the\n * answer does not have the documented shape, and `problems` tells why.\n */\nexport type MeteredParseResult =\n | {\n readonly ok: true;\n readonly observations: readonly MeteredObservation[];\n readonly notes: readonly string[];\n readonly next: string | null;\n }\n | Refused;\n\n/** A value that a reader found, or the reason that it found none. */\nexport type Read<T> = { readonly ok: true; readonly value: T } | { readonly ok: false; readonly why: string };\n\n/** This function tells if a JSON value is an object that is not a list. */\nexport function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/** This function gives the value at `key` of a JSON object, or undefined when the value is not an object. */\nexport function field(value: unknown, key: string): unknown {\n return isRecord(value) && Object.hasOwn(value, key) ? value[key] : undefined;\n}\n\n/** This function gives the value at a path of keys in a JSON value, or undefined when a step is missing. */\nexport function path(value: unknown, ...keys: readonly string[]): unknown {\n let current = value;\n for (const key of keys) current = field(current, key);\n return current;\n}\n\n/** This function gives a list, or undefined for each other value. A source writes an absent list as null or as no key. */\nexport function list(value: unknown): readonly unknown[] | undefined {\n return Array.isArray(value) ? value : undefined;\n}\n\n/** This function gives a text without spaces at its ends, or undefined for an empty text, null and each other value. */\nexport function text(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n return trimmed === \"\" ? undefined : trimmed;\n}\n\n/** This function gives a whole number of zero or more, or undefined for each other value. */\nexport function wholeNumber(value: unknown): number | undefined {\n return typeof value === \"number\" && Number.isSafeInteger(value) && value >= 0 ? value : undefined;\n}\n\nconst DECIMAL = /^\\d+(\\.\\d+)?$/;\n\n/**\n * This function gives the number of a decimal of zero or more. The decimal is a finite JSON number, or a text with\n * digits, and a point and digits as an option. It refuses an exponent, a sign, a space and a hexadecimal text.\n */\nexport function decimal(value: unknown): number | undefined {\n if (typeof value === \"number\") return Number.isFinite(value) && value >= 0 ? value : undefined;\n if (typeof value !== \"string\" || !DECIMAL.test(value)) return undefined;\n const number = Number(value);\n return Number.isFinite(number) ? number : undefined;\n}\n\n/** This function gives a short JSON text of a value for a note. */\nexport function show(value: unknown): string {\n let shown: string | undefined;\n try {\n shown = JSON.stringify(value);\n } catch {\n shown = undefined;\n }\n if (shown === undefined) return String(typeof value);\n return shown.length > 40 ? `${shown.slice(0, 37)}...` : shown;\n}\n\n/** This function gives an amount of money from an amount and a currency code, or the reason that it is not one. */\nexport function readMoney(amount: unknown, currency: unknown): Read<Quantity> {\n const notDecimal: Read<Quantity> = { ok: false, why: `the amount ${show(amount)} is not a decimal of zero or more` };\n const value = decimal(amount);\n if (value === undefined) return notDecimal;\n const unit = text(currency);\n if (unit === undefined) return { ok: false, why: `the amount ${show(amount)} has no currency` };\n if (!isCurrency(unit)) return { ok: false, why: `the currency ${show(unit)} is not a money unit of @mark1russell7/quantity` };\n const parsed = moneySchema.safeParse({ value, unit });\n return parsed.success ? { ok: true, value: parsed.data } : notDecimal;\n}\n\n/** This function tells if a currency code is a money unit of `@mark1russell7/quantity`. */\nexport function isCurrency(unit: string): boolean {\n return moneySchema.safeParse({ value: 0, unit }).success;\n}\n\nconst httpsSchema = z.url({ protocol: /^https$/ });\n\n/** This function gives an `https` URL, or undefined for each other value. */\nexport function httpsUrl(value: unknown): string | undefined {\n const candidate = text(value);\n return candidate !== undefined && httpsSchema.safeParse(candidate).success ? candidate : undefined;\n}\n\n/** This function gives an instant in UTC in the ISO 8601 form, or undefined for each other value. */\nexport function instant(value: unknown): string | undefined {\n const candidate = text(value);\n return candidate !== undefined && instantSchema.safeParse(candidate).success ? candidate : undefined;\n}\n\n/**\n * This function examines the instant of an answer.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function checkAt(at: string): void {\n if (!instantSchema.safeParse(at).success) {\n throw new RangeError(`The instant ${show(at)} of the answer is not an ISO 8601 instant in UTC.`);\n }\n}\n\n/** This function gives a copy of an object without its keys that have the value undefined. */\nexport function compact<T extends object>(record: T): T {\n return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== undefined)) as T;\n}\n\nfunction issues(error: z.ZodError): string {\n return error.issues.map((issue) => `${issue.path.join(\".\") || \"(root)\"}: ${issue.message}`).join(\", \");\n}\n\n/**\n * This function examines an offer and its reading with the schemas of `@mark1russell7/market`. It gives the\n * observation, or it adds a note and gives undefined.\n */\nexport function observe(offer: Offer, reading: PriceReading, notes: string[]): Observation | undefined {\n const checkedOffer = offerSchema.safeParse(compact(offer));\n if (!checkedOffer.success) {\n notes.push(`The offer ${offer.id} is skipped: the schema refuses it (${issues(checkedOffer.error)}).`);\n return undefined;\n }\n const checkedReading = priceReadingSchema.safeParse(compact(reading));\n if (!checkedReading.success) {\n notes.push(`The offer ${offer.id} is skipped: the schema refuses its reading (${issues(checkedReading.error)}).`);\n return undefined;\n }\n return { offer: checkedOffer.data, reading: checkedReading.data };\n}\n\n/**\n * This function examines a metered offer and its reading with the schemas of `@mark1russell7/market`. It gives\n * the observation, or it adds a note and gives undefined.\n */\nexport function observeMetered(offer: MeteredOffer, reading: MeteredReading, notes: string[]): MeteredObservation | undefined {\n const checked = meteredObservationSchema.safeParse({ offer: compact(offer), reading: compact(reading) });\n if (!checked.success) {\n notes.push(`The offer ${offer.id} is skipped: the schema refuses it (${issues(checked.error)}).`);\n return undefined;\n }\n return checked.data;\n}\n\n/** This function gives a result with the observations. An offer that the answer repeats counts once. */\nexport function done(observations: readonly Observation[], notes: readonly string[]): ParseResult {\n const seen = new Set<string>();\n const unique = observations.filter((each) => {\n if (seen.has(each.offer.id)) return false;\n seen.add(each.offer.id);\n return true;\n });\n return { ok: true, observations: unique, notes };\n}\n\n/** This function gives a result for an answer that does not have the documented shape. */\nexport function refused(...problems: readonly string[]): Refused {\n return { ok: false, problems };\n}\n","import {\n meteredKindOf,\n offerId,\n type Meter,\n type MeteredObservation,\n type PriceTerm,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport { canonicalUnit, rationals } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n decimal,\n field,\n isCurrency,\n isRecord,\n list,\n observeMetered,\n refused,\n show,\n text,\n type MeteredParseResult,\n} from \"./parse.ts\";\n\n/** The name of the Azure Retail Prices API as a source of metered offers. */\nexport const AZURE_SOURCE = \"azure\";\n\n/** The provider of the location of each offer of the Azure Retail Prices API. */\nexport const AZURE_PROVIDER = \"azure\";\n\n/**\n * The terms of the Azure Retail Prices API. The API needs no key, and its documentation names tools for internal\n * analysis and price comparison. The Microsoft APIs Terms of Use permit copies only for the use of the\n * application, and they forbid redistribution and resale of the data.\n */\nexport const AZURE_TERMS: SourceTerms = {\n source: AZURE_SOURCE,\n retention: { kind: \"keep\" },\n deleteWhenEnded: false,\n priceModel: true,\n clause:\n \"Azure Retail Prices REST API overview, read on 2026-11-18, and Microsoft APIs Terms of Use of October 2025, sections 3(b)(4) and 3(b)(14): copies only as the application needs them, and no redistribution or resale\",\n};\n\n/** The address of the Azure Retail Prices API. */\nexport const AZURE_PRICES_URL = \"https://prices.azure.com/api/retail/prices\";\n\n/** The version of the API that the request builder asks for. Only this version gives the prices of savings plans. */\nexport const AZURE_API_VERSION = \"2023-01-01-preview\";\n\n/** The fields of a filter of the Azure Retail Prices API, from its documentation. */\nexport const AZURE_FILTER_FIELDS = [\n \"armRegionName\",\n \"location\",\n \"meterId\",\n \"meterName\",\n \"productId\",\n \"skuId\",\n \"productName\",\n \"skuName\",\n \"serviceName\",\n \"serviceId\",\n \"serviceFamily\",\n \"priceType\",\n \"armSkuName\",\n] as const;\n\n/** A field of a filter of the Azure Retail Prices API. */\nexport type AzureFilterField = (typeof AZURE_FILTER_FIELDS)[number];\n\n/** A filter of the Azure Retail Prices API: the value of each field. The API compares each value with its case. */\nexport type AzureFilter = { readonly [Field in AzureFilterField]?: string };\n\n/** A unit of measure of the API: the count of units that one price buys, and the unit of `@mark1russell7/quantity`. */\nexport interface AzureUnit {\n readonly count: number;\n readonly unit: string;\n}\n\n/** The longest value of a field of a filter, in code units. */\nconst FILTER_VALUE_LIMIT = 200;\n\n/**\n * This function gives the URL of a read of the Azure Retail Prices API with a filter. Each field of the filter\n * gives the term `field eq 'value'`, and the terms join with `and`. Without a currency, the API gives US dollars.\n *\n * @throws RangeError when the filter has no field, or a field that the API does not filter. It also throws when a\n * value is empty, has a space at an end, has a control character or has more than 200 characters. A currency that\n * `@mark1russell7/quantity` does not have also gives a `RangeError`.\n */\nexport function azurePricesUrl(filter: AzureFilter, currency?: string): string {\n const fields: readonly string[] = AZURE_FILTER_FIELDS;\n const other = Object.keys(filter).find((name) => !fields.includes(name));\n if (other !== undefined) throw new RangeError(`The API does not filter the field ${show(other)}.`);\n const terms: string[] = [];\n for (const name of AZURE_FILTER_FIELDS) {\n const value: unknown = filter[name];\n if (value === undefined) continue;\n if (\n typeof value !== \"string\" ||\n value === \"\" ||\n value !== value.trim() ||\n value.length > FILTER_VALUE_LIMIT ||\n /[\\u0000-\\u001f\\u007f]/.test(value)\n ) {\n throw new RangeError(\n `The value of the field ${name} is not a text of 1 to ${FILTER_VALUE_LIMIT} characters with no control character and no space at an end.`,\n );\n }\n terms.push(`${name} eq '${value.replaceAll(\"'\", \"''\")}'`);\n }\n if (terms.length === 0) throw new RangeError(\"The filter has no field. A read of each price of Azure is a large crawl.\");\n const query = [`api-version=${AZURE_API_VERSION}`];\n if (currency !== undefined) {\n if (!/^[A-Z]{3}$/.test(currency) || !isCurrency(currency)) {\n throw new RangeError(`The currency ${show(currency)} is not a money unit of @mark1russell7/quantity.`);\n }\n query.push(`currencyCode=${encodeURIComponent(`'${currency}'`)}`);\n }\n query.push(`$filter=${encodeURIComponent(terms.join(\" and \"))}`);\n return `${AZURE_PRICES_URL}?${query.join(\"&\")}`;\n}\n\n/**\n * The pattern of a link to the Azure Retail Prices API: `https`, the host `prices.azure.com`, no port or the port 443,\n * the path `/api/retail/prices` and an optional query. The pattern refuses a user name, a password and a fragment.\n */\nconst AZURE_PRICES_LINK = /^https:\\/\\/prices\\.azure\\.com(?::443)?\\/api\\/retail\\/prices(?:\\?[^#\\s]*)?$/;\n\n/** This function tells if a link goes to the Azure Retail Prices API (`AZURE_PRICES_LINK`). */\nexport function isAzurePricesUrl(link: string): boolean {\n return AZURE_PRICES_LINK.test(link);\n}\n\n/** This function gives the link of the next page of an answer, or null. A link to another address gives null. */\nexport function azureNextPage(answer: unknown): string | null {\n const link = text(field(answer, \"NextPageLink\"));\n return link !== undefined && isAzurePricesUrl(link) ? link : null;\n}\n\n/** The words of an amount in a unit of measure, and their units. A GB of Azure is 2^30 bytes, thus a GiB. */\nconst AMOUNT_WORDS: Readonly<Record<string, string>> = {\n Second: \"s\",\n Seconds: \"s\",\n Minute: \"min\",\n Minutes: \"min\",\n Hour: \"h\",\n Hours: \"h\",\n Day: \"d\",\n Days: \"d\",\n Month: \"mo\",\n Months: \"mo\",\n Year: \"yr\",\n Years: \"yr\",\n KB: \"KiB\",\n KiB: \"KiB\",\n MB: \"MiB\",\n MiB: \"MiB\",\n GB: \"GiB\",\n GiB: \"GiB\",\n TB: \"TiB\",\n TiB: \"TiB\",\n};\n\n/** The words of a time after the slash of a unit of measure, and their units. */\nconst PER_WORDS: Readonly<Record<string, string>> = { Second: \"s\", Minute: \"min\", Hour: \"h\", Day: \"d\", Month: \"mo\", Year: \"yr\" };\n\n/** A unit of measure: a count with `K` or `M`, a word of an amount, and `/` and a time. Only the count is necessary. */\nconst UNIT_OF_MEASURE = /^([1-9][0-9]{0,8})([KM]?)(?: ([A-Za-z]+))?(?:\\/([A-Za-z]+))?$/;\n\n/**\n * This function gives the unit of a unit of measure of the API, or undefined when the parser does not know it. A\n * count with no word gives `{count}`, for example `10K` gives 10,000 of `{count}`. A word of data or time gives\n * its unit, and `/Month` multiplies it by a month. Only `1/Hour` and `1/Month` give a time alone.\n */\nexport function azureUnit(unitOfMeasure: string): AzureUnit | undefined {\n const match = UNIT_OF_MEASURE.exec(unitOfMeasure);\n if (match === null) return undefined;\n const [, digits = \"\", multiplier = \"\", word, per] = match;\n const count = Number(digits) * (multiplier === \"K\" ? 1000 : multiplier === \"M\" ? 1_000_000 : 1);\n const amount = word === undefined ? undefined : AMOUNT_WORDS[word];\n const time = per === undefined ? undefined : PER_WORDS[per];\n if ((word !== undefined && amount === undefined) || (per !== undefined && time === undefined)) return undefined;\n let unit: string;\n if (amount !== undefined) unit = time === undefined ? amount : `${amount}·${time}`;\n else if (time !== undefined && count === 1) unit = time;\n else unit = time === undefined ? \"{count}\" : `{count}·${time}`;\n try {\n meteredKindOf(priceUnit(\"USD\", unit));\n } catch {\n return undefined;\n }\n return { count, unit };\n}\n\nfunction priceUnit(currency: string, unit: string): string {\n return canonicalUnit(unit.includes(\"·\") ? `${currency}/(${unit})` : `${currency}/${unit}`);\n}\n\n/** This function gives the exact price of one unit, from the price of `count` units, as the nearest number. */\nfunction perUnit(price: number, count: number): number {\n return rationals.toNumber(rationals.div(rationals.fromNumber(price), rationals.fromNumber(count)));\n}\n\n/** A row of an answer that the parser read. */\ninterface Row {\n readonly where: string;\n readonly region: string;\n readonly skuId: string;\n readonly meterId: string;\n readonly meterName: string;\n readonly unitOfMeasure: string;\n readonly unit: AzureUnit;\n readonly currency: string;\n readonly start: number;\n readonly price: number;\n readonly type: string;\n readonly title: string;\n readonly spot: boolean;\n readonly specs: readonly Spec[];\n readonly item: Readonly<Record<string, unknown>>;\n}\n\n/** One offer that a row gives: its term, the price of its tier, and the upfront money of a reservation. */\ninterface Variant {\n readonly key: string;\n readonly term: PriceTerm;\n readonly title: string;\n readonly price: number;\n readonly upfront?: number;\n}\n\ninterface MeterDraft {\n readonly meterId: string;\n readonly meterName: string;\n readonly unit: AzureUnit;\n readonly tiers: Map<number, number>;\n problem?: string;\n}\n\ninterface OfferDraft {\n readonly sourceId: string;\n readonly region: string;\n readonly title: string;\n readonly term: PriceTerm;\n readonly specs: readonly Spec[];\n readonly currency: string;\n readonly upfront: number | undefined;\n readonly meters: Map<string, MeterDraft>;\n}\n\n/** The text of a spot term at the end of a SKU name: `Spot`, or `Low Priority` of the older VMs that Azure can end. */\nconst SPOT = /(?:^|\\s)(?:Spot|Low Priority)$/;\n\n/** A term of a reservation or of a savings plan: `1 Year`, `3 Years` or `10 Years`. */\nconst YEARS = /^([1-9][0-9]?) Years?$/;\n\nfunction yearsOf(value: unknown): number | undefined {\n const match = YEARS.exec(text(value) ?? \"\");\n return match?.[1] === undefined ? undefined : Number(match[1]);\n}\n\n/** The fields of a row that each offer keeps as specs. The spec `pricing` adds the key of the term of the offer. */\nconst SPEC_FIELDS = [\"serviceName\", \"serviceFamily\", \"productName\", \"skuName\", \"armSkuName\", \"location\"] as const;\n\nfunction readRow(item: unknown, where: string, notes: string[]): Row | undefined {\n if (!isRecord(item)) {\n notes.push(`The row ${where} is skipped: it is not an object.`);\n return undefined;\n }\n const skuId = text(item[\"skuId\"]);\n const meterId = text(item[\"meterId\"]);\n const meterName = text(item[\"meterName\"]);\n const region = text(item[\"armRegionName\"]) ?? text(item[\"location\"]);\n const product = text(item[\"productName\"]);\n const sku = text(item[\"skuName\"]);\n const type = text(item[\"type\"]);\n if (\n skuId === undefined ||\n meterId === undefined ||\n meterName === undefined ||\n region === undefined ||\n product === undefined ||\n sku === undefined ||\n type === undefined\n ) {\n const fields = { skuId, meterId, meterName, armRegionName: region, productName: product, skuName: sku, type };\n const missing = Object.entries(fields).filter(([, value]) => value === undefined);\n notes.push(`The row ${where} is skipped: it has no ${missing.map(([name]) => name).join(\", \")}.`);\n return undefined;\n }\n const unitOfMeasure = text(item[\"unitOfMeasure\"]) ?? \"\";\n const unit = azureUnit(unitOfMeasure);\n if (unit === undefined) {\n notes.push(`The row ${where} is skipped: the parser does not know the unit of measure ${show(unitOfMeasure)}.`);\n return undefined;\n }\n const currency = text(item[\"currencyCode\"]);\n if (currency === undefined || !isCurrency(currency)) {\n notes.push(`The row ${where} is skipped: the currency ${show(item[\"currencyCode\"])} is not a money unit of @mark1russell7/quantity.`);\n return undefined;\n }\n const start = decimal(item[\"tierMinimumUnits\"]);\n const price = decimal(item[\"retailPrice\"]);\n if (start === undefined || price === undefined) {\n const name = start === undefined ? \"tierMinimumUnits\" : \"retailPrice\";\n notes.push(`The row ${where} is skipped: its ${name} ${show(item[name])} is not a decimal of zero or more.`);\n return undefined;\n }\n const specs: Spec[] = [];\n for (const name of SPEC_FIELDS) {\n const value = text(item[name]);\n if (value !== undefined) specs.push({ name, value });\n }\n const spot = SPOT.test(sku);\n return { where, region, skuId, meterId, meterName, unitOfMeasure, unit, currency, start, price, type, title: `${product}, ${sku}`, spot, specs, item };\n}\n\nfunction variantsOf(row: Row, notes: string[]): Variant[] {\n const base: PriceTerm = row.spot ? { kind: \"spot\" } : { kind: \"on-demand\" };\n if (row.type === \"DevTestConsumption\") return [{ key: \"dev-test\", term: base, title: `${row.title}, Dev/Test`, price: row.price }];\n if (row.type === \"Reservation\") {\n const years = yearsOf(row.item[\"reservationTerm\"]);\n if (years === undefined) {\n notes.push(`The row ${row.where} is skipped: its reservationTerm ${show(row.item[\"reservationTerm\"])} is not a count of years.`);\n return [];\n }\n const term: PriceTerm = { kind: \"committed\", length: { value: years, unit: \"yr\" } };\n return [{ key: `reservation-${years}y`, term, title: `${row.title}, ${years}-year reservation`, price: 0, upfront: row.price }];\n }\n if (row.type !== \"Consumption\") {\n notes.push(`The row ${row.where} is skipped: its type ${show(row.type)} is not a type of the documentation.`);\n return [];\n }\n const variants: Variant[] = [{ key: \"consumption\", term: base, title: row.title, price: row.price }];\n const plans = row.item[\"savingsPlan\"];\n (list(plans) ?? []).forEach((plan, index) => {\n const years = yearsOf(field(plan, \"term\"));\n const price = decimal(field(plan, \"retailPrice\"));\n if (years === undefined || price === undefined) {\n notes.push(`The savings plan ${row.where}.savingsPlan[${index}] is skipped: it has no term in years or no retailPrice.`);\n return;\n }\n const term: PriceTerm = { kind: \"committed\", length: { value: years, unit: \"yr\" } };\n variants.push({ key: `savings-plan-${years}y`, term, title: `${row.title}, ${years}-year savings plan`, price });\n });\n if (plans !== undefined && plans !== null && list(plans) === undefined) {\n notes.push(`The field savingsPlan of the row ${row.where} is not a list, and the parser does not read it.`);\n }\n return variants;\n}\n\nfunction addRow(row: Row, drafts: Map<string, OfferDraft>, notes: string[]): void {\n for (const variant of variantsOf(row, notes)) {\n const sourceId = `${row.region}/${row.skuId}/${variant.key}`;\n let draft = drafts.get(sourceId);\n if (draft === undefined) {\n draft = {\n sourceId,\n region: row.region,\n title: variant.title,\n term: variant.term,\n specs: [...row.specs, { name: \"pricing\", value: variant.key }],\n currency: row.currency,\n upfront: variant.upfront,\n meters: new Map(),\n };\n drafts.set(sourceId, draft);\n } else if (draft.currency !== row.currency) {\n notes.push(`The row ${row.where} is skipped: its currency ${row.currency} is not the currency of the offer ${offerId(AZURE_SOURCE, sourceId)}.`);\n continue;\n } else if (variant.upfront !== undefined) {\n notes.push(`The row ${row.where} is skipped: it repeats the reservation ${offerId(AZURE_SOURCE, sourceId)}.`);\n continue;\n }\n const key = `${row.meterId}\\u0000${row.meterName}\\u0000${row.unitOfMeasure}`;\n let meter = draft.meters.get(key);\n if (meter === undefined) {\n meter = { meterId: row.meterId, meterName: row.meterName, unit: row.unit, tiers: new Map() };\n draft.meters.set(key, meter);\n }\n if (row.start !== 0 && row.unit.count !== 1) {\n meter.problem = `a tier starts at ${row.start} of the unit of measure ${row.unitOfMeasure}, and the documentation does not tell the unit of the start`;\n }\n const known = meter.tiers.get(row.start);\n if (known !== undefined && known !== variant.price) {\n meter.problem = `two rows give the tier at ${row.start} the prices ${known} and ${variant.price}`;\n }\n meter.tiers.set(row.start, variant.price);\n }\n}\n\nfunction meterOf(draft: OfferDraft, meter: MeterDraft, name: string, id: string, notes: string[]): Meter | undefined {\n if (meter.problem !== undefined) {\n notes.push(`The meter ${show(meter.meterName)} of the offer ${id} is skipped: ${meter.problem}.`);\n return undefined;\n }\n const starts = [...meter.tiers.keys()].sort((a, b) => a - b);\n if (starts[0] !== 0) {\n notes.push(`The meter ${show(meter.meterName)} of the offer ${id} is skipped: it has no tier that starts at 0.`);\n return undefined;\n }\n const unitPrice = priceUnit(draft.currency, meter.unit.unit);\n return {\n name,\n tiers: starts.map((start) => ({\n from: { value: start, unit: meter.unit.unit },\n unitPrice: { value: perUnit(meter.tiers.get(start) ?? 0, meter.unit.count), unit: unitPrice },\n })),\n };\n}\n\nfunction observationOf(draft: OfferDraft, at: string, notes: string[]): MeteredObservation | undefined {\n const id = offerId(AZURE_SOURCE, draft.sourceId);\n const names = new Map<string, number>();\n for (const meter of draft.meters.values()) names.set(meter.meterName, (names.get(meter.meterName) ?? 0) + 1);\n const meters: Meter[] = [];\n for (const meter of draft.meters.values()) {\n const name = (names.get(meter.meterName) ?? 0) > 1 ? `${meter.meterName} (${meter.meterId})` : meter.meterName;\n const read = meterOf(draft, meter, name, id, notes);\n if (read !== undefined) meters.push(read);\n }\n if (meters.length === 0) {\n notes.push(`The offer ${id} is skipped: it has no meter with a valid price.`);\n return undefined;\n }\n return observeMetered(\n {\n id,\n source: AZURE_SOURCE,\n sourceId: draft.sourceId,\n title: draft.title,\n location: { provider: AZURE_PROVIDER, region: draft.region },\n term: draft.term,\n specs: [...draft.specs],\n },\n {\n offerId: id,\n at,\n period: { value: 1, unit: \"mo\" },\n meters,\n upfront: draft.upfront === undefined ? undefined : { value: draft.upfront, unit: draft.currency },\n },\n notes,\n );\n}\n\n/**\n * This function reads one page of the Azure Retail Prices API (`GET /api/retail/prices`) at the instant `at`.\n * The prices of one SKU can continue on the next page: `parseAzureRetailPricePages` reads all the pages together.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseAzureRetailPrices(answer: unknown, at: string): MeteredParseResult {\n return parseAzureRetailPricePages([answer], at);\n}\n\n/**\n * This function reads the pages of one read of the Azure Retail Prices API at the instant `at`. Each SKU in a\n * region on a term gives one offer, with a meter for each meter of the SKU. The `next` of the result is the link\n * of the last page.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseAzureRetailPricePages(answers: readonly unknown[], at: string): MeteredParseResult {\n checkAt(at);\n if (answers.length === 0) return refused(\"The read has no page.\");\n const notes: string[] = [];\n const drafts = new Map<string, OfferDraft>();\n const rows: Row[] = [];\n for (const [index, answer] of answers.entries()) {\n const label = answers.length === 1 ? \"The answer\" : `The page ${index + 1}`;\n if (!isRecord(answer)) return refused(`${label} is not an object.`);\n const items = list(answer[\"Items\"]);\n if (items === undefined) return refused(`The field Items of ${label.toLowerCase()} is not a list.`);\n const prefix = answers.length === 1 ? \"\" : `page ${index + 1}, `;\n items.forEach((item, row) => {\n const read = readRow(item, `${prefix}Items[${row}]`, notes);\n if (read !== undefined) rows.push(read);\n });\n }\n for (const row of rows) addRow(row, drafts, notes);\n const observations: MeteredObservation[] = [];\n for (const draft of drafts.values()) {\n const observation = observationOf(draft, at, notes);\n if (observation !== undefined) observations.push(observation);\n }\n const last = answers[answers.length - 1];\n const next = azureNextPage(last);\n const link = field(last, \"NextPageLink\");\n if (next === null && text(link) !== undefined) {\n notes.push(`The link of the next page ${show(link)} does not go to the Azure Retail Prices API, and the result has no link.`);\n }\n return { ok: true, observations, notes, next };\n}\n","import {\n offerId,\n parseGtin,\n type Availability,\n type Condition,\n type PartNumber,\n type Shipping,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n decimal,\n done,\n field,\n httpsUrl,\n isRecord,\n list,\n observe,\n path,\n readMoney,\n refused,\n text,\n type Observation,\n type ParseResult,\n} from \"./parse.ts\";\n\n/** The name of the Best Buy Products API and Open Box API as a source of offers. */\nexport const BEST_BUY_SOURCE = \"bestbuy\";\n\n/**\n * The terms of the Best Buy APIs: a cache keeps the content for 72 hours at most, and nothing analyzes the prices\n * of Best Buy for a third party.\n */\nexport const BEST_BUY_TERMS: SourceTerms = {\n source: BEST_BUY_SOURCE,\n retention: { kind: \"max-age\", age: { value: 72, unit: \"h\" } },\n deleteWhenEnded: false,\n priceModel: false,\n clause: \"Best Buy API terms of 2021-02-23: no store or cache over 72 hours, and no price analysis for a third party\",\n};\n\n/** The US APIs of Best Buy give each price in US dollars, and the answer names no currency. */\nconst CURRENCY = \"USD\";\n\n/**\n * This function gives the condition of a product of the Best Buy Products API. The text `New` gives `new`, a\n * text with `refurbished` gives `refurbished`, and a pre-owned product gives `used`.\n */\nexport function bestBuyCondition(condition: unknown, preowned: unknown): Condition {\n const lower = text(condition)?.toLowerCase();\n if (lower !== undefined && lower.includes(\"refurb\")) return \"refurbished\";\n if (preowned === true || (lower !== undefined && /pre-?owned|used/.test(lower))) return \"used\";\n if (lower === \"new\") return \"new\";\n return \"unknown\";\n}\n\nfunction skuOf(value: unknown): string | undefined {\n if (typeof value === \"number\") return Number.isSafeInteger(value) && value > 0 ? String(value) : undefined;\n const candidate = text(value);\n return candidate !== undefined && /^\\d+$/.test(candidate) ? candidate : undefined;\n}\n\nfunction listPriceOf(regular: unknown, price: Quantity): Quantity | undefined {\n const read = readMoney(regular, CURRENCY);\n return read.ok && read.value.value > price.value ? read.value : undefined;\n}\n\nfunction shippingOf(product: Readonly<Record<string, unknown>>): Shipping {\n if (product[\"freeShipping\"] === true) return { kind: \"free\" };\n const cost = decimal(product[\"shippingCost\"]);\n if (cost === undefined || cost === 0) return { kind: \"unknown\" };\n const money = readMoney(cost, CURRENCY);\n return money.ok ? { kind: \"fixed\", cost: money.value } : { kind: \"unknown\" };\n}\n\nfunction availabilityOf(product: Readonly<Record<string, unknown>>): Availability {\n if (product[\"active\"] === false || product[\"onlineAvailability\"] === false) return \"out-of-stock\";\n const orderable = text(product[\"orderable\"]);\n if (orderable === \"Available\") return \"in-stock\";\n return orderable === undefined && product[\"onlineAvailability\"] === true ? \"in-stock\" : \"unknown\";\n}\n\nfunction specsOf(value: unknown): Spec[] {\n const specs: Spec[] = [];\n for (const detail of list(value) ?? []) {\n const name = text(field(detail, \"name\"));\n const content = text(field(detail, \"value\"));\n if (name !== undefined && content !== undefined) specs.push({ name, value: content });\n }\n return specs;\n}\n\nfunction mapProduct(product: unknown, where: string, at: string, notes: string[]): Observation | undefined {\n if (!isRecord(product)) {\n notes.push(`The product ${where} is skipped: it is not an object.`);\n return undefined;\n }\n const sourceId = skuOf(product[\"sku\"]);\n if (sourceId === undefined) {\n notes.push(`The product ${where} is skipped: it has no sku.`);\n return undefined;\n }\n const id = offerId(BEST_BUY_SOURCE, sourceId);\n const title = text(product[\"name\"]);\n if (title === undefined) {\n notes.push(`The offer ${id} is skipped: it has no name.`);\n return undefined;\n }\n const price = readMoney(product[\"salePrice\"], CURRENCY);\n if (!price.ok) {\n notes.push(`The offer ${id} is skipped: its salePrice is not valid: ${price.why}.`);\n return undefined;\n }\n\n const upc = text(product[\"upc\"]);\n const gtin = upc === undefined ? null : parseGtin(upc);\n if (upc !== undefined && gtin === null) notes.push(`The offer ${id} has no GTIN: ${JSON.stringify(upc)} is not a valid UPC.`);\n const brand = text(product[\"manufacturer\"]);\n const model = text(product[\"modelNumber\"]);\n const partNumbers: PartNumber[] = brand !== undefined && model !== undefined ? [{ brand, partNumber: model }] : [];\n\n return observe(\n {\n id,\n source: BEST_BUY_SOURCE,\n sourceId,\n title,\n url: httpsUrl(product[\"url\"]),\n seller: {},\n condition: bestBuyCondition(product[\"condition\"], product[\"preowned\"]),\n grade: text(product[\"condition\"]),\n format: \"fixed-price\",\n gtins: gtin === null ? [] : [gtin],\n partNumbers,\n specs: specsOf(product[\"details\"]),\n },\n {\n offerId: id,\n at,\n price: price.value,\n listPrice: listPriceOf(product[\"regularPrice\"], price.value),\n shipping: shippingOf(product),\n availability: availabilityOf(product),\n },\n notes,\n );\n}\n\n/**\n * This function reads the answer of one product of the Best Buy Products API (`GET /v1/products/{sku}.json`) at\n * the instant `at`.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseBestBuyProduct(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of the product is not an object.\");\n const notes: string[] = [];\n const observation = mapProduct(answer, \"of the answer\", at, notes);\n return done(observation === undefined ? [] : [observation], notes);\n}\n\n/**\n * This function reads the answer of a search of the Best Buy Products API (`GET /v1/products(...)?format=json`)\n * at the instant `at`. The answer has its products in the list `products`, in the page form and in the cursor form.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseBestBuyProducts(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of the search is not an object.\");\n const products = list(answer[\"products\"]);\n if (products === undefined) return refused(\"The field products of the answer is not a list.\");\n const notes: string[] = [];\n const observations: Observation[] = [];\n products.forEach((product, index) => {\n const observation = mapProduct(product, `products[${index}]`, at, notes);\n if (observation !== undefined) observations.push(observation);\n });\n return done(observations, notes);\n}\n\nfunction availabilityOfOpenBox(offer: unknown): Availability {\n const online = field(offer, \"onlineAvailability\");\n if (online === true) return \"in-stock\";\n return online === false ? \"out-of-stock\" : \"unknown\";\n}\n\nfunction mapOpenBox(result: unknown, where: string, at: string, notes: string[]): Observation[] {\n if (!isRecord(result)) {\n notes.push(`The result ${where} is skipped: it is not an object.`);\n return [];\n }\n const sku = skuOf(result[\"sku\"]);\n if (sku === undefined) {\n notes.push(`The result ${where} is skipped: it has no sku.`);\n return [];\n }\n const title = text(path(result, \"names\", \"title\"));\n if (title === undefined) {\n notes.push(`The result ${where} is skipped: it has no names.title.`);\n return [];\n }\n const url = httpsUrl(path(result, \"links\", \"web\"));\n const observations: Observation[] = [];\n (list(result[\"offers\"]) ?? []).forEach((offer: unknown, index) => {\n const grade = text(field(offer, \"condition\"));\n const listing = text(field(offer, \"listingId\")) ?? grade;\n if (listing === undefined) {\n notes.push(`The offer ${where}.offers[${index}] is skipped: it has no listingId and no condition.`);\n return;\n }\n const sourceId = `${sku}/open-box/${listing}`;\n const id = offerId(BEST_BUY_SOURCE, sourceId);\n const price = readMoney(path(offer, \"prices\", \"current\"), CURRENCY);\n if (!price.ok) {\n notes.push(`The offer ${id} is skipped: its prices.current is not valid: ${price.why}.`);\n return;\n }\n const sellerId = text(field(offer, \"sellerId\"));\n const observation = observe(\n {\n id,\n source: BEST_BUY_SOURCE,\n sourceId,\n title,\n url,\n seller: sellerId === undefined ? {} : { id: sellerId },\n condition: \"open-box\",\n grade,\n format: \"fixed-price\",\n gtins: [],\n partNumbers: [],\n specs: [],\n },\n {\n offerId: id,\n at,\n price: price.value,\n listPrice: listPriceOf(path(offer, \"prices\", \"regular\"), price.value),\n shipping: { kind: \"unknown\" },\n availability: availabilityOfOpenBox(offer),\n },\n notes,\n );\n if (observation !== undefined) observations.push(observation);\n });\n return observations;\n}\n\n/**\n * This function reads the answer of the Best Buy Open Box API (`GET /beta/products/{sku}/openBox`, or a search of\n * `/beta/products/openBox(...)`) at the instant `at`. Each open-box offer of a SKU gives one observation, with the\n * source id `{sku}/open-box/{listingId}`.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseBestBuyOpenBox(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of the Open Box API is not an object.\");\n const results = list(answer[\"results\"]);\n if (results === undefined) {\n const empty = path(answer, \"metadata\", \"resultSet\", \"count\") === 0 && (answer[\"results\"] ?? null) === null;\n return empty ? done([], []) : refused(\"The field results of the answer is not a list.\");\n }\n const notes: string[] = [];\n const observations = results.flatMap((result, index) => mapOpenBox(result, `results[${index}]`, at, notes));\n return done(observations, notes);\n}\n","import { averagePriceId, averagePriceSchema, type AveragePrice, type SourceTerms } from \"@mark1russell7/market\";\nimport { checkAt, compact, decimal, field, list, refused, show, text, type Refused } from \"./parse.ts\";\n\n/*\n * This module reads the average prices of the U.S. Bureau of Labor Statistics (BLS). The CPI program publishes the\n * average price of some foods, fuels and other items each month: the series of the survey AP. The parser reads an\n * answer of version 1 of the BLS Public Data API, which needs no key. The answer gives no title of a series, so the\n * parser takes the item, the area and the unit of each series from a list of known series.\n */\n\n/** The name of the source. */\nexport const BLS_SOURCE = \"bls-ap\";\n\n/** The statement that the terms of the API make necessary for each user of the data. The layer that shows the prices shows it. */\nexport const BLS_STATEMENT =\n \"BLS.gov cannot vouch for the data or analyses derived from these data after the data have been retrieved from BLS.gov.\";\n\n/** The terms of the BLS Public Data API. They set no limit on the time or the use of the data. */\nexport const BLS_TERMS: SourceTerms = {\n source: BLS_SOURCE,\n retention: { kind: \"keep\" },\n deleteWhenEnded: false,\n priceModel: true,\n clause:\n \"BLS Public Data API Terms of Service, last modified 2023-08-30, read on 2026-11-22: no control over the end use, cite the date of the retrieval, give BLS_STATEMENT, and do not change the content\",\n};\n\n/** The address of version 1 of the BLS Public Data API, for one or more series. */\nexport const BLS_API_URL = \"https://api.bls.gov/publicAPI/v1/timeseries/data/\";\n\n/** The most series of one query of version 1. */\nexport const BLS_SERIES_LIMIT = 25;\n\n/** The most years of one query of version 1. */\nexport const BLS_YEAR_LIMIT = 10;\n\n/** A known series of average prices: its id, its item and its area as BLS names them, and the unit of the item. */\nexport interface BlsSeries {\n readonly series: string;\n readonly item: string;\n readonly area: string;\n /** The unit of the amount of the item, a unit of `@mark1russell7/quantity`, for example `lb`. */\n readonly unit: string;\n}\n\nconst US = \"U.S. city average\";\n\n/**\n * The average prices of some dry staples, in the U.S. city average. The titles are from the BLS data viewer of each\n * series, read on 2026-11-22. The series of the Northeast for these items exist, but they have no value since 2023.\n */\nexport const BLS_STAPLES: readonly BlsSeries[] = [\n { series: \"APU0000701312\", item: \"Rice, white, long grain, uncooked, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000701111\", item: \"Flour, white, all purpose, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000714233\", item: \"Beans, dried, any type, all sizes, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000715211\", item: \"Sugar, white, all sizes, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n { series: \"APU0000701322\", item: \"Spaghetti and macaroni, per lb. (453.6 gm)\", area: US, unit: \"lb\" },\n];\n\n/**\n * The result of the parser of average prices. With `ok`, each price is valid under `averagePriceSchema`, and each\n * note tells why the parser skipped a value. Without `ok`, the answer does not have the documented shape.\n */\nexport type AverageParseResult =\n | { readonly ok: true; readonly prices: readonly AveragePrice[]; readonly notes: readonly string[] }\n | (Refused & { readonly threshold?: true | undefined });\n\n/** A message of BLS that tells that the daily threshold of the user is reached. */\nconst THRESHOLD = /threshold/i;\n\nconst SERIES_ID = /^[A-Z0-9]{1,30}$/;\n\n/**\n * This function gives the request of version 1 of the API for some series, from a first year to a last year. The\n * API gives the last three years when the request has no years.\n *\n * @throws RangeError when the count of series is not from 1 to `BLS_SERIES_LIMIT`, or when an id is not an id of BLS.\n * It also throws when the years are not whole numbers in order, or when they are more than `BLS_YEAR_LIMIT` years.\n */\nexport function blsRequest(\n series: readonly string[],\n years?: { readonly start: number; readonly end: number },\n): { readonly method: \"POST\"; readonly url: string; readonly headers: Readonly<Record<string, string>>; readonly body: string } {\n if (series.length < 1 || series.length > BLS_SERIES_LIMIT) throw new RangeError(`The count of series is not from 1 to ${BLS_SERIES_LIMIT}.`);\n for (const id of series) if (typeof id !== \"string\" || !SERIES_ID.test(id)) throw new RangeError(`The series ${show(id)} is not an id of BLS.`);\n if (new Set(series).size !== series.length) throw new RangeError(\"A series is two times in the request.\");\n let body: { readonly seriesid: readonly string[]; readonly startyear?: string; readonly endyear?: string } = { seriesid: series };\n if (years !== undefined) {\n const { start, end } = years;\n if (!Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start > end || end - start + 1 > BLS_YEAR_LIMIT) {\n throw new RangeError(`The years are not whole numbers in order, with ${BLS_YEAR_LIMIT} years at most.`);\n }\n body = { seriesid: series, startyear: String(start), endyear: String(end) };\n }\n return { method: \"POST\", url: BLS_API_URL, headers: { accept: \"application/json\", \"content-type\": \"application/json\" }, body: JSON.stringify(body) };\n}\n\nconst MONTH = /^M(0[1-9]|1[0-2])$/;\nconst YEAR = /^\\d{4}$/;\n\n/** This function gives the texts of the footnotes of a value. A footnote with no text is not a footnote. */\nfunction footnotesOf(value: unknown): string[] {\n return (list(value) ?? []).map((note) => text(field(note, \"text\"))).filter((note): note is string => note !== undefined);\n}\n\n/**\n * This function reads an answer of version 1 of the BLS Public Data API for series of average prices.\n *\n * - Each value of a month of a known series becomes an average price, in US dollars for each unit of its item.\n * - A series that is not in `known` gives a note, and no price.\n * - A value that is not a decimal, for example `-` for no data, gives a note. So does a period that is not a month.\n * - Each message of the answer gives a note, for example \"No Data Available\" for a year.\n * - An answer that did not succeed gives problems. When a message names the daily threshold, the result also has\n * `threshold: true`. Then a loop waits for the next day. The documentation does not give the shape of this answer.\n *\n * @param json - The JSON of the answer\n * @param at - The instant of the answer\n * @param known - The known series. The default is `BLS_STAPLES`.\n * @throws RangeError when `at` is not an ISO 8601 instant in UTC\n */\nexport function parseBlsSeries(json: unknown, at: string, known: readonly BlsSeries[] = BLS_STAPLES): AverageParseResult {\n checkAt(at);\n const status = field(json, \"status\");\n const messages = (list(field(json, \"message\")) ?? []).map((message) => text(message)).filter((message): message is string => message !== undefined);\n if (status !== \"REQUEST_SUCCEEDED\") {\n const problems = refused(`The status of the answer is ${show(status)}, not \"REQUEST_SUCCEEDED\".`, ...messages.map((message) => `BLS: ${message}`));\n return messages.some((message) => THRESHOLD.test(message)) ? { ...problems, threshold: true } : problems;\n }\n const series = list(field(field(json, \"Results\"), \"series\"));\n if (series === undefined) return refused(\"The answer has no list Results.series.\");\n const byId = new Map(known.map((each) => [each.series, each]));\n const notes: string[] = messages.map((message) => `BLS: ${message}`);\n const prices: AveragePrice[] = [];\n const seen = new Set<string>();\n for (const entry of series) {\n const id = text(field(entry, \"seriesID\"));\n const meta = id === undefined ? undefined : byId.get(id);\n if (meta === undefined) {\n notes.push(`The series ${show(id)} is skipped: it is not a known series.`);\n continue;\n }\n for (const point of list(field(entry, \"data\")) ?? []) {\n const year = text(field(point, \"year\"));\n const period = text(field(point, \"period\"));\n if (year === undefined || period === undefined || !YEAR.test(year) || !MONTH.test(period)) {\n notes.push(`A value of the series ${meta.series} is skipped: the period ${show(year)} ${show(period)} is not a month.`);\n continue;\n }\n const month = `${year}-${period.slice(1)}`;\n const value = decimal(field(point, \"value\"));\n if (value === undefined) {\n notes.push(`The value of the series ${meta.series} for ${month} is skipped: ${show(field(point, \"value\"))} is not a decimal.`);\n continue;\n }\n const footnotes = footnotesOf(field(point, \"footnotes\"));\n const record = compact({\n id: averagePriceId(BLS_SOURCE, meta.series, month),\n source: BLS_SOURCE,\n series: meta.series,\n item: meta.item,\n area: meta.area,\n period: month,\n price: { value, unit: `USD/${meta.unit}` },\n at,\n footnotes: footnotes.length === 0 ? undefined : footnotes,\n });\n const checked = averagePriceSchema.safeParse(record);\n if (!checked.success) {\n notes.push(`The value of the series ${meta.series} for ${month} is skipped: the schema refuses it.`);\n continue;\n }\n if (seen.has(checked.data.id)) continue;\n seen.add(checked.data.id);\n prices.push(checked.data);\n }\n }\n return { ok: true, prices, notes };\n}\n","import { offerId, type PartNumber, type PriceBreak, type Seller, type SourceTerms, type Spec } from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n done,\n field,\n httpsUrl,\n isCurrency,\n isRecord,\n list,\n observe,\n path,\n readMoney,\n refused,\n show,\n text,\n wholeNumber,\n type Observation,\n type ParseResult,\n} from \"./parse.ts\";\n\n/** The name of the Digi-Key Product Information API v4 as a source of offers. */\nexport const DIGIKEY_SOURCE = \"digikey\";\n\n/** The name of the seller of an offer that Digi-Key ships itself. */\nexport const DIGIKEY_SELLER = \"Digi-Key\";\n\n/**\n * The terms of the Digi-Key Product Information API: nothing makes or updates a database of its data. Thus a\n * reading serves one request, and no store keeps it.\n */\nexport const DIGIKEY_TERMS: SourceTerms = {\n source: DIGIKEY_SOURCE,\n retention: { kind: \"no-store\" },\n deleteWhenEnded: false,\n priceModel: false,\n clause: \"Digi-Key API User Agreement, section 5.1(e): no database of the information\",\n};\n\ninterface Break {\n readonly quantity: number;\n readonly unitPrice: Quantity;\n}\n\nfunction breaksOf(value: unknown, currency: string): Break[] {\n const breaks: Break[] = [];\n for (const entry of list(value) ?? []) {\n const quantity = wholeNumber(field(entry, \"BreakQuantity\"));\n const unitPrice = readMoney(field(entry, \"UnitPrice\"), currency);\n if (quantity === undefined || quantity < 1 || !unitPrice.ok) continue;\n if (!breaks.some((each) => each.quantity === quantity)) breaks.push({ quantity, unitPrice: unitPrice.value });\n }\n return breaks.sort((a, b) => a.quantity - b.quantity);\n}\n\nfunction sellerOf(variation: unknown): Seller {\n if (field(variation, \"MarketPlace\") !== true) return { name: DIGIKEY_SELLER };\n const supplierId = wholeNumber(path(variation, \"Supplier\", \"Id\"));\n const name = text(path(variation, \"Supplier\", \"Name\"));\n return {\n ...(supplierId === undefined ? {} : { id: String(supplierId) }),\n ...(name === undefined ? {} : { name }),\n };\n}\n\nfunction specsOf(product: Readonly<Record<string, unknown>>): Spec[] {\n const specs: Spec[] = [];\n for (const parameter of list(product[\"Parameters\"]) ?? []) {\n const name = text(field(parameter, \"ParameterText\"));\n const value = text(field(parameter, \"ValueText\"));\n if (name !== undefined && value !== undefined) specs.push({ name, value });\n }\n const status = text(path(product, \"ProductStatus\", \"Status\"));\n if (status !== undefined) specs.push({ name: \"Product status\", value: status });\n return specs;\n}\n\nfunction mapProduct(product: unknown, where: string, currency: string, at: string, notes: string[]): Observation[] {\n if (!isRecord(product)) {\n notes.push(`The product ${where} is skipped: it is not an object.`);\n return [];\n }\n const title =\n text(path(product, \"Description\", \"ProductDescription\")) ??\n text(path(product, \"Description\", \"DetailedDescription\")) ??\n text(product[\"ManufacturerProductNumber\"]);\n if (title === undefined) {\n notes.push(`The product ${where} is skipped: it has no description and no part number.`);\n return [];\n }\n const variations = list(product[\"ProductVariations\"]) ?? [];\n if (variations.length === 0) notes.push(`The product ${where} has no ProductVariations, so it gives no offer.`);\n const brand = text(path(product, \"Manufacturer\", \"Name\"));\n const partNumber = text(product[\"ManufacturerProductNumber\"]);\n const partNumbers: PartNumber[] = brand !== undefined && partNumber !== undefined ? [{ brand, partNumber }] : [];\n const specs = specsOf(product);\n const url = httpsUrl(product[\"ProductUrl\"]);\n\n const observations: Observation[] = [];\n variations.forEach((variation: unknown, index) => {\n const sourceId = text(field(variation, \"DigiKeyProductNumber\"));\n if (sourceId === undefined) {\n notes.push(`The variation ${where}.ProductVariations[${index}] is skipped: it has no DigiKeyProductNumber.`);\n return;\n }\n const id = offerId(DIGIKEY_SOURCE, sourceId);\n const breaks = breaksOf(field(variation, \"StandardPricing\"), currency);\n const lowest = breaks[0];\n if (lowest === undefined) {\n notes.push(`The offer ${id} is skipped: it has no valid StandardPricing.`);\n return;\n }\n const minimum = Math.max(wholeNumber(field(variation, \"MinimumOrderQuantity\")) ?? 1, lowest.quantity, 1);\n const price = breaks.filter((each) => each.quantity <= minimum).at(-1) ?? lowest;\n const priceBreaks: PriceBreak[] = breaks.filter((each) => each.quantity > minimum);\n const available = wholeNumber(field(variation, \"QuantityAvailableforPackageType\"));\n const packageType = text(path(variation, \"PackageType\", \"Name\"));\n\n const observation = observe(\n {\n id,\n source: DIGIKEY_SOURCE,\n sourceId,\n title,\n url,\n seller: sellerOf(variation),\n condition: \"new\",\n format: \"fixed-price\",\n gtins: [],\n partNumbers,\n specs: packageType === undefined ? specs : [...specs, { name: \"Package type\", value: packageType }],\n },\n {\n offerId: id,\n at,\n price: price.unitPrice,\n shipping: { kind: \"unknown\" },\n availability: available === undefined ? \"unknown\" : available > 0 ? \"in-stock\" : \"out-of-stock\",\n available,\n minimumQuantity: minimum > 1 ? minimum : undefined,\n priceBreaks: priceBreaks.length > 0 ? priceBreaks : undefined,\n },\n notes,\n );\n if (observation !== undefined) observations.push(observation);\n });\n return observations;\n}\n\nfunction currencyOf(answer: Readonly<Record<string, unknown>>): string | ParseResult {\n const currency = text(path(answer, \"SearchLocaleUsed\", \"Currency\"));\n if (currency === undefined) return refused(\"The answer names no currency in SearchLocaleUsed.Currency.\");\n if (!isCurrency(currency)) {\n return refused(`The currency ${show(currency)} of the answer is not a money unit of @mark1russell7/quantity.`);\n }\n return currency;\n}\n\n/**\n * This function reads the answer of `ProductDetails` of the Digi-Key Product Information API v4\n * (`GET /products/v4/search/{productNumber}/productdetails`) at the instant `at`. Each variation of the\n * product (a package type) gives one observation. The currency comes from `SearchLocaleUsed.Currency`.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseDigiKeyProductDetails(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of ProductDetails is not an object.\");\n const currency = currencyOf(answer);\n if (typeof currency !== \"string\") return currency;\n if (!isRecord(answer[\"Product\"])) return refused(\"The field Product of the answer is not an object.\");\n const notes: string[] = [];\n return done(mapProduct(answer[\"Product\"], \"Product\", currency, at, notes), notes);\n}\n\n/**\n * This function reads the answer of `KeywordSearch` of the Digi-Key Product Information API v4\n * (`POST /products/v4/search/keyword`) at the instant `at`. It reads the lists `Products` and `ExactMatches`,\n * and an offer in both lists counts once.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseDigiKeyKeywordSearch(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of KeywordSearch is not an object.\");\n const currency = currencyOf(answer);\n if (typeof currency !== \"string\") return currency;\n const products = list(answer[\"Products\"]);\n const exact = list(answer[\"ExactMatches\"]);\n if (products === undefined && exact === undefined) return refused(\"The answer has no list Products and no list ExactMatches.\");\n const notes: string[] = [];\n const observations = [\n ...(exact ?? []).flatMap((product, index) => mapProduct(product, `ExactMatches[${index}]`, currency, at, notes)),\n ...(products ?? []).flatMap((product, index) => mapProduct(product, `Products[${index}]`, currency, at, notes)),\n ];\n return done(observations, notes);\n}\n","import {\n offerId,\n parseGtin,\n type Availability,\n type Condition,\n type Format,\n type PartNumber,\n type Seller,\n type Shipping,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport type { Quantity } from \"@mark1russell7/quantity\";\nimport {\n checkAt,\n compact,\n decimal,\n done,\n field,\n httpsUrl,\n instant,\n isRecord,\n list,\n observe,\n path,\n readMoney,\n refused,\n show,\n text,\n wholeNumber,\n type Observation,\n type ParseResult,\n type Read,\n} from \"./parse.ts\";\n\n/** The name of the eBay Browse API as a source of offers. */\nexport const EBAY_SOURCE = \"ebay\";\n\n/**\n * The terms of the eBay Browse API. A display shows no data older than 6 hours. An application deletes the data of\n * an ended listing, and nothing models the prices of eBay.\n */\nexport const EBAY_TERMS: SourceTerms = {\n source: EBAY_SOURCE,\n retention: { kind: \"max-age\", age: { value: 6, unit: \"h\" } },\n deleteWhenEnded: true,\n priceModel: false,\n clause: \"eBay API License Agreement of 2025-09-03, sections 8.1(b)(1), 8.1(c) and 9.5\",\n};\n\nconst CONDITIONS_BY_ID: ReadonlyMap<string, Condition> = new Map<string, Condition>([\n [\"1000\", \"new\"],\n [\"1500\", \"open-box\"],\n [\"1750\", \"new\"],\n [\"2000\", \"refurbished\"],\n [\"2010\", \"refurbished\"],\n [\"2020\", \"refurbished\"],\n [\"2030\", \"refurbished\"],\n [\"2500\", \"refurbished\"],\n [\"2750\", \"used\"],\n [\"2990\", \"used\"],\n [\"3000\", \"used\"],\n [\"3010\", \"used\"],\n [\"4000\", \"used\"],\n [\"5000\", \"used\"],\n [\"6000\", \"used\"],\n [\"7000\", \"for-parts\"],\n]);\n\n/**\n * This function gives the condition of an eBay condition id, for example `3000` gives `used`. An id that the\n * table of eBay does not have gives `unknown`.\n */\nexport function ebayCondition(conditionId: unknown): Condition {\n const id = typeof conditionId === \"number\" ? String(conditionId) : text(conditionId);\n return (id === undefined ? undefined : CONDITIONS_BY_ID.get(id)) ?? \"unknown\";\n}\n\nconst AVAILABILITY_BY_STATUS: ReadonlyMap<string, Availability> = new Map<string, Availability>([\n [\"IN_STOCK\", \"in-stock\"],\n [\"LIMITED_STOCK\", \"low-stock\"],\n [\"OUT_OF_STOCK\", \"out-of-stock\"],\n]);\n\nconst PLACEHOLDERS = new Set([\"does not apply\", \"n/a\", \"na\"]);\n\nfunction real(value: unknown): string | undefined {\n const candidate = text(value);\n return candidate === undefined || PLACEHOLDERS.has(candidate.toLowerCase()) ? undefined : candidate;\n}\n\nfunction convertedAmount(value: unknown): Read<Quantity> | undefined {\n if (value === undefined || value === null) return undefined;\n return readMoney(field(value, \"value\"), field(value, \"currency\"));\n}\n\nfunction formatOf(options: readonly unknown[] | undefined): Format | undefined {\n if (options === undefined || options.includes(\"FIXED_PRICE\")) return \"fixed-price\";\n return options.includes(\"AUCTION\") ? \"auction\" : undefined;\n}\n\nfunction shippingOf(options: readonly unknown[] | undefined, currency: string): Shipping {\n let cheapest: Quantity | undefined;\n let calculated = false;\n for (const option of options ?? []) {\n const type = text(field(option, \"shippingCostType\"));\n if (type === \"CALCULATED\") calculated = true;\n if (type !== \"FIXED\") continue;\n const cost = convertedAmount(field(option, \"shippingCost\"));\n if (cost === undefined || !cost.ok || cost.value.unit !== currency) continue;\n if (cheapest === undefined || cost.value.value < cheapest.value) cheapest = cost.value;\n }\n if (cheapest !== undefined) return cheapest.value === 0 ? { kind: \"free\" } : { kind: \"fixed\", cost: cheapest };\n return calculated ? { kind: \"calculated\" } : { kind: \"unknown\" };\n}\n\nfunction sellerOf(value: unknown): Seller {\n const percent = decimal(field(value, \"feedbackPercentage\"));\n const count = wholeNumber(field(value, \"feedbackScore\"));\n const rating = percent !== undefined && percent <= 100 && count !== undefined ? { percent, count } : undefined;\n return compact({ id: text(field(value, \"userId\")), name: text(field(value, \"username\")), rating });\n}\n\nfunction specsOf(value: unknown): Spec[] {\n const specs: Spec[] = [];\n for (const aspect of list(value) ?? []) {\n const name = text(field(aspect, \"name\"));\n const content = text(field(aspect, \"value\"));\n if (name !== undefined && content !== undefined) specs.push({ name, value: content });\n }\n return specs;\n}\n\nfunction mapItem(item: unknown, where: string, at: string, notes: string[]): Observation | undefined {\n if (!isRecord(item)) {\n notes.push(`The item ${where} is skipped: it is not an object.`);\n return undefined;\n }\n const sourceId = text(item[\"itemId\"]);\n if (sourceId === undefined) {\n notes.push(`The item ${where} is skipped: it has no itemId.`);\n return undefined;\n }\n const id = offerId(EBAY_SOURCE, sourceId);\n const skip = (why: string): undefined => {\n notes.push(`The offer ${id} is skipped: ${why}.`);\n return undefined;\n };\n\n const title = text(item[\"title\"]);\n if (title === undefined) return skip(\"it has no title\");\n const options = list(item[\"buyingOptions\"]);\n const format = formatOf(options);\n if (format === undefined) return skip(`its buying options ${(options ?? []).map((option) => (typeof option === \"string\" ? option : show(option))).join(\", \")} have no price to pay`);\n const endsAt = instant(item[\"itemEndDate\"]);\n if (endsAt !== undefined && Date.parse(endsAt) <= Date.parse(at)) return skip(`the listing ended at ${endsAt}`);\n\n const price =\n format === \"auction\"\n ? (convertedAmount(item[\"currentBidPrice\"]) ?? convertedAmount(item[\"price\"]))\n : convertedAmount(item[\"price\"]);\n if (price === undefined) return skip(\"it has no price\");\n if (!price.ok) return skip(`its price is not valid: ${price.why}`);\n\n const original = format === \"fixed-price\" ? convertedAmount(path(item, \"marketingPrice\", \"originalPrice\")) : undefined;\n const listPrice =\n original?.ok === true && original.value.unit === price.value.unit && original.value.value > price.value.value\n ? original.value\n : undefined;\n\n const estimate = (list(item[\"estimatedAvailabilities\"]) ?? []).find(isRecord);\n const availability = AVAILABILITY_BY_STATUS.get(text(field(estimate, \"estimatedAvailabilityStatus\")) ?? \"\") ?? \"unknown\";\n let available =\n text(field(estimate, \"availabilityThresholdType\")) === undefined\n ? wholeNumber(field(estimate, \"estimatedAvailableQuantity\"))\n : undefined;\n if (available !== undefined && availability !== \"unknown\" && (availability === \"out-of-stock\") !== (available === 0)) {\n notes.push(`The offer ${id} has no count: the count ${available} does not agree with ${availability}.`);\n available = undefined;\n }\n\n const gtinText = text(item[\"gtin\"]);\n const gtin = gtinText === undefined ? null : parseGtin(gtinText);\n if (gtinText !== undefined && gtin === null && /\\d/.test(gtinText)) {\n notes.push(`The offer ${id} has no GTIN: ${JSON.stringify(gtinText)} is not a valid GTIN.`);\n }\n const brand = real(item[\"brand\"]);\n const mpn = real(item[\"mpn\"]);\n const partNumbers: PartNumber[] = brand !== undefined && mpn !== undefined ? [{ brand, partNumber: mpn }] : [];\n\n return observe(\n {\n id,\n source: EBAY_SOURCE,\n sourceId,\n title,\n url: httpsUrl(item[\"itemWebUrl\"]),\n seller: sellerOf(item[\"seller\"]),\n condition: ebayCondition(item[\"conditionId\"]),\n grade: text(item[\"condition\"]),\n format,\n endsAt,\n gtins: gtin === null ? [] : [gtin],\n partNumbers,\n specs: specsOf(item[\"localizedAspects\"]),\n },\n {\n offerId: id,\n at,\n price: price.value,\n listPrice,\n shipping: shippingOf(list(item[\"shippingOptions\"]), price.value.unit),\n availability,\n available,\n },\n notes,\n );\n}\n\n/**\n * This function reads the answer of `getItem` of the eBay Browse API (`GET /buy/browse/v1/item/{item_id}`)\n * at the instant `at`. It gives one observation, or a note when the item does not map to an offer.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseEbayItem(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of getItem is not an object.\");\n const notes: string[] = [];\n const observation = mapItem(answer, \"of the answer\", at, notes);\n return done(observation === undefined ? [] : [observation], notes);\n}\n\n/**\n * This function reads the answer of `search` of the eBay Browse API (`GET /buy/browse/v1/item_summary/search`)\n * at the instant `at`. An answer with no results has the `total` 0 and no `itemSummaries`, and it gives no\n * observations.\n *\n * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.\n */\nexport function parseEbaySearch(answer: unknown, at: string): ParseResult {\n checkAt(at);\n if (!isRecord(answer)) return refused(\"The answer of search is not an object.\");\n const summaries = answer[\"itemSummaries\"];\n if ((summaries === undefined || summaries === null) && answer[\"total\"] === 0) return done([], []);\n if (!Array.isArray(summaries)) return refused(\"The field itemSummaries of the answer is not a list, and total is not 0.\");\n const notes: string[] = [];\n const observations: Observation[] = [];\n summaries.forEach((summary: unknown, index) => {\n const observation = mapItem(summary, `itemSummaries[${index}]`, at, notes);\n if (observation !== undefined) observations.push(observation);\n });\n return done(observations, notes);\n}\n","/**\n * The records of the providers with a plan list. Each record is data for `parsePlanLists` and the plan client. A\n * host can also load a record from a JSON file with `parsePlanProvider`.\n *\n * The terms of these sources are the strictest rules: no stored reading and no price model. The terms pages of\n * these providers refused an automated read on 2026-11-18. A person reads the terms before a rule changes.\n */\nimport type { SourceTerms } from \"@mark1russell7/market\";\nimport type { PlanListRead, PlanProvider } from \"./plans.ts\";\n\n/** The name of the Vultr source. */\nexport const VULTR_SOURCE = \"vultr\";\n\n/** The terms of the Vultr source. A reading serves one request. */\nexport const VULTR_TERMS: SourceTerms = {\n source: VULTR_SOURCE,\n retention: { kind: \"no-store\" },\n deleteWhenEnded: false,\n priceModel: false,\n clause:\n \"Not read: the terms pages of vultr.com refused an automated read on 2026-11-18. The strictest rule holds until a person reads the terms.\",\n};\n\n/**\n * The record of the Vultr plan list (`GET /v2/plans` of the API v2). The API gave the list with no key on\n * 2026-11-18. Each plan lists its regions, and the object `location_cost` has the prices that change with the region.\n * A plan has the on-demand term when `deploy_ondemand` is true, and the preemptible term when `deploy_preemptible` is true.\n */\nexport const VULTR_PLANS: PlanProvider = {\n source: VULTR_SOURCE,\n provider: \"vultr\",\n name: \"Vultr\",\n host: \"api.vultr.com\",\n paceMs: 2000,\n currency: \"USD\",\n terms: VULTR_TERMS,\n plans: { path: \"/v2/plans\", query: { per_page: \"500\" }, items: \"plans\", paging: { kind: \"cursor\", param: \"cursor\", next: \"meta.links.next\" } },\n id: \"id\",\n regions: { kind: \"field\", path: \"locations\" },\n regionPrices: { kind: \"map\", path: \"location_cost\" },\n prices: [\n { key: \"on-demand\", term: { kind: \"on-demand\" }, when: \"deploy_ondemand\", hourly: \"hourly_cost\", monthly: \"monthly_cost\" },\n {\n key: \"spot\",\n term: { kind: \"spot\" },\n when: \"deploy_preemptible\",\n hourly: \"hourly_cost_preemptible\",\n monthly: \"monthly_cost_preemptible\",\n },\n ],\n specs: [\n { name: \"type\", path: \"type\" },\n { name: \"vcpu\", path: \"vcpu_count\" },\n { name: \"memory\", path: \"ram\", unit: \"MiB\" },\n { name: \"disk\", path: \"disk\", unit: \"GB\" },\n { name: \"disk-type\", path: \"disk_type\" },\n { name: \"transfer\", path: \"bandwidth\", unit: \"GB\" },\n { name: \"cpu-vendor\", path: \"cpu_vendor\" },\n { name: \"gpu\", path: \"gpu_type\" },\n { name: \"gpu-count\", path: \"gpu_count\" },\n { name: \"gpu-memory\", path: \"gpu_vram_gb\", unit: \"GB\" },\n ],\n};\n\n/** The name of the Linode source of Akamai Cloud. */\nexport const LINODE_SOURCE = \"linode\";\n\n/** The terms of the Linode source. A reading serves one request. */\nexport const LINODE_TERMS: SourceTerms = {\n source: LINODE_SOURCE,\n retention: { kind: \"no-store\" },\n deleteWhenEnded: false,\n priceModel: false,\n clause:\n \"Not read: the legal pages of akamai.com refused an automated read on 2026-11-18. The API reference tells that these reads need no permissions. The strictest rule holds until a person reads the terms.\",\n};\n\nconst LINODE_PAGES: PlanListRead[\"paging\"] = { kind: \"page\", param: \"page\", pages: \"pages\" };\n\n/**\n * The record of the Linode plan list of Akamai Cloud (`GET /v4/linode/types` of the API v4). The API reference\n * tells that the read needs no permissions. The list of `GET /v4/regions/availability` tells the regions of each\n * plan. The list `region_prices` has the prices that change with the region.\n */\nexport const LINODE_PLANS: PlanProvider = {\n source: LINODE_SOURCE,\n provider: \"linode\",\n name: \"Linode\",\n host: \"api.linode.com\",\n paceMs: 2000,\n currency: \"USD\",\n terms: LINODE_TERMS,\n plans: { path: \"/v4/linode/types\", query: { page_size: \"500\" }, items: \"data\", paging: LINODE_PAGES },\n id: \"id\",\n label: \"label\",\n regions: {\n kind: \"list\",\n read: { path: \"/v4/regions/availability\", query: { page_size: \"500\" }, items: \"data\", paging: LINODE_PAGES },\n plan: \"plan\",\n region: \"region\",\n available: \"available\",\n },\n regionPrices: { kind: \"list\", path: \"region_prices\", id: \"id\" },\n prices: [\n {\n key: \"on-demand\",\n term: { kind: \"on-demand\" },\n hourly: \"price.hourly\",\n monthly: \"price.monthly\",\n regionHourly: \"hourly\",\n regionMonthly: \"monthly\",\n },\n ],\n specs: [\n { name: \"class\", path: \"class\" },\n { name: \"vcpu\", path: \"vcpus\" },\n { name: \"memory\", path: \"memory\", unit: \"MiB\" },\n { name: \"disk\", path: \"disk\", unit: \"MiB\" },\n { name: \"transfer\", path: \"transfer\", unit: \"GB\" },\n { name: \"gpu-count\", path: \"gpus\" },\n { name: \"network-out\", path: \"network_out\", unit: \"Mbps\" },\n ],\n};\n\n/** The record of each provider with a plan list, in the order of the names. */\nexport const PLAN_PROVIDERS: readonly PlanProvider[] = [LINODE_PLANS, VULTR_PLANS];\n","/**\n * The shared parts of the clients of the seller APIs. Each client sends its exchanges with the polite send of\n * `polite-crawler/api`. The scheduler of `polite-crawler` keeps the pace of each host. The reaction to each\n * answer is the reaction of the crawler. This module adds the checks of the inputs of a client and the form body.\n * It also adds the read of an answer with a parser of this package, and the redaction of each message.\n *\n * This module uses no type of a platform: the host of a client gives the transport, the clock and the signal.\n */\nimport { redactSecrets } from \"@mark1russell7/text/redact\";\nimport { statusLine, type Answer, type Send } from \"polite-crawler/api\";\nimport { refused, type ParseResult, type Refused } from \"./parse.ts\";\n\nexport {\n ApiError,\n readGrant,\n send,\n sendWithToken,\n statusLine,\n tokenStore,\n TOKEN_MARGIN_MS,\n} from \"polite-crawler/api\";\nexport type {\n Answer,\n ApiScheduler,\n Exchange,\n Grant,\n Pace,\n Redact,\n Reply,\n Send,\n Signal,\n Tokens,\n Transport,\n} from \"polite-crawler/api\";\n\n/** The text in the place of a secret in a message. */\nexport const SECRET_MARK = \"[secret]\";\n\n/** The longest message of a client, in code units. */\nexport const MESSAGE_LIMIT = 300;\n\n/** A key, a secret or a token is printable ASCII with no space, from 8 to 4096 characters. */\nconst SECRET = /^[!-~]{8,4096}$/;\n\n/**\n * This function examines a key or a secret of a client.\n *\n * @throws RangeError when the value is not printable ASCII with no space, from 8 to 4096 characters. The message\n * names the field, and it does not show the value.\n */\nexport function checkSecret(name: string, value: unknown): void {\n if (typeof value !== \"string\" || !SECRET.test(value)) {\n throw new RangeError(`The field ${name} is not a key: printable ASCII with no space, from 8 to 4096 characters.`);\n }\n}\n\n/**\n * This function examines a value that a client puts in a URL, for example a product number.\n *\n * @throws RangeError when the value is empty, has more than 200 characters, or has a control character.\n */\nexport function checkName(name: string, value: unknown): string {\n if (typeof value !== \"string\" || value.trim() === \"\" || value.length > 200 || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n throw new RangeError(`The field ${name} is not a text of 1 to 200 characters with no control character.`);\n }\n return value.trim();\n}\n\n/**\n * This function puts `SECRET_MARK` in the place of each secret and of its forms in a URL and in a form body.\n * It uses `redactSecrets` of `@mark1russell7/text`. Then it cuts the text to `MESSAGE_LIMIT`. Each client gives\n * it to the send as its `redact`.\n */\nexport function redact(text: string, secrets: readonly string[]): string {\n const out = redactSecrets(text, secrets, { mark: SECRET_MARK });\n return out.length > MESSAGE_LIMIT ? `${out.slice(0, MESSAGE_LIMIT)}…` : out;\n}\n\n/** This function gives the body of a form (`application/x-www-form-urlencoded`) with the fields in their order. */\nexport function formBody(fields: Readonly<Record<string, string>>): string {\n return Object.entries(fields)\n .map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`)\n .join(\"&\");\n}\n\n/** The JSON of an answer, or the problems of an answer that is not a 2xx or not JSON. */\nexport type JsonRead = { readonly ok: true; readonly json: unknown } | Refused;\n\n/**\n * This function reads the JSON of an answer. An answer that is not a 2xx gives a problem with its status line,\n * and no part of its body.\n */\nexport function readJson(answer: Answer, input: Pick<Send, \"source\" | \"what\" | \"secrets\">): JsonRead {\n const { reply } = answer;\n if (reply.status < 200 || reply.status > 299) {\n return refused(redact(`${input.source} answered ${statusLine(reply)} to ${input.what}.`, input.secrets ?? []));\n }\n try {\n return { ok: true, json: JSON.parse(reply.body) as unknown };\n } catch {\n return refused(`The answer of ${input.source} to ${input.what} is not JSON.`);\n }\n}\n\n/**\n * This function reads an answer with a parser of this package at the instant `at`. An answer that is not a 2xx\n * gives a problem with its status line, and no part of its body.\n */\nexport function readAnswer(\n answer: Answer,\n input: Pick<Send, \"source\" | \"what\" | \"secrets\">,\n parse: (json: unknown, at: string) => ParseResult,\n at: string,\n): ParseResult {\n const read = readJson(answer, input);\n return read.ok ? parse(read.json, at) : read;\n}\n\n/** This function gives the instant of a time in milliseconds since the epoch, in the ISO 8601 form in UTC. */\nexport function instantOf(ms: number): string {\n return new Date(ms).toISOString();\n}\n","import { quotaGate, withQuota, type Quota, type QuotaGate } from \"polite-crawler/api\";\nimport { BLS_STAPLES, blsRequest, parseBlsSeries, type AverageParseResult, type BlsSeries } from \"./bls.ts\";\nimport { instantOf, readJson, redact, send, type Exchange, type Pace, type Signal, type Transport } from \"./client.ts\";\n\n/** The host of the BLS Public Data API. */\nexport const BLS_HOST = \"api.bls.gov\";\n\n/**\n * The shortest time between two queries of one pace, 10 seconds. The FAQ of the API gives the row \"Request rate limit:\n * 50 requests per 10 seconds\" for the two versions (https://www.bls.gov/developers/api_faqs.htm). The pace is far\n * under it. The quota `BLS_QUOTA`, not the pace, keeps the count of each day.\n */\nexport const BLS_PACE_MS = 10_000;\n\n/**\n * The quota of version 1 of the API: 25 queries each day to a user with no key. The gate keeps 5 in reserve, so a\n * client sends at most 20 queries in each window. The documentation does not tell when the day of the count starts,\n * thus the window is a rolling 24 hours. It is stricter than each calendar day.\n */\nexport const BLS_QUOTA: Quota = {\n name: \"BLS Public Data API queries\",\n limit: 25,\n reserve: 5,\n window: { kind: \"rolling\", ms: 86_400_000 },\n};\n\n/** The name of the key of `BLS_QUOTA`. Version 1 has no key: the API counts the queries of each address. */\nexport const BLS_QUOTA_KEY = \"bls:v1\";\n\n/** The options of a BLS client. Version 1 of the API needs no key. */\nexport interface BlsClientOptions<S extends Signal> {\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n /**\n * The gate of `BLS_QUOTA`. The default is one gate in memory for each pace, with the clock of the pace. Thus each\n * client of one pace counts in one gate, as the pace keeps one interval for each host. A gate with a shared store\n * counts each process of one address in one record. An example store is `SqliteHostStateStore` of `polite-crawler`.\n */\n readonly quota?: QuotaGate | undefined;\n}\n\n/** A client of the average prices of the BLS Public Data API. */\nexport interface BlsClient<S extends Signal> {\n /**\n * This method reads the average prices of some known series in one query. Without years, the API gives the last\n * three years. The default series are `BLS_STAPLES`.\n *\n * @throws QuotaError of `polite-crawler/api` when the quota refuses the query. Its `resetAt` tells when the gate\n * gives a query again. The client sent nothing.\n */\n averages(series?: readonly BlsSeries[], years?: { readonly start: number; readonly end: number }, signal?: S): Promise<AverageParseResult>;\n}\n\nconst SOURCE = \"BLS Public Data API\";\n\n/** The default gate of each pace. A pace is the pace of the clients of one process, and the API counts each address. */\nconst PACE_GATES = new WeakMap<object, QuotaGate>();\n\nfunction paceGate<S extends Signal>(pace: Pace<S>): QuotaGate {\n const found = PACE_GATES.get(pace);\n if (found !== undefined) return found;\n const gate = quotaGate(BLS_QUOTA, { key: BLS_QUOTA_KEY, now: pace.now });\n PACE_GATES.set(pace, gate);\n return gate;\n}\n\n/**\n * This function makes a client of the average prices of the BLS Public Data API, version 1.\n *\n * - The gate counts each query before the client sends it, and it refuses a query over the quota.\n * - An answer that tells that the daily threshold is reached sets the count to the limit. Then the gate refuses each\n * query until the queries of the window go out of it, 24 hours at most.\n */\nexport function createBlsClient<S extends Signal>(options: BlsClientOptions<S>): BlsClient<S> {\n const { pace, transport } = options;\n const query = withQuota(\n options.quota ?? paceGate(pace),\n async (exchange: Exchange, series: readonly BlsSeries[], signal: S | undefined): Promise<AverageParseResult> => {\n const what = `the average prices of ${series.length} series`;\n const input = { source: SOURCE, host: BLS_HOST, minIntervalMs: BLS_PACE_MS, what, secrets: [], redact, exchange };\n const answer = await send(pace, transport, input, signal);\n const json = readJson(answer, input);\n return json.ok ? parseBlsSeries(json.json, instantOf(pace.now()), series) : json;\n },\n { read: (result) => (!result.ok && result.threshold === true ? { remaining: 0 } : undefined) },\n );\n return {\n async averages(series = BLS_STAPLES, years, signal) {\n // The request is made first: a bad series or bad years throw a RangeError, and the gate counts nothing.\n const exchange = blsRequest(\n series.map((each) => each.series),\n years,\n );\n return await query(exchange, series, signal);\n },\n };\n}\n","import {\n checkName,\n checkSecret,\n formBody,\n instantOf,\n readAnswer,\n readGrant,\n redact,\n send,\n sendWithToken,\n tokenStore,\n type Pace,\n type Signal,\n type Transport,\n} from \"./client.ts\";\nimport { parseDigiKeyKeywordSearch, parseDigiKeyProductDetails } from \"./digikey.ts\";\nimport type { ParseResult } from \"./parse.ts\";\n\n/** The host of the Digi-Key APIs. */\nexport const DIGIKEY_HOST = \"api.digikey.com\";\n\n/** The host of the sandbox of the Digi-Key APIs. Its answers have example data. */\nexport const DIGIKEY_SANDBOX_HOST = \"sandbox-api.digikey.com\";\n\n/** The burst limit of Product Information v4 is 120 requests each minute. Thus the client sends one request each 500 ms at most. */\nexport const DIGIKEY_PACE_MS = 500;\n\n/** The most products of one `KeywordSearch`. */\nexport const DIGIKEY_SEARCH_LIMIT = 50;\n\n/** The locale of the answers: the site, the language and the currency of the prices. */\nexport interface DigiKeyLocale {\n readonly site: string;\n readonly language: string;\n readonly currency: string;\n}\n\n/** The locale of the US site, with prices in US dollars. */\nexport const DIGIKEY_US: DigiKeyLocale = { site: \"US\", language: \"en\", currency: \"USD\" };\n\n/** The options of a Digi-Key client. */\nexport interface DigiKeyClientOptions<S extends Signal> {\n /** The client id of the API application. */\n readonly clientId: string;\n /** The client secret of the API application. */\n readonly clientSecret: string;\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n /** With true, the client uses the sandbox host. */\n readonly sandbox?: boolean | undefined;\n /** The default is `DIGIKEY_US`. */\n readonly locale?: DigiKeyLocale | undefined;\n}\n\n/** A client of the Digi-Key Product Information API v4. Each method gives the result of a parser of this package. */\nexport interface DigiKeyClient<S extends Signal> {\n /** This method reads `ProductDetails` of a Digi-Key or maker product number. */\n productDetails(productNumber: string, signal?: S): Promise<ParseResult>;\n /** This method reads `KeywordSearch` of the keywords, with `limit` products at most (1 to 50, the default 10). */\n keywordSearch(keywords: string, limit?: number, signal?: S): Promise<ParseResult>;\n}\n\nconst SOURCE = \"Digi-Key\";\n\n/**\n * This function makes a client of the Digi-Key Product Information API v4. The client gets a token with the\n * 2-legged OAuth flow (the client credentials grant), and it keeps the token until 1 minute before its end. Each\n * request sends the token, the client id and the locale.\n *\n * @throws RangeError when the client id or the client secret is not a key. The message does not show the value.\n */\nexport function createDigiKeyClient<S extends Signal>(options: DigiKeyClientOptions<S>): DigiKeyClient<S> {\n checkSecret(\"clientId\", options.clientId);\n checkSecret(\"clientSecret\", options.clientSecret);\n const { clientId, clientSecret, pace, transport } = options;\n const host = options.sandbox === true ? DIGIKEY_SANDBOX_HOST : DIGIKEY_HOST;\n const base = `https://${host}`;\n const locale = options.locale ?? DIGIKEY_US;\n const secrets = [clientId, clientSecret];\n const context = { source: SOURCE, host, minIntervalMs: DIGIKEY_PACE_MS, secrets, redact };\n\n const tokens = tokenStore<S>(async (signal) => {\n const issuedAt = pace.now();\n const exchange = {\n method: \"POST\" as const,\n url: `${base}/v1/oauth2/token`,\n headers: { \"content-type\": \"application/x-www-form-urlencoded\", accept: \"application/json\" },\n body: formBody({ client_id: clientId, client_secret: clientSecret, grant_type: \"client_credentials\" }),\n };\n const { reply } = await send(pace, transport, { ...context, what: \"the token\", exchange }, signal);\n return readGrant(reply, SOURCE, issuedAt, secrets, redact);\n }, pace.now);\n\n const headers = (token: string): Readonly<Record<string, string>> => ({\n authorization: `Bearer ${token}`,\n \"x-digikey-client-id\": clientId,\n \"x-digikey-locale-site\": locale.site,\n \"x-digikey-locale-language\": locale.language,\n \"x-digikey-locale-currency\": locale.currency,\n });\n\n return {\n async productDetails(productNumber, signal) {\n const number = checkName(\"productNumber\", productNumber);\n const what = `ProductDetails of ${number}`;\n const exchange = {\n method: \"GET\" as const,\n url: `${base}/products/v4/search/${encodeURIComponent(number)}/productdetails`,\n headers: { accept: \"application/json\" },\n body: null,\n };\n const answer = await sendWithToken(pace, transport, tokens, { ...context, what, exchange }, headers, signal);\n return readAnswer(answer, { ...context, what }, parseDigiKeyProductDetails, instantOf(pace.now()));\n },\n async keywordSearch(keywords, limit = 10, signal) {\n const words = checkName(\"keywords\", keywords);\n if (!Number.isInteger(limit) || limit < 1 || limit > DIGIKEY_SEARCH_LIMIT) {\n throw new RangeError(`The limit is not a whole number from 1 to ${DIGIKEY_SEARCH_LIMIT}.`);\n }\n const what = `KeywordSearch of ${JSON.stringify(words)}`;\n const exchange = {\n method: \"POST\" as const,\n url: `${base}/products/v4/search/keyword`,\n headers: { accept: \"application/json\", \"content-type\": \"application/json\" },\n body: JSON.stringify({ Keywords: words, Limit: limit, Offset: 0 }),\n };\n const answer = await sendWithToken(pace, transport, tokens, { ...context, what, exchange }, headers, signal);\n return readAnswer(answer, { ...context, what }, parseDigiKeyKeywordSearch, instantOf(pace.now()));\n },\n };\n}\n","import {\n checkName,\n checkSecret,\n formBody,\n instantOf,\n readAnswer,\n readGrant,\n redact,\n send,\n sendWithToken,\n tokenStore,\n type Pace,\n type Signal,\n type Transport,\n} from \"./client.ts\";\nimport { parseEbayItem, parseEbaySearch } from \"./ebay.ts\";\nimport type { ParseResult } from \"./parse.ts\";\n\n/** The host of the eBay APIs. */\nexport const EBAY_HOST = \"api.ebay.com\";\n\n/** The host of the sandbox of the eBay APIs. */\nexport const EBAY_SANDBOX_HOST = \"api.sandbox.ebay.com\";\n\n/** The scope of an application token for the Browse API. */\nexport const EBAY_SCOPE = \"https://api.ebay.com/oauth/api_scope\";\n\n/**\n * The client sends one request each second at most: the API interval of the policy of `polite-crawler`. The\n * Browse API documents a count of calls each day, but no pace.\n */\nexport const EBAY_PACE_MS = 1000;\n\n/** The most items of one page of `search`. */\nexport const EBAY_SEARCH_LIMIT = 200;\n\n/** The marketplace of the US. */\nexport const EBAY_US = \"EBAY_US\";\n\n/** The options of an eBay client. */\nexport interface EbayClientOptions<S extends Signal> {\n /** The client id (the App ID) of the application. */\n readonly clientId: string;\n /** The client secret (the Cert ID) of the application. */\n readonly clientSecret: string;\n /** This function encodes a text in UTF-8, and gives its Base64 form. The host gives it, for example with `Buffer`. */\n readonly base64: (text: string) => string;\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n /** With true, the client uses the sandbox host. */\n readonly sandbox?: boolean | undefined;\n /** The marketplace of the answers. The default is `EBAY_US`. */\n readonly marketplace?: string | undefined;\n}\n\n/** A client of the eBay Browse API. Each method gives the result of a parser of this package. */\nexport interface EbayClient<S extends Signal> {\n /** This method reads `getItem` of a RESTful item id, for example `v1|110000000001|0`. */\n item(itemId: string, signal?: S): Promise<ParseResult>;\n /** This method reads one page of `search` of the words, with `limit` items at most (1 to 200, the default 50). */\n search(words: string, limit?: number, signal?: S): Promise<ParseResult>;\n}\n\nconst SOURCE = \"eBay\";\n\nconst ITEM_ID = /^v1\\|\\d{1,20}\\|\\d{1,20}$/;\nconst MARKETPLACE = /^EBAY_[A-Z]{2,4}$/;\n\n/**\n * This function makes a client of the eBay Browse API. The client gets an application token with the client\n * credentials grant, and it keeps the token until 1 minute before its end. Each request sends the token and the\n * marketplace.\n *\n * @throws RangeError when the client id or the client secret is not a key, or the marketplace is not valid.\n */\nexport function createEbayClient<S extends Signal>(options: EbayClientOptions<S>): EbayClient<S> {\n checkSecret(\"clientId\", options.clientId);\n checkSecret(\"clientSecret\", options.clientSecret);\n const marketplace = options.marketplace ?? EBAY_US;\n if (!MARKETPLACE.test(marketplace)) throw new RangeError(`The marketplace ${JSON.stringify(marketplace)} is not an eBay marketplace id.`);\n const { clientId, clientSecret, pace, transport } = options;\n const host = options.sandbox === true ? EBAY_SANDBOX_HOST : EBAY_HOST;\n const base = `https://${host}`;\n const basic = options.base64(`${clientId}:${clientSecret}`);\n const secrets = [clientId, clientSecret, basic];\n const context = { source: SOURCE, host, minIntervalMs: EBAY_PACE_MS, secrets, redact };\n\n const tokens = tokenStore<S>(async (signal) => {\n const issuedAt = pace.now();\n const exchange = {\n method: \"POST\" as const,\n url: `${base}/identity/v1/oauth2/token`,\n headers: {\n authorization: `Basic ${basic}`,\n \"content-type\": \"application/x-www-form-urlencoded\",\n accept: \"application/json\",\n },\n body: formBody({ grant_type: \"client_credentials\", scope: EBAY_SCOPE }),\n };\n const { reply } = await send(pace, transport, { ...context, what: \"the token\", exchange }, signal);\n return readGrant(reply, SOURCE, issuedAt, secrets, redact);\n }, pace.now);\n\n const headers = (token: string): Readonly<Record<string, string>> => ({\n authorization: `Bearer ${token}`,\n \"x-ebay-c-marketplace-id\": marketplace,\n });\n\n const read = async (what: string, url: string, parse: (json: unknown, at: string) => ParseResult, signal?: S) => {\n const exchange = { method: \"GET\" as const, url, headers: { accept: \"application/json\" }, body: null };\n const answer = await sendWithToken(pace, transport, tokens, { ...context, what, exchange }, headers, signal);\n return readAnswer(answer, { ...context, what }, parse, instantOf(pace.now()));\n };\n\n return {\n async item(itemId, signal) {\n const id = checkName(\"itemId\", itemId);\n if (!ITEM_ID.test(id)) throw new RangeError(`The item id ${JSON.stringify(id)} is not a RESTful item id (v1|#|#).`);\n return read(`getItem of ${id}`, `${base}/buy/browse/v1/item/${encodeURIComponent(id)}`, parseEbayItem, signal);\n },\n async search(words, limit = 50, signal) {\n const q = checkName(\"words\", words);\n if (!Number.isInteger(limit) || limit < 1 || limit > EBAY_SEARCH_LIMIT) {\n throw new RangeError(`The limit is not a whole number from 1 to ${EBAY_SEARCH_LIMIT}.`);\n }\n const query = formBody({ q, limit: String(limit) });\n return read(`search of ${JSON.stringify(q)}`, `${base}/buy/browse/v1/item_summary/search?${query}`, parseEbaySearch, signal);\n },\n };\n}\n","import { azureNextPage, azurePricesUrl, isAzurePricesUrl, parseAzureRetailPricePages, type AzureFilter } from \"./azure.ts\";\nimport { instantOf, readJson, redact, send, type Pace, type Signal, type Transport } from \"./client.ts\";\nimport type { MeteredParseResult } from \"./parse.ts\";\n\n/** The host of the Azure Retail Prices API. */\nexport const AZURE_HOST = \"prices.azure.com\";\n\n/**\n * The client sends one request each 6 seconds at most. The documentation gives no limit. But each answer has the\n * headers `x-ms-ratelimit-remaining-retailprices-requests` and `x-ms-ratelimit-retailprices-retry-after: 60`.\n * Thus the client sends 10 requests in 60 seconds at most.\n */\nexport const AZURE_PACE_MS = 6000;\n\n/** The most pages of one read. Each page has 1,000 prices at most. */\nexport const AZURE_PAGE_LIMIT = 10;\n\n/** The options of an Azure Retail Prices client. The API needs no key. */\nexport interface AzureClientOptions<S extends Signal> {\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n}\n\n/** The options of one read of prices. */\nexport interface AzureReadOptions {\n /** The most pages that the read follows, from 1 to `AZURE_PAGE_LIMIT`. The default is 1. */\n readonly pages?: number | undefined;\n /** The currency of the prices, a money unit of `@mark1russell7/quantity`. Without it, the API gives US dollars. */\n readonly currency?: string | undefined;\n}\n\n/** A client of the Azure Retail Prices API. Each method gives the result of `parseAzureRetailPricePages`. */\nexport interface AzureClient<S extends Signal> {\n /** This method reads the prices of a filter: the first page, and the next pages up to the limit of the options. */\n prices(filter: AzureFilter, options?: AzureReadOptions, signal?: S): Promise<MeteredParseResult>;\n /** This method continues a read at the link `next` of a result, with `pages` pages at most. The default is 1. */\n more(next: string, pages?: number, signal?: S): Promise<MeteredParseResult>;\n}\n\nconst SOURCE = \"Azure Retail Prices\";\n\nfunction checkPages(pages: number): number {\n if (!Number.isInteger(pages) || pages < 1 || pages > AZURE_PAGE_LIMIT) {\n throw new RangeError(`The count of pages is not a whole number from 1 to ${AZURE_PAGE_LIMIT}.`);\n }\n return pages;\n}\n\n/**\n * This function makes a client of the Azure Retail Prices API. A read follows the link of the next page of each\n * answer, only to the same API, up to its count of pages. It then reads all the pages together.\n */\nexport function createAzureClient<S extends Signal>(options: AzureClientOptions<S>): AzureClient<S> {\n const { pace, transport } = options;\n\n const read = async (first: string, pages: number, what: string, signal?: S): Promise<MeteredParseResult> => {\n const answers: unknown[] = [];\n let link: string | null = first;\n while (link !== null && answers.length < pages) {\n const page = answers.length + 1;\n const exchange = { method: \"GET\" as const, url: link, headers: { accept: \"application/json\" }, body: null };\n const input = {\n source: SOURCE,\n host: AZURE_HOST,\n minIntervalMs: AZURE_PACE_MS,\n what: page === 1 ? what : `${what}, page ${page}`,\n secrets: [],\n redact,\n exchange,\n };\n const answer = await send(pace, transport, input, signal);\n const json = readJson(answer, input);\n if (!json.ok) return json;\n answers.push(json.json);\n link = azureNextPage(json.json);\n }\n return parseAzureRetailPricePages(answers, instantOf(pace.now()));\n };\n\n return {\n async prices(filter, readOptions = {}, signal) {\n const url = azurePricesUrl(filter, readOptions.currency);\n return read(url, checkPages(readOptions.pages ?? 1), \"the prices of a filter\", signal);\n },\n async more(next, pages = 1, signal) {\n if (typeof next !== \"string\" || !isAzurePricesUrl(next)) {\n throw new RangeError(\"The link is not a link of the Azure Retail Prices API.\");\n }\n return read(next, checkPages(pages), \"the next page of a read\", signal);\n },\n };\n}\n","import { checkName, checkSecret, formBody, instantOf, readAnswer, redact, send, type Pace, type Signal, type Transport } from \"./client.ts\";\nimport { parseBestBuyOpenBox, parseBestBuyProduct, parseBestBuyProducts } from \"./bestbuy.ts\";\nimport type { ParseResult } from \"./parse.ts\";\n\n/** The host of the Best Buy APIs. */\nexport const BEST_BUY_HOST = \"api.bestbuy.com\";\n\n/**\n * The client sends one request each second at most: the API interval of the policy of `polite-crawler`. The\n * documentation of Best Buy gives no pace. It answers 403 when a key passes its limit of calls.\n */\nexport const BEST_BUY_PACE_MS = 1000;\n\n/** The most products of one page of a search. */\nexport const BEST_BUY_PAGE_LIMIT = 100;\n\n/** The options of a Best Buy client. */\nexport interface BestBuyClientOptions<S extends Signal> {\n /** The API key. It goes in the query of each request, and no message has it. */\n readonly apiKey: string;\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n}\n\n/** A client of the Best Buy Products API and Open Box API. Each method gives the result of a parser of this package. */\nexport interface BestBuyClient<S extends Signal> {\n /** This method reads one product of a SKU. */\n product(sku: string, signal?: S): Promise<ParseResult>;\n /** This method reads the first page of a search of the words, with `pageSize` products at most (1 to 100, the default 10). */\n search(words: string, pageSize?: number, signal?: S): Promise<ParseResult>;\n /** This method reads the open-box offers of a SKU. */\n openBox(sku: string, signal?: S): Promise<ParseResult>;\n}\n\nconst SOURCE = \"Best Buy\";\n\nconst SKU = /^\\d{1,12}$/;\nconst WORD = /^[A-Za-z0-9.-]{1,40}$/;\n\nfunction checkSku(sku: string): string {\n const value = checkName(\"sku\", sku);\n if (!SKU.test(value)) throw new RangeError(`The SKU ${JSON.stringify(value)} is not a number of 1 to 12 digits.`);\n return value;\n}\n\n/**\n * This function makes a client of the Best Buy APIs. The API key goes in the query of each request. A 401 or a\n * 403 stops the host for 1 hour, because Best Buy gives a 403 for a key that passed its limit.\n *\n * @throws RangeError when the API key is not a key. The message does not show the value.\n */\nexport function createBestBuyClient<S extends Signal>(options: BestBuyClientOptions<S>): BestBuyClient<S> {\n checkSecret(\"apiKey\", options.apiKey);\n const { apiKey, pace, transport } = options;\n const base = `https://${BEST_BUY_HOST}`;\n const secrets = [apiKey];\n\n const read = async (\n what: string,\n path: string,\n query: Readonly<Record<string, string>>,\n parse: (json: unknown, at: string) => ParseResult,\n signal?: S,\n ) => {\n const exchange = {\n method: \"GET\" as const,\n url: `${base}${path}?${formBody({ ...query, apiKey })}`,\n headers: { accept: \"application/json\" },\n body: null,\n };\n const input = { source: SOURCE, host: BEST_BUY_HOST, minIntervalMs: BEST_BUY_PACE_MS, what, secrets, redact, exchange };\n const answer = await send(pace, transport, input, signal);\n return readAnswer(answer, input, parse, instantOf(pace.now()));\n };\n\n return {\n async product(sku, signal) {\n const id = checkSku(sku);\n return read(`the product ${id}`, `/v1/products/${id}.json`, {}, parseBestBuyProduct, signal);\n },\n async search(words, pageSize = 10, signal) {\n const list = checkName(\"words\", words).split(/\\s+/);\n if (list.length > 10 || !list.every((word) => WORD.test(word))) {\n throw new RangeError(\"The words are not 1 to 10 words of letters, digits, points and hyphens.\");\n }\n if (!Number.isInteger(pageSize) || pageSize < 1 || pageSize > BEST_BUY_PAGE_LIMIT) {\n throw new RangeError(`The page size is not a whole number from 1 to ${BEST_BUY_PAGE_LIMIT}.`);\n }\n const filter = list.map((word) => `search=${word}`).join(\"&\");\n const query = { format: \"json\", pageSize: String(pageSize) };\n return read(`the search ${JSON.stringify(list.join(\" \"))}`, `/v1/products(${filter})`, query, parseBestBuyProducts, signal);\n },\n async openBox(sku, signal) {\n const id = checkSku(sku);\n return read(`the open-box offers of ${id}`, `/beta/products/${id}/openBox`, {}, parseBestBuyOpenBox, signal);\n },\n };\n}\n","/**\n * The generic parser of the plan lists of cloud providers. A plan list is an API that gives each plan of virtual\n * machines with its hourly price, its monthly cap and its regions. A `PlanProvider` record tells where the API keeps\n * each value. Thus a new provider is a record of data, and not new code.\n *\n * The parser gives one metered offer for each plan, region and price term. The meter `compute` counts the hours of\n * a month: the hourly price up to the monthly cap, then no price.\n */\nimport {\n offerId,\n priceTermSchema,\n sourceSchema,\n sourceTermsSchema,\n textSchema,\n type Meter,\n type MeteredObservation,\n type PriceTerm,\n type SourceTerms,\n type Spec,\n} from \"@mark1russell7/market\";\nimport { canonicalUnit, rationals } from \"@mark1russell7/quantity\";\nimport { z } from \"zod\";\nimport {\n checkAt,\n decimal,\n field,\n isCurrency,\n isRecord,\n list,\n observeMetered,\n path,\n refused,\n show,\n text,\n wholeNumber,\n type MeteredParseResult,\n type Read,\n} from \"./parse.ts\";\n\n/** The name of the meter of each plan offer. It counts the hours of use in one month. */\nexport const PLAN_METER = \"compute\";\n\n/** The name of the spec that the parser adds to each offer. Its value is the key of the price term. */\nexport const PLAN_PRICING_SPEC = \"pricing\";\n\n/**\n * The paging of a list. With `page`, the query parameter `param` has the number of the page, and the field `pages`\n * of an answer has the count of pages. With `cursor`, the field `next` of an answer has the value of `param` for the\n * next page, and an empty value ends the list.\n */\nexport type PlanPaging =\n | { readonly kind: \"none\" }\n | { readonly kind: \"page\"; readonly param: string; readonly pages: string }\n | { readonly kind: \"cursor\"; readonly param: string; readonly next: string };\n\n/** A list of an API: its path on the host, its query, the field of its items in an answer, and its paging. */\nexport interface PlanListRead {\n readonly path: string;\n readonly query: Readonly<Record<string, string>>;\n readonly items: string;\n readonly paging: PlanPaging;\n}\n\n/**\n * The price of a plan on one term. Each field is a path of names with dots in a plan, for example `price.hourly`.\n * A plan has the term only when the field `when` is `true`. The fields `regionHourly` and `regionMonthly` are the\n * paths in a price of one region. Without them, the paths in the fields `hourly` and `monthly` of the term apply.\n */\nexport interface PlanTerm {\n readonly key: string;\n readonly term: PriceTerm;\n readonly when?: string | undefined;\n readonly hourly: string;\n readonly monthly?: string | undefined;\n readonly regionHourly?: string | undefined;\n readonly regionMonthly?: string | undefined;\n}\n\n/**\n * The regions of each plan. With `field`, a plan has a list of the ids of its regions. With `list`, a different\n * list of the API has one row for each plan and region. The field `available` of a row tells if the provider has\n * the plan in that region.\n */\nexport type PlanRegions =\n | { readonly kind: \"field\"; readonly path: string }\n | {\n readonly kind: \"list\";\n readonly read: PlanListRead;\n readonly plan: string;\n readonly region: string;\n readonly available: string;\n };\n\n/**\n * The prices of a plan that change with the region. With `map`, an object of a plan has a price for each id of a\n * region. With `list`, a list of a plan has prices, each with the id of its region in the field `id`.\n */\nexport type PlanRegionPrices =\n | { readonly kind: \"none\" }\n | { readonly kind: \"map\"; readonly path: string }\n | { readonly kind: \"list\"; readonly path: string; readonly id: string };\n\n/** A spec of each offer: its name, the path of its value in a plan, and the unit that the parser adds to the value. */\nexport interface PlanSpec {\n readonly name: string;\n readonly path: string;\n readonly unit?: string | undefined;\n}\n\n/**\n * The record of a provider with a plan list. The parser and the client read the API with only this record. Each\n * path is a path of names with dots in an answer or in a plan.\n */\nexport interface PlanProvider {\n readonly source: string;\n readonly provider: string;\n readonly name: string;\n readonly host: string;\n readonly paceMs: number;\n readonly currency: string;\n readonly terms: SourceTerms;\n readonly plans: PlanListRead;\n readonly id: string;\n readonly label?: string | undefined;\n readonly regions: PlanRegions;\n readonly regionPrices: PlanRegionPrices;\n readonly prices: readonly PlanTerm[];\n readonly specs: readonly PlanSpec[];\n}\n\n/** The answers of one read of a provider: the pages of its plan list, and the pages of its list of regions. */\nexport interface PlanAnswers {\n readonly plans: readonly unknown[];\n readonly regions?: readonly unknown[] | undefined;\n}\n\nconst dottedSchema = z\n .string()\n .regex(/^[A-Za-z0-9_$-]+(\\.[A-Za-z0-9_$-]+)*$/, \"The path has names of letters, digits, _, $ and -, with a dot between two names.\");\n\nconst paramSchema = z.string().regex(/^[A-Za-z0-9_.-]+$/, \"The name of a query parameter has letters, digits, _, . and -.\");\n\nconst pagingSchema: z.ZodType<PlanPaging> = z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"none\") }),\n z.strictObject({ kind: z.literal(\"page\"), param: paramSchema, pages: dottedSchema }),\n z.strictObject({ kind: z.literal(\"cursor\"), param: paramSchema, next: dottedSchema }),\n]);\n\nconst listReadSchema: z.ZodType<PlanListRead> = z.strictObject({\n path: z.string().regex(/^\\/[A-Za-z0-9._~/-]*$/, \"The path of a list starts with a slash, and it has no query.\"),\n query: z.record(paramSchema, z.string()),\n items: dottedSchema,\n paging: pagingSchema,\n});\n\nconst termSchema: z.ZodType<PlanTerm> = z.strictObject({\n key: sourceSchema,\n term: priceTermSchema,\n when: dottedSchema.optional(),\n hourly: dottedSchema,\n monthly: dottedSchema.optional(),\n regionHourly: dottedSchema.optional(),\n regionMonthly: dottedSchema.optional(),\n});\n\nconst HOST = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/;\n\n/**\n * This schema accepts the record of a provider with a plan list. The terms are the terms of the source of the\n * record. Each price term has its own key, and each spec has its own name. The name `pricing` is for the parser.\n */\nexport const planProviderSchema: z.ZodType<PlanProvider> = z\n .strictObject({\n source: sourceSchema,\n provider: textSchema,\n name: textSchema,\n host: z.string().regex(HOST, \"The host is a DNS name with small letters, digits, hyphens and dots.\"),\n paceMs: z.number().int().min(1),\n currency: z.string().refine(isCurrency, \"The currency is not a money unit of @mark1russell7/quantity.\"),\n terms: sourceTermsSchema,\n plans: listReadSchema,\n id: dottedSchema,\n label: dottedSchema.optional(),\n regions: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"field\"), path: dottedSchema }),\n z.strictObject({\n kind: z.literal(\"list\"),\n read: listReadSchema,\n plan: dottedSchema,\n region: dottedSchema,\n available: dottedSchema,\n }),\n ]),\n regionPrices: z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"none\") }),\n z.strictObject({ kind: z.literal(\"map\"), path: dottedSchema }),\n z.strictObject({ kind: z.literal(\"list\"), path: dottedSchema, id: dottedSchema }),\n ]),\n prices: z.array(termSchema).min(1),\n specs: z.array(z.strictObject({ name: textSchema, path: dottedSchema, unit: textSchema.optional() })),\n })\n .superRefine((record, context) => {\n if (record.terms.source !== record.source) {\n context.addIssue({ code: \"custom\", message: `The terms are the terms of ${record.terms.source}, and not of ${record.source}.`, path: [\"terms\", \"source\"] });\n }\n const keys = record.prices.map((price) => price.key);\n if (new Set(keys).size !== keys.length) context.addIssue({ code: \"custom\", message: \"Two price terms have one key.\", path: [\"prices\"] });\n const names = record.specs.map((spec) => spec.name);\n if (new Set(names).size !== names.length) context.addIssue({ code: \"custom\", message: \"Two specs have one name.\", path: [\"specs\"] });\n if (names.includes(PLAN_PRICING_SPEC)) {\n context.addIssue({ code: \"custom\", message: `The spec name ${PLAN_PRICING_SPEC} is for the parser.`, path: [\"specs\"] });\n }\n });\n\n/** The result of a check of a provider record. */\nexport type PlanProviderRead = { readonly ok: true; readonly provider: PlanProvider } | { readonly ok: false; readonly problems: readonly string[] };\n\n/** This function examines a provider record, for example a record from a JSON file. */\nexport function parsePlanProvider(value: unknown): PlanProviderRead {\n const checked = planProviderSchema.safeParse(value);\n if (checked.success) return { ok: true, provider: checked.data };\n return { ok: false, problems: checked.error.issues.map((issue) => `${issue.path.join(\".\") || \"record\"}: ${issue.message}`) };\n}\n\n/** This function gives the value at a path of names with dots, or undefined. */\nfunction dig(value: unknown, dotted: string): unknown {\n return path(value, ...dotted.split(\".\"));\n}\n\n/**\n * This function gives the address of one page of a list of a provider. `after` is the value of the paging parameter\n * of the page. Without it, the address is the address of the first page.\n */\nexport function planListUrl(provider: PlanProvider, read: PlanListRead, after?: string): string {\n const { paging } = read;\n const pairs = Object.entries(read.query).filter(([name]) => paging.kind === \"none\" || after === undefined || name !== paging.param);\n if (after !== undefined && paging.kind !== \"none\") pairs.push([paging.param, after]);\n const search = pairs.map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join(\"&\");\n return `https://${provider.host}${read.path}${search === \"\" ? \"\" : `?${search}`}`;\n}\n\n/**\n * The page after an answer. The kind `next` has the value of the paging parameter of the next page. The kind `end`\n * tells that the answer is the last page. The kind `fault` tells that the answer has no valid paging field.\n */\nexport type PlanNextPage =\n | { readonly kind: \"next\"; readonly after: string }\n | { readonly kind: \"end\" }\n | { readonly kind: \"fault\"; readonly why: string };\n\n/**\n * This function gives the page after an answer. `page` is the number of the page of the answer, from 1. A paging\n * field that is missing or of a wrong type gives a fault, not the end. A part of a list gives wrong offers. A cursor\n * of empty text or null is the end.\n */\nexport function planNextPage(read: PlanListRead, answer: unknown, page: number): PlanNextPage {\n const { paging } = read;\n if (paging.kind === \"none\") return { kind: \"end\" };\n if (paging.kind === \"page\") {\n const raw = dig(answer, paging.pages);\n const pages = wholeNumber(raw);\n if (pages === undefined) return { kind: \"fault\", why: `The count of pages ${show(raw)} at ${show(paging.pages)} is not a whole number.` };\n return page < pages ? { kind: \"next\", after: String(page + 1) } : { kind: \"end\" };\n }\n const raw = dig(answer, paging.next);\n if (raw === null || (typeof raw === \"string\" && raw.trim() === \"\")) return { kind: \"end\" };\n if (typeof raw !== \"string\") return { kind: \"fault\", why: `The cursor ${show(raw)} at ${show(paging.next)} is not text or null.` };\n // The cursor is opaque, so it goes back with no change.\n return { kind: \"next\", after: raw };\n}\n\nfunction itemsOf(pages: readonly unknown[], read: PlanListRead, what: string): Read<readonly unknown[]> {\n const items: unknown[] = [];\n for (const [index, page] of pages.entries()) {\n const found = list(dig(page, read.items));\n if (found === undefined) return { ok: false, why: `The page ${index + 1} of the ${what} has no list at ${show(read.items)}.` };\n items.push(...found);\n }\n return { ok: true, value: items };\n}\n\n/** This function gives the available regions of each plan id from the rows of a list of regions. */\nfunction availability(\n rows: readonly unknown[],\n regions: Extract<PlanRegions, { kind: \"list\" }>,\n notes: string[],\n): ReadonlyMap<string, readonly string[]> {\n const map = new Map<string, string[]>();\n let bad = 0;\n let off = 0;\n for (const row of rows) {\n const plan = text(dig(row, regions.plan));\n const region = text(dig(row, regions.region));\n const available = dig(row, regions.available);\n if (plan === undefined || region === undefined || typeof available !== \"boolean\") {\n bad += 1;\n continue;\n }\n if (!available) {\n off += 1;\n continue;\n }\n const found = map.get(plan);\n if (found === undefined) map.set(plan, [region]);\n else if (!found.includes(region)) found.push(region);\n }\n if (bad > 0) notes.push(`${bad} rows of the list of regions are skipped: each has no plan, no region or no ${show(regions.available)} of true or false.`);\n if (off > 0) notes.push(`${off} pairs of a plan and a region are not available.`);\n return map;\n}\n\nfunction regionsOfItem(item: unknown, at: string): readonly string[] {\n const ids = (list(dig(item, at)) ?? []).map(text).filter((id): id is string => id !== undefined);\n return [...new Set(ids)];\n}\n\n/** This function gives the price object of one region of a plan, or undefined when the plan has no price for that region. */\nfunction regionPrice(item: unknown, prices: PlanRegionPrices, region: string): unknown {\n if (prices.kind === \"none\") return undefined;\n const found = dig(item, prices.path);\n if (prices.kind === \"map\") return isRecord(found) ? field(found, region) : undefined;\n return (list(found) ?? []).find((row) => text(dig(row, prices.id)) === region);\n}\n\n/** This function reads a price: the value at the path of the price of the region, else the value at the path of the plan. */\nfunction priceOf(item: unknown, region: unknown, itemPath: string | undefined, regionPath: string | undefined): unknown {\n if (itemPath === undefined) return undefined;\n const fromRegion = region === undefined ? undefined : dig(region, regionPath ?? itemPath);\n return fromRegion ?? dig(item, itemPath);\n}\n\n/** This function gives the meter of an hourly price with a monthly cap. Above the cap, an hour has no price. */\nfunction computeMeter(currency: string, hourly: number, monthly: number | undefined): Meter {\n const unit = canonicalUnit(`${currency}/h`);\n const tiers = [{ from: { value: 0, unit: \"h\" }, unitPrice: { value: hourly, unit } }];\n if (monthly !== undefined && monthly > 0 && hourly > 0) {\n const cap = rationals.toNumber(rationals.div(rationals.fromNumber(monthly), rationals.fromNumber(hourly)));\n tiers.push({ from: { value: cap, unit: \"h\" }, unitPrice: { value: 0, unit } });\n }\n return { name: PLAN_METER, tiers };\n}\n\nfunction specsOf(item: unknown, provider: PlanProvider, key: string): Spec[] {\n const specs: Spec[] = [];\n for (const spec of provider.specs) {\n const value = dig(item, spec.path);\n const shown = typeof value === \"number\" && Number.isFinite(value) ? String(value) : text(value);\n if (shown === undefined) continue;\n specs.push({ name: spec.name, value: spec.unit === undefined ? shown : `${shown} ${spec.unit}` });\n }\n specs.push({ name: PLAN_PRICING_SPEC, value: key });\n return specs;\n}\n\n/** This function reads one price term of one plan in one region. */\nfunction observationOf(\n provider: PlanProvider,\n item: unknown,\n plan: { readonly id: string; readonly title: string },\n term: PlanTerm,\n region: string,\n at: string,\n notes: string[],\n): MeteredObservation | undefined {\n const sourceId = `${plan.id}/${region}/${term.key}`;\n const id = offerId(provider.source, sourceId);\n const price = regionPrice(item, provider.regionPrices, region);\n const rawHourly = priceOf(item, price, term.hourly, term.regionHourly);\n const hourly = decimal(rawHourly);\n if (hourly === undefined) {\n notes.push(`The offer ${id} is skipped: its hourly price ${show(rawHourly)} is not a number of 0 or more.`);\n return undefined;\n }\n const rawMonthly = priceOf(item, price, term.monthly, term.regionMonthly);\n const monthly = rawMonthly === undefined || rawMonthly === null ? undefined : decimal(rawMonthly);\n if (rawMonthly !== undefined && rawMonthly !== null && monthly === undefined) {\n notes.push(`The offer ${id} is skipped: its monthly price ${show(rawMonthly)} is not a number of 0 or more.`);\n return undefined;\n }\n // An hourly meter of price 0 cannot give a monthly price, and the offer would look free.\n if (hourly === 0 && monthly !== undefined && monthly > 0) {\n notes.push(`The offer ${id} is skipped: its hourly price is 0 and its monthly price is ${String(monthly)}.`);\n return undefined;\n }\n // A monthly price of 0 cannot be a cap above an hourly price, so the meter has no cap. The note shows the fault of the data.\n if (hourly > 0 && monthly === 0) notes.push(`The offer ${id} has no monthly cap: its monthly price is 0 and its hourly price is ${String(hourly)}.`);\n return observeMetered(\n {\n id,\n source: provider.source,\n sourceId,\n title: plan.title,\n location: { provider: provider.provider, region },\n term: term.term,\n specs: specsOf(item, provider, term.key),\n },\n { offerId: id, at, period: { value: 1, unit: \"mo\" }, meters: [computeMeter(provider.currency, hourly, monthly)] },\n notes,\n );\n}\n\n/**\n * This function reads the answers of a plan list at the instant `at`. It gives one metered offer for each plan,\n * available region and price term. A provider with regions of the kind `list` needs the pages of that list. The\n * result has no link of a next page: the client reads each page of a list before the parse.\n */\nexport function parsePlanLists(provider: PlanProvider, answers: PlanAnswers, at: string): MeteredParseResult {\n checkAt(at);\n const notes: string[] = [];\n const items = itemsOf(answers.plans, provider.plans, \"plan list\");\n if (!items.ok) return refused(items.why);\n const { regions } = provider;\n let available: ReadonlyMap<string, readonly string[]> | undefined;\n if (regions.kind === \"list\") {\n if (answers.regions === undefined || answers.regions.length === 0) {\n return refused(`The provider ${provider.source} reads its regions from a list, and the answers have no page of that list.`);\n }\n const rows = itemsOf(answers.regions, regions.read, \"list of regions\");\n if (!rows.ok) return refused(rows.why);\n available = availability(rows.value, regions, notes);\n }\n const observations: MeteredObservation[] = [];\n const seen = new Set<string>();\n for (const [index, item] of items.value.entries()) {\n const planId = text(dig(item, provider.id));\n if (planId === undefined) {\n notes.push(`The plan ${index + 1} is skipped: it has no text at ${show(provider.id)}.`);\n continue;\n }\n const label = provider.label === undefined ? undefined : text(dig(item, provider.label));\n const plan = { id: planId, title: `${provider.name} ${label ?? planId}` };\n const places = regions.kind === \"field\" ? regionsOfItem(item, regions.path) : (available?.get(planId) ?? []);\n if (places.length === 0) {\n notes.push(`The plan ${planId} has no offer: it has no available region.`);\n continue;\n }\n for (const term of provider.prices) {\n if (term.when !== undefined && dig(item, term.when) !== true) continue;\n for (const region of places) {\n const observation = observationOf(provider, item, plan, term, region, at, notes);\n if (observation === undefined || seen.has(observation.offer.id)) continue;\n seen.add(observation.offer.id);\n observations.push(observation);\n }\n }\n }\n return { ok: true, observations, notes, next: null };\n}\n","import { instantOf, readJson, redact, send, type Pace, type Signal, type Transport } from \"./client.ts\";\nimport { refused, type MeteredParseResult, type Refused } from \"./parse.ts\";\nimport { parsePlanLists, parsePlanProvider, planListUrl, planNextPage, type PlanListRead, type PlanProvider } from \"./plans.ts\";\n\n/** The most pages of one list in one read. */\nexport const PLAN_PAGE_LIMIT = 20;\n\n/** The options of a plan client. The plan lists of the records of this package need no key. */\nexport interface PlanClientOptions<S extends Signal> {\n readonly transport: Transport<S>;\n readonly pace: Pace<S>;\n}\n\n/** The options of one read of a provider. */\nexport interface PlanReadOptions {\n /** The most pages of each list, from 1 to `PLAN_PAGE_LIMIT`. The default is `PLAN_PAGE_LIMIT`. */\n readonly pages?: number | undefined;\n}\n\n/** A client of the plan lists of providers. */\nexport interface PlanClient<S extends Signal> {\n /** This method reads each page of the lists of a provider, and gives the result of `parsePlanLists`. */\n plans(provider: PlanProvider, options?: PlanReadOptions, signal?: S): Promise<MeteredParseResult>;\n}\n\nfunction checkPages(pages: number): number {\n if (!Number.isInteger(pages) || pages < 1 || pages > PLAN_PAGE_LIMIT) {\n throw new RangeError(`The count of pages is not a whole number from 1 to ${PLAN_PAGE_LIMIT}.`);\n }\n return pages;\n}\n\ntype Pages = { readonly ok: true; readonly pages: readonly unknown[] } | Refused;\n\n/**\n * This function makes a client of the plan lists of providers. Each address comes from the provider record. An\n * answer gives only the number or the cursor of the next page. A read refuses a list with more pages than the limit,\n * because a part of a list gives wrong regions.\n */\nexport function createPlanClient<S extends Signal>(options: PlanClientOptions<S>): PlanClient<S> {\n const { pace, transport } = options;\n\n const readList = async (provider: PlanProvider, read: PlanListRead, what: string, limit: number, signal?: S): Promise<Pages> => {\n const pages: unknown[] = [];\n let after: string | undefined;\n while (pages.length < limit) {\n const page = pages.length + 1;\n const exchange = { method: \"GET\" as const, url: planListUrl(provider, read, after), headers: { accept: \"application/json\" }, body: null };\n const input = {\n source: provider.name,\n host: provider.host,\n minIntervalMs: provider.paceMs,\n what: page === 1 ? what : `${what}, page ${page}`,\n secrets: [],\n redact,\n exchange,\n };\n const answer = await send(pace, transport, input, signal);\n const json = readJson(answer, input);\n if (!json.ok) return json;\n pages.push(json.json);\n const next = planNextPage(read, json.json, page);\n if (next.kind === \"end\") return { ok: true, pages };\n if (next.kind === \"fault\") return refused(`The read stops at the page ${page} of ${what}. ${next.why}`);\n if (next.after === after) return refused(`The read stops: ${what} gives the cursor of its page ${page} again.`);\n after = next.after;\n }\n return refused(`The read stops: ${what} has more pages than the limit of ${limit}.`);\n };\n\n return {\n async plans(provider, readOptions = {}, signal) {\n const checked = parsePlanProvider(provider);\n if (!checked.ok) throw new RangeError(`The provider record is not valid: ${checked.problems.join(\" \")}`);\n const limit = checkPages(readOptions.pages ?? PLAN_PAGE_LIMIT);\n const record = checked.provider;\n const plans = await readList(record, record.plans, \"the plan list\", limit, signal);\n if (!plans.ok) return plans;\n let regions: readonly unknown[] | undefined;\n if (record.regions.kind === \"list\") {\n const read = await readList(record, record.regions.read, \"the list of regions\", limit, signal);\n if (!read.ok) return read;\n regions = read.pages;\n }\n return parsePlanLists(record, { plans: plans.pages, regions }, instantOf(pace.now()));\n },\n };\n}\n","/**\n * The adapters of the sellers of a market. Each parser reads the answer of an official API at one instant, and\n * gives the current offers and price readings as records of `@mark1russell7/market`. A parser keeps no store,\n * and it sends no request. Each source also has the terms of its API. The Azure parser gives the metered prices\n * of cloud resources as metered offers. The plan parser reads the plan list of each provider record as metered offers.\n * The BLS parser reads the average prices of the Consumer Price Index as average prices of `@mark1russell7/market`.\n *\n * Each client sends the requests of one API through a transport that its host gives. The scheduler of\n * `polite-crawler/api` keeps the pace of each host. A client keeps no store, and no message of a client has a key.\n */\nimport type { SourceTerms } from \"@mark1russell7/market\";\nimport { AZURE_TERMS } from \"./azure.ts\";\nimport { BEST_BUY_TERMS } from \"./bestbuy.ts\";\nimport { BLS_TERMS } from \"./bls.ts\";\nimport { DIGIKEY_TERMS } from \"./digikey.ts\";\nimport { EBAY_TERMS } from \"./ebay.ts\";\nimport { LINODE_TERMS, VULTR_TERMS } from \"./providers.ts\";\n\nexport {\n AZURE_API_VERSION,\n AZURE_FILTER_FIELDS,\n AZURE_PRICES_URL,\n AZURE_PROVIDER,\n AZURE_SOURCE,\n AZURE_TERMS,\n azureNextPage,\n azurePricesUrl,\n azureUnit,\n isAzurePricesUrl,\n parseAzureRetailPricePages,\n parseAzureRetailPrices,\n type AzureFilter,\n type AzureFilterField,\n type AzureUnit,\n} from \"./azure.ts\";\nexport {\n BLS_API_URL,\n BLS_SERIES_LIMIT,\n BLS_SOURCE,\n BLS_STAPLES,\n BLS_STATEMENT,\n BLS_TERMS,\n BLS_YEAR_LIMIT,\n blsRequest,\n parseBlsSeries,\n type AverageParseResult,\n type BlsSeries,\n} from \"./bls.ts\";\nexport { BLS_HOST, BLS_PACE_MS, BLS_QUOTA, BLS_QUOTA_KEY, createBlsClient, type BlsClient, type BlsClientOptions } from \"./bls-client.ts\";\nexport {\n BEST_BUY_SOURCE,\n BEST_BUY_TERMS,\n bestBuyCondition,\n parseBestBuyOpenBox,\n parseBestBuyProduct,\n parseBestBuyProducts,\n} from \"./bestbuy.ts\";\nexport {\n DIGIKEY_SELLER,\n DIGIKEY_SOURCE,\n DIGIKEY_TERMS,\n parseDigiKeyKeywordSearch,\n parseDigiKeyProductDetails,\n} from \"./digikey.ts\";\nexport { EBAY_SOURCE, EBAY_TERMS, ebayCondition, parseEbayItem, parseEbaySearch } from \"./ebay.ts\";\nexport type { MeteredObservation, MeteredParseResult, Observation, ParseResult } from \"./parse.ts\";\nexport { ApiError, SECRET_MARK, redact } from \"./client.ts\";\nexport type { ApiScheduler, Exchange, Pace, Reply, Signal, Transport } from \"./client.ts\";\nexport {\n DIGIKEY_HOST,\n DIGIKEY_PACE_MS,\n DIGIKEY_SANDBOX_HOST,\n DIGIKEY_SEARCH_LIMIT,\n DIGIKEY_US,\n createDigiKeyClient,\n} from \"./digikey-client.ts\";\nexport type { DigiKeyClient, DigiKeyClientOptions, DigiKeyLocale } from \"./digikey-client.ts\";\nexport {\n EBAY_HOST,\n EBAY_PACE_MS,\n EBAY_SANDBOX_HOST,\n EBAY_SCOPE,\n EBAY_SEARCH_LIMIT,\n EBAY_US,\n createEbayClient,\n} from \"./ebay-client.ts\";\nexport type { EbayClient, EbayClientOptions } from \"./ebay-client.ts\";\nexport { AZURE_HOST, AZURE_PACE_MS, AZURE_PAGE_LIMIT, createAzureClient } from \"./azure-client.ts\";\nexport type { AzureClient, AzureClientOptions, AzureReadOptions } from \"./azure-client.ts\";\nexport { BEST_BUY_HOST, BEST_BUY_PACE_MS, BEST_BUY_PAGE_LIMIT, createBestBuyClient } from \"./bestbuy-client.ts\";\nexport type { BestBuyClient, BestBuyClientOptions } from \"./bestbuy-client.ts\";\nexport {\n PLAN_METER,\n PLAN_PRICING_SPEC,\n parsePlanLists,\n parsePlanProvider,\n planListUrl,\n planNextPage,\n planProviderSchema,\n type PlanAnswers,\n type PlanListRead,\n type PlanNextPage,\n type PlanPaging,\n type PlanProvider,\n type PlanProviderRead,\n type PlanRegionPrices,\n type PlanRegions,\n type PlanSpec,\n type PlanTerm,\n} from \"./plans.ts\";\nexport { LINODE_PLANS, LINODE_SOURCE, LINODE_TERMS, PLAN_PROVIDERS, VULTR_PLANS, VULTR_SOURCE, VULTR_TERMS } from \"./providers.ts\";\nexport { PLAN_PAGE_LIMIT, createPlanClient } from \"./plans-client.ts\";\nexport type { PlanClient, PlanClientOptions, PlanReadOptions } from \"./plans-client.ts\";\n\n/** The terms of each source of this package: the sellers in the order of the hand crawl, then Azure, then the plan lists. */\n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ore.org/package",
|
|
3
3
|
"name": "@mark1russell7/market-sources",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.6",
|
|
5
5
|
"description": "The adapters of the sellers of a market and of cloud price APIs: each one reads the answer of an official API, and gives the current offers and price readings as records of @mark1russell7/market.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@mark1russell7/market": "0.
|
|
41
|
+
"@mark1russell7/market": "0.7.0",
|
|
42
42
|
"@mark1russell7/quantity": "^0.4.5",
|
|
43
43
|
"@mark1russell7/text": "^0.0.16",
|
|
44
44
|
"polite-crawler": "^0.7.3",
|