@leaflow/sdk 0.46.0 → 0.48.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,10 +30,14 @@ 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/{chargeId}/usage` 成功时的响应体。 */
34
+ export type GetChargeUsageResult = operations["get-charge-usage"]["responses"][200]["content"]["application/json"];
33
35
  /** `GET /account/v1/billing-accounts/{accountKey}/invoices` 成功时的响应体。 */
34
36
  export type ListInvoicesResult = operations["list-invoices"]["responses"][200]["content"]["application/json"];
35
37
  /** `GET /account/v1/billing-accounts/{accountKey}/invoices/{invoiceId}` 成功时的响应体。 */
36
38
  export type GetInvoiceResult = operations["get-invoice"]["responses"][200]["content"]["application/json"];
39
+ /** `GET /account/v1/projects/{projectId}/billing-account` 成功时的响应体。 */
40
+ export type ReadProjectBillingAccountResult = operations["read-project-billing-account"]["responses"][200]["content"]["application/json"];
37
41
  /** `POST /account/v1/projects/{projectId}/quote` 成功时的响应体。 */
38
42
  export type QuoteProjectUsageResult = operations["quote-project-usage"]["responses"][200]["content"]["application/json"];
39
43
  /** `POST /account/v1/projects/{projectId}/quote` 的请求体。 */
@@ -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;
@@ -326,6 +383,49 @@ export interface paths {
326
383
  patch?: never;
327
384
  trace?: never;
328
385
  };
386
+ "/account/v1/projects/{projectId}/billing-account": {
387
+ parameters: {
388
+ query?: never;
389
+ header?: never;
390
+ path?: never;
391
+ cookie?: never;
392
+ };
393
+ /**
394
+ * Which account pays for this project
395
+ * @description The account a project's resources are charged to, resolved from the project rather than
396
+ * guessed.
397
+ *
398
+ * ## Why a console needs this
399
+ *
400
+ * Everything in a console happens inside a project, while billing accounts belong to a person —
401
+ * and a person can have many. Showing "the first one" next to a sentence like *you are
402
+ * overdrawn, new resources will be refused* pairs one account's balance with another account's
403
+ * rule. Both directions are wrong and one of them is silent: the figures look healthy while
404
+ * creating anything is refused, and the refusal names a reason the page just contradicted.
405
+ *
406
+ * ## Being a member is enough to ask, but not to see the money
407
+ *
408
+ * The answer is the account's identity, not its balance. A project's members are not
409
+ * necessarily the people paying for it — a company account can pay for a project someone else
410
+ * works in — and their balance is not those members' business. Whoever owns the account reads
411
+ * the figures from the balance route as before; `owned_by_me` says which case this is, so a
412
+ * page can tell "you are overdrawn" apart from "ask whoever pays for this project".
413
+ *
414
+ * ## A project with no account is a normal state, and it answers 404
415
+ *
416
+ * A project nobody has bound yet cannot create resources at all — admission refuses it. That is
417
+ * worth saying plainly ("this project has no billing account, bind one") rather than falling
418
+ * back to some other account of theirs, which is how the wrong-account problem started.
419
+ */
420
+ get: operations["read-project-billing-account"];
421
+ put?: never;
422
+ post?: never;
423
+ delete?: never;
424
+ options?: never;
425
+ head?: never;
426
+ patch?: never;
427
+ trace?: never;
428
+ };
329
429
  "/account/v1/projects/{projectId}/quote": {
330
430
  parameters: {
331
431
  query?: never;
@@ -1231,6 +1331,19 @@ export interface components {
1231
1331
  */
1232
1332
  available: string;
1233
1333
  };
1334
+ /** @description The account a project's resources are charged to */
1335
+ ProjectBillingAccount: {
1336
+ account_key: string;
1337
+ project_id: string;
1338
+ display_name: string;
1339
+ currency: components["schemas"]["Currency"];
1340
+ /**
1341
+ * @description Whether the caller owns this account, and therefore whether the balance routes will
1342
+ * answer for it. False means someone else pays for this project: the figures are theirs,
1343
+ * not the caller's, and a page should say so rather than showing nothing.
1344
+ */
1345
+ owned_by_me: boolean;
1346
+ };
1234
1347
  /** @description Which account pays for which project, as it stands once the request has been applied */
1235
1348
  ProjectBinding: {
1236
1349
  account_key: string;
@@ -1315,6 +1428,93 @@ export interface components {
1315
1428
  * just started as zero
1316
1429
  */
1317
1430
  total: string;
1431
+ /**
1432
+ * @description Which meter it is for, when the charge came from usage. A hash, not something to show —
1433
+ * it is here so two rows can be told apart programmatically and so support can line a row
1434
+ * up with the catalogue.
1435
+ */
1436
+ feature_key?: string;
1437
+ /**
1438
+ * @description Whether this figure moves. A usage charge climbs through the period; a flat fee does not.
1439
+ * Without it, the same number on two refreshes could mean "nobody used it" or "it never
1440
+ * moves", and those need different next steps.
1441
+ * @enum {string}
1442
+ */
1443
+ type: "usage_based" | "flat_fee";
1444
+ /**
1445
+ * Format: date-time
1446
+ * @description Start of the service period this charge covers.
1447
+ *
1448
+ * This is what tells two same-named rows apart. Something billed by the hour produces
1449
+ * hundreds of identically named charges in a month, and a list carrying only a name and an
1450
+ * amount shows them as a wall of duplicates — which is what it looks like today.
1451
+ */
1452
+ period_from: string;
1453
+ /**
1454
+ * Format: date-time
1455
+ * @description End of the service period this charge covers.
1456
+ */
1457
+ period_to: string;
1458
+ /**
1459
+ * @description How much of this charge was covered by credit, as a decimal string.
1460
+ *
1461
+ * It is the answer to "I have a balance, why am I still being charged". Without it the
1462
+ * customer sees a number that disagrees with what they expected and the only thing that
1463
+ * explains it is on our side.
1464
+ */
1465
+ credits?: string;
1466
+ /**
1467
+ * @description How much was taken off by a discount, as a decimal string. A usage allowance (the first N
1468
+ * units free) lands here too.
1469
+ */
1470
+ discounts?: string;
1471
+ /** @description Free text from the charge, usually empty. Set on charges raised by hand. */
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";
1318
1518
  };
1319
1519
  ChargeList: {
1320
1520
  currency: components["schemas"]["Currency"];
@@ -1354,6 +1554,33 @@ export interface components {
1354
1554
  /** @description Before discounts and credit */
1355
1555
  amount: string;
1356
1556
  discounts_total?: string;
1557
+ /**
1558
+ * @description The billed quantity for this line, as a decimal string — after conversion. A machine
1559
+ * billed by the hour reports machine-seconds; this is machine-hours.
1560
+ *
1561
+ * It comes from the line's detailed segments summed together: the engine splits a line
1562
+ * into segments (different cost categories, different sub-periods) and the quantity lives
1563
+ * on those.
1564
+ */
1565
+ quantity?: string;
1566
+ /**
1567
+ * @description What one unit cost, as a decimal string, frozen at billing time. Absent on a flat fee,
1568
+ * whose amount is the amount, and on tiered prices, whose rate changes with volume.
1569
+ */
1570
+ unit_price?: string;
1571
+ /**
1572
+ * @description How reported quantity became billed quantity — 3600 for a machine billed by the hour
1573
+ * from machine-seconds, 1000000 for a price per million tokens.
1574
+ *
1575
+ * Without it, `quantity` disagrees with what the customer remembers doing, by whole orders
1576
+ * of magnitude, and there is nothing on the page that explains the gap.
1577
+ */
1578
+ conversion_factor?: string;
1579
+ /**
1580
+ * @description What was done with the factor.
1581
+ * @enum {string}
1582
+ */
1583
+ conversion_operation?: "divide" | "multiply";
1357
1584
  /** @description How much of this line credit covered */
1358
1585
  credits_total?: string;
1359
1586
  total: string;
@@ -1888,6 +2115,43 @@ export interface operations {
1888
2115
  };
1889
2116
  };
1890
2117
  };
2118
+ "get-charge-usage": {
2119
+ parameters: {
2120
+ query?: never;
2121
+ header?: never;
2122
+ path: {
2123
+ /**
2124
+ * @description The account's key, of the form `u_<user_id>_<seq>`. Ownership is stated by the key itself,
2125
+ * which is why the key is what addresses the account.
2126
+ */
2127
+ accountKey: components["parameters"]["AccountKey"];
2128
+ /** @description Which charge, from the charges list */
2129
+ chargeId: string;
2130
+ };
2131
+ cookie?: never;
2132
+ };
2133
+ requestBody?: never;
2134
+ responses: {
2135
+ /** @description OK */
2136
+ 200: {
2137
+ headers: {
2138
+ [name: string]: unknown;
2139
+ };
2140
+ content: {
2141
+ "application/json": components["schemas"]["ChargeUsage"];
2142
+ };
2143
+ };
2144
+ /** @description Error */
2145
+ default: {
2146
+ headers: {
2147
+ [name: string]: unknown;
2148
+ };
2149
+ content: {
2150
+ "application/json": components["schemas"]["Error"];
2151
+ };
2152
+ };
2153
+ };
2154
+ };
1891
2155
  "list-invoices": {
1892
2156
  parameters: {
1893
2157
  query?: never;
@@ -1959,6 +2223,38 @@ export interface operations {
1959
2223
  };
1960
2224
  };
1961
2225
  };
2226
+ "read-project-billing-account": {
2227
+ parameters: {
2228
+ query?: never;
2229
+ header?: never;
2230
+ path: {
2231
+ /** @description The project being worked in */
2232
+ projectId: string;
2233
+ };
2234
+ cookie?: never;
2235
+ };
2236
+ requestBody?: never;
2237
+ responses: {
2238
+ /** @description OK */
2239
+ 200: {
2240
+ headers: {
2241
+ [name: string]: unknown;
2242
+ };
2243
+ content: {
2244
+ "application/json": components["schemas"]["ProjectBillingAccount"];
2245
+ };
2246
+ };
2247
+ /** @description Error */
2248
+ default: {
2249
+ headers: {
2250
+ [name: string]: unknown;
2251
+ };
2252
+ content: {
2253
+ "application/json": components["schemas"]["Error"];
2254
+ };
2255
+ };
2256
+ };
2257
+ };
1962
2258
  "quote-project-usage": {
1963
2259
  parameters: {
1964
2260
  query?: never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.46.0",
3
+ "version": "0.48.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {