/
configSchema.js
148 lines (144 loc) · 4.27 KB
/
configSchema.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
'use strict';
const functionNamePattern = '^[a-zA-Z0-9-_]+$';
const stagePattern = '^[a-zA-Z0-9-]+$';
const schema = {
type: 'object',
properties: {
/*
* Modes for config validation:
* - error: the error is thrown
* - warn: logs error to console without throwing an error
* - off: disables validation at all
*
* The default is `warn`, and will be set to `error` in v2
*/
configValidationMode: { enum: ['error', 'warn', 'off'] },
custom: {
type: 'object',
properties: {},
required: [],
// User is free to add any properties for its own purpose
},
deprecationNotificationMode: {
enum: ['error', 'warn', 'warn:summary'],
},
disabledDeprecations: {
anyOf: [
{ const: '*' },
{
type: 'array',
items: { $ref: '#/definitions/errorCode' },
},
],
},
enableLocalInstallationFallback: { type: 'boolean' },
frameworkVersion: { type: 'string' },
functions: {
type: 'object',
patternProperties: {
[functionNamePattern]: {
type: 'object',
properties: {
name: { type: 'string' }, // name property is added by service class
events: {
type: 'array',
items: {
/*
* `anyOf` array by JSON schema spec cannot be empty, threfore we start
* with one dummy item as workaround to ensure it validates against
* any undefined function events.
*/
anyOf: [
{
type: 'object',
properties: { __schemaWorkaround__: { const: null } },
required: ['__schemaWorkaround__'],
additionalProperties: false,
},
],
},
},
},
/*
* Schema for function properties is extended by a provider plugin.
* For example, in the context of AWS provider props like
* provisionedConcurrency, memorySize, reservedConcurrency, etc.
* should be extended by awsProvider plugin.
*/
additionalProperties: false,
},
},
additionalProperties: false,
},
package: {
type: 'object',
properties: {
artifact: { type: 'string' },
exclude: { type: 'array', items: { type: 'string' } },
excludeDevDependencies: { type: 'boolean' },
include: { type: 'array', items: { type: 'string' } },
individually: { type: 'boolean' },
path: { type: 'string' },
patterns: { type: 'array', items: { type: 'string' } },
},
additionalProperties: false,
},
params: {
type: 'object',
patternProperties: {
[stagePattern]: {
type: 'object',
},
},
additionalProperties: false,
},
plugins: {
anyOf: [
{
type: 'object',
properties: {
localPath: { type: 'string' },
modules: { type: 'array', items: { type: 'string' } },
},
additionalProperties: false,
required: ['modules'],
},
{ type: 'array', items: { type: 'string' } },
],
},
projectDir: {
type: 'string',
pattern: '^(\\.\\/?|(\\.\\/)?\\.\\.(\\/\\.\\.)*\\/?)$',
},
/*
* Provider specific properties are extended in respected provider plugins.
*/
provider: {
type: 'object',
properties: {
// "name" is configured as const by loaded provider
},
required: ['name'],
additionalProperties: false,
},
service: { $ref: '#/definitions/serviceName' },
unresolvedVariablesNotificationMode: { enum: ['error', 'warn'] },
useDotenv: { const: true },
variablesResolutionMode: { type: 'string', enum: ['20210219', '20210326'] },
},
additionalProperties: false,
required: ['provider', 'service'],
definitions: {
errorCode: {
type: 'string',
pattern: '^[A-Z0-9_]+$',
},
functionName: {
type: 'string',
pattern: functionNamePattern,
},
serviceName: { type: 'string', pattern: '^[a-zA-Z][0-9a-zA-Z-]+$' },
stage: { type: 'string', pattern: stagePattern },
},
};
module.exports = schema;