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.75.4 to 0.75.5

4

dist/cjs/Equivalence.js

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

var Option = _interopRequireWildcard(require("effect/Option"));
var Predicate = _interopRequireWildcard(require("effect/Predicate"));
var AST = _interopRequireWildcard(require("./AST.js"));

@@ -189,3 +188,3 @@ var errors_ = _interopRequireWildcard(require("./internal/errors.js"));

let candidates = [];
if (len > 0 && Predicate.isRecord(a)) {
if (len > 0 && isRecordOrArray(a)) {
for (let i = 0; i < len; i++) {

@@ -221,2 +220,3 @@ const name = ownKeys[i];

};
const isRecordOrArray = input => typeof input === "object" && input !== null;
//# sourceMappingURL=Equivalence.js.map

@@ -1691,51 +1691,54 @@ /**

};
const getTypeLiteralPropertySignature = (ast, name) => {
// from property signatures...
const ops = Arr.findFirst(ast.propertySignatures, ps => ps.name === name);
if (Option.isSome(ops)) {
return ops.value;
}
// from index signatures...
if (Predicate.isString(name)) {
let out = undefined;
for (const is of ast.indexSignatures) {
const parameterBase = getParameterBase(is.parameter);
switch (parameterBase._tag) {
case "TemplateLiteral":
{
const regex = getTemplateLiteralRegExp(parameterBase);
if (regex.test(name)) {
return new PropertySignature(name, is.type, false, true);
}
break;
}
case "StringKeyword":
{
if (out === undefined) {
out = new PropertySignature(name, is.type, false, true);
}
}
}
}
if (out) {
return out;
}
} else if (Predicate.isSymbol(name)) {
for (const is of ast.indexSignatures) {
const parameterBase = getParameterBase(is.parameter);
if (isSymbolKeyword(parameterBase)) {
return new PropertySignature(name, is.type, false, true);
}
}
}
};
/** @internal */
export const getPropertyKeyIndexedAccess = (ast, name) => {
const annotation = getSurrogateAnnotation(ast);
if (Option.isSome(annotation)) {
return getPropertyKeyIndexedAccess(annotation.value, name);
}
switch (ast._tag) {
case "Declaration":
{
const annotation = getSurrogateAnnotation(ast);
if (Option.isSome(annotation)) {
return getPropertyKeyIndexedAccess(annotation.value, name);
}
break;
}
case "TypeLiteral":
{
const ops = Arr.findFirst(ast.propertySignatures, ps => ps.name === name);
if (Option.isSome(ops)) {
return ops.value;
} else {
if (Predicate.isString(name)) {
let out = undefined;
for (const is of ast.indexSignatures) {
const parameterBase = getParameterBase(is.parameter);
switch (parameterBase._tag) {
case "TemplateLiteral":
{
const regex = getTemplateLiteralRegExp(parameterBase);
if (regex.test(name)) {
return new PropertySignature(name, is.type, false, true);
}
break;
}
case "StringKeyword":
{
if (out === undefined) {
out = new PropertySignature(name, is.type, false, true);
}
}
}
}
if (out) {
return out;
}
} else if (Predicate.isSymbol(name)) {
for (const is of ast.indexSignatures) {
const parameterBase = getParameterBase(is.parameter);
if (isSymbolKeyword(parameterBase)) {
return new PropertySignature(name, is.type, false, true);
}
}
}
const ps = getTypeLiteralPropertySignature(ast, name);
if (ps) {
return ps;
}

@@ -1748,2 +1751,4 @@ break;

return getPropertyKeyIndexedAccess(ast.f(), name);
case "Refinement":
return getPropertyKeyIndexedAccess(ast.from, name);
}

@@ -1823,32 +1828,57 @@ return new PropertySignature(name, neverKeyword, false, true);

export const pick = (ast, keys) => {
if (isTransformation(ast)) {
switch (ast.transformation._tag) {
case "ComposeTransformation":
return new Transformation(pick(ast.from, keys), pick(ast.to, keys), composeTransformation);
case "TypeLiteralTransformation":
{
const ts = [];
const fromKeys = [];
for (const k of keys) {
const t = ast.transformation.propertySignatureTransformations.find(t => t.to === k);
if (t) {
ts.push(t);
fromKeys.push(t.from);
} else {
fromKeys.push(k);
}
const annotation = getSurrogateAnnotation(ast);
if (Option.isSome(annotation)) {
return pick(annotation.value, keys);
}
switch (ast._tag) {
case "TypeLiteral":
{
const pss = [];
const names = {};
for (const ps of ast.propertySignatures) {
names[ps.name] = null;
if (keys.includes(ps.name)) {
pss.push(ps);
}
return Arr.isNonEmptyReadonlyArray(ts) ? new Transformation(pick(ast.from, fromKeys), pick(ast.to, keys), new TypeLiteralTransformation(ts)) : pick(ast.from, fromKeys);
}
case "FinalTransformation":
{
const annotation = getSurrogateAnnotation(ast);
if (Option.isSome(annotation)) {
return pick(annotation.value, keys);
for (const key of keys) {
if (!(key in names)) {
const ps = getTypeLiteralPropertySignature(ast, key);
if (ps) {
pss.push(ps);
}
}
throw new Error(errors_.getASTUnsupportedSchema(ast));
}
}
return new TypeLiteral(pss, []);
}
case "Union":
return new TypeLiteral(keys.map(name => getPropertyKeyIndexedAccess(ast, name)), []);
case "Suspend":
return pick(ast.f(), keys);
case "Refinement":
return pick(ast.from, keys);
case "Transformation":
{
switch (ast.transformation._tag) {
case "ComposeTransformation":
return new Transformation(pick(ast.from, keys), pick(ast.to, keys), composeTransformation);
case "TypeLiteralTransformation":
{
const ts = [];
const fromKeys = [];
for (const k of keys) {
const t = ast.transformation.propertySignatureTransformations.find(t => t.to === k);
if (t) {
ts.push(t);
fromKeys.push(t.from);
} else {
fromKeys.push(k);
}
}
return Arr.isNonEmptyReadonlyArray(ts) ? new Transformation(pick(ast.from, fromKeys), pick(ast.to, keys), new TypeLiteralTransformation(ts)) : pick(ast.from, fromKeys);
}
}
}
}
return new TypeLiteral(keys.map(key => getPropertyKeyIndexedAccess(ast, key)), []);
throw new Error(errors_.getASTUnsupportedSchema(ast));
};

@@ -1855,0 +1885,0 @@ /**

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

import * as Option from "effect/Option";
import * as Predicate from "effect/Predicate";
import * as AST from "./AST.js";

@@ -178,3 +177,3 @@ import * as errors_ from "./internal/errors.js";

let candidates = [];
if (len > 0 && Predicate.isRecord(a)) {
if (len > 0 && isRecordOrArray(a)) {
for (let i = 0; i < len; i++) {

@@ -210,2 +209,3 @@ const name = ownKeys[i];

};
const isRecordOrArray = input => typeof input === "object" && input !== null;
//# sourceMappingURL=Equivalence.js.map
{
"name": "@effect/schema",
"version": "0.75.4",
"version": "0.75.5",
"description": "Modeling the schema of data structures as first-class values",

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

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

import * as Option from "effect/Option"
import * as Predicate from "effect/Predicate"
import * as AST from "./AST.js"

@@ -193,3 +192,3 @@ import * as errors_ from "./internal/errors.js"

let candidates: Array<AST.AST> = []
if (len > 0 && Predicate.isRecord(a)) {
if (len > 0 && isRecordOrArray(a)) {
for (let i = 0; i < len; i++) {

@@ -223,1 +222,4 @@ const name = ownKeys[i]

}
const isRecordOrArray = (input: unknown): input is { [x: PropertyKey]: unknown } =>
typeof input === "object" && input !== null

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