@rosen-bridge/config 0.1.0 → 0.2.1

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.
@@ -67,6 +67,64 @@ export const correctApiSchema = {
67
67
  { choices: ['node', 'explorer'] },
68
68
  ],
69
69
  },
70
+ logs: {
71
+ type: 'array',
72
+ items: {
73
+ type: 'object',
74
+ children: {
75
+ type: {
76
+ type: 'string',
77
+ validations: [
78
+ {
79
+ required: true,
80
+ error: 'log type must be specified',
81
+ },
82
+ { choices: ['file', 'console', 'loki'] },
83
+ ],
84
+ },
85
+ maxSize: {
86
+ type: 'string',
87
+ validations: [
88
+ {
89
+ required: true,
90
+ error: 'maxSize for file log type must be specified',
91
+ when: { path: 'logs.type', value: 'file' },
92
+ },
93
+ ],
94
+ },
95
+ maxFiles: {
96
+ type: 'string',
97
+ validations: [
98
+ {
99
+ required: true,
100
+ error: 'maxFiles for file log type must be specified',
101
+ when: { path: 'logs.type', value: 'file' },
102
+ },
103
+ ],
104
+ },
105
+ path: {
106
+ type: 'string',
107
+ validations: [
108
+ {
109
+ required: true,
110
+ error: 'path for file log type must be specified',
111
+ when: { path: 'logs.type', value: 'file' },
112
+ },
113
+ ],
114
+ },
115
+ level: {
116
+ type: 'string',
117
+ validations: [
118
+ {
119
+ required: true,
120
+ error: 'log level must be specified',
121
+ when: { path: 'logs.type', value: 'file' },
122
+ },
123
+ ],
124
+ },
125
+ },
126
+ },
127
+ },
70
128
  servers: {
71
129
  type: 'object',
72
130
  children: {
@@ -94,6 +152,16 @@ export const correctApiSchema = {
94
152
  },
95
153
  },
96
154
  },
155
+ useTls: {
156
+ type: 'boolean',
157
+ default: false,
158
+ validations: [
159
+ {
160
+ required: true,
161
+ error: 'useTls must be specified',
162
+ },
163
+ ],
164
+ },
97
165
  },
98
166
  },
99
167
  };
@@ -140,6 +208,18 @@ export const schemaWithIncorrectPortDefaultValueTypeSample = {
140
208
  },
141
209
  };
142
210
 
211
+ export const arrayTypeSchemaWithoutItems = {
212
+ logs: {
213
+ type: 'array',
214
+ },
215
+ };
216
+
217
+ export const objectTypeSchemaWithoutChildren = {
218
+ api: {
219
+ type: 'object',
220
+ },
221
+ };
222
+
143
223
  export const apiSchemaConfigPair = {
144
224
  schema: {
145
225
  apiType: {
@@ -155,6 +235,64 @@ export const apiSchemaConfigPair = {
155
235
  { choices: ['node', 'explorer'] },
156
236
  ],
157
237
  },
238
+ logs: {
239
+ type: 'array',
240
+ items: {
241
+ type: 'object',
242
+ children: {
243
+ type: {
244
+ type: 'string',
245
+ validations: [
246
+ {
247
+ required: true,
248
+ error: 'log type must be specified',
249
+ },
250
+ { choices: ['file', 'console', 'loki'] },
251
+ ],
252
+ },
253
+ maxSize: {
254
+ type: 'string',
255
+ validations: [
256
+ {
257
+ required: true,
258
+ error: 'maxSize for file log type must be specified',
259
+ when: { path: 'logs.type', value: 'file' },
260
+ },
261
+ ],
262
+ },
263
+ maxFiles: {
264
+ type: 'string',
265
+ validations: [
266
+ {
267
+ required: true,
268
+ error: 'maxFiles for file log type must be specified',
269
+ when: { path: 'logs.type', value: 'file' },
270
+ },
271
+ ],
272
+ },
273
+ path: {
274
+ type: 'string',
275
+ validations: [
276
+ {
277
+ required: true,
278
+ error: 'path for file log type must be specified',
279
+ when: { path: 'logs.type', value: 'file' },
280
+ },
281
+ ],
282
+ },
283
+ level: {
284
+ type: 'string',
285
+ validations: [
286
+ {
287
+ required: true,
288
+ error: 'log level must be specified',
289
+ when: { path: 'logs.type', value: 'file' },
290
+ },
291
+ ],
292
+ },
293
+ },
294
+ },
295
+ },
158
296
  servers: {
159
297
  type: 'object',
160
298
  children: {
@@ -194,6 +332,19 @@ export const apiSchemaConfigPair = {
194
332
  },
195
333
  config: {
196
334
  apiType: 'explorer',
335
+ logs: [
336
+ {
337
+ type: 'file',
338
+ maxSize: '20m',
339
+ maxFiles: '14d',
340
+ path: './logs/',
341
+ level: 'info',
342
+ },
343
+ {
344
+ type: 'loki',
345
+ level: 'debug',
346
+ },
347
+ ],
197
348
  servers: {
198
349
  url: 'node256.mydomain.net',
199
350
  },
@@ -230,6 +381,31 @@ export const apiSchemaConfigPairWrongChoice = {
230
381
  },
231
382
  };
232
383
 
384
+ export const arraySchemaConfigPairWrongValueType = {
385
+ schema: {
386
+ logs: {
387
+ type: 'array',
388
+ items: {
389
+ type: 'object',
390
+ children: {
391
+ type: {
392
+ type: 'string',
393
+ },
394
+ maxSize: {
395
+ type: 'string',
396
+ },
397
+ },
398
+ },
399
+ },
400
+ },
401
+ config: {
402
+ logs: {
403
+ type: 'loki',
404
+ maxSize: '12m',
405
+ },
406
+ },
407
+ };
408
+
233
409
  export const apiSchemaConfigPairWrongRegex = {
234
410
  schema: {
235
411
  servers: {
@@ -818,6 +994,60 @@ export const schemaTypeScriptTypesPair = {
818
994
  schema: {
819
995
  apiType: {
820
996
  type: 'string',
997
+ validations: [{ choices: ['node', 'explorer', 'superApi'] }],
998
+ },
999
+ logs: {
1000
+ type: 'array',
1001
+ items: {
1002
+ type: 'object',
1003
+ children: {
1004
+ type: {
1005
+ type: 'string',
1006
+ validations: [
1007
+ {
1008
+ required: true,
1009
+ },
1010
+ { choices: ['file', 'console', 'loki'] },
1011
+ ],
1012
+ },
1013
+ maxSize: {
1014
+ type: 'string',
1015
+ validations: [
1016
+ {
1017
+ required: true,
1018
+ when: { path: 'logs.type', value: 'file' },
1019
+ },
1020
+ ],
1021
+ },
1022
+ maxFiles: {
1023
+ type: 'string',
1024
+ validations: [
1025
+ {
1026
+ required: true,
1027
+ when: { path: 'logs.type', value: 'file' },
1028
+ },
1029
+ ],
1030
+ },
1031
+ path: {
1032
+ type: 'string',
1033
+ validations: [
1034
+ {
1035
+ required: true,
1036
+ when: { path: 'logs.type', value: 'file' },
1037
+ },
1038
+ ],
1039
+ },
1040
+ level: {
1041
+ type: 'string',
1042
+ validations: [
1043
+ {
1044
+ required: true,
1045
+ when: { path: 'logs.type', value: 'file' },
1046
+ },
1047
+ ],
1048
+ },
1049
+ },
1050
+ },
821
1051
  },
822
1052
  explorer: {
823
1053
  type: 'object',
@@ -858,30 +1088,39 @@ export const schemaTypeScriptTypesPair = {
858
1088
  },
859
1089
  },
860
1090
  },
861
- types: `interface Infrastructure {
1091
+ types: `export interface Infrastructure {
862
1092
  apis: Apis;
863
1093
  server: Server;
864
1094
  explorer: Explorer1;
865
- apiType: string;
1095
+ logs: Logs[];
1096
+ apiType?: 'node' | 'explorer' | 'superApi';
1097
+ }
1098
+
1099
+ export interface Logs {
1100
+ type: 'file' | 'console' | 'loki';
1101
+ maxSize?: string;
1102
+ maxFiles?: string;
1103
+ path?: string;
1104
+ level?: string;
866
1105
  }
867
1106
 
868
- interface Explorer1 {
869
- domain: string;
870
- path: string;
1107
+ export interface Explorer1 {
1108
+ domain?: string;
1109
+ path?: string;
871
1110
  }
872
1111
 
873
- interface Server {
874
- url: string;
875
- port: number;
1112
+ export interface Server {
1113
+ url?: string;
1114
+ port?: number;
876
1115
  }
877
1116
 
878
- interface Apis {
1117
+ export interface Apis {
879
1118
  explorer: Explorer;
880
1119
  }
881
1120
 
882
- interface Explorer {
883
- url: string;
884
- port: number;
1121
+ export interface Explorer {
1122
+ url?: string;
1123
+ port?: number;
885
1124
  }
886
1125
  `,
887
1126
  };