@leaflow/sdk 0.40.0 → 0.42.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,14 @@ 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/projects/{projectId}/quote` 成功时的响应体。 */
38
+ export type QuoteProjectUsageResult = operations["quote-project-usage"]["responses"][200]["content"]["application/json"];
39
+ /** `POST /account/v1/projects/{projectId}/quote` 的请求体。 */
40
+ export type QuoteProjectUsageBody = NonNullable<operations["quote-project-usage"]["requestBody"]>["content"]["application/json"];
41
+ /** `POST /account/v1/billing-accounts/{accountKey}/quote` 成功时的响应体。 */
42
+ export type QuoteUsageResult = operations["quote-usage"]["responses"][200]["content"]["application/json"];
43
+ /** `POST /account/v1/billing-accounts/{accountKey}/quote` 的请求体。 */
44
+ export type QuoteUsageBody = NonNullable<operations["quote-usage"]["requestBody"]>["content"]["application/json"];
37
45
  /** `GET /account/v1/billing-accounts/{accountKey}/subscription` 成功时的响应体。 */
38
46
  export type ReadSubscriptionResult = operations["read-subscription"]["responses"][200]["content"]["application/json"];
39
47
  /** `POST /account/v1/billing-accounts/{accountKey}/subscription/cancel` 成功时的响应体。 */
@@ -326,6 +326,93 @@ export interface paths {
326
326
  patch?: never;
327
327
  trace?: never;
328
328
  };
329
+ "/account/v1/projects/{projectId}/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 in this project
340
+ * @description Prices a set of usages against whatever plan pays for this project, and returns **every
341
+ * intermediate step** rather than a single number.
342
+ *
343
+ * # Why by project rather than by billing account
344
+ *
345
+ * The page that needs this is the one where somebody is about to create a machine, and all it has
346
+ * is a project. Which account pays for that project is billing's own bookkeeping — asking the
347
+ * caller to resolve it first would put that mapping into a page that otherwise has no business
348
+ * knowing accounts exist.
349
+ *
350
+ * # Quantities are raw
351
+ *
352
+ * Seconds, token counts, GiB-seconds: the amount a service reports. Conversion happens here, which
353
+ * is why services keep no conversion tables of their own and why the caller must not do the
354
+ * arithmetic itself.
355
+ *
356
+ * Name each usage by `service` and `product_id` rather than by key: the key is a hash of a
357
+ * convention that has exactly one implementation on purpose.
358
+ *
359
+ * # It is an estimate
360
+ *
361
+ * The engine computes the real amount; this reproduces the same rules. Every step comes back for
362
+ * that reason — a single number that disagrees with the bill says nothing about which step was
363
+ * wrong.
364
+ *
365
+ * `404` means the project has no billing account, or its account is on no plan. Both are worth
366
+ * showing: nothing can be created in either case, because admission refuses it.
367
+ */
368
+ post: operations["quote-project-usage"];
369
+ delete?: never;
370
+ options?: never;
371
+ head?: never;
372
+ patch?: never;
373
+ trace?: never;
374
+ };
375
+ "/account/v1/billing-accounts/{accountKey}/quote": {
376
+ parameters: {
377
+ query?: never;
378
+ header?: never;
379
+ path?: never;
380
+ cookie?: never;
381
+ };
382
+ get?: never;
383
+ put?: never;
384
+ /**
385
+ * What a usage would cost on this account's plan
386
+ * @description Prices a set of usages against whatever plan this account is currently on, and returns **every
387
+ * intermediate step** rather than a single number.
388
+ *
389
+ * # What it is for
390
+ *
391
+ * Showing someone what a machine will cost before they create it. The console asks for the usage a
392
+ * machine of that shape produces in an hour, and gets back what that hour costs them — on their
393
+ * plan, with their discounts.
394
+ *
395
+ * # Quantities are raw
396
+ *
397
+ * Seconds, token counts, GiB-seconds: the amount a service reports. Conversion happens here, which
398
+ * is why services keep no conversion tables of their own and why the console must not do the
399
+ * arithmetic itself.
400
+ *
401
+ * # It is an estimate
402
+ *
403
+ * The engine computes the real amount; this reproduces the same rules. Every step comes back for
404
+ * that reason — a single number that disagrees with the bill says nothing about which step was
405
+ * wrong.
406
+ *
407
+ * `404` means this account is not on any plan, and there is therefore nothing to price against.
408
+ */
409
+ post: operations["quote-usage"];
410
+ delete?: never;
411
+ options?: never;
412
+ head?: never;
413
+ patch?: never;
414
+ trace?: never;
415
+ };
329
416
  "/account/v1/billing-accounts/{accountKey}/subscription": {
330
417
  parameters: {
331
418
  query?: never;
@@ -592,6 +679,95 @@ export interface paths {
592
679
  export type webhooks = Record<string, never>;
593
680
  export interface components {
594
681
  schemas: {
682
+ /**
683
+ * @description The usages to price. Quantities are the **raw amounts a service reports** — seconds, token
684
+ * counts, GiB-seconds. Conversion happens on the billing side, which is why services keep no
685
+ * conversion tables of their own.
686
+ */
687
+ QuoteRequest: {
688
+ lines: components["schemas"]["QuoteUsage"][];
689
+ };
690
+ /**
691
+ * @description One usage to price. Name the thing **either** by its rate card key **or** by the service and
692
+ * product it belongs to — exactly one of the two.
693
+ *
694
+ * # Why the second form exists
695
+ *
696
+ * A meter's key is a hash of `(service, product_id, variant)`, computed by a function that lives in
697
+ * one place on purpose: get it wrong and usage lands in the wrong bucket, or in none, and nothing
698
+ * reports it. A caller that derived the key itself would be a second copy of that convention.
699
+ *
700
+ * So callers that know what they are buying — a machine of a given type, a model's input tokens —
701
+ * give the service and product, and this side derives the key.
702
+ */
703
+ QuoteUsage: {
704
+ /**
705
+ * @description The rate card's key. For a card tied to a meter that is the meter's key, because the engine
706
+ * requires the two to be identical.
707
+ *
708
+ * Leave it out when giving `service` and `product_id` instead
709
+ */
710
+ key?: string;
711
+ /** @description The service that owns the product, as it appears in its usage events */
712
+ service?: string;
713
+ /** @description That service's own catalogue id for the thing being bought */
714
+ product_id?: string;
715
+ /**
716
+ * @description The fixed dimension values that split one product into several meters — canopy's token kind,
717
+ * for instance. Part of the key, so leaving it out names a different meter
718
+ */
719
+ variant?: {
720
+ [key: string]: string;
721
+ };
722
+ /** @description The raw amount, before any conversion. A decimal string */
723
+ quantity: string;
724
+ };
725
+ /**
726
+ * @description One rate card priced, with every intermediate step.
727
+ *
728
+ * Each step is here on purpose: a single total that disagrees with the bill says nothing about
729
+ * which step went wrong, and this is a second implementation of the engine's rules
730
+ */
731
+ QuoteLine: {
732
+ key: string;
733
+ name: string;
734
+ /** @description False for a flat fee, which ignores usage entirely */
735
+ metered: boolean;
736
+ /** @description The quantity as given */
737
+ raw: string;
738
+ /** @description After unit conversion, before rounding */
739
+ converted: string;
740
+ /**
741
+ * @description After rounding. `unit_config.rounding` applies to this step only — entitlement uses the
742
+ * exact converted value, which is the engine's documented behaviour
743
+ */
744
+ billable: string;
745
+ /** @description Units covered by the usage discount */
746
+ free_units: string;
747
+ charged: string;
748
+ unit_price: string;
749
+ /** @description Before the percentage discount */
750
+ gross: string;
751
+ discount: string;
752
+ /**
753
+ * @description Rounded to the currency's minor unit, **per line**. Not by rounding the sum: the engine
754
+ * rounds each line, and the difference grows with the number of lines
755
+ */
756
+ total: string;
757
+ };
758
+ Quote: {
759
+ lines: components["schemas"]["QuoteLine"][];
760
+ /** @description The sum of the already-rounded lines */
761
+ total: string;
762
+ /**
763
+ * @description Keys that were given a usage but have no rate card on this plan.
764
+ *
765
+ * **Reported rather than ignored**, because ignoring them yields a smaller but entirely
766
+ * normal-looking number — and that is the most expensive misconfiguration there is: usage
767
+ * lands, the usage chart shows it, and the bill has no line for it
768
+ */
769
+ unpriced?: string[];
770
+ };
595
771
  /**
596
772
  * @description When a plan change takes effect. There is no default: an upgrade and a downgrade want opposite
597
773
  * answers, and the difference is money
@@ -1580,6 +1756,80 @@ export interface operations {
1580
1756
  };
1581
1757
  };
1582
1758
  };
1759
+ "quote-project-usage": {
1760
+ parameters: {
1761
+ query?: never;
1762
+ header?: never;
1763
+ path: {
1764
+ projectId: string;
1765
+ };
1766
+ cookie?: never;
1767
+ };
1768
+ requestBody: {
1769
+ content: {
1770
+ "application/json": components["schemas"]["QuoteRequest"];
1771
+ };
1772
+ };
1773
+ responses: {
1774
+ /** @description OK */
1775
+ 200: {
1776
+ headers: {
1777
+ [name: string]: unknown;
1778
+ };
1779
+ content: {
1780
+ "application/json": components["schemas"]["Quote"];
1781
+ };
1782
+ };
1783
+ /** @description Error */
1784
+ default: {
1785
+ headers: {
1786
+ [name: string]: unknown;
1787
+ };
1788
+ content: {
1789
+ "application/json": components["schemas"]["Error"];
1790
+ };
1791
+ };
1792
+ };
1793
+ };
1794
+ "quote-usage": {
1795
+ parameters: {
1796
+ query?: never;
1797
+ header?: never;
1798
+ path: {
1799
+ /**
1800
+ * @description The account's key, of the form `u_<user_id>_<seq>`. Ownership is stated by the key itself,
1801
+ * which is why the key is what addresses the account.
1802
+ */
1803
+ accountKey: components["parameters"]["AccountKey"];
1804
+ };
1805
+ cookie?: never;
1806
+ };
1807
+ requestBody: {
1808
+ content: {
1809
+ "application/json": components["schemas"]["QuoteRequest"];
1810
+ };
1811
+ };
1812
+ responses: {
1813
+ /** @description OK */
1814
+ 200: {
1815
+ headers: {
1816
+ [name: string]: unknown;
1817
+ };
1818
+ content: {
1819
+ "application/json": components["schemas"]["Quote"];
1820
+ };
1821
+ };
1822
+ /** @description Error */
1823
+ default: {
1824
+ headers: {
1825
+ [name: string]: unknown;
1826
+ };
1827
+ content: {
1828
+ "application/json": components["schemas"]["Error"];
1829
+ };
1830
+ };
1831
+ };
1832
+ };
1583
1833
  "read-subscription": {
1584
1834
  parameters: {
1585
1835
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.40.0",
3
+ "version": "0.42.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {