How to use the cloudinary-core.Transformation.PARAM_NAMES function in cloudinary-core

To help you get started, we’ve selected a few cloudinary-core 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 cloudinary / cloudinary-react / src / Util / extractCloudinaryProps.js View on Github external
import {Transformation, Util} from 'cloudinary-core';

const CLOUDINARY_REACT_PROPS = {includeOwnBody: true};

// Map Cloudinary props from array to object for efficient lookup
const CLOUDINARY_PROPS = Transformation.PARAM_NAMES.map(Util.camelCase).reduce(
  (accumulator, cloudinaryPropName) => {
    accumulator[cloudinaryPropName] = true;
    return accumulator;
  },
  {}
);

const isDefined = (props, key) => {
  return (props[key] !== undefined && props[key] !== null);
};

/**
 * Extracts cloudinaryProps and nonCloudinaryProps from given props
 *
 * @param props
 * @returns {{children: *, cloudinaryReactProps: {}, cloudinaryProps: {}, nonCloudinaryProps: {}}}
github cloudinary / cloudinary-react / src / components / CloudinaryComponent / CloudinaryComponent.js View on Github external
/**
   * Generate a Cloudinary resource URL based on the options provided and child Transformation elements
   * @param extendedProps React props combined with custom Cloudinary configuration options
   * @returns {string} a cloudinary URL
   * @protected
   */
  getUrl(extendedProps) {
    let transformation = this.getTransformation(extendedProps);
    let options = Util.extractUrlParams(Util.withSnakeCaseKeys(extendedProps));
    let cl = Cloudinary.new(options);
    return cl.url(extendedProps.publicId, transformation);
  }
}

CloudinaryComponent.contextType = CloudinaryContextType;
CloudinaryComponent.propTypes = typesFrom(Transformation.PARAM_NAMES.map(camelCase));
CloudinaryComponent.propTypes.publicId = PropTypes.string;
CloudinaryComponent.propTypes.responsive = PropTypes.bool;

/**
 * Create a React type definition object. All items are PropTypes.string or [string] or object or [object].
 * @param {Array} configParams a list of parameter names
 * @returns {Object}
 * @private
 */
function typesFrom(configParams) {
  configParams = configParams || [];
  const types = {};
  for (let i =0; i < configParams.length; i++) {
    const key = configParams[i];
    types[camelCase(key)] = PropTypes.any;
  }
github cloudinary / cloudinary-vue / src / helpers / attributes.js View on Github external
import { Transformation, Util, Configuration } from "cloudinary-core";
import { formatObject, normalizeObject, pick, omit, merge } from "../utils";

export const configuration = Configuration.CONFIG_PARAMS.map(Util.camelCase);
export const transformation = Transformation.PARAM_NAMES.map(
  Util.camelCase
).filter(name => configuration.indexOf(name) < 0);

export function normalizeConfiguration(cfg) {
  return Util.withSnakeCaseKeys(
    formatObject(normalizeObject(pick(cfg, configuration)), {
      secure: v => (typeof v === "boolean" ? v : v === "true")
    })
  );
}

export function normalizeTransformation(cfg) {
  return Util.withSnakeCaseKeys(normalizeObject(pick(cfg, transformation)));
}

export function normalizeRest(cfg) {