Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import RESTSerializer from '@ember-data/serializer/rest';
export default RESTSerializer.extend({
primaryKey: 'name',
serializeAttribute(snapshot, json, key, attributes) {
// Don't send values that are undefined
if (
undefined !== snapshot.attr(key) &&
(snapshot.record.get('isNew') || snapshot.changedAttributes()[key])
) {
this._super(snapshot, json, key, attributes);
}
},
normalizeSecrets(payload) {
if (payload.data.keys && Array.isArray(payload.data.keys)) {
const connections = payload.data.keys.map(secret => ({ name: secret, backend: payload.backend }));
return connections;
import { inject as service } from '@ember/service';
/*
* extends DS.RESTSerializer to implement encryption
*
* By default every attribute hash is encrypted using SJCL.
* This is configurable by options parameter of DS.attr().
*
* Options:
* - encrypted (boolean)
* If false the attribute won't be encrypted.
* - includePlainOnCreate (string)
* If set the attribute will be included plain (not encrypted) when
* recorde is created. Value is the attributes name used.
*/
export default RESTSerializer.extend({
isNewSerializerAPI: true,
encryption: service(),
/*
* implement decryption
*/
normalize(modelClass, resourceHash, prop) {
// run before serialization of attribute hash
modelClass.eachAttribute(function(key, attributes) {
if (
attributes.options.encrypted !== false
) {
if (typeof resourceHash[key] !== 'undefined' && resourceHash[key] !== null) {
resourceHash[key] = this.encryption.decrypt(resourceHash[key]);
import RESTSerializer, { EmbeddedRecordsMixin } from '@ember-data/serializer/rest';
import { assign } from '@ember/polyfills';
import { decamelize } from '@ember/string';
export default RESTSerializer.extend(EmbeddedRecordsMixin, {
keyForAttribute: function(attr) {
return decamelize(attr);
},
attrs: {
nodes: { embedded: 'always' },
},
pushPayload(store, payload) {
const transformedPayload = this.normalizeResponse(
store,
store.modelFor('cluster'),
payload,
null,
'findAll'
);
import RESTSerializer from '@ember-data/serializer/rest';
export default RESTSerializer.extend({
});
import RESTSerializer from '@ember-data/serializer/rest';
import { isNone, isBlank } from '@ember/utils';
import { assign } from '@ember/polyfills';
import { decamelize } from '@ember/string';
export default RESTSerializer.extend({
keyForAttribute: function(attr) {
return decamelize(attr);
},
pushPayload(store, payload) {
const transformedPayload = this.normalizeResponse(
store,
store.modelFor(payload.modelName),
payload,
payload.id,
'findRecord'
);
return store.push(transformedPayload);
},
normalizeItems(payload) {
import RESTSerializer from '@ember-data/serializer/rest';
import { decamelize } from '@ember/string';
export default RESTSerializer.extend({
keyForAttribute: function(attr) {
return decamelize(attr);
},
});
import RESTSerializer from '@ember-data/serializer/rest';
import { assign } from '@ember/polyfills';
import { decamelize } from '@ember/string';
export default RESTSerializer.extend({
keyForAttribute: function(attr) {
return decamelize(attr);
},
normalizeAll(payload) {
if (payload.data) {
const data = assign({}, payload, payload.data);
return [data];
}
return [payload];
},
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
const records = this.normalizeAll(payload);
const { modelName } = primaryModelClass;
let transformedPayload = { [modelName]: records };
import RESTSerializer from '@ember-data/serializer/rest';
export default RESTSerializer.extend({
});
import RESTSerializer from '@ember-data/serializer/rest';
import { decamelize } from '@ember/string';
export default RESTSerializer.extend({
keyForAttribute: function(attr) {
return decamelize(attr);
},
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
const { modelName } = primaryModelClass;
payload.data.id = id;
const transformedPayload = { [modelName]: payload.data };
return this._super(store, primaryModelClass, transformedPayload, id, requestType);
},
});
import RESTSerializer from '@ember-data/serializer/rest';
import { decamelize } from '@ember/string';
export default RESTSerializer.extend({
keyForAttribute: function(attr) {
return decamelize(attr);
},
normalizeAll(payload) {
if (payload.data.keys && Array.isArray(payload.data.keys)) {
const records = payload.data.keys.map(record => {
const fullPath = payload.prefix ? payload.prefix + record : record;
return { id: fullPath };
});
return records;
}
return [payload.data];
},
normalizeResponse(store, primaryModelClass, payload, id, requestType) {