New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alexa smart home event schema #8255
Merged
medikoo
merged 4 commits into
serverless:master
from
thewizarodofoz:aws-alexaSmartHome-event-schema
Sep 24, 2020
Merged
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,9 +11,25 @@ class AwsCompileAlexaSmartHomeEvents { | |
'package:compileEvents': this.compileAlexaSmartHomeEvents.bind(this), | ||
}; | ||
|
||
// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8024 | ||
const appIdSchema = { | ||
type: 'string', | ||
minLength: 0, | ||
maxLength: 256, | ||
pattern: '^[a-zA-Z0-9._\\-]+$', | ||
}; | ||
|
||
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'alexaSmartHome', { | ||
anyOf: [{ type: 'string' }, { type: 'object' }], | ||
anyOf: [ | ||
appIdSchema, | ||
{ | ||
type: 'object', | ||
properties: { | ||
appId: appIdSchema, | ||
enabled: { type: 'boolean' }, | ||
}, | ||
required: ['appId'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We miss |
||
}, | ||
], | ||
}); | ||
} | ||
|
||
|
@@ -30,15 +46,6 @@ class AwsCompileAlexaSmartHomeEvents { | |
let Action; | ||
|
||
if (typeof event.alexaSmartHome === 'object') { | ||
if (!event.alexaSmartHome.appId) { | ||
const errorMessage = [ | ||
`Missing "appId" property for alexaSmartHome event in function ${functionName}`, | ||
' The correct syntax is: appId: amzn1.ask.skill.xxxx-xxxx', | ||
' OR an object with "appId" property.', | ||
' Please check the docs for more info.', | ||
].join(''); | ||
throw new this.serverless.classes.Error(errorMessage); | ||
} | ||
EventSourceToken = event.alexaSmartHome.appId; | ||
Action = | ||
event.alexaSmartHome.enabled !== false | ||
|
@@ -47,13 +54,6 @@ class AwsCompileAlexaSmartHomeEvents { | |
} else if (typeof event.alexaSmartHome === 'string') { | ||
EventSourceToken = event.alexaSmartHome; | ||
Action = 'lambda:InvokeFunction'; | ||
} else { | ||
const errorMessage = [ | ||
`Alexa Smart Home event of function "${functionName}" is not an object or string.`, | ||
' The correct syntax is: alexaSmartHome.', | ||
' Please check the docs for more info.', | ||
].join(''); | ||
throw new this.serverless.classes.Error(errorMessage); | ||
} | ||
const lambdaLogicalId = this.provider.naming.getLambdaLogicalId(functionName); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it'll be good to define
awsAlexaEventToken
atserverless/lib/plugins/aws/provider/awsProvider.js
Line 143 in d070986
Especially that it looks we will need same reference in
alexaSkill
event