Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
roger-zhangg committed Apr 18, 2024
1 parent a9bdbfa commit 46dba87
Show file tree
Hide file tree
Showing 18 changed files with 1,211 additions and 0 deletions.
68 changes: 68 additions & 0 deletions packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/api-call.d.ts
@@ -0,0 +1,68 @@
import type { AwsCredentialIdentityProvider } from '@smithy/types';
export interface InvokeOptions {
/**
* The SDKv3 package for the service.
*
* @default - Load the package automatically
*/
readonly sdkPackage?: any;
/**
* Override API version
*
* @default - Use default API version
*/
readonly apiVersion?: string;
/**
* Override region
*
* @default - Current region
*/
readonly region?: string;
/**
* Override credentials
*
* @default - Default credentials
*/
readonly credentials?: AwsCredentialIdentityProvider;
/**
* Parameters to the API call
*
* @default {}
*/
readonly parameters?: Record<string, unknown>;
/**
* Flatten the response object
*
* Instead of a nested object structure, return a map of `{ string -> value }`, with the keys
* being the paths to each primitive value.
*
* @default false
*/
readonly flattenResponse?: boolean;
}
/**
* Wrapper to make an SDKv3 API call, with SDKv2 compatibility
*/
export declare class ApiCall {
readonly service: string;
readonly action: string;
readonly v3PackageName: string;
v3Package?: any;
client?: any;
constructor(service: string, action: string);
invoke(options: InvokeOptions): Promise<Record<string, unknown>>;
initializePackage(packageOverride?: any): any;
initializeClient(options: Pick<InvokeOptions, 'apiVersion' | 'credentials' | 'region'>): any;
findCommandClass(): new (input: any) => any;
private findConstructor;
}
/**
* Flattens a nested object
*
* @param object the object to be flattened
* @returns a flat object with path as keys
*/
export declare function flatten(root: unknown): {
[key: string]: any;
};
export declare function coerceSdkv3Response(value: unknown): Promise<unknown>;
136 changes: 136 additions & 0 deletions packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/api-call.js

Large diffs are not rendered by default.

@@ -0,0 +1,24 @@
import { TypeCoercionStateMachine } from './parameter-types';
type ApiParameters = {
[param: string]: any;
};
/**
* Given a minimal AWS SDKv3 call definition (service, action, parameters),
* coerces nested parameter values into a Uint8Array if that's what the SDKv3 expects.
*/
export declare function coerceApiParameters(v3service: string, action: string, parameters?: ApiParameters): ApiParameters;
/**
* Make this a class in order to have multiple entry points for testing that can all share convenience functions
*/
export declare class Coercer {
private readonly typeMachine;
constructor(typeMachine: TypeCoercionStateMachine);
coerceApiParameters(v3service: string, action: string, parameters?: ApiParameters): ApiParameters;
testCoerce(value: unknown): any;
private recurse;
/**
* From a given state, return the state we would end up in if we followed this field
*/
private progress;
}
export {};

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

@@ -0,0 +1,4 @@
export declare function findV3ClientConstructor(pkg: Object): new (config: any) => {
send: (command: any) => Promise<any>;
config: any;
};

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

4 changes: 4 additions & 0 deletions packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/index.d.ts
@@ -0,0 +1,4 @@
export { coerceApiParameters } from './coerce-api-parameters';
export { findV3ClientConstructor } from './find-client-constructor';
export { normalizeServiceName, normalizeActionName } from './sdk-info';
export * from './api-call';
26 changes: 26 additions & 0 deletions packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/index.js

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

@@ -0,0 +1,2 @@
export type TypeCoercionStateMachine = Array<Record<string, number | 'b' | 'n' | 'd'>>;
export declare let typeCoercionStateMachine: () => TypeCoercionStateMachine;
14 changes: 14 additions & 0 deletions packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/parameter-types.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/sdk-info.d.ts
@@ -0,0 +1,20 @@
/**
* Normalize a service name from:
*
* - A full SDKv3 package name
* - A partial SDKv3 package name
* - An SDKv2 constructor name
*
* To a partial SDKv3 package name.
*/
export declare function normalizeServiceName(service: string): string;
/**
* Normalize an action name from:
*
* - camelCase SDKv2 method name
* - PascalCase API name
* - SDKv3 command class name
*
* To a PascalCase API name.
*/
export declare function normalizeActionName(v3Service: string, action: string): string;

0 comments on commit 46dba87

Please sign in to comment.