@leaflow/sdk 0.47.0 → 0.49.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.
@@ -30,6 +30,10 @@ export type StartTopUpResult = operations["start-top-up"]["responses"][200]["con
30
30
  export type StartTopUpBody = NonNullable<operations["start-top-up"]["requestBody"]>["content"]["application/json"];
31
31
  /** `GET /account/v1/billing-accounts/{accountKey}/charges` 成功时的响应体。 */
32
32
  export type ListChargesResult = operations["list-charges"]["responses"][200]["content"]["application/json"];
33
+ /** `GET /account/v1/billing-accounts/{accountKey}/charges` 的查询参数。 */
34
+ export type ListChargesQuery = operations["list-charges"]["parameters"]["query"];
35
+ /** `GET /account/v1/billing-accounts/{accountKey}/charges/{chargeId}/usage` 成功时的响应体。 */
36
+ export type GetChargeUsageResult = operations["get-charge-usage"]["responses"][200]["content"]["application/json"];
33
37
  /** `GET /account/v1/billing-accounts/{accountKey}/invoices` 成功时的响应体。 */
34
38
  export type ListInvoicesResult = operations["list-invoices"]["responses"][200]["content"]["application/json"];
35
39
  /** `GET /account/v1/billing-accounts/{accountKey}/invoices/{invoiceId}` 成功时的响应体。 */
@@ -282,6 +282,63 @@ export interface paths {
282
282
  patch?: never;
283
283
  trace?: never;
284
284
  };
285
+ "/account/v1/billing-accounts/{accountKey}/charges/{chargeId}/usage": {
286
+ parameters: {
287
+ query?: never;
288
+ header?: never;
289
+ path?: never;
290
+ cookie?: never;
291
+ };
292
+ /**
293
+ * What produced this charge
294
+ * @description Splits one charge back into the projects that produced it, and lists the resources it could
295
+ * have come from.
296
+ *
297
+ * ## Why this is not a field on the charge
298
+ *
299
+ * A charge has no project, and that is not an omission: the billing subject is the **account**,
300
+ * and the project is a dimension on each usage event. When three of an account's projects use
301
+ * the same product, their usage aggregates into one charge — that charge genuinely spans three
302
+ * projects, and stamping any single project id on it would be wrong.
303
+ *
304
+ * A split is also more useful than a label would be: it gives proportions, and proportions are
305
+ * what decide which project's resources to switch off.
306
+ *
307
+ * ## The quantity here is what was reported, not what was billed
308
+ *
309
+ * Conversion (machine-seconds to machine-hours) happens on the pricing side, and the engine
310
+ * does not echo `unit_config` back on a charge. So this figure times the unit price does not
311
+ * equal the total — a step is missing in between, and that step only becomes visible on the
312
+ * invoice, where the whole pricing configuration is frozen onto each line.
313
+ *
314
+ * Reported quantity is still the right number for "which project is burning this", which is
315
+ * what the split is for.
316
+ *
317
+ * ## The resource list says which, not how much
318
+ *
319
+ * Usage events carry no resource id — it is not a grouping dimension, and making it one would
320
+ * mean one time series per machine per hour. So the engine cannot attribute a charge to a
321
+ * machine. What it can be attributed to is a product, and which resources of that product
322
+ * exist is something billing knows from its own records.
323
+ *
324
+ * Destroyed resources are listed too: this period's charge includes the part they ran for.
325
+ * Leaving them out is what makes the numbers fail to add up for someone who deleted a machine
326
+ * mid-month — which is exactly the case they are trying to explain.
327
+ *
328
+ * ## A flat fee answers with an empty split
329
+ *
330
+ * There is no meter behind it, so there is nothing to attribute. That is an answer, not an
331
+ * error.
332
+ */
333
+ get: operations["get-charge-usage"];
334
+ put?: never;
335
+ post?: never;
336
+ delete?: never;
337
+ options?: never;
338
+ head?: never;
339
+ patch?: never;
340
+ trace?: never;
341
+ };
285
342
  "/account/v1/billing-accounts/{accountKey}/invoices": {
286
343
  parameters: {
287
344
  query?: never;
@@ -1413,11 +1470,69 @@ export interface components {
1413
1470
  discounts?: string;
1414
1471
  /** @description Free text from the charge, usually empty. Set on charges raised by hand. */
1415
1472
  description?: string;
1473
+ /**
1474
+ * @description What one unit costs, as a decimal string. Absent when the line has no single unit price
1475
+ * — a flat fee, or a tiered price whose rate changes with volume.
1476
+ *
1477
+ * The conversion between reported and billed quantity is deliberately not here: the engine
1478
+ * does not echo it back on a charge, only on an invoice line. So a charge answers "what
1479
+ * does a unit cost", and an invoice answers "how the total was reached".
1480
+ */
1481
+ unit_price?: string;
1482
+ };
1483
+ /** @description What produced one charge */
1484
+ ChargeUsage: {
1485
+ charge_id: string;
1486
+ /**
1487
+ * @description Total reported quantity for the period, as a decimal string. Empty on a charge with no
1488
+ * meter behind it.
1489
+ *
1490
+ * Reported, not billed: see the route's description.
1491
+ */
1492
+ quantity: string;
1493
+ /**
1494
+ * @description The same quantity split by project. Empty when the charge has no meter behind it — a
1495
+ * flat fee has nothing to attribute.
1496
+ */
1497
+ by_project: components["schemas"]["ProjectUsage"][];
1498
+ /**
1499
+ * @description Resources of this product in the account's projects — candidates for what produced the
1500
+ * charge, not a per-resource breakdown. Absent when billing could not look them up; the
1501
+ * charge itself is still answered.
1502
+ */
1503
+ resources?: components["schemas"]["ChargeResource"][];
1504
+ };
1505
+ ProjectUsage: {
1506
+ project_id: string;
1507
+ /** @description Decimal string. */
1508
+ quantity: string;
1509
+ };
1510
+ ChargeResource: {
1511
+ project_id: string;
1512
+ /** @description Which service holds it, and therefore which console manages it. */
1513
+ service: string;
1514
+ product_id: string;
1515
+ resource_id: string;
1516
+ /** @enum {string} */
1517
+ state: "pending" | "active" | "suspended" | "terminated";
1416
1518
  };
1417
1519
  ChargeList: {
1418
1520
  currency: components["schemas"]["Currency"];
1419
1521
  charges: components["schemas"]["Charge"][];
1420
- /** @description The sum, which is the same number as `unsettled` on the balance */
1522
+ /**
1523
+ * Format: int64
1524
+ * @description How many charges there are in total, across every page.
1525
+ *
1526
+ * Without it, "is there another page" has to be guessed from whether this one came back
1527
+ * full — and that guess turns into one extra fetch of an empty page whenever the last page
1528
+ * happens to be exactly full.
1529
+ */
1530
+ total_count?: number;
1531
+ /**
1532
+ * @description The sum over the **whole period**, not this page — it is the same number as `unsettled`
1533
+ * on the balance, and paging must not change it. A page-scoped sum would disagree with the
1534
+ * balance card sitting next to it, and there would be no way to tell which one to believe.
1535
+ */
1421
1536
  total: string;
1422
1537
  };
1423
1538
  /** @enum {string} */
@@ -1452,6 +1567,33 @@ export interface components {
1452
1567
  /** @description Before discounts and credit */
1453
1568
  amount: string;
1454
1569
  discounts_total?: string;
1570
+ /**
1571
+ * @description The billed quantity for this line, as a decimal string — after conversion. A machine
1572
+ * billed by the hour reports machine-seconds; this is machine-hours.
1573
+ *
1574
+ * It comes from the line's detailed segments summed together: the engine splits a line
1575
+ * into segments (different cost categories, different sub-periods) and the quantity lives
1576
+ * on those.
1577
+ */
1578
+ quantity?: string;
1579
+ /**
1580
+ * @description What one unit cost, as a decimal string, frozen at billing time. Absent on a flat fee,
1581
+ * whose amount is the amount, and on tiered prices, whose rate changes with volume.
1582
+ */
1583
+ unit_price?: string;
1584
+ /**
1585
+ * @description How reported quantity became billed quantity — 3600 for a machine billed by the hour
1586
+ * from machine-seconds, 1000000 for a price per million tokens.
1587
+ *
1588
+ * Without it, `quantity` disagrees with what the customer remembers doing, by whole orders
1589
+ * of magnitude, and there is nothing on the page that explains the gap.
1590
+ */
1591
+ conversion_factor?: string;
1592
+ /**
1593
+ * @description What was done with the factor.
1594
+ * @enum {string}
1595
+ */
1596
+ conversion_operation?: "divide" | "multiply";
1455
1597
  /** @description How much of this line credit covered */
1456
1598
  credits_total?: string;
1457
1599
  total: string;
@@ -1953,7 +2095,18 @@ export interface operations {
1953
2095
  };
1954
2096
  "list-charges": {
1955
2097
  parameters: {
1956
- query?: never;
2098
+ query?: {
2099
+ /** @description 1-based page number; the first page when omitted. */
2100
+ page?: number;
2101
+ /**
2102
+ * @description How many charges per page. Defaults to a full page.
2103
+ *
2104
+ * Charge count grows with resource count — an account running dozens of machines produces
2105
+ * hundreds of lines in a period, and a screen shows a dozen. Fetching all of them on every
2106
+ * visit carries data nothing displays.
2107
+ */
2108
+ page_size?: number;
2109
+ };
1957
2110
  header?: never;
1958
2111
  path: {
1959
2112
  /**
@@ -1986,6 +2139,43 @@ export interface operations {
1986
2139
  };
1987
2140
  };
1988
2141
  };
2142
+ "get-charge-usage": {
2143
+ parameters: {
2144
+ query?: never;
2145
+ header?: never;
2146
+ path: {
2147
+ /**
2148
+ * @description The account's key, of the form `u_<user_id>_<seq>`. Ownership is stated by the key itself,
2149
+ * which is why the key is what addresses the account.
2150
+ */
2151
+ accountKey: components["parameters"]["AccountKey"];
2152
+ /** @description Which charge, from the charges list */
2153
+ chargeId: string;
2154
+ };
2155
+ cookie?: never;
2156
+ };
2157
+ requestBody?: never;
2158
+ responses: {
2159
+ /** @description OK */
2160
+ 200: {
2161
+ headers: {
2162
+ [name: string]: unknown;
2163
+ };
2164
+ content: {
2165
+ "application/json": components["schemas"]["ChargeUsage"];
2166
+ };
2167
+ };
2168
+ /** @description Error */
2169
+ default: {
2170
+ headers: {
2171
+ [name: string]: unknown;
2172
+ };
2173
+ content: {
2174
+ "application/json": components["schemas"]["Error"];
2175
+ };
2176
+ };
2177
+ };
2178
+ };
1989
2179
  "list-invoices": {
1990
2180
  parameters: {
1991
2181
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.47.0",
3
+ "version": "0.49.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {