pg-mvc-service 2.0.67 → 2.0.69

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, // // tODO : mapのエラーメッセージどうするか
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,
@@ -282,13 +284,14 @@ class RequestType extends ReqResType_1.default {
282
284
  break;
283
285
  case 'map':
284
286
  case 'map?':
287
+ // tODO : ここは共通化したい
285
288
  const mapData = {};
286
289
  for (const [mapKey, mapValue] of Object.entries(value)) {
287
290
  switch (this.properties[key].mapType) {
288
291
  case 'number':
289
292
  case 'number?':
290
293
  if (this.isNumber(mapValue) === false) {
291
- this.throwInputError("MAP_011", [key], value);
294
+ this.throwInputError("MAP_01", [key], value);
292
295
  }
293
296
  mapData[mapKey] = Number(mapValue);
294
297
  break;
@@ -302,11 +305,10 @@ class RequestType extends ReqResType_1.default {
302
305
  mapData[mapKey] = mapValue;
303
306
  break;
304
307
  default:
305
- this.throwInputError("MAP_012", [key], value);
308
+ this.throwInputError("MAP_02", [key], value);
306
309
  }
307
310
  }
308
311
  }
309
- console.log('mapData', mapData);
310
312
  this.changeBody([key], mapData);
311
313
  break;
312
314
  case 'enum':
@@ -420,45 +422,40 @@ class RequestType extends ReqResType_1.default {
420
422
  this.setEnum([...keys, i], value);
421
423
  }
422
424
  break;
425
+ case 'map':
426
+ case 'map?':
427
+ const mapData = {};
428
+ for (const [mapKey, mapValue] of Object.entries(values[i])) {
429
+ switch (property.item.mapType) {
430
+ case 'number':
431
+ case 'number?':
432
+ if (this.isNumber(mapValue) === false) {
433
+ this.throwInputError("MAP_11", [...keys, i], values[i]);
434
+ }
435
+ mapData[mapKey] = Number(mapValue);
436
+ break;
437
+ case 'string':
438
+ case 'string?':
439
+ switch (typeof mapValue) {
440
+ case 'number':
441
+ mapData[mapKey] = mapValue.toString();
442
+ break;
443
+ case 'string':
444
+ mapData[mapKey] = mapValue;
445
+ break;
446
+ default:
447
+ this.throwInputError("MAP_12", [...keys, i], values[i]);
448
+ }
449
+ }
450
+ }
451
+ this.changeBody([...keys, i], mapData);
452
+ break;
423
453
  default:
424
454
  this.convertInput([...keys, i], values[i]);
425
455
  break;
426
456
  }
427
457
  }
428
458
  }
429
- setDictionary(keys, values) {
430
- // const property = this.getProperty(keys);
431
- // for (let i = 0;i < values.length; i++) {
432
- // // NULL Check
433
- // if (values[i] === undefined || values[i] === null || (property.properties.type.replace("?", "") !== "string" && values[i] === "")) {
434
- // if (property.properties.type.endsWith('?')) {
435
- // this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
436
- // continue;
437
- // } else {
438
- // this.throwInputError("DICTIONARY_51", [...keys, i], "");
439
- // }
440
- // }
441
- // switch (property.properties.type) {
442
- // case 'object':
443
- // case 'object?':
444
- // this.setObject([...keys, i], values[i]);
445
- // break;
446
- // case 'array':
447
- // case 'array?':
448
- // this.setArray([...keys, i], values[i]);
449
- // break;
450
- // case 'enum':
451
- // case 'enum?':
452
- // for (const value of values) {
453
- // this.setEnum([...keys, i], value);
454
- // }
455
- // break;
456
- // default:
457
- // this.convertInput([...keys, i], values[i]);
458
- // break;
459
- // }
460
- // }
461
- }
462
459
  /**
463
460
  * Set the value of the request body to the specified path.
464
461
  * Automatically create intermediate objects or arrays as needed.
@@ -536,6 +533,34 @@ class RequestType extends ReqResType_1.default {
536
533
  case 'enum?':
537
534
  this.setEnum([...keys, key], value);
538
535
  break;
536
+ case 'map':
537
+ case 'map?':
538
+ const mapData = {};
539
+ for (const [mapKey, mapValue] of Object.entries(value)) {
540
+ switch (property.properties[key].mapType) {
541
+ case 'number':
542
+ case 'number?':
543
+ if (this.isNumber(mapValue) === false) {
544
+ this.throwInputError("MAP_11", [key], value);
545
+ }
546
+ mapData[mapKey] = Number(mapValue);
547
+ break;
548
+ case 'string':
549
+ case 'string?':
550
+ switch (typeof mapValue) {
551
+ case 'number':
552
+ mapData[mapKey] = mapValue.toString();
553
+ break;
554
+ case 'string':
555
+ mapData[mapKey] = mapValue;
556
+ break;
557
+ default:
558
+ this.throwInputError("MAP_12", [key], value);
559
+ }
560
+ }
561
+ }
562
+ this.changeBody([...keys, key], mapData);
563
+ break;
539
564
  default:
540
565
  this.convertInput([...keys, key], value);
541
566
  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.69",
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, // // tODO : mapのエラーメッセージどうするか
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,
@@ -291,13 +293,14 @@ export class RequestType extends ReqResType {
291
293
  break;
292
294
  case 'map':
293
295
  case 'map?':
296
+ // tODO : ここは共通化したい
294
297
  const mapData: {[key: string]: string | number} = {};
295
298
  for (const [mapKey, mapValue] of Object.entries(value)) {
296
299
  switch (this.properties[key].mapType) {
297
300
  case 'number':
298
301
  case 'number?':
299
302
  if (this.isNumber(mapValue) === false) {
300
- this.throwInputError("MAP_011", [key], value);
303
+ this.throwInputError("MAP_01", [key], value);
301
304
  }
302
305
  mapData[mapKey] = Number(mapValue);
303
306
  break;
@@ -311,12 +314,11 @@ export class RequestType extends ReqResType {
311
314
  mapData[mapKey] = mapValue;
312
315
  break;
313
316
  default:
314
- this.throwInputError("MAP_012", [key], value);
317
+ this.throwInputError("MAP_02", [key], value);
315
318
  }
316
319
  }
317
320
  }
318
-
319
- console.log('mapData', mapData);
321
+
320
322
  this.changeBody([key], mapData);
321
323
  break;
322
324
  case 'enum':
@@ -438,6 +440,35 @@ export class RequestType extends ReqResType {
438
440
  this.setEnum([...keys, i], value);
439
441
  }
440
442
  break;
443
+ case 'map':
444
+ case 'map?':
445
+ const mapData: {[key: string]: string | number} = {};
446
+ for (const [mapKey, mapValue] of Object.entries(values[i])) {
447
+ switch (property.item.mapType) {
448
+ case 'number':
449
+ case 'number?':
450
+ if (this.isNumber(mapValue) === false) {
451
+ this.throwInputError("MAP_11", [...keys, i], values[i]);
452
+ }
453
+ mapData[mapKey] = Number(mapValue);
454
+ break;
455
+ case 'string':
456
+ case 'string?':
457
+ switch (typeof mapValue) {
458
+ case 'number':
459
+ mapData[mapKey] = mapValue.toString();
460
+ break;
461
+ case 'string':
462
+ mapData[mapKey] = mapValue;
463
+ break;
464
+ default:
465
+ this.throwInputError("MAP_12", [...keys, i], values[i]);
466
+ }
467
+ }
468
+ }
469
+
470
+ this.changeBody([...keys, i], mapData);
471
+ break;
441
472
  default:
442
473
  this.convertInput([...keys, i], values[i]);
443
474
  break;
@@ -445,42 +476,6 @@ export class RequestType extends ReqResType {
445
476
  }
446
477
  }
447
478
 
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
479
  /**
485
480
  * Set the value of the request body to the specified path.
486
481
  * Automatically create intermediate objects or arrays as needed.
@@ -560,6 +555,35 @@ export class RequestType extends ReqResType {
560
555
  case 'enum?':
561
556
  this.setEnum([...keys, key], value);
562
557
  break;
558
+ case 'map':
559
+ case 'map?':
560
+ const mapData: {[key: string]: string | number} = {};
561
+ for (const [mapKey, mapValue] of Object.entries(value)) {
562
+ switch (property.properties[key].mapType) {
563
+ case 'number':
564
+ case 'number?':
565
+ if (this.isNumber(mapValue) === false) {
566
+ this.throwInputError("MAP_11", [key], value);
567
+ }
568
+ mapData[mapKey] = Number(mapValue);
569
+ break;
570
+ case 'string':
571
+ case 'string?':
572
+ switch (typeof mapValue) {
573
+ case 'number':
574
+ mapData[mapKey] = mapValue.toString();
575
+ break;
576
+ case 'string':
577
+ mapData[mapKey] = mapValue;
578
+ break;
579
+ default:
580
+ this.throwInputError("MAP_12", [key], value);
581
+ }
582
+ }
583
+ }
584
+
585
+ this.changeBody([...keys, key], mapData);
586
+ break;
563
587
  default:
564
588
  this.convertInput([...keys, key], value);
565
589
  break;