-
Notifications
You must be signed in to change notification settings - Fork 9
/
schema.js
80 lines (76 loc) · 3.17 KB
/
schema.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
const Joi = require('joi');
// Schema Configuration
// required:
// * api.version (string)
// * api.indexName (string)
// * api.host (string)
// * esclient (object - positive integer requestTimeout)
//
// optional:
// * api.accessLog (string)
// * api.relativeScores (boolean)
// * api.localization (flipNumberAndStreetCountries is array of 3 character strings)
module.exports = Joi.object().keys({
api: Joi.object().keys({
version: Joi.string(),
indexName: Joi.string(),
host: Joi.string(),
accessLog: Joi.string(),
relativeScores: Joi.boolean(),
requestRetries: Joi.number().integer().min(0),
customBoosts: Joi.object().keys({
layer: Joi.object(),
source: Joi.object()
}),
localization: Joi.object().keys({
flipNumberAndStreetCountries: Joi.array().items(Joi.string().regex(/^[A-Z]{3}$/)),
confidenceAdminWeights: Joi.object(),
confidenceAddressParts: Joi.object(),
filteredRegions: Joi.array().items(Joi.string()),
cleanRegions: Joi.boolean(),
postalCodeValidator: Joi.string(),
streetNumberValidator: Joi.string(),
translations: Joi.string(),
equalCharMap: Joi.object(),
labelSchemas: Joi.object()
}).unknown(false),
sizePadding: Joi.number().integer().min(2),
minConfidence: Joi.number(),
relativeMinConfidence: Joi.number(),
languageMatchThreshold: Joi.number(),
query: Joi.object(),
languages: Joi.array().items(Joi.string()),
languageMap: Joi.object(),
pipService: Joi.any(), // got moved to services, ignored for now
placeholderService: Joi.any().forbidden(), // got moved to services
services: Joi.object().keys({
pip: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
}).unknown(false).requiredKeys('url'),
placeholder: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
}).unknown(false).requiredKeys('url'),
interpolation: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
}).unknown(false).requiredKeys('url'),
libpostal: Joi.object().keys({
url: Joi.string().uri({ scheme: /https?/ }),
timeout: Joi.number().integer().optional().default(250).min(0),
retries: Joi.number().integer().optional().default(3).min(0),
}).unknown(false).requiredKeys('url')
}).unknown(false).default({}), // default api.services to an empty object
defaultParameters: Joi.object().keys({
'focus.point.lat': Joi.number(),
'focus.point.lon': Joi.number(),
}).unknown(true).default({})
}).requiredKeys('version', 'indexName', 'host').unknown(true),
esclient: Joi.object().keys({
requestTimeout: Joi.number().integer().min(0)
}).unknown(true)
}).requiredKeys('api', 'esclient').unknown(true);