Skip to content
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

feat: update AWS Service Spec #27997

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/@aws-cdk/cloudformation-diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
},
"license": "Apache-2.0",
"dependencies": {
"@aws-cdk/aws-service-spec": "^0.0.27",
"@aws-cdk/service-spec-types": "^0.0.27",
"@aws-cdk/aws-service-spec": "^0.0.28",
"@aws-cdk/service-spec-types": "^0.0.28",
"chalk": "^4",
"diff": "^5.1.0",
"fast-deep-equal": "^3.1.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/integ-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"@aws-cdk/cloud-assembly-schema": "0.0.0",
"@aws-cdk/cloudformation-diff": "0.0.0",
"@aws-cdk/cx-api": "0.0.0",
"@aws-cdk/aws-service-spec": "^0.0.27",
"@aws-cdk/aws-service-spec": "^0.0.28",
"cdk-assets": "0.0.0",
"@aws-cdk/cdk-cli-wrapper": "0.0.0",
"aws-cdk": "0.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"yaml": "1.10.2"
},
"devDependencies": {
"@aws-cdk/aws-service-spec": "^0.0.27",
"@aws-cdk/aws-service-spec": "^0.0.28",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/custom-resource-handlers": "0.0.0",
"@aws-cdk/pkglint": "0.0.0",
Expand Down
2 changes: 2 additions & 0 deletions tools/@aws-cdk/cfn2ts/bin/cfn2ts.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};
46 changes: 46 additions & 0 deletions tools/@aws-cdk/cfn2ts/bin/cfn2ts.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions tools/@aws-cdk/cfn2ts/lib/augmentation-generator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { schema } from '@aws-cdk/cfnspec';
/**
* Generate augmentation methods for the given types
*
* Augmentation consists of two parts:
*
* - Adding method declarations to an interface (IBucket)
* - Adding implementations for those methods to the base class (BucketBase)
*
* The augmentation file must be imported in `index.ts`.
*
* ----------------------------------------------------------
*
* Generates code similar to the following:
*
* ```
* import <Class>Base from './<class>-base';
*
* declare module './<class>-base' {
* interface <IClass> {
* method(...): Type;
* }
* interface <ClassBase> {
* method(...): Type;
* }
* }
*
* <ClassBase>.prototype.<method> = // ...impl...
* ```
*/
export interface AugmentationsGeneratorOptions {
/**
* Path of cloudwatch import to use when generating augmentation source
* files.
*
* @default '@aws-cdk/aws-cloudwatch'
*/
cloudwatchImport?: string;
}
export declare class AugmentationGenerator {
private readonly spec;
private readonly affix;
private readonly config?;
readonly outputFile: string;
private readonly code;
constructor(moduleName: string, spec: schema.Specification, affix: string, config?: AugmentationsGeneratorOptions | undefined);
emitCode(): boolean;
/**
* Saves the generated file.
*/
save(dir: string): Promise<string[]>;
private emitMetricAugmentations;
private emitMetricFunctionDeclaration;
private emitMetricFunction;
private emitSpecificMetricFunctionDeclaration;
private emitSpecificMetricFunction;
}
133 changes: 133 additions & 0 deletions tools/@aws-cdk/cfn2ts/lib/augmentation-generator.js

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions tools/@aws-cdk/cfn2ts/lib/canned-metrics-generator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Generate default prop sets for canned metric
*
* We don't generate `cloudwatch.Metric` objects directly (because we can't
* guarantee that all packages already properly depend on
* `@aws-cdk/aws-cloudwatch`).
*
* Instead, we generate functions that return the set of properties that should
* be passed to a `cloudwatch.Metric` to construct it.
*
* ----------------------------------------------------------
*
* Generates code similar to the following:
*
* ```
* export class <Namespace>Metrics {
* public static <metric><statistic>(<dimensions>): Props {
* // ...
* }
* }
* ```
*/
export declare class CannedMetricsGenerator {
private readonly namespace;
readonly outputFile: string;
private readonly code;
constructor(moduleName: string, namespace: string);
generate(): boolean;
/**
* Saves the generated file.
*/
save(dir: string): Promise<string[]>;
private functionName;
private emitTypeDef;
}
132 changes: 132 additions & 0 deletions tools/@aws-cdk/cfn2ts/lib/canned-metrics-generator.js

Large diffs are not rendered by default.

124 changes: 124 additions & 0 deletions tools/@aws-cdk/cfn2ts/lib/codegen.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { schema } from '@aws-cdk/cfnspec';
export interface CodeGeneratorOptions {
/**
* How to import the core library.
*
* @default '@aws-cdk/core'
*/
readonly coreImport?: string;
}
/**
* Emits classes for all resource types
*/
export default class CodeGenerator {
private readonly spec;
private readonly affix;
readonly outputFile: string;
readonly resources: Record<string, string>;
private code;
/**
* Creates the code generator.
* @param moduleName the name of the module (used to determine the file name).
* @param spec CloudFormation resource specification
*/
constructor(moduleName: string, spec: schema.Specification, affix: string, options?: CodeGeneratorOptions);
emitCode(): void;
/**
* Saves the generated file.
*/
save(dir: string): Promise<string[]>;
/**
* Emits classes for all property types
*/
private emitPropertyTypes;
private openClass;
private closeClass;
private emitPropsType;
/**
* Emit TypeScript for each of the CloudFormation properties, while renaming
*
* Return a mapping of { originalName -> newName }.
*/
private emitPropsTypeProperties;
private emitResourceType;
/**
* We resolve here.
*
* Since resolve() deep-resolves, we only need to do this once.
*/
private emitCloudFormationProperties;
/**
* Add validations for the given construct
*
* The generated code looks like this:
*
* ```
* this.node.addValidation({ validate: () => /* validation code * / });
* }
* ```
*/
private emitConstructValidator;
/**
* Emit the function that is going to implement the IInspectable interface.
*
* The generated code looks like this:
* public inspect(inspector: cdk.TreeInspector) {
* inspector.addAttribute("aws:cdk:cloudformation:type", CfnManagedPolicy.CFN_RESOURCE_TYPE_NAME);
* inspector.addAttribute("aws:cdk:cloudformation:props", this.cfnProperties);
* }
*
*/
private emitTreeAttributes;
/**
* Emit the function that is going to map the generated TypeScript object back into the schema that CloudFormation expects
*
* The generated code looks like this:
*
* function bucketPropsToCloudFormation(properties: any): any {
* if (!cdk.canInspect(properties)) return properties;
* BucketPropsValidator(properties).assertSuccess();
* return {
* AccelerateConfiguration: bucketAccelerateConfigurationPropertyToCloudFormation(properties.accelerateConfiguration),
* AccessControl: cdk.stringToCloudFormation(properties.accessControl),
* AnalyticsConfigurations: cdk.listMapper(bucketAnalyticsConfigurationPropertyToCloudFormation)
* (properties.analyticsConfigurations),
* // ...
* };
* }
*
* Generated as a top-level function outside any namespace so we can hide it from library consumers.
*/
private emitCloudFormationMapper;
/**
* Generates a function that converts from a pure CloudFormation value taken from a template
* to an instance of the given CDK struct.
* This involves changing the casing of the properties,
* from UpperCamelCase used by CloudFormation,
* to lowerCamelCase used by the CDK,
* and also translating things like IResolvable into strings, numbers or string arrays,
* depending on the type of the L1 property.
*/
private emitFromCfnFactoryFunction;
/**
* Emit a function that will validate whether the given property bag matches the schema of this complex type
*
* Generated as a top-level function outside any namespace so we can hide it from library consumers.
*/
private emitPropertiesValidator;
private emitInterfaceProperty;
private emitClassProperty;
private emitProperty;
private beginNamespace;
private endNamespace;
private emitPropertyType;
/**
* Return the native type expression for the given propSpec
*/
private findNativeType;
/**
* Render a CodeName to a string representation of it in TypeScript
*/
private renderCodeName;
private renderTypeUnion;
private docLink;
}
Loading
Loading