New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@cypress/schema-tools

Package Overview
Dependencies
Maintainers
5
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cypress/schema-tools - npm Package Compare versions

Comparing version 2.1.2 to 3.0.0

dist/actions.js

1

dist/index.js

@@ -9,3 +9,4 @@ "use strict";

__export(require("./utils"));
__export(require("./actions"));
__export(require("./formats"));
__export(require("./document/docs"));

32

dist/utils.js

@@ -8,3 +8,2 @@ "use strict";

var lodash_camelcase_1 = __importDefault(require("lodash.camelcase"));
var lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep"));
var ramda_1 = require("ramda");

@@ -63,32 +62,1 @@ exports.semverToString = function (s) {

};
exports.addProperty = function (objectSchema, title, description, property, propertyType, propertyFormat, exampleValue, isRequired, propertyDescription, see) {
var newSchema = lodash_clonedeep_1.default(objectSchema);
newSchema.schema.description = description;
newSchema.schema.title = title;
if (!newSchema.schema.properties) {
newSchema.schema.properties = {};
}
newSchema.schema.properties[property] = {
type: propertyType,
};
var newProp = newSchema.schema.properties[property];
if (propertyFormat) {
newProp.format = propertyFormat;
}
if (isRequired) {
if (!newSchema.schema.required) {
newSchema.schema.required = [];
}
if (Array.isArray(newSchema.schema.required)) {
newSchema.schema.required.push(property);
}
}
if (propertyDescription) {
newProp.description = propertyDescription;
}
if (see) {
newProp.see = see;
}
newSchema.example[property] = lodash_clonedeep_1.default(exampleValue);
return newSchema;
};
{
"name": "@cypress/schema-tools",
"version": "2.1.2",
"version": "3.0.0",
"description": "Validate, sanitize and document JSON schemas",

@@ -48,11 +48,11 @@ "main": "dist",

"@types/lodash.camelcase": "4.3.3",
"@types/node": "9.6.18",
"@types/ramda": "0.25.29",
"@types/node": "9.6.20",
"@types/ramda": "0.25.32",
"ava": "0.25.0",
"ava-ts": "0.24.5",
"common-tags": "1.7.2",
"ava-ts": "0.24.6",
"common-tags": "1.8.0",
"deps-ok": "1.4.1",
"husky": "0.15.0-rc.13",
"jsen": "0.6.6",
"prettier": "1.12.1",
"prettier": "1.13.4",
"semantic-release": "15.5.0",

@@ -62,3 +62,3 @@ "terminal-banner": "1.1.0",

"tslint": "5.10.0",
"typescript": "2.8.3"
"typescript": "2.9.1"
},

@@ -65,0 +65,0 @@ "repository": {

@@ -134,2 +134,3 @@ # @cypress/schema-tools [![CircleCI](https://circleci.com/gh/cypress-io/schema-tools.svg?style=svg&circle-token=aa9b52bab9e9216699ba7258929f727b06b13afe)](https://circleci.com/gh/cypress-io/schema-tools) [![renovate-app badge][renovate-badge]][renovate-app]

* [SchemaError](#schemaerror)
* [addProperty](#addproperty)

@@ -278,2 +279,6 @@ TODO describe current API

### addProperty
You can easily extend existing schema using included `addProperty` function. See [src/actions.ts](src/actions.ts) and [test/add-property-test.ts](test/add-property-test.ts) for examples.
## Debugging

@@ -280,0 +285,0 @@

@@ -6,3 +6,4 @@ // TODO maybe group the exports by type

export * from './utils'
export * from './actions'
export * from './formats'
export * from './document/docs'
import la from 'lazy-ass'
import camelCase from 'lodash.camelcase'
import cloneDeep from 'lodash.clonedeep'
import { map, path, uniq } from 'ramda'
import {
JsonPropertyTypes,
ObjectSchema,

@@ -88,55 +86,1 @@ SchemaCollection,

}
/**
* Adds a property to another schema, creating a new schema.
*/
export const addProperty = (
objectSchema: ObjectSchema,
title: string,
description: string,
property: string,
propertyType: JsonPropertyTypes,
propertyFormat: string | null,
exampleValue: any,
isRequired?: boolean,
propertyDescription?: string,
see?: string,
) => {
const newSchema: ObjectSchema = cloneDeep(objectSchema)
newSchema.schema.description = description
newSchema.schema.title = title
if (!newSchema.schema.properties) {
newSchema.schema.properties = {}
}
newSchema.schema.properties[property] = {
type: propertyType,
}
const newProp = newSchema.schema.properties[property]
// refine new property
if (propertyFormat) {
newProp.format = propertyFormat
}
if (isRequired) {
if (!newSchema.schema.required) {
newSchema.schema.required = []
}
if (Array.isArray(newSchema.schema.required)) {
newSchema.schema.required.push(property)
}
}
if (propertyDescription) {
newProp.description = propertyDescription
}
if (see) {
newProp.see = see
}
newSchema.example[property] = cloneDeep(exampleValue)
return newSchema
}
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