@cloudbase/lowcode-builder 1.8.97 → 1.8.98
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/lib/builder/core/index.js +3 -5
- package/lib/builder/mp/index.d.ts +4 -4
- package/lib/builder/mp/index.js +20 -19
- package/lib/builder/mp/lowcode.d.ts +1 -1
- package/lib/builder/mp/util.js +3 -1
- package/lib/builder.web.js +6 -6
- package/package.json +2 -2
- package/template/html/index.html.ejs +1 -1
- package/template/mp/common/query.js +102 -78
- package/template/mp/page/index.json +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/lowcode-builder",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.98",
|
|
4
4
|
"description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
|
|
5
5
|
"author": "yhsunshining@gmail.com",
|
|
6
6
|
"homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@babel/core": "7.21.4",
|
|
49
49
|
"@babel/preset-env": "7.21.4",
|
|
50
|
-
"@cloudbase/cals": "^1.0.
|
|
50
|
+
"@cloudbase/cals": "^1.0.79",
|
|
51
51
|
"@cloudbase/lowcode-generator": "^1.8.29",
|
|
52
52
|
"axios": "^0.21.0",
|
|
53
53
|
"browserfs": "^1.4.3",
|
|
@@ -549,7 +549,7 @@
|
|
|
549
549
|
crossorigin
|
|
550
550
|
src="<%=
|
|
551
551
|
cdnEndpoints.cdngo
|
|
552
|
-
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.
|
|
552
|
+
%>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.acef94ce4b0574004da6.bundle.js"
|
|
553
553
|
></script>
|
|
554
554
|
</body>
|
|
555
555
|
</html>
|
|
@@ -2,6 +2,23 @@ import { observable, autorun, toJS } from 'mobx';
|
|
|
2
2
|
import { createEventHandlers, getMpEventHandlerName, mergeDynamic2StaticData } from './util';
|
|
3
3
|
import { Event } from './event-emitter';
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
const QUERY_RESOURCE = {
|
|
7
|
+
SQL : 'mysql-plugin',
|
|
8
|
+
SQLSERVER : 'mssql-plugin',
|
|
9
|
+
CLOUDCONNECTOR : 'apis-plugin',
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const QUERY_PATH = {
|
|
13
|
+
SQL : '/WeDa/Query/V1/RunPluginQuery',
|
|
14
|
+
SQLSERVER : '/WeDa/Query/V1/RunPluginQuery',
|
|
15
|
+
CLOUDCONNECTOR : '/WeDa/Connector/v1/RunApisQuery',
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const KEYS = ['id', 'label', 'description', 'data', 'error', 'isFetching', 'trigger', 'reset'];
|
|
19
|
+
|
|
20
|
+
const GENERALFUNC = 'general-func'
|
|
21
|
+
|
|
5
22
|
export class Query {
|
|
6
23
|
_schema = {};
|
|
7
24
|
#schema;
|
|
@@ -17,9 +34,9 @@ export class Query {
|
|
|
17
34
|
#eventHandlerMap = {};
|
|
18
35
|
#action = () => {};
|
|
19
36
|
#runQueryMap = {
|
|
20
|
-
sql: { QueryResource:
|
|
21
|
-
sqlserver: { QueryResource:
|
|
22
|
-
'cloud-connector': { QueryResource:
|
|
37
|
+
sql: { QueryResource: QUERY_RESOURCE.SQL, QueryPath: QUERY_PATH.SQL },
|
|
38
|
+
sqlserver: { QueryResource: QUERY_RESOURCE.SQLSERVER, QueryPath: QUERY_PATH.SQLSERVER },
|
|
39
|
+
'cloud-connector': { QueryResource: QUERY_RESOURCE.CLOUDCONNECTOR, QueryPath: QUERY_PATH.CLOUDCONNECTOR },
|
|
23
40
|
};
|
|
24
41
|
constructor({ schema, context, options = {} }) {
|
|
25
42
|
const { looseError = false } = options;
|
|
@@ -64,85 +81,93 @@ export class Query {
|
|
|
64
81
|
|
|
65
82
|
const { $w } = this.#context;
|
|
66
83
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
type = 'OBJECT';
|
|
95
|
-
}
|
|
96
|
-
}
|
|
84
|
+
const runQueryType = async function (data) {
|
|
85
|
+
const requestData = {
|
|
86
|
+
EnvId: $w.env.envId,
|
|
87
|
+
Name: data.sqlTemplateId,
|
|
88
|
+
Parameter: JSON.stringify(
|
|
89
|
+
Object.entries(data.params || {}).reduce((list, [key, value]) => {
|
|
90
|
+
if (value !== undefined) {
|
|
91
|
+
let type = 'OBJECT';
|
|
92
|
+
const typeofValue = typeof value;
|
|
93
|
+
switch (typeofValue) {
|
|
94
|
+
case 'boolean': {
|
|
95
|
+
type = 'BOOLEAN';
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'number': {
|
|
99
|
+
type = 'NUMBER';
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case 'string': {
|
|
103
|
+
type = 'STRING';
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
default: {
|
|
107
|
+
if (Array.isArray(value)) {
|
|
108
|
+
type = 'ARRAY';
|
|
109
|
+
} else {
|
|
110
|
+
type = 'OBJECT';
|
|
97
111
|
}
|
|
98
|
-
|
|
99
|
-
list.push({
|
|
100
|
-
Key: key,
|
|
101
|
-
Type: type,
|
|
102
|
-
Value: type === 'STRING' ? value : JSON.stringify(value),
|
|
103
|
-
});
|
|
104
112
|
}
|
|
113
|
+
}
|
|
105
114
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
list.push({
|
|
116
|
+
Key: key,
|
|
117
|
+
Type: type,
|
|
118
|
+
Value: type === 'STRING' ? value : JSON.stringify(value),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
110
121
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
EnvId: requestData.EnvId,
|
|
116
|
-
QueryName: requestData.Name,
|
|
117
|
-
data: requestData,
|
|
118
|
-
});
|
|
122
|
+
return list;
|
|
123
|
+
}, []) || [],
|
|
124
|
+
),
|
|
125
|
+
};
|
|
119
126
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
const Data = await $w.cloud.callWedaApi({
|
|
128
|
+
action: 'RunQuery',
|
|
129
|
+
CallQuery: true,
|
|
130
|
+
...(this.#runQueryMap[this.#schema.type] || this.#runQueryMap['sql']),
|
|
131
|
+
EnvId: requestData.EnvId,
|
|
132
|
+
QueryName: requestData.Name,
|
|
133
|
+
data: requestData,
|
|
134
|
+
});
|
|
127
135
|
|
|
128
|
-
|
|
136
|
+
// const Data = await $w.cloud.callWedaApi({
|
|
137
|
+
// action: 'RunPluginQuery',
|
|
138
|
+
// data: {
|
|
139
|
+
// MainAppId: $w.app.id,
|
|
140
|
+
// ...requestData
|
|
141
|
+
// },
|
|
142
|
+
// });
|
|
129
143
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return {
|
|
137
|
-
...(this.#schema.type === 'cloud-connector'
|
|
138
|
-
? payload
|
|
139
|
-
: {
|
|
140
|
-
records: ExecuteResultList.map((item) => JSON.parse(item)),
|
|
141
|
-
total: Total || ExecuteResultList.length,
|
|
142
|
-
}),
|
|
143
|
-
};
|
|
144
|
+
const { ExecuteResultList = [], Total, Payload } = Data || {};
|
|
145
|
+
|
|
146
|
+
let payload = Payload;
|
|
147
|
+
try {
|
|
148
|
+
if (Payload) {
|
|
149
|
+
payload = JSON.parse(Payload);
|
|
144
150
|
}
|
|
145
|
-
|
|
151
|
+
} catch (e) {}
|
|
152
|
+
return {
|
|
153
|
+
...(this.#schema.type === 'cloud-connector'
|
|
154
|
+
? payload
|
|
155
|
+
: {
|
|
156
|
+
records: ExecuteResultList.map((item) => JSON.parse(item)),
|
|
157
|
+
total: Total || ExecuteResultList.length,
|
|
158
|
+
}),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.#action = async function (data,additionalScope){
|
|
163
|
+
return this.#isRunQueryType
|
|
164
|
+
? runQueryType.call(this,data)
|
|
165
|
+
: this.#schema.type === GENERALFUNC
|
|
166
|
+
? this.#schema.handler.call(this,data,additionalScope)
|
|
167
|
+
: this.#schema.handler.call(this,data);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
|
|
146
171
|
this.#eventHandlerMap = Object.entries(
|
|
147
172
|
createEventHandlers(this.#schema.eventHandlers || {}, {
|
|
148
173
|
looseError: looseError,
|
|
@@ -183,7 +208,7 @@ export class Query {
|
|
|
183
208
|
}
|
|
184
209
|
async trigger(additionalScope, options = {}) {
|
|
185
210
|
this.#triggered = true;
|
|
186
|
-
return this.#innerTrigger(this.#resolveParams(additionalScope), options);
|
|
211
|
+
return this.#innerTrigger(this.#resolveParams(additionalScope),additionalScope, options);
|
|
187
212
|
}
|
|
188
213
|
reset() {
|
|
189
214
|
this.#observableValue.data = null;
|
|
@@ -202,12 +227,12 @@ export class Query {
|
|
|
202
227
|
return this.#schema;
|
|
203
228
|
}
|
|
204
229
|
|
|
205
|
-
async #innerTrigger(args, options = {}) {
|
|
230
|
+
async #innerTrigger(args, additionalScope,options = {}) {
|
|
206
231
|
this.#currentRequestKey = Date.now();
|
|
207
232
|
const key = this.#currentRequestKey;
|
|
208
233
|
try {
|
|
209
234
|
this.#observableValue.isFetching = true;
|
|
210
|
-
const res = await this.#action(
|
|
235
|
+
const res = await this.#action(args?.[0],additionalScope);
|
|
211
236
|
if (key === this.#currentRequestKey) {
|
|
212
237
|
this.#observableValue.isFetching = false;
|
|
213
238
|
this.#observableValue.data = res;
|
|
@@ -260,7 +285,6 @@ export class Query {
|
|
|
260
285
|
}
|
|
261
286
|
|
|
262
287
|
toJSON() {
|
|
263
|
-
const KEYS = ['id', 'label', 'description', 'data', 'error', 'isFetching', 'trigger', 'reset'];
|
|
264
288
|
return KEYS.reduce((obj, key) => {
|
|
265
289
|
obj[key] = this[key];
|
|
266
290
|
return obj;
|