How to use the @ember-data/serializer/rest.extend function in @ember-data/serializer

To help you get started, we’ve selected a few @ember-data/serializer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hashicorp / vault / ui / app / serializers / database / connection.js View on Github external
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;
github jelhan / croodle / app / serializers / application.js View on Github external
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]);
github hashicorp / vault / ui / app / serializers / cluster.js View on Github external
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'
    );
github jelhan / croodle / app / serializers / answer.js View on Github external
import RESTSerializer from '@ember-data/serializer/rest';

export default RESTSerializer.extend({
});
github hashicorp / vault / ui / app / serializers / pki-certificate.js View on Github external
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) {
github hashicorp / vault / ui / app / serializers / replication-attributes.js View on Github external
import RESTSerializer from '@ember-data/serializer/rest';
import { decamelize } from '@ember/string';

export default RESTSerializer.extend({
  keyForAttribute: function(attr) {
    return decamelize(attr);
  },
});
github hashicorp / vault / ui / app / serializers / config.js View on Github external
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 };
github jelhan / croodle / app / serializers / selection.js View on Github external
import RESTSerializer from '@ember-data/serializer/rest';

export default RESTSerializer.extend({
});
github hashicorp / vault / ui / app / serializers / path-filter-config.js View on Github external
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);
  },
});
github hashicorp / vault / ui / app / serializers / lease.js View on Github external
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) {

@ember-data/serializer

Provides Legacy JSON, JSON:API and REST Implementations of the Serializer Interface for use with @ember-data/store

MIT
Latest version published 18 days ago

Package Health Score

89 / 100
Full package analysis