This commit is contained in:
Rikki Gibson 2018-04-02 16:58:47 -07:00
Родитель 4df2d14009
Коммит 2776c9d271
17 изменённых файлов: 11374 добавлений и 553 удалений

4
dist/lib/filters/rpRegistrationFilter.js поставляемый
Просмотреть файл

@ -252,8 +252,8 @@ var RPRegistrationFilter = /** @class */ (function (_super) {
err_5 = _a.sent();
return [2 /*return*/, Promise.reject(err_5)];
case 4:
obj = res.bodyAsJson;
if (res.bodyAsJson && obj.registrationState && obj.registrationState === "Registered") {
obj = res.parsedBody;
if (res.parsedBody && obj.registrationState && obj.registrationState === "Registered") {
result = true;
}
else {

4
dist/lib/httpOperationResponse.js поставляемый
Просмотреть файл

@ -4,7 +4,7 @@
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `bodyAsJson` property when the response body is received in JSON.
* the `parsedBody` property when the response body is received in JSON or XML.
* @class
* Initializes a new instance of the HttpOperationResponse class.
* @constructor
@ -25,7 +25,7 @@ var HttpOperationResponse = /** @class */ (function () {
this.response = response;
/* tslint:disable:no-null-keyword */
this.bodyAsText = null;
this.bodyAsJson = null;
this.parsedBody = null;
}
return HttpOperationResponse;
}());

2
dist/lib/httpOperationResponse.js.map поставляемый
Просмотреть файл

@ -1 +1 @@
{"version":3,"file":"httpOperationResponse.js","sourceRoot":"","sources":["../../lib/httpOperationResponse.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAI/F;;;;;;GAMG;AACH;IAkBE,+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,AApCD,IAoCC;AApCY,sDAAqB"}
{"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"}

2
dist/lib/msRest.js поставляемый
Просмотреть файл

@ -45,6 +45,8 @@ exports.isValidUuid = utils_1.isValidUuid;
exports.dispatchRequest = utils_1.dispatchRequest;
exports.applyMixins = utils_1.applyMixins;
exports.isNode = utils_1.isNode;
exports.stringifyXML = utils_1.stringifyXML;
exports.prepareXMLRootList = utils_1.prepareXMLRootList;
// Credentials
var tokenCredentials_1 = require("./credentials/tokenCredentials");
exports.TokenCredentials = tokenCredentials_1.TokenCredentials;

2
dist/lib/msRest.js.map поставляемый
Просмотреть файл

@ -1 +1 @@
{"version":3,"file":"msRest.js","sourceRoot":"","sources":["../../lib/msRest.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,6CAAoH;AAmClH,sBAnCO,yBAAW,CAmCP;AAlCb,iEAAgE;AAkCG,gCAlC1D,6CAAqB,CAkC0D;AAjCxF,yCAAwC;AAoCA,oBApC/B,qBAAS,CAoC+B;AAnCjD,iDAAsE;AAgCoB,wBAhCjF,6BAAa,CAgCiF;AA/BvG,8CAA6C;AA+B4D,oBA/BhG,qBAAS,CA+BgG;AA9BlH,qDAAqE;AA8B+C,0BA9B3G,iCAAe,CA8B2G;AA7BnI,iDAAgD;AA8BoE,oBA9B3G,qBAAS,CA8B2G;A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,4BAAQ"}

246
dist/lib/serializer.js поставляемый
Просмотреть файл

@ -4,10 +4,11 @@
Object.defineProperty(exports, "__esModule", { value: true });
var utils = require("./util/utils");
var moment_1 = require("moment");
var isBuffer = require("is-buffer");
var isStream = require("is-stream");
var isBuffer = require("is-buffer");
var Serializer = /** @class */ (function () {
function Serializer(mappers) {
function Serializer(mappers, isXML) {
this.isXML = isXML;
this.modelMappers = mappers;
}
Serializer.prototype.validateConstraints = function (mapper, value, objectName) {
@ -305,45 +306,69 @@ var Serializer = /** @class */ (function () {
("mapper \"" + JSON.stringify(modelMapper) + "\" of type \"" + mapper.type.className + "\" for object \"" + objectName + "\"."));
}
}
for (var key in modelProps) {
if (modelProps.hasOwnProperty(key)) {
var paths = this.splitSerializeName(modelProps[key].serializedName);
var propName = paths.pop();
var parentObject = payload;
for (var _i = 0, paths_1 = paths; _i < paths_1.length; _i++) {
var pathName = paths_1[_i];
for (var _i = 0, _a = Object.keys(modelProps); _i < _a.length; _i++) {
var key = _a[_i];
var propertyMapper = modelProps[key];
var propName = void 0;
var parentObject = payload;
if (this.isXML) {
if (propertyMapper.xmlIsWrapped) {
propName = propertyMapper.xmlName;
}
else {
propName = propertyMapper.xmlElementName || propertyMapper.xmlName;
}
}
else {
var paths = this.splitSerializeName(propertyMapper.serializedName);
propName = paths.pop();
for (var _b = 0, paths_1 = paths; _b < paths_1.length; _b++) {
var pathName = paths_1[_b];
var childObject = parentObject[pathName];
if ((childObject === null || childObject === undefined) && (object[key] !== null && object[key] !== undefined)) {
parentObject[pathName] = {};
}
parentObject = parentObject[pathName];
}
// make sure required properties of the CompositeType are present
if (modelProps[key].required && !modelProps[key].isConstant) {
if (object[key] === null || object[key] === undefined) {
throw new Error(key + "\" cannot be null or undefined in \"" + objectName + "\".");
}
// make sure required properties of the CompositeType are present
if (propertyMapper.required && !propertyMapper.isConstant) {
if (object[key] == undefined) {
throw new Error(key + "\" cannot be null or undefined in \"" + objectName + "\".");
}
}
// make sure that readOnly properties are not sent on the wire
if (propertyMapper.readOnly) {
continue;
}
// serialize the property if it is present in the provided object instance
if (((parentObject !== null && parentObject !== undefined) && (propertyMapper.defaultValue !== null && propertyMapper.defaultValue !== undefined)) ||
(object[key] !== null && object[key] !== undefined)) {
var propertyObjectName = propertyMapper.serializedName !== ""
? objectName + "." + propertyMapper.serializedName
: objectName;
var serializedValue = this.serialize(propertyMapper, object[key], propertyObjectName);
if (propName !== null && propName !== undefined) {
if (propertyMapper.xmlIsAttribute) {
// $ is the key attributes are kept under in xml2js.
// This keeps things simple while preventing name collision
// with names in user documents.
parentObject.$ = parentObject.$ || {};
parentObject.$[propName] = serializedValue;
}
}
// make sure that readOnly properties are not sent on the wire
if (modelProps[key].readOnly) {
continue;
}
// serialize the property if it is present in the provided object instance
if (((parentObject !== null && parentObject !== undefined) && (modelProps[key].defaultValue !== null && modelProps[key].defaultValue !== undefined)) ||
(object[key] !== null && object[key] !== undefined)) {
var propertyObjectName = objectName;
if (modelProps[key].serializedName !== "")
propertyObjectName = objectName + "." + modelProps[key].serializedName;
var propertyMapper = modelProps[key];
var serializedValue = this.serialize(propertyMapper, object[key], propertyObjectName);
if (propName !== null && propName !== undefined)
else if (propertyMapper.xmlIsWrapped) {
parentObject[propName] = (_c = {}, _c[propertyMapper.xmlElementName] = serializedValue, _c);
}
else {
parentObject[propName] = serializedValue;
}
}
}
}
return payload;
}
return object;
var _c;
};
/**
* Serialize the given object based on its metadata defined in the mapper
@ -420,57 +445,75 @@ var Serializer = /** @class */ (function () {
name: "Composite"
}
};
if (responseBody !== null && responseBody !== undefined) {
var modelProps = mapper.type.modelProperties;
responseBody = responseBody || {};
var modelProps = mapper.type.modelProperties;
if (!modelProps) {
if (!mapper.type.className) {
throw new Error("Class name for model \"" + objectName + "\" is not provided in the mapper \"" + JSON.stringify(mapper) + "\"");
}
// get the mapper if modelProperties of the CompositeType is not present and
// then get the modelProperties from it.
modelMapper = this.modelMappers[mapper.type.className];
if (!modelMapper) {
throw new Error("mapper() cannot be null or undefined for model \"" + mapper.type.className + "\"");
}
modelProps = modelMapper.type.modelProperties;
if (!modelProps) {
if (!mapper.type.className) {
throw new Error("Class name for model \"" + objectName + "\" is not provided in the mapper \"" + JSON.stringify(mapper) + "\"");
}
// get the mapper if modelProperties of the CompositeType is not present and
// then get the modelProperties from it.
modelMapper = this.modelMappers[mapper.type.className];
if (!modelMapper) {
throw new Error("mapper() cannot be null or undefined for model \"" + mapper.type.className + "\"");
}
modelProps = modelMapper.type.modelProperties;
if (!modelProps) {
throw new Error("modelProperties cannot be null or undefined in the " +
("mapper \"" + JSON.stringify(modelMapper) + "\" of type \"" + mapper.type.className + "\" for responseBody \"" + objectName + "\"."));
}
throw new Error("modelProperties cannot be null or undefined in the " +
("mapper \"" + JSON.stringify(modelMapper) + "\" of type \"" + mapper.type.className + "\" for responseBody \"" + objectName + "\"."));
}
for (var key in modelProps) {
if (modelProps.hasOwnProperty(key)) {
var paths = this.splitSerializeName(modelProps[key].serializedName);
// deserialize the property if it is present in the provided responseBody instance
var propertyInstance = void 0;
var res = responseBody;
// traversing the object step by step.
for (var _i = 0, paths_2 = paths; _i < paths_2.length; _i++) {
var item = paths_2[_i];
if (!res)
break;
res = res[item];
}
propertyInstance = res;
var propertyObjectName = objectName;
if (modelProps[key].serializedName !== "")
propertyObjectName = objectName + "." + modelProps[key].serializedName;
var propertyMapper = modelProps[key];
var serializedValue = void 0;
// paging
if (Array.isArray(responseBody[key]) && modelProps[key].serializedName === "") {
propertyInstance = responseBody[key];
instance = this.deserialize(propertyMapper, propertyInstance, propertyObjectName);
}
else if (propertyInstance !== null && propertyInstance !== undefined) {
serializedValue = this.deserialize(propertyMapper, propertyInstance, propertyObjectName);
instance[key] = serializedValue;
}
}
}
return instance;
}
return responseBody;
for (var _i = 0, _a = Object.keys(modelProps); _i < _a.length; _i++) {
var key = _a[_i];
var propertyMapper = modelProps[key];
var propertyObjectName = objectName;
if (propertyMapper.serializedName !== "") {
propertyObjectName = objectName + "." + propertyMapper.serializedName;
}
if (this.isXML) {
if (propertyMapper.xmlIsAttribute && responseBody.$) {
instance[key] = this.deserialize(propertyMapper, responseBody.$[propertyMapper.xmlName], propertyObjectName);
}
else {
var propertyName = propertyMapper.xmlElementName || propertyMapper.xmlName;
var unwrappedProperty = responseBody[propertyName];
if (propertyMapper.xmlIsWrapped) {
unwrappedProperty = responseBody[propertyMapper.xmlName];
unwrappedProperty = unwrappedProperty && unwrappedProperty[propertyMapper.xmlElementName];
if (unwrappedProperty === undefined) {
// undefined means a wrapped list was empty
unwrappedProperty = [];
}
}
instance[key] = this.deserialize(propertyMapper, unwrappedProperty, propertyObjectName);
}
}
else {
var paths = this.splitSerializeName(modelProps[key].serializedName);
// deserialize the property if it is present in the provided responseBody instance
var propertyInstance = void 0;
var res = responseBody;
// traversing the object step by step.
for (var _b = 0, paths_2 = paths; _b < paths_2.length; _b++) {
var item = paths_2[_b];
if (!res)
break;
res = res[item];
}
propertyInstance = res;
var serializedValue = void 0;
// paging
if (Array.isArray(responseBody[key]) && modelProps[key].serializedName === "") {
propertyInstance = responseBody[key];
instance = this.deserialize(propertyMapper, propertyInstance, propertyObjectName);
}
else if (propertyInstance !== null && propertyInstance !== undefined) {
serializedValue = this.deserialize(propertyMapper, propertyInstance, propertyObjectName);
instance[key] = serializedValue;
}
}
}
return instance;
};
Serializer.prototype.deserializeDictionaryType = function (mapper, responseBody, objectName) {
/*jshint validthis: true */
@ -496,6 +539,10 @@ var Serializer = /** @class */ (function () {
("mapper and it must of type \"object\" in " + objectName));
}
if (responseBody) {
if (!Array.isArray(responseBody)) {
// xml2js will interpret a single element array as just the element, so force it to be an array
responseBody = [responseBody];
}
var tempArray = [];
for (var i = 0; i < responseBody.length; i++) {
tempArray[i] = this.deserialize(mapper.type.element, responseBody[i], objectName);
@ -516,15 +563,51 @@ var Serializer = /** @class */ (function () {
* @returns {object|string|Array|number|boolean|Date|stream} A valid deserialized Javascript object
*/
Serializer.prototype.deserialize = function (mapper, responseBody, objectName) {
if (responseBody === null || responseBody === undefined)
if (responseBody == undefined) {
if (this.isXML && mapper.type.name === "Sequence" && !mapper.xmlIsWrapped) {
// Edge case for empty XML non-wrapped lists. xml2js can't distinguish
// between the list being empty versus being missing,
// so let's do the more user-friendly thing and return an empty list.
responseBody = [];
}
else {
return responseBody;
}
return responseBody;
}
var payload;
var mapperType = mapper.type.name;
if (!objectName)
if (!objectName) {
objectName = mapper.serializedName;
if (mapperType.match(/^Sequence$/ig) !== null)
payload = [];
if (mapperType.match(/^(Number|String|Boolean|Enum|Object|Stream|Uuid|any)$/ig) !== null) {
}
if (mapperType.match(/^Number$/ig) !== null) {
if (this.isXML) {
payload = parseFloat(responseBody);
if (isNaN(payload)) {
payload = responseBody;
}
}
else {
payload = responseBody;
}
}
else if (mapperType.match(/^Boolean$/ig) !== null) {
if (this.isXML) {
if (responseBody === "true") {
payload = true;
}
else if (responseBody === "false") {
payload = false;
}
else {
payload = responseBody;
}
}
else {
payload = responseBody;
}
}
else if (mapperType.match(/^(String|Enum|Object|Stream|Uuid|any)$/ig) !== null) {
payload = responseBody;
}
else if (mapperType.match(/^(Date|DateTime|DateTimeRfc1123)$/ig) !== null) {
@ -551,8 +634,9 @@ var Serializer = /** @class */ (function () {
else if (mapperType.match(/^Composite$/ig) !== null) {
payload = this.deserializeCompositeType(mapper, responseBody, objectName);
}
if (mapper.isConstant)
if (mapper.isConstant) {
payload = mapper.defaultValue;
}
return payload;
};
Serializer.prototype.getPolymorphicMapper = function (mapper, object, objectName, mode) {

2
dist/lib/serializer.js.map поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

93
dist/lib/util/utils.js поставляемый
Просмотреть файл

@ -43,6 +43,7 @@ var webResource_1 = require("../webResource");
var constants_1 = require("./constants");
var restError_1 = require("../restError");
var httpOperationResponse_1 = require("../httpOperationResponse");
var xml2js = require("xml2js");
/**
* Provides the fetch() method based on the environment.
* @returns {fetch} fetch - The fetch() method available in the environment to make requests
@ -277,13 +278,35 @@ function promiseToServiceCallback(promise) {
}
return function (cb) {
promise.then(function (data) {
process.nextTick(cb, undefined, data.bodyAsJson, data.request, data.response);
process.nextTick(cb, undefined, data.parsedBody, data.request, data.response);
}, function (err) {
process.nextTick(cb, err);
});
};
}
exports.promiseToServiceCallback = promiseToServiceCallback;
var XML2JS_PARSER_OPTS = {
explicitArray: false,
explicitCharkey: false,
explicitRoot: false
};
function stringifyXML(obj, opts) {
var builder = new xml2js.Builder({
explicitArray: false,
explicitCharkey: false,
rootName: (opts || {}).rootName
});
return builder.buildObject(obj);
}
exports.stringifyXML = stringifyXML;
function prepareXMLRootList(obj, elementName) {
if (!Array.isArray(obj)) {
obj = [obj];
}
return _a = {}, _a[elementName] = obj, _a;
var _a;
}
exports.prepareXMLRootList = prepareXMLRootList;
/**
* Sends the request and returns the received response.
* @param {WebResource} options - The request to be sent.
@ -291,9 +314,9 @@ exports.promiseToServiceCallback = promiseToServiceCallback;
*/
function dispatchRequest(options) {
return __awaiter(this, void 0, void 0, function () {
var formData, requestForm_1, appendFormValue, formKey, formValue, j, res, err_1, operationResponse, _a, err_2, msg, errCode, e, msg, errCode, e;
return __generator(this, function (_b) {
switch (_b.label) {
var formData, requestForm_1, appendFormValue, formKey, formValue, j, res, err_1, operationResponse, _a, err_2, msg, errCode, e, contentType, xmlParser_1, parseString, _b, err_3, msg, errCode, e;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
if (!options) {
return [2 /*return*/, Promise.reject(new Error("options (WebResource) cannot be null or undefined and must be of type object."))];
@ -329,47 +352,65 @@ function dispatchRequest(options) {
options.headers["Content-Type"] = "multipart/form-data; boundary=" + requestForm_1.getBoundary();
}
}
_b.label = 1;
_c.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
_c.trys.push([1, 3, , 4]);
return [4 /*yield*/, exports.myFetch(options.url, options)];
case 2:
res = _b.sent();
res = _c.sent();
return [3 /*break*/, 4];
case 3:
err_1 = _b.sent();
err_1 = _c.sent();
return [2 /*return*/, Promise.reject(err_1)];
case 4:
operationResponse = new httpOperationResponse_1.HttpOperationResponse(options, res);
if (!!options.rawResponse) return [3 /*break*/, 9];
_b.label = 5;
if (!!options.rawResponse) return [3 /*break*/, 13];
_c.label = 5;
case 5:
_b.trys.push([5, 7, , 8]);
_c.trys.push([5, 7, , 8]);
_a = operationResponse;
return [4 /*yield*/, res.text()];
case 6:
_a.bodyAsText = _b.sent();
_a.bodyAsText = _c.sent();
return [3 /*break*/, 8];
case 7:
err_2 = _b.sent();
err_2 = _c.sent();
msg = "Error \"" + err_2 + "\" occured while converting the raw response body into string.";
errCode = err_2.code || "RAWTEXT_CONVERSION_ERROR";
e = new restError_1.RestError(msg, errCode, res.status, options, res, res.body);
return [2 /*return*/, Promise.reject(e)];
case 8:
try {
if (operationResponse.bodyAsText) {
operationResponse.bodyAsJson = JSON.parse(operationResponse.bodyAsText);
}
}
catch (err) {
msg = "Error \"" + err + "\" occured while executing JSON.parse on the response body - " + operationResponse.bodyAsText + ".";
errCode = err.code || "JSON_PARSE_ERROR";
e = new restError_1.RestError(msg, errCode, res.status, options, res, operationResponse.bodyAsText);
return [2 /*return*/, Promise.reject(e)];
}
_b.label = 9;
case 9: return [2 /*return*/, Promise.resolve(operationResponse)];
_c.trys.push([8, 12, , 13]);
if (!operationResponse.bodyAsText) return [3 /*break*/, 11];
contentType = res.headers.get("Content-Type");
if (!(contentType === "application/xml" || contentType === "text/xml")) return [3 /*break*/, 10];
xmlParser_1 = new xml2js.Parser(XML2JS_PARSER_OPTS);
parseString = new Promise(function (resolve, reject) {
xmlParser_1.parseString(operationResponse.bodyAsText, function (err, result) {
if (err) {
reject(err);
}
else {
resolve(result);
}
});
});
_b = operationResponse;
return [4 /*yield*/, parseString];
case 9:
_b.parsedBody = _c.sent();
return [3 /*break*/, 11];
case 10:
operationResponse.parsedBody = JSON.parse(operationResponse.bodyAsText);
_c.label = 11;
case 11: return [3 /*break*/, 13];
case 12:
err_3 = _c.sent();
msg = "Error \"" + err_3 + "\" occured while executing JSON.parse on the response body - " + operationResponse.bodyAsText + ".";
errCode = err_3.code || "JSON_PARSE_ERROR";
e = new restError_1.RestError(msg, errCode, res.status, options, res, operationResponse.bodyAsText);
return [2 /*return*/, Promise.reject(e)];
case 13: return [2 /*return*/, Promise.resolve(operationResponse)];
}
});
});

2
dist/lib/util/utils.js.map поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

2
msRestBundle.min.js поставляемый

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

8
typings/lib/httpOperationResponse.d.ts поставляемый
Просмотреть файл

@ -1,7 +1,7 @@
import { WebResource } from "./webResource";
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `bodyAsJson` property when the response body is received in JSON.
* the `parsedBody` property when the response body is received in JSON or XML.
* @class
* Initializes a new instance of the HttpOperationResponse class.
* @constructor
@ -18,11 +18,11 @@ export declare class HttpOperationResponse {
/**
* The response body as text (string format)
*/
bodyAsText: string | null;
bodyAsText?: string | null;
/**
* The response body as parsed JSON
* The response body as parsed JSON or XML
*/
bodyAsJson: {
parsedBody?: {
[key: string]: any;
} | Array<any> | string | number | boolean | null | void;
constructor(request: WebResource, response: Response);

4
typings/lib/msRest.d.ts поставляемый
Просмотреть файл

@ -12,10 +12,10 @@ 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 } from "./util/utils";
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 };
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 };

7
typings/lib/serializer.d.ts поставляемый
Просмотреть файл

@ -1,10 +1,11 @@
export declare class Serializer {
private isXML;
modelMappers?: {
[key: string]: any;
};
constructor(mappers?: {
[key: string]: any;
});
}, isXML?: boolean | undefined);
validateConstraints(mapper: Mapper, value: any, objectName: string): void;
private trimEnd(str, ch);
private bufferToBase64Url(buffer);
@ -69,6 +70,10 @@ export interface BaseMapperType {
[key: string]: any;
}
export interface Mapper {
xmlName?: string;
xmlIsAttribute?: boolean;
xmlElementName?: string;
xmlIsWrapped?: boolean;
readOnly?: boolean;
isConstant?: boolean;
required: boolean;

6
typings/lib/util/utils.d.ts поставляемый
Просмотреть файл

@ -124,6 +124,12 @@ export declare function promiseToCallback(promise: Promise<any>): Function;
* @returns {Function} fn - A function that takes the service callback (cb: ServiceCallback<T>): void
*/
export declare function promiseToServiceCallback<T>(promise: Promise<HttpOperationResponse>): Function;
export declare function stringifyXML(obj: any, opts?: {
rootName?: string;
}): string;
export declare function prepareXMLRootList(obj: any, elementName: string): {
[x: string]: any;
};
/**
* Sends the request and returns the received response.
* @param {WebResource} options - The request to be sent.