checkly 9.5.0 → 10.0.0-rc.1

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 (372) hide show
  1. package/dist/ai-context/context.js +1 -0
  2. package/dist/ai-context/context.js.map +1 -1
  3. package/dist/ai-context/onboarding-boilerplate/checkly-config-template.ts +2 -0
  4. package/dist/ai-context/public-skills/checkly/SKILL.md +18 -5
  5. package/dist/ai-context/skills-command/references/communicate.md +6 -3
  6. package/dist/ai-context/skills-command/references/configure-api-checks.md +1 -9
  7. package/dist/ai-context/skills-command/references/configure-browser-checks.md +1 -8
  8. package/dist/ai-context/skills-command/references/configure-check-groups.md +1 -0
  9. package/dist/ai-context/skills-command/references/configure-dns-monitors.md +1 -9
  10. package/dist/ai-context/skills-command/references/configure-grpc-monitors.md +24 -0
  11. package/dist/ai-context/skills-command/references/configure-heartbeat-monitors.md +1 -9
  12. package/dist/ai-context/skills-command/references/configure-icmp-monitors.md +1 -9
  13. package/dist/ai-context/skills-command/references/configure-multistep-checks.md +1 -9
  14. package/dist/ai-context/skills-command/references/configure-playwright-checks.md +1 -1
  15. package/dist/ai-context/skills-command/references/configure-supporting-constructs.md +6 -2
  16. package/dist/ai-context/skills-command/references/configure-tcp-monitors.md +1 -10
  17. package/dist/ai-context/skills-command/references/configure-url-monitors.md +1 -10
  18. package/dist/ai-context/skills-command/references/configure.md +16 -5
  19. package/dist/ai-context/skills-command/references/initialize.md +11 -3
  20. package/dist/ai-context/skills-command/references/investigate-checks.md +1 -1
  21. package/dist/auth/api-key.d.ts +24 -0
  22. package/dist/auth/api-key.js +104 -0
  23. package/dist/auth/api-key.js.map +1 -0
  24. package/dist/auth/device-flow.d.ts +57 -0
  25. package/dist/auth/device-flow.js +221 -0
  26. package/dist/auth/device-flow.js.map +1 -0
  27. package/dist/auth/index.d.ts +6 -6
  28. package/dist/auth/index.js +64 -64
  29. package/dist/auth/index.js.map +1 -1
  30. package/dist/commands/api.js +43 -10
  31. package/dist/commands/api.js.map +1 -1
  32. package/dist/commands/authCommand.d.ts +2 -0
  33. package/dist/commands/authCommand.js +77 -7
  34. package/dist/commands/authCommand.js.map +1 -1
  35. package/dist/commands/debug/parse-project.d.ts +1 -0
  36. package/dist/commands/debug/parse-project.js +5 -2
  37. package/dist/commands/debug/parse-project.js.map +1 -1
  38. package/dist/commands/deploy.d.ts +7 -1
  39. package/dist/commands/deploy.js +627 -271
  40. package/dist/commands/deploy.js.map +1 -1
  41. package/dist/commands/import/plan.js +18 -4
  42. package/dist/commands/import/plan.js.map +1 -1
  43. package/dist/commands/init.js +29 -13
  44. package/dist/commands/init.js.map +1 -1
  45. package/dist/commands/login.d.ts +18 -2
  46. package/dist/commands/login.js +681 -48
  47. package/dist/commands/login.js.map +1 -1
  48. package/dist/commands/logout.js +7 -1
  49. package/dist/commands/logout.js.map +1 -1
  50. package/dist/commands/pw-test.js +3 -2
  51. package/dist/commands/pw-test.js.map +1 -1
  52. package/dist/commands/switch.js +23 -10
  53. package/dist/commands/switch.js.map +1 -1
  54. package/dist/commands/test.js +16 -17
  55. package/dist/commands/test.js.map +1 -1
  56. package/dist/commands/trigger.js +4 -3
  57. package/dist/commands/trigger.js.map +1 -1
  58. package/dist/commands/validate.js +1 -0
  59. package/dist/commands/validate.js.map +1 -1
  60. package/dist/constants.d.ts +1 -2
  61. package/dist/constants.js +0 -1
  62. package/dist/constants.js.map +1 -1
  63. package/dist/constructs/alert-channel-codegen.d.ts +6 -1
  64. package/dist/constructs/alert-channel-codegen.js +12 -6
  65. package/dist/constructs/alert-channel-codegen.js.map +1 -1
  66. package/dist/constructs/alert-escalation-policy-codegen.d.ts +7 -0
  67. package/dist/constructs/alert-escalation-policy-codegen.js +25 -8
  68. package/dist/constructs/alert-escalation-policy-codegen.js.map +1 -1
  69. package/dist/constructs/api-assertion.d.ts +0 -2
  70. package/dist/constructs/api-assertion.js +0 -4
  71. package/dist/constructs/api-assertion.js.map +1 -1
  72. package/dist/constructs/api-check-codegen.js +1 -1
  73. package/dist/constructs/api-check-codegen.js.map +1 -1
  74. package/dist/constructs/api-check.d.ts +4 -22
  75. package/dist/constructs/api-check.js +15 -17
  76. package/dist/constructs/api-check.js.map +1 -1
  77. package/dist/constructs/api-request-codegen.js +10 -8
  78. package/dist/constructs/api-request-codegen.js.map +1 -1
  79. package/dist/constructs/browser-check-bundle.d.ts +19 -13
  80. package/dist/constructs/browser-check-bundle.js +5 -1
  81. package/dist/constructs/browser-check-bundle.js.map +1 -1
  82. package/dist/constructs/browser-check.d.ts +1 -4
  83. package/dist/constructs/browser-check.js +1 -1
  84. package/dist/constructs/browser-check.js.map +1 -1
  85. package/dist/constructs/check-codegen.d.ts +39 -14
  86. package/dist/constructs/check-codegen.js +101 -23
  87. package/dist/constructs/check-codegen.js.map +1 -1
  88. package/dist/constructs/check-group-codegen.js +23 -9
  89. package/dist/constructs/check-group-codegen.js.map +1 -1
  90. package/dist/constructs/check-group-v1.d.ts +19 -14
  91. package/dist/constructs/check-group-v1.js +39 -14
  92. package/dist/constructs/check-group-v1.js.map +1 -1
  93. package/dist/constructs/check-group-v2.d.ts +0 -20
  94. package/dist/constructs/check-group-v2.js +0 -4
  95. package/dist/constructs/check-group-v2.js.map +1 -1
  96. package/dist/constructs/check.d.ts +45 -32
  97. package/dist/constructs/check.js +78 -17
  98. package/dist/constructs/check.js.map +1 -1
  99. package/dist/constructs/construct-codegen.d.ts +1 -2
  100. package/dist/constructs/construct-diagnostics.d.ts +3 -0
  101. package/dist/constructs/construct-diagnostics.js +11 -0
  102. package/dist/constructs/construct-diagnostics.js.map +1 -1
  103. package/dist/constructs/construct.d.ts +25 -4
  104. package/dist/constructs/construct.js +41 -5
  105. package/dist/constructs/construct.js.map +1 -1
  106. package/dist/constructs/dns-request-codegen.js +1 -1
  107. package/dist/constructs/dns-request-codegen.js.map +1 -1
  108. package/dist/constructs/email-alert-channel-codegen.js +1 -1
  109. package/dist/constructs/email-alert-channel-codegen.js.map +1 -1
  110. package/dist/constructs/frequency-codegen.js +10 -2
  111. package/dist/constructs/frequency-codegen.js.map +1 -1
  112. package/dist/constructs/frequency.d.ts +8 -3
  113. package/dist/constructs/frequency.js +7 -2
  114. package/dist/constructs/frequency.js.map +1 -1
  115. package/dist/constructs/grpc-monitor.js +19 -0
  116. package/dist/constructs/grpc-monitor.js.map +1 -1
  117. package/dist/constructs/grpc-request-codegen.js +13 -4
  118. package/dist/constructs/grpc-request-codegen.js.map +1 -1
  119. package/dist/constructs/grpc-request.d.ts +23 -0
  120. package/dist/constructs/heartbeat-monitor.d.ts +2 -1
  121. package/dist/constructs/heartbeat-monitor.js +2 -2
  122. package/dist/constructs/heartbeat-monitor.js.map +1 -1
  123. package/dist/constructs/icmp-request-codegen.js +1 -1
  124. package/dist/constructs/icmp-request-codegen.js.map +1 -1
  125. package/dist/constructs/incidentio-alert-channel-codegen.d.ts +1 -1
  126. package/dist/constructs/incidentio-alert-channel-codegen.js +14 -8
  127. package/dist/constructs/incidentio-alert-channel-codegen.js.map +1 -1
  128. package/dist/constructs/index.d.ts +1 -1
  129. package/dist/constructs/index.js +1 -1
  130. package/dist/constructs/index.js.map +1 -1
  131. package/dist/constructs/internal/assertion-validation.js +1 -2
  132. package/dist/constructs/internal/assertion-validation.js.map +1 -1
  133. package/dist/constructs/internal/codegen/context.d.ts +73 -6
  134. package/dist/constructs/internal/codegen/context.js +78 -6
  135. package/dist/constructs/internal/codegen/context.js.map +1 -1
  136. package/dist/constructs/internal/codegen/index.d.ts +3 -1
  137. package/dist/constructs/internal/codegen/index.js +2 -1
  138. package/dist/constructs/internal/codegen/index.js.map +1 -1
  139. package/dist/constructs/internal/codegen/render.d.ts +68 -0
  140. package/dist/constructs/internal/codegen/render.js +75 -0
  141. package/dist/constructs/internal/codegen/render.js.map +1 -0
  142. package/dist/constructs/internal/common-diagnostics.d.ts +1 -2
  143. package/dist/constructs/internal/common-diagnostics.js +6 -14
  144. package/dist/constructs/internal/common-diagnostics.js.map +1 -1
  145. package/dist/constructs/internal/declaring-file.d.ts +39 -0
  146. package/dist/constructs/internal/declaring-file.js +139 -0
  147. package/dist/constructs/internal/declaring-file.js.map +1 -0
  148. package/dist/constructs/internal/retry-strategy-defaults.d.ts +13 -0
  149. package/dist/constructs/internal/retry-strategy-defaults.js +14 -0
  150. package/dist/constructs/internal/retry-strategy-defaults.js.map +1 -0
  151. package/dist/constructs/key-value-pair-codegen.d.ts +6 -1
  152. package/dist/constructs/key-value-pair-codegen.js +24 -3
  153. package/dist/constructs/key-value-pair-codegen.js.map +1 -1
  154. package/dist/constructs/maintenance-window-codegen.d.ts +7 -0
  155. package/dist/constructs/maintenance-window-codegen.js +36 -19
  156. package/dist/constructs/maintenance-window-codegen.js.map +1 -1
  157. package/dist/constructs/maintenance-window.d.ts +35 -3
  158. package/dist/constructs/maintenance-window.js +35 -1
  159. package/dist/constructs/maintenance-window.js.map +1 -1
  160. package/dist/constructs/monitor.d.ts +1 -1
  161. package/dist/constructs/msteams-alert-channel-codegen.d.ts +1 -1
  162. package/dist/constructs/msteams-alert-channel-codegen.js +8 -18
  163. package/dist/constructs/msteams-alert-channel-codegen.js.map +1 -1
  164. package/dist/constructs/opsgenie-alert-channel-codegen.js +1 -1
  165. package/dist/constructs/opsgenie-alert-channel-codegen.js.map +1 -1
  166. package/dist/constructs/pagerduty-alert-channel-codegen.js +1 -1
  167. package/dist/constructs/pagerduty-alert-channel-codegen.js.map +1 -1
  168. package/dist/constructs/phone-call-alert-channel-codegen.js +1 -1
  169. package/dist/constructs/phone-call-alert-channel-codegen.js.map +1 -1
  170. package/dist/constructs/playwright-check-bundle.d.ts +7 -1
  171. package/dist/constructs/playwright-check-bundle.js +3 -0
  172. package/dist/constructs/playwright-check-bundle.js.map +1 -1
  173. package/dist/constructs/playwright-check-codegen.d.ts +85 -0
  174. package/dist/constructs/playwright-check-codegen.js +212 -0
  175. package/dist/constructs/playwright-check-codegen.js.map +1 -0
  176. package/dist/constructs/playwright-check.d.ts +14 -24
  177. package/dist/constructs/playwright-check.js +16 -52
  178. package/dist/constructs/playwright-check.js.map +1 -1
  179. package/dist/constructs/retry-strategy-codegen.d.ts +7 -1
  180. package/dist/constructs/retry-strategy-codegen.js +41 -32
  181. package/dist/constructs/retry-strategy-codegen.js.map +1 -1
  182. package/dist/constructs/retry-strategy.d.ts +0 -4
  183. package/dist/constructs/retry-strategy.js +5 -8
  184. package/dist/constructs/retry-strategy.js.map +1 -1
  185. package/dist/constructs/session.d.ts +26 -1
  186. package/dist/constructs/session.js +33 -2
  187. package/dist/constructs/session.js.map +1 -1
  188. package/dist/constructs/slack-alert-channel-codegen.js +1 -1
  189. package/dist/constructs/slack-alert-channel-codegen.js.map +1 -1
  190. package/dist/constructs/slack-app-alert-channel-codegen.js +1 -1
  191. package/dist/constructs/slack-app-alert-channel-codegen.js.map +1 -1
  192. package/dist/constructs/sms-alert-channel-codegen.js +1 -1
  193. package/dist/constructs/sms-alert-channel-codegen.js.map +1 -1
  194. package/dist/constructs/ssl-request-codegen.js +4 -3
  195. package/dist/constructs/ssl-request-codegen.js.map +1 -1
  196. package/dist/constructs/status-page-v3-automation-rule-codegen.js +5 -4
  197. package/dist/constructs/status-page-v3-automation-rule-codegen.js.map +1 -1
  198. package/dist/constructs/status-page-v3-codegen.js +3 -2
  199. package/dist/constructs/status-page-v3-codegen.js.map +1 -1
  200. package/dist/constructs/status-page-v3-component-codegen.js +8 -7
  201. package/dist/constructs/status-page-v3-component-codegen.js.map +1 -1
  202. package/dist/constructs/tcp-monitor-codegen.js +3 -2
  203. package/dist/constructs/tcp-monitor-codegen.js.map +1 -1
  204. package/dist/constructs/tcp-monitor.d.ts +4 -3
  205. package/dist/constructs/tcp-monitor.js +3 -2
  206. package/dist/constructs/tcp-monitor.js.map +1 -1
  207. package/dist/constructs/telegram-alert-channel-codegen.d.ts +1 -1
  208. package/dist/constructs/telegram-alert-channel-codegen.js +14 -8
  209. package/dist/constructs/telegram-alert-channel-codegen.js.map +1 -1
  210. package/dist/constructs/time-zone.d.ts +24 -0
  211. package/dist/constructs/time-zone.js +455 -0
  212. package/dist/constructs/time-zone.js.map +1 -0
  213. package/dist/constructs/traceroute-request-codegen.js +2 -2
  214. package/dist/constructs/traceroute-request-codegen.js.map +1 -1
  215. package/dist/constructs/url-monitor-codegen.js +1 -1
  216. package/dist/constructs/url-monitor-codegen.js.map +1 -1
  217. package/dist/constructs/url-monitor.d.ts +3 -2
  218. package/dist/constructs/url-monitor.js +3 -0
  219. package/dist/constructs/url-monitor.js.map +1 -1
  220. package/dist/constructs/url-request-codegen.js +4 -3
  221. package/dist/constructs/url-request-codegen.js.map +1 -1
  222. package/dist/constructs/webhook-alert-channel-codegen.js +3 -3
  223. package/dist/constructs/webhook-alert-channel-codegen.js.map +1 -1
  224. package/dist/formatters/check-result-detail.js +0 -185
  225. package/dist/formatters/check-result-detail.js.map +1 -1
  226. package/dist/helpers/activate-account.d.ts +14 -0
  227. package/dist/helpers/activate-account.js +25 -0
  228. package/dist/helpers/activate-account.js.map +1 -0
  229. package/dist/helpers/cli-mode.d.ts +18 -0
  230. package/dist/helpers/cli-mode.js +41 -2
  231. package/dist/helpers/cli-mode.js.map +1 -1
  232. package/dist/helpers/command-preview.d.ts +44 -0
  233. package/dist/helpers/command-preview.js +29 -9
  234. package/dist/helpers/command-preview.js.map +1 -1
  235. package/dist/helpers/flags.d.ts +10 -0
  236. package/dist/helpers/flags.js +17 -0
  237. package/dist/helpers/flags.js.map +1 -1
  238. package/dist/helpers/onboarding/boilerplate.js +13 -1
  239. package/dist/helpers/onboarding/boilerplate.js.map +1 -1
  240. package/dist/helpers/onboarding/index.d.ts +1 -1
  241. package/dist/helpers/onboarding/index.js +1 -1
  242. package/dist/helpers/onboarding/index.js.map +1 -1
  243. package/dist/helpers/onboarding/messages.d.ts +6 -0
  244. package/dist/helpers/onboarding/messages.js +14 -0
  245. package/dist/helpers/onboarding/messages.js.map +1 -1
  246. package/dist/helpers/onboarding/skill-install.js +2 -2
  247. package/dist/helpers/onboarding/skill-install.js.map +1 -1
  248. package/dist/helpers/wrap.js +1 -1
  249. package/dist/helpers/wrap.js.map +1 -1
  250. package/dist/reporters/abstract-list.js +11 -2
  251. package/dist/reporters/abstract-list.js.map +1 -1
  252. package/dist/reporters/github.js +3 -2
  253. package/dist/reporters/github.js.map +1 -1
  254. package/dist/reporters/util.d.ts +1 -0
  255. package/dist/reporters/util.js +5 -58
  256. package/dist/reporters/util.js.map +1 -1
  257. package/dist/rest/analytics.js +0 -4
  258. package/dist/rest/analytics.js.map +1 -1
  259. package/dist/rest/api.d.ts +8 -1
  260. package/dist/rest/api.js +21 -3
  261. package/dist/rest/api.js.map +1 -1
  262. package/dist/rest/check-results.d.ts +1 -50
  263. package/dist/rest/check-results.js.map +1 -1
  264. package/dist/rest/checkly-storage.d.ts +6 -1
  265. package/dist/rest/checkly-storage.js +13 -2
  266. package/dist/rest/checkly-storage.js.map +1 -1
  267. package/dist/rest/errors.d.ts +13 -0
  268. package/dist/rest/errors.js +5 -1
  269. package/dist/rest/errors.js.map +1 -1
  270. package/dist/rest/projects.d.ts +254 -4
  271. package/dist/rest/projects.js +184 -12
  272. package/dist/rest/projects.js.map +1 -1
  273. package/dist/services/abstract-check-runner.d.ts +11 -0
  274. package/dist/services/abstract-check-runner.js +98 -46
  275. package/dist/services/abstract-check-runner.js.map +1 -1
  276. package/dist/services/check-parser/bundler.d.ts +26 -0
  277. package/dist/services/check-parser/bundler.js +81 -7
  278. package/dist/services/check-parser/bundler.js.map +1 -1
  279. package/dist/services/check-parser/cache-hash.d.ts +1 -4
  280. package/dist/services/check-parser/cache-hash.js.map +1 -1
  281. package/dist/services/checkly-config-codegen.js +1 -4
  282. package/dist/services/checkly-config-codegen.js.map +1 -1
  283. package/dist/services/checkly-config-loader.d.ts +7 -33
  284. package/dist/services/checkly-config-loader.js +50 -47
  285. package/dist/services/checkly-config-loader.js.map +1 -1
  286. package/dist/services/config.d.ts +2 -0
  287. package/dist/services/config.js +14 -0
  288. package/dist/services/config.js.map +1 -1
  289. package/dist/services/content-hash.d.ts +14 -0
  290. package/dist/services/content-hash.js +22 -0
  291. package/dist/services/content-hash.js.map +1 -0
  292. package/dist/services/deploy-diff/diff-lines.d.ts +38 -0
  293. package/dist/services/deploy-diff/diff-lines.js +191 -0
  294. package/dist/services/deploy-diff/diff-lines.js.map +1 -0
  295. package/dist/services/deploy-diff/import-shape.d.ts +171 -0
  296. package/dist/services/deploy-diff/import-shape.js +633 -0
  297. package/dist/services/deploy-diff/import-shape.js.map +1 -0
  298. package/dist/services/deploy-diff/legacy-payload.d.ts +22 -0
  299. package/dist/services/deploy-diff/legacy-payload.js +51 -0
  300. package/dist/services/deploy-diff/legacy-payload.js.map +1 -0
  301. package/dist/services/deploy-diff/plan-summary.d.ts +37 -0
  302. package/dist/services/deploy-diff/plan-summary.js +154 -0
  303. package/dist/services/deploy-diff/plan-summary.js.map +1 -0
  304. package/dist/services/deploy-diff/preview-output.d.ts +61 -0
  305. package/dist/services/deploy-diff/preview-output.js +394 -0
  306. package/dist/services/deploy-diff/preview-output.js.map +1 -0
  307. package/dist/services/deploy-diff/render.d.ts +53 -0
  308. package/dist/services/deploy-diff/render.js +317 -0
  309. package/dist/services/deploy-diff/render.js.map +1 -0
  310. package/dist/services/deploy-diff/shape-changes.d.ts +2 -0
  311. package/dist/services/deploy-diff/shape-changes.js +35 -0
  312. package/dist/services/deploy-diff/shape-changes.js.map +1 -0
  313. package/dist/services/deploy-diff/source-index.d.ts +18 -0
  314. package/dist/services/deploy-diff/source-index.js +48 -0
  315. package/dist/services/deploy-diff/source-index.js.map +1 -0
  316. package/dist/services/deploy-diff/variable-names.d.ts +30 -0
  317. package/dist/services/deploy-diff/variable-names.js +64 -0
  318. package/dist/services/deploy-diff/variable-names.js.map +1 -0
  319. package/dist/services/project-parser.d.ts +5 -0
  320. package/dist/services/project-parser.js +25 -13
  321. package/dist/services/project-parser.js.map +1 -1
  322. package/dist/services/snapshot-service.d.ts +25 -8
  323. package/dist/services/snapshot-service.js +46 -4
  324. package/dist/services/snapshot-service.js.map +1 -1
  325. package/dist/services/test-filters.d.ts +18 -0
  326. package/dist/services/test-filters.js +10 -0
  327. package/dist/services/test-filters.js.map +1 -1
  328. package/dist/services/test-runner.js +7 -3
  329. package/dist/services/test-runner.js.map +1 -1
  330. package/dist/services/test-session-cancel.js +1 -1
  331. package/dist/services/test-session-cancel.js.map +1 -1
  332. package/dist/services/util.d.ts +17 -2
  333. package/dist/services/util.js +118 -11
  334. package/dist/services/util.js.map +1 -1
  335. package/dist/services/write-back/apply-edits.d.ts +29 -0
  336. package/dist/services/write-back/apply-edits.js +255 -0
  337. package/dist/services/write-back/apply-edits.js.map +1 -0
  338. package/dist/services/write-back/helper-edit.d.ts +135 -0
  339. package/dist/services/write-back/helper-edit.js +343 -0
  340. package/dist/services/write-back/helper-edit.js.map +1 -0
  341. package/dist/services/write-back/imports.d.ts +30 -0
  342. package/dist/services/write-back/imports.js +82 -0
  343. package/dist/services/write-back/imports.js.map +1 -0
  344. package/dist/services/write-back/literal-edit.d.ts +183 -0
  345. package/dist/services/write-back/literal-edit.js +359 -0
  346. package/dist/services/write-back/literal-edit.js.map +1 -0
  347. package/dist/services/write-back/output.d.ts +26 -0
  348. package/dist/services/write-back/output.js +110 -0
  349. package/dist/services/write-back/output.js.map +1 -0
  350. package/dist/services/write-back/plan.d.ts +173 -0
  351. package/dist/services/write-back/plan.js +968 -0
  352. package/dist/services/write-back/plan.js.map +1 -0
  353. package/dist/services/write-back/source-file.d.ts +118 -0
  354. package/dist/services/write-back/source-file.js +432 -0
  355. package/dist/services/write-back/source-file.js.map +1 -0
  356. package/dist/sourcegen/index.d.ts +1 -1
  357. package/dist/sourcegen/index.js +1 -1
  358. package/dist/sourcegen/index.js.map +1 -1
  359. package/dist/sourcegen/program.d.ts +19 -1
  360. package/dist/sourcegen/program.js +32 -7
  361. package/dist/sourcegen/program.js.map +1 -1
  362. package/oclif.manifest.json +676 -635
  363. package/package.json +13 -13
  364. package/dist/commands/rules.d.ts +0 -9
  365. package/dist/commands/rules.js +0 -13
  366. package/dist/commands/rules.js.map +0 -1
  367. package/dist/constructs/agentic-check-codegen.d.ts +0 -22
  368. package/dist/constructs/agentic-check-codegen.js +0 -59
  369. package/dist/constructs/agentic-check-codegen.js.map +0 -1
  370. package/dist/constructs/agentic-check.d.ts +0 -237
  371. package/dist/constructs/agentic-check.js +0 -100
  372. package/dist/constructs/agentic-check.js.map +0 -1
@@ -16,6 +16,135 @@ export interface Change {
16
16
  type: string;
17
17
  action: string;
18
18
  }
19
+ /** The API's stand-in for a sensitive value in a reported change. */
20
+ export interface DiffMaskedMarker {
21
+ $masked: 'same' | 'changed';
22
+ }
23
+ /**
24
+ * One property of one resource that a deploy would change, or has changed.
25
+ *
26
+ * `origin` says which side moved since the last deploy: `code` for a local
27
+ * edit, `remote` for one made outside the CLI (the web app, the API), `both`
28
+ * when the property moved on both sides — in which case `remote` carries the
29
+ * movement the deploy is about to overwrite. A value too large to inline is
30
+ * reported as a `{ $hash }` object rather than in the clear; under
31
+ * `detail: 'full'` the deployed text is in the entry's `before`, at the path
32
+ * the import format gives it (the same one for a script or a request body).
33
+ * A secret change (`secret: true`) carries its values with every sensitive
34
+ * position replaced by a `DiffMaskedMarker`, `changed` on the element whose
35
+ * secret moved on that side; never a value or a hash. A list holding an
36
+ * unmoved secret carries `same` markers without the flag.
37
+ * `cause` names the reason for a change with no user-facing property behind
38
+ * it, such as a new code bundle.
39
+ */
40
+ export interface DiffChange {
41
+ path: string;
42
+ /**
43
+ * `unmanaged` marks an alert channel or private location attached to this
44
+ * project's check or group from outside the project: reported on the resource
45
+ * it belongs to, and only deleted with `--prune-relations`.
46
+ */
47
+ origin: 'code' | 'remote' | 'both' | 'unmanaged';
48
+ before?: unknown;
49
+ after?: unknown;
50
+ remote?: {
51
+ before?: unknown;
52
+ after?: unknown;
53
+ };
54
+ cause?: string;
55
+ /** Set when a sensitive value moved or a sensitive list element could not be matched; see `DiffMaskedMarker`. */
56
+ secret?: true;
57
+ }
58
+ /**
59
+ * One rule of the redaction table the API applies to an entry's `before`, as
60
+ * a JSON Pointer pattern (`*` for every list position) and the flag test on
61
+ * the holding element that decides it. The API reports the resource type's
62
+ * whole table, whatever the deployed row held, so the local side blanks by
63
+ * the same rules — a credential the code adds included.
64
+ */
65
+ export interface DiffRedaction {
66
+ path: string;
67
+ /** What the rule blanks to: a `value` becomes the empty string, an `object` becomes null. */
68
+ kind: 'value' | 'object';
69
+ when?: 'locked' | 'lockedOrSecret';
70
+ }
71
+ /**
72
+ * A resource in a deploy plan or an applied deploy. `action` is CREATE,
73
+ * UPDATE, DELETE, DETACH (removed from code but kept in the account) or
74
+ * UNCHANGED.
75
+ */
76
+ export interface DiffEntry extends Change {
77
+ origin?: 'code' | 'remote' | 'unmanaged';
78
+ /** Absent under `detail: 'summary'`. */
79
+ changes?: DiffChange[];
80
+ /**
81
+ * The resource as currently deployed, in the import format: the payload the
82
+ * import plan returns for it, references as physical ids, a check's or
83
+ * group's subscription and assignment rows on it, credential values blanked.
84
+ * Only under `detail: 'full'`, and only for a retained resource with a
85
+ * change to show.
86
+ */
87
+ before?: Record<string, unknown>;
88
+ /** With `before`: the type's redaction rule table, applied to it. */
89
+ redactions?: DiffRedaction[];
90
+ /**
91
+ * Set on a relation (an alert channel subscription, a private location
92
+ * assignment) whose change is reported as part of the check or group it
93
+ * belongs to, so a renderer can fold it into that resource instead of
94
+ * listing it separately.
95
+ */
96
+ foldedInto?: {
97
+ type: string;
98
+ logicalId: string;
99
+ };
100
+ /** The file Checkly has recorded for the resource, or null if none. */
101
+ sourceFile?: string | null;
102
+ /**
103
+ * `live` when Checkly had no usable state from an earlier planned deploy to
104
+ * compare the resource with (the project's first plan, the first after a
105
+ * deploy without one, a resource added with `checkly import`, or a stored
106
+ * state a Checkly update made unusable) and compared the code with the
107
+ * deployed resource instead. The deploy
108
+ * writes such a resource whatever the comparison found, to set the baseline
109
+ * for later plans, and `changes` is not exhaustive: a value the deployed
110
+ * resource holds on a property the code does not set is left out, although
111
+ * the write may reset it.
112
+ */
113
+ basis?: 'live';
114
+ /**
115
+ * On a check the deploy created, updated or kept, other than a heartbeat
116
+ * monitor: whether Checkly selected it to run right after the deploy. Only on
117
+ * a deploy's result, never on a preview or a dry run, and absent from an API
118
+ * that predates it.
119
+ */
120
+ scheduled?: boolean;
121
+ /**
122
+ * Why `scheduled` is false: the deploy did not ask for scheduling, it had
123
+ * more checks than the scheduling threshold allows, it left the check
124
+ * unchanged while scheduling changed checks only, or the check runs more
125
+ * often than the minimum frequency for scheduling on deploy.
126
+ */
127
+ scheduleSkippedReason?: 'NOT_REQUESTED' | 'THRESHOLD' | 'UNCHANGED' | 'MIN_FREQUENCY';
128
+ }
129
+ /**
130
+ * Which checks a deploy schedules: the ones it created or updated, or every
131
+ * check it deployed, the unchanged ones included.
132
+ */
133
+ export type ScheduleOnDeployScope = 'changed' | 'all';
134
+ /** How much of each change a preview reports. */
135
+ export type ProjectPreviewDetail = 'summary' | 'changes' | 'full';
136
+ export interface ProjectPreviewResponse {
137
+ /** The project as currently deployed; absent before its first deploy. */
138
+ project?: DeployedProject | null;
139
+ /**
140
+ * Opaque fingerprint of the Checkly-side state this plan was computed
141
+ * against. Passing it to a deploy makes that deploy refuse, rather than
142
+ * apply a different plan than the one that was reviewed, if anything moved
143
+ * in between.
144
+ */
145
+ planToken: string;
146
+ diff: DiffEntry[];
147
+ }
19
148
  export interface ResourceSync {
20
149
  logicalId: string;
21
150
  physicalId?: string | number;
@@ -86,7 +215,14 @@ export interface DeployedProject extends Project {
86
215
  }
87
216
  export interface ProjectDeployResponse {
88
217
  project: DeployedProject;
89
- diff: Array<Change>;
218
+ diff: Array<DiffEntry>;
219
+ /**
220
+ * Whether Checkly scheduled the deployed checks to run. Set by `deploy()`
221
+ * from the deployment; false when it was asked not to, and when the deploy
222
+ * had more checks than the scheduling threshold allows. Absent from an API
223
+ * that predates the threshold.
224
+ */
225
+ scheduled?: boolean;
90
226
  }
91
227
  export type ProjectDeploymentStatus = 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'CANCELLED';
92
228
  export interface ProjectDeployment {
@@ -102,6 +238,14 @@ export interface ProjectDeployment {
102
238
  } | null;
103
239
  /** The applied { project, diff }; present once the deployment has succeeded. */
104
240
  result: ProjectDeployResponse | null;
241
+ /**
242
+ * Whether the deploy schedules its checks. False when it was sent with
243
+ * scheduleOnDeploy=false, and when it had more checks than the scheduling
244
+ * threshold allows, which is decided from the applied diff: until the
245
+ * deployment has finished it is the request. Absent from an API that
246
+ * predates the threshold.
247
+ */
248
+ scheduleOnDeploy?: boolean;
105
249
  createdAt: string;
106
250
  startedAt: string | null;
107
251
  endedAt: string | null;
@@ -154,6 +298,57 @@ export declare class ProjectAlreadyExistsError extends Error {
154
298
  export declare class NoImportableResourcesFoundError extends Error {
155
299
  constructor(options?: ErrorOptions);
156
300
  }
301
+ /**
302
+ * The plan a deploy was pinned to no longer describes Checkly's state: a
303
+ * change landed between the preview and the deploy, so the deploy applied
304
+ * nothing. `diff` is the plan as it looks now.
305
+ */
306
+ export declare class ProjectPlanStaleError extends Error {
307
+ readonly diff: DiffEntry[];
308
+ constructor(message: string, diff: DiffEntry[], options?: ErrorOptions);
309
+ }
310
+ /**
311
+ * A deployment that was already running finished while this one waited for it.
312
+ * Whatever it wrote, it moved the state the plan was computed against, so the
313
+ * plan is stale before the deploy is even attempted — reported here rather
314
+ * than after re-sending the whole payload for a refusal that is certain.
315
+ *
316
+ * A subtype of {@link ProjectPlanStaleError}: callers recover from both the
317
+ * same way, by planning again. It carries no diff, because no new plan has
318
+ * been computed yet.
319
+ */
320
+ export declare class ProjectPlanSupersededError extends ProjectPlanStaleError {
321
+ constructor(options?: ErrorOptions);
322
+ }
323
+ /**
324
+ * The preview could not be computed because another operation is holding the
325
+ * project. Transient: the operation holding it finishes.
326
+ */
327
+ export declare class ProjectPreviewUnavailableError extends Error {
328
+ constructor(message: string, options?: ErrorOptions);
329
+ }
330
+ /**
331
+ * The account's Checkly API does not have the preview endpoint yet (a
332
+ * self-hosted or not-yet-updated backend). Callers fall back to the older,
333
+ * coarser deploy preview.
334
+ */
335
+ export declare class ProjectPreviewNotSupportedError extends Error {
336
+ constructor(options?: ErrorOptions);
337
+ }
338
+ /**
339
+ * The account's Checkly API has deploy plans switched off at the moment. Unlike
340
+ * an API without the preview endpoint, it knows every payload field a planned
341
+ * deploy sends, so callers fall back to a deploy without a plan and leave the
342
+ * payload as it is.
343
+ */
344
+ export declare class ProjectPlanDisabledError extends Error {
345
+ constructor(options?: ErrorOptions);
346
+ }
347
+ /**
348
+ * `code` of what the API answers with while plans are switched off: the 404 of
349
+ * the preview endpoint, and the 400 a deploy that needs a plan is refused with.
350
+ */
351
+ export declare const DEPLOY_PLAN_DISABLED = "DEPLOY_PLAN_DISABLED";
157
352
  export declare class ImportPlanNotFoundError extends Error {
158
353
  constructor(options?: ErrorOptions);
159
354
  }
@@ -197,6 +392,26 @@ declare class Projects {
197
392
  * (the project does not exist) — a plain result with no deployment to follow.
198
393
  */
199
394
  private submitDeletion;
395
+ /**
396
+ * What deploying this payload would change, per resource and per property,
397
+ * without writing anything.
398
+ *
399
+ * The returned `planToken` pins the plan: pass it to {@link deploy} and the
400
+ * deploy refuses if Checkly's state moved in between. A code-side edit
401
+ * between the two is not such a move — the token describes Checkly's state,
402
+ * not the payload — so previewing, editing and deploying still works.
403
+ *
404
+ * @throws {ProjectPreviewNotSupportedError} If the API has no preview endpoint.
405
+ * @throws {ProjectPlanDisabledError} If the API has deploy plans switched off.
406
+ * @throws {ProjectPreviewUnavailableError} If the project stayed busy.
407
+ */
408
+ preview(resources: ProjectSync, { detail, preserveResources, pruneRelations, onStatus, }?: {
409
+ detail?: ProjectPreviewDetail;
410
+ preserveResources?: boolean;
411
+ pruneRelations?: boolean;
412
+ /** Human-readable status updates (e.g. while retrying behind another operation). */
413
+ onStatus?: (message: string) => void;
414
+ }): Promise<ProjectPreviewResponse>;
200
415
  /**
201
416
  * Deploy a project. The deployment runs asynchronously on the backend: this
202
417
  * submits it, then follows its progress stream to completion, so large projects
@@ -205,14 +420,45 @@ declare class Projects {
205
420
  *
206
421
  * @throws {ProjectDeployFailedError} If the deployment finishes unsuccessfully.
207
422
  */
208
- deploy(resources: ProjectSync, { dryRun, scheduleOnDeploy, preserveResources, cancelInProgress, onProgress, onStatus, }?: {
423
+ deploy(resources: ProjectSync, { dryRun, scheduleOnDeploy, scheduleOnDeployScope, scheduleOnDeployThreshold, scheduleOnDeployMinFrequency, preserveResources, plan, pruneRelations, planToken, cancelInProgress, onProgress, onStatus, }?: {
209
424
  dryRun?: boolean;
210
425
  scheduleOnDeploy?: boolean;
426
+ /** Which checks to schedule: the changed ones, or every deployed check. */
427
+ scheduleOnDeployScope?: ScheduleOnDeployScope;
428
+ /**
429
+ * Schedule no checks if the deploy would schedule more than this many,
430
+ * not counting the ones the scope and the minimum frequency leave out.
431
+ * Without it Checkly applies its own threshold.
432
+ */
433
+ scheduleOnDeployThreshold?: number;
434
+ /**
435
+ * Leave out of scheduling the checks that run more often than every this
436
+ * many minutes. Without it Checkly applies its own minimum.
437
+ */
438
+ scheduleOnDeployMinFrequency?: number;
211
439
  /**
212
440
  * Keep resources removed from code (and their run history) in the account
213
441
  * instead of deleting them.
214
442
  */
215
443
  preserveResources?: boolean;
444
+ /**
445
+ * Apply a plan: compare every resource with what was last deployed and
446
+ * with its current state, and write only the ones that differ. Without
447
+ * it the deploy writes every resource. `pruneRelations` and `planToken`
448
+ * are refused by the API unless this is set.
449
+ */
450
+ plan?: boolean;
451
+ /**
452
+ * Delete the alert channel subscriptions and private location assignments
453
+ * on this project's checks and groups that the project does not manage.
454
+ */
455
+ pruneRelations?: boolean;
456
+ /**
457
+ * The `planToken` of the preview this deploy was reviewed against. The
458
+ * deploy is refused with {@link ProjectPlanStaleError}, having written
459
+ * nothing, if Checkly's state moved since that preview.
460
+ */
461
+ planToken?: string;
216
462
  /**
217
463
  * On a 409 (another deployment is already in progress), cancel that
218
464
  * deployment instead of waiting for it to finish, then retry.
@@ -230,8 +476,12 @@ declare class Projects {
230
476
  * optionally cancel it, then wait until it reaches a final state (or is gone)
231
477
  * before returning — so the caller re-POSTs only when the slot is actually
232
478
  * free, never re-uploading the payload while the predecessor is still running.
233
- * Returns early if the overall `deadlineAt` passes (the caller then re-POSTs
234
- * once and surfaces the conflict).
479
+ *
480
+ * @returns Whether the predecessor was observed to reach a final state.
481
+ * `false` means the wait hit its deadline with the predecessor still running,
482
+ * which is a different situation for the caller: nothing has changed, so a
483
+ * plan computed before the wait still stands, and re-POSTing surfaces the
484
+ * conflict the caller needs to hear about.
235
485
  */
236
486
  private resolveInProgressDeployment;
237
487
  getDeployment(logicalId: string, deploymentId: string): Promise<import("axios").AxiosResponse<ProjectDeployment, any, {}, any>>;
@@ -2,6 +2,7 @@ import { isAxiosError } from 'axios';
2
2
  import { Readable } from 'node:stream';
3
3
  import { compressJSONPayload } from './util.js';
4
4
  import { ConflictError, ForbiddenError, handleErrorResponse, NotFoundError, RequestTimeoutError } from './errors.js';
5
+ import { parseRetryAfter } from './retry.js';
5
6
  export class ProjectDeployFailedError extends Error {
6
7
  constructor(message, options) {
7
8
  super(message, options);
@@ -78,6 +79,74 @@ export class NoImportableResourcesFoundError extends Error {
78
79
  this.name = 'NoImportableResourcesFoundError';
79
80
  }
80
81
  }
82
+ /**
83
+ * The plan a deploy was pinned to no longer describes Checkly's state: a
84
+ * change landed between the preview and the deploy, so the deploy applied
85
+ * nothing. `diff` is the plan as it looks now.
86
+ */
87
+ export class ProjectPlanStaleError extends Error {
88
+ diff;
89
+ constructor(message, diff, options) {
90
+ super(message, options);
91
+ this.name = 'ProjectPlanStaleError';
92
+ this.diff = diff;
93
+ }
94
+ }
95
+ /**
96
+ * A deployment that was already running finished while this one waited for it.
97
+ * Whatever it wrote, it moved the state the plan was computed against, so the
98
+ * plan is stale before the deploy is even attempted — reported here rather
99
+ * than after re-sending the whole payload for a refusal that is certain.
100
+ *
101
+ * A subtype of {@link ProjectPlanStaleError}: callers recover from both the
102
+ * same way, by planning again. It carries no diff, because no new plan has
103
+ * been computed yet.
104
+ */
105
+ export class ProjectPlanSupersededError extends ProjectPlanStaleError {
106
+ constructor(options) {
107
+ super('Another deployment of this project finished while this one was waiting for it, '
108
+ + 'so the plan this deploy was pinned to no longer describes your Checkly account.', [], options);
109
+ this.name = 'ProjectPlanSupersededError';
110
+ }
111
+ }
112
+ /**
113
+ * The preview could not be computed because another operation is holding the
114
+ * project. Transient: the operation holding it finishes.
115
+ */
116
+ export class ProjectPreviewUnavailableError extends Error {
117
+ constructor(message, options) {
118
+ super(message, options);
119
+ this.name = 'ProjectPreviewUnavailableError';
120
+ }
121
+ }
122
+ /**
123
+ * The account's Checkly API does not have the preview endpoint yet (a
124
+ * self-hosted or not-yet-updated backend). Callers fall back to the older,
125
+ * coarser deploy preview.
126
+ */
127
+ export class ProjectPreviewNotSupportedError extends Error {
128
+ constructor(options) {
129
+ super('This Checkly API does not support deploy previews.', options);
130
+ this.name = 'ProjectPreviewNotSupportedError';
131
+ }
132
+ }
133
+ /**
134
+ * The account's Checkly API has deploy plans switched off at the moment. Unlike
135
+ * an API without the preview endpoint, it knows every payload field a planned
136
+ * deploy sends, so callers fall back to a deploy without a plan and leave the
137
+ * payload as it is.
138
+ */
139
+ export class ProjectPlanDisabledError extends Error {
140
+ constructor(options) {
141
+ super('Checkly has deploy plans switched off at the moment.', options);
142
+ this.name = 'ProjectPlanDisabledError';
143
+ }
144
+ }
145
+ /**
146
+ * `code` of what the API answers with while plans are switched off: the 404 of
147
+ * the preview endpoint, and the 400 a deploy that needs a plan is refused with.
148
+ */
149
+ export const DEPLOY_PLAN_DISABLED = 'DEPLOY_PLAN_DISABLED';
81
150
  export class ImportPlanNotFoundError extends Error {
82
151
  constructor(options) {
83
152
  super(`Import plan does not exist.`, options);
@@ -94,6 +163,13 @@ export class InvalidImportPlanStateError extends Error {
94
163
  // in-progress operation before giving up and surfacing the 409. Generous, since a
95
164
  // large predecessor deploy or delete can legitimately run for many minutes.
96
165
  const DEPLOY_CONFLICT_WAIT_DEADLINE_MS = 30 * 60_000;
166
+ // A preview conflicts only while something else holds the project, which is
167
+ // measured in seconds, so it is retried a few times rather than waited out
168
+ // like a deploy's predecessor. The cap keeps a server asking for an
169
+ // unreasonable wait from stalling the command instead of failing it.
170
+ const PREVIEW_CONFLICT_ATTEMPTS = 3;
171
+ const PREVIEW_RETRY_AFTER_DEFAULT_MS = 2_000;
172
+ const PREVIEW_RETRY_AFTER_MAX_MS = 10_000;
97
173
  class Projects {
98
174
  api;
99
175
  constructor(api) {
@@ -185,6 +261,54 @@ class Projects {
185
261
  throw new ProjectDeployFailedError(completed.error?.message ?? 'The deletion did not complete successfully.');
186
262
  }
187
263
  }
264
+ /**
265
+ * What deploying this payload would change, per resource and per property,
266
+ * without writing anything.
267
+ *
268
+ * The returned `planToken` pins the plan: pass it to {@link deploy} and the
269
+ * deploy refuses if Checkly's state moved in between. A code-side edit
270
+ * between the two is not such a move — the token describes Checkly's state,
271
+ * not the payload — so previewing, editing and deploying still works.
272
+ *
273
+ * @throws {ProjectPreviewNotSupportedError} If the API has no preview endpoint.
274
+ * @throws {ProjectPlanDisabledError} If the API has deploy plans switched off.
275
+ * @throws {ProjectPreviewUnavailableError} If the project stayed busy.
276
+ */
277
+ async preview(resources, { detail = 'changes', preserveResources = false, pruneRelations = false, onStatus, } = {}) {
278
+ const query = new URLSearchParams({ detail });
279
+ // Only sent when opted in, like deploy's: false is the default and the
280
+ // endpoint's contract is easier to keep stable if the CLI omits defaults.
281
+ if (preserveResources) {
282
+ query.set('preserveResources', 'true');
283
+ }
284
+ if (pruneRelations) {
285
+ query.set('pruneRelations', 'true');
286
+ }
287
+ for (let attempt = 1;; attempt++) {
288
+ try {
289
+ const { data } = await this.api.post(`/v1/projects/preview?${query.toString()}`, resources, { transformRequest: compressJSONPayload });
290
+ return data;
291
+ }
292
+ catch (err) {
293
+ if (err instanceof NotFoundError) {
294
+ // Both are a 404: only the body tells an API that has plans switched
295
+ // off from one that never had the endpoint.
296
+ throw err.data.code === DEPLOY_PLAN_DISABLED
297
+ ? new ProjectPlanDisabledError({ cause: err })
298
+ : new ProjectPreviewNotSupportedError({ cause: err });
299
+ }
300
+ if (!(err instanceof ConflictError)) {
301
+ throw err;
302
+ }
303
+ if (attempt >= PREVIEW_CONFLICT_ATTEMPTS) {
304
+ throw new ProjectPreviewUnavailableError(err.data.message, { cause: err });
305
+ }
306
+ const retryAfterMs = Math.min(parseRetryAfter(err.data.retryAfter) ?? PREVIEW_RETRY_AFTER_DEFAULT_MS, PREVIEW_RETRY_AFTER_MAX_MS);
307
+ onStatus?.('Another operation is holding the project, retrying...');
308
+ await new Promise(resolve => setTimeout(resolve, retryAfterMs));
309
+ }
310
+ }
311
+ }
188
312
  /**
189
313
  * Deploy a project. The deployment runs asynchronously on the backend: this
190
314
  * submits it, then follows its progress stream to completion, so large projects
@@ -193,7 +317,7 @@ class Projects {
193
317
  *
194
318
  * @throws {ProjectDeployFailedError} If the deployment finishes unsuccessfully.
195
319
  */
196
- async deploy(resources, { dryRun = false, scheduleOnDeploy = true, preserveResources = false, cancelInProgress = false, onProgress, onStatus, } = {}) {
320
+ async deploy(resources, { dryRun = false, scheduleOnDeploy = false, scheduleOnDeployScope = 'changed', scheduleOnDeployThreshold, scheduleOnDeployMinFrequency, preserveResources = false, plan = false, pruneRelations = false, planToken, cancelInProgress = false, onProgress, onStatus, } = {}) {
197
321
  const logicalId = resources.project.logicalId;
198
322
  // On a 409 the project already has a deployment in progress. By default we
199
323
  // wait for it to finish then retry; with cancelInProgress we cancel it first.
@@ -204,7 +328,18 @@ class Projects {
204
328
  const deadlineAt = Date.now() + DEPLOY_CONFLICT_WAIT_DEADLINE_MS;
205
329
  for (;;) {
206
330
  try {
207
- return await this.submitDeployment(resources, { dryRun, scheduleOnDeploy, preserveResources, onProgress });
331
+ return await this.submitDeployment(resources, {
332
+ dryRun,
333
+ scheduleOnDeploy,
334
+ scheduleOnDeployScope,
335
+ scheduleOnDeployThreshold,
336
+ scheduleOnDeployMinFrequency,
337
+ preserveResources,
338
+ plan,
339
+ pruneRelations,
340
+ planToken,
341
+ onProgress,
342
+ });
208
343
  }
209
344
  catch (err) {
210
345
  if (dryRun
@@ -213,21 +348,46 @@ class Projects {
213
348
  || Date.now() >= deadlineAt) {
214
349
  throw err;
215
350
  }
216
- await this.resolveInProgressDeployment(logicalId, err.data.deploymentId, {
351
+ const finished = await this.resolveInProgressDeployment(logicalId, err.data.deploymentId, {
217
352
  cancel: cancelInProgress,
218
353
  onStatus,
219
354
  deadlineAt,
220
355
  });
356
+ // A predecessor that ran to completion is what invalidates a plan
357
+ // token, so re-POSTing with this one would spend the whole payload on a
358
+ // refusal nobody can act on. Two cases are not that: one we cancelled
359
+ // ourselves (the caller asked to deploy instead of it, and it may well
360
+ // have written nothing), and one still running when the wait gave up —
361
+ // nothing has changed, and the re-POST surfaces the conflict the caller
362
+ // needs to hear about.
363
+ if (planToken !== undefined && !cancelInProgress && finished) {
364
+ throw new ProjectPlanSupersededError({ cause: err });
365
+ }
221
366
  // loop → re-POST, now that the predecessor has reached a final state
222
367
  }
223
368
  }
224
369
  }
225
- async submitDeployment(resources, { dryRun, scheduleOnDeploy, preserveResources, onProgress }) {
370
+ async submitDeployment(resources, { dryRun, scheduleOnDeploy, scheduleOnDeployScope, scheduleOnDeployThreshold, scheduleOnDeployMinFrequency, preserveResources, plan, pruneRelations, planToken, onProgress, }) {
226
371
  // Only send preserveResources when the user opted in. The endpoint rejects
227
372
  // unknown query params, and preserveResources=false is the default (delete)
228
373
  // behavior, so omitting it keeps default deploys backwards compatible.
374
+ // plan, pruneRelations, planToken, scheduleOnDeployThreshold and
375
+ // scheduleOnDeployMinFrequency are omitted for the same reason: an older
376
+ // API knows none of them. The scope is always sent: it decides which
377
+ // checks run after the deploy, whatever the API's own default.
378
+ const scopeParam = `&scheduleOnDeployScope=${scheduleOnDeployScope}`;
379
+ const thresholdParam = scheduleOnDeployThreshold === undefined
380
+ ? ''
381
+ : `&scheduleOnDeployThreshold=${scheduleOnDeployThreshold}`;
382
+ const minFrequencyParam = scheduleOnDeployMinFrequency === undefined
383
+ ? ''
384
+ : `&scheduleOnDeployMinFrequency=${scheduleOnDeployMinFrequency}`;
229
385
  const preserveParam = preserveResources ? '&preserveResources=true' : '';
230
- const { data } = await this.api.post(`/v1/projects/deploy?dryRun=${dryRun}&scheduleOnDeploy=${scheduleOnDeploy}${preserveParam}`, resources, { transformRequest: compressJSONPayload });
386
+ const planParam = plan ? '&plan=true' : '';
387
+ const pruneParam = pruneRelations ? '&pruneRelations=true' : '';
388
+ const tokenParam = planToken ? `&planToken=${encodeURIComponent(planToken)}` : '';
389
+ const { data } = await this.api.post(`/v1/projects/deploy?dryRun=${dryRun}&scheduleOnDeploy=${scheduleOnDeploy}`
390
+ + `${scopeParam}${thresholdParam}${minFrequencyParam}${preserveParam}${planParam}${pruneParam}${tokenParam}`, resources, { transformRequest: compressJSONPayload });
231
391
  // A dry run responds synchronously with the preview diff.
232
392
  if (dryRun) {
233
393
  return { data: data };
@@ -238,18 +398,30 @@ class Projects {
238
398
  if (completed.status === 'CANCELLED') {
239
399
  throw new ProjectDeployCancelledError('A newer deployment may have cancelled yours. Try deploying again if you still need to apply your changes.');
240
400
  }
401
+ // A refused plan is not a failed deploy: nothing was written, and the
402
+ // deployment carries the plan as it looks now so the caller can show what
403
+ // moved instead of a bare error.
404
+ if (completed.error?.code === 'PLAN_STALE') {
405
+ throw new ProjectPlanStaleError(completed.error.message, completed.result?.diff ?? []);
406
+ }
241
407
  if (completed.status !== 'SUCCEEDED' || completed.result === null) {
242
408
  throw new ProjectDeployFailedError(completed.error?.message ?? 'The deployment did not complete successfully.');
243
409
  }
244
- return { data: completed.result };
410
+ // An API from before the scheduling threshold does not report the outcome;
411
+ // it scheduled as asked.
412
+ return { data: { ...completed.result, scheduled: completed.scheduleOnDeploy ?? scheduleOnDeploy } };
245
413
  }
246
414
  /**
247
415
  * Resolve a collision with an in-progress deployment so the caller can retry:
248
416
  * optionally cancel it, then wait until it reaches a final state (or is gone)
249
417
  * before returning — so the caller re-POSTs only when the slot is actually
250
418
  * free, never re-uploading the payload while the predecessor is still running.
251
- * Returns early if the overall `deadlineAt` passes (the caller then re-POSTs
252
- * once and surfaces the conflict).
419
+ *
420
+ * @returns Whether the predecessor was observed to reach a final state.
421
+ * `false` means the wait hit its deadline with the predecessor still running,
422
+ * which is a different situation for the caller: nothing has changed, so a
423
+ * plan computed before the wait still stands, and re-POSTing surfaces the
424
+ * conflict the caller needs to hear about.
253
425
  */
254
426
  async resolveInProgressDeployment(logicalId, deploymentId, { cancel, onStatus, deadlineAt }) {
255
427
  if (cancel) {
@@ -262,7 +434,7 @@ class Projects {
262
434
  if (!(err instanceof NotFoundError)) {
263
435
  throw err;
264
436
  }
265
- return;
437
+ return true;
266
438
  }
267
439
  }
268
440
  else {
@@ -274,18 +446,18 @@ class Projects {
274
446
  for (;;) {
275
447
  try {
276
448
  await this.awaitDeploymentCompletion(logicalId, deploymentId);
277
- return; // reached a final state → slot free
449
+ return true; // reached a final state → slot free
278
450
  }
279
451
  catch (err) {
280
452
  if (err instanceof NotFoundError) {
281
- return; // gone → slot free
453
+ return true; // gone → slot free
282
454
  }
283
455
  // 408 = still running after the long-poll window. Keep waiting unless the
284
456
  // overall deadline has passed, in which case return and let the caller
285
457
  // re-POST once and surface the conflict.
286
458
  if (err instanceof RequestTimeoutError) {
287
459
  if (Date.now() >= deadlineAt) {
288
- return;
460
+ return false;
289
461
  }
290
462
  continue;
291
463
  }