@celljs/core 4.2.0 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/README.md +48 -20
  2. package/cell.schema.json +84 -0
  3. package/cell.yml +13 -12
  4. package/esm/browser/application/frontend-application.d.ts +2 -2
  5. package/esm/browser/application/frontend-application.js +6 -25
  6. package/esm/browser/application/frontend-application.js.map +1 -1
  7. package/esm/common/annotation/component.js +1 -2
  8. package/esm/common/annotation/component.js.map +1 -1
  9. package/esm/common/annotation/service.js +2 -1
  10. package/esm/common/annotation/service.js.map +1 -1
  11. package/esm/common/application/application-entry.js +4 -0
  12. package/esm/common/application/application-entry.js.map +1 -1
  13. package/esm/common/application/application-protocol.d.ts +9 -3
  14. package/esm/common/application/application-protocol.js +19 -7
  15. package/esm/common/application/application-protocol.js.map +1 -1
  16. package/esm/common/application/application.js +1 -1
  17. package/esm/common/application/application.js.map +1 -1
  18. package/esm/common/config/config-util.d.ts +3 -0
  19. package/esm/common/config/config-util.js +6 -1
  20. package/esm/common/config/config-util.js.map +1 -1
  21. package/esm/common/config/dynamic-config.d.ts +3 -0
  22. package/esm/common/config/dynamic-config.js +3 -1
  23. package/esm/common/config/dynamic-config.js.map +1 -1
  24. package/esm/common/config/env-config-util.d.ts +32 -26
  25. package/esm/common/config/env-config-util.js +84 -40
  26. package/esm/common/config/env-config-util.js.map +1 -1
  27. package/esm/common/constants.d.ts +1 -1
  28. package/esm/common/constants.js +1 -1
  29. package/esm/common/constants.js.map +1 -1
  30. package/esm/common/container/auto-bind.js +2 -2
  31. package/esm/common/container/auto-bind.js.map +1 -1
  32. package/esm/common/container/container.js +3 -3
  33. package/esm/common/container/container.js.map +1 -1
  34. package/esm/common/el/core-context-initializer.js +3 -1
  35. package/esm/common/el/core-context-initializer.js.map +1 -1
  36. package/esm/common/el/expression-engine.d.ts +3 -3
  37. package/esm/common/el/expression-engine.js +18 -9
  38. package/esm/common/el/expression-engine.js.map +1 -1
  39. package/esm/common/el/expression-handler.js +2 -1
  40. package/esm/common/el/expression-handler.js.map +1 -1
  41. package/esm/common/el/expression-util.d.ts +17 -4
  42. package/esm/common/el/expression-util.js +28 -9
  43. package/esm/common/el/expression-util.js.map +1 -1
  44. package/esm/common/index.d.ts +1 -0
  45. package/esm/common/index.js +1 -0
  46. package/esm/common/index.js.map +1 -1
  47. package/esm/common/logger/abstract-logger.d.ts +2 -1
  48. package/esm/common/logger/abstract-logger.js +28 -17
  49. package/esm/common/logger/abstract-logger.js.map +1 -1
  50. package/esm/common/logger/logger-protocol.d.ts +2 -2
  51. package/esm/common/logger/logger-protocol.js +1 -1
  52. package/esm/common/logger/logger-protocol.js.map +1 -1
  53. package/esm/common/logger/logger.js +11 -4
  54. package/esm/common/logger/logger.js.map +1 -1
  55. package/esm/common/security-check/index.d.ts +2 -0
  56. package/esm/common/security-check/index.js +3 -0
  57. package/esm/common/security-check/index.js.map +1 -0
  58. package/esm/common/security-check/security-check-protocol.d.ts +40 -0
  59. package/esm/common/security-check/security-check-protocol.js +24 -0
  60. package/esm/common/security-check/security-check-protocol.js.map +1 -0
  61. package/esm/common/security-check/security-checker.d.ts +14 -0
  62. package/esm/common/security-check/security-checker.js +61 -0
  63. package/esm/common/security-check/security-checker.js.map +1 -0
  64. package/esm/common/utils/emitter.d.ts +2 -0
  65. package/esm/common/utils/emitter.js +4 -0
  66. package/esm/common/utils/emitter.js.map +1 -1
  67. package/esm/common/utils/error-util.d.ts +8 -0
  68. package/esm/common/utils/error-util.js +24 -0
  69. package/esm/common/utils/error-util.js.map +1 -1
  70. package/esm/common/utils/event.d.ts +6 -1
  71. package/esm/common/utils/event.js +20 -6
  72. package/esm/common/utils/event.js.map +1 -1
  73. package/esm/common/utils/uuid.d.ts +1 -1
  74. package/esm/common/utils/uuid.js +1 -1
  75. package/esm/common/utils/uuid.js.map +1 -1
  76. package/esm/node/application/backend-application.js +1 -1
  77. package/esm/node/application/backend-application.js.map +1 -1
  78. package/esm/node/context/context.js +3 -3
  79. package/esm/node/context/context.js.map +1 -1
  80. package/lib/browser/application/frontend-application.d.ts +2 -2
  81. package/lib/browser/application/frontend-application.d.ts.map +1 -1
  82. package/lib/browser/application/frontend-application.js +6 -25
  83. package/lib/browser/application/frontend-application.js.map +1 -1
  84. package/lib/common/annotation/component.js +1 -2
  85. package/lib/common/annotation/component.js.map +1 -1
  86. package/lib/common/annotation/service.d.ts.map +1 -1
  87. package/lib/common/annotation/service.js +2 -1
  88. package/lib/common/annotation/service.js.map +1 -1
  89. package/lib/common/annotation/service.spec.d.ts +2 -0
  90. package/lib/common/annotation/service.spec.d.ts.map +1 -0
  91. package/lib/common/annotation/service.spec.js +43 -0
  92. package/lib/common/annotation/service.spec.js.map +1 -0
  93. package/lib/common/aop/aop.spec.js +4 -4
  94. package/lib/common/aop/aop.spec.js.map +1 -1
  95. package/lib/common/application/application-entry.js +4 -0
  96. package/lib/common/application/application-entry.js.map +1 -1
  97. package/lib/common/application/application-protocol.d.ts +9 -3
  98. package/lib/common/application/application-protocol.d.ts.map +1 -1
  99. package/lib/common/application/application-protocol.js +19 -7
  100. package/lib/common/application/application-protocol.js.map +1 -1
  101. package/lib/common/application/application.js +1 -1
  102. package/lib/common/application/application.js.map +1 -1
  103. package/lib/common/application/lifecycle.spec.js +54 -7
  104. package/lib/common/application/lifecycle.spec.js.map +1 -1
  105. package/lib/common/config/config-util.d.ts +3 -0
  106. package/lib/common/config/config-util.d.ts.map +1 -1
  107. package/lib/common/config/config-util.js +5 -0
  108. package/lib/common/config/config-util.js.map +1 -1
  109. package/lib/common/config/dynamic-config.d.ts +3 -0
  110. package/lib/common/config/dynamic-config.d.ts.map +1 -1
  111. package/lib/common/config/dynamic-config.js +4 -2
  112. package/lib/common/config/dynamic-config.js.map +1 -1
  113. package/lib/common/config/env-config-util.d.ts +32 -26
  114. package/lib/common/config/env-config-util.d.ts.map +1 -1
  115. package/lib/common/config/env-config-util.js +84 -40
  116. package/lib/common/config/env-config-util.js.map +1 -1
  117. package/lib/common/config/env-config-util.spec.js +148 -132
  118. package/lib/common/config/env-config-util.spec.js.map +1 -1
  119. package/lib/common/constants.d.ts +1 -1
  120. package/lib/common/constants.d.ts.map +1 -1
  121. package/lib/common/constants.js +1 -1
  122. package/lib/common/constants.js.map +1 -1
  123. package/lib/common/container/auto-bind.js +2 -2
  124. package/lib/common/container/auto-bind.js.map +1 -1
  125. package/lib/common/container/container.js +3 -3
  126. package/lib/common/container/container.js.map +1 -1
  127. package/lib/common/el/core-context-initializer.d.ts.map +1 -1
  128. package/lib/common/el/core-context-initializer.js +3 -1
  129. package/lib/common/el/core-context-initializer.js.map +1 -1
  130. package/lib/common/el/expression-engine.d.ts +3 -3
  131. package/lib/common/el/expression-engine.js +18 -9
  132. package/lib/common/el/expression-engine.js.map +1 -1
  133. package/lib/common/el/expression-engine.spec.js +15 -7
  134. package/lib/common/el/expression-engine.spec.js.map +1 -1
  135. package/lib/common/el/expression-handler.d.ts.map +1 -1
  136. package/lib/common/el/expression-handler.js +2 -1
  137. package/lib/common/el/expression-handler.js.map +1 -1
  138. package/lib/common/el/expression-util.d.ts +17 -4
  139. package/lib/common/el/expression-util.d.ts.map +1 -1
  140. package/lib/common/el/expression-util.js +28 -10
  141. package/lib/common/el/expression-util.js.map +1 -1
  142. package/lib/common/index.d.ts +1 -0
  143. package/lib/common/index.d.ts.map +1 -1
  144. package/lib/common/index.js +1 -0
  145. package/lib/common/index.js.map +1 -1
  146. package/lib/common/logger/abstract-logger.d.ts +2 -1
  147. package/lib/common/logger/abstract-logger.d.ts.map +1 -1
  148. package/lib/common/logger/abstract-logger.js +28 -17
  149. package/lib/common/logger/abstract-logger.js.map +1 -1
  150. package/lib/common/logger/logger-protocol.d.ts +2 -2
  151. package/lib/common/logger/logger-protocol.d.ts.map +1 -1
  152. package/lib/common/logger/logger-protocol.js +1 -1
  153. package/lib/common/logger/logger-protocol.js.map +1 -1
  154. package/lib/common/logger/logger.d.ts.map +1 -1
  155. package/lib/common/logger/logger.js +11 -4
  156. package/lib/common/logger/logger.js.map +1 -1
  157. package/lib/common/logger/logger.spec.js +35 -0
  158. package/lib/common/logger/logger.spec.js.map +1 -1
  159. package/lib/common/security-check/index.d.ts +3 -0
  160. package/lib/common/security-check/index.d.ts.map +1 -0
  161. package/lib/common/security-check/index.js +19 -0
  162. package/lib/common/security-check/index.js.map +1 -0
  163. package/lib/common/security-check/security-check-protocol.d.ts +41 -0
  164. package/lib/common/security-check/security-check-protocol.d.ts.map +1 -0
  165. package/lib/common/security-check/security-check-protocol.js +28 -0
  166. package/lib/common/security-check/security-check-protocol.js.map +1 -0
  167. package/lib/common/security-check/security-checker.d.ts +15 -0
  168. package/lib/common/security-check/security-checker.d.ts.map +1 -0
  169. package/lib/common/security-check/security-checker.js +64 -0
  170. package/lib/common/security-check/security-checker.js.map +1 -0
  171. package/lib/common/security-check/security-checker.spec.d.ts +2 -0
  172. package/lib/common/security-check/security-checker.spec.d.ts.map +1 -0
  173. package/lib/common/security-check/security-checker.spec.js +68 -0
  174. package/lib/common/security-check/security-checker.spec.js.map +1 -0
  175. package/lib/common/utils/emitter.d.ts +2 -0
  176. package/lib/common/utils/emitter.d.ts.map +1 -1
  177. package/lib/common/utils/emitter.js +4 -0
  178. package/lib/common/utils/emitter.js.map +1 -1
  179. package/lib/common/utils/error-util.d.ts +8 -0
  180. package/lib/common/utils/error-util.d.ts.map +1 -1
  181. package/lib/common/utils/error-util.js +24 -0
  182. package/lib/common/utils/error-util.js.map +1 -1
  183. package/lib/common/utils/event.d.ts +6 -1
  184. package/lib/common/utils/event.d.ts.map +1 -1
  185. package/lib/common/utils/event.js +20 -6
  186. package/lib/common/utils/event.js.map +1 -1
  187. package/lib/common/utils/utils-behavior.spec.js +21 -2
  188. package/lib/common/utils/utils-behavior.spec.js.map +1 -1
  189. package/lib/common/utils/uuid.d.ts +1 -1
  190. package/lib/common/utils/uuid.d.ts.map +1 -1
  191. package/lib/common/utils/uuid.js +2 -2
  192. package/lib/common/utils/uuid.js.map +1 -1
  193. package/lib/node/application/backend-application.js +1 -1
  194. package/lib/node/application/backend-application.js.map +1 -1
  195. package/lib/node/context/context.d.ts.map +1 -1
  196. package/lib/node/context/context.js +3 -3
  197. package/lib/node/context/context.js.map +1 -1
  198. package/lib/node/context/context.spec.js +13 -0
  199. package/lib/node/context/context.spec.js.map +1 -1
  200. package/package.json +6 -2
  201. package/src/browser/application/frontend-application.ts +7 -28
  202. package/src/common/annotation/component.ts +1 -1
  203. package/src/common/annotation/service.spec.ts +29 -0
  204. package/src/common/annotation/service.ts +2 -1
  205. package/src/common/aop/aop.spec.ts +4 -4
  206. package/src/common/application/application-entry.ts +4 -0
  207. package/src/common/application/application-protocol.ts +21 -11
  208. package/src/common/application/application.ts +1 -1
  209. package/src/common/application/lifecycle.spec.ts +52 -8
  210. package/src/common/config/config-util.ts +7 -1
  211. package/src/common/config/dynamic-config.ts +6 -1
  212. package/src/common/config/env-config-util.spec.ts +152 -149
  213. package/src/common/config/env-config-util.ts +95 -51
  214. package/src/common/constants.ts +1 -1
  215. package/src/common/container/auto-bind.ts +1 -1
  216. package/src/common/container/container.ts +3 -3
  217. package/src/common/el/core-context-initializer.ts +4 -2
  218. package/src/common/el/expression-engine.spec.ts +17 -8
  219. package/src/common/el/expression-engine.ts +17 -9
  220. package/src/common/el/expression-handler.ts +2 -1
  221. package/src/common/el/expression-util.ts +37 -8
  222. package/src/common/index.ts +1 -0
  223. package/src/common/logger/abstract-logger.ts +30 -17
  224. package/src/common/logger/logger-protocol.ts +1 -1
  225. package/src/common/logger/logger.spec.ts +37 -0
  226. package/src/common/logger/logger.ts +12 -4
  227. package/src/common/security-check/index.ts +2 -0
  228. package/src/common/security-check/security-check-protocol.ts +59 -0
  229. package/src/common/security-check/security-checker.spec.ts +70 -0
  230. package/src/common/security-check/security-checker.ts +48 -0
  231. package/src/common/utils/emitter.ts +5 -0
  232. package/src/common/utils/error-util.ts +27 -1
  233. package/src/common/utils/event.ts +20 -9
  234. package/src/common/utils/utils-behavior.spec.ts +23 -3
  235. package/src/common/utils/uuid.ts +1 -1
  236. package/src/node/application/backend-application.ts +1 -1
  237. package/src/node/context/context.spec.ts +14 -0
  238. package/src/node/context/context.ts +2 -3
  239. package/cell.remote.yml +0 -8
@@ -5,53 +5,50 @@ const expect = chai.expect;
5
5
 
6
6
  describe('EnvConfigUtil', () => {
7
7
  const config = () => ({
8
- cell: {
9
- server: { path: '/', port: 3000, endpoint: 'http://localhost:${cell.server.port}' },
10
- 'serve-static': { enabled: true },
11
- typeorm: { ormConfig: [{ type: 'sqlite', database: 'db.sql', logging: false }] },
12
- cors: null,
13
- },
8
+ server: { path: '/', port: 3000, endpoint: 'http://localhost:${server.port}' },
9
+ 'serve-static': { enabled: true },
10
+ typeorm: { ormConfig: [{ type: 'sqlite', database: 'db.sql', logging: false }] },
11
+ cors: null as unknown,
14
12
  accounts: { title: 'Accounts', providers: ['github'] },
15
13
  mode: ['production'],
16
14
  });
17
15
 
18
- it('sets keys under cell, matching case, underscores and dashes loosely', () => {
16
+ it('sets keys, matching case, underscores and dashes loosely', () => {
19
17
  const target = config();
20
18
  const result = EnvConfigUtil.apply(
21
19
  target,
22
20
  {
23
- CELL_BACKEND__SERVER__PORT: '8080',
24
- CELL_BACKEND__SERVE_STATIC__ENABLED: 'FALSE',
25
- CELL_BACKEND__TYPEORM__ORM_CONFIG__0__DATABASE: '/data/db.sql',
26
- CELL_BACKEND__TYPEORM__ORM_CONFIG__0__LOGGING: 'true',
21
+ CELL_SERVER__PORT: '8080',
22
+ CELL_SERVE_STATIC__ENABLED: 'FALSE',
23
+ CELL_TYPEORM__ORM_CONFIG__0__DATABASE: '/data/db.sql',
24
+ CELL_TYPEORM__ORM_CONFIG__0__LOGGING: 'true',
27
25
  PATH: '/usr/bin',
28
- },
29
- 'backend',
26
+ }
30
27
  );
31
28
  expect(result.problems).to.deep.equal([]);
32
29
  expect(result.applied).to.deep.equal([
33
- { variable: 'CELL_BACKEND__SERVER__PORT', path: 'cell.server.port' },
34
- { variable: 'CELL_BACKEND__SERVE_STATIC__ENABLED', path: 'cell.serve-static.enabled' },
35
- { variable: 'CELL_BACKEND__TYPEORM__ORM_CONFIG__0__DATABASE', path: 'cell.typeorm.ormConfig.0.database' },
36
- { variable: 'CELL_BACKEND__TYPEORM__ORM_CONFIG__0__LOGGING', path: 'cell.typeorm.ormConfig.0.logging' },
30
+ { variable: 'CELL_SERVER__PORT', path: 'server.port' },
31
+ { variable: 'CELL_SERVE_STATIC__ENABLED', path: 'serve-static.enabled' },
32
+ { variable: 'CELL_TYPEORM__ORM_CONFIG__0__DATABASE', path: 'typeorm.ormConfig.0.database' },
33
+ { variable: 'CELL_TYPEORM__ORM_CONFIG__0__LOGGING', path: 'typeorm.ormConfig.0.logging' },
37
34
  ]);
38
- expect(target.cell.server.port).to.equal(8080);
39
- expect(target.cell['serve-static'].enabled).to.equal(false);
40
- expect(target.cell.typeorm.ormConfig[0]).to.deep.equal({ type: 'sqlite', database: '/data/db.sql', logging: true });
35
+ expect(target.server.port).to.equal(8080);
36
+ expect(target['serve-static'].enabled).to.equal(false);
37
+ expect(target.typeorm.ormConfig[0]).to.deep.equal({ type: 'sqlite', database: '/data/db.sql', logging: true });
41
38
  });
42
39
 
43
40
  it('keeps expressions of other keys for later evaluation', () => {
44
41
  const target = config();
45
- EnvConfigUtil.apply(target, { CELL_BACKEND__SERVER__PORT: '8080' }, 'backend');
46
- expect(target.cell.server.endpoint).to.equal('http://localhost:${cell.server.port}');
42
+ EnvConfigUtil.apply(target, { CELL_SERVER__PORT: '8080' });
43
+ expect(target.server.endpoint).to.equal('http://localhost:${server.port}');
47
44
  });
48
45
 
49
- it('reaches top-level keys outside cell from the root', () => {
46
+ it('reaches every top-level key', () => {
50
47
  const target = config();
51
- const { applied } = EnvConfigUtil.apply(target, { CELL_BACKEND__ACCOUNTS__TITLE: 'Team', CELL_BACKEND__CELL__SERVER__PATH: '/api' }, 'backend');
52
- expect(applied.map(a => a.path)).to.deep.equal(['accounts.title', 'cell.server.path']);
48
+ const { applied } = EnvConfigUtil.apply(target, { CELL_ACCOUNTS__TITLE: 'Team', CELL_SERVER__PATH: '/api' });
49
+ expect(applied.map(a => a.path)).to.deep.equal(['accounts.title', 'server.path']);
53
50
  expect(target.accounts.title).to.equal('Team');
54
- expect(target.cell.server.path).to.equal('/api');
51
+ expect(target.server.path).to.equal('/api');
55
52
  });
56
53
 
57
54
  it('parses objects and arrays as JSON and leaves strings as they are', () => {
@@ -59,16 +56,15 @@ describe('EnvConfigUtil', () => {
59
56
  const result = EnvConfigUtil.apply(
60
57
  target,
61
58
  {
62
- CELL_BACKEND__ACCOUNTS__PROVIDERS: '["github","gitlab"]',
63
- CELL_BACKEND__CORS: '{"origin":"*"}',
64
- CELL_BACKEND__SERVER__ENDPOINT: '8080',
65
- },
66
- 'backend',
59
+ CELL_ACCOUNTS__PROVIDERS: '["github","gitlab"]',
60
+ CELL_CORS: '{"origin":"*"}',
61
+ CELL_SERVER__ENDPOINT: '8080',
62
+ }
67
63
  );
68
64
  expect(result.problems).to.deep.equal([]);
69
65
  expect(target.accounts.providers).to.deep.equal(['github', 'gitlab']);
70
- expect(target.cell.cors).to.deep.equal({ origin: '*' });
71
- expect(target.cell.server.endpoint).to.equal('8080');
66
+ expect(target.cors).to.deep.equal({ origin: '*' });
67
+ expect(target.server.endpoint).to.equal('8080');
72
68
  });
73
69
 
74
70
  it('reports variables that match no key or do not fit its type, and changes nothing for them', () => {
@@ -76,36 +72,35 @@ describe('EnvConfigUtil', () => {
76
72
  const { applied, problems } = EnvConfigUtil.apply(
77
73
  target,
78
74
  {
79
- CELL_BACKEND__SERVER__PROT: '1',
80
- CELL_BACKEND__SERVR__PORT: '1',
81
- CELL_BACKEND__SERVER__PORT: 'abc',
82
- CELL_BACKEND__SERVE_STATIC__ENABLED: 'yes',
83
- CELL_BACKEND__ACCOUNTS__PROVIDERS: 'github',
84
- CELL_BACKEND__TYPEORM__ORM_CONFIG__3__TYPE: 'mysql',
85
- CELL_BACKEND__SERVER__PORT__X: '1',
86
- CELL_BACKEND__SERVER____PORT: '1',
87
- },
88
- 'backend',
75
+ CELL_SERVER__PROT: '1',
76
+ CELL_SERVR__PORT: '1',
77
+ CELL_SERVER__PORT: 'abc',
78
+ CELL_SERVE_STATIC__ENABLED: 'yes',
79
+ CELL_ACCOUNTS__PROVIDERS: 'github',
80
+ CELL_TYPEORM__ORM_CONFIG__3__TYPE: 'mysql',
81
+ CELL_SERVER__PORT__X: '1',
82
+ CELL_SERVER____PORT: '1',
83
+ }
89
84
  );
90
85
  expect(applied).to.deep.equal([]);
91
86
  expect(target).to.deep.equal(config());
92
87
  const messages = Object.fromEntries(problems.map(p => [p.variable, p.message]));
93
- expect(messages.CELL_BACKEND__SERVER__PROT).to.equal(
94
- "no key 'PROT' under cell.server (keys: path, port, endpoint). Only keys present in cell.yml can be overridden.",
88
+ expect(messages.CELL_SERVER__PROT).to.equal(
89
+ "no key 'PROT' under server (keys: path, port, endpoint). Only keys present in cell.yml can be overridden.",
95
90
  );
96
- expect(messages.CELL_BACKEND__SERVR__PORT).to.equal(
97
- "no key 'SERVR' at the top level (keys: cell, accounts, mode) or under cell (keys: server, serve-static, typeorm, cors). Only keys present in cell.yml can be overridden.",
91
+ expect(messages.CELL_SERVR__PORT).to.equal(
92
+ "no key 'SERVR' under the top level (keys: server, serve-static, typeorm, cors, accounts, mode). Only keys present in cell.yml can be overridden.",
98
93
  );
99
- expect(messages.CELL_BACKEND__SERVER__PORT).to.equal("cell.server.port is a number, got 'abc'. Use a decimal number such as 8080, -1 or 0.5.");
100
- expect(messages.CELL_BACKEND__SERVE_STATIC__ENABLED).to.equal("cell.serve-static.enabled is a boolean, got 'yes'. Use true or false.");
101
- expect(messages.CELL_BACKEND__ACCOUNTS__PROVIDERS).to.contain('accounts.providers is an array; pass it as JSON');
102
- expect(messages.CELL_BACKEND__TYPEORM__ORM_CONFIG__3__TYPE).to.contain('(indexes 0-0)');
103
- expect(messages.CELL_BACKEND__SERVER__PORT__X).to.equal("cell.server.port is not an object, so it has no key 'X'.");
104
- expect(messages.CELL_BACKEND__SERVER____PORT).to.contain('empty segment');
94
+ expect(messages.CELL_SERVER__PORT).to.equal("server.port is a number, got 'abc'. Use a decimal number such as 8080, -1 or 0.5.");
95
+ expect(messages.CELL_SERVE_STATIC__ENABLED).to.equal("serve-static.enabled is a boolean, got 'yes'. Use true or false.");
96
+ expect(messages.CELL_ACCOUNTS__PROVIDERS).to.contain('accounts.providers is an array; pass it as JSON');
97
+ expect(messages.CELL_TYPEORM__ORM_CONFIG__3__TYPE).to.contain('(indexes 0-0)');
98
+ expect(messages.CELL_SERVER__PORT__X).to.equal("server.port is not an object, so it has no key 'X'.");
99
+ expect(messages.CELL_SERVER____PORT).to.contain('empty segment');
105
100
  });
106
101
 
107
- it('applies the backend variables of process.env and warns about the ones that do not apply', () => {
108
- const variables = { CELL_BACKEND__SERVER__PORT: '8080', CELL_BACKEND__SERVER__PROT: '1', CELL_FRONTEND__SERVER__PATH: '/ui' };
102
+ it('applies the CELL_ variables of process.env and warns about the ones that do not apply', () => {
103
+ const variables = { CELL_SERVER__PORT: '8080', CELL_SERVER__PROT: '1', CELL_FRONTEND__SERVER__PATH: '/ui' };
109
104
  const warn = console.warn;
110
105
  const warnings: string[] = [];
111
106
  console.warn = (message: string) => warnings.push(message);
@@ -113,10 +108,11 @@ describe('EnvConfigUtil', () => {
113
108
  try {
114
109
  const target = config();
115
110
  const result = EnvConfigUtil.applyProcessEnv(target);
116
- expect(result.applied).to.deep.equal([{ variable: 'CELL_BACKEND__SERVER__PORT', path: 'cell.server.port' }]);
117
- expect(target.cell.server).to.deep.include({ port: 8080, path: '/' });
111
+ expect(result.applied).to.deep.equal([{ variable: 'CELL_SERVER__PORT', path: 'server.port' }]);
112
+ expect(target.server).to.deep.include({ port: 8080, path: '/' });
118
113
  expect(warnings).to.deep.equal([
119
- "[cell] CELL_BACKEND__SERVER__PROT is ignored: no key 'PROT' under cell.server (keys: path, port, endpoint). Only keys present in cell.yml can be overridden.",
114
+ '[cell] CELL_FRONTEND__SERVER__PATH is ignored: the CELL_BACKEND__ / CELL_FRONTEND__ prefixes are gone: the same variable serves both sides, e.g. CELL_SERVER__PATH.',
115
+ "[cell] CELL_SERVER__PROT is ignored: no key 'PROT' under server (keys: path, port, endpoint). Only keys present in cell.yml can be overridden.",
120
116
  ]);
121
117
  } finally {
122
118
  console.warn = warn;
@@ -129,22 +125,22 @@ describe('EnvConfigUtil', () => {
129
125
  it('takes finite numbers in JSON syntax only', () => {
130
126
  const port = (value: string) => {
131
127
  const target = config();
132
- const { applied, problems } = EnvConfigUtil.apply(target, { CELL_BACKEND__SERVER__PORT: value }, 'backend');
133
- return applied.length === 1 ? target.cell.server.port : problems[0].message;
128
+ const { applied, problems } = EnvConfigUtil.apply(target, { CELL_SERVER__PORT: value });
129
+ return applied.length === 1 ? target.server.port : problems[0].message;
134
130
  };
135
131
  for (const [value, expected] of [['8080', 8080], ['0', 0], ['-1', -1], ['0.5', 0.5], ['1e3', 1000], ['-2.5E-1', -0.25]] as const) {
136
132
  expect(port(value), value).to.equal(expected);
137
133
  }
138
134
  for (const value of ['Infinity', '-Infinity', 'NaN', '1e999', '0x10', '0b1', '1_000', '+1', '08080', '.5', '5.', '', ' 8080', '8080 ']) {
139
- expect(port(value), JSON.stringify(value)).to.equal(`cell.server.port is a number, got '${value}'. Use a decimal number such as 8080, -1 or 0.5.`);
135
+ expect(port(value), JSON.stringify(value)).to.equal(`server.port is a number, got '${value}'. Use a decimal number such as 8080, -1 or 0.5.`);
140
136
  }
141
137
  });
142
138
 
143
139
  it('follows null in cell.yml with JSON when the value is JSON, else text', () => {
144
140
  const cors = (value: string) => {
145
141
  const target = config();
146
- EnvConfigUtil.apply(target, { CELL_BACKEND__CORS: value }, 'backend');
147
- return target.cell.cors;
142
+ EnvConfigUtil.apply(target, { CELL_CORS: value });
143
+ return target.cors;
148
144
  };
149
145
  expect(cors('null')).to.equal(null);
150
146
  expect(cors('5')).to.equal(5);
@@ -160,59 +156,57 @@ describe('EnvConfigUtil', () => {
160
156
  const { applied, problems } = EnvConfigUtil.apply(
161
157
  target,
162
158
  {
163
- CELL_BACKEND__SERVER__PORT: '${env.PORT ?: 3000}',
164
- CELL_BACKEND__SERVE_STATIC__ENABLED: '${env.STATIC == "on"}',
165
- CELL_BACKEND__ACCOUNTS__PROVIDERS: '${cell.providers}',
166
- CELL_BACKEND__SERVER__PATH: '/${env.BASE}',
167
- },
168
- 'backend',
159
+ CELL_SERVER__PORT: '${env.PORT ?: 3000}',
160
+ CELL_SERVE_STATIC__ENABLED: '${env.STATIC == "on"}',
161
+ CELL_ACCOUNTS__PROVIDERS: '${app.providers}',
162
+ CELL_SERVER__PATH: '/${env.BASE}',
163
+ }
169
164
  );
170
165
  expect(problems).to.deep.equal([]);
171
166
  expect(applied).to.have.length(4);
172
- expect(target.cell.server.port).to.equal('${env.PORT ?: 3000}');
173
- expect(target.cell['serve-static'].enabled).to.equal('${env.STATIC == "on"}');
174
- expect(target.accounts.providers).to.equal('${cell.providers}');
175
- expect(target.cell.server.path).to.equal('/${env.BASE}');
167
+ expect(target.server.port).to.equal('${env.PORT ?: 3000}');
168
+ expect(target['serve-static'].enabled).to.equal('${env.STATIC == "on"}');
169
+ expect(target.accounts.providers).to.equal('${app.providers}');
170
+ expect(target.server.path).to.equal('/${env.BASE}');
176
171
  });
177
172
 
178
173
  it('rejects text around an expression where the key needs a number, boolean, object or array', () => {
179
174
  const { applied, problems } = EnvConfigUtil.apply(
180
175
  config(),
181
- { CELL_BACKEND__SERVER__PORT: '80${env.X}', CELL_BACKEND__SERVE_STATIC__ENABLED: '${a} ${b}', CELL_BACKEND__ACCOUNTS__PROVIDERS: 'x${a}' },
182
- 'backend',
176
+ { CELL_SERVER__PORT: '80${env.X}', CELL_SERVE_STATIC__ENABLED: '${a} ${b}', CELL_ACCOUNTS__PROVIDERS: 'x${a}' }
183
177
  );
184
178
  expect(applied).to.deep.equal([]);
185
179
  expect(problems.map(p => p.variable)).to.deep.equal([
186
- 'CELL_BACKEND__ACCOUNTS__PROVIDERS',
187
- 'CELL_BACKEND__SERVER__PORT',
188
- 'CELL_BACKEND__SERVE_STATIC__ENABLED',
180
+ 'CELL_ACCOUNTS__PROVIDERS',
181
+ 'CELL_SERVER__PORT',
182
+ 'CELL_SERVE_STATIC__ENABLED',
189
183
  ]);
190
184
  });
191
185
 
192
186
  it('takes true and false in any case for booleans and names the value it rejects', () => {
193
187
  const enabled = (value: string) => {
194
188
  const target = config();
195
- const { problems } = EnvConfigUtil.apply(target, { CELL_BACKEND__SERVE_STATIC__ENABLED: value }, 'backend');
196
- return problems.length > 0 ? problems[0].message : target.cell['serve-static'].enabled;
189
+ const { problems } = EnvConfigUtil.apply(target, { CELL_SERVE_STATIC__ENABLED: value });
190
+ return problems.length > 0 ? problems[0].message : target['serve-static'].enabled;
197
191
  };
198
192
  expect(enabled('FALSE')).to.equal(false);
199
193
  expect(enabled('True')).to.equal(true);
200
194
  for (const value of ['yes', '1', '0', '', ' true']) {
201
- expect(enabled(value)).to.equal(`cell.serve-static.enabled is a boolean, got '${value}'. Use true or false.`);
195
+ expect(enabled(value)).to.equal(`serve-static.enabled is a boolean, got '${value}'. Use true or false.`);
202
196
  }
203
197
  });
204
198
 
205
199
  it('rejects integers that a number cannot hold exactly', () => {
206
200
  const port = (value: string) => {
207
201
  const target = config();
208
- const { problems } = EnvConfigUtil.apply(target, { CELL_BACKEND__SERVER__PORT: value }, 'backend');
209
- return problems.length > 0 ? problems[0].message : target.cell.server.port;
202
+ const { problems } = EnvConfigUtil.apply(target, { CELL_SERVER__PORT: value });
203
+ return problems.length > 0 ? problems[0].message : target.server.port;
210
204
  };
211
205
  expect(port('9007199254740991')).to.equal(9007199254740991);
212
206
  expect(port('-9007199254740991')).to.equal(-9007199254740991);
213
207
  expect(port('1.5e300')).to.equal(1.5e300);
214
208
  expect(port('9007199254740993')).to.equal(
215
- "cell.server.port is a number, got '9007199254740993', which is too large to keep exactly. Use a string in cell.yml for such values.",
209
+ "server.port is a number, got '9007199254740993', which is too large to keep exactly. Use a string in cell.yml for such values.",
216
210
  );
217
211
  });
218
212
 
@@ -221,121 +215,130 @@ describe('EnvConfigUtil', () => {
221
215
  const { applied, problems } = EnvConfigUtil.apply(
222
216
  target,
223
217
  {
224
- CELL_BACKEND__ACCOUNTS__PROVIDERS__00: 'gitlab',
225
- CELL_BACKEND__TYPEORM__ORM_CONFIG__00__TYPE: 'mysql',
226
- CELL_BACKEND__TYPEORM__ORM_CONFIG__0__TYPE: 'postgres',
227
- },
228
- 'backend',
218
+ CELL_ACCOUNTS__PROVIDERS__00: 'gitlab',
219
+ CELL_TYPEORM__ORM_CONFIG__00__TYPE: 'mysql',
220
+ CELL_TYPEORM__ORM_CONFIG__0__TYPE: 'postgres',
221
+ }
229
222
  );
230
- expect(applied.map(a => a.path)).to.deep.equal(['cell.typeorm.ormConfig.0.type']);
231
- expect(problems.map(p => p.variable)).to.deep.equal(['CELL_BACKEND__ACCOUNTS__PROVIDERS__00', 'CELL_BACKEND__TYPEORM__ORM_CONFIG__00__TYPE']);
223
+ expect(applied.map(a => a.path)).to.deep.equal(['typeorm.ormConfig.0.type']);
224
+ expect(problems.map(p => p.variable)).to.deep.equal(['CELL_ACCOUNTS__PROVIDERS__00', 'CELL_TYPEORM__ORM_CONFIG__00__TYPE']);
232
225
  expect(problems[0].message).to.equal("no key '00' under accounts.providers (indexes 0-0). Only keys present in cell.yml can be overridden.");
233
226
  // '00' must not become a property of the array next to item 0.
234
227
  expect(Object.keys(target.accounts.providers)).to.deep.equal(['0']);
235
- expect(target.cell.typeorm.ormConfig[0].type).to.equal('postgres');
228
+ expect(target.typeorm.ormConfig[0].type).to.equal('postgres');
236
229
  });
237
230
 
238
231
  describe('keys set by more than one variable', () => {
239
232
  const conflict = (env: Record<string, string>) => {
240
233
  const target = config();
241
- return { target, ...EnvConfigUtil.apply(target, env, 'backend') };
234
+ return { target, ...EnvConfigUtil.apply(target, env) };
242
235
  };
243
236
 
244
237
  it('applies none of the variables that set the same key, however they spell it', () => {
245
238
  const { target, applied, problems } = conflict({
246
- CELL_BACKEND__SERVER__PORT: '1',
247
- CELL_BACKEND__CELL__SERVER__PORT: '2',
248
- CELL_BACKEND__SERVER__P_ORT: '3',
249
- CELL_BACKEND__SERVER__PATH: '/api',
239
+ CELL_SERVER__PORT: '1',
240
+ CELL_server__port: '2',
241
+ CELL_SERVER__P_ORT: '3',
242
+ CELL_SERVER__PATH: '/api',
250
243
  });
251
- expect(applied).to.deep.equal([{ variable: 'CELL_BACKEND__SERVER__PATH', path: 'cell.server.path' }]);
252
- expect(target.cell.server.port).to.equal(3000);
253
- expect(problems.map(p => p.variable)).to.deep.equal(['CELL_BACKEND__CELL__SERVER__PORT', 'CELL_BACKEND__SERVER__PORT', 'CELL_BACKEND__SERVER__P_ORT']);
254
- expect(problems[1].message).to.equal(
255
- 'sets cell.server.port, which CELL_BACKEND__CELL__SERVER__PORT (cell.server.port), CELL_BACKEND__SERVER__P_ORT (cell.server.port) also set. Set each key with one variable; to change items of an object or array you replace, write them into its JSON.',
244
+ expect(applied).to.deep.equal([{ variable: 'CELL_SERVER__PATH', path: 'server.path' }]);
245
+ expect(target.server.port).to.equal(3000);
246
+ expect(problems.map(p => p.variable)).to.deep.equal(['CELL_SERVER__PORT', 'CELL_SERVER__P_ORT', 'CELL_server__port']);
247
+ expect(problems[0].message).to.equal(
248
+ 'sets server.port, which CELL_SERVER__P_ORT (server.port), CELL_server__port (server.port) also set. Set each key with one variable; to change items of an object or array you replace, write them into its JSON.',
256
249
  );
257
250
  });
258
251
 
259
252
  it('applies neither a key nor a key inside it, in either order of the names', () => {
260
253
  const pairs = [
261
254
  // The whole array sorts first, then the item.
262
- ['CELL_BACKEND__TYPEORM__ORM_CONFIG', 'CELL_BACKEND__TYPEORM__ORM_CONFIG__0__DATABASE'],
255
+ ['CELL_TYPEORM__ORM_CONFIG', 'CELL_TYPEORM__ORM_CONFIG__0__DATABASE'],
263
256
  // The item sorts first: applied in order, the array would have wiped it out.
264
- ['CELL_BACKEND__TYPEORM__ORM_CONFIG', 'CELL_BACKEND__CELL__TYPEORM__ORM_CONFIG__0__DATABASE'],
265
- ['CELL_BACKEND__CELL__TYPEORM__ORM_CONFIG', 'CELL_BACKEND__TYPEORM__ORM_CONFIG__0__DATABASE'],
257
+ ['CELL_TYPEORM__ORM_CONFIG', 'CELL_typeorm__ormConfig__0__DATABASE'],
258
+ ['CELL_typeorm__ormConfig', 'CELL_TYPEORM__ORM_CONFIG__0__DATABASE'],
266
259
  ];
267
260
  for (const [whole, item] of pairs) {
268
261
  const { target, applied, problems } = conflict({ [whole]: '[{"type":"mysql"}]', [item]: 'x.sql' });
269
262
  expect(applied, `${whole} + ${item}`).to.deep.equal([]);
270
263
  expect(problems.map(p => p.variable).sort()).to.deep.equal([item, whole].sort());
271
- expect(problems.find(p => p.variable === item)!.message).to.contain(`which ${whole} (cell.typeorm.ormConfig) also sets`);
272
- expect(target.cell.typeorm.ormConfig).to.deep.equal(config().cell.typeorm.ormConfig);
264
+ expect(problems.find(p => p.variable === item)!.message).to.contain(`which ${whole} (typeorm.ormConfig) also sets`);
265
+ expect(target.typeorm.ormConfig).to.deep.equal(config().typeorm.ormConfig);
273
266
  }
274
267
  });
275
268
 
276
269
  it('lets variables of different keys under the same object apply', () => {
277
- const { applied, problems } = conflict({ CELL_BACKEND__TYPEORM__ORM_CONFIG__0__TYPE: 'mysql', CELL_BACKEND__TYPEORM__ORM_CONFIG__0__DATABASE: 'x' });
270
+ const { applied, problems } = conflict({ CELL_TYPEORM__ORM_CONFIG__0__TYPE: 'mysql', CELL_TYPEORM__ORM_CONFIG__0__DATABASE: 'x' });
278
271
  expect(problems).to.deep.equal([]);
279
272
  expect(applied).to.have.length(2);
280
273
  });
281
274
 
282
275
  it('does not depend on the order of the variables in the environment', () => {
283
- const names = ['CELL_BACKEND__TYPEORM__ORM_CONFIG__0__DATABASE', 'CELL_BACKEND__CELL__TYPEORM__ORM_CONFIG', 'CELL_BACKEND__SERVER__PORT'];
276
+ const names = ['CELL_TYPEORM__ORM_CONFIG__0__DATABASE', 'CELL_typeorm__ormConfig', 'CELL_SERVER__PORT'];
284
277
  const run = (order: string[]) => {
285
278
  const target = config();
286
279
  const env = Object.fromEntries(order.map(name => [name, name.endsWith('ORM_CONFIG') ? '[]' : '1']));
287
- return JSON.stringify({ result: EnvConfigUtil.apply(target, env, 'backend'), target });
280
+ return JSON.stringify({ result: EnvConfigUtil.apply(target, env), target });
288
281
  };
289
282
  expect(run([...names].reverse())).to.equal(run(names));
290
283
  });
291
284
  });
292
285
 
293
- describe('top-level keys with the same name as keys under cell', () => {
294
- const shadowed = () => ({ cell: { server: { port: 3000 }, accounts: { title: 'Inner' } }, server: { x: 1 }, accounts: { title: 'Outer', team: 't' } });
286
+ it('reads CELL_ variables, leaving the toolchain ones and those of other tools alone', () => {
287
+ const target = config();
288
+ const result = EnvConfigUtil.apply(target, {
289
+ CELL_SERVER__PORT: '3',
290
+ CELL_MODE: 'production',
291
+ CELL_PRESET: 'node',
292
+ CELL_REGION: 'cn-hangzhou',
293
+ SERVER__PORT: '4',
294
+ });
295
+ expect(result).to.deep.equal({ applied: [{ variable: 'CELL_SERVER__PORT', path: 'server.port' }], problems: [] });
296
+ expect(target.server.port).to.equal(3);
297
+ expect(target.mode).to.deep.equal(['production']);
298
+ expect(EnvConfigUtil.isOverride('CELL_MODE')).to.equal(false);
299
+ });
295
300
 
296
- it('looks up the first key at the top level, then under cell', () => {
297
- const target = shadowed();
298
- const { applied, problems } = EnvConfigUtil.apply(
299
- target,
300
- { CELL_BACKEND__SERVER__X: '5', CELL_BACKEND__ACCOUNTS__TEAM: 'u', CELL_BACKEND__ACCOUNTS__TITLE: 'Top' },
301
- 'backend',
302
- );
301
+ it('reports a name with __ whose first key does not exist, and the earlier prefixes', () => {
302
+ const { applied, problems } = EnvConfigUtil.apply(config(), {
303
+ CELL_SERVR__PORT: '1',
304
+ CELL__SERVER__PORT: '2',
305
+ CELL_BACKEND__SERVER__PORT: '3',
306
+ });
307
+ expect(applied).to.deep.equal([]);
308
+ expect(Object.fromEntries(problems.map(p => [p.variable, p.message]))).to.deep.equal({
309
+ CELL_BACKEND__SERVER__PORT: 'the CELL_BACKEND__ / CELL_FRONTEND__ prefixes are gone: the same variable serves both sides, e.g. CELL_SERVER__PORT.',
310
+ CELL_SERVR__PORT: "no key 'SERVR' under the top level (keys: server, serve-static, typeorm, cors, accounts, mode). Only keys present in cell.yml can be overridden.",
311
+ CELL__SERVER__PORT: 'one underscore after CELL, then `__` between keys: CELL_SERVER__PORT.',
312
+ });
313
+ });
314
+
315
+ describe('schema types', () => {
316
+ it('convert a value replacing an expression to the type of the key', () => {
317
+ const target = { server: { port: '${env.PORT ?? 3000}', secure: '${env.SECURE ?? false}' } };
318
+ const { applied, problems } = EnvConfigUtil.apply(target, { CELL_SERVER__PORT: '8080', CELL_SERVER__SECURE: 'TRUE' }, { 'server.port': 'integer', 'server.secure': 'boolean' });
303
319
  expect(problems).to.deep.equal([]);
304
- expect(applied).to.deep.equal([
305
- { variable: 'CELL_BACKEND__ACCOUNTS__TEAM', path: 'accounts.team', shadows: 'cell.accounts' },
306
- { variable: 'CELL_BACKEND__ACCOUNTS__TITLE', path: 'accounts.title', shadows: 'cell.accounts' },
307
- { variable: 'CELL_BACKEND__SERVER__X', path: 'server.x', shadows: 'cell.server' },
308
- ]);
309
- expect(target).to.deep.equal({ cell: { server: { port: 3000 }, accounts: { title: 'Inner' } }, server: { x: 5 }, accounts: { title: 'Top', team: 'u' } });
320
+ expect(applied).to.have.length(2);
321
+ expect(target.server).to.deep.equal({ port: 8080, secure: true });
310
322
  });
311
323
 
312
- it('reaches the keys under cell with CELL__, and reports a key missing from the top-level one', () => {
313
- const target = shadowed();
314
- const { applied, problems } = EnvConfigUtil.apply(
315
- target,
316
- { CELL_BACKEND__CELL__ACCOUNTS__TITLE: 'In', CELL_BACKEND__CELL__SERVER__PORT: '8080', CELL_BACKEND__SERVER__PORT: '1' },
317
- 'backend',
318
- );
319
- expect(applied).to.deep.equal([
320
- { variable: 'CELL_BACKEND__CELL__ACCOUNTS__TITLE', path: 'cell.accounts.title' },
321
- { variable: 'CELL_BACKEND__CELL__SERVER__PORT', path: 'cell.server.port' },
322
- ]);
323
- expect(target.cell).to.deep.equal({ server: { port: 8080 }, accounts: { title: 'In' } });
324
- expect(problems).to.deep.equal([
325
- { variable: 'CELL_BACKEND__SERVER__PORT', message: "no key 'PORT' under server (keys: x). Only keys present in cell.yml can be overridden." },
326
- ]);
324
+ it('record the type of a number or boolean key that a variable sets to an expression', () => {
325
+ const types = {};
326
+ EnvConfigUtil.apply({ server: { port: 3000, host: 'x' } }, { CELL_SERVER__PORT: '${env.PLATFORM_PORT}', CELL_SERVER__HOST: '${env.HOST}' }, types);
327
+ expect(types).to.deep.equal({ 'server.port': 'number' });
327
328
  });
328
329
 
329
- it('falls back to cell when the top level has no such key', () => {
330
- const { applied } = EnvConfigUtil.apply(config(), { CELL_BACKEND__SERVER__PORT: '1' }, 'backend');
331
- expect(applied).to.deep.equal([{ variable: 'CELL_BACKEND__SERVER__PORT', path: 'cell.server.port' }]);
330
+ it('reject a value that does not fit the type', () => {
331
+ const target = { server: { port: '${env.PORT}' } };
332
+ const { problems } = EnvConfigUtil.apply(target, { CELL_SERVER__PORT: '80.5' }, { 'server.port': 'integer' });
333
+ expect(problems[0].message).to.equal("server.port is an integer, got '80.5'.");
332
334
  });
333
- });
334
335
 
335
- it('only reads the variables of the given target', () => {
336
- const target = config();
337
- const result = EnvConfigUtil.apply(target, { CELL_FRONTEND__SERVER__PORT: '1', CELL_BACKEND__SERVER__PORT: '2' }, 'frontend');
338
- expect(result.applied).to.deep.equal([{ variable: 'CELL_FRONTEND__SERVER__PORT', path: 'cell.server.port' }]);
339
- expect(target.cell.server.port).to.equal(1);
336
+ it('toType converts text and keeps other values', () => {
337
+ expect(EnvConfigUtil.toType('number', '1.5', 'a')).to.equal(1.5);
338
+ expect(EnvConfigUtil.toType('boolean', 'false', 'a')).to.equal(false);
339
+ expect(EnvConfigUtil.toType('integer', 3, 'a')).to.equal(3);
340
+ expect(EnvConfigUtil.toType('string', '3', 'a')).to.equal('3');
341
+ expect(() => EnvConfigUtil.toType('number', 'abc', 'a')).to.throw("a is a number, got 'abc'.");
342
+ });
340
343
  });
341
344
  });