-
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
Open
ericrav
wants to merge
1
commit into
serverless:master
Choose a base branch
from
ericrav:types
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/** | ||
* This file was automatically generated by json-schema-to-typescript. | ||
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, | ||
* and run json-schema-to-typescript to regenerate this file. | ||
*/ | ||
|
||
export type ErrorCode = string; | ||
export type CloudFunctionRuntime = | ||
| 'nodejs6' | ||
| 'nodejs8' | ||
| 'nodejs10' | ||
| 'nodejs12' | ||
| 'nodejs14' | ||
| 'nodejs16' | ||
| 'python37' | ||
| 'python38' | ||
| 'python39' | ||
| 'go111' | ||
| 'go113' | ||
| 'go116' | ||
| 'java11' | ||
| 'dotnet3' | ||
| 'ruby26' | ||
| 'ruby27'; | ||
export type CloudFunctionMemory = 128 | 256 | 512 | 1024 | 2048 | 4096; | ||
export type CloudFunctionVpcEgress = 'ALL' | 'ALL_TRAFFIC' | 'PRIVATE' | 'PRIVATE_RANGES_ONLY'; | ||
export type CloudFunctionRegion = | ||
| 'us-central1' | ||
| 'us-east1' | ||
| 'us-east4' | ||
| 'europe-west1' | ||
| 'europe-west2' | ||
| 'asia-east1' | ||
| 'asia-east2' | ||
| 'asia-northeast1' | ||
| 'asia-northeast2' | ||
| 'us-west2' | ||
| 'us-west3' | ||
| 'us-west4' | ||
| 'northamerica-northeast1' | ||
| 'southamerica-east1' | ||
| 'europe-west3' | ||
| 'europe-west6' | ||
| 'europe-central2' | ||
| 'australia-southeast1' | ||
| 'asia-south1' | ||
| 'asia-southeast1' | ||
| 'asia-southeast2' | ||
| 'asia-northeast3'; | ||
export type ServiceName = string; | ||
|
||
export interface GCP { | ||
configValidationMode?: 'error' | 'warn' | 'off'; | ||
console?: | ||
| boolean | ||
| { | ||
monitoring?: { | ||
logs?: { | ||
disabled?: boolean; | ||
}; | ||
request?: { | ||
disabled?: boolean; | ||
}; | ||
response?: { | ||
disabled?: boolean; | ||
}; | ||
}; | ||
org?: string; | ||
}; | ||
custom?: { | ||
[k: string]: unknown; | ||
}; | ||
dashboard?: { | ||
disableMonitoring?: boolean; | ||
}; | ||
deprecationNotificationMode?: 'error' | 'warn' | 'warn:summary'; | ||
disabledDeprecations?: '*' | ErrorCode[]; | ||
frameworkVersion?: string; | ||
functions?: { | ||
/** | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` "^[a-zA-Z0-9-_]+$". | ||
*/ | ||
[k: string]: { | ||
name?: string; | ||
events?: ( | ||
| { | ||
__schemaWorkaround__: null; | ||
} | ||
| { | ||
http: string; | ||
} | ||
| { | ||
event: { | ||
eventType: string; | ||
path?: string; | ||
resource: string; | ||
failurePolicy?: { | ||
retry?: { | ||
[k: string]: unknown; | ||
}; | ||
}; | ||
}; | ||
} | ||
)[]; | ||
handler?: string; | ||
runtime?: CloudFunctionRuntime; | ||
serviceAccountEmail?: string; | ||
memorySize?: CloudFunctionMemory; | ||
timeout?: string; | ||
minInstances?: number; | ||
environment?: CloudFunctionEnvironmentVariables; | ||
secrets?: CloudFunctionSecretEnvironmentVariables; | ||
vpc?: string; | ||
vpcEgress?: CloudFunctionVpcEgress; | ||
labels?: ResourceManagerLabels; | ||
}; | ||
}; | ||
package?: { | ||
artifact?: string; | ||
exclude?: string[]; | ||
excludeDevDependencies?: boolean; | ||
include?: string[]; | ||
individually?: boolean; | ||
path?: string; | ||
patterns?: string[]; | ||
}; | ||
params?: { | ||
/** | ||
* This interface was referenced by `undefined`'s JSON-Schema definition | ||
* via the `patternProperty` "^[a-zA-Z0-9-]+$". | ||
*/ | ||
[k: string]: { | ||
[k: string]: unknown; | ||
}; | ||
}; | ||
plugins?: | ||
| { | ||
localPath?: string; | ||
modules: string[]; | ||
} | ||
| string[]; | ||
projectDir?: string; | ||
provider: { | ||
name: 'google'; | ||
credentials?: string; | ||
project?: string; | ||
region?: CloudFunctionRegion; | ||
runtime?: CloudFunctionRuntime; | ||
serviceAccountEmail?: string; | ||
memorySize?: CloudFunctionMemory; | ||
timeout?: string; | ||
environment?: CloudFunctionEnvironmentVariables; | ||
secrets?: CloudFunctionSecretEnvironmentVariables; | ||
vpc?: string; | ||
vpcEgress?: CloudFunctionVpcEgress; | ||
labels?: ResourceManagerLabels; | ||
stage?: string; | ||
}; | ||
service: ServiceName; | ||
useDotenv?: true; | ||
variablesResolutionMode?: '20210219' | '20210326'; | ||
} | ||
export interface CloudFunctionEnvironmentVariables { | ||
/** | ||
* This interface was referenced by `CloudFunctionEnvironmentVariables`'s JSON-Schema definition | ||
* via the `patternProperty` "^.*$". | ||
*/ | ||
[k: string]: string; | ||
} | ||
export interface CloudFunctionSecretEnvironmentVariables { | ||
/** | ||
* This interface was referenced by `CloudFunctionSecretEnvironmentVariables`'s JSON-Schema definition | ||
* via the `patternProperty` "^[a-zA-Z0-9_]+$". | ||
*/ | ||
[k: string]: { | ||
projectId?: string; | ||
secret: string; | ||
version: string; | ||
[k: string]: unknown; | ||
}; | ||
} | ||
export interface ResourceManagerLabels { | ||
/** | ||
* This interface was referenced by `ResourceManagerLabels`'s JSON-Schema definition | ||
* via the `patternProperty` "^[a-z][a-z0-9_.]*$". | ||
*/ | ||
[k: string]: string; | ||
} |
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.
I know this was auto generated, but this library throws when
events
is not present.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
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:
The type of
cloudFunctionEvent
nor theevents
key doesn't seem to matter. Evenstring
threw this error.