Skip to content

Commit 4cf088c

Browse files
release(required): Amplify JS release (#13814)
2 parents be1442d + 5918360 commit 4cf088c

File tree

129 files changed

+2913
-1030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+2913
-1030
lines changed

.github/actions/load-verdaccio-with-amplify-js/action.yml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ runs:
66
steps:
77
- name: Start verdaccio
88
run: |
9-
9+
# This version supports Node.js v22
10+
1011
while ! nc -z localhost 4873; do
1112
echo "Verdaccio not running yet"
1213
sleep 1
@@ -18,25 +19,30 @@ runs:
1819
- name: Install and run npm-cli-login
1920
shell: bash
2021
env:
21-
NPM_REGISTRY: http://localhost:4873/
22+
NPM_REGISTRY_HOST: localhost:4873
23+
NPM_REGISTRY: http://localhost:4873
2224
NPM_USER: verdaccio
2325
NPM_PASS: verdaccio
2426
NPM_EMAIL: [email protected]
2527
run: |
26-
npm i -g npm-cli-adduser
27-
npm-cli-adduser
28-
sleep 1
29-
- name: Configure registry and git
28+
# Make the HTTP request that npm addUser makes to avoid the "Exit handler never called" error
29+
TOKEN=$(curl -s \
30+
-H "Accept: application/json" \
31+
-H "Content-Type:application/json" \
32+
-X PUT --data "{\"name\": \"$NPM_USER\", \"password\": \"$NPM_PASS\", \"email\": \"$NPM_EMAIL\"}" \
33+
$NPM_REGISTRY/-/user/org.couchdb.user:$NPM_USER 2>&1 | jq -r '.token')
34+
35+
# Set the Verdaccio registry and set the token for logging in
36+
yarn config set registry $NPM_REGISTRY
37+
npm set registry $NPM_REGISTRY
38+
npm set //"$NPM_REGISTRY_HOST"/:_authToken $TOKEN
39+
- name: Configure git
3040
shell: bash
3141
working-directory: ./amplify-js
3242
env:
33-
NPM_REGISTRY: http://localhost:4873/
3443
NPM_USER: verdaccio
35-
NPM_PASS: verdaccio
3644
NPM_EMAIL: [email protected]
3745
run: |
38-
yarn config set registry $NPM_REGISTRY
39-
npm set registry $NPM_REGISTRY
4046
git config --global user.email $NPM_EMAIL
4147
git config --global user.name $NPM_USER
4248
git status

.github/actions/node-and-build/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ inputs:
44
is-prebuild:
55
required: false
66
default: false
7+
node_version:
8+
required: false
79
runs:
810
using: 'composite'
911
steps:
10-
- name: Setup Node.js 18
12+
- name: Setup Node.js
1113
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
1214
with:
13-
node-version: 18.20.2
15+
node-version: ${{ inputs.node_version || '18.x' }}
1416
env:
1517
SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2
1618
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0

.github/integ-config/integ-all.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,3 +870,10 @@ tests:
870870
spec: ssr-context-isolation
871871
yarn_script: ci:ssr-context-isolation
872872
browser: [chrome]
873+
- test_name: integ_node_envs
874+
desc: 'Node.js environment tests'
875+
framework: node
876+
category: integration
877+
sample_name: auth-gql-storage
878+
yarn_script: ci:node-env-test
879+
node_versions: ['18.x', '20.x', '22.x']

.github/workflows/callable-e2e-test.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ on:
3737
yarn_script:
3838
required: false
3939
type: string
40+
node_versions:
41+
required: false
42+
type: string
4043

4144
env:
4245
AMPLIFY_DIR: /home/runner/work/amplify-js/amplify-js/amplify-js
@@ -54,6 +57,8 @@ jobs:
5457
- ${{ fromJson(inputs.browser) }}
5558
sample_name:
5659
- ${{ fromJson(inputs.sample_name) }}
60+
node_version:
61+
- ${{ fromJson(inputs.node_versions) }}
5762
fail-fast: false
5863
timeout-minutes: ${{ inputs.timeout_minutes }}
5964

@@ -64,6 +69,8 @@ jobs:
6469
path: amplify-js
6570
- name: Setup node and build the repository
6671
uses: ./amplify-js/.github/actions/node-and-build
72+
with:
73+
node_version: ${{ matrix.node_version }}
6774
- name: Setup samples staging repository
6875
uses: ./amplify-js/.github/actions/setup-samples-staging
6976
with:

.github/workflows/callable-e2e-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ jobs:
4444
timeout_minutes: ${{ matrix.integ-config.timeout_minutes || 35 }}
4545
retry_count: ${{ matrix.integ-config.retry_count || 3 }}
4646
yarn_script: ${{ matrix.integ-config.yarn_script || '' }}
47+
node_versions: ${{ toJSON(matrix.integ-config.node_versions) || '[""]' }}
4748

4849
# e2e-test-runner-headless:
4950
# name: E2E test runnner_headless

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@
130130
"webpack-bundle-analyzer": "^4.7.0",
131131
"webpack-cli": "^5.0.0"
132132
},
133+
"engines": {
134+
"node": ">=18"
135+
},
133136
"resolutions": {
134137
"@types/babel__traverse": "7.20.0",
135138
"path-scurry": "1.10.0",

packages/api-graphql/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"dependencies": {
8787
"@aws-amplify/api-rest": "4.0.47",
8888
"@aws-amplify/core": "6.4.0",
89-
"@aws-amplify/data-schema": "^1.0.0",
89+
"@aws-amplify/data-schema": "^1.5.0",
9090
"@aws-sdk/types": "3.387.0",
9191
"graphql": "15.8.0",
9292
"rxjs": "^7.8.1",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { AmplifyUrl } from '@aws-amplify/core/internals/utils';
2+
3+
import { cognitoUserPoolEndpointResolver } from '../../src/foundation/cognitoUserPoolEndpointResolver';
4+
import { COGNITO_IDP_SERVICE_NAME } from '../../src/foundation/constants';
5+
6+
describe('cognitoUserPoolEndpointResolver', () => {
7+
it('should return the Cognito User Pool endpoint', () => {
8+
const region = 'us-west-2';
9+
const { url } = cognitoUserPoolEndpointResolver({ region });
10+
11+
expect(url instanceof AmplifyUrl).toBe(true);
12+
expect(url.toString()).toEqual(
13+
`https://${COGNITO_IDP_SERVICE_NAME}.us-west-2.amazonaws.com/`,
14+
);
15+
});
16+
});
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { composeServiceApi } from '@aws-amplify/core/internals/aws-client-utils/composers';
2+
3+
import * as serviceClients from '../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider';
4+
import { DEFAULT_SERVICE_CLIENT_API_CONFIG } from '../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/constants';
5+
6+
import { mockServiceClientAPIConfig } from './testUtils/data';
7+
8+
jest.mock('@aws-amplify/core/internals/aws-client-utils/composers', () => ({
9+
...jest.requireActual(
10+
'@aws-amplify/core/internals/aws-client-utils/composers',
11+
),
12+
composeServiceApi: jest.fn(),
13+
}));
14+
15+
export const mockComposeServiceApi = jest.mocked(composeServiceApi);
16+
17+
describe('service clients', () => {
18+
const serviceClientFactories = Object.keys(serviceClients);
19+
20+
afterEach(() => {
21+
mockComposeServiceApi.mockClear();
22+
});
23+
24+
test.each(serviceClientFactories)(
25+
'factory `%s` should invoke composeServiceApi with expected parameters',
26+
serviceClientFactory => {
27+
// eslint-disable-next-line import/namespace
28+
serviceClients[serviceClientFactory](mockServiceClientAPIConfig);
29+
30+
expect(mockComposeServiceApi).toHaveBeenCalledWith(
31+
expect.any(Function),
32+
expect.any(Function),
33+
expect.any(Function),
34+
expect.objectContaining({
35+
...DEFAULT_SERVICE_CLIENT_API_CONFIG,
36+
...mockServiceClientAPIConfig,
37+
}),
38+
);
39+
},
40+
);
41+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { unauthenticatedHandler } from '@aws-amplify/core/internals/aws-client-utils';
2+
import { composeTransferHandler } from '@aws-amplify/core/internals/aws-client-utils/composers';
3+
4+
import { cognitoUserPoolTransferHandler } from '../../../../../../../src/foundation/factories/serviceClients/cognitoIdentityProvider/shared/handler';
5+
6+
jest.mock('@aws-amplify/core/internals/aws-client-utils/composers');
7+
jest.mock('@aws-amplify/core/internals/aws-client-utils');
8+
9+
const mockComposeTransferHandler = jest.mocked(composeTransferHandler);
10+
const mockUnauthenticatedHandler = jest.mocked(unauthenticatedHandler);
11+
12+
describe('cognitoUserPoolTransferHandler', () => {
13+
beforeAll(() => {
14+
// need to make sure cognitoUserPoolTransferHandler is imported and used in
15+
// the scope of the test
16+
const _ = cognitoUserPoolTransferHandler;
17+
});
18+
19+
it('adds the disableCacheMiddlewareFactory at module loading', () => {
20+
expect(mockComposeTransferHandler).toHaveBeenCalledTimes(1);
21+
22+
const [core, middleware] = mockComposeTransferHandler.mock.calls[0];
23+
24+
expect(core).toStrictEqual(mockUnauthenticatedHandler);
25+
expect(middleware).toHaveLength(1);
26+
27+
const disableCacheMiddlewareFactory = middleware[0] as any;
28+
const disableCacheMiddlewarePendingNext = disableCacheMiddlewareFactory();
29+
30+
const mockNext = jest.fn();
31+
const disableCacheMiddleware = disableCacheMiddlewarePendingNext(mockNext);
32+
const mockRequest = {
33+
headers: {},
34+
};
35+
36+
disableCacheMiddleware(mockRequest);
37+
38+
expect(mockNext).toHaveBeenCalledWith(mockRequest);
39+
expect(mockRequest.headers).toEqual({
40+
'cache-control': 'no-store',
41+
});
42+
});
43+
});

0 commit comments

Comments
 (0)