-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9bdbfa
commit 46dba87
Showing
18 changed files
with
1,211 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>; |
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/coerce-api-parameters.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 {}; |
96 changes: 96 additions & 0 deletions
96
packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/coerce-api-parameters.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/find-client-constructor.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export declare function findV3ClientConstructor(pkg: Object): new (config: any) => { | ||
send: (command: any) => Promise<any>; | ||
config: any; | ||
}; |
12 changes: 12 additions & 0 deletions
12
packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/find-client-constructor.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/parameter-types.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
14
packages/@aws-cdk/sdk-v2-to-v3-adapter/lib/parameter-types.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
Oops, something went wrong.