pg-mvc-service 2.0.0 → 2.0.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.
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.StringClient = void 0;
4
7
  const crypto_1 = require("crypto");
8
+ const StringUtil_1 = __importDefault(require("../Utils/StringUtil"));
5
9
  class StringClient {
6
10
  constructor() { }
7
11
  generateUUIDv7() {
@@ -10,5 +14,8 @@ class StringClient {
10
14
  const randomHex = (0, crypto_1.randomBytes)(8).toString('hex');
11
15
  return `${timeHex.slice(0, 8)}-${timeHex.slice(8, 12)}-7${timeHex.slice(13, 16)}-${randomHex.slice(0, 4)}-${randomHex.slice(4)}`;
12
16
  }
17
+ isUUID(value) {
18
+ return StringUtil_1.default.isUUID(value);
19
+ }
13
20
  }
14
21
  exports.StringClient = StringClient;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const StringUtil_1 = __importDefault(require("../Utils/StringUtil"));
6
+ const StringUtil_1 = __importDefault(require("../../Utils/StringUtil"));
7
7
  class SelectExpression {
8
8
  /**
9
9
  * 指定されたカラム情報と関数を使用して、SQLのSELECT文を作成します。
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const DateTimeUtil_1 = __importDefault(require("../Utils/DateTimeUtil"));
7
- const StringUtil_1 = __importDefault(require("../Utils/StringUtil"));
6
+ const DateTimeUtil_1 = __importDefault(require("../../Utils/DateTimeUtil"));
7
+ const StringUtil_1 = __importDefault(require("../../Utils/StringUtil"));
8
8
  class ValidateValueUtil {
9
9
  static validateId(columns, id) {
10
10
  if ('id' in columns === false) {
@@ -266,7 +266,7 @@ td:nth-child(11) {
266
266
  <td>${((_d = column.comment) !== null && _d !== void 0 ? _d : '').replace('\n', '<br>')}</td>
267
267
  <td>
268
268
  ${column.attribute === "primary" ? `` : `
269
- <button onclick="${addFuncName}()">Copy add column</button>
269
+ <button onclick="${addFuncName}()">Copy add column</button><br>
270
270
  <button onclick="${dropFuncName}()">Copy drop column</button>
271
271
  `}
272
272
  </td>
@@ -60,7 +60,12 @@ class TableModel {
60
60
  get createSqlFromJoinWhere() {
61
61
  let sql = ` FROM ${this.TableName} as "${this.TableAlias}"`;
62
62
  for (const join of this.joinConditions) {
63
- sql += join.type === 'left' ? ' LEFT OUTER JOIN' : ' INNER JOIN';
63
+ const joins = {
64
+ inner: ' INNER JOIN',
65
+ left: ' LEFT OUTER JOIN',
66
+ full: ' FULL OUTER JOIN',
67
+ };
68
+ sql += joins[join.type];
64
69
  sql += ` ${join.model.TableName} as "${join.model.TableAlias}" ON `;
65
70
  const query = WhereExpression_1.default.createCondition(join.conditions, this, this.vars.length + 1);
66
71
  sql += query.expression;
@@ -114,19 +114,6 @@ class ReqResType {
114
114
  return false;
115
115
  }
116
116
  }
117
- /**
118
- * Validates if the given value is a valid UUID
119
- * 与えられた値が有効なUUIDであるかどうかを検証します
120
- * @param value - The value to be validated, 検証する値
121
- * @returns {boolean} - Whether the value is a valid UUID, 値が有効なUUIDであるかどうか
122
- */
123
- isUUID(value) {
124
- if (typeof value !== 'string') {
125
- return false;
126
- }
127
- const pattern = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$');
128
- return pattern.test(value);
129
- }
130
117
  /**
131
118
  * 値がメールアドレス形式であるかどうかを検証します
132
119
  * Validates if the given value is in the format of an email address
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RequestType = void 0;
7
7
  const ReqResType_1 = __importDefault(require("./ReqResType"));
8
8
  const Exception_1 = require("../exceptions/Exception");
9
+ const StringUtil_1 = __importDefault(require("../Utils/StringUtil"));
9
10
  class RequestType extends ReqResType_1.default {
10
11
  constructor() {
11
12
  super(...arguments);
@@ -525,7 +526,7 @@ class RequestType extends ReqResType_1.default {
525
526
  }
526
527
  case 'uuid':
527
528
  case 'uuid?':
528
- if (this.isUUID(value)) {
529
+ if (StringUtil_1.default.isUUID(value)) {
529
530
  return value;
530
531
  }
531
532
  this.throwInputError(isRequestBody ? "UUID_21" : "UUID_91", keys, value);
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ResponseType = void 0;
7
+ const StringUtil_1 = __importDefault(require("../Utils/StringUtil"));
7
8
  const ReqResType_1 = __importDefault(require("./ReqResType"));
8
9
  class ResponseType extends ReqResType_1.default {
9
10
  constructor() {
@@ -203,7 +204,7 @@ class ResponseType extends ReqResType_1.default {
203
204
  }
204
205
  case 'uuid':
205
206
  case 'uuid?':
206
- if (this.isUUID(value)) {
207
+ if (StringUtil_1.default.isUUID(value)) {
207
208
  return value;
208
209
  }
209
210
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from 'crypto';
2
+ import StringUtil from '../Utils/StringUtil';
2
3
 
3
4
  export class StringClient {
4
5
  constructor() { }
@@ -11,4 +12,8 @@ export class StringClient {
11
12
 
12
13
  return `${timeHex.slice(0, 8)}-${timeHex.slice(8, 12)}-7${timeHex.slice(13, 16)}-${randomHex.slice(0, 4)}-${randomHex.slice(4)}`;
13
14
  }
15
+
16
+ public isUUID(value: any) {
17
+ return StringUtil.isUUID(value);
18
+ }
14
19
  }
@@ -1,6 +1,6 @@
1
1
  import { TableModel } from "../TableModel";
2
2
  import { TAggregateFuncType, TColumnInfo, TKeyFormat } from "../Type";
3
- import StringUtil from "../Utils/StringUtil";
3
+ import StringUtil from "../../Utils/StringUtil";
4
4
 
5
5
  export default class SelectExpression {
6
6
 
@@ -1,6 +1,6 @@
1
1
  import { TColumn, TColumnArrayType, TColumnType } from "../Type";
2
- import DateTimeUtil from "../Utils/DateTimeUtil";
3
- import StringUtil from "../Utils/StringUtil";
2
+ import DateTimeUtil from "../../Utils/DateTimeUtil";
3
+ import StringUtil from "../../Utils/StringUtil";
4
4
 
5
5
  export default class ValidateValueUtil {
6
6
 
@@ -271,7 +271,7 @@ td:nth-child(11) {
271
271
  <td>${(column.comment ?? '').replace('\n', '<br>')}</td>
272
272
  <td>
273
273
  ${column.attribute === "primary" ? `` : `
274
- <button onclick="${addFuncName}()">Copy add column</button>
274
+ <button onclick="${addFuncName}()">Copy add column</button><br>
275
275
  <button onclick="${dropFuncName}()">Copy drop column</button>
276
276
  `}
277
277
  </td>
@@ -70,7 +70,7 @@ export class TableModel {
70
70
 
71
71
  private selectExpressions: Array<string> = [];
72
72
  private joinConditions: Array<{
73
- type: 'inner' | 'left',
73
+ type: 'inner' | 'left' | 'full',
74
74
  model: TableModel,
75
75
  conditions: Array<TNestedCondition>
76
76
  }> = [];
@@ -83,7 +83,12 @@ export class TableModel {
83
83
  let sql = ` FROM ${this.TableName} as "${this.TableAlias}"`;
84
84
 
85
85
  for (const join of this.joinConditions) {
86
- sql += join.type === 'left' ? ' LEFT OUTER JOIN' : ' INNER JOIN';
86
+ const joins = {
87
+ inner: ' INNER JOIN',
88
+ left: ' LEFT OUTER JOIN',
89
+ full: ' FULL OUTER JOIN',
90
+ }
91
+ sql += joins[join.type];
87
92
  sql += ` ${join.model.TableName} as "${join.model.TableAlias}" ON `;
88
93
  const query = WhereExpression.createCondition(join.conditions, this, this.vars.length + 1);
89
94
  sql += query.expression;
@@ -248,7 +253,7 @@ export class TableModel {
248
253
  * @param joinBaseModel 結合する対象のBaseModelインスタンスを指定します。
249
254
  * @param conditions 結合条件を指定します。条件はオブジェクトまたは文字列で指定できます。
250
255
  */
251
- public join(joinType: 'left' | 'inner', joinModel: TableModel, conditions: Array<TNestedCondition>): void {
256
+ public join(joinType: 'left' | 'inner' | 'full', joinModel: TableModel, conditions: Array<TNestedCondition>): void {
252
257
  this.joinConditions.push({type: joinType, model: joinModel, conditions: conditions});
253
258
  }
254
259
 
@@ -151,21 +151,6 @@ export default class ReqResType {
151
151
  }
152
152
  }
153
153
 
154
- /**
155
- * Validates if the given value is a valid UUID
156
- * 与えられた値が有効なUUIDであるかどうかを検証します
157
- * @param value - The value to be validated, 検証する値
158
- * @returns {boolean} - Whether the value is a valid UUID, 値が有効なUUIDであるかどうか
159
- */
160
- protected isUUID(value: any) {
161
- if (typeof value !== 'string') {
162
- return false;
163
- }
164
-
165
- const pattern = new RegExp('^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$');
166
- return pattern.test(value);
167
- }
168
-
169
154
  /**
170
155
  * 値がメールアドレス形式であるかどうかを検証します
171
156
  * Validates if the given value is in the format of an email address
@@ -1,6 +1,7 @@
1
1
  import { Request } from 'express';
2
2
  import ReqResType, { EnumType, PrimitiveType, PropertyType } from "./ReqResType";
3
3
  import { InputErrorException } from '../exceptions/Exception';
4
+ import StringUtil from '../Utils/StringUtil';
4
5
 
5
6
  // エラーメッセージの型定義
6
7
  export interface ErrorMessageType {
@@ -568,7 +569,7 @@ export class RequestType extends ReqResType {
568
569
  }
569
570
  case 'uuid':
570
571
  case 'uuid?':
571
- if (this.isUUID(value)) {
572
+ if (StringUtil.isUUID(value)) {
572
573
  return value;
573
574
  }
574
575
  this.throwInputError(isRequestBody ? "UUID_21" : "UUID_91", keys, value);
@@ -1,3 +1,4 @@
1
+ import StringUtil from "../Utils/StringUtil";
1
2
  import ReqResType from "./ReqResType";
2
3
 
3
4
  export class ResponseType extends ReqResType {
@@ -219,7 +220,7 @@ export class ResponseType extends ReqResType {
219
220
  }
220
221
  case 'uuid':
221
222
  case 'uuid?':
222
- if (this.isUUID(value)) {
223
+ if (StringUtil.isUUID(value)) {
223
224
  return value;
224
225
  }
225
226
  return undefined;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes