Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cloudinary/base

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cloudinary/base - npm Package Compare versions

Comparing version 1.0.0-beta.2 to 1.0.0-beta.3

34

actions/variable.d.ts

@@ -34,3 +34,3 @@ import SetAction from "./variable/SetAction";

* @memberOf Actions.Variable
* @param name Variable name
* @param {string} name Variable name
* @param {number | string | number[] | string[]} value Variable value

@@ -42,2 +42,29 @@ * @return {Actions.Variable.SetAction}

* @summary action
* @description Same as 'set', but forces the end value to be a float setFloat(1) will result in $foo_1.0
* @memberOf Actions.Variable
* @param {string} name Variable name
* @param {number} value Variable value
* @return {Actions.Variable.SetAction}
*/
declare function setFloat(name: string, value: number): SetAction;
/**
* @summary action
* @description Same as 'set', but forces the end value to be an integer setInteger(1.1) will result in $foo_1, input is rounded down
* @memberOf Actions.Variable
* @param {string} name Variable name
* @param {number} value Variable value
* @return {Actions.Variable.SetAction}
*/
declare function setInteger(name: string, value: number): SetAction;
/**
* @summary action
* @description Same as 'set', but forces the end value to be a string setString(1) will result in $foo_!1!
* @memberOf Actions.Variable
* @param {string | number} name Variable name
* @param {number} value Variable value
* @return {Actions.Variable.SetAction}
*/
declare function setString(name: string, value: string | number): SetAction;
/**
* @summary action
* @description Allows adding a variable by sending a key and value which is a reference to an asset.

@@ -72,2 +99,5 @@ * @memberOf Actions.Variable

set: typeof set;
setFloat: typeof setFloat;
setString: typeof setString;
setInteger: typeof setInteger;
setAssetReference: typeof setAssetReference;

@@ -77,2 +107,2 @@ setFromContext: typeof setFromContext;

};
export { set, setAssetReference, setFromContext, setFromMetadata, Variable };
export { set, setFloat, setString, setInteger, setAssetReference, setFromContext, setFromMetadata, Variable };

@@ -5,2 +5,3 @@ import SetAction from "./variable/SetAction";

import SetFromMetadataAction from "./variable/SetFromMetadataAction";
import { toFloatAsString } from "../internal/utils/toFloatAsString";
/**

@@ -34,3 +35,3 @@ * Defines a new user variable with the given value.

* @memberOf Actions.Variable
* @param name Variable name
* @param {string} name Variable name
* @param {number | string | number[] | string[]} value Variable value

@@ -40,2 +41,5 @@ * @return {Actions.Variable.SetAction}

function set(name, value) {
if (Object.prototype.hasOwnProperty.call(value, 'push')) {
return new SetAction(name, value);
}
return new SetAction(name, value);

@@ -45,2 +49,42 @@ }

* @summary action
* @description Same as 'set', but forces the end value to be a float setFloat(1) will result in $foo_1.0
* @memberOf Actions.Variable
* @param {string} name Variable name
* @param {number} value Variable value
* @return {Actions.Variable.SetAction}
*/
function setFloat(name, value) {
return new SetAction(name, toFloatAsString(value), '');
}
/**
* @summary action
* @description Same as 'set', but forces the end value to be an integer setInteger(1.1) will result in $foo_1, input is rounded down
* @memberOf Actions.Variable
* @param {string} name Variable name
* @param {number} value Variable value
* @return {Actions.Variable.SetAction}
*/
function setInteger(name, value) {
let val = value;
if (typeof value === 'string') {
val = parseInt(value);
}
if (isNaN(val)) {
val = 0;
}
return new SetAction(name, Math.round(val));
}
/**
* @summary action
* @description Same as 'set', but forces the end value to be a string setString(1) will result in $foo_!1!
* @memberOf Actions.Variable
* @param {string | number} name Variable name
* @param {number} value Variable value
* @return {Actions.Variable.SetAction}
*/
function setString(name, value) {
return new SetAction(name, value.toString());
}
/**
* @summary action
* @description Allows adding a variable by sending a key and value which is a reference to an asset.

@@ -81,2 +125,5 @@ * @memberOf Actions.Variable

set,
setFloat,
setString,
setInteger,
setAssetReference,

@@ -86,2 +133,2 @@ setFromContext,

};
export { set, setAssetReference, setFromContext, setFromMetadata, Variable };
export { set, setFloat, setString, setInteger, setAssetReference, setFromContext, setFromMetadata, Variable };

2

actions/variable/SetAction.d.ts

@@ -10,4 +10,4 @@ import VariableAction from "./VariableAction";

declare class SetAction extends VariableAction {
constructor(name: string, value: number | string | string[] | number[] | ExpressionQualifier);
constructor(name: string, value: number | string | string[] | number[] | ExpressionQualifier, wrapper?: string);
}
export default SetAction;

@@ -10,10 +10,16 @@ import { isString } from "../../internal/utils/dataStructureUtils";

class SetAction extends VariableAction {
constructor(name, value) {
constructor(name, value, wrapper = '!') {
let finalValue;
const parsedValue = Array.isArray(value) ? value.join(':') : value;
let finalValue;
if (isString(parsedValue)) {
finalValue = `!${parsedValue
/*
* Encoding needed to make the Variable value Cloudinary Safe
* If a string, we also determine what wrapper is used (wrapper variable)
* The wrapper variable is needed because floats are passed as strings ('1.0') - in those case
* we don't need to treat them as URL strings ($foo_!1.0!), but instead as foo_1.0
*/
finalValue = `${wrapper}${parsedValue
.replace(/,/g, '%2C')
.replace(/\//g, '%2F')
.replace(/!/g, '%21')}!`;
.replace(/!/g, '%21')}${wrapper}`;
}

@@ -20,0 +26,0 @@ else {

@@ -56,3 +56,2 @@ import { processLayer } from "./transformationProcessing/processLayer";

let effect = transformationOptions.effect;
let border = transformationOptions.border;
// TODO, Do we need this?

@@ -99,6 +98,13 @@ const no_html_sizes = hasLayer || angle || crop === "fit" || crop === "limit";

}
let borderParam;
let border = transformationOptions.border;
if (isObject(border)) {
borderParam = `${border.width != null ? border.width : 2}px_solid_${(border.color != null ? border.color : "black").replace(/^#/, 'rgb:')}`;
border = `${border.width != null ? border.width : 2}px_solid_${(border.color != null ? border.color : "black").replace(/^#/, 'rgb:')}`;
}
else {
// @ts-ignore
if (/^\d+$/.exec(border)) { // fallback to html border attributes
transformationOptions.border = border;
border = void 0;
}
}
if (Array.isArray(fps)) {

@@ -105,0 +111,0 @@ fps = fps.join('-');

@@ -53,3 +53,3 @@ export declare type StreamingProfiles = string | "4k" | "full_hd" | "hd" | "sd" | "full_hd_wifi" | "full_hd_lean" | "hd_lean";

color?: string;
};
} | string;
default_image?: string;

@@ -56,0 +56,0 @@ density?: stringOrNumber;

@@ -5,2 +5,2 @@ /**

*/
export declare function isObject(a: any): boolean;
export declare function isObject(a: any): a is Record<string, any>;
{
"name": "@cloudinary/base",
"version": "1.0.0-beta.2",
"version": "1.0.0-beta.3",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc