checkly 10.0.0-rc.2 → 10.0.0-rc.3

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.
Files changed (193) hide show
  1. package/README.md +10 -0
  2. package/dist/ai-context/public-skills/checkly/SKILL.md +16 -4
  3. package/dist/ai-context/skills-command/references/configure.md +1 -1
  4. package/dist/ai-context/skills-command/references/initialize.md +1 -1
  5. package/dist/auth/device-flow.d.ts +2 -1
  6. package/dist/auth/device-flow.js +9 -2
  7. package/dist/auth/device-flow.js.map +1 -1
  8. package/dist/commands/account/usage/projections.d.ts +16 -0
  9. package/dist/commands/account/usage/projections.js +39 -0
  10. package/dist/commands/account/usage/projections.js.map +1 -0
  11. package/dist/commands/account/usage/series.d.ts +7 -3
  12. package/dist/commands/account/usage/series.js +28 -86
  13. package/dist/commands/account/usage/series.js.map +1 -1
  14. package/dist/commands/account/usage/summary.d.ts +4 -1
  15. package/dist/commands/account/usage/summary.js +17 -26
  16. package/dist/commands/account/usage/summary.js.map +1 -1
  17. package/dist/commands/account/usage/term.d.ts +15 -0
  18. package/dist/commands/account/usage/term.js +31 -0
  19. package/dist/commands/account/usage/term.js.map +1 -0
  20. package/dist/commands/account/usage/terms.d.ts +4 -0
  21. package/dist/commands/account/usage/terms.js +17 -26
  22. package/dist/commands/account/usage/terms.js.map +1 -1
  23. package/dist/commands/authCommand.d.ts +10 -0
  24. package/dist/commands/authCommand.js +32 -6
  25. package/dist/commands/authCommand.js.map +1 -1
  26. package/dist/commands/baseCommand.d.ts +12 -0
  27. package/dist/commands/baseCommand.js +22 -0
  28. package/dist/commands/baseCommand.js.map +1 -1
  29. package/dist/commands/checks/delete.js +1 -1
  30. package/dist/commands/checks/delete.js.map +1 -1
  31. package/dist/commands/deploy.d.ts +0 -1
  32. package/dist/commands/deploy.js +50 -36
  33. package/dist/commands/deploy.js.map +1 -1
  34. package/dist/commands/login.d.ts +21 -1
  35. package/dist/commands/login.js +205 -54
  36. package/dist/commands/login.js.map +1 -1
  37. package/dist/commands/logout.js +1 -1
  38. package/dist/commands/logout.js.map +1 -1
  39. package/dist/commands/rca/run.js +1 -1
  40. package/dist/commands/rca/run.js.map +1 -1
  41. package/dist/commands/switch.d.ts +10 -1
  42. package/dist/commands/switch.js +54 -6
  43. package/dist/commands/switch.js.map +1 -1
  44. package/dist/commands/whoami.d.ts +8 -0
  45. package/dist/commands/whoami.js +55 -4
  46. package/dist/commands/whoami.js.map +1 -1
  47. package/dist/constants.d.ts +2 -0
  48. package/dist/constants.js +8 -0
  49. package/dist/constants.js.map +1 -1
  50. package/dist/constructs/alert-channel-subscription.d.ts +1 -0
  51. package/dist/constructs/alert-channel-subscription.js +4 -0
  52. package/dist/constructs/alert-channel-subscription.js.map +1 -1
  53. package/dist/constructs/alert-channel.js +8 -5
  54. package/dist/constructs/alert-channel.js.map +1 -1
  55. package/dist/constructs/api-check-bundle.d.ts +4 -124
  56. package/dist/constructs/api-check.d.ts +4 -106
  57. package/dist/constructs/browser-check-bundle.d.ts +4 -124
  58. package/dist/constructs/browser-check.d.ts +4 -103
  59. package/dist/constructs/check-codegen.d.ts +7 -0
  60. package/dist/constructs/check-codegen.js +17 -11
  61. package/dist/constructs/check-codegen.js.map +1 -1
  62. package/dist/constructs/check-group-v1.d.ts +9 -2
  63. package/dist/constructs/check-group-v1.js +13 -7
  64. package/dist/constructs/check-group-v1.js.map +1 -1
  65. package/dist/constructs/check-group-v2.d.ts +2 -1
  66. package/dist/constructs/check-group-v2.js +5 -1
  67. package/dist/constructs/check-group-v2.js.map +1 -1
  68. package/dist/constructs/check.d.ts +23 -188
  69. package/dist/constructs/check.js +32 -24
  70. package/dist/constructs/check.js.map +1 -1
  71. package/dist/constructs/construct.d.ts +5 -0
  72. package/dist/constructs/construct.js +11 -1
  73. package/dist/constructs/construct.js.map +1 -1
  74. package/dist/constructs/dashboard.js +11 -7
  75. package/dist/constructs/dashboard.js.map +1 -1
  76. package/dist/constructs/dns-monitor.d.ts +4 -100
  77. package/dist/constructs/grpc-monitor.d.ts +4 -100
  78. package/dist/constructs/icmp-monitor.d.ts +4 -100
  79. package/dist/constructs/internal/common-diagnostics.js +1 -3
  80. package/dist/constructs/internal/common-diagnostics.js.map +1 -1
  81. package/dist/constructs/internal/default-retry-strategy.d.ts +9 -0
  82. package/dist/constructs/internal/default-retry-strategy.js +13 -0
  83. package/dist/constructs/internal/default-retry-strategy.js.map +1 -0
  84. package/dist/constructs/maintenance-window.d.ts +6 -4
  85. package/dist/constructs/maintenance-window.js +3 -4
  86. package/dist/constructs/maintenance-window.js.map +1 -1
  87. package/dist/constructs/monitor.d.ts +5 -118
  88. package/dist/constructs/monitor.js +3 -5
  89. package/dist/constructs/monitor.js.map +1 -1
  90. package/dist/constructs/multi-step-check-bundle.d.ts +4 -109
  91. package/dist/constructs/multi-step-check.d.ts +4 -100
  92. package/dist/constructs/playwright-check-bundle.d.ts +6 -132
  93. package/dist/constructs/playwright-check-bundle.js +0 -3
  94. package/dist/constructs/playwright-check-bundle.js.map +1 -1
  95. package/dist/constructs/playwright-check.d.ts +5 -103
  96. package/dist/constructs/playwright-check.js +4 -2
  97. package/dist/constructs/playwright-check.js.map +1 -1
  98. package/dist/constructs/private-location-check-assignment.d.ts +1 -0
  99. package/dist/constructs/private-location-check-assignment.js +4 -0
  100. package/dist/constructs/private-location-check-assignment.js.map +1 -1
  101. package/dist/constructs/private-location-group-assignment.d.ts +1 -0
  102. package/dist/constructs/private-location-group-assignment.js +4 -0
  103. package/dist/constructs/private-location-group-assignment.js.map +1 -1
  104. package/dist/constructs/private-location.js +3 -1
  105. package/dist/constructs/private-location.js.map +1 -1
  106. package/dist/constructs/ssl-monitor.d.ts +4 -142
  107. package/dist/constructs/tcp-monitor.d.ts +4 -100
  108. package/dist/constructs/traceroute-monitor.d.ts +4 -100
  109. package/dist/constructs/url-monitor.d.ts +4 -121
  110. package/dist/formatters/render.d.ts +2 -1
  111. package/dist/formatters/render.js +2 -2
  112. package/dist/formatters/render.js.map +1 -1
  113. package/dist/formatters/usage.d.ts +18 -12
  114. package/dist/formatters/usage.js +285 -245
  115. package/dist/formatters/usage.js.map +1 -1
  116. package/dist/help/help-extension.js +2 -1
  117. package/dist/help/help-extension.js.map +1 -1
  118. package/dist/helpers/accounts.d.ts +19 -0
  119. package/dist/helpers/accounts.js +26 -0
  120. package/dist/helpers/accounts.js.map +1 -0
  121. package/dist/helpers/activate-account.d.ts +5 -6
  122. package/dist/helpers/activate-account.js +6 -7
  123. package/dist/helpers/activate-account.js.map +1 -1
  124. package/dist/helpers/command-style.js +11 -1
  125. package/dist/helpers/command-style.js.map +1 -1
  126. package/dist/helpers/usage.d.ts +51 -14
  127. package/dist/helpers/usage.js +188 -52
  128. package/dist/helpers/usage.js.map +1 -1
  129. package/dist/messages/common-messages.d.ts +1 -0
  130. package/dist/messages/common-messages.js +4 -2
  131. package/dist/messages/common-messages.js.map +1 -1
  132. package/dist/rest/api.d.ts +6 -4
  133. package/dist/rest/api.js +38 -21
  134. package/dist/rest/api.js.map +1 -1
  135. package/dist/rest/usage.d.ts +164 -73
  136. package/dist/rest/usage.js +21 -10
  137. package/dist/rest/usage.js.map +1 -1
  138. package/dist/services/check-parser/package-files/json-text-source-file.d.ts +0 -2
  139. package/dist/services/check-parser/package-files/json-text-source-file.js +6 -6
  140. package/dist/services/check-parser/package-files/json-text-source-file.js.map +1 -1
  141. package/dist/services/check-parser/parser.d.ts +3 -2
  142. package/dist/services/check-parser/parser.js +31 -40
  143. package/dist/services/check-parser/parser.js.map +1 -1
  144. package/dist/services/config.d.ts +23 -1
  145. package/dist/services/config.js +31 -5
  146. package/dist/services/config.js.map +1 -1
  147. package/dist/services/deploy-diff/double-check.d.ts +9 -0
  148. package/dist/services/deploy-diff/double-check.js +21 -0
  149. package/dist/services/deploy-diff/double-check.js.map +1 -0
  150. package/dist/services/deploy-diff/preview-output.js +8 -2
  151. package/dist/services/deploy-diff/preview-output.js.map +1 -1
  152. package/dist/services/deploy-diff/render.d.ts +6 -0
  153. package/dist/services/deploy-diff/render.js +11 -2
  154. package/dist/services/deploy-diff/render.js.map +1 -1
  155. package/dist/services/deploy-diff/shape-changes.d.ts +2 -2
  156. package/dist/services/deploy-diff/shape-changes.js +24 -11
  157. package/dist/services/deploy-diff/shape-changes.js.map +1 -1
  158. package/dist/services/deploy-diff/source-index.d.ts +1 -1
  159. package/dist/services/oxc-parser.d.ts +26 -0
  160. package/dist/services/oxc-parser.js +70 -0
  161. package/dist/services/oxc-parser.js.map +1 -0
  162. package/dist/services/socket-client.js +1 -1
  163. package/dist/services/socket-client.js.map +1 -1
  164. package/dist/services/test-runner.js +1 -6
  165. package/dist/services/test-runner.js.map +1 -1
  166. package/dist/services/test-session-cancel.js +23 -5
  167. package/dist/services/test-session-cancel.js.map +1 -1
  168. package/dist/services/write-back/apply-edits.d.ts +1 -1
  169. package/dist/services/write-back/imports.js +9 -3
  170. package/dist/services/write-back/imports.js.map +1 -1
  171. package/dist/services/write-back/literal-edit.d.ts +1 -1
  172. package/dist/services/write-back/literal-edit.js +3 -3
  173. package/dist/services/write-back/literal-edit.js.map +1 -1
  174. package/dist/services/write-back/plan.d.ts +7 -0
  175. package/dist/services/write-back/plan.js +102 -24
  176. package/dist/services/write-back/plan.js.map +1 -1
  177. package/dist/services/write-back/source-file.d.ts +23 -8
  178. package/dist/services/write-back/source-file.js +81 -53
  179. package/dist/services/write-back/source-file.js.map +1 -1
  180. package/dist/testing/clear-git-env.d.ts +1 -0
  181. package/dist/testing/clear-git-env.js +25 -0
  182. package/dist/testing/clear-git-env.js.map +1 -0
  183. package/dist/testing/global-setup.d.ts +1 -0
  184. package/dist/testing/global-setup.js +3 -0
  185. package/dist/testing/global-setup.js.map +1 -1
  186. package/oclif.manifest.json +421 -267
  187. package/package.json +4 -2
  188. package/dist/services/check-parser/package-files/json-text-source-file-parser.d.ts +0 -7
  189. package/dist/services/check-parser/package-files/json-text-source-file-parser.js +0 -47
  190. package/dist/services/check-parser/package-files/json-text-source-file-parser.js.map +0 -1
  191. package/dist/services/check-parser/package-files/source-file-parser.d.ts +0 -10
  192. package/dist/services/check-parser/package-files/source-file-parser.js +0 -13
  193. package/dist/services/check-parser/package-files/source-file-parser.js.map +0 -1
package/README.md CHANGED
@@ -89,6 +89,16 @@ npm install --save-dev checkly
89
89
 
90
90
  Official docs are over at [checklyhq.com/docs/cli](https://checklyhq.com/docs/cli/)
91
91
 
92
+ ## Account usage in v10
93
+
94
+ Migration from v9:
95
+
96
+ - Summary JSON renames `totals.credits.used` to `totals.creditsUsed` and removes `totals.credits.percentOfBudget` and embedded `projections`. Get forecasts with `checkly account usage projections <id>`.
97
+ - Summary and series expose `usageTermsIds` instead of `usageTermsId`. Series replaces `warnings` with `coverage.gaps`.
98
+ - Terms and series JSON use `{ data, pagination: { nextId, length } }`. Terms default to table output; use `term <id>` for detail.
99
+ - `--from` and `--to` bound an inclusive UTC range. On `terms`, they select overlapping contracts rather than one contract covering `--to`.
100
+ - `--check-type` is removed. Use `--pricing-rule` to select charges or `series --group-by checkType` for a check-type breakdown.
101
+
92
102
  # AI Agents & Coding Assistants
93
103
 
94
104
  The Checkly CLI is designed with AI-powered development in mind. With [**Monitoring as Code**](https://www.checklyhq.com/docs/concepts/monitoring-as-code/), your entire monitoring setup lives in TypeScript files — perfect for AI agents that can read, write, and reason about code.
@@ -30,15 +30,27 @@ Two rules that survive any fallback:
30
30
 
31
31
  `npx checkly login` needs no terminal, and any command that requires authentication starts it for you when no credentials are stored, so you rarely run it by hand. It prints one JSON line and exits; when another command started it, the line goes to stderr. Relay what it says; never guess:
32
32
 
33
- - `{"status":"action_required","reason":"login_required","verification_uri_complete":…,"user_code":…,"expires_in":…}` — a human must approve. Give the user the URL and the code (valid for `expires_in` seconds). Users without a Checkly account can sign up on the same page. Once they say they are done, run the same command again: it picks up the approval. (When another command started the login, run that command again; it picks up the approval and does its work.) Running it earlier shows the code again (or a new one when the old one is about to expire); always relay the latest `user_code`. Until the login is done, don't run several Checkly commands in parallel.
33
+ - `{"status":"action_required","reason":"login_required","verification_uri_complete":…,"user_code":…,"expires_in":…}` — a human must approve. Give the user the URL and the code (valid for `expires_in` seconds). Users without a Checkly account can sign up on the same page. Then, without waiting for the user to say they are done, run the first `next` command (`npx checkly login --wait`): it returns once they have approved, with the line below. Run it in the background: it can wait up to `expires_in` seconds, often longer than your shell's command timeout. If it is stopped before the user approves, run it again; the same code stays valid. (When another command started the login, run that command again afterwards, as the second `next` entry says.) A run without `--wait` before the approval shows the code again (or a new one when the old one is about to expire); always relay the latest `user_code`. Until the login is done, don't run several Checkly commands in parallel.
34
34
  - If the line has a `verification_uri` but no `user_code`, the URL must be opened on the same machine as the CLI, and the command waits for it instead of exiting: run it in the background so you can relay the URL.
35
35
  - If it has no URL and its `next` has no `when`, run that command now, in the background, relay what it prints, and run the original command again once the user is done (running it earlier only repeats this line).
36
- - `{"status":"action_required","reason":"select_account","choices":[…],"next":[…]}` — the key is stored, but the user belongs to several accounts. Ask the user which one (or use an id they already gave you) and run `npx checkly login --account-id <id>`. Never pick one yourself, even if you cannot ask: stop and say which accounts are available. There is no second browser step. The same command switches accounts later.
37
- - `{"status":"success","reason":…,"message":…,"accountId":…,"accountName":…}` — done. Tell the user which account you are on.
38
- - `{"status":"error","reason":…,"message":…}` — report the message; do not retry in a loop. `reason` is one of `access_denied`, `expired_token`, `code_used` (run the login again for a new code), `account_not_found`, `no_accounts`, `invalid_response`, `network_error` (the login server could not be reached), `api_error`, `env_credentials` (credentials are set in the environment; the user must remove them to log in) or `login_failed`. To log in as a different user, run `npx checkly logout` first.
36
+ - `{"status":"action_required","reason":"select_account","choices":[…],"next":[…]}` — the key is stored, but the user belongs to several accounts. No account is the default yet, so every command stops here until one is chosen or named. Ask the user which one, unless they already named it: an account name or id they gave you that matches exactly one entry in `choices` counts as their choice. Never pick one yourself, even if you cannot ask: stop and say which accounts are available. There is no second browser step. Then either:
37
+ - run `npx checkly login --account-id <id>` to make it the default for later commands, or
38
+ - put `CHECKLY_ACCOUNT_ID=<id>` in front of a command to run just that command against the account (see "Working with several accounts" below).
39
+ - `{"status":"success","reason":…,"message":…,"accountId":…,"accountName":…,"defaultAccount":…}` — done. `defaultAccount` is the stored default (`null` when none is stored); while `CHECKLY_ACCOUNT_ID` is set, commands use that account instead, as the message says. Tell the user which account you are on.
40
+ - `{"status":"error","reason":…,"message":…}` — report the message; do not retry in a loop. `reason` is one of `access_denied`, `expired_token`, `code_used` (run the login again for a new code), `account_not_found`, `no_accounts`, `invalid_response`, `network_error` (the login server could not be reached), `api_error`, `env_credentials` (`CHECKLY_API_KEY` is set, so API key credentials are in use; the user must remove them to log in) or `login_failed`. To log in as a different user, run `npx checkly logout` first.
39
41
 
40
42
  On a host without a browser set `CHECKLY_NO_BROWSER=1` so the CLI does not try to open one; the URL and code are printed regardless. The flag forms are `--account-id` and `--no-browser`.
41
43
 
44
+ ### Working with several accounts
45
+
46
+ A `checkly login` belongs to the user, not to one account, so it works with every account they belong to. The default account is the one commands use unless told otherwise.
47
+
48
+ - **List accounts:** `npx checkly whoami` names the account in use, the default and the user's other accounts. `--output json` adds `accountSource` (`login`: the default; `account_override`: `CHECKLY_ACCOUNT_ID` picks the account; `environment`: API key credentials via `CHECKLY_API_KEY`, which belong to one account) and `defaultAccount` (`null` for API key credentials, and while `CHECKLY_ACCOUNT_ID` picks the account and no default is chosen yet; without either, commands stop at `select_account` instead).
49
+ - **Use another account for one command:** put `CHECKLY_ACCOUNT_ID=<id>` in front of it (`CHECKLY_ACCOUNT_ID=<id> npx checkly test-sessions get <id>`). It uses the stored login and leaves the default as it is. Prefer this when a task touches an account other than the default (e.g. a CI test session in another account), so you don't change the default behind the user's back. Without a stored login, the command logs in first (relay the code as above) and then uses that account, without storing a default. An id that is not one of the user's accounts fails with the list of the accounts the login works with.
50
+ - **`CHECKLY_ACCOUNT_ID` in the shell or `.env`:** without `CHECKLY_API_KEY`, it works like the prefix for every command until it is unset, whatever the default is. A login then needs no account choice: commands use that account, and no default is stored. A prefix on the command line wins over the value in `.env` (`.env` never overrides a variable that is already set). `whoami` says so; `login` and `switch` warn that it takes precedence over the default they store. If the user wants the default to apply, they have to remove it (a project may keep it in `.env` on purpose, to pin that project to an account).
51
+ - **Change the default:** only when the user asks for it, run `npx checkly switch --account-id <id>`. It applies at once (no confirmation step, nothing to undo but switching back) and prints a plain `Account switched to …` line; check with `npx checkly whoami`. Without `--account-id`, `switch` prints a `select_account` line with the stored `defaultAccount` (or `null`) and the `choices`.
52
+ - **Not found?** When a lookup by ID finds nothing, the message names the account that was searched; with `--output json` the error also has `hint` and `searchedAccount` fields. If the resource may be in another account, run the command again with `CHECKLY_ACCOUNT_ID=<id>` for each likely account.
53
+
42
54
  ## Always load the current action list first
43
55
 
44
56
  **Required:** Before answering any Checkly question, run `npx checkly skills` to get the current and up-to-date action list. Do not rely on memory or prior context — the CLI is the source of truth and actions might change between releases. `npx checkly skills` runs locally — it needs no authentication or API access, so it works before you've established your path above.
@@ -163,7 +163,7 @@ Run `npx checkly skills manage plan` for the full reference.
163
163
  - A resource Checkly has no baseline for (for example every resource already deployed on a project's first planned `checkly deploy` or on the first after any deploy with `--no-plan`, one added with `checkly import`, or one whose stored baseline a Checkly update made unusable) is written once to set it. When nothing differs the plan lists it with the marker `=` after the resources it changes, counts it as `to set a baseline` rather than `to update`, and a note under the overview explains the marker; the `confirmation_required` envelope names it `Set a baseline for <Type>: <id>`. When something differs it is an ordinary update with its diff. Such an entry carries `basis: "live"` in the machine-readable plan, and its list of changes is not exhaustive: a value set only in Checkly, on a property the code does not set, may be reset without being shown. Later deploys show and write only what changed.
164
164
  - Use `--preview` to see which resources a deploy would create, update or delete, without applying it. It also shows the resources the deploy would keep as they are and a diff of each updated resource's construct as deployed against as in code, and a plain interactive `checkly deploy` prints that same preview before asking the user to apply the changes or cancel. The machine-readable forms (`--dry-run`, and the `confirmation_required` envelope) additionally carry the individual properties that would change; with `--no-plan` they list the deploy's options and the resources it would delete.
165
165
  - When the preview shows a resource that was edited outside the project (in the web app or through the API), an interactive `checkly deploy` offers a third choice next to apply and cancel: update the code with the values from Checkly and deploy nothing. It exists only in a terminal; there is no flag for it, and the `confirmation_required` envelope is unchanged.
166
- - It rewrites literal values (strings, numbers, booleans, and arrays or objects of those; a multi-line string over a template literal is written as a template literal) and the helper-spelled properties `frequency` (`Frequency.EVERY_5M`), `retryStrategy` (`RetryStrategyBuilder`), `alertEscalationPolicy` (`AlertEscalationBuilder`) and `assertions` (the class's assertion builder) inside the `new SomeConstruct('id', { … })` call, adds a helper's import when the file lacks it, and leaves the rest of the file untouched. Covered: checks and check groups (including `runtimeId` on runtime checks and groups, the `request` of every check and monitor type, `sslCheckDomain` and `aiAutoRepairEnabled` on browser checks, and `aiAutoRepairEnabled` on multistep checks), alert channels of every type, private locations, dashboards, maintenance windows (`repeatInterval` and `repeatUnit` together), status pages (v2 and v3, each theme colour under an existing `themeColors.light`/`.dark`), status page services, v3 components and automation rules.
166
+ - It rewrites literal values (strings, numbers, booleans, and arrays or objects of those; a multi-line string over a template literal is written as a template literal) and the helper-spelled properties `frequency` (`Frequency.EVERY_5M`), `retryStrategy` (`RetryStrategyBuilder`), `alertEscalationPolicy` (`AlertEscalationBuilder`) and `assertions` (the class's assertion builder) inside the `new SomeConstruct('id', { … })` call, adds a helper's import when the file lacks it, and leaves the rest of the file untouched. Covered: checks and check groups (including `runtimeId` on runtime checks and groups, the `request` of every check and monitor type, `intent` on every check and monitor that takes one, `sslCheckDomain` and `aiAutoRepairEnabled` on browser checks, and `aiAutoRepairEnabled` on multistep checks), alert channels of every type, private locations, dashboards, maintenance windows (`repeatInterval` and `repeatUnit` together), status pages (v2 and v3, each theme colour under an existing `themeColors.light`/`.dark`), status page services, v3 components and automation rules.
167
167
  - It lists everything it could not update with the reason: references to other resources, secrets (a credential such as a webhook URL or API key is never written), scripts, a dashboard's `customCSS`, an incident trigger, an alert channel's type or a webhook-based channel's fixed type and method, Telegram's packed template, a helper call holding a variable, a check moved to the global alert policy, which needs `alertEscalationPolicy` removed by hand.
168
168
  - Use `--prune-relations` to also delete the alert channel subscriptions and private location assignments on this project's checks and groups that the project does not manage. Without it they are only reported. Not available with `--no-plan`.
169
169
 
@@ -115,7 +115,7 @@ If the user is logged in, verify the information and if it's the correct account
115
115
 
116
116
  If the user is NOT logged in, run the login yourself unless the user prefers API keys:
117
117
 
118
- - **Option A: `npx checkly login`** — Works for agents. It prints a JSON `action_required` line with a URL and a short code and exits: give both to the user, and once they have approved, run it again. With several accounts it stops at a `select_account` line listing them; ask the user which one and run `npx checkly login --account-id <id>`. Details are in the skill's "Logging in as an agent" section. Any authenticated command starts this flow on its own when no credentials are stored.
118
+ - **Option A: `npx checkly login`** — Works for agents. It prints a JSON `action_required` line with a URL and a short code and exits: give both to the user, then run `npx checkly login --wait`, which returns once they have approved. With several accounts it stops at a `select_account` line listing them; ask the user which one and run `npx checkly login --account-id <id>`. Details are in the skill's "Logging in as an agent" section. Any authenticated command starts this flow on its own when no credentials are stored. To pin this project to one account, put `CHECKLY_ACCOUNT_ID=<id>` (without `CHECKLY_API_KEY`) in its `.env`.
119
119
  - **Option B: Environment variables** — For CI/CD, or when the user prefers keys: they set `CHECKLY_API_KEY` and `CHECKLY_ACCOUNT_ID` (API keys are created at https://app.checklyhq.com/accounts/settings/user/api-keys). Once both are set, re-run `npx checkly whoami` to verify.
120
120
 
121
121
  #### Step 6: Summarize and test the new monitoring configuration
@@ -39,7 +39,8 @@ export declare class DeviceFlow {
39
39
  * coming from something other than the login server (a proxy or captive
40
40
  * portal), `onUnexpectedAnswers` is called once per such run with the latest one, and
41
41
  * polling goes on: the user may still be getting past a captive portal,
42
- * and the code stays valid.
42
+ * and the code stays valid. If the code expires during such a run, the
43
+ * error is a `network_error` rather than `expired_token`.
43
44
  */
44
45
  pollForTokens(auth: DeviceAuthorization, { onUnexpectedAnswers }?: {
45
46
  onUnexpectedAnswers?: (failure: string) => void;
@@ -134,7 +134,8 @@ export class DeviceFlow {
134
134
  * coming from something other than the login server (a proxy or captive
135
135
  * portal), `onUnexpectedAnswers` is called once per such run with the latest one, and
136
136
  * polling goes on: the user may still be getting past a captive portal,
137
- * and the code stays valid.
137
+ * and the code stays valid. If the code expires during such a run, the
138
+ * error is a `network_error` rather than `expired_token`.
138
139
  */
139
140
  async pollForTokens(auth, { onUnexpectedAnswers } = {}) {
140
141
  const params = tokenParams(auth);
@@ -157,7 +158,13 @@ export class DeviceFlow {
157
158
  }
158
159
  }
159
160
  // A code the user approved can still expire here when the login server
160
- // was unreachable at the end; say so rather than blaming the user.
161
+ // was unreachable at the end; say so rather than blaming the user. While
162
+ // something else kept answering for it, the connection is the problem.
163
+ if (unexpectedInARow >= MAX_UNEXPECTED_RESPONSES) {
164
+ throw new DeviceFlowError('network_error', 'The login code expired while the answers to the login server '
165
+ + `kept coming from something else (${lastFailure}); a proxy or captive portal may be in the way. `
166
+ + 'Fix the connection and run the login again.');
167
+ }
161
168
  throw new DeviceFlowError('expired_token', lastFailure
162
169
  ? `The login code expired; the last attempt to reach the login server failed (${lastFailure}). `
163
170
  + 'Please run the login again.'
@@ -1 +1 @@
1
- {"version":3,"file":"device-flow.js","sourceRoot":"","sources":["../../src/auth/device-flow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,MAAM,MAAM,uBAAuB,CAAA;AAE1C,kFAAkF;AAClF,gFAAgF;AAChF,8EAA8E;AAC9E,wEAAwE;AAExE,MAAM,CAAC,MAAM,eAAe,GAAG,kCAAkC,CAAA;AAEjE,MAAM,aAAa,GAAG,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAA;AACtE,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,EAAE,cAAc,CAAA;AAC3D,MAAM,YAAY,GAAG,sBAAsB,CAAA;AAC3C,MAAM,iBAAiB,GAAG,8CAA8C,CAAA;AACx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+1,16 @@
1
+ import { AuthCommand } from '../../authCommand.js';
2
+ export default class UsageProjectionsCommand extends AuthCommand {
3
+ static hidden: boolean;
4
+ static readOnly: boolean;
5
+ static destructive: boolean;
6
+ static idempotent: boolean;
7
+ static description: string;
8
+ static args: {
9
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ };
11
+ static flags: {
12
+ 'as-of': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,39 @@
1
+ import { Args, Flags } from '@oclif/core';
2
+ import { AuthCommand } from '../../authCommand.js';
3
+ import { outputFlag } from '../../../helpers/flags.js';
4
+ import { describeUsageError, projectionsParams, validateUsageTermId } from '../../../helpers/usage.js';
5
+ import * as api from '../../../rest/api.js';
6
+ import { formatUsageProjections } from '../../../formatters/usage.js';
7
+ export default class UsageProjectionsCommand extends AuthCommand {
8
+ static hidden = false;
9
+ static readOnly = true;
10
+ static destructive = false;
11
+ static idempotent = true;
12
+ static description = 'Project credit consumption for one usage term through a completed UTC day.';
13
+ static args = { id: Args.string({ description: 'Usage term UUID.', required: true }) };
14
+ static flags = {
15
+ 'as-of': Flags.string({
16
+ description: 'Inclusive completed UTC date (YYYY-MM-DD). Defaults to yesterday UTC; today and future rejected.',
17
+ }),
18
+ 'output': outputFlag({ default: 'detail' }),
19
+ };
20
+ async run() {
21
+ const { args, flags } = await this.parse(UsageProjectionsCommand);
22
+ this.style.outputFormat = flags.output;
23
+ try {
24
+ const id = validateUsageTermId(args.id);
25
+ const { data: projections } = await api.usage.getProjections(id, projectionsParams(flags));
26
+ if (flags.output === 'json') {
27
+ this.log(JSON.stringify(projections, null, 2));
28
+ return;
29
+ }
30
+ const term = await api.usage.getTerm(id).then(response => response.data).catch(() => undefined);
31
+ this.log(formatUsageProjections(projections, flags.output === 'md' ? 'md' : 'terminal', term));
32
+ }
33
+ catch (err) {
34
+ this.style.longError('Failed to load usage projections.', describeUsageError(err, { termId: args.id }));
35
+ process.exitCode = 1;
36
+ }
37
+ }
38
+ }
39
+ //# sourceMappingURL=projections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projections.js","sourceRoot":"","sources":["../../../../src/commands/account/usage/projections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AACtG,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAErE,MAAM,CAAC,OAAO,OAAO,uBAAwB,SAAQ,WAAW;IAC9D,MAAM,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAA;IACtB,MAAM,CAAC,WAAW,GAAG,KAAK,CAAA;IAC1B,MAAM,CAAC,UAAU,GAAG,IAAI,CAAA;IACxB,MAAM,CAAC,WAAW,GAAG,4EAA4E,CAAA;IACjG,MAAM,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;IACtF,MAAM,CAAC,KAAK,GAAG;QACb,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC;YACpB,WAAW,EAAE,kGAAkG;SAChH,CAAC;QACF,QAAQ,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;KAC5C,CAAA;IAED,KAAK,CAAC,GAAG;QACP,MAA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
2
  export default class UsageSeriesCommand extends AuthCommand {
3
3
  static hidden: boolean;
4
4
  static readOnly: boolean;
5
+ static destructive: boolean;
5
6
  static idempotent: boolean;
6
7
  static description: string;
7
8
  static flags: {
8
- interval: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ interval: import("@oclif/core/interfaces").OptionFlag<"month" | "week" | "day" | "total">;
9
11
  'group-by': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
12
+ include: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
13
  limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
14
  cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
15
  from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
+ to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ 'usage-terms-id': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
18
  'account-id': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ 'pricing-rule': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
15
20
  'check-type': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
16
- to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
21
  };
18
22
  run(): Promise<void>;
19
23
  }
@@ -1,110 +1,52 @@
1
- import { Flags } from '@oclif/core';
2
1
  import { AuthCommand } from '../../authCommand.js';
3
2
  import { outputFlag } from '../../../helpers/flags.js';
4
- import { validateIntegerRange } from '../../../helpers/number.js';
5
- import { describeUsageError, usageRangeFlags, usageRangeParams, usageTermsParams } from '../../../helpers/usage.js';
3
+ import { describeUsageError, loadUsageNames, usageSeriesFlags, usageSeriesParams } from '../../../helpers/usage.js';
6
4
  import * as api from '../../../rest/api.js';
7
- import { USAGE_GROUP_BY, USAGE_INTERVALS } from '../../../rest/usage.js';
8
- import { formatUsageSeries, formatUsageSeriesNavigationHints, formatUsageSeriesPaginationInfo, formatUsageWarnings, } from '../../../formatters/usage.js';
9
- // The API binds the cursor to every resolved query param, so the hint must
10
- // repeat the flags verbatim. Values are validated enums, dates, and IDs.
11
- function buildSeriesCommand(flags) {
12
- const parts = [
13
- 'checkly account usage series',
14
- '--interval', flags.interval,
15
- '--group-by', flags['group-by'],
16
- '--limit', String(flags.limit),
17
- ];
18
- if (flags.from)
19
- parts.push('--from', flags.from);
20
- if (flags.to)
21
- parts.push('--to', flags.to);
22
- for (const accountId of flags['account-id'] ?? [])
23
- parts.push('--account-id', accountId);
24
- for (const checkType of flags['check-type'] ?? [])
25
- parts.push('--check-type', checkType);
26
- return parts.join(' ');
27
- }
5
+ import { heading } from '../../../formatters/render.js';
6
+ import { formatUsageCoverage, formatUsageSeries, formatUsagePaginationInfo, formatUsageNavigationHints, usageListCommand, } from '../../../formatters/usage.js';
28
7
  export default class UsageSeriesCommand extends AuthCommand {
29
8
  static hidden = false;
30
9
  static readOnly = true;
10
+ static destructive = false;
31
11
  static idempotent = true;
32
- static description = 'List organization usage per period, grouped by account and/or check type.';
33
- static flags = {
34
- ...usageRangeFlags(),
35
- 'interval': Flags.string({
36
- description: 'Aggregation interval for each row.',
37
- options: USAGE_INTERVALS,
38
- default: 'day',
39
- }),
40
- 'group-by': Flags.string({
41
- description: 'Dimensions to group rows by.',
42
- options: USAGE_GROUP_BY,
43
- default: 'account,checkType',
44
- }),
45
- 'limit': Flags.integer({
46
- char: 'l',
47
- description: 'Number of rows to return (1-500).',
48
- default: 100,
49
- }),
50
- 'cursor': Flags.string({
51
- description: 'Cursor for the next page (from previous output). Re-use the same flags it was issued with.',
52
- }),
53
- 'output': outputFlag({ default: 'table' }),
54
- };
12
+ static description = 'List usage credits per period with composable grouping and optional runs or calculations.';
13
+ static flags = { ...usageSeriesFlags(), output: outputFlag({ default: 'table' }) };
55
14
  async run() {
56
15
  const { flags } = await this.parse(UsageSeriesCommand);
57
16
  this.style.outputFormat = flags.output;
58
17
  try {
59
- // Account names only matter for the human views, and they come from the terms.
60
- const wantsAccountNames = flags.output !== 'json' && flags['group-by'].includes('account');
61
- const [{ data: series }, terms] = await Promise.all([
62
- api.usage.getSeries({
63
- ...usageRangeParams(flags),
64
- interval: flags.interval,
65
- groupBy: flags['group-by'],
66
- limit: validateIntegerRange(flags.limit, '--limit', 1, 500),
67
- nextId: flags.cursor,
68
- }),
69
- wantsAccountNames ? api.usage.getTerms(usageTermsParams(flags)) : undefined,
70
- ]);
18
+ const params = usageSeriesParams(flags);
19
+ const { data: series } = await api.usage.getSeries(params);
71
20
  if (flags.output === 'json') {
72
21
  this.log(JSON.stringify({
73
22
  data: series.data,
74
- pagination: { nextId: series.nextId, length: series.length },
75
- usageTermsId: series.usageTermsId,
23
+ pagination: { nextId: series.nextId, length: series.data.length },
76
24
  period: series.period,
77
- warnings: series.warnings,
25
+ usageTermsIds: series.usageTermsIds,
26
+ interval: series.interval,
27
+ groupBy: series.groupBy,
28
+ coverage: series.coverage,
78
29
  }, null, 2));
79
30
  return;
80
31
  }
32
+ const wantsNames = series.data.length > 0
33
+ && (series.groupBy.includes('account') || series.groupBy.includes('usageTerm'));
34
+ const names = wantsNames ? await loadUsageNames(series.usageTermsIds, series.period) : undefined;
81
35
  const fmt = flags.output === 'md' ? 'md' : 'terminal';
82
- const output = [];
83
- const warnings = formatUsageWarnings(series.warnings, fmt);
84
- if (warnings)
85
- output.push(warnings, '');
86
- if (series.length === 0) {
87
- output.push('No usage rows found for the requested range.');
88
- this.log(output.join('\n'));
89
- return;
90
- }
91
- const { interval, groupBy } = series.period;
92
- const accountNames = terms && new Map(terms.data.accounts.map(account => [account.id, account.name]));
93
- output.push(formatUsageSeries(series.data, fmt, { interval, groupBy, accountNames }));
94
- if (fmt === 'md') {
95
- if (series.nextId)
96
- output.push('', `Next page cursor: \`${series.nextId}\``);
97
- this.log(output.join('\n'));
98
- return;
99
- }
100
- output.push('', formatUsageSeriesPaginationInfo(series.length, series.nextId));
101
- const hints = formatUsageSeriesNavigationHints(series.nextId, buildSeriesCommand(flags));
102
- if (hints)
103
- output.push('', hints);
104
- this.log(output.join('\n'));
36
+ const pinned = { ...params, ...series.period, interval: series.interval, groupBy: series.groupBy };
37
+ this.log([
38
+ fmt === 'md' ? heading('Usage series', 1, fmt) : '',
39
+ formatUsageCoverage(series.coverage, fmt),
40
+ fmt === 'md' ? heading('Usage rows', 2, fmt) : '',
41
+ formatUsageSeries(series.data, fmt, {
42
+ interval: series.interval, groupBy: series.groupBy, include: params.include ?? [], names,
43
+ }),
44
+ formatUsagePaginationInfo(series.data.length, series.nextId, 'usage row'),
45
+ formatUsageNavigationHints(series.nextId, usageListCommand('series', pinned, fmt), fmt),
46
+ ].filter(Boolean).join('\n\n'));
105
47
  }
106
48
  catch (err) {
107
- this.style.longError('Failed to load usage series.', describeUsageError(err, { to: flags.to }) ?? err);
49
+ this.style.longError('Failed to load usage series.', describeUsageError(err));
108
50
  process.exitCode = 1;
109
51
  }
110
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"series.js","sourceRoot":"","sources":["../../../../src/commands/account/usage/series.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA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AAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,CAAA;YAClG,IAAI,CAAC,GAAG,CAAC;gBACP,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;gBACnD,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,CAAC;gBACzC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;gBACjD,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE;oBAClC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE,KAAK;iBACzF,CAAC;gBACF,yBAAyB,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;gBACzE,0BAA0B,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC;aACxF,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;QACjC,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,8BAA8B,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAA;YAC7E,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC"}
@@ -2,14 +2,17 @@ import { AuthCommand } from '../../authCommand.js';
2
2
  export default class UsageSummaryCommand extends AuthCommand {
3
3
  static hidden: boolean;
4
4
  static readOnly: boolean;
5
+ static destructive: boolean;
5
6
  static idempotent: boolean;
6
7
  static description: string;
7
8
  static flags: {
8
9
  output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
9
10
  from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ 'usage-terms-id': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
13
  'account-id': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
14
+ 'pricing-rule': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
15
  'check-type': import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
- to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
13
16
  };
14
17
  run(): Promise<void>;
15
18
  }
@@ -1,49 +1,40 @@
1
1
  import { AuthCommand } from '../../authCommand.js';
2
2
  import { outputFlag } from '../../../helpers/flags.js';
3
- import { describeUsageError, usageRangeFlags, usageRangeParams, usageTermsParams } from '../../../helpers/usage.js';
3
+ import { describeUsageError, usageRangeFlags, usageRangeParams } from '../../../helpers/usage.js';
4
4
  import * as api from '../../../rest/api.js';
5
5
  import { renderCommandHints } from '../../../formatters/render.js';
6
- import { formatUsageSummary } from '../../../formatters/usage.js';
6
+ import { formatUsageSummary, usageListCommand } from '../../../formatters/usage.js';
7
7
  export default class UsageSummaryCommand extends AuthCommand {
8
8
  static hidden = false;
9
9
  static readOnly = true;
10
+ static destructive = false;
10
11
  static idempotent = true;
11
- static description = 'Show organization usage totals for a date range, plus credit projections as of today.';
12
- static flags = {
13
- ...usageRangeFlags(),
14
- output: outputFlag({ default: 'detail' }),
15
- };
12
+ static description = 'Show usage credits, pricing breakdowns, and coverage gaps across selected terms.';
13
+ static flags = { ...usageRangeFlags(), output: outputFlag({ default: 'detail' }) };
16
14
  async run() {
17
15
  const { flags } = await this.parse(UsageSummaryCommand);
18
16
  this.style.outputFormat = flags.output;
19
17
  try {
18
+ const params = usageRangeParams(flags);
19
+ const { data: summary } = await api.usage.getSummary(params);
20
20
  if (flags.output === 'json') {
21
- const { data: summary } = await api.usage.getSummary(usageRangeParams(flags));
22
21
  this.log(JSON.stringify(summary, null, 2));
23
22
  return;
24
23
  }
25
- // The summary carries no organization name or budget; the terms do.
26
- const [{ data: summary }, { data: terms }] = await Promise.all([
27
- api.usage.getSummary(usageRangeParams(flags)),
28
- api.usage.getTerms(usageTermsParams(flags)),
29
- ]);
30
24
  const fmt = flags.output === 'md' ? 'md' : 'terminal';
31
- if (fmt === 'md') {
32
- this.log(formatUsageSummary(summary, fmt, terms));
33
- return;
25
+ const output = [formatUsageSummary(summary, fmt)];
26
+ if (fmt === 'terminal') {
27
+ output.push(renderCommandHints([
28
+ { label: 'Daily series', command: usageListCommand('series', {
29
+ ...params, ...summary.period, interval: 'day', groupBy: ['account', 'checkType'],
30
+ }) },
31
+ { label: 'Terms', command: 'checkly account usage terms' },
32
+ ], { gap: 1 }));
34
33
  }
35
- const output = [];
36
- output.push(formatUsageSummary(summary, fmt, terms));
37
- output.push('');
38
- output.push(renderCommandHints([
39
- { label: 'Daily series', command: 'checkly account usage series --interval day' },
40
- { label: 'Monthly by account', command: 'checkly account usage series --interval month --group-by account' },
41
- { label: 'Terms', command: 'checkly account usage terms' },
42
- ], { gap: 1 }));
43
- this.log(output.join('\n'));
34
+ this.log(output.join('\n\n'));
44
35
  }
45
36
  catch (err) {
46
- this.style.longError('Failed to load usage summary.', describeUsageError(err, { to: flags.to }) ?? err);
37
+ this.style.longError('Failed to load usage summary.', describeUsageError(err));
47
38
  process.exitCode = 1;
48
39
  }
49
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"summary.js","sourceRoot":"","sources":["../../../../src/commands/account/usage/summary.ts"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}
@@ -0,0 +1,15 @@
1
+ import { AuthCommand } from '../../authCommand.js';
2
+ export default class UsageTermCommand extends AuthCommand {
3
+ static hidden: boolean;
4
+ static readOnly: boolean;
5
+ static destructive: boolean;
6
+ static idempotent: boolean;
7
+ static description: string;
8
+ static args: {
9
+ id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
+ };
11
+ static flags: {
12
+ output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
13
+ };
14
+ run(): Promise<void>;
15
+ }
@@ -0,0 +1,31 @@
1
+ import { Args } from '@oclif/core';
2
+ import { AuthCommand } from '../../authCommand.js';
3
+ import { outputFlag } from '../../../helpers/flags.js';
4
+ import { describeUsageError, validateUsageTermId } from '../../../helpers/usage.js';
5
+ import * as api from '../../../rest/api.js';
6
+ import { formatUsageTermDetail } from '../../../formatters/usage.js';
7
+ export default class UsageTermCommand extends AuthCommand {
8
+ static hidden = false;
9
+ static readOnly = true;
10
+ static destructive = false;
11
+ static idempotent = true;
12
+ static description = 'Show one usage term with pricing rules and covered accounts.';
13
+ static args = { id: Args.string({ description: 'Usage term UUID.', required: true }) };
14
+ static flags = { output: outputFlag({ default: 'detail' }) };
15
+ async run() {
16
+ const { args, flags } = await this.parse(UsageTermCommand);
17
+ this.style.outputFormat = flags.output;
18
+ try {
19
+ const id = validateUsageTermId(args.id);
20
+ const { data: term } = await api.usage.getTerm(id);
21
+ this.log(flags.output === 'json'
22
+ ? JSON.stringify(term, null, 2)
23
+ : formatUsageTermDetail(term, flags.output === 'md' ? 'md' : 'terminal'));
24
+ }
25
+ catch (err) {
26
+ this.style.longError('Failed to load usage term.', describeUsageError(err, { termId: args.id }));
27
+ process.exitCode = 1;
28
+ }
29
+ }
30
+ }
31
+ //# sourceMappingURL=term.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"term.js","sourceRoot":"","sources":["../../../../src/commands/account/usage/term.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,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AAK,CAAC,MAAM,KAAK,MAAM;gBAC9B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC/B,CAAC,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;QAC7E,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;YAChG,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAA;QACtB,CAAC;IACH,CAAC"}
@@ -2,10 +2,14 @@ import { AuthCommand } from '../../authCommand.js';
2
2
  export default class UsageTermsCommand extends AuthCommand {
3
3
  static hidden: boolean;
4
4
  static readOnly: boolean;
5
+ static destructive: boolean;
5
6
  static idempotent: boolean;
6
7
  static description: string;
7
8
  static flags: {
8
9
  output: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
10
+ limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
11
+ cursor: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ from: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
13
  to: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
10
14
  };
11
15
  run(): Promise<void>;