@rosen-bridge/config 0.1.0 → 0.2.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.
@@ -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: {
@@ -140,6 +198,18 @@ export const schemaWithIncorrectPortDefaultValueTypeSample = {
140
198
  },
141
199
  };
142
200
 
201
+ export const arrayTypeSchemaWithoutItems = {
202
+ logs: {
203
+ type: 'array',
204
+ },
205
+ };
206
+
207
+ export const objectTypeSchemaWithoutChildren = {
208
+ api: {
209
+ type: 'object',
210
+ },
211
+ };
212
+
143
213
  export const apiSchemaConfigPair = {
144
214
  schema: {
145
215
  apiType: {
@@ -155,6 +225,64 @@ export const apiSchemaConfigPair = {
155
225
  { choices: ['node', 'explorer'] },
156
226
  ],
157
227
  },
228
+ logs: {
229
+ type: 'array',
230
+ items: {
231
+ type: 'object',
232
+ children: {
233
+ type: {
234
+ type: 'string',
235
+ validations: [
236
+ {
237
+ required: true,
238
+ error: 'log type must be specified',
239
+ },
240
+ { choices: ['file', 'console', 'loki'] },
241
+ ],
242
+ },
243
+ maxSize: {
244
+ type: 'string',
245
+ validations: [
246
+ {
247
+ required: true,
248
+ error: 'maxSize for file log type must be specified',
249
+ when: { path: 'logs.type', value: 'file' },
250
+ },
251
+ ],
252
+ },
253
+ maxFiles: {
254
+ type: 'string',
255
+ validations: [
256
+ {
257
+ required: true,
258
+ error: 'maxFiles for file log type must be specified',
259
+ when: { path: 'logs.type', value: 'file' },
260
+ },
261
+ ],
262
+ },
263
+ path: {
264
+ type: 'string',
265
+ validations: [
266
+ {
267
+ required: true,
268
+ error: 'path for file log type must be specified',
269
+ when: { path: 'logs.type', value: 'file' },
270
+ },
271
+ ],
272
+ },
273
+ level: {
274
+ type: 'string',
275
+ validations: [
276
+ {
277
+ required: true,
278
+ error: 'log level must be specified',
279
+ when: { path: 'logs.type', value: 'file' },
280
+ },
281
+ ],
282
+ },
283
+ },
284
+ },
285
+ },
158
286
  servers: {
159
287
  type: 'object',
160
288
  children: {
@@ -194,6 +322,19 @@ export const apiSchemaConfigPair = {
194
322
  },
195
323
  config: {
196
324
  apiType: 'explorer',
325
+ logs: [
326
+ {
327
+ type: 'file',
328
+ maxSize: '20m',
329
+ maxFiles: '14d',
330
+ path: './logs/',
331
+ level: 'info',
332
+ },
333
+ {
334
+ type: 'loki',
335
+ level: 'debug',
336
+ },
337
+ ],
197
338
  servers: {
198
339
  url: 'node256.mydomain.net',
199
340
  },
@@ -230,6 +371,31 @@ export const apiSchemaConfigPairWrongChoice = {
230
371
  },
231
372
  };
232
373
 
374
+ export const arraySchemaConfigPairWrongValueType = {
375
+ schema: {
376
+ logs: {
377
+ type: 'array',
378
+ items: {
379
+ type: 'object',
380
+ children: {
381
+ type: {
382
+ type: 'string',
383
+ },
384
+ maxSize: {
385
+ type: 'string',
386
+ },
387
+ },
388
+ },
389
+ },
390
+ },
391
+ config: {
392
+ logs: {
393
+ type: 'loki',
394
+ maxSize: '12m',
395
+ },
396
+ },
397
+ };
398
+
233
399
  export const apiSchemaConfigPairWrongRegex = {
234
400
  schema: {
235
401
  servers: {
@@ -818,6 +984,60 @@ export const schemaTypeScriptTypesPair = {
818
984
  schema: {
819
985
  apiType: {
820
986
  type: 'string',
987
+ validations: [{ choices: ['node', 'explorer', 'superApi'] }],
988
+ },
989
+ logs: {
990
+ type: 'array',
991
+ items: {
992
+ type: 'object',
993
+ children: {
994
+ type: {
995
+ type: 'string',
996
+ validations: [
997
+ {
998
+ required: true,
999
+ },
1000
+ { choices: ['file', 'console', 'loki'] },
1001
+ ],
1002
+ },
1003
+ maxSize: {
1004
+ type: 'string',
1005
+ validations: [
1006
+ {
1007
+ required: true,
1008
+ when: { path: 'logs.type', value: 'file' },
1009
+ },
1010
+ ],
1011
+ },
1012
+ maxFiles: {
1013
+ type: 'string',
1014
+ validations: [
1015
+ {
1016
+ required: true,
1017
+ when: { path: 'logs.type', value: 'file' },
1018
+ },
1019
+ ],
1020
+ },
1021
+ path: {
1022
+ type: 'string',
1023
+ validations: [
1024
+ {
1025
+ required: true,
1026
+ when: { path: 'logs.type', value: 'file' },
1027
+ },
1028
+ ],
1029
+ },
1030
+ level: {
1031
+ type: 'string',
1032
+ validations: [
1033
+ {
1034
+ required: true,
1035
+ when: { path: 'logs.type', value: 'file' },
1036
+ },
1037
+ ],
1038
+ },
1039
+ },
1040
+ },
821
1041
  },
822
1042
  explorer: {
823
1043
  type: 'object',
@@ -858,30 +1078,39 @@ export const schemaTypeScriptTypesPair = {
858
1078
  },
859
1079
  },
860
1080
  },
861
- types: `interface Infrastructure {
1081
+ types: `export interface Infrastructure {
862
1082
  apis: Apis;
863
1083
  server: Server;
864
1084
  explorer: Explorer1;
865
- apiType: string;
1085
+ logs: Logs[];
1086
+ apiType?: 'node' | 'explorer' | 'superApi';
1087
+ }
1088
+
1089
+ export interface Logs {
1090
+ type: 'file' | 'console' | 'loki';
1091
+ maxSize?: string;
1092
+ maxFiles?: string;
1093
+ path?: string;
1094
+ level?: string;
866
1095
  }
867
1096
 
868
- interface Explorer1 {
869
- domain: string;
870
- path: string;
1097
+ export interface Explorer1 {
1098
+ domain?: string;
1099
+ path?: string;
871
1100
  }
872
1101
 
873
- interface Server {
874
- url: string;
875
- port: number;
1102
+ export interface Server {
1103
+ url?: string;
1104
+ port?: number;
876
1105
  }
877
1106
 
878
- interface Apis {
1107
+ export interface Apis {
879
1108
  explorer: Explorer;
880
1109
  }
881
1110
 
882
- interface Explorer {
883
- url: string;
884
- port: number;
1111
+ export interface Explorer {
1112
+ url?: string;
1113
+ port?: number;
885
1114
  }
886
1115
  `,
887
1116
  };