|
11 | 11 | */
|
12 | 12 | const parsers = require('../src/Options/parsers');
|
13 | 13 |
|
| 14 | +// The types of nested options. |
| 15 | +const nestedOptionTypes = [ |
| 16 | + 'Object', |
| 17 | + 'PasswordPolicyOptions', |
| 18 | + 'IdempotencyOptions', |
| 19 | + 'FileUploadOptions', |
| 20 | + 'CustomPagesOptions', |
| 21 | + 'PagesCustomUrlsOptions', |
| 22 | + 'PagesOptions' |
| 23 | +]; |
| 24 | + |
| 25 | +// The prefix of environment variables for nested options. |
| 26 | +const nestedOptionEnvPrefix = { |
| 27 | + 'ParseServerOptions' : 'PARSE_SERVER_', |
| 28 | + 'PagesOptions' : 'PARSE_SERVER_PAGES_', |
| 29 | + 'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_', |
| 30 | + 'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_', |
| 31 | + 'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_', |
| 32 | + 'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_', |
| 33 | + 'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_', |
| 34 | + 'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_', |
| 35 | + 'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_', |
| 36 | + 'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_', |
| 37 | +} |
| 38 | + |
14 | 39 | function last(array) {
|
15 | 40 | return array[array.length - 1];
|
16 | 41 | }
|
@@ -40,20 +65,8 @@ function getCommentValue(comment) {
|
40 | 65 | }
|
41 | 66 |
|
42 | 67 | function getENVPrefix(iface) {
|
43 |
| - const options = { |
44 |
| - 'ParseServerOptions' : 'PARSE_SERVER_', |
45 |
| - 'PagesOptions' : 'PARSE_SERVER_PAGES_', |
46 |
| - 'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_', |
47 |
| - 'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_', |
48 |
| - 'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_', |
49 |
| - 'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_', |
50 |
| - 'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_', |
51 |
| - 'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_', |
52 |
| - 'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_', |
53 |
| - 'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_', |
54 |
| - } |
55 |
| - if (options[iface.id.name]) { |
56 |
| - return options[iface.id.name] |
| 68 | + if (nestedOptionEnvPrefix[iface.id.name]) { |
| 69 | + return nestedOptionEnvPrefix[iface.id.name] |
57 | 70 | }
|
58 | 71 | }
|
59 | 72 |
|
@@ -166,8 +179,7 @@ function parseDefaultValue(elt, value, t) {
|
166 | 179 | if (type == 'NumberOrBoolean') {
|
167 | 180 | literalValue = t.numericLiteral(parsers.numberOrBoolParser('')(value));
|
168 | 181 | }
|
169 |
| - const literalTypes = ['Object', 'IdempotencyOptions','FileUploadOptions','CustomPagesOptions', 'PagesCustomUrlsOptions', 'PagesOptions']; |
170 |
| - if (literalTypes.includes(type)) { |
| 182 | + if (nestedOptionTypes.includes(type)) { |
171 | 183 | const object = parsers.objectParser(value);
|
172 | 184 | const props = Object.keys(object).map((key) => {
|
173 | 185 | return t.objectProperty(key, object[value]);
|
|
0 commit comments