pg-mvc-service 2.0.1 → 2.0.3
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/clients/StringClient.js +7 -0
- package/dist/models/SqlUtils/SelectExpression.js +1 -1
- package/dist/models/SqlUtils/ValidateValueUtil.js +2 -2
- package/dist/models/TableDoc.js +1 -1
- package/dist/models/TableModel.js +2 -2
- package/dist/reqestResponse/ReqResType.js +0 -13
- package/dist/reqestResponse/RequestType.js +2 -1
- package/dist/reqestResponse/ResponseType.js +2 -1
- package/package.json +1 -1
- package/src/clients/StringClient.ts +5 -0
- package/src/models/SqlUtils/SelectExpression.ts +1 -1
- package/src/models/SqlUtils/ValidateValueUtil.ts +2 -2
- package/src/models/TableDoc.ts +1 -1
- package/src/models/TableModel.ts +2 -2
- package/src/reqestResponse/ReqResType.ts +0 -15
- package/src/reqestResponse/RequestType.ts +2 -1
- package/src/reqestResponse/ResponseType.ts +2 -1
- /package/dist/{models/Utils → Utils}/DateTimeUtil.js +0 -0
- /package/dist/{models/Utils → Utils}/NumberUtil.js +0 -0
- /package/dist/{models/Utils → Utils}/StringUtil.js +0 -0
- /package/src/{models/Utils → Utils}/DateTimeUtil.ts +0 -0
- /package/src/{models/Utils → Utils}/NumberUtil.ts +0 -0
- /package/src/{models/Utils → Utils}/StringUtil.ts +0 -0
|
@@ -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("
|
|
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("
|
|
7
|
-
const StringUtil_1 = __importDefault(require("
|
|
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) {
|
package/dist/models/TableDoc.js
CHANGED
|
@@ -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>
|
|
@@ -339,7 +339,7 @@ class TableModel {
|
|
|
339
339
|
}
|
|
340
340
|
throw new Exception_1.UnprocessableException(code, message);
|
|
341
341
|
}
|
|
342
|
-
validateOptions(options, isInsert) {
|
|
342
|
+
validateOptions(options, isInsert, pkOrId) {
|
|
343
343
|
return __awaiter(this, void 0, void 0, function* () {
|
|
344
344
|
if (Object.keys(options).length === 0) {
|
|
345
345
|
throw new Error('At least one key-value pair is required in options.');
|
|
@@ -432,7 +432,7 @@ class TableModel {
|
|
|
432
432
|
update(pkOrId, options) {
|
|
433
433
|
return __awaiter(this, void 0, void 0, function* () {
|
|
434
434
|
var _a;
|
|
435
|
-
yield this.validateOptions(options, false);
|
|
435
|
+
yield this.validateOptions(options, false, pkOrId);
|
|
436
436
|
const updateSetQuery = UpdateExpression_1.default.createUpdateSet(this, options);
|
|
437
437
|
let whereQuery;
|
|
438
438
|
if (typeof pkOrId === 'string' || typeof pkOrId === 'number' || typeof pkOrId === 'boolean') {
|
|
@@ -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 (
|
|
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 (
|
|
207
|
+
if (StringUtil_1.default.isUUID(value)) {
|
|
207
208
|
return value;
|
|
208
209
|
}
|
|
209
210
|
return undefined;
|
package/package.json
CHANGED
|
@@ -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 { TColumn, TColumnArrayType, TColumnType } from "../Type";
|
|
2
|
-
import DateTimeUtil from "
|
|
3
|
-
import StringUtil from "
|
|
2
|
+
import DateTimeUtil from "../../Utils/DateTimeUtil";
|
|
3
|
+
import StringUtil from "../../Utils/StringUtil";
|
|
4
4
|
|
|
5
5
|
export default class ValidateValueUtil {
|
|
6
6
|
|
package/src/models/TableDoc.ts
CHANGED
|
@@ -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>
|
package/src/models/TableModel.ts
CHANGED
|
@@ -400,7 +400,7 @@ export class TableModel {
|
|
|
400
400
|
throw new UnprocessableException(code, message);
|
|
401
401
|
}
|
|
402
402
|
|
|
403
|
-
protected async validateOptions(options: {[key: string]: any}, isInsert: boolean): Promise<void> {
|
|
403
|
+
protected async validateOptions(options: {[key: string]: any}, isInsert: boolean, pkOrId?: string | number | boolean | {[key: string]: any}): Promise<void> {
|
|
404
404
|
if (Object.keys(options).length === 0) {
|
|
405
405
|
throw new Error('At least one key-value pair is required in options.');
|
|
406
406
|
}
|
|
@@ -502,7 +502,7 @@ export class TableModel {
|
|
|
502
502
|
}
|
|
503
503
|
|
|
504
504
|
public async update(pkOrId: string | number | boolean | {[key: string]: any}, options: {[key: string]: any}) : Promise<void> {
|
|
505
|
-
await this.validateOptions(options, false);
|
|
505
|
+
await this.validateOptions(options, false, pkOrId);
|
|
506
506
|
|
|
507
507
|
const updateSetQuery = UpdateExpression.createUpdateSet(this, options);
|
|
508
508
|
let whereQuery: TQuery;
|
|
@@ -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 (
|
|
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 (
|
|
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
|