pg-mvc-service 2.0.41 → 2.0.43

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 (37) hide show
  1. package/dist/Service.js +16 -9
  2. package/dist/assets/favicon.ico +0 -0
  3. package/dist/models/TableDoc.js +4 -1
  4. package/package.json +8 -2
  5. package/index.d.ts +0 -189
  6. package/src/PoolManager.ts +0 -48
  7. package/src/Service.ts +0 -269
  8. package/src/Utils/DateTimeUtil.ts +0 -146
  9. package/src/Utils/NumberUtil.ts +0 -23
  10. package/src/Utils/StringUtil.ts +0 -33
  11. package/src/clients/AwsS3Client.ts +0 -310
  12. package/src/clients/Base64Client.ts +0 -305
  13. package/src/clients/EncryptClient.ts +0 -100
  14. package/src/clients/StringClient.ts +0 -19
  15. package/src/cron/BaseCron.ts +0 -122
  16. package/src/cron/CronExecuter.ts +0 -34
  17. package/src/cron/CronType.ts +0 -25
  18. package/src/documents/Swagger.ts +0 -105
  19. package/src/exceptions/Exception.ts +0 -72
  20. package/src/index.ts +0 -23
  21. package/src/models/ExpressionClient.ts +0 -72
  22. package/src/models/MigrateDatabase.ts +0 -135
  23. package/src/models/MigrateRollback.ts +0 -151
  24. package/src/models/MigrateTable.ts +0 -56
  25. package/src/models/SqlUtils/SelectExpression.ts +0 -97
  26. package/src/models/SqlUtils/UpdateExpression.ts +0 -29
  27. package/src/models/SqlUtils/ValidateValueUtil.ts +0 -354
  28. package/src/models/SqlUtils/WhereExpression.ts +0 -421
  29. package/src/models/TableDoc.ts +0 -366
  30. package/src/models/TableModel.ts +0 -701
  31. package/src/models/Type.ts +0 -62
  32. package/src/models/Utils/MessageUtil.ts +0 -60
  33. package/src/models/ValidateClient.ts +0 -182
  34. package/src/reqestResponse/ReqResType.ts +0 -170
  35. package/src/reqestResponse/RequestType.ts +0 -918
  36. package/src/reqestResponse/ResponseType.ts +0 -420
  37. package/tsconfig.json +0 -14
@@ -1,366 +0,0 @@
1
- import { TableModel } from "./TableModel";
2
- import { TColumn } from "./Type";
3
-
4
- export const createTableDoc = (models: Array<TableModel>, serviceName?: string) => {
5
- let html = `
6
- <!DOCTYPE html>
7
- <html lang="ja">
8
- <head>
9
- <meta charset="UTF-8">
10
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
11
- <title>table document</title>
12
- </head>
13
- <style>
14
- :root {
15
- --primary: rgb(73, 204, 144);
16
- --primary-dark: rgb(64, 169, 121);
17
- --bg-primary: rgba(73, 204, 144, 0.15);
18
- --border-primary: rgba(73, 204, 144, 0.3);
19
- --border-gray: rgb(200, 200, 200);
20
- }
21
-
22
- body {
23
- padding: 0px;
24
- padding-left: 12px;
25
- padding-right: 12px;
26
- margin: 0px;
27
- color: rgb(30, 35, 40);
28
- }
29
-
30
-
31
- button {
32
- padding-left: 8px;
33
- padding-right: 8px;
34
- padding-top: 2px;
35
- padding-bottom: 2px;
36
- background-color: var(--primary);
37
- border: 0px;
38
- color: #ffffff;
39
- border-radius: 999px;
40
- }
41
-
42
- button:hover {
43
- background-color: var(--primary-dark);
44
- }
45
-
46
- /* title*/
47
- h1 {
48
- font-size: 28px;
49
- font-weight: bold;
50
- }
51
-
52
- /* db-title*/
53
- h2 {
54
- background-color: var(--primary);
55
- border-top-left-radius: 8px;
56
- border-top-right-radius: 8px;
57
- color: #ffffff;
58
- padding-left: 4px;
59
- margin: 0;
60
- font-size: 24px;
61
- font-weight: bold;
62
- }
63
-
64
- .db-wrapper {
65
- border-radius: 8px;
66
- border: var(--primary) solid 1px;
67
- margin-bottom: 24px;
68
- }
69
-
70
- /* table-title*/
71
- h3 {
72
- font-size: 18px;
73
- font-weight: bold;
74
- }
75
-
76
- .table-wrapper {
77
- padding: 0px;
78
- margin-bottom: 16px;
79
- }
80
-
81
- .table-title-wrapper {
82
- background-color: var(--bg-primary);
83
- border-top: var(--border-primary) solid 1px;
84
- margin: 0;
85
- padding: 2px 4px;
86
- align-items: center;
87
- display: flex;
88
- }
89
-
90
- .table-title-left {
91
- font-size: 18px;
92
- font-weight: bold;
93
- text-align: left;
94
- font-size: 18px;
95
- font-weight: bold;
96
- }
97
-
98
- .table-title-right {
99
- margin-left: auto;
100
- padding: 2px;
101
- }
102
-
103
- .comment-wrapper {
104
- padding-left: 4px;
105
- padding-top: 4px;
106
- padding-bottom: 8px;
107
- font-size: 14px;
108
- }
109
-
110
- table {
111
- border-collapse: collapse;
112
- margin-top: 0px;
113
- margin-left: 8px;
114
- margin-right: 8px;
115
- margin-bottom: 12px;
116
- font-size: 14px;
117
- }
118
-
119
- tr:nth-child(odd) {
120
- background-color: var(--bg-primary); /* 奇数行の背景色を変更 */
121
- }
122
-
123
- tr:nth-child(even) {
124
- background-color: #ffffff; /* 偶数行の背景色を変更 */
125
- }
126
-
127
- th {
128
- padding-left: 4px;
129
- padding-right: 4px;
130
- background-color: var(--primary);
131
- color: #ffffff;
132
- border: 1px solid var(--border-gray); /* 線の色と太さを指定 */
133
- }
134
-
135
- td {
136
- border: 1px solid var(--border-primary); /* 線の色と太さを指定 */
137
- padding-left: 4px;
138
- padding-right: 4px;
139
- }
140
-
141
- /* No */
142
- td:nth-child(1) {
143
- width: 16px;
144
- text-align: center;
145
- }
146
-
147
- /* PK */
148
- td:nth-child(2) {
149
- width: 24px;
150
- text-align: center;
151
- }
152
-
153
- /* name */
154
- td:nth-child(3) {
155
- width: 140px;
156
- }
157
-
158
- /* alias */
159
- td:nth-child(4) {
160
- width: 180px;
161
- }
162
-
163
- /* type */
164
- td:nth-child(5) {
165
- width: 60px;
166
- }
167
-
168
- /* length */
169
- td:nth-child(6) {
170
- width: 40px;
171
- }
172
-
173
- /* nullable */
174
- td:nth-child(7) {
175
- width: 40px;
176
- }
177
-
178
- /* default */
179
- td:nth-child(8) {
180
- width: 120px;
181
- }
182
-
183
- /* Foreign Key */
184
- td:nth-child(9) {
185
- width: 300px;
186
- }
187
-
188
- /* comment */
189
- td:nth-child(10) {
190
- width: auto;
191
- }
192
-
193
- /* function */
194
- td:nth-child(11) {
195
- width: auto;
196
- }
197
- </style>
198
-
199
- <body>
200
- <h1>${serviceName === undefined ? '': serviceName + ' :'}Your Table Definition Document</h1>
201
- `;
202
-
203
- const dbObj: {[key: string]: Array<TableModel>} = {};
204
- for (const model of models) {
205
- if (model.DbName in dbObj === false) {
206
- dbObj[model.DbName] = [];
207
- }
208
- dbObj[model.DbName].push(model);
209
- }
210
-
211
- const jsCripFuncs: { [key: string]: string } = {};
212
- for (const [keyDbName, models] of Object.entries(dbObj)) {
213
- html += `
214
- <div class="db-wrapper">
215
- <h2>${keyDbName} Database</h2>`;
216
-
217
- for (const model of models) {
218
- const createFuncName = `clipboard_createTable_${model.DbName}_${model.TableName}`;
219
- html += `
220
- <div class="table-wrapper">
221
- <div class="table-title-wrapper">
222
- <div class="table-title-left">${model.Id !== "" ? `[${model.Id}] ` : ""}${model.TableName} ${model.TableDescription !== '' ? ` : ${model.TableDescription}` : ''}</div>
223
- <button class="table-title-right" onclick="${createFuncName}()">Copy Create Query</button>
224
- </div>
225
- <div class="comment-wrapper">${model.Comment.replace('\n', '<br>')}</div>
226
-
227
- <table>
228
- <tr>
229
- <th>No</th>
230
- <th>PK</th>
231
- <th>name</th>
232
- <th>alias</th>
233
- <th>type</th>
234
- <th>length</th>
235
- <th>nullable</th>
236
- <th>default</th>
237
- <th>foreign key</th>
238
- <th>comment</th>
239
- <th>function</th>
240
- </tr>`;
241
-
242
- const createColExpressions: Array<string> = [];
243
- const pkColNames: Array<string> = [];
244
- let index = 0;
245
- for (const [keyColName, column] of Object.entries(model.Columns)) {
246
- index++;
247
- const addFuncName = `clipboard_addColumn_${model.DbName}_${model.TableName}_${keyColName}`;
248
- const dropFuncName = `clipboard_dropColumn_${model.DbName}_${model.TableName}_${keyColName}`;
249
-
250
- // 外部キー用
251
- let references: Array<string> = [];
252
- for (const ref of model.GetReferences(keyColName)) {
253
- const targetRef = ref.columns.filter(col => col.target === keyColName);
254
- if (targetRef.length > 0) {
255
- references.push(`[${ref.table}].[${targetRef[0].ref}]`);
256
- }
257
- }
258
- references = Array.from(new Set(references)); // 重複を除く
259
-
260
- html += `
261
- <tr>
262
- <td>${index}</td>
263
- <td>${column.attribute === 'primary' ? 'PK' : ''}</td>
264
- <td>${keyColName}</td>
265
- <td>${column.alias ?? keyColName}</td>
266
- <td>${column.type}</td>
267
- <td>${column.length ?? ''}</td>
268
- <td>${column.attribute === 'nullable' ? 'nullable' : ''}</td>
269
- <td>${column.attribute === 'hasDefault' ? column.default ?? '???' : ''}</td>
270
- <td>${references.length === 0 ? '' : references.join('<br>')}</td>
271
- <td>${(column.comment ?? '').replace('\n', '<br>')}</td>
272
- <td>
273
- ${column.attribute === "primary" ? `` : `
274
- <button onclick="${addFuncName}()">Copy add column</button><br>
275
- <button onclick="${dropFuncName}()">Copy drop column</button>
276
- `}
277
- </td>
278
- </tr>`;
279
-
280
- jsCripFuncs[addFuncName] = `ALTER TABLE ${model.TableName} ADD COLUMN ${keyColName} ${toColumnType(column)} ${toColumnAttibute(column)};`;
281
- jsCripFuncs[dropFuncName] = `ALTER TABLE ${model.TableName} DROP COLUMN ${keyColName};`;
282
-
283
- // CreateTable作成用
284
- createColExpressions.push(`${keyColName} ${toColumnType(column)} ${toColumnAttibute(column)}`)
285
- if (column.attribute === 'primary') {
286
- pkColNames.push(keyColName);
287
- }
288
- }
289
-
290
- // CreateTable作成文
291
- const expressions = [...createColExpressions];
292
- if (pkColNames.length > 0) {
293
- expressions.push(`PRIMARY KEY (${pkColNames.join(', ')})`);
294
- }
295
- for (const ref of model.References) {
296
- expressions.push(`FOREIGN KEY (${ref.columns.map(col => col.target).join(', ')}) REFERENCES ${ref.table}(${ref.columns.map(col => col.ref).join(', ')})`);
297
- }
298
- jsCripFuncs[createFuncName] = `CREATE TABLE ${model.TableName} (\n ${expressions.join(',\n ')}\n);`;
299
-
300
- html += `
301
- </table>
302
- </div>`;
303
- }
304
- html += `
305
- </div>`;
306
- }
307
-
308
- html += `\n <script>\n`;
309
- for (const [keyFunName, value] of Object.entries(jsCripFuncs)) {
310
- html += `
311
- function ${keyFunName}() {
312
- const el = document.createElement('textarea');
313
- el.value = \`${value}\`;
314
- document.body.appendChild(el);
315
- el.select();
316
- document.execCommand('copy');
317
- document.body.removeChild(el);
318
- alert('コピーしました');
319
- }\n`;
320
- }
321
-
322
- html += ` </script>
323
- </body>
324
- </html>
325
- `;
326
- return html;
327
- }
328
-
329
- function toColumnType(column: TColumn) {
330
- if (column.type.startsWith('uuid')) {
331
- return column.type.replace('uuid', 'UUID');
332
- } else if (column.type.startsWith('bool')) {
333
- return column.type.replace('bool', 'BOOLEAN');
334
- } else if (column.type.startsWith('date')) {
335
- return column.type.replace('date', 'DATE');
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');
340
- } else if (column.type.startsWith('string')) {
341
- return column.type.replace('string', `VARCHAR(${column.length})`);
342
- } else if (column.type.startsWith('timestamp')) {
343
- return column.type.replace('timestamp', 'TIMESTAMP');
344
- } else if (column.type.startsWith('time')) {
345
- return column.type.replace('time', 'TIME');
346
- } else if (column.type.startsWith('jsonb')) {
347
- return column.type.replace('jsonb', 'JSONB');
348
- } else if (column.type.startsWith('json')) {
349
- return column.type.replace('json', 'JSON');
350
- }
351
-
352
- return '';
353
- }
354
-
355
- function toColumnAttibute(column: TColumn) {
356
- switch (column.attribute) {
357
- case 'hasDefault':
358
- return 'NOT NULL DEFAULT ' + column.default;
359
- case 'noDefault':
360
- return 'NOT NULL';
361
- case 'nullable':
362
- return 'NULL';
363
- case 'primary':
364
- return ''; // 主キーは後で設定するので
365
- }
366
- }