-
Notifications
You must be signed in to change notification settings - Fork 126
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
feat: Add serverless configuration TS typings #297
base: master
Are you sure you want to change the base?
Conversation
*/ | ||
[k: string]: { | ||
name?: string; | ||
events?: ( |
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.
I know this was auto generated, but this library throws when events
is not present.
Error: Missing "events" property for function "X". Your function needs at least one "event". Please check the docs for more info.
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.
Got the source:
serverless-google-cloudfunctions/shared/validate.js
Lines 55 to 63 in b1cdaf2
validateEventsProperty(funcObject, functionName, supportedEvents = ['http', 'event']) { | |
if (!funcObject.events || funcObject.events.length === 0) { | |
const errorMessage = [ | |
`Missing "events" property for function "${functionName}".`, | |
' Your function needs at least one "event".', | |
' Please check the docs for more info.', | |
].join(''); | |
throw new Error(errorMessage); | |
} |
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.
Good catch! Perhaps these keys should also be added as required in the JSON schema https://github.com/serverless/serverless-google-cloudfunctions/blob/master/provider/googleProvider.js#L151
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.
I agree.
Haven't seen much in the way of maintenance on this repo lately. Hopefully this can get some attention and get in there.
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.
It seems adding event's causes a runtime error. Pretty strange though, as many of the other properties should also fall under this boat:
events: {
type: 'string',
items: { $ref: '#/definitions/cloudFunctionEvent' },
},
The type of cloudFunctionEvent
nor the events
key doesn't seem to matter. Even string
threw this error.
Property 'functions[].events' already have a definition - this property might have already been defined by the Serverless framework or one other plugin
Love this, having the types for the AWS version is really helpful. |
These are generated from the provider JSON schema using the plugin used to generate the AWS Serverless config typings: https://github.com/serverless/typescript
Usage:
A future PR may add this process to the CI workflow so any provider JSON schema changes are automatically captured in changes to the TypeScript .d.ts file, as is done in
@serverless/typescript