@google/earthengine 1.6.12 → 1.6.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/browser.js +179 -156
- package/build/ee_api_js.js +235 -235
- package/build/ee_api_js_debug.js +157 -133
- package/build/ee_api_js_npm.js +179 -156
- package/build/main.js +179 -156
- package/package.json +1 -1
- package/src/apiclient.js +44 -7
- package/src/data.js +4 -0
package/package.json
CHANGED
package/src/apiclient.js
CHANGED
|
@@ -24,7 +24,7 @@ const {trustedResourceUrl} = goog.require('safevalues.index');
|
|
|
24
24
|
/** @namespace */
|
|
25
25
|
const apiclient = {};
|
|
26
26
|
|
|
27
|
-
const API_CLIENT_VERSION = '1.6.
|
|
27
|
+
const API_CLIENT_VERSION = '1.6.13';
|
|
28
28
|
|
|
29
29
|
exports.VERSION = apiVersion.VERSION;
|
|
30
30
|
exports.API_CLIENT_VERSION = API_CLIENT_VERSION;
|
|
@@ -380,6 +380,9 @@ class BatchRequestService extends PromiseRequestService {
|
|
|
380
380
|
if (authToken != null) {
|
|
381
381
|
request.push('Authorization: ' + authToken);
|
|
382
382
|
}
|
|
383
|
+
if (apiclient.userAgent_) {
|
|
384
|
+
request.push('User-Agent: ' + apiclient.userAgent_);
|
|
385
|
+
}
|
|
383
386
|
const body = params.body ? JSON.stringify(params.body) : '';
|
|
384
387
|
const message = `${request.join('\r\n')}\r\n\r\n${body}`;
|
|
385
388
|
return /** @type {?} */([message, responseCtor]);
|
|
@@ -672,6 +675,24 @@ apiclient.setAppIdToken = function(token) {
|
|
|
672
675
|
};
|
|
673
676
|
|
|
674
677
|
|
|
678
|
+
/**
|
|
679
|
+
* Sets the user agent for API requests.
|
|
680
|
+
* @param {string} userAgent The user agent string.
|
|
681
|
+
*/
|
|
682
|
+
apiclient.setUserAgent = function(userAgent) {
|
|
683
|
+
apiclient.userAgent_ = userAgent;
|
|
684
|
+
};
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
/**
|
|
688
|
+
* Returns the user agent for API requests.
|
|
689
|
+
* @return {?string}
|
|
690
|
+
*/
|
|
691
|
+
apiclient.getUserAgent = function() {
|
|
692
|
+
return apiclient.userAgent_;
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
|
|
675
696
|
////////////////////////////////////////////////////////////////////////////////
|
|
676
697
|
// Initialization. //
|
|
677
698
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -836,6 +857,9 @@ apiclient.send = function(
|
|
|
836
857
|
let version = API_CLIENT_VERSION;
|
|
837
858
|
headers[apiclient.API_CLIENT_VERSION_HEADER] = 'ee-js/' + version;
|
|
838
859
|
}
|
|
860
|
+
if (apiclient.userAgent_) {
|
|
861
|
+
headers['User-Agent'] = apiclient.userAgent_;
|
|
862
|
+
}
|
|
839
863
|
|
|
840
864
|
// Set up client-side authorization.
|
|
841
865
|
const authToken = apiclient.getAuthToken();
|
|
@@ -1250,7 +1274,7 @@ apiclient.setupMockSend = function(calls) {
|
|
|
1250
1274
|
// If it's a function, call the function and use its return value.
|
|
1251
1275
|
// If it's an object it has fields specifying more details.
|
|
1252
1276
|
// If there's nothing set for this url, throw.
|
|
1253
|
-
function getResponse(url, method, data) {
|
|
1277
|
+
function getResponse(url, method, data, headers) {
|
|
1254
1278
|
url =
|
|
1255
1279
|
url.replace(apiBaseUrl, '')
|
|
1256
1280
|
.replace(
|
|
@@ -1263,7 +1287,7 @@ apiclient.setupMockSend = function(calls) {
|
|
|
1263
1287
|
throw new Error(url + ' mock response not specified');
|
|
1264
1288
|
}
|
|
1265
1289
|
if (typeof response === 'function') {
|
|
1266
|
-
response = response(url, method, data);
|
|
1290
|
+
response = response(url, method, data, headers);
|
|
1267
1291
|
}
|
|
1268
1292
|
if (typeof response === 'string') {
|
|
1269
1293
|
response = {
|
|
@@ -1284,9 +1308,9 @@ apiclient.setupMockSend = function(calls) {
|
|
|
1284
1308
|
}
|
|
1285
1309
|
|
|
1286
1310
|
// Mock XhrIo.send for async calls.
|
|
1287
|
-
XhrIo.send = function(url, callback, method, data) {
|
|
1311
|
+
XhrIo.send = function(url, callback, method, data, headers) {
|
|
1288
1312
|
apiBaseUrl = apiBaseUrl || apiclient.apiBaseUrl_;
|
|
1289
|
-
const responseData = getResponse(url, method, data);
|
|
1313
|
+
const responseData = getResponse(url, method, data, headers);
|
|
1290
1314
|
// An anonymous class to simulate an event. Closure doesn't like this.
|
|
1291
1315
|
/** @constructor */
|
|
1292
1316
|
const fakeEvent = function() {
|
|
@@ -1321,13 +1345,16 @@ apiclient.setupMockSend = function(calls) {
|
|
|
1321
1345
|
/** @type {string} */ this.contentType_;
|
|
1322
1346
|
/** @type {string} */ this.responseText;
|
|
1323
1347
|
/** @type {number} */ this.status;
|
|
1348
|
+
/** @type {!Object<string, string>} */ this.requestHeaders_ = {};
|
|
1324
1349
|
};
|
|
1325
1350
|
fakeXmlHttp.prototype.open = function(method, urlIn) {
|
|
1326
1351
|
apiBaseUrl = apiBaseUrl || apiclient.apiBaseUrl_;
|
|
1327
1352
|
this.url = urlIn;
|
|
1328
1353
|
this.method = method;
|
|
1329
1354
|
};
|
|
1330
|
-
fakeXmlHttp.prototype.setRequestHeader = function() {
|
|
1355
|
+
fakeXmlHttp.prototype.setRequestHeader = function(key, value) {
|
|
1356
|
+
this.requestHeaders_[key] = value;
|
|
1357
|
+
};
|
|
1331
1358
|
fakeXmlHttp.prototype.getResponseHeader = function(header) {
|
|
1332
1359
|
if (header === 'Content-Type') {
|
|
1333
1360
|
return this.contentType_ || null;
|
|
@@ -1336,7 +1363,8 @@ apiclient.setupMockSend = function(calls) {
|
|
|
1336
1363
|
}
|
|
1337
1364
|
};
|
|
1338
1365
|
fakeXmlHttp.prototype.send = function(data) {
|
|
1339
|
-
const responseData =
|
|
1366
|
+
const responseData =
|
|
1367
|
+
getResponse(this.url, this.method, data, this.requestHeaders_);
|
|
1340
1368
|
this.responseText = responseData.text;
|
|
1341
1369
|
this.status = typeof responseData.status === 'function' ?
|
|
1342
1370
|
responseData.status() :
|
|
@@ -1482,6 +1510,13 @@ apiclient.xsrfToken_ = null;
|
|
|
1482
1510
|
apiclient.appIdToken_ = null;
|
|
1483
1511
|
|
|
1484
1512
|
|
|
1513
|
+
/**
|
|
1514
|
+
* A string to pass as User-Agent header in XHRs.
|
|
1515
|
+
* @private {?string}
|
|
1516
|
+
*/
|
|
1517
|
+
apiclient.userAgent_ = null;
|
|
1518
|
+
|
|
1519
|
+
|
|
1485
1520
|
/**
|
|
1486
1521
|
* A function used to transform parameters right before they are sent to the
|
|
1487
1522
|
* server. Takes the URL of the request as the second argument.
|
|
@@ -1781,6 +1816,8 @@ exports.setAuthToken = apiclient.setAuthToken;
|
|
|
1781
1816
|
exports.clearAuthToken = apiclient.clearAuthToken;
|
|
1782
1817
|
exports.setAuthTokenRefresher = apiclient.setAuthTokenRefresher;
|
|
1783
1818
|
exports.setAppIdToken = apiclient.setAppIdToken;
|
|
1819
|
+
exports.setUserAgent = apiclient.setUserAgent;
|
|
1820
|
+
exports.getUserAgent = apiclient.getUserAgent;
|
|
1784
1821
|
exports.mergeAuthScopes = apiclient.mergeAuthScopes_;
|
|
1785
1822
|
|
|
1786
1823
|
exports.setupMockSend = apiclient.setupMockSend;
|
package/src/data.js
CHANGED
|
@@ -266,6 +266,10 @@ ee.data.getAuthScopes = ee.apiclient.getAuthScopes;
|
|
|
266
266
|
goog.exportSymbol('ee.data.getAuthScopes', ee.data.getAuthScopes);
|
|
267
267
|
ee.data.setDeadline = ee.apiclient.setDeadline;
|
|
268
268
|
goog.exportSymbol('ee.data.setDeadline', ee.data.setDeadline);
|
|
269
|
+
ee.data.setUserAgent = ee.apiclient.setUserAgent;
|
|
270
|
+
goog.exportSymbol('ee.data.setUserAgent', ee.data.setUserAgent);
|
|
271
|
+
ee.data.getUserAgent = ee.apiclient.getUserAgent;
|
|
272
|
+
goog.exportSymbol('ee.data.getUserAgent', ee.data.getUserAgent);
|
|
269
273
|
|
|
270
274
|
// The following symbol is exported because it is used in the Code Editor, much
|
|
271
275
|
// like ee.data.setExpressionAugmenter above is.
|