From 597fdf93c555af0520dc0b8c1338395c7fb0bf16 Mon Sep 17 00:00:00 2001 From: Kasra Kyanzadeh Date: Thu, 12 Apr 2018 12:51:44 -0400 Subject: [PATCH] v0.5.3 --- CHANGELOG.md | 4 + build/airtable.browser.js | 204 +++++++++++--------------------------- package.json | 2 +- 3 files changed, 64 insertions(+), 146 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 187793f4..5dbf266e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.5.3 + * Fix User-Agent header warnings when running Chrome (#52) + * Fix JSON imports so webpack can bundle + # v0.5.2 * Support for the `cellFormat`, `userLocale`, and `timeZone` parameters diff --git a/build/airtable.browser.js b/build/airtable.browser.js index 70d5a7f6..d916c581 100644 --- a/build/airtable.browser.js +++ b/build/airtable.browser.js @@ -24,7 +24,7 @@ module.exports = AirtableError; 'use strict'; var _ = require('lodash'); -var internalConfig = require('./internal_config'); +var internalConfig = require('./internal_config.json'); var Class = require('./class'); var AirtableError = require('./airtable_error'); var Table = require('./table'); @@ -101,7 +101,7 @@ Base.createFunctor = function(airtable, baseId) { module.exports = Base; -},{"./airtable_error":1,"./class":4,"./internal_config":6,"./run_action":10,"./table":11,"lodash":19}],3:[function(require,module,exports){ +},{"./airtable_error":1,"./class":4,"./internal_config.json":6,"./run_action":10,"./table":11,"lodash":19}],3:[function(require,module,exports){ 'use strict'; /** @@ -595,7 +595,7 @@ module.exports = Record; },{"./callback_to_promise":3,"./class":4,"lodash":19}],10:[function(require,module,exports){ 'use strict'; -var internalConfig = require('./internal_config'); +var internalConfig = require('./internal_config.json'); var objectToQueryParamString = require('./object_to_query_param_string'); // This will become require('xhr') in the browser. @@ -604,17 +604,29 @@ var request = require('request'); function runAction(base, method, path, queryParams, bodyData, callback) { var url = base._airtable._endpointUrl + '/v' + base._airtable._apiVersionMajor + '/' + base._id + path + '?' + objectToQueryParamString(queryParams); + var headers = { + 'authorization': 'Bearer ' + base._airtable._apiKey, + 'x-api-version': base._airtable._apiVersion, + 'x-airtable-application-id': base.getId(), + }; + + var userAgent = 'Airtable.js'; + var isBrowser = typeof window !== 'undefined'; + // Some browsers do not allow overriding the user agent. + // https://github.com/Airtable/airtable.js/issues/52 + if (isBrowser) { + headers['x-airtable-user-agent'] = userAgent; + } else { + headers['User-Agent'] = userAgent; + } + + var options = { method: method.toUpperCase(), url: url, json: true, timeout: base._airtable.requestTimeout, - headers: { - 'authorization': 'Bearer ' + base._airtable._apiKey, - 'x-api-version': base._airtable._apiVersion, - 'x-airtable-application-id': base.getId(), - 'User-Agent': 'Airtable.js', - }, + headers: headers, // agentOptions are ignored when running in the browser. agentOptions: { rejectUnauthorized: base._airtable._allowUnauthorizedSsl @@ -645,7 +657,7 @@ function runAction(base, method, path, queryParams, bodyData, callback) { module.exports = runAction; -},{"./internal_config":6,"./object_to_query_param_string":7,"request":20}],11:[function(require,module,exports){ +},{"./internal_config.json":6,"./object_to_query_param_string":7,"request":20}],11:[function(require,module,exports){ 'use strict'; var _ = require('lodash'); @@ -2108,7 +2120,7 @@ module.exports = check; }()); }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"_process":15}],14:[function(require,module,exports){ +},{"_process":16}],14:[function(require,module,exports){ // http://wiki.commonjs.org/wiki/Unit_Testing/1.0 // // THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! @@ -2470,104 +2482,40 @@ var objectKeys = Object.keys || function (obj) { }; },{"util/":18}],15:[function(require,module,exports){ -// shim for using process in browser -var process = module.exports = {}; - -// cached from whatever global is present so that test runners that stub it -// don't break things. But we need to wrap it in a try catch in case it is -// wrapped in strict mode code which doesn't define any globals. It's inside a -// function because try/catches deoptimize in certain engines. - -var cachedSetTimeout; -var cachedClearTimeout; - -function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); -} -function defaultClearTimeout () { - throw new Error('clearTimeout has not been defined'); -} -(function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } -} ()) -function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } - // if setTimeout wasn't available but was latter defined - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch(e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch(e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - - +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } } -function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } - // if clearTimeout wasn't available but was latter defined - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e){ - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e){ - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - +},{}],16:[function(require,module,exports){ +// shim for using process in browser -} +var process = module.exports = {}; var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); @@ -2583,7 +2531,7 @@ function drainQueue() { if (draining) { return; } - var timeout = runTimeout(cleanUpNextTick); + var timeout = setTimeout(cleanUpNextTick); draining = true; var len = queue.length; @@ -2591,16 +2539,14 @@ function drainQueue() { currentQueue = queue; queue = []; while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } + currentQueue[queueIndex].run(); } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; - runClearTimeout(timeout); + clearTimeout(timeout); } process.nextTick = function (fun) { @@ -2612,7 +2558,7 @@ process.nextTick = function (fun) { } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { - runTimeout(drainQueue); + setTimeout(drainQueue, 0); } }; @@ -2640,46 +2586,18 @@ process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; -process.prependListener = noop; -process.prependOnceListener = noop; - -process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; +// TODO(shtylman) process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; -},{}],16:[function(require,module,exports){ -if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - }; -} else { - // old school shim for old browsers - module.exports = function inherits(ctor, superCtor) { - ctor.super_ = superCtor - var TempCtor = function () {} - TempCtor.prototype = superCtor.prototype - ctor.prototype = new TempCtor() - ctor.prototype.constructor = ctor - } -} - },{}],17:[function(require,module,exports){ module.exports = function isBuffer(arg) { return arg && typeof arg === 'object' @@ -3277,7 +3195,7 @@ function hasOwnProperty(obj, prop) { } }).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./support/isBuffer":17,"_process":15,"inherits":16}],19:[function(require,module,exports){ +},{"./support/isBuffer":17,"_process":16,"inherits":15}],19:[function(require,module,exports){ (function (global){ /** * @license @@ -10311,20 +10229,16 @@ function noop() {} },{"global/window":21,"is-function":22,"parse-headers":25,"xtend":26}],21:[function(require,module,exports){ (function (global){ -var win; - if (typeof window !== "undefined") { - win = window; + module.exports = window; } else if (typeof global !== "undefined") { - win = global; + module.exports = global; } else if (typeof self !== "undefined"){ - win = self; + module.exports = self; } else { - win = {}; + module.exports = {}; } -module.exports = win; - }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],22:[function(require,module,exports){ module.exports = isFunction @@ -10521,4 +10435,4 @@ Airtable.Error = AirtableError; module.exports = Airtable; }).call(this,require('_process')) -},{"./airtable_error":1,"./base":2,"./class":4,"./record":9,"./table":11,"_process":15,"assert":14}]},{},["airtable"]); +},{"./airtable_error":1,"./base":2,"./class":4,"./record":9,"./table":11,"_process":16,"assert":14}]},{},["airtable"]); diff --git a/package.json b/package.json index c83daa54..e60ab1ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "airtable", - "version": "0.5.2", + "version": "0.5.3", "homepage": "https://github.com/airtable/airtable.js", "repository": "git://github.com/airtable/airtable.js.git", "private": false,