kuzzle 2.19.2 → 2.19.3

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 (289) hide show
  1. package/lib/api/controllers/adminController.js +94 -80
  2. package/lib/api/controllers/authController.js +239 -212
  3. package/lib/api/controllers/baseController.js +89 -51
  4. package/lib/api/controllers/bulkController.js +62 -49
  5. package/lib/api/controllers/clusterController.js +6 -8
  6. package/lib/api/controllers/collectionController.js +140 -129
  7. package/lib/api/controllers/debugController.d.ts +2 -2
  8. package/lib/api/controllers/debugController.js +33 -31
  9. package/lib/api/controllers/documentController.js +365 -274
  10. package/lib/api/controllers/index.js +13 -13
  11. package/lib/api/controllers/indexController.js +46 -50
  12. package/lib/api/controllers/memoryStorageController.js +410 -360
  13. package/lib/api/controllers/realtimeController.js +37 -36
  14. package/lib/api/controllers/securityController.js +553 -412
  15. package/lib/api/controllers/serverController.js +111 -104
  16. package/lib/api/documentExtractor.js +75 -68
  17. package/lib/api/funnel.js +411 -312
  18. package/lib/api/httpRoutes.js +1493 -324
  19. package/lib/api/openapi/OpenApiManager.d.ts +1 -1
  20. package/lib/api/openapi/OpenApiManager.js +22 -22
  21. package/lib/api/openapi/components/document/count.yaml +1 -1
  22. package/lib/api/openapi/components/document/create.yaml +2 -2
  23. package/lib/api/openapi/components/document/delete.yaml +1 -1
  24. package/lib/api/openapi/components/document/deleteByQuery.yaml +1 -1
  25. package/lib/api/openapi/components/document/exists.yaml +1 -1
  26. package/lib/api/openapi/components/document/get.yaml +2 -2
  27. package/lib/api/openapi/components/document/index.js +12 -12
  28. package/lib/api/openapi/components/document/replace.yaml +1 -1
  29. package/lib/api/openapi/components/document/scroll.yaml +1 -1
  30. package/lib/api/openapi/components/document/validate.yaml +1 -1
  31. package/lib/api/openapi/components/index.d.ts +2 -2
  32. package/lib/api/openapi/components/index.js +1 -1
  33. package/lib/api/openapi/components/security/index.js +1 -1
  34. package/lib/api/openapi/components/security/upsertUser.yaml +2 -3
  35. package/lib/api/openapi/index.d.ts +1 -1
  36. package/lib/api/openapi/openApiGenerator.d.ts +1 -1
  37. package/lib/api/openapi/openApiGenerator.js +7 -7
  38. package/lib/api/rateLimiter.js +12 -13
  39. package/lib/api/request/index.d.ts +4 -4
  40. package/lib/api/request/kuzzleRequest.d.ts +9 -9
  41. package/lib/api/request/kuzzleRequest.js +89 -87
  42. package/lib/api/request/requestContext.d.ts +2 -2
  43. package/lib/api/request/requestContext.js +17 -17
  44. package/lib/api/request/requestInput.d.ts +1 -1
  45. package/lib/api/request/requestInput.js +19 -19
  46. package/lib/api/request/requestResponse.d.ts +4 -4
  47. package/lib/api/request/requestResponse.js +31 -33
  48. package/lib/cluster/command.js +48 -44
  49. package/lib/cluster/idCardHandler.d.ts +1 -1
  50. package/lib/cluster/idCardHandler.js +15 -15
  51. package/lib/cluster/index.js +2 -2
  52. package/lib/cluster/node.js +301 -269
  53. package/lib/cluster/publisher.js +45 -46
  54. package/lib/cluster/state.d.ts +5 -5
  55. package/lib/cluster/state.js +8 -8
  56. package/lib/cluster/subscriber.js +163 -113
  57. package/lib/cluster/workers/IDCardRenewer.js +33 -32
  58. package/lib/config/default.config.d.ts +1 -1
  59. package/lib/config/default.config.js +212 -171
  60. package/lib/config/documentEventAliases.js +6 -6
  61. package/lib/config/index.js +161 -98
  62. package/lib/config/sdkCompatibility.json +8 -8
  63. package/lib/core/auth/formatProcessing.js +7 -7
  64. package/lib/core/auth/passportResponse.js +7 -7
  65. package/lib/core/auth/passportWrapper.js +34 -30
  66. package/lib/core/auth/tokenManager.d.ts +2 -2
  67. package/lib/core/auth/tokenManager.js +11 -10
  68. package/lib/core/backend/applicationManager.d.ts +1 -1
  69. package/lib/core/backend/applicationManager.js +2 -2
  70. package/lib/core/backend/backend.d.ts +3 -3
  71. package/lib/core/backend/backend.js +34 -31
  72. package/lib/core/backend/backendCluster.d.ts +2 -2
  73. package/lib/core/backend/backendCluster.js +5 -5
  74. package/lib/core/backend/backendConfig.d.ts +2 -2
  75. package/lib/core/backend/backendConfig.js +3 -3
  76. package/lib/core/backend/backendController.d.ts +2 -2
  77. package/lib/core/backend/backendController.js +9 -10
  78. package/lib/core/backend/backendErrors.d.ts +3 -3
  79. package/lib/core/backend/backendErrors.js +2 -1
  80. package/lib/core/backend/backendHook.d.ts +2 -2
  81. package/lib/core/backend/backendHook.js +5 -5
  82. package/lib/core/backend/backendImport.d.ts +3 -3
  83. package/lib/core/backend/backendImport.js +23 -23
  84. package/lib/core/backend/backendOpenApi.d.ts +2 -2
  85. package/lib/core/backend/backendOpenApi.js +16 -16
  86. package/lib/core/backend/backendPipe.d.ts +2 -2
  87. package/lib/core/backend/backendPipe.js +6 -6
  88. package/lib/core/backend/backendPlugin.d.ts +4 -4
  89. package/lib/core/backend/backendPlugin.js +14 -14
  90. package/lib/core/backend/backendStorage.d.ts +2 -2
  91. package/lib/core/backend/backendStorage.js +1 -2
  92. package/lib/core/backend/backendVault.d.ts +2 -2
  93. package/lib/core/backend/backendVault.js +3 -3
  94. package/lib/core/backend/index.d.ts +14 -14
  95. package/lib/core/backend/internalLogger.d.ts +1 -1
  96. package/lib/core/backend/internalLogger.js +5 -5
  97. package/lib/core/cache/cacheDbEnum.js +4 -4
  98. package/lib/core/cache/cacheEngine.js +79 -85
  99. package/lib/core/network/accessLogger.js +126 -120
  100. package/lib/core/network/clientConnection.js +5 -5
  101. package/lib/core/network/context.js +8 -8
  102. package/lib/core/network/entryPoint.js +100 -85
  103. package/lib/core/network/httpRouter/index.js +63 -60
  104. package/lib/core/network/httpRouter/routeHandler.js +18 -19
  105. package/lib/core/network/httpRouter/routePart.js +23 -19
  106. package/lib/core/network/protocolManifest.js +3 -3
  107. package/lib/core/network/protocols/httpMessage.js +8 -10
  108. package/lib/core/network/protocols/httpwsProtocol.js +305 -250
  109. package/lib/core/network/protocols/internalProtocol.js +27 -24
  110. package/lib/core/network/protocols/mqttProtocol.js +106 -96
  111. package/lib/core/network/protocols/protocol.js +20 -17
  112. package/lib/core/network/router.js +56 -46
  113. package/lib/core/plugin/plugin.js +151 -120
  114. package/lib/core/plugin/pluginContext.d.ts +7 -7
  115. package/lib/core/plugin/pluginContext.js +48 -44
  116. package/lib/core/plugin/pluginManifest.js +13 -12
  117. package/lib/core/plugin/pluginRepository.js +26 -27
  118. package/lib/core/plugin/pluginsManager.js +425 -304
  119. package/lib/core/plugin/privilegedContext.js +3 -3
  120. package/lib/core/realtime/actionEnum.js +1 -1
  121. package/lib/core/realtime/channel.d.ts +1 -1
  122. package/lib/core/realtime/channel.js +22 -22
  123. package/lib/core/realtime/connectionRooms.d.ts +1 -1
  124. package/lib/core/realtime/hotelClerk.d.ts +2 -2
  125. package/lib/core/realtime/hotelClerk.js +53 -50
  126. package/lib/core/realtime/index.js +5 -5
  127. package/lib/core/realtime/notification/document.js +25 -25
  128. package/lib/core/realtime/notification/index.js +4 -4
  129. package/lib/core/realtime/notification/server.js +3 -3
  130. package/lib/core/realtime/notification/user.js +4 -4
  131. package/lib/core/realtime/notifier.js +113 -75
  132. package/lib/core/realtime/room.d.ts +1 -1
  133. package/lib/core/realtime/subscription.d.ts +1 -1
  134. package/lib/core/realtime/subscription.js +1 -1
  135. package/lib/core/security/index.js +8 -8
  136. package/lib/core/security/profileRepository.d.ts +6 -6
  137. package/lib/core/security/profileRepository.js +48 -45
  138. package/lib/core/security/roleRepository.js +127 -115
  139. package/lib/core/security/securityLoader.js +70 -63
  140. package/lib/core/security/tokenRepository.js +132 -118
  141. package/lib/core/security/userRepository.js +104 -88
  142. package/lib/core/shared/KoncordeWrapper.d.ts +1 -1
  143. package/lib/core/shared/KoncordeWrapper.js +3 -1
  144. package/lib/core/shared/abstractManifest.js +22 -23
  145. package/lib/core/shared/repository.js +69 -67
  146. package/lib/core/shared/sdk/embeddedSdk.d.ts +2 -2
  147. package/lib/core/shared/sdk/embeddedSdk.js +36 -32
  148. package/lib/core/shared/sdk/funnelProtocol.d.ts +1 -1
  149. package/lib/core/shared/sdk/funnelProtocol.js +11 -11
  150. package/lib/core/shared/sdk/impersonatedSdk.js +19 -18
  151. package/lib/core/shared/store.js +127 -32
  152. package/lib/core/statistics/index.js +2 -2
  153. package/lib/core/statistics/statistics.js +99 -85
  154. package/lib/core/storage/clientAdapter.js +219 -136
  155. package/lib/core/storage/indexCache.js +3 -3
  156. package/lib/core/storage/storageEngine.js +10 -13
  157. package/lib/core/storage/storeScopeEnum.js +3 -3
  158. package/lib/core/validation/baseType.js +12 -10
  159. package/lib/core/validation/index.js +2 -2
  160. package/lib/core/validation/types/anything.js +4 -4
  161. package/lib/core/validation/types/boolean.js +7 -7
  162. package/lib/core/validation/types/date.js +165 -131
  163. package/lib/core/validation/types/email.js +18 -21
  164. package/lib/core/validation/types/enum.js +34 -21
  165. package/lib/core/validation/types/geoPoint.js +7 -7
  166. package/lib/core/validation/types/geoShape.js +148 -125
  167. package/lib/core/validation/types/integer.js +9 -9
  168. package/lib/core/validation/types/ipAddress.js +17 -19
  169. package/lib/core/validation/types/numeric.js +36 -29
  170. package/lib/core/validation/types/object.js +19 -19
  171. package/lib/core/validation/types/string.js +36 -29
  172. package/lib/core/validation/types/url.js +17 -19
  173. package/lib/core/validation/validation.js +422 -378
  174. package/lib/kerror/codes/1-services.json +7 -1
  175. package/lib/kerror/codes/4-plugin.json +2 -2
  176. package/lib/kerror/codes/index.js +85 -63
  177. package/lib/kerror/errors/badRequestError.d.ts +1 -1
  178. package/lib/kerror/errors/externalServiceError.d.ts +1 -1
  179. package/lib/kerror/errors/forbiddenError.d.ts +1 -1
  180. package/lib/kerror/errors/gatewayTimeoutError.d.ts +1 -1
  181. package/lib/kerror/errors/index.d.ts +15 -15
  182. package/lib/kerror/errors/internalError.d.ts +1 -1
  183. package/lib/kerror/errors/kuzzleError.d.ts +1 -1
  184. package/lib/kerror/errors/multipleErrorsError.d.ts +1 -1
  185. package/lib/kerror/errors/multipleErrorsError.js +1 -1
  186. package/lib/kerror/errors/notFoundError.d.ts +1 -1
  187. package/lib/kerror/errors/partialError.d.ts +1 -1
  188. package/lib/kerror/errors/partialError.js +1 -1
  189. package/lib/kerror/errors/pluginImplementationError.d.ts +1 -1
  190. package/lib/kerror/errors/pluginImplementationError.js +2 -1
  191. package/lib/kerror/errors/preconditionError.d.ts +1 -1
  192. package/lib/kerror/errors/serviceUnavailableError.d.ts +1 -1
  193. package/lib/kerror/errors/sizeLimitError.d.ts +1 -1
  194. package/lib/kerror/errors/tooManyRequestsError.d.ts +1 -1
  195. package/lib/kerror/errors/unauthorizedError.d.ts +1 -1
  196. package/lib/kerror/index.d.ts +3 -3
  197. package/lib/kerror/index.js +17 -16
  198. package/lib/kuzzle/dumpGenerator.js +130 -114
  199. package/lib/kuzzle/event/kuzzleEventEmitter.js +96 -70
  200. package/lib/kuzzle/event/pipeRunner.js +25 -24
  201. package/lib/kuzzle/event/waterfall.js +13 -15
  202. package/lib/kuzzle/index.js +2 -2
  203. package/lib/kuzzle/internalIndexHandler.js +80 -59
  204. package/lib/kuzzle/kuzzle.js +99 -99
  205. package/lib/kuzzle/kuzzleStateEnum.js +1 -1
  206. package/lib/kuzzle/log.js +23 -18
  207. package/lib/kuzzle/vault.js +34 -19
  208. package/lib/model/security/profile.d.ts +3 -3
  209. package/lib/model/security/profile.js +38 -37
  210. package/lib/model/security/rights.js +5 -5
  211. package/lib/model/security/role.d.ts +3 -3
  212. package/lib/model/security/role.js +25 -26
  213. package/lib/model/security/token.d.ts +1 -1
  214. package/lib/model/security/token.js +4 -4
  215. package/lib/model/security/user.d.ts +2 -2
  216. package/lib/model/security/user.js +9 -9
  217. package/lib/model/storage/apiKey.js +43 -33
  218. package/lib/model/storage/baseModel.js +49 -45
  219. package/lib/service/cache/redis.js +60 -55
  220. package/lib/service/service.js +17 -17
  221. package/lib/service/storage/elasticsearch.js +839 -755
  222. package/lib/service/storage/esWrapper.js +103 -86
  223. package/lib/service/storage/queryTranslator.js +52 -59
  224. package/lib/types/Controller.d.ts +3 -3
  225. package/lib/types/ControllerDefinition.d.ts +3 -3
  226. package/lib/types/DebugModule.d.ts +2 -2
  227. package/lib/types/DebugModule.js +1 -1
  228. package/lib/types/Global.d.ts +1 -1
  229. package/lib/types/HttpStream.d.ts +2 -1
  230. package/lib/types/HttpStream.js +7 -5
  231. package/lib/types/Kuzzle.d.ts +1 -1
  232. package/lib/types/KuzzleDocument.d.ts +1 -1
  233. package/lib/types/OpenApiDefinition.d.ts +1 -1
  234. package/lib/types/PasswordPolicy.d.ts +1 -1
  235. package/lib/types/Plugin.d.ts +6 -6
  236. package/lib/types/Plugin.js +2 -2
  237. package/lib/types/Policy.d.ts +1 -1
  238. package/lib/types/RequestPayload.d.ts +1 -1
  239. package/lib/types/ResponsePayload.d.ts +1 -1
  240. package/lib/types/Token.d.ts +1 -1
  241. package/lib/types/User.d.ts +1 -1
  242. package/lib/types/config/DumpConfiguration.d.ts +8 -8
  243. package/lib/types/config/HttpConfiguration.d.ts +1 -1
  244. package/lib/types/config/KuzzleConfiguration.d.ts +1 -1
  245. package/lib/types/config/LimitsConfiguration.d.ts +8 -8
  246. package/lib/types/config/PluginsConfiguration.d.ts +4 -4
  247. package/lib/types/config/SecurityConfiguration.d.ts +62 -62
  248. package/lib/types/config/ServerConfiguration.d.ts +55 -55
  249. package/lib/types/config/ServicesConfiguration.d.ts +2 -2
  250. package/lib/types/config/internalCache/InternalCacheRedisConfiguration.d.ts +10 -10
  251. package/lib/types/config/publicCache/PublicCacheRedisConfiguration.d.ts +3 -3
  252. package/lib/types/config/storageEngine/StorageEngineElasticsearchConfiguration.d.ts +194 -110
  253. package/lib/types/errors/ErrorDefinition.d.ts +1 -1
  254. package/lib/types/errors/ErrorDomains.d.ts +1 -1
  255. package/lib/types/index.d.ts +38 -38
  256. package/lib/types/realtime/RealtimeScope.d.ts +1 -1
  257. package/lib/types/realtime/RealtimeUsers.d.ts +1 -1
  258. package/lib/util/assertType.js +13 -11
  259. package/lib/util/async.d.ts +1 -0
  260. package/lib/util/async.js +61 -0
  261. package/lib/util/asyncStore.js +19 -21
  262. package/lib/util/bufferedPassThrough.d.ts +2 -2
  263. package/lib/util/bufferedPassThrough.js +4 -4
  264. package/lib/util/bytes.js +9 -13
  265. package/lib/util/crypto.js +1 -1
  266. package/lib/util/debug.js +5 -5
  267. package/lib/util/deprecate.js +24 -21
  268. package/lib/util/didYouMean.js +7 -7
  269. package/lib/util/dump-collection.d.ts +2 -2
  270. package/lib/util/dump-collection.js +26 -26
  271. package/lib/util/esRequest.d.ts +1 -0
  272. package/lib/util/esRequest.js +62 -0
  273. package/lib/util/extractFields.js +24 -25
  274. package/lib/util/inflector.js +5 -5
  275. package/lib/util/koncordeCompat.d.ts +2 -2
  276. package/lib/util/koncordeCompat.js +5 -5
  277. package/lib/util/memoize.js +3 -5
  278. package/lib/util/mutex.d.ts +19 -1
  279. package/lib/util/mutex.js +39 -12
  280. package/lib/util/name-generator.js +1331 -1331
  281. package/lib/util/promback.js +8 -10
  282. package/lib/util/readYamlFile.d.ts +1 -1
  283. package/lib/util/readYamlFile.js +1 -1
  284. package/lib/util/requestAssertions.js +34 -34
  285. package/lib/util/safeObject.js +5 -5
  286. package/lib/util/stackTrace.js +20 -22
  287. package/lib/util/wildcard.js +15 -15
  288. package/package.json +6 -6
  289. package/npm-shrinkwrap.json +0 -19422
@@ -45,7 +45,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
46
  exports.IndexCache = void 0;
47
47
  const kerror = __importStar(require("../../kerror"));
48
- const storageError = kerror.wrap('services', 'storage');
48
+ const storageError = kerror.wrap("services", "storage");
49
49
  class IndexCache {
50
50
  constructor() {
51
51
  /**
@@ -129,7 +129,7 @@ class IndexCache {
129
129
  */
130
130
  assertIndexExists(index) {
131
131
  if (!this.indexes.has(index)) {
132
- throw storageError.get('unknown_index', index);
132
+ throw storageError.get("unknown_index", index);
133
133
  }
134
134
  }
135
135
  /**
@@ -138,7 +138,7 @@ class IndexCache {
138
138
  assertCollectionExists(index, collection) {
139
139
  this.assertIndexExists(index);
140
140
  if (!this.indexes.get(index).has(collection)) {
141
- throw storageError.get('unknown_collection', index, collection);
141
+ throw storageError.get("unknown_collection", index, collection);
142
142
  }
143
143
  }
144
144
  }
@@ -19,16 +19,16 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- const Bluebird = require('bluebird');
24
+ const Bluebird = require("bluebird");
25
25
 
26
- const kerror = require('../../kerror').wrap('services', 'storage');
27
- const ClientAdapter = require('./clientAdapter');
28
- const scopeEnum = require('./storeScopeEnum');
26
+ const kerror = require("../../kerror").wrap("services", "storage");
27
+ const ClientAdapter = require("./clientAdapter");
28
+ const scopeEnum = require("./storeScopeEnum");
29
29
 
30
30
  class StorageEngine {
31
- constructor () {
31
+ constructor() {
32
32
  // Storage client for public indexes only
33
33
  this.public = new ClientAdapter(scopeEnum.PUBLIC);
34
34
 
@@ -41,21 +41,18 @@ class StorageEngine {
41
41
  *
42
42
  * @returns {Promise}
43
43
  */
44
- async init () {
45
- await Bluebird.all([
46
- this.public.init(),
47
- this.private.init(),
48
- ]);
44
+ async init() {
45
+ await Bluebird.all([this.public.init(), this.private.init()]);
49
46
 
50
47
  const privateIndexes = await this.private.cache.listIndexes();
51
48
 
52
49
  for (const publicIndex of await this.public.cache.listIndexes()) {
53
50
  if (privateIndexes.includes(publicIndex)) {
54
- throw kerror.get('index_already_exists', 'public', publicIndex);
51
+ throw kerror.get("index_already_exists", "public", publicIndex);
55
52
  }
56
53
  }
57
54
 
58
- global.kuzzle.log.info('[✔] Storage initialized');
55
+ global.kuzzle.log.info("[✔] Storage initialized");
59
56
  }
60
57
  }
61
58
 
@@ -19,7 +19,7 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  /**
25
25
  * @typedef {string} storeScopeEnum
@@ -32,8 +32,8 @@
32
32
  * @enum {storeScopeEnum}
33
33
  */
34
34
  const storeScopeEnum = Object.freeze({
35
- PRIVATE: 'private',
36
- PUBLIC: 'public',
35
+ PRIVATE: "private",
36
+ PUBLIC: "public",
37
37
  });
38
38
 
39
39
  module.exports = storeScopeEnum;
@@ -19,7 +19,7 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
24
  /**
25
25
  * @class BaseType
@@ -33,7 +33,7 @@ class BaseType {
33
33
  * @param {string[]} errorMessages
34
34
  * @returns {boolean}
35
35
  */
36
- validate () {
36
+ validate() {
37
37
  return true;
38
38
  }
39
39
 
@@ -44,7 +44,7 @@ class BaseType {
44
44
  * @returns {TypeOptions}
45
45
  * @throws {KuzzleError}
46
46
  */
47
- validateFieldSpecification (opts) {
47
+ validateFieldSpecification(opts) {
48
48
  return opts;
49
49
  }
50
50
 
@@ -53,16 +53,18 @@ class BaseType {
53
53
  * @param {string[]} allowedProperties
54
54
  * @returns {boolean}
55
55
  */
56
- checkAllowedProperties (object, allowedProperties) {
57
- if (typeof object !== 'object'
58
- || Array.isArray(object)
59
- || object === null
56
+ checkAllowedProperties(object, allowedProperties) {
57
+ if (
58
+ typeof object !== "object" ||
59
+ Array.isArray(object) ||
60
+ object === null
60
61
  ) {
61
62
  return false;
62
63
  }
63
64
 
64
- return ! Object.keys(object).some(
65
- propertyName => allowedProperties.indexOf(propertyName) === -1);
65
+ return !Object.keys(object).some(
66
+ (propertyName) => allowedProperties.indexOf(propertyName) === -1
67
+ );
66
68
  }
67
69
 
68
70
  /**
@@ -70,7 +72,7 @@ class BaseType {
70
72
  * @param {boolean} parentStrictness
71
73
  * @returns {boolean}
72
74
  */
73
- getStrictness (fieldSpec, parentStrictness) {
75
+ getStrictness(fieldSpec, parentStrictness) {
74
76
  return parentStrictness;
75
77
  }
76
78
  }
@@ -19,6 +19,6 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- module.exports = require('./validation');
24
+ module.exports = require("./validation");
@@ -19,17 +19,17 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- const BaseType = require('../baseType');
24
+ const BaseType = require("../baseType");
25
25
 
26
26
  /**
27
27
  * @class AnythingType
28
28
  */
29
29
  class AnythingType extends BaseType {
30
- constructor () {
30
+ constructor() {
31
31
  super();
32
- this.typeName = 'anything';
32
+ this.typeName = "anything";
33
33
  this.allowChildren = false;
34
34
  this.allowedTypeOptions = [];
35
35
  }
@@ -19,17 +19,17 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- const BaseType = require('../baseType');
24
+ const BaseType = require("../baseType");
25
25
 
26
26
  /**
27
27
  * @class BooleanType
28
28
  */
29
29
  class BooleanType extends BaseType {
30
- constructor () {
30
+ constructor() {
31
31
  super();
32
- this.typeName = 'boolean';
32
+ this.typeName = "boolean";
33
33
  this.allowChildren = false;
34
34
  this.allowedTypeOptions = [];
35
35
  }
@@ -39,9 +39,9 @@ class BooleanType extends BaseType {
39
39
  * @param {*} fieldValue
40
40
  * @param {string[]} errorMessages
41
41
  */
42
- validate (typeOptions, fieldValue, errorMessages) {
43
- if (typeof fieldValue !== 'boolean') {
44
- errorMessages.push('The field must be of type boolean.');
42
+ validate(typeOptions, fieldValue, errorMessages) {
43
+ if (typeof fieldValue !== "boolean") {
44
+ errorMessages.push("The field must be of type boolean.");
45
45
  return false;
46
46
  }
47
47
 
@@ -19,106 +19,138 @@
19
19
  * limitations under the License.
20
20
  */
21
21
 
22
- 'use strict';
22
+ "use strict";
23
23
 
24
- const
25
- kerror = require('../../../kerror'),
26
- { has, isPlainObject } = require('../../../util/safeObject'),
27
- BaseType = require('../baseType'),
28
- moment = require('moment'),
24
+ const kerror = require("../../../kerror"),
25
+ { has, isPlainObject } = require("../../../util/safeObject"),
26
+ BaseType = require("../baseType"),
27
+ moment = require("moment"),
29
28
  formatMap = {
30
- basic_date: date => moment.utc(date, 'YYYYMMDD', true),
31
- basic_date_time: date => moment.utc(date, 'YYYYMMDD\\THHmmss.SSSZ', true),
32
- basic_date_time_no_millis: date => moment.utc(date, 'YYYYMMDD\\THHmmssZ', true),
33
- basic_ordinal_date: date => moment.utc(date, 'YYYYDDD', true),
34
- basic_ordinal_date_time: date => moment.utc(date, 'YYYYDDD\\THHmmss.SSSZ', true),
35
- basic_ordinal_date_time_no_millis: date => moment.utc(date, 'YYYYDDD\\THHmmssZ', true),
36
- basic_t_time: date => moment.utc(date, '\\THHmmss.SSSZ', true),
37
- basic_t_time_no_millis: date => moment.utc(date, '\\THHmmssZ', true),
38
- basic_time: date => moment.utc(date, 'HHmmss.SSSZ', true),
39
- basic_time_no_millis: date => moment.utc(date, 'HHmmssZ', true),
40
- basic_week_date: date => moment.utc(date, 'gggg\\Wwwe', false),
41
- basic_week_date_time: date => moment.utc(date, 'gggg\\Wwwe\\THHmmss.SSSZ', false),
42
- basic_week_date_time_no_millis: date => moment.utc(date, 'gggg\\Wwwe\\THHmmssZ', false),
43
- date: date => moment.utc(date, 'YYYY-MM-DD', false),
44
- date_hour: date => moment.utc(date, 'YYYY-MM-DD\\THH', false),
45
- date_hour_minute: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm', false),
46
- date_hour_minute_second: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss', false),
47
- date_hour_minute_second_fraction: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss.SSS', false),
48
- date_hour_minute_second_millis: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss.SSS', false),
49
- date_time: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss.SSSZZ', false),
50
- date_time_no_millis: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ssZZ', false),
51
- epoch_millis: date => typeof date === 'number' ? moment.utc(date) : moment.invalid(),
52
- epoch_second: date => typeof date === 'number' ? moment.utc(moment.unix(date)) : moment.invalid(),
53
- hour: date => moment.utc(date, 'HH', false),
54
- hour_minute: date => moment.utc(date, 'HH:mm', false),
55
- hour_minute_second: date => moment.utc(date, 'HH:mm:ss', false),
56
- hour_minute_second_fraction: date => moment.utc(date, 'HH:mm:ss.SSS', false),
57
- hour_minute_second_millis: date => moment.utc(date, 'HH:mm:ss.SSS', false),
58
- ordinal_date: date => moment.utc(date, 'YYYY-DDD', false),
59
- ordinal_date_time: date => moment.utc(date, 'YYYY-DDD\\THH:mm:ss.SSSZZ', false),
60
- ordinal_date_time_no_millis: date => moment.utc(date, 'YYYY-DDD\\THH:mm:ssZZ', false),
61
- strict_basic_week_date: date => moment.utc(date, 'gggg\\Wwwe', true),
62
- strict_basic_week_date_time: date => moment.utc(date, 'gggg\\Wwwe\\THHmmss.SSSZ', true),
63
- strict_basic_week_date_time_no_millis: date => moment.utc(date, 'gggg\\Wwwe\\THHmmssZ', true),
64
- strict_date: date => moment.utc(date, 'YYYY-MM-DD', true),
65
- strict_date_hour: date => moment.utc(date, 'YYYY-MM-DD\\THH', true),
66
- strict_date_hour_minute: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm', true),
67
- strict_date_hour_minute_second: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss', true),
68
- strict_date_hour_minute_second_fraction: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss.SSS', true),
69
- strict_date_hour_minute_second_millis: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss.SSS', true),
70
- strict_date_optional_time: date => moment.utc(date, moment.ISO_8601, true),
71
- strict_date_time: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ss.SSSZZ', true),
72
- strict_date_time_no_millis: date => moment.utc(date, 'YYYY-MM-DD\\THH:mm:ssZZ', true),
73
- strict_hour: date => moment.utc(date, 'HH', true),
74
- strict_hour_minute: date => moment.utc(date, 'HH:mm', true),
75
- strict_hour_minute_second: date => moment.utc(date, 'HH:mm:ss', true),
76
- strict_hour_minute_second_fraction: date => moment.utc(date, 'HH:mm:ss.SSS', true),
77
- strict_hour_minute_second_millis: date => moment.utc(date, 'HH:mm:ss.SSS', true),
78
- strict_ordinal_date: date => moment.utc(date, 'YYYY-DDD', true),
79
- strict_ordinal_date_time: date => moment.utc(date, 'YYYY-DDD\\THH:mm:ss.SSSZZ', true),
80
- strict_ordinal_date_time_no_millis: date => moment.utc(date, 'YYYY-DDD\\THH:mm:ssZZ', true),
81
- strict_t_time: date => moment.utc(date, '\\THH:mm:ss.SSSZZ', true),
82
- strict_t_time_no_millis: date => moment.utc(date, '\\THH:mm:ssZZ', true),
83
- strict_time: date => moment.utc(date, 'HH:mm:ss.SSSZZ', true),
84
- strict_time_no_millis: date => moment.utc(date, 'HH:mm:ssZZ', true),
85
- strict_week_date: date => moment.utc(date, 'gggg-\\Www-e', true),
86
- strict_week_date_time: date => moment.utc(date, 'gggg-\\Www-e\\THH:mm:ss.SSSZZ', true),
87
- strict_week_date_time_no_millis: date => moment.utc(date, 'gggg-\\Www-e\\THH:mm:ssZZ', true),
88
- strict_weekyear: date => moment.utc(date, 'gggg', true),
89
- strict_weekyear_week: date => moment.utc(date, 'ggggww', true),
90
- strict_weekyear_week_day: date => moment.utc(date, 'ggggwwe', true),
91
- strict_year: date => moment.utc(date, 'YYYY', true),
92
- strict_year_month: date => moment.utc(date, 'YYYYMM', true),
93
- strict_year_month_day: date => moment.utc(date, 'YYYYMMDD', true),
94
- t_time: date => moment.utc(date, '\\THH:mm:ss.SSSZZ', false),
95
- t_time_no_millis: date => moment.utc(date, '\\THH:mm:ssZZ', false),
96
- time: date => moment.utc(date, 'HH:mm:ss.SSSZZ', false),
97
- time_no_millis: date => moment.utc(date, 'HH:mm:ssZZ', false),
98
- week_date: date => moment.utc(date, 'gggg-\\Www-e', false),
99
- week_date_time: date => moment.utc(date, 'gggg-\\Www-e\\THH:mm:ss.SSSZZ', false),
100
- week_date_time_no_millis: date => moment.utc(date, 'gggg-\\Www-e\\THH:mm:ssZZ', false),
101
- weekyear: date => moment.utc(date, 'gggg', false),
102
- weekyear_week: date => moment.utc(date, 'ggggww', false),
103
- weekyear_week_day: date => moment.utc(date, 'ggggwwe', false),
104
- year: date => moment.utc(date, 'YYYY', false),
105
- year_month: date => moment.utc(date, 'YYYYMM', false),
106
- year_month_day: date => moment.utc(date, 'YYYYMMDD', false)
29
+ basic_date: (date) => moment.utc(date, "YYYYMMDD", true),
30
+ basic_date_time: (date) => moment.utc(date, "YYYYMMDD\\THHmmss.SSSZ", true),
31
+ basic_date_time_no_millis: (date) =>
32
+ moment.utc(date, "YYYYMMDD\\THHmmssZ", true),
33
+ basic_ordinal_date: (date) => moment.utc(date, "YYYYDDD", true),
34
+ basic_ordinal_date_time: (date) =>
35
+ moment.utc(date, "YYYYDDD\\THHmmss.SSSZ", true),
36
+ basic_ordinal_date_time_no_millis: (date) =>
37
+ moment.utc(date, "YYYYDDD\\THHmmssZ", true),
38
+ basic_t_time: (date) => moment.utc(date, "\\THHmmss.SSSZ", true),
39
+ basic_t_time_no_millis: (date) => moment.utc(date, "\\THHmmssZ", true),
40
+ basic_time: (date) => moment.utc(date, "HHmmss.SSSZ", true),
41
+ basic_time_no_millis: (date) => moment.utc(date, "HHmmssZ", true),
42
+ basic_week_date: (date) => moment.utc(date, "gggg\\Wwwe", false),
43
+ basic_week_date_time: (date) =>
44
+ moment.utc(date, "gggg\\Wwwe\\THHmmss.SSSZ", false),
45
+ basic_week_date_time_no_millis: (date) =>
46
+ moment.utc(date, "gggg\\Wwwe\\THHmmssZ", false),
47
+ date: (date) => moment.utc(date, "YYYY-MM-DD", false),
48
+ date_hour: (date) => moment.utc(date, "YYYY-MM-DD\\THH", false),
49
+ date_hour_minute: (date) => moment.utc(date, "YYYY-MM-DD\\THH:mm", false),
50
+ date_hour_minute_second: (date) =>
51
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss", false),
52
+ date_hour_minute_second_fraction: (date) =>
53
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss.SSS", false),
54
+ date_hour_minute_second_millis: (date) =>
55
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss.SSS", false),
56
+ date_time: (date) => moment.utc(date, "YYYY-MM-DD\\THH:mm:ss.SSSZZ", false),
57
+ date_time_no_millis: (date) =>
58
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ssZZ", false),
59
+ epoch_millis: (date) =>
60
+ typeof date === "number" ? moment.utc(date) : moment.invalid(),
61
+ epoch_second: (date) =>
62
+ typeof date === "number"
63
+ ? moment.utc(moment.unix(date))
64
+ : moment.invalid(),
65
+ hour: (date) => moment.utc(date, "HH", false),
66
+ hour_minute: (date) => moment.utc(date, "HH:mm", false),
67
+ hour_minute_second: (date) => moment.utc(date, "HH:mm:ss", false),
68
+ hour_minute_second_fraction: (date) =>
69
+ moment.utc(date, "HH:mm:ss.SSS", false),
70
+ hour_minute_second_millis: (date) =>
71
+ moment.utc(date, "HH:mm:ss.SSS", false),
72
+ ordinal_date: (date) => moment.utc(date, "YYYY-DDD", false),
73
+ ordinal_date_time: (date) =>
74
+ moment.utc(date, "YYYY-DDD\\THH:mm:ss.SSSZZ", false),
75
+ ordinal_date_time_no_millis: (date) =>
76
+ moment.utc(date, "YYYY-DDD\\THH:mm:ssZZ", false),
77
+ strict_basic_week_date: (date) => moment.utc(date, "gggg\\Wwwe", true),
78
+ strict_basic_week_date_time: (date) =>
79
+ moment.utc(date, "gggg\\Wwwe\\THHmmss.SSSZ", true),
80
+ strict_basic_week_date_time_no_millis: (date) =>
81
+ moment.utc(date, "gggg\\Wwwe\\THHmmssZ", true),
82
+ strict_date: (date) => moment.utc(date, "YYYY-MM-DD", true),
83
+ strict_date_hour: (date) => moment.utc(date, "YYYY-MM-DD\\THH", true),
84
+ strict_date_hour_minute: (date) =>
85
+ moment.utc(date, "YYYY-MM-DD\\THH:mm", true),
86
+ strict_date_hour_minute_second: (date) =>
87
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss", true),
88
+ strict_date_hour_minute_second_fraction: (date) =>
89
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss.SSS", true),
90
+ strict_date_hour_minute_second_millis: (date) =>
91
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss.SSS", true),
92
+ strict_date_optional_time: (date) =>
93
+ moment.utc(date, moment.ISO_8601, true),
94
+ strict_date_time: (date) =>
95
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ss.SSSZZ", true),
96
+ strict_date_time_no_millis: (date) =>
97
+ moment.utc(date, "YYYY-MM-DD\\THH:mm:ssZZ", true),
98
+ strict_hour: (date) => moment.utc(date, "HH", true),
99
+ strict_hour_minute: (date) => moment.utc(date, "HH:mm", true),
100
+ strict_hour_minute_second: (date) => moment.utc(date, "HH:mm:ss", true),
101
+ strict_hour_minute_second_fraction: (date) =>
102
+ moment.utc(date, "HH:mm:ss.SSS", true),
103
+ strict_hour_minute_second_millis: (date) =>
104
+ moment.utc(date, "HH:mm:ss.SSS", true),
105
+ strict_ordinal_date: (date) => moment.utc(date, "YYYY-DDD", true),
106
+ strict_ordinal_date_time: (date) =>
107
+ moment.utc(date, "YYYY-DDD\\THH:mm:ss.SSSZZ", true),
108
+ strict_ordinal_date_time_no_millis: (date) =>
109
+ moment.utc(date, "YYYY-DDD\\THH:mm:ssZZ", true),
110
+ strict_t_time: (date) => moment.utc(date, "\\THH:mm:ss.SSSZZ", true),
111
+ strict_t_time_no_millis: (date) => moment.utc(date, "\\THH:mm:ssZZ", true),
112
+ strict_time: (date) => moment.utc(date, "HH:mm:ss.SSSZZ", true),
113
+ strict_time_no_millis: (date) => moment.utc(date, "HH:mm:ssZZ", true),
114
+ strict_week_date: (date) => moment.utc(date, "gggg-\\Www-e", true),
115
+ strict_week_date_time: (date) =>
116
+ moment.utc(date, "gggg-\\Www-e\\THH:mm:ss.SSSZZ", true),
117
+ strict_week_date_time_no_millis: (date) =>
118
+ moment.utc(date, "gggg-\\Www-e\\THH:mm:ssZZ", true),
119
+ strict_weekyear: (date) => moment.utc(date, "gggg", true),
120
+ strict_weekyear_week: (date) => moment.utc(date, "ggggww", true),
121
+ strict_weekyear_week_day: (date) => moment.utc(date, "ggggwwe", true),
122
+ strict_year: (date) => moment.utc(date, "YYYY", true),
123
+ strict_year_month: (date) => moment.utc(date, "YYYYMM", true),
124
+ strict_year_month_day: (date) => moment.utc(date, "YYYYMMDD", true),
125
+ t_time: (date) => moment.utc(date, "\\THH:mm:ss.SSSZZ", false),
126
+ t_time_no_millis: (date) => moment.utc(date, "\\THH:mm:ssZZ", false),
127
+ time: (date) => moment.utc(date, "HH:mm:ss.SSSZZ", false),
128
+ time_no_millis: (date) => moment.utc(date, "HH:mm:ssZZ", false),
129
+ week_date: (date) => moment.utc(date, "gggg-\\Www-e", false),
130
+ week_date_time: (date) =>
131
+ moment.utc(date, "gggg-\\Www-e\\THH:mm:ss.SSSZZ", false),
132
+ week_date_time_no_millis: (date) =>
133
+ moment.utc(date, "gggg-\\Www-e\\THH:mm:ssZZ", false),
134
+ weekyear: (date) => moment.utc(date, "gggg", false),
135
+ weekyear_week: (date) => moment.utc(date, "ggggww", false),
136
+ weekyear_week_day: (date) => moment.utc(date, "ggggwwe", false),
137
+ year: (date) => moment.utc(date, "YYYY", false),
138
+ year_month: (date) => moment.utc(date, "YYYYMM", false),
139
+ year_month_day: (date) => moment.utc(date, "YYYYMMDD", false),
107
140
  };
108
141
 
109
- const
110
- assertionError = kerror.wrap('validation', 'assert'),
111
- typeError = kerror.wrap('validation', 'types');
142
+ const assertionError = kerror.wrap("validation", "assert"),
143
+ typeError = kerror.wrap("validation", "types");
112
144
 
113
145
  /**
114
146
  * @class DateType
115
147
  */
116
148
  class DateType extends BaseType {
117
- constructor () {
149
+ constructor() {
118
150
  super();
119
- this.typeName = 'date';
151
+ this.typeName = "date";
120
152
  this.allowChildren = false;
121
- this.allowedTypeOptions = ['range', 'formats'];
153
+ this.allowedTypeOptions = ["range", "formats"];
122
154
  }
123
155
 
124
156
  /**
@@ -127,7 +159,7 @@ class DateType extends BaseType {
127
159
  * @param {string[]} errorMessages
128
160
  * @returns {boolean}
129
161
  */
130
- validate (typeOptions, fieldValue, errorMessages) {
162
+ validate(typeOptions, fieldValue, errorMessages) {
131
163
  let momentDate = null;
132
164
 
133
165
  for (const formatOpt of typeOptions.formats) {
@@ -138,30 +170,34 @@ class DateType extends BaseType {
138
170
  }
139
171
  }
140
172
 
141
- if (momentDate === null || ! momentDate.isValid()) {
142
- errorMessages.push('The date format is invalid.');
173
+ if (momentDate === null || !momentDate.isValid()) {
174
+ errorMessages.push("The date format is invalid.");
143
175
  return false;
144
176
  }
145
177
 
146
178
  if (isPlainObject(typeOptions.range)) {
147
179
  if (typeOptions.range.min) {
148
- const min = typeOptions.range.min === 'NOW'
149
- ? moment.utc()
150
- : typeOptions.range.min;
180
+ const min =
181
+ typeOptions.range.min === "NOW"
182
+ ? moment.utc()
183
+ : typeOptions.range.min;
151
184
 
152
185
  if (momentDate.isBefore(min)) {
153
- errorMessages.push('The provided date is before the defined minimum.');
186
+ errorMessages.push(
187
+ "The provided date is before the defined minimum."
188
+ );
154
189
  return false;
155
190
  }
156
191
  }
157
192
 
158
193
  if (typeOptions.range.max) {
159
- const max = typeOptions.range.max === 'NOW'
160
- ? moment.utc()
161
- : typeOptions.range.max;
194
+ const max =
195
+ typeOptions.range.max === "NOW"
196
+ ? moment.utc()
197
+ : typeOptions.range.max;
162
198
 
163
199
  if (max.isBefore(momentDate)) {
164
- errorMessages.push('The provided date is after the defined maximum.');
200
+ errorMessages.push("The provided date is after the defined maximum.");
165
201
  return false;
166
202
  }
167
203
  }
@@ -175,51 +211,50 @@ class DateType extends BaseType {
175
211
  * @returns {TypeOptions}
176
212
  * @throws {PreconditionError}
177
213
  */
178
- validateFieldSpecification (typeOptions) {
179
- if (has(typeOptions, 'formats')) {
180
- if ( ! Array.isArray(typeOptions.formats)
181
- || typeOptions.formats.length === 0
214
+ validateFieldSpecification(typeOptions) {
215
+ if (has(typeOptions, "formats")) {
216
+ if (
217
+ !Array.isArray(typeOptions.formats) ||
218
+ typeOptions.formats.length === 0
182
219
  ) {
183
- throw assertionError.get('invalid_type', 'formats', 'non-empty array');
220
+ throw assertionError.get("invalid_type", "formats", "non-empty array");
184
221
  }
185
222
 
186
- const unrecognized = typeOptions.formats.filter(f => ! formatMap[f]);
223
+ const unrecognized = typeOptions.formats.filter((f) => !formatMap[f]);
187
224
  if (unrecognized.length > 0) {
188
- throw typeError.get('invalid_date_format', unrecognized.join(', '));
225
+ throw typeError.get("invalid_date_format", unrecognized.join(", "));
189
226
  }
190
- }
191
- else {
192
- typeOptions.formats = ['epoch_millis'];
227
+ } else {
228
+ typeOptions.formats = ["epoch_millis"];
193
229
  }
194
230
 
195
- if (has(typeOptions, 'range')) {
196
- let
197
- min = null,
231
+ if (has(typeOptions, "range")) {
232
+ let min = null,
198
233
  max = null;
199
234
 
200
- if (! this.checkAllowedProperties(typeOptions.range, ['min', 'max'])) {
201
- throw assertionError.get('unexpected_properties', 'range', 'min, max');
235
+ if (!this.checkAllowedProperties(typeOptions.range, ["min", "max"])) {
236
+ throw assertionError.get("unexpected_properties", "range", "min, max");
202
237
  }
203
238
 
204
- if (has(typeOptions.range, 'min')) {
205
- min = convertRangeValue('min', typeOptions.range.min);
239
+ if (has(typeOptions.range, "min")) {
240
+ min = convertRangeValue("min", typeOptions.range.min);
206
241
  }
207
242
 
208
- if (has(typeOptions.range, 'max')) {
209
- max = convertRangeValue('max', typeOptions.range.max);
243
+ if (has(typeOptions.range, "max")) {
244
+ max = convertRangeValue("max", typeOptions.range.max);
210
245
  }
211
246
 
212
247
  if (min && max && max.isBefore(min)) {
213
- throw assertionError.get('invalid_range', 'range', 'min', 'max');
248
+ throw assertionError.get("invalid_range", "range", "min", "max");
214
249
  }
215
250
 
216
251
  // We want to keep NOW as a special value, else we would keep the time
217
252
  // of the launch
218
- if (min && typeOptions.range.min !== 'NOW') {
253
+ if (min && typeOptions.range.min !== "NOW") {
219
254
  typeOptions.range.min = min;
220
255
  }
221
256
 
222
- if (max && typeOptions.range.max !== 'NOW') {
257
+ if (max && typeOptions.range.max !== "NOW") {
223
258
  typeOptions.range.max = max;
224
259
  }
225
260
  }
@@ -228,20 +263,19 @@ class DateType extends BaseType {
228
263
  }
229
264
  }
230
265
 
231
- function convertRangeValue (name, value) {
266
+ function convertRangeValue(name, value) {
232
267
  let converted;
233
268
 
234
- if (typeof value === 'string') {
235
- converted = value === 'NOW'
236
- ? moment.utc()
237
- : moment.utc(value, moment.ISO_8601);
238
- }
239
- else if (typeof value === 'number') { // epoch or epoch-millis
269
+ if (typeof value === "string") {
270
+ converted =
271
+ value === "NOW" ? moment.utc() : moment.utc(value, moment.ISO_8601);
272
+ } else if (typeof value === "number") {
273
+ // epoch or epoch-millis
240
274
  converted = moment.utc(value);
241
275
  }
242
276
 
243
- if (! converted || ! converted.isValid()) {
244
- throw typeError.get('invalid_date', value);
277
+ if (!converted || !converted.isValid()) {
278
+ throw typeError.get("invalid_date", value);
245
279
  }
246
280
 
247
281
  return converted;