dist/globals/ember-data.prod.js in ember-data-source-2.8.0.beta.1 vs dist/globals/ember-data.prod.js in ember-data-source-2.8.0.beta.2

- old
+ new

@@ -4,18 +4,20 @@ /*! * @overview Ember Data * @copyright Copyright 2011-2016 Tilde Inc. and contributors. * Portions Copyright 2011 LivingSocial Inc. * @license Licensed under MIT license (see license.js) - * @version 2.8.0-beta.1 + * @version 2.8.0-beta.2 */ var loader, define, requireModule, require, requirejs; (function(global) { 'use strict'; + var stats; + // Save off the original values of these globals, so we can restore them if someone asks us to var oldGlobals = { loader: loader, define: define, requireModule: requireModule, @@ -49,11 +51,10 @@ pendingQueueLength: 0 }; requirejs._stats = stats; } - var stats; resetStats(); loader = { noConflict: function(aliases) { @@ -141,11 +142,11 @@ Module.prototype.unsee = function() { this.finalized = false; this._foundDeps = false; this.isPending = false; - this.module = { exports: {}}; + this.module = { exports: {} }; }; Module.prototype.reify = function() { stats.reify++; var reified = this.reified; @@ -188,11 +189,11 @@ return require(resolve(dep, name)); }; r['default'] = r; r.has = function(dep) { return has(resolve(dep, name)); - } + }; return r; }; define = function(name, deps, callback) { stats.define++; @@ -10764,14 +10765,13 @@ import DS from 'ember-data'; export default DS.Adapter.extend({ findRecord: function(store, type, id, snapshot) { return new Ember.RSVP.Promise(function(resolve, reject) { Ember.$.getJSON(`/${type.modelName}/${id}`).then(function(data) { - Ember.run(null, resolve, data); + resolve(data); }, function(jqXHR) { - jqXHR.then = null; // tame jQuery's ill mannered promises - Ember.run(null, reject, jqXHR); + reject(jqXHR); }); }); } }); ``` @@ -10792,14 +10792,13 @@ export default DS.Adapter.extend({ findAll: function(store, type, sinceToken) { var query = { since: sinceToken }; return new Ember.RSVP.Promise(function(resolve, reject) { Ember.$.getJSON(`/${type.modelName}`, query).then(function(data) { - Ember.run(null, resolve, data); + resolve(data); }, function(jqXHR) { - jqXHR.then = null; // tame jQuery's ill mannered promises - Ember.run(null, reject, jqXHR); + reject(jqXHR); }); }); } }); ``` @@ -10819,14 +10818,13 @@ import DS from 'ember-data'; export default DS.Adapter.extend({ query: function(store, type, query) { return new Ember.RSVP.Promise(function(resolve, reject) { Ember.$.getJSON(`/${type.modelName}`, query).then(function(data) { - Ember.run(null, resolve, data); + resolve(data); }, function(jqXHR) { - jqXHR.then = null; // tame jQuery's ill mannered promises - Ember.run(null, reject, jqXHR); + reject(jqXHR); }); }); } }); ``` @@ -10852,14 +10850,13 @@ import Ember from 'ember'; export default DS.Adapter.extend(DS.BuildURLMixin, { queryRecord: function(store, type, query) { return new Ember.RSVP.Promise(function(resolve, reject) { Ember.$.getJSON(`/${type.modelName}`, query).then(function(data) { - Ember.run(null, resolve, data); + resolve(data); }, function(jqXHR) { - jqXHR.then = null; // tame jQuery's ill mannered promises - Ember.run(null, reject, jqXHR); + reject(jqXHR); }); }); } }); ``` @@ -11680,10 +11677,12 @@ */ define('ember-data/adapters/rest', ['exports', 'ember', 'ember-data/adapter', 'ember-data/adapters/errors', 'ember-data/-private/adapters/build-url-mixin', 'ember-data/-private/features', 'ember-data/-private/debug', 'ember-data/-private/utils/parse-response-headers'], function (exports, _ember, _emberDataAdapter, _emberDataAdaptersErrors, _emberDataPrivateAdaptersBuildUrlMixin, _emberDataPrivateFeatures, _emberDataPrivateDebug, _emberDataPrivateUtilsParseResponseHeaders) { var MapWithDefault = _ember.default.MapWithDefault; var get = _ember.default.get; + var Promise = _ember.default.RSVP.Promise; + /** The REST adapter allows your store to communicate with an HTTP server by transmitting JSON via XHR. Most Ember.js apps that consume a JSON API should use the REST adapter. @@ -12569,39 +12568,33 @@ var requestData = { url: url, method: type }; - return new _ember.default.RSVP.Promise(function (resolve, reject) { + return new Promise(function (resolve, reject) { var hash = adapter.ajaxOptions(url, type, options); hash.success = function (payload, textStatus, jqXHR) { - - var response = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), payload, requestData); - - if (response && response.isAdapterError) { - _ember.default.run.join(null, reject, response); - } else { + try { + var response = ajaxSuccess(adapter, jqXHR, payload, requestData); _ember.default.run.join(null, resolve, response); + } catch (error) { + _ember.default.run.join(null, reject, error); } }; hash.error = function (jqXHR, textStatus, errorThrown) { - - var error = undefined; - - if (errorThrown instanceof Error) { - error = errorThrown; - } else if (textStatus === 'timeout') { - error = new _emberDataAdaptersErrors.TimeoutError(); - } else if (textStatus === 'abort') { - error = new _emberDataAdaptersErrors.AbortError(); - } else { - error = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || errorThrown, requestData); + try { + var responseData = { + textStatus: textStatus, + errorThrown: errorThrown + }; + var error = ajaxError(adapter, jqXHR, requestData, responseData); + _ember.default.run.join(null, reject, error); + } catch (error) { + _ember.default.run.join(null, reject, error); } - - _ember.default.run.join(null, reject, error); }; adapter._ajaxRequest(hash); }, 'DS: RESTAdapter#ajax ' + type + ' to ' + url); }, @@ -12961,42 +12954,64 @@ var requestData = { method: method, url: url }; return new _ember.default.RSVP.Promise(function (resolve, reject) { hash.success = function (payload, textStatus, jqXHR) { - var response = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), payload, requestData); - - if (response instanceof _emberDataAdaptersErrors.AdapterError) { - _ember.default.run.join(null, reject, response); - } else { + try { + var response = ajaxSuccess(adapter, jqXHR, payload, requestData); _ember.default.run.join(null, resolve, response); + } catch (error) { + _ember.default.run.join(null, reject, error); } }; hash.error = function (jqXHR, textStatus, errorThrown) { - - var error = undefined; - - if (errorThrown instanceof Error) { - error = errorThrown; - } else if (textStatus === 'timeout') { - error = new _emberDataAdaptersErrors.TimeoutError(); - } else if (textStatus === 'abort') { - error = new _emberDataAdaptersErrors.AbortError(); - } else { - error = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || errorThrown, requestData); + try { + var responseData = { + textStatus: textStatus, + errorThrown: errorThrown + }; + var error = ajaxError(adapter, jqXHR, requestData, responseData); + _ember.default.run.join(null, reject, error); + } catch (error) { + _ember.default.run.join(null, reject, error); } - - _ember.default.run.join(null, reject, error); }; adapter._ajaxRequest(hash); }, 'DS: RESTAdapter#makeRequest: ' + method + ' ' + url); } }); } + function ajaxSuccess(adapter, jqXHR, payload, requestData) { + var response = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), payload, requestData); + + if (response && response.isAdapterError) { + return Promise.reject(response); + } else { + return response; + } + } + + function ajaxError(adapter, jqXHR, requestData, responseData) { + + var error = undefined; + + if (responseData.errorThrown instanceof Error) { + error = responseData.errorThrown; + } else if (responseData.textStatus === 'timeout') { + error = new _emberDataAdaptersErrors.TimeoutError(); + } else if (responseData.textStatus === 'abort') { + error = new _emberDataAdaptersErrors.AbortError(); + } else { + error = adapter.handleResponse(jqXHR.status, (0, _emberDataPrivateUtilsParseResponseHeaders.default)(jqXHR.getAllResponseHeaders()), adapter.parseErrorResponse(jqXHR.responseText) || responseData.errorThrown, requestData); + } + + return error; + } + //From http://stackoverflow.com/questions/280634/endswith-in-javascript function endsWith(string, suffix) { if (typeof String.prototype.endsWith !== 'function') { return string.indexOf(suffix, string.length - suffix.length) !== -1; } else { @@ -13547,17 +13562,20 @@ return; } var includeIds = this.hasSerializeIdsOption(attr); var includeRecords = this.hasSerializeRecordsOption(attr); var embeddedSnapshot = snapshot.belongsTo(attr); - var key; if (includeIds) { - key = this.keyForRelationship(attr, relationship.kind, 'serialize'); + var serializedKey = this._getMappedKey(relationship.key, snapshot.type); + if (serializedKey === relationship.key && this.keyForRelationship) { + serializedKey = this.keyForRelationship(relationship.key, relationship.kind, "serialize"); + } + if (!embeddedSnapshot) { - json[key] = null; + json[serializedKey] = null; } else { - json[key] = embeddedSnapshot.id; + json[serializedKey] = embeddedSnapshot.id; if (relationship.options.polymorphic) { this.serializePolymorphicType(snapshot, json, relationship); } } @@ -13701,11 +13719,15 @@ this._super(snapshot, json, relationship); return; } if (this.hasSerializeIdsOption(attr)) { - var serializedKey = this.keyForRelationship(attr, relationship.kind, 'serialize'); + var serializedKey = this._getMappedKey(relationship.key, snapshot.type); + if (serializedKey === relationship.key && this.keyForRelationship) { + serializedKey = this.keyForRelationship(relationship.key, relationship.kind, "serialize"); + } + json[serializedKey] = snapshot.hasMany(attr, { ids: true }); } else if (this.hasSerializeRecordsOption(attr)) { this._serializeEmbeddedHasMany(snapshot, json, relationship); } else { if (this.hasSerializeIdsAndTypesOption(attr)) { @@ -16973,11 +16995,11 @@ */ deserialize: null }); }); define("ember-data/version", ["exports"], function (exports) { - exports.default = "2.8.0-beta.1"; + exports.default = "2.8.0-beta.2"; }); define("ember-inflector", ["exports", "ember", "ember-inflector/lib/system", "ember-inflector/lib/ext/string"], function (exports, _ember, _emberInflectorLibSystem, _emberInflectorLibExtString) { _emberInflectorLibSystem.Inflector.defaultRules = _emberInflectorLibSystem.defaultRules; _ember.default.Inflector = _emberInflectorLibSystem.Inflector; @@ -17089,12 +17111,12 @@ exports.pluralize = _emberInflectorLibSystemString.pluralize; exports.defaultRules = _emberInflectorLibSystemInflections.default; }); define('ember-inflector/lib/system/inflections', ['exports'], function (exports) { exports.default = { - plurals: [[/$/, 's'], [/s$/i, 's'], [/^(ax|test)is$/i, '$1es'], [/(octop|vir)us$/i, '$1i'], [/(octop|vir)i$/i, '$1i'], [/(alias|status)$/i, '$1es'], [/(bu)s$/i, '$1ses'], [/(buffal|tomat)o$/i, '$1oes'], [/([ti])um$/i, '$1a'], [/([ti])a$/i, '$1a'], [/sis$/i, 'ses'], [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'], [/(hive)$/i, '$1s'], [/([^aeiouy]|qu)y$/i, '$1ies'], [/(x|ch|ss|sh)$/i, '$1es'], [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'], [/^(m|l)ouse$/i, '$1ice'], [/^(m|l)ice$/i, '$1ice'], [/^(ox)$/i, '$1en'], [/^(oxen)$/i, '$1'], [/(quiz)$/i, '$1zes']], + plurals: [[/$/, 's'], [/s$/i, 's'], [/^(ax|test)is$/i, '$1es'], [/(octop|vir)us$/i, '$1i'], [/(octop|vir)i$/i, '$1i'], [/(alias|status|bonus)$/i, '$1es'], [/(bu)s$/i, '$1ses'], [/(buffal|tomat)o$/i, '$1oes'], [/([ti])um$/i, '$1a'], [/([ti])a$/i, '$1a'], [/sis$/i, 'ses'], [/(?:([^f])fe|([lr])f)$/i, '$1$2ves'], [/(hive)$/i, '$1s'], [/([^aeiouy]|qu)y$/i, '$1ies'], [/(x|ch|ss|sh)$/i, '$1es'], [/(matr|vert|ind)(?:ix|ex)$/i, '$1ices'], [/^(m|l)ouse$/i, '$1ice'], [/^(m|l)ice$/i, '$1ice'], [/^(ox)$/i, '$1en'], [/^(oxen)$/i, '$1'], [/(quiz)$/i, '$1zes']], - singular: [[/s$/i, ''], [/(ss)$/i, '$1'], [/(n)ews$/i, '$1ews'], [/([ti])a$/i, '$1um'], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'], [/(^analy)(sis|ses)$/i, '$1sis'], [/([^f])ves$/i, '$1fe'], [/(hive)s$/i, '$1'], [/(tive)s$/i, '$1'], [/([lr])ves$/i, '$1f'], [/([^aeiouy]|qu)ies$/i, '$1y'], [/(s)eries$/i, '$1eries'], [/(m)ovies$/i, '$1ovie'], [/(x|ch|ss|sh)es$/i, '$1'], [/^(m|l)ice$/i, '$1ouse'], [/(bus)(es)?$/i, '$1'], [/(o)es$/i, '$1'], [/(shoe)s$/i, '$1'], [/(cris|test)(is|es)$/i, '$1is'], [/^(a)x[ie]s$/i, '$1xis'], [/(octop|vir)(us|i)$/i, '$1us'], [/(alias|status)(es)?$/i, '$1'], [/^(ox)en/i, '$1'], [/(vert|ind)ices$/i, '$1ex'], [/(matr)ices$/i, '$1ix'], [/(quiz)zes$/i, '$1'], [/(database)s$/i, '$1']], + singular: [[/s$/i, ''], [/(ss)$/i, '$1'], [/(n)ews$/i, '$1ews'], [/([ti])a$/i, '$1um'], [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)(sis|ses)$/i, '$1sis'], [/(^analy)(sis|ses)$/i, '$1sis'], [/([^f])ves$/i, '$1fe'], [/(hive)s$/i, '$1'], [/(tive)s$/i, '$1'], [/([lr])ves$/i, '$1f'], [/([^aeiouy]|qu)ies$/i, '$1y'], [/(s)eries$/i, '$1eries'], [/(m)ovies$/i, '$1ovie'], [/(x|ch|ss|sh)es$/i, '$1'], [/^(m|l)ice$/i, '$1ouse'], [/(bus)(es)?$/i, '$1'], [/(o)es$/i, '$1'], [/(shoe)s$/i, '$1'], [/(cris|test)(is|es)$/i, '$1is'], [/^(a)x[ie]s$/i, '$1xis'], [/(octop|vir)(us|i)$/i, '$1us'], [/(alias|status|bonus)(es)?$/i, '$1'], [/^(ox)en/i, '$1'], [/(vert|ind)ices$/i, '$1ex'], [/(matr)ices$/i, '$1ix'], [/(quiz)zes$/i, '$1'], [/(database)s$/i, '$1']], irregularPairs: [['person', 'people'], ['man', 'men'], ['child', 'children'], ['sex', 'sexes'], ['move', 'moves'], ['cow', 'kine'], ['zombie', 'zombies']], uncountable: ['equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep', 'jeans', 'police'] };