├── .commitlintrc.json ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ └── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── ask-sdk-unit-test.yml │ └── ask-smapi-sdk-unit-test.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.ja.md ├── README.md ├── ask-sdk-controls └── README.md ├── ask-sdk-core ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── attributes │ │ ├── AttributesManager.ts │ │ ├── AttributesManagerFactory.ts │ │ └── persistence │ │ │ └── PersistenceAdapter.ts │ ├── components │ │ └── ComponentInterface.ts │ ├── dispatcher │ │ ├── error │ │ │ └── handler │ │ │ │ └── CustomSkillErrorHandler.ts │ │ └── request │ │ │ ├── handler │ │ │ ├── CustomSkillRequestHandler.ts │ │ │ ├── DelegateToIntentHandler.ts │ │ │ └── HandlerInput.ts │ │ │ └── interceptor │ │ │ ├── CustomSkillRequestInterceptor.ts │ │ │ └── CustomSkillResponseInterceptor.ts │ ├── index.ts │ ├── response │ │ ├── ImageHelper.ts │ │ ├── PlainTextContentHelper.ts │ │ ├── ResponseBuilder.ts │ │ ├── ResponseFactory.ts │ │ ├── RichTextContentHelper.ts │ │ └── TextContentHelper.ts │ ├── service │ │ └── DefaultApiClient.ts │ ├── skill │ │ ├── CustomSkill.ts │ │ ├── CustomSkillConfiguration.ts │ │ ├── SkillBuilders.ts │ │ └── factory │ │ │ ├── BaseSkillBuilder.ts │ │ │ ├── BaseSkillFactory.ts │ │ │ ├── CustomSkillBuilder.ts │ │ │ └── CustomSkillFactory.ts │ └── util │ │ ├── ComponentUtils.ts │ │ ├── RequestEnvelopeUtils.ts │ │ ├── SsmlUtils.ts │ │ └── ViewportUtils.ts ├── package.json ├── tsconfig.json └── tst │ ├── attributes │ └── AttributesManagerFactory.spec.ts │ ├── mocks │ ├── JsonProvider.ts │ ├── error │ │ ├── MockAlwaysFalseErrorHandler.ts │ │ └── MockAlwaysTrueErrorHandler.ts │ ├── persistence │ │ └── MockPersistenceAdapter.ts │ └── request │ │ ├── MockAlwaysFalseRequestHandler.ts │ │ └── MockAlwaysTrueRequestHandler.ts │ ├── response │ ├── ImageHelper.spec.ts │ ├── PlainTextContentHelper.spec.ts │ ├── ResponseFactory.spec.ts │ └── RichTextContentHelper.spec.ts │ ├── service │ └── DefaultApiClient.spec.ts │ ├── skill │ ├── CustomSkill.spec.ts │ ├── SkillBuilders.spec.ts │ └── factory │ │ ├── BaseSkillFactory.spec.ts │ │ └── CustomSkillFactory.spec.ts │ ├── tsconfig.json │ └── util │ ├── RequestEnvelopeUtil.spec.ts │ ├── SsmlUtils.spec.ts │ └── ViewportUtils.spec.ts ├── ask-sdk-dynamodb-persistence-adapter ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── attributes │ │ └── persistence │ │ │ ├── DynamoDbPersistenceAdapter.ts │ │ │ └── PartitionKeyGenerators.ts │ └── index.ts ├── package.json ├── tsconfig.json └── tst │ ├── attributes │ └── persistence │ │ ├── DynamoDbPersistenceAdapter.spec.ts │ │ └── PartitionKeyGenerators.spec.ts │ ├── mocks │ └── JsonProvider.ts │ └── tsconfig.json ├── ask-sdk-express-adapter ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── adapter │ │ └── ExpressAdapter.ts │ ├── index.ts │ ├── util │ │ └── index.ts │ └── verifier │ │ ├── helper.ts │ │ └── index.ts ├── package.json ├── tsconfig.json └── tst │ ├── adapter │ └── ExpressAdapter.spec.ts │ ├── mocks │ ├── DataProvider.ts │ ├── echo-api-cert-7.pem │ ├── requestEnvelope.json │ ├── rsa_sha256 │ └── rsa_sha256_pub │ ├── tsconfig.json │ ├── util │ └── index.spec.ts │ └── verifier │ └── index.spec.ts ├── ask-sdk-local-debug ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── NOTICE.txt ├── README.md ├── lib │ ├── LocalDebuggerInvoker.ts │ ├── builder │ │ ├── ClientConfigBuilder.ts │ │ ├── SkillInvokerConfigBuilder.ts │ │ └── WebSocketClientConfigBuilder.ts │ ├── client │ │ ├── ILocalDebugClient.ts │ │ └── LocalDebugClient.ts │ ├── config │ │ ├── ClientConfig.ts │ │ ├── SkillInvokerConfig.ts │ │ └── WebSocketClientConfig.ts │ ├── constants │ │ └── Constants.ts │ ├── request │ │ └── DynamicEndpointsRequest.ts │ └── util │ │ ├── ArgsParserUtils.ts │ │ └── RequestResponseUtils.ts ├── package.json └── tsconfig.json ├── ask-sdk-runtime ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── dispatcher │ │ ├── GenericRequestDispatcher.ts │ │ ├── RequestDispatcher.ts │ │ ├── error │ │ │ ├── handler │ │ │ │ └── ErrorHandler.ts │ │ │ └── mapper │ │ │ │ ├── ErrorMapper.ts │ │ │ │ └── GenericErrorMapper.ts │ │ └── request │ │ │ ├── handler │ │ │ ├── GenericHandlerAdapter.ts │ │ │ ├── GenericRequestHandlerChain.ts │ │ │ ├── HandlerAdapter.ts │ │ │ ├── RequestHandler.ts │ │ │ └── RequestHandlerChain.ts │ │ │ ├── interceptor │ │ │ ├── RequestInterceptor.ts │ │ │ └── ResponseInterceptor.ts │ │ │ └── mapper │ │ │ ├── GenericRequestMapper.ts │ │ │ └── RequestMapper.ts │ ├── index.ts │ ├── skill │ │ ├── RuntimeConfiguration.ts │ │ ├── RuntimeConfigurationBuilder.ts │ │ └── Skill.ts │ └── util │ │ ├── AskSdkUtils.ts │ │ └── UserAgentManager.ts ├── package.json ├── tsconfig.json └── tst │ ├── dispatcher │ ├── GenericRequestDispatcher.spec.ts │ ├── error │ │ └── mapper │ │ │ └── GenericErrorMapper.spec.ts │ └── request │ │ ├── handler │ │ ├── GenericHandlerAdapter.spec.ts │ │ └── GenericRequestHandlerChain.spec.ts │ │ └── mapper │ │ └── GenericRequestMapper.spec.ts │ ├── mocks │ ├── error │ │ ├── MockAlwaysFalseErrorHandler.ts │ │ └── MockAlwaysTrueErrorHandler.ts │ └── request │ │ ├── MockAlwaysFalseRequestHandler.ts │ │ └── MockAlwaysTrueRequestHandler.ts │ ├── skill │ └── RuntimeConfigurationBuilder.ts │ ├── tsconfig.json │ └── util │ ├── AskSdkUtils.spec.ts │ └── UserAgentManager.spec.ts ├── ask-sdk-s3-persistence-adapter ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── attributes │ │ └── persistence │ │ │ ├── ObjectKeyGenerators.ts │ │ │ └── S3PersistenceAdapter.ts │ └── index.ts ├── package.json ├── tsconfig.json └── tst │ ├── attributes │ └── persistence │ │ ├── ObjectKeyGenerators.spec.ts │ │ └── S3PersistenceAdapter.spec.ts │ ├── mocks │ └── JsonProvider.ts │ └── tsconfig.json ├── ask-sdk-v1adapter ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── adapter.ts │ ├── copySessionAttributesInterceptor.ts │ ├── defaultHandlers │ │ └── skillEventHandlers.ts │ ├── directives │ │ └── voicePlayerSpeakDirective.ts │ ├── eventParser.ts │ ├── handler.ts │ ├── index.ts │ ├── responseBuilderShim.ts │ ├── responseHandlers.ts │ ├── services │ │ ├── apiClient.ts │ │ ├── deviceAddressService.ts │ │ ├── directiveService.ts │ │ ├── listManagementService.ts │ │ ├── serviceError.ts │ │ └── v1ApiClient.ts │ ├── templateBuilders │ │ ├── bodyTemplate1Builder.ts │ │ ├── bodyTemplate2Builder.ts │ │ ├── bodyTemplate3Builder.ts │ │ ├── bodyTemplate6Builder.ts │ │ ├── bodyTemplate7Builder.ts │ │ ├── listItemBuilder.ts │ │ ├── listTemplate1Builder.ts │ │ └── listTemplate2Builder.ts │ ├── utils │ │ ├── imageUtils.ts │ │ └── textUtils.ts │ └── v1Handler.ts ├── package.json ├── tsconfig.json └── tst │ ├── adapter.spec.ts │ ├── eventParser.spec.ts │ ├── handler.spec.ts │ ├── mock │ ├── mockPersistenceAdapter.ts │ ├── mockSampleRequest.ts │ └── mockV2RequestHandler.js │ ├── responseBuilderShim.spec.ts │ ├── services │ ├── apiClient.spec.ts │ ├── deviceAddressService.spec.ts │ ├── directiveService.spec.ts │ ├── listManagementService.spec.ts │ └── serviceError.spec.ts │ ├── templateBuilders │ ├── bodyTemplate1Builder.spec.ts │ ├── bodyTemplate2Builder.spec.ts │ ├── bodyTemplate3Builder.spec.ts │ ├── bodyTemplate6Builder.spec.ts │ ├── bodyTemplate7Builder.spec.ts │ ├── listItemBuilder.spec.ts │ ├── listTemplate1Builder.spec.ts │ └── listTemplate2Builder.spec.ts │ └── tsconfig.json ├── ask-sdk ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── lib │ ├── index.ts │ └── skill │ │ ├── SkillBuilders.ts │ │ └── factory │ │ ├── StandardSkillBuilder.ts │ │ └── StandardSkillFactory.ts ├── package.json ├── tsconfig.json └── tst │ ├── skill │ ├── SkillBuilders.spec.ts │ └── factory │ │ └── StandardSkillFactory.spec.ts │ └── tsconfig.json ├── ask-smapi-sdk ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── LICENSE ├── NOTICE.txt ├── README.md ├── THIRD-PARTY.txt ├── lib │ ├── index.ts │ ├── smapiClientBuilder │ │ ├── AbstractSmapiClientBuilder.ts │ │ ├── SmapiClientBuilder.ts │ │ └── authMethods │ │ │ └── AuthMethods.ts │ └── util │ │ ├── ModelIntrospector.ts │ │ └── Util.ts ├── package.json ├── tsconfig.json └── tst │ ├── tsconfig.json │ └── util │ ├── ModelIntrospector.spec.ts │ └── Util.spec.ts ├── docs ├── en │ ├── README.md │ ├── conf.py │ └── legacy.rst └── ja │ ├── ASK-SDK-Migration-Guide.rst │ ├── ASK-SDK-Utilities.rst │ ├── Building-Response.rst │ ├── Calling-Alexa-Service-APIs.rst │ ├── Configuring-Skill-Instance.rst │ ├── Developing-Your-First-Skill.rst │ ├── Managing-Attributes.rst │ ├── Processing-Request.rst │ ├── Setting-Up-The-ASK-SDK.rst │ ├── conf.py │ ├── index.rst │ └── requirements.txt ├── lerna.json ├── package.json └── tsconfig.json /.commitlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "body-leading-blank": [1, "always"], 4 | "footer-leading-blank": [1, "always"], 5 | "subject-empty": [2, "never"], 6 | "subject-full-stop": [2, "never", "."], 7 | "subject-case": [ 8 | 2, 9 | "never", 10 | ["sentence-case", "pascal-case", "start-case", "upper-case"] 11 | ], 12 | "scope-case": [2, "always", "lower-case"], 13 | "type-case": [2, "always", "lower-case"], 14 | "type-empty": [2, "never"], 15 | "type-enum": [ 16 | 2, 17 | "always", 18 | [ 19 | "chore", 20 | "docs", 21 | "feat", 22 | "fix", 23 | "perf", 24 | "refactor", 25 | "revert", 26 | "style", 27 | "test" 28 | ] 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | 12 | 13 | ## I'm submitting a... 14 | 15 |

16 | [ ] Regression (a behavior that used to work and stopped working in a new release)
17 | [ ] Bug report  
18 | [ ] Performance issue
19 | [ ] Feature request
20 | [ ] Documentation issue or request
21 | [ ] Other... Please describe:
22 | 
23 | 24 | 25 | 26 | ## Expected Behavior 27 | 28 | 29 | 30 | ## Current Behavior 31 | 32 | 33 | 34 | 35 | 36 | ## Possible Solution 37 | 38 | 39 | 40 | ## Steps to Reproduce (for bugs) 41 | 42 | 43 | 44 | 45 | ## Context 46 | 47 | 48 | 49 | ## Your Environment 50 | 51 | * ASK SDK for Node.js used: x.x.x 52 | * Operating System and version: 53 | 54 | ## Node.js and NPM Info 55 | * Node.js version used for development: 56 | * NPM version used for development: 57 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | ## Motivation and Context 7 | 8 | 9 | 10 | ## Testing 11 | 12 | 13 | 14 | 15 | ## Screenshots (if appropriate) 16 | 17 | ## Types of changes 18 | 19 | - [ ] Bug fix (non-breaking change which fixes an issue) 20 | - [ ] New feature (non-breaking change which adds functionality) 21 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 22 | - [ ] Docs(Add new document content) 23 | - [ ] Translate Docs(Translate document content) 24 | 25 | ## Checklist 26 | 27 | 28 | - [ ] My code follows the code style of this project 29 | - [ ] My change requires a change to the documentation 30 | - [ ] I have updated the documentation accordingly 31 | - [ ] I have read the **README** document 32 | - [ ] I have added tests to cover my changes 33 | - [ ] All new and existing tests passed 34 | - [ ] My commit message follows [Conventional Commit Guideline](https://conventionalcommits.org/) 35 | 36 | ## License 37 | - [ ] By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. 38 | 39 | [issues]: https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues 40 | [license]: http://aws.amazon.com/apache2.0/ 41 | [cla]: http://en.wikipedia.org/wiki/Contributor_License_Agreement 42 | -------------------------------------------------------------------------------- /.github/workflows/ask-sdk-unit-test.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests on ask-sdk 2 | 3 | on: 4 | push: 5 | branches: 6 | - 2.0.x 7 | pull_request: 8 | branches: 9 | - 2.0.x 10 | 11 | jobs: 12 | build: 13 | runs-on: ${{ matrix.os }} 14 | strategy: 15 | matrix: 16 | os: [ubuntu-latest, macos-latest, windows-latest] 17 | node: [12, 14] 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Use Node.js ${{ matrix.node }} 21 | uses: actions/setup-node@v1 22 | with: 23 | node-version: ${{ matrix.node }} 24 | - run: npm install 25 | - run: npm run bootstrap 26 | - run: npm run build 27 | - run: npm run test 28 | -------------------------------------------------------------------------------- /.github/workflows/ask-smapi-sdk-unit-test.yml: -------------------------------------------------------------------------------- 1 | name: Unit Tests on ask-smapi-sdk 2 | 3 | on: 4 | push: 5 | branches: 6 | - 2.0.x 7 | paths: 8 | - ask-smapi-sdk/**' 9 | pull_request: 10 | branches: 11 | - 2.0.x 12 | paths: 13 | - ask-smapi-sdk/**' 14 | 15 | defaults: 16 | run: 17 | working-directory: ask-smapi-sdk 18 | 19 | jobs: 20 | build: 21 | runs-on: ${{ matrix.os }} 22 | strategy: 23 | matrix: 24 | os: [ubuntu-latest, macos-latest, windows-latest] 25 | node: [12, 14] 26 | steps: 27 | - uses: actions/checkout@v2 28 | - name: Use Node.js ${{ matrix.node }} 29 | uses: actions/setup-node@v1 30 | with: 31 | node-version: ${{ matrix.node }} 32 | - run: npm install 33 | - run: npm run build 34 | - run: npm run test 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dist/ 2 | node_modules/ 3 | typedoc/ 4 | package-lock.json 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /ask-sdk-controls/README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

5 | 6 |
7 |

ASK SDK Controls Framework (Beta)

8 |

9 | 10 | The ASK SDK Controls framework builds on the [ASK SDK for Node.js](https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs), offering a scalable solution for creating large, multi-turn skills in code with reusable components called *controls*. 11 | 12 | You can find the Github Repo for ASK SDK Controls at [https://github.com/alexa/ask-sdk-controls](https://github.com/alexa/ask-sdk-controls) 13 | -------------------------------------------------------------------------------- /ask-sdk-core/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | build 7 | -------------------------------------------------------------------------------- /ask-sdk-core/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-sdk-core/README.md: -------------------------------------------------------------------------------- 1 | Core SDK package contains basic components and default implementations of ASK SDK v2 for Node.js. 2 | 3 | ## What is ASK SDK v2 for Node.js 4 | 5 | The ASK SDK v2 for Node.js is an open-source Alexa Skill Development Kit. ASK SDK v2 for Node.js makes it easier for you to build highly engaging skills, by allowing you to spend more time on implementing features and less on writing boiler-plate code. 6 | 7 | ## Installing 8 | To use the Core SDK package, you need to install two modules: core SDK and model(peer dependency of core SDK) within your NPM project. Run the following commands in the terminal to install them: 9 | 10 | ``` 11 | npm install --save ask-sdk-core 12 | ``` 13 | 14 | ``` 15 | npm install --save ask-sdk-model 16 | ``` 17 | 18 | ## Usage and Getting Started 19 | 20 | You can find a getting started guide [here](https://developer.amazon.com/docs/alexa-skills-kit-sdk-for-nodejs/overview.html). 21 | 22 | ## Usage with TypeScript 23 | The Core SDK package for Node.js bundles TypeScript definition files for use in TypeScript projects and to support tools that can read .d.ts files. Our goal is to keep these TypeScript definition files updated with each release for any public api. 24 | 25 | ### Pre-requisites 26 | Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets a few of these requirements: 27 | - Use TypeScript v2.x 28 | - Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window: 29 | 30 | ``` 31 | npm install --save-dev @types/node 32 | ``` 33 | 34 | ### In Node.js 35 | To use the TypeScript definition files within a Node.js project, simply import ask-sdk-core as below: 36 | 37 | In a TypeScript file: 38 | 39 | ```typescript 40 | import * as Alexa from 'ask-sdk-core'; 41 | ``` 42 | 43 | In a JavaScript file: 44 | 45 | ```javascript 46 | const Alexa = require('ask-sdk-core'); 47 | ``` 48 | 49 | ## Opening Issues 50 | For bug reports, feature requests and questions, we would like to hear about it. Search the [existing issues](https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues) and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of the SDK, Node.js or browser environment and OS you’re using. Please include a stack trace and reduced repro case when appropriate, too. 51 | 52 | ## License 53 | This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information. 54 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/attributes/persistence/PersistenceAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestEnvelope } from 'ask-sdk-model'; 15 | 16 | /** 17 | * An interface for storing and retrieving persistent attributes from persistence tier given request envelope. 18 | */ 19 | export interface PersistenceAdapter { 20 | getAttributes(requestEnvelope : RequestEnvelope) : Promise<{[key : string] : any}>; 21 | saveAttributes(requestEnvelope : RequestEnvelope, attributes : {[key : string] : any}) : Promise; 22 | deleteAttributes?(requestEnvelope : RequestEnvelope) : Promise; 23 | } 24 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/components/ComponentInterface.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { 15 | Directive, Response, Slot 16 | } from 'ask-sdk-model'; 17 | import { CustomSkillRequestHandler as RequestHandler } from '../dispatcher/request/handler/CustomSkillRequestHandler'; 18 | import { HandlerInput } from '../dispatcher/request/handler/HandlerInput'; 19 | 20 | export abstract class ComponentInterface { 21 | 22 | static launch: (options?: { 23 | slots?: {[key : string] : Slot }, 24 | isUserUtteranceInput?: boolean 25 | }) => Directive; 26 | 27 | static egress: (egressInput: { 28 | intentName?:string, 29 | callBack?: ((input: HandlerInput) => Response | Promise) 30 | }) => RequestHandler; 31 | } -------------------------------------------------------------------------------- /ask-sdk-core/lib/dispatcher/error/handler/CustomSkillErrorHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { ErrorHandler } from 'ask-sdk-runtime'; 16 | import { HandlerInput } from '../../request/handler/HandlerInput'; 17 | 18 | export interface CustomSkillErrorHandler extends ErrorHandler {} 19 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/dispatcher/request/handler/CustomSkillRequestHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { RequestHandler } from 'ask-sdk-runtime'; 16 | import { HandlerInput } from './HandlerInput'; 17 | 18 | export interface CustomSkillRequestHandler extends RequestHandler {} 19 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/dispatcher/request/handler/HandlerInput.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | import { 17 | RequestEnvelope, 18 | services 19 | } from 'ask-sdk-model'; 20 | import { AttributesManager } from '../../../attributes/AttributesManager'; 21 | import { ResponseBuilder } from '../../../response/ResponseBuilder'; 22 | import ServiceClientFactory = services.ServiceClientFactory; 23 | 24 | /** 25 | * An interface that represents components passed into {@link CustomSkillRequestHandler} and {@link CustomSkillErrorHandler}. 26 | */ 27 | export interface HandlerInput { 28 | requestEnvelope : RequestEnvelope; 29 | context? : any; 30 | attributesManager : AttributesManager; 31 | responseBuilder : ResponseBuilder; 32 | serviceClientFactory? : ServiceClientFactory; 33 | } 34 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/dispatcher/request/interceptor/CustomSkillRequestInterceptor.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestInterceptor } from 'ask-sdk-runtime'; 15 | import { HandlerInput } from '../handler/HandlerInput'; 16 | 17 | export interface CustomSkillRequestInterceptor extends RequestInterceptor {} 18 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/dispatcher/request/interceptor/CustomSkillResponseInterceptor.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { ResponseInterceptor } from 'ask-sdk-runtime'; 16 | import { HandlerInput } from '../handler/HandlerInput'; 17 | 18 | export interface CustomSkillResponseInterceptor extends ResponseInterceptor {} 19 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/response/PlainTextContentHelper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextContentHelper } from './TextContentHelper'; 16 | import TextContent = interfaces.display.TextContent; 17 | 18 | /** 19 | * Responsible for building plain text content object using ask-sdk-model in Alexa skills kit display interface 20 | * https://developer.amazon.com/docs/custom-skills/display-interface-reference.html#textcontent-object-specifications. 21 | */ 22 | export class PlainTextContentHelper extends TextContentHelper { 23 | constructor() { 24 | super(); 25 | } 26 | 27 | /** 28 | * @returns {interfaces.display.TextContent} 29 | */ 30 | public getTextContent() : interfaces.display.TextContent { 31 | const textContent : TextContent = {}; 32 | 33 | if (this.primaryText) { 34 | textContent.primaryText = { 35 | type : 'PlainText', 36 | text : this.primaryText, 37 | }; 38 | } 39 | 40 | if (this.secondaryText) { 41 | textContent.secondaryText = { 42 | type : 'PlainText', 43 | text : this.secondaryText, 44 | }; 45 | } 46 | 47 | if (this.tertiaryText) { 48 | textContent.tertiaryText = { 49 | type : 'PlainText', 50 | text : this.tertiaryText, 51 | }; 52 | } 53 | 54 | return textContent; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/response/RichTextContentHelper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextContentHelper } from './TextContentHelper'; 16 | import TextContent = interfaces.display.TextContent; 17 | 18 | /** 19 | * Responsible for building rich text content object using ask-sdk-model in Alexa skills kit display interface 20 | * https://developer.amazon.com/docs/custom-skills/display-interface-reference.html#textcontent-object-specifications. 21 | */ 22 | export class RichTextContentHelper extends TextContentHelper { 23 | constructor() { 24 | super(); 25 | } 26 | 27 | /** 28 | * @returns {interfaces.display.TextContent} 29 | */ 30 | public getTextContent() : TextContent { 31 | const textContent : TextContent = {}; 32 | 33 | if (this.primaryText) { 34 | textContent.primaryText = { 35 | type : 'RichText', 36 | text : this.primaryText, 37 | }; 38 | } 39 | 40 | if (this.secondaryText) { 41 | textContent.secondaryText = { 42 | type : 'RichText', 43 | text : this.secondaryText, 44 | }; 45 | } 46 | 47 | if (this.tertiaryText) { 48 | textContent.tertiaryText = { 49 | type : 'RichText', 50 | text : this.tertiaryText, 51 | }; 52 | } 53 | 54 | return textContent; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/response/TextContentHelper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import TextContent = interfaces.display.TextContent; 16 | 17 | /** 18 | * An abstract class responsible for building text content object using ask-sdk-model in Alexa skills kit display interface 19 | * https://developer.amazon.com/docs/custom-skills/display-interface-reference.html#textcontent-object-specifications. 20 | */ 21 | export abstract class TextContentHelper { 22 | protected primaryText : string; 23 | protected secondaryText : string; 24 | protected tertiaryText : string; 25 | 26 | /** 27 | * @param {string} primaryText 28 | * @returns {this} 29 | */ 30 | public withPrimaryText(primaryText : string) : this { 31 | this.primaryText = primaryText; 32 | 33 | return this; 34 | } 35 | 36 | /** 37 | * @param {string} secondaryText 38 | * @returns {this} 39 | */ 40 | public withSecondaryText(secondaryText : string) : this { 41 | this.secondaryText = secondaryText; 42 | 43 | return this; 44 | } 45 | 46 | /** 47 | * @param {string} tertiaryText 48 | * @returns {this} 49 | */ 50 | public withTertiaryText(tertiaryText : string) : this { 51 | this.tertiaryText = tertiaryText; 52 | 53 | return this; 54 | } 55 | 56 | /** 57 | * @returns {interfaces.display.TextContent} 58 | */ 59 | public abstract getTextContent() : TextContent; 60 | } 61 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/skill/CustomSkillConfiguration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { 15 | Response, 16 | services 17 | } from 'ask-sdk-model'; 18 | import { RuntimeConfiguration } from 'ask-sdk-runtime'; 19 | import { PersistenceAdapter } from '../attributes/persistence/PersistenceAdapter'; 20 | import { HandlerInput} from '../dispatcher/request/handler/HandlerInput'; 21 | 22 | /** 23 | * An interfaces that represents the standard components needed to build {@link CustomSkill}. 24 | */ 25 | export interface CustomSkillConfiguration extends RuntimeConfiguration { 26 | persistenceAdapter? : PersistenceAdapter; 27 | apiClient? : services.ApiClient; 28 | customUserAgent? : string; 29 | skillId? : string; 30 | } 31 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/skill/SkillBuilders.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { CustomSkillBuilder } from './factory/CustomSkillBuilder'; 15 | import { CustomSkillFactory } from './factory/CustomSkillFactory'; 16 | 17 | /** 18 | * Provider for skill builders. 19 | */ 20 | export const SkillBuilders = { 21 | custom() : CustomSkillBuilder { 22 | return CustomSkillFactory.init(); 23 | }, 24 | }; 25 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/skill/factory/CustomSkillBuilder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { services } from 'ask-sdk-model'; 15 | import { PersistenceAdapter } from '../../attributes/persistence/PersistenceAdapter'; 16 | import { BaseSkillBuilder } from './BaseSkillBuilder'; 17 | import ApiClient = services.ApiClient; 18 | 19 | /** 20 | * An interface which helps building a customized skill. 21 | */ 22 | export interface CustomSkillBuilder extends BaseSkillBuilder { 23 | withPersistenceAdapter(persistenceAdapter : PersistenceAdapter) : this; 24 | withApiClient(apiClient : ApiClient) : this; 25 | } 26 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/skill/factory/CustomSkillFactory.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { services } from 'ask-sdk-model'; 15 | import { PersistenceAdapter } from '../../attributes/persistence/PersistenceAdapter'; 16 | import { CustomSkillConfiguration } from '../CustomSkillConfiguration'; 17 | import { BaseSkillFactory } from './BaseSkillFactory'; 18 | import { CustomSkillBuilder } from './CustomSkillBuilder'; 19 | import ApiClient = services.ApiClient; 20 | 21 | /** 22 | * Provider for {@link CustomSkillBuilder} 23 | */ 24 | export class CustomSkillFactory { 25 | public static init() : CustomSkillBuilder { 26 | let thisPersistenceAdapter : PersistenceAdapter; 27 | let thisApiClient : ApiClient; 28 | 29 | const baseSkillBuilder = BaseSkillFactory.init(); 30 | 31 | return { 32 | ... baseSkillBuilder, 33 | getSkillConfiguration() : CustomSkillConfiguration { 34 | const skillConfiguration = baseSkillBuilder.getSkillConfiguration(); 35 | 36 | return { 37 | ...skillConfiguration, 38 | persistenceAdapter : thisPersistenceAdapter, 39 | apiClient : thisApiClient, 40 | }; 41 | }, 42 | withPersistenceAdapter(persistenceAdapter : PersistenceAdapter) : CustomSkillBuilder { 43 | thisPersistenceAdapter = persistenceAdapter; 44 | 45 | return this; 46 | }, 47 | withApiClient(apiClient : ApiClient) : CustomSkillBuilder { 48 | thisApiClient = apiClient; 49 | 50 | return this; 51 | }, 52 | }; 53 | } 54 | 55 | private constructor() {} 56 | } 57 | -------------------------------------------------------------------------------- /ask-sdk-core/lib/util/SsmlUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * return the string with all invalid XML characters escaped 16 | * @param input 17 | */ 18 | export function escapeXmlCharacters(input : string) : string { 19 | const invalidXmlCharactersMapping = { 20 | '&' : '&', 21 | '<' : '<', 22 | '>' : '>', 23 | '"' : '"', 24 | "'" : ''', 25 | }; 26 | 27 | const invalidXmlCharactersMappingReverse = Object.keys(invalidXmlCharactersMapping).reduce( 28 | /* eslint-disable-next-line */ 29 | (obj : object, key : string) => { 30 | obj[invalidXmlCharactersMapping[key]] = key; 31 | 32 | return obj; 33 | }, 34 | {}, 35 | ); 36 | 37 | // sanitize any already escaped character to ensure they are not escaped more than once 38 | const sanitizedInput = input.replace(/&|<|>|"|']/g, (c) => invalidXmlCharactersMappingReverse[c]); 39 | 40 | return sanitizedInput.replace(/[&'"><]/g, (c) => invalidXmlCharactersMapping[c]); 41 | } 42 | -------------------------------------------------------------------------------- /ask-sdk-core/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-core", 3 | "version": "2.14.0", 4 | "description": "Core package for Alexa Skills Kit SDK", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [ 17 | { 18 | "name": "Tianren Zhang", 19 | "email": "tianrenz@amazon.com" 20 | }, 21 | { 22 | "name": "Tiantian Xie", 23 | "email": "xtiantia@amazon.com" 24 | } 25 | ], 26 | "license": "Apache-2.0", 27 | "keywords": [ 28 | "Alexa", 29 | "SDK" 30 | ], 31 | "dependencies": { 32 | "ask-sdk-runtime": "^2.14.0" 33 | }, 34 | "peerDependencies": { 35 | "ask-sdk-model": "^1.29.0" 36 | }, 37 | "devDependencies": { 38 | "@types/chai": "^4.1.2", 39 | "@types/mocha": "^5.0.0", 40 | "@types/node": "^16.11.1", 41 | "@types/sinon": "^7.0.13", 42 | "@typescript-eslint/eslint-plugin": "^3.9.0", 43 | "@typescript-eslint/parser": "^3.9.0", 44 | "ask-sdk-model": "^1.29.0", 45 | "chai": "^4.1.2", 46 | "cross-env": "^7.0.2", 47 | "eslint": "^7.6.0", 48 | "eslint-plugin-tsdoc": "^0.2.6", 49 | "mocha": "^5.0.5", 50 | "nock": "^13.3.0", 51 | "nyc": "^14.1.1", 52 | "sinon": "^7.0.13", 53 | "ts-node": "^6.0.1", 54 | "typescript": "^4.9.5" 55 | }, 56 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 57 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 58 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 59 | } 60 | -------------------------------------------------------------------------------- /ask-sdk-core/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/mocks/error/MockAlwaysFalseErrorHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { CustomSkillErrorHandler } from '../../../lib/dispatcher/error/handler/CustomSkillErrorHandler'; 16 | import { HandlerInput } from '../../../lib/dispatcher/request/handler/HandlerInput'; 17 | 18 | export class MockAlwaysFalseErrorHandler implements CustomSkillErrorHandler { 19 | public canHandle(input : HandlerInput, error : Error) : boolean { 20 | return false; 21 | } 22 | 23 | public handle(input : HandlerInput, error : Error) : Response { 24 | throw new Error(`${this.constructor.name} Error: this line should never be reached!`); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/mocks/error/MockAlwaysTrueErrorHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { CustomSkillErrorHandler } from '../../../lib/dispatcher/error/handler/CustomSkillErrorHandler'; 16 | import { HandlerInput } from '../../../lib/dispatcher/request/handler/HandlerInput'; 17 | import { ResponseFactory } from '../../../lib/response/ResponseFactory'; 18 | 19 | export class MockAlwaysTrueErrorHandler implements CustomSkillErrorHandler { 20 | public canHandle(input : HandlerInput, error : Error) : boolean { 21 | return true; 22 | } 23 | 24 | public handle(input : HandlerInput, error : Error) : Response { 25 | return input.responseBuilder 26 | .speak(`${error.name} received at ${this.constructor.name}.`) 27 | .getResponse(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/mocks/persistence/MockPersistenceAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestEnvelope } from 'ask-sdk-model'; 15 | import { PersistenceAdapter } from '../../../lib/attributes/persistence/PersistenceAdapter'; 16 | 17 | export class MockPersistenceAdapter implements PersistenceAdapter { 18 | public getCounter : number = 0; 19 | public saveCounter : number = 0; 20 | 21 | private partitionKey : string = 'userId'; 22 | private savedAttributes : {[key : string] : any} = { 23 | key_1 : 'v1', /* eslint-disable-line camelcase */ 24 | key_2 : 'v2', /* eslint-disable-line camelcase */ 25 | state : 'mockState', 26 | }; 27 | 28 | public async getAttributes(requestEnvelope : RequestEnvelope) : Promise<{[key : string] : any}> { 29 | this.getCounter++; 30 | 31 | const id = requestEnvelope.context.System.user.userId; 32 | 33 | if (id === this.partitionKey) { 34 | return this.savedAttributes; 35 | } 36 | 37 | throw new Error('Resource Not Found'); 38 | } 39 | 40 | public async saveAttributes(requestEnvelope : RequestEnvelope, attributes : {[key : string] : any}) : Promise { 41 | this.saveCounter ++; 42 | 43 | const id = requestEnvelope.context.System.user.userId; 44 | 45 | if (id === this.partitionKey) { 46 | this.savedAttributes = attributes; 47 | 48 | return; 49 | } 50 | 51 | throw new Error('Maximum Capacity Reached'); 52 | } 53 | 54 | public async deleteAttributes(requestEnvelope : RequestEnvelope) : Promise { 55 | const id = requestEnvelope.context.System.user.userId; 56 | 57 | if (id === this.partitionKey) { 58 | this.savedAttributes = {}; 59 | } 60 | } 61 | 62 | public resetCounter() : void { 63 | this.getCounter = 0; 64 | this.saveCounter = 0; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/mocks/request/MockAlwaysFalseRequestHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { CustomSkillRequestHandler } from '../../../lib/dispatcher/request/handler/CustomSkillRequestHandler'; 16 | import { HandlerInput } from '../../../lib/dispatcher/request/handler/HandlerInput'; 17 | 18 | export class MockAlwaysFalseRequestHandler implements CustomSkillRequestHandler { 19 | public canHandle(input : HandlerInput) : boolean { 20 | return false; 21 | } 22 | 23 | public handle(input : HandlerInput) : Response { 24 | throw new Error(`${this.constructor.name} Error: this line should never be reached!`); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/mocks/request/MockAlwaysTrueRequestHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { Response } from 'ask-sdk-model'; 15 | import { CustomSkillRequestHandler } from '../../../lib/dispatcher/request/handler/CustomSkillRequestHandler'; 16 | import { HandlerInput } from '../../../lib/dispatcher/request/handler/HandlerInput'; 17 | 18 | export class MockAlwaysTrueRequestHandler implements CustomSkillRequestHandler { 19 | public canHandle(input : HandlerInput) : boolean { 20 | return true; 21 | } 22 | 23 | public async handle(input : HandlerInput) : Promise { 24 | try { 25 | const sessionAttributes = input.attributesManager.getSessionAttributes(); 26 | sessionAttributes.key = 'value'; 27 | input.attributesManager.setSessionAttributes(sessionAttributes); 28 | } catch (err) {} /* eslint-disable-line no-empty */ 29 | 30 | try { 31 | const persistentAttributes = await input.attributesManager.getPersistentAttributes(); 32 | persistentAttributes.key = 'value'; 33 | input.attributesManager.setPersistentAttributes(persistentAttributes); 34 | } catch (err) {} /* eslint-disable-line no-empty */ 35 | 36 | try { 37 | await input.attributesManager.savePersistentAttributes(); 38 | } catch (err) {} /* eslint-disable-line no-empty */ 39 | 40 | return input.responseBuilder 41 | .speak(`Request received at ${this.constructor.name}.`) 42 | .getResponse(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/skill/SkillBuilders.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { SkillBuilders } from '../../lib/skill/SkillBuilders'; 16 | 17 | describe('SkillBuilders', () => { 18 | it('should be able to return CustomSkillBuilder', () => { 19 | const customSkillBuilder = SkillBuilders.custom(); 20 | 21 | expect('withPersistenceAdapter' in customSkillBuilder).equal(true); 22 | expect('withApiClient' in customSkillBuilder).equal(true); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/skill/factory/CustomSkillFactory.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { DefaultApiClient } from '../../../lib/service/DefaultApiClient'; 16 | import { CustomSkillFactory } from '../../../lib/skill/factory/CustomSkillFactory'; 17 | import { MockPersistenceAdapter } from '../../mocks/persistence/MockPersistenceAdapter'; 18 | 19 | describe('CustomSkillFactory', () => { 20 | it('should be able to add persistence adapter', () => { 21 | const config = CustomSkillFactory.init() 22 | .withPersistenceAdapter(new MockPersistenceAdapter()) 23 | .getSkillConfiguration(); 24 | 25 | expect(config.persistenceAdapter).instanceOf(MockPersistenceAdapter); 26 | }); 27 | 28 | it('should be able to add api client', () => { 29 | const config = CustomSkillFactory.init() 30 | .withApiClient(new DefaultApiClient()) 31 | .getSkillConfiguration(); 32 | 33 | expect(config.apiClient).instanceOf(DefaultApiClient); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-sdk-core/tst/util/SsmlUtils.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { escapeXmlCharacters } from '../../lib/util/SsmlUtils'; 16 | 17 | describe('SsmlUtils', () => { 18 | it('should be able to escape all invalid XML characters', () => { 19 | expect(escapeXmlCharacters('<>"\'&')).eq('<>"'&'); 20 | }); 21 | 22 | it('should not escape any already escaped character', () => { 23 | expect(escapeXmlCharacters('&&')).eq('&&'); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /ask-sdk-dynamodb-persistence-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | build 7 | -------------------------------------------------------------------------------- /ask-sdk-dynamodb-persistence-adapter/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-sdk-dynamodb-persistence-adapter/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export { DynamoDbPersistenceAdapter } from './attributes/persistence/DynamoDbPersistenceAdapter'; 15 | export { 16 | PartitionKeyGenerator, 17 | PartitionKeyGenerators 18 | } from './attributes/persistence/PartitionKeyGenerators'; 19 | -------------------------------------------------------------------------------- /ask-sdk-dynamodb-persistence-adapter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-dynamodb-persistence-adapter", 3 | "version": "2.14.0", 4 | "description": "DynamoDB based implementation package of PersistenceAdapter interface in ASK SDK v2 for Node.js", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [ 17 | { 18 | "name": "Tianren Zhang", 19 | "email": "tianrenz@amazon.com" 20 | }, 21 | { 22 | "name": "Tiantian Xie", 23 | "email": "xtiantia@amazon.com" 24 | } 25 | ], 26 | "license": "Apache-2.0", 27 | "keywords": [ 28 | "Alexa", 29 | "SDK" 30 | ], 31 | "dependencies": { 32 | "aws-sdk": "^2.163.0" 33 | }, 34 | "peerDependencies": { 35 | "ask-sdk-core": "^2.0.0" 36 | }, 37 | "devDependencies": { 38 | "@types/chai": "^4.1.2", 39 | "@types/mocha": "^5.0.0", 40 | "@types/node": "^16.11.1", 41 | "@typescript-eslint/eslint-plugin": "^3.9.0", 42 | "@typescript-eslint/parser": "^3.9.0", 43 | "ask-sdk-core": "^2.14.0", 44 | "ask-sdk-model": "^1.29.0", 45 | "aws-sdk-mock": "^4.1.0", 46 | "chai": "^4.1.2", 47 | "cross-env": "^7.0.2", 48 | "eslint": "^7.6.0", 49 | "eslint-plugin-tsdoc": "^0.2.6", 50 | "mocha": "^5.0.5", 51 | "nyc": "^14.1.1", 52 | "ts-node": "^6.0.1", 53 | "typescript": "^4.9.5" 54 | }, 55 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 56 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 57 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 58 | } 59 | -------------------------------------------------------------------------------- /ask-sdk-dynamodb-persistence-adapter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-dynamodb-persistence-adapter/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | .DS_Store 7 | build 8 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export { ExpressAdapter } from './adapter/ExpressAdapter'; 15 | export { 16 | SkillRequestSignatureVerifier, 17 | TimestampVerifier, 18 | Verifier 19 | } from './verifier'; 20 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/lib/util/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { createAskSdkError, Skill } from 'ask-sdk-core'; 15 | import { ResponseEnvelope } from 'ask-sdk-model'; 16 | import { IncomingHttpHeaders } from 'http'; 17 | import { Verifier } from '../verifier'; 18 | 19 | /** 20 | * Verify request and dispatch 21 | * 22 | * This method first validate request with all provided verifiers 23 | * Then, invoke the skill to handle request envelope to get response 24 | * @param {IncomingHttpHeaders} httpRequestHeader Http request header 25 | * @param {string} httpRequestBody Http request body in string format 26 | * @param {Skill} skill ask-sdk-core custom skill instance 27 | * @param {Verifier[]} verifiers Array of user customized Verifier instances 28 | */ 29 | export async function asyncVerifyRequestAndDispatch(httpRequestHeader: IncomingHttpHeaders, httpRequestBody: string, skill: Skill, verifiers: Verifier[]): Promise { 30 | try { 31 | await Promise.all(verifiers.map(async (verifier) => { 32 | await verifier.verify(httpRequestBody, httpRequestHeader); 33 | })); 34 | } catch (err) { 35 | throw createAskSdkError('Request verification failed', err.message); 36 | } 37 | 38 | let responseEnvelope; 39 | try { 40 | responseEnvelope = await skill.invoke(JSON.parse(httpRequestBody)); 41 | } catch (err) { 42 | throw createAskSdkError('Skill dispatch failed', err.message); 43 | } 44 | 45 | return responseEnvelope; 46 | } 47 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/lib/verifier/helper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { pki } from 'node-forge'; 15 | 16 | /** 17 | * Function used to convert certificate chain string into Certificate Object Array 18 | * @param {string} certChain certificate chain in pem format 19 | * @return {pki.Certificate[]} 20 | */ 21 | 22 | const CERT_START_KEY = '-----BEGIN CERTIFICATE-----'; 23 | const CERT_END_KEY = '-----END CERTIFICATE-----'; 24 | export function generateCertificatesArray(certChain: string): pki.Certificate[] { 25 | const certs = []; 26 | while (certChain.length > 0) { 27 | const start = certChain.indexOf(CERT_START_KEY); 28 | const end = certChain.indexOf(CERT_END_KEY) + CERT_END_KEY.length; 29 | const certString = certChain.slice(start, end); 30 | certs.push(pki.certificateFromPem(certString)); 31 | certChain = certChain.slice(end).trim(); 32 | } 33 | 34 | return certs; 35 | } 36 | 37 | /** 38 | * Function used to generate ca store based on input root CAs list 39 | * @param {string[]} certs root CAs in pem format 40 | */ 41 | export function generateCAStore(certs: string[]): pki.CAStore { 42 | const caStore = pki.createCaStore([]); 43 | 44 | for (const cert of certs) { 45 | try { 46 | caStore.addCertificate(cert); 47 | } catch (e) { 48 | // do nothing 49 | // node-forge doesn't support ECDSA encrypted pem 50 | } 51 | 52 | } 53 | 54 | return caStore; 55 | } 56 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-express-adapter", 3 | "version": "2.14.0", 4 | "description": "Express adapter package for Alexa Skills Kit SDK", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install", 14 | "coverage": "nyc -x tst -e .ts -r html -r text-summary -t coverage/.nyc_output --cache npm test" 15 | }, 16 | "keywords": [ 17 | "Alexa", 18 | "Skill", 19 | "SDK", 20 | "Express" 21 | ], 22 | "author": "Amazon.com", 23 | "contributors": [ 24 | { 25 | "name": "Shen Chen", 26 | "email": "shench@amazon.com" 27 | } 28 | ], 29 | "license": "Apache-2.0", 30 | "dependencies": { 31 | "body-parser": "^1.18.2", 32 | "node-forge": "^1.3.0", 33 | "semver": "^7.3.4" 34 | }, 35 | "peerDependencies": { 36 | "ask-sdk-core": "^2.7.0" 37 | }, 38 | "devDependencies": { 39 | "@types/chai": "^4.1.2", 40 | "@types/express": "^4.16.1", 41 | "@types/mocha": "^5.0.0", 42 | "@types/node": "^16.11.1", 43 | "@types/node-forge": "^0.8.0", 44 | "@types/semver": "^7.3.4", 45 | "@types/sinon": "^7.0.13", 46 | "@types/supertest": "^2.0.7", 47 | "@typescript-eslint/eslint-plugin": "^3.9.0", 48 | "@typescript-eslint/parser": "^3.9.0", 49 | "ask-sdk-core": "^2.14.0", 50 | "ask-sdk-model": "^1.29.0", 51 | "chai": "^4.1.2", 52 | "cross-env": "^7.0.2", 53 | "eslint": "^7.6.0", 54 | "eslint-plugin-tsdoc": "^0.2.6", 55 | "express": "^4.16.4", 56 | "mocha": "^8.3.2", 57 | "nock": "^13.3.0", 58 | "nyc": "^14.1.1", 59 | "sinon": "^7.0.13", 60 | "supertest": "^3.1.0", 61 | "ts-node": "^6.0.1", 62 | "typescript": "^4.9.5" 63 | }, 64 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 65 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 66 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 67 | } 68 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/tst/mocks/rsa_sha256_pub: -------------------------------------------------------------------------------- 1 | -----BEGIN PUBLIC KEY----- 2 | MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA5z4oJtvKEKb/JrbKYfQw 3 | kRsa/T46XGCxJEbUDQ0OyS++KXOTBn/wILCKgShRE5jxvWaG4xOPEjQjuVWuuUee 4 | tuG5zsmybqyMaQKiRbp9WNwL3dSheQWee4Kn3F86AeM8HBu1XQIR9YAqY4utLVG4 5 | J8cUUaP2ScgtJ7rSHXvak61ZTUThWi4uDhINK96Tz2UvN7qB0j5gqLE828Ii+Qdk 6 | F1TmF3XwVRwIZ6o0xhAiLmoCqta9dQO7m6etPNbQrj5Kbb4zrgaVXBABenwHh3Ix 7 | VyIILs3V9opVeuInDAmq0mMBVPEK5LARrbC3/eZKJOIuqrwMmv8tTL+vcaWgrQ4b 8 | jA0YL5gYx3w3uDVwHm0kj8IwRPYWRxxSjXvOqVPtIYN0zetjjAfJkzaRQlZO93k1 9 | rxS39PkwmeNpfk97PgM8ca9+ZHyoHQujcUTd2pCa0jAC/AJSzlr6zF/nBfTU3dIu 10 | tbxc0PhUCegh3KVjA38lRXMhSkAFaN5TAXZM1NClAUFaYaoBZdFu/MwRefNqpg+N 11 | zy47jJmD/4S56vdp/mZxWxb5rkUG1RtbHhTI9AEZsF9W3LfeO1D+hR134uvnapwp 12 | fGpTFl6lqQDcvj9nqNCpuLfM77roBNigwLnhlC30U4bHtmPlZrp4Ys5NojSkJUO1 13 | jhdLMKdwJZVUKYl7rhmhCcMCAwEAAQ== 14 | -----END PUBLIC KEY----- 15 | -------------------------------------------------------------------------------- /ask-sdk-express-adapter/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | build 4 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | .DS_Store 7 | .idea/ 8 | .vscode/ 9 | build 10 | package/ 11 | *.tgz 12 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | tslint.json 9 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | # 1.1.0 (2020-11-10) 4 | 5 | This release contains the following changes : 6 | 7 | - Adding support for EU and FE. 8 | 9 | # 1.0.0 (2020-07-21) 10 | 11 | This release contains the following changes : 12 | 13 | - Initial release for local development support for ASK SDK for Node.js. 14 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ASK SDK Local Debug for Node.js 2 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/LocalDebuggerInvoker.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import WsClient from 'ws'; 15 | import { ClientConfigBuilder } from './builder/ClientConfigBuilder'; 16 | import { SkillInvokerConfigBuilder } from './builder/SkillInvokerConfigBuilder'; 17 | import { WebSocketClientConfigBuilder } from './builder/WebSocketClientConfigBuilder'; 18 | import { LocalDebugClient } from './client/LocalDebugClient'; 19 | import { argsParser, getHandlerFunction } from './util/ArgsParserUtils'; 20 | 21 | const { argv } = argsParser(); 22 | 23 | const clientConfig = new ClientConfigBuilder() 24 | .withAccessToken(argv.accessToken) 25 | .withHandlerName(argv.handlerName) 26 | .withSkillEntryFile(argv.skillEntryFile) 27 | .withSkillId(argv.skillId) 28 | .withRegion(argv.region) 29 | .build(); 30 | 31 | const skillInvokerConfig = new SkillInvokerConfigBuilder() 32 | .withHandler(getHandlerFunction(clientConfig.skillEntryFile, clientConfig.handlerName)) 33 | .build(); 34 | 35 | const webSocketClientConfig = new WebSocketClientConfigBuilder() 36 | .withSkillId(clientConfig.skillId) 37 | .withAccessToken(clientConfig.accessToken) 38 | .withRegion(clientConfig.region) 39 | .build(); 40 | 41 | const webSocketClient = new WsClient(webSocketClientConfig.webSocketServerUri, { 42 | headers: webSocketClientConfig.headers, 43 | }); 44 | 45 | const client = new LocalDebugClient(webSocketClient, skillInvokerConfig); 46 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/builder/ClientConfigBuilder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ClientConfig } from '../config/ClientConfig'; 15 | 16 | export class ClientConfigBuilder { 17 | private _skillEntryFile: string; 18 | 19 | private _handlerName: string; 20 | 21 | private _accessToken: string; 22 | 23 | private _skillId: string; 24 | 25 | private _region: string; 26 | 27 | public withSkillEntryFile(skillEntryFile: string): ClientConfigBuilder { 28 | this._skillEntryFile = skillEntryFile; 29 | 30 | return this; 31 | } 32 | 33 | public withHandlerName(handlerName: string): ClientConfigBuilder { 34 | this._handlerName = handlerName; 35 | 36 | return this; 37 | } 38 | 39 | public withAccessToken(accessToken: string): ClientConfigBuilder { 40 | this._accessToken = accessToken; 41 | 42 | return this; 43 | } 44 | 45 | public withSkillId(skillId: string): ClientConfigBuilder { 46 | this._skillId = skillId; 47 | 48 | return this; 49 | } 50 | 51 | withRegion(region: string): ClientConfigBuilder { 52 | this._region = region; 53 | 54 | return this; 55 | } 56 | 57 | public get skillEntryFile(): string { 58 | return this._skillEntryFile; 59 | } 60 | 61 | public get handlerName(): string { 62 | return this._handlerName; 63 | } 64 | 65 | public get accessToken(): string { 66 | return this._accessToken; 67 | } 68 | 69 | public get skillId(): string { 70 | return this._skillId; 71 | } 72 | 73 | public get region(): string { 74 | return this._region; 75 | } 76 | 77 | public build(): ClientConfig { 78 | return new ClientConfig(this); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/builder/SkillInvokerConfigBuilder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { LambdaHandler } from 'ask-sdk-core'; 15 | import { SkillInvokerConfig } from '../config/SkillInvokerConfig'; 16 | 17 | export class SkillInvokerConfigBuilder { 18 | private _skillHandler: LambdaHandler; 19 | 20 | public withHandler(handlerName: LambdaHandler): SkillInvokerConfigBuilder { 21 | this._skillHandler = handlerName; 22 | 23 | return this; 24 | } 25 | 26 | public get handler(): LambdaHandler { 27 | return this._skillHandler; 28 | } 29 | 30 | public build(): SkillInvokerConfig { 31 | return new SkillInvokerConfig(this); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/builder/WebSocketClientConfigBuilder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | import { WebSocketClientConfig } from '../config/WebSocketClientConfig'; 14 | import { RegionEndpointMapping } from '../constants/Constants'; 15 | 16 | export class WebSocketClientConfigBuilder { 17 | private _headers: {}; 18 | 19 | private _skillId: string; 20 | 21 | private _region: string; 22 | 23 | public withSkillId(skillId: string): WebSocketClientConfigBuilder { 24 | this._skillId = skillId; 25 | 26 | return this; 27 | } 28 | 29 | public withRegion(region: string): WebSocketClientConfigBuilder { 30 | this._region = region; 31 | 32 | return this; 33 | } 34 | 35 | public withAccessToken(accessToken: string): WebSocketClientConfigBuilder { 36 | this._headers = { authorization: accessToken }; 37 | 38 | return this; 39 | } 40 | 41 | public get webSocketServerUri(): string { 42 | console.log(`Region chosen: ${this._region}`); 43 | return `wss://${RegionEndpointMapping.get( 44 | this._region, 45 | )}/v1/skills/${ 46 | this._skillId 47 | }/stages/development/connectCustomDebugEndpoint`; 48 | } 49 | 50 | public get headers(): {} { 51 | return this._headers; 52 | } 53 | 54 | public build(): WebSocketClientConfig { 55 | return new WebSocketClientConfig(this); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/client/ILocalDebugClient.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import WebSocket from 'ws'; 15 | 16 | export interface ILocalDebugClient { 17 | connectedEvent(): void; 18 | 19 | messageEvent(data: WebSocket.Data): void; 20 | 21 | errorEvent(event: WebSocket.ErrorEvent): void; 22 | 23 | closeEvent(event: WebSocket.CloseEvent): void; 24 | 25 | sendResponse(responseString: string): void; 26 | } 27 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/config/ClientConfig.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ClientConfigBuilder } from '../builder/ClientConfigBuilder'; 15 | 16 | export class ClientConfig { 17 | private readonly _accessToken: string; 18 | 19 | private readonly _skillId: string; 20 | 21 | private readonly _handlerName: string; 22 | 23 | private readonly _skillEntryFile: string; 24 | 25 | private readonly _region: string; 26 | 27 | constructor(clientConfigBuilder: ClientConfigBuilder) { 28 | this._skillEntryFile = clientConfigBuilder.skillEntryFile; 29 | this._handlerName = clientConfigBuilder.handlerName; 30 | this._accessToken = clientConfigBuilder.accessToken; 31 | this._skillId = clientConfigBuilder.skillId; 32 | this._region = clientConfigBuilder.region; 33 | } 34 | 35 | public get skillEntryFile(): string { 36 | return this._skillEntryFile; 37 | } 38 | 39 | public get skillId(): string { 40 | return this._skillId; 41 | } 42 | 43 | public get handlerName(): string { 44 | return this._handlerName; 45 | } 46 | 47 | public get accessToken(): string { 48 | return this._accessToken; 49 | } 50 | 51 | public get region(): string { 52 | return this._region; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/config/SkillInvokerConfig.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { LambdaHandler } from 'ask-sdk-core'; 15 | import { SkillInvokerConfigBuilder } from '../builder/SkillInvokerConfigBuilder'; 16 | 17 | export class SkillInvokerConfig { 18 | public readonly _handler: LambdaHandler; 19 | 20 | constructor(skillInvokerConfigBuilder: SkillInvokerConfigBuilder) { 21 | this._handler = skillInvokerConfigBuilder.handler; 22 | } 23 | 24 | public get handler(): LambdaHandler { 25 | return this._handler; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/config/WebSocketClientConfig.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { WebSocketClientConfigBuilder } from '../builder/WebSocketClientConfigBuilder'; 15 | 16 | export class WebSocketClientConfig { 17 | private readonly _webSocketServerUri: string; 18 | 19 | private readonly _headers: {}; 20 | 21 | constructor(webSocketClientConfigBuilder: WebSocketClientConfigBuilder) { 22 | this._webSocketServerUri = webSocketClientConfigBuilder.webSocketServerUri; 23 | this._headers = webSocketClientConfigBuilder.headers; 24 | } 25 | 26 | public get webSocketServerUri(): string { 27 | return this._webSocketServerUri; 28 | } 29 | 30 | public get headers(): {} { 31 | return this._headers; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/constants/Constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | import { Map } from 'immutable'; 14 | 15 | export const RegionEndpointMapping = Map({ 16 | NA: 'bob-dispatch-prod-na.amazon.com', 17 | FE: 'bob-dispatch-prod-fe.amazon.com', 18 | EU: 'bob-dispatch-prod-eu.amazon.com', 19 | }); 20 | 21 | export const DefaultRegion = 'NA'; 22 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/lib/request/DynamicEndpointsRequest.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the 'License'). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the 'license' file accompanying this file. This file is distributed 9 | * on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { dynamicEndpoints } from 'ask-sdk-model'; 15 | 16 | export class DynamicEndpointsRequest implements dynamicEndpoints.Request { 17 | public version: string; 18 | 19 | public type: string; 20 | 21 | public requestId: string; 22 | 23 | public requestPayload: string; 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-local-debug", 3 | "version": "1.1.0", 4 | "description": "Local debug package for Alexa Skills Kit SDK", 5 | "main": "dist/client/WebSocketClient.js", 6 | "types": "dist/client/WebSocketClient.d.ts", 7 | "scripts": { 8 | "lint": "eslint . --ext .ts", 9 | "lint-and-fix": "eslint . --ext .ts --fix", 10 | "compile": "tsc", 11 | "cleanup": "rm -rf dist", 12 | "start": "npm run lint && npm run cleanup && npm run compile", 13 | "release": "npm run start", 14 | "pack": "npm run release && npm pack" 15 | }, 16 | "author": "Amazon.com", 17 | "license": "Apache-2.0", 18 | "devDependencies": { 19 | "@types/node": "^14.0.10", 20 | "@types/ws": "^7.2.4", 21 | "@types/yargs": "^15.0.5", 22 | "@typescript-eslint/eslint-plugin": "^2.34.0", 23 | "@typescript-eslint/parser": "^2.34.0", 24 | "eslint-config-airbnb": "^18.2.0", 25 | "eslint-import-resolver-typescript": "^2.0.0", 26 | "eslint-config-prettier": "^6.11.0", 27 | "eslint-plugin-import": "^2.21.2", 28 | "eslint-plugin-json": "^2.1.1", 29 | "eslint-plugin-jsx-a11y": "^5.1.1", 30 | "eslint-plugin-prettier": "^3.1.4", 31 | "eslint-plugin-react": "^7.20.0", 32 | "eslint-plugin-eslint-comments": "^3.2.0", 33 | "prettier": "^2.0.5", 34 | "eslint": "^6.8.0", 35 | "ts-node": "^8.10.2", 36 | "tsc-watch": "^4.2.3", 37 | "typescript": "^3.9.5" 38 | }, 39 | "dependencies": { 40 | "ws": "^7.3.0", 41 | "yargs": "^15.3.1", 42 | "immutable": "^4.0.0-rc.11", 43 | "ask-sdk-model": "^1.29.0", 44 | "ask-sdk-core": "^2.8.0" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ask-sdk-local-debug/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "outDir": "./dist", 5 | "esModuleInterop": true, 6 | "allowSyntheticDefaultImports": true, 7 | "target": "es6", 8 | "noImplicitAny": true, 9 | "moduleResolution": "node", 10 | "sourceMap": true, 11 | "baseUrl": ".", 12 | "paths": { 13 | "*": ["node_modules/*"] 14 | } 15 | }, 16 | "include": ["lib/**/*"] 17 | } 18 | -------------------------------------------------------------------------------- /ask-sdk-runtime/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | build 7 | -------------------------------------------------------------------------------- /ask-sdk-runtime/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-sdk-runtime/README.md: -------------------------------------------------------------------------------- 1 | ASK SDK Runtime package contains generic components and implementations of ASK SDK v2 for Node.js. 2 | 3 | ## What is ASK SDK v2 for Node.js 4 | 5 | The ASK SDK v2 for Node.js is an open-source Alexa Skill Development Kit. ASK SDK v2 for Node.js makes it easier for you to build highly engaging skills, by allowing you to spend more time on implementing features and less on writing boiler-plate code. 6 | 7 | ## Installing 8 | To use the ASK SDK Runtime pacakge, simply run the following command in terminal: 9 | 10 | ``` 11 | npm install --save ask-sdk-runtime 12 | ``` 13 | 14 | ## Usage and Getting Started 15 | 16 | You can find a getting started guide [here](https://developer.amazon.com/docs/alexa-skills-kit-sdk-for-nodejs/overview.html). 17 | 18 | ## Usage with TypeScript 19 | The SDK runtime package for Node.js bundles TypeScript definition files for use in TypeScript projects and to support tools that can read .d.ts files. Our goal is to keep these TypeScript definition files updated with each release for any public api. 20 | 21 | ### Pre-requisites 22 | Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets a few of these requirements: 23 | - Use TypeScript v2.x 24 | - Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window: 25 | 26 | ``` 27 | npm install --save-dev @types/node 28 | ``` 29 | 30 | ### In Node.js 31 | To use the TypeScript definition files within a Node.js project, simply import ask-sdk-core as below: 32 | 33 | In a TypeScript file: 34 | 35 | ```typescript 36 | import * as Runtime from 'ask-sdk-runtime'; 37 | ``` 38 | 39 | In a JavaScript file: 40 | 41 | ```javascript 42 | const Runtime = require('ask-sdk-runtime'); 43 | ``` 44 | 45 | ## Opening Issues 46 | For bug reports, feature requests and questions, we would like to hear about it. Search the [existing issues](https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues) and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of the SDK, Node.js or browser environment and OS you’re using. Please include a stack trace and reduced repro case when appropriate, too. 47 | 48 | ## License 49 | This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information. 50 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/RequestDispatcher.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * An interface providing the logic for dispatching handler input to handler. 16 | */ 17 | export interface RequestDispatcher { 18 | dispatch(input: Input): Promise | Output; 19 | } 20 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/error/handler/ErrorHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * An interface for user created handler logic to add to {@link ErrorMapper}. 16 | */ 17 | export interface ErrorHandler { 18 | canHandle(handlerInput: Input, error: Error): Promise | boolean; 19 | handle(handlerInput: Input, error: Error): Promise | Output; 20 | } 21 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/error/mapper/ErrorMapper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ErrorHandler } from '../handler/ErrorHandler'; 15 | 16 | /** 17 | * An interface providing a mapping of handler input and error to {@link ErrorHandler}. 18 | */ 19 | export interface ErrorMapper { 20 | getErrorHandler(input: Input, error: Error): Promise> | ErrorHandler; 21 | } 22 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/error/mapper/GenericErrorMapper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ErrorHandler } from '../handler/ErrorHandler'; 15 | import { ErrorMapper } from './ErrorMapper'; 16 | 17 | /** 18 | * Generic implementation of @{link ErrorMapper} 19 | */ 20 | export class GenericErrorMapper implements ErrorMapper { 21 | protected errorHandlers: Array>; 22 | 23 | constructor(options: {errorHandlers: Array>}) { 24 | this.errorHandlers = options.errorHandlers; 25 | } 26 | 27 | public async getErrorHandler(handlerInput: Input, error: Error): Promise> { 28 | for (const errorHandler of this.errorHandlers) { 29 | if (await errorHandler.canHandle(handlerInput, error)) { 30 | return errorHandler; 31 | } 32 | } 33 | 34 | return null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/handler/GenericHandlerAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { HandlerAdapter } from './HandlerAdapter'; 15 | import { RequestHandler } from './RequestHandler'; 16 | 17 | /** 18 | * Generic implementation of {@link HandlerAdapter that supports the {@link RequestHandler}}} 19 | */ 20 | export class GenericHandlerAdapter implements HandlerAdapter { 21 | public supports(handler: any): boolean { 22 | return typeof handler.canHandle === 'function' 23 | && typeof handler.handle === 'function'; 24 | } 25 | 26 | public async execute(input: Input, handler: any): Promise { 27 | return (handler as RequestHandler).handle(input); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/handler/GenericRequestHandlerChain.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestInterceptor } from '../interceptor/RequestInterceptor'; 15 | import { ResponseInterceptor } from '../interceptor/ResponseInterceptor'; 16 | import { RequestHandler } from './RequestHandler'; 17 | import { RequestHandlerChain } from './RequestHandlerChain'; 18 | 19 | /** 20 | * Generic implementation of {@link RequestHandlerChain}. 21 | */ 22 | export class GenericRequestHandlerChain implements RequestHandlerChain { 23 | protected requestHandler: RequestHandler; 24 | protected requestInterceptors: Array>; 25 | protected responseInterceptors: Array>; 26 | 27 | constructor(options: { 28 | requestHandler: RequestHandler, 29 | requestInterceptors? : Array>, 30 | responseInterceptors? : Array>, 31 | }) { 32 | this.requestHandler = options.requestHandler; 33 | this.requestInterceptors = options.requestInterceptors; 34 | this.responseInterceptors = options.responseInterceptors; 35 | } 36 | 37 | public getRequestHandler(): RequestHandler { 38 | return this.requestHandler; 39 | } 40 | 41 | public getRequestInterceptors(): Array> { 42 | return this.requestInterceptors; 43 | } 44 | 45 | public getResponseInterceptors(): Array> { 46 | return this.responseInterceptors; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/handler/HandlerAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * An interface that abstracts the handling of a request for specific types of handlers. 16 | */ 17 | export interface HandlerAdapter { 18 | supports(handler: any): boolean; 19 | execute(input: Input, handler: any): Promise | Output; 20 | } 21 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/handler/RequestHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * An interface for user-created handler logic to add to {@link CustomSkillRequestMapper}. 16 | */ 17 | export interface RequestHandler { 18 | canHandle(input: Input): Promise | boolean; 19 | handle(input: Input): Promise | Output; 20 | } 21 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/handler/RequestHandlerChain.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestInterceptor } from '../interceptor/RequestInterceptor'; 15 | import { ResponseInterceptor } from '../interceptor/ResponseInterceptor'; 16 | 17 | /** 18 | * An interface containing the request handler and corresponding request/response interceptors. 19 | */ 20 | export interface RequestHandlerChain { 21 | getRequestHandler(): any; 22 | getRequestInterceptors(): Array>; 23 | getResponseInterceptors(): Array>; 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/interceptor/RequestInterceptor.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * An interface containing the logic to execute before handler is called. 16 | */ 17 | export interface RequestInterceptor { 18 | process(input: Input): Promise | void; 19 | } 20 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/interceptor/ResponseInterceptor.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * An interface containing the logic to execute after handler returns. 16 | */ 17 | export interface ResponseInterceptor { 18 | process(input: Input, output? : Output): Promise | void; 19 | } 20 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/mapper/GenericRequestMapper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { GenericRequestHandlerChain } from '../handler/GenericRequestHandlerChain'; 15 | import { RequestMapper } from './RequestMapper'; 16 | 17 | /** 18 | * Generic implementation for {@link RequestMapper}. 19 | */ 20 | export class GenericRequestMapper implements RequestMapper { 21 | protected requestHandlerChains: Array>; 22 | 23 | constructor(options: { 24 | requestHandlerChains: Array>, 25 | }) { 26 | this.requestHandlerChains = options.requestHandlerChains; 27 | } 28 | 29 | public async getRequestHandlerChain(input: Input): Promise> { 30 | for (const requestHandlerChain of this.requestHandlerChains) { 31 | const requestHandler = requestHandlerChain.getRequestHandler(); 32 | if (await requestHandler.canHandle(input)) { 33 | return requestHandlerChain; 34 | } 35 | } 36 | 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/dispatcher/request/mapper/RequestMapper.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestHandlerChain } from '../handler/RequestHandlerChain'; 15 | 16 | /** 17 | * An interface providing a mapping of handler input to {@link RequestHandlerChain}. 18 | */ 19 | export interface RequestMapper { 20 | getRequestHandlerChain(input: Input): Promise> | RequestHandlerChain; 21 | } 22 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export { ErrorHandler } from './dispatcher/error/handler/ErrorHandler'; 15 | export { ErrorMapper } from './dispatcher/error/mapper/ErrorMapper'; 16 | export { GenericErrorMapper} from './dispatcher/error/mapper/GenericErrorMapper'; 17 | export { GenericHandlerAdapter } from './dispatcher/request/handler/GenericHandlerAdapter'; 18 | export { GenericRequestHandlerChain } from './dispatcher/request/handler/GenericRequestHandlerChain'; 19 | export { HandlerAdapter } from './dispatcher/request/handler/HandlerAdapter'; 20 | export { RequestHandler } from './dispatcher/request/handler/RequestHandler'; 21 | export { RequestHandlerChain } from './dispatcher/request/handler/RequestHandlerChain'; 22 | export { RequestInterceptor } from './dispatcher/request/interceptor/RequestInterceptor'; 23 | export { ResponseInterceptor } from './dispatcher/request/interceptor/ResponseInterceptor'; 24 | export { GenericRequestMapper } from './dispatcher/request/mapper/GenericRequestMapper'; 25 | export { RequestMapper } from './dispatcher/request/mapper/RequestMapper'; 26 | export { RuntimeConfiguration } from './skill/RuntimeConfiguration'; 27 | export { RuntimeConfigurationBuilder } from './skill/RuntimeConfigurationBuilder'; 28 | export { GenericRequestDispatcher } from './dispatcher/GenericRequestDispatcher'; 29 | export { RequestDispatcher } from './dispatcher/RequestDispatcher'; 30 | 31 | export { Skill } from './skill/Skill'; 32 | 33 | export { 34 | createAskSdkError, 35 | createAskSdkUserAgent 36 | } from './util/AskSdkUtils'; 37 | 38 | export { UserAgentManager } from './util/UserAgentManager'; -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/skill/RuntimeConfiguration.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ErrorMapper } from '../dispatcher/error/mapper/ErrorMapper'; 15 | import { HandlerAdapter } from '../dispatcher/request/handler/HandlerAdapter'; 16 | import { RequestInterceptor } from '../dispatcher/request/interceptor/RequestInterceptor'; 17 | import { ResponseInterceptor } from '../dispatcher/request/interceptor/ResponseInterceptor'; 18 | import { RequestMapper } from '../dispatcher/request/mapper/RequestMapper'; 19 | 20 | export interface RuntimeConfiguration { 21 | requestMappers: Array>; 22 | handlerAdapters: Array>; 23 | errorMapper? : ErrorMapper; 24 | requestInterceptors? : Array>; 25 | responseInterceptors? : Array>; 26 | } 27 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/skill/Skill.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export interface Skill { 15 | invoke(event: Request, context? : any): Promise | Response; 16 | supports(event: any, context? : any): Promise | boolean; 17 | } 18 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/util/AskSdkUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | 'use strict'; 15 | 16 | /** 17 | * function creating an AskSdk error. 18 | * @param {string} errorScope 19 | * @param {string} errorMessage 20 | * @returns {Error} 21 | */ 22 | export function createAskSdkError(errorScope: string, errorMessage: string): Error { 23 | const error = new Error(errorMessage); 24 | error.name = `AskSdk.${errorScope} Error`; 25 | 26 | return error; 27 | } 28 | 29 | /** 30 | * function creating an AskSdk user agent. 31 | * @param packageVersion 32 | * @param customUserAgent 33 | */ 34 | export function createAskSdkUserAgent(packageVersion: string, customUserAgent?: string): string { 35 | const customUserAgentString = customUserAgent ? (` ${ customUserAgent}`) : ''; 36 | 37 | return `ask-node/${packageVersion} Node/${process.version}${ customUserAgentString}`; 38 | } 39 | -------------------------------------------------------------------------------- /ask-sdk-runtime/lib/util/UserAgentManager.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | /** 15 | * Static manager of environment level SDK user agent information. 16 | */ 17 | export class UserAgentManager { 18 | 19 | private static components: Set = new Set(); 20 | private static userAgent: string = ''; 21 | 22 | /** 23 | * Retrieves the full user agent string, containing all registered components. 24 | */ 25 | static getUserAgent(): string { 26 | return this.userAgent; 27 | } 28 | 29 | /** 30 | * Registers a user agent component. This will be appended to the generated 31 | * user agent string. Duplicate components will be ignored. 32 | * 33 | * @param component string component to add to the full user agent 34 | */ 35 | static registerComponent(component: string): void { 36 | if (!this.components.has(component)) { 37 | this.components.add(component); 38 | let updatedUserAgent: string; 39 | for (const component of this.components) { 40 | updatedUserAgent = updatedUserAgent ? `${updatedUserAgent} ${component}` : component; 41 | } 42 | this.userAgent = updatedUserAgent; 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /ask-sdk-runtime/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-runtime", 3 | "version": "2.14.0", 4 | "description": "Base runtime package for Alexa Skills Kit SDK", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [ 17 | { 18 | "name": "Tianren Zhang", 19 | "email": "tianrenz@amazon.com" 20 | } 21 | ], 22 | "license": "Apache-2.0", 23 | "keywords": [ 24 | "Alexa", 25 | "SDK" 26 | ], 27 | "devDependencies": { 28 | "@types/chai": "^4.1.2", 29 | "@types/mocha": "^5.0.0", 30 | "@types/node": "^16.11.1", 31 | "@types/sinon": "^7.0.13", 32 | "@typescript-eslint/eslint-plugin": "^3.9.0", 33 | "@typescript-eslint/parser": "^3.9.0", 34 | "chai": "^4.1.2", 35 | "cross-env": "^7.0.2", 36 | "eslint": "^7.6.0", 37 | "eslint-plugin-tsdoc": "^0.2.6", 38 | "mocha": "^5.0.5", 39 | "nock": "^9.2.3", 40 | "nyc": "^14.1.1", 41 | "sinon": "^7.0.13", 42 | "ts-node": "^6.0.1", 43 | "typescript": "^4.9.5" 44 | }, 45 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 46 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 47 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 48 | } 49 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/dispatcher/error/mapper/GenericErrorMapper.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { GenericErrorMapper } from '../../../../lib/dispatcher/error/mapper/GenericErrorMapper'; 16 | import { MockAlwaysFalseErrorHandler } from '../../../mocks/error/MockAlwaysFalseErrorHandler'; 17 | import { MockAlwaysTrueErrorHandler } from '../../../mocks/error/MockAlwaysTrueErrorHandler'; 18 | 19 | describe('GenericErrorMapper', () => { 20 | it('should be able to get the error handler that can handle the error', async () => { 21 | const mapper = new GenericErrorMapper({ 22 | errorHandlers : [ 23 | new MockAlwaysTrueErrorHandler(), 24 | new MockAlwaysFalseErrorHandler(), 25 | ], 26 | }); 27 | 28 | const handler = await mapper.getErrorHandler(null, new Error('Test error')); 29 | 30 | expect(handler).instanceof(MockAlwaysTrueErrorHandler); 31 | }); 32 | 33 | it('should return null if no error handle can handle the error', async () => { 34 | const mapper = new GenericErrorMapper({ 35 | errorHandlers : [ 36 | new MockAlwaysFalseErrorHandler(), 37 | ], 38 | }); 39 | 40 | const handler = await mapper.getErrorHandler(null, new Error('Test error')); 41 | 42 | expect(handler).equal(null); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/dispatcher/request/handler/GenericHandlerAdapter.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { GenericHandlerAdapter } from '../../../../lib/dispatcher/request/handler/GenericHandlerAdapter'; 16 | import { MockAlwaysFalseRequestHandler } from '../../../mocks/request/MockAlwaysFalseRequestHandler'; 17 | import { MockAlwaysTrueRequestHandler } from '../../../mocks/request/MockAlwaysTrueRequestHandler'; 18 | 19 | describe('GenericHandlerAdapter', () => { 20 | const handlerAdapter = new GenericHandlerAdapter(); 21 | 22 | it('should be able to check for supported handler object', () => { 23 | expect(handlerAdapter.supports(new MockAlwaysTrueRequestHandler())).eq(true); 24 | expect(handlerAdapter.supports(new MockAlwaysFalseRequestHandler())).eq(true); 25 | expect(handlerAdapter.supports({canHandle : true, handle : true})).equal(false); 26 | }); 27 | 28 | it('should be able to invoke the execute function on supported handler object', async () => { 29 | const response = await handlerAdapter.execute('test', new MockAlwaysTrueRequestHandler()); 30 | 31 | expect(response).eq('Input(test) received at MockAlwaysTrueRequestHandler'); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/dispatcher/request/handler/GenericRequestHandlerChain.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { GenericRequestHandlerChain } from '../../../../lib/dispatcher/request/handler/GenericRequestHandlerChain'; 16 | import { MockAlwaysTrueRequestHandler } from '../../../mocks/request/MockAlwaysTrueRequestHandler'; 17 | 18 | describe('GenericRequestHandlerChain', () => { 19 | it('should be able to get request handler', () => { 20 | const handlerChain = new GenericRequestHandlerChain({ 21 | requestHandler : new MockAlwaysTrueRequestHandler(), 22 | }); 23 | 24 | expect(handlerChain.getRequestHandler()).instanceof(MockAlwaysTrueRequestHandler); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/mocks/error/MockAlwaysFalseErrorHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ErrorHandler } from '../../../lib/dispatcher/error/handler/ErrorHandler'; 15 | 16 | export class MockAlwaysFalseErrorHandler implements ErrorHandler { 17 | public canHandle(input: string, error: Error): boolean { 18 | return false; 19 | } 20 | 21 | public handle(input: string, error: Error): string { 22 | throw new Error('This line should never be reached!'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/mocks/error/MockAlwaysTrueErrorHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { ErrorHandler } from '../../../lib/dispatcher/error/handler/ErrorHandler'; 15 | 16 | export class MockAlwaysTrueErrorHandler implements ErrorHandler { 17 | public canHandle(input: string, error: Error): boolean { 18 | return true; 19 | } 20 | 21 | public handle(input: string, error: Error): string { 22 | return `${error.name} received at ${this.constructor.name}`; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/mocks/request/MockAlwaysFalseRequestHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestHandler } from '../../../lib/dispatcher/request/handler/RequestHandler'; 15 | 16 | export class MockAlwaysFalseRequestHandler implements RequestHandler { 17 | public canHandle(input: string): boolean { 18 | return false; 19 | } 20 | 21 | public handle(input: string): string { 22 | throw new Error('This line should never be reached!'); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/mocks/request/MockAlwaysTrueRequestHandler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { RequestHandler } from '../../../lib/dispatcher/request/handler/RequestHandler'; 15 | 16 | export class MockAlwaysTrueRequestHandler implements RequestHandler { 17 | public canHandle(input: string): boolean { 18 | return true; 19 | } 20 | 21 | public handle(input: string): string { 22 | return `Input(${input}) received at ${this.constructor.name}`; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/util/AskSdkUtils.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { 16 | createAskSdkError, 17 | createAskSdkUserAgent 18 | } from '../../lib/util/AskSdkUtils'; 19 | 20 | describe('AskSdkUtils', () => { 21 | it('should be able to create custom error', () => { 22 | const error = createAskSdkError( 23 | 'Custom name', 24 | 'Custom message', 25 | ); 26 | 27 | expect(error.name).equal('AskSdk.Custom name Error'); 28 | expect(error.message).equal('Custom message'); 29 | }); 30 | 31 | it('should be able to create user agent string', () => { 32 | const userAgent = createAskSdkUserAgent('2.0.0', undefined); 33 | 34 | expect(userAgent).equal(`ask-node/2.0.0 Node/${process.version}`); 35 | }); 36 | 37 | it('should be able to create user agent string with custom user agent', () => { 38 | const userAgent = createAskSdkUserAgent('2.0.0', 'custom user agent'); 39 | const packageInfo = require('../../package.json'); 40 | 41 | expect(userAgent).equal(`ask-node/2.0.0 Node/${process.version} custom user agent`); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /ask-sdk-runtime/tst/util/UserAgentManager.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { UserAgentManager } from '../../lib/util/UserAgentManager'; 16 | 17 | describe('UserAgentManager', () => { 18 | it('should be initialized with an empty string', () => { 19 | expect(UserAgentManager.getUserAgent()).equal(''); 20 | }); 21 | 22 | it('should handle a single component', () => { 23 | UserAgentManager.registerComponent('foo'); 24 | expect(UserAgentManager.getUserAgent()).equal('foo'); 25 | }); 26 | 27 | it('should handle multiple components', () => { 28 | UserAgentManager.registerComponent('foo'); 29 | UserAgentManager.registerComponent('bar'); 30 | expect(UserAgentManager.getUserAgent()).equal('foo bar'); 31 | }); 32 | 33 | it('should clear components', () => { 34 | UserAgentManager.registerComponent('foo'); 35 | UserAgentManager.registerComponent('bar'); 36 | UserAgentManager['components'].clear(); 37 | UserAgentManager['userAgent'] = ''; 38 | expect(UserAgentManager.getUserAgent()).equal(''); 39 | }); 40 | }); 41 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | build 7 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | gulpfile.js 7 | gulpfile-base.js 8 | package-lock.json 9 | tsconfig.json 10 | .eslintrc.json 11 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export { S3PersistenceAdapter } from './attributes/persistence/S3PersistenceAdapter'; 15 | export { 16 | ObjectKeyGenerator, 17 | ObjectKeyGenerators 18 | } from './attributes/persistence/ObjectKeyGenerators'; 19 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-s3-persistence-adapter", 3 | "version": "2.14.0", 4 | "description": "S3 based implementation package of PersistenceAdapter interface in ASK SDK v2 for Node.js", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [ 17 | { 18 | "name": "Tianren Zhang", 19 | "email": "tianrenz@amazon.com" 20 | } 21 | ], 22 | "license": "Apache-2.0", 23 | "keywords": [ 24 | "Alexa", 25 | "SDK" 26 | ], 27 | "dependencies": { 28 | "aws-sdk": "^2.163.0" 29 | }, 30 | "peerDependencies": { 31 | "ask-sdk-core": "^2.0.0" 32 | }, 33 | "devDependencies": { 34 | "@types/chai": "^4.1.2", 35 | "@types/mocha": "^5.0.0", 36 | "@types/node": "^16.11.1", 37 | "@typescript-eslint/eslint-plugin": "^3.9.0", 38 | "@typescript-eslint/parser": "^3.9.0", 39 | "ask-sdk-core": "^2.14.0", 40 | "ask-sdk-model": "^1.29.0", 41 | "aws-sdk-mock": "^4.1.0", 42 | "chai": "^4.1.2", 43 | "cross-env": "^7.0.2", 44 | "eslint": "^7.6.0", 45 | "eslint-plugin-tsdoc": "^0.2.6", 46 | "mocha": "^5.0.5", 47 | "nyc": "^14.1.1", 48 | "ts-node": "^6.2.0", 49 | "typescript": "^4.9.5" 50 | }, 51 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 52 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 53 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 54 | } 55 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/tst/mocks/JsonProvider.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { 15 | Intent, 16 | RequestEnvelope, 17 | Slot 18 | } from 'ask-sdk-model'; 19 | 20 | export const JsonProvider = { 21 | requestEnvelope(): RequestEnvelope { 22 | return { 23 | context : { 24 | AudioPlayer : null, 25 | Display : null, 26 | System : { 27 | apiAccessToken : null, 28 | apiEndpoint : null, 29 | application : { 30 | applicationId : null, 31 | }, 32 | device : { 33 | deviceId : null, 34 | supportedInterfaces : null, 35 | }, 36 | user : { 37 | userId : null, 38 | }, 39 | }, 40 | }, 41 | request: null, 42 | session: { 43 | application: { 44 | applicationId: null, 45 | }, 46 | attributes: null, 47 | new: true, 48 | sessionId: null, 49 | user: { 50 | accessToken: null, 51 | permissions: { 52 | consentToken: null, 53 | }, 54 | userId: null, 55 | }, 56 | }, 57 | version: '1.0', 58 | }; 59 | }, 60 | intent(): Intent { 61 | return { 62 | confirmationStatus : null, 63 | name : null, 64 | slots : null, 65 | }; 66 | }, 67 | slot(): Slot { 68 | return { 69 | confirmationStatus : null, 70 | name : null, 71 | value : null, 72 | resolutions: null, 73 | }; 74 | }, 75 | }; 76 | -------------------------------------------------------------------------------- /ask-sdk-s3-persistence-adapter/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | dist/ 4 | node_modules/ 5 | package-lock.json 6 | build 7 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/copySessionAttributesInterceptor.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { 15 | HandlerInput, 16 | RequestInterceptor 17 | } from 'ask-sdk'; 18 | 19 | export class CopySessionAttributesInterceptor implements RequestInterceptor { 20 | public process(handlerInput: HandlerInput): void { 21 | const attributes = handlerInput.requestEnvelope.session.attributes; 22 | handlerInput.attributesManager.setSessionAttributes(attributes); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/defaultHandlers/skillEventHandlers.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { V1Handler } from '../v1Handler'; 15 | 16 | export const SkillEventHandlers: V1Handler = { 17 | 'AlexaSkillEvent.SkillAccountLinked'(): void { 18 | // do something 19 | }, 20 | 'AlexaSkillEvent.SkillDisabled'(): void { 21 | // do something 22 | }, 23 | 'AlexaSkillEvent.SkillEnabled'(): void { 24 | // do something 25 | }, 26 | 'AlexaSkillEvent.SkillPermissionAccepted'(): void { 27 | // do something 28 | }, 29 | 'AlexaSkillEvent.SkillPermissionChanged'(): void { 30 | // do something 31 | }, 32 | }; 33 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/directives/voicePlayerSpeakDirective.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { services } from 'ask-sdk-model'; 15 | 16 | export class VoicePlayerSpeakDirective implements services.directive.SendDirectiveRequest { 17 | public directive: services.directive.Directive; 18 | public header: services.directive.Header; 19 | 20 | constructor(id: string, speechContent: string) { 21 | this.directive = { 22 | speech: speechContent, 23 | type: 'VoicePlayer.Speak', 24 | }; 25 | this.header = { 26 | requestId : id, 27 | }; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/eventParser.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { 15 | IntentRequest, 16 | RequestEnvelope 17 | } from 'ask-sdk-model'; 18 | 19 | export const EventParser = (event: RequestEnvelope): string => { 20 | const requestType = event.request.type; 21 | if (requestType === 'IntentRequest') { 22 | return ( event.request).intent.name; 23 | } else if (requestType.startsWith('Display.') || 24 | requestType.startsWith('AudioPlayer.') || 25 | requestType.startsWith('PlaybackController.')) { 26 | return requestType.split('.')[1]; 27 | } else { 28 | return requestType; 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/services/apiClient.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { services } from 'ask-sdk-model'; 15 | 16 | export interface ApiClient { 17 | post? : (uri: string, headers: Array<{key: string, value: string}>, body: string) => Promise; 18 | get? : (uri: string, headers: Array<{key: string, value: string}>) => Promise; 19 | put? : (uri: string, headers: Array<{key: string, value: string}>, body: string) => Promise; 20 | delete? : (uri: string, headers: Array<{key: string, value: string}>) => Promise; 21 | } 22 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/services/directiveService.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { services } from 'ask-sdk-model'; 15 | import { VoicePlayerSpeakDirective } from '../directives/voicePlayerSpeakDirective'; 16 | import { ApiClient } from './apiClient'; 17 | import { ServiceError } from './serviceError'; 18 | import { V1ApiClient } from './v1ApiClient'; 19 | 20 | export class DirectiveService { 21 | protected apiClient: ApiClient; 22 | protected directivesApiPath: string; 23 | 24 | constructor(apiClient? : ApiClient) { 25 | this.apiClient = apiClient || new V1ApiClient(); 26 | this.directivesApiPath = '/v1/directives'; 27 | } 28 | 29 | public enqueue(directive: VoicePlayerSpeakDirective, apiEndpoint: string, token: string): Promise { 30 | const uri = apiEndpoint + this.directivesApiPath; 31 | 32 | return this.dispatch(directive, uri, token); 33 | } 34 | 35 | private async dispatch(directive: VoicePlayerSpeakDirective, url: string, token: string): Promise { 36 | const body = JSON.stringify(directive); 37 | const headers = [{key : 'Authorization', value : `Bearer ${token}`}, 38 | {key : 'Content-Type', value : 'application/json'}]; 39 | 40 | const response = await this.apiClient.post(url, headers, body); 41 | 42 | return this.validateApiResponse(response); 43 | } 44 | 45 | private validateApiResponse(apiClientResponse: services.ApiClientResponse): void { 46 | const isResponseCodeValid = apiClientResponse.statusCode >= 200 && apiClientResponse.statusCode < 300; 47 | if (isResponseCodeValid) { 48 | return; 49 | } 50 | 51 | throw new ServiceError(apiClientResponse.statusCode, JSON.stringify(apiClientResponse.body)); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/services/serviceError.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export class ServiceError extends Error { 15 | public name: string; 16 | protected statusCode: number; 17 | 18 | constructor(statusCode: number, message: string) { 19 | super(message); 20 | this.name = 'ServiceError'; 21 | this.statusCode = statusCode; 22 | Error.captureStackTrace(this, ServiceError); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/bodyTemplate1Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextUtils } from '../utils/textUtils'; 16 | 17 | export class BodyTemplate1Builder { 18 | protected template: interfaces.display.BodyTemplate1; 19 | 20 | constructor() { 21 | this.template = { type : 'BodyTemplate1' }; 22 | } 23 | 24 | public setTextContent(primaryText? : interfaces.display.TextField, 25 | secondaryText? : interfaces.display.TextField, 26 | tertiaryText? : interfaces.display.TextField): this { 27 | 28 | this.template.textContent = TextUtils.makeTextContent(primaryText, secondaryText, tertiaryText); 29 | 30 | return this; 31 | } 32 | 33 | public setTitle(title: string): this { 34 | this.template.title = title; 35 | 36 | return this; 37 | } 38 | 39 | public setToken(token: string): this { 40 | this.template.token = token; 41 | 42 | return this; 43 | } 44 | 45 | public setBackgroundImage(image: interfaces.display.Image): this { 46 | this.template.backgroundImage = image; 47 | 48 | return this; 49 | } 50 | 51 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 52 | this.template.backButton = backButtonBehavior; 53 | 54 | return this; 55 | } 56 | 57 | public build(): interfaces.display.BodyTemplate1 { 58 | return this.template; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/bodyTemplate2Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextUtils } from '../utils/textUtils'; 16 | 17 | export class BodyTemplate2Builder { 18 | protected template: interfaces.display.BodyTemplate2; 19 | 20 | constructor() { 21 | this.template = { type : 'BodyTemplate2' }; 22 | } 23 | 24 | public setImage(image: interfaces.display.Image): this { 25 | this.template.image = image; 26 | 27 | return this; 28 | } 29 | public setTextContent(primaryText? : interfaces.display.TextField, 30 | secondaryText? : interfaces.display.TextField, 31 | tertiaryText? : interfaces.display.TextField): this { 32 | this.template.textContent = TextUtils.makeTextContent(primaryText, secondaryText, tertiaryText); 33 | 34 | return this; 35 | } 36 | 37 | public setTitle(title: string): this { 38 | this.template.title = title; 39 | 40 | return this; 41 | } 42 | 43 | public setToken(token: string): this { 44 | this.template.token = token; 45 | 46 | return this; 47 | } 48 | 49 | public setBackgroundImage(image: interfaces.display.Image): this { 50 | this.template.backgroundImage = image; 51 | 52 | return this; 53 | } 54 | 55 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 56 | this.template.backButton = backButtonBehavior; 57 | 58 | return this; 59 | } 60 | 61 | public build(): interfaces.display.BodyTemplate2 { 62 | return this.template; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/bodyTemplate3Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextUtils } from '../utils/textUtils'; 16 | 17 | export class BodyTemplate3Builder { 18 | protected template: interfaces.display.BodyTemplate3; 19 | 20 | constructor() { 21 | this.template = { type : 'BodyTemplate3' }; 22 | } 23 | 24 | public setImage(image: interfaces.display.Image): this { 25 | this.template.image = image; 26 | 27 | return this; 28 | } 29 | public setTextContent(primaryText? : interfaces.display.TextField, 30 | secondaryText? : interfaces.display.TextField, 31 | tertiaryText? : interfaces.display.TextField): this { 32 | this.template.textContent = TextUtils.makeTextContent(primaryText, secondaryText, tertiaryText); 33 | 34 | return this; 35 | } 36 | 37 | public setTitle(title: string): this { 38 | this.template.title = title; 39 | 40 | return this; 41 | } 42 | 43 | public setToken(token: string): this { 44 | this.template.token = token; 45 | 46 | return this; 47 | } 48 | 49 | public setBackgroundImage(image: interfaces.display.Image): this { 50 | this.template.backgroundImage = image; 51 | 52 | return this; 53 | } 54 | 55 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 56 | this.template.backButton = backButtonBehavior; 57 | 58 | return this; 59 | } 60 | 61 | public build(): interfaces.display.BodyTemplate3 { 62 | return this.template; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/bodyTemplate6Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextUtils } from '../utils/textUtils'; 16 | 17 | export class BodyTemplate6Builder { 18 | protected template: interfaces.display.BodyTemplate6; 19 | 20 | constructor() { 21 | this.template = { type : 'BodyTemplate6' }; 22 | } 23 | 24 | public setTextContent(primaryText? : interfaces.display.TextField, 25 | secondaryText? : interfaces.display.TextField, 26 | tertiaryText? : interfaces.display.TextField): this { 27 | this.template.textContent = TextUtils.makeTextContent(primaryText, secondaryText, tertiaryText); 28 | 29 | return this; 30 | } 31 | 32 | public setToken(token: string): this { 33 | this.template.token = token; 34 | 35 | return this; 36 | } 37 | 38 | public setBackgroundImage(image: interfaces.display.Image): this { 39 | this.template.backgroundImage = image; 40 | 41 | return this; 42 | } 43 | 44 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 45 | this.template.backButton = backButtonBehavior; 46 | 47 | return this; 48 | } 49 | 50 | public setImage(image: interfaces.display.Image): this { 51 | this.template.image = image; 52 | 53 | return this; 54 | } 55 | 56 | public build(): interfaces.display.BodyTemplate6 { 57 | return this.template; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/bodyTemplate7Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | 16 | export class BodyTemplate7Builder { 17 | protected template: interfaces.display.BodyTemplate7; 18 | 19 | constructor() { 20 | this.template = { type : 'BodyTemplate7' }; 21 | } 22 | 23 | public setImage(image: interfaces.display.Image): this { 24 | this.template.image = image; 25 | 26 | return this; 27 | } 28 | 29 | public setTitle(title: string): this { 30 | this.template.title = title; 31 | 32 | return this; 33 | } 34 | 35 | public setToken(token: string): this { 36 | this.template.token = token; 37 | 38 | return this; 39 | } 40 | 41 | public setBackgroundImage(image: interfaces.display.Image): this { 42 | this.template.backgroundImage = image; 43 | 44 | return this; 45 | } 46 | 47 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 48 | this.template.backButton = backButtonBehavior; 49 | 50 | return this; 51 | } 52 | 53 | public build(): interfaces.display.BodyTemplate7 { 54 | return this.template; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/listItemBuilder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | import { TextUtils } from '../utils/textUtils'; 16 | 17 | export class ListItemBuilder { 18 | protected listItems: interfaces.display.ListItem[]; 19 | 20 | constructor() { 21 | this.listItems = []; 22 | } 23 | 24 | public addItem(image: interfaces.display.Image, token: string, 25 | primaryText? : interfaces.display.TextField, 26 | secondaryText? : interfaces.display.TextField, 27 | tertiaryText? : interfaces.display.TextField): this { 28 | const listItem: interfaces.display.ListItem = { 29 | token, 30 | image, 31 | textContent : TextUtils.makeTextContent(primaryText, secondaryText, tertiaryText), 32 | }; 33 | 34 | this.listItems.push(listItem); 35 | 36 | return this; 37 | } 38 | 39 | public build(): interfaces.display.ListItem[] { 40 | return this.listItems; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/listTemplate1Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | 16 | export class ListTemplate1Builder { 17 | protected template: interfaces.display.ListTemplate1; 18 | 19 | constructor() { 20 | this.template = { type : 'ListTemplate1' }; 21 | } 22 | 23 | public setListItems(listItems: interfaces.display.ListItem[]): this { 24 | this.template.listItems = listItems; 25 | 26 | return this; 27 | } 28 | 29 | public setTitle(title: string): this { 30 | this.template.title = title; 31 | 32 | return this; 33 | } 34 | 35 | public setToken(token: string): this { 36 | this.template.token = token; 37 | 38 | return this; 39 | } 40 | 41 | public setBackgroundImage(image: interfaces.display.Image): this { 42 | this.template.backgroundImage = image; 43 | 44 | return this; 45 | } 46 | 47 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 48 | this.template.backButton = backButtonBehavior; 49 | 50 | return this; 51 | } 52 | 53 | public build(): interfaces.display.ListTemplate1 { 54 | return this.template; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/templateBuilders/listTemplate2Builder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | 16 | export class ListTemplate2Builder { 17 | protected template: interfaces.display.ListTemplate2; 18 | 19 | constructor() { 20 | this.template = { type : 'ListTemplate2' }; 21 | } 22 | 23 | public setListItems(listItems: interfaces.display.ListItem[]): this { 24 | this.template.listItems = listItems; 25 | 26 | return this; 27 | } 28 | 29 | public setTitle(title: string): this { 30 | this.template.title = title; 31 | 32 | return this; 33 | } 34 | 35 | public setToken(token: string): this { 36 | this.template.token = token; 37 | 38 | return this; 39 | } 40 | 41 | public setBackgroundImage(image: interfaces.display.Image): this { 42 | this.template.backgroundImage = image; 43 | 44 | return this; 45 | } 46 | 47 | public setBackButtonBehavior(backButtonBehavior: interfaces.display.BackButtonBehavior): this { 48 | this.template.backButton = backButtonBehavior; 49 | 50 | return this; 51 | } 52 | 53 | public build(): interfaces.display.ListTemplate2 { 54 | return this.template; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/utils/imageUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | 16 | export class ImageUtils { 17 | public static makeImage(url: string, widthPixels? : number, heightPixels? : number, 18 | size? : interfaces.display.ImageSize, description? : string): interfaces.display.Image { 19 | const imageInstance: interfaces.display.ImageInstance = { 20 | url, 21 | size, 22 | widthPixels, 23 | heightPixels, 24 | }; 25 | 26 | const image: interfaces.display.Image = { 27 | sources : [imageInstance], 28 | contentDescription : description, 29 | }; 30 | 31 | return image; 32 | } 33 | 34 | public static makeImages(imgArr: interfaces.display.ImageInstance[], 35 | description? : string): interfaces.display.Image { 36 | const images: interfaces.display.Image = { 37 | sources : imgArr, 38 | contentDescription : description, 39 | }; 40 | 41 | return images; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/utils/textUtils.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { interfaces } from 'ask-sdk-model'; 15 | 16 | export class TextUtils { 17 | public static makePlainText(text: string): interfaces.display.PlainText { 18 | const plainText: interfaces.display.PlainText = { 19 | type : 'PlainText', 20 | text, 21 | }; 22 | 23 | return plainText; 24 | } 25 | 26 | public static makeRichText(text: string): interfaces.display.RichText { 27 | const richText: interfaces.display.RichText = { 28 | type : 'RichText', 29 | text, 30 | }; 31 | 32 | return richText; 33 | } 34 | 35 | public static makeTextContent(primaryText: interfaces.display.TextField, 36 | secondaryText: interfaces.display.TextField, 37 | tertiaryText: interfaces.display.TextField): interfaces.display.TextContent { 38 | const textContent: interfaces.display.TextContent = { 39 | primaryText, 40 | secondaryText, 41 | tertiaryText, 42 | }; 43 | 44 | return textContent; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/lib/v1Handler.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export interface V1Handler { 15 | [key: string]: (...args: any[]) => void; 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk-v1adapter", 3 | "version": "2.14.0", 4 | "description": "Adapter from v1 Alexa Node.js SDK to v2", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [ 17 | { 18 | "name": "Tianren Zhang", 19 | "email": "tianrenz@amazon.com" 20 | }, 21 | { 22 | "name": "Tiantian Xie", 23 | "email": "xtiantia@amazon.com" 24 | } 25 | ], 26 | "license": "Apache-2.0", 27 | "keywords": [ 28 | "Alexa", 29 | "Skill", 30 | "SDK" 31 | ], 32 | "dependencies": { 33 | "i18next": "^3.4.1", 34 | "i18next-sprintf-postprocessor": "^0.2.2" 35 | }, 36 | "peerDependencies": { 37 | "ask-sdk": "^2.0.0" 38 | }, 39 | "devDependencies": { 40 | "@types/chai": "^4.1.2", 41 | "@types/mocha": "^5.0.0", 42 | "@types/node": "^16.11.1", 43 | "@types/sinon": "^7.0.13", 44 | "@typescript-eslint/eslint-plugin": "^3.9.0", 45 | "@typescript-eslint/parser": "^3.9.0", 46 | "ask-sdk": "^2.14.0", 47 | "chai": "^4.1.2", 48 | "cross-env": "^7.0.2", 49 | "eslint": "^7.6.0", 50 | "eslint-plugin-tsdoc": "^0.2.6", 51 | "mocha": "^5.0.5", 52 | "nock": "^13.3.0", 53 | "nyc": "^14.1.1", 54 | "sinon": "^7.0.13", 55 | "ts-node": "^6.0.1", 56 | "typescript": "^4.9.5" 57 | }, 58 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 59 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 60 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 61 | } 62 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/mock/mockPersistenceAdapter.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { PersistenceAdapter } from 'ask-sdk'; 15 | import { RequestEnvelope } from 'ask-sdk-model'; 16 | 17 | export class MockPersistenceAdapter implements PersistenceAdapter { 18 | public getCounter: number = 0; 19 | public saveCounter: number = 0; 20 | 21 | private partitionKey: string = 'amzn1.ask.account.[unique-value-here]'; 22 | private savedAttributes: {[key: string]: any} = { 23 | key_1 : 'v1', /* eslint-disable-line camelcase */ 24 | key_2 : 'v2', /* eslint-disable-line camelcase */ 25 | state : 'mockState', 26 | }; 27 | 28 | public getAttributes(requestEnvelope: RequestEnvelope): Promise<{[key: string]: any}> { 29 | this.getCounter++; 30 | 31 | const id = requestEnvelope.context.System.user.userId; 32 | 33 | return new Promise<{[key: string]: any}>((resolve, reject) => { 34 | if (id === this.partitionKey) { 35 | resolve(this.savedAttributes); 36 | } else { 37 | reject(new Error('Resource Not Found')); 38 | } 39 | }); 40 | } 41 | 42 | public saveAttributes(requestEnvelope: RequestEnvelope, attributes: {[key: string]: any}): Promise { 43 | this.saveCounter ++; 44 | 45 | const id = requestEnvelope.context.System.user.userId; 46 | 47 | return new Promise((resolve, reject) => { 48 | // Enforce the mock DB to only have one entry capacity 49 | if (id === this.partitionKey) { 50 | this.savedAttributes = attributes; 51 | resolve(); 52 | } else { 53 | reject(new Error('Maximum Capacity Reached')); 54 | } 55 | }); 56 | } 57 | 58 | public resetCounter(): void { 59 | this.getCounter = 0; 60 | this.saveCounter = 0; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/mock/mockV2RequestHandler.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | module.exports.mockV2Requesthandler = { 15 | canHandle(handlerInput) { 16 | return true; 17 | }, 18 | handle(handlerInnput) { 19 | return null; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/services/serviceError.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { ServiceError } from '../../lib/services/serviceError'; 16 | 17 | function throwServiceError(): void { 18 | throw new ServiceError(202, 'Error Message'); 19 | } 20 | 21 | describe('ServiceError', () => { 22 | it('should create a ServiceError with statusCode and message', () => { 23 | try { 24 | throwServiceError(); 25 | } catch (error) { 26 | expect(error.statusCode).to.equal(202); 27 | expect(error.message).to.equal('Error Message'); 28 | expect(error).to.be.an.instanceOf(Error); 29 | expect(require('util').isError(error)).to.equal(true); 30 | expect(error.stack.split('\n')[0]).to.deep.equal('ServiceError: Error Message'); 31 | expect(error.stack.split('\n')[1].indexOf('throwServiceError')).to.deep.equal(7); 32 | } 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/bodyTemplate1Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { BodyTemplate1Builder } from '../../lib/templateBuilders/bodyTemplate1Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('BodyTemplate1Builder', () => { 20 | it('should create BodyTemplate1', () => { 21 | const expectedBackButtonBehavior = 'VISIBLE'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedPrimaryText = TextUtils.makePlainText('text'); 24 | const expectedTitle = 'title'; 25 | const expectedToken = 'token'; 26 | 27 | const template = new BodyTemplate1Builder() 28 | .setBackButtonBehavior(expectedBackButtonBehavior) 29 | .setBackgroundImage(expectedBgImage) 30 | .setTextContent(expectedPrimaryText) 31 | .setTitle(expectedTitle) 32 | .setToken(expectedToken) 33 | .build(); 34 | expect(template.type).to.equal('BodyTemplate1'); 35 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 36 | expect(template.backgroundImage).to.equal(expectedBgImage); 37 | expect(template.textContent.primaryText).to.equal(expectedPrimaryText); 38 | expect(template.token).to.equal(expectedToken); 39 | expect(template.title).to.equal(expectedTitle); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/bodyTemplate2Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { BodyTemplate2Builder } from '../../lib/templateBuilders/bodyTemplate2Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('BodyTemplate2Builder', () => { 20 | it('should create BodyTemplate2', () => { 21 | const expectedBackButtonBehavior = 'HIDDEN'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedPrimaryText = TextUtils.makePlainText('text'); 24 | const expectedTitle = 'title'; 25 | const expectedToken = 'token'; 26 | const expectedFgImage = ImageUtils.makeImage('url2'); 27 | 28 | const template = new BodyTemplate2Builder() 29 | .setBackButtonBehavior(expectedBackButtonBehavior) 30 | .setBackgroundImage(expectedBgImage) 31 | .setTextContent(expectedPrimaryText) 32 | .setTitle(expectedTitle) 33 | .setToken(expectedToken) 34 | .setImage(expectedFgImage) 35 | .build(); 36 | 37 | expect(template.type).to.equal('BodyTemplate2'); 38 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 39 | expect(template.backgroundImage).to.equal(expectedBgImage); 40 | expect(template.textContent.primaryText).to.equal(expectedPrimaryText); 41 | expect(template.token).to.equal(expectedToken); 42 | expect(template.title).to.equal(expectedTitle); 43 | expect(template.image).to.equal(expectedFgImage); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/bodyTemplate3Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { BodyTemplate3Builder } from '../../lib/templateBuilders/bodyTemplate3Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('BodyTemplate3Builder', () => { 20 | it('should create BodyTemplate3', () => { 21 | const expectedBackButtonBehavior = 'HIDDEN'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedPrimaryText = TextUtils.makePlainText('text'); 24 | const expectedTitle = 'title'; 25 | const expectedToken = 'token'; 26 | const expectedFgImage = ImageUtils.makeImage('url2'); 27 | 28 | const template = new BodyTemplate3Builder() 29 | .setBackButtonBehavior(expectedBackButtonBehavior) 30 | .setBackgroundImage(expectedBgImage) 31 | .setTextContent(expectedPrimaryText) 32 | .setTitle(expectedTitle) 33 | .setToken(expectedToken) 34 | .setImage(expectedFgImage) 35 | .build(); 36 | 37 | expect(template.type).to.equal('BodyTemplate3'); 38 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 39 | expect(template.backgroundImage).to.equal(expectedBgImage); 40 | expect(template.textContent.primaryText).to.equal(expectedPrimaryText); 41 | expect(template.token).to.equal(expectedToken); 42 | expect(template.title).to.equal(expectedTitle); 43 | expect(template.image).to.equal(expectedFgImage); 44 | }); 45 | }); 46 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/bodyTemplate6Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { BodyTemplate6Builder } from '../../lib/templateBuilders/bodyTemplate6Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('BodyTemplate6Builder', () => { 20 | it('should create BodyTemplate6', () => { 21 | const expectedBackButtonBehavior = 'HIDDEN'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedPrimaryText = TextUtils.makePlainText('text'); 24 | const expectedTitle = 'title'; 25 | const expectedToken = 'token'; 26 | const expectedFgImage = ImageUtils.makeImage('url2'); 27 | 28 | const template = new BodyTemplate6Builder() 29 | .setBackButtonBehavior(expectedBackButtonBehavior) 30 | .setBackgroundImage(expectedBgImage) 31 | .setTextContent(expectedPrimaryText) 32 | .setToken(expectedToken) 33 | .setImage(expectedFgImage) 34 | .build(); 35 | 36 | expect(template.type).to.equal('BodyTemplate6'); 37 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 38 | expect(template.backgroundImage).to.equal(expectedBgImage); 39 | expect(template.textContent.primaryText).to.equal(expectedPrimaryText); 40 | expect(template.token).to.equal(expectedToken); 41 | expect(template.image).to.equal(expectedFgImage); 42 | }); 43 | }); 44 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/bodyTemplate7Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { BodyTemplate7Builder } from '../../lib/templateBuilders/bodyTemplate7Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('BodyTemplate7Builder', () => { 20 | it('should create BodyTemplate7', () => { 21 | const expectedBackButtonBehavior = 'HIDDEN'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedTitle = 'title'; 24 | const expectedToken = 'token'; 25 | const expectedFgImage = ImageUtils.makeImage('url2'); 26 | 27 | const template = new BodyTemplate7Builder() 28 | .setBackButtonBehavior(expectedBackButtonBehavior) 29 | .setBackgroundImage(expectedBgImage) 30 | .setTitle(expectedTitle) 31 | .setToken(expectedToken) 32 | .setImage(expectedFgImage) 33 | .build(); 34 | 35 | expect(template.type).to.equal('BodyTemplate7'); 36 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 37 | expect(template.backgroundImage).to.equal(expectedBgImage); 38 | expect(template.token).to.equal(expectedToken); 39 | expect(template.title).to.equal(expectedTitle); 40 | expect(template.image).to.equal(expectedFgImage); 41 | }); 42 | }); 43 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/listItemBuilder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { ListItemBuilder } from '../../lib/templateBuilders/listItemBuilder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('ListItemBuilder', () => { 20 | it('should initialize with 0 list items', () => { 21 | const listItems = new ListItemBuilder().build(); 22 | 23 | expect(listItems.length).to.equal(0); 24 | }); 25 | 26 | it('should build with a single list item', () => { 27 | const expectedImage = ImageUtils.makeImage('url'); 28 | const expectedToken = 'token'; 29 | const expectedPrimaryText = TextUtils.makePlainText('text'); 30 | 31 | const listItems = new ListItemBuilder() 32 | .addItem(expectedImage, expectedToken, expectedPrimaryText) 33 | .build(); 34 | 35 | expect(listItems.length).to.equal(1); 36 | expect(listItems[0].image).to.equal(expectedImage); 37 | expect(listItems[0].token).to.equal(expectedToken); 38 | expect(listItems[0].textContent.primaryText).to.equal(expectedPrimaryText); 39 | 40 | }); 41 | 42 | it('should build with multiple list items', () => { 43 | const expectedImage = ImageUtils.makeImage('url'); 44 | const expectedToken = 'token'; 45 | const expectedPrimaryText = TextUtils.makePlainText('text'); 46 | 47 | const listItems = new ListItemBuilder() 48 | .addItem(expectedImage, expectedToken, expectedPrimaryText) 49 | .addItem(expectedImage, expectedToken, expectedPrimaryText) 50 | .build(); 51 | 52 | expect(listItems.length).to.equal(2); 53 | }); 54 | }); 55 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/listTemplate1Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { ListTemplate1Builder } from '../../lib/templateBuilders/listTemplate1Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('ListTemplate1Builder', () => { 20 | it('should create BodyTemplate6', () => { 21 | const expectedBackButtonBehavior = 'HIDDEN'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedTitle = 'title'; 24 | const expectedToken = 'token'; 25 | 26 | const template = new ListTemplate1Builder() 27 | .setBackButtonBehavior(expectedBackButtonBehavior) 28 | .setBackgroundImage(expectedBgImage) 29 | .setTitle(expectedTitle) 30 | .setToken(expectedToken) 31 | .setListItems([]) 32 | .build(); 33 | 34 | expect(template.type).to.equal('ListTemplate1'); 35 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 36 | expect(template.backgroundImage).to.equal(expectedBgImage); 37 | expect(template.token).to.equal(expectedToken); 38 | expect(template.title).to.equal(expectedTitle); 39 | expect(template.listItems.length).to.equal(0); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/templateBuilders/listTemplate2Builder.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { ListTemplate2Builder } from '../../lib/templateBuilders/listTemplate2Builder'; 16 | import { ImageUtils } from '../../lib/utils/imageUtils'; 17 | import { TextUtils } from '../../lib/utils/textUtils'; 18 | 19 | describe('ListTemplate2Builder', () => { 20 | it('should create BodyTemplate6', () => { 21 | const expectedBackButtonBehavior = 'HIDDEN'; 22 | const expectedBgImage = ImageUtils.makeImage('url'); 23 | const expectedTitle = 'title'; 24 | const expectedToken = 'token'; 25 | 26 | const template = new ListTemplate2Builder() 27 | .setBackButtonBehavior(expectedBackButtonBehavior) 28 | .setBackgroundImage(expectedBgImage) 29 | .setTitle(expectedTitle) 30 | .setToken(expectedToken) 31 | .setListItems([]) 32 | .build(); 33 | 34 | expect(template.type).to.equal('ListTemplate2'); 35 | expect(template.backButton).to.equal(expectedBackButtonBehavior); 36 | expect(template.backgroundImage).to.equal(expectedBgImage); 37 | expect(template.token).to.equal(expectedToken); 38 | expect(template.title).to.equal(expectedTitle); 39 | expect(template.listItems.length).to.equal(0); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /ask-sdk-v1adapter/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | build 7 | -------------------------------------------------------------------------------- /ask-sdk/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-sdk/README.md: -------------------------------------------------------------------------------- 1 | ASK SDK package is the standard distribution of ASK SDK v2 for Node.js. 2 | 3 | ## What is ASK SDK v2 for Node.js 4 | 5 | The ASK SDK v2 for Node.js is an open-source Alexa Skill Development Kit. ASK SDK v2 for Node.js makes it easier for you to build highly engaging skills, by allowing you to spend more time on implementing features and less on writing boiler-plate code. 6 | 7 | ## Installing 8 | To use the ASK SDK package, simply run the following command in terminal: 9 | 10 | ``` 11 | npm install --save ask-sdk 12 | ``` 13 | 14 | ## Usage and Getting Started 15 | 16 | You can find a getting started guide [here](https://developer.amazon.com/docs/alexa-skills-kit-sdk-for-nodejs/overview.html). 17 | 18 | ## Usage with TypeScript 19 | The ASK SDK package for Node.js bundles TypeScript definition files for use in TypeScript projects and to support tools that can read .d.ts files. Our goal is to keep these TypeScript definition files updated with each release for any public api. 20 | 21 | ### Pre-requisites 22 | Before you can begin using these TypeScript definitions with your project, you need to make sure your project meets a few of these requirements: 23 | - Use TypeScript v2.x 24 | - Includes the TypeScript definitions for node. You can use npm to install this by typing the following into a terminal window: 25 | 26 | ``` 27 | npm install --save-dev @types/node 28 | ``` 29 | 30 | ### In Node.js 31 | To use the TypeScript definition files within a Node.js project, simply import ask-sdk as below: 32 | 33 | In a TypeScript file: 34 | 35 | ```typescript 36 | import * as Alexa from 'ask-sdk'; 37 | ``` 38 | 39 | In a JavaScript file: 40 | 41 | ```javascript 42 | const Alexa = require('ask-sdk'); 43 | ``` 44 | 45 | ## Opening Issues 46 | For bug reports, feature requests and questions, we would like to hear about it. Search the [existing issues](https://github.com/alexa/alexa-skills-kit-sdk-for-nodejs/issues) and try to make sure your problem doesn’t already exist before opening a new issue. It’s helpful if you include the version of the SDK, Node.js or browser environment and OS you’re using. Please include a stack trace and reduced repro case when appropriate, too. 47 | 48 | ## License 49 | This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information. 50 | -------------------------------------------------------------------------------- /ask-sdk/lib/index.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export { StandardSkillBuilder } from './skill/factory/StandardSkillBuilder'; 15 | export { StandardSkillFactory } from './skill/factory/StandardSkillFactory'; 16 | export { SkillBuilders } from './skill/SkillBuilders'; 17 | 18 | export { 19 | AttributesManager, 20 | AttributesManagerFactory, 21 | BaseSkillBuilder, 22 | BaseSkillFactory, 23 | LambdaHandler, 24 | createAskSdkError, 25 | CustomSkillBuilder, 26 | CustomSkillFactory, 27 | DefaultApiClient, 28 | ErrorHandler, 29 | escapeXmlCharacters, 30 | getAccountLinkingAccessToken, 31 | getApiAccessToken, 32 | getDeviceId, 33 | getUserId, 34 | getDialogState, 35 | getIntentName, 36 | getLocale, 37 | getRequest, 38 | getRequestType, 39 | getSlot, 40 | getSlotValue, 41 | getSupportedInterfaces, 42 | getViewportDpiGroup, 43 | getViewportOrientation, 44 | getViewportProfile, 45 | getViewportSizeGroup, 46 | HandlerInput, 47 | ImageHelper, 48 | isNewSession, 49 | PersistenceAdapter, 50 | PlainTextContentHelper, 51 | RequestHandler, 52 | RequestInterceptor, 53 | ResponseBuilder, 54 | ResponseFactory, 55 | ResponseInterceptor, 56 | RichTextContentHelper, 57 | Skill, 58 | SkillConfiguration, 59 | TextContentHelper, 60 | ViewportDpiGroup, 61 | ViewportDpiGroupOrder, 62 | ViewportOrientation, 63 | ViewportProfile, 64 | ViewportSizeGroup, 65 | ViewportSizeGroupOrder 66 | } from 'ask-sdk-core'; 67 | 68 | export { 69 | DynamoDbPersistenceAdapter, 70 | PartitionKeyGenerator, 71 | PartitionKeyGenerators 72 | } from 'ask-sdk-dynamodb-persistence-adapter'; 73 | -------------------------------------------------------------------------------- /ask-sdk/lib/skill/SkillBuilders.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { 15 | CustomSkillBuilder, 16 | SkillBuilders as BaseSkillBuilders 17 | } from 'ask-sdk-core'; 18 | import { StandardSkillBuilder } from './factory/StandardSkillBuilder'; 19 | import { StandardSkillFactory } from './factory/StandardSkillFactory'; 20 | 21 | /** 22 | * Provider for skill builder. 23 | */ 24 | export const SkillBuilders = { 25 | ...BaseSkillBuilders, 26 | standard(): StandardSkillBuilder { 27 | return StandardSkillFactory.init(); 28 | }, 29 | }; 30 | -------------------------------------------------------------------------------- /ask-sdk/lib/skill/factory/StandardSkillBuilder.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { BaseSkillBuilder } from 'ask-sdk-core'; 15 | import { PartitionKeyGenerator } from 'ask-sdk-dynamodb-persistence-adapter'; 16 | import { DynamoDB } from 'aws-sdk'; 17 | 18 | /** 19 | * An interface containing help functions to build a {@link CustomSkill} with dynamoDB configuration options. 20 | */ 21 | export interface StandardSkillBuilder extends BaseSkillBuilder { 22 | withTableName(tableName: string): this; 23 | withAutoCreateTable(autoCreateTable: boolean): this; 24 | withPartitionKeyGenerator(partitionKeyGenerator: PartitionKeyGenerator): this; 25 | withDynamoDbClient(customDynamoDBClient: DynamoDB): this; 26 | } 27 | -------------------------------------------------------------------------------- /ask-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-sdk", 3 | "version": "2.14.0", 4 | "description": "Standard distribution package for Alexa Skills Kit SDK", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [ 17 | { 18 | "name": "Tianren Zhang", 19 | "email": "tianrenz@amazon.com" 20 | }, 21 | { 22 | "name": "Tiantian Xie", 23 | "email": "xtiantia@amazon.com" 24 | } 25 | ], 26 | "license": "Apache-2.0", 27 | "keywords": [ 28 | "Alexa", 29 | "SDK" 30 | ], 31 | "dependencies": { 32 | "ask-sdk-core": "^2.14.0", 33 | "ask-sdk-dynamodb-persistence-adapter": "^2.14.0", 34 | "ask-sdk-model": "^1.29.0" 35 | }, 36 | "devDependencies": { 37 | "@types/chai": "^4.1.2", 38 | "@types/mocha": "^5.0.0", 39 | "@types/node": "^16.11.1", 40 | "@typescript-eslint/eslint-plugin": "^3.9.0", 41 | "@typescript-eslint/parser": "^3.9.0", 42 | "chai": "^4.1.2", 43 | "cross-env": "^7.0.2", 44 | "eslint": "^7.6.0", 45 | "eslint-plugin-tsdoc": "^0.2.6", 46 | "mocha": "^5.0.5", 47 | "nyc": "^14.1.1", 48 | "ts-node": "^6.0.1", 49 | "typescript": "^4.9.5" 50 | }, 51 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 52 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 53 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 54 | } 55 | -------------------------------------------------------------------------------- /ask-sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-sdk/tst/skill/SkillBuilders.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { SkillBuilders } from '../../lib/skill/SkillBuilders'; 16 | 17 | describe('SkillBuilders', () => { 18 | it('should be able to return CustomSkillBuilder', () => { 19 | const skillBuilder = SkillBuilders.custom(); 20 | 21 | expect('withPersistenceAdapter' in skillBuilder).equal(true); 22 | expect('withApiClient' in skillBuilder).equal(true); 23 | expect('withTableName' in skillBuilder).equal(false); 24 | expect('withPartitionKeyGenerator' in skillBuilder).equal(false); 25 | expect('withDynamoDbClient' in skillBuilder).equal(false); 26 | }); 27 | 28 | it('should be able to return StandardSkillBuilder', () => { 29 | const skillBuilder = SkillBuilders.standard(); 30 | 31 | expect('withPersistenceAdapter' in skillBuilder).equal(false); 32 | expect('withApiClient' in skillBuilder).equal(false); 33 | expect('withTableName' in skillBuilder).equal(true); 34 | expect('withPartitionKeyGenerator' in skillBuilder).equal(true); 35 | expect('withDynamoDbClient' in skillBuilder).equal(true); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /ask-sdk/tst/skill/factory/StandardSkillFactory.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { DefaultApiClient } from 'ask-sdk-core'; 15 | import { 16 | DynamoDbPersistenceAdapter, 17 | PartitionKeyGenerators 18 | } from 'ask-sdk-dynamodb-persistence-adapter'; 19 | import { DynamoDB } from 'aws-sdk'; 20 | import { expect } from 'chai'; 21 | import { StandardSkillFactory } from '../../../lib/skill/factory/StandardSkillFactory'; 22 | 23 | describe('StandardSkillFactory', () => { 24 | it('should be able to add DefaultApiClient', () => { 25 | const skillConfig = StandardSkillFactory.init().getSkillConfiguration(); 26 | 27 | expect(skillConfig.apiClient).instanceOf(DefaultApiClient); 28 | }); 29 | 30 | it('should be able to add DynamoDbPersistenceAdapter with table name', () => { 31 | const skillConfig = StandardSkillFactory.init() 32 | .withTableName('testTable') 33 | .getSkillConfiguration(); 34 | 35 | expect(skillConfig.persistenceAdapter).instanceOf(DynamoDbPersistenceAdapter); 36 | }); 37 | 38 | it('should be able to add DynamoDbPersistenceAdapter with customization', () => { 39 | const skillConfig = StandardSkillFactory.init() 40 | .withTableName('testTable') 41 | .withAutoCreateTable(false) 42 | .withDynamoDbClient(new DynamoDB({apiVersion : 'latest'})) 43 | .withPartitionKeyGenerator(PartitionKeyGenerators.userId) 44 | .getSkillConfiguration(); 45 | 46 | expect(skillConfig.persistenceAdapter).instanceOf(DynamoDbPersistenceAdapter); 47 | }); 48 | }); 49 | -------------------------------------------------------------------------------- /ask-sdk/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-smapi-sdk/.gitignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | dist/ 3 | doc/ 4 | node_modules/ 5 | package-lock.json 6 | .DS_Store 7 | build 8 | -------------------------------------------------------------------------------- /ask-smapi-sdk/.npmignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | doc/ 3 | lib/ 4 | node_modules/ 5 | tst/ 6 | package-lock.json 7 | tsconfig.json 8 | .eslintrc.json 9 | -------------------------------------------------------------------------------- /ask-smapi-sdk/NOTICE.txt: -------------------------------------------------------------------------------- 1 | ASK SMAPI SDK for Node.js 2 | Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | -------------------------------------------------------------------------------- /ask-smapi-sdk/lib/index.ts: -------------------------------------------------------------------------------- 1 | export { SmapiClientBuilder } from './smapiClientBuilder/AbstractSmapiClientBuilder'; 2 | export { StandardSmapiClientBuilder, CustomSmapiClientBuilder } from './smapiClientBuilder/SmapiClientBuilder'; 3 | export { getValueFromHeader } from './util/Util'; 4 | export { RefreshTokenConfig } from './smapiClientBuilder/authMethods/AuthMethods'; 5 | export { ModelIntrospector, CustomizationProcessor, ApiOperation, TypeDefinition, ApiParameter } from './util/ModelIntrospector'; 6 | -------------------------------------------------------------------------------- /ask-smapi-sdk/lib/smapiClientBuilder/authMethods/AuthMethods.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export interface RefreshTokenConfig { 15 | clientId: string; 16 | clientSecret: string; 17 | refreshToken: string; 18 | } 19 | 20 | export interface AccessTokenConfig { 21 | clientId: string; 22 | clientSecret: string; 23 | accessToken: string; 24 | } 25 | -------------------------------------------------------------------------------- /ask-smapi-sdk/lib/util/Util.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | export declare type Header = Array<{ 15 | key: string; 16 | value: string; 17 | }>; 18 | 19 | export function getValueFromHeader(header: Header, key: string): string[] { 20 | const result: string[] = []; 21 | if (!header || !key) { 22 | return result; 23 | } 24 | header.forEach((object) => { 25 | if (object.key === key) { 26 | result.push(object.value); 27 | } 28 | }); 29 | 30 | return result; 31 | } 32 | -------------------------------------------------------------------------------- /ask-smapi-sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ask-smapi-sdk", 3 | "version": "1.3.0", 4 | "description": "Core package for SMAPI Skills Kit SDK", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc && npm run lint", 9 | "compile": "tsc", 10 | "test": "cross-env TS_NODE_FILES=true mocha -r ts-node/register \"./tst/**/*.spec.ts\"", 11 | "lint": "eslint \"lib/**/*.{ts,tsx}\" \"tst/**/*.{ts,tsx}\"", 12 | "clean": "rm -rf ./dist", 13 | "reinstall": "rm -rf ./node_modules && npm install" 14 | }, 15 | "author": "Amazon.com", 16 | "contributors": [], 17 | "license": "Apache-2.0", 18 | "keywords": [ 19 | "Alexa", 20 | "SMAPI", 21 | "SDK" 22 | ], 23 | "dependencies": { 24 | "ask-smapi-model": "^1.4.0" 25 | }, 26 | "devDependencies": { 27 | "@types/chai": "^4.1.2", 28 | "@types/jsonpath": "^0.2.0", 29 | "@types/mocha": "^5.0.0", 30 | "@types/node": "^16.11.1", 31 | "@types/sinon": "^4.3.0", 32 | "@typescript-eslint/eslint-plugin": "^3.9.0", 33 | "@typescript-eslint/parser": "^3.9.0", 34 | "chai": "^4.1.2", 35 | "cross-env": "^7.0.2", 36 | "eslint": "^7.6.0", 37 | "eslint-plugin-tsdoc": "^0.2.6", 38 | "mocha": "^5.0.5", 39 | "nock": "^9.2.3", 40 | "nyc": "^13.0.1", 41 | "sinon": "^4.5.0", 42 | "ts-node": "^6.0.1", 43 | "typescript": "^3.7.3" 44 | }, 45 | "repository": "github:alexa/alexa-skills-kit-sdk-for-nodejs", 46 | "bugs": "https://github.com/alexa/alexa-skill-sdk-for-nodejs/issues", 47 | "homepage": "https://github.com/alexa/alexa-skill-sdk-for-nodejs#readme" 48 | } 49 | -------------------------------------------------------------------------------- /ask-smapi-sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "./lib", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | }, 13 | "include": [ 14 | "lib" 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /ask-smapi-sdk/tst/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2017", 4 | "module": "commonjs", 5 | "moduleResolution": "node", 6 | "rootDir": "../", 7 | "outDir" : "dist", 8 | "sourceMap" : true, 9 | "alwaysStrict" : true, 10 | "declaration" : true, 11 | "lib": [] 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ask-smapi-sdk/tst/util/Util.spec.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"). 4 | * You may not use this file except in compliance with the License. 5 | * A copy of the License is located at 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * or in the "license" file accompanying this file. This file is distributed 9 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 10 | * express or implied. See the License for the specific language governing 11 | * permissions and limitations under the License. 12 | */ 13 | 14 | import { expect } from 'chai'; 15 | import { getValueFromHeader } from '../../lib/util/Util'; 16 | 17 | describe('getValueFromHeaderByKeyName', () => { 18 | const MockHeader = [ 19 | {key:"content-type", value:"application/json"}, 20 | {key:"content-length", value:"44"}, 21 | {key:"connection", value:"close"}, 22 | {key:"server", value:"Server1"}, 23 | {key:"server", value:"Server2"}, 24 | {key:"date", value:"Wed, 27 Nov 2019 00:33:32 GMT"}, 25 | {key:"x-amzn-requestid", value:"fakeId"}, 26 | {key:"x-amz-date", value:"Wed, 27 Nov 2019 00:33:32 GMT"}, 27 | {key:"x-amz-rid", value:"T5XCCNVZEVJFYHZ6A648"}, 28 | {key:"vary", value:"Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent"}, 29 | {key:"x-cache", value:"Miss from cloudfront"}, 30 | {key:"via", value:"1.1 490c6b39f412c738a30c226f07db749c.cloudfront.net (CloudFront)"}, 31 | {key:"x-amz-cf-pop", value:"HIO51-C1"}, 32 | {key:"x-amz-cf-id", value:"rf53XdWct4udipVWarUytHSqb_ZXS8DA2byAOILCN5ESD65XEUcCvw=="} 33 | ]; 34 | 35 | it('should be able to find value by valid key', () => { 36 | expect(getValueFromHeader(MockHeader, 'x-amzn-requestid')).deep.equal(['fakeId']); 37 | }); 38 | 39 | it('should be able to find multiple value share the same key name', () => { 40 | expect(getValueFromHeader(MockHeader, 'server')).deep.equal(['Server1', 'Server2']); 41 | }); 42 | 43 | it('should return null when key not exist in header', () => { 44 | expect(getValueFromHeader(MockHeader, 'notExistKey')).deep.equal([]); 45 | }); 46 | 47 | it('should return empty array when header or key is null', () => { 48 | expect(getValueFromHeader(null, 'notExistKey')).deep.equal([]); 49 | expect(getValueFromHeader(MockHeader, null)).deep.equal([]); 50 | }); 51 | }); 52 | -------------------------------------------------------------------------------- /docs/en/README.md: -------------------------------------------------------------------------------- 1 | Alexa Skills Kit SDK for Node JS 2 | =============================== 3 | 4 | The **ASK SDK for Node JS** makes it easier for you to build highly engaging skills, 5 | by allowing you to spend more time on implementing features and less on writing boiler-plate code. 6 | 7 | You can find the latest documentation about the SDK [here](https://developer.amazon.com/docs/alexa-skills-kit-sdk-for-nodejs/overview.html). 8 | -------------------------------------------------------------------------------- /docs/ja/ASK-SDK-Utilities.rst: -------------------------------------------------------------------------------- 1 | ***************** 2 | ユーティリティ 3 | ***************** 4 | 5 | The SDK provides mutiple utility functions that aims to reduce boilerplate code so that you can focus on skill business logic. 6 | 7 | RequestEnvelopeUtils 8 | ==================== 9 | 10 | The ``RequestEnvelopeUtils`` provides functions for getting frequently used attributes from the ``RequestEnvelope`` with error checking logic. 11 | 12 | Available Methods 13 | ----------------- 14 | 15 | .. code-block:: typescript 16 | 17 | getLocale(requestEnvelope: RequestEnvelope): string; 18 | getRequestType(requestEnvelope: RequestEnvelope): string; 19 | getIntentName(requestEnvelope: RequestEnvelope): string; 20 | getAccountLinkingAccessToken(requestEnvelope: RequestEnvelope): string; 21 | getApiAccessToken(requestEnvelope: RequestEnvelope): string; 22 | getDeviceId(requestEnvelope: RequestEnvelope): string; 23 | getDialogState(requestEnvelope: RequestEnvelope): string; 24 | getSlot(requestEnvelope: RequestEnvelope, slotName: string): Slot; 25 | getSlotValue(requestEnvelope: RequestEnvelope, slotName: string): string; 26 | getSupportedInterfaces(requestEnvelope: RequestEnvelope): SupportedInterfaces; 27 | isNewSession(requestEnvelope: RequestEnvelope): boolean; 28 | 29 | SsmlUtils 30 | ========= 31 | 32 | The ``SsmlUtils`` provides a function for escaping invalid SSML characters in a speech string. 33 | 34 | Available Methods 35 | ----------------- 36 | 37 | .. code-block:: typescript 38 | 39 | escapeXmlCharacters(input: string): string 40 | 41 | ViewportUtils 42 | ============= 43 | 44 | The ``ViewportUtils`` provides functions for checking the viewport profile and other device characteristics such as display size or dpi in the ``RequestEnvelope``. 45 | 46 | Available Methods 47 | ----------------- 48 | 49 | .. code-block:: typescript 50 | 51 | getViewportOrientation(width: number, height: number): ViewportOrientation; 52 | getViewportSizeGroup(size: number): ViewportSizeGroup; 53 | getViewportDpiGroup(dpi: number): ViewportDpiGroup; 54 | getViewportProfile(requestEnvelope: RequestEnvelope): ViewportProfile; -------------------------------------------------------------------------------- /docs/ja/Setting-Up-The-ASK-SDK.rst: -------------------------------------------------------------------------------- 1 | ********************** 2 | ASK SDKのセットアップ 3 | ********************** 4 | 5 | このガイドでは、プロジェクトでASK SDK v2 for Node.jsを使用する方法を説明します。 6 | 7 | 前提条件 8 | ============= 9 | 10 | - `NPM `__\ プロジェクト。 11 | - 適切なNode.js開発環境。ASK SDK v2 for Node.jsには、Node 4.3.2以上が必要です。 12 | 13 | ASK SDKをプロジェクトに追加する 14 | ================================== 15 | 16 | プロジェクトでASK SDK v2 for Node.jsを使うには、NPMモジュールとしてSDKをインストールする必要があります。標準SDK配布パッケージ、SDKのコアモジュールといずれかのアドオンパッケージを選択してインストールします。すぐにセットアップして実行するには、標準SDK配布パッケージを選ぶのがもっとも簡単です。標準SDK配布パッケージには、SDKのコアモジュール、モデルパッケージ、DynamoDBにスキルのアトリビュートを格納できるようにするAmazon DynamoDB永続アダプターが含まれます。 17 | 18 | 標準ASK SDK配布パッケージをインストールする 19 | ------------------------------------------- 20 | 21 | NPMプロジェクトから、以下のコマンドを実行して標準ASK SDK v2 for 22 | Node.js配布パッケージをインストールします。 23 | 24 | :: 25 | 26 | npm install --save ask-sdk 27 | 28 | コアSDKモジュールのみをインストールする 29 | ------------------------------------------- 30 | 31 | ``ask-sdk``\ モジュールすべてを使う必要がない場合、コアモジュールのみをインストールし、後からアドオンパッケージを個別に追加できます。NPMプロジェクトから、以下のコマンドを実行してコアASK 32 | SDK v2 for Node.js配布パッケージをインストールします。 33 | 34 | **モデル(ask-sdk-coreのpeer依存関係として必要)** 35 | 36 | :: 37 | 38 | npm install --save ask-sdk-model 39 | 40 | **コアSDK** 41 | 42 | :: 43 | 44 | npm install --save ask-sdk-core 45 | 46 | アドオンのASK SDKモジュールのインストール 47 | ------------------------------------------- 48 | 49 | アドオンパッケージをインストールすると、\ ``PersistenceAdapter``\ などのSDK機能が実装されます。スキルの機能を拡張するには、必要に応じてモジュールを選んでコアSDKモジュールに追加インストールできます。 50 | 51 | **Amazon DynamoDB永続アダプター** 52 | 53 | :: 54 | 55 | npm install --save ask-sdk-dynamodb-persistence-adapter 56 | 57 | **Amazon S3永続アダプター** 58 | 59 | :: 60 | 61 | npm install --save ask-sdk-s3-persistence-adapter 62 | 63 | 次のステップ 64 | ==================== 65 | 66 | プロジェクトにSDKを追加したら、スキルの開発を開始できます。次の\ `初めてのスキル開発 `__\ セクションに進み、基本のスキル開発の手順をご覧ください。 67 | -------------------------------------------------------------------------------- /docs/ja/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx_tabs -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.14.0", 3 | "packages": [ 4 | "ask-sdk", 5 | "ask-sdk-core", 6 | "ask-sdk-dynamodb-persistence-adapter", 7 | "ask-sdk-runtime", 8 | "ask-sdk-s3-persistence-adapter", 9 | "ask-sdk-v1adapter", 10 | "ask-sdk-express-adapter" 11 | ], 12 | "command": { 13 | "bootstrap": { 14 | "npmClientArgs": [ 15 | "--no-package-lock" 16 | ], 17 | "ci": false 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "lerna": "./node_modules/.bin/lerna", 5 | "setup": "lerna exec npm install", 6 | "bootstrap": "lerna bootstrap --force-local --hoist --nohoist=ts-node", 7 | "build": "lerna exec npm run build", 8 | "test": "lerna exec npm run test", 9 | "docs": "rm -rf ./alexa-sdk-node-typedoc && ./node_modules/.bin/typedoc --out alexa-sdk-node-typedoc" 10 | }, 11 | "devDependencies": { 12 | "@commitlint/cli": "^9.1.2", 13 | "@commitlint/config-conventional": "^9.1.2", 14 | "husky": "^4.2.5", 15 | "lerna": "^3.16.4", 16 | "typedoc": "^0.17.8", 17 | "typescript": "^3.9.5" 18 | }, 19 | "husky": { 20 | "hooks": { 21 | "commit-msg": "commitlint -E HUSKY_GIT_PARAMS" 22 | } 23 | }, 24 | "name": "alexa-skills-kit-sdk-for-nodejs" 25 | } 26 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions" : { 3 | "target" : "es5", 4 | "module" : "commonjs", 5 | "moduleResolution": "node", 6 | "outDir" : "dist", 7 | "sourceMap" : true, 8 | "alwaysStrict" : true, 9 | "declaration" : true, 10 | "lib": [ 11 | "es2017", 12 | "dom" 13 | ] 14 | }, 15 | "include" : [ 16 | "ask-sdk/lib", 17 | "ask-sdk-core/lib", 18 | "ask-sdk-dynamodb-persistence-adapter/lib", 19 | "ask-sdk-runtime/lib", 20 | "ask-sdk-s3-persistence-adapter/lib", 21 | "ask-sdk-v1adapter/lib", 22 | "ask-sdk-express-adapter/lib", 23 | "ask-smapi-sdk/lib" 24 | ], 25 | "exclude" : [ 26 | "node_modules" 27 | ], 28 | "typedocOptions": { 29 | "name" : "ASK SDK for Node.js", 30 | "readme" : "none", 31 | "mode": "file", 32 | "out": "typedoc", 33 | "theme": "default", 34 | "excludeExternals" : true, 35 | "hideGenerator" : true, 36 | "target": "ES6", 37 | "module": "commonjs" 38 | } 39 | } 40 | --------------------------------------------------------------------------------