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.15 to 0.68.16

46

dist/cjs/JSONSchema.js

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

{
const len = ast.elements.length;
const elements = ast.elements.map((e, i) => merge(go(e.type, $defs, true, path.concat(i)), getJsonSchemaAnnotations(e)));

@@ -227,2 +226,3 @@ const rest = ast.rest.map(annotatedAST => merge(go(annotatedAST.type, $defs, true, path), getJsonSchemaAnnotations(annotatedAST)));

// ---------------------------------------------
const len = ast.elements.length;
if (len > 0) {

@@ -235,8 +235,10 @@ output.minItems = len - ast.elements.filter(element => element.isOptional).length;

// ---------------------------------------------
if (rest.length > 0) {
const restLength = rest.length;
if (restLength > 0) {
const head = rest[0];
if (len > 0) {
const isHomogeneous = restLength === 1 && ast.elements.every(e => e.type === ast.rest[0].type);
if (isHomogeneous) {
output.items = head;
} else {
output.additionalItems = head;
} else {
output.items = head;
}

@@ -246,3 +248,3 @@ // ---------------------------------------------

// ---------------------------------------------
if (rest.length > 1) {
if (restLength > 1) {
throw new Error(errors_.getJSONSchemaUnsupportedPostRestElementsErrorMessage(path));

@@ -264,4 +266,4 @@ }

}
let additionalProperties = undefined;
let patternProperties = undefined;
let propertyNames = undefined;
for (const is of ast.indexSignatures) {

@@ -272,3 +274,3 @@ const parameter = is.parameter;

{
additionalProperties = go(is.type, $defs, true, path);
patternProperties = go(is.type, $defs, true, path);
break;

@@ -278,4 +280,6 @@ }

{
patternProperties = {
[AST.getTemplateLiteralRegExp(parameter).source]: go(is.type, $defs, true, path)
patternProperties = go(is.type, $defs, true, path);
propertyNames = {
type: "string",
pattern: AST.getTemplateLiteralRegExp(parameter).source
};

@@ -286,10 +290,5 @@ break;

{
const hook = AST.getJSONSchemaAnnotation(parameter);
if (Option.isSome(hook) && "pattern" in hook.value && Predicate.isString(hook.value.pattern)) {
patternProperties = {
[hook.value.pattern]: go(is.type, $defs, true, path)
};
break;
}
throw new Error(errors_.getJSONSchemaUnsupportedParameterErrorMessage(path, parameter));
patternProperties = go(is.type, $defs, true, path);
propertyNames = go(parameter, $defs, true, path);
break;
}

@@ -329,8 +328,11 @@ case "SymbolKeyword":

// ---------------------------------------------
if (additionalProperties !== undefined) {
output.additionalProperties = additionalProperties;
}
if (patternProperties !== undefined) {
output.patternProperties = patternProperties;
delete output.additionalProperties;
output.patternProperties = {
"": patternProperties
};
}
if (propertyNames !== undefined) {
output.propertyNames = propertyNames;
}
return merge(output, getJsonSchemaAnnotations(ast));

@@ -337,0 +339,0 @@ }

@@ -168,2 +168,3 @@ /**

patternProperties?: Record<string, JsonSchema7>;
propertyNames?: JsonSchema7;
}

@@ -170,0 +171,0 @@ /**

@@ -58,5 +58,13 @@ /**

/**
* @since 0.68.16
*/
type Success<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _A : never;
/**
* @since 0.68.16
*/
type Error<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _E : never;
/**
* @since 0.67.0
*/
type Context<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer R> ? R : never;
type Context<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _R : never;
}

@@ -63,0 +71,0 @@ /**

@@ -184,3 +184,2 @@ /**

{
const len = ast.elements.length;
const elements = ast.elements.map((e, i) => merge(go(e.type, $defs, true, path.concat(i)), getJsonSchemaAnnotations(e)));

@@ -194,2 +193,3 @@ const rest = ast.rest.map(annotatedAST => merge(go(annotatedAST.type, $defs, true, path), getJsonSchemaAnnotations(annotatedAST)));

// ---------------------------------------------
const len = ast.elements.length;
if (len > 0) {

@@ -202,8 +202,10 @@ output.minItems = len - ast.elements.filter(element => element.isOptional).length;

// ---------------------------------------------
if (rest.length > 0) {
const restLength = rest.length;
if (restLength > 0) {
const head = rest[0];
if (len > 0) {
const isHomogeneous = restLength === 1 && ast.elements.every(e => e.type === ast.rest[0].type);
if (isHomogeneous) {
output.items = head;
} else {
output.additionalItems = head;
} else {
output.items = head;
}

@@ -213,3 +215,3 @@ // ---------------------------------------------

// ---------------------------------------------
if (rest.length > 1) {
if (restLength > 1) {
throw new Error(errors_.getJSONSchemaUnsupportedPostRestElementsErrorMessage(path));

@@ -231,4 +233,4 @@ }

}
let additionalProperties = undefined;
let patternProperties = undefined;
let propertyNames = undefined;
for (const is of ast.indexSignatures) {

@@ -239,3 +241,3 @@ const parameter = is.parameter;

{
additionalProperties = go(is.type, $defs, true, path);
patternProperties = go(is.type, $defs, true, path);
break;

@@ -245,4 +247,6 @@ }

{
patternProperties = {
[AST.getTemplateLiteralRegExp(parameter).source]: go(is.type, $defs, true, path)
patternProperties = go(is.type, $defs, true, path);
propertyNames = {
type: "string",
pattern: AST.getTemplateLiteralRegExp(parameter).source
};

@@ -253,10 +257,5 @@ break;

{
const hook = AST.getJSONSchemaAnnotation(parameter);
if (Option.isSome(hook) && "pattern" in hook.value && Predicate.isString(hook.value.pattern)) {
patternProperties = {
[hook.value.pattern]: go(is.type, $defs, true, path)
};
break;
}
throw new Error(errors_.getJSONSchemaUnsupportedParameterErrorMessage(path, parameter));
patternProperties = go(is.type, $defs, true, path);
propertyNames = go(parameter, $defs, true, path);
break;
}

@@ -296,8 +295,11 @@ case "SymbolKeyword":

// ---------------------------------------------
if (additionalProperties !== undefined) {
output.additionalProperties = additionalProperties;
}
if (patternProperties !== undefined) {
output.patternProperties = patternProperties;
delete output.additionalProperties;
output.patternProperties = {
"": patternProperties
};
}
if (propertyNames !== undefined) {
output.propertyNames = propertyNames;
}
return merge(output, getJsonSchemaAnnotations(ast));

@@ -304,0 +306,0 @@ }

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

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -184,2 +184,3 @@ /**

patternProperties?: Record<string, JsonSchema7>
propertyNames?: JsonSchema7
}

@@ -389,3 +390,2 @@

case "TupleType": {
const len = ast.elements.length
const elements = ast.elements.map((e, i) =>

@@ -407,2 +407,3 @@ merge(

// ---------------------------------------------
const len = ast.elements.length
if (len > 0) {

@@ -415,8 +416,10 @@ output.minItems = len - ast.elements.filter((element) => element.isOptional).length

// ---------------------------------------------
if (rest.length > 0) {
const restLength = rest.length
if (restLength > 0) {
const head = rest[0]
if (len > 0) {
const isHomogeneous = restLength === 1 && ast.elements.every((e) => e.type === ast.rest[0].type)
if (isHomogeneous) {
output.items = head
} else {
output.additionalItems = head
} else {
output.items = head
}

@@ -427,3 +430,3 @@

// ---------------------------------------------
if (rest.length > 1) {
if (restLength > 1) {
throw new Error(errors_.getJSONSchemaUnsupportedPostRestElementsErrorMessage(path))

@@ -445,4 +448,4 @@ }

}
let additionalProperties: JsonSchema7 | undefined = undefined
let patternProperties: Record<string, JsonSchema7> | undefined = undefined
let patternProperties: JsonSchema7 | undefined = undefined
let propertyNames: JsonSchema7 | undefined = undefined
for (const is of ast.indexSignatures) {

@@ -452,8 +455,10 @@ const parameter = is.parameter

case "StringKeyword": {
additionalProperties = go(is.type, $defs, true, path)
patternProperties = go(is.type, $defs, true, path)
break
}
case "TemplateLiteral": {
patternProperties = {
[AST.getTemplateLiteralRegExp(parameter).source]: go(is.type, $defs, true, path)
patternProperties = go(is.type, $defs, true, path)
propertyNames = {
type: "string",
pattern: AST.getTemplateLiteralRegExp(parameter).source
}

@@ -463,13 +468,5 @@ break

case "Refinement": {
const hook = AST.getJSONSchemaAnnotation(parameter)
if (
Option.isSome(hook) && "pattern" in hook.value &&
Predicate.isString(hook.value.pattern)
) {
patternProperties = {
[hook.value.pattern]: go(is.type, $defs, true, path)
}
break
}
throw new Error(errors_.getJSONSchemaUnsupportedParameterErrorMessage(path, parameter))
patternProperties = go(is.type, $defs, true, path)
propertyNames = go(parameter, $defs, true, path)
break
}

@@ -512,8 +509,9 @@ case "SymbolKeyword":

// ---------------------------------------------
if (additionalProperties !== undefined) {
output.additionalProperties = additionalProperties
}
if (patternProperties !== undefined) {
output.patternProperties = patternProperties
delete output.additionalProperties
output.patternProperties = { "": patternProperties }
}
if (propertyNames !== undefined) {
output.propertyNames = propertyNames
}

@@ -520,0 +518,0 @@ return merge(output, getJsonSchemaAnnotations(ast))

@@ -68,5 +68,15 @@ /**

/**
* @since 0.68.16
*/
export type Success<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _A : never
/**
* @since 0.68.16
*/
export type Error<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _E : never
/**
* @since 0.67.0
*/
export type Context<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer R> ? R : never
export type Context<T> = T extends WithResult<infer _A, infer _I, infer _E, infer _EI, infer _R> ? _R : never
}

@@ -73,0 +83,0 @@

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

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