зеркало из https://github.com/Azure/ms-rest-js.git
Merge branch 'master' into daschult/httpPipeline
This commit is contained in:
Коммит
7ee9f765f2
|
@ -84,3 +84,8 @@ SdkCodeGen
|
|||
output/*
|
||||
|
||||
# Typescript output
|
||||
dist/
|
||||
typings/
|
||||
*.js
|
||||
*.js.map
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
.vscode/
|
||||
node_modules/
|
||||
.idea/
|
||||
samples/
|
||||
lib/
|
||||
test/
|
||||
.travis.yml
|
||||
.gitignore
|
||||
gulpfile.js
|
||||
.git
|
||||
.git
|
||||
.DS_Store
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
webpack.config.ts
|
|
@ -1,5 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=serviceClientCredentials.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"serviceClientCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/serviceClientCredentials.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F"}
|
|
@ -1,17 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var BaseFilter = /** @class */ (function () {
|
||||
function BaseFilter() {
|
||||
}
|
||||
BaseFilter.prototype.before = function (request) {
|
||||
return Promise.resolve(request);
|
||||
};
|
||||
BaseFilter.prototype.after = function (response) {
|
||||
return Promise.resolve(response);
|
||||
};
|
||||
return BaseFilter;
|
||||
}());
|
||||
exports.BaseFilter = BaseFilter;
|
||||
//# sourceMappingURL=baseFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"baseFilter.js","sourceRoot":"","sources":["../../../lib/filters/baseFilter.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAK/F;IAEE;IAAgB,CAAC;IAEjB,2BAAM,GAAN,UAAO,OAAoB;QACzB,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,0BAAK,GAAL,UAAM,QAA+B;QACnC,OAAO,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;IACH,iBAAC;AAAD,CAAC,AAXD,IAWC;AAXY,gCAAU"}
|
|
@ -1,167 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var utils = require("../util/utils");
|
||||
/**
|
||||
* @class
|
||||
* Instantiates a new "ExponentialRetryPolicyFilter" instance.
|
||||
*
|
||||
* @constructor
|
||||
* @param {number} retryCount The client retry count.
|
||||
* @param {number} retryInterval The client retry interval, in milliseconds.
|
||||
* @param {number} minRetryInterval The minimum retry interval, in milliseconds.
|
||||
* @param {number} maxRetryInterval The maximum retry interval, in milliseconds.
|
||||
*/
|
||||
var ExponentialRetryPolicyFilter = /** @class */ (function (_super) {
|
||||
__extends(ExponentialRetryPolicyFilter, _super);
|
||||
function ExponentialRetryPolicyFilter(retryCount, retryInterval, minRetryInterval, maxRetryInterval) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.DEFAULT_CLIENT_RETRY_INTERVAL = 1000 * 30;
|
||||
_this.DEFAULT_CLIENT_RETRY_COUNT = 3;
|
||||
_this.DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 90;
|
||||
_this.DEFAULT_CLIENT_MIN_RETRY_INTERVAL = 1000 * 3;
|
||||
_this.retryCount = typeof retryCount === "number" ? retryCount : _this.DEFAULT_CLIENT_RETRY_COUNT;
|
||||
_this.retryInterval = typeof retryInterval === "number" ? retryInterval : _this.DEFAULT_CLIENT_RETRY_INTERVAL;
|
||||
_this.minRetryInterval = typeof minRetryInterval === "number" ? minRetryInterval : _this.DEFAULT_CLIENT_MIN_RETRY_INTERVAL;
|
||||
_this.maxRetryInterval = typeof maxRetryInterval === "number" ? maxRetryInterval : _this.DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Determines if the operation should be retried and how long to wait until the next retry.
|
||||
*
|
||||
* @param {number} statusCode The HTTP status code.
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @return {boolean} True if the operation qualifies for a retry; false otherwise.
|
||||
*/
|
||||
ExponentialRetryPolicyFilter.prototype.shouldRetry = function (statusCode, retryData) {
|
||||
if ((statusCode < 500 && statusCode !== 408) || statusCode === 501 || statusCode === 505) {
|
||||
return false;
|
||||
}
|
||||
var currentCount;
|
||||
if (!retryData) {
|
||||
throw new Error("retryData for the ExponentialRetryPolicyFilter cannot be null.");
|
||||
}
|
||||
else {
|
||||
currentCount = (retryData && retryData.retryCount);
|
||||
}
|
||||
return (currentCount < this.retryCount);
|
||||
};
|
||||
/**
|
||||
* Updates the retry data for the next attempt.
|
||||
*
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @param {object} err The operation"s error, if any.
|
||||
*/
|
||||
ExponentialRetryPolicyFilter.prototype.updateRetryData = function (retryData, err) {
|
||||
if (!retryData) {
|
||||
retryData = {
|
||||
retryCount: 0,
|
||||
retryInterval: 0
|
||||
};
|
||||
}
|
||||
if (err) {
|
||||
if (retryData.error) {
|
||||
err.innerError = retryData.error;
|
||||
}
|
||||
retryData.error = err;
|
||||
}
|
||||
// Adjust retry count
|
||||
retryData.retryCount++;
|
||||
// Adjust retry interval
|
||||
var incrementDelta = Math.pow(2, retryData.retryCount) - 1;
|
||||
var boundedRandDelta = this.retryInterval * 0.8 +
|
||||
Math.floor(Math.random() * (this.retryInterval * 1.2 - this.retryInterval * 0.8));
|
||||
incrementDelta *= boundedRandDelta;
|
||||
retryData.retryInterval = Math.min(this.minRetryInterval + incrementDelta, this.maxRetryInterval);
|
||||
return retryData;
|
||||
};
|
||||
ExponentialRetryPolicyFilter.prototype.retry = function (operationResponse, retryData, err) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var self, response, res, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
self = this;
|
||||
response = operationResponse.response;
|
||||
retryData = self.updateRetryData(retryData, err);
|
||||
if (!(!utils.objectIsNull(response) && self.shouldRetry(response.status, retryData))) return [3 /*break*/, 6];
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 4, , 5]);
|
||||
return [4 /*yield*/, utils.delay(retryData.retryInterval)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [4 /*yield*/, utils.dispatchRequest(operationResponse.request)];
|
||||
case 3:
|
||||
res = _a.sent();
|
||||
return [2 /*return*/, self.retry(res, retryData, err)];
|
||||
case 4:
|
||||
err_1 = _a.sent();
|
||||
return [2 /*return*/, self.retry(operationResponse, retryData, err_1)];
|
||||
case 5: return [3 /*break*/, 7];
|
||||
case 6:
|
||||
if (!utils.objectIsNull(err)) {
|
||||
// If the operation failed in the end, return all errors instead of just the last one
|
||||
err = retryData.error;
|
||||
return [2 /*return*/, Promise.reject(err)];
|
||||
}
|
||||
return [2 /*return*/, Promise.resolve(operationResponse)];
|
||||
case 7: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
ExponentialRetryPolicyFilter.prototype.after = function (operationResponse) {
|
||||
return this.retry(operationResponse);
|
||||
};
|
||||
return ExponentialRetryPolicyFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.ExponentialRetryPolicyFilter = ExponentialRetryPolicyFilter;
|
||||
//# sourceMappingURL=exponentialRetryPolicyFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"exponentialRetryPolicyFilter.js","sourceRoot":"","sources":["../../../lib/filters/exponentialRetryPolicyFilter.ts"],"names":[],"mappings":"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"}
|
|
@ -1,35 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var LogFilter = /** @class */ (function (_super) {
|
||||
__extends(LogFilter, _super);
|
||||
function LogFilter(logger) {
|
||||
if (logger === void 0) { logger = console.log; }
|
||||
var _this = _super.call(this) || this;
|
||||
_this.logger = logger;
|
||||
return _this;
|
||||
}
|
||||
LogFilter.prototype.after = function (operationResponse) {
|
||||
var self = this;
|
||||
self.logger(">> Request: " + JSON.stringify(operationResponse.request, undefined, 2));
|
||||
self.logger(">> Response status code: " + operationResponse.response.status);
|
||||
var responseBody = operationResponse.bodyAsText;
|
||||
self.logger(">> Body: " + responseBody);
|
||||
return Promise.resolve(operationResponse);
|
||||
};
|
||||
return LogFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.LogFilter = LogFilter;
|
||||
//# sourceMappingURL=logFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"logFilter.js","sourceRoot":"","sources":["../../../lib/filters/logFilter.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;;;;;;;;;;;AAE/F,2CAA0C;AAG1C;IAA+B,6BAAU;IAIvC,mBAAY,MAAyB;QAAzB,uBAAA,EAAA,SAAc,OAAO,CAAC,GAAG;QAArC,YACE,iBAAO,SAER;QADC,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;;IACvB,CAAC;IAED,yBAAK,GAAL,UAAM,iBAAwC;QAC5C,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,CAAC,iBAAe,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAG,CAAC,CAAC;QACtF,IAAI,CAAC,MAAM,CAAC,8BAA4B,iBAAiB,CAAC,QAAQ,CAAC,MAAQ,CAAC,CAAC;QAC7E,IAAM,YAAY,GAAG,iBAAiB,CAAC,UAAU,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,cAAY,YAAc,CAAC,CAAC;QACxC,OAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC5C,CAAC;IACH,gBAAC;AAAD,CAAC,AAjBD,CAA+B,uBAAU,GAiBxC;AAjBY,8BAAS"}
|
|
@ -1,65 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var constants_1 = require("../util/constants");
|
||||
var utils_1 = require("../util/utils");
|
||||
var os = require("os");
|
||||
var HeaderConstants = constants_1.Constants.HeaderConstants;
|
||||
var MsRestUserAgentFilter = /** @class */ (function (_super) {
|
||||
__extends(MsRestUserAgentFilter, _super);
|
||||
function MsRestUserAgentFilter(userAgentInfo) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.userAgentInfo = userAgentInfo;
|
||||
return _this;
|
||||
}
|
||||
MsRestUserAgentFilter.prototype.tagRequest = function (request) {
|
||||
if (utils_1.isNode) {
|
||||
var osInfo = "(" + os.arch() + "-" + os.type() + "-" + os.release() + ")";
|
||||
if (this.userAgentInfo.indexOf(osInfo) === -1) {
|
||||
this.userAgentInfo.unshift(osInfo);
|
||||
}
|
||||
var runtimeInfo = "Node/" + process.version;
|
||||
if (this.userAgentInfo.indexOf(runtimeInfo) === -1) {
|
||||
this.userAgentInfo.unshift(runtimeInfo);
|
||||
}
|
||||
var nodeSDKSignature = "Azure-SDK-For-Node";
|
||||
if (this.userAgentInfo.indexOf(nodeSDKSignature) === -1) {
|
||||
var azureRuntime = "ms-rest-azure";
|
||||
var insertIndex = this.userAgentInfo.indexOf(azureRuntime);
|
||||
// insert after azureRuntime, otherwise, insert last.
|
||||
insertIndex = insertIndex < 0 ? this.userAgentInfo.length : insertIndex + 1;
|
||||
this.userAgentInfo.splice(insertIndex, 0, nodeSDKSignature);
|
||||
}
|
||||
if (!request.headers)
|
||||
request.headers = {};
|
||||
request.headers[HeaderConstants.USER_AGENT] = this.userAgentInfo.join(" ");
|
||||
}
|
||||
return Promise.resolve(request);
|
||||
};
|
||||
MsRestUserAgentFilter.prototype.before = function (request) {
|
||||
var self = this;
|
||||
if (!request.headers)
|
||||
request.headers = {};
|
||||
if (!request.headers[HeaderConstants.USER_AGENT]) {
|
||||
return self.tagRequest(request);
|
||||
}
|
||||
else {
|
||||
return Promise.resolve(request);
|
||||
}
|
||||
};
|
||||
return MsRestUserAgentFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.MsRestUserAgentFilter = MsRestUserAgentFilter;
|
||||
//# sourceMappingURL=msRestUserAgentFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"msRestUserAgentFilter.js","sourceRoot":"","sources":["../../../lib/filters/msRestUserAgentFilter.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;;;;;;;;;;;AAE/F,2CAA0C;AAE1C,+CAA8C;AAC9C,uCAAuC;AACvC,uBAAyB;AAEzB,IAAM,eAAe,GAAG,qBAAS,CAAC,eAAe,CAAC;AAElD;IAA2C,yCAAU;IAInD,+BAAY,aAA4B;QAAxC,YACE,iBAAO,SAER;QADC,KAAI,CAAC,aAAa,GAAG,aAAa,CAAC;;IACrC,CAAC;IAED,0CAAU,GAAV,UAAW,OAAoB;QAC7B,IAAI,cAAM,EAAE;YACV,IAAM,MAAM,GAAG,MAAI,EAAE,CAAC,IAAI,EAAE,SAAI,EAAE,CAAC,IAAI,EAAE,SAAI,EAAE,CAAC,OAAO,EAAE,MAAG,CAAC;YAC7D,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBAC7C,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACpC;YAED,IAAM,WAAW,GAAG,UAAQ,OAAO,CAAC,OAAS,CAAC;YAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE;gBAClD,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;aACzC;YAED,IAAM,gBAAgB,GAAG,oBAAoB,CAAC;YAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE;gBACvD,IAAM,YAAY,GAAG,eAAe,CAAC;gBAErC,IAAI,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;gBAC3D,qDAAqD;gBACrD,WAAW,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC;gBAC5E,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC;aAC7D;YACD,IAAI,CAAC,OAAO,CAAC,OAAO;gBAAE,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YAC3C,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAC5E;QACD,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAED,sCAAM,GAAN,UAAO,OAAoB;QACzB,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;QAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,EAAE;YAChD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;SACjC;aAAM;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;SACjC;IACH,CAAC;IACH,4BAAC;AAAD,CAAC,AA7CD,CAA2C,uBAAU,GA6CpD;AA7CY,sDAAqB"}
|
|
@ -1,102 +0,0 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var utils = require("../util/utils");
|
||||
var parse = require("url-parse");
|
||||
var RedirectFilter = /** @class */ (function (_super) {
|
||||
__extends(RedirectFilter, _super);
|
||||
function RedirectFilter(maximumRetries) {
|
||||
if (maximumRetries === void 0) { maximumRetries = 20; }
|
||||
var _this = _super.call(this) || this;
|
||||
_this.maximumRetries = maximumRetries;
|
||||
return _this;
|
||||
}
|
||||
RedirectFilter.prototype.handleRedirect = function (operationResponse, currentRetries) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var request, response, res, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
request = operationResponse.request;
|
||||
response = operationResponse.response;
|
||||
if (!(response && response.headers && response.headers.get("location") &&
|
||||
(response.status === 300 || response.status === 307 || (response.status === 303 && request.method === "POST")) &&
|
||||
(!this.maximumRetries || currentRetries < this.maximumRetries))) return [3 /*break*/, 5];
|
||||
request.url = parse(response.headers.get("location"), parse(request.url)).href;
|
||||
// POST request with Status code 303 should be converted into a
|
||||
// redirected GET request if the redirect url is present in the location header
|
||||
if (response.status === 303) {
|
||||
request.method = "GET";
|
||||
}
|
||||
res = void 0;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, utils.dispatchRequest(request)];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
currentRetries++;
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
return [2 /*return*/, Promise.reject(err_1)];
|
||||
case 4: return [2 /*return*/, this.handleRedirect(res, currentRetries)];
|
||||
case 5: return [2 /*return*/, Promise.resolve(operationResponse)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
RedirectFilter.prototype.after = function (operationResponse) {
|
||||
return this.handleRedirect(operationResponse, 0);
|
||||
};
|
||||
return RedirectFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.RedirectFilter = RedirectFilter;
|
||||
//# sourceMappingURL=redirectFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"redirectFilter.js","sourceRoot":"","sources":["../../../lib/filters/redirectFilter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA4D;AAC5D,+FAA+F;AAC/F,2CAA0C;AAE1C,qCAAuC;AACvC,iCAAmC;AAEnC;IAAoC,kCAAU;IAI5C,wBAAY,cAAmB;QAAnB,+BAAA,EAAA,mBAAmB;QAA/B,YACE,iBAAO,SAER;QADC,KAAI,CAAC,cAAc,GAAG,cAAc,CAAC;;IACvC,CAAC;IAEK,uCAAc,GAApB,UAAqB,iBAAwC,EAAE,cAAsB;;;;;;wBAC7E,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;wBACpC,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC;6BACxC,CAAA,QAAQ,IAAI,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;4BAClE,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;4BAC9G,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,CAAA,EAF5D,wBAE4D;wBAE9D,OAAO,CAAC,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAE,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;wBAEhF,+DAA+D;wBAC/D,+EAA+E;wBAC/E,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE;4BAC3B,OAAO,CAAC,MAAM,GAAG,KAAK,CAAC;yBACxB;wBACG,GAAG,SAAuB,CAAC;;;;wBAEvB,qBAAM,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,EAAA;;wBAA1C,GAAG,GAAG,SAAoC,CAAC;wBAC3C,cAAc,EAAE,CAAC;;;;wBAEjB,sBAAO,OAAO,CAAC,MAAM,CAAC,KAAG,CAAC,EAAC;4BAE7B,sBAAO,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,cAAc,CAAC,EAAC;4BAElD,sBAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAC;;;;KAC3C;IAED,8BAAK,GAAL,UAAM,iBAAwC;QAC5C,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IACH,qBAAC;AAAD,CAAC,AAtCD,CAAoC,uBAAU,GAsC7C;AAtCY,wCAAc"}
|
|
@ -1,270 +0,0 @@
|
|||
"use strict";
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var utils = require("../util/utils");
|
||||
/* tslint:disable:prefer-const */
|
||||
var retryTimeout = 30;
|
||||
/* tslint:enable:prefer-const */
|
||||
var RPRegistrationFilter = /** @class */ (function (_super) {
|
||||
__extends(RPRegistrationFilter, _super);
|
||||
function RPRegistrationFilter(retryTimeout) {
|
||||
if (retryTimeout === void 0) { retryTimeout = 30; }
|
||||
var _this = _super.call(this) || this;
|
||||
retryTimeout = retryTimeout;
|
||||
return _this;
|
||||
}
|
||||
RPRegistrationFilter.prototype.after = function (operationResponse) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var rpName, urlPrefix, options, registrationStatus, err_1, finalRes, err_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
options = operationResponse.request;
|
||||
if (operationResponse.response.status === 409) {
|
||||
rpName = this.checkRPNotRegisteredError(operationResponse.bodyAsText);
|
||||
}
|
||||
if (!rpName) return [3 /*break*/, 9];
|
||||
urlPrefix = this.extractSubscriptionUrl(options.url);
|
||||
registrationStatus = false;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.registerRP(urlPrefix, rpName, options)];
|
||||
case 2:
|
||||
registrationStatus = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 4:
|
||||
if (!registrationStatus) return [3 /*break*/, 9];
|
||||
// Retry the original request. We have to change the x-ms-client-request-id
|
||||
// otherwise Azure endpoint will return the initial 409 (cached) response.
|
||||
options.headers["x-ms-client-request-id"] = utils.generateUuid();
|
||||
finalRes = void 0;
|
||||
_a.label = 5;
|
||||
case 5:
|
||||
_a.trys.push([5, 7, , 8]);
|
||||
return [4 /*yield*/, utils.dispatchRequest(options)];
|
||||
case 6:
|
||||
finalRes = _a.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 7:
|
||||
err_2 = _a.sent();
|
||||
return [2 /*return*/, Promise.reject(err_2)];
|
||||
case 8: return [2 /*return*/, Promise.resolve(finalRes)];
|
||||
case 9: return [2 /*return*/, Promise.resolve(operationResponse)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Reuses the headers of the original request and url (if specified).
|
||||
* @param {WebResource} originalRequest The original request
|
||||
* @param {boolean} reuseUrlToo Should the url from the original request be reused as well. Default false.
|
||||
* @returns {object} reqOptions - A new request object with desired headers.
|
||||
*/
|
||||
RPRegistrationFilter.prototype.getRequestEssentials = function (originalRequest, reuseUrlToo) {
|
||||
if (reuseUrlToo === void 0) { reuseUrlToo = false; }
|
||||
var reqOptions = {
|
||||
headers: {}
|
||||
};
|
||||
if (reuseUrlToo) {
|
||||
reqOptions.url = originalRequest.url;
|
||||
}
|
||||
// Copy over the original request headers. This will get us the auth token and other useful stuff from
|
||||
// the original request header. Thus making it easier to make requests from this filter.
|
||||
for (var h in originalRequest.headers) {
|
||||
reqOptions.headers[h] = originalRequest.headers[h];
|
||||
}
|
||||
// We have to change the x-ms-client-request-id otherwise Azure endpoint
|
||||
// will return the initial 409 (cached) response.
|
||||
reqOptions.headers["x-ms-client-request-id"] = utils.generateUuid();
|
||||
// Set content-type to application/json
|
||||
reqOptions.headers["Content-Type"] = "application/json; charset=utf-8";
|
||||
return reqOptions;
|
||||
};
|
||||
/**
|
||||
* Validates the error code and message associated with 409 response status code. If it matches to that of
|
||||
* RP not registered then it returns the name of the RP else returns undefined.
|
||||
* @param {string} body - The response body received after making the original request.
|
||||
* @returns {string} result The name of the RP if condition is satisfied else undefined.
|
||||
*/
|
||||
RPRegistrationFilter.prototype.checkRPNotRegisteredError = function (body) {
|
||||
var result, responseBody;
|
||||
if (body) {
|
||||
try {
|
||||
responseBody = JSON.parse(body);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing;
|
||||
}
|
||||
if (responseBody && responseBody.error && responseBody.error.message &&
|
||||
responseBody.error.code && responseBody.error.code === "MissingSubscriptionRegistration") {
|
||||
var matchRes = responseBody.error.message.match(/.*'(.*)'/i);
|
||||
if (matchRes) {
|
||||
result = matchRes.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Extracts the first part of the URL, just after subscription:
|
||||
* https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/
|
||||
* @param {string} url - The original request url
|
||||
* @returns {string} urlPrefix The url prefix as explained above.
|
||||
*/
|
||||
RPRegistrationFilter.prototype.extractSubscriptionUrl = function (url) {
|
||||
var result;
|
||||
var matchRes = url.match(/.*\/subscriptions\/[a-f0-9-]+\//ig);
|
||||
if (matchRes && matchRes[0]) {
|
||||
result = matchRes[0];
|
||||
}
|
||||
else {
|
||||
throw new Error("Unable to extract subscriptionId from the given url - " + url + ".");
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* Registers the given provider.
|
||||
* @param {string} urlPrefix - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/
|
||||
* @param {string} provider - The provider name to be registered.
|
||||
* @param {object} originalRequest - The original request sent by the user that returned a 409 response
|
||||
* with a message that the provider is not registered.
|
||||
* @param {registrationCallback} callback - The callback that handles the RP registration
|
||||
*/
|
||||
RPRegistrationFilter.prototype.registerRP = function (urlPrefix, provider, originalRequest) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var postUrl, getUrl, reqOptions, res, err_3, statusRes, err_4;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
postUrl = urlPrefix + "providers/" + provider + "/register?api-version=2016-02-01";
|
||||
getUrl = urlPrefix + "providers/" + provider + "?api-version=2016-02-01";
|
||||
reqOptions = this.getRequestEssentials(originalRequest);
|
||||
reqOptions.method = "POST";
|
||||
reqOptions.url = postUrl;
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, utils.dispatchRequest(reqOptions)];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_3 = _a.sent();
|
||||
return [2 /*return*/, Promise.reject(err_3)];
|
||||
case 4:
|
||||
if (res.response.status !== 200) {
|
||||
return [2 /*return*/, Promise.reject(new Error("Autoregistration of " + provider + " failed. Please try registering manually."))];
|
||||
}
|
||||
statusRes = false;
|
||||
_a.label = 5;
|
||||
case 5:
|
||||
_a.trys.push([5, 7, , 8]);
|
||||
return [4 /*yield*/, this.getRegistrationStatus(getUrl, originalRequest)];
|
||||
case 6:
|
||||
statusRes = _a.sent();
|
||||
return [3 /*break*/, 8];
|
||||
case 7:
|
||||
err_4 = _a.sent();
|
||||
return [2 /*return*/, Promise.reject(err_4)];
|
||||
case 8: return [2 /*return*/, Promise.resolve(statusRes)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Polls the registration status of the provider that was registered. Polling happens at an interval of 30 seconds.
|
||||
* Polling will happen till the registrationState property of the response body is "Registered".
|
||||
* @param {string} url - The request url for polling
|
||||
* @param {object} originalRequest - The original request sent by the user that returned a 409 response
|
||||
* with a message that the provider is not registered.
|
||||
* @returns {Promise<boolean>} promise - True if RP Registration is successful.
|
||||
*/
|
||||
RPRegistrationFilter.prototype.getRegistrationStatus = function (url, originalRequest) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
var reqOptions, res, result, err_5, obj;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
reqOptions = this.getRequestEssentials(originalRequest);
|
||||
result = false;
|
||||
reqOptions.url = url;
|
||||
reqOptions.method = "GET";
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, utils.dispatchRequest(reqOptions)];
|
||||
case 2:
|
||||
res = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_5 = _a.sent();
|
||||
return [2 /*return*/, Promise.reject(err_5)];
|
||||
case 4:
|
||||
obj = res.parsedBody;
|
||||
if (res.parsedBody && obj.registrationState && obj.registrationState === "Registered") {
|
||||
result = true;
|
||||
}
|
||||
else {
|
||||
setTimeout(function () { return _this.getRegistrationStatus(url, originalRequest); }, retryTimeout * 1000);
|
||||
}
|
||||
return [2 /*return*/, Promise.resolve(result)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return RPRegistrationFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.RPRegistrationFilter = RPRegistrationFilter;
|
||||
//# sourceMappingURL=rpRegistrationFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"rpRegistrationFilter.js","sourceRoot":"","sources":["../../../lib/filters/rpRegistrationFilter.ts"],"names":[],"mappings":"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"}
|
|
@ -1,30 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var SigningFilter = /** @class */ (function (_super) {
|
||||
__extends(SigningFilter, _super);
|
||||
function SigningFilter(authenticationProvider) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.authenticationProvider = authenticationProvider;
|
||||
return _this;
|
||||
}
|
||||
SigningFilter.prototype.before = function (request) {
|
||||
var self = this;
|
||||
return self.authenticationProvider.signRequest(request);
|
||||
};
|
||||
return SigningFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.SigningFilter = SigningFilter;
|
||||
//# sourceMappingURL=signingFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"signingFilter.js","sourceRoot":"","sources":["../../../lib/filters/signingFilter.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;;;;;;;;;;;AAE/F,2CAA0C;AAI1C;IAAmC,iCAAU;IAI3C,uBAAY,sBAAgD;QAA5D,YACE,iBAAO,SAER;QADC,KAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;;IACvD,CAAC;IAED,8BAAM,GAAN,UAAO,OAAoB;QACzB,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,OAAO,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC;IACH,oBAAC;AAAD,CAAC,AAbD,CAAmC,uBAAU,GAa5C;AAbY,sCAAa"}
|
|
@ -1,165 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var baseFilter_1 = require("./baseFilter");
|
||||
var utils = require("../util/utils");
|
||||
/**
|
||||
* @class
|
||||
* Instantiates a new "ExponentialRetryPolicyFilter" instance.
|
||||
*
|
||||
* @constructor
|
||||
* @param {number} retryCount The client retry count.
|
||||
* @param {number} retryInterval The client retry interval, in milliseconds.
|
||||
* @param {number} minRetryInterval The minimum retry interval, in milliseconds.
|
||||
* @param {number} maxRetryInterval The maximum retry interval, in milliseconds.
|
||||
*/
|
||||
var SystemErrorRetryPolicyFilter = /** @class */ (function (_super) {
|
||||
__extends(SystemErrorRetryPolicyFilter, _super);
|
||||
function SystemErrorRetryPolicyFilter(retryCount, retryInterval, minRetryInterval, maxRetryInterval) {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.DEFAULT_CLIENT_RETRY_INTERVAL = 1000 * 30;
|
||||
_this.DEFAULT_CLIENT_RETRY_COUNT = 3;
|
||||
_this.DEFAULT_CLIENT_MAX_RETRY_INTERVAL = 1000 * 90;
|
||||
_this.DEFAULT_CLIENT_MIN_RETRY_INTERVAL = 1000 * 3;
|
||||
_this.retryCount = typeof retryCount === "number" ? retryCount : _this.DEFAULT_CLIENT_RETRY_COUNT;
|
||||
_this.retryInterval = typeof retryInterval === "number" ? retryInterval : _this.DEFAULT_CLIENT_RETRY_INTERVAL;
|
||||
_this.minRetryInterval = typeof minRetryInterval === "number" ? minRetryInterval : _this.DEFAULT_CLIENT_MIN_RETRY_INTERVAL;
|
||||
_this.maxRetryInterval = typeof maxRetryInterval === "number" ? maxRetryInterval : _this.DEFAULT_CLIENT_MAX_RETRY_INTERVAL;
|
||||
return _this;
|
||||
}
|
||||
/**
|
||||
* Determines if the operation should be retried and how long to wait until the next retry.
|
||||
*
|
||||
* @param {number} statusCode The HTTP status code.
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @return {boolean} True if the operation qualifies for a retry; false otherwise.
|
||||
*/
|
||||
SystemErrorRetryPolicyFilter.prototype.shouldRetry = function (retryData) {
|
||||
var currentCount;
|
||||
if (!retryData) {
|
||||
throw new Error("retryData for the SystemErrorRetryPolicyFilter cannot be null.");
|
||||
}
|
||||
else {
|
||||
currentCount = (retryData && retryData.retryCount);
|
||||
}
|
||||
return (currentCount < this.retryCount);
|
||||
};
|
||||
/**
|
||||
* Updates the retry data for the next attempt.
|
||||
*
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @param {object} err The operation"s error, if any.
|
||||
*/
|
||||
SystemErrorRetryPolicyFilter.prototype.updateRetryData = function (retryData, err) {
|
||||
if (!retryData) {
|
||||
retryData = {
|
||||
retryCount: 0,
|
||||
retryInterval: 0
|
||||
};
|
||||
}
|
||||
if (err) {
|
||||
if (retryData.error) {
|
||||
err.innerError = retryData.error;
|
||||
}
|
||||
retryData.error = err;
|
||||
}
|
||||
// Adjust retry count
|
||||
retryData.retryCount++;
|
||||
// Adjust retry interval
|
||||
var incrementDelta = Math.pow(2, retryData.retryCount) - 1;
|
||||
var boundedRandDelta = this.retryInterval * 0.8 +
|
||||
Math.floor(Math.random() * (this.retryInterval * 1.2 - this.retryInterval * 0.8));
|
||||
incrementDelta *= boundedRandDelta;
|
||||
retryData.retryInterval = Math.min(this.minRetryInterval + incrementDelta, this.maxRetryInterval);
|
||||
return retryData;
|
||||
};
|
||||
SystemErrorRetryPolicyFilter.prototype.retry = function (operationResponse, retryData, err) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var self, res, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
self = this;
|
||||
retryData = self.updateRetryData(retryData, err);
|
||||
if (!(err && err.code && self.shouldRetry(retryData) &&
|
||||
(err.code === "ETIMEDOUT" || err.code === "ESOCKETTIMEDOUT" || err.code === "ECONNREFUSED" ||
|
||||
err.code === "ECONNRESET" || err.code === "ENOENT"))) return [3 /*break*/, 6];
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 4, , 5]);
|
||||
return [4 /*yield*/, utils.delay(retryData.retryInterval)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [4 /*yield*/, utils.dispatchRequest(operationResponse.request)];
|
||||
case 3:
|
||||
res = _a.sent();
|
||||
return [2 /*return*/, self.retry(res, retryData, err)];
|
||||
case 4:
|
||||
err_1 = _a.sent();
|
||||
return [2 /*return*/, self.retry(operationResponse, retryData, err_1)];
|
||||
case 5: return [3 /*break*/, 7];
|
||||
case 6:
|
||||
if (!utils.objectIsNull(err)) {
|
||||
// If the operation failed in the end, return all errors instead of just the last one
|
||||
err = retryData.error;
|
||||
return [2 /*return*/, Promise.reject(err)];
|
||||
}
|
||||
return [2 /*return*/, Promise.resolve(operationResponse)];
|
||||
case 7: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
SystemErrorRetryPolicyFilter.prototype.after = function (operationResponse) {
|
||||
return this.retry(operationResponse); // See: https://github.com/Microsoft/TypeScript/issues/7426
|
||||
};
|
||||
return SystemErrorRetryPolicyFilter;
|
||||
}(baseFilter_1.BaseFilter));
|
||||
exports.SystemErrorRetryPolicyFilter = SystemErrorRetryPolicyFilter;
|
||||
//# sourceMappingURL=systemErrorRetryPolicyFilter.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"systemErrorRetryPolicyFilter.js","sourceRoot":"","sources":["../../../lib/filters/systemErrorRetryPolicyFilter.ts"],"names":[],"mappings":"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"}
|
|
@ -1,33 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/**
|
||||
* Wrapper object for http request and response. Deserialized object is stored in
|
||||
* the `parsedBody` property when the response body is received in JSON or XML.
|
||||
* @class
|
||||
* Initializes a new instance of the HttpOperationResponse class.
|
||||
* @constructor
|
||||
*/
|
||||
var HttpOperationResponse = /** @class */ (function () {
|
||||
function HttpOperationResponse(request, response) {
|
||||
/**
|
||||
* Reference to the original request object.
|
||||
* [WebResource] object.
|
||||
* @type {object}
|
||||
*/
|
||||
this.request = request;
|
||||
/**
|
||||
* Reference to the original response object.
|
||||
* [ServerResponse] object.
|
||||
* @type {object}
|
||||
*/
|
||||
this.response = response;
|
||||
/* tslint:disable:no-null-keyword */
|
||||
this.bodyAsText = null;
|
||||
this.parsedBody = null;
|
||||
}
|
||||
return HttpOperationResponse;
|
||||
}());
|
||||
exports.HttpOperationResponse = HttpOperationResponse;
|
||||
//# sourceMappingURL=httpOperationResponse.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"httpOperationResponse.js","sourceRoot":"","sources":["../../lib/httpOperationResponse.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAI/F;;;;;;GAMG;AACH;IAmBE,+BAAY,OAAoB,EAAE,QAAkB;QAClD;;;;WAIG;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB;;;;WAIG;QACH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,oCAAoC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IACH,4BAAC;AAAD,CAAC,AArCD,IAqCC;AArCY,sDAAqB"}
|
|
@ -1,52 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var utils = require("./util/utils");
|
||||
var RequestPipeline = /** @class */ (function () {
|
||||
function RequestPipeline(filters, requestOptions) {
|
||||
this.filters = filters || [];
|
||||
this.requestOptions = requestOptions || {};
|
||||
}
|
||||
RequestPipeline.prototype.addFilter = function (f) {
|
||||
this.filters.push(f);
|
||||
return;
|
||||
};
|
||||
RequestPipeline.prototype.create = function () {
|
||||
var self = this;
|
||||
var pipeline = [];
|
||||
if (self.filters && self.filters.length) {
|
||||
var beforeFilters = [];
|
||||
var afterFilters = [];
|
||||
for (var i = 0; i < self.filters.length; i++) {
|
||||
var filter = self.filters[i];
|
||||
if (filter.before && typeof filter.before === "function") {
|
||||
beforeFilters.push(filter.before.bind(filter));
|
||||
}
|
||||
if (filter.after && typeof filter.after === "function") {
|
||||
afterFilters.push(filter.after.bind(filter));
|
||||
}
|
||||
} // end-of-for-loop
|
||||
// add the request sink
|
||||
beforeFilters.push(self.requestSink.bind(self));
|
||||
pipeline = beforeFilters.concat(afterFilters);
|
||||
}
|
||||
else {
|
||||
pipeline.push(self.requestSink.bind(self));
|
||||
}
|
||||
var requestFun = function (request) {
|
||||
if (!request.headers)
|
||||
request.headers = {};
|
||||
return utils.executePromisesSequentially(pipeline, request);
|
||||
};
|
||||
return requestFun;
|
||||
};
|
||||
RequestPipeline.prototype.requestSink = function (options) {
|
||||
if (this.requestOptions.method)
|
||||
delete this.requestOptions.method;
|
||||
return utils.dispatchRequest(options);
|
||||
};
|
||||
return RequestPipeline;
|
||||
}());
|
||||
exports.RequestPipeline = RequestPipeline;
|
||||
//# sourceMappingURL=requestPipeline.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"requestPipeline.js","sourceRoot":"","sources":["../../lib/requestPipeline.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAK/F,oCAAsC;AAKtC;IAIE,yBAAY,OAAsB,EAAE,cAA4B;QAC9D,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,EAAE,CAAC;IAC7C,CAAC;IAED,mCAAS,GAAT,UAAU,CAAa;QACrB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACrB,OAAO;IACT,CAAC;IAED,gCAAM,GAAN;QACE,IAAM,IAAI,GAAG,IAAI,CAAC;QAClB,IAAI,QAAQ,GAAoB,EAAE,CAAC;QACnC,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACvC,IAAM,aAAa,GAAoB,EAAE,CAAC;YAC1C,IAAM,YAAY,GAAoB,EAAE,CAAC;YACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC5C,IAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC/B,IAAI,MAAM,CAAC,MAAM,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE;oBACxD,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;iBAChD;gBACD,IAAI,MAAM,CAAC,KAAK,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE;oBACtD,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;iBAC9C;aACF,CAAA,kBAAkB;YACnB,uBAAuB;YACvB,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAChD,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SAC/C;aAAM;YACL,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC5C;QACD,IAAM,UAAU,GAAoB,UAAC,OAAoB;YACvD,IAAI,CAAC,OAAO,CAAC,OAAO;gBAAE,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;YAC3C,OAAO,KAAK,CAAC,2BAA2B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC,CAAC;QACF,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,qCAAW,GAAX,UAAY,OAAoB;QAC9B,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM;YAAE,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC;QAClE,OAAO,KAAK,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IACH,sBAAC;AAAD,CAAC,AA9CD,IA8CC;AA9CY,0CAAe"}
|
|
@ -1,29 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var RestError = /** @class */ (function (_super) {
|
||||
__extends(RestError, _super);
|
||||
function RestError(message, code, statusCode, request, response, body) {
|
||||
var _this = _super.call(this, message) || this;
|
||||
_this.code = code;
|
||||
_this.statusCode = statusCode;
|
||||
_this.request = request;
|
||||
_this.response = response;
|
||||
_this.body = body;
|
||||
return _this;
|
||||
}
|
||||
return RestError;
|
||||
}(Error));
|
||||
exports.RestError = RestError;
|
||||
//# sourceMappingURL=restError.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"restError.js","sourceRoot":"","sources":["../../lib/restError.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;;;;;;;;;;;AAI/F;IAA+B,6BAAK;IAMlC,mBAAY,OAAe,EAAE,IAAa,EAAE,UAAmB,EAAE,OAAqB,EAAE,QAAmB,EAAE,IAAU;QAAvH,YACE,kBAAM,OAAO,CAAC,SAMf;QALC,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,KAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;;IACnB,CAAC;IACH,gBAAC;AAAD,CAAC,AAdD,CAA+B,KAAK,GAcnC;AAdY,8BAAS"}
|
|
@ -1,145 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var requestPipeline_1 = require("./requestPipeline");
|
||||
var exponentialRetryPolicyFilter_1 = require("./filters/exponentialRetryPolicyFilter");
|
||||
var systemErrorRetryPolicyFilter_1 = require("./filters/systemErrorRetryPolicyFilter");
|
||||
var redirectFilter_1 = require("./filters/redirectFilter");
|
||||
var signingFilter_1 = require("./filters/signingFilter");
|
||||
var rpRegistrationFilter_1 = require("./filters/rpRegistrationFilter");
|
||||
var msRestUserAgentFilter_1 = require("./filters/msRestUserAgentFilter");
|
||||
var webResource_1 = require("./webResource");
|
||||
var constants_1 = require("./util/constants");
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the ServiceClient.
|
||||
*/
|
||||
var ServiceClient = /** @class */ (function () {
|
||||
/**
|
||||
* The ServiceClient constructor
|
||||
* @constructor
|
||||
* @param {ServiceClientCredentials }[credentials] - BasicAuthenticationCredentials or
|
||||
* TokenCredentials object used for authentication.
|
||||
* @param { ServiceClientOptions } [options] The service client options that govern the behavior of the client.
|
||||
*/
|
||||
function ServiceClient(credentials, options) {
|
||||
if (!options) {
|
||||
options = {};
|
||||
}
|
||||
if (!options.requestOptions) {
|
||||
options.requestOptions = {};
|
||||
}
|
||||
if (!options.filters) {
|
||||
options.filters = [];
|
||||
}
|
||||
this.userAgentInfo = { value: [] };
|
||||
if (credentials && !credentials.signRequest) {
|
||||
throw new Error("credentials argument needs to implement signRequest method");
|
||||
}
|
||||
try {
|
||||
var moduleName = "ms-rest-js";
|
||||
var moduleVersion = constants_1.Constants.msRestVersion;
|
||||
this.addUserAgentInfo(moduleName + "/" + moduleVersion);
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
if (credentials) {
|
||||
options.filters.push(new signingFilter_1.SigningFilter(credentials));
|
||||
}
|
||||
options.filters.push(new msRestUserAgentFilter_1.MsRestUserAgentFilter(this.userAgentInfo.value));
|
||||
options.filters.push(new redirectFilter_1.RedirectFilter());
|
||||
options.filters.push(new rpRegistrationFilter_1.RPRegistrationFilter(options.rpRegistrationRetryTimeout));
|
||||
if (!options.noRetryPolicy) {
|
||||
options.filters.push(new exponentialRetryPolicyFilter_1.ExponentialRetryPolicyFilter());
|
||||
options.filters.push(new systemErrorRetryPolicyFilter_1.SystemErrorRetryPolicyFilter());
|
||||
}
|
||||
this.pipeline = new requestPipeline_1.RequestPipeline(options.filters, options.requestOptions).create();
|
||||
}
|
||||
/**
|
||||
* Adds custom information to user agent header
|
||||
* @param {any} additionalUserAgentInfo - information to be added to user agent header, as string.
|
||||
*/
|
||||
ServiceClient.prototype.addUserAgentInfo = function (additionalUserAgentInfo) {
|
||||
if (this.userAgentInfo.value.indexOf(additionalUserAgentInfo) === -1) {
|
||||
this.userAgentInfo.value.push(additionalUserAgentInfo);
|
||||
}
|
||||
return;
|
||||
};
|
||||
ServiceClient.prototype.sendRequest = function (options) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var httpRequest, operationResponse, err_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
if (options === null || options === undefined || typeof options !== "object") {
|
||||
throw new Error("options cannot be null or undefined and it must be of type object.");
|
||||
}
|
||||
try {
|
||||
if (options instanceof webResource_1.WebResource) {
|
||||
options.validateRequestProperties();
|
||||
httpRequest = options;
|
||||
}
|
||||
else {
|
||||
httpRequest = new webResource_1.WebResource();
|
||||
httpRequest = httpRequest.prepare(options);
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
return [2 /*return*/, Promise.reject(error)];
|
||||
}
|
||||
_a.label = 1;
|
||||
case 1:
|
||||
_a.trys.push([1, 3, , 4]);
|
||||
return [4 /*yield*/, this.pipeline(httpRequest)];
|
||||
case 2:
|
||||
operationResponse = _a.sent();
|
||||
return [3 /*break*/, 4];
|
||||
case 3:
|
||||
err_1 = _a.sent();
|
||||
return [2 /*return*/, Promise.reject(err_1)];
|
||||
case 4: return [2 /*return*/, Promise.resolve(operationResponse)];
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
return ServiceClient;
|
||||
}());
|
||||
exports.ServiceClient = ServiceClient;
|
||||
//# sourceMappingURL=serviceClient.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"serviceClient.js","sourceRoot":"","sources":["../../lib/serviceClient.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE/F,qDAAoD;AAGpD,uFAAsF;AACtF,uFAAsF;AACtF,2DAA0D;AAC1D,yDAAwD;AACxD,uEAAsE;AACtE,yEAAwE;AACxE,6CAAmE;AACnE,8CAA6C;AA4B7C;;;GAGG;AACH;IAcE;;;;;;OAMG;IACH,uBAAY,WAAsC,EAAE,OAA8B;QAChF,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,EAAE,CAAC;SACd;QAED,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE;YAC3B,OAAO,CAAC,cAAc,GAAG,EAAE,CAAC;SAC7B;QAED,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;SACtB;QAED,IAAI,CAAC,aAAa,GAAG,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;QAEnC,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;SAC/E;QAED,IAAI;YACF,IAAM,UAAU,GAAG,YAAY,CAAC;YAChC,IAAM,aAAa,GAAG,qBAAS,CAAC,aAAa,CAAC;YAC9C,IAAI,CAAC,gBAAgB,CAAI,UAAU,SAAI,aAAe,CAAC,CAAC;SACzD;QAAC,OAAO,GAAG,EAAE;YACZ,aAAa;SACd;QAED,IAAI,WAAW,EAAE;YACf,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,6BAAa,CAAC,WAAW,CAAC,CAAC,CAAC;SACtD;QAED,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,6CAAqB,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,+BAAc,EAAE,CAAC,CAAC;QAC3C,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,2CAAoB,CAAC,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC;QAEnF,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE;YAC1B,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,2DAA4B,EAAE,CAAC,CAAC;YACzD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,2DAA4B,EAAE,CAAC,CAAC;SAC1D;QAED,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAe,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,CAAC;IACxF,CAAC;IAED;;;OAGG;IACH,wCAAgB,GAAhB,UAAiB,uBAA+B;QAC9C,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,EAAE;YACpE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;SACxD;QACD,OAAO;IACT,CAAC;IAEK,mCAAW,GAAjB,UAAkB,OAA4C;;;;;;wBAC5D,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;4BAC5E,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;yBACvF;wBAGD,IAAI;4BACF,IAAI,OAAO,YAAY,yBAAW,EAAE;gCAClC,OAAO,CAAC,yBAAyB,EAAE,CAAC;gCACpC,WAAW,GAAG,OAAO,CAAC;6BACvB;iCAAM;gCACL,WAAW,GAAG,IAAI,yBAAW,EAAE,CAAC;gCAChC,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;6BAC5C;yBACF;wBAAC,OAAO,KAAK,EAAE;4BACd,sBAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,EAAC;yBAC9B;;;;wBAIqB,qBAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAA;;wBAApD,iBAAiB,GAAG,SAAgC,CAAC;;;;wBAErD,sBAAO,OAAO,CAAC,MAAM,CAAC,KAAG,CAAC,EAAC;4BAE7B,sBAAO,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAC;;;;KAC3C;IACH,oBAAC;AAAD,CAAC,AArGD,IAqGC;AArGY,sCAAa"}
|
|
@ -1,78 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Constants = {
|
||||
/**
|
||||
* The ms-rest version
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
msRestVersion: "0.1.0",
|
||||
/**
|
||||
* Specifies HTTP.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
HTTP: "http:",
|
||||
/**
|
||||
* Specifies HTTPS.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
HTTPS: "https:",
|
||||
/**
|
||||
* Specifies HTTP Proxy.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
HTTP_PROXY: "HTTP_PROXY",
|
||||
/**
|
||||
* Specifies HTTPS Proxy.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
HTTPS_PROXY: "HTTPS_PROXY",
|
||||
HttpConstants: {
|
||||
/**
|
||||
* Http Verbs
|
||||
*
|
||||
* @const
|
||||
* @enum {string}
|
||||
*/
|
||||
HttpVerbs: {
|
||||
PUT: "PUT",
|
||||
GET: "GET",
|
||||
DELETE: "DELETE",
|
||||
POST: "POST",
|
||||
MERGE: "MERGE",
|
||||
HEAD: "HEAD",
|
||||
PATCH: "PATCH"
|
||||
},
|
||||
},
|
||||
/**
|
||||
* Defines constants for use with HTTP headers.
|
||||
*/
|
||||
HeaderConstants: {
|
||||
/**
|
||||
* The Authorization header.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
AUTHORIZATION: "authorization",
|
||||
AUTHORIZATION_SCHEME: "Bearer",
|
||||
/**
|
||||
* The UserAgent header.
|
||||
*
|
||||
* @const
|
||||
* @type {string}
|
||||
*/
|
||||
USER_AGENT: "User-Agent"
|
||||
}
|
||||
};
|
||||
//# sourceMappingURL=constants.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../lib/util/constants.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAElF,QAAA,SAAS,GAAG;IAEvB;;;;OAIG;IACH,aAAa,EAAE,OAAO;IAEtB;;;;;OAKG;IACH,IAAI,EAAE,OAAO;IAEb;;;;;OAKG;IACH,KAAK,EAAE,QAAQ;IAEf;;;;;OAKG;IACH,UAAU,EAAE,YAAY;IAExB;;;;;OAKG;IACH,WAAW,EAAE,aAAa;IAE1B,aAAa,EAAE;QACb;;;;;WAKG;QACH,SAAS,EAAE;YACT,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO;YACd,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,OAAO;SACf;KACF;IAED;;OAEG;IACH,eAAe,EAAE;QACf;;;;;WAKG;QACH,aAAa,EAAE,eAAe;QAE9B,oBAAoB,EAAE,QAAQ;QAE9B;;;;;WAKG;QACH,UAAU,EAAE,YAAY;KACzB;CACF,CAAC"}
|
|
@ -1,209 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var utils_1 = require("./util/utils");
|
||||
var serializer_1 = require("./serializer");
|
||||
/**
|
||||
* Creates a new WebResource object.
|
||||
*
|
||||
* This class provides an abstraction over a REST call by being library / implementation agnostic and wrapping the necessary
|
||||
* properties to initiate a request.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var WebResource = /** @class */ (function () {
|
||||
function WebResource(url, method, body, query, headers, rawResponse) {
|
||||
if (headers === void 0) { headers = {}; }
|
||||
if (rawResponse === void 0) { rawResponse = false; }
|
||||
this.headers = {};
|
||||
this.rawResponse = rawResponse;
|
||||
this.url = url || "";
|
||||
this.method = method || "GET";
|
||||
this.headers = headers || {};
|
||||
this.body = body;
|
||||
this.query = query;
|
||||
this.formData = undefined;
|
||||
}
|
||||
/**
|
||||
* Validates that the required properties such as method, url, headers["Content-Type"],
|
||||
* headers["accept-language"] are defined. It will throw an error if one of the above
|
||||
* mentioned properties are not defined.
|
||||
*/
|
||||
WebResource.prototype.validateRequestProperties = function () {
|
||||
if (!this.method || !this.url || !this.headers["Content-Type"] || !this.headers["accept-language"]) {
|
||||
throw new Error("method, url, headers[\"Content-Type\"], headers[\"accept-language\"] are " +
|
||||
"required properties before making a request. Either provide them or use WebResource.prepare() method.");
|
||||
}
|
||||
return;
|
||||
};
|
||||
/**
|
||||
* Prepares the request.
|
||||
* @param {RequestPrepareOptions} options - Options to provide for preparing the request.
|
||||
* @returns {object} WebResource Returns the prepared WebResource (HTTP Request) object that needs to be given to the request pipeline.
|
||||
*/
|
||||
WebResource.prototype.prepare = function (options) {
|
||||
if (options === null || options === undefined || typeof options !== "object") {
|
||||
throw new Error("options cannot be null or undefined and must be of type object");
|
||||
}
|
||||
if (options.method === null || options.method === undefined || typeof options.method.valueOf() !== "string") {
|
||||
throw new Error("options.method cannot be null or undefined and it must be of type string.");
|
||||
}
|
||||
if (options.url && options.pathTemplate) {
|
||||
throw new Error("options.url and options.pathTemplate are mutually exclusive. Please provide either of them.");
|
||||
}
|
||||
if ((options.pathTemplate === null || options.pathTemplate === undefined || typeof options.pathTemplate.valueOf() !== "string") && (options.url === null || options.url === undefined || typeof options.url.valueOf() !== "string")) {
|
||||
throw new Error("Please provide either options.pathTemplate or options.url. Currently none of them were provided.");
|
||||
}
|
||||
// set the url if it is provided.
|
||||
if (options.url) {
|
||||
if (typeof options.url !== "string") {
|
||||
throw new Error("options.url must be of type \"string\".");
|
||||
}
|
||||
this.url = options.url;
|
||||
}
|
||||
// set the method
|
||||
if (options.method) {
|
||||
var validMethods = ["GET", "PUT", "HEAD", "DELETE", "OPTIONS", "POST", "PATCH", "TRACE"];
|
||||
if (validMethods.indexOf(options.method.toUpperCase()) === -1) {
|
||||
throw new Error("The provided method \"" + options.method + "\" is invalid. Supported HTTP methods are: " + JSON.stringify(validMethods));
|
||||
}
|
||||
}
|
||||
this.method = options.method.toUpperCase();
|
||||
// construct the url if path template is provided
|
||||
if (options.pathTemplate) {
|
||||
if (typeof options.pathTemplate !== "string") {
|
||||
throw new Error("options.pathTemplate must be of type \"string\".");
|
||||
}
|
||||
if (!options.baseUrl) {
|
||||
options.baseUrl = "https://management.azure.com";
|
||||
}
|
||||
var baseUrl = options.baseUrl;
|
||||
var url_1 = baseUrl + (baseUrl.endsWith("/") ? "" : "/") + (options.pathTemplate.startsWith("/") ? options.pathTemplate.slice(1) : options.pathTemplate);
|
||||
var segments = url_1.match(/({\w*\s*\w*})/ig);
|
||||
if (segments && segments.length) {
|
||||
if (options.pathParameters === null || options.pathParameters === undefined || typeof options.pathParameters !== "object") {
|
||||
throw new Error("pathTemplate: " + options.pathTemplate + " has been provided. Hence, options.pathParameters " +
|
||||
"cannot be null or undefined and must be of type \"object\".");
|
||||
}
|
||||
segments.forEach(function (item) {
|
||||
var pathParamName = item.slice(1, -1);
|
||||
var pathParam = options.pathParameters[pathParamName];
|
||||
if (pathParam === null || pathParam === undefined || !(typeof pathParam === "string" || typeof pathParam === "object")) {
|
||||
throw new Error("pathTemplate: " + options.pathTemplate + " contains the path parameter " + pathParamName +
|
||||
(" however, it is not present in " + options.pathParameters + " - " + JSON.stringify(options.pathParameters, undefined, 2) + ".") +
|
||||
("The value of the path parameter can either be a \"string\" of the form { " + pathParamName + ": \"some sample value\" } or ") +
|
||||
("it can be an \"object\" of the form { \"" + pathParamName + "\": { value: \"some sample value\", skipUrlEncoding: true } }."));
|
||||
}
|
||||
if (typeof pathParam.valueOf() === "string") {
|
||||
url_1 = url_1.replace(item, encodeURIComponent(pathParam));
|
||||
}
|
||||
if (typeof pathParam.valueOf() === "object") {
|
||||
if (!pathParam.value) {
|
||||
throw new Error("options.pathParameters[" + pathParamName + "] is of type \"object\" but it does not contain a \"value\" property.");
|
||||
}
|
||||
if (pathParam.skipUrlEncoding) {
|
||||
url_1 = url_1.replace(item, pathParam.value);
|
||||
}
|
||||
else {
|
||||
url_1 = url_1.replace(item, encodeURIComponent(pathParam.value));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
this.url = url_1;
|
||||
}
|
||||
// append query parameters to the url if they are provided. They can be provided with pathTemplate or url option.
|
||||
if (options.queryParameters) {
|
||||
if (typeof options.queryParameters !== "object") {
|
||||
throw new Error("options.queryParameters must be of type object. It should be a JSON object " +
|
||||
"of \"query-parameter-name\" as the key and the \"query-parameter-value\" as the value. " +
|
||||
"The \"query-parameter-value\" may be fo type \"string\" or an \"object\" of the form { value: \"query-parameter-value\", skipUrlEncoding: true }.");
|
||||
}
|
||||
// append question mark if it is not present in the url
|
||||
if (this.url && this.url.indexOf("?") === -1) {
|
||||
this.url += "?";
|
||||
}
|
||||
// construct queryString
|
||||
var queryParams = [];
|
||||
var queryParameters = options.queryParameters;
|
||||
// We need to populate this.query as a dictionary if the request is being used for Sway's validateRequest().
|
||||
this.query = {};
|
||||
for (var queryParamName in queryParameters) {
|
||||
var queryParam = queryParameters[queryParamName];
|
||||
if (queryParam) {
|
||||
if (typeof queryParam === "string") {
|
||||
queryParams.push(queryParamName + "=" + encodeURIComponent(queryParam));
|
||||
this.query[queryParamName] = encodeURIComponent(queryParam);
|
||||
}
|
||||
else if (typeof queryParam === "object") {
|
||||
if (!queryParam.value) {
|
||||
throw new Error("options.queryParameters[" + queryParamName + "] is of type \"object\" but it does not contain a \"value\" property.");
|
||||
}
|
||||
if (queryParam.skipUrlEncoding) {
|
||||
queryParams.push(queryParamName + "=" + queryParam.value);
|
||||
this.query[queryParamName] = queryParam.value;
|
||||
}
|
||||
else {
|
||||
queryParams.push(queryParamName + "=" + encodeURIComponent(queryParam.value));
|
||||
this.query[queryParamName] = encodeURIComponent(queryParam.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // end-of-for
|
||||
// append the queryString
|
||||
this.url += queryParams.join("&");
|
||||
}
|
||||
// add headers to the request if they are provided
|
||||
if (options.headers) {
|
||||
var headers = options.headers;
|
||||
for (var headerName in headers) {
|
||||
if (headers.hasOwnProperty(headerName)) {
|
||||
this.headers[headerName] = headers[headerName];
|
||||
}
|
||||
}
|
||||
}
|
||||
// ensure accept-language is set correctly
|
||||
if (!this.headers["accept-language"]) {
|
||||
this.headers["accept-language"] = "en-US";
|
||||
}
|
||||
// ensure the request-id is set correctly
|
||||
if (!this.headers["x-ms-client-request-id"] && !options.disableClientRequestId) {
|
||||
this.headers["x-ms-client-request-id"] = utils_1.generateUuid();
|
||||
}
|
||||
// default
|
||||
if (!this.headers["Content-Type"]) {
|
||||
this.headers["Content-Type"] = "application/json; charset=utf-8";
|
||||
}
|
||||
// set the request body. request.js automatically sets the Content-Length request header, so we need not set it explicilty
|
||||
this.body = undefined;
|
||||
if (options.body !== null && options.body !== undefined) {
|
||||
// body as a stream special case. set the body as-is and check for some special request headers specific to sending a stream.
|
||||
if (options.bodyIsStream) {
|
||||
this.body = options.body;
|
||||
if (!this.headers["Transfer-Encoding"]) {
|
||||
this.headers["Transfer-Encoding"] = "chunked";
|
||||
}
|
||||
if (this.headers["Content-Type"] !== "application/octet-stream") {
|
||||
this.headers["Content-Type"] = "application/octet-stream";
|
||||
}
|
||||
}
|
||||
else {
|
||||
var serializedBody = undefined;
|
||||
if (options.serializationMapper) {
|
||||
serializedBody = new serializer_1.Serializer(options.mappers).serialize(options.serializationMapper, options.body, "requestBody");
|
||||
}
|
||||
if (options.disableJsonStringifyOnBody) {
|
||||
this.body = serializedBody || options.body;
|
||||
}
|
||||
else {
|
||||
this.body = serializedBody ? JSON.stringify(serializedBody) : JSON.stringify(options.body);
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
return WebResource;
|
||||
}());
|
||||
exports.WebResource = WebResource;
|
||||
//# sourceMappingURL=webResource.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,218 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (_) try {
|
||||
if (f = 1, y && (t = y[op[0] & 2 ? "return" : op[0] ? "throw" : "next"]) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [0, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var msRest = require("../lib/msRest");
|
||||
var should = require("should");
|
||||
var TokenCredentials = msRest.TokenCredentials;
|
||||
var BasicAuthenticationCredentials = msRest.BasicAuthenticationCredentials;
|
||||
var ApiKeyCredentials = msRest.ApiKeyCredentials;
|
||||
var dummyToken = "A-dummy-access-token";
|
||||
var fakeScheme = "fake-auth-scheme";
|
||||
var dummyuserName = "dummy@mummy.com";
|
||||
var dummyPassword = "IL0veDummies";
|
||||
describe("Token credentials", function () {
|
||||
describe("usage", function () {
|
||||
it("should set auth header with bearer scheme in request", function (done) {
|
||||
var creds = new TokenCredentials(dummyToken);
|
||||
var request = new msRest.WebResource();
|
||||
request.headers = {};
|
||||
creds.signRequest(request).then(function (signedRequest) {
|
||||
should.exist(signedRequest.headers["authorization"]);
|
||||
signedRequest.headers["authorization"].should.match(new RegExp("^Bearer\\s+" + dummyToken + "$"));
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should set auth header with custom scheme in request", function (done) {
|
||||
var creds = new TokenCredentials(dummyToken, fakeScheme);
|
||||
var request = new msRest.WebResource();
|
||||
request.headers = {};
|
||||
creds.signRequest(request).then(function (signedRequest) {
|
||||
should.exist(signedRequest.headers["authorization"]);
|
||||
signedRequest.headers["authorization"].should.match(new RegExp("^" + fakeScheme + "\\s+" + dummyToken + "$"));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("construction", function () {
|
||||
it("should succeed with token", function () {
|
||||
(function () {
|
||||
new TokenCredentials(dummyToken);
|
||||
}).should.not.throw();
|
||||
});
|
||||
// it("should fail without credentials", () => {
|
||||
// (() => {
|
||||
// new TokenCredentials();
|
||||
// }).should.throw();
|
||||
// });
|
||||
// it("should fail without token", () => {
|
||||
// (() => {
|
||||
// new TokenCredentials(null, fakeScheme);
|
||||
// }).should.throw();
|
||||
// });
|
||||
});
|
||||
});
|
||||
describe("Basic Authentication credentials", function () {
|
||||
var encodedCredentials = Buffer.from(dummyuserName + ":" + dummyPassword).toString("base64");
|
||||
describe("usage", function () {
|
||||
it("should base64 encode the username and password and set auth header with baisc scheme in request", function (done) {
|
||||
var creds = new BasicAuthenticationCredentials(dummyuserName, dummyPassword);
|
||||
var request = new msRest.WebResource();
|
||||
request.headers = {};
|
||||
creds.signRequest(request).then(function (signedRequest) {
|
||||
signedRequest.headers.should.have.property("authorization");
|
||||
signedRequest.headers["authorization"].should.match(new RegExp("^Basic\\s+" + encodedCredentials + "$"));
|
||||
done();
|
||||
});
|
||||
});
|
||||
it("should base64 encode the username and password and set auth header with custom scheme in request", function (done) {
|
||||
var creds = new BasicAuthenticationCredentials(dummyuserName, dummyPassword, fakeScheme);
|
||||
var request = new msRest.WebResource();
|
||||
request.headers = {};
|
||||
creds.signRequest(request).then(function (signedRequest) {
|
||||
signedRequest.headers.should.have.property("authorization");
|
||||
signedRequest.headers["authorization"].should.match(new RegExp("^" + fakeScheme + "\\s+" + encodedCredentials + "$"));
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
describe("construction", function () {
|
||||
it("should succeed with userName and password", function () {
|
||||
(function () {
|
||||
new BasicAuthenticationCredentials(dummyuserName, dummyPassword);
|
||||
}).should.not.throw();
|
||||
});
|
||||
// it("should fail without credentials", () => {
|
||||
// (() => {
|
||||
// new BasicAuthenticationCredentials(null, null);
|
||||
// }).should.throw();
|
||||
// });
|
||||
// it("should fail without userName and password", () => {
|
||||
// (() => {
|
||||
// new BasicAuthenticationCredentials(null, null, fakeScheme);
|
||||
// }).should.throw();
|
||||
// });
|
||||
});
|
||||
describe('ApiKey credentials', function () {
|
||||
describe('usage', function () {
|
||||
it('should set header parameters properly in request', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var creds, request;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
creds = new ApiKeyCredentials({ inHeader: { 'key1': 'value1', 'key2': 'value2' } });
|
||||
request = {
|
||||
headers: {}
|
||||
};
|
||||
return [4 /*yield*/, creds.signRequest(request)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
request.headers.should.have.property('key1');
|
||||
request.headers.should.have.property('key2');
|
||||
request.headers['key1'].should.match(new RegExp('^value1$'));
|
||||
request.headers['key2'].should.match(new RegExp('^value2$'));
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should set query parameters properly in the request url without any query parameters', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var creds, request;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
creds = new ApiKeyCredentials({ inQuery: { 'key1': 'value1', 'key2': 'value2' } });
|
||||
request = {
|
||||
headers: {},
|
||||
url: 'https://example.com'
|
||||
};
|
||||
return [4 /*yield*/, creds.signRequest(request)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
request.url.should.equal('https://example.com?key1=value1&key2=value2');
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
it('should set query parameters properly in the request url with existing query parameters', function () {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var creds, request;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
creds = new ApiKeyCredentials({ inQuery: { 'key1': 'value1', 'key2': 'value2' } });
|
||||
request = {
|
||||
headers: {},
|
||||
url: 'https://example.com?q1=v2'
|
||||
};
|
||||
return [4 /*yield*/, creds.signRequest(request)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
request.url.should.equal('https://example.com?q1=v2&key1=value1&key2=value2');
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('construction', function () {
|
||||
it('should fail with options.inHeader and options.inQuery set to null or undefined', function (done) {
|
||||
(function () {
|
||||
new ApiKeyCredentials({ inHeader: null, inQuery: undefined });
|
||||
}).should.throw();
|
||||
done();
|
||||
});
|
||||
it('should fail without options', function (done) {
|
||||
(function () {
|
||||
new ApiKeyCredentials();
|
||||
}).should.throw();
|
||||
done();
|
||||
});
|
||||
it('should fail with empty options', function (done) {
|
||||
(function () {
|
||||
new ApiKeyCredentials({});
|
||||
}).should.throw();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=credentialTests.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,600 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for
|
||||
* license information.
|
||||
*/
|
||||
var internalMappers = {};
|
||||
internalMappers.Cat = {
|
||||
required: false,
|
||||
serializedName: "cat",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Cat",
|
||||
modelProperties: {
|
||||
id: {
|
||||
required: false,
|
||||
serializedName: "id",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
name: {
|
||||
required: false,
|
||||
serializedName: "name",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
pettype: {
|
||||
required: true,
|
||||
serializedName: "pet\\.type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
color: {
|
||||
required: false,
|
||||
serializedName: "color",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
hates: {
|
||||
required: false,
|
||||
serializedName: "hates",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: false,
|
||||
serializedName: "DogElementType",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Dog"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.Dog = {
|
||||
required: false,
|
||||
serializedName: "dog",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Dog",
|
||||
modelProperties: {
|
||||
id: {
|
||||
required: false,
|
||||
serializedName: "id",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
name: {
|
||||
required: false,
|
||||
serializedName: "name",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
pettype: {
|
||||
required: true,
|
||||
serializedName: "pet\\.type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
food: {
|
||||
required: false,
|
||||
serializedName: "food",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.Fish = {
|
||||
required: false,
|
||||
serializedName: "Fish",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: {
|
||||
serializedName: "fish.type",
|
||||
clientName: "fishtype"
|
||||
},
|
||||
uberParent: "Fish",
|
||||
className: "Fish",
|
||||
modelProperties: {
|
||||
species: {
|
||||
required: false,
|
||||
serializedName: "species",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
length: {
|
||||
required: true,
|
||||
serializedName: "length",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
siblings: {
|
||||
required: false,
|
||||
serializedName: "siblings",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: false,
|
||||
serializedName: "FishElementType",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: {
|
||||
serializedName: "fish.type",
|
||||
clientName: "fishtype"
|
||||
},
|
||||
uberParent: "Fish",
|
||||
className: "Fish"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
fishtype: {
|
||||
required: true,
|
||||
serializedName: "fish\\.type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.Invoice = {
|
||||
required: false,
|
||||
serializedName: "Invoice",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Invoice",
|
||||
modelProperties: {
|
||||
invId: {
|
||||
serializedName: "invoiceId",
|
||||
required: true,
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
invDate: {
|
||||
serializedName: "invDate",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Date"
|
||||
}
|
||||
},
|
||||
invProducts: {
|
||||
serializedName: "invProducts",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Product"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.Pet = {
|
||||
required: false,
|
||||
serializedName: "pet",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Pet",
|
||||
polymorphicDiscriminator: "pet.type",
|
||||
modelProperties: {
|
||||
id: {
|
||||
required: false,
|
||||
serializedName: "id",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
name: {
|
||||
required: false,
|
||||
serializedName: "name",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
pettype: {
|
||||
required: true,
|
||||
serializedName: "pet\\.type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.PetGallery = {
|
||||
required: false,
|
||||
serializedName: "PetGallery",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "PetGallery",
|
||||
modelProperties: {
|
||||
id: {
|
||||
required: false,
|
||||
serializedName: "id",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
name: {
|
||||
required: false,
|
||||
serializedName: "name",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
pets: {
|
||||
required: false,
|
||||
serializedName: "pets",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: false,
|
||||
serializedName: "petElementType",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: "pet.type",
|
||||
uberParent: "Pet",
|
||||
className: "Pet"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.Product = {
|
||||
required: false,
|
||||
serializedName: "Product",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Product",
|
||||
modelProperties: {
|
||||
id: {
|
||||
serializedName: "id",
|
||||
constraints: {},
|
||||
required: true,
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
name: {
|
||||
serializedName: "name",
|
||||
required: true,
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
provisioningState: {
|
||||
serializedName: "properties.provisioningState",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Enum",
|
||||
allowedValues: ["Creating", "Failed", "Succeeded"]
|
||||
}
|
||||
},
|
||||
tags: {
|
||||
serializedName: "tags",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
dispatchTime: {
|
||||
serializedName: "dispatchTime",
|
||||
required: false,
|
||||
type: {
|
||||
name: "DateTime"
|
||||
}
|
||||
},
|
||||
invoiceInfo: {
|
||||
serializedName: "invoiceInfo",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Invoice"
|
||||
}
|
||||
},
|
||||
subProducts: {
|
||||
serializedName: "subProducts",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "SubProduct"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.ProductListResult = {
|
||||
required: false,
|
||||
serializedName: "ProductListResult",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "ProductListResult",
|
||||
modelProperties: {
|
||||
value: {
|
||||
serializedName: "",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Product"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.ProductListResultNextLink = {
|
||||
required: false,
|
||||
serializedName: "ProductListResultNextLink",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "ProductListResultNextLink",
|
||||
modelProperties: {
|
||||
value: {
|
||||
serializedName: "",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Product"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
nextLink: {
|
||||
serializedName: "nextLink",
|
||||
required: false,
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.SawShark = {
|
||||
required: false,
|
||||
serializedName: "sawshark",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: {
|
||||
serializedName: 'fish.type',
|
||||
clientName: 'fishtype'
|
||||
},
|
||||
uberParent: 'Fish',
|
||||
className: "Sawshark",
|
||||
modelProperties: {
|
||||
species: {
|
||||
required: false,
|
||||
serializedName: "species",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
length: {
|
||||
required: true,
|
||||
serializedName: "length",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
siblings: {
|
||||
required: false,
|
||||
serializedName: "siblings",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: false,
|
||||
serializedName: "FishElementType",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: {
|
||||
serializedName: "fish.type",
|
||||
clientName: "fishtype"
|
||||
},
|
||||
uberParent: "Fish",
|
||||
className: "Fish"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
fishtype: {
|
||||
required: true,
|
||||
serializedName: "fish\\.type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
age: {
|
||||
required: false,
|
||||
serializedName: "age",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
birthday: {
|
||||
required: true,
|
||||
serializedName: "birthday",
|
||||
type: {
|
||||
name: "DateTime"
|
||||
}
|
||||
},
|
||||
picture: {
|
||||
required: false,
|
||||
serializedName: "picture",
|
||||
type: {
|
||||
name: "ByteArray"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.Shark = {
|
||||
required: false,
|
||||
serializedName: "shark",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: {
|
||||
serializedName: 'fish.type',
|
||||
clientName: 'fishtype'
|
||||
},
|
||||
uberParent: 'Fish',
|
||||
className: "Shark",
|
||||
modelProperties: {
|
||||
species: {
|
||||
required: false,
|
||||
serializedName: "species",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
length: {
|
||||
required: true,
|
||||
serializedName: "length",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
siblings: {
|
||||
required: false,
|
||||
serializedName: "siblings",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: false,
|
||||
serializedName: "FishElementType",
|
||||
type: {
|
||||
name: "Composite",
|
||||
polymorphicDiscriminator: {
|
||||
serializedName: "fish.type",
|
||||
clientName: "fishtype"
|
||||
},
|
||||
uberParent: "Fish",
|
||||
className: "Fish"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
fishtype: {
|
||||
required: true,
|
||||
serializedName: "fish\\.type",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
age: {
|
||||
required: false,
|
||||
serializedName: "age",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
birthday: {
|
||||
required: true,
|
||||
serializedName: "birthday",
|
||||
type: {
|
||||
name: "DateTime"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.SubProduct = {
|
||||
required: false,
|
||||
serializedName: "SubProduct",
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "SubProduct",
|
||||
modelProperties: {
|
||||
subId: {
|
||||
serializedName: "subId",
|
||||
required: true,
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
},
|
||||
subName: {
|
||||
serializedName: "subName",
|
||||
required: true,
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
},
|
||||
provisioningState: {
|
||||
serializedName: "provisioningState",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Enum",
|
||||
allowedValues: ["Creating", "Failed", "Succeeded"]
|
||||
}
|
||||
},
|
||||
makeTime: {
|
||||
serializedName: "makeTime",
|
||||
required: false,
|
||||
type: {
|
||||
name: "DateTime"
|
||||
}
|
||||
},
|
||||
invoiceInfo: {
|
||||
serializedName: "invoiceInfo",
|
||||
required: false,
|
||||
type: {
|
||||
name: "Composite",
|
||||
className: "Invoice"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
internalMappers.discriminators = {
|
||||
"Fish": internalMappers.Fish,
|
||||
"Fish.shark": internalMappers.Shark,
|
||||
"Fish.sawshark": internalMappers.SawShark,
|
||||
"Pet": internalMappers.Pet,
|
||||
"Pet.Cat": internalMappers.Cat,
|
||||
"Pet.Dog": internalMappers.Dog
|
||||
};
|
||||
exports.Mappers = internalMappers;
|
||||
//# sourceMappingURL=mappers.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for
|
||||
* license information.
|
||||
*
|
||||
* Code generated by Microsoft (R) AutoRest Code Generator 0.14.0.0
|
||||
* Changes may cause incorrect behavior and will be lost if the code is
|
||||
* regenerated.
|
||||
*/
|
||||
/* jshint latedef:false */
|
||||
/* jshint forin:false */
|
||||
/* jshint noempty:false */
|
||||
'use strict';
|
||||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var msRest = require("../../../../lib/msRest");
|
||||
var mappers_1 = require("./models/mappers");
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the TestClient class.
|
||||
* @constructor
|
||||
*
|
||||
* @param {string} [baseUri] - The base URI of the service.
|
||||
*
|
||||
* @param {object} [options] - The parameter options
|
||||
*
|
||||
* @param {Array} [options.filters] - Filters to be added to the request pipeline
|
||||
*
|
||||
* @param {object} [options.requestOptions] - Options for the underlying request object
|
||||
* {@link https://github.com/request/request#requestoptions-callback Options doc}
|
||||
*
|
||||
* @param {bool} [options.noRetryPolicy] - If set to true, turn off default retry policy
|
||||
*/
|
||||
var TestClient = /** @class */ (function (_super) {
|
||||
__extends(TestClient, _super);
|
||||
function TestClient(baseUri, options) {
|
||||
var _this = this;
|
||||
if (!options)
|
||||
options = {};
|
||||
_this = _super.call(this, undefined, options) || this;
|
||||
_this.baseUri = baseUri;
|
||||
if (!_this.baseUri) {
|
||||
_this.baseUri = 'https://management.azure.com';
|
||||
}
|
||||
if (!_this.acceptLanguage) {
|
||||
_this.acceptLanguage = 'en-US';
|
||||
}
|
||||
_this.serializer = new msRest.Serializer(mappers_1.Mappers);
|
||||
return _this;
|
||||
}
|
||||
return TestClient;
|
||||
}(msRest.ServiceClient));
|
||||
exports.TestClient = TestClient;
|
||||
//# sourceMappingURL=testClient.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"testClient.js","sourceRoot":"","sources":["../../../../../test/data/TestClient/lib/testClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,0BAA0B;AAC1B,wBAAwB;AACxB,0BAA0B;AAE1B,YAAY,CAAC;;;;;;;;;;;;AAEb,+CAAiD;AACjD,4CAA2C;AAE3C;;;;;;;;;;;;;;;GAeG;AAEH;IAAyB,8BAAoB;IAK3C,oBAAY,OAAe,EAAE,OAAqC;QAAlE,iBAYC;QAXC,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,EAAE,CAAC;QAC3B,QAAA,kBAAM,SAAS,EAAE,OAAO,CAAC,SAAC;QAC1B,KAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAI,CAAC,OAAO,EAAE;YACjB,KAAI,CAAC,OAAO,GAAG,8BAA8B,CAAC;SAC/C;QAED,IAAI,CAAC,KAAI,CAAC,cAAc,EAAE;YACxB,KAAI,CAAC,cAAc,GAAG,OAAO,CAAC;SAC/B;QACD,KAAI,CAAC,UAAU,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,iBAAO,CAAC,CAAC;;IACnD,CAAC;IACH,iBAAC;AAAD,CAAC,AAlBD,CAAyB,MAAM,CAAC,aAAa,GAkB5C;AAEQ,gCAAU"}
|
|
@ -1,30 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var assert = require("assert");
|
||||
var webResource_1 = require("../lib/webResource");
|
||||
var httpOperationResponse_1 = require("../lib/httpOperationResponse");
|
||||
var logFilter_1 = require("../lib/filters/logFilter");
|
||||
var node_fetch_1 = require("node-fetch");
|
||||
describe("Log filter", function () {
|
||||
it("should log messages when a logger object is provided", function (done) {
|
||||
var expected = ">> Request: {\n \"headers\": {},\n \"rawResponse\": false,\n \"url\": \"https://foo.com\",\n \"method\": \"PUT\",\n \"body\": {\n \"a\": 1\n }\n}\n>> Response status code: 200\n>> Body: null\n";
|
||||
var output = "";
|
||||
var logger = function (message) { output += message + "\n"; };
|
||||
var lf = new logFilter_1.LogFilter(logger);
|
||||
var req = new webResource_1.WebResource("https://foo.com", "PUT", { "a": 1 });
|
||||
var res = new node_fetch_1.Response();
|
||||
var opRes = new httpOperationResponse_1.HttpOperationResponse(req, res);
|
||||
lf.after(opRes).then(function () {
|
||||
//console.dir(output, { depth: null });
|
||||
//console.log(">>>>>>>");
|
||||
//console.dir(expected);
|
||||
assert.deepEqual(output, expected);
|
||||
done();
|
||||
}).catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=logFilterTests.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"logFilterTests.js","sourceRoot":"","sources":["../../test/logFilterTests.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAG/F,+BAAiC;AACjC,kDAAiD;AACjD,sEAAqE;AACrE,sDAAqD;AAErD,yCAAsC;AAEtC,QAAQ,CAAC,YAAY,EAAE;IAErB,EAAE,CAAC,sDAAsD,EAAE,UAAC,IAAI;QAC9D,IAAM,QAAQ,GAAG,2MAWpB,CAAC;QACE,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAM,MAAM,GAAa,UAAC,OAAe,IAAa,MAAM,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QAClF,IAAM,EAAE,GAAG,IAAI,qBAAS,CAAC,MAAM,CAAC,CAAC;QACjC,IAAM,GAAG,GAAG,IAAI,yBAAW,CAAC,iBAAiB,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAClE,IAAM,GAAG,GAAG,IAAI,qBAAQ,EAAE,CAAC;QAC3B,IAAM,KAAK,GAAG,IAAI,6CAAqB,CAAC,GAAG,EAAE,GAAU,CAAC,CAAC;QACzD,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;YACnB,uCAAuC;YACvC,yBAAyB;YACzB,wBAAwB;YACxB,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YACnC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC,KAAK,CAAC,UAAC,GAAU;YAClB,IAAI,CAAC,GAAG,CAAC,CAAC;QACZ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@ -1,888 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var assert = require("assert");
|
||||
var moment = require("moment");
|
||||
var msRest = require("../lib/msRest");
|
||||
var should = require("should");
|
||||
var testClient_1 = require("./data/TestClient/lib/testClient");
|
||||
var mappers_1 = require("./data/TestClient/lib/models/mappers");
|
||||
var Serializer = new msRest.Serializer({});
|
||||
var valid_uuid = "ceaafd1e-f936-429f-bbfc-82ee75dddc33";
|
||||
describe("msrest", function () {
|
||||
describe("serializeObject", function () {
|
||||
it("should correctly serialize a Date Object", function (done) {
|
||||
var dateObj = new Date("2015-01-01");
|
||||
var dateISO = "2015-01-01T00:00:00.000Z";
|
||||
msRest.serializeObject(dateObj).should.equal(dateISO);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a Date object with max value", function (done) {
|
||||
var serializedDateString = msRest.serializeObject(new Date("9999-12-31T23:59:59-12:00"));
|
||||
serializedDateString.should.equal("+010000-01-01T11:59:59.000Z");
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a Buffer Object", function (done) {
|
||||
var bufferObj = new Buffer("Javascript");
|
||||
var base64str = "SmF2YXNjcmlwdA==";
|
||||
msRest.serializeObject(bufferObj).should.equal(base64str);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize Primitive types", function (done) {
|
||||
msRest.serializeObject(true).should.equal(true);
|
||||
msRest.serializeObject(false).should.equal(false);
|
||||
msRest.serializeObject("true").should.equal("true");
|
||||
msRest.serializeObject(1).should.equal(1);
|
||||
msRest.serializeObject(100.0123).should.equal(100.0123);
|
||||
assert.equal(msRest.serializeObject(null), null);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize an empty array and an empty dictionary", function (done) {
|
||||
assert.deepEqual(msRest.serializeObject([]), []);
|
||||
assert.deepEqual(msRest.serializeObject({}), {});
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a complex JSON object", function (done) {
|
||||
var o1 = {
|
||||
"p1": "value1",
|
||||
"p2": "value2",
|
||||
"top-buf": new Buffer("top string", "utf-8"),
|
||||
"top-date": new Date("2014"),
|
||||
"top-dates": [new Date("1900"), new Date("1901")],
|
||||
"insider": {
|
||||
"insider-buf": new Buffer("insider string", "utf-8"),
|
||||
"insider-date": new Date("2015"),
|
||||
"insider-dates": [new Date("2100"), new Date("2101")],
|
||||
"insider-dictionary": {
|
||||
"k1": new Date("2015"),
|
||||
"k2": new Date("2016"),
|
||||
"k3": new Date("2017")
|
||||
},
|
||||
"top-complex": {
|
||||
"id": 1,
|
||||
"name": "Joey",
|
||||
"age": 23.36,
|
||||
"male": true,
|
||||
"birthday": "1992-01-01T00:00:00.000Z",
|
||||
"anniversary": new Date("2013-12-08"),
|
||||
"memory": new Buffer("Yadadadada")
|
||||
}
|
||||
}
|
||||
};
|
||||
var o2 = {
|
||||
p1: "value1",
|
||||
p2: "value2",
|
||||
"top-buf": "dG9wIHN0cmluZw==",
|
||||
"top-date": "2014-01-01T00:00:00.000Z",
|
||||
"top-dates": [
|
||||
"1900-01-01T00:00:00.000Z",
|
||||
"1901-01-01T00:00:00.000Z"
|
||||
],
|
||||
insider: {
|
||||
"insider-buf": "aW5zaWRlciBzdHJpbmc=",
|
||||
"insider-date": "2015-01-01T00:00:00.000Z",
|
||||
"insider-dates": [
|
||||
"2100-01-01T00:00:00.000Z",
|
||||
"2101-01-01T00:00:00.000Z"
|
||||
],
|
||||
"insider-dictionary": {
|
||||
k1: "2015-01-01T00:00:00.000Z",
|
||||
k2: "2016-01-01T00:00:00.000Z",
|
||||
k3: "2017-01-01T00:00:00.000Z"
|
||||
},
|
||||
"top-complex": {
|
||||
id: 1,
|
||||
name: "Joey",
|
||||
age: 23.36,
|
||||
male: true,
|
||||
birthday: "1992-01-01T00:00:00.000Z",
|
||||
anniversary: "2013-12-08T00:00:00.000Z",
|
||||
memory: "WWFkYWRhZGFkYQ=="
|
||||
}
|
||||
}
|
||||
};
|
||||
assert.deepEqual(msRest.serializeObject(o1), o2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
describe("serialize", function () {
|
||||
var invalid_uuid = "abcd-efgd90-90890jkh";
|
||||
it("should correctly serialize a string if the type is 'any'", function (done) {
|
||||
var mapper = { type: { name: "any" }, required: false, serializedName: "any" };
|
||||
var serializedObject = Serializer.serialize(mapper, "foo", "anyBody");
|
||||
serializedObject.should.equal("foo");
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize an array if the type is 'any'", function (done) {
|
||||
var mapper = { type: { name: "any" }, required: false, serializedName: "any" };
|
||||
var serializedObject = Serializer.serialize(mapper, [1, 2], "anyBody");
|
||||
assert.deepEqual(serializedObject, [1, 2]);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a string", function (done) {
|
||||
var mapper = { type: { name: "String" }, required: false, serializedName: "string" };
|
||||
var serializedObject = Serializer.serialize(mapper, "foo", "stringBody");
|
||||
serializedObject.should.equal("foo");
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a uuid", function (done) {
|
||||
var mapper = { type: { name: "Uuid" }, required: false, serializedName: "Uuid" };
|
||||
var serializedObject = Serializer.serialize(mapper, valid_uuid, "uuidBody");
|
||||
serializedObject.should.equal(valid_uuid);
|
||||
done();
|
||||
});
|
||||
it("should throw an error if the value is not a valid Uuid", function (done) {
|
||||
var mapper = { type: { name: "Uuid" }, required: false, serializedName: "Uuid" };
|
||||
try {
|
||||
Serializer.serialize(mapper, invalid_uuid, "uuidBody");
|
||||
}
|
||||
catch (error) {
|
||||
error.message.should.match(/.*with value.*must be of type string and a valid uuid/ig);
|
||||
done();
|
||||
}
|
||||
});
|
||||
it("should correctly serialize a number", function (done) {
|
||||
var mapper = { type: { name: "Number" }, required: false, serializedName: "Number" };
|
||||
var serializedObject = Serializer.serialize(mapper, 1.506, "stringBody");
|
||||
serializedObject.should.equal(1.506);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a boolean", function (done) {
|
||||
var mapper = { type: { name: "Boolean" }, required: false, serializedName: "Boolean" };
|
||||
var serializedObject = Serializer.serialize(mapper, false, "stringBody");
|
||||
serializedObject.should.equal(false);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize an Enum", function (done) {
|
||||
var mapper = { type: { name: "Enum", allowedValues: [1, 2, 3, 4] }, required: false, serializedName: "Enum" };
|
||||
var serializedObject = Serializer.serialize(mapper, 1, "enumBody");
|
||||
serializedObject.should.equal(1);
|
||||
done();
|
||||
});
|
||||
it("should throw an error if the value is not valid for an Enum", function (done) {
|
||||
var mapper = { type: { name: "Enum", allowedValues: [1, 2, 3, 4] }, required: false, serializedName: "Enum" };
|
||||
try {
|
||||
Serializer.serialize(mapper, 6, "enumBody");
|
||||
}
|
||||
catch (error) {
|
||||
error.message.should.match(/6 is not a valid value for enumBody\. The valid values are: \[1,2,3,4\]/ig);
|
||||
done();
|
||||
}
|
||||
});
|
||||
it("should correctly serialize a Buffer Object", function (done) {
|
||||
var mapper = { type: { name: "ByteArray" }, required: false, serializedName: "ByteArray" };
|
||||
var bufferObj = new Buffer("Javascript");
|
||||
var base64str = "SmF2YXNjcmlwdA==";
|
||||
var serializedObject = Serializer.serialize(mapper, bufferObj, "stringBody");
|
||||
serializedObject.should.equal(base64str);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a Date Object", function (done) {
|
||||
var dateObj = new Date("2015-01-01");
|
||||
var dateISO = "2015-01-01";
|
||||
var mapper = { type: { name: "Date" }, required: false, serializedName: "Date" };
|
||||
Serializer.serialize(mapper, dateObj, "dateObj").should.equal(dateISO);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a Date object with max value", function (done) {
|
||||
var mapper = { type: { name: "DateTime" }, required: false, serializedName: "DateTime" };
|
||||
var serializedDateString = Serializer.serialize(mapper, new Date("9999-12-31T23:59:59-12:00"), "dateTimeObj");
|
||||
should.equal(serializedDateString, "+010000-01-01T11:59:59.000Z");
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a Date object with max value and format UnixTime", function (done) {
|
||||
var mapper = { type: { name: "UnixTime" }, required: false, serializedName: "UnixTime" };
|
||||
var serializedDate = Serializer.serialize(mapper, new Date("9999-12-31T23:59:59-12:00"), "dateTimeObj");
|
||||
serializedDate.should.equal(253402343999);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a string in DateTimeRfc1123", function (done) {
|
||||
var mapper = { type: { name: "DateTimeRfc1123" }, required: false, serializedName: "DateTimeRfc1123" };
|
||||
var rfc = new Date("Mon, 01 Jan 0001 00:00:00 GMT");
|
||||
var serializedDateString = Serializer.serialize(mapper, rfc, "dateTimeObj");
|
||||
serializedDateString.should.equal("Mon, 01 Jan 2001 00:00:00 GMT");
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a duration object", function (done) {
|
||||
var mapper = { type: { name: "TimeSpan" }, required: false, serializedName: "TimeSpan" };
|
||||
var duration = moment.duration({ days: 123, hours: 22, minutes: 14, seconds: 12, milliseconds: 11 });
|
||||
var serializedDateString = Serializer.serialize(mapper, duration, "dateTimeObj");
|
||||
if (serializedDateString !== "P123DT22H14M12.011S" && serializedDateString !== "P123DT22H14M12.010999999998603S") {
|
||||
done(new Error("serializedDateString: " + serializedDateString + " from moment is invalid."));
|
||||
}
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize an array of primitives", function (done) {
|
||||
var mapper = {
|
||||
required: false,
|
||||
serializedName: "Sequence",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
type: { name: "String" },
|
||||
required: true,
|
||||
serializedName: "sequenceElement"
|
||||
}
|
||||
}
|
||||
};
|
||||
var array = ["One", "Two", "three"];
|
||||
var serializedArray = Serializer.serialize(mapper, array, "arrayObj");
|
||||
assert.deepEqual(array, serializedArray);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize an array of array of primitives", function (done) {
|
||||
var mapper = {
|
||||
required: false,
|
||||
serializedName: "Sequence",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: true,
|
||||
serializedName: "sequenceElement",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: true,
|
||||
serializedName: "sequenceElement",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var array = [[1], [2], [1, 2, 3]];
|
||||
var serializedArray = Serializer.serialize(mapper, array, "arrayObj");
|
||||
assert.deepEqual(array, serializedArray);
|
||||
done();
|
||||
});
|
||||
it('should correctly serialize an array of array of object types', function (done) {
|
||||
var mapper = {
|
||||
serializedName: 'arrayObj',
|
||||
required: true,
|
||||
type: {
|
||||
name: 'Sequence',
|
||||
element: {
|
||||
type: {
|
||||
name: 'Sequence',
|
||||
element: {
|
||||
type: {
|
||||
name: 'Object'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var array = [[1], ['2'], [1, '2', {}, true, []]];
|
||||
var serializedArray = Serializer.serialize(mapper, array, mapper.serializedName);
|
||||
assert.deepEqual(array, serializedArray);
|
||||
done();
|
||||
});
|
||||
it('should fail while serializing an array of array of "object" types when a null value is provided', function (done) {
|
||||
var mapper = {
|
||||
serializedName: 'arrayObj',
|
||||
required: true,
|
||||
type: {
|
||||
name: 'Sequence',
|
||||
element: {
|
||||
type: {
|
||||
name: 'Sequence',
|
||||
element: {
|
||||
required: true,
|
||||
type: {
|
||||
name: 'Object'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var array = [[1], ['2'], [null], [1, '2', {}, true, []]];
|
||||
try {
|
||||
Serializer.serialize(mapper, array, mapper.serializedName);
|
||||
}
|
||||
catch (err) {
|
||||
assert.equal(err.message, 'arrayObj cannot be null or undefined.');
|
||||
}
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize an array of dictionary of primitives", function (done) {
|
||||
var mapper = {
|
||||
required: false,
|
||||
serializedName: "Sequence",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: true,
|
||||
serializedName: "sequenceElement",
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
required: true,
|
||||
serializedName: "valueElement",
|
||||
type: {
|
||||
name: "Boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var array = [{ 1: true }, { 2: false }, { 1: true, 2: false, 3: true }];
|
||||
var serializedArray = Serializer.serialize(mapper, array, "arrayObj");
|
||||
assert.deepEqual(array, serializedArray);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a dictionary of primitives", function (done) {
|
||||
var mapper = {
|
||||
required: false,
|
||||
serializedName: "Dictionary",
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
required: true,
|
||||
serializedName: "valueElement",
|
||||
type: {
|
||||
name: "String"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var dict = { 1: "One", 2: "Two", 3: "three" };
|
||||
var serializedDictionary = Serializer.serialize(mapper, dict, "dictObj");
|
||||
assert.deepEqual(dict, serializedDictionary);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a dictionary of array of primitives", function (done) {
|
||||
var mapper = {
|
||||
required: false,
|
||||
serializedName: "Dictionary",
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
required: true,
|
||||
serializedName: "valueElement",
|
||||
type: {
|
||||
name: "Sequence",
|
||||
element: {
|
||||
required: true,
|
||||
serializedName: "sequenceElement",
|
||||
type: {
|
||||
name: "Number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var dict = { "One": [1], "Two": [1, 2], "three": [1, 2, 3] };
|
||||
var serializedDictionary = Serializer.serialize(mapper, dict, "dictObj");
|
||||
assert.deepEqual(dict, serializedDictionary);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a dictionary of dictionary of primitives", function (done) {
|
||||
var mapper = {
|
||||
required: false,
|
||||
serializedName: "Dictionary",
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
required: true,
|
||||
serializedName: "valueElement",
|
||||
type: {
|
||||
name: "Dictionary",
|
||||
value: {
|
||||
required: true,
|
||||
serializedName: "valueElement",
|
||||
type: {
|
||||
name: "Boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var dict = { 1: { "One": true }, 2: { "Two": false }, 3: { "three": true } };
|
||||
var serializedDictionary = Serializer.serialize(mapper, dict, "dictObj");
|
||||
assert.deepEqual(dict, serializedDictionary);
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize a composite type", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.Product;
|
||||
var productObj = {
|
||||
id: 101,
|
||||
name: "TestProduct",
|
||||
provisioningState: "Succeeded",
|
||||
tags: {
|
||||
tag1: "value1",
|
||||
tag2: "value2"
|
||||
},
|
||||
dispatchTime: new Date("2015-01-01T12:35:36.009Z"),
|
||||
invoiceInfo: {
|
||||
invId: 1002,
|
||||
invDate: "2015-12-25",
|
||||
invProducts: [
|
||||
{
|
||||
"Product1": {
|
||||
id: 101,
|
||||
name: "TestProduct"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Product2": {
|
||||
id: 104,
|
||||
name: "TestProduct1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
subProducts: [
|
||||
{
|
||||
subId: 102,
|
||||
subName: "SubProduct1",
|
||||
makeTime: new Date("2015-12-21T01:01:01"),
|
||||
invoiceInfo: {
|
||||
invId: 1002,
|
||||
invDate: "2015-12-25"
|
||||
}
|
||||
},
|
||||
{
|
||||
subId: 103,
|
||||
subName: "SubProduct2",
|
||||
makeTime: new Date("2015-12-21T01:01:01"),
|
||||
invoiceInfo: {
|
||||
invId: 1003,
|
||||
invDate: "2015-12-25"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
var serializedProduct = client.serializer.serialize(mapper, productObj, "productObject");
|
||||
for (var prop in serializedProduct) {
|
||||
if (prop === "properties") {
|
||||
serializedProduct[prop].provisioningState.should.equal(productObj.provisioningState);
|
||||
}
|
||||
else if (prop === "id") {
|
||||
serializedProduct[prop].should.equal(productObj.id);
|
||||
}
|
||||
else if (prop === "name") {
|
||||
serializedProduct[prop].should.equal(productObj.name);
|
||||
}
|
||||
else if (prop === "tags") {
|
||||
JSON.stringify(serializedProduct[prop]).should.equal(JSON.stringify(productObj.tags));
|
||||
}
|
||||
else if (prop === "dispatchTime") {
|
||||
JSON.stringify(serializedProduct[prop]).should.equal(JSON.stringify(productObj.dispatchTime));
|
||||
}
|
||||
else if (prop === "invoiceInfo") {
|
||||
(JSON.stringify(serializedProduct[prop]).length - JSON.stringify(productObj.invoiceInfo).length).should.equal(4);
|
||||
}
|
||||
else if (prop === "subProducts") {
|
||||
(JSON.stringify(serializedProduct[prop]).length - JSON.stringify(productObj.subProducts).length).should.equal(8);
|
||||
}
|
||||
}
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize object version of polymorphic discriminator", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.SawShark;
|
||||
var sawshark = {
|
||||
"fishtype": "sawshark",
|
||||
"age": 22,
|
||||
"birthday": new Date("2012-01-05T01:00:00Z"),
|
||||
"species": "king",
|
||||
"length": 1.0,
|
||||
"picture": new Buffer([255, 255, 255, 255, 254]),
|
||||
"siblings": [
|
||||
{
|
||||
"fishtype": "shark",
|
||||
"age": 6,
|
||||
"birthday": new Date("2012-01-05T01:00:00Z"),
|
||||
"length": 20.0,
|
||||
"species": "predator"
|
||||
},
|
||||
{
|
||||
"fishtype": "sawshark",
|
||||
"age": 105,
|
||||
"birthday": new Date("1900-01-05T01:00:00Z"),
|
||||
"length": 10.0,
|
||||
"picture": new Buffer([255, 255, 255, 255, 254]),
|
||||
"species": "dangerous"
|
||||
}
|
||||
]
|
||||
};
|
||||
var serializedSawshark = client.serializer.serialize(mapper, sawshark, "result");
|
||||
serializedSawshark.age.should.equal(22);
|
||||
serializedSawshark["fish.type"].should.equal("sawshark");
|
||||
serializedSawshark.siblings.length.should.equal(2);
|
||||
serializedSawshark.siblings[0]["fish.type"].should.equal("shark");
|
||||
serializedSawshark.siblings[0].age.should.equal(6);
|
||||
serializedSawshark.siblings[0].birthday.should.equal(new Date("2012-01-05T01:00:00Z").toISOString());
|
||||
serializedSawshark.siblings[1]["fish.type"].should.equal("sawshark");
|
||||
serializedSawshark.siblings[1].age.should.equal(105);
|
||||
serializedSawshark.siblings[1].birthday.should.equal(new Date("1900-01-05T01:00:00Z").toISOString());
|
||||
serializedSawshark.siblings[1].picture.should.equal("//////4=");
|
||||
serializedSawshark.picture.should.equal("//////4=");
|
||||
done();
|
||||
});
|
||||
it("should correctly serialize string version of polymorphic discriminator", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.PetGallery;
|
||||
var petgallery = {
|
||||
"id": 1,
|
||||
"name": "Fav pet gallery",
|
||||
"pets": [
|
||||
{
|
||||
"id": 2,
|
||||
"name": "moti",
|
||||
"food": "buiscuit",
|
||||
"pet.type": "Dog",
|
||||
"pettype": "Dog"
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "billa",
|
||||
"color": "red",
|
||||
"pet.type": "Cat",
|
||||
"pettype": "Cat" // In string version the user has to pass the actual property with dot and the normalized one.
|
||||
}
|
||||
]
|
||||
};
|
||||
var serializedPetGallery = client.serializer.serialize(mapper, petgallery, "result");
|
||||
serializedPetGallery.id.should.equal(1);
|
||||
serializedPetGallery.name.should.equal("Fav pet gallery");
|
||||
serializedPetGallery.pets.length.should.equal(2);
|
||||
serializedPetGallery.pets[0]["pet.type"].should.equal("Dog");
|
||||
serializedPetGallery.pets[0].id.should.equal(2);
|
||||
serializedPetGallery.pets[0].name.should.equal("moti");
|
||||
serializedPetGallery.pets[0].food.should.equal("buiscuit");
|
||||
serializedPetGallery.pets[1]["pet.type"].should.equal("Cat");
|
||||
serializedPetGallery.pets[1].id.should.equal(3);
|
||||
serializedPetGallery.pets[1].name.should.equal("billa");
|
||||
serializedPetGallery.pets[1].color.should.equal("red");
|
||||
done();
|
||||
});
|
||||
});
|
||||
describe("deserialize", function () {
|
||||
it("should correctly deserialize a Date if the type is 'any'", function (done) {
|
||||
var mapper = { type: { name: "any" }, required: false, serializedName: "any" };
|
||||
var d = new Date();
|
||||
var deserializedObject = Serializer.deserialize(mapper, d, "anyResponseBody");
|
||||
deserializedObject.should.equal(d);
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize an array if the type is 'any'", function (done) {
|
||||
var mapper = { type: { name: "any" }, required: false, serializedName: "any" };
|
||||
var buf = Buffer.from("HelloWorld!");
|
||||
var deserializedObject = Serializer.deserialize(mapper, buf, "anyBody");
|
||||
deserializedObject.should.equal(buf);
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize a uuid", function (done) {
|
||||
var mapper = { type: { name: "Uuid" }, required: false, serializedName: "Uuid" };
|
||||
var serializedObject = Serializer.deserialize(mapper, valid_uuid, "uuidBody");
|
||||
serializedObject.should.equal(valid_uuid);
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize a composite type", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.Product;
|
||||
var responseBody = {
|
||||
id: 101,
|
||||
name: "TestProduct",
|
||||
properties: {
|
||||
provisioningState: "Succeeded"
|
||||
},
|
||||
tags: {
|
||||
tag1: "value1",
|
||||
tag2: "value2"
|
||||
},
|
||||
dispatchTime: new Date("2015-01-01T12:35:36.009Z"),
|
||||
invoiceInfo: {
|
||||
invoiceId: 1002,
|
||||
invDate: "2015-12-25",
|
||||
invProducts: [
|
||||
{
|
||||
"Product1": {
|
||||
id: 101,
|
||||
name: "TestProduct"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Product2": {
|
||||
id: 104,
|
||||
name: "TestProduct1"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
subProducts: [
|
||||
{
|
||||
subId: 102,
|
||||
subName: "SubProduct1",
|
||||
makeTime: new Date("2015-12-21T01:01:01"),
|
||||
invoiceInfo: {
|
||||
invoiceId: 1002,
|
||||
invDate: "2015-12-25"
|
||||
}
|
||||
},
|
||||
{
|
||||
subId: 103,
|
||||
subName: "SubProduct2",
|
||||
makeTime: new Date("2015-12-21T01:01:01"),
|
||||
invoiceInfo: {
|
||||
invoiceId: 1003,
|
||||
invDate: "2015-12-25"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
var deserializedProduct = client.serializer.deserialize(mapper, responseBody, "responseBody");
|
||||
for (var prop in deserializedProduct) {
|
||||
if (prop === "provisioningState") {
|
||||
deserializedProduct.provisioningState.should.equal(responseBody.properties.provisioningState);
|
||||
}
|
||||
else if (prop === "id") {
|
||||
deserializedProduct[prop].should.equal(responseBody.id);
|
||||
}
|
||||
else if (prop === "name") {
|
||||
deserializedProduct[prop].should.equal(responseBody.name);
|
||||
}
|
||||
else if (prop === "tags") {
|
||||
JSON.stringify(deserializedProduct[prop]).should.equal(JSON.stringify(responseBody.tags));
|
||||
}
|
||||
else if (prop === "dispatchTime") {
|
||||
JSON.stringify(deserializedProduct[prop]).should.equal(JSON.stringify(responseBody.dispatchTime));
|
||||
}
|
||||
else if (prop === "invoiceInfo") {
|
||||
(JSON.stringify(deserializedProduct[prop]).length - JSON.stringify(responseBody.invoiceInfo).length).should.equal(10);
|
||||
}
|
||||
else if (prop === "subProducts") {
|
||||
(JSON.stringify(deserializedProduct[prop]).length - JSON.stringify(responseBody.subProducts).length).should.equal(20);
|
||||
}
|
||||
}
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize a pageable type without nextLink", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.ProductListResult;
|
||||
var responseBody = {
|
||||
value: [
|
||||
{
|
||||
id: 101,
|
||||
name: "TestProduct",
|
||||
properties: {
|
||||
provisioningState: "Succeeded"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 104,
|
||||
name: "TestProduct1",
|
||||
properties: {
|
||||
provisioningState: "Failed"
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
var deserializedProduct = client.serializer.deserialize(mapper, responseBody, "responseBody");
|
||||
(Array.isArray(deserializedProduct)).should.be.true;
|
||||
deserializedProduct.length.should.equal(2);
|
||||
for (var i = 0; i < deserializedProduct.length; i++) {
|
||||
if (i === 0) {
|
||||
deserializedProduct[i].id.should.equal(101);
|
||||
deserializedProduct[i].name.should.equal("TestProduct");
|
||||
deserializedProduct[i].provisioningState.should.equal("Succeeded");
|
||||
}
|
||||
else if (i === 1) {
|
||||
deserializedProduct[i].id.should.equal(104);
|
||||
deserializedProduct[i].name.should.equal("TestProduct1");
|
||||
deserializedProduct[i].provisioningState.should.equal("Failed");
|
||||
}
|
||||
}
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize a pageable type with nextLink", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.ProductListResultNextLink;
|
||||
var responseBody = {
|
||||
value: [
|
||||
{
|
||||
id: 101,
|
||||
name: "TestProduct",
|
||||
properties: {
|
||||
provisioningState: "Succeeded"
|
||||
}
|
||||
},
|
||||
{
|
||||
id: 104,
|
||||
name: "TestProduct1",
|
||||
properties: {
|
||||
provisioningState: "Failed"
|
||||
}
|
||||
}
|
||||
],
|
||||
nextLink: "https://helloworld.com"
|
||||
};
|
||||
var deserializedProduct = client.serializer.deserialize(mapper, responseBody, "responseBody");
|
||||
(Array.isArray(deserializedProduct)).should.be.true;
|
||||
deserializedProduct.length.should.equal(2);
|
||||
deserializedProduct.nextLink.should.equal("https://helloworld.com");
|
||||
for (var i = 0; i < deserializedProduct.length; i++) {
|
||||
if (i === 0) {
|
||||
deserializedProduct[i].id.should.equal(101);
|
||||
deserializedProduct[i].name.should.equal("TestProduct");
|
||||
deserializedProduct[i].provisioningState.should.equal("Succeeded");
|
||||
}
|
||||
else if (i === 1) {
|
||||
deserializedProduct[i].id.should.equal(104);
|
||||
deserializedProduct[i].name.should.equal("TestProduct1");
|
||||
deserializedProduct[i].provisioningState.should.equal("Failed");
|
||||
}
|
||||
}
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize object version of polymorphic discriminator", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.Fish;
|
||||
var responseBody = {
|
||||
"fish.type": "sawshark",
|
||||
"age": 22,
|
||||
"birthday": new Date("2012-01-05T01:00:00Z").toISOString(),
|
||||
"species": "king",
|
||||
"length": 1.0,
|
||||
"picture": new Buffer([255, 255, 255, 255, 254]).toString(),
|
||||
"siblings": [
|
||||
{
|
||||
"fish.type": "shark",
|
||||
"age": 6,
|
||||
"birthday": new Date("2012-01-05T01:00:00Z"),
|
||||
"length": 20.0,
|
||||
"species": "predator"
|
||||
},
|
||||
{
|
||||
"fish.type": "sawshark",
|
||||
"age": 105,
|
||||
"birthday": new Date("1900-01-05T01:00:00Z").toISOString(),
|
||||
"length": 10.0,
|
||||
"picture": new Buffer([255, 255, 255, 255, 254]).toString(),
|
||||
"species": "dangerous"
|
||||
}
|
||||
]
|
||||
};
|
||||
var deserializedSawshark = client.serializer.deserialize(mapper, responseBody, "responseBody");
|
||||
deserializedSawshark.age.should.equal(22);
|
||||
deserializedSawshark.fishtype.should.equal("sawshark");
|
||||
deserializedSawshark.siblings.length.should.equal(2);
|
||||
deserializedSawshark.siblings[0].fishtype.should.equal("shark");
|
||||
deserializedSawshark.siblings[0].age.should.equal(6);
|
||||
deserializedSawshark.siblings[0].birthday.toISOString().should.equal("2012-01-05T01:00:00.000Z");
|
||||
deserializedSawshark.siblings[1].fishtype.should.equal("sawshark");
|
||||
deserializedSawshark.siblings[1].age.should.equal(105);
|
||||
deserializedSawshark.siblings[1].birthday.toISOString().should.equal("1900-01-05T01:00:00.000Z");
|
||||
done();
|
||||
});
|
||||
it("should correctly deserialize string version of polymorphic discriminator", function (done) {
|
||||
var client = new testClient_1.TestClient("http://localhost:9090");
|
||||
var mapper = mappers_1.Mappers.PetGallery;
|
||||
var petgallery = {
|
||||
"id": 1,
|
||||
"name": "Fav pet gallery",
|
||||
"pets": [
|
||||
{
|
||||
"id": 2,
|
||||
"name": "moti",
|
||||
"food": "buiscuit",
|
||||
"pet.type": "Dog",
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name": "billa",
|
||||
"color": "red",
|
||||
"pet.type": "Cat",
|
||||
}
|
||||
]
|
||||
};
|
||||
var deserializedPetGallery = client.serializer.deserialize(mapper, petgallery, "result");
|
||||
deserializedPetGallery.id.should.equal(1);
|
||||
deserializedPetGallery.name.should.equal("Fav pet gallery");
|
||||
deserializedPetGallery.pets.length.should.equal(2);
|
||||
deserializedPetGallery.pets[0]["pettype"].should.equal("Dog");
|
||||
deserializedPetGallery.pets[0].id.should.equal(2);
|
||||
deserializedPetGallery.pets[0].name.should.equal("moti");
|
||||
deserializedPetGallery.pets[0].food.should.equal("buiscuit");
|
||||
deserializedPetGallery.pets[1]["pettype"].should.equal("Cat");
|
||||
deserializedPetGallery.pets[1].id.should.equal(3);
|
||||
deserializedPetGallery.pets[1].name.should.equal("billa");
|
||||
deserializedPetGallery.pets[1].color.should.equal("red");
|
||||
done();
|
||||
});
|
||||
it('should correctly deserialize an array of array of object types', function (done) {
|
||||
var mapper = {
|
||||
serializedName: 'arrayObj',
|
||||
required: true,
|
||||
type: {
|
||||
name: 'Sequence',
|
||||
element: {
|
||||
type: {
|
||||
name: 'Sequence',
|
||||
element: {
|
||||
type: {
|
||||
name: 'Object'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var array = [[1], ["2"], [1, "2", {}, true, []]];
|
||||
var deserializedArray = Serializer.deserialize(mapper, array, mapper.serializedName);
|
||||
assert.deepEqual(array, deserializedArray);
|
||||
done();
|
||||
});
|
||||
it('should correctly deserialize without failing when encountering unrecognized discriminator', function (done) {
|
||||
var client = new testClient_1.TestClient('http://localhost:9090');
|
||||
var mapper = mappers_1.Mappers.Fish;
|
||||
var responseBody = {
|
||||
'fish.type': 'sawshark',
|
||||
'age': 22,
|
||||
'birthday': new Date('2012-01-05T01:00:00Z').toISOString(),
|
||||
'species': 'king',
|
||||
'length': 1.0,
|
||||
'picture': new Buffer([255, 255, 255, 255, 254]).toString(),
|
||||
'siblings': [
|
||||
{
|
||||
'fish.type': 'mutatedshark',
|
||||
'age': 105,
|
||||
'birthday': new Date('1900-01-05T01:00:00Z').toISOString(),
|
||||
'length': 10.0,
|
||||
'picture': new Buffer([255, 255, 255, 255, 254]).toString(),
|
||||
'species': 'dangerous',
|
||||
'siblings': [
|
||||
{
|
||||
'fish.type': 'mutatedshark',
|
||||
'age': 6,
|
||||
'length': 20.0,
|
||||
'species': 'predator'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
var deserializedSawshark = client.serializer.deserialize(mapper, responseBody, 'responseBody');
|
||||
deserializedSawshark.siblings.length.should.equal(1);
|
||||
deserializedSawshark.siblings[0].fishtype.should.equal('mutatedshark');
|
||||
deserializedSawshark.siblings[0].species.should.equal('dangerous');
|
||||
deserializedSawshark.siblings[0].should.not.have.property('birthday');
|
||||
deserializedSawshark.siblings[0].should.not.have.property('age');
|
||||
deserializedSawshark.siblings[0].siblings[0].fishtype.should.equal('mutatedshark');
|
||||
deserializedSawshark.siblings[0].siblings[0].species.should.equal('predator');
|
||||
deserializedSawshark.siblings[0].siblings[0].should.not.have.property('age');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=serializationTests.js.map
|
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
|
@ -1,65 +0,0 @@
|
|||
"use strict";
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var assert = require("assert");
|
||||
var webResource_1 = require("../lib/webResource");
|
||||
var msRestUserAgentFilter_1 = require("../lib/filters/msRestUserAgentFilter");
|
||||
var constants_1 = require("../lib/util/constants");
|
||||
var should = require("should");
|
||||
var userAgentHeader = constants_1.Constants.HeaderConstants.USER_AGENT;
|
||||
describe("ms-rest user agent filter", function () {
|
||||
it("should construct user agent header when supplied empty array", function (done) {
|
||||
var userAgentArray = [];
|
||||
var userAgentFilter = new msRestUserAgentFilter_1.MsRestUserAgentFilter(userAgentArray);
|
||||
var resource = new webResource_1.WebResource();
|
||||
resource.headers = {};
|
||||
userAgentFilter.before(resource).then(function (resource) {
|
||||
should.ok(resource);
|
||||
resource.headers[userAgentHeader].should.containEql("Node");
|
||||
resource.headers[userAgentHeader].should.containEql("Azure-SDK-For-Node");
|
||||
done();
|
||||
}).catch(function (err) { done(err); });
|
||||
});
|
||||
it("should not modify user agent header if already present", function (done) {
|
||||
var genericRuntime = "ms-rest";
|
||||
var azureRuntime = "ms-rest-azure";
|
||||
var azureSDK = "Azure-SDK-For-Node";
|
||||
var userAgentArray = [genericRuntime + "/v1.0.0", azureRuntime + "/v1.0.0"];
|
||||
var userAgentFilter = new msRestUserAgentFilter_1.MsRestUserAgentFilter(userAgentArray);
|
||||
var customUA = "my custom user agent";
|
||||
var resource = new webResource_1.WebResource();
|
||||
resource.headers = {};
|
||||
resource.headers[userAgentHeader] = customUA;
|
||||
userAgentFilter.before(resource).then(function (resource) {
|
||||
should.ok(resource);
|
||||
var actualUA = resource.headers[userAgentHeader];
|
||||
actualUA.should.not.containEql("Node");
|
||||
actualUA.should.not.containEql(azureSDK);
|
||||
actualUA.should.not.containEql(azureRuntime);
|
||||
actualUA.should.containEql(customUA);
|
||||
done();
|
||||
}).catch(function (err) { done(err); });
|
||||
});
|
||||
it("should insert azure-sdk-for-node at right position", function (done) {
|
||||
var genericRuntime = "ms-rest";
|
||||
var azureRuntime = "ms-rest-azure";
|
||||
var azureSDK = "Azure-SDK-For-Node";
|
||||
var userAgentArray = [genericRuntime + "/v1.0.0", azureRuntime + "/v1.0.0"];
|
||||
var userAgentFilter = new msRestUserAgentFilter_1.MsRestUserAgentFilter(userAgentArray);
|
||||
var resource = new webResource_1.WebResource();
|
||||
resource.headers = {};
|
||||
userAgentFilter.before(resource).then(function (resource) {
|
||||
should.ok(resource);
|
||||
var deconstructedUserAgent = resource.headers[userAgentHeader].split(" ");
|
||||
should.ok(deconstructedUserAgent);
|
||||
var indexOfAzureRuntime = deconstructedUserAgent.findIndex(function (e) { return e.startsWith(azureRuntime); });
|
||||
assert.notEqual(indexOfAzureRuntime, -1, "did not find " + azureRuntime + " in user agent");
|
||||
var indexOfAzureSDK = deconstructedUserAgent.indexOf(azureSDK);
|
||||
assert.notEqual(indexOfAzureSDK, -1, "did not find " + azureSDK + " in user agent");
|
||||
assert.equal(indexOfAzureSDK, 1 + indexOfAzureRuntime, azureSDK + " is not in the right place in user agent string");
|
||||
done();
|
||||
}).catch(function (err) { done(err); });
|
||||
});
|
||||
});
|
||||
//# sourceMappingURL=userAgentFilterTests.js.map
|
|
@ -1 +0,0 @@
|
|||
{"version":3,"file":"userAgentFilterTests.js","sourceRoot":"","sources":["../../test/userAgentFilterTests.ts"],"names":[],"mappings":"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"}
|
30
gulpfile.js
30
gulpfile.js
|
@ -1,30 +0,0 @@
|
|||
var gulp = require("gulp"),
|
||||
tslint = require("gulp-tslint"),
|
||||
tsc = require("gulp-typescript"),
|
||||
sourcemaps = require("gulp-sourcemaps"),
|
||||
runSequence = require("run-sequence"),
|
||||
mocha = require("gulp-mocha");
|
||||
|
||||
gulp.task('default', function () {
|
||||
console.log("run gulp -T to see all available tasks.\n");
|
||||
});
|
||||
|
||||
gulp.task("lint", () =>
|
||||
gulp.src([
|
||||
"lib/**/**.ts",
|
||||
"test/**/**.ts"
|
||||
])
|
||||
.pipe(tslint({
|
||||
formatter: "verbose"
|
||||
}))
|
||||
.pipe(tslint.report())
|
||||
);
|
||||
|
||||
// TODO: Doesn't yet confirm to folder structure
|
||||
gulp.task("build", () =>
|
||||
gulp.src([
|
||||
"lib/**/**.ts"
|
||||
])
|
||||
.pipe(tsc(tsc.createProject("tsconfig.json")))
|
||||
.js.pipe(gulp.dest("dist/lib/"))
|
||||
);
|
|
@ -45,6 +45,21 @@
|
|||
"integrity": "sha1-4rRgJDaF2+N3GC857zjTf00Veto=",
|
||||
"dev": true
|
||||
},
|
||||
"@types/tapable": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/tapable/-/tapable-1.0.1.tgz",
|
||||
"integrity": "sha512-zRc13uGALq6rmLOYmpdI8X5TK6ATuf9jITC7iKTxaHqb/se7vBdiC8BEp1vM2VJQVSt3N53kDDzJOYeVkUKO/Q==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/uglify-js": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/uglify-js/-/uglify-js-3.0.2.tgz",
|
||||
"integrity": "sha512-o8hU2+4xsyGC27Vujoklvxl88Ew5zmJuTBYMX1Uro2rYUt4HEFJKL6fuq8aGykvS+ssIsIzerWWP2DRxonownQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"source-map": "0.6.1"
|
||||
}
|
||||
},
|
||||
"@types/url-parse": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/url-parse/-/url-parse-1.1.0.tgz",
|
||||
|
@ -68,6 +83,18 @@
|
|||
"@types/node": "9.6.2"
|
||||
}
|
||||
},
|
||||
"@types/webpack": {
|
||||
"version": "4.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/webpack/-/webpack-4.1.3.tgz",
|
||||
"integrity": "sha512-NoGVTCumOsyFfuy3934f3ktiJi+wcXHJFxT47tby3iCpuo6M/WjFA9VqT5bYO+FE46i3R0N00RpJX75HxHKDaQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "9.6.2",
|
||||
"@types/tapable": "1.0.1",
|
||||
"@types/uglify-js": "3.0.2",
|
||||
"source-map": "0.6.1"
|
||||
}
|
||||
},
|
||||
"@types/xml2js": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/xml2js/-/xml2js-0.4.2.tgz",
|
||||
|
@ -181,6 +208,24 @@
|
|||
"integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=",
|
||||
"dev": true
|
||||
},
|
||||
"array-filter": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz",
|
||||
"integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw=",
|
||||
"dev": true
|
||||
},
|
||||
"array-map": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz",
|
||||
"integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI=",
|
||||
"dev": true
|
||||
},
|
||||
"array-reduce": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz",
|
||||
"integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=",
|
||||
"dev": true
|
||||
},
|
||||
"array-unique": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz",
|
||||
|
@ -838,6 +883,16 @@
|
|||
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=",
|
||||
"dev": true
|
||||
},
|
||||
"define-properties": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
|
||||
"integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"foreach": "2.0.5",
|
||||
"object-keys": "1.0.11"
|
||||
}
|
||||
},
|
||||
"define-property": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
|
||||
|
@ -923,6 +978,12 @@
|
|||
"integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==",
|
||||
"dev": true
|
||||
},
|
||||
"duplexer": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
|
||||
"integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=",
|
||||
"dev": true
|
||||
},
|
||||
"elliptic": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.0.tgz",
|
||||
|
@ -982,6 +1043,30 @@
|
|||
"is-arrayish": "0.2.1"
|
||||
}
|
||||
},
|
||||
"es-abstract": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.11.0.tgz",
|
||||
"integrity": "sha512-ZnQrE/lXTTQ39ulXZ+J1DTFazV9qBy61x2bY071B+qGco8Z8q1QddsLdt/EF8Ai9hcWH72dWS0kFqXLxOxqslA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es-to-primitive": "1.1.1",
|
||||
"function-bind": "1.1.1",
|
||||
"has": "1.0.1",
|
||||
"is-callable": "1.1.3",
|
||||
"is-regex": "1.0.4"
|
||||
}
|
||||
},
|
||||
"es-to-primitive": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz",
|
||||
"integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-callable": "1.1.3",
|
||||
"is-date-object": "1.0.1",
|
||||
"is-symbol": "1.0.1"
|
||||
}
|
||||
},
|
||||
"es5-ext": {
|
||||
"version": "0.10.42",
|
||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.42.tgz",
|
||||
|
@ -1113,6 +1198,21 @@
|
|||
"es5-ext": "0.10.42"
|
||||
}
|
||||
},
|
||||
"event-stream": {
|
||||
"version": "3.3.4",
|
||||
"resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz",
|
||||
"integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"duplexer": "0.1.1",
|
||||
"from": "0.1.7",
|
||||
"map-stream": "0.1.0",
|
||||
"pause-stream": "0.0.11",
|
||||
"split": "0.3.3",
|
||||
"stream-combiner": "0.0.4",
|
||||
"through": "2.3.8"
|
||||
}
|
||||
},
|
||||
"events": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz",
|
||||
|
@ -1348,6 +1448,12 @@
|
|||
"integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=",
|
||||
"dev": true
|
||||
},
|
||||
"foreach": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
|
||||
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
|
||||
"dev": true
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
|
||||
|
@ -1367,6 +1473,12 @@
|
|||
"map-cache": "0.2.2"
|
||||
}
|
||||
},
|
||||
"from": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz",
|
||||
"integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=",
|
||||
"dev": true
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
|
@ -2277,6 +2389,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
||||
"dev": true
|
||||
},
|
||||
"get-caller-file": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.2.tgz",
|
||||
|
@ -2348,6 +2466,15 @@
|
|||
"integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=",
|
||||
"dev": true
|
||||
},
|
||||
"has": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz",
|
||||
"integrity": "sha1-hGFzP1OLCDfJNh45qauelwTcLyg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "1.1.1"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
|
@ -2535,6 +2662,12 @@
|
|||
"builtin-modules": "1.1.1"
|
||||
}
|
||||
},
|
||||
"is-callable": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz",
|
||||
"integrity": "sha1-hut1OSgF3cM69xySoO7fdO52BLI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-data-descriptor": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
|
||||
|
@ -2544,6 +2677,12 @@
|
|||
"kind-of": "3.2.2"
|
||||
}
|
||||
},
|
||||
"is-date-object": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
|
||||
"dev": true
|
||||
},
|
||||
"is-descriptor": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
|
||||
|
@ -2628,11 +2767,26 @@
|
|||
"isobject": "3.0.1"
|
||||
}
|
||||
},
|
||||
"is-regex": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has": "1.0.1"
|
||||
}
|
||||
},
|
||||
"is-stream": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz",
|
||||
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ="
|
||||
},
|
||||
"is-symbol": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
|
||||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-windows": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
|
||||
|
@ -2679,6 +2833,12 @@
|
|||
"integrity": "sha512-QLPs8Dj7lnf3e3QYS1zkCo+4ZwqOiF9d/nZnYozTISxXWCfNs9yuky5rJw4/W34s7POaNlbZmQGaB5NiXCbP4w==",
|
||||
"dev": true
|
||||
},
|
||||
"json-parse-better-errors": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
|
||||
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
|
||||
"dev": true
|
||||
},
|
||||
"json-schema-traverse": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz",
|
||||
|
@ -2697,6 +2857,12 @@
|
|||
"integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=",
|
||||
"dev": true
|
||||
},
|
||||
"jsonify": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
|
||||
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=",
|
||||
"dev": true
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
|
||||
|
@ -2870,6 +3036,12 @@
|
|||
"integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=",
|
||||
"dev": true
|
||||
},
|
||||
"map-stream": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.1.0.tgz",
|
||||
"integrity": "sha1-5WqpTEyAVaFkBKBnS3jyFffI4ZQ=",
|
||||
"dev": true
|
||||
},
|
||||
"map-visit": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz",
|
||||
|
@ -2920,6 +3092,12 @@
|
|||
"readable-stream": "2.3.6"
|
||||
}
|
||||
},
|
||||
"memorystream": {
|
||||
"version": "0.3.1",
|
||||
"resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz",
|
||||
"integrity": "sha1-htcJCzDORV1j+64S3aUaR93K+bI=",
|
||||
"dev": true
|
||||
},
|
||||
"micromatch": {
|
||||
"version": "3.1.10",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz",
|
||||
|
@ -3174,6 +3352,73 @@
|
|||
"remove-trailing-separator": "1.1.0"
|
||||
}
|
||||
},
|
||||
"npm-run-all": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.2.tgz",
|
||||
"integrity": "sha512-Z2aRlajMK4SQ8u19ZA75NZZu7wupfCNQWdYosIi8S6FgBdGf/8Y6Hgyjdc8zU2cYmIRVCx1nM80tJPkdEd+UYg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-styles": "3.2.1",
|
||||
"chalk": "2.3.2",
|
||||
"cross-spawn": "5.1.0",
|
||||
"memorystream": "0.3.1",
|
||||
"minimatch": "3.0.4",
|
||||
"ps-tree": "1.1.0",
|
||||
"read-pkg": "3.0.0",
|
||||
"shell-quote": "1.6.1",
|
||||
"string.prototype.padend": "3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"load-json-file": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
|
||||
"integrity": "sha1-L19Fq5HjMhYjT9U62rZo607AmTs=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11",
|
||||
"parse-json": "4.0.0",
|
||||
"pify": "3.0.0",
|
||||
"strip-bom": "3.0.0"
|
||||
}
|
||||
},
|
||||
"parse-json": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz",
|
||||
"integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"error-ex": "1.3.1",
|
||||
"json-parse-better-errors": "1.0.2"
|
||||
}
|
||||
},
|
||||
"path-type": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz",
|
||||
"integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"pify": "3.0.0"
|
||||
}
|
||||
},
|
||||
"pify": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
|
||||
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
|
||||
"dev": true
|
||||
},
|
||||
"read-pkg": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz",
|
||||
"integrity": "sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"load-json-file": "4.0.0",
|
||||
"normalize-package-data": "2.4.0",
|
||||
"path-type": "3.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"npm-run-path": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz",
|
||||
|
@ -3217,6 +3462,12 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"object-keys": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.11.tgz",
|
||||
"integrity": "sha1-xUYBd4rVYPEULODgG8yotW0TQm0=",
|
||||
"dev": true
|
||||
},
|
||||
"object-visit": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
|
||||
|
@ -3370,6 +3621,15 @@
|
|||
"pify": "2.3.0"
|
||||
}
|
||||
},
|
||||
"pause-stream": {
|
||||
"version": "0.0.11",
|
||||
"resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz",
|
||||
"integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"through": "2.3.8"
|
||||
}
|
||||
},
|
||||
"pbkdf2": {
|
||||
"version": "3.0.14",
|
||||
"resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.14.tgz",
|
||||
|
@ -3413,6 +3673,15 @@
|
|||
"integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=",
|
||||
"dev": true
|
||||
},
|
||||
"ps-tree": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ps-tree/-/ps-tree-1.1.0.tgz",
|
||||
"integrity": "sha1-tCGyQUDWID8e08dplrRCewjowBQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"event-stream": "3.3.4"
|
||||
}
|
||||
},
|
||||
"pseudomap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
||||
|
@ -3703,6 +3972,18 @@
|
|||
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
|
||||
"dev": true
|
||||
},
|
||||
"shell-quote": {
|
||||
"version": "1.6.1",
|
||||
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz",
|
||||
"integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"array-filter": "0.0.1",
|
||||
"array-map": "0.0.0",
|
||||
"array-reduce": "0.0.0",
|
||||
"jsonify": "0.0.0"
|
||||
}
|
||||
},
|
||||
"should": {
|
||||
"version": "5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/should/-/should-5.2.0.tgz",
|
||||
|
@ -3884,14 +4165,6 @@
|
|||
"dev": true,
|
||||
"requires": {
|
||||
"source-map": "0.6.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"source-map-url": {
|
||||
|
@ -3932,6 +4205,15 @@
|
|||
"integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==",
|
||||
"dev": true
|
||||
},
|
||||
"split": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/split/-/split-0.3.3.tgz",
|
||||
"integrity": "sha1-zQ7qXmOiEd//frDwkcQTPi0N0o8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"through": "2.3.8"
|
||||
}
|
||||
},
|
||||
"split-string": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz",
|
||||
|
@ -3978,6 +4260,15 @@
|
|||
"readable-stream": "2.3.6"
|
||||
}
|
||||
},
|
||||
"stream-combiner": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.0.4.tgz",
|
||||
"integrity": "sha1-TV5DPBhSYd3mI8o/RMWGvPXErRQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"duplexer": "0.1.1"
|
||||
}
|
||||
},
|
||||
"stream-http": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.1.tgz",
|
||||
|
@ -4024,6 +4315,17 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"string.prototype.padend": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.0.0.tgz",
|
||||
"integrity": "sha1-86rvfBcZ8XDF6rHDK/eA2W4h8vA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "1.1.2",
|
||||
"es-abstract": "1.11.0",
|
||||
"function-bind": "1.1.1"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
|
@ -4069,6 +4371,12 @@
|
|||
"integrity": "sha1-mTcqXJmb8t8WCvwNdL7U9HlIzSI=",
|
||||
"dev": true
|
||||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
"integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=",
|
||||
"dev": true
|
||||
},
|
||||
"timers-browserify": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.6.tgz",
|
||||
|
|
16
package.json
16
package.json
|
@ -48,8 +48,10 @@
|
|||
"@types/mocha": "^2.2.40",
|
||||
"@types/should": "^8.1.30",
|
||||
"@types/url-parse": "^1.1.0",
|
||||
"@types/webpack": "^4.1.3",
|
||||
"@types/xml2js": "^0.4.2",
|
||||
"mocha": "^3.5.3",
|
||||
"npm-run-all": "^4.1.2",
|
||||
"should": "5.2.0",
|
||||
"ts-loader": "^2.3.7",
|
||||
"ts-node": "^5.0.1",
|
||||
|
@ -67,10 +69,14 @@
|
|||
"url": "http://github.com/Azure/ms-rest-js/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"tsc": "tsc -p tsconfig.json",
|
||||
"test": "mocha -r ts-node/register -t 50000 ./test/**/*.ts",
|
||||
"uglify": "node node_modules/uglify-es/bin/uglifyjs --source-map -c -m -o msRestBundle.min.js msRestBundle.js",
|
||||
"build": "npm run tsc && npm run tslint && webpack && npm run uglify",
|
||||
"tslint": "tslint -p . -c tslint.json --exclude test/**/*.ts"
|
||||
"build": "run-p build:node build:browser",
|
||||
"build:node": "tsc",
|
||||
"build:browser": "webpack && node node_modules/uglify-es/bin/uglifyjs --source-map -c -m -o msRestBundle.min.js msRestBundle.js",
|
||||
"watch:node": "tsc -w",
|
||||
"watch:browser": "webpack -w",
|
||||
"test": "run-p test:tslint test:unit",
|
||||
"test:unit": "mocha",
|
||||
"test:tslint": "tslint -p . -c tslint.json --exclude test/**/*.ts",
|
||||
"prepare": "npm run build"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
--require ts-node/register
|
||||
--timeout 50000
|
||||
--reporter list
|
||||
--colors
|
||||
test/**/*.ts
|
|
@ -1,21 +1,16 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"alwaysStrict": true,
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"preserveConstEnums": true,
|
||||
"sourceMap": true,
|
||||
"newLine": "LF",
|
||||
"target": "es5",
|
||||
"moduleResolution": "node",
|
||||
"noImplicitReturns": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"outDir": "dist",
|
||||
"allowJs": false,
|
||||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"declaration": true,
|
||||
"declarationDir": "./typings",
|
||||
"lib": [
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
import { WebResource } from "../webResource";
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
export declare class BaseFilter {
|
||||
constructor();
|
||||
before(request: WebResource): Promise<WebResource>;
|
||||
after(response: HttpOperationResponse): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
export interface RetryData {
|
||||
retryCount: number;
|
||||
retryInterval: number;
|
||||
error?: RetryError;
|
||||
}
|
||||
export interface RetryError extends Error {
|
||||
message: string;
|
||||
code?: string;
|
||||
innerError?: RetryError;
|
||||
}
|
||||
/**
|
||||
* @class
|
||||
* Instantiates a new "ExponentialRetryPolicyFilter" instance.
|
||||
*
|
||||
* @constructor
|
||||
* @param {number} retryCount The client retry count.
|
||||
* @param {number} retryInterval The client retry interval, in milliseconds.
|
||||
* @param {number} minRetryInterval The minimum retry interval, in milliseconds.
|
||||
* @param {number} maxRetryInterval The maximum retry interval, in milliseconds.
|
||||
*/
|
||||
export declare class ExponentialRetryPolicyFilter extends BaseFilter {
|
||||
retryCount: number;
|
||||
retryInterval: number;
|
||||
minRetryInterval: number;
|
||||
maxRetryInterval: number;
|
||||
DEFAULT_CLIENT_RETRY_INTERVAL: number;
|
||||
DEFAULT_CLIENT_RETRY_COUNT: number;
|
||||
DEFAULT_CLIENT_MAX_RETRY_INTERVAL: number;
|
||||
DEFAULT_CLIENT_MIN_RETRY_INTERVAL: number;
|
||||
constructor(retryCount?: number, retryInterval?: number, minRetryInterval?: number, maxRetryInterval?: number);
|
||||
/**
|
||||
* Determines if the operation should be retried and how long to wait until the next retry.
|
||||
*
|
||||
* @param {number} statusCode The HTTP status code.
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @return {boolean} True if the operation qualifies for a retry; false otherwise.
|
||||
*/
|
||||
shouldRetry(statusCode: number, retryData: RetryData): boolean;
|
||||
/**
|
||||
* Updates the retry data for the next attempt.
|
||||
*
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @param {object} err The operation"s error, if any.
|
||||
*/
|
||||
updateRetryData(retryData?: RetryData, err?: RetryError): RetryData;
|
||||
retry(operationResponse: HttpOperationResponse, retryData?: RetryData, err?: RetryError): Promise<HttpOperationResponse>;
|
||||
after(operationResponse: HttpOperationResponse): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
export declare class LogFilter extends BaseFilter {
|
||||
logger?: any;
|
||||
constructor(logger?: any);
|
||||
after(operationResponse: HttpOperationResponse): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { WebResource } from "../webResource";
|
||||
export declare class MsRestUserAgentFilter extends BaseFilter {
|
||||
userAgentInfo: Array<string>;
|
||||
constructor(userAgentInfo: Array<string>);
|
||||
tagRequest(request: WebResource): Promise<WebResource>;
|
||||
before(request: WebResource): Promise<WebResource>;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
export declare class RedirectFilter extends BaseFilter {
|
||||
maximumRetries?: number;
|
||||
constructor(maximumRetries?: number);
|
||||
handleRedirect(operationResponse: HttpOperationResponse, currentRetries: number): Promise<HttpOperationResponse>;
|
||||
after(operationResponse: HttpOperationResponse): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
import { WebResource } from "../webResource";
|
||||
export declare class RPRegistrationFilter extends BaseFilter {
|
||||
constructor(retryTimeout?: number);
|
||||
after(operationResponse: HttpOperationResponse): Promise<HttpOperationResponse>;
|
||||
/**
|
||||
* Reuses the headers of the original request and url (if specified).
|
||||
* @param {WebResource} originalRequest The original request
|
||||
* @param {boolean} reuseUrlToo Should the url from the original request be reused as well. Default false.
|
||||
* @returns {object} reqOptions - A new request object with desired headers.
|
||||
*/
|
||||
getRequestEssentials(originalRequest: WebResource, reuseUrlToo?: boolean): any;
|
||||
/**
|
||||
* Validates the error code and message associated with 409 response status code. If it matches to that of
|
||||
* RP not registered then it returns the name of the RP else returns undefined.
|
||||
* @param {string} body - The response body received after making the original request.
|
||||
* @returns {string} result The name of the RP if condition is satisfied else undefined.
|
||||
*/
|
||||
checkRPNotRegisteredError(body: string): string;
|
||||
/**
|
||||
* Extracts the first part of the URL, just after subscription:
|
||||
* https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/
|
||||
* @param {string} url - The original request url
|
||||
* @returns {string} urlPrefix The url prefix as explained above.
|
||||
*/
|
||||
extractSubscriptionUrl(url: string): string;
|
||||
/**
|
||||
* Registers the given provider.
|
||||
* @param {string} urlPrefix - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/
|
||||
* @param {string} provider - The provider name to be registered.
|
||||
* @param {object} originalRequest - The original request sent by the user that returned a 409 response
|
||||
* with a message that the provider is not registered.
|
||||
* @param {registrationCallback} callback - The callback that handles the RP registration
|
||||
*/
|
||||
registerRP(urlPrefix: string, provider: string, originalRequest: WebResource): Promise<boolean>;
|
||||
/**
|
||||
* Polls the registration status of the provider that was registered. Polling happens at an interval of 30 seconds.
|
||||
* Polling will happen till the registrationState property of the response body is "Registered".
|
||||
* @param {string} url - The request url for polling
|
||||
* @param {object} originalRequest - The original request sent by the user that returned a 409 response
|
||||
* with a message that the provider is not registered.
|
||||
* @returns {Promise<boolean>} promise - True if RP Registration is successful.
|
||||
*/
|
||||
getRegistrationStatus(url: string, originalRequest: WebResource): Promise<boolean>;
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { WebResource } from "../webResource";
|
||||
import { ServiceClientCredentials } from "../credentials/serviceClientCredentials";
|
||||
export declare class SigningFilter extends BaseFilter {
|
||||
authenticationProvider: ServiceClientCredentials;
|
||||
constructor(authenticationProvider: ServiceClientCredentials);
|
||||
before(request: WebResource): Promise<WebResource>;
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
import { BaseFilter } from "./baseFilter";
|
||||
import { HttpOperationResponse } from "../httpOperationResponse";
|
||||
export interface RetryData {
|
||||
retryCount: number;
|
||||
retryInterval: number;
|
||||
error?: RetryError;
|
||||
}
|
||||
export interface RetryError extends Error {
|
||||
message: string;
|
||||
code?: string;
|
||||
innerError?: RetryError;
|
||||
}
|
||||
/**
|
||||
* @class
|
||||
* Instantiates a new "ExponentialRetryPolicyFilter" instance.
|
||||
*
|
||||
* @constructor
|
||||
* @param {number} retryCount The client retry count.
|
||||
* @param {number} retryInterval The client retry interval, in milliseconds.
|
||||
* @param {number} minRetryInterval The minimum retry interval, in milliseconds.
|
||||
* @param {number} maxRetryInterval The maximum retry interval, in milliseconds.
|
||||
*/
|
||||
export declare class SystemErrorRetryPolicyFilter extends BaseFilter {
|
||||
retryCount: number;
|
||||
retryInterval: number;
|
||||
minRetryInterval: number;
|
||||
maxRetryInterval: number;
|
||||
DEFAULT_CLIENT_RETRY_INTERVAL: number;
|
||||
DEFAULT_CLIENT_RETRY_COUNT: number;
|
||||
DEFAULT_CLIENT_MAX_RETRY_INTERVAL: number;
|
||||
DEFAULT_CLIENT_MIN_RETRY_INTERVAL: number;
|
||||
constructor(retryCount?: number, retryInterval?: number, minRetryInterval?: number, maxRetryInterval?: number);
|
||||
/**
|
||||
* Determines if the operation should be retried and how long to wait until the next retry.
|
||||
*
|
||||
* @param {number} statusCode The HTTP status code.
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @return {boolean} True if the operation qualifies for a retry; false otherwise.
|
||||
*/
|
||||
shouldRetry(retryData: RetryData): boolean;
|
||||
/**
|
||||
* Updates the retry data for the next attempt.
|
||||
*
|
||||
* @param {RetryData} retryData The retry data.
|
||||
* @param {object} err The operation"s error, if any.
|
||||
*/
|
||||
updateRetryData(retryData?: RetryData, err?: RetryError): RetryData;
|
||||
retry(operationResponse: HttpOperationResponse, retryData?: RetryData, err?: RetryError): Promise<HttpOperationResponse>;
|
||||
after(operationResponse: HttpOperationResponse): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
import { WebResource } from "./webResource";
|
||||
/**
|
||||
* Wrapper object for http request and response. Deserialized object is stored in
|
||||
* the `parsedBody` property when the response body is received in JSON or XML.
|
||||
* @class
|
||||
* Initializes a new instance of the HttpOperationResponse class.
|
||||
* @constructor
|
||||
*/
|
||||
export declare class HttpOperationResponse {
|
||||
/**
|
||||
* The raw request
|
||||
*/
|
||||
request: WebResource;
|
||||
/**
|
||||
* The raw response. Please use the response directly when the response body is a ReadableStream.
|
||||
*/
|
||||
response: Response;
|
||||
/**
|
||||
* The response body as text (string format)
|
||||
*/
|
||||
bodyAsText?: string | null;
|
||||
/**
|
||||
* The response body as parsed JSON or XML
|
||||
*/
|
||||
parsedBody?: {
|
||||
[key: string]: any;
|
||||
} | Array<any> | string | number | boolean | null | void;
|
||||
constructor(request: WebResource, response: Response);
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { WebResource, RequestPrepareOptions, HttpMethods, ParameterValue, RequestOptionsBase } from "./webResource";
|
||||
import { HttpOperationResponse } from "./httpOperationResponse";
|
||||
import { RestError } from "./restError";
|
||||
import { ServiceClient, ServiceClientOptions } from "./serviceClient";
|
||||
import { Constants } from "./util/constants";
|
||||
import { RequestPipeline, RequestFunction } from "./requestPipeline";
|
||||
import { LogFilter } from "./filters/logFilter";
|
||||
import { BaseFilter } from "./filters/baseFilter";
|
||||
import { ExponentialRetryPolicyFilter } from "./filters/exponentialRetryPolicyFilter";
|
||||
import { SystemErrorRetryPolicyFilter } from "./filters/systemErrorRetryPolicyFilter";
|
||||
import { RedirectFilter } from "./filters/redirectFilter";
|
||||
import { SigningFilter } from "./filters/signingFilter";
|
||||
import { MsRestUserAgentFilter } from "./filters/msRestUserAgentFilter";
|
||||
import { BaseMapperType, CompositeMapper, DictionaryMapper, EnumMapper, Mapper, MapperConstraints, MapperType, PolymorphicDiscriminator, SequenceMapper, Serializer, UrlParameterValue, serializeObject } from "./serializer";
|
||||
import { stripRequest, stripResponse, delay, executePromisesSequentially, generateUuid, encodeUri, ServiceCallback, promiseToCallback, promiseToServiceCallback, isValidUuid, dispatchRequest, applyMixins, isNode, stringifyXML, prepareXMLRootList } from "./util/utils";
|
||||
import { TokenCredentials } from "./credentials/tokenCredentials";
|
||||
import { BasicAuthenticationCredentials } from "./credentials/basicAuthenticationCredentials";
|
||||
import { ApiKeyCredentials, ApiKeyCredentialOptions } from "./credentials/apiKeyCredentials";
|
||||
import { ServiceClientCredentials } from "./credentials/serviceClientCredentials";
|
||||
import * as isStream from "is-stream";
|
||||
export { BaseMapperType, CompositeMapper, DictionaryMapper, EnumMapper, Mapper, MapperConstraints, MapperType, PolymorphicDiscriminator, SequenceMapper, UrlParameterValue, Serializer, serializeObject, TokenCredentials, WebResource, RequestPrepareOptions, HttpMethods, ParameterValue, HttpOperationResponse, ServiceClient, Constants, RequestPipeline, BasicAuthenticationCredentials, ApiKeyCredentials, ApiKeyCredentialOptions, ServiceClientCredentials, BaseFilter, LogFilter, ServiceClientOptions, ExponentialRetryPolicyFilter, SystemErrorRetryPolicyFilter, SigningFilter, MsRestUserAgentFilter, stripRequest, stripResponse, delay, executePromisesSequentially, generateUuid, isValidUuid, encodeUri, RestError, RequestOptionsBase, RequestFunction, ServiceCallback, promiseToCallback, promiseToServiceCallback, isStream, dispatchRequest, RedirectFilter, applyMixins, isNode, stringifyXML, prepareXMLRootList };
|
|
@ -1,14 +0,0 @@
|
|||
import { WebResource } from "./webResource";
|
||||
import { HttpOperationResponse } from "./httpOperationResponse";
|
||||
import { BaseFilter } from "./filters/baseFilter";
|
||||
export interface RequestFunction {
|
||||
(webResource: WebResource): Promise<HttpOperationResponse>;
|
||||
}
|
||||
export declare class RequestPipeline {
|
||||
filters: BaseFilter[];
|
||||
requestOptions: RequestInit;
|
||||
constructor(filters?: BaseFilter[], requestOptions?: RequestInit);
|
||||
addFilter(f: BaseFilter): void;
|
||||
create(): RequestFunction;
|
||||
requestSink(options: WebResource): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
import { WebResource } from "./webResource";
|
||||
export declare class RestError extends Error {
|
||||
code?: string;
|
||||
statusCode?: number;
|
||||
request?: WebResource;
|
||||
response?: Response;
|
||||
body?: any;
|
||||
constructor(message: string, code?: string, statusCode?: number, request?: WebResource, response?: Response, body?: any);
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
import { ServiceClientCredentials } from "./credentials/serviceClientCredentials";
|
||||
import { BaseFilter } from "./filters/baseFilter";
|
||||
import { WebResource, RequestPrepareOptions } from "./webResource";
|
||||
import { HttpOperationResponse } from "./httpOperationResponse";
|
||||
/**
|
||||
* Options to be provided while creating the client.
|
||||
*/
|
||||
export interface ServiceClientOptions {
|
||||
/**
|
||||
* @property {RequestInit} [requestOptions] The request options. Detailed info can be found
|
||||
* here https://github.github.io/fetch/#Request
|
||||
*/
|
||||
requestOptions?: RequestInit;
|
||||
/**
|
||||
* @property {Array<BaseFilter>} [filters] An array of filters/interceptors that will
|
||||
* be processed in the request pipeline (before and after) sending the request on the wire.
|
||||
*/
|
||||
filters?: BaseFilter[];
|
||||
/**
|
||||
* @property {bool} [noRetryPolicy] - If set to true, turn off the default retry policy.
|
||||
*/
|
||||
noRetryPolicy?: boolean;
|
||||
/**
|
||||
* @property {number} [rpRegistrationRetryTimeout] - Gets or sets the retry timeout
|
||||
* in seconds for AutomaticRPRegistration. Default value is 30.
|
||||
*/
|
||||
rpRegistrationRetryTimeout?: number;
|
||||
}
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the ServiceClient.
|
||||
*/
|
||||
export declare class ServiceClient {
|
||||
/**
|
||||
* The string to be appended to the User-Agent header while sending the request.
|
||||
* This will be applicable only for node.js environment as the fetch library in browser does not allow setting custom UA.
|
||||
* @property {Array<string>} value - An array of string that need to be appended to the User-Agent request header.
|
||||
*/
|
||||
userAgentInfo: {
|
||||
value: Array<string>;
|
||||
};
|
||||
/**
|
||||
* The request pipeline that provides hooks for adding custom filters.
|
||||
* The before filters get executed before sending the request and the after filters get executed after receiving the response.
|
||||
*/
|
||||
pipeline: Function;
|
||||
/**
|
||||
* The ServiceClient constructor
|
||||
* @constructor
|
||||
* @param {ServiceClientCredentials }[credentials] - BasicAuthenticationCredentials or
|
||||
* TokenCredentials object used for authentication.
|
||||
* @param { ServiceClientOptions } [options] The service client options that govern the behavior of the client.
|
||||
*/
|
||||
constructor(credentials?: ServiceClientCredentials, options?: ServiceClientOptions);
|
||||
/**
|
||||
* Adds custom information to user agent header
|
||||
* @param {any} additionalUserAgentInfo - information to be added to user agent header, as string.
|
||||
*/
|
||||
addUserAgentInfo(additionalUserAgentInfo: string): void;
|
||||
sendRequest(options: RequestPrepareOptions | WebResource): Promise<HttpOperationResponse>;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export declare const fetch: any;
|
|
@ -1,23 +0,0 @@
|
|||
export declare const Constants: {
|
||||
msRestVersion: string;
|
||||
HTTP: string;
|
||||
HTTPS: string;
|
||||
HTTP_PROXY: string;
|
||||
HTTPS_PROXY: string;
|
||||
HttpConstants: {
|
||||
HttpVerbs: {
|
||||
PUT: string;
|
||||
GET: string;
|
||||
DELETE: string;
|
||||
POST: string;
|
||||
MERGE: string;
|
||||
HEAD: string;
|
||||
PATCH: string;
|
||||
};
|
||||
};
|
||||
HeaderConstants: {
|
||||
AUTHORIZATION: string;
|
||||
AUTHORIZATION_SCHEME: string;
|
||||
USER_AGENT: string;
|
||||
};
|
||||
};
|
|
@ -1 +0,0 @@
|
|||
export declare const fetch: any;
|
|
@ -1,132 +0,0 @@
|
|||
import { Mapper } from "./serializer";
|
||||
export declare type HttpMethods = "GET" | "PUT" | "POST" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS" | "TRACE";
|
||||
/**
|
||||
* Creates a new WebResource object.
|
||||
*
|
||||
* This class provides an abstraction over a REST call by being library / implementation agnostic and wrapping the necessary
|
||||
* properties to initiate a request.
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
export declare class WebResource {
|
||||
url: string;
|
||||
method: HttpMethods;
|
||||
body?: any;
|
||||
headers: {
|
||||
[key: string]: any;
|
||||
};
|
||||
rawResponse?: boolean;
|
||||
formData?: any;
|
||||
query?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
constructor(url?: string, method?: HttpMethods, body?: any, query?: {
|
||||
[key: string]: any;
|
||||
}, headers?: {
|
||||
[key: string]: any;
|
||||
}, rawResponse?: boolean);
|
||||
/**
|
||||
* Validates that the required properties such as method, url, headers["Content-Type"],
|
||||
* headers["accept-language"] are defined. It will throw an error if one of the above
|
||||
* mentioned properties are not defined.
|
||||
*/
|
||||
validateRequestProperties(): void;
|
||||
/**
|
||||
* Prepares the request.
|
||||
* @param {RequestPrepareOptions} options - Options to provide for preparing the request.
|
||||
* @returns {object} WebResource Returns the prepared WebResource (HTTP Request) object that needs to be given to the request pipeline.
|
||||
*/
|
||||
prepare(options: RequestPrepareOptions): this;
|
||||
}
|
||||
/**
|
||||
* Prepares the request.
|
||||
* @param {object} options The request options that should be provided to send a request successfully
|
||||
* @param {string} options.method The HTTP request method. Valid values are "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "POST", "PATCH".
|
||||
* @param {string} [options.url] The request url. It may or may not have query parameters in it.
|
||||
* Either provide the "url" or provide the "pathTemplate" in the options object. Both the options are mutually exclusive.
|
||||
* @param {object} [options.queryParameters] A dictionary of query parameters to be appended to the url, where
|
||||
* the "key" is the "query-parameter-name" and the "value" is the "query-parameter-value".
|
||||
* The "query-parameter-value" can be of type "string" or it can be of type "object".
|
||||
* The "object" format should be used when you want to skip url encoding. While using the object format,
|
||||
* the object must have a property named value which provides the "query-parameter-value".
|
||||
* Example:
|
||||
* - query-parameter-value in "object" format: { "query-parameter-name": { value: "query-parameter-value", skipUrlEncoding: true } }
|
||||
* - query-parameter-value in "string" format: { "query-parameter-name": "query-parameter-value"}.
|
||||
* Note: "If options.url already has some query parameters, then the value provided in options.queryParameters will be appended to the url.
|
||||
* @param {string} [options.pathTemplate] The path template of the request url. Either provide the "url" or provide the "pathTemplate"
|
||||
* in the options object. Both the options are mutually exclusive.
|
||||
* Example: "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"
|
||||
* @param {string} [options.baseUrl] The base url of the request. Default value is: "https://management.azure.com". This is applicable only with
|
||||
* options.pathTemplate. If you are providing options.url then it is expected that you provide the complete url.
|
||||
* @param {object} [options.pathParameters] A dictionary of path parameters that need to be replaced with actual values in the pathTemplate.
|
||||
* Here the key is the "path-parameter-name" and the value is the "path-parameter-value".
|
||||
* The "path-parameter-value" can be of type "string" or it can be of type "object".
|
||||
* The "object" format should be used when you want to skip url encoding. While using the object format,
|
||||
* the object must have a property named value which provides the "path-parameter-value".
|
||||
* Example:
|
||||
* - path-parameter-value in "object" format: { "path-parameter-name": { value: "path-parameter-value", skipUrlEncoding: true } }
|
||||
* - path-parameter-value in "string" format: { "path-parameter-name": "path-parameter-value" }.
|
||||
* @param {object} [options.headers] A dictionary of request headers that need to be applied to the request.
|
||||
* Here the key is the "header-name" and the value is the "header-value". The header-value MUST be of type string.
|
||||
* - ContentType must be provided with the key name as "Content-Type". Default value "application/json; charset=utf-8".
|
||||
* - "Transfer-Encoding" is set to "chunked" by default if "options.bodyIsStream" is set to true.
|
||||
* - "Content-Type" is set to "application/octet-stream" by default if "options.bodyIsStream" is set to true.
|
||||
* - "accept-language" by default is set to "en-US"
|
||||
* - "x-ms-client-request-id" by default is set to a new Guid. To not generate a guid for the request, please set options.disableClientRequestId to true
|
||||
* @param {boolean} [options.disableClientRequestId] When set to true, instructs the client to not set "x-ms-client-request-id" header to a new Guid().
|
||||
* @param {object|string|boolean|array|number|null|undefined} [options.body] - The request body. It can be of any type. This method will JSON.stringify() the request body.
|
||||
* @param {object} [options.serializationMapper] - Provides information on how to serialize the request body.
|
||||
* @param {object} [options.mappers] - A dictionary of mappers that may be used while [de]serialization.
|
||||
* @param {object} [options.deserializationMapper] - Provides information on how to deserialize the response body.
|
||||
* @param {boolean} [options.disableJsonStringifyOnBody] - Indicates whether this method should JSON.stringify() the request body. Default value: false.
|
||||
* @param {boolean} [options.bodyIsStream] - Indicates whether the request body is a stream (useful for file upload scenarios).
|
||||
* @returns {object} WebResource Returns the prepared WebResource (HTTP Request) object that needs to be given to the request pipeline.
|
||||
*/
|
||||
export interface RequestPrepareOptions {
|
||||
method: HttpMethods;
|
||||
url?: string;
|
||||
queryParameters?: {
|
||||
[key: string]: any | ParameterValue;
|
||||
};
|
||||
pathTemplate?: string;
|
||||
baseUrl?: string;
|
||||
pathParameters?: {
|
||||
[key: string]: any | ParameterValue;
|
||||
};
|
||||
formData?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
headers?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
disableClientRequestId?: boolean;
|
||||
body?: any;
|
||||
serializationMapper?: Mapper;
|
||||
mappers?: {
|
||||
[x: string]: any;
|
||||
};
|
||||
deserializationMapper?: object;
|
||||
disableJsonStringifyOnBody?: boolean;
|
||||
bodyIsStream?: boolean;
|
||||
}
|
||||
/**
|
||||
* The Parameter value provided for path or query parameters in RequestPrepareOptions
|
||||
*/
|
||||
export interface ParameterValue {
|
||||
value: any;
|
||||
skipUrlEncoding: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
/**
|
||||
* Describes the base structure of the options object that will be used in every operation.
|
||||
*/
|
||||
export interface RequestOptionsBase {
|
||||
/**
|
||||
* @property {object} [customHeaders] - User defined custom request headers that
|
||||
* will be applied before the request is sent.
|
||||
*/
|
||||
customHeaders?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
[key: string]: any;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export {};
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
import * as models from './index';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Cat class.
|
||||
* @constructor
|
||||
* @member {string} [color]
|
||||
*
|
||||
* @member {array} [hates]
|
||||
*
|
||||
*/
|
||||
export declare class Cat extends models.Pet {
|
||||
/**
|
||||
* Defines the metadata of Cat
|
||||
*
|
||||
* @returns {object} metadata of Cat
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
import * as models from './index';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Dog class.
|
||||
* @constructor
|
||||
* @member {string} [food]
|
||||
*
|
||||
*/
|
||||
export declare class Dog extends models.Pet {
|
||||
/**
|
||||
* Defines the metadata of Dog
|
||||
*
|
||||
* @returns {object} metadata of Dog
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Fish class.
|
||||
* @constructor
|
||||
* @member {string} [species]
|
||||
*
|
||||
* @member {number} length
|
||||
*
|
||||
* @member {array} [siblings]
|
||||
*
|
||||
* @member {string} fishtype Polymorhpic Discriminator
|
||||
*
|
||||
*/
|
||||
export declare class Fish {
|
||||
constructor();
|
||||
/**
|
||||
* Defines the metadata of Fish
|
||||
*
|
||||
* @returns {object} metadata of Fish
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { Product } from './product';
|
||||
import { Invoice } from './invoice';
|
||||
import { SubProduct } from './subProduct';
|
||||
import { ProductListResult } from './productListResult';
|
||||
import { ProductListResultNextLink } from './productListResultNextLink';
|
||||
import { Pet } from './pet';
|
||||
import { Cat } from './cat';
|
||||
import { Dog } from './dog';
|
||||
import { Fish } from './fish';
|
||||
import { Shark } from './shark';
|
||||
import { Sawshark } from './sawshark';
|
||||
import { PetGallery } from './petgallery';
|
||||
declare const discriminators: {
|
||||
'Fish': typeof Fish;
|
||||
'Fish.shark': typeof Shark;
|
||||
'Fish.sawshark': typeof Sawshark;
|
||||
'Pet': typeof Pet;
|
||||
'Pet.Cat': typeof Cat;
|
||||
'Pet.Dog': typeof Dog;
|
||||
};
|
||||
export { Product, Invoice, SubProduct, ProductListResult, ProductListResultNextLink, Pet, Cat, Dog, Fish, Shark, Sawshark, PetGallery, discriminators };
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Invoice class.
|
||||
* @constructor
|
||||
* @member {number} [integer]
|
||||
*
|
||||
* @member {string} [string]
|
||||
*
|
||||
*/
|
||||
export declare class Invoice {
|
||||
constructor();
|
||||
/**
|
||||
* Metadata of Invoice
|
||||
*
|
||||
* @returns {object} metadata of the Invoice
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export declare const Mappers: any;
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Pet class.
|
||||
* @constructor
|
||||
* @member {number} [id]
|
||||
*
|
||||
* @member {string} [name]
|
||||
*
|
||||
*/
|
||||
export declare class Pet {
|
||||
constructor();
|
||||
/**
|
||||
* Defines the metadata of Pet
|
||||
*
|
||||
* @returns {object} metadata of Pet
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the PetGallery class.
|
||||
* @constructor
|
||||
* @member {number} [id]
|
||||
*
|
||||
* @member {string} [name]
|
||||
*
|
||||
*/
|
||||
export declare class PetGallery {
|
||||
constructor();
|
||||
/**
|
||||
* Defines the metadata of PetGallery
|
||||
*
|
||||
* @returns {object} metadata of PetGallery
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Product class.
|
||||
* @constructor
|
||||
* @member {number} [integer]
|
||||
*
|
||||
* @member {string} [string]
|
||||
*
|
||||
*/
|
||||
export declare class Product {
|
||||
constructor();
|
||||
/**
|
||||
* Metadata of Product
|
||||
*
|
||||
* @returns {object} metadata of the Product
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the ProductListResult class.
|
||||
* @constructor
|
||||
* The list storage accounts operation response.
|
||||
* @member {array} [value] Gets the list of products and their
|
||||
* properties.
|
||||
*
|
||||
*/
|
||||
export declare class ProductListResult extends Array {
|
||||
constructor();
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the ProductListResultNextLink class.
|
||||
* @constructor
|
||||
* The list storage accounts operation response.
|
||||
* @member {array} [value] Gets the list of products and their
|
||||
* properties.
|
||||
*
|
||||
*/
|
||||
import * as msRest from '../../../../../lib/msRest';
|
||||
export declare class ProductListResultNextLink extends Array {
|
||||
constructor();
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
import * as models from './index';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Sawshark class.
|
||||
* @constructor
|
||||
* @member {buffer} [picture]
|
||||
*
|
||||
*/
|
||||
export declare class Sawshark extends models.Shark {
|
||||
/**
|
||||
* Defines the metadata of Sawshark
|
||||
*
|
||||
* @returns {object} metadata of Sawshark
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
import * as models from './index';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the Shark class.
|
||||
* @constructor
|
||||
* @member {number} [age]
|
||||
*
|
||||
* @member {date} birthday
|
||||
*
|
||||
*/
|
||||
export declare class Shark extends models.Fish {
|
||||
/**
|
||||
* Defines the metadata of Shark
|
||||
*
|
||||
* @returns {object} metadata of Shark
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import * as msRest from '../../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the SubProduct class.
|
||||
* @constructor
|
||||
* @member {number} [integer]
|
||||
*
|
||||
* @member {string} [string]
|
||||
*
|
||||
*/
|
||||
export declare class SubProduct {
|
||||
constructor();
|
||||
/**
|
||||
* Metadata of SubProduct
|
||||
*
|
||||
* @returns {object} metadata of the SubProduct
|
||||
*
|
||||
*/
|
||||
mapper(): msRest.CompositeMapper;
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
import * as msRest from '../../../../lib/msRest';
|
||||
/**
|
||||
* @class
|
||||
* Initializes a new instance of the TestClient class.
|
||||
* @constructor
|
||||
*
|
||||
* @param {string} [baseUri] - The base URI of the service.
|
||||
*
|
||||
* @param {object} [options] - The parameter options
|
||||
*
|
||||
* @param {Array} [options.filters] - Filters to be added to the request pipeline
|
||||
*
|
||||
* @param {object} [options.requestOptions] - Options for the underlying request object
|
||||
* {@link https://github.com/request/request#requestoptions-callback Options doc}
|
||||
*
|
||||
* @param {bool} [options.noRetryPolicy] - If set to true, turn off default retry policy
|
||||
*/
|
||||
declare class TestClient extends msRest.ServiceClient {
|
||||
baseUri?: string;
|
||||
acceptLanguage?: string;
|
||||
models?: any;
|
||||
serializer: msRest.Serializer;
|
||||
constructor(baseUri: string, options?: msRest.ServiceClientOptions);
|
||||
}
|
||||
export { TestClient };
|
|
@ -1 +0,0 @@
|
|||
export {};
|
|
@ -1 +0,0 @@
|
|||
export {};
|
|
@ -1 +0,0 @@
|
|||
export {};
|
|
@ -1,8 +1,7 @@
|
|||
const webpack = require('webpack');
|
||||
//var UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||
const path = require('path');
|
||||
import * as webpack from 'webpack';
|
||||
import * as path from 'path';
|
||||
|
||||
module.exports = {
|
||||
const config: webpack.Configuration = {
|
||||
entry: './lib/msRest.ts',
|
||||
devtool: 'source-map',
|
||||
output: {
|
||||
|
@ -39,4 +38,6 @@ module.exports = {
|
|||
v8: false,
|
||||
Buffer: false
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export default config;
|
Загрузка…
Ссылка в новой задаче