-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hidetaka Okamoto
committed
Jul 6, 2020
1 parent
664b5e0
commit 63e8727
Showing
22 changed files
with
564 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules/ | |
package-lock.json | ||
.DS_Store | ||
.ask/ | ||
build/ | ||
build/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
# package directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Serverless directories | ||
.serverless | ||
|
||
# Webpack directories | ||
.webpack | ||
.envrc | ||
|
||
# Build files | ||
dist/ | ||
build/ | ||
|
||
# ASK CLI files | ||
.ask/lambda | ||
|
||
# Misc | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Alexa skill functions | ||
|
||
## Development | ||
|
||
### Unit test | ||
|
||
```bash | ||
$ yarn test | ||
|
||
# Watch mode | ||
$ yarn test:dev | ||
``` | ||
|
||
### Build code | ||
|
||
We have to build the project before deploy to AWS Lambda | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
### Lambda entrypoint | ||
By the default, the Lambda function information is in `./dist/index.js`. | ||
And the handler name is `handler`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
{ | ||
"name": "hello-world", | ||
"version": "0.0.0", | ||
"description": "alexa utility for quickly building skills", | ||
"main": "/index.js", | ||
"scripts": { | ||
"build": "webpack", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"test:dev": "jest --watch --silent=false --verbose false --coverage" | ||
}, | ||
"author": "TalkyJS team", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@talkyjs/core": "0.x", | ||
"@ask-utils/router": "3.x", | ||
"@ask-utils/speech-script": "3.x", | ||
"ask-sdk-core": "^2.6.0", | ||
"ask-sdk-model": "^1.18.0" | ||
}, | ||
"directories": { | ||
"lib": "src", | ||
"test": "tests" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"json", | ||
"tsx", | ||
"ts" | ||
], | ||
"rootDir": "src", | ||
"testRegex": ".spec.(ts|tsx)$", | ||
"transform": { | ||
"^.+\\.(ts|tsx)$": "ts-jest" | ||
}, | ||
"collectCoverageFrom": [ | ||
"**/*.(t|j)s" | ||
], | ||
"coverageDirectory": "../coverage", | ||
"testEnvironment": "node", | ||
"globals": { | ||
"ts-jest": { | ||
"tsConfig": "tsconfig.json" | ||
} | ||
} | ||
}, | ||
"devDependencies": { | ||
"@ask-utils/test": "3.x", | ||
"@types/jest": "^25.2.1", | ||
"@types/node": "^13.13.5", | ||
"@types/webpack": "^4.41.12", | ||
"jest": "^26.0.1", | ||
"source-map-support": "^0.5.19", | ||
"ts-jest": "^25.5.1", | ||
"ts-loader": "^7.0.2", | ||
"ts-node": "^8.10.1", | ||
"typescript": "^3.8.3", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Router } from "@ask-utils/router"; | ||
|
||
import { HelpIntentScript } from './HelpIntent.speech' | ||
|
||
|
||
export const HelpIntentRouter: Router = { | ||
requestType: "IntentRequest", | ||
intentName: "AMAZON.HelpIntent", | ||
handler: async (handlerInput) => { | ||
|
||
|
||
const script = new HelpIntentScript(handlerInput) | ||
return script | ||
.createResponseBuilder() | ||
.getResponse(); | ||
|
||
|
||
} | ||
} | ||
|
||
export default HelpIntentRouter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** @jsx ssml */ | ||
import { | ||
ssml, | ||
SpeechScriptJSX, | ||
} from '@ask-utils/speech-script' | ||
|
||
export class HelpIntentScript extends SpeechScriptJSX { | ||
speech() { | ||
return ( | ||
<speak> | ||
<p>Hello! It's a nice development. How are you?</p> | ||
</speak> | ||
) | ||
} | ||
|
||
reprompt() { | ||
return ( | ||
<speak> | ||
<p>How are you?</p> | ||
</speak> | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { HandlerInputCreator } from '@ask-utils/test'; | ||
import { RequestHandlerFactory } from '@ask-utils/router'; | ||
import { RequestHandler } from 'ask-sdk-core'; | ||
import { HelpIntentRouter } from '../HelpIntent.router' | ||
|
||
describe('HelpIntentRouter', () => { | ||
let handler: RequestHandler; | ||
beforeEach(() => { | ||
handler = RequestHandlerFactory.create(HelpIntentRouter); | ||
}); | ||
describe('canHandle', () => { | ||
it('should return false when given a not LaunchRequest', async () => { | ||
const handlerInput = new HandlerInputCreator().createLaunchRequest(); | ||
await expect(handler.canHandle(handlerInput)).resolves.toEqual(false); | ||
}); | ||
|
||
it('should return false when given a not IntentRequest', async () => { | ||
const handlerInput = new HandlerInputCreator().createIntentRequest({ | ||
name: "AMAZON.HelpIntent", | ||
confirmationStatus: 'NONE' | ||
}); | ||
await expect(handler.canHandle(handlerInput)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
}); | ||
describe('handle', () => { | ||
it('should match snapshot', async () => { | ||
const handlerInput = new HandlerInputCreator().createLaunchRequest(); | ||
await expect(handler.handle(handlerInput)).resolves.toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { HandlerInputCreator } from '@ask-utils/test'; | ||
import { HelpIntentScript } from '../HelpIntent.speech' | ||
|
||
describe('HelpIntentScript', () => { | ||
|
||
it('should return false when given a not IntentRequest', async () => { | ||
const handlerInput = new HandlerInputCreator().createIntentRequest({ | ||
name: "AMAZON.HelpIntent", | ||
confirmationStatus: 'NONE' | ||
}); | ||
const script = new HelpIntentScript(handlerInput); | ||
expect(script.createResponse()).toMatchSnapshot(); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Router } from "@ask-utils/router"; | ||
|
||
import { LaunchRequestScript } from './LaunchRequest.speech' | ||
|
||
|
||
export const LaunchRequestRouter: Router = { | ||
requestType: "LaunchRequest", | ||
|
||
handler: async (handlerInput) => { | ||
|
||
|
||
const script = new LaunchRequestScript(handlerInput) | ||
return script | ||
.createResponseBuilder() | ||
.getResponse(); | ||
|
||
|
||
} | ||
} | ||
|
||
export default LaunchRequestRouter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** @jsx ssml */ | ||
import { | ||
ssml, | ||
SpeechScriptJSX, | ||
} from '@ask-utils/speech-script' | ||
|
||
export class LaunchRequestScript extends SpeechScriptJSX { | ||
speech() { | ||
return ( | ||
<speak> | ||
<p>Hello! It's a nice development. How are you?</p> | ||
</speak> | ||
) | ||
} | ||
|
||
reprompt() { | ||
return ( | ||
<speak> | ||
<p>How are you?</p> | ||
</speak> | ||
) | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
lambda/src/LaunchRequest/tests/LaunchRequest.router.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { HandlerInputCreator } from '@ask-utils/test'; | ||
import { RequestHandlerFactory } from '@ask-utils/router'; | ||
import { RequestHandler } from 'ask-sdk-core'; | ||
import { LaunchRequestRouter } from '../LaunchRequest.router' | ||
|
||
describe('LaunchRequestRouter', () => { | ||
let handler: RequestHandler; | ||
beforeEach(() => { | ||
handler = RequestHandlerFactory.create(LaunchRequestRouter); | ||
}); | ||
describe('canHandle', () => { | ||
it('should return false when given a not LaunchRequest', async () => { | ||
const handlerInput = new HandlerInputCreator().createLaunchRequest(); | ||
await expect(handler.canHandle(handlerInput)).resolves.toEqual(true); | ||
}); | ||
|
||
it('should return false when given a not IntentRequest', async () => { | ||
const handlerInput = new HandlerInputCreator().createIntentRequest({ | ||
name: "LaunchRequest", | ||
confirmationStatus: 'NONE' | ||
}); | ||
await expect(handler.canHandle(handlerInput)).resolves.toMatchSnapshot(); | ||
}); | ||
|
||
}); | ||
describe('handle', () => { | ||
it('should match snapshot', async () => { | ||
const handlerInput = new HandlerInputCreator().createLaunchRequest(); | ||
await expect(handler.handle(handlerInput)).resolves.toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.