@mark1russell7/market-sources 0.2.6 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @mark1russell7/market-sources
2
2
 
3
- The adapters of the sellers of a market. Each parser reads the answer of an official API at one instant. It gives the current offers and their price readings as records of [`@mark1russell7/market`](../market/README.md).
3
+ The adapters of the sellers of a market and of the price APIs of clouds. Each parser reads the answer of an official API at one instant. It gives the current offers and their price readings as records of [`@mark1russell7/market`](../market/README.md). The parsers of a cloud give metered offers and their metered readings.
4
4
 
5
5
  ```sh
6
6
  pnpm add @mark1russell7/market-sources
@@ -36,12 +36,17 @@ for (const note of result.notes) console.warn(note);
36
36
  | `parseBestBuyOpenBox` | the Best Buy Open Box API: `GET /beta/products/{sku}/openBox` |
37
37
  | `parseDigiKeyProductDetails` | `ProductDetails` of the Digi-Key Product Information API v4 |
38
38
  | `parseDigiKeyKeywordSearch` | `KeywordSearch` of the Digi-Key Product Information API v4 |
39
+ | `parseAzureRetailPrices` | one page of the Azure Retail Prices API: `GET /api/retail/prices` |
40
+ | `parseAzureRetailPricePages` | all the pages of one read of the Azure Retail Prices API |
41
+ | `parsePlanLists` | all the pages of the plan list of a provider record, for example `GET /v2/plans` of the Vultr API |
39
42
 
40
43
  Each parser takes the JSON of the answer and the instant `at` of the answer. It gives one of two results:
41
44
 
42
45
  - `{ ok: true, observations, notes }`. The answer has the documented shape. Each observation is an offer and its reading, and the schemas of `@mark1russell7/market` accept both. Each note tells why the parser skipped a record or a field.
43
46
  - `{ ok: false, problems }`. The answer does not have the documented shape, for example the error body of an API.
44
47
 
48
+ The Azure parsers and the plan parser give metered observations of `@mark1russell7/market`, and `next`. The field `next` is the link of the next page, or `null`.
49
+
45
50
  A parser throws a `RangeError` only when `at` is not an ISO 8601 instant in UTC. It does not throw on the answer, for any JSON value.
46
51
 
47
52
  ## The rules of the parsers
@@ -88,6 +93,53 @@ The US APIs of Best Buy give each price in US dollars.
88
93
 
89
94
  The API has no GTIN and no shipping cost. The shipping of a reading is `unknown`.
90
95
 
96
+ ### Azure
97
+
98
+ The Azure Retail Prices API gives the public retail prices of Azure. It needs no key. Each observation goes through `meteredObservationSchema`.
99
+
100
+ | Field | Rule |
101
+ | --- | --- |
102
+ | Offers | Each SKU in a region on a term is one offer, with the source id `{armRegionName}/{skuId}/{term}`. Each meter of the SKU is a meter of the offer. |
103
+ | Terms | A `Consumption` row gives `on-demand`, or `spot` when its SKU name ends in `Spot` or `Low Priority`. Each entry of `savingsPlan` gives a `committed` offer at its rate. |
104
+ | Reservations | A `Reservation` row gives a `committed` offer. Its price is the total for the term. Thus it is the `upfront` money of the reading, and the rate is 0. |
105
+ | Dev/Test | A `DevTestConsumption` row gives its own offer, with `Dev/Test` in its title. |
106
+ | Units | The unit of measure gives a unit of `@mark1russell7/quantity`. `1 Hour` gives `h`, `1 GB/Month` gives `GiB·mo` and `10K` gives 10,000 `{count}`. |
107
+ | Unit prices | The price of a unit is the price of the row over its count, with exact rationals. |
108
+ | Data | A GB of Azure is 2^30 bytes, from the pricing pages of Blob Storage. Thus `GB`, `MB` and `TB` give `GiB`, `MiB` and `TiB`. |
109
+ | Tiers | `tierMinimumUnits` is the start of a tier, in the unit of its meter. A free first amount stays a tier at the price 0. |
110
+ | Period | Each reading has the period of 1 month. |
111
+ | Specs | `serviceName`, `serviceFamily`, `productName`, `skuName`, `armSkuName` and `location`, and `pricing`: the key of the term, for example `savings-plan-3y`. |
112
+ | Pages | A page has 1,000 rows at most. The tiers of a meter can continue on the next page. Thus `parseAzureRetailPricePages` reads the pages of one read together. |
113
+
114
+ These rows give a note, and the parser skips them:
115
+
116
+ - A meter whose tiers start above 0 in a unit of more than 1 count. The documentation does not tell the unit of the start.
117
+ - A meter with no tier at 0, or with two prices for one tier.
118
+ - A unit of measure that the parser does not know, for example `1 PB`. The unit `PiB` is not in `@mark1russell7/quantity`.
119
+
120
+ A reservation and a savings plan cover a fixed amount of use. The metered model has no limit of coverage. Thus give the usage of a committed offer only for the covered hours.
121
+
122
+ ### Plan lists
123
+
124
+ A plan list is an API that gives each plan of virtual machines with its prices and its regions. A `PlanProvider` record tells where the API keeps each value. Each value is at a path of names with dots, for example `price.hourly`. Thus a new provider is a record of data, and not new code. `parsePlanProvider` examines a record, for example a record from a JSON file.
125
+
126
+ | Record | API | Regions | Prices of a region | Terms |
127
+ | --- | --- | --- | --- | --- |
128
+ | `VULTR_PLANS` | `GET /v2/plans` of the Vultr API v2 | the list `locations` of each plan | the object `location_cost` | `on-demand` when `deploy_ondemand` is true, `spot` when `deploy_preemptible` is true |
129
+ | `LINODE_PLANS` | `GET /v4/linode/types` of the Linode API v4 of Akamai Cloud | the rows of `GET /v4/regions/availability` with `available: true` | the list `region_prices` | `on-demand` |
130
+
131
+ | Field | Rule |
132
+ | --- | --- |
133
+ | Offers | Each plan in each available region on each term is one offer, with the source id `{plan}/{region}/{term}`. A plan with no available region gives a note. |
134
+ | Meter | The meter `compute` counts the hours of use in 1 month. Its first tier is the hourly price. A tier at the price 0 starts at the monthly price over the hourly price. |
135
+ | Cost | Thus the cost of a month is the smaller of the hourly cost and the monthly price. A plan with no monthly price has only the hourly tier. |
136
+ | Prices of a region | The price of a region replaces the price of the plan. A field that the price of a region does not have comes from the plan. |
137
+ | Specs | Each spec of the record, with its unit, for example `memory` with the value `1024 MiB`. The spec `pricing` has the key of the term. |
138
+ | Availability | The rows of the list of regions with no plan, no region or no `available` of true or false count in one note. The pairs that are not available count in one note. |
139
+ | Transfer | The included transfer is a spec. The plan lists do not give the price of the transfer above it. Thus an offer has no meter of transfer. |
140
+
141
+ `parsePlanLists(provider, { plans, regions }, at)` takes the pages of the plan list. A record with regions of the kind `list` also needs the pages of that list. The field `next` of the result is always `null`, because the client reads each page before the parse.
142
+
91
143
  ## The clients
92
144
 
93
145
  | Client | Methods | Pace | Access |
@@ -95,6 +147,8 @@ The API has no GTIN and no shipping cost. The shipping of a reading is `unknown`
95
147
  | `createDigiKeyClient` | `productDetails(productNumber)`, `keywordSearch(keywords, limit)` | 500 ms | OAuth 2.0 client credentials, the client id in a header |
96
148
  | `createEbayClient` | `item(itemId)`, `search(words, limit)` | 1 s | OAuth 2.0 client credentials with Basic, the scope `api_scope` |
97
149
  | `createBestBuyClient` | `product(sku)`, `search(words, pageSize)`, `openBox(sku)` | 1 s | the API key in the query |
150
+ | `createAzureClient` | `prices(filter, { pages, currency })`, `more(next, pages)` | 6 s | no key |
151
+ | `createPlanClient` | `plans(provider, { pages })` | the pace of the record, 2 s for each record of the package | no key |
98
152
 
99
153
  ```ts
100
154
  import { HostScheduler, realClock } from "polite-crawler/politeness";
@@ -125,6 +179,9 @@ The package uses no type of a platform. Thus the host gives each port:
125
179
  - **Answers.** An answer that is not a 2xx gives `{ ok: false, problems }` with its status line. The problem has no part of the body.
126
180
  - **Secrets.** No message of a client has a key, a secret or a token. The text `[secret]` is in the place of each one, also in its URL form, its form-body form and its Basic form. `redact` uses `redactSecrets` of `@mark1russell7/text`.
127
181
  - **Inputs.** A client refuses a bad key, a bad product number, a bad SKU and a limit out of range with a `RangeError`, before a request.
182
+ - **Pages.** The Azure client follows the link of the next page only to the same API, up to 10 pages. An empty filter is a `RangeError`, because a read of all the prices is a large crawl.
183
+ - **Plan lists.** The plan client makes each address from the record. An answer gives only the number or the cursor of the next page. A list with more pages than the limit gives a problem, because a part of a list gives wrong regions. The limit is 20 pages. A cursor that comes again also gives a problem.
184
+ - **Pace of Azure.** Each answer of Azure tells the requests that remain in a window of 60 seconds, from 10. Thus the client sends 1 request in 6 seconds at most.
128
185
 
129
186
  The clients send each request with `send` of `polite-crawler/api`. It has the scheduler, the classifier and the reaction of the crawler to an answer, with no page store. The entry also gives the token store and the grant. The clients do not use the `Crawler`. The crawler keeps a copy of each page, and the terms of Digi-Key permit no store. The crawler also sends only `GET`, and a token request is a `POST`.
130
187
 
@@ -137,13 +194,22 @@ Each source has its terms as a `SourceTerms` record of `@mark1russell7/market`,
137
194
  | `ebay` | `EBAY_TERMS` | 6 hours | deleted | no |
138
195
  | `bestbuy` | `BEST_BUY_TERMS` | 72 hours | kept until the limit | no |
139
196
  | `digikey` | `DIGIKEY_TERMS` | no store | not applicable | no |
197
+ | `azure` | `AZURE_TERMS` | no limit | kept | yes |
198
+ | `linode` | `LINODE_TERMS` | no store | not applicable | no |
199
+ | `vultr` | `VULTR_TERMS` | no store | not applicable | no |
200
+
201
+ `SOURCE_TERMS` has the six records.
202
+
203
+ The terms pages of Vultr and of Akamai refused an automated read on 2026-11-18. Thus `LINODE_TERMS` and `VULTR_TERMS` have the strictest rules: no store and no model of prices. A person reads the terms before a rule changes. The Linode API reference tells that the reads of the plan list need no permissions.
140
204
 
141
- `SOURCE_TERMS` has the three records.
205
+ The Microsoft APIs Terms of Use permit copies of the Azure prices only as the application needs them. They forbid the redistribution and the resale of the data.
142
206
 
143
207
  ## Tests
144
208
 
145
209
  - Each parser has a test of the documented answer of its API, and tests of each rule above.
210
+ - The Azure parser has a test of a page of 18 real public rows, read on 2026-11-18. Each row has only the fields that the parser reads. The tests also find the cost of each offer with `meteredCost`.
146
211
  - Property tests with `fast-check` mutate each documented answer: they delete fields, and put edge values and random JSON in their place. Each result has only valid records, and each reading belongs to its offer.
147
212
  - A property test gives each parser random JSON values. No parser throws.
213
+ - The plan parser has tests of plans from public answers of Vultr and Linode, read on 2026-11-18. Property tests mutate each answer. A property test holds the cost of each offer: the smaller of the hourly cost and the monthly price.
148
214
  - The tests of the clients use a fake transport and a real scheduler of `polite-crawler` on a fake clock. They hold each rule of the clients: the pace, the waits, the stops, the tokens and the secrets. `polite-crawler/api` has the tests of the send and of the token store.
149
215
  - A property test puts a random secret in random texts. No text that `redact` gives has the secret.
package/build/index.d.ts CHANGED
@@ -1,14 +1,16 @@
1
1
  /**
2
2
  * The adapters of the sellers of a market. Each parser reads the answer of an official API at one instant, and
3
3
  * gives the current offers and price readings as records of `@mark1russell7/market`. A parser keeps no store,
4
- * and it sends no request. Each source also has the terms of its API.
4
+ * and it sends no request. Each source also has the terms of its API. The Azure parser gives the metered prices
5
+ * of cloud resources as metered offers. The plan parser reads the plan list of each provider record as metered offers.
5
6
  *
6
7
  * Each client sends the requests of one API through a transport that its host gives. The scheduler of
7
8
  * `polite-crawler/api` keeps the pace of each host. A client keeps no store, and no message of a client has a key.
8
9
  */
9
- import { Condition, Observation, SourceTerms } from "@mark1russell7/market";
10
- import { ApiError, ApiScheduler, Exchange, Pace, Reply, Signal, Transport } from "polite-crawler/api";
10
+ import { Condition, MeteredObservation, Observation, PriceTerm, SourceTerms } from "@mark1russell7/market";
11
11
  import "@mark1russell7/quantity";
12
+ import { z } from "zod";
13
+ import { ApiError, ApiScheduler, Exchange, Pace, Reply, Signal, Transport } from "polite-crawler/api";
12
14
  /**
13
15
  * The result of a parser. With `ok`, the answer has the documented shape. Each observation is valid under the
14
16
  * schemas of `@mark1russell7/market`, and each note tells why the parser skipped a record or a field. Without
@@ -22,6 +24,80 @@ type ParseResult = {
22
24
  readonly ok: false;
23
25
  readonly problems: readonly string[];
24
26
  };
27
+ /** The result of a parser for an answer that does not have the documented shape. */
28
+ type Refused = Extract<ParseResult, {
29
+ readonly ok: false;
30
+ }>;
31
+ /**
32
+ * The result of a parser of metered prices. With `ok`, each observation is valid under the schemas of
33
+ * `@mark1russell7/market`, and `next` is the link of the next page of the answer, or null. Without `ok`, the
34
+ * answer does not have the documented shape, and `problems` tells why.
35
+ */
36
+ type MeteredParseResult = {
37
+ readonly ok: true;
38
+ readonly observations: readonly MeteredObservation[];
39
+ readonly notes: readonly string[];
40
+ readonly next: string | null;
41
+ } | Refused;
42
+ /** The name of the Azure Retail Prices API as a source of metered offers. */
43
+ export declare const AZURE_SOURCE = "azure";
44
+ /** The provider of the location of each offer of the Azure Retail Prices API. */
45
+ export declare const AZURE_PROVIDER = "azure";
46
+ /**
47
+ * The terms of the Azure Retail Prices API. The API needs no key, and its documentation names tools for internal
48
+ * analysis and price comparison. The Microsoft APIs Terms of Use permit copies only for the use of the
49
+ * application, and they forbid redistribution and resale of the data.
50
+ */
51
+ export declare const AZURE_TERMS: SourceTerms;
52
+ /** The address of the Azure Retail Prices API. */
53
+ export declare const AZURE_PRICES_URL = "https://prices.azure.com/api/retail/prices";
54
+ /** The version of the API that the request builder asks for. Only this version gives the prices of savings plans. */
55
+ export declare const AZURE_API_VERSION = "2023-01-01-preview";
56
+ /** The fields of a filter of the Azure Retail Prices API, from its documentation. */
57
+ export declare const AZURE_FILTER_FIELDS: readonly ["armRegionName", "location", "meterId", "meterName", "productId", "skuId", "productName", "skuName", "serviceName", "serviceId", "serviceFamily", "priceType", "armSkuName"];
58
+ /** A field of a filter of the Azure Retail Prices API. */
59
+ type AzureFilterField = (typeof AZURE_FILTER_FIELDS)[number];
60
+ /** A filter of the Azure Retail Prices API: the value of each field. The API compares each value with its case. */
61
+ type AzureFilter = { readonly [Field in AzureFilterField]?: string; };
62
+ /** A unit of measure of the API: the count of units that one price buys, and the unit of `@mark1russell7/quantity`. */
63
+ interface AzureUnit {
64
+ readonly count: number;
65
+ readonly unit: string;
66
+ }
67
+ /**
68
+ * This function gives the URL of a read of the Azure Retail Prices API with a filter. Each field of the filter
69
+ * gives the term `field eq 'value'`, and the terms join with `and`. Without a currency, the API gives US dollars.
70
+ *
71
+ * @throws RangeError when the filter has no field, or a field that the API does not filter. It also throws when a
72
+ * value is empty, has a space at an end, has a control character or has more than 200 characters. A currency that
73
+ * `@mark1russell7/quantity` does not have also gives a `RangeError`.
74
+ */
75
+ export declare function azurePricesUrl(filter: AzureFilter, currency?: string): string;
76
+ /** This function tells if a link goes to the Azure Retail Prices API (`AZURE_PRICES_LINK`). */
77
+ export declare function isAzurePricesUrl(link: string): boolean;
78
+ /** This function gives the link of the next page of an answer, or null. A link to another address gives null. */
79
+ export declare function azureNextPage(answer: unknown): string | null;
80
+ /**
81
+ * This function gives the unit of a unit of measure of the API, or undefined when the parser does not know it. A
82
+ * count with no word gives `{count}`, for example `10K` gives 10,000 of `{count}`. A word of data or time gives
83
+ * its unit, and `/Month` multiplies it by a month. Only `1/Hour` and `1/Month` give a time alone.
84
+ */
85
+ export declare function azureUnit(unitOfMeasure: string): AzureUnit | undefined;
86
+ /**
87
+ * This function reads one page of the Azure Retail Prices API (`GET /api/retail/prices`) at the instant `at`.
88
+ * The prices of one SKU can continue on the next page: `parseAzureRetailPricePages` reads all the pages together.
89
+ *
90
+ * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.
91
+ */
92
+ export declare function parseAzureRetailPrices(answer: unknown, at: string): MeteredParseResult;
93
+ /**
94
+ * This function reads the pages of one read of the Azure Retail Prices API at the instant `at`. Each SKU in a
95
+ * region on a term gives one offer, with a meter for each meter of the SKU. The `next` of the result is the link
96
+ * of the last page.
97
+ *
98
+ * @throws RangeError when `at` is not an instant in UTC in the ISO 8601 form.
99
+ */
100
+ export declare function parseAzureRetailPricePages(answers: readonly unknown[], at: string): MeteredParseResult;
25
101
  /** The name of the Best Buy Products API and Open Box API as a source of offers. */
26
102
  export declare const BEST_BUY_SOURCE = "bestbuy";
27
103
  /**
@@ -205,6 +281,40 @@ interface EbayClient<S extends Signal> {
205
281
  * @throws RangeError when the client id or the client secret is not a key, or the marketplace is not valid.
206
282
  */
207
283
  export declare function createEbayClient<S extends Signal>(options: EbayClientOptions<S>): EbayClient<S>;
284
+ /** The host of the Azure Retail Prices API. */
285
+ export declare const AZURE_HOST = "prices.azure.com";
286
+ /**
287
+ * The client sends one request each 6 seconds at most. The documentation gives no limit. But each answer has the
288
+ * headers `x-ms-ratelimit-remaining-retailprices-requests` and `x-ms-ratelimit-retailprices-retry-after: 60`.
289
+ * Thus the client sends 10 requests in 60 seconds at most.
290
+ */
291
+ export declare const AZURE_PACE_MS = 6e3;
292
+ /** The most pages of one read. Each page has 1,000 prices at most. */
293
+ export declare const AZURE_PAGE_LIMIT = 10;
294
+ /** The options of an Azure Retail Prices client. The API needs no key. */
295
+ interface AzureClientOptions<S extends Signal> {
296
+ readonly transport: Transport<S>;
297
+ readonly pace: Pace<S>;
298
+ }
299
+ /** The options of one read of prices. */
300
+ interface AzureReadOptions {
301
+ /** The most pages that the read follows, from 1 to `AZURE_PAGE_LIMIT`. The default is 1. */
302
+ readonly pages?: number | undefined;
303
+ /** The currency of the prices, a money unit of `@mark1russell7/quantity`. Without it, the API gives US dollars. */
304
+ readonly currency?: string | undefined;
305
+ }
306
+ /** A client of the Azure Retail Prices API. Each method gives the result of `parseAzureRetailPricePages`. */
307
+ interface AzureClient<S extends Signal> {
308
+ /** This method reads the prices of a filter: the first page, and the next pages up to the limit of the options. */
309
+ prices(filter: AzureFilter, options?: AzureReadOptions, signal?: S): Promise<MeteredParseResult>;
310
+ /** This method continues a read at the link `next` of a result, with `pages` pages at most. The default is 1. */
311
+ more(next: string, pages?: number, signal?: S): Promise<MeteredParseResult>;
312
+ }
313
+ /**
314
+ * This function makes a client of the Azure Retail Prices API. A read follows the link of the next page of each
315
+ * answer, only to the same API, up to its count of pages. It then reads all the pages together.
316
+ */
317
+ export declare function createAzureClient<S extends Signal>(options: AzureClientOptions<S>): AzureClient<S>;
208
318
  /** The host of the Best Buy APIs. */
209
319
  export declare const BEST_BUY_HOST = "api.bestbuy.com";
210
320
  /**
@@ -237,7 +347,184 @@ interface BestBuyClient<S extends Signal> {
237
347
  * @throws RangeError when the API key is not a key. The message does not show the value.
238
348
  */
239
349
  export declare function createBestBuyClient<S extends Signal>(options: BestBuyClientOptions<S>): BestBuyClient<S>;
240
- /** The terms of each source of this package, in the order of the hand crawl. */
350
+ /** The name of the meter of each plan offer. It counts the hours of use in one month. */
351
+ export declare const PLAN_METER = "compute";
352
+ /** The name of the spec that the parser adds to each offer. Its value is the key of the price term. */
353
+ export declare const PLAN_PRICING_SPEC = "pricing";
354
+ /**
355
+ * The paging of a list. With `page`, the query parameter `param` has the number of the page, and the field `pages`
356
+ * of an answer has the count of pages. With `cursor`, the field `next` of an answer has the value of `param` for the
357
+ * next page, and an empty value ends the list.
358
+ */
359
+ type PlanPaging = {
360
+ readonly kind: "none";
361
+ } | {
362
+ readonly kind: "page";
363
+ readonly param: string;
364
+ readonly pages: string;
365
+ } | {
366
+ readonly kind: "cursor";
367
+ readonly param: string;
368
+ readonly next: string;
369
+ };
370
+ /** A list of an API: its path on the host, its query, the field of its items in an answer, and its paging. */
371
+ interface PlanListRead {
372
+ readonly path: string;
373
+ readonly query: Readonly<Record<string, string>>;
374
+ readonly items: string;
375
+ readonly paging: PlanPaging;
376
+ }
377
+ /**
378
+ * The price of a plan on one term. Each field is a path of names with dots in a plan, for example `price.hourly`.
379
+ * A plan has the term only when the field `when` is `true`. The fields `regionHourly` and `regionMonthly` are the
380
+ * paths in a price of one region. Their defaults are `hourly` and `monthly`.
381
+ */
382
+ interface PlanTerm {
383
+ readonly key: string;
384
+ readonly term: PriceTerm;
385
+ readonly when?: string | undefined;
386
+ readonly hourly: string;
387
+ readonly monthly?: string | undefined;
388
+ readonly regionHourly?: string | undefined;
389
+ readonly regionMonthly?: string | undefined;
390
+ }
391
+ /**
392
+ * The regions of each plan. With `field`, a plan has a list of the ids of its regions. With `list`, a different
393
+ * list of the API has one row for each plan and region. The field `available` of a row tells if the provider has
394
+ * the plan in that region.
395
+ */
396
+ type PlanRegions = {
397
+ readonly kind: "field";
398
+ readonly path: string;
399
+ } | {
400
+ readonly kind: "list";
401
+ readonly read: PlanListRead;
402
+ readonly plan: string;
403
+ readonly region: string;
404
+ readonly available: string;
405
+ };
406
+ /**
407
+ * The prices of a plan that change with the region. With `map`, an object of a plan has a price for each id of a
408
+ * region. With `list`, a list of a plan has prices, each with the id of its region in the field `id`.
409
+ */
410
+ type PlanRegionPrices = {
411
+ readonly kind: "none";
412
+ } | {
413
+ readonly kind: "map";
414
+ readonly path: string;
415
+ } | {
416
+ readonly kind: "list";
417
+ readonly path: string;
418
+ readonly id: string;
419
+ };
420
+ /** A spec of each offer: its name, the path of its value in a plan, and the unit that the parser adds to the value. */
421
+ interface PlanSpec {
422
+ readonly name: string;
423
+ readonly path: string;
424
+ readonly unit?: string | undefined;
425
+ }
426
+ /**
427
+ * The record of a provider with a plan list. The parser and the client read the API with only this record. Each
428
+ * path is a path of names with dots in an answer or in a plan.
429
+ */
430
+ interface PlanProvider {
431
+ readonly source: string;
432
+ readonly provider: string;
433
+ readonly name: string;
434
+ readonly host: string;
435
+ readonly paceMs: number;
436
+ readonly currency: string;
437
+ readonly terms: SourceTerms;
438
+ readonly plans: PlanListRead;
439
+ readonly id: string;
440
+ readonly label?: string | undefined;
441
+ readonly regions: PlanRegions;
442
+ readonly regionPrices: PlanRegionPrices;
443
+ readonly prices: readonly PlanTerm[];
444
+ readonly specs: readonly PlanSpec[];
445
+ }
446
+ /** The answers of one read of a provider: the pages of its plan list, and the pages of its list of regions. */
447
+ interface PlanAnswers {
448
+ readonly plans: readonly unknown[];
449
+ readonly regions?: readonly unknown[] | undefined;
450
+ }
451
+ /**
452
+ * This schema accepts the record of a provider with a plan list. The terms are the terms of the source of the
453
+ * record. Each price term has its own key, and each spec has its own name. The name `pricing` is for the parser.
454
+ */
455
+ export declare const planProviderSchema: z.ZodType<PlanProvider>;
456
+ /** The result of a check of a provider record. */
457
+ type PlanProviderRead = {
458
+ readonly ok: true;
459
+ readonly provider: PlanProvider;
460
+ } | {
461
+ readonly ok: false;
462
+ readonly problems: readonly string[];
463
+ };
464
+ /** This function examines a provider record, for example a record from a JSON file. */
465
+ export declare function parsePlanProvider(value: unknown): PlanProviderRead;
466
+ /**
467
+ * This function gives the address of one page of a list of a provider. `after` is the value of the paging parameter
468
+ * of the page. Without it, the address is the address of the first page.
469
+ */
470
+ export declare function planListUrl(provider: PlanProvider, read: PlanListRead, after?: string): string;
471
+ /**
472
+ * This function gives the value of the paging parameter of the page after an answer, or null when the answer is the
473
+ * last page. `page` is the number of the page of the answer, from 1.
474
+ */
475
+ export declare function planNextPage(read: PlanListRead, answer: unknown, page: number): string | null;
476
+ /**
477
+ * This function reads the answers of a plan list at the instant `at`. It gives one metered offer for each plan,
478
+ * available region and price term. A provider with regions of the kind `list` needs the pages of that list. The
479
+ * result has no link of a next page: the client reads each page of a list before the parse.
480
+ */
481
+ export declare function parsePlanLists(provider: PlanProvider, answers: PlanAnswers, at: string): MeteredParseResult;
482
+ /** The name of the Vultr source. */
483
+ export declare const VULTR_SOURCE = "vultr";
484
+ /** The terms of the Vultr source. A reading serves one request. */
485
+ export declare const VULTR_TERMS: SourceTerms;
486
+ /**
487
+ * The record of the Vultr plan list (`GET /v2/plans` of the API v2). The API gave the list with no key on
488
+ * 2026-11-18. Each plan lists its regions, and the object `location_cost` has the prices that change with the region.
489
+ * A plan has the on-demand term when `deploy_ondemand` is true, and the preemptible term when `deploy_preemptible` is true.
490
+ */
491
+ export declare const VULTR_PLANS: PlanProvider;
492
+ /** The name of the Linode source of Akamai Cloud. */
493
+ export declare const LINODE_SOURCE = "linode";
494
+ /** The terms of the Linode source. A reading serves one request. */
495
+ export declare const LINODE_TERMS: SourceTerms;
496
+ /**
497
+ * The record of the Linode plan list of Akamai Cloud (`GET /v4/linode/types` of the API v4). The API reference
498
+ * tells that the read needs no permissions. The list of `GET /v4/regions/availability` tells the regions of each
499
+ * plan. The list `region_prices` has the prices that change with the region.
500
+ */
501
+ export declare const LINODE_PLANS: PlanProvider;
502
+ /** The record of each provider with a plan list, in the order of the names. */
503
+ export declare const PLAN_PROVIDERS: readonly PlanProvider[];
504
+ /** The most pages of one list in one read. */
505
+ export declare const PLAN_PAGE_LIMIT = 20;
506
+ /** The options of a plan client. The plan lists of the records of this package need no key. */
507
+ interface PlanClientOptions<S extends Signal> {
508
+ readonly transport: Transport<S>;
509
+ readonly pace: Pace<S>;
510
+ }
511
+ /** The options of one read of a provider. */
512
+ interface PlanReadOptions {
513
+ /** The most pages of each list, from 1 to `PLAN_PAGE_LIMIT`. The default is `PLAN_PAGE_LIMIT`. */
514
+ readonly pages?: number | undefined;
515
+ }
516
+ /** A client of the plan lists of providers. */
517
+ interface PlanClient<S extends Signal> {
518
+ /** This method reads each page of the lists of a provider, and gives the result of `parsePlanLists`. */
519
+ plans(provider: PlanProvider, options?: PlanReadOptions, signal?: S): Promise<MeteredParseResult>;
520
+ }
521
+ /**
522
+ * This function makes a client of the plan lists of providers. Each address comes from the provider record. An
523
+ * answer gives only the number or the cursor of the next page. A read refuses a list with more pages than the limit,
524
+ * because a part of a list gives wrong regions.
525
+ */
526
+ export declare function createPlanClient<S extends Signal>(options: PlanClientOptions<S>): PlanClient<S>;
527
+ /** The terms of each source of this package: the sellers in the order of the hand crawl, then Azure, then the plan lists. */
241
528
  export declare const SOURCE_TERMS: readonly SourceTerms[];
242
- export { ApiError, type ApiScheduler, type BestBuyClient, type BestBuyClientOptions, type DigiKeyClient, type DigiKeyClientOptions, type DigiKeyLocale, type EbayClient, type EbayClientOptions, type Exchange, type Observation, type Pace, type ParseResult, type Reply, type Signal, type Transport };
529
+ export { ApiError, type ApiScheduler, type AzureClient, type AzureClientOptions, type AzureFilter, type AzureFilterField, type AzureReadOptions, type AzureUnit, type BestBuyClient, type BestBuyClientOptions, type DigiKeyClient, type DigiKeyClientOptions, type DigiKeyLocale, type EbayClient, type EbayClientOptions, type Exchange, type MeteredObservation, type MeteredParseResult, type Observation, type Pace, type ParseResult, type PlanAnswers, type PlanClient, type PlanClientOptions, type PlanListRead, type PlanPaging, type PlanProvider, type PlanProviderRead, type PlanReadOptions, type PlanRegionPrices, type PlanRegions, type PlanSpec, type PlanTerm, type Reply, type Signal, type Transport };
243
530
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"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"],"mappings":";;;;;;;;;;;;;;;;KAoBY;WACG;WAAmB,uBAAuB;WAAwB;;WAClE;WAAoB;;;qBCOtB;;;;;qBAMA,gBAAgB;;;;;wBAeb,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C,QAAQ,aAAa,SAAS,IAAI,QAAQ;;EAE1C,OAAO,eAAe,mBAAmB,SAAS,IAAI,QAAQ;;EAE9D,QAAQ,aAAa,SAAS,IAAI,QAAQ;;;;;;;;wBAoB5B,oBAAoB,UAAU,QAAQ,SAAS,qBAAqB,KAAK,cAAc;;qBCI1F,uBAAuB"}
1
+ {"version":3,"file":"index.d.ts","names":[],"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/plans.ts","../src/providers.ts","../src/plans-client.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;KA2BY;WACG;WAAmB,uBAAuB;WAAwB;;WAClE;WAAoB;;;KAGvB,UAAU,QAAQ;WAAwB;;;;;;;KAO1C;WAEG;WACA,uBAAuB;WACvB;WACA;IAEX;;qBCrBS;;qBAGA;;;;;;qBAOA,aAAa;;qBAUb;;qBAGA;;qBAGA;;KAiBD,2BAA2B;;KAG3B,0BAA0B,SAAS;;UAG9B;WACN;WACA;;;;;;;;;;wBAcK,eAAe,QAAQ,aAAa;;wBAwCpC,iBAAiB;;wBAKjB,cAAc;;;;;;wBAwCd,UAAU,wBAAwB;;;;;;;wBAsRlC,uBAAuB,iBAAiB,aAAa;;;;;;;;wBAWrD,2BAA2B,6BAA6B,aAAa;;qBCnbxE;;;;;qBAMA,gBAAgB;;;;;wBAeb,iBAAiB,oBAAoB,oBAAoB;;;;;;;wBA0GzD,oBAAoB,iBAAiB,aAAa;;;;;;;wBAclD,qBAAqB,iBAAiB,aAAa;;;;;;;;wBAyFnD,oBAAoB,iBAAiB,aAAa;;qBC7OrD;;qBAGA;;;;;qBAMA,eAAe;;;;;;;;wBAsIZ,2BAA2B,iBAAiB,aAAa;;;;;;;;wBAiBzD,0BAA0B,iBAAiB,aAAa;;qBCnJ3D;;;;;qBAMA,YAAY;;;;;wBA+BT,cAA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