diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/index.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/index.ts index f1c7cb73d..556994ed7 100644 --- a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/index.ts +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/index.ts @@ -1,3 +1,5 @@ export * from './io-host'; export * from './io-message'; export * from './toolkit-action'; +export * from './payloads'; +export * from './messages'; diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/io-message.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/io-message.ts index 6a6855118..19c896580 100644 --- a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/io-message.ts +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/io-message.ts @@ -62,7 +62,7 @@ export interface IoMessage { /** * The data attached to the message. */ - readonly data?: T; + readonly data: T; } /** diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/messages.ts similarity index 92% rename from packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts rename to packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/messages.ts index caca8d5ea..ff52fa60c 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/messages.ts +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/messages.ts @@ -1,15 +1,15 @@ import type * as cxapi from '@aws-cdk/cx-api'; -import type { SdkTrace } from '../'; -import type { BootstrapEnvironmentProgress } from '../../../actions/bootstrap'; -import type { DeployConfirmationRequest, StackDeployProgress } from '../../../actions/deploy'; -import type { StackDestroyProgress } from '../../../actions/destroy'; -import type { StackDetailsPayload } from '../../../actions/list'; -import type { StackRollbackProgress } from '../../../actions/rollback'; -import type { FileWatchEvent, WatchSettings } from '../../../actions/watch'; -import type { AssemblyData, ConfirmationRequest, Duration, ErrorPayload, StackAndAssemblyData, SuccessfulDeployStackResult } from '../../../toolkit/types'; -import type { StackActivity, StackMonitoringControlEvent } from '../../aws-cdk'; -import type { MissingContext, UpdatedContext } from '../../cloud-assembly/context'; -import * as make from '../../shared-private'; +import type { BootstrapEnvironmentProgress } from './payloads/bootstrap-environment-progress'; +import type { MissingContext, UpdatedContext } from './payloads/context'; +import type { DeployConfirmationRequest, StackDeployProgress, SuccessfulDeployStackResult } from './payloads/deploy'; +import type { StackDestroyProgress } from './payloads/destroy'; +import type { StackDetailsPayload } from './payloads/list'; +import type { StackRollbackProgress } from './payloads/rollback'; +import type { SdkTrace } from './payloads/sdk-trace'; +import type { StackActivity, StackMonitoringControlEvent } from './payloads/stack-activity'; +import type { AssemblyData, ConfirmationRequest, Duration, ErrorPayload, StackAndAssemblyData } from './payloads/types'; +import type { FileWatchEvent, WatchSettings } from './payloads/watch'; +import * as make from './private'; /** * We have a rough system by which we assign message codes: @@ -328,6 +328,10 @@ export const IO = { }), // SDK codes + CDK_SDK_I0000: make.trace({ + code: 'CDK_SDK_I0000', + description: 'An SDK message.', + }), CDK_SDK_I0100: make.trace({ code: 'CDK_SDK_I0100', description: 'An SDK trace. SDK traces are emitted as traces to the IoHost, but contain the original SDK logging level.', diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/bootstrap-environment-progress.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/bootstrap-environment-progress.ts new file mode 100644 index 000000000..6f77c897d --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/bootstrap-environment-progress.ts @@ -0,0 +1,18 @@ +import type * as cxapi from '@aws-cdk/cx-api'; + +export interface BootstrapEnvironmentProgress { + /** + * The total number of environments being deployed + */ + readonly total: number; + /** + * The count of the environment currently bootstrapped + * + * This is counting value, not an identifier. + */ + readonly current: number; + /** + * The environment that's currently being bootstrapped + */ + readonly environment: cxapi.Environment; +} diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/context.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/context.ts similarity index 100% rename from packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/context.ts rename to packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/context.ts diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/deploy.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/deploy.ts new file mode 100644 index 000000000..b3b7bf364 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/deploy.ts @@ -0,0 +1,57 @@ +import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; +import type { PermissionChangeType } from './diff'; +import type { ConfirmationRequest } from './types'; + +export interface StackDeployProgress { + /** + * The total number of stacks being deployed + */ + readonly total: number; + /** + * The count of the stack currently attempted to be deployed + * + * This is counting value, not an identifier. + */ + readonly current: number; + /** + * The stack that's currently being deployed + */ + readonly stack: CloudFormationStackArtifact; +} + +/** + * Payload for a yes/no confirmation in deploy. Includes information on + * what kind of change is being made. + */ +export interface DeployConfirmationRequest extends ConfirmationRequest { + /** + * The type of change being made to the IAM permissions. + */ + readonly permissionChangeType: PermissionChangeType; +} + +export type DeployStackResult = + | SuccessfulDeployStackResult + | NeedRollbackFirstDeployStackResult + | ReplacementRequiresRollbackStackResult + ; + +/** Successfully deployed a stack */ +export interface SuccessfulDeployStackResult { + readonly type: 'did-deploy-stack'; + readonly noOp: boolean; + readonly outputs: { [name: string]: string }; + readonly stackArn: string; +} + +/** The stack is currently in a failpaused state, and needs to be rolled back before the deployment */ +export interface NeedRollbackFirstDeployStackResult { + readonly type: 'failpaused-need-rollback-first'; + readonly reason: 'not-norollback' | 'replacement'; + readonly status: string; +} + +/** The upcoming change has a replacement, which requires deploying with --rollback */ +export interface ReplacementRequiresRollbackStackResult { + readonly type: 'replacement-requires-rollback'; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/destroy.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/destroy.ts new file mode 100644 index 000000000..3aa0eb328 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/destroy.ts @@ -0,0 +1,18 @@ +import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; + +export interface StackDestroyProgress { + /** + * The total number of stacks being destroyed + */ + readonly total: number; + /** + * The count of the stack currently attempted to be destroyed + * + * This is counting value, not an identifier. + */ + readonly current: number; + /** + * The stack that's currently being destroyed + */ + readonly stack: CloudFormationStackArtifact; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/diff.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/diff.ts new file mode 100644 index 000000000..82ab65432 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/diff.ts @@ -0,0 +1,19 @@ +/** + * Different types of permission related changes in a diff + */ +export enum PermissionChangeType { + /** + * No permission changes + */ + NONE = 'none', + + /** + * Permissions are broadening + */ + BROADENING = 'broadening', + + /** + * Permissions are changed but not broadening + */ + NON_BROADENING = 'non-broadening', +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/index.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/index.ts new file mode 100644 index 000000000..ec206a970 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/index.ts @@ -0,0 +1,13 @@ +export * from './bootstrap-environment-progress'; +export * from './deploy'; +export * from './destroy'; +export * from './list'; +export * from './sdk-trace'; +export * from './context'; +export * from './rollback'; +export * from './stack-activity'; +export * from './types'; +export * from './progress'; +export * from './watch'; +export * from './stack-details'; +export * from './diff'; diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/list.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/list.ts new file mode 100644 index 000000000..47cfbd200 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/list.ts @@ -0,0 +1,5 @@ +import type { StackDetails } from './stack-details'; + +export interface StackDetailsPayload { + stacks: StackDetails[]; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/progress.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/progress.ts new file mode 100644 index 000000000..768d8754c --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/progress.ts @@ -0,0 +1,17 @@ +export interface StackProgress { + /** + * The total number of progress monitored resources. + */ + readonly total?: number; + + /** + * The number of completed resources. + */ + readonly completed: number; + + /** + * The current progress as a [34/42] string, or just [34] if the total is unknown. + */ + readonly formatted: string; +} + diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/rollback.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/rollback.ts new file mode 100644 index 000000000..1a97bd1d7 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/rollback.ts @@ -0,0 +1,18 @@ +import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; + +export interface StackRollbackProgress { + /** + * The total number of stacks being rolled back + */ + readonly total: number; + /** + * The count of the stack currently attempted to be rolled back + * + * This is counting value, not an identifier. + */ + readonly current: number; + /** + * The stack that's currently being rolled back + */ + readonly stack: CloudFormationStackArtifact; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/sdk-trace.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/sdk-trace.ts new file mode 100644 index 000000000..fa5bf15c6 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/sdk-trace.ts @@ -0,0 +1,21 @@ +/** + * An SDK logging trace. + * + * Only info, warn and error level messages are emitted. + * SDK traces are emitted as traces to the IoHost, but contain the original SDK logging level. + */ +export interface SdkTrace { + /** + * The level the SDK has emitted the original message with + */ + readonly sdkLevel: 'info' | 'warn' | 'error'; + + /** + * The content of the SDK trace + * + * This will include the request and response data for API calls, including potentially sensitive information. + * + * @see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/logging-sdk-calls.html + */ + readonly content: any; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-activity.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-activity.ts new file mode 100644 index 000000000..1740601ce --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-activity.ts @@ -0,0 +1,63 @@ +import { type MetadataEntry } from '@aws-cdk/cloud-assembly-schema'; +import { type CloudFormationStackArtifact } from '@aws-cdk/cx-api'; +import type { StackEvent } from '@aws-sdk/client-cloudformation'; +import type { StackProgress } from './progress'; + +/** + * Payload when stack monitoring is starting or stopping for a given stack deployment. + */ +export interface StackMonitoringControlEvent { + /** + * A unique identifier for a specific stack deployment. + * + * Use this value to attribute stack activities received for concurrent deployments. + */ + readonly deployment: string; + + /** + * The stack artifact that is getting deployed + */ + readonly stack: CloudFormationStackArtifact; + + /** + * The name of the Stack that is getting deployed + */ + readonly stackName: string; + + /** + * Total number of resources taking part in this deployment + * + * The number might not always be known or accurate. + * Only use for informational purposes and handle the case when it's unavailable. + */ + readonly resourcesTotal?: number; +} + +export interface StackActivity { + /** + * A unique identifier for a specific stack deployment. + * + * Use this value to attribute stack activities received for concurrent deployments. + */ + readonly deployment: string; + + /** + * The Stack Event as received from CloudFormation + */ + readonly event: StackEvent; + + /** + * Additional resource metadata + */ + readonly metadata?: ResourceMetadata; + + /** + * The stack progress + */ + readonly progress: StackProgress; +} + +export interface ResourceMetadata { + entry: MetadataEntry; + constructPath: string; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-details.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-details.ts new file mode 100644 index 000000000..31d995755 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/stack-details.ts @@ -0,0 +1,20 @@ +import type * as cxapi from '@aws-cdk/cx-api'; + +/** + * The dependencies of a stack. + */ +export interface StackDependency { + id: string; + dependencies: StackDependency[]; +} + +/** + * Details of a stack. + */ +export interface StackDetails { + id: string; + name: string; + environment: cxapi.Environment; + dependencies: StackDependency[]; +} + diff --git a/packages/@aws-cdk/toolkit-lib/lib/toolkit/types.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/types.ts similarity index 86% rename from packages/@aws-cdk/toolkit-lib/lib/toolkit/types.ts rename to packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/types.ts index 4c29336a4..909caef8a 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/toolkit/types.ts +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/types.ts @@ -1,5 +1,3 @@ -import type { SuccessfulDeployStackResult as _SuccessfulDeployStackResult } from '../api/aws-cdk'; - /** * Assembly data returned in the payload of an IO Message. */ @@ -20,13 +18,6 @@ export interface AssemblyData { readonly stackIds: string[]; } -/** - * A successful deploy stack result. Intentionally exposed in toolkit-lib so documentation - * can be generated from this interface. - */ -export interface SuccessfulDeployStackResult extends _SuccessfulDeployStackResult { -} - /** * Stack data returned in the payload of an IO Message. */ diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/watch.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/watch.ts new file mode 100644 index 000000000..efcdab095 --- /dev/null +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/payloads/watch.ts @@ -0,0 +1,29 @@ + +/** + * The computed file watch settings + */ +export interface WatchSettings { + /** + * The directory observed for file changes + */ + readonly watchDir: string; + /** + * List of include patterns for watching files + */ + readonly includes: string[]; + /** + * List of excludes patterns for watching files + */ + readonly excludes: string[]; +} + +export interface FileWatchEvent { + /** + * The change to the path + */ + readonly event: string; + /** + * The path that has an observed event + */ + readonly path?: string; +} diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/io-helper.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/io-helper.ts index 2a1da3fe3..e1ded895f 100644 --- a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/io-helper.ts +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/io-helper.ts @@ -14,6 +14,7 @@ export type ActionLessRequest = Omit, 'action'>; */ export interface IoHelper extends IIoHost { notify(msg: ActionLessMessage): Promise; + notify(msg: ActionLessMessage): Promise; requestResponse(msg: ActionLessRequest): Promise; } diff --git a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/message-maker.ts b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/message-maker.ts index 57994219d..ddf23d461 100644 --- a/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/message-maker.ts +++ b/packages/@aws-cdk/tmp-toolkit-helpers/src/api/io/private/message-maker.ts @@ -1,4 +1,4 @@ -import type { IoMessageCode, IoMessageLevel } from '../io-message'; +import type { IoMessage, IoMessageCode, IoMessageLevel } from '../io-message'; import type { ActionLessMessage, ActionLessRequest } from './io-helper'; /** @@ -44,13 +44,18 @@ export interface IoMessageMaker extends MessageInfo { /** * Create a message for this code, with or without payload. */ - msg: [T] extends [never] ? (message: string) => ActionLessMessage : (message: string, data: T) => ActionLessMessage; + msg: [T] extends [AbsentData] ? (message: string) => ActionLessMessage : (message: string, data: T) => ActionLessMessage; + + /** + * Returns whether the given `IoMessage` instance matches the current message definition + */ + is(x: IoMessage): x is IoMessage; } /** * Produce an IoMessageMaker for the provided level and code info. */ -function message(level: IoMessageLevel, details: CodeInfo): IoMessageMaker { +function message(level: IoMessageLevel, details: CodeInfo): IoMessageMaker { const maker = (text: string, data: T) => ({ time: new Date(), level, @@ -63,6 +68,7 @@ function message(level: IoMessageLevel, details: CodeInfo): IoMessage ...details, level, msg: maker as any, + is: (m): m is IoMessage => m.code === details.code, }; } @@ -76,14 +82,25 @@ export type ImpossibleType = { }; // Create `IoMessageMaker`s for a given level and type check that calls with payload are using the correct interface -type CodeInfoMaybeInterface = [T] extends [never] ? Omit : Required; +type CodeInfoMaybeInterface = [T] extends [AbsentData] ? Omit : Required; + +/** + * The type we use to represent an absent data field + * + * This is here to make it easy to change between `undefined`, `void` + * and `never`. + * + * Not a lot of difference between `undefined` and `void`, but `void` + * reads better. + */ +type AbsentData = void; -export const trace = (details: CodeInfoMaybeInterface) => message('trace', details); -export const debug = (details: CodeInfoMaybeInterface) => message('debug', details); -export const info = (details: CodeInfoMaybeInterface) => message('info', details); -export const warn = (details: CodeInfoMaybeInterface) => message('warn', details); -export const error = (details: CodeInfoMaybeInterface) => message('error', details); -export const result = (details: Required) => message('result', details); +export const trace = (details: CodeInfoMaybeInterface) => message('trace', details); +export const debug = (details: CodeInfoMaybeInterface) => message('debug', details); +export const info = (details: CodeInfoMaybeInterface) => message('info', details); +export const warn = (details: CodeInfoMaybeInterface) => message('warn', details); +export const error = (details: CodeInfoMaybeInterface) => message('error', details); +export const result = (details: Required) => message('result', details); interface RequestInfo extends CodeInfo { readonly defaultResponse: U; @@ -96,13 +113,13 @@ export interface IoRequestMaker extends MessageInfo { /** * Create a message for this code, with or without payload. */ - req: [T] extends [never] ? (message: string) => ActionLessMessage : (message: string, data: T) => ActionLessRequest; + req: [T] extends [AbsentData] ? (message: string) => ActionLessMessage : (message: string, data: T) => ActionLessRequest; } /** * Produce an IoRequestMaker for the provided level and request info. */ -function request(level: IoMessageLevel, details: RequestInfo): IoRequestMaker { +function request(level: IoMessageLevel, details: RequestInfo): IoRequestMaker { const maker = (text: string, data: T) => ({ time: new Date(), level, diff --git a/packages/@aws-cdk/toolkit-lib/docs/message-registry.md b/packages/@aws-cdk/toolkit-lib/docs/message-registry.md index 51f118f49..90b756295 100644 --- a/packages/@aws-cdk/toolkit-lib/docs/message-registry.md +++ b/packages/@aws-cdk/toolkit-lib/docs/message-registry.md @@ -65,4 +65,5 @@ group: Documents | `CDK_ASSEMBLY_I9999` | Annotations emitted by the cloud assembly | `info` | [cxapi.SynthesisMessage](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_cx-api.SynthesisMessage.html) | | `CDK_ASSEMBLY_W9999` | Warnings emitted by the cloud assembly | `warn` | [cxapi.SynthesisMessage](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_cx-api.SynthesisMessage.html) | | `CDK_ASSEMBLY_E9999` | Errors emitted by the cloud assembly | `error` | [cxapi.SynthesisMessage](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_cx-api.SynthesisMessage.html) | +| `CDK_SDK_I0000` | An SDK message. | `trace` | n/a | | `CDK_SDK_I0100` | An SDK trace. SDK traces are emitted as traces to the IoHost, but contain the original SDK logging level. | `trace` | {@link SdkTrace} | diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/bootstrap/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/bootstrap/index.ts index 9ee31fc42..951eb95dd 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/bootstrap/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/bootstrap/index.ts @@ -227,20 +227,3 @@ export class BootstrapSource { }; } } - -export interface BootstrapEnvironmentProgress { - /** - * The total number of environments being deployed - */ - readonly total: number; - /** - * The count of the environment currently bootstrapped - * - * This is counting value, not an identifier. - */ - readonly current: number; - /** - * The environment that's currently being bootstrapped - */ - readonly environment: cxapi.Environment; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts index ad278d47f..cb909dc20 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/deploy/index.ts @@ -1,10 +1,5 @@ -import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; import type { BaseDeployOptions } from './private/deploy-options'; import type { Tag } from '../../api/aws-cdk'; -import type { ConfirmationRequest } from '../../toolkit/types'; -import type { PermissionChangeType } from '../diff'; - -export type { StackMonitoringControlEvent, StackActivity } from '../../api/aws-cdk'; export type DeploymentMethod = DirectDeploymentMethod | ChangeSetDeploymentMethod; @@ -217,31 +212,3 @@ export interface HotswapProperties { */ readonly ecs: EcsHotswapProperties; } - -export interface StackDeployProgress { - /** - * The total number of stacks being deployed - */ - readonly total: number; - /** - * The count of the stack currently attempted to be deployed - * - * This is counting value, not an identifier. - */ - readonly current: number; - /** - * The stack that's currently being deployed - */ - readonly stack: CloudFormationStackArtifact; -} - -/** - * Payload for a yes/no confirmation in deploy. Includes information on - * what kind of change is being made. - */ -export interface DeployConfirmationRequest extends ConfirmationRequest { - /** - * The type of change being made to the IAM permissions. - */ - readonly permissionChangeType: PermissionChangeType; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/destroy/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/destroy/index.ts index ce6f90226..3a9862048 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/destroy/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/destroy/index.ts @@ -1,4 +1,3 @@ -import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; import type { StackSelector } from '../../api/cloud-assembly'; export interface DestroyOptions { @@ -19,20 +18,3 @@ export interface DestroyOptions { */ readonly ci?: boolean; } - -export interface StackDestroyProgress { - /** - * The total number of stacks being destroyed - */ - readonly total: number; - /** - * The count of the stack currently attempted to be destroyed - * - * This is counting value, not an identifier. - */ - readonly current: number; - /** - * The stack that's currently being destroyed - */ - readonly stack: CloudFormationStackArtifact; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts index bbe1e7261..327a200ec 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/diff/index.ts @@ -115,23 +115,3 @@ export interface DiffOptions { */ readonly securityOnly?: boolean; } - -/** - * Different types of permission related changes in a diff - */ -export enum PermissionChangeType { - /** - * No permission changes - */ - NONE = 'none', - - /** - * Permissions are broadening - */ - BROADENING = 'broadening', - - /** - * Permissions are changed but not broadening - */ - NON_BROADENING = 'non-broadening', -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/diff/private/helpers.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/diff/private/helpers.ts index 790d9a171..4917ce1b2 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/diff/private/helpers.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/diff/private/helpers.ts @@ -1,7 +1,7 @@ import type { DescribeChangeSetOutput } from '@aws-cdk/cloudformation-diff'; import { fullDiff } from '@aws-cdk/cloudformation-diff'; import type * as cxapi from '@aws-cdk/cx-api'; -import { PermissionChangeType } from '..'; +import { PermissionChangeType } from '../../../api/shared-public'; /** * Return whether the diff has security-impacting changes that need confirmation. diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/index.ts index 1e86ec265..add78a1be 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/index.ts @@ -1,7 +1,6 @@ export * from './bootstrap'; export * from './deploy'; export * from './destroy'; -export { PermissionChangeType } from './diff'; export * from './list'; export * from './rollback'; export * from './synth'; diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/list/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/list/index.ts index 6f96efe60..2882b9739 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/list/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/list/index.ts @@ -1,4 +1,3 @@ -import type { StackDetails } from '../../api/aws-cdk'; import type { StackSelector } from '../../api/cloud-assembly'; export interface ListOptions { @@ -7,7 +6,3 @@ export interface ListOptions { */ readonly stacks?: StackSelector; } - -export interface StackDetailsPayload { - stacks: StackDetails[]; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/rollback/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/rollback/index.ts index ef38edaf6..7f5f8e5ae 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/rollback/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/rollback/index.ts @@ -1,4 +1,3 @@ -import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; import type { StackSelector } from '../../api/cloud-assembly'; export interface RollbackOptions { @@ -43,20 +42,3 @@ export interface RollbackOptions { */ readonly validateBootstrapStackVersion?: boolean; } - -export interface StackRollbackProgress { - /** - * The total number of stacks being rolled back - */ - readonly total: number; - /** - * The count of the stack currently attempted to be rolled back - * - * This is counting value, not an identifier. - */ - readonly current: number; - /** - * The stack that's currently being rolled back - */ - readonly stack: CloudFormationStackArtifact; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/actions/watch/index.ts b/packages/@aws-cdk/toolkit-lib/lib/actions/watch/index.ts index 8887b5647..25824c017 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/actions/watch/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/actions/watch/index.ts @@ -38,32 +38,3 @@ export interface WatchOptions extends BaseDeployOptions { */ readonly outdir?: string; } - -/** - * The computed file watch settings - */ -export interface WatchSettings { - /** - * The directory observed for file changes - */ - readonly watchDir: string; - /** - * List of include patterns for watching files - */ - readonly includes: string[]; - /** - * List of excludes patterns for watching files - */ - readonly excludes: string[]; -} - -export interface FileWatchEvent { - /** - * The change to the path - */ - readonly event: string; - /** - * The path that has an observed event - */ - readonly path?: string; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts b/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts index 7a1934796..4d987c5c7 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/aws-cdk.ts @@ -11,7 +11,6 @@ export { ResourceMigrator } from '../../../../aws-cdk/lib/api/resource-import'; export { CloudWatchLogEventMonitor, findCloudWatchLogGroups } from '../../../../aws-cdk/lib/api/logs'; export { type WorkGraph, WorkGraphBuilder, AssetBuildNode, AssetPublishNode, StackNode, Concurrency } from '../../../../aws-cdk/lib/api/work-graph'; export { Bootstrapper } from '../../../../aws-cdk/lib/api/bootstrap'; -export type { StackActivity, StackMonitoringControlEvent } from '../../../../aws-cdk/lib/api/stack-events'; // Context Providers export * as contextproviders from '../../../../aws-cdk/lib/context-providers'; @@ -25,7 +24,7 @@ export { RWLock, type ILock } from '../../../../aws-cdk/lib/api/util/rwlock'; export { loadTree, some } from '../../../../aws-cdk/lib/tree'; // @todo Cloud Assembly and Executable - this is a messy API right now -export { CloudAssembly, sanitizePatterns, type StackDetails, StackCollection, ExtendedStackSelection } from '../../../../aws-cdk/lib/api/cxapp/cloud-assembly'; +export { CloudAssembly, sanitizePatterns, StackCollection, ExtendedStackSelection } from '../../../../aws-cdk/lib/api/cxapp/cloud-assembly'; export { prepareDefaultEnvironment, prepareContext, spaceAvailableForContext } from '../../../../aws-cdk/lib/api/cxapp/exec'; export { guessExecutable } from '../../../../aws-cdk/lib/api/cxapp/exec'; diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/index.ts b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/index.ts index 412137fd7..7ab0af5dc 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/cloud-assembly/index.ts @@ -1,4 +1,4 @@ -export * from './context'; +export * from '../../api/shared-public'; export * from './source-builder'; export * from './stack-selector'; export * from './types'; diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/index.ts b/packages/@aws-cdk/toolkit-lib/lib/api/io/index.ts index 78ea7527a..00239c196 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/io/index.ts @@ -1,23 +1 @@ export type { IoMessageLevel, IoMessageCode, IIoHost, IoMessage, IoRequest } from '../shared-public'; - -/** - * An SDK logging trace. - * - * Only info, warn and error level messages are emitted. - * SDK traces are emitted as traces to the IoHost, but contain the original SDK logging level. - */ -export interface SdkTrace { - /** - * The level the SDK has emitted the original message with - */ - readonly sdkLevel: 'info' | 'warn' | 'error'; - - /** - * The content of the SDK trace - * - * This will include the request and response data for API calls, including potentially sensitive information. - * - * @see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/logging-sdk-calls.html - */ - readonly content: any; -} diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/index.ts b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/index.ts index bfc5d252f..811fb65da 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/index.ts @@ -1,4 +1,4 @@ -export * from './messages'; +export * from '../../shared-public'; export * from './io-host-wrappers'; export * from './timer'; export * from './sdk-logger'; diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/sdk-logger.ts b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/sdk-logger.ts index d96a81e99..c0d036fa8 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/sdk-logger.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/sdk-logger.ts @@ -1,9 +1,9 @@ import { inspect } from 'util'; import type { Logger } from '@smithy/types'; -import { IO } from './messages'; import { replacerBufferWithInfo } from '../../../private/util'; import type { IoHelper } from '../../shared-private'; +import { IO } from '../../shared-public'; export function asSdkLogger(ioHost: IoHelper): Logger { return new class implements Logger { diff --git a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/timer.ts b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/timer.ts index 2351e786a..28547a6cc 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/api/io/private/timer.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/api/io/private/timer.ts @@ -1,7 +1,7 @@ import { format } from 'util'; -import { IO } from './messages'; import { formatTime } from '../../../private/util'; import type { IoHelper } from '../../shared-private'; +import { IO } from '../../shared-public'; /** * Helper class to measure the time of code. diff --git a/packages/@aws-cdk/toolkit-lib/lib/toolkit/index.ts b/packages/@aws-cdk/toolkit-lib/lib/toolkit/index.ts index 952bc9a3a..c28e88c5d 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/toolkit/index.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/toolkit/index.ts @@ -1,2 +1,2 @@ export * from './toolkit'; -export * from './types'; +export * from '../api/shared-public'; diff --git a/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts b/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts index 096fdc34b..eef1d0f56 100644 --- a/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts +++ b/packages/@aws-cdk/toolkit-lib/lib/toolkit/toolkit.ts @@ -5,7 +5,6 @@ import * as chokidar from 'chokidar'; import * as fs from 'fs-extra'; import type { ToolkitServices } from './private'; import { assemblyFromSource } from './private'; -import type { AssemblyData } from './types'; import type { BootstrapEnvironments, BootstrapOptions } from '../actions/bootstrap'; import { BootstrapSource } from '../actions/bootstrap'; import { AssetBuildTime, type DeployOptions, RequireApproval } from '../actions/deploy'; @@ -18,7 +17,7 @@ import { type SynthOptions } from '../actions/synth'; import type { WatchOptions } from '../actions/watch'; import { patternsArrayForWatch } from '../actions/watch/private'; import { type SdkConfig } from '../api/aws-auth'; -import type { SuccessfulDeployStackResult, StackCollection, Concurrency, AssetBuildNode, AssetPublishNode, StackNode, StackDetails } from '../api/aws-cdk'; +import type { SuccessfulDeployStackResult, StackCollection, Concurrency, AssetBuildNode, AssetPublishNode, StackNode } from '../api/aws-cdk'; import { DEFAULT_TOOLKIT_STACK_NAME, Bootstrapper, SdkProvider, Deployments, HotswapMode, ResourceMigrator, tagsForStack, CliIoHost, WorkGraphBuilder, CloudWatchLogEventMonitor, findCloudWatchLogGroups } from '../api/aws-cdk'; import type { ICloudAssemblySource } from '../api/cloud-assembly'; import { StackSelectionStrategy } from '../api/cloud-assembly'; @@ -28,7 +27,7 @@ import type { IIoHost, IoMessageLevel } from '../api/io'; import { Timer, IO, asSdkLogger, withoutColor, withoutEmojis, withTrimmedWhitespace } from '../api/io/private'; import type { IoHelper } from '../api/shared-private'; import { asIoHelper } from '../api/shared-private'; -import type { ToolkitAction } from '../api/shared-public'; +import type { AssemblyData, StackDetails, ToolkitAction } from '../api/shared-public'; import { ToolkitError } from '../api/shared-public'; import { obscureTemplate, serializeStructure, validateSnsTopicArn, formatTime, formatErrorMessage } from '../private/util'; import { pLimit } from '../util/concurrency'; diff --git a/packages/@aws-cdk/toolkit-lib/scripts/gen-code-registry.ts b/packages/@aws-cdk/toolkit-lib/scripts/gen-code-registry.ts index ed00fbbdb..950325d12 100644 --- a/packages/@aws-cdk/toolkit-lib/scripts/gen-code-registry.ts +++ b/packages/@aws-cdk/toolkit-lib/scripts/gen-code-registry.ts @@ -1,16 +1,16 @@ import * as fs from 'fs'; import * as util from 'util'; -import { IO } from '../lib/api/io/private/messages'; +import { IO } from '../lib/api/shared-public'; function codesToMarkdownTable(codes: Record, mdPrefix?: string, mdPostfix?: string) { let table = '| Code | Description | Level | Data Interface |\n'; table += '|------|-------------|-------|----------------|\n'; - + Object.entries(codes).forEach(([key, code]) => { // we allow DEFAULT_* as special case here if (key !== code.code && !key.startsWith('DEFAULT_')) { diff --git a/packages/@aws-cdk/toolkit-lib/test/toolkit/toolkit.test.ts b/packages/@aws-cdk/toolkit-lib/test/toolkit/toolkit.test.ts index 156b428b8..6f5983c56 100644 --- a/packages/@aws-cdk/toolkit-lib/test/toolkit/toolkit.test.ts +++ b/packages/@aws-cdk/toolkit-lib/test/toolkit/toolkit.test.ts @@ -20,6 +20,7 @@ describe('message formatting', () => { level: 'info', code: 'CDK_TOOLKIT_I0000', time: new Date(), + data: undefined, }); expect(ioHost.notifySpy).toHaveBeenCalledWith(expect.objectContaining({ @@ -40,6 +41,7 @@ describe('message formatting', () => { level: 'info', code: 'CDK_TOOLKIT_I0000', time: new Date(), + data: undefined, }); expect(ioHost.notifySpy).toHaveBeenCalledWith(expect.objectContaining({ @@ -60,6 +62,7 @@ describe('message formatting', () => { level: 'info', code: 'CDK_TOOLKIT_I0000', time: new Date(), + data: undefined, }); expect(ioHost.notifySpy).toHaveBeenCalledWith(expect.objectContaining({ diff --git a/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts b/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts index 5de89fa85..dcaf93ea8 100644 --- a/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts +++ b/packages/aws-cdk/lib/api/aws-auth/sdk-logger.ts @@ -1,5 +1,6 @@ import { inspect, format } from 'util'; import { Logger } from '@smithy/types'; +import { IO } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/messages'; import { IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private'; import { replacerBufferWithInfo } from '../../util'; @@ -11,12 +12,7 @@ export class SdkToCliLogger implements Logger { } private notify(level: 'debug' | 'info' | 'warn' | 'error', ...content: any[]) { - void this.ioHelper.notify({ - time: new Date(), - level: 'trace', // always log all SDK logs at trace level, no matter what level they are coming from the SDK - code: 'CDK_SDK_I0000', - message: format('[SDK %s] %s', level, formatSdkLoggerContent(content)), - }); + void this.ioHelper.notify(IO.CDK_SDK_I0000.msg(format('[SDK %s] %s', level, formatSdkLoggerContent(content)))); } public trace(..._content: any[]) { diff --git a/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts index c2c8aae65..0bf9eec44 100644 --- a/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts +++ b/packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts @@ -1,5 +1,6 @@ import type * as cxapi from '@aws-cdk/cx-api'; import { SynthesisMessageLevel } from '@aws-cdk/cx-api'; +import { type StackDetails } from '@aws-cdk/tmp-toolkit-helpers'; import * as chalk from 'chalk'; import { minimatch } from 'minimatch'; import * as semver from 'semver'; @@ -205,24 +206,6 @@ export class CloudAssembly { } } -/** - * The dependencies of a stack. - */ -export type StackDependency = { - id: string; - dependencies: StackDependency[]; -}; - -/** - * Details of a stack. - */ -export type StackDetails = { - id: string; - name: string; - environment: cxapi.Environment; - dependencies: StackDependency[]; -}; - /** * A collection of stacks and related artifacts * diff --git a/packages/aws-cdk/lib/api/deployments/asset-publishing.ts b/packages/aws-cdk/lib/api/deployments/asset-publishing.ts index 5579d4e14..43355ef65 100644 --- a/packages/aws-cdk/lib/api/deployments/asset-publishing.ts +++ b/packages/aws-cdk/lib/api/deployments/asset-publishing.ts @@ -199,6 +199,7 @@ export abstract class BasePublishProgressListener implements IPublishProgressLis formatMessage({ level, message: this.getMessage(type, event), + data: undefined, }), ); } diff --git a/packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts b/packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts index b5064048a..b266cc9f3 100644 --- a/packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts +++ b/packages/aws-cdk/lib/api/stack-events/stack-activity-monitor.ts @@ -1,75 +1,16 @@ import * as util from 'util'; -import { ArtifactMetadataEntryType, type MetadataEntry } from '@aws-cdk/cloud-assembly-schema'; +import { ArtifactMetadataEntryType } from '@aws-cdk/cloud-assembly-schema'; import type { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; -import { StackEvent } from '@aws-sdk/client-cloudformation'; +import type { ResourceMetadata, StackActivity, StackMonitoringControlEvent } from '@aws-cdk/tmp-toolkit-helpers'; import * as uuid from 'uuid'; import { StackEventPoller } from './stack-event-poller'; import { debug, error, info } from '../../cli/messages'; import { stackEventHasErrorMessage } from '../../util'; import type { ICloudFormationClient } from '../aws-auth'; -import { StackProgress, StackProgressMonitor } from './stack-progress-monitor'; +import { StackProgressMonitor } from './stack-progress-monitor'; import { IoHelper } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/private'; -/** - * Payload when stack monitoring is starting or stopping for a given stack deployment. - */ -export interface StackMonitoringControlEvent { - /** - * A unique identifier for a specific stack deployment. - * - * Use this value to attribute stack activities received for concurrent deployments. - */ - readonly deployment: string; - - /** - * The stack artifact that is getting deployed - */ - readonly stack: CloudFormationStackArtifact; - - /** - * The name of the Stack that is getting deployed - */ - readonly stackName: string; - - /** - * Total number of resources taking part in this deployment - * - * The number might not always be known or accurate. - * Only use for informational purposes and handle the case when it's unavailable. - */ - readonly resourcesTotal?: number; -} - -export interface StackActivity { - /** - * A unique identifier for a specific stack deployment. - * - * Use this value to attribute stack activities received for concurrent deployments. - */ - readonly deployment: string; - - /** - * The Stack Event as received from CloudFormation - */ - readonly event: StackEvent; - - /** - * Additional resource metadata - */ - readonly metadata?: ResourceMetadata; - - /** - * The stack progress - */ - readonly progress: StackProgress; -} - -export interface ResourceMetadata { - entry: MetadataEntry; - constructPath: string; -} - export interface StackActivityMonitorProps { /** * The CloudFormation client diff --git a/packages/aws-cdk/lib/api/stack-events/stack-progress-monitor.ts b/packages/aws-cdk/lib/api/stack-events/stack-progress-monitor.ts index ee8876172..92a0209b9 100644 --- a/packages/aws-cdk/lib/api/stack-events/stack-progress-monitor.ts +++ b/packages/aws-cdk/lib/api/stack-events/stack-progress-monitor.ts @@ -1,25 +1,9 @@ import * as util from 'util'; +import type { StackProgress } from '@aws-cdk/tmp-toolkit-helpers'; import { StackEvent } from '@aws-sdk/client-cloudformation'; import { padLeft } from '../../util'; -export interface StackProgress { - /** - * The total number of progress monitored resources. - */ - readonly total?: number; - - /** - * The number of completed resources. - */ - readonly completed: number; - - /** - * The current progress as a [34/42] string, or just [34] if the total is unknown. - */ - readonly formatted: string; -} - /** * Monitors stack progress.s */ diff --git a/packages/aws-cdk/lib/cli/activity-printer/base.ts b/packages/aws-cdk/lib/cli/activity-printer/base.ts index 3e1534a7a..8eab609f2 100644 --- a/packages/aws-cdk/lib/cli/activity-printer/base.ts +++ b/packages/aws-cdk/lib/cli/activity-printer/base.ts @@ -1,6 +1,6 @@ import { CloudFormationStackArtifact } from '@aws-cdk/cx-api'; -import type { StackActivity } from '../../api/stack-events'; -import { StackProgress } from '../../api/stack-events/stack-progress-monitor'; +import { type StackActivity, type StackProgress } from '@aws-cdk/tmp-toolkit-helpers'; +import { IO } from '../../../../@aws-cdk/tmp-toolkit-helpers/src/api/io/messages'; import { IoMessage } from '../../toolkit/cli-io-host'; import { maxResourceTypeLength, stackEventHasErrorMessage } from '../../util'; @@ -52,14 +52,14 @@ export abstract class ActivityPrinterBase implements IActivityPrinter { * Receive a stack activity message */ public notify(msg: IoMessage): void { - switch (msg.code) { - case 'CDK_TOOLKIT_I5501': - this.start(msg.data as { stack: CloudFormationStackArtifact }); + switch (true) { + case IO.CDK_TOOLKIT_I5501.is(msg): + this.start(msg.data); break; - case 'CDK_TOOLKIT_I5502': - this.activity(msg.data as StackActivity); + case IO.CDK_TOOLKIT_I5502.is(msg): + this.activity(msg.data); break; - case 'CDK_TOOLKIT_I5503': + case IO.CDK_TOOLKIT_I5503.is(msg): this.stop(); break; default: diff --git a/packages/aws-cdk/lib/cli/activity-printer/current.ts b/packages/aws-cdk/lib/cli/activity-printer/current.ts index e8e8d8aa0..a2c473dfc 100644 --- a/packages/aws-cdk/lib/cli/activity-printer/current.ts +++ b/packages/aws-cdk/lib/cli/activity-printer/current.ts @@ -1,8 +1,8 @@ import * as util from 'util'; +import type { StackActivity } from '@aws-cdk/tmp-toolkit-helpers'; import * as chalk from 'chalk'; import { ActivityPrinterBase, ActivityPrinterProps } from './base'; import { RewritableBlock } from './display'; -import type { StackActivity } from '../../api/stack-events'; import { padLeft, padRight, stackEventHasErrorMessage } from '../../util'; /** diff --git a/packages/aws-cdk/lib/cli/activity-printer/history.ts b/packages/aws-cdk/lib/cli/activity-printer/history.ts index c6cafb124..82b7651c5 100644 --- a/packages/aws-cdk/lib/cli/activity-printer/history.ts +++ b/packages/aws-cdk/lib/cli/activity-printer/history.ts @@ -1,7 +1,7 @@ import * as util from 'util'; +import type { StackActivity } from '@aws-cdk/tmp-toolkit-helpers'; import * as chalk from 'chalk'; import { ActivityPrinterBase, ActivityPrinterProps } from './base'; -import type { StackActivity } from '../../api/stack-events'; import { padRight } from '../../util'; /** diff --git a/packages/aws-cdk/lib/list-stacks.ts b/packages/aws-cdk/lib/list-stacks.ts index f2d212520..dbe846a6a 100644 --- a/packages/aws-cdk/lib/list-stacks.ts +++ b/packages/aws-cdk/lib/list-stacks.ts @@ -1,4 +1,5 @@ -import { DefaultSelection, ExtendedStackSelection, type StackDetails } from './api/cxapp/cloud-assembly'; +import type { StackDetails } from '@aws-cdk/tmp-toolkit-helpers'; +import { DefaultSelection, ExtendedStackSelection } from './api/cxapp/cloud-assembly'; import { CdkToolkit } from './cli/cdk-toolkit'; /** diff --git a/packages/aws-cdk/lib/logging.ts b/packages/aws-cdk/lib/logging.ts index dd0aa12d3..03ea3fd3d 100644 --- a/packages/aws-cdk/lib/logging.ts +++ b/packages/aws-cdk/lib/logging.ts @@ -35,6 +35,7 @@ function formatMessageAndLog( level, message: finalMessage, code, + data: undefined, }; void ioHost.notify(ioMessage);