@leaflow/sdk 0.57.0 → 0.58.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.
package/README.md CHANGED
@@ -7,7 +7,7 @@ Leaflow 平台的 TypeScript SDK(`@leaflow/sdk`),由
7
7
  npm i @leaflow/sdk openapi-fetch
8
8
  ```
9
9
 
10
- 当前只含类型。请求由 `openapi-fetch` 发出,路径与参数由契约约束。
10
+ 包含 Node.js 可用的 JavaScript 客户端和 TypeScript 类型。请求由 `openapi-fetch` 发出,路径与参数由契约约束。
11
11
 
12
12
  ```ts
13
13
  import createClient from 'openapi-fetch';
@@ -32,3 +32,15 @@ npm run generate
32
32
  ```
33
33
 
34
34
  契约版本记在 `CONTRACTS_REF`。
35
+
36
+ ## Billing
37
+
38
+ ```ts
39
+ import { client } from "@leaflow/sdk/billing/v1";
40
+
41
+ const billing = client({ baseUrl: billingBaseUrl, headers });
42
+ ```
43
+
44
+ 公共目录、账户和项目接口使用 `@leaflow/sdk`,运营管理接口使用 `@leaflow/sdk-admin`。服务间 Proto 使用独立的 `@leaflow/billing` 包。
45
+
46
+ 本地契约可通过 `CONTRACTS_DIR=/absolute/path/to/contracts npm run generate` 生成。发布时将契约提交号写入 `CONTRACTS_REF`,再使用默认生成命令。
@@ -0,0 +1,6 @@
1
+ import { type ClientOptions } from "openapi-fetch";
2
+ import type { paths } from "./schema.js";
3
+ /** A client for the billing service. Pass baseUrl to override the address. */
4
+ export declare function client(options: ClientOptions & {
5
+ baseUrl: string;
6
+ }): import("openapi-fetch").Client<paths, `${string}/${string}`>;
@@ -0,0 +1,6 @@
1
+ // Code generated from the contract's servers[0]. DO NOT EDIT.
2
+ import createClient, {} from "openapi-fetch";
3
+ /** A client for the billing service. Pass baseUrl to override the address. */
4
+ export function client(options) {
5
+ return createClient(options);
6
+ }
@@ -1,4 +1,5 @@
1
1
  export type { paths, components, operations, webhooks } from "./schema.js";
2
+ export { client } from "./client.js";
2
3
  import type { operations } from "./schema.js";
3
4
  /** The success response body of `GET /catalog/v1/products`. */
4
5
  export type ListCatalogProductsResult = operations["list-catalog-products"]["responses"][200]["content"]["application/json"];
@@ -2,4 +2,4 @@
2
2
  //
3
3
  // The aliases replace the operations[...] subscript chain with a name. The raw paths /
4
4
  // components / operations are exported as well: paths is what createClient<paths>() takes.
5
- export {};
5
+ export { client } from "./client.js";
@@ -1361,6 +1361,10 @@ export interface components {
1361
1361
  total_count?: number;
1362
1362
  };
1363
1363
  CatalogPrice: {
1364
+ /** @description External lookup alias within the service. Existing references use the price ID. */
1365
+ lookup_key?: string;
1366
+ /** Format: uuid */
1367
+ product_id?: string;
1364
1368
  /** Format: uuid */
1365
1369
  id: string;
1366
1370
  /** Format: uuid */
@@ -1395,6 +1399,17 @@ export interface components {
1395
1399
  * @description For `rated` prices, the price list the rates are read from.
1396
1400
  */
1397
1401
  rate_card_id?: string;
1402
+ /** @description The smallest quantity that can be bought. Absent means no lower bound. */
1403
+ min_quantity?: components["schemas"]["Money"];
1404
+ /**
1405
+ * @description The largest quantity that can be bought. Absent means no upper bound.
1406
+ *
1407
+ * An order beyond it is refused with its own code, apart from the codes for running
1408
+ * out of stock and for exceeding what the infrastructure allows.
1409
+ */
1410
+ max_quantity?: components["schemas"]["Money"];
1411
+ /** @description Quantities must be a multiple of this. Absent means any quantity within the bounds. */
1412
+ quantity_step?: components["schemas"]["Money"];
1398
1413
  /**
1399
1414
  * @description Quantities included when this price is bought — the traffic or requests that are
1400
1415
  * used before anything is charged for.
@@ -1414,8 +1429,7 @@ export interface components {
1414
1429
  total_count?: number;
1415
1430
  };
1416
1431
  CatalogRate: {
1417
- /** @description What is being measured. */
1418
- meter_key: string;
1432
+ meter: components["schemas"]["ObjectIdentity"];
1419
1433
  /** @description The unit readings arrive in, such as `core-second`. */
1420
1434
  unit?: string;
1421
1435
  /** @description The attributes this rate applies to, such as region and machine type. */
@@ -1444,22 +1458,12 @@ export interface components {
1444
1458
  /** Format: int64 */
1445
1459
  total_count?: number;
1446
1460
  };
1447
- /**
1448
- * @description Identify what to price either by `price_id`, or by `product_key` together with
1449
- * `service_product_id`. Supplying both, or neither, is refused.
1450
- */
1461
+ /** @description Identify a price directly, or select a price for a plan. Lookup keys are scoped to the product. Account quotes apply applicable contract prices. */
1451
1462
  QuoteLine: {
1452
- /** Format: uuid */
1453
- price_id?: string;
1454
- /** @description The service, such as `compute`. */
1455
- product_key?: string;
1456
- /** @description How the owning service identifies the item, such as a machine type. */
1457
- service_product_id?: string;
1458
- /**
1459
- * @description Required for a metered price whose price list covers more than one meter, so that
1460
- * the intended one is unambiguous.
1461
- */
1462
- meter_key?: string;
1463
+ price?: components["schemas"]["ObjectReference"];
1464
+ product?: components["schemas"]["ObjectReference"];
1465
+ plan?: components["schemas"]["ObjectReference"];
1466
+ meter?: components["schemas"]["ObjectReference"];
1463
1467
  /**
1464
1468
  * @description The attributes the price depends on — region, instance type, token class.
1465
1469
  *
@@ -1474,13 +1478,7 @@ export interface components {
1474
1478
  [key: string]: string;
1475
1479
  };
1476
1480
  /**
1477
- * @description Which way of buying. Required when the item is sold in more than one way — the
1478
- * same item may be offered metered, prepaid and as a one-off pack, and the pair
1479
- * `product_key` + `service_product_id` names only the item, not the way.
1480
- *
1481
- * Omit it when the item is sold one way only. If what is given matches no price, or
1482
- * still leaves more than one candidate, the request is refused rather than resolved
1483
- * by guessing.
1481
+ * @description Narrows the selection when a plan offers more than one billing type.
1484
1482
  * @enum {string}
1485
1483
  */
1486
1484
  price_type?: "metered" | "prepaid" | "one_time";
@@ -1497,25 +1495,15 @@ export interface components {
1497
1495
  */
1498
1496
  duration_seconds?: number;
1499
1497
  };
1500
- /**
1501
- * @description Price a change to something already running, rather than a new purchase.
1502
- *
1503
- * The result states what is still owed for the period already paid for, what the new
1504
- * configuration costs for the remainder, and the difference in either direction.
1505
- */
1498
+ /** @description Estimate a change to a subscription item using a target plan or price. */
1506
1499
  QuoteChange: {
1507
1500
  /**
1508
1501
  * Format: uuid
1509
1502
  * @description What is being changed.
1510
1503
  */
1511
1504
  subscription_item_id: string;
1512
- /**
1513
- * Format: uuid
1514
- * @description The price to move to. Identify it here, or by `service_product_id` below. Supplying
1515
- * both, or neither, is refused.
1516
- */
1517
- price_id?: string;
1518
- service_product_id?: string;
1505
+ price?: components["schemas"]["ObjectReference"];
1506
+ plan?: components["schemas"]["ObjectReference"];
1519
1507
  /** @description The new quantity. The current one is kept when omitted. */
1520
1508
  quantity?: string;
1521
1509
  /**
@@ -2290,11 +2278,10 @@ export interface components {
2290
2278
  id: string;
2291
2279
  /** Format: uuid */
2292
2280
  project_id?: string;
2293
- product_key: string;
2281
+ product: components["schemas"]["ObjectIdentity"];
2294
2282
  /** @description Which resource this was charged for. Empty for charges not tied to one. */
2295
2283
  resource_id?: string;
2296
- /** @description What was measured, such as `instance_seconds`. */
2297
- meter_key: string;
2284
+ meter: components["schemas"]["ObjectIdentity"];
2298
2285
  unit?: string;
2299
2286
  /** @description The attributes the rate was chosen by, such as region and machine type. */
2300
2287
  dimensions?: {
@@ -2328,7 +2315,7 @@ export interface components {
2328
2315
  total_count?: number;
2329
2316
  };
2330
2317
  SpendRow: {
2331
- product_key?: string;
2318
+ product?: components["schemas"]["ObjectIdentity"];
2332
2319
  /** Format: uuid */
2333
2320
  plan_id?: string;
2334
2321
  plan_name?: string;
@@ -2358,7 +2345,7 @@ export interface components {
2358
2345
  billing_account_id?: number;
2359
2346
  /** Format: uuid */
2360
2347
  product_id: string;
2361
- product_key?: string;
2348
+ product?: components["schemas"]["ObjectIdentity"];
2362
2349
  /**
2363
2350
  * @description `pending` is a subscription created by an order that has not completed, so it
2364
2351
  * appears in the list before anything under it is running.
@@ -2384,7 +2371,7 @@ export interface components {
2384
2371
  * membership, which belongs to no single project.
2385
2372
  */
2386
2373
  project_id?: string | null;
2387
- product_key?: string;
2374
+ product?: components["schemas"]["ObjectIdentity"];
2388
2375
  /** Format: uuid */
2389
2376
  plan_id: string;
2390
2377
  plan_name?: string;
@@ -2429,10 +2416,10 @@ export interface components {
2429
2416
  /** @description A resource currently accruing charges by the second. */
2430
2417
  ActiveResource: {
2431
2418
  resource_id: string;
2432
- product_key: string;
2419
+ product: components["schemas"]["ObjectIdentity"];
2433
2420
  /** @description What it is, as its own service names it. */
2434
2421
  resource_type?: string;
2435
- meter_key: string;
2422
+ meter: components["schemas"]["ObjectIdentity"];
2436
2423
  unit?: string;
2437
2424
  /** @description How much is held — cores, MiB, cards. Not how much has been used. */
2438
2425
  quantity: string;
@@ -2627,8 +2614,8 @@ export interface components {
2627
2614
  * measured against **the qualifying lines only**, not the order total.
2628
2615
  */
2629
2616
  Applicability: {
2630
- product_keys?: string[];
2631
- plan_keys?: string[];
2617
+ product_ids?: string[];
2618
+ plan_ids?: string[];
2632
2619
  price_types?: string[];
2633
2620
  operations?: components["schemas"]["PurchaseOperation"][];
2634
2621
  /** @description Restricted to your first purchase of a covered product. */
@@ -2676,11 +2663,7 @@ export interface components {
2676
2663
  * @description Which service this line belongs to.
2677
2664
  */
2678
2665
  product_id?: string;
2679
- /**
2680
- * @description How that service is named, such as `compute`. Read from the catalogue rather than
2681
- * recorded on the line, so it always matches the service it points at.
2682
- */
2683
- product_key?: string;
2666
+ product?: components["schemas"]["ObjectIdentity"];
2684
2667
  /**
2685
2668
  * Format: uuid
2686
2669
  * @description Which plan was bought.
@@ -2709,18 +2692,20 @@ export interface components {
2709
2692
  total_count?: number;
2710
2693
  };
2711
2694
  Allowance: {
2695
+ /**
2696
+ * @description Allowed values for selected meter dimensions, such as region or storage class.
2697
+ * Every specified dimension must match one listed value. Omitted dimensions are
2698
+ * unrestricted. An empty map covers all dimensions of this meter.
2699
+ */
2700
+ dimension_values?: {
2701
+ [key: string]: string[];
2702
+ };
2712
2703
  /** Format: uuid */
2713
2704
  id: string;
2714
2705
  /** Format: int64 */
2715
2706
  billing_account_id?: number;
2716
- /**
2717
- * @description Which service it covers, such as `compute`. Read it alongside `meter_key`: a meter
2718
- * name is unique only within its own service, so two allowances for `egress_bytes`
2719
- * may belong to different services and cover different traffic.
2720
- */
2721
- product_key: string;
2722
- /** @description What it covers, such as `egress_bytes`. */
2723
- meter_key: string;
2707
+ product: components["schemas"]["ObjectIdentity"];
2708
+ meter: components["schemas"]["ObjectIdentity"];
2724
2709
  /** @description The unit it is counted in, such as `MiB`. */
2725
2710
  unit?: string;
2726
2711
  /**
@@ -2757,7 +2742,7 @@ export interface components {
2757
2742
  id: string;
2758
2743
  /** Format: uuid */
2759
2744
  usage_charge_id?: string;
2760
- meter_key?: string;
2745
+ meter?: components["schemas"]["ObjectIdentity"];
2761
2746
  quantity: string;
2762
2747
  /** Format: date-time */
2763
2748
  consumed_at: string;
@@ -2770,7 +2755,15 @@ export interface components {
2770
2755
  total_count?: number;
2771
2756
  };
2772
2757
  IncludedAllowance: {
2773
- meter_key: string;
2758
+ /**
2759
+ * @description Allowed values for selected meter dimensions, such as region or storage class.
2760
+ * Every specified dimension must match one listed value. Omitted dimensions are
2761
+ * unrestricted. An empty map covers all dimensions of this meter.
2762
+ */
2763
+ dimension_values?: {
2764
+ [key: string]: string[];
2765
+ };
2766
+ meter: components["schemas"]["ObjectIdentity"];
2774
2767
  unit?: string;
2775
2768
  /** @description How much is included. */
2776
2769
  quantity: string;
@@ -2784,7 +2777,7 @@ export interface components {
2784
2777
  valid_days?: number;
2785
2778
  };
2786
2779
  IncludedFeature: {
2787
- feature_key: string;
2780
+ feature: components["schemas"]["ObjectIdentity"];
2788
2781
  name: string;
2789
2782
  name_translations?: components["schemas"]["Translations"];
2790
2783
  description?: string;
@@ -2804,13 +2797,8 @@ export interface components {
2804
2797
  unit?: string;
2805
2798
  };
2806
2799
  Entitlement: {
2807
- /**
2808
- * @description Which service. Read it alongside `feature_key`, which is unique only within its
2809
- * service.
2810
- */
2811
- product_key: string;
2812
- /** @description What calling code tests against. */
2813
- feature_key: string;
2800
+ product: components["schemas"]["ObjectIdentity"];
2801
+ feature: components["schemas"]["ObjectIdentity"];
2814
2802
  name?: string;
2815
2803
  enabled: boolean;
2816
2804
  /**
@@ -2846,6 +2834,17 @@ export interface components {
2846
2834
  /** Format: int64 */
2847
2835
  total_count?: number;
2848
2836
  };
2837
+ /** @description Identify an object by ID or lookup key, exactly one. A lookup key requires the owning product. */
2838
+ ObjectReference: {
2839
+ /** Format: uuid */
2840
+ id?: string;
2841
+ lookup_key?: string;
2842
+ };
2843
+ ObjectIdentity: {
2844
+ /** Format: uuid */
2845
+ id: string;
2846
+ lookup_key?: string;
2847
+ };
2849
2848
  };
2850
2849
  responses: {
2851
2850
  /** @description Unchanged since the `ETag` that was sent. No body. */
@@ -3039,7 +3038,8 @@ export interface operations {
3039
3038
  page?: components["parameters"]["Page"];
3040
3039
  /** @description How many per page, 100 at most. */
3041
3040
  page_size?: components["parameters"]["PageSize"];
3042
- meter_key?: string;
3041
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
3042
+ meter?: components["schemas"]["ObjectReference"];
3043
3043
  /** @description Return the rates in effect at this moment. Defaults to now. */
3044
3044
  at?: string;
3045
3045
  };
@@ -3861,8 +3861,8 @@ export interface operations {
3861
3861
  /** @description Restrict to one of your accounts. All of them when omitted. */
3862
3862
  billing_account_id?: components["parameters"]["AccountIdQuery"];
3863
3863
  project_id?: string;
3864
- /** @description Restrict to one service, such as `compute`. */
3865
- product_key?: string;
3864
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
3865
+ product?: components["schemas"]["ObjectReference"];
3866
3866
  resource_id?: string;
3867
3867
  from?: components["parameters"]["From"];
3868
3868
  /** @description Exclusive. */
@@ -4085,7 +4085,8 @@ export interface operations {
4085
4085
  * the owning service and not here.
4086
4086
  */
4087
4087
  group_by?: "product" | "plan" | "resource";
4088
- product_key?: string;
4088
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4089
+ product?: components["schemas"]["ObjectReference"];
4089
4090
  /** @description 1-based page number; the first page when omitted. */
4090
4091
  page?: components["parameters"]["Page"];
4091
4092
  /** @description How many per page, 100 at most. */
@@ -4119,13 +4120,10 @@ export interface operations {
4119
4120
  /** @description How many per page, 100 at most. */
4120
4121
  page_size?: components["parameters"]["PageSize"];
4121
4122
  resource_id?: string;
4122
- /**
4123
- * @description Restrict to one service, such as `compute`. Give it alongside `meter_key`: a meter
4124
- * name is unique only within its own service, and more than one service may measure
4125
- * `traffic_bytes`, so `meter_key` on its own can return charges from several.
4126
- */
4127
- product_key?: string;
4128
- meter_key?: string;
4123
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4124
+ product?: components["schemas"]["ObjectReference"];
4125
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4126
+ meter?: components["schemas"]["ObjectReference"];
4129
4127
  from?: components["parameters"]["From"];
4130
4128
  /** @description Exclusive. */
4131
4129
  to?: components["parameters"]["To"];
@@ -4356,8 +4354,11 @@ export interface operations {
4356
4354
  page_size?: components["parameters"]["PageSize"];
4357
4355
  /** @description Restrict to one of your accounts. All of them when omitted. */
4358
4356
  billing_account_id?: components["parameters"]["AccountIdQuery"];
4359
- meter_key?: string;
4357
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4358
+ meter?: components["schemas"]["ObjectReference"];
4360
4359
  status?: "active" | "depleted" | "expired" | "voided";
4360
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4361
+ product?: components["schemas"]["ObjectReference"];
4361
4362
  };
4362
4363
  header?: never;
4363
4364
  path?: never;
@@ -4571,7 +4572,10 @@ export interface operations {
4571
4572
  page?: components["parameters"]["Page"];
4572
4573
  /** @description How many per page, 100 at most. */
4573
4574
  page_size?: components["parameters"]["PageSize"];
4574
- meter_key?: string;
4575
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4576
+ meter?: components["schemas"]["ObjectReference"];
4577
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4578
+ product?: components["schemas"]["ObjectReference"];
4575
4579
  };
4576
4580
  header?: never;
4577
4581
  path: {
@@ -4633,7 +4637,8 @@ export interface operations {
4633
4637
  page?: components["parameters"]["Page"];
4634
4638
  /** @description How many per page, 100 at most. */
4635
4639
  page_size?: components["parameters"]["PageSize"];
4636
- product_key?: string;
4640
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4641
+ product?: components["schemas"]["ObjectReference"];
4637
4642
  };
4638
4643
  header?: never;
4639
4644
  path: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.57.0",
3
+ "version": "0.58.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -23,6 +23,10 @@
23
23
  "types": "./dist/assistant/v1/index.d.ts",
24
24
  "default": "./dist/assistant/v1/index.js"
25
25
  },
26
+ "./billing/v1": {
27
+ "types": "./dist/billing/v1/index.d.ts",
28
+ "default": "./dist/billing/v1/index.js"
29
+ },
26
30
  "./canopy/v1": {
27
31
  "types": "./dist/canopy/v1/index.d.ts",
28
32
  "default": "./dist/canopy/v1/index.js"
@@ -31,6 +35,14 @@
31
35
  "types": "./dist/compute/v1/index.d.ts",
32
36
  "default": "./dist/compute/v1/index.js"
33
37
  },
38
+ "./dns/v1": {
39
+ "types": "./dist/dns/v1/index.d.ts",
40
+ "default": "./dist/dns/v1/index.js"
41
+ },
42
+ "./fleet/v1": {
43
+ "types": "./dist/fleet/v1/index.d.ts",
44
+ "default": "./dist/fleet/v1/index.js"
45
+ },
34
46
  "./iam/v1": {
35
47
  "types": "./dist/iam/v1/index.d.ts",
36
48
  "default": "./dist/iam/v1/index.js"
@@ -39,6 +51,14 @@
39
51
  "types": "./dist/monitoring/v1/index.d.ts",
40
52
  "default": "./dist/monitoring/v1/index.js"
41
53
  },
54
+ "./notification/v1": {
55
+ "types": "./dist/notification/v1/index.d.ts",
56
+ "default": "./dist/notification/v1/index.js"
57
+ },
58
+ "./support/v1": {
59
+ "types": "./dist/support/v1/index.d.ts",
60
+ "default": "./dist/support/v1/index.js"
61
+ },
42
62
  "./tunnel/v1": {
43
63
  "types": "./dist/tunnel/v1/index.d.ts",
44
64
  "default": "./dist/tunnel/v1/index.js"
@@ -56,7 +76,6 @@
56
76
  "format:check": "prettier --check gen scripts"
57
77
  },
58
78
  "devDependencies": {
59
- "openapi-fetch": "^0.17.0",
60
79
  "openapi-typescript": "7.13.0",
61
80
  "prettier": "^3.6.2",
62
81
  "typescript": "^5.9.3",
@@ -65,12 +84,7 @@
65
84
  "publishConfig": {
66
85
  "access": "public"
67
86
  },
68
- "peerDependencies": {
87
+ "dependencies": {
69
88
  "openapi-fetch": "^0.17.0"
70
- },
71
- "peerDependenciesMeta": {
72
- "openapi-fetch": {
73
- "optional": true
74
- }
75
89
  }
76
90
  }