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

@effect/schema

Package Overview
Dependencies
Maintainers
3
Versions
335
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.68.25 to 0.68.26

49

dist/cjs/JSONSchema.js

@@ -73,6 +73,8 @@ "use strict";

const type = ps.type;
if (ps.isOptional && AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
return AST.Union.make(type.types.filter(type => !AST.isUndefinedKeyword(type)), type.annotations);
if (AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
const types = type.types.filter(type => !AST.isUndefinedKeyword(type));
if (types.length < type.types.length) {
return AST.Union.make(types, type.annotations);
}
}
return type;
};

@@ -82,8 +84,8 @@ /** @internal */

const get$ref = id => `${DEFINITION_PREFIX}${id}`;
const hasTransformation = ast => {
const getRefinementInnerTransformation = ast => {
switch (ast.from._tag) {
case "Transformation":
return true;
return ast.from;
case "Refinement":
return hasTransformation(ast.from);
return getRefinementInnerTransformation(ast.from);
case "Suspend":

@@ -93,8 +95,6 @@ {

if (AST.isRefinement(from)) {
return hasTransformation(from);
return getRefinementInnerTransformation(from);
}
}
break;
}
return false;
};

@@ -108,2 +108,5 @@ const isParseJsonTransformation = ast => ast.annotations[AST.TypeAnnotationId] === filters_.ParseJsonTypeId;

}
const isOverrideAnnotation = jsonSchema => {
return "type" in jsonSchema || "oneOf" in jsonSchema || "anyOf" in jsonSchema || "const" in jsonSchema || "enum" in jsonSchema || "$ref" in jsonSchema;
};
const go = (ast, $defs, handleIdentifier, path) => {

@@ -113,7 +116,12 @@ const hook = AST.getJSONSchemaAnnotation(ast);

const handler = hook.value;
if (AST.isRefinement(ast) && !hasTransformation(ast)) {
try {
return merge(merge(go(ast.from, $defs, true, path), getJsonSchemaAnnotations(ast)), handler);
} catch (e) {
return merge(getJsonSchemaAnnotations(ast), handler);
if (AST.isRefinement(ast)) {
const t = getRefinementInnerTransformation(ast);
if (t === undefined) {
try {
return merge(merge(go(ast.from, $defs, true, path), getJsonSchemaAnnotations(ast)), handler);
} catch (e) {
return merge(getJsonSchemaAnnotations(ast), handler);
}
} else if (!isOverrideAnnotation(handler)) {
return go(t, $defs, true, path);
}

@@ -273,5 +281,2 @@ }

}
const propertySignatures = ast.propertySignatures.map(ps => {
return merge(go(pruneUndefinedKeyword(ps), $defs, true, path.concat(ps.name)), getJsonSchemaAnnotations(ps));
});
const output = {

@@ -286,10 +291,12 @@ type: "object",

// ---------------------------------------------
for (let i = 0; i < propertySignatures.length; i++) {
const name = ast.propertySignatures[i].name;
for (let i = 0; i < ast.propertySignatures.length; i++) {
const ps = ast.propertySignatures[i];
const name = ps.name;
if (Predicate.isString(name)) {
output.properties[name] = propertySignatures[i];
const pruned = pruneUndefinedKeyword(ps);
output.properties[name] = merge(go(pruned ? pruned : ps.type, $defs, true, path.concat(ps.name)), getJsonSchemaAnnotations(ps));
// ---------------------------------------------
// handle optional property signatures
// ---------------------------------------------
if (!ast.propertySignatures[i].isOptional) {
if (!ps.isOptional && pruned === undefined) {
output.required.push(name);

@@ -296,0 +303,0 @@ }

@@ -63,6 +63,8 @@ /**

const type = ps.type;
if (ps.isOptional && AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
return AST.Union.make(type.types.filter(type => !AST.isUndefinedKeyword(type)), type.annotations);
if (AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
const types = type.types.filter(type => !AST.isUndefinedKeyword(type));
if (types.length < type.types.length) {
return AST.Union.make(types, type.annotations);
}
}
return type;
};

@@ -72,8 +74,8 @@ /** @internal */

const get$ref = id => `${DEFINITION_PREFIX}${id}`;
const hasTransformation = ast => {
const getRefinementInnerTransformation = ast => {
switch (ast.from._tag) {
case "Transformation":
return true;
return ast.from;
case "Refinement":
return hasTransformation(ast.from);
return getRefinementInnerTransformation(ast.from);
case "Suspend":

@@ -83,8 +85,6 @@ {

if (AST.isRefinement(from)) {
return hasTransformation(from);
return getRefinementInnerTransformation(from);
}
}
break;
}
return false;
};

@@ -98,2 +98,5 @@ const isParseJsonTransformation = ast => ast.annotations[AST.TypeAnnotationId] === filters_.ParseJsonTypeId;

}
const isOverrideAnnotation = jsonSchema => {
return "type" in jsonSchema || "oneOf" in jsonSchema || "anyOf" in jsonSchema || "const" in jsonSchema || "enum" in jsonSchema || "$ref" in jsonSchema;
};
const go = (ast, $defs, handleIdentifier, path) => {

@@ -103,7 +106,12 @@ const hook = AST.getJSONSchemaAnnotation(ast);

const handler = hook.value;
if (AST.isRefinement(ast) && !hasTransformation(ast)) {
try {
return merge(merge(go(ast.from, $defs, true, path), getJsonSchemaAnnotations(ast)), handler);
} catch (e) {
return merge(getJsonSchemaAnnotations(ast), handler);
if (AST.isRefinement(ast)) {
const t = getRefinementInnerTransformation(ast);
if (t === undefined) {
try {
return merge(merge(go(ast.from, $defs, true, path), getJsonSchemaAnnotations(ast)), handler);
} catch (e) {
return merge(getJsonSchemaAnnotations(ast), handler);
}
} else if (!isOverrideAnnotation(handler)) {
return go(t, $defs, true, path);
}

@@ -263,5 +271,2 @@ }

}
const propertySignatures = ast.propertySignatures.map(ps => {
return merge(go(pruneUndefinedKeyword(ps), $defs, true, path.concat(ps.name)), getJsonSchemaAnnotations(ps));
});
const output = {

@@ -276,10 +281,12 @@ type: "object",

// ---------------------------------------------
for (let i = 0; i < propertySignatures.length; i++) {
const name = ast.propertySignatures[i].name;
for (let i = 0; i < ast.propertySignatures.length; i++) {
const ps = ast.propertySignatures[i];
const name = ps.name;
if (Predicate.isString(name)) {
output.properties[name] = propertySignatures[i];
const pruned = pruneUndefinedKeyword(ps);
output.properties[name] = merge(go(pruned ? pruned : ps.type, $defs, true, path.concat(ps.name)), getJsonSchemaAnnotations(ps));
// ---------------------------------------------
// handle optional property signatures
// ---------------------------------------------
if (!ast.propertySignatures[i].isOptional) {
if (!ps.isOptional && pruned === undefined) {
output.required.push(name);

@@ -286,0 +293,0 @@ }

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

@@ -16,3 +16,3 @@ "license": "MIT",

"peerDependencies": {
"effect": "^3.5.5"
"effect": "^3.5.6"
},

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

@@ -271,8 +271,10 @@ /**

const pruneUndefinedKeyword = (ps: AST.PropertySignature): AST.AST => {
const pruneUndefinedKeyword = (ps: AST.PropertySignature): AST.AST | undefined => {
const type = ps.type
if (ps.isOptional && AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
return AST.Union.make(type.types.filter((type) => !AST.isUndefinedKeyword(type)), type.annotations)
if (AST.isUnion(type) && Option.isNone(AST.getJSONSchemaAnnotation(type))) {
const types = type.types.filter((type) => !AST.isUndefinedKeyword(type))
if (types.length < type.types.length) {
return AST.Union.make(types, type.annotations)
}
}
return type
}

@@ -285,18 +287,15 @@

const hasTransformation = (ast: AST.Refinement): boolean => {
const getRefinementInnerTransformation = (ast: AST.Refinement): AST.AST | undefined => {
switch (ast.from._tag) {
case "Transformation":
return true
return ast.from
case "Refinement":
return hasTransformation(ast.from)
case "Suspend":
{
const from = ast.from.f()
if (AST.isRefinement(from)) {
return hasTransformation(from)
}
return getRefinementInnerTransformation(ast.from)
case "Suspend": {
const from = ast.from.f()
if (AST.isRefinement(from)) {
return getRefinementInnerTransformation(from)
}
break
}
}
return false
}

@@ -314,2 +313,7 @@

const isOverrideAnnotation = (jsonSchema: JsonSchema7): boolean => {
return ("type" in jsonSchema) || ("oneOf" in jsonSchema) || ("anyOf" in jsonSchema) || ("const" in jsonSchema) ||
("enum" in jsonSchema) || ("$ref" in jsonSchema)
}
const go = (

@@ -324,7 +328,12 @@ ast: AST.AST,

const handler = hook.value as JsonSchema7
if (AST.isRefinement(ast) && !hasTransformation(ast)) {
try {
return merge(merge(go(ast.from, $defs, true, path), getJsonSchemaAnnotations(ast)), handler)
} catch (e) {
return merge(getJsonSchemaAnnotations(ast), handler)
if (AST.isRefinement(ast)) {
const t = getRefinementInnerTransformation(ast)
if (t === undefined) {
try {
return merge(merge(go(ast.from, $defs, true, path), getJsonSchemaAnnotations(ast)), handler)
} catch (e) {
return merge(getJsonSchemaAnnotations(ast), handler)
}
} else if (!isOverrideAnnotation(handler)) {
return go(t, $defs, true, path)
}

@@ -473,8 +482,2 @@ }

}
const propertySignatures = ast.propertySignatures.map((ps) => {
return merge(
go(pruneUndefinedKeyword(ps), $defs, true, path.concat(ps.name)),
getJsonSchemaAnnotations(ps)
)
})
const output: JsonSchema7Object = {

@@ -489,10 +492,15 @@ type: "object",

// ---------------------------------------------
for (let i = 0; i < propertySignatures.length; i++) {
const name = ast.propertySignatures[i].name
for (let i = 0; i < ast.propertySignatures.length; i++) {
const ps = ast.propertySignatures[i]
const name = ps.name
if (Predicate.isString(name)) {
output.properties[name] = propertySignatures[i]
const pruned = pruneUndefinedKeyword(ps)
output.properties[name] = merge(
go(pruned ? pruned : ps.type, $defs, true, path.concat(ps.name)),
getJsonSchemaAnnotations(ps)
)
// ---------------------------------------------
// handle optional property signatures
// ---------------------------------------------
if (!ast.propertySignatures[i].isOptional) {
if (!ps.isOptional && pruned === undefined) {
output.required.push(name)

@@ -499,0 +507,0 @@ }

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 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

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