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

schematized

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schematized - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

dist/schema-builder.d.ts

2

dist/index.d.ts

@@ -1,1 +0,1 @@

export { SchemaBuilder } from './builder';
export { default } from './schema-builder';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var builder_1 = require("./builder");
Object.defineProperty(exports, "SchemaBuilder", { enumerable: true, get: function () { return builder_1.SchemaBuilder; } });
const schema_builder_1 = __importDefault(require("./schema-builder"));
var schema_builder_2 = require("./schema-builder");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return schema_builder_2.default; } });
module.exports = schema_builder_1.default;
//# sourceMappingURL=index.js.map

@@ -39,3 +39,3 @@ "use strict";

const items = this.items.toSchema();
if (items?.anyOf && Array.isArray(items.anyOf)) {
if ((items === null || items === void 0 ? void 0 : items.anyOf) && Array.isArray(items.anyOf)) {
console.log(items.anyOf);

@@ -42,0 +42,0 @@ items.anyOf = lodash_1.default.uniqWith(items.anyOf, lodash_1.default.isEqual);

export declare class Required {
keywords: Set<string>;
required: Set<unknown>;
addObject(object: Record<string, unknown>): void;
required: Set<string> | null;
addObject(object: Record<string, any>): void;
addSchema(schema: Record<string, any>): void;
toSchema(): {
required: unknown[];
required: string[];
};
}

@@ -11,7 +11,7 @@ "use strict";

this.keywords = new Set(['required']);
this.required = new Set();
this.required = null;
}
addObject(object) {
const properties = new Set(Object.keys(object));
if (lodash_1.default.isNil(this.required) || this.required.size === 0) {
if (lodash_1.default.isNil(this.required)) {
this.required = properties;

@@ -27,7 +27,8 @@ }

const required = new Set(schema.required);
if (lodash_1.default.isNil(this.required) || this.required.size === 0) {
if (lodash_1.default.isNil(this.required)) {
this.required = required;
}
else {
this.required.add(required);
const newRequirements = lodash_1.default.intersection([...required], [...this.required]);
this.required = new Set(newRequirements);
}

@@ -34,0 +35,0 @@ }

{
"name": "schematized",
"description": "Turn objects into JSON schemas! The more examples you provide, the better your schema will be.",
"version": "1.6.0",
"version": "1.7.0",
"files": [

@@ -54,4 +54,4 @@ "dist/"

"@ava/typescript": "^1.1.1",
"@types/lodash": "^4.14.155",
"@types/node": "^14.0.13",
"@types/lodash": "^4.14.157",
"@types/node": "^14.0.14",
"ajv": "^6.12.2",

@@ -65,5 +65,5 @@ "ava": "^3.9.0",

"rimraf": "^3.0.2",
"semantic-release": "^17.0.8",
"semantic-release": "^17.1.1",
"ts-node": "^8.10.2",
"typescript": "^3.9.5",
"typescript": "^3.9.6",
"xo": "^0.32.0"

@@ -70,0 +70,0 @@ },

@@ -21,4 +21,4 @@ # Schematized

- [Schema from the two examples and the schema](#schema-from-the-two-examples-and-the-schema)
- [📖 API](#��-api)
- [✅ Supported Schema Features](#�-supported-schema-features)
- [:books: API](#-api)
- [:dart: Supported Schema Features](#-supported-schema-features)
- [Types](#types)

@@ -45,4 +45,4 @@ - [Typeless](#typeless)

```ts
import { SchemaBuilder } from 'schematized' // Typescript & ES6+
const { SchemaBuilder } = require('schematized') // CommonJS
import SchemaBuilder from 'schematized' // Typescript & ESM
const { default: SchemaBuilder } = require('schematized') // CommonJS

@@ -82,4 +82,4 @@ const builder = new SchemaBuilder()

builder.addSchema({
title: '/user response',
description: 'User data from server.'
title: '/user server response',
description: '/user server response'
})

@@ -94,3 +94,3 @@ ```

{
"$schema": "http://json-schema.org/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",

@@ -100,4 +100,4 @@ "properties": {

"type": "string",
"maxLength": 32,
"minLength": 32
"maxLength": 39,
"minLength": 39
},

@@ -108,3 +108,3 @@ "role": {

"type": "string",
"maxLength": 5,
"maxLength": 9,
"minLength": 5

@@ -117,3 +117,6 @@ }

"token"
]
],
"additionalProperties": false,
"maxProperties": 2,
"minProperties": 2
}

@@ -126,3 +129,3 @@ ```

{
"$schema": "http://json-schema.org/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",

@@ -133,3 +136,3 @@ "properties": {

"maxLength": 39,
"minLength": 32
"minLength": 39
},

@@ -148,3 +151,6 @@ "role": {

"token"
]
],
"additionalProperties": false,
"maxProperties": 2,
"minProperties": 2
}

@@ -157,5 +163,5 @@ ```

{
"$schema": "http://json-schema.org/schema#",
"title": "/user response",
"description": "User data from server.",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "/user server response",
"description": "User data.",
"type": "object",

@@ -166,3 +172,3 @@ "properties": {

"maxLength": 39,
"minLength": 32
"minLength": 39
},

@@ -181,3 +187,6 @@ "role": {

"token"
]
],
"additionalProperties": false,
"maxProperties": 2,
"minProperties": 2
}

@@ -188,3 +197,3 @@ ```

## 📖 API
## :books: API

@@ -198,3 +207,3 @@ | Method | Definition | Parameter |

## ✅ Supported Schema Features
## :dart: Supported Schema Features

@@ -201,0 +210,0 @@ Visit the [official JSON Schema site](https://json-schema.org/understanding-json-schema/reference/index.html) for specification details.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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