pg-mvc-service 2.0.68 → 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,7 +168,7 @@ 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_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
171
+ "MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER, // // tODO : mapのエラーメッセージどうするか
172
172
  "MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
173
173
  "MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
174
174
  "MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
@@ -284,6 +284,7 @@ class RequestType extends ReqResType_1.default {
284
284
  break;
285
285
  case 'map':
286
286
  case 'map?':
287
+ // tODO : ここは共通化したい
287
288
  const mapData = {};
288
289
  for (const [mapKey, mapValue] of Object.entries(value)) {
289
290
  switch (this.properties[key].mapType) {
@@ -421,45 +422,40 @@ class RequestType extends ReqResType_1.default {
421
422
  this.setEnum([...keys, i], value);
422
423
  }
423
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;
424
453
  default:
425
454
  this.convertInput([...keys, i], values[i]);
426
455
  break;
427
456
  }
428
457
  }
429
458
  }
430
- setDictionary(keys, values) {
431
- // const property = this.getProperty(keys);
432
- // for (let i = 0;i < values.length; i++) {
433
- // // NULL Check
434
- // if (values[i] === undefined || values[i] === null || (property.properties.type.replace("?", "") !== "string" && values[i] === "")) {
435
- // if (property.properties.type.endsWith('?')) {
436
- // this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
437
- // continue;
438
- // } else {
439
- // this.throwInputError("DICTIONARY_51", [...keys, i], "");
440
- // }
441
- // }
442
- // switch (property.properties.type) {
443
- // case 'object':
444
- // case 'object?':
445
- // this.setObject([...keys, i], values[i]);
446
- // break;
447
- // case 'array':
448
- // case 'array?':
449
- // this.setArray([...keys, i], values[i]);
450
- // break;
451
- // case 'enum':
452
- // case 'enum?':
453
- // for (const value of values) {
454
- // this.setEnum([...keys, i], value);
455
- // }
456
- // break;
457
- // default:
458
- // this.convertInput([...keys, i], values[i]);
459
- // break;
460
- // }
461
- // }
462
- }
463
459
  /**
464
460
  * Set the value of the request body to the specified path.
465
461
  * Automatically create intermediate objects or arrays as needed.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.68",
3
+ "version": "2.0.69",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -177,7 +177,7 @@ 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_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
180
+ "MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER, // // tODO : mapのエラーメッセージどうするか
181
181
  "MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
182
182
  "MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
183
183
  "MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
@@ -293,6 +293,7 @@ export class RequestType extends ReqResType {
293
293
  break;
294
294
  case 'map':
295
295
  case 'map?':
296
+ // tODO : ここは共通化したい
296
297
  const mapData: {[key: string]: string | number} = {};
297
298
  for (const [mapKey, mapValue] of Object.entries(value)) {
298
299
  switch (this.properties[key].mapType) {
@@ -439,6 +440,35 @@ export class RequestType extends ReqResType {
439
440
  this.setEnum([...keys, i], value);
440
441
  }
441
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;
442
472
  default:
443
473
  this.convertInput([...keys, i], values[i]);
444
474
  break;