Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dry-swans-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/arktype-test": patch
---

break(arktype-test): removes `minDepth` option
5 changes: 5 additions & 0 deletions .changeset/empty-terms-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/zod-test": patch
---

docs(zod-test): adds documentation for all of the package exports
5 changes: 5 additions & 0 deletions .changeset/fast-baboons-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/valibot-test": patch
---

break(valibot-test): removes `minDepth` option
5 changes: 5 additions & 0 deletions .changeset/short-islands-cut.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/zod-test": patch
---

fix(zod-test): fixes bug with `unbounded` option for array schemas (#429)
5 changes: 5 additions & 0 deletions .changeset/sour-frogs-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/typebox-test": patch
---

break(typebox-test): removes `minDepth` option
5 changes: 5 additions & 0 deletions .changeset/tame-apes-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/json-schema-test": patch
---

break(json-schema-test): removes `minDepth` option
5 changes: 5 additions & 0 deletions .changeset/thin-pets-make.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@traversable/zod-test": patch
---

break(zod-test): removes `minDepth` option
4 changes: 0 additions & 4 deletions packages/arktype-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ const builder = arkTest.SeedGenerator({
// 𐙘 use `include` to only include certain schema types
exclude: ["boolean", "unknown"],
// 𐙘 use `exclude` to exclude certain schema types altogether (overrides `include`)
minDepth: 1,
// 𐙘 use `minDepth` to control the schema's minimum depth
// **NOTE:** schemas can get very large!
// using in your CI/CD pipeline is _not_ recommended
object: { maxKeys: 5 },
// 𐙘 specific arbitraries are configurable by name
})
Expand Down
5 changes: 0 additions & 5 deletions packages/arktype-test/src/generator-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ export interface OptionsBase<
root: '*' | K
sortBias: { [K in keyof SeedMap]+?: number }
forceInvalid: boolean
minDepth: number
// minDepth: 1 | 2 | 3 | 4 | 5
}
export interface Config<T = never> extends OptionsBase<T>, byTypeName {}

Expand Down Expand Up @@ -205,7 +203,6 @@ export const defaults = {
exclude: [],
forceInvalid: false,
include: TypeNames,
minDepth: -1,
root: '*',
sortBias: byTag,
} as const satisfies OptionsBase<any>
Expand All @@ -217,7 +214,6 @@ export function parseOptions(options: Options<any> = defaults as never): Config
exclude = defaults.exclude,
forceInvalid = defaults.forceInvalid,
include = defaults.include,
minDepth: rootMinDepth = defaults.minDepth,
root = defaults.root,
sortBias = defaults.sortBias,
['*']: {
Expand Down Expand Up @@ -302,7 +298,6 @@ export function parseOptions(options: Options<any> = defaults as never): Config
exclude,
forceInvalid,
include: include.length === 0 || include[0] === '*' ? defaults.include : include,
minDepth: rootMinDepth,
root,
sortBias: { ...defaults.sortBias, ...sortBias },
['*']: {
Expand Down
47 changes: 23 additions & 24 deletions packages/arktype-test/src/generator-seed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type } from 'arktype'
import type * as T from '@traversable/registry'
import type { newtype } from '@traversable/registry'
import { fn, Object_keys } from '@traversable/registry'

import * as Bounds from './generator-bounds.js'
Expand Down Expand Up @@ -29,10 +28,10 @@ export const byTag = {
tuple: 8000,
anyOf: 8500,
oneOf: 9000,
} as const satisfies Record<AnyTypeName, number>
} as const satisfies globalThis.Record<AnyTypeName, number>

export function invert<T extends Record<keyof any, keyof any>>(x: T): { [K in keyof T as T[K]]: K }
export function invert(x: Record<keyof any, keyof any>) {
export function invert<T extends globalThis.Record<keyof any, keyof any>>(x: T): { [K in keyof T as T[K]]: K }
export function invert(x: globalThis.Record<keyof any, keyof any>) {
return Object_keys(x).reduce((acc, k) => (acc[x[k]] = k, acc), {} as typeof x)
}

Expand Down Expand Up @@ -70,13 +69,13 @@ export declare namespace Seed {
interface Free extends T.HKT { [-1]: Seed.F<this[0]> }
////////////////
/// nullary
interface Boolean extends newtype<[byTag['boolean']]> {}
// interface Date extends newtype<[byTag['date']]> {}
interface Never extends newtype<[byTag['never']]> {}
interface Null extends newtype<[byTag['null']]> {}
// interface Symbol extends newtype<[byTag['symbol']]> {}
// interface Undefined extends newtype<[byTag['undefined']]> {}
interface Unknown extends newtype<[byTag['unknown']]> {}
type Boolean = [boolean: byTag['boolean']]
// type Date = [byTag['date']]
type Never = [never: byTag['never']]
type Null = [null: byTag['null']]
// type Symbol = [symbol: byTag['symbol']]
// type Undefined = [undefined: byTag['undefined']]
type Unknown = [unknown: byTag['unknown']]
type Terminal = TerminalMap[keyof TerminalMap]
type TerminalMap = {
boolean: Boolean
Expand All @@ -89,9 +88,9 @@ export declare namespace Seed {
}
////////////////
/// boundable
// interface BigInt extends newtype<[seed: byTag['bigint'], bounds?: Bounds.bigint]> {}
interface Number extends newtype<[seed: byTag['number'], bounds?: Bounds.number]> {}
interface String extends newtype<[seed: byTag['string'], bounds?: Bounds.string]> {}
// interface BigInt = [seed: byTag['bigint'], bounds?: Bounds.bigint]> {}
type Number = [number: byTag['number'], bounds?: Bounds.number]
type String = [string: byTag['string'], bounds?: Bounds.string]
type Boundable = BoundableMap[keyof BoundableMap]
type BoundableMap = {
// bigint: BigInt
Expand All @@ -100,17 +99,17 @@ export declare namespace Seed {
}
////////////////
/// value
interface Enum extends newtype<[seed: byTag['enum'], value: { [x: string]: number | string }]> {}
interface Literal extends newtype<[seed: byTag['literal'], value: boolean | number | string]> {}
type Enum = [enum_: byTag['enum'], value: { [x: string]: number | string }]
type Literal = [literal: byTag['literal'], value: boolean | number | string]
type Value = ValueMap[keyof ValueMap]
type ValueMap = {
enum: Enum
literal: Literal
}
////////////////
/// unary
interface Array<T = unknown> extends newtype<[seed: byTag['array'], def: T, bounds?: Bounds.array]> {}
interface Optional<T = unknown> extends newtype<[seed: byTag['optional'], def: T]> {}
type Array<T = unknown> = [array: byTag['array'], def: T, bounds?: Bounds.array]
type Optional<T = unknown> = [optional: byTag['optional'], def: T]
type UnaryMap<T = unknown> = {
array: Seed.Array<T>
record: Seed.Record<T>
Expand Down Expand Up @@ -139,14 +138,14 @@ export declare namespace Seed {
}
////////////////
/// applicative
interface Object<T = unknown> extends newtype<[seed: byTag['object'], def: [K: string, V: T][]]> {}
interface AnyOf<T = unknown> extends newtype<[seed: byTag['anyOf'], def: T[]]> {}
interface OneOf<T = unknown> extends newtype<[seed: byTag['oneOf'], def: T[]]> {}
interface Tuple<T = unknown> extends newtype<[seed: byTag['tuple'], def: T[]]> {}
type Object<T = unknown> = [object: byTag['object'], def: [K: string, V: T][]]
type AnyOf<T = unknown> = [union: byTag['anyOf'], def: T[]]
type OneOf<T = unknown> = [disjointUnion: byTag['oneOf'], def: T[]]
type Tuple<T = unknown> = [tuple: byTag['tuple'], def: T[]]
////////////////
/// binary
interface Record<T = unknown> extends newtype<[seed: byTag['record'], def: T]> {}
interface AllOf<T = unknown> extends newtype<[seed: byTag['allOf'], def: [A: T, B: T]]> {}
type Record<T = unknown> = [record: byTag['record'], def: T]
type AllOf<T = unknown> = [intersection: byTag['allOf'], def: [A: T, B: T]]
}

export const Functor: T.Functor.Ix<boolean, Seed.Free, Seed.F<unknown>> = {
Expand Down
23 changes: 0 additions & 23 deletions packages/arktype-test/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,6 @@ export const ark_array
}
}

const branchNames = [
'array',
'object',
'record',
'tuple',
] as const satisfies AnyTypeName[]

export interface Builder extends inline<{ [K in Tag]+?: fc.Arbitrary<unknown> }> {
root?: fc.Arbitrary<unknown>
invalid?: fc.Arbitrary<typeof symbol.invalid_value>
Expand Down Expand Up @@ -246,14 +239,6 @@ export function Builder<T>(base: Gen.Base<T, Config.byTypeName>) {
const root = isKeyOf(builder, $.root) && builder[$.root]
let leaf = builder['*']

if ($.minDepth > 0) {
let branchName = getRandomElementOf(branchNames)
do {
if (branchName === 'object') leaf = fc.tuple(fc.constant(byTag.object), entries(builder['*']))
else if (branchName === 'tuple') leaf = fc.tuple(fc.constant(byTag.tuple), fc.array(builder['*']))
} while (--$.minDepth > 0)
}

return Object_assign(
builder, {
...root && { root },
Expand Down Expand Up @@ -389,10 +374,6 @@ export function seedToInvalidDataGenerator<T>(seed: Seed.F<T>, options?: Config.
*
* Many of those options are forwarded to the corresponding `fast-check` arbitrary.
*
* **Note:** support for `options.minDepth` is experimental. If you use it, be advised that
* even with a minimum depth of 1, the schemas produced will be quite large. Using this option
* in your CI/CD pipeline is not recommended.
*
* See also:
* - {@link SeedGenerator `arkTest.SeedGenerator`}
*
Expand Down Expand Up @@ -513,10 +494,6 @@ export const SeedInvalidDataGenerator = fn.pipe(
*
* Many of those options are forwarded to the corresponding `fast-check` arbitrary.
*
* **Note:** support for `options.minDepth` is experimental. If you use it, be advised that
* _even with a minimum depth of 1_, the schemas produced will be **quite** large. Using this option
* in your CI/CD pipeline is _not_ recommended.
*
* See also:
* - {@link SeedGenerator `arkTest.SeedGenerator`}
*
Expand Down
4 changes: 0 additions & 4 deletions packages/json-schema-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,6 @@ const builder = JsonSchemaTest.SeedGenerator({
// 𐙘 use `include` to only include certain schema types
exclude: ["boolean", "unknown"],
// 𐙘 use `exclude` to exclude certain schema types altogether (overrides `include`)
minDepth: 1,
// 𐙘 use `minDepth` to control the schema's minimum depth
// **NOTE:** schemas can get very large!
// using in your CI/CD pipeline is _not_ recommended
object: { maxKeys: 5 },
// 𐙘 specific arbitraries are configurable by name
})
Expand Down
5 changes: 0 additions & 5 deletions packages/json-schema-test/src/generator-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ export interface OptionsBase<
root: '*' | K
sortBias: { [K in keyof SeedMap]: number }
forceInvalid: boolean
minDepth: number
// minDepth: 1 | 2 | 3 | 4 | 5
}
export interface Config<T = never> extends OptionsBase<T>, byTypeName {}

Expand Down Expand Up @@ -195,7 +193,6 @@ export const defaults = {
exclude: [],
forceInvalid: false,
include: TypeNames,
minDepth: -1,
root: '*',
sortBias: byTag,
} as const satisfies OptionsBase<any>
Expand All @@ -207,7 +204,6 @@ export function parseOptions(options: Options<any> = defaults as never): Config
exclude = defaults.exclude,
forceInvalid = defaults.forceInvalid,
include = defaults.include,
minDepth: rootMinDepth = defaults.minDepth,
root = defaults.root,
sortBias = defaults.sortBias,
['*']: {
Expand Down Expand Up @@ -283,7 +279,6 @@ export function parseOptions(options: Options<any> = defaults as never): Config
exclude: exclude,
forceInvalid,
include: include.length === 0 || include[0] === '*' ? defaults.include : include,
minDepth: rootMinDepth,
root,
sortBias: { ...defaults.sortBias, ...sortBias },
['*']: {
Expand Down
65 changes: 32 additions & 33 deletions packages/json-schema-test/src/generator-seed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type * as T from '@traversable/registry'
import type { newtype } from '@traversable/registry'
import { fn, Object_keys } from '@traversable/registry'

import * as Bounds from './generator-bounds.js'
Expand All @@ -9,22 +8,22 @@ import { Json } from '@traversable/json'
export type Tag = byTag[keyof byTag]
export type byTag = typeof byTag
export const byTag = {
boolean: 15 as const,
never: 35 as const,
null: 40 as const,
unknown: 55 as const,
integer: 100 as const,
number: 200 as const,
string: 250 as const,
enum: 350 as const,
const: 550 as const,
array: 1000 as const,
allOf: 6000 as const,
record: 7000 as const,
object: 7500 as const,
tuple: 8000 as const,
anyOf: 8500 as const,
oneOf: 9000 as const,
boolean: 15,
never: 35,
null: 40,
unknown: 55,
integer: 100,
number: 200,
string: 250,
enum: 350,
const: 550,
array: 1000,
allOf: 6000,
record: 7000,
object: 7500,
tuple: 8000,
anyOf: 8500,
oneOf: 9000,
} as const satisfies Record<TypeName, number>

export function invert<T extends Record<keyof any, keyof any>>(x: { [K in keyof T]: T[K] }): { [K in keyof T as T[K]]: K }
Expand Down Expand Up @@ -69,10 +68,10 @@ export declare namespace Seed {
interface Free extends T.HKT { [-1]: Seed.F<this[0]> }
////////////////
/// nullary
interface Boolean extends newtype<[byTag['boolean']]> {}
interface Never extends newtype<[byTag['never']]> {}
interface Null extends newtype<[byTag['null']]> {}
interface Unknown extends newtype<[byTag['unknown']]> {}
type Boolean = [boolean: byTag['boolean']]
type Never = [never: byTag['never']]
type Null = [null: byTag['null']]
type Unknown = [unknown: byTag['unknown']]
type Terminal = TerminalMap[keyof TerminalMap]
type TerminalMap = {
boolean: Boolean
Expand All @@ -82,9 +81,9 @@ export declare namespace Seed {
}
////////////////
/// boundable
interface Integer extends newtype<[seed: byTag['integer'], bounds?: Bounds.int]> {}
interface Number extends newtype<[seed: byTag['number'], bounds?: Bounds.number]> {}
interface String extends newtype<[seed: byTag['string'], bounds?: Bounds.string]> {}
type Integer = [integer: byTag['integer'], bounds?: Bounds.int]
type Number = [number: byTag['number'], bounds?: Bounds.number]
type String = [string: byTag['string'], bounds?: Bounds.string]
type Boundable = BoundableMap[keyof BoundableMap]
type BoundableMap = {
integer: Integer
Expand All @@ -93,16 +92,16 @@ export declare namespace Seed {
}
////////////////
/// value
interface Const extends newtype<[seed: byTag['const'], value: Json]> {}
interface Enum extends newtype<[seed: byTag['enum'], value: Exclude<Json.Scalar, undefined>[]]> {}
type Const = [const_: byTag['const'], value: Json]
type Enum = [enum_: byTag['enum'], value: Exclude<Json.Scalar, undefined>[]]
type Value = ValueMap[keyof ValueMap]
type ValueMap = {
const: Const
enum: Enum
}
////////////////
/// unary
interface Array<T = unknown> extends newtype<[seed: byTag['array'], def: T, bounds?: Bounds.array]> {}
type Array<T = unknown> = [array: byTag['array'], items: T, bounds?: Bounds.array]
type UnaryMap<T = unknown> = {
array: Seed.Array<T>
record: Seed.Record<T>
Expand All @@ -125,14 +124,14 @@ export declare namespace Seed {
}
////////////////
/// applicative
interface AnyOf<T = unknown> extends newtype<[seed: byTag['anyOf'], def: T[]]> {}
interface OneOf<T = unknown> extends newtype<[seed: byTag['oneOf'], def: T[]]> {}
interface Tuple<T = unknown> extends newtype<[seed: byTag['tuple'], def: T[]]> {}
interface Object<T = unknown> extends newtype<[seed: byTag['object'], def: [K: string, V: T][], req: string[]]> {}
type AnyOf<T = unknown> = [anyOf: byTag['anyOf'], members: T[]]
type OneOf<T = unknown> = [oneOf: byTag['oneOf'], members: T[]]
type Tuple<T = unknown> = [tuple: byTag['tuple'], items: T[]]
type Object<T = unknown> = [object: byTag['object'], properties: [K: string, V: T][], req: string[]]
////////////////
/// binary
interface Record<T = unknown> extends newtype<[seed: byTag['record'], additionalProperties?: T, patternProperties?: [K: string, V: T]]> {}
interface AllOf<T = unknown> extends newtype<[seed: byTag['allOf'], def: T[]]> {}
type Record<T = unknown> = [record: byTag['record'], additionalProperties?: T, patternProperties?: [K: string, V: T]]
type AllOf<T = unknown> = [allOf: byTag['allOf'], members: T[]]
}

export const Functor: T.Functor.Ix<boolean, Seed.Free, Seed.F<unknown>> = {
Expand Down
Loading
Loading