@leaflow/sdk 0.40.0 → 0.41.0
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.
|
@@ -34,6 +34,10 @@ export type ListChargesResult = operations["list-charges"]["responses"][200]["co
|
|
|
34
34
|
export type ListInvoicesResult = operations["list-invoices"]["responses"][200]["content"]["application/json"];
|
|
35
35
|
/** `GET /account/v1/billing-accounts/{accountKey}/invoices/{invoiceId}` 成功时的响应体。 */
|
|
36
36
|
export type GetInvoiceResult = operations["get-invoice"]["responses"][200]["content"]["application/json"];
|
|
37
|
+
/** `POST /account/v1/billing-accounts/{accountKey}/quote` 成功时的响应体。 */
|
|
38
|
+
export type QuoteUsageResult = operations["quote-usage"]["responses"][200]["content"]["application/json"];
|
|
39
|
+
/** `POST /account/v1/billing-accounts/{accountKey}/quote` 的请求体。 */
|
|
40
|
+
export type QuoteUsageBody = NonNullable<operations["quote-usage"]["requestBody"]>["content"]["application/json"];
|
|
37
41
|
/** `GET /account/v1/billing-accounts/{accountKey}/subscription` 成功时的响应体。 */
|
|
38
42
|
export type ReadSubscriptionResult = operations["read-subscription"]["responses"][200]["content"]["application/json"];
|
|
39
43
|
/** `POST /account/v1/billing-accounts/{accountKey}/subscription/cancel` 成功时的响应体。 */
|
|
@@ -326,6 +326,47 @@ export interface paths {
|
|
|
326
326
|
patch?: never;
|
|
327
327
|
trace?: never;
|
|
328
328
|
};
|
|
329
|
+
"/account/v1/billing-accounts/{accountKey}/quote": {
|
|
330
|
+
parameters: {
|
|
331
|
+
query?: never;
|
|
332
|
+
header?: never;
|
|
333
|
+
path?: never;
|
|
334
|
+
cookie?: never;
|
|
335
|
+
};
|
|
336
|
+
get?: never;
|
|
337
|
+
put?: never;
|
|
338
|
+
/**
|
|
339
|
+
* What a usage would cost on this account's plan
|
|
340
|
+
* @description Prices a set of usages against whatever plan this account is currently on, and returns **every
|
|
341
|
+
* intermediate step** rather than a single number.
|
|
342
|
+
*
|
|
343
|
+
* # What it is for
|
|
344
|
+
*
|
|
345
|
+
* Showing someone what a machine will cost before they create it. The console asks for the usage a
|
|
346
|
+
* machine of that shape produces in an hour, and gets back what that hour costs them — on their
|
|
347
|
+
* plan, with their discounts.
|
|
348
|
+
*
|
|
349
|
+
* # Quantities are raw
|
|
350
|
+
*
|
|
351
|
+
* Seconds, token counts, GiB-seconds: the amount a service reports. Conversion happens here, which
|
|
352
|
+
* is why services keep no conversion tables of their own and why the console must not do the
|
|
353
|
+
* arithmetic itself.
|
|
354
|
+
*
|
|
355
|
+
* # It is an estimate
|
|
356
|
+
*
|
|
357
|
+
* The engine computes the real amount; this reproduces the same rules. Every step comes back for
|
|
358
|
+
* that reason — a single number that disagrees with the bill says nothing about which step was
|
|
359
|
+
* wrong.
|
|
360
|
+
*
|
|
361
|
+
* `404` means this account is not on any plan, and there is therefore nothing to price against.
|
|
362
|
+
*/
|
|
363
|
+
post: operations["quote-usage"];
|
|
364
|
+
delete?: never;
|
|
365
|
+
options?: never;
|
|
366
|
+
head?: never;
|
|
367
|
+
patch?: never;
|
|
368
|
+
trace?: never;
|
|
369
|
+
};
|
|
329
370
|
"/account/v1/billing-accounts/{accountKey}/subscription": {
|
|
330
371
|
parameters: {
|
|
331
372
|
query?: never;
|
|
@@ -592,6 +633,95 @@ export interface paths {
|
|
|
592
633
|
export type webhooks = Record<string, never>;
|
|
593
634
|
export interface components {
|
|
594
635
|
schemas: {
|
|
636
|
+
/**
|
|
637
|
+
* @description The usages to price. Quantities are the **raw amounts a service reports** — seconds, token
|
|
638
|
+
* counts, GiB-seconds. Conversion happens on the billing side, which is why services keep no
|
|
639
|
+
* conversion tables of their own.
|
|
640
|
+
*/
|
|
641
|
+
QuoteRequest: {
|
|
642
|
+
lines: components["schemas"]["QuoteUsage"][];
|
|
643
|
+
};
|
|
644
|
+
/**
|
|
645
|
+
* @description One usage to price. Name the thing **either** by its rate card key **or** by the service and
|
|
646
|
+
* product it belongs to — exactly one of the two.
|
|
647
|
+
*
|
|
648
|
+
* # Why the second form exists
|
|
649
|
+
*
|
|
650
|
+
* A meter's key is a hash of `(service, product_id, variant)`, computed by a function that lives in
|
|
651
|
+
* one place on purpose: get it wrong and usage lands in the wrong bucket, or in none, and nothing
|
|
652
|
+
* reports it. A caller that derived the key itself would be a second copy of that convention.
|
|
653
|
+
*
|
|
654
|
+
* So callers that know what they are buying — a machine of a given type, a model's input tokens —
|
|
655
|
+
* give the service and product, and this side derives the key.
|
|
656
|
+
*/
|
|
657
|
+
QuoteUsage: {
|
|
658
|
+
/**
|
|
659
|
+
* @description The rate card's key. For a card tied to a meter that is the meter's key, because the engine
|
|
660
|
+
* requires the two to be identical.
|
|
661
|
+
*
|
|
662
|
+
* Leave it out when giving `service` and `product_id` instead
|
|
663
|
+
*/
|
|
664
|
+
key?: string;
|
|
665
|
+
/** @description The service that owns the product, as it appears in its usage events */
|
|
666
|
+
service?: string;
|
|
667
|
+
/** @description That service's own catalogue id for the thing being bought */
|
|
668
|
+
product_id?: string;
|
|
669
|
+
/**
|
|
670
|
+
* @description The fixed dimension values that split one product into several meters — canopy's token kind,
|
|
671
|
+
* for instance. Part of the key, so leaving it out names a different meter
|
|
672
|
+
*/
|
|
673
|
+
variant?: {
|
|
674
|
+
[key: string]: string;
|
|
675
|
+
};
|
|
676
|
+
/** @description The raw amount, before any conversion. A decimal string */
|
|
677
|
+
quantity: string;
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* @description One rate card priced, with every intermediate step.
|
|
681
|
+
*
|
|
682
|
+
* Each step is here on purpose: a single total that disagrees with the bill says nothing about
|
|
683
|
+
* which step went wrong, and this is a second implementation of the engine's rules
|
|
684
|
+
*/
|
|
685
|
+
QuoteLine: {
|
|
686
|
+
key: string;
|
|
687
|
+
name: string;
|
|
688
|
+
/** @description False for a flat fee, which ignores usage entirely */
|
|
689
|
+
metered: boolean;
|
|
690
|
+
/** @description The quantity as given */
|
|
691
|
+
raw: string;
|
|
692
|
+
/** @description After unit conversion, before rounding */
|
|
693
|
+
converted: string;
|
|
694
|
+
/**
|
|
695
|
+
* @description After rounding. `unit_config.rounding` applies to this step only — entitlement uses the
|
|
696
|
+
* exact converted value, which is the engine's documented behaviour
|
|
697
|
+
*/
|
|
698
|
+
billable: string;
|
|
699
|
+
/** @description Units covered by the usage discount */
|
|
700
|
+
free_units: string;
|
|
701
|
+
charged: string;
|
|
702
|
+
unit_price: string;
|
|
703
|
+
/** @description Before the percentage discount */
|
|
704
|
+
gross: string;
|
|
705
|
+
discount: string;
|
|
706
|
+
/**
|
|
707
|
+
* @description Rounded to the currency's minor unit, **per line**. Not by rounding the sum: the engine
|
|
708
|
+
* rounds each line, and the difference grows with the number of lines
|
|
709
|
+
*/
|
|
710
|
+
total: string;
|
|
711
|
+
};
|
|
712
|
+
Quote: {
|
|
713
|
+
lines: components["schemas"]["QuoteLine"][];
|
|
714
|
+
/** @description The sum of the already-rounded lines */
|
|
715
|
+
total: string;
|
|
716
|
+
/**
|
|
717
|
+
* @description Keys that were given a usage but have no rate card on this plan.
|
|
718
|
+
*
|
|
719
|
+
* **Reported rather than ignored**, because ignoring them yields a smaller but entirely
|
|
720
|
+
* normal-looking number — and that is the most expensive misconfiguration there is: usage
|
|
721
|
+
* lands, the usage chart shows it, and the bill has no line for it
|
|
722
|
+
*/
|
|
723
|
+
unpriced?: string[];
|
|
724
|
+
};
|
|
595
725
|
/**
|
|
596
726
|
* @description When a plan change takes effect. There is no default: an upgrade and a downgrade want opposite
|
|
597
727
|
* answers, and the difference is money
|
|
@@ -1580,6 +1710,45 @@ export interface operations {
|
|
|
1580
1710
|
};
|
|
1581
1711
|
};
|
|
1582
1712
|
};
|
|
1713
|
+
"quote-usage": {
|
|
1714
|
+
parameters: {
|
|
1715
|
+
query?: never;
|
|
1716
|
+
header?: never;
|
|
1717
|
+
path: {
|
|
1718
|
+
/**
|
|
1719
|
+
* @description The account's key, of the form `u_<user_id>_<seq>`. Ownership is stated by the key itself,
|
|
1720
|
+
* which is why the key is what addresses the account.
|
|
1721
|
+
*/
|
|
1722
|
+
accountKey: components["parameters"]["AccountKey"];
|
|
1723
|
+
};
|
|
1724
|
+
cookie?: never;
|
|
1725
|
+
};
|
|
1726
|
+
requestBody: {
|
|
1727
|
+
content: {
|
|
1728
|
+
"application/json": components["schemas"]["QuoteRequest"];
|
|
1729
|
+
};
|
|
1730
|
+
};
|
|
1731
|
+
responses: {
|
|
1732
|
+
/** @description OK */
|
|
1733
|
+
200: {
|
|
1734
|
+
headers: {
|
|
1735
|
+
[name: string]: unknown;
|
|
1736
|
+
};
|
|
1737
|
+
content: {
|
|
1738
|
+
"application/json": components["schemas"]["Quote"];
|
|
1739
|
+
};
|
|
1740
|
+
};
|
|
1741
|
+
/** @description Error */
|
|
1742
|
+
default: {
|
|
1743
|
+
headers: {
|
|
1744
|
+
[name: string]: unknown;
|
|
1745
|
+
};
|
|
1746
|
+
content: {
|
|
1747
|
+
"application/json": components["schemas"]["Error"];
|
|
1748
|
+
};
|
|
1749
|
+
};
|
|
1750
|
+
};
|
|
1751
|
+
};
|
|
1583
1752
|
"read-subscription": {
|
|
1584
1753
|
parameters: {
|
|
1585
1754
|
query?: never;
|