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,22 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createReadStream } from 'node:fs';
|
|
3
|
+
import { pipeline } from 'node:stream/promises';
|
|
4
|
+
/**
|
|
5
|
+
* Lowercase hex SHA-256 of a file's contents.
|
|
6
|
+
*
|
|
7
|
+
* The deploy payload carries one of these per uploaded artifact — every
|
|
8
|
+
* Playwright visual snapshot and the code bundle archive — so Checkly can tell
|
|
9
|
+
* an unchanged upload from a new one by content rather than by storage key,
|
|
10
|
+
* which changes on every upload. A hash is also computable before anything is
|
|
11
|
+
* uploaded, which is what lets `checkly deploy` ask what a deploy would change
|
|
12
|
+
* without uploading first.
|
|
13
|
+
*
|
|
14
|
+
* Streamed rather than read into a buffer: a bundle archive or a full-page
|
|
15
|
+
* screenshot can be tens of megabytes, and several are hashed per deploy.
|
|
16
|
+
*/
|
|
17
|
+
export async function sha256OfFile(filePath) {
|
|
18
|
+
const hash = createHash('sha256');
|
|
19
|
+
await pipeline(createReadStream(filePath), hash);
|
|
20
|
+
return hash.digest('hex');
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=content-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-hash.js","sourceRoot":"","sources":["../../src/services/content-hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAE,QAAgB;IAClD,MAAM,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA;IACjC,MAAM,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;IAChD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A line-oriented diff, used to show what a deploy would change about a
|
|
3
|
+
* resource: the construct as Checkly currently has it against the construct
|
|
4
|
+
* the local code would produce.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately implemented here rather than taken from a package. The output
|
|
7
|
+
* is read by people in a terminal, the inputs are a few dozen lines of
|
|
8
|
+
* generated code, and a diff library would be a new dependency of a CLI that
|
|
9
|
+
* ships to users for the sake of one screen of code.
|
|
10
|
+
*/
|
|
11
|
+
export interface DiffLinesOptions {
|
|
12
|
+
/** Lines of context around each change. Defaults to 3. */
|
|
13
|
+
context?: number;
|
|
14
|
+
/** Lines per side above which no diff is produced. Defaults to 1500. */
|
|
15
|
+
maxLines?: number;
|
|
16
|
+
}
|
|
17
|
+
/** One line of a diff: a hunk boundary (with no text of its own), or a line of either side. */
|
|
18
|
+
export interface DiffLine {
|
|
19
|
+
kind: 'context' | 'add' | 'remove' | 'hunk';
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The diff of two texts as typed lines, without colour — the caller decides
|
|
24
|
+
* how to present them.
|
|
25
|
+
*
|
|
26
|
+
* Hunk grouping follows `git diff` and GNU `diff -u`, which is the shape a
|
|
27
|
+
* reader recognises. When two sides can be aligned in more than one minimal
|
|
28
|
+
* way, which edit script you get is a matter of heuristics, and this one's is
|
|
29
|
+
* not git's: the result is always a valid, minimal diff of the same two texts,
|
|
30
|
+
* but it may group its hunks differently from the diff the same input would
|
|
31
|
+
* get from git.
|
|
32
|
+
*
|
|
33
|
+
* @returns An empty array when the two sides are identical (or differ only by
|
|
34
|
+
* a trailing newline), `undefined` when they are too large to compare (see
|
|
35
|
+
* {@link DEFAULT_MAX_LINES} and {@link MAX_CELLS}), and otherwise one `hunk`
|
|
36
|
+
* line per changed region followed by that region's lines.
|
|
37
|
+
*/
|
|
38
|
+
export declare function diffLines(before: string, after: string, options?: DiffLinesOptions): DiffLine[] | undefined;
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A line-oriented diff, used to show what a deploy would change about a
|
|
3
|
+
* resource: the construct as Checkly currently has it against the construct
|
|
4
|
+
* the local code would produce.
|
|
5
|
+
*
|
|
6
|
+
* Deliberately implemented here rather than taken from a package. The output
|
|
7
|
+
* is read by people in a terminal, the inputs are a few dozen lines of
|
|
8
|
+
* generated code, and a diff library would be a new dependency of a CLI that
|
|
9
|
+
* ships to users for the sake of one screen of code.
|
|
10
|
+
*/
|
|
11
|
+
/** Lines of leading and trailing context kept around each changed run. */
|
|
12
|
+
const DEFAULT_CONTEXT = 3;
|
|
13
|
+
/**
|
|
14
|
+
* Largest number of lines either side may have before the diff is declined.
|
|
15
|
+
* The comparison is a quadratic dynamic program over the lines that actually
|
|
16
|
+
* differ, so a pathological input (two unrelated thousand-line scripts) would
|
|
17
|
+
* cost a multiple of a million cells for output nobody would read. Callers
|
|
18
|
+
* have a coarser listing to fall back to.
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_MAX_LINES = 1500;
|
|
21
|
+
/**
|
|
22
|
+
* Cells the dynamic program may allocate, whatever `maxLines` says. The line
|
|
23
|
+
* guard above is about output nobody would read; this one is about the
|
|
24
|
+
* allocation itself, which is the product of the two sides and so grows far
|
|
25
|
+
* faster — without it, a caller raising `maxLines` gets a `RangeError` from
|
|
26
|
+
* the typed array instead of the `undefined` this function promises for an
|
|
27
|
+
* input it declines. Four million cells is 16 MB, and comfortably above what
|
|
28
|
+
* the default line guard can reach.
|
|
29
|
+
*/
|
|
30
|
+
const MAX_CELLS = 4_000_000;
|
|
31
|
+
/**
|
|
32
|
+
* Splits text into lines, treating a trailing newline as a line terminator
|
|
33
|
+
* rather than as an empty last line, so `'a\n'` and `'a'` both have one line
|
|
34
|
+
* and neither reports a phantom change against the other.
|
|
35
|
+
*/
|
|
36
|
+
function toLines(text) {
|
|
37
|
+
if (text === '') {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const lines = text.split('\n');
|
|
41
|
+
if (lines[lines.length - 1] === '') {
|
|
42
|
+
lines.pop();
|
|
43
|
+
}
|
|
44
|
+
return lines;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The edit script turning `before` into `after`, one entry per line of either
|
|
48
|
+
* side, via the longest common subsequence of the two.
|
|
49
|
+
*
|
|
50
|
+
* Identical head and tail lines are matched off before the dynamic program
|
|
51
|
+
* runs — they are the bulk of any real comparison — and put back as context
|
|
52
|
+
* afterwards, so the line numbering downstream needs no adjustment.
|
|
53
|
+
*
|
|
54
|
+
* @returns `undefined` when what is left after that trim would need more than
|
|
55
|
+
* {@link MAX_CELLS} cells to compare.
|
|
56
|
+
*/
|
|
57
|
+
function editScript(before, after) {
|
|
58
|
+
let head = 0;
|
|
59
|
+
while (head < before.length && head < after.length && before[head] === after[head]) {
|
|
60
|
+
head += 1;
|
|
61
|
+
}
|
|
62
|
+
let tail = 0;
|
|
63
|
+
while (tail < before.length - head
|
|
64
|
+
&& tail < after.length - head
|
|
65
|
+
&& before[before.length - 1 - tail] === after[after.length - 1 - tail]) {
|
|
66
|
+
tail += 1;
|
|
67
|
+
}
|
|
68
|
+
const a = before.slice(head, before.length - tail);
|
|
69
|
+
const b = after.slice(head, after.length - tail);
|
|
70
|
+
const n = a.length;
|
|
71
|
+
const m = b.length;
|
|
72
|
+
if ((n + 1) * (m + 1) > MAX_CELLS) {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
const width = m + 1;
|
|
76
|
+
// lengths[i][j] is the LCS length of a[i..] and b[j..], filled from the end
|
|
77
|
+
// so the walk below can go forwards and keep the two sides in step.
|
|
78
|
+
const lengths = new Int32Array((n + 1) * width);
|
|
79
|
+
for (let i = n - 1; i >= 0; i -= 1) {
|
|
80
|
+
for (let j = m - 1; j >= 0; j -= 1) {
|
|
81
|
+
lengths[i * width + j] = a[i] === b[j]
|
|
82
|
+
? lengths[(i + 1) * width + j + 1] + 1
|
|
83
|
+
: Math.max(lengths[(i + 1) * width + j], lengths[i * width + j + 1]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
const edits = [];
|
|
87
|
+
for (const line of before.slice(0, head)) {
|
|
88
|
+
edits.push({ kind: 'context', line });
|
|
89
|
+
}
|
|
90
|
+
let i = 0;
|
|
91
|
+
let j = 0;
|
|
92
|
+
while (i < n && j < m) {
|
|
93
|
+
if (a[i] === b[j]) {
|
|
94
|
+
edits.push({ kind: 'context', line: a[i] });
|
|
95
|
+
i += 1;
|
|
96
|
+
j += 1;
|
|
97
|
+
}
|
|
98
|
+
else if (lengths[(i + 1) * width + j] >= lengths[i * width + j + 1]) {
|
|
99
|
+
// Dropping a[i] keeps at least as much of the common subsequence as
|
|
100
|
+
// dropping b[j] would; ties go to the deletion so a replaced line reads
|
|
101
|
+
// as `-old` then `+new`.
|
|
102
|
+
edits.push({ kind: 'remove', line: a[i] });
|
|
103
|
+
i += 1;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
edits.push({ kind: 'add', line: b[j] });
|
|
107
|
+
j += 1;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
while (i < n) {
|
|
111
|
+
edits.push({ kind: 'remove', line: a[i] });
|
|
112
|
+
i += 1;
|
|
113
|
+
}
|
|
114
|
+
while (j < m) {
|
|
115
|
+
edits.push({ kind: 'add', line: b[j] });
|
|
116
|
+
j += 1;
|
|
117
|
+
}
|
|
118
|
+
for (const line of before.slice(before.length - tail)) {
|
|
119
|
+
edits.push({ kind: 'context', line });
|
|
120
|
+
}
|
|
121
|
+
return edits;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Groups the edit script into hunks: every changed line with `context` lines
|
|
125
|
+
* either side, and two changed runs separated by no more than twice that
|
|
126
|
+
* merged into one, which is what keeps a diff of scattered small edits from
|
|
127
|
+
* repeating the same lines under two headers.
|
|
128
|
+
*/
|
|
129
|
+
function toHunks(edits, context) {
|
|
130
|
+
const ranges = [];
|
|
131
|
+
edits.forEach((edit, index) => {
|
|
132
|
+
if (edit.kind === 'context') {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const from = Math.max(0, index - context);
|
|
136
|
+
const to = Math.min(edits.length - 1, index + context);
|
|
137
|
+
const last = ranges[ranges.length - 1];
|
|
138
|
+
if (last !== undefined && from <= last[1] + 1) {
|
|
139
|
+
last[1] = Math.max(last[1], to);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
ranges.push([from, to]);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return ranges.map(([from, to]) => ({ edits: edits.slice(from, to + 1) }));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The diff of two texts as typed lines, without colour — the caller decides
|
|
149
|
+
* how to present them.
|
|
150
|
+
*
|
|
151
|
+
* Hunk grouping follows `git diff` and GNU `diff -u`, which is the shape a
|
|
152
|
+
* reader recognises. When two sides can be aligned in more than one minimal
|
|
153
|
+
* way, which edit script you get is a matter of heuristics, and this one's is
|
|
154
|
+
* not git's: the result is always a valid, minimal diff of the same two texts,
|
|
155
|
+
* but it may group its hunks differently from the diff the same input would
|
|
156
|
+
* get from git.
|
|
157
|
+
*
|
|
158
|
+
* @returns An empty array when the two sides are identical (or differ only by
|
|
159
|
+
* a trailing newline), `undefined` when they are too large to compare (see
|
|
160
|
+
* {@link DEFAULT_MAX_LINES} and {@link MAX_CELLS}), and otherwise one `hunk`
|
|
161
|
+
* line per changed region followed by that region's lines.
|
|
162
|
+
*/
|
|
163
|
+
export function diffLines(before, after, options = {}) {
|
|
164
|
+
const { context = DEFAULT_CONTEXT, maxLines = DEFAULT_MAX_LINES, } = options;
|
|
165
|
+
if (before === after) {
|
|
166
|
+
return [];
|
|
167
|
+
}
|
|
168
|
+
const beforeLines = toLines(before);
|
|
169
|
+
const afterLines = toLines(after);
|
|
170
|
+
if (beforeLines.length > maxLines || afterLines.length > maxLines) {
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
const edits = editScript(beforeLines, afterLines);
|
|
174
|
+
if (edits === undefined) {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
const hunks = toHunks(edits, context);
|
|
178
|
+
if (hunks.length === 0) {
|
|
179
|
+
// The texts differ only by the trailing newline that `toLines` dropped.
|
|
180
|
+
return [];
|
|
181
|
+
}
|
|
182
|
+
const lines = [];
|
|
183
|
+
for (const hunk of hunks) {
|
|
184
|
+
lines.push({ kind: 'hunk', text: '' });
|
|
185
|
+
for (const edit of hunk.edits) {
|
|
186
|
+
lines.push({ kind: edit.kind, text: edit.line });
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return lines;
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=diff-lines.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-lines.js","sourceRoot":"","sources":["../../../src/services/deploy-diff/diff-lines.ts"],"names":[],"mappings":"AAAA;;;;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AAC;QACzB,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;QACtC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Resource, ResourceType } from '../../constructs/construct-codegen.js';
|
|
2
|
+
import { type Context } from '../../constructs/internal/codegen/index.js';
|
|
3
|
+
import type { Project } from '../../constructs/project.js';
|
|
4
|
+
import type { DiffChange, DiffEntry, DiffMaskedMarker, DiffRedaction, ResourceSync } from '../../rest/projects.js';
|
|
5
|
+
import type { Program } from '../../sourcegen/index.js';
|
|
6
|
+
/**
|
|
7
|
+
* Shapes the local side of a deploy preview like an import resource — the
|
|
8
|
+
* payload `checkly import` receives per resource and the construct codegens
|
|
9
|
+
* read — so it can be rendered by the same codegen as the deployed side and
|
|
10
|
+
* the two diffed as text.
|
|
11
|
+
*
|
|
12
|
+
* The deployed side needs no shaping: a preview's `before` (`detail: 'full'`)
|
|
13
|
+
* IS the import format, straight from the API. The local side is the payload
|
|
14
|
+
* this CLI synthesized for the deploy, which differs from the import format in
|
|
15
|
+
* exactly the ways `toImportResource` bridges: it has no `id`; it references
|
|
16
|
+
* other resources by logical id (`{ ref }`) where the import format carries
|
|
17
|
+
* physical ids; its relations are separate subscription and assignment
|
|
18
|
+
* resources, which the codegen folds onto the parent by registering them; it
|
|
19
|
+
* keeps a check's intent constraints in the author's order where the stored
|
|
20
|
+
* form groups them; and it carries a few keys only a deploy reads.
|
|
21
|
+
*
|
|
22
|
+
* Nothing here canonicalizes nulls, defaults or ordering beyond that. The
|
|
23
|
+
* local payload is well-formed by construction, and the deployed side comes
|
|
24
|
+
* from the same function the import plan uses, which the codegen was written
|
|
25
|
+
* for. A payload that cannot be shaped throws `UnshapeableError`; the
|
|
26
|
+
* renderer catches it and lists the changes instead.
|
|
27
|
+
*/
|
|
28
|
+
/** Physical ids keyed by `${type}:${logicalId}`. */
|
|
29
|
+
export type PhysicalIds = ReadonlyMap<string, string | number>;
|
|
30
|
+
export declare function idKey(type: string, logicalId: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* The segments of an RFC 6901 pointer, unescaped; the root pointer has none.
|
|
33
|
+
*
|
|
34
|
+
* @throws UnshapeableError for a string that is not a pointer, rather than
|
|
35
|
+
* matching it against nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare function pointerSegments(pointer: string): string[];
|
|
38
|
+
/** A payload this module cannot turn into an import resource; the message says why. */
|
|
39
|
+
export declare class UnshapeableError extends Error {
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Every resource's physical id, for the rendering: the preview's entries
|
|
43
|
+
* carry the id of everything that exists (including a resource the code only
|
|
44
|
+
* references, whose `fromId` construct sends it), and a resource being created
|
|
45
|
+
* gets a synthetic one so the codegen has something to key its registrations
|
|
46
|
+
* on. Every local resource has an entry afterwards; this is the one place an
|
|
47
|
+
* id is minted.
|
|
48
|
+
*/
|
|
49
|
+
export declare function physicalIdsFromPlan(diff: readonly DiffEntry[], local: readonly ResourceSync[]): PhysicalIds;
|
|
50
|
+
/**
|
|
51
|
+
* Keys of a deployed row that neither side renders: a setup or teardown
|
|
52
|
+
* snippet reference. The codegen resolves one through snippet files an
|
|
53
|
+
* import registers and a preview has not, a deploy clears it either way, and
|
|
54
|
+
* it is a bookkeeping column the plan never reports — so left in `before`,
|
|
55
|
+
* `fillUnchangedFromBefore` would copy it onto the local side.
|
|
56
|
+
*/
|
|
57
|
+
export declare const UNRENDERED_KEYS: readonly ["setupSnippetId", "tearDownSnippetId"];
|
|
58
|
+
/**
|
|
59
|
+
* Fills into the shaped local payload every property the deployed row holds
|
|
60
|
+
* that the payload leaves out and the plan does not report as changed. Those
|
|
61
|
+
* are the defaults the deploy's validation fills into an absent property
|
|
62
|
+
* (`activated: true`, a check type's response-time limits, an empty header
|
|
63
|
+
* list), which the row then always carries and the codegen prints: the plan
|
|
64
|
+
* compared the validated payload against the row, so a property absent here
|
|
65
|
+
* and unreported there is one the deploy leaves as it is. Taking it from
|
|
66
|
+
* `before` makes the two renderings agree on it without this CLI keeping a
|
|
67
|
+
* copy of any default — and cannot hide a change, since a value copied to
|
|
68
|
+
* both sides prints alike on both.
|
|
69
|
+
*
|
|
70
|
+
* A key is left alone when a reported change path is it, lies under it, or
|
|
71
|
+
* lies above it; an explicit `null` is a value, not an absence; and only
|
|
72
|
+
* object keys are filled, never the elements of a list.
|
|
73
|
+
*/
|
|
74
|
+
export declare function fillUnchangedFromBefore(local: Record<string, unknown>, before: Record<string, unknown>, changes: readonly DiffChange[]): void;
|
|
75
|
+
/**
|
|
76
|
+
* The local payload of one resource, as an import resource: `id` set, every
|
|
77
|
+
* reference a physical id, deploy-only keys dropped, the intent's constraints
|
|
78
|
+
* grouped as stored. No canonicalization of nulls, defaults or
|
|
79
|
+
* ordering: the payload has none, and the defaults the deploy would fill
|
|
80
|
+
* are taken from the deployed row by `fillUnchangedFromBefore`.
|
|
81
|
+
*
|
|
82
|
+
* @throws UnshapeableError for a payload the codegen could not render.
|
|
83
|
+
*/
|
|
84
|
+
export declare function toImportResource(type: ResourceType, logicalId: string, payload: unknown, ids: PhysicalIds): Resource;
|
|
85
|
+
/**
|
|
86
|
+
* The relation rows a parent's `before` carries — every live subscription
|
|
87
|
+
* and assignment, the way the import format spells them — as the resources
|
|
88
|
+
* whose `prepare()` registers them on the codegen context.
|
|
89
|
+
*/
|
|
90
|
+
export declare function relationResourcesFromBefore(type: string, before: Record<string, unknown>): Resource[];
|
|
91
|
+
export interface AfterRelationsInput {
|
|
92
|
+
ids: PhysicalIds;
|
|
93
|
+
/** Every resource of the local deploy payload. */
|
|
94
|
+
local: readonly ResourceSync[];
|
|
95
|
+
/** The parent's own preview entry: its type, logical id and `before`. */
|
|
96
|
+
entry: DiffEntry;
|
|
97
|
+
/** The whole preview, for the relation entries folded into this parent. */
|
|
98
|
+
diff: readonly DiffEntry[];
|
|
99
|
+
pruneRelations: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The relation resources the local side renders with: the project's own
|
|
103
|
+
* subscription and assignment constructs for this parent, plus every deployed
|
|
104
|
+
* relation the deploy will leave in place. A deployed row is left out when the
|
|
105
|
+
* code removed it (a DELETE or DETACH relation entry folded into this parent
|
|
106
|
+
* names its row id), when `--prune-relations` will delete it (a pruned entry
|
|
107
|
+
* names it too), or when a local construct already stands for the same target.
|
|
108
|
+
* What remains is unmanaged: the deploy keeps it, so both sides show it.
|
|
109
|
+
*
|
|
110
|
+
* @throws UnshapeableError when one of the parent's own relations cannot be shaped.
|
|
111
|
+
*/
|
|
112
|
+
export declare function relationResourcesForAfter(input: AfterRelationsInput): Resource[];
|
|
113
|
+
/** What a redacted value renders as, on both sides: never an empty string, which could pass for a value. */
|
|
114
|
+
export declare const MASK = "********";
|
|
115
|
+
/**
|
|
116
|
+
* A payload with the API's redaction rules applied — the type's whole table,
|
|
117
|
+
* whatever the deployed row held — so a credential is masked on both sides
|
|
118
|
+
* (the deployed side arrives blanked and is masked the same way, since a
|
|
119
|
+
* blank could pass for a value) and never a phantom change, nor printed. A
|
|
120
|
+
* rule that matches nothing is simply ignored. No table at all is refused:
|
|
121
|
+
* an API that reports a `before` without one predates the rules, and the one
|
|
122
|
+
* direction this module must never take is printing a credential.
|
|
123
|
+
*
|
|
124
|
+
* @throws UnshapeableError when the API reported no rule table.
|
|
125
|
+
*/
|
|
126
|
+
export declare function blankRedacted<T>(payload: T, redactions: readonly DiffRedaction[] | undefined): T;
|
|
127
|
+
export declare function isMaskedMarker(value: unknown): value is DiffMaskedMarker;
|
|
128
|
+
/** Whether a reported value holds a marker anywhere inside it. */
|
|
129
|
+
export declare const carriesMarker: (value: unknown) => boolean;
|
|
130
|
+
/** The value at `segments` inside `root`, or undefined where the path does not resolve. */
|
|
131
|
+
export declare function nodeAt(root: unknown, segments: readonly string[]): unknown;
|
|
132
|
+
/**
|
|
133
|
+
* Write `text` over the masked value of every element the report marks
|
|
134
|
+
* `changed`, in the payload's list at `path`. A reported element is matched
|
|
135
|
+
* to the payload's by `key` when that key is unique in both, else by index
|
|
136
|
+
* when the key at that index is the same and the lists are equal in length,
|
|
137
|
+
* else not at all — the deployed row's list can be ordered differently from
|
|
138
|
+
* the report, so an index alone is never trusted, and a name is never
|
|
139
|
+
* wrong. A scalar marker names its own path. Returns whether any mark was
|
|
140
|
+
* placed.
|
|
141
|
+
*/
|
|
142
|
+
export declare function markChanged(payload: unknown, path: string, reported: unknown, text: string): boolean;
|
|
143
|
+
/** The types another construct refers to by variable. */
|
|
144
|
+
export declare const REFERENCEABLE_TYPES: (keyof import("../../constructs/project.js").Resources)[];
|
|
145
|
+
/**
|
|
146
|
+
* Re-register the construct a codegen has just prepared under the name it
|
|
147
|
+
* has in the user's code (`names`, keyed by `idKey`), or else its logical
|
|
148
|
+
* id, in the construct file the codegen chose. A codegen names the variable
|
|
149
|
+
* it exports after the resource's content (an alert channel after its
|
|
150
|
+
* address, a group after its name), so a change to that content would show
|
|
151
|
+
* as a renamed variable beside the change itself; the code's name and the
|
|
152
|
+
* logical id are the same on both sides. The codegen's own name is given up
|
|
153
|
+
* first, so the new one can be the same (a group declared as `websiteGroup`
|
|
154
|
+
* and named "Website Group") without a counter to tell the two apart. A type
|
|
155
|
+
* whose codegen registers no variable is left alone.
|
|
156
|
+
*/
|
|
157
|
+
export declare function registerUnderCodeName(context: Context, resource: Resource, names?: ReadonlyMap<string, string>): void;
|
|
158
|
+
/**
|
|
159
|
+
* Register every referenceable construct of the local project on a fresh
|
|
160
|
+
* context, under its physical id, so a rendered reference comes out as a
|
|
161
|
+
* variable rather than as `fromId(...)`: the one the construct has in the
|
|
162
|
+
* user's code (`names`, keyed by `idKey`), or else one derived from its name. Both
|
|
163
|
+
* sides of a comparison register the same set in the same order, which is
|
|
164
|
+
* what makes their identifiers agree. The constructs the code names go
|
|
165
|
+
* first, so a name derived for another construct that happens to be the
|
|
166
|
+
* same is the one that gets a counter. One support file for all of them, so
|
|
167
|
+
* the context's per-file identifier namespace tells two constructs with the
|
|
168
|
+
* same name apart (`group`, `group2`); a support file, not a construct file,
|
|
169
|
+
* because `renderConstruct` counts the construct files a render adds.
|
|
170
|
+
*/
|
|
171
|
+
export declare function registerProject(context: Context, program: Program, project: Project, ids: PhysicalIds, names?: ReadonlyMap<string, string>): void;
|