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.
- package/dist/ai-context/context.js +1 -0
- package/dist/ai-context/context.js.map +1 -1
- package/dist/ai-context/onboarding-boilerplate/checkly-config-template.ts +2 -0
- package/dist/ai-context/public-skills/checkly/SKILL.md +18 -5
- package/dist/ai-context/skills-command/references/communicate.md +6 -3
- package/dist/ai-context/skills-command/references/configure-api-checks.md +1 -9
- package/dist/ai-context/skills-command/references/configure-browser-checks.md +1 -8
- package/dist/ai-context/skills-command/references/configure-check-groups.md +1 -0
- package/dist/ai-context/skills-command/references/configure-dns-monitors.md +1 -9
- package/dist/ai-context/skills-command/references/configure-grpc-monitors.md +24 -0
- package/dist/ai-context/skills-command/references/configure-heartbeat-monitors.md +1 -9
- package/dist/ai-context/skills-command/references/configure-icmp-monitors.md +1 -9
- package/dist/ai-context/skills-command/references/configure-multistep-checks.md +1 -9
- package/dist/ai-context/skills-command/references/configure-playwright-checks.md +1 -1
- package/dist/ai-context/skills-command/references/configure-supporting-constructs.md +6 -2
- package/dist/ai-context/skills-command/references/configure-tcp-monitors.md +1 -10
- package/dist/ai-context/skills-command/references/configure-url-monitors.md +1 -10
- package/dist/ai-context/skills-command/references/configure.md +16 -5
- package/dist/ai-context/skills-command/references/initialize.md +11 -3
- package/dist/ai-context/skills-command/references/investigate-checks.md +1 -1
- package/dist/auth/api-key.d.ts +24 -0
- package/dist/auth/api-key.js +104 -0
- package/dist/auth/api-key.js.map +1 -0
- package/dist/auth/device-flow.d.ts +57 -0
- package/dist/auth/device-flow.js +221 -0
- package/dist/auth/device-flow.js.map +1 -0
- package/dist/auth/index.d.ts +6 -6
- package/dist/auth/index.js +64 -64
- package/dist/auth/index.js.map +1 -1
- package/dist/commands/api.js +43 -10
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/authCommand.d.ts +2 -0
- package/dist/commands/authCommand.js +77 -7
- package/dist/commands/authCommand.js.map +1 -1
- package/dist/commands/debug/parse-project.d.ts +1 -0
- package/dist/commands/debug/parse-project.js +5 -2
- package/dist/commands/debug/parse-project.js.map +1 -1
- package/dist/commands/deploy.d.ts +7 -1
- package/dist/commands/deploy.js +627 -271
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/import/plan.js +18 -4
- package/dist/commands/import/plan.js.map +1 -1
- package/dist/commands/init.js +29 -13
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/login.d.ts +18 -2
- package/dist/commands/login.js +681 -48
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js +7 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/pw-test.js +3 -2
- package/dist/commands/pw-test.js.map +1 -1
- package/dist/commands/switch.js +23 -10
- package/dist/commands/switch.js.map +1 -1
- package/dist/commands/test.js +16 -17
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/trigger.js +4 -3
- package/dist/commands/trigger.js.map +1 -1
- package/dist/commands/validate.js +1 -0
- package/dist/commands/validate.js.map +1 -1
- package/dist/constants.d.ts +1 -2
- package/dist/constants.js +0 -1
- package/dist/constants.js.map +1 -1
- package/dist/constructs/alert-channel-codegen.d.ts +6 -1
- package/dist/constructs/alert-channel-codegen.js +12 -6
- package/dist/constructs/alert-channel-codegen.js.map +1 -1
- package/dist/constructs/alert-escalation-policy-codegen.d.ts +7 -0
- package/dist/constructs/alert-escalation-policy-codegen.js +25 -8
- package/dist/constructs/alert-escalation-policy-codegen.js.map +1 -1
- package/dist/constructs/api-assertion.d.ts +0 -2
- package/dist/constructs/api-assertion.js +0 -4
- package/dist/constructs/api-assertion.js.map +1 -1
- package/dist/constructs/api-check-codegen.js +1 -1
- package/dist/constructs/api-check-codegen.js.map +1 -1
- package/dist/constructs/api-check.d.ts +4 -22
- package/dist/constructs/api-check.js +15 -17
- package/dist/constructs/api-check.js.map +1 -1
- package/dist/constructs/api-request-codegen.js +10 -8
- package/dist/constructs/api-request-codegen.js.map +1 -1
- package/dist/constructs/browser-check-bundle.d.ts +19 -13
- package/dist/constructs/browser-check-bundle.js +5 -1
- package/dist/constructs/browser-check-bundle.js.map +1 -1
- package/dist/constructs/browser-check.d.ts +1 -4
- package/dist/constructs/browser-check.js +1 -1
- package/dist/constructs/browser-check.js.map +1 -1
- package/dist/constructs/check-codegen.d.ts +39 -14
- package/dist/constructs/check-codegen.js +101 -23
- package/dist/constructs/check-codegen.js.map +1 -1
- package/dist/constructs/check-group-codegen.js +23 -9
- package/dist/constructs/check-group-codegen.js.map +1 -1
- package/dist/constructs/check-group-v1.d.ts +19 -14
- package/dist/constructs/check-group-v1.js +39 -14
- package/dist/constructs/check-group-v1.js.map +1 -1
- package/dist/constructs/check-group-v2.d.ts +0 -20
- package/dist/constructs/check-group-v2.js +0 -4
- package/dist/constructs/check-group-v2.js.map +1 -1
- package/dist/constructs/check.d.ts +45 -32
- package/dist/constructs/check.js +78 -17
- package/dist/constructs/check.js.map +1 -1
- package/dist/constructs/construct-codegen.d.ts +1 -2
- package/dist/constructs/construct-diagnostics.d.ts +3 -0
- package/dist/constructs/construct-diagnostics.js +11 -0
- package/dist/constructs/construct-diagnostics.js.map +1 -1
- package/dist/constructs/construct.d.ts +25 -4
- package/dist/constructs/construct.js +41 -5
- package/dist/constructs/construct.js.map +1 -1
- package/dist/constructs/dns-request-codegen.js +1 -1
- package/dist/constructs/dns-request-codegen.js.map +1 -1
- package/dist/constructs/email-alert-channel-codegen.js +1 -1
- package/dist/constructs/email-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/frequency-codegen.js +10 -2
- package/dist/constructs/frequency-codegen.js.map +1 -1
- package/dist/constructs/frequency.d.ts +8 -3
- package/dist/constructs/frequency.js +7 -2
- package/dist/constructs/frequency.js.map +1 -1
- package/dist/constructs/grpc-monitor.js +19 -0
- package/dist/constructs/grpc-monitor.js.map +1 -1
- package/dist/constructs/grpc-request-codegen.js +13 -4
- package/dist/constructs/grpc-request-codegen.js.map +1 -1
- package/dist/constructs/grpc-request.d.ts +23 -0
- package/dist/constructs/heartbeat-monitor.d.ts +2 -1
- package/dist/constructs/heartbeat-monitor.js +2 -2
- package/dist/constructs/heartbeat-monitor.js.map +1 -1
- package/dist/constructs/icmp-request-codegen.js +1 -1
- package/dist/constructs/icmp-request-codegen.js.map +1 -1
- package/dist/constructs/incidentio-alert-channel-codegen.d.ts +1 -1
- package/dist/constructs/incidentio-alert-channel-codegen.js +14 -8
- package/dist/constructs/incidentio-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/index.d.ts +1 -1
- package/dist/constructs/index.js +1 -1
- package/dist/constructs/index.js.map +1 -1
- package/dist/constructs/internal/assertion-validation.js +1 -2
- package/dist/constructs/internal/assertion-validation.js.map +1 -1
- package/dist/constructs/internal/codegen/context.d.ts +73 -6
- package/dist/constructs/internal/codegen/context.js +78 -6
- package/dist/constructs/internal/codegen/context.js.map +1 -1
- package/dist/constructs/internal/codegen/index.d.ts +3 -1
- package/dist/constructs/internal/codegen/index.js +2 -1
- package/dist/constructs/internal/codegen/index.js.map +1 -1
- package/dist/constructs/internal/codegen/render.d.ts +68 -0
- package/dist/constructs/internal/codegen/render.js +75 -0
- package/dist/constructs/internal/codegen/render.js.map +1 -0
- package/dist/constructs/internal/common-diagnostics.d.ts +1 -2
- package/dist/constructs/internal/common-diagnostics.js +6 -14
- package/dist/constructs/internal/common-diagnostics.js.map +1 -1
- package/dist/constructs/internal/declaring-file.d.ts +39 -0
- package/dist/constructs/internal/declaring-file.js +139 -0
- package/dist/constructs/internal/declaring-file.js.map +1 -0
- package/dist/constructs/internal/retry-strategy-defaults.d.ts +13 -0
- package/dist/constructs/internal/retry-strategy-defaults.js +14 -0
- package/dist/constructs/internal/retry-strategy-defaults.js.map +1 -0
- package/dist/constructs/key-value-pair-codegen.d.ts +6 -1
- package/dist/constructs/key-value-pair-codegen.js +24 -3
- package/dist/constructs/key-value-pair-codegen.js.map +1 -1
- package/dist/constructs/maintenance-window-codegen.d.ts +7 -0
- package/dist/constructs/maintenance-window-codegen.js +36 -19
- package/dist/constructs/maintenance-window-codegen.js.map +1 -1
- package/dist/constructs/maintenance-window.d.ts +35 -3
- package/dist/constructs/maintenance-window.js +35 -1
- package/dist/constructs/maintenance-window.js.map +1 -1
- package/dist/constructs/monitor.d.ts +1 -1
- package/dist/constructs/msteams-alert-channel-codegen.d.ts +1 -1
- package/dist/constructs/msteams-alert-channel-codegen.js +8 -18
- package/dist/constructs/msteams-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/opsgenie-alert-channel-codegen.js +1 -1
- package/dist/constructs/opsgenie-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/pagerduty-alert-channel-codegen.js +1 -1
- package/dist/constructs/pagerduty-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/phone-call-alert-channel-codegen.js +1 -1
- package/dist/constructs/phone-call-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/playwright-check-bundle.d.ts +7 -1
- package/dist/constructs/playwright-check-bundle.js +3 -0
- package/dist/constructs/playwright-check-bundle.js.map +1 -1
- package/dist/constructs/playwright-check-codegen.d.ts +85 -0
- package/dist/constructs/playwright-check-codegen.js +212 -0
- package/dist/constructs/playwright-check-codegen.js.map +1 -0
- package/dist/constructs/playwright-check.d.ts +14 -24
- package/dist/constructs/playwright-check.js +16 -52
- package/dist/constructs/playwright-check.js.map +1 -1
- package/dist/constructs/retry-strategy-codegen.d.ts +7 -1
- package/dist/constructs/retry-strategy-codegen.js +41 -32
- package/dist/constructs/retry-strategy-codegen.js.map +1 -1
- package/dist/constructs/retry-strategy.d.ts +0 -4
- package/dist/constructs/retry-strategy.js +5 -8
- package/dist/constructs/retry-strategy.js.map +1 -1
- package/dist/constructs/session.d.ts +26 -1
- package/dist/constructs/session.js +33 -2
- package/dist/constructs/session.js.map +1 -1
- package/dist/constructs/slack-alert-channel-codegen.js +1 -1
- package/dist/constructs/slack-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/slack-app-alert-channel-codegen.js +1 -1
- package/dist/constructs/slack-app-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/sms-alert-channel-codegen.js +1 -1
- package/dist/constructs/sms-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/ssl-request-codegen.js +4 -3
- package/dist/constructs/ssl-request-codegen.js.map +1 -1
- package/dist/constructs/status-page-v3-automation-rule-codegen.js +5 -4
- package/dist/constructs/status-page-v3-automation-rule-codegen.js.map +1 -1
- package/dist/constructs/status-page-v3-codegen.js +3 -2
- package/dist/constructs/status-page-v3-codegen.js.map +1 -1
- package/dist/constructs/status-page-v3-component-codegen.js +8 -7
- package/dist/constructs/status-page-v3-component-codegen.js.map +1 -1
- package/dist/constructs/tcp-monitor-codegen.js +3 -2
- package/dist/constructs/tcp-monitor-codegen.js.map +1 -1
- package/dist/constructs/tcp-monitor.d.ts +4 -3
- package/dist/constructs/tcp-monitor.js +3 -2
- package/dist/constructs/tcp-monitor.js.map +1 -1
- package/dist/constructs/telegram-alert-channel-codegen.d.ts +1 -1
- package/dist/constructs/telegram-alert-channel-codegen.js +14 -8
- package/dist/constructs/telegram-alert-channel-codegen.js.map +1 -1
- package/dist/constructs/time-zone.d.ts +24 -0
- package/dist/constructs/time-zone.js +455 -0
- package/dist/constructs/time-zone.js.map +1 -0
- package/dist/constructs/traceroute-request-codegen.js +2 -2
- package/dist/constructs/traceroute-request-codegen.js.map +1 -1
- package/dist/constructs/url-monitor-codegen.js +1 -1
- package/dist/constructs/url-monitor-codegen.js.map +1 -1
- package/dist/constructs/url-monitor.d.ts +3 -2
- package/dist/constructs/url-monitor.js +3 -0
- package/dist/constructs/url-monitor.js.map +1 -1
- package/dist/constructs/url-request-codegen.js +4 -3
- package/dist/constructs/url-request-codegen.js.map +1 -1
- package/dist/constructs/webhook-alert-channel-codegen.js +3 -3
- package/dist/constructs/webhook-alert-channel-codegen.js.map +1 -1
- package/dist/formatters/check-result-detail.js +0 -185
- package/dist/formatters/check-result-detail.js.map +1 -1
- package/dist/helpers/activate-account.d.ts +14 -0
- package/dist/helpers/activate-account.js +25 -0
- package/dist/helpers/activate-account.js.map +1 -0
- package/dist/helpers/cli-mode.d.ts +18 -0
- package/dist/helpers/cli-mode.js +41 -2
- package/dist/helpers/cli-mode.js.map +1 -1
- package/dist/helpers/command-preview.d.ts +44 -0
- package/dist/helpers/command-preview.js +29 -9
- package/dist/helpers/command-preview.js.map +1 -1
- package/dist/helpers/flags.d.ts +10 -0
- package/dist/helpers/flags.js +17 -0
- package/dist/helpers/flags.js.map +1 -1
- package/dist/helpers/onboarding/boilerplate.js +13 -1
- package/dist/helpers/onboarding/boilerplate.js.map +1 -1
- package/dist/helpers/onboarding/index.d.ts +1 -1
- package/dist/helpers/onboarding/index.js +1 -1
- package/dist/helpers/onboarding/index.js.map +1 -1
- package/dist/helpers/onboarding/messages.d.ts +6 -0
- package/dist/helpers/onboarding/messages.js +14 -0
- package/dist/helpers/onboarding/messages.js.map +1 -1
- package/dist/helpers/onboarding/skill-install.js +2 -2
- package/dist/helpers/onboarding/skill-install.js.map +1 -1
- package/dist/helpers/wrap.js +1 -1
- package/dist/helpers/wrap.js.map +1 -1
- package/dist/reporters/abstract-list.js +11 -2
- package/dist/reporters/abstract-list.js.map +1 -1
- package/dist/reporters/github.js +3 -2
- package/dist/reporters/github.js.map +1 -1
- package/dist/reporters/util.d.ts +1 -0
- package/dist/reporters/util.js +5 -58
- package/dist/reporters/util.js.map +1 -1
- package/dist/rest/analytics.js +0 -4
- package/dist/rest/analytics.js.map +1 -1
- package/dist/rest/api.d.ts +8 -1
- package/dist/rest/api.js +21 -3
- package/dist/rest/api.js.map +1 -1
- package/dist/rest/check-results.d.ts +1 -50
- package/dist/rest/check-results.js.map +1 -1
- package/dist/rest/checkly-storage.d.ts +6 -1
- package/dist/rest/checkly-storage.js +13 -2
- package/dist/rest/checkly-storage.js.map +1 -1
- package/dist/rest/errors.d.ts +13 -0
- package/dist/rest/errors.js +5 -1
- package/dist/rest/errors.js.map +1 -1
- package/dist/rest/projects.d.ts +254 -4
- package/dist/rest/projects.js +184 -12
- package/dist/rest/projects.js.map +1 -1
- package/dist/services/abstract-check-runner.d.ts +11 -0
- package/dist/services/abstract-check-runner.js +98 -46
- package/dist/services/abstract-check-runner.js.map +1 -1
- package/dist/services/check-parser/bundler.d.ts +26 -0
- package/dist/services/check-parser/bundler.js +81 -7
- package/dist/services/check-parser/bundler.js.map +1 -1
- package/dist/services/check-parser/cache-hash.d.ts +1 -4
- package/dist/services/check-parser/cache-hash.js.map +1 -1
- package/dist/services/checkly-config-codegen.js +1 -4
- package/dist/services/checkly-config-codegen.js.map +1 -1
- package/dist/services/checkly-config-loader.d.ts +7 -33
- package/dist/services/checkly-config-loader.js +50 -47
- package/dist/services/checkly-config-loader.js.map +1 -1
- package/dist/services/config.d.ts +2 -0
- package/dist/services/config.js +14 -0
- package/dist/services/config.js.map +1 -1
- package/dist/services/content-hash.d.ts +14 -0
- package/dist/services/content-hash.js +22 -0
- package/dist/services/content-hash.js.map +1 -0
- package/dist/services/deploy-diff/diff-lines.d.ts +38 -0
- package/dist/services/deploy-diff/diff-lines.js +191 -0
- package/dist/services/deploy-diff/diff-lines.js.map +1 -0
- package/dist/services/deploy-diff/import-shape.d.ts +171 -0
- package/dist/services/deploy-diff/import-shape.js +633 -0
- package/dist/services/deploy-diff/import-shape.js.map +1 -0
- package/dist/services/deploy-diff/legacy-payload.d.ts +22 -0
- package/dist/services/deploy-diff/legacy-payload.js +51 -0
- package/dist/services/deploy-diff/legacy-payload.js.map +1 -0
- package/dist/services/deploy-diff/plan-summary.d.ts +37 -0
- package/dist/services/deploy-diff/plan-summary.js +154 -0
- package/dist/services/deploy-diff/plan-summary.js.map +1 -0
- package/dist/services/deploy-diff/preview-output.d.ts +61 -0
- package/dist/services/deploy-diff/preview-output.js +394 -0
- package/dist/services/deploy-diff/preview-output.js.map +1 -0
- package/dist/services/deploy-diff/render.d.ts +53 -0
- package/dist/services/deploy-diff/render.js +317 -0
- package/dist/services/deploy-diff/render.js.map +1 -0
- package/dist/services/deploy-diff/shape-changes.d.ts +2 -0
- package/dist/services/deploy-diff/shape-changes.js +35 -0
- package/dist/services/deploy-diff/shape-changes.js.map +1 -0
- package/dist/services/deploy-diff/source-index.d.ts +18 -0
- package/dist/services/deploy-diff/source-index.js +48 -0
- package/dist/services/deploy-diff/source-index.js.map +1 -0
- package/dist/services/deploy-diff/variable-names.d.ts +30 -0
- package/dist/services/deploy-diff/variable-names.js +64 -0
- package/dist/services/deploy-diff/variable-names.js.map +1 -0
- package/dist/services/project-parser.d.ts +5 -0
- package/dist/services/project-parser.js +25 -13
- package/dist/services/project-parser.js.map +1 -1
- package/dist/services/snapshot-service.d.ts +25 -8
- package/dist/services/snapshot-service.js +46 -4
- package/dist/services/snapshot-service.js.map +1 -1
- package/dist/services/test-filters.d.ts +18 -0
- package/dist/services/test-filters.js +10 -0
- package/dist/services/test-filters.js.map +1 -1
- package/dist/services/test-runner.js +7 -3
- package/dist/services/test-runner.js.map +1 -1
- package/dist/services/test-session-cancel.js +1 -1
- package/dist/services/test-session-cancel.js.map +1 -1
- package/dist/services/util.d.ts +17 -2
- package/dist/services/util.js +118 -11
- package/dist/services/util.js.map +1 -1
- package/dist/services/write-back/apply-edits.d.ts +29 -0
- package/dist/services/write-back/apply-edits.js +255 -0
- package/dist/services/write-back/apply-edits.js.map +1 -0
- package/dist/services/write-back/helper-edit.d.ts +135 -0
- package/dist/services/write-back/helper-edit.js +343 -0
- package/dist/services/write-back/helper-edit.js.map +1 -0
- package/dist/services/write-back/imports.d.ts +30 -0
- package/dist/services/write-back/imports.js +82 -0
- package/dist/services/write-back/imports.js.map +1 -0
- package/dist/services/write-back/literal-edit.d.ts +183 -0
- package/dist/services/write-back/literal-edit.js +359 -0
- package/dist/services/write-back/literal-edit.js.map +1 -0
- package/dist/services/write-back/output.d.ts +26 -0
- package/dist/services/write-back/output.js +110 -0
- package/dist/services/write-back/output.js.map +1 -0
- package/dist/services/write-back/plan.d.ts +173 -0
- package/dist/services/write-back/plan.js +968 -0
- package/dist/services/write-back/plan.js.map +1 -0
- package/dist/services/write-back/source-file.d.ts +118 -0
- package/dist/services/write-back/source-file.js +432 -0
- package/dist/services/write-back/source-file.js.map +1 -0
- package/dist/sourcegen/index.d.ts +1 -1
- package/dist/sourcegen/index.js +1 -1
- package/dist/sourcegen/index.js.map +1 -1
- package/dist/sourcegen/program.d.ts +19 -1
- package/dist/sourcegen/program.js +32 -7
- package/dist/sourcegen/program.js.map +1 -1
- package/oclif.manifest.json +676 -635
- package/package.json +13 -13
- package/dist/commands/rules.d.ts +0 -9
- package/dist/commands/rules.js +0 -13
- package/dist/commands/rules.js.map +0 -1
- package/dist/constructs/agentic-check-codegen.d.ts +0 -22
- package/dist/constructs/agentic-check-codegen.js +0 -59
- package/dist/constructs/agentic-check-codegen.js.map +0 -1
- package/dist/constructs/agentic-check.d.ts +0 -237
- package/dist/constructs/agentic-check.js +0 -100
- package/dist/constructs/agentic-check.js.map +0 -1
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/typescript-estree';
|
|
2
|
+
import type { Value } from '../../sourcegen/index.js';
|
|
3
|
+
import { type Node, type ParsedSource, type SourceToken, type Splice } from './source-file.js';
|
|
4
|
+
/**
|
|
5
|
+
* Literal edits of the options object of a construct call: where a path
|
|
6
|
+
* (`['request', 'url']`) lands in the object, what may be replaced there,
|
|
7
|
+
* and how a plain value is rendered in the file's own style.
|
|
8
|
+
*
|
|
9
|
+
* A position that exists and holds a plain literal may be replaced; a key
|
|
10
|
+
* the innermost object lacks is inserted after the object's last member;
|
|
11
|
+
* anything else — a variable, a spread, a missing parent — is refused,
|
|
12
|
+
* because a rewrite that guesses what the code means is worse than none.
|
|
13
|
+
* A value the construct spells with a helper (`Frequency.EVERY_5M`,
|
|
14
|
+
* `RetryStrategyBuilder.fixedStrategy({ … })`) is `helper-edit.ts`'s job;
|
|
15
|
+
* `apply-edits.ts` splices both kinds into the text, and `imports.ts` adds
|
|
16
|
+
* the helper classes to the file's import.
|
|
17
|
+
*
|
|
18
|
+
* Rendering copies what surrounds the value: the quote character the object
|
|
19
|
+
* already uses, its indentation unit, whether it ends members with a
|
|
20
|
+
* trailing comma, and the file's line ending. Commas and comments are
|
|
21
|
+
* located through the parser's tokens, so a comma or a line break inside a
|
|
22
|
+
* comment cannot mislead a splice. (`src/sourcegen` renders construct
|
|
23
|
+
* source too, but it orders keys and fixes the style, which is what a
|
|
24
|
+
* splice into a user's file must not do.)
|
|
25
|
+
*/
|
|
26
|
+
export interface LiteralEdit {
|
|
27
|
+
/** Property path inside the options object; a numeric segment indexes an array. */
|
|
28
|
+
path: string[];
|
|
29
|
+
/** The value to write. `null` and `undefined` are refused (see `renderValue`). */
|
|
30
|
+
value: unknown;
|
|
31
|
+
/** Absent on a literal edit; a `HelperEdit` (`helper-edit.ts`) sets it. */
|
|
32
|
+
helper?: undefined;
|
|
33
|
+
}
|
|
34
|
+
export interface AppliedEdit extends LiteralEdit {
|
|
35
|
+
/** The source text the edit replaced, or undefined when the property was added. */
|
|
36
|
+
previous?: string;
|
|
37
|
+
/** The text written for the value. */
|
|
38
|
+
rendered: string;
|
|
39
|
+
/** Whether the text is a plain literal or a helper expression (see `helper-edit.ts`). */
|
|
40
|
+
form: 'literal' | 'helper';
|
|
41
|
+
/** For the literal form, the value the written text evaluates to. */
|
|
42
|
+
expected?: unknown;
|
|
43
|
+
/** For the helper form, the expression the text was rendered from, and the local name of each class it references. */
|
|
44
|
+
expression?: {
|
|
45
|
+
value: Value;
|
|
46
|
+
locals: ReadonlyMap<string, string>;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** An edit of either kind that was not applied, with the reason. */
|
|
50
|
+
export interface SkippedEdit {
|
|
51
|
+
path: string[];
|
|
52
|
+
value: unknown;
|
|
53
|
+
reason: string;
|
|
54
|
+
}
|
|
55
|
+
export interface EditResult {
|
|
56
|
+
text: string;
|
|
57
|
+
applied: AppliedEdit[];
|
|
58
|
+
skipped: SkippedEdit[];
|
|
59
|
+
/** Helper classes added to the file's `checkly/constructs` import. */
|
|
60
|
+
imports: string[];
|
|
61
|
+
}
|
|
62
|
+
export interface SourceStyle {
|
|
63
|
+
quote: '\'' | '"';
|
|
64
|
+
indentUnit: string;
|
|
65
|
+
lineEnding: '\n' | '\r\n';
|
|
66
|
+
}
|
|
67
|
+
type ObjectNode = TSESTree.ObjectExpression;
|
|
68
|
+
export type Resolution = {
|
|
69
|
+
kind: 'found';
|
|
70
|
+
node: Node;
|
|
71
|
+
parent: ObjectNode | TSESTree.ArrayExpression;
|
|
72
|
+
} | {
|
|
73
|
+
kind: 'missing';
|
|
74
|
+
parent: ObjectNode;
|
|
75
|
+
key: string;
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'unsupported';
|
|
78
|
+
reason: string;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Whether a node is a value this module could have written itself: a
|
|
82
|
+
* string, number or boolean literal, a template with no `${}`, a negated
|
|
83
|
+
* number, or an array or object built only of those. Such a node can be
|
|
84
|
+
* replaced wholesale without losing anything but the comments inside it.
|
|
85
|
+
*/
|
|
86
|
+
export declare function isPlainLiteral(node: Node): boolean;
|
|
87
|
+
/** The value a plain literal node evaluates to; only meaningful when `isPlainLiteral` holds. */
|
|
88
|
+
export declare function evaluateLiteral(node: Node): unknown;
|
|
89
|
+
export declare function describe(node: Node): string;
|
|
90
|
+
export interface ResolveOptions {
|
|
91
|
+
/** Whether an existing node at the path may be replaced; a plain literal by default. */
|
|
92
|
+
replaceable?: (node: Node) => boolean;
|
|
93
|
+
/** What a refused node should have been, for the reason. */
|
|
94
|
+
expected?: string;
|
|
95
|
+
/**
|
|
96
|
+
* Whether a `null` in the code may be replaced. A literal edit never
|
|
97
|
+
* writes null (`renderValue`), so by default a null is left for the user;
|
|
98
|
+
* a helper edit writes an expression and may replace it like any literal.
|
|
99
|
+
*/
|
|
100
|
+
replaceNull?: boolean;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Where `path` lands inside `options`: an existing node that may be
|
|
104
|
+
* replaced, a key the innermost object lacks, or a position this module
|
|
105
|
+
* must not touch.
|
|
106
|
+
*/
|
|
107
|
+
export declare function resolvePath(options: ObjectNode, path: readonly string[], resolve?: ResolveOptions): Resolution;
|
|
108
|
+
/**
|
|
109
|
+
* The conventions the edited object follows: the quote most of its strings
|
|
110
|
+
* use (the whole file's when it has none), the indentation unit between it
|
|
111
|
+
* and its members, and the file's line ending. Defaults (single quotes, two
|
|
112
|
+
* spaces, LF) apply where there is no evidence.
|
|
113
|
+
*/
|
|
114
|
+
export declare function detectStyle(source: ParsedSource, options: ObjectNode): SourceStyle;
|
|
115
|
+
/** The line ending a file uses: CRLF when it holds one, else LF. */
|
|
116
|
+
export declare function lineEndingOf(text: string): SourceStyle['lineEnding'];
|
|
117
|
+
export declare function lineStart(text: string, offset: number): number;
|
|
118
|
+
/** The leading whitespace of the line holding `offset`. */
|
|
119
|
+
export declare function indentationAt(text: string, offset: number): string;
|
|
120
|
+
export declare function isMultiLine(text: string, node: Node): boolean;
|
|
121
|
+
/** The comma token that follows a list's last member, if the list has one. */
|
|
122
|
+
export declare function trailingCommaOf(source: ParsedSource, list: ObjectNode | TSESTree.ArrayExpression): SourceToken | undefined;
|
|
123
|
+
export declare function quoteString(value: string, quote: SourceStyle['quote']): string;
|
|
124
|
+
/**
|
|
125
|
+
* `value` as a template literal, for a multi-line string replacing one so
|
|
126
|
+
* the author's form is kept; undefined when it cannot read back as the same
|
|
127
|
+
* string, which a parser guarantees only for LF and TAB among the control
|
|
128
|
+
* characters (CR and CRLF are normalised to LF inside a template).
|
|
129
|
+
*/
|
|
130
|
+
export declare function templateLiteral(value: string): string | undefined;
|
|
131
|
+
export declare function renderKey(key: string, quote: SourceStyle['quote']): string;
|
|
132
|
+
/**
|
|
133
|
+
* The source text for a value. Arrays of scalars stay on one line; arrays
|
|
134
|
+
* holding objects, and objects, put one member per line indented one unit
|
|
135
|
+
* past `column` (the indentation of the line the value starts on), unless
|
|
136
|
+
* `inline` asks for the one-line form an existing node used. `trailingComma`
|
|
137
|
+
* ends the last member of a multi-line list with a comma, as the edited
|
|
138
|
+
* object does.
|
|
139
|
+
*
|
|
140
|
+
* @throws WriteBackSkipped for a value the construct cannot hold as a
|
|
141
|
+
* literal: null or undefined (Checkly has cleared the property, and removing
|
|
142
|
+
* it from the code would hand it to a default that need not match), a
|
|
143
|
+
* non-finite number, or anything that is not JSON data.
|
|
144
|
+
*/
|
|
145
|
+
export declare function renderValue(value: unknown, style: SourceStyle, layout: {
|
|
146
|
+
column: string;
|
|
147
|
+
inline: boolean;
|
|
148
|
+
trailingComma: boolean;
|
|
149
|
+
at?: string;
|
|
150
|
+
}): string;
|
|
151
|
+
/**
|
|
152
|
+
* A list of rendered members between `open` and `close`: empty as `[]` or
|
|
153
|
+
* `{}`, on one line when `inline`, otherwise one member per line indented one
|
|
154
|
+
* unit past `column`, the last ending with a comma when `trailingComma`.
|
|
155
|
+
*/
|
|
156
|
+
export declare function layoutList(open: string, members: readonly string[], close: string, style: SourceStyle, layout: {
|
|
157
|
+
column: string;
|
|
158
|
+
inline: boolean;
|
|
159
|
+
trailingComma: boolean;
|
|
160
|
+
}): string;
|
|
161
|
+
/**
|
|
162
|
+
* The indentation a member added to `parent` gets: that of the last
|
|
163
|
+
* member's line when it starts one, otherwise one unit past the object's
|
|
164
|
+
* own line (which also covers an empty object).
|
|
165
|
+
*/
|
|
166
|
+
export declare function memberColumn(text: string, parent: ObjectNode, style: SourceStyle): string;
|
|
167
|
+
/**
|
|
168
|
+
* The single splice that adds `pending` members to `parent`, after its last
|
|
169
|
+
* member. A multi-line object gets one line per member at the last member's
|
|
170
|
+
* indentation, a trailing comma on the last new member only if the object
|
|
171
|
+
* already used one, and a comma added right after the old last member if it
|
|
172
|
+
* had none. The new lines go after the line the last member (or its comma)
|
|
173
|
+
* ends on, so a comment on that line stays with that member — unless a
|
|
174
|
+
* comment runs on past that line end, in which case they go right after the
|
|
175
|
+
* member's comma rather than into the comment. A one-line object gets
|
|
176
|
+
* `, key: value` before its closing brace, and an empty one is rewritten as
|
|
177
|
+
* `{ key: value }`.
|
|
178
|
+
*/
|
|
179
|
+
export declare function insertionSplice(text: string, source: ParsedSource, parent: ObjectNode, pending: readonly {
|
|
180
|
+
key: string;
|
|
181
|
+
rendered: string;
|
|
182
|
+
}[], style: SourceStyle): Splice;
|
|
183
|
+
export {};
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
import { appendAfterLast, IDENTIFIER, memberName, tokensBetween, WriteBackSkipped, walk, } from './source-file.js';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a node is a value this module could have written itself: a
|
|
4
|
+
* string, number or boolean literal, a template with no `${}`, a negated
|
|
5
|
+
* number, or an array or object built only of those. Such a node can be
|
|
6
|
+
* replaced wholesale without losing anything but the comments inside it.
|
|
7
|
+
*/
|
|
8
|
+
export function isPlainLiteral(node) {
|
|
9
|
+
switch (node.type) {
|
|
10
|
+
case 'Literal':
|
|
11
|
+
return typeof node.value === 'string' || typeof node.value === 'number' || typeof node.value === 'boolean';
|
|
12
|
+
case 'TemplateLiteral':
|
|
13
|
+
return node.expressions.length === 0;
|
|
14
|
+
case 'UnaryExpression':
|
|
15
|
+
return node.operator === '-' && node.argument.type === 'Literal' && typeof node.argument.value === 'number';
|
|
16
|
+
case 'ArrayExpression':
|
|
17
|
+
return node.elements.every(element => element !== null && element.type !== 'SpreadElement' && isPlainLiteral(element));
|
|
18
|
+
case 'ObjectExpression':
|
|
19
|
+
return node.properties.every(property => memberName(property) !== undefined
|
|
20
|
+
&& !property.shorthand
|
|
21
|
+
&& isPlainLiteral(property.value));
|
|
22
|
+
default:
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The value a plain literal node evaluates to; only meaningful when `isPlainLiteral` holds. */
|
|
27
|
+
export function evaluateLiteral(node) {
|
|
28
|
+
switch (node.type) {
|
|
29
|
+
case 'Literal':
|
|
30
|
+
return node.value;
|
|
31
|
+
case 'TemplateLiteral':
|
|
32
|
+
return node.quasis.map(quasi => quasi.value.cooked ?? '').join('');
|
|
33
|
+
case 'UnaryExpression':
|
|
34
|
+
return -evaluateLiteral(node.argument);
|
|
35
|
+
case 'ArrayExpression':
|
|
36
|
+
return node.elements.map(element => (element === null ? undefined : evaluateLiteral(element)));
|
|
37
|
+
case 'ObjectExpression':
|
|
38
|
+
return Object.fromEntries(node.properties.map(property => [memberName(property), evaluateLiteral(property.value)]));
|
|
39
|
+
default:
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function describe(node) {
|
|
44
|
+
switch (node.type) {
|
|
45
|
+
case 'Identifier':
|
|
46
|
+
return `the variable ${node.name}`;
|
|
47
|
+
case 'MemberExpression':
|
|
48
|
+
return node.object.type === 'Identifier' && node.property.type === 'Identifier'
|
|
49
|
+
? `${node.object.name}.${node.property.name}`
|
|
50
|
+
: 'a member expression';
|
|
51
|
+
case 'CallExpression':
|
|
52
|
+
return 'a function call';
|
|
53
|
+
case 'NewExpression':
|
|
54
|
+
return 'a constructor call';
|
|
55
|
+
case 'TemplateLiteral':
|
|
56
|
+
return node.expressions.length === 0 ? 'a string' : 'a template with expressions';
|
|
57
|
+
case 'Literal':
|
|
58
|
+
if (node.value === null) {
|
|
59
|
+
return 'null';
|
|
60
|
+
}
|
|
61
|
+
if ('regex' in node && node.regex !== undefined) {
|
|
62
|
+
return 'a regular expression';
|
|
63
|
+
}
|
|
64
|
+
return typeof node.value === 'bigint' ? 'a bigint' : 'a literal';
|
|
65
|
+
case 'ArrayExpression':
|
|
66
|
+
return node.elements.some(element => element === null) ? 'an array with holes' : 'an array with non-literal elements';
|
|
67
|
+
case 'ObjectExpression':
|
|
68
|
+
return 'an object with non-literal members';
|
|
69
|
+
default:
|
|
70
|
+
return node.type.startsWith('TS') ? 'a TypeScript expression' : 'not a plain literal';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Where `path` lands inside `options`: an existing node that may be
|
|
75
|
+
* replaced, a key the innermost object lacks, or a position this module
|
|
76
|
+
* must not touch.
|
|
77
|
+
*/
|
|
78
|
+
export function resolvePath(options, path, resolve = {}) {
|
|
79
|
+
const { replaceable = isPlainLiteral, expected = 'a plain literal', replaceNull = false } = resolve;
|
|
80
|
+
if (path.length === 0) {
|
|
81
|
+
return { kind: 'unsupported', reason: 'no property named' };
|
|
82
|
+
}
|
|
83
|
+
let node = options;
|
|
84
|
+
let parent = options;
|
|
85
|
+
for (let i = 0; i < path.length; i++) {
|
|
86
|
+
const segment = path[i];
|
|
87
|
+
const last = i === path.length - 1;
|
|
88
|
+
if (node.type === 'ObjectExpression') {
|
|
89
|
+
const members = node.properties.filter(property => memberName(property) === segment);
|
|
90
|
+
if (members.length > 1) {
|
|
91
|
+
return { kind: 'unsupported', reason: `${segment} is set twice in the code` };
|
|
92
|
+
}
|
|
93
|
+
if (members.length === 0) {
|
|
94
|
+
if (!last) {
|
|
95
|
+
return { kind: 'unsupported', reason: `${path.slice(0, i + 1).join('.')} is not set in the code` };
|
|
96
|
+
}
|
|
97
|
+
// A method, accessor or computed key could be this very property
|
|
98
|
+
// under a spelling this module cannot read; adding a second one
|
|
99
|
+
// would leave the object with two.
|
|
100
|
+
if (node.properties.some(property => memberName(property) === undefined)) {
|
|
101
|
+
const where = path.slice(0, i).join('.') || 'the options';
|
|
102
|
+
return { kind: 'unsupported', reason: `${where} has members this tool cannot read` };
|
|
103
|
+
}
|
|
104
|
+
return { kind: 'missing', parent: node, key: segment };
|
|
105
|
+
}
|
|
106
|
+
if (members[0].shorthand) {
|
|
107
|
+
return { kind: 'unsupported', reason: `${segment} is the variable ${segment}, not a literal` };
|
|
108
|
+
}
|
|
109
|
+
// A spread or an unreadable member after it could override the value
|
|
110
|
+
// at runtime, which would make the edit look applied and change nothing.
|
|
111
|
+
const index = node.properties.indexOf(members[0]);
|
|
112
|
+
if (node.properties.slice(index + 1).some(property => memberName(property) === undefined)) {
|
|
113
|
+
return { kind: 'unsupported', reason: `${segment} may be overridden by a later member` };
|
|
114
|
+
}
|
|
115
|
+
parent = node;
|
|
116
|
+
node = members[0].value;
|
|
117
|
+
}
|
|
118
|
+
else if (node.type === 'ArrayExpression') {
|
|
119
|
+
const index = /^\d+$/.test(segment) ? Number(segment) : -1;
|
|
120
|
+
const element = node.elements[index];
|
|
121
|
+
if (element === null || element === undefined) {
|
|
122
|
+
return { kind: 'unsupported', reason: `${path.slice(0, i + 1).join('.')} is not set in the code` };
|
|
123
|
+
}
|
|
124
|
+
parent = node;
|
|
125
|
+
node = element;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
return { kind: 'unsupported', reason: `${path.slice(0, i).join('.')} is ${describe(node)}, not an object literal` };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
if (node.type === 'Literal' && node.value === null && !replaceNull) {
|
|
132
|
+
return { kind: 'unsupported', reason: `${path.join('.')} is null in the code; set a value by hand` };
|
|
133
|
+
}
|
|
134
|
+
if (!replaceable(node)) {
|
|
135
|
+
return { kind: 'unsupported', reason: `${path.join('.')} is ${describe(node)}, not ${expected}` };
|
|
136
|
+
}
|
|
137
|
+
return { kind: 'found', node, parent };
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The conventions the edited object follows: the quote most of its strings
|
|
141
|
+
* use (the whole file's when it has none), the indentation unit between it
|
|
142
|
+
* and its members, and the file's line ending. Defaults (single quotes, two
|
|
143
|
+
* spaces, LF) apply where there is no evidence.
|
|
144
|
+
*/
|
|
145
|
+
export function detectStyle(source, options) {
|
|
146
|
+
const { text } = source;
|
|
147
|
+
const count = (root) => {
|
|
148
|
+
let single = 0;
|
|
149
|
+
let double = 0;
|
|
150
|
+
for (const node of walk(root)) {
|
|
151
|
+
if (node.type === 'Literal' && typeof node.value === 'string') {
|
|
152
|
+
if (text[node.range[0]] === '"') {
|
|
153
|
+
double++;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
single++;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return { single, double };
|
|
161
|
+
};
|
|
162
|
+
let quotes = count(options);
|
|
163
|
+
if (quotes.single === 0 && quotes.double === 0) {
|
|
164
|
+
quotes = count(source.program);
|
|
165
|
+
}
|
|
166
|
+
const lineEnding = lineEndingOf(text);
|
|
167
|
+
let indentUnit = ' ';
|
|
168
|
+
const first = options.properties[0];
|
|
169
|
+
if (first !== undefined && isMultiLine(text, options)) {
|
|
170
|
+
const outer = indentationAt(text, options.range[0]);
|
|
171
|
+
const inner = indentationAt(text, first.range[0]);
|
|
172
|
+
if (inner.length > outer.length && inner.startsWith(outer)) {
|
|
173
|
+
indentUnit = inner.slice(outer.length);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
return { quote: quotes.double > quotes.single ? '"' : '\'', indentUnit, lineEnding };
|
|
177
|
+
}
|
|
178
|
+
/** The line ending a file uses: CRLF when it holds one, else LF. */
|
|
179
|
+
export function lineEndingOf(text) {
|
|
180
|
+
return text.includes('\r\n') ? '\r\n' : '\n';
|
|
181
|
+
}
|
|
182
|
+
export function lineStart(text, offset) {
|
|
183
|
+
const index = text.lastIndexOf('\n', offset - 1);
|
|
184
|
+
return index === -1 ? 0 : index + 1;
|
|
185
|
+
}
|
|
186
|
+
/** The leading whitespace of the line holding `offset`. */
|
|
187
|
+
export function indentationAt(text, offset) {
|
|
188
|
+
const start = lineStart(text, offset);
|
|
189
|
+
const match = /^[ \t]*/.exec(text.slice(start, offset));
|
|
190
|
+
return match === null ? '' : match[0];
|
|
191
|
+
}
|
|
192
|
+
export function isMultiLine(text, node) {
|
|
193
|
+
return text.slice(node.range[0], node.range[1]).includes('\n');
|
|
194
|
+
}
|
|
195
|
+
/** The comma token that follows a list's last member, if the list has one. */
|
|
196
|
+
export function trailingCommaOf(source, list) {
|
|
197
|
+
const members = list.type === 'ObjectExpression' ? list.properties : list.elements;
|
|
198
|
+
const last = members[members.length - 1];
|
|
199
|
+
if (last === null || last === undefined) {
|
|
200
|
+
return undefined;
|
|
201
|
+
}
|
|
202
|
+
return tokensBetween(source, last.range[1], list.range[1] - 1).find(token => token.kind === 'token' && token.value === ',');
|
|
203
|
+
}
|
|
204
|
+
export function quoteString(value, quote) {
|
|
205
|
+
// JSON.stringify encodes every control character and backslash; U+2028
|
|
206
|
+
// and U+2029 it leaves in the clear, and a parser reading them as line
|
|
207
|
+
// terminators would see an unterminated string. Only the quote character
|
|
208
|
+
// needs swapping for a single-quoted file.
|
|
209
|
+
const json = JSON.stringify(value).replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029');
|
|
210
|
+
if (quote === '"') {
|
|
211
|
+
return json;
|
|
212
|
+
}
|
|
213
|
+
return `'${json.slice(1, -1).replace(/\\"/g, '"').replace(/'/g, '\\\'')}'`;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* `value` as a template literal, for a multi-line string replacing one so
|
|
217
|
+
* the author's form is kept; undefined when it cannot read back as the same
|
|
218
|
+
* string, which a parser guarantees only for LF and TAB among the control
|
|
219
|
+
* characters (CR and CRLF are normalised to LF inside a template).
|
|
220
|
+
*/
|
|
221
|
+
export function templateLiteral(value) {
|
|
222
|
+
// eslint-disable-next-line no-control-regex
|
|
223
|
+
if (/[\u0000-\u0008\u000b-\u001f\u007f]/.test(value)) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
return '`' + value.replace(/\\/g, '\\\\').replace(/`/g, '\\`').replace(/\$\{/g, '\\${') + '`';
|
|
227
|
+
}
|
|
228
|
+
export function renderKey(key, quote) {
|
|
229
|
+
// A bare `__proto__` in an object literal sets the prototype rather than
|
|
230
|
+
// a property; quoted, it is a property like any other.
|
|
231
|
+
return IDENTIFIER.test(key) && key !== '__proto__' ? key : quoteString(key, quote);
|
|
232
|
+
}
|
|
233
|
+
function isScalar(value) {
|
|
234
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
235
|
+
}
|
|
236
|
+
function isPlainObject(value) {
|
|
237
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
const prototype = Object.getPrototypeOf(value);
|
|
241
|
+
return prototype === Object.prototype || prototype === null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The source text for a value. Arrays of scalars stay on one line; arrays
|
|
245
|
+
* holding objects, and objects, put one member per line indented one unit
|
|
246
|
+
* past `column` (the indentation of the line the value starts on), unless
|
|
247
|
+
* `inline` asks for the one-line form an existing node used. `trailingComma`
|
|
248
|
+
* ends the last member of a multi-line list with a comma, as the edited
|
|
249
|
+
* object does.
|
|
250
|
+
*
|
|
251
|
+
* @throws WriteBackSkipped for a value the construct cannot hold as a
|
|
252
|
+
* literal: null or undefined (Checkly has cleared the property, and removing
|
|
253
|
+
* it from the code would hand it to a default that need not match), a
|
|
254
|
+
* non-finite number, or anything that is not JSON data.
|
|
255
|
+
*/
|
|
256
|
+
export function renderValue(value, style, layout) {
|
|
257
|
+
if (value === null || value === undefined) {
|
|
258
|
+
throw new WriteBackSkipped(layout.at === undefined
|
|
259
|
+
? 'Checkly has no value for it; edit the property by hand'
|
|
260
|
+
: `Checkly has no value for ${layout.at}; edit the property by hand`);
|
|
261
|
+
}
|
|
262
|
+
if (typeof value === 'string') {
|
|
263
|
+
return quoteString(value, style.quote);
|
|
264
|
+
}
|
|
265
|
+
if (typeof value === 'number') {
|
|
266
|
+
if (!Number.isFinite(value)) {
|
|
267
|
+
throw new WriteBackSkipped(`${value} cannot be written as a literal`);
|
|
268
|
+
}
|
|
269
|
+
return String(value);
|
|
270
|
+
}
|
|
271
|
+
if (typeof value === 'boolean') {
|
|
272
|
+
return String(value);
|
|
273
|
+
}
|
|
274
|
+
const inner = layout.column + style.indentUnit;
|
|
275
|
+
const nested = (member, key) => renderValue(member, style, { ...layout, column: inner, at: layout.at === undefined ? key : `${layout.at}.${key}` });
|
|
276
|
+
if (Array.isArray(value)) {
|
|
277
|
+
const members = value.map((member, index) => nested(member, String(index)));
|
|
278
|
+
return layoutList('[', members, ']', style, { ...layout, inline: layout.inline || value.every(isScalar) });
|
|
279
|
+
}
|
|
280
|
+
if (isPlainObject(value)) {
|
|
281
|
+
const members = Object.entries(value).map(([key, member]) => `${renderKey(key, style.quote)}: ${nested(member, key)}`);
|
|
282
|
+
return layoutList('{', members, '}', style, layout);
|
|
283
|
+
}
|
|
284
|
+
const kind = typeof value === 'object' ? (value.constructor?.name ?? 'object') : typeof value;
|
|
285
|
+
throw new WriteBackSkipped(`a ${kind} cannot be written as a literal`);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* A list of rendered members between `open` and `close`: empty as `[]` or
|
|
289
|
+
* `{}`, on one line when `inline`, otherwise one member per line indented one
|
|
290
|
+
* unit past `column`, the last ending with a comma when `trailingComma`.
|
|
291
|
+
*/
|
|
292
|
+
export function layoutList(open, members, close, style, layout) {
|
|
293
|
+
if (members.length === 0) {
|
|
294
|
+
return `${open}${close}`;
|
|
295
|
+
}
|
|
296
|
+
if (layout.inline) {
|
|
297
|
+
return open === '{' ? `{ ${members.join(', ')} }` : `${open}${members.join(', ')}${close}`;
|
|
298
|
+
}
|
|
299
|
+
const inner = layout.column + style.indentUnit;
|
|
300
|
+
return `${open}${style.lineEnding}${members.map(member => `${inner}${member}`).join(`,${style.lineEnding}`)}`
|
|
301
|
+
+ `${layout.trailingComma ? ',' : ''}${style.lineEnding}${layout.column}${close}`;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The indentation a member added to `parent` gets: that of the last
|
|
305
|
+
* member's line when it starts one, otherwise one unit past the object's
|
|
306
|
+
* own line (which also covers an empty object).
|
|
307
|
+
*/
|
|
308
|
+
export function memberColumn(text, parent, style) {
|
|
309
|
+
const last = parent.properties[parent.properties.length - 1];
|
|
310
|
+
if (last !== undefined) {
|
|
311
|
+
const indentation = indentationAt(text, last.range[0]);
|
|
312
|
+
if (lineStart(text, last.range[0]) + indentation.length === last.range[0]) {
|
|
313
|
+
return indentation;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return indentationAt(text, parent.range[0]) + style.indentUnit;
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* The single splice that adds `pending` members to `parent`, after its last
|
|
320
|
+
* member. A multi-line object gets one line per member at the last member's
|
|
321
|
+
* indentation, a trailing comma on the last new member only if the object
|
|
322
|
+
* already used one, and a comma added right after the old last member if it
|
|
323
|
+
* had none. The new lines go after the line the last member (or its comma)
|
|
324
|
+
* ends on, so a comment on that line stays with that member — unless a
|
|
325
|
+
* comment runs on past that line end, in which case they go right after the
|
|
326
|
+
* member's comma rather than into the comment. A one-line object gets
|
|
327
|
+
* `, key: value` before its closing brace, and an empty one is rewritten as
|
|
328
|
+
* `{ key: value }`.
|
|
329
|
+
*/
|
|
330
|
+
export function insertionSplice(text, source, parent, pending, style) {
|
|
331
|
+
const members = pending.map(({ key, rendered }) => `${renderKey(key, style.quote)}: ${rendered}`);
|
|
332
|
+
const last = parent.properties[parent.properties.length - 1];
|
|
333
|
+
const closing = parent.range[1] - 1;
|
|
334
|
+
if (last === undefined) {
|
|
335
|
+
// Between the braces, so a comment inside `{ }` stays; the braces and
|
|
336
|
+
// whatever they hold are not replaced.
|
|
337
|
+
const at = parent.range[0] + 1;
|
|
338
|
+
// Whitespace alone between the braces is replaced; a comment stays,
|
|
339
|
+
// after the new members.
|
|
340
|
+
const held = tokensBetween(source, at, closing).length > 0;
|
|
341
|
+
const end = held ? at : closing;
|
|
342
|
+
if (!isMultiLine(text, parent)) {
|
|
343
|
+
return { start: at, end, text: ` ${members.join(', ')}${held ? ',' : ' '}` };
|
|
344
|
+
}
|
|
345
|
+
const inner = indentationAt(text, parent.range[0]) + style.indentUnit;
|
|
346
|
+
const lines = members.map(member => `${style.lineEnding}${inner}${member}`).join(',');
|
|
347
|
+
const close = held ? ',' : `${style.lineEnding}${indentationAt(text, parent.range[0])}`;
|
|
348
|
+
return { start: at, end, text: `${lines}${close}` };
|
|
349
|
+
}
|
|
350
|
+
if (!isMultiLine(text, parent)) {
|
|
351
|
+
// `{ a: 1 }` or `{ a: 1, }`: the new members join the line.
|
|
352
|
+
const comma = trailingCommaOf(source, parent);
|
|
353
|
+
const text = `${comma === undefined ? ',' : ''} ${members.join(', ')}${comma === undefined ? '' : ','}`;
|
|
354
|
+
return { start: afterMember(last, comma), end: afterMember(last, comma), text };
|
|
355
|
+
}
|
|
356
|
+
return appendAfterLast(source, last, closing, members, memberColumn(text, parent, style), style.lineEnding);
|
|
357
|
+
}
|
|
358
|
+
const afterMember = (last, comma) => comma === undefined ? last.range[1] : comma.range[1];
|
|
359
|
+
//# sourceMappingURL=literal-edit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"literal-edit.js","sourceRoot":"","sources":["../../../src/services/write-back/literal-edit.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,eAAe,EACf,UAAU,EACV,UAAU,EAKV,aAAa,EACb,gBAAgB,EAChB,IAAI,GACL,MAAM,kBAAkB,CAAA;AA4EzB;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAE,IAAU;IACxC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,SAAS;YACZ,OAAO,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAA;QAC5G,KAAK,iBAAiB;YACpB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,CAAA;QACtC,KAAK,iBAAiB;YACpB,OAAO,IAAI,CAAC,QAAQ,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAA;QAC7G,K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AAI,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,IAAI,EAAE,CAAA;IACjF,CAAC;IACD,OAAO,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAA;AAC7G,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,IAAU,EAAE,KAA8B,EAAU,EAAE,CACzE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Project } from '../../constructs/project.js';
|
|
2
|
+
import type { WriteBackPlan } from './plan.js';
|
|
3
|
+
/**
|
|
4
|
+
* What `checkly deploy` prints after writing the changes made in Checkly into
|
|
5
|
+
* the code. Shaped like the plan the user just read: one header per resource
|
|
6
|
+
* with its class, logical id and file, and under it the diff of the construct
|
|
7
|
+
* source as it was against as it is now, in the plan's markers and colours.
|
|
8
|
+
* What was not written is listed the same way, with the reason per property.
|
|
9
|
+
*/
|
|
10
|
+
export interface WriteBackOutputInput {
|
|
11
|
+
writeBack: WriteBackPlan;
|
|
12
|
+
project: Project;
|
|
13
|
+
/** The directory file names are shown relative to. */
|
|
14
|
+
cwd: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The block for the code that was updated: per construct, the diff of its
|
|
18
|
+
* source, then what a diff cannot say (a property that replaced an edit the
|
|
19
|
+
* code had made too, a helper the file now imports).
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatWriteBackUpdated({ writeBack, project }: WriteBackOutputInput): string;
|
|
22
|
+
/**
|
|
23
|
+
* The block for what was not written: per resource, each property with the
|
|
24
|
+
* reason, or the reason alone when it is about the whole resource.
|
|
25
|
+
*/
|
|
26
|
+
export declare function formatWriteBackSkipped({ writeBack, project, cwd }: WriteBackOutputInput): string;
|