-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathconstants.mjs
More file actions
51 lines (47 loc) · 1.55 KB
/
constants.mjs
File metadata and controls
51 lines (47 loc) · 1.55 KB
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
// Error Messages
export const ERRORS = {
missingCCandHFiles:
'Both node_options.cc and node_options.h must be provided.',
headerTypeNotFound:
'Header type for "{{headerKey}}" not found in the header file.',
missingTypeDefinition:
'No type definition found for header type "{{headerType}}" in TYPE_DEFINITION_MAP.',
};
// Regex pattern to match calls to the AddOption function.
export const ADD_OPTION_REGEX =
/AddOption[\s\n\r]*\([\s\n\r]*"([^"]+)"(.*?)\);/gs;
// Regex pattern to match header keys in the Options class.
export const OPTION_HEADER_KEY_REGEX = /Options::(\w+)/;
// Basic JSON schema for node.config.json
export const BASIC_SCHEMA = {
$schema: 'https://json-schema.org/draft/2020-12/schema',
additionalProperties: false,
properties: {
$schema: {
type: 'string',
},
nodeOptions: {
additionalProperties: false,
properties: {},
type: 'object',
},
},
type: 'object',
};
// Schema Definition Map for Data Types
export const TYPE_DEFINITION_MAP = {
'std::vector<std::string>': {
oneOf: [
{ type: 'string' }, // Single string case
{
items: { type: 'string', minItems: 1 }, // Array of strings, ensuring at least one item
type: 'array',
},
],
},
uint64_t: { type: 'number' }, // 64-bit unsigned integer maps to a number
int64_t: { type: 'number' }, // 64-bit signed integer maps to a number
HostPort: { type: 'number' }, // HostPort is a number, like 4000
'std::string': { type: 'string' }, // String type
bool: { type: 'boolean' }, // Boolean type
};