anymock-openapi
Advanced tools
Comparing version 1.2.0 to 1.2.1-alpha.1
@@ -17,4 +17,4 @@ "use strict"; | ||
finalData = payload; | ||
if (!anymock_client_token_1.isValidToken(finalConfig.projectToken)) { | ||
throw new Error("missing or invalid project token: " + projectToken); | ||
if (!(0, anymock_client_token_1.isValidToken)(finalConfig.projectToken)) { | ||
throw new Error("missing or invalid project token: ".concat(projectToken)); | ||
} | ||
@@ -29,8 +29,8 @@ // 序列化数据,去掉 undefined | ||
} | ||
_a = anymock_client_token_1.tokenToAk(projectToken), accessId = _a.accessId, accessSecret = _a.accessSecret; | ||
signature = anymock_client_token_1.default(accessSecret, finalData); | ||
_a = (0, anymock_client_token_1.tokenToAk)(projectToken), accessId = _a.accessId, accessSecret = _a.accessSecret; | ||
signature = (0, anymock_client_token_1.default)(accessSecret, finalData); | ||
// console.log('finalData:', finalData); | ||
// console.log('url:', `${finalConfig.host}/openapi${path}`); | ||
return [2 /*return*/, this.ctx.requestPipe({ | ||
url: finalConfig.host + "/openapi" + path, | ||
url: "".concat(finalConfig.host, "/openapi").concat(path), | ||
headers: { | ||
@@ -37,0 +37,0 @@ 'Content-Type': 'application/json', |
@@ -56,3 +56,3 @@ "use strict"; | ||
if (verbose && !mounted) { | ||
console.log(name + "@" + version); | ||
console.log("".concat(name, "@").concat(version)); | ||
mounted = true; | ||
@@ -59,0 +59,0 @@ } |
@@ -40,3 +40,3 @@ "use strict"; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/interface/" + interfaceId + "/get", {}, config)]; | ||
return [2 /*return*/, this.request("/interface/".concat(interfaceId, "/get"), {}, config)]; | ||
}); | ||
@@ -52,3 +52,3 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/interface/" + interfaceId + "/update", payload, config)]; | ||
return [2 /*return*/, this.request("/interface/".concat(interfaceId, "/update"), payload, config)]; | ||
}); | ||
@@ -64,3 +64,3 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/interface/" + interfaceId + "/delete", {}, config)]; | ||
return [2 /*return*/, this.request("/interface/".concat(interfaceId, "/delete"), {}, config)]; | ||
}); | ||
@@ -67,0 +67,0 @@ }); |
@@ -17,2 +17,16 @@ import { IAnymockConfigUpdate, IMockQueryPayload } from 'anymock-include'; | ||
update(requestId: ID, mockId: ID, payload: Partial<IMock>, config?: IAnymockConfigUpdate): Promise<IAnymockResponse<any>>; | ||
record(data: { | ||
recordId: number; | ||
requestIndex?: number; | ||
type: string; | ||
name: string; | ||
request: { | ||
header: string; | ||
content: string; | ||
}; | ||
response: { | ||
header: string; | ||
content: string; | ||
}; | ||
}, config?: IAnymockConfigUpdate): Promise<void>; | ||
} |
@@ -19,14 +19,13 @@ "use strict"; | ||
type = finalPayload.type, subType = finalPayload.subType, matching = finalPayload.matching, sceneId = finalPayload.sceneId; | ||
query = type ? "type=" + type : ''; | ||
query = type ? "type=".concat(type) : ''; | ||
if (subType) { | ||
query += (query ? '&' : '') + ("subType=" + encodeURIComponent(subType)); | ||
query += (query ? '&' : '') + "subType=".concat(encodeURIComponent(subType)); | ||
} | ||
if (matching) { | ||
query += (query ? '&' : '') + ("matching=" + encodeURIComponent(matching)); | ||
query += (query ? '&' : '') + "matching=".concat(encodeURIComponent(matching)); | ||
} | ||
if (sceneId) { | ||
query += (query ? '&' : '') + ("sceneId=" + encodeURIComponent(sceneId)); | ||
query += (query ? '&' : '') + "sceneId=".concat(encodeURIComponent(sceneId)); | ||
} | ||
// return this.request(`/mock/query`, finalPayload, options); | ||
return [2 /*return*/, this.request("/mock/query?" + query, finalPayload, options)]; | ||
return [2 /*return*/, this.request("/mock/query?".concat(query), finalPayload, options)]; | ||
}); | ||
@@ -43,6 +42,28 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/request/" + requestId + "/mock/" + mockId + "/update", payload, config)]; | ||
return [2 /*return*/, this.request("/request/".concat(requestId, "/mock/").concat(mockId, "/update"), payload, config)]; | ||
}); | ||
}); | ||
}; | ||
Mock.prototype.record = function (data, config) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function () { | ||
var _a, _b, type, _c, name, request, response, recordId, _d, requestIndex; | ||
return tslib_1.__generator(this, function (_e) { | ||
_a = data || {}, _b = _a.type, type = _b === void 0 ? '' : _b, _c = _a.name, name = _c === void 0 ? '' : _c, request = _a.request, response = _a.response, recordId = _a.recordId, _d = _a.requestIndex, requestIndex = _d === void 0 ? 1 : _d; | ||
if (!name || !type) { | ||
return [2 /*return*/]; | ||
} | ||
this.request("/record/recordRequests", { | ||
name: name, | ||
type: type, | ||
recordId: recordId, | ||
requestIndex: requestIndex, | ||
requestHeader: (request === null || request === void 0 ? void 0 : request.header) || '', | ||
requestContent: (request === null || request === void 0 ? void 0 : request.content) || '', | ||
responseHeader: (response === null || response === void 0 ? void 0 : response.header) || '', | ||
responseContent: (response === null || response === void 0 ? void 0 : response.content) || '', | ||
}, config); | ||
return [2 /*return*/]; | ||
}); | ||
}); | ||
}; | ||
return Mock; | ||
@@ -49,0 +70,0 @@ }(base_1.default)); |
@@ -33,3 +33,3 @@ "use strict"; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/page/" + pageId, payload, options)]; | ||
return [2 /*return*/, this.request("/page/".concat(pageId), payload, options)]; | ||
}); | ||
@@ -36,0 +36,0 @@ }); |
@@ -17,3 +17,3 @@ "use strict"; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/interface/" + interfaceId + "/request/create", payload, config)]; | ||
return [2 /*return*/, this.request("/interface/".concat(interfaceId, "/request/create"), payload, config)]; | ||
}); | ||
@@ -29,3 +29,3 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/request/" + requestId + "/get", {}, config)]; | ||
return [2 /*return*/, this.request("/request/".concat(requestId, "/get"), {}, config)]; | ||
}); | ||
@@ -41,3 +41,3 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/interface/" + interfaceId + "/request/" + requestId + "/update", payload, config)]; | ||
return [2 /*return*/, this.request("/interface/".concat(interfaceId, "/request/").concat(requestId, "/update"), payload, config)]; | ||
}); | ||
@@ -53,3 +53,3 @@ }); | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/request/" + requestId + "/delete", {}, config)]; | ||
return [2 /*return*/, this.request("/request/".concat(requestId, "/delete"), {}, config)]; | ||
}); | ||
@@ -56,0 +56,0 @@ }); |
@@ -32,3 +32,3 @@ "use strict"; | ||
return tslib_1.__generator(this, function (_a) { | ||
return [2 /*return*/, this.request("/scene/" + sceneId, payload, options)]; | ||
return [2 /*return*/, this.request("/scene/".concat(sceneId), payload, options)]; | ||
}); | ||
@@ -35,0 +35,0 @@ }); |
{ | ||
"name": "anymock-openapi", | ||
"version": "1.2.0", | ||
"version": "1.2.1-alpha.1", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "./lib/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
61406
980
2
1