Skip to content

Commit

Permalink
feat: add appendAdditionalUserAgent function to customSkill in ask-sd…
Browse files Browse the repository at this point in the history
…k-core
  • Loading branch information
Shen Chen committed Aug 1, 2019
1 parent 1321407 commit ac238bb
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 20 deletions.
8 changes: 8 additions & 0 deletions ask-sdk-core/lib/skill/CustomSkill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,12 @@ export class CustomSkill implements Skill<RequestEnvelope, ResponseEnvelope> {
public supports(input : any, context? : any) : boolean {
return !!input.request;
}

/**
* Append additional user agent info
* @param userAgent
*/
public appendAdditionalUserAgent(userAgent : string) : void {
this.customUserAgent = this.customUserAgent ? (`${this.customUserAgent} ${userAgent}`) : userAgent;
}
}
8 changes: 4 additions & 4 deletions ask-sdk-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@
"@types/chai": "^4.1.2",
"@types/mocha": "^5.0.0",
"@types/node": "^9.6.1",
"@types/sinon": "^4.3.0",
"@types/sinon": "^7.0.13",
"ask-sdk-model": "^1.9.0",
"chai": "^4.1.2",
"del": "^3.0.0",
"gulp": "^4.0.0",
"mocha": "^5.0.5",
"nock": "^9.2.3",
"nyc": "^13.0.1",
"sinon": "^4.5.0",
"nyc": "^14.1.1",
"sinon": "^7.0.13",
"ts-node": "^6.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^3.5.3"
},
"repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs",
"bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues",
Expand Down
17 changes: 17 additions & 0 deletions ask-sdk-core/tst/skill/CustomSkill.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,21 @@ describe('CustomSkill', () => {
expect(skill.supports(requestEnvelope)).eq(true);
expect(skill.supports({} as any)).eq(false);
});

it('should be able to append additional user agent', async() => {
const additionUserAnger : string = 'TEST_Agent';
const packageInfo = require('../../package.json');
const skill = SkillBuilders.custom()
.addRequestHandlers(
new MockAlwaysTrueRequestHandler(),
new MockAlwaysFalseRequestHandler(),
)
.create();

const requestEnvelope = JsonProvider.requestEnvelope();
skill.appendAdditionalUserAgent(additionUserAnger);
const responseEnvelope = await skill.invoke(requestEnvelope);

expect(responseEnvelope.userAgent).equal(`ask-node/${packageInfo.version} Node/${process.version} ${additionUserAnger}`);
});
});
4 changes: 2 additions & 2 deletions ask-sdk-dynamodb-persistence-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"del": "^3.0.0",
"gulp": "^4.0.0",
"mocha": "^5.0.5",
"nyc": "^13.0.1",
"nyc": "^14.1.1",
"ts-node": "^6.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^3.5.3"
},
"repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs",
"bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues",
Expand Down
8 changes: 4 additions & 4 deletions ask-sdk-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@
"@types/chai": "^4.1.2",
"@types/mocha": "^5.0.0",
"@types/node": "^9.6.1",
"@types/sinon": "^4.3.0",
"@types/sinon": "^7.0.13",
"chai": "^4.1.2",
"del": "^3.0.0",
"gulp": "^4.0.0",
"mocha": "^5.0.5",
"nock": "^9.2.3",
"nyc": "^13.0.1",
"sinon": "^4.5.0",
"nyc": "^14.1.1",
"sinon": "^7.0.13",
"ts-node": "^6.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^3.5.3"
},
"repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs",
"bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues",
Expand Down
4 changes: 2 additions & 2 deletions ask-sdk-s3-persistence-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"del": "^3.0.0",
"gulp": "^4.0.0",
"mocha": "^5.0.5",
"nyc": "^13.0.1",
"nyc": "^14.1.1",
"ts-node": "^6.2.0",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^3.5.3"
},
"repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs",
"bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues",
Expand Down
8 changes: 4 additions & 4 deletions ask-sdk-v1adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@
"@types/chai": "^4.1.2",
"@types/mocha": "^5.0.0",
"@types/node": "^9.6.1",
"@types/sinon": "^4.3.0",
"@types/sinon": "^7.0.13",
"ask-sdk": "^2.6.0",
"chai": "^4.1.2",
"del": "^3.0.0",
"gulp": "^4.0.0",
"mocha": "^5.0.5",
"nock": "^9.2.3",
"nyc": "^13.0.1",
"sinon": "^4.5.0",
"nyc": "^14.1.1",
"sinon": "^7.0.13",
"ts-node": "^6.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^3.5.3"
},
"repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs",
"bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues",
Expand Down
4 changes: 2 additions & 2 deletions ask-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"del": "^3.0.0",
"gulp": "^4.0.0",
"mocha": "^5.0.5",
"nyc": "^13.0.1",
"nyc": "^14.1.1",
"ts-node": "^6.0.1",
"tslint": "^5.9.1",
"typescript": "^2.8.1"
"typescript": "^3.5.3"
},
"repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs",
"bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues",
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"clean-all": "npm run clean-build && npm run clean-node_modules"
},
"devDependencies": {
"lerna": "^3.4.3"
}
"lerna": "^3.16.4"
},
"name": "alexa-skills-kit-sdk-for-nodejs"
}

0 comments on commit ac238bb

Please sign in to comment.