UNPKG

2.27 kBTypeScriptView Raw
1import type { StringConstraints } from '../../string.js';
2import type { DepthSize } from './MaxLengthFromMinLength.js';
3/**
4 * Shared constraints for:
5 * - {@link json},
6 * - {@link jsonValue},
7 *
8 * @remarks Since 2.5.0
9 * @public
10 */
11export interface JsonSharedConstraints {
12 /**
13 * Limit the depth of the object by increasing the probability to generate simple values (defined via values)
14 * as we go deeper in the object.
15 *
16 * @remarks Since 2.20.0
17 */
18 depthSize?: DepthSize;
19 /**
20 * Maximal depth allowed
21 * @defaultValue Number.POSITIVE_INFINITY — _defaulting seen as "max non specified" when `defaultSizeToMaxWhenMaxSpecified=true`_
22 * @remarks Since 2.5.0
23 */
24 maxDepth?: number;
25 /**
26 * Only generate instances having keys and values made of ascii strings (when true)
27 * @deprecated Prefer using `stringUnit` to customize the kind of strings that will be generated by default.
28 * @defaultValue true
29 * @remarks Since 3.19.0
30 */
31 noUnicodeString?: boolean;
32 /**
33 * Replace the default unit for strings.
34 * @defaultValue undefined
35 * @remarks Since 3.23.0
36 */
37 stringUnit?: StringConstraints['unit'];
38}
39/**
40 * Shared constraints for:
41 * - {@link unicodeJson},
42 * - {@link unicodeJsonValue}
43 *
44 * @remarks Since 3.19.0
45 * @public
46 */
47export interface UnicodeJsonSharedConstraints {
48 /**
49 * Limit the depth of the object by increasing the probability to generate simple values (defined via values)
50 * as we go deeper in the object.
51 *
52 * @remarks Since 2.20.0
53 */
54 depthSize?: DepthSize;
55 /**
56 * Maximal depth allowed
57 * @defaultValue Number.POSITIVE_INFINITY — _defaulting seen as "max non specified" when `defaultSizeToMaxWhenMaxSpecified=true`_
58 * @remarks Since 2.5.0
59 */
60 maxDepth?: number;
61}
62/**
63 * Typings for a Json array
64 * @remarks Since 2.20.0
65 * @public
66 */
67export interface JsonArray extends Array<JsonValue> {
68}
69/**
70 * Typings for a Json object
71 * @remarks Since 2.20.0
72 * @public
73 */
74export type JsonObject = {
75 [key in string]?: JsonValue;
76};
77/**
78 * Typings for a Json value
79 * @remarks Since 2.20.0
80 * @public
81 */
82export type JsonValue = boolean | number | string | null | JsonArray | JsonObject;