@ark/schema
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -1,4 +0,3 @@ | ||
import { Callable, type array, type Hkt, type Json } from "@ark/util"; | ||
import { Callable, type array, type Json } from "@ark/util"; | ||
import type { inferRoot } from "./inference.js"; | ||
import type { RootSchema } from "./kinds.js"; | ||
import type { SchemaRoot, UnknownRoot } from "./roots/root.js"; | ||
@@ -50,3 +49,3 @@ import type { BaseScope, InternalBaseScope } from "./scope.js"; | ||
}; | ||
export declare class LazyGenericBody<params extends array<GenericParamAst> = array<GenericParamAst>, returns = unknown> extends Callable<(args: GenericArgResolutions<params>) => returns> { | ||
export declare class LazyGenericBody<argResolutions = {}, returns = unknown> extends Callable<(args: argResolutions) => returns> { | ||
} | ||
@@ -72,7 +71,12 @@ export declare class GenericRoot<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, arg$ = $> extends Callable<GenericRootInstantiator<params, bodyDef, $>> { | ||
} | ||
export type GenericHktSchemaParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: paramsDef) => (instantiateDef: LazyGenericBody<genericParamSchemasToAst<paramsDef, $>, RootSchema>) => GenericHktRootSubclass<genericParamSchemasToAst<paramsDef, $>, $>; | ||
export type GenericHktRootSubclass<params extends array<GenericParamAst>, $> = abstract new () => GenericHktRoot<params, $, $>; | ||
interface Hkt extends Hkt.Kind { | ||
export type GenericHktSchemaParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: paramsDef) => <hkt extends abstract new () => GenericHkt, params extends Array<GenericParamAst> = genericParamSchemasToAst<paramsDef, $>>(instantiateDef: LazyGenericBody<GenericArgResolutions<params>>, hkt: hkt) => GenericRoot<params, InstanceType<hkt>, $, $>; | ||
export declare abstract class GenericHkt<hkt extends (args: any) => unknown = (args: any) => unknown> { | ||
readonly args: array; | ||
abstract readonly hkt: hkt; | ||
} | ||
export interface GenericHktRoot<params extends array<GenericParamAst>, $, args$> extends GenericRoot<params, Hkt, $, args$>, Hkt.Kind { | ||
export declare namespace GenericHkt { | ||
type instantiate<hkt extends GenericHkt, args extends Parameters<hkt["hkt"]>[0]> = ReturnType<(hkt & { | ||
readonly args: args; | ||
})["hkt"]>; | ||
type conform<thisArgs, parameters extends array> = thisArgs extends parameters ? thisArgs : parameters; | ||
} | ||
@@ -79,0 +83,0 @@ export declare const writeUnsatisfiedParameterConstraintMessage: <name extends string, constraint extends string, arg extends string>(name: name, constraint: constraint, arg: arg) => writeUnsatisfiedParameterConstraintMessage<name, constraint, arg>; |
@@ -130,2 +130,4 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { | ||
export { GenericRoot }; | ||
export class GenericHkt { | ||
} | ||
export const writeUnsatisfiedParameterConstraintMessage = (name, constraint, arg) => `${name} must be assignable to ${constraint} (was ${arg})`; |
import type { RootModule, SchemaModule } from "../module.js"; | ||
import { type BaseScope } from "../scope.js"; | ||
import { type tsKeywordExports } from "./tsKeywords.js"; | ||
import { type arkGenericsExports } from "./arkGenerics.js"; | ||
import { type formattingExports } from "./format.js"; | ||
@@ -14,3 +15,3 @@ import { type internalExports } from "./internal.js"; | ||
export declare const keywordNodes: SchemaModule<Ark>; | ||
export interface Ark extends tsKeywordExports, jsObjectExports, platformObjectExports, validationExports, tsGenericsExports, internalExports { | ||
export interface Ark extends tsKeywordExports, jsObjectExports, platformObjectExports, validationExports, tsGenericsExports, arkGenericsExports, internalExports { | ||
TypedArray: RootModule<typedArrayExports>; | ||
@@ -17,0 +18,0 @@ parse: RootModule<parsingExports>; |
@@ -6,2 +6,3 @@ import { schemaScope } from "../scope.js"; | ||
import { $ark } from "@ark/util"; | ||
import { arkGenerics } from "./arkGenerics.js"; | ||
import { formatting } from "./format.js"; | ||
@@ -22,2 +23,3 @@ import { internal } from "./internal.js"; | ||
...tsGenerics, | ||
...arkGenerics, | ||
TypedArray: typedArray, | ||
@@ -24,0 +26,0 @@ parse: parsing, |
@@ -1,35 +0,32 @@ | ||
import { liftArray, type conform, type Hkt, type Key, type show } from "@ark/util"; | ||
import { type Key } from "@ark/util"; | ||
import type { SchemaModule } from "../module.js"; | ||
import type { Out } from "../roots/morph.js"; | ||
declare const ArkRecord_base: import("../generic.js").GenericHktRootSubclass<[["K", Key], import("../generic.js").GenericParamAst<"V", unknown>], {}>; | ||
declare class ArkRecord extends ArkRecord_base { | ||
hkt: (args: conform<this[Hkt.args], [PropertyKey, unknown]>) => Record<(typeof args)[0], (typeof args)[1]>; | ||
} | ||
declare const ArkPick_base: import("../generic.js").GenericHktRootSubclass<[["T", object], ["K", Key]], {}>; | ||
declare class ArkPick extends ArkPick_base { | ||
hkt: (args: conform<this[Hkt.args], [object, Key]>) => show<Pick<(typeof args)[0], (typeof args)[1] & keyof (typeof args)[0]>>; | ||
} | ||
declare const ArkOmit_base: import("../generic.js").GenericHktRootSubclass<[["T", object], ["K", Key]], {}>; | ||
declare class ArkOmit extends ArkOmit_base { | ||
hkt: (args: conform<this[Hkt.args], [object, Key]>) => show<Omit<(typeof args)[0], (typeof args)[1] & keyof (typeof args)[0]>>; | ||
} | ||
declare const ArkExclude_base: import("../generic.js").GenericHktRootSubclass<[import("../generic.js").GenericParamAst<"T", unknown>, import("../generic.js").GenericParamAst<"U", unknown>], {}>; | ||
declare class ArkExclude extends ArkExclude_base { | ||
hkt: (args: conform<this[Hkt.args], [unknown, unknown]>) => Exclude<(typeof args)[0], (typeof args)[1]>; | ||
} | ||
declare const ArkExtract_base: import("../generic.js").GenericHktRootSubclass<[import("../generic.js").GenericParamAst<"T", unknown>, import("../generic.js").GenericParamAst<"U", unknown>], {}>; | ||
declare class ArkExtract extends ArkExtract_base { | ||
hkt: (args: conform<this[Hkt.args], [unknown, unknown]>) => Extract<(typeof args)[0], (typeof args)[1]>; | ||
} | ||
declare const ArkLiftArray_base: import("../generic.js").GenericHktRootSubclass<[import("../generic.js").GenericParamAst<"T", unknown>], {}>; | ||
declare class ArkLiftArray extends ArkLiftArray_base { | ||
hkt: (args: conform<this[Hkt.args], [unknown]>) => liftArray<(typeof args)[0]> extends infer lifted ? (In: (typeof args)[0] | lifted) => Out<lifted> : never; | ||
} | ||
declare const tsGenericsExports: { | ||
Record: ArkRecord; | ||
Pick: ArkPick; | ||
Omit: ArkOmit; | ||
Exclude: ArkExclude; | ||
Extract: ArkExtract; | ||
liftArray: ArkLiftArray; | ||
Record: import("../generic.js").GenericRoot<[["K", Key], import("../generic.js").GenericParamAst<"V", unknown>], { | ||
hkt: (args: [PropertyKey, unknown]) => Record<PropertyKey, unknown>; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
Pick: import("../generic.js").GenericRoot<[["T", object], ["K", Key]], { | ||
hkt: (args: [object, Key]) => {}; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
Omit: import("../generic.js").GenericRoot<[["T", object], ["K", Key]], { | ||
hkt: (args: [object, Key]) => {}; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
Exclude: import("../generic.js").GenericRoot<[import("../generic.js").GenericParamAst<"T", unknown>, import("../generic.js").GenericParamAst<"U", unknown>], { | ||
hkt: (args: [unknown, unknown]) => never; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
Extract: import("../generic.js").GenericRoot<[import("../generic.js").GenericParamAst<"T", unknown>, import("../generic.js").GenericParamAst<"U", unknown>], { | ||
hkt: (args: [unknown, unknown]) => unknown; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
Partial: import("../generic.js").GenericRoot<[["T", object]], { | ||
hkt: (args: [object]) => object; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
Required: import("../generic.js").GenericRoot<[["T", object]], { | ||
hkt: (args: [object]) => object; | ||
readonly args: import("@ark/util").array; | ||
}, {}, {}>; | ||
}; | ||
@@ -36,0 +33,0 @@ export type tsGenericsExports = typeof tsGenericsExports; |
@@ -1,4 +0,5 @@ | ||
import { $ark, liftArray } from "@ark/util"; | ||
import { $ark } from "@ark/util"; | ||
import { GenericHkt } from "../generic.js"; | ||
import { generic, schemaScope } from "../scope.js"; | ||
class ArkRecord extends generic(["K", $ark.intrinsic.propertyKey], "V")(args => ({ | ||
const Record = generic(["K", $ark.intrinsic.propertyKey], "V")(args => ({ | ||
domain: "object", | ||
@@ -9,23 +10,26 @@ index: { | ||
} | ||
})) { | ||
} | ||
class ArkPick extends generic(["T", $ark.intrinsic.object], ["K", $ark.intrinsic.propertyKey])(args => args.T.pick(args.K)) { | ||
} | ||
class ArkOmit extends generic(["T", $ark.intrinsic.object], ["K", $ark.intrinsic.propertyKey])(args => args.T.omit(args.K)) { | ||
} | ||
class ArkExclude extends generic("T", "U")(args => args.T.exclude(args.U)) { | ||
} | ||
class ArkExtract extends generic("T", "U")(args => args.T.extract(args.U)) { | ||
} | ||
class ArkLiftArray extends generic("T")(args => args.T.or(args.T.array()).pipe(liftArray)) { | ||
} | ||
}), class RecordHkt extends GenericHkt { | ||
}); | ||
const Pick = generic(["T", $ark.intrinsic.object], ["K", $ark.intrinsic.propertyKey])(args => args.T.pick(args.K), class PickHkt extends GenericHkt { | ||
}); | ||
const Omit = generic(["T", $ark.intrinsic.object], ["K", $ark.intrinsic.propertyKey])(args => args.T.omit(args.K), class OmitHkt extends GenericHkt { | ||
}); | ||
const Partial = generic(["T", $ark.intrinsic.object])(args => args.T.partial(), class PartialHkt extends GenericHkt { | ||
}); | ||
const Required = generic(["T", $ark.intrinsic.object])(args => args.T.required(), class RequiredHkt extends GenericHkt { | ||
}); | ||
const Exclude = generic("T", "U")(args => args.T.exclude(args.U), class ExcludeHkt extends GenericHkt { | ||
}); | ||
const Extract = generic("T", "U")(args => args.T.extract(args.U), class ExtractHkt extends GenericHkt { | ||
}); | ||
const tsGenericsExports = { | ||
Record: new ArkRecord(), | ||
Pick: new ArkPick(), | ||
Omit: new ArkOmit(), | ||
Exclude: new ArkExclude(), | ||
Extract: new ArkExtract(), | ||
liftArray: new ArkLiftArray() | ||
Record, | ||
Pick, | ||
Omit, | ||
Exclude, | ||
Extract, | ||
Partial, | ||
Required | ||
}; | ||
const $ = schemaScope(tsGenericsExports); | ||
export const tsGenerics = $.export(); |
@@ -1,2 +0,2 @@ | ||
import type { anonymous, number, string } from "../ast.js"; | ||
import type { anonymous, AtLeast, AtMost, DivisibleBy, number, string } from "../ast.js"; | ||
import type { SchemaModule } from "../module.js"; | ||
@@ -16,4 +16,5 @@ export interface validationExports { | ||
integer: number.divisibleBy<1>; | ||
unixTimestamp: number.is<DivisibleBy<1> & AtMost<8640000000000000> & AtLeast<-8640000000000000>>; | ||
} | ||
export type validation = SchemaModule<validationExports>; | ||
export declare const validation: validation; |
@@ -41,2 +41,27 @@ import { defineRoot, schemaScope } from "../scope.js"; | ||
}); | ||
/** | ||
* As per the ECMA-262 specification: | ||
* A time value supports a slightly smaller range of -8,640,000,000,000,000 to 8,640,000,000,000,000 milliseconds. | ||
* | ||
* @see https://262.ecma-international.org/15.0/index.html#sec-time-values-and-time-range | ||
*/ | ||
const unixTimestamp = defineRoot({ | ||
domain: { | ||
domain: "number", | ||
description: "a number representing a Unix timestamp" | ||
}, | ||
divisor: { | ||
rule: 1, | ||
description: `an integer representing a Unix timestamp` | ||
}, | ||
min: { | ||
rule: -8640000000000000, | ||
description: `a Unix timestamp after -8640000000000000` | ||
}, | ||
max: { | ||
rule: 8640000000000000, | ||
description: "a Unix timestamp before 8640000000000000" | ||
}, | ||
description: "an integer representing a safe Unix timestamp" | ||
}); | ||
export const validation = schemaScope({ | ||
@@ -57,3 +82,4 @@ alpha: defineRegex(/^[A-Za-z]*$/, "only letters"), | ||
divisor: 1 | ||
} | ||
}, | ||
unixTimestamp | ||
}, { prereducedAliases: true }).export(); |
@@ -29,3 +29,3 @@ import { type array, type listable, type show } from "@ark/util"; | ||
proto?: ProtoSchema; | ||
} & conditionalRootOf<inferredBasis>>; | ||
} & conditionalRootOf<inferredBasis>> | IntersectionNode; | ||
export type IntersectionDeclaration = declareNode<{ | ||
@@ -32,0 +32,0 @@ kind: "intersection"; |
@@ -58,2 +58,3 @@ import { $ark, arrayEquals, liftArray, throwParseError } from "@ark/util"; | ||
...l.inner, | ||
// TODO: https://github.com/arktypeio/arktype/issues/1067 | ||
in: inTersection | ||
@@ -60,0 +61,0 @@ })); |
@@ -42,6 +42,8 @@ import type { ConstraintKind, DivisorSchema, ExactLengthSchema, ExclusiveDateRangeSchema, ExclusiveNumericRangeSchema, FlatRef, InclusiveDateRangeSchema, InclusiveNumericRangeSchema, InferredRoot, LimitSchemaValue, PatternSchema, TypeIndexer, TypeKey, UnknownRangeSchema, writeInvalidOperandMessage } from "@ark/schema"; | ||
assert(data: unknown): unknown; | ||
pick(...keys: array<TypeKey>): BaseRoot; | ||
omit(...keys: array<TypeKey>): BaseRoot; | ||
private filterKeys; | ||
get(...path: array<TypeIndexer>): BaseRoot; | ||
pick(...keys: TypeKey[]): BaseRoot; | ||
omit(...keys: TypeKey[]): BaseRoot; | ||
required(): BaseRoot; | ||
partial(): BaseRoot; | ||
private applyStructuralOperation; | ||
get(...path: TypeIndexer[]): BaseRoot; | ||
extract(r: unknown): BaseRoot; | ||
@@ -64,2 +66,3 @@ exclude(r: UnknownRoot): BaseRoot; | ||
onUndeclaredKey(cfg: UndeclaredKeyBehavior | UndeclaredKeyConfig): BaseRoot; | ||
onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): BaseRoot; | ||
satisfying(predicate: Predicate): BaseRoot; | ||
@@ -128,2 +131,3 @@ divisibleBy(schema: DivisorSchema): BaseRoot; | ||
onUndeclaredKey(behavior: UndeclaredKeyBehavior): this; | ||
onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this; | ||
from(literal: this["inferIn"]): this["infer"]; | ||
@@ -143,2 +147,8 @@ } | ||
}, $>; | ||
required(this: validateStructuralOperand<"required", this>): SchemaRoot<{ | ||
[k in keyof this["inferIn"]]-?: this["inferIn"][k]; | ||
}, $>; | ||
partial(this: validateStructuralOperand<"partial", this>): SchemaRoot<{ | ||
[k in keyof this["inferIn"]]?: this["inferIn"][k]; | ||
}, $>; | ||
get<k1 extends arkKeyOf<t>>(k1: k1 | InferredRoot<k1>): SchemaRoot<getArkKey<t, k1>, $>; | ||
@@ -193,5 +203,5 @@ get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>>(k1: k1 | InferredRoot<k1>, k2: k2 | InferredRoot<k2>): SchemaRoot<getArkKey<getArkKey<t, k1>, k2>, $>; | ||
}> = t["inferIn"] extends Prerequisite<kind> ? t : ErrorMessage<writeInvalidOperandMessage<kind, SchemaRoot<t["inferIn"]>>>; | ||
export type StructuralOperationName = "pick" | "omit" | "index access"; | ||
export type StructuralOperationName = "pick" | "omit" | "get" | "required" | "partial"; | ||
export type writeNonStructuralOperandMessage<operation extends StructuralOperationName, operand extends string> = `${operation} operand must be an object (was ${operand})`; | ||
export declare const writeNonStructuralOperandMessage: <operation extends StructuralOperationName, operand extends string>(operation: operation, operand: operand) => writeNonStructuralOperandMessage<operation, operand>; | ||
export {}; |
@@ -97,10 +97,16 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { | ||
pick(...keys) { | ||
return this.filterKeys("pick", keys); | ||
return this.applyStructuralOperation("pick", keys); | ||
} | ||
omit(...keys) { | ||
return this.filterKeys("omit", keys); | ||
return this.applyStructuralOperation("omit", keys); | ||
} | ||
filterKeys(operation, keys) { | ||
required() { | ||
return this.applyStructuralOperation("required", []); | ||
} | ||
partial() { | ||
return this.applyStructuralOperation("partial", []); | ||
} | ||
applyStructuralOperation(operation, args) { | ||
if (this.hasKind("union")) { | ||
return this.$.schema(this.branches.map(branch => branch[operation](...keys))); | ||
return this.$.schema(this.branches.map(branch => branch.applyStructuralOperation(operation, args))); | ||
} | ||
@@ -110,3 +116,3 @@ if (this.hasKind("morph")) { | ||
...this.inner, | ||
in: this.in[operation](...keys) | ||
in: this.in.applyStructuralOperation(operation, args) | ||
}); | ||
@@ -118,5 +124,8 @@ } | ||
} | ||
const structuralMethodName = operation === "required" ? "require" | ||
: operation === "partial" ? "optionalize" | ||
: operation; | ||
return this.$.node("intersection", { | ||
...this.inner, | ||
structure: this.inner.structure[operation](...keys) | ||
structure: this.inner.structure[structuralMethodName](...args) | ||
}); | ||
@@ -137,3 +146,3 @@ } | ||
return (branch.structure?.get(...path) ?? | ||
throwParseError(writeNonStructuralOperandMessage("index access", this.expression))); | ||
throwParseError(writeNonStructuralOperandMessage("get", this.expression))); | ||
} | ||
@@ -246,2 +255,5 @@ extract(r) { | ||
} | ||
onDeepUndeclaredKey(behavior) { | ||
return this.onUndeclaredKey({ rule: behavior, deep: true }); | ||
} | ||
satisfying(predicate) { | ||
@@ -248,0 +260,0 @@ return this.constrain("predicate", predicate); |
@@ -15,4 +15,5 @@ import { type Domain, type Json, type Key, type SerializedPrimitive, type show } from "@ark/util"; | ||
export type UnionChildNode = Node<UnionChildKind>; | ||
export type UnionSchema<branches extends readonly UnionChildSchema[] = readonly UnionChildSchema[]> = NormalizedUnionSchema<branches> | branches; | ||
export interface NormalizedUnionSchema<branches extends readonly UnionChildSchema[] = readonly UnionChildSchema[]> extends BaseMeta { | ||
export type UnionBranchSchema = UnionChildSchema | BaseRoot; | ||
export type UnionSchema<branches extends readonly UnionBranchSchema[] = readonly UnionBranchSchema[]> = NormalizedUnionSchema<branches> | branches; | ||
export interface NormalizedUnionSchema<branches extends readonly UnionBranchSchema[] = readonly UnionBranchSchema[]> extends BaseMeta { | ||
readonly branches: branches; | ||
@@ -19,0 +20,0 @@ readonly ordered?: true; |
@@ -42,3 +42,3 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { | ||
import { registeredReference } from "../shared/registry.js"; | ||
import { pathToPropString } from "../shared/utils.js"; | ||
import { hasArkKind, pathToPropString } from "../shared/utils.js"; | ||
import { BaseRoot } from "./root.js"; | ||
@@ -59,3 +59,5 @@ import { defineRightwardIntersections } from "./utils.js"; | ||
parse: (schema, ctx) => { | ||
const branches = schema.map(branch => ctx.$.node(unionChildKinds, branch)); | ||
const branches = schema.flatMap(branch => hasArkKind(branch, "root") ? | ||
branch.branches | ||
: ctx.$.node(unionChildKinds, branch)); | ||
if (!ctx.schema.ordered) | ||
@@ -62,0 +64,0 @@ branches.sort((l, r) => (l.innerHash < r.innerHash ? -1 : 1)); |
@@ -92,3 +92,3 @@ import { DynamicBase, ParseError, type Json, type anyOrNever, type array, type flattenListable, type show } from "@ark/util"; | ||
export declare const schemaScope: <const aliases>(aliases: validateAliases<aliases>, config?: ArkConfig) => SchemaScope<instantiateAliases<aliases>>; | ||
export interface BaseScope<$ = any> { | ||
export interface BaseScope<$ = {}> { | ||
t: $; | ||
@@ -116,2 +116,3 @@ [arkKind]: "scope"; | ||
} | ||
/** @ts-ignore sometimes infinite? requires further investigation */ | ||
export interface SchemaScope<$ = {}> extends BaseScope<$> { | ||
@@ -118,0 +119,0 @@ defineRoot: this["defineSchema"]; |
@@ -129,7 +129,3 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { | ||
const $ = this; | ||
return (instantiateDef) => class GenericHktSubclass extends GenericRoot { | ||
constructor() { | ||
super(params, new LazyGenericBody(instantiateDef), $, $); | ||
} | ||
}; | ||
return instantiateDef => new GenericRoot(params, new LazyGenericBody(instantiateDef), $, $); | ||
} | ||
@@ -136,0 +132,0 @@ units(values, opts) { |
@@ -116,4 +116,5 @@ import { Hkt } from "@ark/util"; | ||
morphs: to.morphs, | ||
// TODO: https://github.com/arktypeio/arktype/issues/1067 | ||
in: result | ||
}); | ||
}; |
@@ -57,4 +57,6 @@ import { type array, type join, type Key, type typeToString } from "@ark/util"; | ||
readonly exhaustive: boolean; | ||
pick(...keys: array<BaseRoot | Key>): StructureNode; | ||
omit(...keys: array<BaseRoot | Key>): StructureNode; | ||
pick(...keys: TypeKey[]): StructureNode; | ||
omit(...keys: TypeKey[]): StructureNode; | ||
optionalize(): StructureNode; | ||
require(): StructureNode; | ||
merge(r: StructureNode): StructureNode; | ||
@@ -61,0 +63,0 @@ private filterKeys; |
@@ -141,2 +141,19 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { | ||
} | ||
optionalize() { | ||
const { required, ...inner } = this.inner; | ||
return this.$.node("structure", { | ||
...inner, | ||
optional: this.props.map(prop => prop.hasKind("required") ? this.$.node("optional", prop.inner) : prop) | ||
}); | ||
} | ||
require() { | ||
const { optional, ...inner } = this.inner; | ||
return this.$.node("structure", { | ||
...inner, | ||
required: this.props.map(prop => prop.hasKind("optional") ? | ||
// don't include keys like default that don't exist on required | ||
this.$.node("required", { key: prop.key, value: prop.value }) | ||
: prop) | ||
}); | ||
} | ||
merge(r) { | ||
@@ -143,0 +160,0 @@ const inner = makeRootAndArrayPropertiesMutable(this.filterKeys("omit", [r.keyof()])); |
{ | ||
"name": "@ark/schema", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"license": "MIT", | ||
@@ -27,3 +27,3 @@ "author": { | ||
"dependencies": { | ||
"@ark/util": "0.1.1" | ||
"@ark/util": "0.1.2" | ||
}, | ||
@@ -30,0 +30,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
379765
131
8280
+ Added@ark/util@0.1.2(transitive)
- Removed@ark/util@0.1.1(transitive)
Updated@ark/util@0.1.2