ts-glitter 22.3.5 → 22.3.7

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.
@@ -13,51 +13,15 @@ const user_js_1 = require("./user.js");
13
13
  const shopping_js_1 = require("./shopping.js");
14
14
  const updated_table_checked_js_1 = require("./updated-table-checked.js");
15
15
  class ApiPublic {
16
- static async createScheme(appName) {
17
- var _a;
18
- if (ApiPublic.checkedApp.find(dd => {
19
- return dd.app_name === appName;
20
- })) {
21
- return;
22
- }
23
- if (ApiPublic.checkingApp.find(dd => {
24
- return dd.app_name === appName;
25
- })) {
26
- const result = await new Promise(resolve => {
27
- const interval = setInterval(() => {
28
- if (ApiPublic.checkedApp.find(dd => {
29
- return dd.app_name === appName;
30
- })) {
31
- resolve(true);
32
- clearInterval(interval);
33
- }
34
- else if (!ApiPublic.checkingApp.find(dd => {
35
- return dd.app_name === appName;
36
- })) {
37
- resolve(false);
38
- clearInterval(interval);
39
- }
40
- }, 500);
41
- });
42
- if (result) {
43
- return;
44
- }
45
- }
46
- ApiPublic.checkingApp.push({
47
- app_name: appName,
48
- refer_app: (await database_1.default.query(`select refer_app
49
- from \`${config_js_1.saasConfig.SAAS_NAME}\`.app_config
50
- where appName = ?`, [appName]))[0]['refer_app'],
51
- });
52
- try {
53
- await database_1.default.execute(`CREATE SCHEMA if not exists \`${appName}\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`, []);
54
- await database_1.default.execute(`CREATE SCHEMA if not exists \`${appName}_recover\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`, []);
55
- const groupSize = 15;
56
- const sqlArray = [
57
- {
58
- scheme: appName,
59
- table: 't_chat_detail',
60
- sql: `(
16
+ static async createTable(appName) {
17
+ const groupSize = 15;
18
+ await database_1.default.query(`CREATE SCHEMA if not exists \`${appName}\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`, []);
19
+ await database_1.default.query(`CREATE SCHEMA if not exists \`${appName}_recover\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`, []);
20
+ const sqlArray = [
21
+ {
22
+ scheme: appName,
23
+ table: 't_chat_detail',
24
+ sql: `(
61
25
  \`id\` int NOT NULL AUTO_INCREMENT,
62
26
  \`chat_id\` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
63
27
  \`user_id\` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -68,11 +32,11 @@ class ApiPublic {
68
32
  KEY \`index3\` (\`user_id\`),
69
33
  KEY \`index4\` (\`created_time\`)
70
34
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
71
- },
72
- {
73
- scheme: appName,
74
- table: `t_invoice_memory`,
75
- sql: `(
35
+ },
36
+ {
37
+ scheme: appName,
38
+ table: `t_invoice_memory`,
39
+ sql: `(
76
40
  \`id\` int NOT NULL AUTO_INCREMENT,
77
41
  \`status\` int NOT NULL DEFAULT 1,
78
42
  \`order_id\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -85,11 +49,11 @@ class ApiPublic {
85
49
  KEY \`index4\` (\`create_date\`),
86
50
  KEY \`index5\` (\`status\`)
87
51
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
88
- },
89
- {
90
- scheme: appName,
91
- table: `t_allowance_memory`,
92
- sql: `(
52
+ },
53
+ {
54
+ scheme: appName,
55
+ table: `t_allowance_memory`,
56
+ sql: `(
93
57
  \`id\` int NOT NULL AUTO_INCREMENT,
94
58
  \`status\` int NOT NULL DEFAULT 1,
95
59
  \`order_id\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -103,22 +67,22 @@ class ApiPublic {
103
67
  KEY \`index4\` (\`create_date\`),
104
68
  KEY \`index5\` (\`status\`)
105
69
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
106
- },
107
- {
108
- scheme: appName,
109
- table: 't_variants',
110
- sql: `(
70
+ },
71
+ {
72
+ scheme: appName,
73
+ table: 't_variants',
74
+ sql: `(
111
75
  \`id\` int NOT NULL AUTO_INCREMENT,
112
76
  \`product_id\` int DEFAULT NULL,
113
77
  \`content\` json NOT NULL,
114
78
  PRIMARY KEY (\`id\`),
115
79
  KEY \`index2\` (\`product_id\`)
116
80
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
117
- },
118
- {
119
- scheme: appName,
120
- table: 't_recommend_users',
121
- sql: `(
81
+ },
82
+ {
83
+ scheme: appName,
84
+ table: 't_recommend_users',
85
+ sql: `(
122
86
  \`id\` int NOT NULL AUTO_INCREMENT,
123
87
  \`email\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
124
88
  \`content\` json NOT NULL,
@@ -126,11 +90,11 @@ class ApiPublic {
126
90
  PRIMARY KEY (\`id\`),
127
91
  UNIQUE KEY \`email_UNIQUE\` (\`email\`)
128
92
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
129
- },
130
- {
131
- scheme: appName,
132
- table: 't_recommend_links',
133
- sql: `(
93
+ },
94
+ {
95
+ scheme: appName,
96
+ table: 't_recommend_links',
97
+ sql: `(
134
98
  \`id\` int NOT NULL AUTO_INCREMENT,
135
99
  \`code\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
136
100
  \`content\` json NOT NULL,
@@ -138,11 +102,11 @@ class ApiPublic {
138
102
  PRIMARY KEY (\`id\`),
139
103
  UNIQUE KEY \`code_UNIQUE\` (\`code\`)
140
104
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
141
- },
142
- {
143
- scheme: appName,
144
- table: 't_triggers',
145
- sql: `(
105
+ },
106
+ {
107
+ scheme: appName,
108
+ table: 't_triggers',
109
+ sql: `(
146
110
  \`id\` int NOT NULL AUTO_INCREMENT,
147
111
  \`tag\` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
148
112
  \`content\` json NOT NULL,
@@ -150,11 +114,11 @@ class ApiPublic {
150
114
  \`status\` int NOT NULL DEFAULT '1',
151
115
  PRIMARY KEY (\`id\`)
152
116
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
153
- },
154
- {
155
- scheme: appName,
156
- table: 't_api_router',
157
- sql: `(
117
+ },
118
+ {
119
+ scheme: appName,
120
+ table: 't_api_router',
121
+ sql: `(
158
122
  \`id\` int NOT NULL AUTO_INCREMENT,
159
123
  \`name\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
160
124
  \`port\` int NOT NULL,
@@ -166,11 +130,11 @@ class ApiPublic {
166
130
  UNIQUE KEY \`name_UNIQUE\` (\`name\`),
167
131
  UNIQUE KEY \`port_UNIQUE\` (\`port\`)
168
132
  ) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
169
- },
170
- {
171
- scheme: appName,
172
- table: `t_domain_setting`,
173
- sql: `(
133
+ },
134
+ {
135
+ scheme: appName,
136
+ table: `t_domain_setting`,
137
+ sql: `(
174
138
  \`id\` int NOT NULL AUTO_INCREMENT,
175
139
  \`domain\` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
176
140
  \`port\` int NOT NULL,
@@ -179,11 +143,11 @@ class ApiPublic {
179
143
  UNIQUE KEY \`domain_UNIQUE\` (\`domain\`),
180
144
  UNIQUE KEY \`port_UNIQUE\` (\`port\`)
181
145
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
182
- },
183
- {
184
- scheme: appName,
185
- table: 'public_config',
186
- sql: ` (
146
+ },
147
+ {
148
+ scheme: appName,
149
+ table: 'public_config',
150
+ sql: ` (
187
151
  \`id\` int NOT NULL AUTO_INCREMENT,
188
152
  \`key\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
189
153
  \`value\` json NOT NULL,
@@ -191,11 +155,11 @@ class ApiPublic {
191
155
  PRIMARY KEY (\`id\`),
192
156
  UNIQUE KEY \`index2\` (\`key\`)
193
157
  ) ENGINE=InnoDB AUTO_INCREMENT=295 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
194
- },
195
- {
196
- scheme: appName,
197
- table: 't_user_public_config',
198
- sql: ` (
158
+ },
159
+ {
160
+ scheme: appName,
161
+ table: 't_user_public_config',
162
+ sql: ` (
199
163
  \`id\` int NOT NULL AUTO_INCREMENT,
200
164
  \`user_id\` varchar(200) COLLATE utf8mb4_unicode_ci NOT NULL,
201
165
  \`key\` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -204,11 +168,11 @@ class ApiPublic {
204
168
  PRIMARY KEY (\`id\`),
205
169
  UNIQUE KEY \`index2\` (\`user_id\`,\`key\`)
206
170
  ) ENGINE=InnoDB AUTO_INCREMENT=309 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
207
- },
208
- {
209
- scheme: appName,
210
- table: 't_chat_list',
211
- sql: ` (
171
+ },
172
+ {
173
+ scheme: appName,
174
+ table: 't_chat_list',
175
+ sql: ` (
212
176
  \`id\` int NOT NULL AUTO_INCREMENT,
213
177
  \`chat_id\` varchar(120) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
214
178
  \`type\` varchar(45) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'user',
@@ -220,11 +184,11 @@ class ApiPublic {
220
184
  KEY \`index3\` (\`type\`),
221
185
  KEY \`index4\` (\`updated_time\`)
222
186
  ) ENGINE=InnoDB AUTO_INCREMENT=71 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
223
- },
224
- {
225
- scheme: appName,
226
- table: 't_chat_participants',
227
- sql: `(
187
+ },
188
+ {
189
+ scheme: appName,
190
+ table: 't_chat_participants',
191
+ sql: `(
228
192
  \`id\` int NOT NULL AUTO_INCREMENT,
229
193
  \`chat_id\` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
230
194
  \`user_id\` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -233,11 +197,11 @@ class ApiPublic {
233
197
  PRIMARY KEY (\`id\`),
234
198
  UNIQUE KEY \`index2\` (\`chat_id\`,\`user_id\`)
235
199
  ) ENGINE=InnoDB AUTO_INCREMENT=92 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
236
- },
237
- {
238
- scheme: appName,
239
- table: 't_post',
240
- sql: `(
200
+ },
201
+ {
202
+ scheme: appName,
203
+ table: 't_post',
204
+ sql: `(
241
205
  \`id\` int NOT NULL AUTO_INCREMENT,
242
206
  \`userID\` int NOT NULL,
243
207
  \`content\` json DEFAULT NULL,
@@ -246,11 +210,11 @@ class ApiPublic {
246
210
  PRIMARY KEY (\`id\`),
247
211
  KEY \`index2\` (\`userID\`)
248
212
  ) ENGINE=InnoDB AUTO_INCREMENT=287 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
249
- },
250
- {
251
- scheme: appName,
252
- table: 't_manager_post',
253
- sql: ` (
213
+ },
214
+ {
215
+ scheme: appName,
216
+ table: 't_manager_post',
217
+ sql: ` (
254
218
  \`id\` int NOT NULL AUTO_INCREMENT,
255
219
  \`userID\` int NOT NULL,
256
220
  \`content\` json DEFAULT NULL,
@@ -260,11 +224,11 @@ class ApiPublic {
260
224
  PRIMARY KEY (\`id\`),
261
225
  KEY \`index2\` (\`userID\`)
262
226
  ) ENGINE=InnoDB AUTO_INCREMENT=287 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
263
- },
264
- {
265
- scheme: appName,
266
- table: 't_user',
267
- sql: `(
227
+ },
228
+ {
229
+ scheme: appName,
230
+ table: 't_user',
231
+ sql: `(
268
232
  \`id\` int NOT NULL AUTO_INCREMENT,
269
233
  \`userID\` int NOT NULL,
270
234
  \`account\` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -285,11 +249,11 @@ class ApiPublic {
285
249
  KEY \`index4\` (\`status\`),
286
250
  KEY \`index7\` (\`member_level\`)
287
251
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='V1.2'`,
288
- },
289
- {
290
- scheme: appName,
291
- table: 't_checkout',
292
- sql: `(
252
+ },
253
+ {
254
+ scheme: appName,
255
+ table: 't_checkout',
256
+ sql: `(
293
257
  \`id\` int NOT NULL AUTO_INCREMENT,
294
258
  \`cart_token\` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
295
259
  \`status\` int NOT NULL DEFAULT '0',
@@ -342,11 +306,11 @@ class ApiPublic {
342
306
  KEY \`index23\` (\`shipment_phone\`),
343
307
  KEY \`index24\` (\`shipment_address\`)
344
308
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='V1.9'`,
345
- },
346
- {
347
- scheme: appName,
348
- table: 't_voucher_history',
349
- sql: `(
309
+ },
310
+ {
311
+ scheme: appName,
312
+ table: 't_voucher_history',
313
+ sql: `(
350
314
  \`id\` int NOT NULL AUTO_INCREMENT,
351
315
  \`user_id\` int NOT NULL COMMENT '會員id',
352
316
  \`order_id\` varchar(200) NOT NULL COMMENT '購物車id',
@@ -357,22 +321,22 @@ class ApiPublic {
357
321
  PRIMARY KEY (\`id\`),
358
322
  UNIQUE KEY \`id_UNIQUE\` (\`id\`)
359
323
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
360
- },
361
- {
362
- scheme: appName,
363
- table: 't_subscribe',
364
- sql: `(
324
+ },
325
+ {
326
+ scheme: appName,
327
+ table: 't_subscribe',
328
+ sql: `(
365
329
  \`id\` int NOT NULL AUTO_INCREMENT,
366
330
  \`email\` varchar(105) COLLATE utf8mb4_unicode_ci NOT NULL,
367
331
  \`tag\` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL,
368
332
  PRIMARY KEY (\`id\`),
369
333
  UNIQUE KEY \`index2\` (\`email\`,\`tag\`)
370
334
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `,
371
- },
372
- {
373
- scheme: appName,
374
- table: 't_fcm',
375
- sql: `(
335
+ },
336
+ {
337
+ scheme: appName,
338
+ table: 't_fcm',
339
+ sql: `(
376
340
  \`id\` INT NOT NULL AUTO_INCREMENT,
377
341
  \`userID\` VARCHAR(100) NULL,
378
342
  \`deviceToken\` VARCHAR(200) NULL,
@@ -381,11 +345,11 @@ class ApiPublic {
381
345
  PRIMARY KEY (\`id\`)
382
346
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
383
347
  `,
384
- },
385
- {
386
- scheme: appName,
387
- table: 't_wallet',
388
- sql: ` (
348
+ },
349
+ {
350
+ scheme: appName,
351
+ table: 't_wallet',
352
+ sql: ` (
389
353
  \`id\` int NOT NULL AUTO_INCREMENT,
390
354
  \`orderID\` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
391
355
  \`userID\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -398,11 +362,11 @@ class ApiPublic {
398
362
  KEY \`index2\` (\`userID\`),
399
363
  KEY \`index3\` (\`status\`)
400
364
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
401
- },
402
- {
403
- scheme: appName,
404
- table: 't_ai_points',
405
- sql: `(
365
+ },
366
+ {
367
+ scheme: appName,
368
+ table: 't_ai_points',
369
+ sql: `(
406
370
  \`id\` int NOT NULL AUTO_INCREMENT,
407
371
  \`orderID\` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
408
372
  \`userID\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -415,11 +379,11 @@ class ApiPublic {
415
379
  KEY \`index2\` (\`userID\`),
416
380
  KEY \`index3\` (\`status\`)
417
381
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
418
- },
419
- {
420
- scheme: appName,
421
- table: 't_sms_points',
422
- sql: `(
382
+ },
383
+ {
384
+ scheme: appName,
385
+ table: 't_sms_points',
386
+ sql: `(
423
387
  \`id\` int NOT NULL AUTO_INCREMENT,
424
388
  \`orderID\` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
425
389
  \`userID\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -432,11 +396,11 @@ class ApiPublic {
432
396
  KEY \`index2\` (\`userID\`),
433
397
  KEY \`index3\` (\`status\`)
434
398
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
435
- },
436
- {
437
- scheme: appName,
438
- table: 't_rebate_point',
439
- sql: `(
399
+ },
400
+ {
401
+ scheme: appName,
402
+ table: 't_rebate_point',
403
+ sql: `(
440
404
  \`id\` int NOT NULL AUTO_INCREMENT,
441
405
  \`user_id\` int NOT NULL COMMENT '用戶 ID',
442
406
  \`origin\` int NOT NULL COMMENT '原始點數',
@@ -448,11 +412,11 @@ class ApiPublic {
448
412
  \`deadline\` datetime DEFAULT NULL COMMENT '過期時間',
449
413
  PRIMARY KEY (\`id\`)
450
414
  ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
451
- },
452
- {
453
- scheme: appName,
454
- table: 't_withdraw',
455
- sql: `(
415
+ },
416
+ {
417
+ scheme: appName,
418
+ table: 't_withdraw',
419
+ sql: `(
456
420
  \`id\` INT NOT NULL AUTO_INCREMENT,
457
421
  \`userID\` VARCHAR(45) NOT NULL,
458
422
  \`money\` INT NOT NULL DEFAULT 0,
@@ -461,11 +425,11 @@ class ApiPublic {
461
425
  \`created_time\` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
462
426
  PRIMARY KEY (\`id\`),
463
427
  INDEX \`index2\` (\`userID\` ASC) VISIBLE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;`,
464
- },
465
- {
466
- scheme: appName,
467
- table: 't_global_event',
468
- sql: ` (
428
+ },
429
+ {
430
+ scheme: appName,
431
+ table: 't_global_event',
432
+ sql: ` (
469
433
  \`id\` INT NOT NULL AUTO_INCREMENT,
470
434
  \`tag\` VARCHAR(45) NOT NULL,
471
435
  \`name\` VARCHAR(45) NOT NULL,
@@ -474,11 +438,11 @@ class ApiPublic {
474
438
  PRIMARY KEY (\`id\`),
475
439
  UNIQUE INDEX \`tag_UNIQUE\` (\`tag\` ASC) VISIBLE) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
476
440
  `,
477
- },
478
- {
479
- scheme: appName,
480
- table: 't_stock_recover',
481
- sql: `(
441
+ },
442
+ {
443
+ scheme: appName,
444
+ table: 't_stock_recover',
445
+ sql: `(
482
446
  \`id\` int NOT NULL AUTO_INCREMENT,
483
447
  \`order_id\` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
484
448
  \`product_id\` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
@@ -490,11 +454,11 @@ class ApiPublic {
490
454
  KEY \`index3\` (\`product_id\`)
491
455
  ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
492
456
  `,
493
- },
494
- {
495
- scheme: appName,
496
- table: 't_chat_last_read',
497
- sql: `(
457
+ },
458
+ {
459
+ scheme: appName,
460
+ table: 't_chat_last_read',
461
+ sql: `(
498
462
  \`id\` int NOT NULL AUTO_INCREMENT,
499
463
  \`user_id\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
500
464
  \`chat_id\` varchar(120) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -503,11 +467,11 @@ class ApiPublic {
503
467
  UNIQUE KEY \`index2\` (\`user_id\`,\`chat_id\`)
504
468
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
505
469
  `,
506
- },
507
- {
508
- scheme: appName,
509
- table: 't_graph_api',
510
- sql: `(
470
+ },
471
+ {
472
+ scheme: appName,
473
+ table: 't_graph_api',
474
+ sql: `(
511
475
  \`id\` INT NOT NULL AUTO_INCREMENT,
512
476
  \`route\` VARCHAR(200) NOT NULL,
513
477
  \`method\` VARCHAR(45) NOT NULL,
@@ -516,11 +480,11 @@ class ApiPublic {
516
480
  PRIMARY KEY (\`id\`),
517
481
  UNIQUE INDEX \`index2\` (\`route\` ASC, \`method\` ASC) VISIBLE);
518
482
  `,
519
- },
520
- {
521
- scheme: appName,
522
- table: `t_notice`,
523
- sql: `(
483
+ },
484
+ {
485
+ scheme: appName,
486
+ table: `t_notice`,
487
+ sql: `(
524
488
  \`id\` INT NOT NULL AUTO_INCREMENT,
525
489
  \`user_id\` VARCHAR(45) NOT NULL,
526
490
  \`tag\` VARCHAR(45) NOT NULL,
@@ -530,11 +494,11 @@ class ApiPublic {
530
494
  \`created_time\` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
531
495
  PRIMARY KEY (\`id\`),
532
496
  INDEX \`index2\` (\`user_id\` ASC) VISIBLE);`,
533
- },
534
- {
535
- scheme: appName,
536
- table: 't_return_order',
537
- sql: `(
497
+ },
498
+ {
499
+ scheme: appName,
500
+ table: 't_return_order',
501
+ sql: `(
538
502
  \`id\` int NOT NULL AUTO_INCREMENT,
539
503
  \`return_order_id\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
540
504
  \`order_id\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -547,11 +511,11 @@ class ApiPublic {
547
511
  KEY \`index3\` (\`email\`),
548
512
  KEY \`index4\` (\`created_time\`)
549
513
  ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
550
- },
551
- {
552
- scheme: appName,
553
- table: `t_stock_history`,
554
- sql: `(
514
+ },
515
+ {
516
+ scheme: appName,
517
+ table: `t_stock_history`,
518
+ sql: `(
555
519
  \`id\` int NOT NULL AUTO_INCREMENT,
556
520
  \`type\` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
557
521
  \`order_id\` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -562,11 +526,11 @@ class ApiPublic {
562
526
  KEY \`index2\` (\`order_id\`),
563
527
  UNIQUE KEY \`order_id_UNIQUE\` (\`order_id\`)
564
528
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
565
- },
566
- {
567
- scheme: appName,
568
- table: `t_live_purchase_interactions`,
569
- sql: `(
529
+ },
530
+ {
531
+ scheme: appName,
532
+ table: `t_live_purchase_interactions`,
533
+ sql: `(
570
534
  \`id\` int NOT NULL AUTO_INCREMENT,
571
535
  \`type\` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
572
536
  \`name\` varchar(200) NOT NULL,
@@ -577,11 +541,11 @@ class ApiPublic {
577
541
  KEY \`index2\` (\`name\`)
578
542
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT = 'V1.1';
579
543
  `,
580
- },
581
- {
582
- scheme: appName,
583
- table: `t_line_group_inf`,
584
- sql: `(
544
+ },
545
+ {
546
+ scheme: appName,
547
+ table: `t_line_group_inf`,
548
+ sql: `(
585
549
  \`id\` int NOT NULL AUTO_INCREMENT,
586
550
  \`group_id\` VARCHAR(50) NOT NULL,
587
551
  \`group_name\` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -594,11 +558,11 @@ class ApiPublic {
594
558
  KEY \`index3\` (\`shopnex_user_id\`)
595
559
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
596
560
  `,
597
- },
598
- {
599
- scheme: appName,
600
- table: `t_app_line_group_verification`,
601
- sql: `(
561
+ },
562
+ {
563
+ scheme: appName,
564
+ table: `t_app_line_group_verification`,
565
+ sql: `(
602
566
  \`id\` int NOT NULL AUTO_INCREMENT,
603
567
  \`app_name\` VARCHAR(255) COLLATE utf8mb4_unicode_ci NOT NULL,
604
568
  \`verification_code\` VARCHAR(255) NOT NULL,
@@ -609,11 +573,11 @@ class ApiPublic {
609
573
  UNIQUE KEY \`unique_verification_code\` (\`verification_code\`)
610
574
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
611
575
  `,
612
- },
613
- {
614
- scheme: appName,
615
- table: `t_temporary_cart`,
616
- sql: `(
576
+ },
577
+ {
578
+ scheme: appName,
579
+ table: `t_temporary_cart`,
580
+ sql: `(
617
581
  \`id\` int NOT NULL AUTO_INCREMENT,
618
582
  \`cart_id\` VARCHAR(255) NOT NULL ,
619
583
  \`content\` json DEFAULT NULL,
@@ -623,11 +587,11 @@ class ApiPublic {
623
587
  INDEX \`idx_created_time\` (\`created_time\`)
624
588
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
625
589
  `,
626
- },
627
- {
628
- scheme: appName,
629
- table: `t_live_comments`,
630
- sql: `(
590
+ },
591
+ {
592
+ scheme: appName,
593
+ table: `t_live_comments`,
594
+ sql: `(
631
595
  \`id\` int NOT NULL AUTO_INCREMENT COMMENT 'Primary Key: Auto-incremented ID',
632
596
  \`interaction_id\` varchar(50) NOT NULL COMMENT 'ID that links to t_live_purchase_interactions',
633
597
  \`user_id\` varchar(50) NOT NULL COMMENT 'ID from FB or IG packet which is used to identify the user',
@@ -638,11 +602,11 @@ class ApiPublic {
638
602
  KEY \`index2\` (\`interaction_id\`)
639
603
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
640
604
  `,
641
- },
642
- {
643
- scheme: appName,
644
- table: `t_check_in_pos`,
645
- sql: `(
605
+ },
606
+ {
607
+ scheme: appName,
608
+ table: `t_check_in_pos`,
609
+ sql: `(
646
610
  \`id\` INT NOT NULL AUTO_INCREMENT,
647
611
  \`staff\` VARCHAR(45) NOT NULL,
648
612
  \`execute\` VARCHAR(45) NOT NULL,
@@ -654,11 +618,11 @@ class ApiPublic {
654
618
  INDEX \`index5\` (\`store\` ASC) VISIBLE,
655
619
  INDEX \`index4\` (\`execute\` ASC) VISIBLE) COMMENT = 'V1.1';
656
620
  `,
657
- },
658
- {
659
- scheme: appName,
660
- table: `t_pos_summary`,
661
- sql: `(
621
+ },
622
+ {
623
+ scheme: appName,
624
+ table: `t_pos_summary`,
625
+ sql: `(
662
626
  \`id\` INT NOT NULL AUTO_INCREMENT,
663
627
  \`staff\` VARCHAR(45) NOT NULL,
664
628
  \`summary_type\` VARCHAR(45) NOT NULL,
@@ -669,22 +633,22 @@ class ApiPublic {
669
633
  INDEX \`index3\` (\`summary_type\` ASC) VISIBLE,
670
634
  INDEX \`index4\` (\`created_time\` ASC) VISIBLE);
671
635
  `,
672
- },
673
- {
674
- scheme: appName,
675
- table: 't_product_comment',
676
- sql: `(
636
+ },
637
+ {
638
+ scheme: appName,
639
+ table: 't_product_comment',
640
+ sql: `(
677
641
  \`id\` int NOT NULL AUTO_INCREMENT,
678
642
  \`product_id\` int DEFAULT NULL,
679
643
  \`content\` json NOT NULL,
680
644
  PRIMARY KEY (\`id\`),
681
645
  KEY \`index2\` (\`product_id\`)
682
646
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
683
- },
684
- {
685
- scheme: appName,
686
- table: 't_products_sold_history',
687
- sql: `(
647
+ },
648
+ {
649
+ scheme: appName,
650
+ table: 't_products_sold_history',
651
+ sql: `(
688
652
  \`id\` int NOT NULL AUTO_INCREMENT,
689
653
  \`product_id\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
690
654
  \`order_id\` varchar(45) COLLATE utf8mb4_unicode_ci NOT NULL,
@@ -696,11 +660,11 @@ class ApiPublic {
696
660
  KEY \`index4\` (\`spec\`),
697
661
  KEY \`index5\` (\`count\`)
698
662
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='V1.1'`,
699
- },
700
- {
701
- scheme: appName,
702
- table: `visit_logs`,
703
- sql: `(
663
+ },
664
+ {
665
+ scheme: appName,
666
+ table: `visit_logs`,
667
+ sql: `(
704
668
  \`id\` INT NOT NULL AUTO_INCREMENT,
705
669
  \`date\` DATETIME NOT NULL,
706
670
  \`count\` INT NOT NULL,
@@ -710,11 +674,11 @@ class ApiPublic {
710
674
  INDEX \`index2\` (\`date\` ASC) VISIBLE,
711
675
  UNIQUE INDEX \`tag_name_UNIQUE\` (\`tag_name\` ASC) VISIBLE);
712
676
  `,
713
- },
714
- {
715
- scheme: 't_1725992531001',
716
- table: 't_changed_logs',
717
- sql: `(
677
+ },
678
+ {
679
+ scheme: 't_1725992531001',
680
+ table: 't_changed_logs',
681
+ sql: `(
718
682
  \`id\` INT NOT NULL AUTO_INCREMENT,
719
683
  \`entity_table\` varchar(200) NOT NULL COMMENT '關聯的table',
720
684
  \`entity_id\` INT NOT NULL COMMENT '關聯的id',
@@ -727,21 +691,60 @@ class ApiPublic {
727
691
  PRIMARY KEY (\`id\`),
728
692
  UNIQUE KEY \`id_UNIQUE\` (\`id\`)
729
693
  ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci`,
730
- },
731
- ];
732
- for (const b of chunkArray(sqlArray, groupSize)) {
733
- let check = b.length;
734
- await new Promise(resolve => {
735
- for (const d of b) {
736
- (0, saas_table_check_js_1.compare_sql_table)(d.scheme, d.table, d.sql).then(() => {
737
- check--;
738
- if (check === 0) {
739
- resolve(true);
740
- }
741
- });
694
+ },
695
+ ];
696
+ for (const b of chunkArray(sqlArray, groupSize)) {
697
+ let check = b.length;
698
+ await new Promise(resolve => {
699
+ for (const d of b) {
700
+ (0, saas_table_check_js_1.compare_sql_table)(d.scheme, d.table, d.sql).then(() => {
701
+ check--;
702
+ if (check === 0) {
703
+ resolve(true);
704
+ }
705
+ });
706
+ }
707
+ });
708
+ }
709
+ }
710
+ static async createScheme(appName) {
711
+ var _a;
712
+ if (ApiPublic.checkedApp.find(dd => {
713
+ return dd.app_name === appName;
714
+ })) {
715
+ return;
716
+ }
717
+ if (ApiPublic.checkingApp.find(dd => {
718
+ return dd.app_name === appName;
719
+ })) {
720
+ const result = await new Promise(resolve => {
721
+ const interval = setInterval(() => {
722
+ if (ApiPublic.checkedApp.find(dd => {
723
+ return dd.app_name === appName;
724
+ })) {
725
+ resolve(true);
726
+ clearInterval(interval);
742
727
  }
743
- });
728
+ else if (!ApiPublic.checkingApp.find(dd => {
729
+ return dd.app_name === appName;
730
+ })) {
731
+ resolve(false);
732
+ clearInterval(interval);
733
+ }
734
+ }, 500);
735
+ });
736
+ if (result) {
737
+ return;
744
738
  }
739
+ }
740
+ ApiPublic.checkingApp.push({
741
+ app_name: appName,
742
+ refer_app: (await database_1.default.query(`select refer_app
743
+ from \`${config_js_1.saasConfig.SAAS_NAME}\`.app_config
744
+ where appName = ?`, [appName]))[0]['refer_app'],
745
+ });
746
+ try {
747
+ await this.createTable(appName);
745
748
  ai_robot_js_1.AiRobot.syncAiRobot(appName);
746
749
  await ApiPublic.migrateVariants(appName);
747
750
  await updated_table_checked_js_1.UpdatedTableChecked.startCheck(appName);