ts-glitter 21.1.8 → 21.1.9

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 (78) hide show
  1. package/lowcode/Entry.js +14 -1
  2. package/lowcode/Entry.ts +13 -1
  3. package/lowcode/backend-manager/bg-line.js +18 -10
  4. package/lowcode/backend-manager/bg-line.ts +19 -10
  5. package/lowcode/backend-manager/bg-list-component.js +1 -2
  6. package/lowcode/backend-manager/bg-list-component.ts +1 -1
  7. package/lowcode/backend-manager/bg-notify.js +17 -10
  8. package/lowcode/backend-manager/bg-notify.ts +19 -11
  9. package/lowcode/backend-manager/bg-recommend.js +15 -9
  10. package/lowcode/backend-manager/bg-recommend.ts +16 -9
  11. package/lowcode/backend-manager/bg-sns.js +16 -9
  12. package/lowcode/backend-manager/bg-sns.ts +18 -11
  13. package/lowcode/backend-manager/bg-widget.js +325 -261
  14. package/lowcode/backend-manager/bg-widget.ts +117 -45
  15. package/lowcode/cms-plugin/auto-fcm-history.js +15 -6
  16. package/lowcode/cms-plugin/auto-fcm-history.ts +18 -11
  17. package/lowcode/cms-plugin/auto-reply.js +17 -1
  18. package/lowcode/cms-plugin/auto-reply.ts +16 -1
  19. package/lowcode/cms-plugin/exhibition-list.js +11 -2
  20. package/lowcode/cms-plugin/exhibition-list.ts +12 -2
  21. package/lowcode/cms-plugin/live_capture.js +2 -2
  22. package/lowcode/cms-plugin/live_capture.ts +2 -2
  23. package/lowcode/cms-plugin/model/order.d.ts +1 -0
  24. package/lowcode/cms-plugin/module/order-excel.js +15 -1
  25. package/lowcode/cms-plugin/module/order-excel.ts +22 -2
  26. package/lowcode/cms-plugin/module/table-storage.js +11 -0
  27. package/lowcode/cms-plugin/module/table-storage.ts +12 -0
  28. package/lowcode/cms-plugin/permission-setting.js +16 -9
  29. package/lowcode/cms-plugin/permission-setting.ts +18 -10
  30. package/lowcode/cms-plugin/reconciliation-area.js +12 -3
  31. package/lowcode/cms-plugin/reconciliation-area.ts +13 -3
  32. package/lowcode/cms-plugin/shopping-allowance-manager.js +12 -3
  33. package/lowcode/cms-plugin/shopping-allowance-manager.ts +13 -3
  34. package/lowcode/cms-plugin/shopping-invoice-manager.js +12 -3
  35. package/lowcode/cms-plugin/shopping-invoice-manager.ts +13 -4
  36. package/lowcode/cms-plugin/shopping-order-manager.js +12 -3
  37. package/lowcode/cms-plugin/shopping-order-manager.ts +13 -4
  38. package/lowcode/cms-plugin/shopping-product-setting.js +16 -10
  39. package/lowcode/cms-plugin/shopping-product-setting.ts +17 -10
  40. package/lowcode/cms-plugin/shopping-product-stock.js +17 -11
  41. package/lowcode/cms-plugin/shopping-product-stock.ts +18 -11
  42. package/lowcode/cms-plugin/shopping-setting-basic.js +129 -38
  43. package/lowcode/cms-plugin/shopping-setting-basic.ts +134 -38
  44. package/lowcode/cms-plugin/stock-history.js +14 -7
  45. package/lowcode/cms-plugin/stock-history.ts +15 -7
  46. package/lowcode/cms-plugin/stock-stores.js +13 -6
  47. package/lowcode/cms-plugin/stock-stores.ts +14 -6
  48. package/lowcode/cms-plugin/stock-vendors.js +13 -6
  49. package/lowcode/cms-plugin/stock-vendors.ts +14 -6
  50. package/lowcode/cms-plugin/user-list.js +24 -7
  51. package/lowcode/cms-plugin/user-list.ts +25 -7
  52. package/lowcode/css/editor.css +9 -4
  53. package/lowcode/public-components/product/pd-class.js +11 -2
  54. package/lowcode/public-components/product/pd-class.ts +16 -3
  55. package/lowcode/public-components/public/ad.js +42 -10
  56. package/lowcode/public-components/public/ad.ts +28 -1
  57. package/lowcode/public-models/product.ts +1 -0
  58. package/lowcode/view-model/saas-view-model.js +394 -379
  59. package/lowcode/view-model/saas-view-model.ts +1451 -1405
  60. package/package.json +1 -1
  61. package/src/api-public/controllers/user.js +4 -4
  62. package/src/api-public/controllers/user.js.map +1 -1
  63. package/src/api-public/controllers/user.ts +4 -4
  64. package/src/api-public/services/checkout-event.js +7 -17
  65. package/src/api-public/services/checkout-event.js.map +1 -1
  66. package/src/api-public/services/fb-api.d.ts +4 -3
  67. package/src/api-public/services/fb-api.js +72 -27
  68. package/src/api-public/services/fb-api.js.map +1 -1
  69. package/src/api-public/services/fb-api.ts +183 -127
  70. package/src/api-public/services/user.d.ts +6 -5
  71. package/src/api-public/services/user.js +19 -27
  72. package/src/api-public/services/user.js.map +1 -1
  73. package/src/api-public/services/user.ts +14 -10
  74. package/src/seo-config.js +1 -0
  75. package/src/seo-config.js.map +1 -1
  76. package/src/seo-config.ts +1 -0
  77. package/src/services/app.js +7 -17
  78. package/src/services/app.js.map +1 -1
@@ -1,143 +1,199 @@
1
1
  import db from '../../modules/database.js';
2
- import {User} from "./user.js";
3
- import axios from "axios";
4
- import {Cart} from "./shopping.js";
5
- import tool from "../../services/tool.js";
6
- import express from "express";
7
- import {IToken} from "../models/Auth.js";
8
- import exception from "../../modules/exception.js";
2
+ import { User } from './user.js';
3
+ import axios from 'axios';
4
+ import { Cart } from './shopping.js';
5
+ import tool from '../../services/tool.js';
6
+ import express from 'express';
7
+ import { IToken } from '../models/Auth.js';
8
+ import exception from '../../modules/exception.js';
9
9
 
10
10
  export class FbApi {
11
- public app_name: string
12
- public token?: IToken
11
+ public app_name: string;
12
+ public token?: IToken;
13
13
 
14
- constructor(app_name: string,token?:IToken) {
15
- this.app_name = app_name
16
- this.token=token
17
- }
14
+ constructor(app_name: string, token?: IToken) {
15
+ this.app_name = app_name;
16
+ this.token = token;
17
+ }
18
18
 
19
- public async config() {
20
- const cf = await new User(this.app_name).getConfigV2({
21
- key: 'login_fb_setting',
22
- user_id: 'manager'
23
- })
24
- return {
25
- link: `https://graph.facebook.com/v22.0/${cf.pixel}/events`.trim(),
26
- api_token: cf.api_token
27
- }
28
- }
19
+ public async config() {
20
+ const cf = await new User(this.app_name).getConfigV2({
21
+ key: 'login_fb_setting',
22
+ user_id: 'manager',
23
+ });
24
+ return {
25
+ link: `https://graph.facebook.com/v22.0/${cf.pixel}/events`.trim(),
26
+ api_token: cf.api_token,
27
+ };
28
+ }
29
29
 
30
- //結帳
31
- public async checkOut(data: Cart) {
32
- const cf = await this.config();
33
- if (cf.link && cf.api_token) {
34
- return await new Promise<boolean>(async (resolve, reject) => {
35
- try {
36
- axios
37
- .post(cf.link, JSON.stringify({
38
- data: [{
39
- "eventID":data.orderID,
40
- "event_name": "Purchase",
41
- "event_time": (new Date().getTime() / 1000).toFixed(0),
42
- "action_source": "website",
43
- "user_data": {
44
- "em": [
45
- tool.hashSHA256(data.customer_info.email)
46
- ],
47
- "ph": [
48
- tool.hashSHA256(data.customer_info.phone)
49
- ],
50
- "client_ip_address": data.client_ip_address,
51
- "fbc": data.fbc,
52
- "fbp": data.fbp
53
- },
54
- "custom_data": {
55
- "currency": "TWD",
56
- "value": data.total
57
- }
58
- }],
59
- access_token: cf.api_token
60
- }), {
61
- headers: {
62
- 'Content-Type': 'application/json',
63
- },
64
- })
65
- .then((response: any) => {
66
- console.log('FB APIC已成功發送:', response.data);
67
- resolve(response.data);
68
- })
69
- .catch((error: any) => {
70
- console.error('發送FB APIC發生錯誤:', error.response ? error.response.data : error.message);
71
- resolve(false)
72
- });
73
- } catch (e) {
74
- console.error(e)
75
- resolve(false)
76
- }
30
+ //註冊
31
+ public async register(data: any,req: express.Request) {
32
+ const cf = await this.config();
33
+ if (cf.link && cf.api_token) {
77
34
 
35
+ return await new Promise<boolean>(async (resolve, reject) => {
36
+ try {
37
+ axios
38
+ .post(
39
+ cf.link,
40
+ JSON.stringify({
41
+ data: [
42
+ {
43
+ fbc: req.cookies._fbc,
44
+ fbp: req.cookies._fbp,
45
+ external_id:`${data.userID}`,
46
+ ip_address: (req.query.ip || req.headers['x-real-ip'] || req.ip) as string,
47
+ "event_name": "CompleteRegistration",
48
+ "event_time": new Date().getTime() / 1000,
49
+ "event_id": `${data.userID}`,
50
+ "user_data": {
51
+ em: [tool.hashSHA256(data.email ?? '')],
52
+ ph: [tool.hashSHA256(data.phone ?? '')]
53
+ },
54
+ "action_source": "website"
55
+ }
56
+ ],
57
+ access_token: cf.api_token,
58
+ }),
59
+ {
60
+ headers: {
61
+ 'Content-Type': 'application/json',
62
+ },
63
+ }
64
+ )
65
+ .then((response: any) => {
66
+ console.log('FB APIC已成功發送:', response.data);
67
+ resolve(response.data);
78
68
  })
69
+ .catch((error: any) => {
70
+ console.error('發送FB APIC發生錯誤:', error.response ? error.response.data : error.message);
71
+ resolve(false);
72
+ });
73
+ } catch (e) {
74
+ console.error(e);
75
+ resolve(false);
79
76
  }
77
+ });
80
78
  }
79
+ }
81
80
 
82
- //
83
- public async post(data: any,req:express.Request) {
84
- try {
85
- const cf = await this.config();
86
- console.log(`cf.link=>`,this.app_name)
87
- console.log(`cf.link=>`,cf.link)
88
- console.log(`cf.api_token=>`,cf.api_token)
89
- if (cf.link && cf.api_token) {
90
- data.user_data={
91
- "client_ip_address": (req.query.ip || req.headers['x-real-ip'] || req.ip) as string,
92
- "fbc": req.cookies._fbc,
93
- "fbp": req.cookies._fbp
94
- }
95
- if(this.token){
96
- const dd=(await new User(this.app_name).getUserData(this.token.userID as any, 'userID'))
97
- if(dd && dd.userData){
98
- const email=dd.userData.email;
99
- const phone=dd.userData.phone;
100
- email && (data.user_data.email=[tool.hashSHA256(email)])
101
- phone && (data.user_data.ph=[tool.hashSHA256(phone)])
102
- }
103
- }
104
- data.event_time=(new Date().getTime() / 1000).toFixed(0);
105
- // data.action_source='website'
106
- // data.test_event_code='TEST82445'
107
- // console.log(data)
108
- return await new Promise<boolean>(async (resolve, reject) => {
109
- try {
110
- axios
111
- .post(cf.link, JSON.stringify({
112
- data: [data],
113
- access_token: cf.api_token,
114
- }), {
115
- headers: {
116
- 'Content-Type': 'application/json',
117
- },
118
- })
119
- .then((response: any) => {
120
- console.log('FB APIC已成功發送:', response.data);
121
- resolve(response.data);
122
- })
123
- .catch((error: any) => {
124
- console.error('發送FB APIC發生錯誤:', error.response ? error.response.data : error.message);
125
- resolve(false)
126
- });
127
- } catch (e) {
128
- console.error(e)
129
- resolve(false)
130
- }
131
-
81
+ //結帳
82
+ public async checkOut(data: Cart) {
83
+ const cf = await this.config();
84
+ if (cf.link && cf.api_token) {
85
+ return await new Promise<boolean>(async (resolve, reject) => {
86
+ try {
87
+ axios
88
+ .post(
89
+ cf.link,
90
+ JSON.stringify({
91
+ data: [
92
+ {
93
+ eventID: data.orderID,
94
+ event_name: 'Purchase',
95
+ event_time: (new Date().getTime() / 1000).toFixed(0),
96
+ action_source: 'website',
97
+ user_data: {
98
+ em: [tool.hashSHA256(data.customer_info.email)],
99
+ ph: [tool.hashSHA256(data.customer_info.phone)],
100
+ client_ip_address: data.client_ip_address,
101
+ fbc: data.fbc,
102
+ fbp: data.fbp,
103
+ },
104
+ custom_data: {
105
+ currency: 'TWD',
106
+ value: data.total,
107
+ },
108
+ },
109
+ ],
110
+ access_token: cf.api_token,
111
+ }),
112
+ {
113
+ headers: {
114
+ 'Content-Type': 'application/json',
115
+ },
116
+ }
117
+ )
118
+ .then((response: any) => {
119
+ console.log('FB APIC已成功發送:', response.data);
120
+ resolve(response.data);
132
121
  })
122
+ .catch((error: any) => {
123
+ console.error('發送FB APIC發生錯誤:', error.response ? error.response.data : error.message);
124
+ resolve(false);
125
+ });
126
+ } catch (e) {
127
+ console.error(e);
128
+ resolve(false);
133
129
  }
134
- }catch (e:any) {
135
- console.error(e)
136
- throw exception.BadRequestError(e.code ?? 'BAD_REQUEST', e, null);
137
- }
130
+ });
138
131
  }
132
+ }
139
133
 
140
- public async OAuth(url:any){
141
- // console.log("url -- " , url);
134
+ //
135
+ public async post(data: any, req: express.Request) {
136
+ try {
137
+ const cf = await this.config();
138
+ console.log(`cf.link=>`, this.app_name);
139
+ console.log(`cf.link=>`, cf.link);
140
+ console.log(`cf.api_token=>`, cf.api_token);
141
+ if (cf.link && cf.api_token) {
142
+ data.user_data = {
143
+ client_ip_address: (req.query.ip || req.headers['x-real-ip'] || req.ip) as string,
144
+ ip_address: (req.query.ip || req.headers['x-real-ip'] || req.ip) as string,
145
+ fbc: req.cookies._fbc,
146
+ fbp: req.cookies._fbp,
147
+ };
148
+ if (this.token) {
149
+ const dd = await new User(this.app_name).getUserData(this.token.userID as any, 'userID');
150
+ if (dd && dd.userData) {
151
+ const email = dd.userData.email;
152
+ const phone = dd.userData.phone;
153
+ email && (data.user_data.email = [tool.hashSHA256(email)]);
154
+ phone && (data.user_data.ph = [tool.hashSHA256(phone)]);
155
+ }
156
+ }
157
+ data.event_time = (new Date().getTime() / 1000).toFixed(0);
158
+ // data.action_source='website'
159
+ // data.test_event_code='TEST82445'
160
+ // console.log(data)
161
+ return await new Promise<boolean>(async (resolve, reject) => {
162
+ try {
163
+ axios
164
+ .post(
165
+ cf.link,
166
+ JSON.stringify({
167
+ data: [data],
168
+ access_token: cf.api_token,
169
+ }),
170
+ {
171
+ headers: {
172
+ 'Content-Type': 'application/json',
173
+ },
174
+ }
175
+ )
176
+ .then((response: any) => {
177
+ console.log('FB APIC已成功發送:', response.data);
178
+ resolve(response.data);
179
+ })
180
+ .catch((error: any) => {
181
+ console.error('發送FB APIC發生錯誤:', error.response ? error.response.data : error.message);
182
+ resolve(false);
183
+ });
184
+ } catch (e) {
185
+ console.error(e);
186
+ resolve(false);
187
+ }
188
+ });
189
+ }
190
+ } catch (e: any) {
191
+ console.error(e);
192
+ throw exception.BadRequestError(e.code ?? 'BAD_REQUEST', e, null);
142
193
  }
143
- }
194
+ }
195
+
196
+ public async OAuth(url: any) {
197
+ // console.log("url -- " , url);
198
+ }
199
+ }
@@ -1,4 +1,5 @@
1
1
  import { IToken } from '../models/Auth.js';
2
+ import express from 'express';
2
3
  interface UserQuery {
3
4
  page?: number;
4
5
  limit?: number;
@@ -78,14 +79,14 @@ export declare class User {
78
79
  out_limit?: undefined;
79
80
  }>;
80
81
  createUser(account: string, pwd: string, userData: any, req: any, pass_verify?: boolean): Promise<any>;
81
- createUserHook(userID: string): Promise<void>;
82
+ createUserHook(userID: string, req: express.Request): Promise<void>;
82
83
  updateAccount(account: string, userID: string): Promise<any>;
83
84
  login(account: string, pwd: string): Promise<any>;
84
- loginWithFb(token: string): Promise<any>;
85
- loginWithLine(code: string, redirect: string): Promise<any>;
86
- loginWithGoogle(code: string, redirect: string): Promise<any>;
85
+ loginWithFb(token: string, req: express.Request): Promise<any>;
86
+ loginWithLine(code: string, redirect: string, req: express.Request): Promise<any>;
87
+ loginWithGoogle(code: string, redirect: string, req: express.Request): Promise<any>;
87
88
  loginWithPin(user_id: string, pin: string): Promise<any>;
88
- loginWithApple(token: string): Promise<any>;
89
+ loginWithApple(token: string, req: express.Request): Promise<any>;
89
90
  getUserData(query: string, type?: 'userID' | 'account' | 'email_or_phone'): Promise<any>;
90
91
  checkMember(userData: any, trigger: boolean): Promise<{
91
92
  id: string;
@@ -15,23 +15,13 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
35
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
27
  };
@@ -70,6 +60,7 @@ const ut_timer_1 = require("../utils/ut-timer");
70
60
  const auto_fcm_js_1 = require("../../public-config-initial/auto-fcm.js");
71
61
  const phone_verify_js_1 = require("./phone-verify.js");
72
62
  const update_progress_track_js_1 = require("../../update-progress-track.js");
63
+ const fb_api_js_1 = require("./fb-api.js");
73
64
  class User {
74
65
  constructor(app, token) {
75
66
  this.normalMember = {
@@ -225,7 +216,7 @@ class User {
225
216
  Object.assign(Object.assign({}, (userData !== null && userData !== void 0 ? userData : {})), { status: undefined }),
226
217
  userData.status === 0 ? 0 : 1,
227
218
  ]);
228
- await this.createUserHook(userID);
219
+ await this.createUserHook(userID, req);
229
220
  const usData = await this.getUserData(userID, 'userID');
230
221
  usData.pwd = undefined;
231
222
  usData.token = await UserUtil_1.default.generateToken({
@@ -244,7 +235,7 @@ class User {
244
235
  throw exception_1.default.BadRequestError('BAD_REQUEST', 'Register Error:' + e, e.data);
245
236
  }
246
237
  }
247
- async createUserHook(userID) {
238
+ async createUserHook(userID, req) {
248
239
  const usData = await this.getUserData(userID, 'userID');
249
240
  usData.userData.repeatPwd = undefined;
250
241
  await database_1.default.query(`update \`${this.app}\`.t_user
@@ -271,6 +262,7 @@ class User {
271
262
  }
272
263
  new notify_js_1.ManagerNotify(this.app).userRegister({ user_id: userID });
273
264
  await user_update_js_1.UserUpdate.update(this.app, userID);
265
+ await new fb_api_js_1.FbApi(this.app).register(usData, req);
274
266
  }
275
267
  async updateAccount(account, userID) {
276
268
  try {
@@ -323,7 +315,7 @@ class User {
323
315
  throw exception_1.default.BadRequestError('BAD_REQUEST', 'Login Error:' + e, null);
324
316
  }
325
317
  }
326
- async loginWithFb(token) {
318
+ async loginWithFb(token, req) {
327
319
  let config = {
328
320
  method: 'get',
329
321
  maxBodyLength: Infinity,
@@ -359,7 +351,7 @@ class User {
359
351
  },
360
352
  1,
361
353
  ]);
362
- await this.createUserHook(userID);
354
+ await this.createUserHook(userID, req);
363
355
  }
364
356
  const data = (await database_1.default.execute(`select *
365
357
  from \`${this.app}\`.t_user
@@ -379,7 +371,7 @@ class User {
379
371
  });
380
372
  return usData;
381
373
  }
382
- async loginWithLine(code, redirect) {
374
+ async loginWithLine(code, redirect, req) {
383
375
  try {
384
376
  const lineData = await this.getConfigV2({
385
377
  key: 'login_line_setting',
@@ -473,7 +465,7 @@ class User {
473
465
  },
474
466
  1,
475
467
  ]);
476
- await this.createUserHook(userID);
468
+ await this.createUserHook(userID, req);
477
469
  findList = await getUsData();
478
470
  }
479
471
  const data = findList[0];
@@ -496,7 +488,7 @@ class User {
496
488
  throw exception_1.default.BadRequestError('BAD_REQUEST', e, null);
497
489
  }
498
490
  }
499
- async loginWithGoogle(code, redirect) {
491
+ async loginWithGoogle(code, redirect, req) {
500
492
  try {
501
493
  const config = await this.getConfigV2({
502
494
  key: 'login_google_setting',
@@ -552,7 +544,7 @@ class User {
552
544
  },
553
545
  1,
554
546
  ]);
555
- await this.createUserHook(userID);
547
+ await this.createUserHook(userID, req);
556
548
  }
557
549
  const data = (await database_1.default.execute(`select *
558
550
  from \`${this.app}\`.t_user
@@ -611,7 +603,7 @@ class User {
611
603
  throw exception_1.default.BadRequestError('BAD_REQUEST', e, null);
612
604
  }
613
605
  }
614
- async loginWithApple(token) {
606
+ async loginWithApple(token, req) {
615
607
  try {
616
608
  const config = await this.getConfigV2({
617
609
  key: 'login_apple_setting',
@@ -660,7 +652,7 @@ class User {
660
652
  },
661
653
  1,
662
654
  ]);
663
- await this.createUserHook(userID);
655
+ await this.createUserHook(userID, req);
664
656
  }
665
657
  const data = (await database_1.default.execute(`select *
666
658
  from \`${this.app}\`.t_user