pg-mvc-service 2.1.0 → 2.1.2

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.
Files changed (98) hide show
  1. package/dist/PoolManager.d.ts +7 -0
  2. package/dist/PoolManager.d.ts.map +1 -0
  3. package/dist/Service.d.ts +79 -0
  4. package/dist/Service.d.ts.map +1 -0
  5. package/dist/Service.js +0 -8
  6. package/dist/Utils/DateTimeUtil.d.ts +58 -0
  7. package/dist/Utils/DateTimeUtil.d.ts.map +1 -0
  8. package/dist/Utils/NumberUtil.d.ts +10 -0
  9. package/dist/Utils/NumberUtil.d.ts.map +1 -0
  10. package/dist/Utils/StringUtil.d.ts +16 -0
  11. package/dist/Utils/StringUtil.d.ts.map +1 -0
  12. package/dist/clients/AwsS3Client.d.ts +34 -0
  13. package/dist/clients/AwsS3Client.d.ts.map +1 -0
  14. package/dist/clients/AwsS3Client.js +13 -28
  15. package/dist/clients/EncryptClient.d.ts +18 -0
  16. package/dist/clients/EncryptClient.d.ts.map +1 -0
  17. package/dist/clients/StringClient.d.ts +6 -0
  18. package/dist/clients/StringClient.d.ts.map +1 -0
  19. package/dist/cron/BaseCron.d.ts +32 -0
  20. package/dist/cron/BaseCron.d.ts.map +1 -0
  21. package/dist/cron/BaseCron.js +0 -7
  22. package/dist/cron/CronExecuter.d.ts +2 -0
  23. package/dist/cron/CronExecuter.d.ts.map +1 -0
  24. package/dist/cron/CronType.d.ts +6 -0
  25. package/dist/cron/CronType.d.ts.map +1 -0
  26. package/dist/documents/Swagger.d.ts +10 -0
  27. package/dist/documents/Swagger.d.ts.map +1 -0
  28. package/dist/exceptions/Exception.d.ts +31 -0
  29. package/dist/exceptions/Exception.d.ts.map +1 -0
  30. package/{src/index.ts → dist/index.d.ts} +3 -7
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +1 -3
  33. package/dist/models/ExpressionClient.d.ts +12 -0
  34. package/dist/models/ExpressionClient.d.ts.map +1 -0
  35. package/dist/models/MigrateDatabase.d.ts +19 -0
  36. package/dist/models/MigrateDatabase.d.ts.map +1 -0
  37. package/dist/models/MigrateRollback.d.ts +18 -0
  38. package/dist/models/MigrateRollback.d.ts.map +1 -0
  39. package/dist/models/MigrateTable.d.ts +13 -0
  40. package/dist/models/MigrateTable.d.ts.map +1 -0
  41. package/dist/models/SqlUtils/SelectExpression.d.ts +31 -0
  42. package/dist/models/SqlUtils/SelectExpression.d.ts.map +1 -0
  43. package/dist/models/SqlUtils/UpdateExpression.d.ts +8 -0
  44. package/dist/models/SqlUtils/UpdateExpression.d.ts.map +1 -0
  45. package/dist/models/SqlUtils/ValidateValueUtil.d.ts +19 -0
  46. package/dist/models/SqlUtils/ValidateValueUtil.d.ts.map +1 -0
  47. package/dist/models/SqlUtils/WhereExpression.d.ts +30 -0
  48. package/dist/models/SqlUtils/WhereExpression.d.ts.map +1 -0
  49. package/dist/models/TableDoc.d.ts +3 -0
  50. package/dist/models/TableDoc.d.ts.map +1 -0
  51. package/dist/models/TableModel.d.ts +196 -0
  52. package/dist/models/TableModel.d.ts.map +1 -0
  53. package/dist/models/Type.d.ts +64 -0
  54. package/dist/models/Type.d.ts.map +1 -0
  55. package/dist/models/Utils/MessageUtil.d.ts +7 -0
  56. package/dist/models/Utils/MessageUtil.d.ts.map +1 -0
  57. package/dist/models/ValidateClient.d.ts +27 -0
  58. package/dist/models/ValidateClient.d.ts.map +1 -0
  59. package/dist/reqestResponse/ReqResType.d.ts +113 -0
  60. package/dist/reqestResponse/ReqResType.d.ts.map +1 -0
  61. package/dist/reqestResponse/RequestType.d.ts +247 -0
  62. package/dist/reqestResponse/RequestType.d.ts.map +1 -0
  63. package/dist/reqestResponse/ResponseType.d.ts +85 -0
  64. package/dist/reqestResponse/ResponseType.d.ts.map +1 -0
  65. package/package.json +7 -2
  66. package/dist/clients/Base64Client.js +0 -292
  67. package/index.d.ts +0 -192
  68. package/src/PoolManager.ts +0 -48
  69. package/src/Service.ts +0 -307
  70. package/src/Utils/DateTimeUtil.ts +0 -146
  71. package/src/Utils/NumberUtil.ts +0 -23
  72. package/src/Utils/StringUtil.ts +0 -33
  73. package/src/clients/AwsS3Client.ts +0 -310
  74. package/src/clients/Base64Client.ts +0 -305
  75. package/src/clients/EncryptClient.ts +0 -100
  76. package/src/clients/StringClient.ts +0 -19
  77. package/src/cron/BaseCron.ts +0 -122
  78. package/src/cron/CronExecuter.ts +0 -34
  79. package/src/cron/CronType.ts +0 -25
  80. package/src/documents/Swagger.ts +0 -106
  81. package/src/exceptions/Exception.ts +0 -72
  82. package/src/models/ExpressionClient.ts +0 -72
  83. package/src/models/MigrateDatabase.ts +0 -135
  84. package/src/models/MigrateRollback.ts +0 -151
  85. package/src/models/MigrateTable.ts +0 -56
  86. package/src/models/SqlUtils/SelectExpression.ts +0 -102
  87. package/src/models/SqlUtils/UpdateExpression.ts +0 -29
  88. package/src/models/SqlUtils/ValidateValueUtil.ts +0 -354
  89. package/src/models/SqlUtils/WhereExpression.ts +0 -455
  90. package/src/models/TableDoc.ts +0 -372
  91. package/src/models/TableModel.ts +0 -749
  92. package/src/models/Type.ts +0 -62
  93. package/src/models/Utils/MessageUtil.ts +0 -60
  94. package/src/models/ValidateClient.ts +0 -182
  95. package/src/reqestResponse/ReqResType.ts +0 -241
  96. package/src/reqestResponse/RequestType.ts +0 -1619
  97. package/src/reqestResponse/ResponseType.ts +0 -549
  98. package/tsconfig.json +0 -14
@@ -1,1619 +0,0 @@
1
- import { Request } from 'express';
2
- import ReqResType, { EnumType, NumberType, PrimitiveType, PropertyType, StringType } from "./ReqResType";
3
- import { InputErrorException } from '../exceptions/Exception';
4
- import StringUtil from '../Utils/StringUtil';
5
- import { ValidateStringUtil } from 'type-utils-n-daira';
6
- import { IError } from '../Service';
7
- import { Context } from 'hono';
8
-
9
- // エラーメッセージの型定義
10
- export interface ErrorMessageType {
11
- REQUIRED: string;
12
- UNNECESSARY: string;
13
- INVALID_OBJECT: string;
14
- INVALID_ARRAY: string;
15
- INVALID_NUMBER: string;
16
- INVALID_NUMBER_MIN: string;
17
- INVALID_NUMBER_MAX: string;
18
- INVALID_BOOL: string;
19
- INVALID_STRING: string;
20
- INVALID_STRING_MAX_LENGTH: string;
21
- INVALID_STRING_REG_EXP: string;
22
- INVALID_UUID: string;
23
- INVALID_MAIL: string;
24
- INVALID_HTTPS: string;
25
- INVALID_DATE: string;
26
- INVALID_TIME: string;
27
- INVALID_DATETIME: string;
28
- INVALID_BASE64: string;
29
- INVALID_ENUM: string;
30
- INVALID_MAP_NUMBER: string;
31
- INVALID_MAP_STRING: string;
32
- INVALID_MAP_BOOL: string;
33
- }
34
-
35
- export class RequestType extends ReqResType {
36
-
37
- // *****************************************
38
- // Input Error Message
39
- // Please make changes to error messages in the subclass
40
- // エラー文言
41
- // エラーメッセージの変更はサブクラスで行ってください
42
- // *****************************************
43
- private readonly ERROR_MESSAGE_ENGLISH: ErrorMessageType = {
44
- REQUIRED: '{property} is required.',
45
- UNNECESSARY: '{property} is unnecessary input. ',
46
- INVALID_OBJECT: '{property} must be of type Object. ({value})',
47
- INVALID_ARRAY: '{property} must be of type Array. ({value})',
48
- INVALID_NUMBER: '{property} must be of type number. ({value})',
49
- INVALID_NUMBER_MAX: '{property} must be less than or equal to {max}. ({value})',
50
- INVALID_NUMBER_MIN: '{property} must be greater than or equal to {min}. ({value})',
51
- INVALID_BOOL: '{property} must be of type bool or a string with true, false, or a number with 0, 1. ({value})',
52
- INVALID_STRING: '{property} must be of type string. ({value})',
53
- INVALID_STRING_MAX_LENGTH: '{property} must be less than or equal to {maxLength} characters. ({value})',
54
- INVALID_STRING_REG_EXP: '{property} is invalid because it does not match the pattern {regExp}. ({value})',
55
- INVALID_UUID: '{property} must be a UUID. ({value})',
56
- INVALID_MAIL: '{property} must be an email. ({value})',
57
- INVALID_HTTPS: '{property} must be an https or http URL. ({value})',
58
- INVALID_DATE: '{property} must be a string in "YYYY-MM-DD" format and a valid date. ({value})',
59
- INVALID_TIME: '{property} must be a string in "hh:mi" format and a valid time. ({value})',
60
- INVALID_DATETIME: '{property} must be a string in "YYYY-MM-DD hh:mi:ss" or "YYYY-MM-DDThh:mi:ss" format and a valid date and time. ({value})',
61
- INVALID_BASE64: '{property} must be in Base64 format. ({value})',
62
- INVALID_ENUM: '{property} must be in {enums}. ({value})',
63
- INVALID_MAP_NUMBER: '{property} must be a valid number for a map key. ({value})',
64
- INVALID_MAP_STRING: '{property} must be a valid string for a map key. ({value})',
65
- INVALID_MAP_BOOL: '{property} must be a valid boolean for a map key. ({value})',
66
- }
67
- private readonly ERROR_MESSAGE_JAPAN: ErrorMessageType = {
68
- REQUIRED: '{property}は必須項目です。',
69
- UNNECESSARY: '{property}は不要な入力です。',
70
- INVALID_OBJECT: '{property}はobject型で入力してください。({value})',
71
- INVALID_ARRAY: '{property}はarray型で入力してください。({value})',
72
- INVALID_NUMBER: '{property}はnumber型または半角数値のstring型で入力してください。({value})',
73
- INVALID_NUMBER_MAX: '{property}は{max}以下の値で入力してください。({value})',
74
- INVALID_NUMBER_MIN: '{property}は{min}以上の値で入力してください。({value})',
75
- INVALID_BOOL: '{property}はboolean型またはtrue、falseのstring型または0、1のnumber型で入力してください。({value})',
76
- INVALID_STRING: '{property}はstring型で入力してください。({value})',
77
- INVALID_STRING_MAX_LENGTH: '{property}は{maxLength}文字以内で入力してください。({value})',
78
- INVALID_STRING_REG_EXP: '{property} は {regExp} のパターンに一致しないため無効です。({value})',
79
- INVALID_UUID: '{property}はUUID形式のstring型で入力してください。({value})',
80
- INVALID_MAIL: '{property}はメールアドレス形式のstring型で入力してください。({value})',
81
- INVALID_HTTPS: '{property}はhttpsまたはhttpのURL形式のstring型で入力してください。({value})',
82
- INVALID_DATE: '{property}は"YYYY-MM-DD"形式のstring型で入力してください。({value})',
83
- INVALID_TIME: '{property}は"hh:mi"形式のstring型で入力してください。({value})',
84
- INVALID_DATETIME: '{property}は"YYYY-MM-DD hh:mi:ss"または"YYYY-MM-DDThh:mi:ss"形式のstring型で入力してください。({value})',
85
- INVALID_BASE64: '{property}はBase64形式のstring型で入力してください。({value})',
86
- INVALID_ENUM: '{property}は{enums}のいずれかの値で入力してください。({value})',
87
- INVALID_MAP_NUMBER: '{property} は有効な数値のマップキーでなければなりません。({value})',
88
- INVALID_MAP_STRING: '{property} は有効な文字列のマップキーでなければなりません。({value})',
89
- INVALID_MAP_BOOL: '{property} は有効なboolのマップキーでなければなりません。({value})',
90
- }
91
- protected readonly ERROR_MESSAGE: ErrorMessageType = process.env.TZ === 'Asia/Tokyo' ? this.ERROR_MESSAGE_JAPAN : this.ERROR_MESSAGE_ENGLISH;
92
-
93
- protected paramProperties: Array<(PrimitiveType | StringType | NumberType | EnumType) & { key: string }> = []
94
- get paramPath(): string {
95
- return this.paramProperties.map(property => `/{${property.key}}`).join("");
96
- }
97
-
98
- private params?: {[key: string]: any};
99
- get Params(): {[key: string]: any} {
100
- if (this.params === undefined) {
101
- throw new Error("Request data must be set using setRequest method before accessing Req.");
102
- }
103
- return this.params ?? {};
104
- }
105
- private data?: {[key: string]: any};
106
- get Data(): {[key: string]: any} {
107
- if (this.data === undefined) {
108
- throw new Error("Request data must be set using setRequest method before accessing Req.");
109
- }
110
- return this.data ?? {};
111
- }
112
- private headers?: IncomingHttpHeaders;
113
- get Headers(): IncomingHttpHeaders {
114
- if (this.headers === undefined) {
115
- throw new Error("Request data must be set using setRequest method before accessing Req.");
116
- }
117
- return this.headers;
118
- }
119
-
120
- get Authorization(): string | null {
121
- const authorization = this.Headers['authorization'] ?? '';
122
- if (authorization.startsWith('Bearer ') === false) {
123
- return null;
124
- }
125
- return authorization.replace(/^Bearer\s/, '');
126
- }
127
-
128
- public async setRequest(module: 'express' | 'hono', request: Request | Context): Promise<void> {
129
- await this.createBody(module, request);
130
-
131
- this.params = {};
132
- if (module === 'express') {
133
- const req = request as Request;
134
- if (req.params !== undefined) {
135
- for (const [key, value] of Object.entries(req.params)) {
136
- const index = this.paramProperties.findIndex((p) => p.key === key);
137
- if (index === -1) throw new Error(`${key} is not set in paramProperties.`);
138
- const prop = this.paramProperties[index];
139
- this.params[key] = this.convertValue(prop, value, [key, `(pathIndex: ${index})`], false);
140
- }
141
- }
142
-
143
- this.params = req.params ?? {};
144
- this.headers = req.headers ?? {};
145
- } else {
146
- const c = request as Context;
147
- for (let index = 0; index < this.paramProperties.length; index++) {
148
- const prop = this.paramProperties[index];
149
- const value = (c.req as any).param?.(prop.key); // hono の param()
150
- if (value !== undefined) {
151
- this.params[prop.key] = this.convertValue(prop, value, [prop.key, `(pathIndex: ${index})`], false);
152
- }
153
- }
154
-
155
- const headersObj: Record<string, string> = {};
156
- c.req.raw.headers.forEach((v, k) => {
157
- headersObj[k.toLowerCase()] = v;
158
- });
159
- this.headers = headersObj as any;
160
- }
161
- }
162
-
163
- private createErrorMessage(code:
164
- "REQUIRE_00" | "REQUIRE_01" | "OBJECT_01" | "ARRAY_01" | "UNNECESSARY_01" |
165
- "REQUIRE_11" | "OBJECT_11" | "ARRAY_11" | "UNNECESSARY_11" |
166
- "NUMBER_21" | "NUMBER_22" | "NUMBER_23" | "BOOL_21" | "BOOL_22" | "BOOL_23" | "STRING_21" | "STRING_22" | "STRING_23" | "UUID_21" | "MAIL_21" | "DATE_21" | "DATE_22" |
167
- "TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
168
- "REQUIRE_31" |
169
- "ENUM_32" | "ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
170
- "MAP_01" | "MAP_02" | "MAP_03" | "MAP_04" | "MAP_05" | "MAP_11" | "MAP_12" | "MAP_13" | "MAP_14" | "MAP_15" |
171
- "MAP_31" | "MAP_32" | "MAP_33" | "MAP_34" | "MAP_35" |
172
- "NUMBER_91" | "NUMBER_92" | "NUMBER_93" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "STRING_92" | "STRING_93" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
173
- "TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91",
174
- keys: Array<string | number>,
175
- value?: any
176
- ) {
177
- const list = {
178
- "REQUIRE_00": this.ERROR_MESSAGE.REQUIRED,
179
- "REQUIRE_01": this.ERROR_MESSAGE.REQUIRED,
180
- "OBJECT_01": this.ERROR_MESSAGE.INVALID_OBJECT,
181
- "ARRAY_01": this.ERROR_MESSAGE.INVALID_ARRAY,
182
- "UNNECESSARY_01": this.ERROR_MESSAGE.UNNECESSARY,
183
- "REQUIRE_11": this.ERROR_MESSAGE.REQUIRED,
184
- "OBJECT_11": this.ERROR_MESSAGE.INVALID_OBJECT,
185
- "ARRAY_11": this.ERROR_MESSAGE.INVALID_ARRAY,
186
- "UNNECESSARY_11": this.ERROR_MESSAGE.UNNECESSARY,
187
- "NUMBER_21": this.ERROR_MESSAGE.INVALID_NUMBER,
188
- "NUMBER_22": this.ERROR_MESSAGE.INVALID_NUMBER_MIN,
189
- "NUMBER_23": this.ERROR_MESSAGE.INVALID_NUMBER_MAX,
190
- "BOOL_21": this.ERROR_MESSAGE.INVALID_BOOL,
191
- "BOOL_22": this.ERROR_MESSAGE.INVALID_BOOL,
192
- "BOOL_23": this.ERROR_MESSAGE.INVALID_BOOL,
193
- "STRING_21": this.ERROR_MESSAGE.INVALID_STRING,
194
- "STRING_22": this.ERROR_MESSAGE.INVALID_STRING_MAX_LENGTH,
195
- "STRING_23": this.ERROR_MESSAGE.INVALID_STRING_REG_EXP,
196
- "UUID_21": this.ERROR_MESSAGE.INVALID_UUID,
197
- "MAIL_21": this.ERROR_MESSAGE.INVALID_MAIL,
198
- "DATE_21": this.ERROR_MESSAGE.INVALID_DATE,
199
- "DATE_22": this.ERROR_MESSAGE.INVALID_DATE,
200
- "TIME_21": this.ERROR_MESSAGE.INVALID_TIME,
201
- "DATETIME_21": this.ERROR_MESSAGE.INVALID_DATETIME,
202
- "DATETIME_22": this.ERROR_MESSAGE.INVALID_DATETIME,
203
- "HTTPS_21": this.ERROR_MESSAGE.INVALID_HTTPS,
204
- "BASE64_21": this.ERROR_MESSAGE.INVALID_BASE64,
205
- "REQUIRE_31": this.ERROR_MESSAGE.REQUIRED,
206
- "ENUM_32": this.ERROR_MESSAGE.INVALID_ENUM,
207
- "NUMBER_41": this.ERROR_MESSAGE.INVALID_NUMBER,
208
- "STRING_41": this.ERROR_MESSAGE.INVALID_STRING,
209
- "ENUM_41": this.ERROR_MESSAGE.INVALID_ENUM,
210
- "ENUM_42": this.ERROR_MESSAGE.INVALID_ENUM,
211
- "MAP_01": this.ERROR_MESSAGE.INVALID_MAP_NUMBER, // // tODO : mapのエラーメッセージどうするか
212
- "MAP_02": this.ERROR_MESSAGE.INVALID_MAP_STRING,
213
- "MAP_03": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
214
- "MAP_04": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
215
- "MAP_05": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
216
- "MAP_11": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
217
- "MAP_12": this.ERROR_MESSAGE.INVALID_MAP_STRING,
218
- "MAP_13": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
219
- "MAP_14": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
220
- "MAP_15": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
221
- "MAP_31": this.ERROR_MESSAGE.INVALID_MAP_NUMBER,
222
- "MAP_32": this.ERROR_MESSAGE.INVALID_MAP_STRING,
223
- "MAP_33": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
224
- "MAP_34": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
225
- "MAP_35": this.ERROR_MESSAGE.INVALID_MAP_BOOL,
226
- "NUMBER_91": this.ERROR_MESSAGE.INVALID_NUMBER,
227
- "NUMBER_92": this.ERROR_MESSAGE.INVALID_NUMBER_MIN,
228
- "NUMBER_93": this.ERROR_MESSAGE.INVALID_NUMBER_MAX,
229
- "BOOL_91": this.ERROR_MESSAGE.INVALID_BOOL,
230
- "BOOL_92": this.ERROR_MESSAGE.INVALID_BOOL,
231
- "BOOL_93": this.ERROR_MESSAGE.INVALID_BOOL,
232
- "STRING_91": this.ERROR_MESSAGE.INVALID_STRING,
233
- "STRING_92": this.ERROR_MESSAGE.INVALID_STRING_MAX_LENGTH,
234
- "STRING_93": this.ERROR_MESSAGE.INVALID_STRING_REG_EXP,
235
- "UUID_91": this.ERROR_MESSAGE.INVALID_UUID,
236
- "MAIL_91": this.ERROR_MESSAGE.INVALID_MAIL,
237
- "DATE_91": this.ERROR_MESSAGE.INVALID_DATE,
238
- "DATE_92": this.ERROR_MESSAGE.INVALID_DATE,
239
- "TIME_91": this.ERROR_MESSAGE.INVALID_TIME,
240
- "DATETIME_91": this.ERROR_MESSAGE.INVALID_DATETIME,
241
- "DATETIME_92": this.ERROR_MESSAGE.INVALID_DATETIME,
242
- "HTTPS_91": this.ERROR_MESSAGE.INVALID_HTTPS,
243
- "BASE64_91": this.ERROR_MESSAGE.INVALID_BASE64,
244
- }
245
-
246
- let errorMessage = list[code];
247
- const property = this.getProperty(keys);
248
- switch (property?.type) {
249
- case 'enum':
250
- case 'enum?':
251
- errorMessage = errorMessage.replace('{enums}', Object.keys(property.enums ?? '').join(','));
252
- break;
253
- case 'string':
254
- case 'string?':
255
- errorMessage = errorMessage.replace('{maxLength}', (property.maxLength ?? '[未指定]').toString());
256
- errorMessage = errorMessage.replace('{regExp}', (property.regExp ?? '[未指定]').toString());
257
- break;
258
- case 'number':
259
- case 'number?':
260
- errorMessage = errorMessage.replace('{max}', (property.max ?? '[未指定]').toString());
261
- errorMessage = errorMessage.replace('{min}', (property.min ?? '[未指定]').toString());
262
- break;
263
- }
264
-
265
- errorMessage = errorMessage.replace("{property}", keys.join('.'));
266
- if (value === undefined || value === '') {
267
- errorMessage = errorMessage.replace("({value})", "");
268
- } else {
269
- errorMessage = errorMessage.replace("{value}", value);
270
- }
271
-
272
-
273
- return errorMessage;
274
- }
275
-
276
- /**
277
- * Generates an error message based on the provided code, keys, and value.
278
- * 指定されたコード、キー、および値に基づいてエラーメッセージを生成します。
279
- * @param {string} code - The error code. エラーコード
280
- * @param {Array<string | number>} keys - The keys indicating the property path. プロパティパスを示すキー
281
- * @param {any} value - The value that caused the error. エラーを引き起こした値
282
- * @returns {string} The generated error message. 生成されたエラーメッセージ
283
- */
284
- private throwInputError(code:
285
- "REQUIRE_00" | "REQUIRE_01" | "OBJECT_01" | "ARRAY_01" | "UNNECESSARY_01" |
286
- "REQUIRE_11" | "OBJECT_11" | "ARRAY_11" | "UNNECESSARY_11" |
287
- "NUMBER_21" | "NUMBER_22" | "NUMBER_23" | "BOOL_21" | "BOOL_22" | "BOOL_23" | "STRING_21" | "STRING_22" | "STRING_23" | "UUID_21" | "MAIL_21" | "DATE_21" | "DATE_22" |
288
- "TIME_21" | "DATETIME_21" | "DATETIME_22" | "HTTPS_21" | "BASE64_21" |
289
- "REQUIRE_31" |
290
- "ENUM_32" | "ENUM_41" | "ENUM_42" | "NUMBER_41" | "STRING_41" |
291
- "MAP_01" | "MAP_02" | "MAP_03" | "MAP_04" | "MAP_05" | "MAP_11" | "MAP_12" | "MAP_13" | "MAP_14" | "MAP_15" |
292
- "MAP_31" | "MAP_32" | "MAP_33" | "MAP_34" | "MAP_35" |
293
- "NUMBER_91" | "NUMBER_92" | "NUMBER_93" | "BOOL_91" | "BOOL_92" | "BOOL_93" | "STRING_91" | "STRING_92" | "STRING_93" | "UUID_91" | "MAIL_91" | "DATE_91" | "DATE_92" |
294
- "TIME_91" | "DATETIME_91" | "DATETIME_92" | "HTTPS_91" | "BASE64_91"
295
- , keys: Array<string | number>, value: any): never {
296
-
297
- throw new InputErrorException(code, this.createErrorMessage(code, keys, value));
298
- }
299
-
300
- /**
301
- * Sets the values of the request body to the class properties.
302
- * リクエストボディの値をクラスのプロパティにセットします。
303
- *
304
- * Note: This method is implemented as a separate method rather than in the constructor.
305
- * This is because if executed in the constructor, the properties of the inheriting class
306
- * are not yet initialized, and the values cannot be set correctly.
307
- * 注意: このメソッドはコンストラクタではなく別メソッドとして実装されています。
308
- * これは、コンストラクタ内で実行すると継承先のクラスのプロパティが
309
- * まだ初期化されていないため、正しく値をセットできないためです。
310
- *
311
- * @param {Object} body - Request body object, リクエストボディオブジェクト
312
- * @throws {InputErrorException} Thrown when the input value is invalid, 入力値が不正な場合にスローされます
313
- */
314
- private async createBody(module: 'express' | 'hono', request: Request | Context): Promise<void> {
315
- let method = '';
316
- if (module === 'express') {
317
- const req = request as Request;
318
- method = req.method;
319
- if (method === 'GET' || method === 'DELETE') {
320
- this.data = req.query;
321
- } else {
322
- this.data = req.body;
323
- }
324
- } else {
325
- const c = request as Context;
326
- method = c.req.method;
327
- if (method === 'GET' || method === 'DELETE') {
328
- const url = new URL(c.req.url);
329
- this.data = Object.fromEntries(url.searchParams.entries());
330
- } else {
331
- // JSON を想定(form 等なら parseBody() を使う)
332
- this.data = await c.req.json();
333
- }
334
- }
335
-
336
-
337
- if (this.data === undefined) {
338
- this.data = {};
339
- }
340
-
341
- for (const key of Object.keys(this.properties)) {
342
-
343
- // NULLチェック
344
- if (key in this.data === false || this.data[key] === null || this.data[key] === "") {
345
- if (this.properties[key].type === 'array' && ['GET', 'DELETE'].includes(method)) {
346
- // GET,DELETEメソッドの場合、?array=1&array=2で配列となるが、
347
- // ?array=1のみで終わる場合は配列にならないため、直接配列にしている
348
- // この処理で空文字やnullが入った場合の対処をここで行う
349
- const itemProperty = this.properties[key].item;
350
- if (itemProperty.type.endsWith('?')) {
351
- const tempValue = this.data[key];
352
- this.data[key] = [];
353
- if (tempValue !== undefined) {
354
- if (itemProperty.type === 'string?') {
355
- this.data[key][0] = tempValue;
356
- } else {
357
- this.data[key][0] = null;
358
- }
359
- }
360
- continue;
361
- } else {
362
- this.throwInputError("REQUIRE_00", [key, 0], "");
363
- }
364
- } else {
365
- if (this.properties[key].type.endsWith('?')) {
366
- this.changeBody([key], null);
367
- continue;
368
- } else {
369
- this.throwInputError("REQUIRE_01", [key], "");
370
- }
371
- }
372
- }
373
-
374
- const value = this.data[key];
375
- switch (this.properties[key].type) {
376
- case 'object':
377
- case 'object?':
378
- if (typeof value === 'object') {
379
- this.setObject([key], value);
380
- } else {
381
- this.throwInputError("OBJECT_01", [key], value);
382
- }
383
- break;
384
- case 'array':
385
- case 'array?':
386
- if (Array.isArray(value)) {
387
- this.setArray([key], value);
388
- } else {
389
- if (method === 'GET' || method === 'DELETE') {
390
- // GET,DELETEメソッドの場合、?array=1&array=2で配列となるが、
391
- // ?array=1のみで終わる場合は配列にならないため、直接配列にしている
392
- const type = this.properties[key].item.type;
393
- if (type === 'object' || type === 'object?' || type === 'array' || type === 'array?' || type === 'map' || type === 'map?') {
394
- throw new Error("GETまたはDELETEメソッドでは配列型にobject, array, mapを使用することはできません。");
395
- }
396
-
397
- if (type === 'enum' || type === 'enum?') {
398
- const tempProp = {
399
- type: type,
400
- description: this.properties[key].item.description,
401
- enumType: this.properties[key].item.enumType,
402
- enums: this.properties[key].item.enums,
403
- };
404
- this.data[key] = [this.convertValue(tempProp, value, [key, 0], true)];
405
- } else if (type === 'string' || type === 'string?') {
406
- const tempProp = {
407
- type: type,
408
- description: this.properties[key].item.description,
409
- maxLength: this.properties[key].item.maxLength,
410
- regExp: this.properties[key].item.regExp
411
- };
412
- this.data[key] = [this.convertValue(tempProp, value, [key, 0], true)];
413
- } else if (type === 'number' || type === 'number?') {
414
- const tempProp = {
415
- type: type,
416
- description: this.properties[key].item.description,
417
- max: this.properties[key].item.max,
418
- min: this.properties[key].item.min,
419
- };
420
- this.data[key] = [this.convertValue(tempProp, value, [key, 0], true)];
421
- } else {
422
- const tempProp = {
423
- type: type,
424
- description: this.properties[key].item.description
425
- };
426
- this.data[key] = [this.convertValue(tempProp, value, [key, 0], true)];
427
- }
428
-
429
- } else {
430
- this.throwInputError("ARRAY_01", [key], value);
431
- }
432
- }
433
- break;
434
- case 'map':
435
- case 'map?':
436
- // tODO : ここは共通化したい
437
- const mapData: {[key: string]: string | number | boolean} = {};
438
- for (const [mapKey, mapValue] of Object.entries(value)) {
439
- switch (this.properties[key].mapType) {
440
- case 'number':
441
- if (this.isNumber(mapValue) === false) {
442
- this.throwInputError("MAP_01", [key], value);
443
- }
444
- mapData[mapKey] = Number(mapValue);
445
- break;
446
- case 'string':
447
- switch (typeof mapValue) {
448
- case 'number':
449
- mapData[mapKey] = mapValue.toString();
450
- break;
451
- case 'string':
452
- mapData[mapKey] = mapValue;
453
- break;
454
- default:
455
- this.throwInputError("MAP_02", [key], value);
456
- }
457
- break;
458
- case 'bool':
459
- switch (typeof mapValue) {
460
- case 'boolean':
461
- mapData[mapKey] = mapValue;
462
- break;
463
- case 'number':
464
- if (mapValue !== 0 && mapValue !== 1) {
465
- this.throwInputError("MAP_03", [key], mapValue);
466
- }
467
- mapData[mapKey] = mapValue === 1;
468
- break;
469
- case 'string':
470
- if (mapValue !== 'true' && mapValue !== 'false') {
471
- this.throwInputError("MAP_04", [key], mapValue);
472
- }
473
- mapData[mapKey] = mapValue === 'true';
474
- break;
475
- default:
476
- this.throwInputError("MAP_05", [key], mapValue);
477
- }
478
- break;
479
- }
480
- }
481
-
482
- this.changeBody([key], mapData);
483
- break;
484
- case 'enum':
485
- case 'enum?':
486
- this.setEnum([key], value);
487
- break;
488
- default:
489
- this.convertInput([key], value);
490
- break;
491
- }
492
- }
493
-
494
- // 不要項目チェック
495
- for (const [key, value] of Object.entries(this.data)) {
496
- if (key in this.properties === false) {
497
- this.throwInputError("UNNECESSARY_01", [key], value);
498
- }
499
- }
500
- }
501
-
502
- /**
503
- * Sets the value for an enum type based on the specified keys.
504
- * 指定されたキーに基づいて列挙型の値を設定します。
505
- * @param {Array<string | number>} keys - Path to the target (array of strings or index numbers)
506
- * 処理対象のパス(文字列またはインデックス番号の配列)
507
- * @param {any} value - Value to be set
508
- * 設定する値
509
- * @throws {InputErrorException} Thrown when the type does not match
510
- * 型が一致しない場合にスローされます
511
- */
512
- private setEnum(keys: Array<string | number>, value: any) {
513
- const property = this.getProperty(keys);
514
- if (property.type !== 'enum' && property.type !== 'enum?') {
515
- throw new Error(`setEnumメソッドでEnum型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
516
- }
517
-
518
- const enumType = property.enumType;
519
- if (value === undefined || value === null || (typeof value === 'string' && value === '')) {
520
- if (enumType.endsWith('?')) {
521
- this.changeBody(keys, null);
522
- } else {
523
- this.throwInputError("ENUM_41", keys, value);
524
- }
525
- }
526
-
527
- switch (enumType) {
528
- case 'number':
529
- case 'number?':
530
- if (this.isNumber(value) === false) {
531
- this.throwInputError("NUMBER_41", keys, value);
532
- }
533
- value = Number(value);
534
- break;
535
- case 'string':
536
- case 'string?':
537
- switch (typeof value) {
538
- case 'number':
539
- value = value.toString();
540
- break;
541
- case 'string':
542
- value = value;
543
- break;
544
- default:
545
- this.throwInputError("STRING_41", keys, value);
546
- }
547
- break;
548
- }
549
-
550
- if (Object.keys(property.enums).includes(value.toString()) === false) {
551
- this.throwInputError("ENUM_42", keys, value);
552
- }
553
-
554
- this.changeBody(keys, value);
555
- }
556
-
557
- /**
558
- * Recursively processes array type values.
559
- * Validates each element of the array and converts it to the appropriate type.
560
- * 配列型の値を再帰的に処理します。
561
- * 配列の各要素を検証し、適切な型に変換します。
562
- *
563
- * @param {Array<string | number>} keys - Current processing path (array of strings or index numbers)
564
- * 現在の処理パス(文字列またはインデックス番号の配列)
565
- * @param {any[]} values - Array to be processed
566
- * 処理対象の配列
567
- * @throws {InputErrorException} Thrown when the type of an array element is invalid
568
- * 配列要素の型が不正な場合にスローされます
569
- */
570
- private setArray(keys: Array<string | number>, values: any) {
571
- const property = this.getProperty(keys);
572
- if (property.type !== 'array' && property.type !== 'array?') {
573
- throw new Error(`setArrayメソッドでArray型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
574
- }
575
-
576
- for (let i = 0;i < values.length; i++) {
577
-
578
- // NULL Check
579
- if (values[i] === undefined || values[i] === null || (property.item.type.replace("?", "") !== "string" && values[i] === "")) {
580
- if (property.item.type.endsWith('?')) {
581
- this.changeBody([...keys, i], values[i] === undefined ? undefined : null);
582
- continue;
583
- } else {
584
- this.throwInputError("REQUIRE_31", [...keys, i], "");
585
- }
586
- }
587
-
588
- switch (property.item.type) {
589
- case 'object':
590
- case 'object?':
591
- this.setObject([...keys, i], values[i]);
592
- break;
593
- case 'array':
594
- case 'array?':
595
- this.setArray([...keys, i], values[i]);
596
- break;
597
- case 'enum':
598
- case 'enum?':
599
- this.setEnum([...keys, i], values[i]);
600
- break;
601
- case 'map':
602
- case 'map?':
603
- const mapData: {[key: string]: string | number | boolean} = {};
604
- for (const [mapKey, mapValue] of Object.entries(values[i])) {
605
- switch (property.item.mapType) {
606
- case 'number':
607
- if (this.isNumber(mapValue) === false) {
608
- this.throwInputError("MAP_31", [...keys, i], values[i]);
609
- }
610
- mapData[mapKey] = Number(mapValue);
611
- break;
612
- case 'string':
613
- switch (typeof mapValue) {
614
- case 'number':
615
- mapData[mapKey] = mapValue.toString();
616
- break;
617
- case 'string':
618
- mapData[mapKey] = mapValue;
619
- break;
620
- default:
621
- this.throwInputError("MAP_32", [...keys, i], values[i]);
622
- }
623
- break;
624
- case 'bool':
625
- switch (typeof mapValue) {
626
- case 'boolean':
627
- mapData[mapKey] = mapValue;
628
- break;
629
- case 'number':
630
- if (mapValue !== 0 && mapValue !== 1) {
631
- this.throwInputError("MAP_33", keys, mapValue);
632
- }
633
- mapData[mapKey] = mapValue === 1;
634
- break;
635
- case 'string':
636
- if (mapValue !== 'true' && mapValue !== 'false') {
637
- this.throwInputError("MAP_34", keys, mapValue);
638
- }
639
- mapData[mapKey] = mapValue === 'true';
640
- break;
641
- default:
642
- this.throwInputError("MAP_35", keys, mapValue);
643
- }
644
- break;
645
- }
646
- }
647
-
648
- this.changeBody([...keys, i], mapData);
649
- break;
650
- default:
651
- this.convertInput([...keys, i], values[i]);
652
- break;
653
- }
654
- }
655
- }
656
-
657
- /**
658
- * Set the value of the request body to the specified path.
659
- * Automatically create intermediate objects or arrays as needed.
660
- * リクエストボディの値を指定されたパスに設定します。
661
- * 必要に応じて中間のオブジェクトや配列を自動的に作成します。
662
- * @param {Array<string | number>} keys - Path to the destination (array of strings or index numbers)
663
- * 設定先へのパス(文字列またはインデックス番号の配列)
664
- * @param {any} value - Value to be set
665
- * 設定する値
666
- */
667
- private changeBody(keys: Array<string | number>, value: any) {
668
- let body: any = this.data;
669
- // 最後のキーを除いて順番にオブジェクトを辿る
670
- for (let i = 0; i < keys.length - 1; i++) {
671
- const key = keys[i];
672
- const nextKey = keys[i + 1];
673
-
674
- // 次のキーが数値型の場合は配列、そうでない場合はオブジェクトとして初期化
675
- if (!(key in body)) {
676
- body[key] = typeof nextKey === 'number' ? [] : {};
677
- }
678
- body = body[key];
679
- }
680
- // 最後のキーに対して値を設定
681
- body[keys[keys.length - 1]] = value;
682
- }
683
-
684
- /**
685
- * Process object type values recursively.
686
- * Validate object properties and convert them to appropriate types.
687
- * オブジェクト型の値を再帰的に処理します。
688
- * オブジェクトのプロパティを検証し、適切な型に変換します。
689
- * @param {Array<string | number>} keys - Current processing path (array of strings or index numbers)
690
- * 現在の処理パス(文字列またはインデックス番号の配列)
691
- * @param {object} values - Object to be processed
692
- * 処理対象のオブジェクト
693
- * @throws {InputErrorException} Thrown when the property type is invalid
694
- * プロパティの型が不正な場合にスローされます
695
- */
696
- private setObject(keys: Array<string | number>, values: {[key: string]: any}) {
697
- const property = this.getProperty(keys);
698
- if (property.type !== 'object' && property.type !== 'object?') {
699
- throw new Error(`setObjectメソッドでObject型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
700
- }
701
-
702
- for (const key of Object.keys(property.properties)) {
703
-
704
- // NULL Check
705
- if (key in values === false || values[key] === null || values[key] === "") {
706
- if (property.properties[key].type.endsWith('?')) {
707
- this.changeBody([...keys, key], null);
708
- continue;
709
- } else {
710
- this.throwInputError("REQUIRE_11", [...keys, key], "");
711
- }
712
- }
713
-
714
- const value = values[key];
715
- switch (property.properties[key].type) {
716
- case 'object':
717
- case 'object?':
718
- if (typeof value === 'object') {
719
- this.setObject([...keys, key], value);
720
- } else {
721
- this.throwInputError("OBJECT_11", [...keys, key], value);
722
- }
723
- break;
724
- case 'array':
725
- case 'array?':
726
- if (Array.isArray(value)) {
727
- this.setArray([...keys, key], value);
728
- } else {
729
- this.throwInputError("ARRAY_11", [...keys, key], value);
730
- }
731
- break;
732
- case 'enum':
733
- case 'enum?':
734
- this.setEnum([...keys, key], value);
735
- break;
736
- case 'map':
737
- case 'map?':
738
- const mapData: {[key: string]: string | number | boolean} = {};
739
- for (const [mapKey, mapValue] of Object.entries(value)) {
740
- switch (property.properties[key].mapType) {
741
- case 'number':
742
- if (this.isNumber(mapValue) === false) {
743
- this.throwInputError("MAP_11", [key], value);
744
- }
745
- mapData[mapKey] = Number(mapValue);
746
- break;
747
- case 'string':
748
- switch (typeof mapValue) {
749
- case 'number':
750
- mapData[mapKey] = mapValue.toString();
751
- break;
752
- case 'string':
753
- mapData[mapKey] = mapValue;
754
- break;
755
- default:
756
- this.throwInputError("MAP_12", [key], value);
757
- }
758
- break;
759
- case 'bool':
760
- switch (typeof mapValue) {
761
- case 'boolean':
762
- mapData[mapKey] = mapValue;
763
- break;
764
- case 'number':
765
- if (mapValue !== 0 && mapValue !== 1) {
766
- this.throwInputError("MAP_13", keys, mapValue);
767
- }
768
- mapData[mapKey] = mapValue === 1;
769
- break;
770
- case 'string':
771
- if (mapValue !== 'true' && mapValue !== 'false') {
772
- this.throwInputError("MAP_14", keys, mapValue);
773
- }
774
- mapData[mapKey] = mapValue === 'true';
775
- break;
776
- default:
777
- this.throwInputError("MAP_15", keys, mapValue);
778
- }
779
- break;
780
- }
781
- }
782
-
783
- this.changeBody([...keys, key], mapData);
784
- break;
785
- default:
786
- this.convertInput([...keys, key], value);
787
- break;
788
- }
789
- }
790
-
791
- // unnecessary input check
792
- for (const [key, value] of Object.entries(values)) {
793
- if (key in property.properties === false) {
794
- this.throwInputError("UNNECESSARY_11", [...keys, key], value);
795
- }
796
- }
797
- }
798
-
799
- /**
800
- * Convert the input value based on the specified type.
801
- * Throws an exception if type conversion fails.
802
- * 指定された型に基づいて入力値を変換します。
803
- * 型変換に失敗した場合は例外をスローします。
804
- *
805
- * @param {string} property - The type to convert to (e.g., 'number', 'boolean', 'string', 'date', 'time', 'datetime')
806
- * 変換する型(例: 'number', 'boolean', 'string', 'date', 'time', 'datetime')
807
- * @param {any} value - The value to convert
808
- * 変換する値
809
- * @param {Array<string | number>} keys - The path to the target (array of strings or index numbers)
810
- * 処理対象のパス(文字列またはインデックス番号の配列)
811
- * @returns {any} The converted value, 変換された値
812
- * @throws {InputErrorException} Thrown if type conversion fails, 型変換に失敗した場合にスローされます
813
- */
814
- private convertValue(property: PropertyType, value: any, keys: Array<string | number>, isRequestBody: boolean) {
815
-
816
- switch (property.type) {
817
- case 'number':
818
- case 'number?':
819
- if (this.isNumber(value) === false) {
820
- this.throwInputError(isRequestBody ? "NUMBER_21" : "NUMBER_91", keys, value);
821
- }
822
- const numberValue = Number(value);
823
- if (property.min !== undefined && numberValue < property.min) {
824
- this.throwInputError(isRequestBody ? "NUMBER_22" : "NUMBER_92", keys, value);
825
- }
826
-
827
- if (property.max !== undefined && numberValue > property.max) {
828
- this.throwInputError(isRequestBody ? "NUMBER_23" : "NUMBER_93", keys, value);
829
- }
830
- return numberValue;
831
- case 'boolean':
832
- case 'boolean?':
833
- switch (typeof value) {
834
- case 'boolean':
835
- return value;
836
- case 'number':
837
- if (value !== 0 && value !== 1) {
838
- this.throwInputError(isRequestBody ? "BOOL_21" : "BOOL_91", keys, value);
839
- }
840
- return value === 1 ? true : false;
841
- case 'string':
842
- if (value !== 'true' && value !== 'false') {
843
- this.throwInputError(isRequestBody ? "BOOL_22" : "BOOL_92", keys, value);
844
- }
845
- return value === 'true' ? true : false;
846
- default:
847
- this.throwInputError(isRequestBody ? "BOOL_23" : "BOOL_93", keys, value);
848
- }
849
- case 'string':
850
- case 'string?':
851
- let stringValue: string = "";
852
- switch (typeof value) {
853
- case 'number':
854
- stringValue = value.toString();
855
- break;
856
- case 'string':
857
- stringValue = value;
858
- break;
859
- default:
860
- this.throwInputError(isRequestBody ? "STRING_21" : "STRING_91", keys, value);
861
- }
862
-
863
- if (property.maxLength !== undefined && stringValue.length > property.maxLength) {
864
- this.throwInputError(isRequestBody ? "STRING_22" : "STRING_92", keys, value);
865
- }
866
-
867
- if (property.regExp !== undefined && property.regExp.test(stringValue) === false) {
868
- this.throwInputError(isRequestBody ? "STRING_23" : "STRING_93", keys, value);
869
- }
870
-
871
- return stringValue;
872
- case 'uuid':
873
- case 'uuid?':
874
- if (StringUtil.isUUID(value)) {
875
- return value;
876
- }
877
- this.throwInputError(isRequestBody ? "UUID_21" : "UUID_91", keys, value);
878
- case 'mail':
879
- case 'mail?':
880
- if (ValidateStringUtil.isMail(value)) {
881
- return value;
882
- }
883
- this.throwInputError(isRequestBody ? "MAIL_21" : "MAIL_91", keys, value);
884
- case 'date':
885
- case 'date?':
886
- if (this.isYYYYMMDD(value) === false) {
887
- this.throwInputError(isRequestBody ? "DATE_21" : "DATE_91", keys, value);
888
- }
889
-
890
- if (this.isErrorDateTime(value)) {
891
- this.throwInputError(isRequestBody ? "DATE_22" : "DATE_92", keys, value);
892
- }
893
- return value;
894
- case 'time':
895
- case 'time?':
896
- if (this.isHHMM(value)) {
897
- return `${value}`;
898
- }
899
- this.throwInputError(isRequestBody ? "TIME_21" : "TIME_91", keys, value);
900
- case 'datetime':
901
- case 'datetime?':
902
- if (this.isYYYYMMDDhhmi(value)) {
903
- value += ':00';
904
- }
905
-
906
- if (this.isYYYYMMDDhhmiss(value) === false) {
907
- this.throwInputError(isRequestBody ? "DATETIME_21" : "DATETIME_91", keys, value);
908
- }
909
-
910
- if (this.isErrorDateTime(value)) {
911
- this.throwInputError(isRequestBody ? "DATETIME_22" : "DATETIME_92", keys, value);
912
- }
913
- return value.replace('T', ' ');
914
- case 'https':
915
- case 'https?':
916
- if (ValidateStringUtil.isHttps(value)) {
917
- return value;
918
- }
919
- this.throwInputError(isRequestBody ? "HTTPS_21" : "HTTPS_91", keys, value);
920
- case 'base64':
921
- case 'base64?':
922
- if (ValidateStringUtil.isBase64(value)) {
923
- return value;
924
- }
925
- this.throwInputError(isRequestBody ? "BASE64_21" : "BASE64_91", keys, value);
926
- }
927
-
928
- return value;
929
- }
930
-
931
- /**
932
- * Convert the input value to the specified type.
933
- * Throws an exception if type conversion fails.
934
- * 入力値を指定された型に変換します。
935
- * 型変換に失敗した場合は例外をスローします。
936
- * @param {Array<string | number>} keys - Path to the target (array of strings or index numbers)
937
- * 処理対象のパス(文字列またはインデックス番号の配列)
938
- * @param {any} value - Value to be converted
939
- * 変換する値
940
- * @throws {InputErrorException} Thrown when type conversion fails
941
- * 型変換に失敗した場合にスローされます
942
- */
943
- private convertInput(keys: Array<string | number>, value: any) {
944
- const property = this.getProperty(keys);
945
- this.changeBody(keys, this.convertValue(property, value, keys, true));
946
- }
947
-
948
-
949
- // ****************************************************************************
950
- // for create swagger
951
- // ****************************************************************************
952
-
953
-
954
- /**
955
- * Generates a Swagger YAML definition from the request body.
956
- * リクエストボディからSwaggerのYAML定義を生成します。
957
- * @returns {string} Swagger format YAML definition
958
- * Swagger形式のYAML定義
959
- */
960
- public createSwagger(method: string) {
961
-
962
- if (method === 'GET' || method === 'DELETE') {
963
-
964
- const tabCount = 4;
965
- const space = ' '.repeat(tabCount);
966
-
967
- let ymlString = '';
968
- for (const [key, property] of Object.entries(this.properties)) {
969
- ymlString += `${space}- name: ${key}\n`;
970
- ymlString += `${space} in: query\n`;
971
-
972
- const descJoin = `\n${space} `;
973
- if (property.type === 'enum' || property.type === 'enum?') {
974
- ymlString += `${space} description: |${property.description === undefined ? '' : `${descJoin}${property.description.replaceAll("\n", descJoin)}`}`;
975
- ymlString += `${descJoin}enum list`;
976
- ymlString += `${Object.entries(property.enums).map(([key, value]) => `${descJoin}- ${key}: ${value}`)}\n`;
977
- } else if (property.description !== undefined) {
978
- ymlString += `${space} description: |\n${space} ${property.description.replaceAll("\n", descJoin)}\n`;
979
- }
980
- ymlString += `${space} required: ${property.type.endsWith('?') ? 'false' : 'true'}\n`;
981
- ymlString += `${space} schema:\n`;
982
- ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
983
- if (property.type === 'enum' || property.type === 'enum?') {
984
- ymlString += `${space} nullable: ${property.enumType.endsWith('?')}\n`;
985
- ymlString += `${space} enum:\n`;
986
- for (const type of Object.keys(property.enumType)) {
987
- ymlString += `${space} - ${type}\n`;
988
- }
989
- if (property.enumType.endsWith('?')) {
990
- ymlString += `${space} - null\n`;
991
- }
992
- }
993
- }
994
-
995
- return ymlString;
996
- } else {
997
- const tabCount = 8;
998
- const space = ' '.repeat(tabCount);
999
- let componentYml = '\n';
1000
- let requiredList: Array<string> = [];
1001
- for (const [key, property] of Object.entries(this.properties)) {
1002
- if (property.type.endsWith('?') === false) {
1003
- requiredList.push(key);
1004
- }
1005
-
1006
- componentYml += `${space}${key}:\n`;
1007
- componentYml += ` ${space}type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
1008
- const descJoin = `\n${space} `;
1009
- if (property.type === 'enum' || property.type === 'enum?') {
1010
- componentYml += `${space} description: |${property.description === undefined ? '' : `${descJoin}${property.description.replaceAll("\n", descJoin)}`}`;
1011
- componentYml += `${descJoin}enum list`;
1012
- componentYml += `${Object.entries(property.enums).map(([key, value]) => `${descJoin}- ${key}: ${value}`)}\n`;
1013
- } else if (property.description !== undefined) {
1014
- componentYml += `${space} description: |${descJoin}${property.description.replaceAll("\n", descJoin)}\n`;
1015
- }
1016
-
1017
- if (property.type === 'enum' || property.type === 'enum?') {
1018
- componentYml += `${space} nullable: ${property.enumType.endsWith('?')}\n`;
1019
- componentYml += `${space} enum:\n`;
1020
- for (const type of Object.keys(property.enums)) {
1021
- componentYml += `${space} - ${type}\n`;
1022
- }
1023
- if (property.enumType.endsWith('?')) {
1024
- componentYml += `${space} - null\n`;
1025
- }
1026
- }
1027
-
1028
- switch (property.type) {
1029
- case 'object':
1030
- case 'object?':
1031
- componentYml += this.makeSwaggerProperyFromObject([key], tabCount + 1);
1032
- break;
1033
- case 'array':
1034
- case 'array?':
1035
- componentYml += this.makeSwaggerPropertyFromArray([key], tabCount + 1);
1036
- break;
1037
- }
1038
- }
1039
-
1040
- if (requiredList.length > 0) {
1041
- componentYml += ` required:\n`;
1042
- componentYml += ` - ${requiredList.join(`\n - `)}\n`;
1043
- }
1044
-
1045
- let ymlString = ` requestBody:\n`;
1046
- ymlString += ` content:\n`;
1047
- ymlString += ` application/json:\n`;
1048
- ymlString += ` schema:\n`;
1049
- ymlString += ` type: object\n`;
1050
- ymlString += ` properties:${componentYml}`;
1051
- ymlString += ` application/x-www-form-urlencoded:\n`;
1052
- ymlString += ` schema:\n`;
1053
- ymlString += ` type: object\n`;
1054
- ymlString += ` properties:${componentYml}`;
1055
-
1056
- return ymlString;
1057
- }
1058
- }
1059
-
1060
-
1061
- /**
1062
- * Generates Swagger properties from object type properties
1063
- * オブジェクト型のプロパティからSwaggerのプロパティを生成
1064
- * @param {Array.<string|number>} keys - Path to the properties
1065
- * プロパティへのパス
1066
- * @returns {string} Swagger format property definition
1067
- * Swagger形式のプロパティ定義
1068
- */
1069
- private makeSwaggerProperyFromObject(keys: Array<string | number>, tabCount: number): string {
1070
-
1071
- const objectProperty = this.getProperty(keys);
1072
- if (objectProperty.type !== 'object' && objectProperty.type !== 'object?') {
1073
- throw new Error(`setObjectメソッドでObject型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
1074
- }
1075
-
1076
- const space = ' '.repeat(tabCount);
1077
- let ymlString = `${space}properties:\n`;
1078
- for (const key of Object.keys(objectProperty.properties)) {
1079
- const property = objectProperty.properties[key];
1080
-
1081
- ymlString += `${space} ${key}:\n`;
1082
- ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(property)}\n`;
1083
- const descJoin = `\n${space} `;
1084
- if (property.type === 'enum' || property.type === 'enum?') {
1085
- ymlString += `${space} description: |${property.description === undefined ? '' : `${descJoin}${property.description.replaceAll('\n', descJoin)}`}`;
1086
- ymlString += `${descJoin}enum list`;
1087
- ymlString += `${Object.entries(property.enums).map(([key, value]) => `${descJoin}- ${key}: ${value}`)}\n`;
1088
- } else if ((property.description ?? '') !== '') {
1089
- ymlString += `${space} description: |${descJoin}${(property.description ?? "").replaceAll('\n', descJoin)}\n`;
1090
- }
1091
-
1092
- if (property.type === 'enum' || property.type === 'enum?') {
1093
- ymlString += `${space} nullable: ${property.enumType.endsWith('?')}\n`;
1094
- ymlString += `${space} enum:\n`;
1095
- for (const type of Object.keys(property.enumType)) {
1096
- ymlString += `${space} - ${type}\n`;
1097
- }
1098
- if (property.enumType.endsWith('?')) {
1099
- ymlString += `${space} - null\n`;
1100
- }
1101
- }
1102
-
1103
- switch (property.type) {
1104
- case 'object':
1105
- case 'object?':
1106
- ymlString += this.makeSwaggerProperyFromObject([...keys, key], tabCount + 2);
1107
- break;
1108
- case 'array':
1109
- case 'array?':
1110
- ymlString += this.makeSwaggerPropertyFromArray([...keys, key], tabCount + 2);
1111
- break;
1112
- }
1113
- }
1114
-
1115
- return ymlString;
1116
- }
1117
-
1118
- /**
1119
- * Generates Swagger properties from array type properties
1120
- * 配列型のプロパティからSwaggerのプロパティを生成
1121
- * @param {Array.<string|number>} keys - Path to the properties
1122
- * プロパティへのパス
1123
- * @returns {string} Swagger format property definition
1124
- * Swagger形式のプロパティ定義
1125
- */
1126
- private makeSwaggerPropertyFromArray(keys: Array<string | number>, tabCount: number): string {
1127
-
1128
- const arrayProperty = this.getProperty(keys);
1129
- if (arrayProperty.type !== 'array' && arrayProperty.type !== 'array?') {
1130
- throw new Error(`getArrayメソッドでArray型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
1131
- }
1132
-
1133
- const space = ' '.repeat(tabCount);
1134
-
1135
- let ymlString = `${space}items:\n`;
1136
- ymlString += `${space} type: ${this.replaceFromPropertyTypeToSwagger(arrayProperty.item)}\n`;
1137
- if ((arrayProperty.item.description ?? '') !== '') {
1138
- const descJoin = `\n${space} `;
1139
- ymlString += `${space} description: |${descJoin}${(arrayProperty.item.description ?? '').replaceAll('\n', descJoin)}\n`;
1140
- }
1141
-
1142
-
1143
- switch (arrayProperty.item.type) {
1144
- case 'object':
1145
- case 'object?':
1146
- ymlString += this.makeSwaggerProperyFromObject([...keys, 0], tabCount + 1);
1147
- break;
1148
- case 'array':
1149
- case 'array?':
1150
- ymlString += this.makeSwaggerPropertyFromArray([...keys, 0], tabCount + 1);
1151
- break;
1152
- }
1153
-
1154
- return ymlString;
1155
- }
1156
-
1157
- public getInputErrorList(method: string): Array<IError> {
1158
- let errorList: Array<IError> = [];
1159
-
1160
- for (const [key, property] of Object.entries(this.properties)) {
1161
- if (property.type.endsWith('?') === false) {
1162
- const errorCode = property.type === 'array' && ['GET', 'DELETE'].includes(method) ? 'REQUIRE_00' : 'REQUIRE_01';
1163
- errorList.push({
1164
- status: 400,
1165
- code: errorCode,
1166
- description: this.createErrorMessage(errorCode, [key])
1167
- });
1168
- }
1169
-
1170
- switch (property.type) {
1171
- case 'object':
1172
- case 'object?':
1173
- errorList.push({
1174
- status: 400,
1175
- code: 'OBJECT_01',
1176
- description: this.createErrorMessage('OBJECT_01', [key])
1177
- });
1178
-
1179
- errorList = [...errorList, ...this.getErrorObject([key])];
1180
- break;
1181
- case 'array':
1182
- case 'array?':
1183
- errorList.push({
1184
- status: 400,
1185
- code: 'ARRAY_01',
1186
- description: this.createErrorMessage('ARRAY_01', [key])
1187
- });
1188
-
1189
- errorList = [...errorList, ...this.getErrorArray([key])];
1190
- break;
1191
- case 'map':
1192
- case 'map?':
1193
- switch (property.mapType) {
1194
- case 'number':
1195
- errorList.push({
1196
- status: 400,
1197
- code: 'MAP_01',
1198
- description: this.createErrorMessage('MAP_01', [key])
1199
- });
1200
- break;
1201
- case 'string':
1202
- errorList.push({
1203
- status: 400,
1204
- code: 'MAP_02',
1205
- description: this.createErrorMessage('MAP_02', [key])
1206
- });
1207
- break;
1208
- case 'bool':
1209
- errorList.push({
1210
- status: 400,
1211
- code: 'MAP_03',
1212
- description: this.createErrorMessage('MAP_03', [key])
1213
- });
1214
- errorList.push({
1215
- status: 400,
1216
- code: 'MAP_04',
1217
- description: this.createErrorMessage('MAP_04', [key])
1218
- });
1219
- errorList.push({
1220
- status: 400,
1221
- code: 'MAP_05',
1222
- description: this.createErrorMessage('MAP_05', [key])
1223
- });
1224
- break;
1225
- }
1226
- break;
1227
- default:
1228
- errorList = [...errorList, ...this.getError([key], true)];
1229
- break;
1230
- }
1231
- }
1232
-
1233
- return errorList;
1234
- }
1235
-
1236
- private getErrorObject(keys: Array<string | number>): Array<IError> {
1237
- let errorList: Array<IError> = [];
1238
-
1239
- const property = this.getProperty(keys);
1240
- if (property.type !== 'object' && property.type !== 'object?') {
1241
- throw new Error(`sgetErrorObjectメソッドでObject型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
1242
- }
1243
-
1244
- for (const key of Object.keys(property.properties)) {
1245
- if (property.properties[key].type.endsWith('?') === false) {
1246
- errorList.push({
1247
- status: 400,
1248
- code: 'REQUIRE_11',
1249
- description: this.createErrorMessage('REQUIRE_11', [...keys, key]),
1250
- });
1251
- }
1252
-
1253
- switch (property.properties[key].type) {
1254
- case 'object':
1255
- case 'object?':
1256
- errorList.push({
1257
- status: 400,
1258
- code: 'OBJECT_11',
1259
- description: this.createErrorMessage('OBJECT_11', [...keys, key]),
1260
- });
1261
-
1262
- errorList = [...errorList, ...this.getErrorObject([...keys, key])];
1263
- break;
1264
- case 'array':
1265
- case 'array?':
1266
- errorList.push({
1267
- status: 400,
1268
- code: 'ARRAY_11',
1269
- description: this.createErrorMessage('ARRAY_11', [...keys, key]),
1270
- });
1271
-
1272
- errorList = [...errorList, ...this.getErrorArray([...keys, key, 0])];
1273
- break;
1274
- case 'map':
1275
- case 'map?':
1276
- switch (property.properties[key].mapType) {
1277
- case 'number':
1278
- errorList.push({
1279
- status: 400,
1280
- code: 'MAP_11',
1281
- description: this.createErrorMessage('MAP_11', [key])
1282
- });
1283
- break;
1284
- case 'string':
1285
- errorList.push({
1286
- status: 400,
1287
- code: 'MAP_12',
1288
- description: this.createErrorMessage('MAP_12', [key])
1289
- });
1290
- break;
1291
- case 'bool':
1292
- errorList.push({
1293
- status: 400,
1294
- code: 'MAP_13',
1295
- description: this.createErrorMessage('MAP_13', [key])
1296
- });
1297
- errorList.push({
1298
- status: 400,
1299
- code: 'MAP_14',
1300
- description: this.createErrorMessage('MAP_14', [key])
1301
- });
1302
- errorList.push({
1303
- status: 400,
1304
- code: 'MAP_15',
1305
- description: this.createErrorMessage('MAP_15', [key])
1306
- });
1307
- break;
1308
- }
1309
- break;
1310
- default:
1311
- errorList = [...errorList, ...this.getError([...keys, key], false)];
1312
- break;
1313
- }
1314
- }
1315
-
1316
- return errorList;
1317
- }
1318
-
1319
- private getErrorArray(keys: Array<string | number>) {
1320
- let errorList: Array<IError> = [];
1321
-
1322
- const property = this.getProperty(keys);
1323
- if (property.type !== 'array' && property.type !== 'array?') {
1324
- throw new Error(`setArrayメソッドでArray型以外が入力された場合はエラー\n keys: ${keys.join(',')}`);
1325
- }
1326
-
1327
- errorList.push({
1328
- status: 400,
1329
- code: 'REQUIRE_31',
1330
- description: this.createErrorMessage('REQUIRE_31', [...keys]),
1331
- });
1332
-
1333
- switch (property.item.type) {
1334
- case 'object':
1335
- case 'object?':
1336
- errorList = [...errorList, ...this.getErrorObject([...keys, 0])];
1337
- break;
1338
- case 'array':
1339
- case 'array?':
1340
- errorList = [...errorList, ...this.getErrorArray([...keys, 0])];
1341
- break;
1342
- case 'map':
1343
- case 'map?':
1344
- switch (property.item.mapType) {
1345
- case 'number':
1346
- errorList.push({
1347
- status: 400,
1348
- code: 'MAP_31',
1349
- description: this.createErrorMessage('MAP_31', [...keys, 0])
1350
- });
1351
- break;
1352
- case 'string':
1353
- errorList.push({
1354
- status: 400,
1355
- code: 'MAP_32',
1356
- description: this.createErrorMessage('MAP_32', [...keys, 0])
1357
- });
1358
- break;
1359
- case 'bool':
1360
- errorList.push({
1361
- status: 400,
1362
- code: 'MAP_33',
1363
- description: this.createErrorMessage('MAP_33', [...keys, 0])
1364
- });
1365
- errorList.push({
1366
- status: 400,
1367
- code: 'MAP_34',
1368
- description: this.createErrorMessage('MAP_34', [...keys, 0])
1369
- });
1370
- errorList.push({
1371
- status: 400,
1372
- code: 'MAP_35',
1373
- description: this.createErrorMessage('MAP_35', [...keys, 0])
1374
- });
1375
- break;
1376
- }
1377
- break;
1378
- default:
1379
- errorList = [...errorList, ...this.getError([...keys, 0], false)];
1380
- break;
1381
- }
1382
-
1383
- return errorList;
1384
- }
1385
-
1386
- private getError(keys: Array<string | number>, isRequestBody: boolean): Array<IError> {
1387
- const errorList: Array<IError> = [];
1388
- const property = this.getProperty(keys);
1389
- switch (property.type) {
1390
- case 'enum':
1391
- case 'enum?':
1392
- switch (property.enumType) {
1393
- case 'number':
1394
- case 'number?':
1395
- errorList.push({
1396
- status: 400,
1397
- code: 'NUMBER_41',
1398
- description: this.createErrorMessage('NUMBER_41', keys)
1399
- });
1400
- break;
1401
- case 'string':
1402
- case 'string?':
1403
- errorList.push({
1404
- status: 400,
1405
- code: 'STRING_41',
1406
- description: this.createErrorMessage('STRING_41', keys)
1407
- });
1408
- break;
1409
- }
1410
- errorList.push({
1411
- status: 400,
1412
- code: 'ENUM_42',
1413
- description: this.createErrorMessage('ENUM_42', keys)
1414
- });
1415
- break;
1416
- case 'number':
1417
- case 'number?':
1418
- errorList.push({
1419
- status: 400,
1420
- code: isRequestBody ? "NUMBER_21" : "NUMBER_91",
1421
- description: this.createErrorMessage(isRequestBody ? "NUMBER_21" : "NUMBER_91", keys)
1422
- });
1423
-
1424
- if (property.min !== undefined) {
1425
- errorList.push({
1426
- status: 400,
1427
- code: isRequestBody ? "NUMBER_22" : "NUMBER_92",
1428
- description: this.createErrorMessage(isRequestBody ? "NUMBER_22" : "NUMBER_92", keys)
1429
- });
1430
- }
1431
-
1432
- if (property.max !== undefined) {
1433
- errorList.push({
1434
- status: 400,
1435
- code: isRequestBody ? "NUMBER_23" : "NUMBER_93",
1436
- description: this.createErrorMessage(isRequestBody ? "NUMBER_23" : "NUMBER_93", keys)
1437
- });
1438
- }
1439
- break;
1440
- case 'boolean':
1441
- case 'boolean?':
1442
- errorList.push({
1443
- status: 400,
1444
- code: isRequestBody ? "BOOL_21" : "BOOL_91",
1445
- description: this.createErrorMessage(isRequestBody ? "BOOL_21" : "BOOL_91", keys)
1446
- });
1447
- errorList.push({
1448
- status: 400,
1449
- code: isRequestBody ? "BOOL_22" : "BOOL_92",
1450
- description: this.createErrorMessage(isRequestBody ? "BOOL_22" : "BOOL_92", keys)
1451
- });
1452
- errorList.push({
1453
- status: 400,
1454
- code: isRequestBody ? "BOOL_23" : "BOOL_93",
1455
- description: this.createErrorMessage(isRequestBody ? "BOOL_23" : "BOOL_93", keys)
1456
- });
1457
- break;
1458
- case 'string':
1459
- case 'string?':
1460
- errorList.push({
1461
- status: 400,
1462
- code: isRequestBody ? "STRING_21" : "STRING_91",
1463
- description: this.createErrorMessage(isRequestBody ? "STRING_21" : "STRING_91", keys)
1464
- });
1465
-
1466
- if (property.maxLength !== undefined) {
1467
- errorList.push({
1468
- status: 400,
1469
- code: isRequestBody ? "STRING_22" : "STRING_92",
1470
- description: this.createErrorMessage(isRequestBody ? "STRING_22" : "STRING_92", keys)
1471
- });
1472
- }
1473
-
1474
- if (property.regExp !== undefined) {
1475
- errorList.push({
1476
- status: 400,
1477
- code: isRequestBody ? "STRING_23" : "STRING_93",
1478
- description: this.createErrorMessage(isRequestBody ? "STRING_23" : "STRING_93", keys)
1479
- });
1480
- }
1481
- break;
1482
- case 'uuid':
1483
- case 'uuid?':
1484
- errorList.push({
1485
- status: 400,
1486
- code: isRequestBody ? "UUID_21" : "UUID_91",
1487
- description: this.createErrorMessage(isRequestBody ? "UUID_21" : "UUID_91", keys)
1488
- });
1489
- break;
1490
- case 'mail':
1491
- case 'mail?':
1492
- errorList.push({
1493
- status: 400,
1494
- code: isRequestBody ? "MAIL_21" : "MAIL_91",
1495
- description: this.createErrorMessage(isRequestBody ? "MAIL_21" : "MAIL_91", keys)
1496
- });
1497
- break;
1498
- case 'date':
1499
- case 'date?':
1500
- errorList.push({
1501
- status: 400,
1502
- code: isRequestBody ? "DATE_21" : "DATE_91",
1503
- description: this.createErrorMessage(isRequestBody ? "DATE_21" : "DATE_91", keys)
1504
- });
1505
- errorList.push({
1506
- status: 400,
1507
- code: isRequestBody ? "DATE_22" : "DATE_92",
1508
- description: this.createErrorMessage(isRequestBody ? "DATE_22" : "DATE_92", keys)
1509
- });
1510
- break;
1511
- case 'time':
1512
- case 'time?':
1513
- errorList.push({
1514
- status: 400,
1515
- code: isRequestBody ? "TIME_21" : "TIME_91",
1516
- description: this.createErrorMessage(isRequestBody ? "TIME_21" : "TIME_91", keys)
1517
- });
1518
- break;
1519
- case 'datetime':
1520
- case 'datetime?':
1521
- errorList.push({
1522
- status: 400,
1523
- code: isRequestBody ? "DATETIME_21" : "DATETIME_91",
1524
- description: this.createErrorMessage(isRequestBody ? "DATETIME_21" : "DATETIME_91", keys)
1525
- });
1526
- errorList.push({
1527
- status: 400,
1528
- code: isRequestBody ? "DATETIME_22" : "DATETIME_92",
1529
- description: this.createErrorMessage(isRequestBody ? "DATETIME_22" : "DATETIME_92", keys)
1530
- });
1531
- break;
1532
- case 'https':
1533
- case 'https?':
1534
- errorList.push({
1535
- status: 400,
1536
- code: isRequestBody ? "HTTPS_21" : "HTTPS_91",
1537
- description: this.createErrorMessage(isRequestBody ? "HTTPS_21" : "HTTPS_91", keys)
1538
- });
1539
- break;
1540
- case 'base64':
1541
- case 'base64?':
1542
- errorList.push({
1543
- status: 400,
1544
- code: isRequestBody ? "BASE64_21" : "BASE64_91",
1545
- description: this.createErrorMessage(isRequestBody ? "BASE64_21" : "BASE64_91", keys)
1546
- });
1547
- break;
1548
- }
1549
-
1550
- return errorList;
1551
- }
1552
- }
1553
-
1554
- // Requestのheaderで定義されているIFをそのまま拝借
1555
- export interface IncomingHttpHeaders extends NodeJS.Dict<string | string[]> {
1556
- accept?: string | undefined;
1557
- "accept-language"?: string | undefined;
1558
- "accept-patch"?: string | undefined;
1559
- "accept-ranges"?: string | undefined;
1560
- "access-control-allow-credentials"?: string | undefined;
1561
- "access-control-allow-headers"?: string | undefined;
1562
- "access-control-allow-methods"?: string | undefined;
1563
- "access-control-allow-origin"?: string | undefined;
1564
- "access-control-expose-headers"?: string | undefined;
1565
- "access-control-max-age"?: string | undefined;
1566
- "access-control-request-headers"?: string | undefined;
1567
- "access-control-request-method"?: string | undefined;
1568
- age?: string | undefined;
1569
- allow?: string | undefined;
1570
- "alt-svc"?: string | undefined;
1571
- authorization?: string | undefined;
1572
- "cache-control"?: string | undefined;
1573
- connection?: string | undefined;
1574
- "content-disposition"?: string | undefined;
1575
- "content-encoding"?: string | undefined;
1576
- "content-language"?: string | undefined;
1577
- "content-length"?: string | undefined;
1578
- "content-location"?: string | undefined;
1579
- "content-range"?: string | undefined;
1580
- "content-type"?: string | undefined;
1581
- cookie?: string | undefined;
1582
- date?: string | undefined;
1583
- etag?: string | undefined;
1584
- expect?: string | undefined;
1585
- expires?: string | undefined;
1586
- forwarded?: string | undefined;
1587
- from?: string | undefined;
1588
- host?: string | undefined;
1589
- "if-match"?: string | undefined;
1590
- "if-modified-since"?: string | undefined;
1591
- "if-none-match"?: string | undefined;
1592
- "if-unmodified-since"?: string | undefined;
1593
- "last-modified"?: string | undefined;
1594
- location?: string | undefined;
1595
- origin?: string | undefined;
1596
- pragma?: string | undefined;
1597
- "proxy-authenticate"?: string | undefined;
1598
- "proxy-authorization"?: string | undefined;
1599
- "public-key-pins"?: string | undefined;
1600
- range?: string | undefined;
1601
- referer?: string | undefined;
1602
- "retry-after"?: string | undefined;
1603
- "sec-websocket-accept"?: string | undefined;
1604
- "sec-websocket-extensions"?: string | undefined;
1605
- "sec-websocket-key"?: string | undefined;
1606
- "sec-websocket-protocol"?: string | undefined;
1607
- "sec-websocket-version"?: string | undefined;
1608
- "set-cookie"?: string[] | undefined;
1609
- "strict-transport-security"?: string | undefined;
1610
- tk?: string | undefined;
1611
- trailer?: string | undefined;
1612
- "transfer-encoding"?: string | undefined;
1613
- upgrade?: string | undefined;
1614
- "user-agent"?: string | undefined;
1615
- vary?: string | undefined;
1616
- via?: string | undefined;
1617
- warning?: string | undefined;
1618
- "www-authenticate"?: string | undefined;
1619
- }