@mark1russell7/market-sources 0.2.6 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["shippingOf","specsOf","mapProduct","sellerOf","specsOf","statusLine","SOURCE","SOURCE"],"sources":["../src/parse.ts","../src/bestbuy.ts","../src/digikey.ts","../src/ebay.ts","../src/client.ts","../src/digikey-client.ts","../src/ebay-client.ts","../src/bestbuy-client.ts","../src/index.ts"],"sourcesContent":["import {\n instantSchema,\n moneySchema,\n offerSchema,\n priceReadingSchema,\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/**\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/** 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/** 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[]): ParseResult {\n return { ok: false, problems };\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 { 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 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 } 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/**\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 { 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 let json: unknown;\n try {\n json = JSON.parse(reply.body);\n } catch {\n return refused(`The answer of ${input.source} to ${input.what} is not JSON.`);\n }\n return parse(json, at);\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 {\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 { 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 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.\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 { BEST_BUY_TERMS } from \"./bestbuy.ts\";\nimport { DIGIKEY_TERMS } from \"./digikey.ts\";\nimport { EBAY_TERMS } from \"./ebay.ts\";\n\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 { 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 { BEST_BUY_HOST, BEST_BUY_PACE_MS, BEST_BUY_PAGE_LIMIT, createBestBuyClient } from \"./bestbuy-client.ts\";\nexport type { BestBuyClient, BestBuyClientOptions } from \"./bestbuy-client.ts\";\n\n/** The terms of each source of this package, in the order of the hand crawl. */\nexport const SOURCE_TERMS: readonly SourceTerms[] = [EBAY_TERMS, BEST_BUY_TERMS, DIGIKEY_TERMS];\n"],"mappings":";;;;;;AA4BA,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,QAAQ,KAAA;CACrF,IAAI,OAAO,UAAU,YAAY,CA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AAK,WAAW,KAAK,WAAA,KACjD,MAAM,IAAI,WAAW,oDAAuE;GAE9F,MAAM,SAAS,KAAK,KAAK,SAAS,UAAU,MAAM,CAAC,CAAC,KAAK,GAAG;GAC5D,MAAM,QAAQ;IAAE,QAAQ;IAAQ,UAAU,OAAO,QAAQ;GAAE;GAC3D,OAAO,KAAK,cAAc,KAAK,UAAU,KAAK,KAAK,GAAG,CAAC,KAAK,gBAAgB,OAAO,IAAI,OAAO,sBAAsB,MAAM;EAC5H;EACA,MAAM,QAAQ,KAAK,QAAQ;GACzB,MAAM,KAAK,SAAS,GAAG;GACvB,OAAO,KAAK,0BAA0B,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,qBAAqB,MAAM;EAC7G;CACF;AACF;;;AC1CA,MAAa,eAAuC;CAAC;CAAY;CAAgB;AAAa"}
1
+ {"version":3,"file":"index.js","names":["shippingOf","specsOf","mapProduct","sellerOf","specsOf","statusLine","SOURCE","SOURCE","SOURCE"],"sources":["../src/parse.ts","../src/azure.ts","../src/bestbuy.ts","../src/digikey.ts","../src/ebay.ts","../src/client.ts","../src/digikey-client.ts","../src/ebay-client.ts","../src/azure-client.ts","../src/bestbuy-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 { 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 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 {\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 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.\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 { DIGIKEY_TERMS } from \"./digikey.ts\";\nimport { EBAY_TERMS } from \"./ebay.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 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\";\n\n/** The terms of each source of this package: the sellers in the order of the hand crawl, then Azure. */\nexport const SOURCE_TERMS: readonly SourceTerms[] = [EBAY_TERMS, BEST_BUY_TERMS, DIGIKEY_TERMS, AZURE_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,QAAQ,KAAA;CACrF,IAAI,OAAO,UAAU,YAAY,CAAC,QAAQ,KAAK,KAAK,GAAG,OAAO,KAAA;CAC9D,MAAM,SAAS,OAAO,KAAK;CAC3B,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS,KAAA;AAC5C;;AAGA,SAAgB,KAAK,OAAwB;CAC3C,IAAI;CACJ,IAAI;EACF,QAAQ,KAAK,UAAU,KAAK;CAC9B,Q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,WAAW,yEAAyE;GAEhG,IAAI,CAAC,OAAO,UAAU,QAAQ,KAAK,WAAW,KAAK,WAAA,KACjD,MAAM,IAAI,WAAW,oDAAuE;GAE9F,MAAM,SAAS,KAAK,KAAK,SAAS,UAAU,MAAM,CAAC,CAAC,KAAK,GAAG;GAC5D,MAAM,QAAQ;IAAE,QAAQ;IAAQ,UAAU,OAAO,QAAQ;GAAE;GAC3D,OAAO,KAAK,cAAc,KAAK,UAAU,KAAK,KAAK,GAAG,CAAC,KAAK,gBAAgB,OAAO,IAAI,OAAO,sBAAsB,MAAM;EAC5H;EACA,MAAM,QAAQ,KAAK,QAAQ;GACzB,MAAM,KAAK,SAAS,GAAG;GACvB,OAAO,KAAK,0BAA0B,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,qBAAqB,MAAM;EAC7G;CACF;AACF;;;ACrBA,MAAa,eAAuC;CAAC;CAAY;CAAgB;CAAe;AAAW"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/market-sources",
4
- "version": "0.2.6",
5
- "description": "The adapters of the sellers of a market: each one reads the answer of an official API, and gives the current offers and price readings as records of @mark1russell7/market.",
4
+ "version": "0.2.7",
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": {
8
8
  "type": "git",
@@ -20,7 +20,9 @@
20
20
  "seller-api",
21
21
  "adapters",
22
22
  "price-history",
23
- "polite-crawler"
23
+ "polite-crawler",
24
+ "cloud-pricing",
25
+ "azure"
24
26
  ],
25
27
  "type": "module",
26
28
  "main": "./build/index.js",