Skip to content

Commit

Permalink
feat(clients): vendor TS types from pinpoint and cognito-identity cli…
Browse files Browse the repository at this point in the history
…ents (#11393)

* chore: dts bundler script for AWS SDK types

* feat(clients): vendor AWS SDK client types

* chore: workaround the tslint errors for generated rollup types

* docs: add readme to build clients script

* feat: update SDK types
  • Loading branch information
AllanZhengYP authored May 24, 2023
1 parent 524e17b commit 9a8569a
Show file tree
Hide file tree
Showing 25 changed files with 1,126 additions and 37 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"build:watch": "concurrently 'lerna run build:cjs:watch --parallel' 'lerna run build:esm:watch --parallel' --raw",
"build:esm:watch": "lerna run build:esm:watch --parallel",
"build:cjs:watch": "lerna run build:cjs:watch --parallel",
"build:client-types": "cd scripts/dts-bundler && yarn && yarn run build",
"clean": "lerna run clean --parallel",
"clean:size": "lerna run clean:size --parallel",
"format": "lerna run format",
Expand Down
5 changes: 1 addition & 4 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@
"tslib": "^1.8.0",
"uuid": "^3.2.1"
},
"devDependencies": {
"@aws-sdk/client-pinpoint": "3.186.1"
},
"size-limit": [
{
"name": "Analytics (Pinpoint)",
Expand All @@ -72,7 +69,7 @@
"name": "Analytics (Kinesis)",
"path": "./lib-esm/index.js",
"import": "{ Amplify, Analytics, AWSKinesisProvider }",
"limit": "58.1 kB"
"limit": "58.2 kB"
}
],
"jest": {
Expand Down
2 changes: 0 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@
},
"homepage": "https://aws-amplify.github.io/",
"devDependencies": {
"@aws-sdk/client-cognito-identity": "3.6.1",
"@aws-sdk/client-pinpoint": "3.186.1",
"@react-native-async-storage/async-storage": "1.15.17",
"find": "^0.2.7",
"genversion": "^2.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import type {
GetCredentialsForIdentityCommandInput as GetCredentialsForIdentityInput,
GetCredentialsForIdentityCommandOutput as GetCredentialsForIdentityOutput,
Credentials,
} from '@aws-sdk/client-cognito-identity';
import {
buildHttpRpcRequest,
cognitoIdentityTransferHandler,
Expand All @@ -21,6 +16,11 @@ import {
parseJsonError,
parseMetadata,
} from '../../clients';
import type {
GetCredentialsForIdentityCommandInput as GetCredentialsForIdentityInput,
GetCredentialsForIdentityCommandOutput as GetCredentialsForIdentityOutput,
Credentials,
} from './types';

export type { GetCredentialsForIdentityInput, GetCredentialsForIdentityOutput };

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/AwsClients/CognitoIdentity/getId.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import {
GetIdCommandInput as GetIdInput,
GetIdCommandOutput as GetIdOutput,
} from '@aws-sdk/client-cognito-identity';
import {
buildHttpRpcRequest,
cognitoIdentityTransferHandler,
Expand All @@ -20,6 +16,10 @@ import {
parseJsonError,
parseMetadata,
} from '../../clients';
import {
GetIdCommandInput as GetIdInput,
GetIdCommandOutput as GetIdOutput,
} from './types';

export type { GetIdInput, GetIdOutput };

Expand Down
159 changes: 159 additions & 0 deletions packages/core/src/AwsClients/CognitoIdentity/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

// Generated by scripts/dts-bundler/README.md

import { MetadataBearer as __MetadataBearer } from '@aws-sdk/types';

/**
* @public
* <p>Credentials for the provided identity ID.</p>
*/
export interface Credentials {
/**
* <p>The Access Key portion of the credentials.</p>
*/
AccessKeyId?: string;
/**
* <p>The Secret Access Key portion of the credentials</p>
*/
SecretKey?: string;
/**
* <p>The Session Token portion of the credentials</p>
*/
SessionToken?: string;
/**
* <p>The date at which these credentials will expire.</p>
*/
Expiration?: Date;
}
/**
* @public
*
* The input for {@link GetCredentialsForIdentityCommand}.
*/
export interface GetCredentialsForIdentityCommandInput
extends GetCredentialsForIdentityInput {}
/**
* @public
*
* The output of {@link GetCredentialsForIdentityCommand}.
*/
export interface GetCredentialsForIdentityCommandOutput
extends GetCredentialsForIdentityResponse,
__MetadataBearer {}
/**
* @public
* <p>Input to the <code>GetCredentialsForIdentity</code> action.</p>
*/
export interface GetCredentialsForIdentityInput {
/**
* <p>A unique identifier in the format REGION:GUID.</p>
*/
IdentityId: string | undefined;
/**
* <p>A set of optional name-value pairs that map provider names to provider tokens. The
* name-value pair will follow the syntax "provider_name":
* "provider_user_identifier".</p>
* <p>Logins should not be specified when trying to get credentials for an unauthenticated
* identity.</p>
* <p>The Logins parameter is required when using identities associated with external
* identity providers such as Facebook. For examples of <code>Logins</code> maps, see the code
* examples in the <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/external-identity-providers.html">External Identity Providers</a> section of the Amazon Cognito Developer
* Guide.</p>
*/
Logins?: Record<string, string>;
/**
* <p>The Amazon Resource Name (ARN) of the role to be assumed when multiple roles were
* received in the token from the identity provider. For example, a SAML-based identity
* provider. This parameter is optional for identity providers that do not support role
* customization.</p>
*/
CustomRoleArn?: string;
}
/**
* @public
* <p>Returned in response to a successful <code>GetCredentialsForIdentity</code>
* operation.</p>
*/
export interface GetCredentialsForIdentityResponse {
/**
* <p>A unique identifier in the format REGION:GUID.</p>
*/
IdentityId?: string;
/**
* <p>Credentials for the provided identity ID.</p>
*/
Credentials?: Credentials;
}
/**
* @public
*
* The input for {@link GetIdCommand}.
*/
export interface GetIdCommandInput extends GetIdInput {}
/**
* @public
*
* The output of {@link GetIdCommand}.
*/
export interface GetIdCommandOutput extends GetIdResponse, __MetadataBearer {}
/**
* @public
* <p>Input to the GetId action.</p>
*/
export interface GetIdInput {
/**
* <p>A standard AWS account ID (9+ digits).</p>
*/
AccountId?: string;
/**
* <p>An identity pool ID in the format REGION:GUID.</p>
*/
IdentityPoolId: string | undefined;
/**
* <p>A set of optional name-value pairs that map provider names to provider tokens. The
* available provider names for <code>Logins</code> are as follows:</p>
* <ul>
* <li>
* <p>Facebook: <code>graph.facebook.com</code>
* </p>
* </li>
* <li>
* <p>Amazon Cognito user pool:
* <code>cognito-idp.<region>.amazonaws.com/<YOUR_USER_POOL_ID></code>,
* for example, <code>cognito-idp.us-east-1.amazonaws.com/us-east-1_123456789</code>.
* </p>
* </li>
* <li>
* <p>Google: <code>accounts.google.com</code>
* </p>
* </li>
* <li>
* <p>Amazon: <code>www.amazon.com</code>
* </p>
* </li>
* <li>
* <p>Twitter: <code>api.twitter.com</code>
* </p>
* </li>
* <li>
* <p>Digits: <code>www.digits.com</code>
* </p>
* </li>
* </ul>
*/
Logins?: Record<string, string>;
}
/**
* @public
* <p>Returned in response to a GetId request.</p>
*/
export interface GetIdResponse {
/**
* <p>A unique identifier in the format REGION:GUID.</p>
*/
IdentityId?: string;
}

export {};
8 changes: 4 additions & 4 deletions packages/core/src/AwsClients/Pinpoint/getInAppMessages.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import type {
GetInAppMessagesCommandInput as GetInAppMessagesInput,
GetInAppMessagesCommandOutput as GetInAppMessagesOutput,
} from '@aws-sdk/client-pinpoint';
import { authenticatedHandler } from '../../clients/handlers/authenticated';
import { composeServiceApi } from '../../clients/internal/composeServiceApi';
import { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent';
Expand All @@ -15,6 +11,10 @@ import {
} from '../../clients/serde';
import { Endpoint, HttpRequest, HttpResponse } from '../../clients/types';
import { defaultConfig, getSharedHeaders } from './base';
import type {
GetInAppMessagesCommandInput as GetInAppMessagesInput,
GetInAppMessagesCommandOutput as GetInAppMessagesOutput,
} from './types';

export type { GetInAppMessagesInput, GetInAppMessagesOutput };

Expand Down
1 change: 1 addition & 0 deletions packages/core/src/AwsClients/Pinpoint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ export {
UpdateEndpointInput,
UpdateEndpointOutput,
} from './updateEndpoint';
export { Event, InAppMessageCampaign } from './types';
8 changes: 4 additions & 4 deletions packages/core/src/AwsClients/Pinpoint/putEvents.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

import type {
PutEventsCommandInput as PutEventsInput,
PutEventsCommandOutput as PutEventsOutput,
} from '@aws-sdk/client-pinpoint';
import { authenticatedHandler } from '../../clients/handlers/authenticated';
import { composeServiceApi } from '../../clients/internal/composeServiceApi';
import { extendedEncodeURIComponent } from '../../clients/middleware/signing/utils/extendedEncodeURIComponent';
Expand All @@ -15,6 +11,10 @@ import {
} from '../../clients/serde';
import { Endpoint, HttpRequest, HttpResponse } from '../../clients/types';
import { defaultConfig, getSharedHeaders } from './base';
import type {
PutEventsCommandInput as PutEventsInput,
PutEventsCommandOutput as PutEventsOutput,
} from './types';

export type { PutEventsInput, PutEventsOutput };

Expand Down
Loading

0 comments on commit 9a8569a

Please sign in to comment.