Merge pull request #8 from RikkiGibson/NoBuildProductsInGit

No build products in git
This commit is contained in:
Rikki Gibson 2018-04-10 16:41:15 -07:00 коммит произвёл GitHub
Родитель 2c06a7f41e 93ce7dbc72
Коммит 2217e39cd3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
33 изменённых файлов: 918 добавлений и 6059 удалений

7
.gitignore поставляемый
Просмотреть файл

@ -82,5 +82,10 @@ node_modules
SdkCodeGen
output/*
# Typescript output
dist/ms-rest/*
dist/
typings/
*.js
*.js.map

Просмотреть файл

@ -1,8 +1,13 @@
.vscode/
node_modules/
.idea/
samples/
lib/
test/
.travis.yml
gulpfile.js
.gitignore
.git
gulpfile.js
.git
.DS_Store
tsconfig.json
tslint.json
webpack.config.ts

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

@ -1,306 +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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const msRest = require("ms-rest-js");
const constants_1 = require("./util/constants");
const pollingState_1 = require("./pollingState");
const LroStates = constants_1.default.LongRunningOperationStates;
/**
* @class
* Initializes a new instance of the AzureServiceClient class.
* @constructor
*
* @param {msRest.ServiceClientCredentilas} credentials - ApplicationTokenCredentials or
* UserTokenCredentials object used for authentication.
* @param {AzureServiceClientOptions} options - The parameter options used by AzureServiceClient
*/
class AzureServiceClient extends msRest.ServiceClient {
constructor(credentials, options) {
super(credentials, options);
this.acceptLanguage = constants_1.default.DEFAULT_LANGUAGE;
this.generateClientRequestId = true;
this.longRunningOperationRetryTimeout = 30;
this.rpRegistrationRetryTimeout = 30;
this.acceptLanguage = constants_1.default.DEFAULT_LANGUAGE;
this.generateClientRequestId = true;
this.longRunningOperationRetryTimeout = 30;
if (!options)
options = {};
if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
this.acceptLanguage = options.acceptLanguage;
}
if (options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) {
this.generateClientRequestId = options.generateClientRequestId;
}
if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout;
}
if (options.rpRegistrationRetryTimeout !== null && options.rpRegistrationRetryTimeout !== undefined) {
this.rpRegistrationRetryTimeout = options.rpRegistrationRetryTimeout;
}
try {
const moduleName = "ms-rest-azure";
const moduleVersion = constants_1.default.msRestAzureVersion;
this.addUserAgentInfo(`${moduleName}/${moduleVersion}`);
}
catch (err) {
// do nothing
}
}
/**
* Provides a mechanism to make a request that will poll and provide the final result.
* @param {msRest.RequestPrepareOptions|msRest.WebResource} request - The request object
* @param {msRest.RequestOptionsBase} [options] Additional options to be sent while making the request
* @returns {Promise<msRest.HttpOperationResponse>} The HttpOperationResponse containing the final polling request, response and the responseBody.
*/
sendLongRunningRequest(request, options) {
return __awaiter(this, void 0, void 0, function* () {
const self = this;
let initialResponse;
try {
initialResponse = yield self.sendRequest(request);
}
catch (err) {
return Promise.reject(err);
}
let finalResponse;
try {
finalResponse = yield self.getLongRunningOperationResult(initialResponse, options);
}
catch (err) {
return Promise.reject(err);
}
return Promise.resolve(finalResponse);
});
}
/**
* Verified whether an unexpected polling status code for long running operation was received for the response of the initial request.
* @param {msRest.HttpOperationResponse} initialResponse - Response to the initial request that was sent as a part of the asynchronous operation.
*/
checkResponseStatusCodeFailed(initialResponse) {
const statusCode = initialResponse.response.status;
const method = initialResponse.request.method;
if (statusCode === 200 || statusCode === 202 ||
(statusCode === 201 && method === "PUT") ||
(statusCode === 204 && (method === "DELETE" || method === "POST"))) {
return false;
}
else {
return true;
}
}
/**
* Poll Azure long running PUT, PATCH, POST or DELETE operations.
* @param {msRest.HttpOperationResponse} resultOfInitialRequest - result/response of the initial request which is a part of the asynchronous polling operation.
* @param {msRest.RequestOptionsBase} [options] - custom request options.
* @returns {Promise<msRest.HttpOperationResponse>} result - The final response after polling is complete.
*/
getLongRunningOperationResult(resultOfInitialRequest, options) {
return __awaiter(this, void 0, void 0, function* () {
const self = this;
const initialRequestMethod = resultOfInitialRequest.request.method;
if (self.checkResponseStatusCodeFailed(resultOfInitialRequest)) {
return Promise.reject(`Unexpected polling status code from long running operation ` +
`"${resultOfInitialRequest.response.status}" for method "${initialRequestMethod}".`);
}
let pollingState;
try {
pollingState = new pollingState_1.default(resultOfInitialRequest, self.longRunningOperationRetryTimeout);
pollingState.optionsOfInitialRequest = options;
}
catch (error) {
return Promise.reject(error);
}
const resourceUrl = resultOfInitialRequest.request.url;
while (![LroStates.Succeeded, LroStates.Failed, LroStates.Canceled].some((e) => { return e === pollingState.status; })) {
yield msRest.delay(pollingState.getTimeout());
if (pollingState.azureAsyncOperationHeaderLink) {
yield self.updateStateFromAzureAsyncOperationHeader(pollingState, true);
}
else if (pollingState.locationHeaderLink) {
yield self.updateStateFromLocationHeader(initialRequestMethod, pollingState);
}
else if (initialRequestMethod === "PUT") {
yield self.updateStateFromGetResourceOperation(resourceUrl, pollingState);
}
else {
return Promise.reject(new Error("Location header is missing from long running operation."));
}
}
if (pollingState.status === LroStates.Succeeded) {
if ((pollingState.azureAsyncOperationHeaderLink || !pollingState.resource) &&
(initialRequestMethod === "PUT" || initialRequestMethod === "PATCH")) {
yield self.updateStateFromGetResourceOperation(resourceUrl, pollingState);
return Promise.resolve(pollingState.getOperationResponse());
}
else {
return Promise.resolve(pollingState.getOperationResponse());
}
}
else {
return Promise.reject(pollingState.getRestError());
}
});
}
/**
* Retrieve operation status by polling from "azure-asyncoperation" header.
* @param {PollingState} pollingState - The object to persist current operation state.
* @param {boolean} inPostOrDelete - Invoked by Post Or Delete operation.
*/
updateStateFromAzureAsyncOperationHeader(pollingState, inPostOrDelete = false) {
return __awaiter(this, void 0, void 0, function* () {
let result;
try {
result = yield this.getStatus(pollingState.azureAsyncOperationHeaderLink, pollingState.optionsOfInitialRequest);
}
catch (err) {
return Promise.reject(err);
}
const parsedResponse = result.parsedBody;
if (!parsedResponse) {
return Promise.reject(new Error("The response from long running operation does not contain a body."));
}
else if (parsedResponse && !parsedResponse.status) {
return Promise.reject(new Error(`The response "${result.bodyAsText}" from long running operation does not contain the status property.`));
}
pollingState.status = parsedResponse.status;
pollingState.error = parsedResponse.error;
pollingState.updateResponse(result.response);
pollingState.request = result.request;
pollingState.resource = undefined;
if (inPostOrDelete) {
pollingState.resource = result.parsedBody;
}
return Promise.resolve();
});
}
/**
* Retrieve PUT operation status by polling from "location" header.
* @param {string} method - The HTTP method.
* @param {PollingState} pollingState - The object to persist current operation state.
*/
updateStateFromLocationHeader(method, pollingState) {
return __awaiter(this, void 0, void 0, function* () {
let result;
try {
result = yield this.getStatus(pollingState.locationHeaderLink, pollingState.optionsOfInitialRequest);
}
catch (err) {
return Promise.reject(err);
}
const parsedResponse = result.parsedBody;
pollingState.updateResponse(result.response);
pollingState.request = result.request;
const statusCode = result.response.status;
if (statusCode === 202) {
pollingState.status = LroStates.InProgress;
}
else if (statusCode === 200 ||
(statusCode === 201 && (method === "PUT" || method === "PATCH")) ||
(statusCode === 204 && (method === "DELETE" || method === "POST"))) {
pollingState.status = LroStates.Succeeded;
pollingState.resource = parsedResponse;
// we might not throw an error, but initialize here just in case.
pollingState.error = new msRest.RestError(`Long running operation failed with status "${pollingState.status}".`);
pollingState.error.code = pollingState.status;
}
else {
return Promise.reject(new Error(`The response with status code ${statusCode} from polling for ` +
`long running operation url "${pollingState.locationHeaderLink}" is not valid.`));
}
});
}
/**
* Polling for resource status.
* @param {string} resourceUrl - The url of resource.
* @param {PollingState} pollingState - The object to persist current operation state.
*/
updateStateFromGetResourceOperation(resourceUrl, pollingState) {
return __awaiter(this, void 0, void 0, function* () {
let result;
try {
result = yield this.getStatus(resourceUrl, pollingState.optionsOfInitialRequest);
}
catch (err) {
return Promise.reject(err);
}
if (!result.parsedBody) {
return Promise.reject(new Error("The response from long running operation does not contain a body."));
}
const parsedResponse = result.parsedBody;
pollingState.status = LroStates.Succeeded;
if (parsedResponse && parsedResponse.properties && parsedResponse.properties.provisioningState) {
pollingState.status = parsedResponse.properties.provisioningState;
}
pollingState.updateResponse(result.response);
pollingState.request = result.request;
pollingState.resource = parsedResponse;
// we might not throw an error, but initialize here just in case.
pollingState.error = new msRest.RestError(`Long running operation failed with status "${pollingState.status}".`);
pollingState.error.code = pollingState.status;
return Promise.resolve();
});
}
/**
* Retrieves operation status by querying the operation URL.
* @param {string} operationUrl - URL used to poll operation result.
* @param {object} options - Options that can be set on the request object
*/
getStatus(operationUrl, options) {
return __awaiter(this, void 0, void 0, function* () {
const self = this;
// Construct URL
const requestUrl = operationUrl.replace(" ", "%20");
// Create HTTP request object
const httpRequest = {
method: "GET",
url: requestUrl,
headers: {}
};
if (options) {
const customHeaders = options.customHeaders;
for (const headerName in customHeaders) {
if (customHeaders.hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = customHeaders[headerName];
}
}
}
let operationResponse;
try {
operationResponse = yield self.sendRequest(httpRequest);
}
catch (err) {
return Promise.reject(err);
}
const statusCode = operationResponse.response.status;
const responseBody = operationResponse.parsedBody;
if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202 && statusCode !== 204) {
const error = new msRest.RestError(`Invalid status code with response body "${operationResponse.bodyAsText}" occurred ` +
`when polling for operation status.`);
error.statusCode = statusCode;
error.request = msRest.stripRequest(operationResponse.request);
error.response = operationResponse.response;
try {
error.body = responseBody;
}
catch (badResponse) {
error.message += ` Error "${badResponse}" occured while deserializing the response body - "${operationResponse.bodyAsText}".`;
error.body = operationResponse.bodyAsText;
}
return Promise.reject(error);
}
return Promise.resolve(operationResponse);
});
}
}
exports.AzureServiceClient = AzureServiceClient;
//# sourceMappingURL=azureServiceClient.js.map

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

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

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

@ -1,14 +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.BaseResourceMapper = {
required: false,
serializedName: "BaseResource",
type: {
name: "Composite",
className: "BaseResource",
modelProperties: {}
}
};
//# sourceMappingURL=baseResource.js.map

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

@ -1 +0,0 @@
{"version":3,"file":"baseResource.js","sourceRoot":"","sources":["../../lib/baseResource.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAQlF,QAAA,kBAAkB,GAAG;IAChC,QAAQ,EAAE,KAAK;IACf,cAAc,EAAE,cAAc;IAC9B,IAAI,EAAE;QACJ,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,cAAc;QACzB,eAAe,EAAE,EAChB;KACF;CACF,CAAC"}

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

@ -1,51 +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.CloudErrorMapper = {
required: false,
serializedName: "CloudError",
type: {
name: "Composite",
className: "CloudError",
modelProperties: {
code: {
required: true,
serializedName: "code",
type: {
name: "String"
}
},
message: {
required: true,
serializedName: "message",
type: {
name: "String"
}
},
target: {
required: false,
serializedName: "target",
type: {
name: "String"
}
},
details: {
required: false,
serializedName: "details",
type: {
name: "Sequence",
element: {
required: false,
serializedName: "CloudErrorElementType",
type: {
name: "Composite",
className: "CloudError"
}
}
}
}
}
}
};
//# sourceMappingURL=cloudError.js.map

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

@ -1 +0,0 @@
{"version":3,"file":"cloudError.js","sourceRoot":"","sources":["../../lib/cloudError.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAyBlF,QAAA,gBAAgB,GAAG;IAC9B,QAAQ,EAAE,KAAK;IACf,cAAc,EAAE,YAAY;IAC5B,IAAI,EAAE;QACJ,IAAI,EAAE,WAAW;QACjB,SAAS,EAAE,YAAY;QACvB,eAAe,EAAE;YACf,IAAI,EAAE;gBACJ,QAAQ,EAAE,IAAI;gBACd,cAAc,EAAE,MAAM;gBACtB,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,OAAO,EAAE;gBACP,QAAQ,EAAE,IAAI;gBACd,cAAc,EAAE,SAAS;gBACzB,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,MAAM,EAAE;gBACN,QAAQ,EAAE,KAAK;gBACf,cAAc,EAAE,QAAQ;gBACxB,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,OAAO,EAAE;gBACP,QAAQ,EAAE,KAAK;gBACf,cAAc,EAAE,SAAS;gBACzB,IAAI,EAAE;oBACJ,IAAI,EAAE,UAAU;oBAChB,OAAO,EAAE;wBACP,QAAQ,EAAE,KAAK;wBACf,cAAc,EAAE,uBAAuB;wBACvC,IAAI,EAAE;4BACJ,IAAI,EAAE,WAAW;4BACjB,SAAS,EAAE,YAAY;yBACxB;qBACF;iBACF;aACF;SACF;KACF;CACF,CAAC"}

Просмотреть файл

@ -1,27 +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 });
const ms_rest_js_1 = require("ms-rest-js");
/**
* Creates a new CognitiveServicesCredentials object.
*
* @constructor
* @param {string} subscriptionKey The CognitiveServices subscription key
*/
class CognitiveServicesCredentials extends ms_rest_js_1.ApiKeyCredentials {
constructor(subscriptionKey) {
if (!subscriptionKey || (subscriptionKey && typeof subscriptionKey.valueOf() !== "string")) {
throw new Error("subscriptionKey cannot be null or undefined and must be of type string.");
}
const options = {
inHeader: {
"Ocp-Apim-Subscription-Key": subscriptionKey,
"X-BingApis-SDK-Client": "node-SDK"
}
};
super(options);
}
}
exports.CognitiveServicesCredentials = CognitiveServicesCredentials;
//# sourceMappingURL=cognitiveServicesCredentials.js.map

Просмотреть файл

@ -1 +0,0 @@
{"version":3,"file":"cognitiveServicesCredentials.js","sourceRoot":"","sources":["../../../lib/credentials/cognitiveServicesCredentials.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,2CAA+C;AAE/C;;;;;GAKG;AACH,kCAA0C,SAAQ,8BAAiB;IACjE,YAAY,eAAuB;QACjC,IAAI,CAAC,eAAe,IAAI,CAAC,eAAe,IAAI,OAAO,eAAe,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC,EAAE;YAC1F,MAAM,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC;SAC5F;QAED,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE;gBACR,2BAA2B,EAAE,eAAe;gBAC5C,uBAAuB,EAAE,UAAU;aACpC;SACF,CAAC;QACF,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAdD,oEAcC"}

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

@ -1,15 +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 });
const azureServiceClient_1 = require("./azureServiceClient");
exports.AzureServiceClient = azureServiceClient_1.AzureServiceClient;
const constants_1 = require("./util/constants");
exports.Constants = constants_1.default;
const cloudError_1 = require("./cloudError");
exports.CloudErrorMapper = cloudError_1.CloudErrorMapper;
const baseResource_1 = require("./baseResource");
exports.BaseResourceMapper = baseResource_1.BaseResourceMapper;
const cognitiveServicesCredentials_1 = require("./credentials/cognitiveServicesCredentials");
exports.CognitiveServicesCredentials = cognitiveServicesCredentials_1.CognitiveServicesCredentials;
//# sourceMappingURL=msRestAzure.js.map

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

@ -1 +0,0 @@
{"version":3,"file":"msRestAzure.js","sourceRoot":"","sources":["../../lib/msRestAzure.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,6DAAqF;AAK5E,6BAL2B,uCAAkB,CAK3B;AAJ3B,gDAAyC;AAIe,oBAJjD,mBAAS,CAIiD;AAHjE,6CAA4D;AAGmB,2BAH1D,6BAAgB,CAG0D;AAF/F,iDAAkE;AAE6C,6BAFxF,iCAAkB,CAEwF;AADjI,6FAA0F;AACyC,uCAD1H,2DAA4B,CAC0H"}

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

@ -1,149 +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 });
const constants_1 = require("./util/constants");
const msRest = require("ms-rest-js");
const LroStates = constants_1.default.LongRunningOperationStates;
/**
* @class
* Initializes a new instance of the PollingState class.
*/
class PollingState {
constructor(resultOfInitialRequest, retryTimeout = 30) {
/**
* @param {number} [retryTimeout] - The timeout in seconds to retry on intermediate operation results. Default Value is 30.
*/
this.retryTimeout = 30;
this.resultOfInitialRequest = resultOfInitialRequest;
this.retryTimeout = retryTimeout;
this.updateResponse(resultOfInitialRequest.response);
this.request = resultOfInitialRequest.request;
// Parse response.body & assign it as the resource.
try {
if (resultOfInitialRequest.bodyAsText && resultOfInitialRequest.bodyAsText.length > 0) {
this.resource = JSON.parse(resultOfInitialRequest.bodyAsText);
}
else {
this.resource = resultOfInitialRequest.parsedBody;
}
}
catch (error) {
const deserializationError = new msRest.RestError(`Error "${error}" occurred in parsing the responseBody " +
"while creating the PollingState for Long Running Operation- "${resultOfInitialRequest.bodyAsText}"`);
deserializationError.request = resultOfInitialRequest.request;
deserializationError.response = resultOfInitialRequest.response;
throw deserializationError;
}
switch (this.response.status) {
case 202:
this.status = LroStates.InProgress;
break;
case 204:
this.status = LroStates.Succeeded;
break;
case 201:
if (this.resource && this.resource.properties && this.resource.properties.provisioningState) {
this.status = this.resource.properties.provisioningState;
}
else {
this.status = LroStates.InProgress;
}
break;
case 200:
if (this.resource && this.resource.properties && this.resource.properties.provisioningState) {
this.status = this.resource.properties.provisioningState;
}
else {
this.status = LroStates.Succeeded;
}
break;
default:
this.status = LroStates.Failed;
break;
}
}
/**
* Update cached data using the provided response object
* @param {Response} [response] - provider response object.
*/
updateResponse(response) {
this.response = response;
if (response && response.headers) {
const asyncOperationHeader = response.headers.get("azure-asyncoperation");
const locationHeader = response.headers.get("location");
if (asyncOperationHeader) {
this.azureAsyncOperationHeaderLink = asyncOperationHeader;
}
if (locationHeader) {
this.locationHeaderLink = locationHeader;
}
}
}
/**
* Gets timeout in milliseconds.
* @returns {number} timeout
*/
getTimeout() {
if (this.retryTimeout || this.retryTimeout === 0) {
return this.retryTimeout * 1000;
}
if (this.response) {
const retryAfter = this.response.headers.get("retry-after");
if (retryAfter) {
return parseInt(retryAfter) * 1000;
}
}
return 30 * 1000;
}
/**
* Returns long running operation result.
* @returns {msRest.HttpOperationResponse} HttpOperationResponse
*/
getOperationResponse() {
const result = new msRest.HttpOperationResponse(this.request, this.response);
if (this.resource && typeof this.resource.valueOf() === "string") {
result.bodyAsText = this.resource;
result.parsedBody = JSON.parse(this.resource);
}
else {
result.parsedBody = this.resource;
result.bodyAsText = JSON.stringify(this.resource);
}
return result;
}
/**
* Returns an Error on operation failure.
* @param {Error} err - The error object.
* @returns {msRest.RestError} The RestError defined in the runtime.
*/
getRestError(err) {
let errMsg;
let errCode = undefined;
const error = new msRest.RestError("");
error.request = msRest.stripRequest(this.request);
error.response = this.response;
const parsedResponse = this.resource;
if (err && err.message) {
errMsg = `Long running operation failed with error: "${err.message}".`;
}
else {
errMsg = `Long running operation failed with status: "${this.status}".`;
}
if (parsedResponse) {
if (parsedResponse.error && parsedResponse.error.message) {
errMsg = `Long running operation failed with error: "${parsedResponse.error.message}".`;
}
if (parsedResponse.error && parsedResponse.error.code) {
errCode = parsedResponse.error.code;
}
}
error.message = errMsg;
if (errCode)
error.code = errCode;
error.body = parsedResponse;
return error;
}
}
exports.default = PollingState;
//# sourceMappingURL=pollingState.js.map

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

@ -1 +0,0 @@
{"version":3,"file":"pollingState.js","sourceRoot":"","sources":["../../lib/pollingState.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,gDAAyC;AACzC,qCAAqC;AACrC,MAAM,SAAS,GAAG,mBAAS,CAAC,0BAA0B,CAAC;AAEvD;;;GAGG;AACH;IA0CE,YAAY,sBAAoD,EAAE,YAAY,GAAG,EAAE;QArBnF;;WAEG;QACH,iBAAY,GAAG,EAAE,CAAC;QAmBhB,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;QACrD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,OAAO,CAAC;QAC9C,mDAAmD;QACnD,IAAI;YACF,IAAI,sBAAsB,CAAC,UAAU,IAAI,sBAAsB,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrF,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAC;aAC/D;iBAAM;gBACL,IAAI,CAAC,QAAQ,GAAG,sBAAsB,CAAC,UAAU,CAAC;aACnD;SACF;QAAC,OAAO,KAAK,EAAE;YACd,MAAM,oBAAoB,GAAG,IAAI,MAAM,CAAC,SAAS,CAAC,UAAU,KAAK;wEACC,sBAAsB,CAAC,UAAU,G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(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 });
const Constants = {
/**
* Defines constants for long running operation states.
*
* @const
* @type {string}
*/
LongRunningOperationStates: {
InProgress: "InProgress",
Succeeded: "Succeeded",
Failed: "Failed",
Canceled: "Canceled"
},
/**
* The default language in the request header.
*
* @const
* @type {string}
*/
DEFAULT_LANGUAGE: "en-us",
/**
* The ms-rest-azure version.
* @const
* @type {string}
*/
msRestAzureVersion: "0.1.0"
};
exports.default = Constants;
//# sourceMappingURL=constants.js.map

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

@ -1 +0,0 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../lib/util/constants.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D,+FAA+F;;AAE/F,MAAM,SAAS,GAAG;IAChB;;;;;OAKG;IACH,0BAA0B,EAAE;QAC1B,UAAU,EAAE,YAAY;QACxB,SAAS,EAAE,WAAW;QACtB,MAAM,EAAE,QAAQ;QAChB,QAAQ,EAAE,UAAU;KACrB;IAED;;;;;OAKG;IACH,gBAAgB,EAAE,OAAO;IAEzB;;;;OAIG;IACH,kBAAkB,EAAE,OAAO;CAC5B,CAAC;AAEF,kBAAe,SAAS,CAAC"}

Просмотреть файл

@ -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/"))
);

Просмотреть файл

@ -1,712 +0,0 @@
var msRestAzure =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = msRest;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"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 });
const Constants = {
/**
* Defines constants for long running operation states.
*
* @const
* @type {string}
*/
LongRunningOperationStates: {
InProgress: "InProgress",
Succeeded: "Succeeded",
Failed: "Failed",
Canceled: "Canceled"
},
/**
* The default language in the request header.
*
* @const
* @type {string}
*/
DEFAULT_LANGUAGE: "en-us",
/**
* The ms-rest-azure version.
* @const
* @type {string}
*/
msRestAzureVersion: "0.1.0"
};
exports.default = Constants;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"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 });
const azureServiceClient_1 = __webpack_require__(3);
exports.AzureServiceClient = azureServiceClient_1.AzureServiceClient;
const constants_1 = __webpack_require__(1);
exports.Constants = constants_1.default;
const cloudError_1 = __webpack_require__(5);
exports.CloudErrorMapper = cloudError_1.CloudErrorMapper;
const baseResource_1 = __webpack_require__(6);
exports.BaseResourceMapper = baseResource_1.BaseResourceMapper;
const cognitiveServicesCredentials_1 = __webpack_require__(7);
exports.CognitiveServicesCredentials = cognitiveServicesCredentials_1.CognitiveServicesCredentials;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const msRest = __webpack_require__(0);
const constants_1 = __webpack_require__(1);
const pollingState_1 = __webpack_require__(4);
const LroStates = constants_1.default.LongRunningOperationStates;
/**
* @class
* Initializes a new instance of the AzureServiceClient class.
* @constructor
*
* @param {msRest.ServiceClientCredentilas} credentials - ApplicationTokenCredentials or
* UserTokenCredentials object used for authentication.
* @param {AzureServiceClientOptions} options - The parameter options used by AzureServiceClient
*/
class AzureServiceClient extends msRest.ServiceClient {
constructor(credentials, options) {
super(credentials, options);
this.acceptLanguage = constants_1.default.DEFAULT_LANGUAGE;
this.generateClientRequestId = true;
this.longRunningOperationRetryTimeout = 30;
this.rpRegistrationRetryTimeout = 30;
this.acceptLanguage = constants_1.default.DEFAULT_LANGUAGE;
this.generateClientRequestId = true;
this.longRunningOperationRetryTimeout = 30;
if (!options)
options = {};
if (options.acceptLanguage !== null && options.acceptLanguage !== undefined) {
this.acceptLanguage = options.acceptLanguage;
}
if (options.generateClientRequestId !== null && options.generateClientRequestId !== undefined) {
this.generateClientRequestId = options.generateClientRequestId;
}
if (options.longRunningOperationRetryTimeout !== null && options.longRunningOperationRetryTimeout !== undefined) {
this.longRunningOperationRetryTimeout = options.longRunningOperationRetryTimeout;
}
if (options.rpRegistrationRetryTimeout !== null && options.rpRegistrationRetryTimeout !== undefined) {
this.rpRegistrationRetryTimeout = options.rpRegistrationRetryTimeout;
}
try {
const moduleName = "ms-rest-azure";
const moduleVersion = constants_1.default.msRestAzureVersion;
this.addUserAgentInfo(`${moduleName}/${moduleVersion}`);
}
catch (err) {
// do nothing
}
}
/**
* Provides a mechanism to make a request that will poll and provide the final result.
* @param {msRest.RequestPrepareOptions|msRest.WebResource} request - The request object
* @param {msRest.RequestOptionsBase} [options] Additional options to be sent while making the request
* @returns {Promise<msRest.HttpOperationResponse>} The HttpOperationResponse containing the final polling request, response and the responseBody.
*/
sendLongRunningRequest(request, options) {
return __awaiter(this, void 0, void 0, function* () {
const self = this;
let initialResponse;
try {
initialResponse = yield self.sendRequest(request);
}
catch (err) {
return Promise.reject(err);
}
let finalResponse;
try {
finalResponse = yield self.getLongRunningOperationResult(initialResponse, options);
}
catch (err) {
return Promise.reject(err);
}
return Promise.resolve(finalResponse);
});
}
/**
* Verified whether an unexpected polling status code for long running operation was received for the response of the initial request.
* @param {msRest.HttpOperationResponse} initialResponse - Response to the initial request that was sent as a part of the asynchronous operation.
*/
checkResponseStatusCodeFailed(initialResponse) {
const statusCode = initialResponse.response.status;
const method = initialResponse.request.method;
if (statusCode === 200 || statusCode === 202 ||
(statusCode === 201 && method === "PUT") ||
(statusCode === 204 && (method === "DELETE" || method === "POST"))) {
return false;
}
else {
return true;
}
}
/**
* Poll Azure long running PUT, PATCH, POST or DELETE operations.
* @param {msRest.HttpOperationResponse} resultOfInitialRequest - result/response of the initial request which is a part of the asynchronous polling operation.
* @param {msRest.RequestOptionsBase} [options] - custom request options.
* @returns {Promise<msRest.HttpOperationResponse>} result - The final response after polling is complete.
*/
getLongRunningOperationResult(resultOfInitialRequest, options) {
return __awaiter(this, void 0, void 0, function* () {
const self = this;
const initialRequestMethod = resultOfInitialRequest.request.method;
if (self.checkResponseStatusCodeFailed(resultOfInitialRequest)) {
return Promise.reject(`Unexpected polling status code from long running operation ` +
`"${resultOfInitialRequest.response.status}" for method "${initialRequestMethod}".`);
}
let pollingState;
try {
pollingState = new pollingState_1.default(resultOfInitialRequest, self.longRunningOperationRetryTimeout);
pollingState.optionsOfInitialRequest = options;
}
catch (error) {
return Promise.reject(error);
}
const resourceUrl = resultOfInitialRequest.request.url;
while (![LroStates.Succeeded, LroStates.Failed, LroStates.Canceled].some((e) => { return e === pollingState.status; })) {
yield msRest.delay(pollingState.getTimeout());
if (pollingState.azureAsyncOperationHeaderLink) {
yield self.updateStateFromAzureAsyncOperationHeader(pollingState, true);
}
else if (pollingState.locationHeaderLink) {
yield self.updateStateFromLocationHeader(initialRequestMethod, pollingState);
}
else if (initialRequestMethod === "PUT") {
yield self.updateStateFromGetResourceOperation(resourceUrl, pollingState);
}
else {
return Promise.reject(new Error("Location header is missing from long running operation."));
}
}
if (pollingState.status === LroStates.Succeeded) {
if ((pollingState.azureAsyncOperationHeaderLink || !pollingState.resource) &&
(initialRequestMethod === "PUT" || initialRequestMethod === "PATCH")) {
yield self.updateStateFromGetResourceOperation(resourceUrl, pollingState);
return Promise.resolve(pollingState.getOperationResponse());
}
else {
return Promise.resolve(pollingState.getOperationResponse());
}
}
else {
return Promise.reject(pollingState.getRestError());
}
});
}
/**
* Retrieve operation status by polling from "azure-asyncoperation" header.
* @param {PollingState} pollingState - The object to persist current operation state.
* @param {boolean} inPostOrDelete - Invoked by Post Or Delete operation.
*/
updateStateFromAzureAsyncOperationHeader(pollingState, inPostOrDelete = false) {
return __awaiter(this, void 0, void 0, function* () {
let result;
try {
result = yield this.getStatus(pollingState.azureAsyncOperationHeaderLink, pollingState.optionsOfInitialRequest);
}
catch (err) {
return Promise.reject(err);
}
const parsedResponse = result.parsedBody;
if (!parsedResponse) {
return Promise.reject(new Error("The response from long running operation does not contain a body."));
}
else if (parsedResponse && !parsedResponse.status) {
return Promise.reject(new Error(`The response "${result.bodyAsText}" from long running operation does not contain the status property.`));
}
pollingState.status = parsedResponse.status;
pollingState.error = parsedResponse.error;
pollingState.updateResponse(result.response);
pollingState.request = result.request;
pollingState.resource = undefined;
if (inPostOrDelete) {
pollingState.resource = result.parsedBody;
}
return Promise.resolve();
});
}
/**
* Retrieve PUT operation status by polling from "location" header.
* @param {string} method - The HTTP method.
* @param {PollingState} pollingState - The object to persist current operation state.
*/
updateStateFromLocationHeader(method, pollingState) {
return __awaiter(this, void 0, void 0, function* () {
let result;
try {
result = yield this.getStatus(pollingState.locationHeaderLink, pollingState.optionsOfInitialRequest);
}
catch (err) {
return Promise.reject(err);
}
const parsedResponse = result.parsedBody;
pollingState.updateResponse(result.response);
pollingState.request = result.request;
const statusCode = result.response.status;
if (statusCode === 202) {
pollingState.status = LroStates.InProgress;
}
else if (statusCode === 200 ||
(statusCode === 201 && (method === "PUT" || method === "PATCH")) ||
(statusCode === 204 && (method === "DELETE" || method === "POST"))) {
pollingState.status = LroStates.Succeeded;
pollingState.resource = parsedResponse;
// we might not throw an error, but initialize here just in case.
pollingState.error = new msRest.RestError(`Long running operation failed with status "${pollingState.status}".`);
pollingState.error.code = pollingState.status;
}
else {
return Promise.reject(new Error(`The response with status code ${statusCode} from polling for ` +
`long running operation url "${pollingState.locationHeaderLink}" is not valid.`));
}
});
}
/**
* Polling for resource status.
* @param {string} resourceUrl - The url of resource.
* @param {PollingState} pollingState - The object to persist current operation state.
*/
updateStateFromGetResourceOperation(resourceUrl, pollingState) {
return __awaiter(this, void 0, void 0, function* () {
let result;
try {
result = yield this.getStatus(resourceUrl, pollingState.optionsOfInitialRequest);
}
catch (err) {
return Promise.reject(err);
}
if (!result.parsedBody) {
return Promise.reject(new Error("The response from long running operation does not contain a body."));
}
const parsedResponse = result.parsedBody;
pollingState.status = LroStates.Succeeded;
if (parsedResponse && parsedResponse.properties && parsedResponse.properties.provisioningState) {
pollingState.status = parsedResponse.properties.provisioningState;
}
pollingState.updateResponse(result.response);
pollingState.request = result.request;
pollingState.resource = parsedResponse;
// we might not throw an error, but initialize here just in case.
pollingState.error = new msRest.RestError(`Long running operation failed with status "${pollingState.status}".`);
pollingState.error.code = pollingState.status;
return Promise.resolve();
});
}
/**
* Retrieves operation status by querying the operation URL.
* @param {string} operationUrl - URL used to poll operation result.
* @param {object} options - Options that can be set on the request object
*/
getStatus(operationUrl, options) {
return __awaiter(this, void 0, void 0, function* () {
const self = this;
// Construct URL
const requestUrl = operationUrl.replace(" ", "%20");
// Create HTTP request object
const httpRequest = {
method: "GET",
url: requestUrl,
headers: {}
};
if (options) {
const customHeaders = options.customHeaders;
for (const headerName in customHeaders) {
if (customHeaders.hasOwnProperty(headerName)) {
httpRequest.headers[headerName] = customHeaders[headerName];
}
}
}
let operationResponse;
try {
operationResponse = yield self.sendRequest(httpRequest);
}
catch (err) {
return Promise.reject(err);
}
const statusCode = operationResponse.response.status;
const responseBody = operationResponse.parsedBody;
if (statusCode !== 200 && statusCode !== 201 && statusCode !== 202 && statusCode !== 204) {
const error = new msRest.RestError(`Invalid status code with response body "${operationResponse.bodyAsText}" occurred ` +
`when polling for operation status.`);
error.statusCode = statusCode;
error.request = msRest.stripRequest(operationResponse.request);
error.response = operationResponse.response;
try {
error.body = responseBody;
}
catch (badResponse) {
error.message += ` Error "${badResponse}" occured while deserializing the response body - "${operationResponse.bodyAsText}".`;
error.body = operationResponse.bodyAsText;
}
return Promise.reject(error);
}
return Promise.resolve(operationResponse);
});
}
}
exports.AzureServiceClient = AzureServiceClient;
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"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 });
const constants_1 = __webpack_require__(1);
const msRest = __webpack_require__(0);
const LroStates = constants_1.default.LongRunningOperationStates;
/**
* @class
* Initializes a new instance of the PollingState class.
*/
class PollingState {
constructor(resultOfInitialRequest, retryTimeout = 30) {
/**
* @param {number} [retryTimeout] - The timeout in seconds to retry on intermediate operation results. Default Value is 30.
*/
this.retryTimeout = 30;
this.resultOfInitialRequest = resultOfInitialRequest;
this.retryTimeout = retryTimeout;
this.updateResponse(resultOfInitialRequest.response);
this.request = resultOfInitialRequest.request;
// Parse response.body & assign it as the resource.
try {
if (resultOfInitialRequest.bodyAsText && resultOfInitialRequest.bodyAsText.length > 0) {
this.resource = JSON.parse(resultOfInitialRequest.bodyAsText);
}
else {
this.resource = resultOfInitialRequest.parsedBody;
}
}
catch (error) {
const deserializationError = new msRest.RestError(`Error "${error}" occurred in parsing the responseBody " +
"while creating the PollingState for Long Running Operation- "${resultOfInitialRequest.bodyAsText}"`);
deserializationError.request = resultOfInitialRequest.request;
deserializationError.response = resultOfInitialRequest.response;
throw deserializationError;
}
switch (this.response.status) {
case 202:
this.status = LroStates.InProgress;
break;
case 204:
this.status = LroStates.Succeeded;
break;
case 201:
if (this.resource && this.resource.properties && this.resource.properties.provisioningState) {
this.status = this.resource.properties.provisioningState;
}
else {
this.status = LroStates.InProgress;
}
break;
case 200:
if (this.resource && this.resource.properties && this.resource.properties.provisioningState) {
this.status = this.resource.properties.provisioningState;
}
else {
this.status = LroStates.Succeeded;
}
break;
default:
this.status = LroStates.Failed;
break;
}
}
/**
* Update cached data using the provided response object
* @param {Response} [response] - provider response object.
*/
updateResponse(response) {
this.response = response;
if (response && response.headers) {
const asyncOperationHeader = response.headers.get("azure-asyncoperation");
const locationHeader = response.headers.get("location");
if (asyncOperationHeader) {
this.azureAsyncOperationHeaderLink = asyncOperationHeader;
}
if (locationHeader) {
this.locationHeaderLink = locationHeader;
}
}
}
/**
* Gets timeout in milliseconds.
* @returns {number} timeout
*/
getTimeout() {
if (this.retryTimeout || this.retryTimeout === 0) {
return this.retryTimeout * 1000;
}
if (this.response) {
const retryAfter = this.response.headers.get("retry-after");
if (retryAfter) {
return parseInt(retryAfter) * 1000;
}
}
return 30 * 1000;
}
/**
* Returns long running operation result.
* @returns {msRest.HttpOperationResponse} HttpOperationResponse
*/
getOperationResponse() {
const result = new msRest.HttpOperationResponse(this.request, this.response);
if (this.resource && typeof this.resource.valueOf() === "string") {
result.bodyAsText = this.resource;
result.parsedBody = JSON.parse(this.resource);
}
else {
result.parsedBody = this.resource;
result.bodyAsText = JSON.stringify(this.resource);
}
return result;
}
/**
* Returns an Error on operation failure.
* @param {Error} err - The error object.
* @returns {msRest.RestError} The RestError defined in the runtime.
*/
getRestError(err) {
let errMsg;
let errCode = undefined;
const error = new msRest.RestError("");
error.request = msRest.stripRequest(this.request);
error.response = this.response;
const parsedResponse = this.resource;
if (err && err.message) {
errMsg = `Long running operation failed with error: "${err.message}".`;
}
else {
errMsg = `Long running operation failed with status: "${this.status}".`;
}
if (parsedResponse) {
if (parsedResponse.error && parsedResponse.error.message) {
errMsg = `Long running operation failed with error: "${parsedResponse.error.message}".`;
}
if (parsedResponse.error && parsedResponse.error.code) {
errCode = parsedResponse.error.code;
}
}
error.message = errMsg;
if (errCode)
error.code = errCode;
error.body = parsedResponse;
return error;
}
}
exports.default = PollingState;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"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.CloudErrorMapper = {
required: false,
serializedName: "CloudError",
type: {
name: "Composite",
className: "CloudError",
modelProperties: {
code: {
required: true,
serializedName: "code",
type: {
name: "String"
}
},
message: {
required: true,
serializedName: "message",
type: {
name: "String"
}
},
target: {
required: false,
serializedName: "target",
type: {
name: "String"
}
},
details: {
required: false,
serializedName: "details",
type: {
name: "Sequence",
element: {
required: false,
serializedName: "CloudErrorElementType",
type: {
name: "Composite",
className: "CloudError"
}
}
}
}
}
}
};
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"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.BaseResourceMapper = {
required: false,
serializedName: "BaseResource",
type: {
name: "Composite",
className: "BaseResource",
modelProperties: {}
}
};
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"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 });
const ms_rest_js_1 = __webpack_require__(0);
/**
* Creates a new CognitiveServicesCredentials object.
*
* @constructor
* @param {string} subscriptionKey The CognitiveServices subscription key
*/
class CognitiveServicesCredentials extends ms_rest_js_1.ApiKeyCredentials {
constructor(subscriptionKey) {
if (!subscriptionKey || (subscriptionKey && typeof subscriptionKey.valueOf() !== "string")) {
throw new Error("subscriptionKey cannot be null or undefined and must be of type string.");
}
const options = {
inHeader: {
"Ocp-Apim-Subscription-Key": subscriptionKey,
"X-BingApis-SDK-Client": "node-SDK"
}
};
super(options);
}
}
exports.CognitiveServicesCredentials = CognitiveServicesCredentials;
/***/ })
/******/ ]);
//# sourceMappingURL=msRestAzureBundle.js.map

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

1
msRestAzureBundle.min.js поставляемый

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

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

5304
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -35,12 +35,14 @@
"@types/mocha": "^2.2.43",
"@types/should": "^8.1.30",
"mocha": "^3.5.3",
"npm-run-all": "^4.1.2",
"should": "5.2.0",
"ts-loader": "^2.3.7",
"ts-node": "^5.0.1",
"tslint": "^5.7.0",
"typescript": "^2.5.2",
"webpack": "^3.6.0",
"uglify-es": "^3.1.0"
"uglify-es": "^3.1.0",
"webpack": "^3.6.0"
},
"homepage": "https://github.com/Azure/ms-rest-azure-js",
"repository": {
@ -51,10 +53,14 @@
"url": "http://github.com/Azure/ms-rest-azure-js/issues"
},
"scripts": {
"tsc": "tsc -p tsconfig.json",
"test": "npm -s run-script tslint",
"unit": "mocha -t 50000 dist/test",
"build": "npm -s run-script tsc && webpack && node node_modules/uglify-es/bin/uglifyjs --source-map -c -m -o msRestAzureBundle.min.js msRestAzureBundle.js",
"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 msRestAzureBundle.min.js msRestAzureBundle.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"
}
}

5
test/mocha.opts Normal file
Просмотреть файл

@ -0,0 +1,5 @@
--require ts-node/register
--timeout 50000
--reporter list
--colors
test/**/*.ts

7
test/placeholder.ts Normal file
Просмотреть файл

@ -0,0 +1,7 @@
import * as assert from 'assert';
describe('ms-rest-azure-js', function() {
it("doesn't have any tests", function() {
assert.fail('Please add some tests');
});
});

Просмотреть файл

@ -1,23 +1,18 @@
{
"compilerOptions": {
"alwaysStrict": true,
"module": "commonjs",
"noImplicitAny": true,
"preserveConstEnums": true,
"sourceMap": true,
"newLine": "LF",
"target": "es6",
"target": "es5",
"moduleResolution": "node",
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist/lib",
"declaration": true,
"declarationDir": "typings/lib",
"allowJs": false,
"outDir": "dist",
"strict": true,
"strictNullChecks": true,
"declaration": true,
"declarationDir": "./typings",
"lib": [
"dom",
"dom.iterable",

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

@ -1,84 +0,0 @@
import * as msRest from "ms-rest-js";
/**
* Options to be provided while creating the client.
*/
export interface AzureServiceClientOptions extends msRest.ServiceClientOptions {
/**
* @property {string} [options.acceptLanguage] - Gets or sets the preferred language for the response. Default value is: "en-US".
*/
acceptLanguage?: string;
/**
* @property {boolean} [options.generateClientRequestId] - When set to true a unique x-ms-client-request-id value
* is generated and included in each request. Default is true.
*/
generateClientRequestId?: boolean;
/**
* @property {number} [options.longRunningOperationRetryTimeout] - Gets or sets the retry timeout in seconds for
* Long Running Operations. Default value is 30.
*/
longRunningOperationRetryTimeout?: number;
/**
* @property {number} [rpRegistrationRetryTimeout] - Gets or sets the retry timeout in seconds for
* AutomaticRPRegistration. Default value is 30 seconds.
*/
rpRegistrationRetryTimeout?: number;
}
/**
* @class
* Initializes a new instance of the AzureServiceClient class.
* @constructor
*
* @param {msRest.ServiceClientCredentilas} credentials - ApplicationTokenCredentials or
* UserTokenCredentials object used for authentication.
* @param {AzureServiceClientOptions} options - The parameter options used by AzureServiceClient
*/
export declare class AzureServiceClient extends msRest.ServiceClient {
acceptLanguage: string;
generateClientRequestId: boolean;
longRunningOperationRetryTimeout: number;
rpRegistrationRetryTimeout: number;
constructor(credentials: msRest.ServiceClientCredentials, options?: AzureServiceClientOptions);
/**
* Provides a mechanism to make a request that will poll and provide the final result.
* @param {msRest.RequestPrepareOptions|msRest.WebResource} request - The request object
* @param {msRest.RequestOptionsBase} [options] Additional options to be sent while making the request
* @returns {Promise<msRest.HttpOperationResponse>} The HttpOperationResponse containing the final polling request, response and the responseBody.
*/
sendLongRunningRequest(request: msRest.RequestPrepareOptions | msRest.WebResource, options?: msRest.RequestOptionsBase): Promise<msRest.HttpOperationResponse>;
/**
* Verified whether an unexpected polling status code for long running operation was received for the response of the initial request.
* @param {msRest.HttpOperationResponse} initialResponse - Response to the initial request that was sent as a part of the asynchronous operation.
*/
private checkResponseStatusCodeFailed(initialResponse);
/**
* Poll Azure long running PUT, PATCH, POST or DELETE operations.
* @param {msRest.HttpOperationResponse} resultOfInitialRequest - result/response of the initial request which is a part of the asynchronous polling operation.
* @param {msRest.RequestOptionsBase} [options] - custom request options.
* @returns {Promise<msRest.HttpOperationResponse>} result - The final response after polling is complete.
*/
getLongRunningOperationResult(resultOfInitialRequest: msRest.HttpOperationResponse, options?: msRest.RequestOptionsBase): Promise<msRest.HttpOperationResponse>;
/**
* Retrieve operation status by polling from "azure-asyncoperation" header.
* @param {PollingState} pollingState - The object to persist current operation state.
* @param {boolean} inPostOrDelete - Invoked by Post Or Delete operation.
*/
private updateStateFromAzureAsyncOperationHeader(pollingState, inPostOrDelete?);
/**
* Retrieve PUT operation status by polling from "location" header.
* @param {string} method - The HTTP method.
* @param {PollingState} pollingState - The object to persist current operation state.
*/
private updateStateFromLocationHeader(method, pollingState);
/**
* Polling for resource status.
* @param {string} resourceUrl - The url of resource.
* @param {PollingState} pollingState - The object to persist current operation state.
*/
private updateStateFromGetResourceOperation(resourceUrl, pollingState);
/**
* Retrieves operation status by querying the operation URL.
* @param {string} operationUrl - URL used to poll operation result.
* @param {object} options - Options that can be set on the request object
*/
private getStatus(operationUrl, options?);
}

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

@ -1,15 +0,0 @@
/**
* @class
* An empty interface.
*/
export interface BaseResource {
}
export declare const BaseResourceMapper: {
required: boolean;
serializedName: string;
type: {
name: string;
className: string;
modelProperties: {};
};
};

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

@ -1,68 +0,0 @@
/**
* @class
* Provides additional information about an http error response returned from a Microsoft Azure service.
*/
export interface CloudError extends Error {
/**
* @property {string} code The error code parsed from the body of the http error response.
*/
code: string;
/**
* @property {string} message The error message parsed from the body of the http error response.
*/
message: string;
/**
* @property {string} [target] The target of the error.
*/
target?: string;
/**
* @property {Array<CloudError>} [details] An array of CloudError objects specifying the details.
*/
details?: Array<CloudError>;
}
export declare const CloudErrorMapper: {
required: boolean;
serializedName: string;
type: {
name: string;
className: string;
modelProperties: {
code: {
required: boolean;
serializedName: string;
type: {
name: string;
};
};
message: {
required: boolean;
serializedName: string;
type: {
name: string;
};
};
target: {
required: boolean;
serializedName: string;
type: {
name: string;
};
};
details: {
required: boolean;
serializedName: string;
type: {
name: string;
element: {
required: boolean;
serializedName: string;
type: {
name: string;
className: string;
};
};
};
};
};
};
};

Просмотреть файл

@ -1,10 +0,0 @@
import { ApiKeyCredentials } from "ms-rest-js";
/**
* Creates a new CognitiveServicesCredentials object.
*
* @constructor
* @param {string} subscriptionKey The CognitiveServices subscription key
*/
export declare class CognitiveServicesCredentials extends ApiKeyCredentials {
constructor(subscriptionKey: string);
}

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

@ -1,6 +0,0 @@
import { AzureServiceClientOptions, AzureServiceClient } from "./azureServiceClient";
import Constants from "./util/constants";
import { CloudError, CloudErrorMapper } from "./cloudError";
import { BaseResource, BaseResourceMapper } from "./baseResource";
import { CognitiveServicesCredentials } from "./credentials/cognitiveServicesCredentials";
export { AzureServiceClient, AzureServiceClientOptions, Constants, CloudError, CloudErrorMapper, BaseResource, BaseResourceMapper, CognitiveServicesCredentials };

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

@ -1,69 +0,0 @@
import * as msRest from "ms-rest-js";
/**
* @class
* Initializes a new instance of the PollingState class.
*/
export default class PollingState {
/**
* @param {msRest.HttpOperationResponse} [response] - Response of the initial request that was made as a part of the asynchronous operation.
*/
resultOfInitialRequest: msRest.HttpOperationResponse;
/**
* @param {msRest.RequestOptionsBase} [optionsOfInitialRequest] - Request options that were provided as a part of the initial request.
*/
optionsOfInitialRequest: msRest.RequestOptionsBase;
/**
* @param {msRest.WebResource} [request] - provides information about the request made for polling.
*/
request: msRest.WebResource;
/**
* @param {Response} [response] - The response object to extract longrunning operation status.
*/
response: Response;
/**
* @param {any} [resource] - Provides information about the response body received in the polling request. Particularly useful when polling via provisioningState.
*/
resource: any;
/**
* @param {number} [retryTimeout] - The timeout in seconds to retry on intermediate operation results. Default Value is 30.
*/
retryTimeout: number;
/**
* @param {string} [azureAsyncOperationHeaderLink] - The url that is present in "azure-asyncoperation" response header.
*/
azureAsyncOperationHeaderLink?: string;
/**
* @param {string} [locationHeaderLink] - The url that is present in "Location" response header.
*/
locationHeaderLink?: string;
/**
* @param {string} [status] - The status of polling. "Succeeded, Failed, Cancelled, Updating, Creating, etc."
*/
status?: string;
/**
* @param {msRest.RestError} [error] - Provides information about the error that happened while polling.
*/
error?: msRest.RestError;
constructor(resultOfInitialRequest: msRest.HttpOperationResponse, retryTimeout?: number);
/**
* Update cached data using the provided response object
* @param {Response} [response] - provider response object.
*/
updateResponse(response: Response): void;
/**
* Gets timeout in milliseconds.
* @returns {number} timeout
*/
getTimeout(): number;
/**
* Returns long running operation result.
* @returns {msRest.HttpOperationResponse} HttpOperationResponse
*/
getOperationResponse(): msRest.HttpOperationResponse;
/**
* Returns an Error on operation failure.
* @param {Error} err - The error object.
* @returns {msRest.RestError} The RestError defined in the runtime.
*/
getRestError(err?: Error): msRest.RestError;
}

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

@ -1,11 +0,0 @@
declare const Constants: {
LongRunningOperationStates: {
InProgress: string;
Succeeded: string;
Failed: string;
Canceled: string;
};
DEFAULT_LANGUAGE: string;
msRestAzureVersion: string;
};
export default Constants;