@leaflow/sdk 0.57.1 → 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 */
@@ -1425,8 +1429,7 @@ export interface components {
1425
1429
  total_count?: number;
1426
1430
  };
1427
1431
  CatalogRate: {
1428
- /** @description What is being measured. */
1429
- meter_key: string;
1432
+ meter: components["schemas"]["ObjectIdentity"];
1430
1433
  /** @description The unit readings arrive in, such as `core-second`. */
1431
1434
  unit?: string;
1432
1435
  /** @description The attributes this rate applies to, such as region and machine type. */
@@ -1455,22 +1458,12 @@ export interface components {
1455
1458
  /** Format: int64 */
1456
1459
  total_count?: number;
1457
1460
  };
1458
- /**
1459
- * @description Identify what to price either by `price_id`, or by `product_key` together with
1460
- * `service_product_id`. Supplying both, or neither, is refused.
1461
- */
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. */
1462
1462
  QuoteLine: {
1463
- /** Format: uuid */
1464
- price_id?: string;
1465
- /** @description The service, such as `compute`. */
1466
- product_key?: string;
1467
- /** @description How the owning service identifies the item, such as a machine type. */
1468
- service_product_id?: string;
1469
- /**
1470
- * @description Required for a metered price whose price list covers more than one meter, so that
1471
- * the intended one is unambiguous.
1472
- */
1473
- meter_key?: string;
1463
+ price?: components["schemas"]["ObjectReference"];
1464
+ product?: components["schemas"]["ObjectReference"];
1465
+ plan?: components["schemas"]["ObjectReference"];
1466
+ meter?: components["schemas"]["ObjectReference"];
1474
1467
  /**
1475
1468
  * @description The attributes the price depends on — region, instance type, token class.
1476
1469
  *
@@ -1485,13 +1478,7 @@ export interface components {
1485
1478
  [key: string]: string;
1486
1479
  };
1487
1480
  /**
1488
- * @description Which way of buying. Required when the item is sold in more than one way — the
1489
- * same item may be offered metered, prepaid and as a one-off pack, and the pair
1490
- * `product_key` + `service_product_id` names only the item, not the way.
1491
- *
1492
- * Omit it when the item is sold one way only. If what is given matches no price, or
1493
- * still leaves more than one candidate, the request is refused rather than resolved
1494
- * by guessing.
1481
+ * @description Narrows the selection when a plan offers more than one billing type.
1495
1482
  * @enum {string}
1496
1483
  */
1497
1484
  price_type?: "metered" | "prepaid" | "one_time";
@@ -1508,25 +1495,15 @@ export interface components {
1508
1495
  */
1509
1496
  duration_seconds?: number;
1510
1497
  };
1511
- /**
1512
- * @description Price a change to something already running, rather than a new purchase.
1513
- *
1514
- * The result states what is still owed for the period already paid for, what the new
1515
- * configuration costs for the remainder, and the difference in either direction.
1516
- */
1498
+ /** @description Estimate a change to a subscription item using a target plan or price. */
1517
1499
  QuoteChange: {
1518
1500
  /**
1519
1501
  * Format: uuid
1520
1502
  * @description What is being changed.
1521
1503
  */
1522
1504
  subscription_item_id: string;
1523
- /**
1524
- * Format: uuid
1525
- * @description The price to move to. Identify it here, or by `service_product_id` below. Supplying
1526
- * both, or neither, is refused.
1527
- */
1528
- price_id?: string;
1529
- service_product_id?: string;
1505
+ price?: components["schemas"]["ObjectReference"];
1506
+ plan?: components["schemas"]["ObjectReference"];
1530
1507
  /** @description The new quantity. The current one is kept when omitted. */
1531
1508
  quantity?: string;
1532
1509
  /**
@@ -2301,11 +2278,10 @@ export interface components {
2301
2278
  id: string;
2302
2279
  /** Format: uuid */
2303
2280
  project_id?: string;
2304
- product_key: string;
2281
+ product: components["schemas"]["ObjectIdentity"];
2305
2282
  /** @description Which resource this was charged for. Empty for charges not tied to one. */
2306
2283
  resource_id?: string;
2307
- /** @description What was measured, such as `instance_seconds`. */
2308
- meter_key: string;
2284
+ meter: components["schemas"]["ObjectIdentity"];
2309
2285
  unit?: string;
2310
2286
  /** @description The attributes the rate was chosen by, such as region and machine type. */
2311
2287
  dimensions?: {
@@ -2339,7 +2315,7 @@ export interface components {
2339
2315
  total_count?: number;
2340
2316
  };
2341
2317
  SpendRow: {
2342
- product_key?: string;
2318
+ product?: components["schemas"]["ObjectIdentity"];
2343
2319
  /** Format: uuid */
2344
2320
  plan_id?: string;
2345
2321
  plan_name?: string;
@@ -2369,7 +2345,7 @@ export interface components {
2369
2345
  billing_account_id?: number;
2370
2346
  /** Format: uuid */
2371
2347
  product_id: string;
2372
- product_key?: string;
2348
+ product?: components["schemas"]["ObjectIdentity"];
2373
2349
  /**
2374
2350
  * @description `pending` is a subscription created by an order that has not completed, so it
2375
2351
  * appears in the list before anything under it is running.
@@ -2395,7 +2371,7 @@ export interface components {
2395
2371
  * membership, which belongs to no single project.
2396
2372
  */
2397
2373
  project_id?: string | null;
2398
- product_key?: string;
2374
+ product?: components["schemas"]["ObjectIdentity"];
2399
2375
  /** Format: uuid */
2400
2376
  plan_id: string;
2401
2377
  plan_name?: string;
@@ -2440,10 +2416,10 @@ export interface components {
2440
2416
  /** @description A resource currently accruing charges by the second. */
2441
2417
  ActiveResource: {
2442
2418
  resource_id: string;
2443
- product_key: string;
2419
+ product: components["schemas"]["ObjectIdentity"];
2444
2420
  /** @description What it is, as its own service names it. */
2445
2421
  resource_type?: string;
2446
- meter_key: string;
2422
+ meter: components["schemas"]["ObjectIdentity"];
2447
2423
  unit?: string;
2448
2424
  /** @description How much is held — cores, MiB, cards. Not how much has been used. */
2449
2425
  quantity: string;
@@ -2638,8 +2614,8 @@ export interface components {
2638
2614
  * measured against **the qualifying lines only**, not the order total.
2639
2615
  */
2640
2616
  Applicability: {
2641
- product_keys?: string[];
2642
- plan_keys?: string[];
2617
+ product_ids?: string[];
2618
+ plan_ids?: string[];
2643
2619
  price_types?: string[];
2644
2620
  operations?: components["schemas"]["PurchaseOperation"][];
2645
2621
  /** @description Restricted to your first purchase of a covered product. */
@@ -2687,11 +2663,7 @@ export interface components {
2687
2663
  * @description Which service this line belongs to.
2688
2664
  */
2689
2665
  product_id?: string;
2690
- /**
2691
- * @description How that service is named, such as `compute`. Read from the catalogue rather than
2692
- * recorded on the line, so it always matches the service it points at.
2693
- */
2694
- product_key?: string;
2666
+ product?: components["schemas"]["ObjectIdentity"];
2695
2667
  /**
2696
2668
  * Format: uuid
2697
2669
  * @description Which plan was bought.
@@ -2720,18 +2692,20 @@ export interface components {
2720
2692
  total_count?: number;
2721
2693
  };
2722
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
+ };
2723
2703
  /** Format: uuid */
2724
2704
  id: string;
2725
2705
  /** Format: int64 */
2726
2706
  billing_account_id?: number;
2727
- /**
2728
- * @description Which service it covers, such as `compute`. Read it alongside `meter_key`: a meter
2729
- * name is unique only within its own service, so two allowances for `egress_bytes`
2730
- * may belong to different services and cover different traffic.
2731
- */
2732
- product_key: string;
2733
- /** @description What it covers, such as `egress_bytes`. */
2734
- meter_key: string;
2707
+ product: components["schemas"]["ObjectIdentity"];
2708
+ meter: components["schemas"]["ObjectIdentity"];
2735
2709
  /** @description The unit it is counted in, such as `MiB`. */
2736
2710
  unit?: string;
2737
2711
  /**
@@ -2768,7 +2742,7 @@ export interface components {
2768
2742
  id: string;
2769
2743
  /** Format: uuid */
2770
2744
  usage_charge_id?: string;
2771
- meter_key?: string;
2745
+ meter?: components["schemas"]["ObjectIdentity"];
2772
2746
  quantity: string;
2773
2747
  /** Format: date-time */
2774
2748
  consumed_at: string;
@@ -2781,7 +2755,15 @@ export interface components {
2781
2755
  total_count?: number;
2782
2756
  };
2783
2757
  IncludedAllowance: {
2784
- 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"];
2785
2767
  unit?: string;
2786
2768
  /** @description How much is included. */
2787
2769
  quantity: string;
@@ -2795,7 +2777,7 @@ export interface components {
2795
2777
  valid_days?: number;
2796
2778
  };
2797
2779
  IncludedFeature: {
2798
- feature_key: string;
2780
+ feature: components["schemas"]["ObjectIdentity"];
2799
2781
  name: string;
2800
2782
  name_translations?: components["schemas"]["Translations"];
2801
2783
  description?: string;
@@ -2815,13 +2797,8 @@ export interface components {
2815
2797
  unit?: string;
2816
2798
  };
2817
2799
  Entitlement: {
2818
- /**
2819
- * @description Which service. Read it alongside `feature_key`, which is unique only within its
2820
- * service.
2821
- */
2822
- product_key: string;
2823
- /** @description What calling code tests against. */
2824
- feature_key: string;
2800
+ product: components["schemas"]["ObjectIdentity"];
2801
+ feature: components["schemas"]["ObjectIdentity"];
2825
2802
  name?: string;
2826
2803
  enabled: boolean;
2827
2804
  /**
@@ -2857,6 +2834,17 @@ export interface components {
2857
2834
  /** Format: int64 */
2858
2835
  total_count?: number;
2859
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
+ };
2860
2848
  };
2861
2849
  responses: {
2862
2850
  /** @description Unchanged since the `ETag` that was sent. No body. */
@@ -3050,7 +3038,8 @@ export interface operations {
3050
3038
  page?: components["parameters"]["Page"];
3051
3039
  /** @description How many per page, 100 at most. */
3052
3040
  page_size?: components["parameters"]["PageSize"];
3053
- meter_key?: string;
3041
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
3042
+ meter?: components["schemas"]["ObjectReference"];
3054
3043
  /** @description Return the rates in effect at this moment. Defaults to now. */
3055
3044
  at?: string;
3056
3045
  };
@@ -3872,8 +3861,8 @@ export interface operations {
3872
3861
  /** @description Restrict to one of your accounts. All of them when omitted. */
3873
3862
  billing_account_id?: components["parameters"]["AccountIdQuery"];
3874
3863
  project_id?: string;
3875
- /** @description Restrict to one service, such as `compute`. */
3876
- product_key?: string;
3864
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
3865
+ product?: components["schemas"]["ObjectReference"];
3877
3866
  resource_id?: string;
3878
3867
  from?: components["parameters"]["From"];
3879
3868
  /** @description Exclusive. */
@@ -4096,7 +4085,8 @@ export interface operations {
4096
4085
  * the owning service and not here.
4097
4086
  */
4098
4087
  group_by?: "product" | "plan" | "resource";
4099
- product_key?: string;
4088
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4089
+ product?: components["schemas"]["ObjectReference"];
4100
4090
  /** @description 1-based page number; the first page when omitted. */
4101
4091
  page?: components["parameters"]["Page"];
4102
4092
  /** @description How many per page, 100 at most. */
@@ -4130,13 +4120,10 @@ export interface operations {
4130
4120
  /** @description How many per page, 100 at most. */
4131
4121
  page_size?: components["parameters"]["PageSize"];
4132
4122
  resource_id?: string;
4133
- /**
4134
- * @description Restrict to one service, such as `compute`. Give it alongside `meter_key`: a meter
4135
- * name is unique only within its own service, and more than one service may measure
4136
- * `traffic_bytes`, so `meter_key` on its own can return charges from several.
4137
- */
4138
- product_key?: string;
4139
- 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"];
4140
4127
  from?: components["parameters"]["From"];
4141
4128
  /** @description Exclusive. */
4142
4129
  to?: components["parameters"]["To"];
@@ -4367,8 +4354,11 @@ export interface operations {
4367
4354
  page_size?: components["parameters"]["PageSize"];
4368
4355
  /** @description Restrict to one of your accounts. All of them when omitted. */
4369
4356
  billing_account_id?: components["parameters"]["AccountIdQuery"];
4370
- meter_key?: string;
4357
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4358
+ meter?: components["schemas"]["ObjectReference"];
4371
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"];
4372
4362
  };
4373
4363
  header?: never;
4374
4364
  path?: never;
@@ -4582,7 +4572,10 @@ export interface operations {
4582
4572
  page?: components["parameters"]["Page"];
4583
4573
  /** @description How many per page, 100 at most. */
4584
4574
  page_size?: components["parameters"]["PageSize"];
4585
- 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"];
4586
4579
  };
4587
4580
  header?: never;
4588
4581
  path: {
@@ -4644,7 +4637,8 @@ export interface operations {
4644
4637
  page?: components["parameters"]["Page"];
4645
4638
  /** @description How many per page, 100 at most. */
4646
4639
  page_size?: components["parameters"]["PageSize"];
4647
- product_key?: string;
4640
+ /** @description Filter by ID or lookup key. A lookup key is scoped to the product. */
4641
+ product?: components["schemas"]["ObjectReference"];
4648
4642
  };
4649
4643
  header?: never;
4650
4644
  path: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.57.1",
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
  }