Comparing version 1.4.0-beta to 1.5.0-beta
{ | ||
"name": "code-push", | ||
"version": "1.4.0-beta", | ||
"version": "1.5.0-beta", | ||
"description": "Management SDK for the CodePush service", | ||
@@ -5,0 +5,0 @@ "main": "script/index.js", |
@@ -17,2 +17,4 @@ /// <reference path="../definitions/harness.d.ts" /> | ||
} | ||
this._appVersion = configuration.appVersion; | ||
this._clientUniqueId = configuration.clientUniqueId; | ||
this._deploymentKey = configuration.deploymentKey; | ||
@@ -76,18 +78,30 @@ this._ignoreAppVersion = configuration.ignoreAppVersion; | ||
}; | ||
AcquisitionManager.prototype.reportStatus = function (status, message, callback) { | ||
var url = this._serverUrl + "reportStatus"; | ||
var body; | ||
switch (status) { | ||
case AcquisitionStatus.DeploymentSucceeded: | ||
case AcquisitionStatus.DeploymentFailed: | ||
url += "/deploy"; | ||
body = JSON.stringify({ deploymentKey: this._deploymentKey, status: status, message: message }); | ||
break; | ||
default: | ||
if (callback) { | ||
callback(new Error("Unrecognized status."), null); | ||
} | ||
return; | ||
AcquisitionManager.prototype.reportStatusDeploy = function (package, status, callback) { | ||
var url = this._serverUrl + "reportStatus/deploy"; | ||
var body = { | ||
appVersion: this._appVersion, | ||
clientUniqueId: this._clientUniqueId, | ||
deploymentKey: this._deploymentKey | ||
}; | ||
if (package) { | ||
body.label = package.label; | ||
body.appVersion = package.appVersion; | ||
switch (status) { | ||
case AcquisitionStatus.DeploymentSucceeded: | ||
case AcquisitionStatus.DeploymentFailed: | ||
body.status = status; | ||
break; | ||
default: | ||
if (callback) { | ||
if (!status) { | ||
callback(new Error("Missing status argument."), null); | ||
} | ||
else { | ||
callback(new Error("Unrecognized status \"" + status + "\"."), null); | ||
} | ||
} | ||
return; | ||
} | ||
} | ||
this._httpRequester.request(2 /* POST */, url, body, function (error, response) { | ||
this._httpRequester.request(2 /* POST */, url, JSON.stringify(body), function (error, response) { | ||
if (callback) { | ||
@@ -106,2 +120,23 @@ if (error) { | ||
}; | ||
AcquisitionManager.prototype.reportStatusDownload = function (package, callback) { | ||
var url = this._serverUrl + "reportStatus/download"; | ||
var body = { | ||
clientUniqueId: this._clientUniqueId, | ||
deploymentKey: this._deploymentKey, | ||
label: package.label | ||
}; | ||
this._httpRequester.request(2 /* POST */, url, JSON.stringify(body), function (error, response) { | ||
if (callback) { | ||
if (error) { | ||
callback(error, null); | ||
return; | ||
} | ||
if (response.statusCode !== 200) { | ||
callback(new Error(response.statusCode + ": " + response.body), null); | ||
return; | ||
} | ||
callback(null, null); | ||
} | ||
}); | ||
}; | ||
return AcquisitionManager; | ||
@@ -108,0 +143,0 @@ })(); |
@@ -371,6 +371,6 @@ var base64 = require("base-64"); | ||
}; | ||
AccountManager.prototype.addApp = function (appName, description) { | ||
AccountManager.prototype.addApp = function (appName) { | ||
var _this = this; | ||
return Promise(function (resolve, reject, notify) { | ||
var app = { name: appName, description: description }; | ||
var app = { name: appName }; | ||
var requester = (_this._authedAgent ? _this._authedAgent : request); | ||
@@ -464,6 +464,6 @@ var req = requester.post(_this.serverUrl + "/apps/"); | ||
// Deployments | ||
AccountManager.prototype.addDeployment = function (appId, name, description) { | ||
AccountManager.prototype.addDeployment = function (appId, name) { | ||
var _this = this; | ||
return Promise(function (resolve, reject, notify) { | ||
var deployment = { name: name, description: description }; | ||
var deployment = { name: name }; | ||
var requester = (_this._authedAgent ? _this._authedAgent : request); | ||
@@ -564,2 +564,33 @@ var req = requester.post(_this.serverUrl + "/apps/" + appId + "/deployments/"); | ||
}; | ||
AccountManager.prototype.getDeploymentMetrics = function (appId, deploymentId) { | ||
var _this = this; | ||
return Promise(function (resolve, reject, notify) { | ||
var requester = (_this._authedAgent ? _this._authedAgent : request); | ||
var req = requester.get(_this.serverUrl + "/apps/" + appId + "/deployments/" + deploymentId + "/metrics"); | ||
_this.attachCredentials(req, requester); | ||
req.end(function (err, res) { | ||
if (err) { | ||
reject({ message: _this.getErrorMessage(err, res) }); | ||
return; | ||
} | ||
var body = tryJSON(res.text); | ||
if (res.ok) { | ||
if (body) { | ||
resolve(body.metrics); | ||
} | ||
else { | ||
reject({ message: "Could not parse response: " + res.text, statusCode: res.status }); | ||
} | ||
} | ||
else { | ||
if (body) { | ||
reject(body); | ||
} | ||
else { | ||
reject({ message: res.text, statusCode: res.status }); | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
AccountManager.prototype.updateDeployment = function (appId, infoToChange) { | ||
@@ -828,5 +859,2 @@ var _this = this; | ||
}; | ||
AccountManager.prototype.generateDeploymentKey = function (name, description, isPrimary, id) { | ||
return { id: id, name: name, description: description, isPrimary: !!isPrimary }; | ||
}; | ||
AccountManager.prototype.attachCredentials = function (request, requester) { | ||
@@ -833,0 +861,0 @@ if (this._saveAuthedAgent) { |
var Acquisition = require("./acquisition-native-stub"); | ||
var MyApp = (function () { | ||
function MyApp() { | ||
this._acquisition = new Acquisition.NativeImplementation({ serverUrl: MyApp.ServerUrl, deploymentKey: "fa3s34a5s6d7f8we9a9r" }); | ||
this._acquisition = new Acquisition.NativeImplementation({ appVersion: "1.0.0", clientUniqueId: "203ff986-f335-4e94-8e79-ee404231218d", deploymentKey: "fa3s34a5s6d7f8we9a9r", serverUrl: MyApp.ServerUrl }); | ||
} | ||
@@ -6,0 +6,0 @@ MyApp.prototype.onAppStartup = function () { |
@@ -18,2 +18,3 @@ /// <reference path="../definitions/harness.d.ts" /> | ||
var reportStatusDeployUrl = exports.serverUrl + "/reportStatus/deploy"; | ||
var reportStatusDownloadUrl = exports.serverUrl + "/reportStatus/download"; | ||
var updateCheckUrl = exports.serverUrl + "/updateCheck?"; | ||
@@ -34,2 +35,5 @@ var HttpRequester = (function () { | ||
} | ||
else if (verb === 2 /* POST */ && url === reportStatusDownloadUrl) { | ||
Server.onReportStatus(callback); | ||
} | ||
else { | ||
@@ -36,0 +40,0 @@ throw new Error("Unexpected call"); |
@@ -7,4 +7,6 @@ /// <reference path="../definitions/harness.d.ts" /> | ||
var configuration = { | ||
appVersion: "1.5.0", | ||
clientUniqueId: "My iPhone", | ||
deploymentKey: mockApi.validDeploymentKey, | ||
serverUrl: mockApi.serverUrl, | ||
deploymentKey: mockApi.validDeploymentKey, | ||
}; | ||
@@ -164,5 +166,5 @@ var templateCurrentPackage = { | ||
}); | ||
it("reportStatus(...) signals completion", function (done) { | ||
it("reportStatusDeploy(...) signals completion", function (done) { | ||
var acquisition = new acquisitionSdk.AcquisitionManager(new mockApi.HttpRequester(), configuration); | ||
acquisition.reportStatus(acquisitionSdk.AcquisitionStatus.DeploymentFailed, "message", (function (error, parameter) { | ||
acquisition.reportStatusDeploy(templateCurrentPackage, acquisitionSdk.AcquisitionStatus.DeploymentFailed, (function (error, parameter) { | ||
if (error) { | ||
@@ -175,2 +177,12 @@ throw error; | ||
}); | ||
it("reportStatusDownload(...) signals completion", function (done) { | ||
var acquisition = new acquisitionSdk.AcquisitionManager(new mockApi.HttpRequester(), configuration); | ||
acquisition.reportStatusDownload(templateCurrentPackage, (function (error, parameter) { | ||
if (error) { | ||
throw error; | ||
} | ||
assert.equal(parameter, null); | ||
done(); | ||
})); | ||
}); | ||
}); | ||
@@ -177,0 +189,0 @@ function clone(initialObject) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68717
1660