Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
registry.register('model:' + dasherize(prop), options[prop]);
}
registry.register(
'service:store',
DS.Store.extend({
adapter: adapter,
})
);
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
registry.register('adapter:-default', DS.Adapter);
registry.register('serializer:-default', DS.JSONAPISerializer);
registry.register('serializer:-json', DS.JSONSerializer);
registry.register('serializer:-rest', DS.RESTSerializer);
registry.register('adapter:-rest', DS.RESTAdapter);
registry.register('adapter:-json-api', DS.JSONAPIAdapter);
registry.injection('serializer', 'store', 'service:store');
env.store = container.lookup('service:store');
env.restSerializer = container.lookup('serializer:-rest');
env.restSerializer.store = env.store;
env.serializer = env.store.serializerFor('-default');
env.serializer.store = env.store;
// lazily create the adapter method because some tets depend on
// modifiying the adapter in the container after setupStore is
// called
Object.defineProperty(env, 'adapter', {
QUnit.begin(() => {
RSVP.configure('onerror', reason => {
// only print error messages if they're exceptions;
// otherwise, let a future turn of the event loop
// handle the error.
if (reason && reason instanceof Error) {
throw reason;
}
});
// Prevent all tests involving serialization to require a container
DS.JSONSerializer.reopen({
transformFor(attributeType) {
return this._super(attributeType, true) || transforms[attributeType];
}
});
});
import DS from 'ember-data';
export default DS.JSONSerializer.extend({
/**
* @summary A serializer hook. Normalizing the payload from api response simpler or legacy json that may not support the http://jsonapi.org/ spec
* @method normalizeQueryResponse
* @param {DS.Store} store
* @param {DS.Model} primaryModelClass
* @param {Object} payload - the data object
* @return {Object}
*/
normalizeQueryResponse(store, primaryModelClass, payload, id, requestType) {
// The response for this is just an object. So we need to normalize it into the meta.
return {
meta: payload,
data: []
};
}
});
let relationships = this._super(...arguments);
modelClass.eachRelationship((key, relationshipMeta) => {
if (relationshipMeta.kind === 'hasMany' && !shouldSaveRelationship(this, relationshipMeta) && !!relationshipMeta.options.async) {
relationships[key] = { links: { related: key } };
}
});
return relationships;
},
});
// DEPRECATION: The private method _shouldSerializeHasMany has been promoted to the public API
// See https://www.emberjs.com/deprecations/ember-data/v2.x/#toc_jsonserializer-shouldserializehasmany
if( ! DS.JSONSerializer.prototype.shouldSerializeHasMany ) {
Serializer.reopen({
_shouldSerializeHasMany( snapshot, key, relationship ){
return this.shouldSerializeHasMany( snapshot, key, relationship );
}
});
}
export default Serializer;
adapter = '-ember-data-test-custom';
}
for (let prop in options) {
registry.register('model:' + dasherize(prop), options[prop]);
}
registry.register('service:store', DS.Store.extend({
adapter: adapter
}));
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
registry.register('adapter:-default', DS.Adapter);
registry.register('serializer:-default', DS.JSONSerializer);
registry.register('serializer:-rest', DS.RESTSerializer);
registry.register('adapter:-rest', DS.RESTAdapter);
registry.register('adapter:-json-api', DS.JSONAPIAdapter);
registry.register('serializer:-json-api', DS.JSONAPISerializer);
env.restSerializer = container.lookup('serializer:-rest');
env.store = container.lookup('service:store');
env.serializer = env.store.serializerFor('-default');
env.adapter = env.store.get('defaultAdapter');
return env;
}
adapter = '-ember-data-test-custom';
}
for (var prop in options) {
registry.register('model:' + Ember.String.dasherize(prop), options[prop]);
}
registry.register('store:main', DS.Store.extend({
adapter: adapter
}));
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
registry.register('adapter:-default', DS.Adapter);
registry.register('serializer:-default', DS.JSONSerializer);
registry.register('serializer:-rest', DS.RESTSerializer);
registry.register('serializer:-rest-new', DS.RESTSerializer.extend({ isNewSerializerAPI: true }));
registry.register('adapter:-rest', DS.RESTAdapter);
registry.injection('serializer', 'store', 'store:main');
registry.register('transform:string', DS.StringTransform);
registry.register('transform:number', DS.NumberTransform);
registry.register('transform:date', DS.DateTransform);
registry.register('transform:main', DS.Transform);
Ember.run(function() {
env.serializer = container.lookup('serializer:-default');
env.restSerializer = container.lookup('serializer:-rest');
env.restNewSerializer = container.lookup('serializer:-rest-new');
env.store = container.lookup('store:main');
adapter = '-ember-data-test-custom';
}
for (var prop in options) {
registry.register('model:' + dasherize(prop), options[prop]);
}
registry.register('service:store', DS.Store.extend({
adapter: adapter
}));
registry.optionsForType('serializer', { singleton: false });
registry.optionsForType('adapter', { singleton: false });
registry.register('adapter:-default', DS.Adapter);
registry.register('serializer:-default', DS.JSONSerializer);
registry.register('serializer:-rest', DS.RESTSerializer);
registry.register('adapter:-rest', DS.RESTAdapter);
registry.register('adapter:-json-api', DS.JSONAPIAdapter);
registry.register('serializer:-json-api', DS.JSONAPISerializer);
registry.register('adapter:-graphql', Adapter);
registry.register('serializer:-graphql', Serializer);
registry.register('transform:string', DS.StringTransform);
registry.register('transform:number', DS.NumberTransform);
env.restSerializer = container.lookup('serializer:-rest');
env.store = container.lookup('service:store');
env.serializer = env.store.serializerFor('-default');
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import DS from 'ember-data';
export default DS.JSONSerializer.extend({
extractArray: function (store, primaryType, rawPayload) {
var databases = rawPayload.databases.map(function (database) {
return {
id: database,
name: database
};
});
var payload = { databases: databases };
return this._super(store, primaryType, payload);
},
normalizePayload: function (payload) {
var normalized = payload.databases.map(function (database) {
return database;
});
import DS from 'ember-data';
export default DS.JSONSerializer.extend(DS.EmbeddedRecordsMixin, {
isNewSerializerAPI: true,
keyForAttribute(key) {
return key.decamelize();
},
keyForRelationship(key) {
return key.decamelize();
},
});
usingJSONSerializer(serializer) {
return serializer instanceof DS.JSONSerializer;
}
}