Socket
Socket
Sign inDemoInstall

@arktype/schema

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@arktype/schema - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

2

out/module.d.ts

@@ -12,3 +12,3 @@ import { DynamicBase, type anyOrNever } from "@ark/util";

export interface InternalModule<exports extends InternalResolutions = InternalResolutions> extends RootModule<exports> {
$root?: BaseRoot;
root?: BaseRoot;
}

@@ -15,0 +15,0 @@ export declare const bindModule: (module: InternalModule, $: BaseScope) => InternalModule;

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

import type { array, Key } from "@ark/util";
import type { NodeCompiler } from "../shared/compile.ts";

@@ -8,3 +7,2 @@ import type { TraverseApply } from "../shared/traversal.ts";

abstract compiledNegation: string;
abstract literalKeys: array<Key>;
structure: undefined;

@@ -11,0 +9,0 @@ traverseApply: TraverseApply<d["prerequisite"]>;

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

import { type Domain as _Domain, type array, type Key } from "@ark/util";
import { type Domain as _Domain } from "@ark/util";
import type { BaseErrorContext, BaseNormalizedSchema, declareNode } from "../shared/declare.ts";

@@ -35,3 +35,2 @@ import { type nodeImplementationOf } from "../shared/implement.ts";

readonly expression: string;
readonly literalKeys: array<Key>;
get shortDescription(): string;

@@ -38,0 +37,0 @@ protected innerToJsonSchema(): JsonSchema.Constrainable;

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

import { domainDescriptions, domainOf, getBaseDomainKeys, throwParseError } from "@ark/util";
import { domainDescriptions, domainOf, throwParseError } from "@ark/util";
import { Disjoint } from "../shared/disjoint.js";

@@ -31,3 +31,2 @@ import { implementNode } from "../shared/implement.js";

expression = this.domain;
literalKeys = getBaseDomainKeys(this.domain);
get shortDescription() {

@@ -34,0 +33,0 @@ return domainDescriptions[this.domain];

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

import { type BuiltinObjectKind, type Constructor, type Key, type array } from "@ark/util";
import { type BuiltinObjectKind, type Constructor } from "@ark/util";
import type { BaseErrorContext, BaseNormalizedSchema, declareNode } from "../shared/declare.ts";

@@ -36,3 +36,2 @@ import { type nodeImplementationOf } from "../shared/implement.ts";

compiledNegation: string;
literalKeys: array<Key>;
protected innerToJsonSchema(): JsonSchema.Array;

@@ -39,0 +38,0 @@ traverseAllows: TraverseAllows;

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

import { builtinConstructors, constructorExtends, getBuiltinNameOfConstructor, objectKindDescriptions, objectKindOrDomainOf, prototypeKeysOf, throwParseError } from "@ark/util";
import { builtinConstructors, constructorExtends, getBuiltinNameOfConstructor, objectKindDescriptions, objectKindOrDomainOf, throwParseError } from "@ark/util";
import { Disjoint } from "../shared/disjoint.js";

@@ -41,3 +41,2 @@ import { defaultValueSerializer, implementNode } from "../shared/implement.js";

compiledNegation = `!(${this.compiledCondition})`;
literalKeys = prototypeKeysOf(this.proto.prototype);
innerToJsonSchema() {

@@ -44,0 +43,0 @@ switch (this.builtinName) {

@@ -56,2 +56,4 @@ import { inferred, type array } from "@ark/util";

describe(description: string): this;
optional(): this;
default(value: unknown): this;
from(input: unknown): unknown;

@@ -58,0 +60,0 @@ protected _pipe(...morphs: Morph[]): BaseRoot;

@@ -141,4 +141,10 @@ import { includes, inferred, omit, throwInternalError, throwParseError } from "@ark/util";

}
optional() {
return this.withMeta({ optional: true });
}
default(value) {
return this.withMeta({ default: value });
}
from(input) {
// ideally we wouldn't validate here but for now we need to do determine
// ideally we might not validate here but for now we need to do determine
// which morphs to apply

@@ -145,0 +151,0 @@ return this.assert(input);

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

import { type Domain, type JsonPrimitive, type Key, type array } from "@ark/util";
import { type Domain, type JsonPrimitive } from "@ark/util";
import type { BaseErrorContext, BaseNormalizedSchema, declareNode } from "../shared/declare.ts";

@@ -29,3 +29,2 @@ import { type nodeImplementationOf } from "../shared/implement.ts";

serializedValue: string;
literalKeys: array<Key>;
compiledCondition: string;

@@ -32,0 +31,0 @@ compiledNegation: string;

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

import { domainDescriptions, domainOf, printable, prototypeKeysOf, throwParseError } from "@ark/util";
import { domainDescriptions, domainOf, printable, throwParseError } from "@ark/util";
import { Disjoint } from "../shared/disjoint.js";

@@ -54,3 +54,2 @@ import { defaultValueSerializer, implementNode } from "../shared/implement.js";

: `${this.compiledValue}`;
literalKeys = prototypeKeysOf(this.unit);
compiledCondition = compileEqualityCheck(this.unit, this.serializedValue);

@@ -57,0 +56,0 @@ compiledNegation = compileEqualityCheck(this.unit, this.serializedValue, "negated");

@@ -15,3 +15,3 @@ import { ParseError, type Json, type anyOrNever, type array, type conform, type flattenListable, type listable, type noSuggest } from "@ark/util";

export type resolvableReferenceIn<$> = {
[k in keyof $]: k extends string ? k extends PrivateDeclaration<infer alias> ? alias : k extends noSuggest | "$root" ? never : k : never;
[k in keyof $]: k extends string ? k extends PrivateDeclaration<infer alias> ? alias : k extends noSuggest | "root" ? never : k : never;
}[keyof $];

@@ -18,0 +18,0 @@ export type resolveReference<reference extends resolvableReferenceIn<$>, $> = reference extends keyof $ ? $[reference] : $[`#${reference}` & keyof $];

@@ -188,4 +188,4 @@ import { ParseError, flatMorph, hasDomain, isArray, printable, throwInternalError, throwParseError } from "@ark/util";

if (hasArkKind(preparsed, "module")) {
if (preparsed.$root)
return (this.resolutions[name] = preparsed.$root.bindScope(this));
if (preparsed.root)
return (this.resolutions[name] = preparsed.root.bindScope(this));
else

@@ -283,3 +283,3 @@ return throwParseError(writeMissingSubmoduleAccessMessage(name));

if (hasArkKind(resolution, "module")) {
return (resolution.$root ??
return (resolution.root ??
throwParseError(writeMissingSubmoduleAccessMessage(name)));

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

@@ -11,2 +11,3 @@ import type { merge, show } from "@ark/util";

alias?: string;
optional?: true;
}

@@ -13,0 +14,0 @@ declare global {

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

import { type JsonArray, type JsonData, type JsonObject, type listable } from "@ark/util";
import { type JsonArray, type JsonObject, type listable } from "@ark/util";
import type { ConstraintKind } from "./implement.ts";

@@ -10,6 +10,7 @@ export type JsonSchema = JsonSchema.Union | JsonSchema.Branch;

**/
type Meta<t extends JsonData = JsonData> = {
type Meta<t = unknown> = {
title?: string;
description?: string;
deprecated?: true;
default?: t;
examples?: readonly t[];

@@ -16,0 +17,0 @@ };

@@ -19,2 +19,3 @@ import type { declareNode } from "../shared/declare.ts";

export declare class OptionalNode extends BaseProp<"optional"> {
constructor(...args: ConstructorParameters<typeof BaseProp>);
expression: string;

@@ -36,1 +37,3 @@ }

};
export declare const writeUnassignableDefaultValueMessage: <key extends string, message extends string>(key: key, message: message) => string;
export type writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} is not assignable to ${baseDef}`;

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

import { throwParseError } from "@ark/util";
import { ArkErrors } from "../shared/errors.js";
import { implementNode } from "../shared/implement.js";

@@ -26,2 +28,11 @@ import { BaseProp, intersectProps } from "./prop.js";

export class OptionalNode extends BaseProp {
constructor(...args) {
super(...args);
if ("default" in this.inner) {
const out = this.value.in(this.inner.default);
if (out instanceof ArkErrors) {
throwParseError(writeUnassignableDefaultValueMessage(this.serializedKey, out.message));
}
}
}
expression = `${this.compiledKey}?: ${this.value.expression}`;

@@ -33,1 +44,2 @@ }

};
export const writeUnassignableDefaultValueMessage = (key, message) => `Default value for key ${key} ${message}`;
{
"name": "@arktype/schema",
"version": "0.6.0",
"version": "0.7.0",
"license": "MIT",

@@ -32,3 +32,3 @@ "author": {

"dependencies": {
"@ark/util": "0.6.0"
"@ark/util": "0.7.0"
},

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

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