@leaflow/sdk 0.29.0 → 0.31.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.
@@ -38,8 +38,12 @@ export type CancelSubscriptionResult = operations["cancel-subscription"]["respon
38
38
  export type CancelSubscriptionQuery = operations["cancel-subscription"]["parameters"]["query"];
39
39
  /** `GET /account/v1/billing-accounts/{accountKey}/top-ups/{paymentId}` 成功时的响应体。 */
40
40
  export type ReadTopUpResult = operations["read-top-up"]["responses"][200]["content"]["application/json"];
41
+ /** `GET /account/v1/billing-accounts/{accountKey}/card` 成功时的响应体。 */
42
+ export type ReadPaymentMethodResult = operations["read-payment-method"]["responses"][200]["content"]["application/json"];
41
43
  /** `POST /account/v1/billing-accounts/{accountKey}/card` 成功时的响应体。 */
42
44
  export type StartCardSetupResult = operations["start-card-setup"]["responses"][200]["content"]["application/json"];
45
+ /** `POST /account/v1/billing-accounts/{accountKey}/billing-portal` 成功时的响应体。 */
46
+ export type StartBillingPortalResult = operations["start-billing-portal"]["responses"][200]["content"]["application/json"];
43
47
  /** `GET /account/v1/billing-accounts/{accountKey}/offers` 成功时的响应体。 */
44
48
  export type ListOffersResult = operations["list-offers"]["responses"][200]["content"]["application/json"];
45
49
  /** `POST /account/v1/billing-accounts/{accountKey}/offers/{offerKey}/purchase` 成功时的响应体。 */
@@ -370,7 +370,30 @@ export interface paths {
370
370
  path?: never;
371
371
  cookie?: never;
372
372
  };
373
- get?: never;
373
+ /**
374
+ * Whether this account can be charged
375
+ * @description Answers whether a card is on file, and nothing else.
376
+ *
377
+ * ## Why there is no brand, no last four digits, no expiry
378
+ *
379
+ * Those would have to be read from the payment provider, and the two answers can disagree: a
380
+ * card present at the provider that the billing engine has not recorded as the default is
381
+ * exactly the state in which money cannot be collected — while a page built on the provider's
382
+ * answer would be showing a card. What matters here is whether the party that will run the
383
+ * charge believes it can, so the answer comes from that party alone.
384
+ *
385
+ * To see the card, replace it, or remove it, open the billing portal.
386
+ *
387
+ * ## Read this before offering a paid plan, not after
388
+ *
389
+ * `ready` being false is why the engine refuses to start a paid subscription. Discovering it
390
+ * at purchase time turns a missing card into a rejection whose wording is about something
391
+ * else entirely.
392
+ *
393
+ * An account that has never had a card returns `ready: false`. That is the normal state of a
394
+ * new account, not an error.
395
+ */
396
+ get: operations["read-payment-method"];
374
397
  put?: never;
375
398
  /**
376
399
  * Add or replace the card on file
@@ -395,6 +418,41 @@ export interface paths {
395
418
  patch?: never;
396
419
  trace?: never;
397
420
  };
421
+ "/account/v1/billing-accounts/{accountKey}/billing-portal": {
422
+ parameters: {
423
+ query?: never;
424
+ header?: never;
425
+ path?: never;
426
+ cookie?: never;
427
+ };
428
+ get?: never;
429
+ put?: never;
430
+ /**
431
+ * Open the hosted billing portal
432
+ * @description Returns a URL to the payment provider's own portal, where the card can be replaced or
433
+ * removed, the billing address changed, and past invoices downloaded.
434
+ *
435
+ * ## Why replacing a card is not a form on this platform
436
+ *
437
+ * A form would mean a card number field, and no card data ever reaches this platform. The
438
+ * portal moves the whole interaction to the provider; only a session URL comes back.
439
+ *
440
+ * ## Something has to be able to replace an expiring card
441
+ *
442
+ * Cards expire. Once one does, the invoices for a plan stop being collectable, dunning runs
443
+ * out, and the projects paid for by this account are suspended for non-payment. Without this
444
+ * operation the account holder watches that happen with nowhere to fix it — adding a card
445
+ * does not help, since that operation only makes sense when there is none.
446
+ *
447
+ * The URL is single-use and expires. Do not store it.
448
+ */
449
+ post: operations["start-billing-portal"];
450
+ delete?: never;
451
+ options?: never;
452
+ head?: never;
453
+ patch?: never;
454
+ trace?: never;
455
+ };
398
456
  "/account/v1/billing-accounts/{accountKey}/offers": {
399
457
  parameters: {
400
458
  query?: never;
@@ -739,6 +797,28 @@ export interface components {
739
797
  */
740
798
  url: string;
741
799
  };
800
+ BillingPortalSession: {
801
+ /**
802
+ * Format: uri
803
+ * @description Send the browser here. It expires, so do not store it
804
+ */
805
+ url: string;
806
+ };
807
+ /** @description Whether money can be collected from this account */
808
+ PaymentMethod: {
809
+ /**
810
+ * @description True when the billing engine holds a default payment method for this account and can
811
+ * therefore collect an invoice.
812
+ *
813
+ * This is the precondition for a paid plan. While it is false, starting a paid
814
+ * subscription is refused, and the refusal is about billing setup rather than about the
815
+ * plan — so check this first and say what is actually missing.
816
+ *
817
+ * A free plan does not require it, which is what allows a new account to be placed on the
818
+ * default tier before anyone has entered a card.
819
+ */
820
+ ready: boolean;
821
+ };
742
822
  TopUpSession: {
743
823
  /**
744
824
  * @description Identifies this attempt. Quote it in a support conversation — it is what ties the payment
@@ -1441,6 +1521,41 @@ export interface operations {
1441
1521
  };
1442
1522
  };
1443
1523
  };
1524
+ "read-payment-method": {
1525
+ parameters: {
1526
+ query?: never;
1527
+ header?: never;
1528
+ path: {
1529
+ /**
1530
+ * @description The account's key, of the form `u_<user_id>_<seq>`. Ownership is stated by the key itself,
1531
+ * which is why the key is what addresses the account.
1532
+ */
1533
+ accountKey: components["parameters"]["AccountKey"];
1534
+ };
1535
+ cookie?: never;
1536
+ };
1537
+ requestBody?: never;
1538
+ responses: {
1539
+ /** @description OK */
1540
+ 200: {
1541
+ headers: {
1542
+ [name: string]: unknown;
1543
+ };
1544
+ content: {
1545
+ "application/json": components["schemas"]["PaymentMethod"];
1546
+ };
1547
+ };
1548
+ /** @description Error */
1549
+ default: {
1550
+ headers: {
1551
+ [name: string]: unknown;
1552
+ };
1553
+ content: {
1554
+ "application/json": components["schemas"]["Error"];
1555
+ };
1556
+ };
1557
+ };
1558
+ };
1444
1559
  "start-card-setup": {
1445
1560
  parameters: {
1446
1561
  query?: never;
@@ -1476,6 +1591,41 @@ export interface operations {
1476
1591
  };
1477
1592
  };
1478
1593
  };
1594
+ "start-billing-portal": {
1595
+ parameters: {
1596
+ query?: never;
1597
+ header?: never;
1598
+ path: {
1599
+ /**
1600
+ * @description The account's key, of the form `u_<user_id>_<seq>`. Ownership is stated by the key itself,
1601
+ * which is why the key is what addresses the account.
1602
+ */
1603
+ accountKey: components["parameters"]["AccountKey"];
1604
+ };
1605
+ cookie?: never;
1606
+ };
1607
+ requestBody?: never;
1608
+ responses: {
1609
+ /** @description OK */
1610
+ 200: {
1611
+ headers: {
1612
+ [name: string]: unknown;
1613
+ };
1614
+ content: {
1615
+ "application/json": components["schemas"]["BillingPortalSession"];
1616
+ };
1617
+ };
1618
+ /** @description Error */
1619
+ default: {
1620
+ headers: {
1621
+ [name: string]: unknown;
1622
+ };
1623
+ content: {
1624
+ "application/json": components["schemas"]["Error"];
1625
+ };
1626
+ };
1627
+ };
1628
+ };
1479
1629
  "list-offers": {
1480
1630
  parameters: {
1481
1631
  query?: never;
@@ -58,6 +58,8 @@ export type GetServerSnapshotResult = operations["get-server-snapshot"]["respons
58
58
  export type ListProjectTopItemsResult = operations["list-project-top-items"]["responses"][200]["content"]["application/json"];
59
59
  /** `GET /api/v1/top-items` 的查询参数。 */
60
60
  export type ListProjectTopItemsQuery = operations["list-project-top-items"]["parameters"]["query"];
61
+ /** `GET /api/v1/templates` 成功时的响应体。 */
62
+ export type ListTemplatesResult = operations["list-templates"]["responses"][200]["content"]["application/json"];
61
63
  /** `GET /api/v1/servers` 成功时的响应体。 */
62
64
  export type ListServersResult = operations["list-servers"]["responses"][200]["content"]["application/json"];
63
65
  /** `GET /api/v1/servers` 的查询参数。 */
@@ -331,6 +331,26 @@ export interface paths {
331
331
  patch?: never;
332
332
  trace?: never;
333
333
  };
334
+ "/api/v1/templates": {
335
+ parameters: {
336
+ query?: never;
337
+ header?: never;
338
+ path?: never;
339
+ cookie?: never;
340
+ };
341
+ /**
342
+ * List the monitoring templates that can be bound to a machine
343
+ * @description The catalog every template binding is validated against — which templates exist, which parameters each of them accepts, and what each parameter defaults to. It is identical for every project and changes only when this deployment is upgraded. Read it rather than keeping a copy. A copy drifts, and only one of the ways it drifts fails loudly — an unknown parameter name is rejected, but a stale `default` and a stale `required` both look correct on screen.
344
+ */
345
+ get: operations["list-templates"];
346
+ put?: never;
347
+ post?: never;
348
+ delete?: never;
349
+ options?: never;
350
+ head?: never;
351
+ patch?: never;
352
+ trace?: never;
353
+ };
334
354
  "/api/v1/servers": {
335
355
  parameters: {
336
356
  query?: never;
@@ -366,6 +386,8 @@ export interface paths {
366
386
  * A failed call leaves the machine recorded with `monitoring_status: FAILED`; the reason is reported in `last_error` via `GET /servers/{serverId}`.
367
387
  *
368
388
  * The `tls_psk` in the response is **returned only this once**; store it immediately. If it is lost, it must be rotated.
389
+ *
390
+ * It is also how collection is resumed after `/disable`. On a machine that already exists, **omitting `template_bindings` keeps the bindings it already has**; it does not fall back to the default of Linux alone, which would silently drop every other template together with its parameters. Secret parameters are likewise carried over — see `parameters` on the binding.
369
391
  */
370
392
  put: operations["enable-server-monitoring"];
371
393
  post?: never;
@@ -1291,6 +1313,46 @@ export interface components {
1291
1313
  TopItemListResponseBody: {
1292
1314
  items: components["schemas"]["TopItemResource"][] | null;
1293
1315
  };
1316
+ TemplateCatalogParameterResource: {
1317
+ /** @description The value that takes effect when the parameter is omitted. An empty string is a real default, not an absent one */
1318
+ default: string;
1319
+ /**
1320
+ * @description The shape of the accepted value. Surrounding whitespace is trimmed before the value is checked, and an omitted or empty value is replaced by `default` and not checked at all.
1321
+ *
1322
+ * - `string` — no constraint; empty is accepted
1323
+ * - `non_empty_string` — must not be empty once trimmed
1324
+ * - `percent` — a number in the **closed** interval 0 to 100; fractions are accepted
1325
+ * - `positive_number` — a number **strictly** greater than 0; fractions are accepted
1326
+ * - `port` — an integer from 1 to 65535 inclusive; `8080/tcp` is not a port
1327
+ * - `host` — an IP address, or a hostname of at most 255 characters whose dot-separated labels are at most 63 characters of `A-Z a-z 0-9 - _` and neither begin nor end with `-`. A single label such as `localhost` is accepted, as is a trailing dot
1328
+ * - `ip_or_empty` — an IP address, or empty to mean "not specified"
1329
+ * - `regexp` — must compile as a **Go RE2** pattern. RE2 has no backreferences and no lookaround, so a pattern that a browser's `new RegExp()` accepts may still be rejected here. Validating client-side narrows the gap but does not close it
1330
+ * @enum {string}
1331
+ */
1332
+ kind: "string" | "non_empty_string" | "percent" | "positive_number" | "port" | "host" | "ip_or_empty" | "regexp";
1333
+ /** @description The key to use in `template_bindings[].parameters`. It is not the Zabbix macro name, which is internal and changes between Zabbix versions */
1334
+ name: string;
1335
+ /** @description Independent of `default`. The three NGINX connection parameters carry a default and are still required, because the template's own default (localhost:80/basic_status) is almost never right */
1336
+ required: boolean;
1337
+ /** @description Supplied in clear text and never returned. A configured one is reported by name only, through `configured_secret_parameters` on the bound template. When updating a machine that already has one stored, omit it to keep the stored value and supply it only to replace it — a caller cannot read it back, so requiring it on every write would make resuming collection impossible */
1338
+ secret: boolean;
1339
+ };
1340
+ TemplateCatalogEntryResource: {
1341
+ /** @description Exactly one template with this set must be bound to every machine. Binding none enrolls a machine that can never alert; binding both loads the Linux and Windows items onto one machine, half of which must fail */
1342
+ is_base: boolean;
1343
+ /** @description False means the template collects without an agent on the machine — ICMP_PING is pinged by the Zabbix server, PROXMOX_VE is polled over the PVE API */
1344
+ needs_agent: boolean;
1345
+ /** @description In declaration order — connection parameters first, thresholds after — and meant to be rendered in that order. It is deliberately not alphabetical, which would split a template's connection parameters apart with thresholds between them even though they only make sense filled in together */
1346
+ parameters: components["schemas"]["TemplateCatalogParameterResource"][] | null;
1347
+ /** @description Templates that must be bound alongside this one. Values are `template_key`s */
1348
+ requires: string[] | null;
1349
+ /** @description Whether this template may be bound when `agent_mode` is ACTIVE. It already combines both reasons it may not be — no active variant exists, or this deployment does not have one installed — because the two are rejected identically and call for the same fix */
1350
+ supports_active_mode: boolean;
1351
+ template_key: string;
1352
+ };
1353
+ TemplateCatalogResponseBody: {
1354
+ items: components["schemas"]["TemplateCatalogEntryResource"][] | null;
1355
+ };
1294
1356
  ServerTemplateResource: {
1295
1357
  configured_secret_parameters: string[] | null;
1296
1358
  parameters: {
@@ -1348,7 +1410,11 @@ export interface components {
1348
1410
  total: number;
1349
1411
  };
1350
1412
  TemplateBindingRequest: {
1351
- /** @description Parameters declared by the template. Secret parameters are supplied in clear text and returned by name only */
1413
+ /**
1414
+ * @description Parameters declared by the template, keyed by `name` from `GET /templates`. This is a full replacement: a parameter that is omitted takes the `default` reported there, so send back the whole `parameters` map read from the machine rather than only the field being changed.
1415
+ *
1416
+ * Secret parameters are the one exception, because they are never returned and so cannot be sent back. Omit one to keep the value already stored, and supply it only to replace it. An empty or blank value counts as omitted.
1417
+ */
1352
1418
  parameters?: {
1353
1419
  [key: string]: string;
1354
1420
  };
@@ -2625,6 +2691,35 @@ export interface operations {
2625
2691
  };
2626
2692
  };
2627
2693
  };
2694
+ "list-templates": {
2695
+ parameters: {
2696
+ query?: never;
2697
+ header?: never;
2698
+ path?: never;
2699
+ cookie?: never;
2700
+ };
2701
+ requestBody?: never;
2702
+ responses: {
2703
+ /** @description OK */
2704
+ 200: {
2705
+ headers: {
2706
+ [name: string]: unknown;
2707
+ };
2708
+ content: {
2709
+ "application/json": components["schemas"]["TemplateCatalogResponseBody"];
2710
+ };
2711
+ };
2712
+ /** @description Error */
2713
+ default: {
2714
+ headers: {
2715
+ [name: string]: unknown;
2716
+ };
2717
+ content: {
2718
+ "application/json": components["schemas"]["Error"];
2719
+ };
2720
+ };
2721
+ };
2722
+ };
2628
2723
  "list-servers": {
2629
2724
  parameters: {
2630
2725
  query?: {
package/package.json CHANGED
@@ -1,74 +1,74 @@
1
1
  {
2
- "name": "@leaflow/sdk",
3
- "version": "0.29.0",
4
- "description": "Leaflow 平台 API 的 TypeScript SDK",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/leaflowapis/leaflow-ts.git"
9
- },
10
- "type": "module",
11
- "main": "./dist/index.js",
12
- "types": "./dist/index.d.ts",
13
- "exports": {
14
- ".": {
15
- "types": "./dist/index.d.ts",
16
- "default": "./dist/index.js"
2
+ "name": "@leaflow/sdk",
3
+ "version": "0.31.0",
4
+ "description": "Leaflow 平台 API 的 TypeScript SDK",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/leaflowapis/leaflow-ts.git"
17
9
  },
18
- "./account/v1": {
19
- "types": "./dist/account/v1/index.d.ts",
20
- "default": "./dist/account/v1/index.js"
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ },
18
+ "./account/v1": {
19
+ "types": "./dist/account/v1/index.d.ts",
20
+ "default": "./dist/account/v1/index.js"
21
+ },
22
+ "./assistant/v1": {
23
+ "types": "./dist/assistant/v1/index.d.ts",
24
+ "default": "./dist/assistant/v1/index.js"
25
+ },
26
+ "./canopy/v1": {
27
+ "types": "./dist/canopy/v1/index.d.ts",
28
+ "default": "./dist/canopy/v1/index.js"
29
+ },
30
+ "./compute/v1": {
31
+ "types": "./dist/compute/v1/index.d.ts",
32
+ "default": "./dist/compute/v1/index.js"
33
+ },
34
+ "./iam/v1": {
35
+ "types": "./dist/iam/v1/index.d.ts",
36
+ "default": "./dist/iam/v1/index.js"
37
+ },
38
+ "./monitoring/v1": {
39
+ "types": "./dist/monitoring/v1/index.d.ts",
40
+ "default": "./dist/monitoring/v1/index.js"
41
+ },
42
+ "./tunnel/v1": {
43
+ "types": "./dist/tunnel/v1/index.d.ts",
44
+ "default": "./dist/tunnel/v1/index.js"
45
+ }
21
46
  },
22
- "./assistant/v1": {
23
- "types": "./dist/assistant/v1/index.d.ts",
24
- "default": "./dist/assistant/v1/index.js"
47
+ "files": [
48
+ "dist"
49
+ ],
50
+ "sideEffects": false,
51
+ "scripts": {
52
+ "generate": "node scripts/generate.mjs",
53
+ "build": "tsc -p tsconfig.build.json",
54
+ "typecheck": "tsc -p tsconfig.json --noEmit",
55
+ "prepublishOnly": "npm run build"
25
56
  },
26
- "./canopy/v1": {
27
- "types": "./dist/canopy/v1/index.d.ts",
28
- "default": "./dist/canopy/v1/index.js"
57
+ "devDependencies": {
58
+ "openapi-typescript": "7.13.0",
59
+ "typescript": "^5.9.3",
60
+ "openapi-fetch": "^0.17.0",
61
+ "yaml": "^2.8.1"
29
62
  },
30
- "./compute/v1": {
31
- "types": "./dist/compute/v1/index.d.ts",
32
- "default": "./dist/compute/v1/index.js"
63
+ "publishConfig": {
64
+ "access": "public"
33
65
  },
34
- "./iam/v1": {
35
- "types": "./dist/iam/v1/index.d.ts",
36
- "default": "./dist/iam/v1/index.js"
66
+ "peerDependencies": {
67
+ "openapi-fetch": ">=0.14"
37
68
  },
38
- "./monitoring/v1": {
39
- "types": "./dist/monitoring/v1/index.d.ts",
40
- "default": "./dist/monitoring/v1/index.js"
41
- },
42
- "./tunnel/v1": {
43
- "types": "./dist/tunnel/v1/index.d.ts",
44
- "default": "./dist/tunnel/v1/index.js"
45
- }
46
- },
47
- "files": [
48
- "dist"
49
- ],
50
- "sideEffects": false,
51
- "scripts": {
52
- "generate": "node scripts/generate.mjs",
53
- "build": "tsc -p tsconfig.build.json",
54
- "typecheck": "tsc -p tsconfig.json --noEmit",
55
- "prepublishOnly": "npm run build"
56
- },
57
- "devDependencies": {
58
- "openapi-typescript": "7.13.0",
59
- "typescript": "^5.9.3",
60
- "openapi-fetch": "^0.17.0",
61
- "yaml": "^2.8.1"
62
- },
63
- "publishConfig": {
64
- "access": "public"
65
- },
66
- "peerDependencies": {
67
- "openapi-fetch": ">=0.14"
68
- },
69
- "peerDependenciesMeta": {
70
- "openapi-fetch": {
71
- "optional": true
69
+ "peerDependenciesMeta": {
70
+ "openapi-fetch": {
71
+ "optional": true
72
+ }
72
73
  }
73
- }
74
74
  }