pg-mvc-service 2.0.67 → 2.0.68

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.
@@ -168,8 +168,10 @@ class RequestType extends ReqResType_1.default {
168
168
  "STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
169
169
  "ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
170
170
  "ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
171
- "MAP_011": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
172
- "MAP_012": this.ERROR_MESSAGE.INVALID_MAP_STRING,
171
+ "MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
172
+ "MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
173
+ "MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
174
+ "MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
173
175
  "NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
174
176
  "BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
175
177
  "BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
@@ -288,7 +290,7 @@ class RequestType extends ReqResType_1.default {
288
290
  case 'number':
289
291
  case 'number?':
290
292
  if (this.isNumber(mapValue) === false) {
291
- this.throwInputError("MAP_011", [key], value);
293
+ this.throwInputError("MAP_01", [key], value);
292
294
  }
293
295
  mapData[mapKey] = Number(mapValue);
294
296
  break;
@@ -302,11 +304,10 @@ class RequestType extends ReqResType_1.default {
302
304
  mapData[mapKey] = mapValue;
303
305
  break;
304
306
  default:
305
- this.throwInputError("MAP_012", [key], value);
307
+ this.throwInputError("MAP_02", [key], value);
306
308
  }
307
309
  }
308
310
  }
309
- console.log('mapData', mapData);
310
311
  this.changeBody([key], mapData);
311
312
  break;
312
313
  case 'enum':
@@ -536,6 +537,34 @@ class RequestType extends ReqResType_1.default {
536
537
  case 'enum?':
537
538
  this.setEnum([...keys, key], value);
538
539
  break;
540
+ case 'map':
541
+ case 'map?':
542
+ const mapData = {};
543
+ for (const [mapKey, mapValue] of Object.entries(value)) {
544
+ switch (property.properties[key].mapType) {
545
+ case 'number':
546
+ case 'number?':
547
+ if (this.isNumber(mapValue) === false) {
548
+ this.throwInputError("MAP_11", [key], value);
549
+ }
550
+ mapData[mapKey] = Number(mapValue);
551
+ break;
552
+ case 'string':
553
+ case 'string?':
554
+ switch (typeof mapValue) {
555
+ case 'number':
556
+ mapData[mapKey] = mapValue.toString();
557
+ break;
558
+ case 'string':
559
+ mapData[mapKey] = mapValue;
560
+ break;
561
+ default:
562
+ this.throwInputError("MAP_12", [key], value);
563
+ }
564
+ }
565
+ }
566
+ this.changeBody([...keys, key], mapData);
567
+ break;
539
568
  default:
540
569
  this.convertInput([...keys, key], value);
541
570
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.67",
3
+ "version": "2.0.68",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -144,7 +144,7 @@ export class RequestType extends ReqResType {
144
144
  "TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
145
145
  "REQUIRE_31" |
146
146
  "ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
147
- "MAP_011" | "MAP_012" |
147
+ "MAP_01" | "MAP_02" | "MAP_11" | "MAP_12" |
148
148
  "NUMBER_91" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
149
149
  "TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
150
150
  , keys: Array<string | number>, value: any): never {
@@ -177,8 +177,10 @@ export class RequestType extends ReqResType {
177
177
  "STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
178
178
  "ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
179
179
  "ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
180
- "MAP_011": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
181
- "MAP_012": this.ERROR_MESSAGE.INVALID_MAP_STRING,
180
+ "MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
181
+ "MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
182
+ "MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
183
+ "MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
182
184
  "NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
183
185
  "BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
184
186
  "BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
@@ -297,7 +299,7 @@ export class RequestType extends ReqResType {
297
299
  case 'number':
298
300
  case 'number?':
299
301
  if (this.isNumber(mapValue) === false) {
300
- this.throwInputError("MAP_011", [key], value);
302
+ this.throwInputError("MAP_01", [key], value);
301
303
  }
302
304
  mapData[mapKey] = Number(mapValue);
303
305
  break;
@@ -311,12 +313,11 @@ export class RequestType extends ReqResType {
311
313
  mapData[mapKey] = mapValue;
312
314
  break;
313
315
  default:
314
- this.throwInputError("MAP_012", [key], value);
316
+ this.throwInputError("MAP_02", [key], value);
315
317
  }
316
318
  }
317
319
  }
318
-
319
- console.log('mapData', mapData);
320
+
320
321
  this.changeBody([key], mapData);
321
322
  break;
322
323
  case 'enum':
@@ -445,42 +446,6 @@ export class RequestType extends ReqResType {
445
446
  }
446
447
  }
447
448
 
448
- private setDictionary(keys: Array<string | number>, values: any) {
449
- // const property = this.getProperty(keys);
450
- // for (let i = 0;i < values.length; i++) {
451
-
452
- // // NULL Check
453
- // if (values[i] === undefined || values[i] === null || (property.properties.type.replace("?", "") !== "string" && values[i] === "")) {
454
- // if (property.properties.type.endsWith('?')) {
455
- // this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
456
- // continue;
457
- // } else {
458
- // this.throwInputError("DICTIONARY_51", [...keys, i], "");
459
- // }
460
- // }
461
-
462
- // switch (property.properties.type) {
463
- // case 'object':
464
- // case 'object?':
465
- // this.setObject([...keys, i], values[i]);
466
- // break;
467
- // case 'array':
468
- // case 'array?':
469
- // this.setArray([...keys, i], values[i]);
470
- // break;
471
- // case 'enum':
472
- // case 'enum?':
473
- // for (const value of values) {
474
- // this.setEnum([...keys, i], value);
475
- // }
476
- // break;
477
- // default:
478
- // this.convertInput([...keys, i], values[i]);
479
- // break;
480
- // }
481
- // }
482
- }
483
-
484
449
  /**
485
450
  * Set the value of the request body to the specified path.
486
451
  * Automatically create intermediate objects or arrays as needed.
@@ -560,6 +525,35 @@ export class RequestType extends ReqResType {
560
525
  case 'enum?':
561
526
  this.setEnum([...keys, key], value);
562
527
  break;
528
+ case 'map':
529
+ case 'map?':
530
+ const mapData: {[key: string]: string | number} = {};
531
+ for (const [mapKey, mapValue] of Object.entries(value)) {
532
+ switch (property.properties[key].mapType) {
533
+ case 'number':
534
+ case 'number?':
535
+ if (this.isNumber(mapValue) === false) {
536
+ this.throwInputError("MAP_11", [key], value);
537
+ }
538
+ mapData[mapKey] = Number(mapValue);
539
+ break;
540
+ case 'string':
541
+ case 'string?':
542
+ switch (typeof mapValue) {
543
+ case 'number':
544
+ mapData[mapKey] = mapValue.toString();
545
+ break;
546
+ case 'string':
547
+ mapData[mapKey] = mapValue;
548
+ break;
549
+ default:
550
+ this.throwInputError("MAP_12", [key], value);
551
+ }
552
+ }
553
+ }
554
+
555
+ this.changeBody([...keys, key], mapData);
556
+ break;
563
557
  default:
564
558
  this.convertInput([...keys, key], value);
565
559
  break;