Socket
Socket
Sign inDemoInstall

@effect/schema

Package Overview
Dependencies
Maintainers
3
Versions
326
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/schema - npm Package Compare versions

Comparing version 0.70.4 to 0.71.0

36

dist/cjs/JSONSchema.js

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

"$id": "/schemas/object",
"oneOf": [{
"anyOf": [{
"type": "object"

@@ -62,3 +62,3 @@ }, {

"$id": "/schemas/{}",
"oneOf": [{
"anyOf": [{
"type": "object"

@@ -157,7 +157,7 @@ }, {

return merge({
const: null
enum: [null]
}, getJsonSchemaAnnotations(ast));
} else if (Predicate.isString(literal) || Predicate.isNumber(literal) || Predicate.isBoolean(literal)) {
return merge({
const: literal
enum: [literal]
}, getJsonSchemaAnnotations(ast));

@@ -327,7 +327,9 @@ }

const schema = go(type, $defs, true, path);
if ("const" in schema) {
if ("enum" in schema) {
if (Object.keys(schema).length > 1) {
anyOf.push(schema);
} else {
enums.push(schema.const);
for (const e of schema.enum) {
enums.push(e);
}
}

@@ -339,18 +341,8 @@ } else {

if (anyOf.length === 0) {
if (enums.length === 1) {
return merge({
const: enums[0]
}, getJsonSchemaAnnotations(ast));
} else {
return merge({
enum: enums
}, getJsonSchemaAnnotations(ast));
}
return merge({
enum: enums
}, getJsonSchemaAnnotations(ast));
} else {
if (enums.length === 1) {
if (enums.length >= 1) {
anyOf.push({
const: enums[0]
});
} else if (enums.length > 1) {
anyOf.push({
enum: enums

@@ -368,5 +360,5 @@ });

$comment: "/schemas/enums",
oneOf: ast.enums.map(e => ({
anyOf: ast.enums.map(e => ({
title: e[0],
const: e[1]
enum: [e[1]]
}))

@@ -373,0 +365,0 @@ }, getJsonSchemaAnnotations(ast));

@@ -39,7 +39,7 @@ /**

* @category model
* @since 0.67.0
* @since 0.71.0
*/
export interface JsonSchema7object extends JsonSchemaAnnotations {
$id: "/schemas/object";
oneOf: [
anyOf: [
{

@@ -55,7 +55,7 @@ type: "object";

* @category model
* @since 0.67.0
* @since 0.71.0
*/
export interface JsonSchema7empty extends JsonSchemaAnnotations {
$id: "/schemas/{}";
oneOf: [
anyOf: [
{

@@ -80,9 +80,2 @@ type: "object";

*/
export interface JsonSchema7Const extends JsonSchemaAnnotations {
const: AST.LiteralValue;
}
/**
* @category model
* @since 0.67.0
*/
export interface JsonSchema7String extends JsonSchemaAnnotations {

@@ -140,9 +133,2 @@ type: "string";

*/
export interface JsonSchema7OneOf extends JsonSchemaAnnotations {
oneOf: Array<JsonSchema7>;
}
/**
* @category model
* @since 0.67.0
*/
export interface JsonSchema7Enum extends JsonSchemaAnnotations {

@@ -153,9 +139,9 @@ enum: Array<AST.LiteralValue>;

* @category model
* @since 0.67.0
* @since 0.71.0
*/
export interface JsonSchema7Enums extends JsonSchemaAnnotations {
$comment: "/schemas/enums";
oneOf: Array<{
anyOf: Array<{
title: string;
const: string | number;
enum: [string | number];
}>;

@@ -184,5 +170,5 @@ }

* @category model
* @since 0.69.0
* @since 0.71.0
*/
export type JsonSchema7 = JsonSchema7Any | JsonSchema7Unknown | JsonSchema7Void | JsonSchema7object | JsonSchema7empty | JsonSchema7Ref | JsonSchema7Const | JsonSchema7String | JsonSchema7Number | JsonSchema7Integer | JsonSchema7Boolean | JsonSchema7Array | JsonSchema7OneOf | JsonSchema7Enum | JsonSchema7Enums | JsonSchema7AnyOf | JsonSchema7Object;
export type JsonSchema7 = JsonSchema7Any | JsonSchema7Unknown | JsonSchema7Void | JsonSchema7object | JsonSchema7empty | JsonSchema7Ref | JsonSchema7String | JsonSchema7Number | JsonSchema7Integer | JsonSchema7Boolean | JsonSchema7Array | JsonSchema7Enum | JsonSchema7Enums | JsonSchema7AnyOf | JsonSchema7Object;
/**

@@ -189,0 +175,0 @@ * @category model

@@ -263,5 +263,3 @@ /**

export const isLiteral = /*#__PURE__*/createASTGuard("Literal");
const $null = /*#__PURE__*/new Literal(null, {
[IdentifierAnnotationId]: "null"
});
const $null = /*#__PURE__*/new Literal(null);
export {

@@ -759,3 +757,2 @@ /**

export const objectKeyword = /*#__PURE__*/new ObjectKeyword({
[IdentifierAnnotationId]: "object",
[TitleAnnotationId]: "object",

@@ -762,0 +759,0 @@ [DescriptionAnnotationId]: "an object in the TypeScript meaning, i.e. the `object` type"

@@ -43,3 +43,3 @@ /**

"$id": "/schemas/object",
"oneOf": [{
"anyOf": [{
"type": "object"

@@ -52,3 +52,3 @@ }, {

"$id": "/schemas/{}",
"oneOf": [{
"anyOf": [{
"type": "object"

@@ -147,7 +147,7 @@ }, {

return merge({
const: null
enum: [null]
}, getJsonSchemaAnnotations(ast));
} else if (Predicate.isString(literal) || Predicate.isNumber(literal) || Predicate.isBoolean(literal)) {
return merge({
const: literal
enum: [literal]
}, getJsonSchemaAnnotations(ast));

@@ -317,7 +317,9 @@ }

const schema = go(type, $defs, true, path);
if ("const" in schema) {
if ("enum" in schema) {
if (Object.keys(schema).length > 1) {
anyOf.push(schema);
} else {
enums.push(schema.const);
for (const e of schema.enum) {
enums.push(e);
}
}

@@ -329,18 +331,8 @@ } else {

if (anyOf.length === 0) {
if (enums.length === 1) {
return merge({
const: enums[0]
}, getJsonSchemaAnnotations(ast));
} else {
return merge({
enum: enums
}, getJsonSchemaAnnotations(ast));
}
return merge({
enum: enums
}, getJsonSchemaAnnotations(ast));
} else {
if (enums.length === 1) {
if (enums.length >= 1) {
anyOf.push({
const: enums[0]
});
} else if (enums.length > 1) {
anyOf.push({
enum: enums

@@ -358,5 +350,5 @@ });

$comment: "/schemas/enums",
oneOf: ast.enums.map(e => ({
anyOf: ast.enums.map(e => ({
title: e[0],
const: e[1]
enum: [e[1]]
}))

@@ -363,0 +355,0 @@ }, getJsonSchemaAnnotations(ast));

{
"name": "@effect/schema",
"version": "0.70.4",
"version": "0.71.0",
"description": "Modeling the schema of data structures as first-class values",

@@ -13,6 +13,6 @@ "license": "MIT",

"dependencies": {
"fast-check": "^3.20.0"
"fast-check": "^3.21.0"
},
"peerDependencies": {
"effect": "^3.6.3"
"effect": "^3.6.4"
},

@@ -19,0 +19,0 @@ "publishConfig": {

@@ -50,7 +50,7 @@ /**

* @category model
* @since 0.67.0
* @since 0.71.0
*/
export interface JsonSchema7object extends JsonSchemaAnnotations {
$id: "/schemas/object"
oneOf: [
anyOf: [
{ type: "object" },

@@ -63,7 +63,7 @@ { type: "array" }

* @category model
* @since 0.67.0
* @since 0.71.0
*/
export interface JsonSchema7empty extends JsonSchemaAnnotations {
$id: "/schemas/{}"
oneOf: [
anyOf: [
{ type: "object" },

@@ -86,10 +86,2 @@ { type: "array" }

*/
export interface JsonSchema7Const extends JsonSchemaAnnotations {
const: AST.LiteralValue
}
/**
* @category model
* @since 0.67.0
*/
export interface JsonSchema7String extends JsonSchemaAnnotations {

@@ -153,10 +145,2 @@ type: "string"

*/
export interface JsonSchema7OneOf extends JsonSchemaAnnotations {
oneOf: Array<JsonSchema7>
}
/**
* @category model
* @since 0.67.0
*/
export interface JsonSchema7Enum extends JsonSchemaAnnotations {

@@ -168,9 +152,9 @@ enum: Array<AST.LiteralValue>

* @category model
* @since 0.67.0
* @since 0.71.0
*/
export interface JsonSchema7Enums extends JsonSchemaAnnotations {
$comment: "/schemas/enums"
oneOf: Array<{
anyOf: Array<{
title: string
const: string | number
enum: [string | number]
}>

@@ -202,3 +186,3 @@ }

* @category model
* @since 0.69.0
* @since 0.71.0
*/

@@ -212,3 +196,2 @@ export type JsonSchema7 =

| JsonSchema7Ref
| JsonSchema7Const
| JsonSchema7String

@@ -219,3 +202,2 @@ | JsonSchema7Number

| JsonSchema7Array
| JsonSchema7OneOf
| JsonSchema7Enum

@@ -266,3 +248,3 @@ | JsonSchema7Enums

"$id": "/schemas/object",
"oneOf": [
"anyOf": [
{ "type": "object" },

@@ -275,3 +257,3 @@ { "type": "array" }

"$id": "/schemas/{}",
"oneOf": [
"anyOf": [
{ "type": "object" },

@@ -382,5 +364,5 @@ { "type": "array" }

if (literal === null) {
return merge({ const: null }, getJsonSchemaAnnotations(ast))
return merge({ enum: [null] }, getJsonSchemaAnnotations(ast))
} else if (Predicate.isString(literal) || Predicate.isNumber(literal) || Predicate.isBoolean(literal)) {
return merge({ const: literal }, getJsonSchemaAnnotations(ast))
return merge({ enum: [literal] }, getJsonSchemaAnnotations(ast))
}

@@ -546,7 +528,9 @@ throw new Error(errors_.getJSONSchemaMissingAnnotationErrorMessage(path, ast))

const schema = go(type, $defs, true, path)
if ("const" in schema) {
if ("enum" in schema) {
if (Object.keys(schema).length > 1) {
anyOf.push(schema)
} else {
enums.push(schema.const)
for (const e of schema.enum) {
enums.push(e)
}
}

@@ -558,11 +542,5 @@ } else {

if (anyOf.length === 0) {
if (enums.length === 1) {
return merge({ const: enums[0] }, getJsonSchemaAnnotations(ast))
} else {
return merge({ enum: enums }, getJsonSchemaAnnotations(ast))
}
return merge({ enum: enums }, getJsonSchemaAnnotations(ast))
} else {
if (enums.length === 1) {
anyOf.push({ const: enums[0] })
} else if (enums.length > 1) {
if (enums.length >= 1) {
anyOf.push({ enum: enums })

@@ -576,3 +554,3 @@ }

$comment: "/schemas/enums",
oneOf: ast.enums.map((e) => ({ title: e[0], const: e[1] }))
anyOf: ast.enums.map((e) => ({ title: e[0], enum: [e[1]] }))
}, getJsonSchemaAnnotations(ast))

@@ -579,0 +557,0 @@ }

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

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 too big to display

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

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

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

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

Sorry, the diff of this file is not supported yet

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

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

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