|
11 | 11 | */
|
12 | 12 | const parsers = require('../src/Options/parsers');
|
13 | 13 |
|
| 14 | +/** The types of nested options. */ |
| 15 | +const nestedOptionTypes = [ |
| 16 | + 'CustomPagesOptions', |
| 17 | + 'DatabaseOptions', |
| 18 | + 'FileUploadOptions', |
| 19 | + 'IdempotencyOptions', |
| 20 | + 'Object', |
| 21 | + 'PagesCustomUrlsOptions', |
| 22 | + 'PagesOptions', |
| 23 | + 'PagesRoute', |
| 24 | + 'PasswordPolicyOptions', |
| 25 | + 'SecurityOptions', |
| 26 | +]; |
| 27 | + |
| 28 | +/** The prefix of environment variables for nested options. */ |
| 29 | +const nestedOptionEnvPrefix = { |
| 30 | + 'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_', |
| 31 | + 'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_', |
| 32 | + 'DatabaseOptions': 'PARSE_SERVER_DATABASE_', |
| 33 | + 'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_', |
| 34 | + 'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_', |
| 35 | + 'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_', |
| 36 | + 'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_', |
| 37 | + 'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_', |
| 38 | + 'PagesOptions' : 'PARSE_SERVER_PAGES_', |
| 39 | + 'PagesRoute': 'PARSE_SERVER_PAGES_ROUTE_', |
| 40 | + 'ParseServerOptions' : 'PARSE_SERVER_', |
| 41 | + 'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_', |
| 42 | + 'SecurityOptions': 'PARSE_SERVER_SECURITY_', |
| 43 | +}; |
| 44 | + |
14 | 45 | function last(array) {
|
15 | 46 | return array[array.length - 1];
|
16 | 47 | }
|
@@ -40,23 +71,8 @@ function getCommentValue(comment) {
|
40 | 71 | }
|
41 | 72 |
|
42 | 73 | function getENVPrefix(iface) {
|
43 |
| - const options = { |
44 |
| - 'ParseServerOptions' : 'PARSE_SERVER_', |
45 |
| - 'PagesOptions' : 'PARSE_SERVER_PAGES_', |
46 |
| - 'PagesRoute': 'PARSE_SERVER_PAGES_ROUTE_', |
47 |
| - 'PagesCustomUrlsOptions' : 'PARSE_SERVER_PAGES_CUSTOM_URL_', |
48 |
| - 'CustomPagesOptions' : 'PARSE_SERVER_CUSTOM_PAGES_', |
49 |
| - 'LiveQueryServerOptions' : 'PARSE_LIVE_QUERY_SERVER_', |
50 |
| - 'LiveQueryOptions' : 'PARSE_SERVER_LIVEQUERY_', |
51 |
| - 'IdempotencyOptions' : 'PARSE_SERVER_EXPERIMENTAL_IDEMPOTENCY_', |
52 |
| - 'AccountLockoutOptions' : 'PARSE_SERVER_ACCOUNT_LOCKOUT_', |
53 |
| - 'PasswordPolicyOptions' : 'PARSE_SERVER_PASSWORD_POLICY_', |
54 |
| - 'FileUploadOptions' : 'PARSE_SERVER_FILE_UPLOAD_', |
55 |
| - 'SecurityOptions': 'PARSE_SERVER_SECURITY_', |
56 |
| - 'DatabaseOptions': 'PARSE_SERVER_DATABASE_' |
57 |
| - } |
58 |
| - if (options[iface.id.name]) { |
59 |
| - return options[iface.id.name] |
| 74 | + if (nestedOptionEnvPrefix[iface.id.name]) { |
| 75 | + return nestedOptionEnvPrefix[iface.id.name] |
60 | 76 | }
|
61 | 77 | }
|
62 | 78 |
|
@@ -169,8 +185,8 @@ function parseDefaultValue(elt, value, t) {
|
169 | 185 | if (type == 'NumberOrBoolean') {
|
170 | 186 | literalValue = t.numericLiteral(parsers.numberOrBoolParser('')(value));
|
171 | 187 | }
|
172 |
| - const literalTypes = ['Object', 'SecurityOptions', 'PagesRoute', 'IdempotencyOptions','FileUploadOptions','CustomPagesOptions', 'PagesCustomUrlsOptions', 'PagesOptions', 'DatabaseOptions']; |
173 |
| - if (literalTypes.includes(type)) { |
| 188 | + |
| 189 | + if (nestedOptionTypes.includes(type)) { |
174 | 190 | const object = parsers.objectParser(value);
|
175 | 191 | const props = Object.keys(object).map((key) => {
|
176 | 192 | return t.objectProperty(key, object[value]);
|
|
0 commit comments