pg-mvc-service 1.0.14 → 1.0.15

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.
package/dist/Service.js CHANGED
@@ -24,7 +24,7 @@ const EncryptClient_1 = require("./clients/EncryptClient");
24
24
  const PoolManager_1 = __importDefault(require("./PoolManager"));
25
25
  class Service {
26
26
  get Method() { return this.method; }
27
- get Endpoint() { return this.endpoint; }
27
+ get Endpoint() { return this.endpoint + this.request.paramPath; }
28
28
  get ApiCode() { return this.apiCode; }
29
29
  get Summary() { return `${this.ApiCode !== '' ? this.apiCode + ': ' : ''}${this.summary}`; }
30
30
  get ApiUserAvailable() { return this.apiUserAvailable; }
@@ -50,7 +50,10 @@ class RequestType extends ReqResType_1.default {
50
50
  INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})'
51
51
  };
52
52
  this.ERROR_MESSAGE = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
53
- this.paramProperties = {};
53
+ this.paramProperties = [];
54
+ }
55
+ get paramPath() {
56
+ return this.paramProperties.map(property => `/{${property.key}}`).join("");
54
57
  }
55
58
  get Params() {
56
59
  var _a;
@@ -87,11 +90,12 @@ class RequestType extends ReqResType_1.default {
87
90
  this.params = {};
88
91
  if (request.params !== undefined) {
89
92
  for (const [key, value] of Object.entries(request.params)) {
90
- const property = this.paramProperties[key];
91
- if (property === undefined) {
93
+ const index = this.paramProperties.findIndex(property => property.key === key);
94
+ if (index === -1) {
92
95
  throw new Error(`${key} is not set in paramProperties.`);
93
96
  }
94
- this.paramProperties[key] = this.convertValue(property.type, value, [key, `(pathIndex: ${property.pathIndex})`], false);
97
+ const property = this.paramProperties[index];
98
+ this.params[key] = this.convertValue(property.type, value, [key, `(pathIndex: ${index})`], false);
95
99
  }
96
100
  }
97
101
  this.params = (_a = request.params) !== null && _a !== void 0 ? _a : {};
package/index.d.ts CHANGED
@@ -85,7 +85,7 @@ declare module 'pg-mvc-service' {
85
85
  constructor();
86
86
 
87
87
  protected properties: { [key: string]: PropertyType; };
88
- protected paramProperties: { [key: string]: (PrimitiveType | EnumType) & { pathIndex: number }; };
88
+ protected paramProperties: Array<(PrimitiveType | EnumType) & { key: string }>;
89
89
  protected readonly ERROR_MESSAGE: ErrorMessageType;
90
90
 
91
91
  protected throwException(code: string, message: string): never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
package/src/Service.ts CHANGED
@@ -16,7 +16,7 @@ export class Service {
16
16
  protected readonly method: MethodType = 'GET';
17
17
  get Method(): MethodType { return this.method; }
18
18
  protected readonly endpoint: string = '';
19
- get Endpoint(): string { return this.endpoint; }
19
+ get Endpoint(): string { return this.endpoint + this.request.paramPath; }
20
20
  protected readonly apiCode: string = '';
21
21
  get ApiCode(): string { return this.apiCode; }
22
22
  protected readonly summary: string = '';
@@ -65,9 +65,10 @@ export class RequestType extends ReqResType {
65
65
  }
66
66
  protected readonly ERROR_MESSAGE: ErrorMessageType = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
67
67
 
68
- protected paramProperties: {
69
- [key: string]: (PrimitiveType | EnumType) & { pathIndex: number };
70
- } = {};
68
+ protected paramProperties: Array<(PrimitiveType | EnumType) & { key: string }> = []
69
+ get paramPath(): string {
70
+ return this.paramProperties.map(property => `/{${property.key}}`).join("");
71
+ }
71
72
 
72
73
  private params?: {[key: string]: any};
73
74
  get Params(): {[key: string]: any} {
@@ -106,11 +107,12 @@ export class RequestType extends ReqResType {
106
107
  this.params = {};
107
108
  if (request.params !== undefined) {
108
109
  for (const [key, value] of Object.entries(request.params)) {
109
- const property = this.paramProperties[key];
110
- if (property === undefined) {
110
+ const index = this.paramProperties.findIndex(property => property.key === key);
111
+ if (index === -1) {
111
112
  throw new Error(`${key} is not set in paramProperties.`);
112
113
  }
113
- this.paramProperties[key] = this.convertValue(property.type, value, [key, `(pathIndex: ${property.pathIndex})`], false);
114
+ const property = this.paramProperties[index];
115
+ this.params[key] = this.convertValue(property.type, value, [key, `(pathIndex: ${index})`], false);
114
116
  }
115
117
  }
116
118
  this.params = request.params ?? {};