@cloudbase/wx-cloud-client-sdk 1.1.0 → 1.2.0
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/api/datasouce-caller.d.ts +1 -1
- package/lib/types/index.d.ts +41 -0
- package/lib/utils.d.ts +1 -0
- package/lib/wxCloudClientSDK.cjs.js +14 -12
- package/lib/wxCloudClientSDK.esm.js +14 -12
- package/lib/wxCloudClientSDK.umd.js +14 -12
- package/package.json +6 -1
|
@@ -6,5 +6,5 @@ export declare const enum EQUERY_PARAM_TYPE {
|
|
|
6
6
|
OBJECT = "OBJECT",
|
|
7
7
|
STRING = "STRING"
|
|
8
8
|
}
|
|
9
|
-
export declare const callDataSource: ({ dataSourceName, methodName, params, realMethodName, callFunction, mode, }: CallDataSourceParams) => Promise<MethodResponse<any>>;
|
|
9
|
+
export declare const callDataSource: ({ dataSourceName, methodName, params, realMethodName, callFunction, envType, mode, }: CallDataSourceParams) => Promise<MethodResponse<any>>;
|
|
10
10
|
export declare const runMysqlCommand: ({ sql, params, config, callFunction, unsafe }: RunMysqlCommandParams) => Promise<MethodResponse<any>>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface Model {
|
|
|
10
10
|
updateBy?: Relation;
|
|
11
11
|
_openid?: string;
|
|
12
12
|
}
|
|
13
|
+
export declare type EnvType = 'prod' | 'pre';
|
|
13
14
|
/**
|
|
14
15
|
* 模型方法的定义
|
|
15
16
|
* =====================================================================
|
|
@@ -48,6 +49,10 @@ export interface DataModelMethods<T> {
|
|
|
48
49
|
*/
|
|
49
50
|
create: (params: {
|
|
50
51
|
data: T;
|
|
52
|
+
/**
|
|
53
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
54
|
+
*/
|
|
55
|
+
envType?: EnvType;
|
|
51
56
|
}) => Promise<MethodResponse<CreateResponse<T>>>;
|
|
52
57
|
/**
|
|
53
58
|
* 创建多条数据的方法。
|
|
@@ -64,6 +69,10 @@ export interface DataModelMethods<T> {
|
|
|
64
69
|
*/
|
|
65
70
|
createMany: (params: {
|
|
66
71
|
data: T[];
|
|
72
|
+
/**
|
|
73
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
74
|
+
*/
|
|
75
|
+
envType?: EnvType;
|
|
67
76
|
}) => Promise<MethodResponse<CreateManyResponse<T>>>;
|
|
68
77
|
/**
|
|
69
78
|
* 更新单条数据的方法。
|
|
@@ -86,6 +95,10 @@ export interface DataModelMethods<T> {
|
|
|
86
95
|
update: (params: {
|
|
87
96
|
data: T;
|
|
88
97
|
filter: FilterParams<T>;
|
|
98
|
+
/**
|
|
99
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
100
|
+
*/
|
|
101
|
+
envType?: EnvType;
|
|
89
102
|
}) => Promise<MethodResponse<UpdateResponse<T>>>;
|
|
90
103
|
/**
|
|
91
104
|
* 创建或者更新的方法
|
|
@@ -112,6 +125,10 @@ export interface DataModelMethods<T> {
|
|
|
112
125
|
update: T;
|
|
113
126
|
create: T;
|
|
114
127
|
filter: FilterParams<T>;
|
|
128
|
+
/**
|
|
129
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
130
|
+
*/
|
|
131
|
+
envType?: EnvType;
|
|
115
132
|
}) => Promise<MethodResponse<UpsertResponse<T>>>;
|
|
116
133
|
/**
|
|
117
134
|
* 更新多条数据的方法。
|
|
@@ -134,6 +151,10 @@ export interface DataModelMethods<T> {
|
|
|
134
151
|
updateMany: (params: {
|
|
135
152
|
data: T;
|
|
136
153
|
filter: FilterParams<T>;
|
|
154
|
+
/**
|
|
155
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
156
|
+
*/
|
|
157
|
+
envType?: EnvType;
|
|
137
158
|
}) => Promise<MethodResponse<CreateManyResponse<T>>>;
|
|
138
159
|
/**
|
|
139
160
|
* 删除单条数据的方法。
|
|
@@ -155,6 +176,10 @@ export interface DataModelMethods<T> {
|
|
|
155
176
|
*/
|
|
156
177
|
delete: (params: {
|
|
157
178
|
filter: FilterParams<T>;
|
|
179
|
+
/**
|
|
180
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
181
|
+
*/
|
|
182
|
+
envType?: EnvType;
|
|
158
183
|
}) => Promise<MethodResponse<DeleteResponse<T>>>;
|
|
159
184
|
/**
|
|
160
185
|
* 删除多条数据的方法。
|
|
@@ -173,6 +198,10 @@ export interface DataModelMethods<T> {
|
|
|
173
198
|
*/
|
|
174
199
|
deleteMany: (params: {
|
|
175
200
|
filter: FilterParams<T>;
|
|
201
|
+
/**
|
|
202
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
203
|
+
*/
|
|
204
|
+
envType?: EnvType;
|
|
176
205
|
}) => Promise<MethodResponse<DeleteManyResponse<T>>>;
|
|
177
206
|
/**
|
|
178
207
|
* 获取单条数据的方法。
|
|
@@ -195,6 +224,10 @@ export interface DataModelMethods<T> {
|
|
|
195
224
|
get: (params: {
|
|
196
225
|
filter: FilterParams<T>;
|
|
197
226
|
select?: SelectParams<T>;
|
|
227
|
+
/**
|
|
228
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
229
|
+
*/
|
|
230
|
+
envType?: EnvType;
|
|
198
231
|
}) => Promise<MethodResponse<T>>;
|
|
199
232
|
/**
|
|
200
233
|
* 获取多条数据的方法。
|
|
@@ -243,6 +276,10 @@ export interface DataModelMethods<T> {
|
|
|
243
276
|
* 排序参数,当前仅支持最多 3 字段排序
|
|
244
277
|
*/
|
|
245
278
|
orderBy?: OrderByParams[];
|
|
279
|
+
/**
|
|
280
|
+
* 请求数据的环境类型,默认是 prod,可选值有 prod 和 pre
|
|
281
|
+
*/
|
|
282
|
+
envType?: EnvType;
|
|
246
283
|
}) => Promise<MethodResponse<{
|
|
247
284
|
records: T[];
|
|
248
285
|
total?: number;
|
|
@@ -616,6 +653,10 @@ export interface CallDataSourceParams {
|
|
|
616
653
|
* 调用函数的方法,用于执行实际的云函数调用。
|
|
617
654
|
*/
|
|
618
655
|
callFunction: CallFunction;
|
|
656
|
+
/**
|
|
657
|
+
* 环境类型,标识当前的环境类型,可选值为`prod`和`pre`。
|
|
658
|
+
*/
|
|
659
|
+
envType?: EnvType;
|
|
619
660
|
/**
|
|
620
661
|
* @deprecated 使用 dataSourceName 替代。
|
|
621
662
|
*/
|
package/lib/utils.d.ts
CHANGED
|
@@ -143,23 +143,23 @@ function getUserAgent() {
|
|
|
143
143
|
return ua_1;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
var VERSION = "1.
|
|
146
|
+
var VERSION = "1.2.0";
|
|
147
147
|
|
|
148
148
|
var callDataSource = function (_a) {
|
|
149
|
-
var dataSourceName = _a.dataSourceName, methodName = _a.methodName, params = _a.params, realMethodName = _a.realMethodName, callFunction = _a.callFunction, mode = _a.mode;
|
|
149
|
+
var dataSourceName = _a.dataSourceName, methodName = _a.methodName, params = _a.params, realMethodName = _a.realMethodName, callFunction = _a.callFunction, _b = _a.envType, envType = _b === void 0 ? 'prod' : _b, mode = _a.mode;
|
|
150
150
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
151
151
|
var result, response, requestId, error_1;
|
|
152
|
-
var
|
|
153
|
-
return __generator(this, function (
|
|
154
|
-
switch (
|
|
152
|
+
var _c, _d;
|
|
153
|
+
return __generator(this, function (_e) {
|
|
154
|
+
switch (_e.label) {
|
|
155
155
|
case 0:
|
|
156
156
|
result = {
|
|
157
157
|
data: {},
|
|
158
158
|
requestId: ''
|
|
159
159
|
};
|
|
160
|
-
|
|
160
|
+
_e.label = 1;
|
|
161
161
|
case 1:
|
|
162
|
-
|
|
162
|
+
_e.trys.push([1, 3, , 4]);
|
|
163
163
|
return [4 /*yield*/, callFunction({
|
|
164
164
|
name: 'lowcode-datasource',
|
|
165
165
|
data: {
|
|
@@ -172,12 +172,13 @@ var callDataSource = function (_a) {
|
|
|
172
172
|
/**
|
|
173
173
|
* todo 移除此字段
|
|
174
174
|
*/
|
|
175
|
+
envType: envType,
|
|
175
176
|
mode: mode
|
|
176
177
|
}
|
|
177
178
|
})];
|
|
178
179
|
case 2:
|
|
179
|
-
response =
|
|
180
|
-
requestId = ((
|
|
180
|
+
response = _e.sent();
|
|
181
|
+
requestId = ((_c = response === null || response === void 0 ? void 0 : response.result) === null || _c === void 0 ? void 0 : _c.requestId) || (response === null || response === void 0 ? void 0 : response.requestId) || (response === null || response === void 0 ? void 0 : response.requestID);
|
|
181
182
|
if (response === null || response === void 0 ? void 0 : response.result.code) {
|
|
182
183
|
throw new WxCloudSDKError("\u3010\u9519\u8BEF\u3011".concat(response === null || response === void 0 ? void 0 : response.result.message, "\n\u3010\u64CD\u4F5C\u3011\u8C03\u7528 models.").concat(dataSourceName ? "".concat(dataSourceName, ".") : "").concat(realMethodName, "\n\u3010\u9519\u8BEF\u7801\u3011").concat(response === null || response === void 0 ? void 0 : response.result.code, "\n\u3010\u8BF7\u6C42ID\u3011").concat(requestId || 'N/A'), {
|
|
183
184
|
code: response === null || response === void 0 ? void 0 : response.result.code,
|
|
@@ -185,12 +186,12 @@ var callDataSource = function (_a) {
|
|
|
185
186
|
});
|
|
186
187
|
}
|
|
187
188
|
else {
|
|
188
|
-
result.data = ((
|
|
189
|
+
result.data = ((_d = response === null || response === void 0 ? void 0 : response.result) === null || _d === void 0 ? void 0 : _d.data) || {};
|
|
189
190
|
result.requestId = requestId;
|
|
190
191
|
}
|
|
191
192
|
return [3 /*break*/, 4];
|
|
192
193
|
case 3:
|
|
193
|
-
error_1 =
|
|
194
|
+
error_1 = _e.sent();
|
|
194
195
|
if (error_1.name === 'WxCloudSDKError') {
|
|
195
196
|
throw error_1;
|
|
196
197
|
}
|
|
@@ -333,7 +334,8 @@ var generateClientByDataSourceName = function (dataSourceName, callFunction) {
|
|
|
333
334
|
dataSourceName: dataSourceName,
|
|
334
335
|
methodName: operation.methodName,
|
|
335
336
|
realMethodName: methodName,
|
|
336
|
-
params: effectiveParams
|
|
337
|
+
params: effectiveParams,
|
|
338
|
+
envType: params === null || params === void 0 ? void 0 : params.envType
|
|
337
339
|
})];
|
|
338
340
|
case 1:
|
|
339
341
|
rawData = _b.sent();
|
|
@@ -141,23 +141,23 @@ function getUserAgent() {
|
|
|
141
141
|
return ua_1;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
var VERSION = "1.
|
|
144
|
+
var VERSION = "1.2.0";
|
|
145
145
|
|
|
146
146
|
var callDataSource = function (_a) {
|
|
147
|
-
var dataSourceName = _a.dataSourceName, methodName = _a.methodName, params = _a.params, realMethodName = _a.realMethodName, callFunction = _a.callFunction, mode = _a.mode;
|
|
147
|
+
var dataSourceName = _a.dataSourceName, methodName = _a.methodName, params = _a.params, realMethodName = _a.realMethodName, callFunction = _a.callFunction, _b = _a.envType, envType = _b === void 0 ? 'prod' : _b, mode = _a.mode;
|
|
148
148
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
149
149
|
var result, response, requestId, error_1;
|
|
150
|
-
var
|
|
151
|
-
return __generator(this, function (
|
|
152
|
-
switch (
|
|
150
|
+
var _c, _d;
|
|
151
|
+
return __generator(this, function (_e) {
|
|
152
|
+
switch (_e.label) {
|
|
153
153
|
case 0:
|
|
154
154
|
result = {
|
|
155
155
|
data: {},
|
|
156
156
|
requestId: ''
|
|
157
157
|
};
|
|
158
|
-
|
|
158
|
+
_e.label = 1;
|
|
159
159
|
case 1:
|
|
160
|
-
|
|
160
|
+
_e.trys.push([1, 3, , 4]);
|
|
161
161
|
return [4 /*yield*/, callFunction({
|
|
162
162
|
name: 'lowcode-datasource',
|
|
163
163
|
data: {
|
|
@@ -170,12 +170,13 @@ var callDataSource = function (_a) {
|
|
|
170
170
|
/**
|
|
171
171
|
* todo 移除此字段
|
|
172
172
|
*/
|
|
173
|
+
envType: envType,
|
|
173
174
|
mode: mode
|
|
174
175
|
}
|
|
175
176
|
})];
|
|
176
177
|
case 2:
|
|
177
|
-
response =
|
|
178
|
-
requestId = ((
|
|
178
|
+
response = _e.sent();
|
|
179
|
+
requestId = ((_c = response === null || response === void 0 ? void 0 : response.result) === null || _c === void 0 ? void 0 : _c.requestId) || (response === null || response === void 0 ? void 0 : response.requestId) || (response === null || response === void 0 ? void 0 : response.requestID);
|
|
179
180
|
if (response === null || response === void 0 ? void 0 : response.result.code) {
|
|
180
181
|
throw new WxCloudSDKError("\u3010\u9519\u8BEF\u3011".concat(response === null || response === void 0 ? void 0 : response.result.message, "\n\u3010\u64CD\u4F5C\u3011\u8C03\u7528 models.").concat(dataSourceName ? "".concat(dataSourceName, ".") : "").concat(realMethodName, "\n\u3010\u9519\u8BEF\u7801\u3011").concat(response === null || response === void 0 ? void 0 : response.result.code, "\n\u3010\u8BF7\u6C42ID\u3011").concat(requestId || 'N/A'), {
|
|
181
182
|
code: response === null || response === void 0 ? void 0 : response.result.code,
|
|
@@ -183,12 +184,12 @@ var callDataSource = function (_a) {
|
|
|
183
184
|
});
|
|
184
185
|
}
|
|
185
186
|
else {
|
|
186
|
-
result.data = ((
|
|
187
|
+
result.data = ((_d = response === null || response === void 0 ? void 0 : response.result) === null || _d === void 0 ? void 0 : _d.data) || {};
|
|
187
188
|
result.requestId = requestId;
|
|
188
189
|
}
|
|
189
190
|
return [3 /*break*/, 4];
|
|
190
191
|
case 3:
|
|
191
|
-
error_1 =
|
|
192
|
+
error_1 = _e.sent();
|
|
192
193
|
if (error_1.name === 'WxCloudSDKError') {
|
|
193
194
|
throw error_1;
|
|
194
195
|
}
|
|
@@ -331,7 +332,8 @@ var generateClientByDataSourceName = function (dataSourceName, callFunction) {
|
|
|
331
332
|
dataSourceName: dataSourceName,
|
|
332
333
|
methodName: operation.methodName,
|
|
333
334
|
realMethodName: methodName,
|
|
334
|
-
params: effectiveParams
|
|
335
|
+
params: effectiveParams,
|
|
336
|
+
envType: params === null || params === void 0 ? void 0 : params.envType
|
|
335
337
|
})];
|
|
336
338
|
case 1:
|
|
337
339
|
rawData = _b.sent();
|
|
@@ -147,23 +147,23 @@
|
|
|
147
147
|
return ua_1;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
var VERSION = "1.
|
|
150
|
+
var VERSION = "1.2.0";
|
|
151
151
|
|
|
152
152
|
var callDataSource = function (_a) {
|
|
153
|
-
var dataSourceName = _a.dataSourceName, methodName = _a.methodName, params = _a.params, realMethodName = _a.realMethodName, callFunction = _a.callFunction, mode = _a.mode;
|
|
153
|
+
var dataSourceName = _a.dataSourceName, methodName = _a.methodName, params = _a.params, realMethodName = _a.realMethodName, callFunction = _a.callFunction, _b = _a.envType, envType = _b === void 0 ? 'prod' : _b, mode = _a.mode;
|
|
154
154
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
155
155
|
var result, response, requestId, error_1;
|
|
156
|
-
var
|
|
157
|
-
return __generator(this, function (
|
|
158
|
-
switch (
|
|
156
|
+
var _c, _d;
|
|
157
|
+
return __generator(this, function (_e) {
|
|
158
|
+
switch (_e.label) {
|
|
159
159
|
case 0:
|
|
160
160
|
result = {
|
|
161
161
|
data: {},
|
|
162
162
|
requestId: ''
|
|
163
163
|
};
|
|
164
|
-
|
|
164
|
+
_e.label = 1;
|
|
165
165
|
case 1:
|
|
166
|
-
|
|
166
|
+
_e.trys.push([1, 3, , 4]);
|
|
167
167
|
return [4 /*yield*/, callFunction({
|
|
168
168
|
name: 'lowcode-datasource',
|
|
169
169
|
data: {
|
|
@@ -176,12 +176,13 @@
|
|
|
176
176
|
/**
|
|
177
177
|
* todo 移除此字段
|
|
178
178
|
*/
|
|
179
|
+
envType: envType,
|
|
179
180
|
mode: mode
|
|
180
181
|
}
|
|
181
182
|
})];
|
|
182
183
|
case 2:
|
|
183
|
-
response =
|
|
184
|
-
requestId = ((
|
|
184
|
+
response = _e.sent();
|
|
185
|
+
requestId = ((_c = response === null || response === void 0 ? void 0 : response.result) === null || _c === void 0 ? void 0 : _c.requestId) || (response === null || response === void 0 ? void 0 : response.requestId) || (response === null || response === void 0 ? void 0 : response.requestID);
|
|
185
186
|
if (response === null || response === void 0 ? void 0 : response.result.code) {
|
|
186
187
|
throw new WxCloudSDKError("\u3010\u9519\u8BEF\u3011".concat(response === null || response === void 0 ? void 0 : response.result.message, "\n\u3010\u64CD\u4F5C\u3011\u8C03\u7528 models.").concat(dataSourceName ? "".concat(dataSourceName, ".") : "").concat(realMethodName, "\n\u3010\u9519\u8BEF\u7801\u3011").concat(response === null || response === void 0 ? void 0 : response.result.code, "\n\u3010\u8BF7\u6C42ID\u3011").concat(requestId || 'N/A'), {
|
|
187
188
|
code: response === null || response === void 0 ? void 0 : response.result.code,
|
|
@@ -189,12 +190,12 @@
|
|
|
189
190
|
});
|
|
190
191
|
}
|
|
191
192
|
else {
|
|
192
|
-
result.data = ((
|
|
193
|
+
result.data = ((_d = response === null || response === void 0 ? void 0 : response.result) === null || _d === void 0 ? void 0 : _d.data) || {};
|
|
193
194
|
result.requestId = requestId;
|
|
194
195
|
}
|
|
195
196
|
return [3 /*break*/, 4];
|
|
196
197
|
case 3:
|
|
197
|
-
error_1 =
|
|
198
|
+
error_1 = _e.sent();
|
|
198
199
|
if (error_1.name === 'WxCloudSDKError') {
|
|
199
200
|
throw error_1;
|
|
200
201
|
}
|
|
@@ -337,7 +338,8 @@
|
|
|
337
338
|
dataSourceName: dataSourceName,
|
|
338
339
|
methodName: operation.methodName,
|
|
339
340
|
realMethodName: methodName,
|
|
340
|
-
params: effectiveParams
|
|
341
|
+
params: effectiveParams,
|
|
342
|
+
envType: params === null || params === void 0 ? void 0 : params.envType
|
|
341
343
|
})];
|
|
342
344
|
case 1:
|
|
343
345
|
rawData = _b.sent();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/wx-cloud-client-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"clean": "npx rimraf lib/*",
|
|
17
17
|
"build": "npm run clean && rollup -c",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:coverage": "jest --coverage",
|
|
18
20
|
"develop": "parcel demo/index.html",
|
|
19
21
|
"sync-dts": "cd demo && tcb model sync-dts --envId=lowcode-4gs26nnz095f6f4d",
|
|
20
22
|
"build-demo": "npx rimraf dist/* && parcel build demo/index.html --public-url ./",
|
|
@@ -29,8 +31,11 @@
|
|
|
29
31
|
"@rollup/plugin-replace": "^5.0.7",
|
|
30
32
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
31
33
|
"@tcwd/dev-tools": "^1.0.1",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
32
36
|
"parcel-bundler": "1.6.1",
|
|
33
37
|
"rollup": "^4.18.0",
|
|
38
|
+
"ts-jest": "^29.2.2",
|
|
34
39
|
"typedoc": "^0.25.13",
|
|
35
40
|
"typedoc-plugin-markdown": "^4.0.3",
|
|
36
41
|
"typescript": "4.4.4"
|