Skip to content

Commit

Permalink
Merge branch 'master' into HubReboot
Browse files Browse the repository at this point in the history
  • Loading branch information
undefobj committed Mar 27, 2019
2 parents 241e5a7 + 1a48f1d commit a034e76
Show file tree
Hide file tree
Showing 49 changed files with 7,120 additions and 6,327 deletions.
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -1,6 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

Expand Down Expand Up @@ -34,4 +37,7 @@ If applicable, add screenshots to help explain your problem.
**Additional context**
Add any other context about the problem here.

**Sample code**
Include additional sample code or a sample repository to help us reproduce the issue. (Be sure to remove any sensitive data)

***You can turn on the debug mode to provide more info for us by setting window.LOG_LEVEL = 'DEBUG'; in your app.***
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -1,6 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

Expand Down
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/usage-question.md
@@ -1,6 +1,9 @@
---
name: Usage Question
about: Ask a question about AWS Amplify usage
title: ''
labels: ''
assignees: ''

---

Expand Down
8 changes: 8 additions & 0 deletions packages/amazon-cognito-identity-js/CHANGELOG.md
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="3.0.10-unstable.0"></a>
## [3.0.10-unstable.0](https://github.com/aws/aws-amplify/compare/amazon-cognito-identity-js@3.0.9...amazon-cognito-identity-js@3.0.10-unstable.0) (2019-03-18)




**Note:** Version bump only for package amazon-cognito-identity-js

<a name="3.0.9"></a>
## [3.0.9](https://github.com/aws/aws-amplify/compare/amazon-cognito-identity-js@3.0.9-unstable.0...amazon-cognito-identity-js@3.0.9) (2019-03-06)

Expand Down
2 changes: 1 addition & 1 deletion packages/amazon-cognito-identity-js/package.json
@@ -1,7 +1,7 @@
{
"name": "amazon-cognito-identity-js",
"description": "Amazon Cognito Identity Provider JavaScript SDK",
"version": "3.0.9",
"version": "3.0.10-unstable.0",
"author": {
"name": "Amazon Web Services",
"email": "aws@amazon.com",
Expand Down
23 changes: 17 additions & 6 deletions packages/amazon-cognito-identity-js/src/CognitoUser.js
Expand Up @@ -1066,19 +1066,30 @@ export default class CognitoUser {
return callback(new Error('User is not authenticated'), null);
}

const bypassCache = params? params.bypassCache : false;
let userData = this.storage.getItem(this.userDataKey);
const bypassCache = params ? params.bypassCache : false;

const userData = this.storage.getItem(this.userDataKey);
// get the cached user data

if (!userData || bypassCache) {
this.client.request('GetUser', {
AccessToken: this.signInUserSession.getAccessToken().getJwtToken(),
}, (err, userData) => {
}, (err, latestUserData) => {
if (err) {
return callback(err, null);
}
this.cacheUserData(userData);
return callback(null, userData);
this.cacheUserData(latestUserData);
const refresh = this.signInUserSession.getRefreshToken();
if (refresh && refresh.getToken()) {
this.refreshSession(refresh, (refreshError, data) => {
if (refreshError) {
return callback(refreshError, null);
}
return callback(null, latestUserData);
});
} else {
return callback(null, latestUserData);
}
});
} else {
try {
Expand Down
8 changes: 8 additions & 0 deletions packages/analytics/CHANGELOG.md
Expand Up @@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="1.2.12-unstable.2"></a>
## [1.2.12-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/analytics@1.2.12-unstable.1...@aws-amplify/analytics@1.2.12-unstable.2) (2019-03-22)




**Note:** Version bump only for package @aws-amplify/analytics

<a name="1.2.12-unstable.1"></a>
## [1.2.12-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/analytics@1.2.12-unstable.0...@aws-amplify/analytics@1.2.12-unstable.1) (2019-03-08)

Expand Down
6 changes: 3 additions & 3 deletions packages/analytics/package.json
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/analytics",
"version": "1.2.12-unstable.1",
"version": "1.2.12-unstable.2",
"description": "Analytics category of aws-amplify",
"main": "./lib/index.js",
"module": "./lib/index.js",
Expand Down Expand Up @@ -53,8 +53,8 @@
"webpack": "^3.5.5"
},
"dependencies": {
"@aws-amplify/cache": "^1.0.23",
"@aws-amplify/core": "^1.0.23",
"@aws-amplify/cache": "1.0.24-unstable.0",
"@aws-amplify/core": "1.0.24-unstable.0",
"uuid": "^3.2.1"
},
"jest": {
Expand Down
59 changes: 59 additions & 0 deletions packages/api/CHANGELOG.md
Expand Up @@ -3,6 +3,65 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

<a name="1.0.30-unstable.6"></a>
## [1.0.30-unstable.6](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.30-unstable.5...@aws-amplify/api@1.0.30-unstable.6) (2019-03-25)


### Bug Fixes

* **api:** allow API options to be merged with root level options ([8965b36](https://github.com/aws/aws-amplify/commit/8965b36)), closes [#1302](https://github.com/aws/aws-amplify/issues/1302)




<a name="1.0.30-unstable.5"></a>
## [1.0.30-unstable.5](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.30-unstable.4...@aws-amplify/api@1.0.30-unstable.5) (2019-03-24)




**Note:** Version bump only for package @aws-amplify/api

<a name="1.0.30-unstable.4"></a>
## [1.0.30-unstable.4](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.30-unstable.3...@aws-amplify/api@1.0.30-unstable.4) (2019-03-22)




**Note:** Version bump only for package @aws-amplify/api

<a name="1.0.30-unstable.3"></a>
## [1.0.30-unstable.3](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.30-unstable.2...@aws-amplify/api@1.0.30-unstable.3) (2019-03-22)




**Note:** Version bump only for package @aws-amplify/api

<a name="1.0.30-unstable.2"></a>
## [1.0.30-unstable.2](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.30-unstable.1...@aws-amplify/api@1.0.30-unstable.2) (2019-03-20)




**Note:** Version bump only for package @aws-amplify/api

<a name="1.0.30-unstable.1"></a>
## [1.0.30-unstable.1](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.30-unstable.0...@aws-amplify/api@1.0.30-unstable.1) (2019-03-19)




**Note:** Version bump only for package @aws-amplify/api

<a name="1.0.30-unstable.0"></a>
## [1.0.30-unstable.0](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.29...@aws-amplify/api@1.0.30-unstable.0) (2019-03-18)




**Note:** Version bump only for package @aws-amplify/api

<a name="1.0.29"></a>
## [1.0.29](https://github.com/aws/aws-amplify/compare/@aws-amplify/api@1.0.29-unstable.1...@aws-amplify/api@1.0.29) (2019-03-06)

Expand Down
82 changes: 40 additions & 42 deletions packages/api/__tests__/API-test.ts
Expand Up @@ -6,7 +6,9 @@ import { RestClient } from '../src/RestClient';
import { print } from 'graphql/language/printer';
import { parse } from 'graphql/language/parser';
import { Signer, Credentials } from '@aws-amplify/core';
import PubSub from '@aws-amplify/pubsub';
import Cache from '@aws-amplify/cache';
import * as Observable from 'zen-observable';

jest.mock('axios');

Expand Down Expand Up @@ -265,20 +267,15 @@ describe('API test', () => {
spyonCache.mockClear();
});

test.skip('happy-case-subscription', (done) => {
const spyonAuth = jest.spyOn(Credentials, 'get').mockImplementation(() => {
return new Promise((res, rej) => {
res('cred');
});
});

// TODO: This mock doesnt work on jest
const spyon = jest.spyOn(RestClient.prototype, 'post')
.mockImplementation((url, init) => {
return new Promise((res, rej) => {
res({})
});
});
test('happy-case-subscription', async (done) => {
jest.spyOn(RestClient.prototype, 'post')
.mockImplementation(async (url, init) => ({
extensions: {
subscription: {
newSubscriptions: {}
}
}
}));

const api = new API(config);
const url = 'https://appsync.amazonaws.com',
Expand All @@ -292,48 +289,27 @@ describe('API test', () => {
aws_appsync_authenticationType: 'API_KEY',
aws_appsync_apiKey: apiKey
});
const pubsub = new PubSub(config);

PubSub.subscribe = jest.fn(() => Observable.of({}));

const SubscribeToEventComments = `subscription SubscribeToEventComments($eventId: String!) {
subscribeToEventComments(eventId: $eventId) {
eventId
commentId
content
eventId
commentId
content
}
}`;
}`;

const doc = parse(SubscribeToEventComments);
const query = print(doc);

const headers = {
Authorization: null,
'X-Api-Key': apiKey
};

const body = {
query,
variables,
};

const init = {
headers,
body,
signerServiceInfo: {
service: 'appsync',
region,
}
};

const observable = api.graphql(graphqlOperation(SubscribeToEventComments, variables)).subscribe({
const observable = api.graphql(graphqlOperation(query, variables)).subscribe({
next: () => {
done();
}
});

pubsub.publish('topic1', 'my message');

expect(observable).not.toBe(undefined);
expect(spyon).toBeCalled();
});

test('happy case mutation', async () => {
Expand Down Expand Up @@ -426,6 +402,28 @@ describe('API test', () => {
region: 'region'
});
});

test('with API options', () => {
const api = new API({});

const options = {
API: {
aws_project_region: 'api-region',
},
aws_project_region: 'region',
aws_appsync_region: 'appsync-region',
aws_cloud_logic_custom
}

expect(api.configure(options)).toEqual({
aws_cloud_logic_custom,
aws_project_region: 'api-region',
aws_appsync_region: 'appsync-region',
endpoints: aws_cloud_logic_custom,
header: {},
region: 'api-region'
});
});
});


Expand Down
8 changes: 4 additions & 4 deletions packages/api/package.json
@@ -1,6 +1,6 @@
{
"name": "@aws-amplify/api",
"version": "1.0.29",
"version": "1.0.30-unstable.6",
"description": "Api category of aws-amplify",
"main": "./lib/index.js",
"module": "./lib/index.js",
Expand Down Expand Up @@ -50,9 +50,9 @@
"webpack": "^3.5.5"
},
"dependencies": {
"@aws-amplify/auth": "^1.2.18",
"@aws-amplify/cache": "^1.0.23",
"@aws-amplify/core": "^1.0.23",
"@aws-amplify/auth": "1.2.19-unstable.4",
"@aws-amplify/cache": "1.0.24-unstable.0",
"@aws-amplify/core": "1.0.24-unstable.0",
"@types/zen-observable": "^0.5.3",
"axios": "^0.17.0",
"graphql": "0.13.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/API.ts
Expand Up @@ -54,7 +54,8 @@ export default class APIClass {
* @return {Object} - The current configuration
*/
configure(options) {
let opt = options ? options.API || options : {};
const { API = {}, ...otherOptions } = options || {};
let opt = { ...otherOptions, ...API };
logger.debug('configure API', { opt });

if (opt['aws_project_region']) {
Expand Down

0 comments on commit a034e76

Please sign in to comment.