pg-mvc-service 1.0.20 → 1.0.21

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.
@@ -107,7 +107,7 @@ class ValidateValueUtil {
107
107
  throw new Error('Please enter a valid timestamp in "YYYY-MM-DD", "YYYY-MM-DD hh:mi:ss", or "YYYY-MM-DDThh:mi:ss" format or as a Date type.');
108
108
  }
109
109
  break;
110
- case "number":
110
+ case "integer":
111
111
  if (this.isErrorNumber(value)) {
112
112
  throw new Error('Please enter a value of type number or a string of half-width digits.');
113
113
  }
@@ -149,7 +149,7 @@ class ValidateValueUtil {
149
149
  case "timestamp[]":
150
150
  isError = this.isErrorTimestamp(v);
151
151
  break;
152
- case "number[]":
152
+ case "integer[]":
153
153
  isError = this.isErrorNumber(v);
154
154
  break;
155
155
  case "bool[]":
@@ -179,7 +179,8 @@ class ValidateValueUtil {
179
179
  return this.isErrorTime(value);
180
180
  case "timestamp":
181
181
  return this.isErrorTimestamp(value);
182
- case "number":
182
+ case "integer": // TODO: ここ最大最小のチェックもしないと
183
+ case "real": // TODO: ここ最大最小 + 桁数のチェックもしないと
183
184
  return this.isErrorNumber(value);
184
185
  case "bool":
185
186
  return this.isErrorBool(value);
@@ -63,8 +63,10 @@ class WhereExpression {
63
63
  const leftColumn = left.model.getColumn(left.name);
64
64
  // Are the operators correct?
65
65
  const useableOperator = {
66
- number: ["=", "!=", ">", ">=", "<", "<=", "in", "not in"],
67
- 'number[]': [],
66
+ integer: ["=", "!=", ">", ">=", "<", "<=", "in", "not in"],
67
+ 'integer[]': [],
68
+ real: ["=", "!=", ">", ">=", "<", "<="],
69
+ 'real[]': [],
68
70
  string: ["=", "!=", "like", "ilike", "h2f_like", "h2f_ilike", "in", "not in"],
69
71
  'string[]': [],
70
72
  uuid: ["=", "!=", "in", "not in"],
@@ -325,8 +325,11 @@ function toColumnType(column) {
325
325
  else if (column.type.startsWith('date')) {
326
326
  return column.type.replace('date', 'DATE');
327
327
  }
328
- else if (column.type.startsWith('number')) {
329
- return column.type.replace('number', 'INTEGER');
328
+ else if (column.type.startsWith('integer')) {
329
+ return column.type.replace('integer', 'INTEGER');
330
+ }
331
+ else if (column.type.startsWith('real')) {
332
+ return column.type.replace('real', 'REAL');
330
333
  }
331
334
  else if (column.type.startsWith('string')) {
332
335
  return column.type.replace('string', `VARCHAR(${column.length})`);
@@ -113,8 +113,10 @@ class TableModel {
113
113
  'string[]': '{name} should be entered as an array of string or number types.',
114
114
  'uuid': '{name} should be entered as a UUID.',
115
115
  'uuid[]': '{name} should be entered as an array of UUIDs.',
116
- 'number': '{name} should be entered as a number.',
117
- 'number[]': '{name} should be entered as an array of numbers.',
116
+ 'integer': '{name} should be entered as a number.',
117
+ 'integer[]': '{name} should be entered as an array of numbers.',
118
+ 'real': '{name} should be entered as a number.',
119
+ 'real[]': '{name} should be entered as an array of numbers.',
118
120
  'bool': '{name} should be entered as a bool type, "true", "false", 0, or 1.',
119
121
  'bool[]': '{name} should be entered as an array of bool types, "true", "false", 0, or 1.',
120
122
  'date': '{name} should be entered in "YYYY-MM-DD" or "YYYY-MM-DD hh:mi:ss" format or as a Date type.',
@@ -138,8 +140,10 @@ class TableModel {
138
140
  'string[]': '{name}はstringかnumberの配列で入力してください。',
139
141
  'uuid': '{name}はuuidで入力してください。',
140
142
  'uuid[]': '{name}はuuidの配列で入力してください。',
141
- 'number': '{name}はnumberか半角数字のstring型で入力してください。',
142
- 'number[]': '{name}はnumberか半角数字のstring型の配列で入力してください。',
143
+ 'integer': '{name}はnumberか半角数字のstring型で入力してください。',
144
+ 'integer[]': '{name}はnumberか半角数字のstring型の配列で入力してください。',
145
+ 'real': '{name}はnumberか半角数字のstring型で入力してください。',
146
+ 'real[]': '{name}はnumberか半角数字のstring型の配列で入力してください。',
143
147
  'bool': '{name}はbool型、"true"、"false"、0、または1で入力してください。',
144
148
  'bool[]': '{name}はbool型、"true"、"false"、0、または1の配列で入力してください。',
145
149
  'date': '{name}は"YYYY-MM-DD"形式、"YYYY-MM-DD hh:mi:ss"形式、またはDate型で入力してください。',
@@ -352,7 +356,7 @@ class TableModel {
352
356
  }
353
357
  ValidateValueUtil_1.default.validateValue(columnInfo, value);
354
358
  switch (columnInfo.type) {
355
- case 'number':
359
+ case 'integer':
356
360
  orderConditions.push(`WHEN ${columnInfo.expression} = ${value} THEN ${i}`);
357
361
  break;
358
362
  case 'uuid':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pg-mvc-service",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "",
5
5
  "homepage": "https://github.com/n-daira/npm-pack_mvc-service#readme",
6
6
  "bugs": {
@@ -117,7 +117,7 @@ export default class ValidateValueUtil {
117
117
  throw new Error('Please enter a valid timestamp in "YYYY-MM-DD", "YYYY-MM-DD hh:mi:ss", or "YYYY-MM-DDThh:mi:ss" format or as a Date type.');
118
118
  }
119
119
  break;
120
- case "number":
120
+ case "integer":
121
121
  if (this.isErrorNumber(value)) {
122
122
  throw new Error('Please enter a value of type number or a string of half-width digits.');
123
123
  }
@@ -162,7 +162,7 @@ export default class ValidateValueUtil {
162
162
  case "timestamp[]":
163
163
  isError = this.isErrorTimestamp(v);
164
164
  break;
165
- case "number[]":
165
+ case "integer[]":
166
166
  isError = this.isErrorNumber(v);
167
167
  break;
168
168
  case "bool[]":
@@ -195,7 +195,8 @@ export default class ValidateValueUtil {
195
195
  return this.isErrorTime(value);
196
196
  case "timestamp":
197
197
  return this.isErrorTimestamp(value);
198
- case "number":
198
+ case "integer": // TODO: ここ最大最小のチェックもしないと
199
+ case "real": // TODO: ここ最大最小 + 桁数のチェックもしないと
199
200
  return this.isErrorNumber(value);
200
201
  case "bool":
201
202
  return this.isErrorBool(value);
@@ -73,8 +73,10 @@ export default class WhereExpression {
73
73
 
74
74
  // Are the operators correct?
75
75
  const useableOperator: { [key in TColumnType | TColumnArrayType]: string[] } = {
76
- number: ["=", "!=", ">", ">=", "<", "<=", "in", "not in"],
77
- 'number[]': [],
76
+ integer: ["=", "!=", ">", ">=", "<", "<=", "in", "not in"],
77
+ 'integer[]': [],
78
+ real: ["=", "!=", ">", ">=", "<", "<="],
79
+ 'real[]': [],
78
80
  string: ["=", "!=", "like", "ilike", "h2f_like", "h2f_ilike", "in", "not in"],
79
81
  'string[]': [],
80
82
  uuid: ["=", "!=", "in", "not in"],
@@ -333,8 +333,10 @@ function toColumnType(column: TColumn) {
333
333
  return column.type.replace('bool', 'BOOLEAN');
334
334
  } else if (column.type.startsWith('date')) {
335
335
  return column.type.replace('date', 'DATE');
336
- } else if (column.type.startsWith('number')) {
337
- return column.type.replace('number', 'INTEGER');
336
+ } else if (column.type.startsWith('integer')) {
337
+ return column.type.replace('integer', 'INTEGER');
338
+ } else if (column.type.startsWith('real')) {
339
+ return column.type.replace('real', 'REAL');
338
340
  } else if (column.type.startsWith('string')) {
339
341
  return column.type.replace('string', `VARCHAR(${column.length})`);
340
342
  } else if (column.type.startsWith('timestamp')) {
@@ -352,7 +352,7 @@ export class TableModel {
352
352
 
353
353
  ValidateValueUtil.validateValue(columnInfo, value);
354
354
  switch (columnInfo.type) {
355
- case 'number':
355
+ case 'integer':
356
356
  orderConditions.push(`WHEN ${columnInfo.expression} = ${value} THEN ${i}`);
357
357
  break;
358
358
  case 'uuid':
@@ -406,8 +406,10 @@ export class TableModel {
406
406
  'string[]': '{name} should be entered as an array of string or number types.',
407
407
  'uuid': '{name} should be entered as a UUID.',
408
408
  'uuid[]': '{name} should be entered as an array of UUIDs.',
409
- 'number': '{name} should be entered as a number.',
410
- 'number[]': '{name} should be entered as an array of numbers.',
409
+ 'integer': '{name} should be entered as a number.',
410
+ 'integer[]': '{name} should be entered as an array of numbers.',
411
+ 'real': '{name} should be entered as a number.',
412
+ 'real[]': '{name} should be entered as an array of numbers.',
411
413
  'bool': '{name} should be entered as a bool type, "true", "false", 0, or 1.',
412
414
  'bool[]': '{name} should be entered as an array of bool types, "true", "false", 0, or 1.',
413
415
  'date': '{name} should be entered in "YYYY-MM-DD" or "YYYY-MM-DD hh:mi:ss" format or as a Date type.',
@@ -431,8 +433,10 @@ export class TableModel {
431
433
  'string[]': '{name}はstringかnumberの配列で入力してください。',
432
434
  'uuid': '{name}はuuidで入力してください。',
433
435
  'uuid[]': '{name}はuuidの配列で入力してください。',
434
- 'number': '{name}はnumberか半角数字のstring型で入力してください。',
435
- 'number[]': '{name}はnumberか半角数字のstring型の配列で入力してください。',
436
+ 'integer': '{name}はnumberか半角数字のstring型で入力してください。',
437
+ 'integer[]': '{name}はnumberか半角数字のstring型の配列で入力してください。',
438
+ 'real': '{name}はnumberか半角数字のstring型で入力してください。',
439
+ 'real[]': '{name}はnumberか半角数字のstring型の配列で入力してください。',
436
440
  'bool': '{name}はbool型、"true"、"false"、0、または1で入力してください。',
437
441
  'bool[]': '{name}はbool型、"true"、"false"、0、または1の配列で入力してください。',
438
442
  'date': '{name}は"YYYY-MM-DD"形式、"YYYY-MM-DD hh:mi:ss"形式、またはDate型で入力してください。',
@@ -2,8 +2,8 @@ import { TableModel } from "./TableModel";
2
2
 
3
3
  // column type
4
4
  export type TColumnAttribute = "primary" | "nullable" | "hasDefault" | "noDefault";
5
- export type TColumnType = "number" | "string" | "uuid" | "date" | "time" | "timestamp" | "bool" | "json" | "jsonb";
6
- export type TColumnArrayType = "number[]" | "string[]" | "uuid[]" | "date[]" | "time[]" | "timestamp[]" | "bool[]" | "json[]" | "jsonb[]";
5
+ export type TColumnType = "integer" | "real" | "string" | "uuid" | "date" | "time" | "timestamp" | "bool" | "json" | "jsonb";
6
+ export type TColumnArrayType = "integer[]" | "real[]" | "string[]" | "uuid[]" | "date[]" | "time[]" | "timestamp[]" | "bool[]" | "json[]" | "jsonb[]";
7
7
  type TColumnBase = {
8
8
  alias?: string,
9
9
  type: TColumnType | TColumnArrayType,