-
Notifications
You must be signed in to change notification settings - Fork 74
chore(toolkit-lib): fix code registry is disconnected from usage #191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export * from './io'; | ||
| export * from './toolkit-error'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from './io-host'; | ||
| export * from './io-message'; | ||
| export * from './toolkit-action'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export * from './action-aware'; | ||
| export * from './message-maker'; | ||
| export * from './types'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import { IoMessageCode, IoMessageLevel } from '../io-message'; | ||
| import { ActionLessMessage } from './action-aware'; | ||
|
|
||
| /** | ||
| * Information for each IO Message Code. | ||
| */ | ||
| interface CodeInfo { | ||
| /** | ||
| * The message code. | ||
| */ | ||
| code: IoMessageCode; | ||
|
|
||
| /** | ||
| * A brief description of the meaning of this IO Message. | ||
| */ | ||
| description: string; | ||
|
|
||
| /** | ||
| * The name of the payload interface, if applicable. | ||
| * Some Io Messages include a payload, with a specific interface. The name of | ||
| * the interface is specified here so that it can be linked with the message | ||
| * when documentation is generated. | ||
| * | ||
| * The interface _must_ be exposed directly from toolkit-lib, so that it will | ||
| * have a documentation page generated (that can be linked to). | ||
| */ | ||
| interface?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Information for each IO Message | ||
| */ | ||
| interface MessageInfo extends CodeInfo { | ||
| /** | ||
| * The message level | ||
| */ | ||
| level: IoMessageLevel; | ||
| } | ||
|
|
||
| /** | ||
| * An interface that can produce messages for a specific code. | ||
| */ | ||
| export interface IoMessageMaker<T> extends MessageInfo { | ||
| /** | ||
| * Create a message for this code, with or without payload. | ||
| */ | ||
| msg: [T] extends [never] ? (message: string) => ActionLessMessage<never> : (message: string, data: T) => ActionLessMessage<T>; | ||
| } | ||
|
|
||
| /** | ||
| * Produce an IoMessageMaker for the provided level and code info. | ||
| */ | ||
| function generic<T = never>(level: IoMessageLevel, details: CodeInfo): IoMessageMaker<T> { | ||
| const msg = (message: string, data: T) => ({ | ||
| time: new Date(), | ||
| level, | ||
| code: details.code, | ||
| message: message, | ||
| data: data, | ||
| } as ActionLessMessage<T>); | ||
|
|
||
| return { | ||
| ...details, | ||
| level, | ||
| msg: msg as any, | ||
| }; | ||
| } | ||
|
|
||
| // Create `IoMessageMaker`s for a given level and type check that calls with payload are using the correct interface | ||
| type CodeInfoMaybeInterface<T> = [T] extends [never] ? Omit<CodeInfo, 'interface'> : Required<CodeInfo>; | ||
|
|
||
| export const trace = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('trace', details); | ||
| export const debug = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('debug', details); | ||
| export const info = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('info', details); | ||
| export const warn = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('warn', details); | ||
| export const error = <T = never>(details: CodeInfoMaybeInterface<T>) => generic<T>('error', details); | ||
| export const result = <T extends object>(details: Required<CodeInfo>) => generic<T extends object ? T : never>('result', details); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /** | ||
| * Valid reporting categories for messages. | ||
| */ | ||
| export type IoMessageCodeCategory = 'TOOLKIT' | 'SDK' | 'ASSETS' | 'ASSEMBLY'; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||
| * The current action being performed by the CLI. 'none' represents the absence of an action. | ||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||
| export type ToolkitAction = | ||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelated to this PR but it just caught my so putting it out here. This list is slightly different than then one in the CLI. Intentional? aws-cdk-cli/packages/aws-cdk/lib/toolkit/cli-io-host.ts Lines 91 to 110 in 01acccf
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the CLI has more. To be unified soon. |
||||||||||||||||||||||||||||||||||||||||||
| | 'assembly' | ||||||||||||||||||||||||||||||||||||||||||
| | 'bootstrap' | ||||||||||||||||||||||||||||||||||||||||||
| | 'synth' | ||||||||||||||||||||||||||||||||||||||||||
| | 'list' | ||||||||||||||||||||||||||||||||||||||||||
| | 'diff' | ||||||||||||||||||||||||||||||||||||||||||
| | 'deploy' | ||||||||||||||||||||||||||||||||||||||||||
| | 'rollback' | ||||||||||||||||||||||||||||||||||||||||||
| | 'watch' | ||||||||||||||||||||||||||||||||||||||||||
| | 'destroy' | ||||||||||||||||||||||||||||||||||||||||||
| | 'doctor' | ||||||||||||||||||||||||||||||||||||||||||
| | 'gc' | ||||||||||||||||||||||||||||||||||||||||||
| | 'import' | ||||||||||||||||||||||||||||||||||||||||||
| | 'metadata' | ||||||||||||||||||||||||||||||||||||||||||
| | 'init' | ||||||||||||||||||||||||||||||||||||||||||
| | 'migrate'; | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| export interface MissingContext { | ||
| missingKeys: string[]; | ||
| } | ||
|
|
||
| export interface UpdatedContext { | ||
| contextFile: string; | ||
| context: { [key: string]: any }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1 @@ | ||
| export * from './io-host'; | ||
| export * from './io-message'; | ||
| export type { IoMessageLevel, IoMessageCode, IIoHost, IoMessage, IoRequest } from '../shared-public'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we already have this function here:
aws-cdk-cli/packages/@aws-cdk/toolkit-lib/lib/api/io/private/logger.ts
Line 14 in 01acccf
Can we reuse?