Skip to content

Commit

Permalink
Merge branch 'main' into temp/release-merge-1725397341
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblanc authored Sep 3, 2024
2 parents b351897 + 1a5366d commit 620c7b2
Show file tree
Hide file tree
Showing 19 changed files with 1,157 additions and 969 deletions.
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/1.bug_report.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Bug report
description: Create a report to help us improve Amplify JS
labels: pending-triage

body:
- type: markdown
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/2.feature_request.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Feature request
description: Suggest an idea for Amplify JS
labels: pending-triage

body:
- type: markdown
Expand Down
23 changes: 0 additions & 23 deletions .github/ISSUE_TEMPLATE/3.usage-question.md

This file was deleted.

46 changes: 0 additions & 46 deletions .github/ISSUE_TEMPLATE/4.rfc.md

This file was deleted.

7 changes: 4 additions & 3 deletions .github/dependency-review/dependecy-review-config.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
allow-licenses:
- 'Apache-2.0'
- '0BSD'
- 'BSL-1.0'
- 'Apache-2.0'
- 'BlueOak-1.0.0'
- 'BSD-1-Clause'
- 'BSD-2-Clause-FreeBSD'
- 'BSD-2-Clause'
- 'BSD-3-Clause-Attribution'
- 'BSD-3-Clause'
- 'BSL-1.0'
- 'CC-BY-3.0'
- 'CC-BY-4.0'
- 'CC0-1.0'
- 'curl'
- 'ISC'
- 'JSON'
Expand All @@ -20,4 +22,3 @@ allow-licenses:
- 'Unlicense'
- 'WTFPL'
- 'Zlib'
- 'CC0-1.0'
22 changes: 22 additions & 0 deletions .github/workflows/issue-closed.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Issue Closed

on:
issues:
types: [closed]

permissions:
issues: write

jobs:
cleanup-labels:
runs-on: ubuntu-latest
if: ${{ (contains(github.event.issue.labels.*.name, 'pending-community-response') || contains(github.event.issue.labels.*.name, 'pending-maintainer-response') || contains(github.event.issue.labels.*.name, 'pending-triage')) }}
steps:
- name: Remove unnecessary labels after closing
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-community-response" --remove-label "pending-maintainer-response" --remove-label "pending-triage"
31 changes: 31 additions & 0 deletions .github/workflows/issue-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Issue Comment

on:
issue_comment:
types: [created]

jobs:
adjust-labels:
runs-on: ubuntu-latest
permissions:
issues: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
steps:
- name: Remove pending-community-response when new comment received
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) && !github.event.issue.pull_request }}
shell: bash
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-community-response"
- name: Add pending-maintainer-response when new community comment received
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }}
shell: bash
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-maintainer-response"
- name: Remove pending-maintainer-response when new owner/member comment received
if: ${{ contains(fromJSON('["MEMBER", "OWNER"]'), github.event.comment.author_association) }}
shell: bash
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-maintainer-response"
21 changes: 21 additions & 0 deletions .github/workflows/issue-labeled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Issue Labeled

on:
issues:
types: [labeled]

jobs:
remove-pending-triage-label:
runs-on: ubuntu-latest
if: ${{ contains(fromJSON('["question", "bug", "feature-request"]'), github.event.label.name) }}
permissions:
issues: write
steps:
- name: Remove the pending-triage label
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --remove-label "pending-triage"
25 changes: 25 additions & 0 deletions .github/workflows/issue-opened.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Issue Opened

on:
issues:
types: [opened]

jobs:
add-issue-opened-labels:
runs-on: ubuntu-latest
permissions:
issues: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
REPOSITORY_NAME: ${{ github.event.repository.full_name }}
steps:
- name: Add the pending-triage label
shell: bash
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-triage"
- name: Add the pending-maintainer-response label
if: ${{ !contains(fromJSON('["MEMBER", "OWNER"]'), github.event.issue.author_association) }}
shell: bash
run: |
gh issue edit $ISSUE_NUMBER --repo $REPOSITORY_NAME --add-label "pending-maintainer-response"
15 changes: 0 additions & 15 deletions .github/workflows/issue-pending-response.yml

This file was deleted.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unused-imports": "^3.0.0",
"expect": "^29.7.0",
"glob": "10.3.10",
"glob": "^10.3.10",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
Expand Down Expand Up @@ -136,7 +136,6 @@
"**/glob/minipass": "6.0.2",
"nx": "16.7.0",
"xml2js": "0.5.0",
"tar": "6.2.1",
"glob@^10.0.0": "10.3.10"
"tar": "6.2.1"
}
}
88 changes: 82 additions & 6 deletions packages/api-graphql/__tests__/AWSAppSyncRealTimeProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ describe('AWSAppSyncRealTimeProvider', () => {

expect(newSocketSpy).toHaveBeenNthCalledWith(
1,
'ws://localhost:8080/realtime?header=&payload=e30=',
'graphql-ws',
'ws://localhost:8080/realtime',
['graphql-ws', 'header-'],
);
});

Expand All @@ -271,8 +271,8 @@ describe('AWSAppSyncRealTimeProvider', () => {

expect(newSocketSpy).toHaveBeenNthCalledWith(
1,
'wss://localhost:8080/realtime?header=&payload=e30=',
'graphql-ws',
'wss://localhost:8080/realtime',
['graphql-ws', 'header-'],
);
});

Expand All @@ -298,8 +298,84 @@ describe('AWSAppSyncRealTimeProvider', () => {

expect(newSocketSpy).toHaveBeenNthCalledWith(
1,
'wss://testaccounturl123456789123.appsync-realtime-api.us-east-1.amazonaws.com/graphql?header=&payload=e30=',
'graphql-ws',
'wss://testaccounturl123456789123.appsync-realtime-api.us-east-1.amazonaws.com/graphql',
['graphql-ws', 'header-'],
);
});

test('subscription generates expected auth token', async () => {
expect.assertions(1);

const newSocketSpy = jest
.spyOn(provider, 'getNewWebSocket')
.mockImplementation(() => {
fakeWebSocketInterface.newWebSocket();
return fakeWebSocketInterface.webSocket;
});

provider
.subscribe({
appSyncGraphqlEndpoint:
'https://testaccounturl123456789123.appsync-api.us-east-1.amazonaws.com/graphql',
// using custom auth instead of apiKey, because the latter inserts a timestamp header => expected value changes
authenticationType: 'lambda',
additionalHeaders: {
Authorization: 'my-custom-auth-token',
},
})
.subscribe({ error: () => {} });

// Wait for the socket to be initialize
await fakeWebSocketInterface.readyForUse;

/*
Regular base64 encoding of auth header {"Authorization":"my-custom-auth-token","host":"testaccounturl123456789123.appsync-api.us-east-1.amazonaws.com"}
Is: `eyJBdXRob3JpemF0aW9uIjoibXktY3VzdG9tLWF1dGgtdG9rZW4iLCJob3N0IjoidGVzdGFjY291bnR1cmwxMjM0NTY3ODkxMjMuYXBwc3luYy1hcGkudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20ifQ==`
(note `==` at the end of the string)
base64url encoding is expected to drop padding chars `=`
*/

expect(newSocketSpy).toHaveBeenNthCalledWith(
1,
'wss://testaccounturl123456789123.appsync-realtime-api.us-east-1.amazonaws.com/graphql',
[
'graphql-ws',
'header-eyJBdXRob3JpemF0aW9uIjoibXktY3VzdG9tLWF1dGgtdG9rZW4iLCJob3N0IjoidGVzdGFjY291bnR1cmwxMjM0NTY3ODkxMjMuYXBwc3luYy1hcGkudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20ifQ',
],
);
});

test('subscription generates expected auth token - custom domain', async () => {
expect.assertions(1);

const newSocketSpy = jest
.spyOn(provider, 'getNewWebSocket')
.mockImplementation(() => {
fakeWebSocketInterface.newWebSocket();
return fakeWebSocketInterface.webSocket;
});

provider
.subscribe({
appSyncGraphqlEndpoint: 'https://unit-test.testurl.com',
// using custom auth instead of apiKey, because the latter inserts a timestamp header => expected value changes
authenticationType: 'lambda',
additionalHeaders: {
Authorization: 'my-custom-auth-token',
},
})
.subscribe({ error: () => {} });

// Wait for the socket to be initialize
await fakeWebSocketInterface.readyForUse;

expect(newSocketSpy).toHaveBeenNthCalledWith(
1,
'wss://unit-test.testurl.com/realtime',
[
'graphql-ws',
'header-eyJBdXRob3JpemF0aW9uIjoibXktY3VzdG9tLWF1dGgtdG9rZW4iLCJob3N0IjoidW5pdC10ZXN0LnRlc3R1cmwuY29tIn0',
],
);
});

Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/__tests__/GraphQLAPI.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@ describe('API test', () => {
`;

const resolvedUrl =
'wss://testaccounturl123456789123.appsync-realtime-api.us-east-1.amazonaws.com/graphql?header=eyJBdXRob3JpemF0aW9uIjoiYWJjMTIzNDUiLCJob3N0IjoidGVzdGFjY291bnR1cmwxMjM0NTY3ODkxMjMuYXBwc3luYy1hcGkudXMtZWFzdC0xLmFtYXpvbmF3cy5jb20ifQ==&payload=e30=&x-amz-user-agent=aws-amplify%2F6.4.0%20api%2F1%20framework%2F2&ex-machina=is%20a%20good%20movie';
'wss://testaccounturl123456789123.appsync-realtime-api.us-east-1.amazonaws.com/graphql?x-amz-user-agent=aws-amplify%2F6.4.0+api%2F1+framework%2F2&ex-machina=is+a+good+movie';

(
client.graphql(
Expand Down
Loading

0 comments on commit 620c7b2

Please sign in to comment.