@fgv/ts-json-base 5.1.0-32 → 5.1.0-34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.js +2 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/packlets/json-schema-builder/factories.js +342 -0
- package/dist/packlets/json-schema-builder/factories.js.map +1 -0
- package/dist/packlets/json-schema-builder/fromJson.js +371 -0
- package/dist/packlets/json-schema-builder/fromJson.js.map +1 -0
- package/dist/packlets/json-schema-builder/index.js +36 -0
- package/dist/packlets/json-schema-builder/index.js.map +1 -0
- package/dist/packlets/json-schema-builder/types.js +23 -0
- package/dist/packlets/json-schema-builder/types.js.map +1 -0
- package/dist/ts-json-base.d.ts +345 -6
- package/lib/index.browser.d.ts +2 -1
- package/lib/index.browser.d.ts.map +1 -1
- package/lib/index.browser.js +3 -1
- package/lib/index.browser.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/packlets/json-schema-builder/factories.d.ts +95 -0
- package/lib/packlets/json-schema-builder/factories.d.ts.map +1 -0
- package/lib/packlets/json-schema-builder/factories.js +352 -0
- package/lib/packlets/json-schema-builder/factories.js.map +1 -0
- package/lib/packlets/json-schema-builder/fromJson.d.ts +45 -0
- package/lib/packlets/json-schema-builder/fromJson.d.ts.map +1 -0
- package/lib/packlets/json-schema-builder/fromJson.js +375 -0
- package/lib/packlets/json-schema-builder/fromJson.js.map +1 -0
- package/lib/packlets/json-schema-builder/index.d.ts +15 -0
- package/lib/packlets/json-schema-builder/index.d.ts.map +1 -0
- package/lib/packlets/json-schema-builder/index.js +52 -0
- package/lib/packlets/json-schema-builder/index.js.map +1 -0
- package/lib/packlets/json-schema-builder/types.d.ts +142 -0
- package/lib/packlets/json-schema-builder/types.d.ts.map +1 -0
- package/lib/packlets/json-schema-builder/types.js +24 -0
- package/lib/packlets/json-schema-builder/types.js.map +1 -0
- package/package.json +6 -6
package/dist/ts-json-base.d.ts
CHANGED
|
@@ -33,6 +33,15 @@ declare type AnyFileTreeDirectoryItem<TCT extends string = string> = IFileTreeDi
|
|
|
33
33
|
*/
|
|
34
34
|
declare type AnyFileTreeFileItem<TCT extends string = string> = IFileTreeFileItem<TCT> | IMutableFileTreeFileItem<TCT>;
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Creates a schema node for a JSON `array` whose elements all match `items`.
|
|
38
|
+
* @param items - The schema applied to every element.
|
|
39
|
+
* @param opts - Optional description.
|
|
40
|
+
* @returns An `ISchemaValidator` whose `Static` type is `Array<Static<S>>`.
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
declare function array<S extends ISchemaValidator<unknown>>(items: S, opts?: ISchemaOptions): ISchemaValidator<Static<S>[]>;
|
|
44
|
+
|
|
36
45
|
/**
|
|
37
46
|
* A converter which converts a supplied `unknown` value to a valid array of {@link JsonCompatibleType | JsonCompatible} values.
|
|
38
47
|
* @public
|
|
@@ -72,12 +81,20 @@ declare type ArrayValidator<T, TC = unknown> = Validation.Classes.ArrayValidator
|
|
|
72
81
|
*/
|
|
73
82
|
declare const boolean: Converter<boolean, IJsonConverterContext>;
|
|
74
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Creates a schema node for a JSON `boolean`.
|
|
86
|
+
* @param opts - Optional description.
|
|
87
|
+
* @returns An `ISchemaValidator` whose `Static` type is `boolean`.
|
|
88
|
+
* @public
|
|
89
|
+
*/
|
|
90
|
+
declare function boolean_2(opts?: ISchemaOptions): ISchemaValidator<boolean>;
|
|
91
|
+
|
|
75
92
|
/**
|
|
76
93
|
* A `BooleanValidator` which validates a boolean in place.
|
|
77
94
|
* Accepts `IJsonValidatorContext` but ignores it.
|
|
78
95
|
* @public
|
|
79
96
|
*/
|
|
80
|
-
declare const
|
|
97
|
+
declare const boolean_3: Validator<boolean, IJsonValidatorContext>;
|
|
81
98
|
|
|
82
99
|
/**
|
|
83
100
|
* Identifies whether some `unknown` value is a {@link JsonPrimitive | primitive},
|
|
@@ -290,6 +307,15 @@ declare function enumeratedValue<T>(values: ReadonlyArray<T>, message?: string):
|
|
|
290
307
|
*/
|
|
291
308
|
declare function enumeratedValue_2<T>(values: ReadonlyArray<T>, message?: string): Validator<T, IJsonValidatorContext | ReadonlyArray<T>>;
|
|
292
309
|
|
|
310
|
+
/**
|
|
311
|
+
* Creates a schema node for a closed set of string literals.
|
|
312
|
+
* @param values - The allowed string values.
|
|
313
|
+
* @param opts - Optional description.
|
|
314
|
+
* @returns An `ISchemaValidator` whose `Static` type is the union of `values`.
|
|
315
|
+
* @public
|
|
316
|
+
*/
|
|
317
|
+
declare function enumOf<T extends string>(values: readonly T[], opts?: ISchemaOptions): ISchemaValidator<T>;
|
|
318
|
+
|
|
293
319
|
/**
|
|
294
320
|
* Class representing a file in a file tree.
|
|
295
321
|
* @public
|
|
@@ -524,6 +550,27 @@ declare function forFilesystem<TCT extends string = string>(prefix?: string): Re
|
|
|
524
550
|
*/
|
|
525
551
|
declare function forFilesystem<TCT extends string = string>(params?: IFileTreeInitParams<TCT>): Result<FileTree_2<TCT>>;
|
|
526
552
|
|
|
553
|
+
/**
|
|
554
|
+
* Parses a raw JSON Schema object (e.g. one discovered at an MCP tool boundary) into a typed schema
|
|
555
|
+
* value within the LLM-tool subset.
|
|
556
|
+
*
|
|
557
|
+
* @remarks
|
|
558
|
+
* Because the static type cannot be recovered from a runtime value, the result is typed as the
|
|
559
|
+
* opaque supertype `ISchemaValidator<JsonValue>` — the honest type when a schema arrives at runtime,
|
|
560
|
+
* since schemas may validate strings, numbers, booleans, arrays, or objects. The `validate()` method
|
|
561
|
+
* performs real runtime validation; the derived static type is the opaque `JsonValue`.
|
|
562
|
+
*
|
|
563
|
+
* Consumers who need a narrower derived type must author the schema via the factories.
|
|
564
|
+
*
|
|
565
|
+
* Out-of-subset features fail loudly (see `FORBIDDEN_KEYWORDS`); `description` is preserved on every
|
|
566
|
+
* node; other annotations (`title`, `default`, `format`, `examples`) are silently ignored.
|
|
567
|
+
*
|
|
568
|
+
* @param json - The raw JSON Schema object to parse.
|
|
569
|
+
* @returns `Success` with the parsed schema, or `Failure` describing the first out-of-subset feature.
|
|
570
|
+
* @public
|
|
571
|
+
*/
|
|
572
|
+
declare function fromJson(json: JsonObject): Result<ISchemaValidator<JsonValue>>;
|
|
573
|
+
|
|
527
574
|
/**
|
|
528
575
|
* Implementation of {@link FileTree.IMutableFileTreeAccessors} that uses the
|
|
529
576
|
* file system to access and modify files and directories.
|
|
@@ -888,6 +935,67 @@ declare interface IJsonValidatorContext {
|
|
|
888
935
|
ignoreUndefinedProperties?: boolean;
|
|
889
936
|
}
|
|
890
937
|
|
|
938
|
+
/**
|
|
939
|
+
* Schema node for a JSON `array`.
|
|
940
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
941
|
+
* @public
|
|
942
|
+
*/
|
|
943
|
+
declare type ILlmArraySchema<S extends ISchemaValidator<unknown>> = ISchemaValidator<Static<S>[]>;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* Schema node for a JSON `boolean`.
|
|
947
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
948
|
+
* @public
|
|
949
|
+
*/
|
|
950
|
+
declare type ILlmBooleanSchema = ISchemaValidator<boolean>;
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* Schema node for a closed set of string literals (`enum`).
|
|
954
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
955
|
+
* @public
|
|
956
|
+
*/
|
|
957
|
+
declare type ILlmEnumSchema<T extends string> = ISchemaValidator<T>;
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* Schema node for a JSON `number` or `integer`.
|
|
961
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
962
|
+
* @public
|
|
963
|
+
*/
|
|
964
|
+
declare type ILlmNumberSchema = ISchemaValidator<number>;
|
|
965
|
+
|
|
966
|
+
/**
|
|
967
|
+
* Schema node for a JSON `object`.
|
|
968
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
969
|
+
* @public
|
|
970
|
+
*/
|
|
971
|
+
declare type ILlmObjectSchema<P extends ILlmProperties> = ISchemaValidator<ObjectStatic<P>>;
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* Wrapper marking a property as optional within an object schema.
|
|
975
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
976
|
+
* @public
|
|
977
|
+
*/
|
|
978
|
+
declare type ILlmOptional<S extends ISchemaValidator<unknown>> = ISchemaValidator<Static<S> | undefined>;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* A record of property schemas, as accepted by the `object` factory.
|
|
982
|
+
* @public
|
|
983
|
+
*/
|
|
984
|
+
declare type ILlmProperties = Record<string, ISchemaValidator<unknown>>;
|
|
985
|
+
|
|
986
|
+
/**
|
|
987
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
988
|
+
* @public
|
|
989
|
+
*/
|
|
990
|
+
declare type ILlmSchema<T> = ISchemaValidator<T>;
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* Schema node for a JSON `string`.
|
|
994
|
+
* @deprecated Use `ISchemaValidator` instead.
|
|
995
|
+
* @public
|
|
996
|
+
*/
|
|
997
|
+
declare type ILlmStringSchema = ISchemaValidator<string>;
|
|
998
|
+
|
|
891
999
|
/**
|
|
892
1000
|
* Extended accessors interface that supports mutation operations.
|
|
893
1001
|
* All mutation methods are required — use {@link FileTree.isMutableAccessors | isMutableAccessors}
|
|
@@ -1135,6 +1243,39 @@ declare class InMemoryTreeAccessors<TCT extends string = string> implements IMut
|
|
|
1135
1243
|
saveFileContents(path: string, contents: string): Result<string>;
|
|
1136
1244
|
}
|
|
1137
1245
|
|
|
1246
|
+
/**
|
|
1247
|
+
* Creates a schema node for a JSON `integer`.
|
|
1248
|
+
* @param opts - Optional description and strict mode (see `INumberSchemaOptions`).
|
|
1249
|
+
* @returns An `ISchemaValidator` (tagged `integer`) whose `Static` type is `number`.
|
|
1250
|
+
* @public
|
|
1251
|
+
*/
|
|
1252
|
+
declare function integer(opts?: INumberSchemaOptions): ISchemaValidator<number>;
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* Options for the `number` and `integer` factories.
|
|
1256
|
+
* @public
|
|
1257
|
+
*/
|
|
1258
|
+
declare interface INumberSchemaOptions extends ISchemaOptions {
|
|
1259
|
+
/**
|
|
1260
|
+
* When `true` (default), the derived validator rejects numeric strings such as `'42'` and
|
|
1261
|
+
* accepts only genuine JSON numbers. Set `false` to opt into permissive coercion (numeric
|
|
1262
|
+
* strings are accepted and converted to their numeric value).
|
|
1263
|
+
*/
|
|
1264
|
+
strict?: boolean;
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* Options for the `object` factory.
|
|
1269
|
+
* @public
|
|
1270
|
+
*/
|
|
1271
|
+
declare interface IObjectSchemaOptions extends ISchemaOptions {
|
|
1272
|
+
/**
|
|
1273
|
+
* When `false` (default), the validator rejects unrecognized properties and the emitted schema
|
|
1274
|
+
* sets `additionalProperties: false`. Set `true` to allow extra fields.
|
|
1275
|
+
*/
|
|
1276
|
+
additionalProperties?: boolean;
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1138
1279
|
/**
|
|
1139
1280
|
* Extended accessors interface that supports persistence operations.
|
|
1140
1281
|
* @public
|
|
@@ -1172,6 +1313,55 @@ declare interface IReadDirectoryItem<T> {
|
|
|
1172
1313
|
item: T;
|
|
1173
1314
|
}
|
|
1174
1315
|
|
|
1316
|
+
/**
|
|
1317
|
+
* Common options accepted by every schema factory.
|
|
1318
|
+
* @public
|
|
1319
|
+
*/
|
|
1320
|
+
declare interface ISchemaOptions {
|
|
1321
|
+
/**
|
|
1322
|
+
* Optional human-readable description emitted into the wire JSON Schema.
|
|
1323
|
+
*/
|
|
1324
|
+
description?: string;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* A typed JSON Schema node for the LLM-tool subset. Every value returned by the
|
|
1329
|
+
* schema factories implements this interface — it IS a `Validator<T>` and also
|
|
1330
|
+
* carries a `toJson()` method for wire-format emission.
|
|
1331
|
+
*
|
|
1332
|
+
* @remarks
|
|
1333
|
+
* The `__staticType` property is a phantom: it exists only in the type system to carry
|
|
1334
|
+
* the derived static type `T` and is never assigned at runtime (declared optional so
|
|
1335
|
+
* factory return values need not populate it). `Static<S>` reads this slot to recover
|
|
1336
|
+
* `T` from a schema value without requiring a user-supplied type assertion. A plain
|
|
1337
|
+
* optional property is used rather than a module-private `unique symbol` because this is
|
|
1338
|
+
* a published package surface — a private-symbol-keyed property cannot be named in the
|
|
1339
|
+
* emitted `.d.ts` (TypeBox issue #679), which would break declaration emission and API
|
|
1340
|
+
* Extractor for downstream consumers.
|
|
1341
|
+
*
|
|
1342
|
+
* Consumers call `schema.validate(input)` directly; no separate adapter step is required.
|
|
1343
|
+
* @public
|
|
1344
|
+
*/
|
|
1345
|
+
declare interface ISchemaValidator<T> extends Validator<T> {
|
|
1346
|
+
/**
|
|
1347
|
+
* Phantom type carrier — type-level only, never present at runtime.
|
|
1348
|
+
*/
|
|
1349
|
+
readonly __staticType?: T;
|
|
1350
|
+
/**
|
|
1351
|
+
* Runtime discriminant. Identifies the schema node kind.
|
|
1352
|
+
*/
|
|
1353
|
+
readonly _type: SchemaNodeType;
|
|
1354
|
+
/**
|
|
1355
|
+
* Optional human-readable description emitted into the wire JSON Schema.
|
|
1356
|
+
*/
|
|
1357
|
+
readonly description?: string;
|
|
1358
|
+
/**
|
|
1359
|
+
* Emits the standard JSON Schema (draft-07 LLM-tool subset) wire form for this schema.
|
|
1360
|
+
* @returns The JSON Schema object describing this schema node.
|
|
1361
|
+
*/
|
|
1362
|
+
toJson(): JsonObject;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1175
1365
|
/**
|
|
1176
1366
|
* Test if an `unknown` is potentially a {@link JsonArray | JsonArray}.
|
|
1177
1367
|
* @param from - The `unknown` to be tested.
|
|
@@ -1525,6 +1715,64 @@ declare type JsonReplacerFunction = (key: string, value: JsonValue) => JsonValue
|
|
|
1525
1715
|
*/
|
|
1526
1716
|
declare type JsonReviver = (key: string, value: JsonValue) => JsonValue;
|
|
1527
1717
|
|
|
1718
|
+
declare namespace JsonSchema {
|
|
1719
|
+
export {
|
|
1720
|
+
SchemaNodeType,
|
|
1721
|
+
ISchemaValidator,
|
|
1722
|
+
Static,
|
|
1723
|
+
ILlmProperties,
|
|
1724
|
+
OptionalKeys,
|
|
1725
|
+
RequiredKeys,
|
|
1726
|
+
OptionalPropertyStatic,
|
|
1727
|
+
Simplify,
|
|
1728
|
+
ObjectStatic,
|
|
1729
|
+
ILlmSchema,
|
|
1730
|
+
ILlmStringSchema,
|
|
1731
|
+
ILlmNumberSchema,
|
|
1732
|
+
ILlmBooleanSchema,
|
|
1733
|
+
ILlmEnumSchema,
|
|
1734
|
+
ILlmOptional,
|
|
1735
|
+
ILlmArraySchema,
|
|
1736
|
+
ILlmObjectSchema,
|
|
1737
|
+
string_2 as string,
|
|
1738
|
+
number_2 as number,
|
|
1739
|
+
integer,
|
|
1740
|
+
boolean_2 as boolean,
|
|
1741
|
+
enumOf,
|
|
1742
|
+
optional,
|
|
1743
|
+
array,
|
|
1744
|
+
object_3 as object,
|
|
1745
|
+
ISchemaOptions,
|
|
1746
|
+
INumberSchemaOptions,
|
|
1747
|
+
IObjectSchemaOptions,
|
|
1748
|
+
fromJson,
|
|
1749
|
+
jsonSchemaConverter
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
export { JsonSchema }
|
|
1753
|
+
|
|
1754
|
+
/**
|
|
1755
|
+
* The main converter. Parses a raw JSON Schema object into a typed schema validator
|
|
1756
|
+
* for the LLM-tool subset.
|
|
1757
|
+
*
|
|
1758
|
+
* @remarks
|
|
1759
|
+
* Performs pre-flight checks (non-object root, union type arrays, forbidden keywords,
|
|
1760
|
+
* unknown types) before dispatching to the per-type arm converters.
|
|
1761
|
+
*
|
|
1762
|
+
* The conversion context (`TC = string`) carries the current JSON Pointer path so that
|
|
1763
|
+
* error messages from nested nodes name the actual failing node (e.g.
|
|
1764
|
+
* `#/properties/config/properties/inner: 'required' key '...'`) rather than always
|
|
1765
|
+
* reporting `#:`. The context defaults to `'#'` when absent (top-level call).
|
|
1766
|
+
*
|
|
1767
|
+
* Array and object arms reference `jsonSchemaConverter` by name from inside function
|
|
1768
|
+
* declarations (hoisted). By the time any arm is called at runtime, `jsonSchemaConverter`
|
|
1769
|
+
* is fully initialized, so recursive sub-schema calls also go through the pre-flight checks
|
|
1770
|
+
* and produce meaningful error messages.
|
|
1771
|
+
*
|
|
1772
|
+
* @public
|
|
1773
|
+
*/
|
|
1774
|
+
declare const jsonSchemaConverter: Converter<ISchemaValidator<JsonValue>, string>;
|
|
1775
|
+
|
|
1528
1776
|
/**
|
|
1529
1777
|
* Helper class to work with JSON files using FileTree API (web-compatible).
|
|
1530
1778
|
* @public
|
|
@@ -1642,12 +1890,20 @@ declare type MutableFileTreeItem<TCT extends string = string> = IMutableFileTree
|
|
|
1642
1890
|
*/
|
|
1643
1891
|
declare const number: Converter<number, IJsonConverterContext>;
|
|
1644
1892
|
|
|
1893
|
+
/**
|
|
1894
|
+
* Creates a schema node for a JSON `number`.
|
|
1895
|
+
* @param opts - Optional description and strict mode (see `INumberSchemaOptions`).
|
|
1896
|
+
* @returns An `ISchemaValidator` whose `Static` type is `number`.
|
|
1897
|
+
* @public
|
|
1898
|
+
*/
|
|
1899
|
+
declare function number_2(opts?: INumberSchemaOptions): ISchemaValidator<number>;
|
|
1900
|
+
|
|
1645
1901
|
/**
|
|
1646
1902
|
* A `NumberValidator` which validates a number in place.
|
|
1647
1903
|
* Accepts {@link Validators.IJsonValidatorContext | IJsonValidatorContext} but ignores it.
|
|
1648
1904
|
* @public
|
|
1649
1905
|
*/
|
|
1650
|
-
declare const
|
|
1906
|
+
declare const number_3: Validation.Classes.NumberValidator<number, IJsonValidatorContext>;
|
|
1651
1907
|
|
|
1652
1908
|
/**
|
|
1653
1909
|
* A helper function to create a {@link JsonCompatible.ObjectConverter | JSON-compatible ObjectConverter<T, TC>} which converts a
|
|
@@ -1669,18 +1925,62 @@ declare function object<T, TC = unknown>(properties: Conversion.FieldConverters<
|
|
|
1669
1925
|
*/
|
|
1670
1926
|
declare function object_2<T, TC = unknown>(properties: Validation.Classes.FieldValidators<JsonCompatibleType<T>, TC>, params?: Omit<Validation.Classes.ObjectValidatorConstructorParams<JsonCompatibleType<T>, TC>, 'fields'>): JsonCompatible_2.ObjectValidator<T, TC>;
|
|
1671
1927
|
|
|
1928
|
+
/**
|
|
1929
|
+
* Creates a schema node for a JSON `object` with a fixed set of typed properties.
|
|
1930
|
+
* @param properties - A record mapping property names to their schemas. Wrap a property with
|
|
1931
|
+
* `optional` to make it optional.
|
|
1932
|
+
* @param opts - Optional description and `additionalProperties` flag.
|
|
1933
|
+
* @returns An `ISchemaValidator` whose `Static` type derives the required/optional split.
|
|
1934
|
+
* @public
|
|
1935
|
+
*/
|
|
1936
|
+
declare function object_3<P extends ILlmProperties>(properties: P, opts?: IObjectSchemaOptions): ISchemaValidator<ObjectStatic<P>>;
|
|
1937
|
+
|
|
1672
1938
|
/**
|
|
1673
1939
|
* A converter which converts a supplied `unknown` value to a valid {@link JsonCompatibleType | JsonCompatible} value.
|
|
1674
1940
|
* @public
|
|
1675
1941
|
*/
|
|
1676
1942
|
declare type ObjectConverter<T, TC = unknown> = ObjectConverter_2<JsonCompatibleType<T>, TC>;
|
|
1677
1943
|
|
|
1944
|
+
/**
|
|
1945
|
+
* The derived static type for an object built from properties `P`: required keys carry their
|
|
1946
|
+
* static type directly, optional keys carry theirs under a `?` modifier.
|
|
1947
|
+
* @public
|
|
1948
|
+
*/
|
|
1949
|
+
declare type ObjectStatic<P extends ILlmProperties> = Simplify<{
|
|
1950
|
+
[K in RequiredKeys<P>]: Static<P[K]>;
|
|
1951
|
+
} & {
|
|
1952
|
+
[K in OptionalKeys<P>]?: OptionalPropertyStatic<P[K]>;
|
|
1953
|
+
}>;
|
|
1954
|
+
|
|
1678
1955
|
/**
|
|
1679
1956
|
* A validator which validates a supplied `unknown` value to a valid {@link JsonCompatibleType | JsonCompatible} value.
|
|
1680
1957
|
* @public
|
|
1681
1958
|
*/
|
|
1682
1959
|
declare type ObjectValidator<T, TC = unknown> = Validation.Classes.ObjectValidator<JsonCompatibleType<T>, TC>;
|
|
1683
1960
|
|
|
1961
|
+
/**
|
|
1962
|
+
* Marks a property schema as optional within an `object` schema.
|
|
1963
|
+
* @param schema - The inner schema to make optional.
|
|
1964
|
+
* @returns An `ISchemaValidator` whose `Static` type is `Static<S> | undefined`.
|
|
1965
|
+
* @public
|
|
1966
|
+
*/
|
|
1967
|
+
declare function optional<S extends ISchemaValidator<unknown>>(schema: S): ISchemaValidator<Static<S> | undefined>;
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* The keys of `P` whose schemas are optional (wrapped with the `optional` modifier).
|
|
1971
|
+
* @public
|
|
1972
|
+
*/
|
|
1973
|
+
declare type OptionalKeys<P extends ILlmProperties> = {
|
|
1974
|
+
[K in keyof P]: P[K] extends ISchemaValidator<infer U> ? (undefined extends U ? K : never) : never;
|
|
1975
|
+
}[keyof P];
|
|
1976
|
+
|
|
1977
|
+
/**
|
|
1978
|
+
* The static value type carried by an optional property (the inner schema's static type,
|
|
1979
|
+
* without the `| undefined` that optionality adds — the `?` modifier conveys that separately).
|
|
1980
|
+
* @public
|
|
1981
|
+
*/
|
|
1982
|
+
declare type OptionalPropertyStatic<V> = V extends ISchemaValidator<infer U> ? Exclude<U, undefined> : never;
|
|
1983
|
+
|
|
1684
1984
|
/**
|
|
1685
1985
|
* Picks a nested {@link JsonObject | JsonObject} from a supplied
|
|
1686
1986
|
* {@link JsonObject | JsonObject}.
|
|
@@ -1749,6 +2049,12 @@ declare function recordOf_2<T, TC = unknown, TK extends string = string>(validat
|
|
|
1749
2049
|
*/
|
|
1750
2050
|
declare type RecordValidator<T, TC = unknown, TK extends string = string> = Validation.Validator<Record<TK, JsonCompatibleType<T>>, TC>;
|
|
1751
2051
|
|
|
2052
|
+
/**
|
|
2053
|
+
* The keys of `P` whose schemas are required (i.e. not optional).
|
|
2054
|
+
* @public
|
|
2055
|
+
*/
|
|
2056
|
+
declare type RequiredKeys<P extends ILlmProperties> = Exclude<keyof P, OptionalKeys<P>>;
|
|
2057
|
+
|
|
1752
2058
|
/**
|
|
1753
2059
|
* "Sanitizes" an `unknown` by stringifying and then parsing it. Guarantees a
|
|
1754
2060
|
* valid {@link JsonValue | JsonValue} but is not idempotent and gives no guarantees
|
|
@@ -1795,6 +2101,31 @@ declare type SaveDetail = SaveCapability | SaveFailureReason;
|
|
|
1795
2101
|
*/
|
|
1796
2102
|
declare type SaveFailureReason = 'not-supported' | 'read-only' | 'not-mutable' | 'path-excluded' | 'permission-denied';
|
|
1797
2103
|
|
|
2104
|
+
/**
|
|
2105
|
+
* Discriminant tag carried by every schema node.
|
|
2106
|
+
* @public
|
|
2107
|
+
*/
|
|
2108
|
+
declare type SchemaNodeType = 'string' | 'number' | 'integer' | 'boolean' | 'enum' | 'optional' | 'array' | 'object';
|
|
2109
|
+
|
|
2110
|
+
/**
|
|
2111
|
+
* Flattens an intersection of object types into a single object type for readable derived types.
|
|
2112
|
+
* @public
|
|
2113
|
+
*/
|
|
2114
|
+
declare type Simplify<T> = {
|
|
2115
|
+
[K in keyof T]: T[K];
|
|
2116
|
+
} & {};
|
|
2117
|
+
|
|
2118
|
+
/**
|
|
2119
|
+
* Recover the derived static type `T` from a schema value.
|
|
2120
|
+
*
|
|
2121
|
+
* @remarks
|
|
2122
|
+
* `Static<typeof MySchema>` resolves to the TypeScript type that `schema.validate()` produces
|
|
2123
|
+
* and that `schema.toJson()` describes — derived, never asserted. No user-supplied `T` is ever
|
|
2124
|
+
* required.
|
|
2125
|
+
* @public
|
|
2126
|
+
*/
|
|
2127
|
+
declare type Static<S extends ISchemaValidator<unknown>> = S extends ISchemaValidator<infer T> ? T : never;
|
|
2128
|
+
|
|
1798
2129
|
/**
|
|
1799
2130
|
* A helper function to create a {@link JsonCompatible.ObjectConverter | JSON-compatible ObjectConverter<T, TC>} which converts a
|
|
1800
2131
|
* supplied `unknown` value to a valid {@link JsonCompatibleType | JsonCompatibleType<T>} value.
|
|
@@ -1813,12 +2144,20 @@ declare function strictObject<T, TC = unknown>(properties: Conversion.FieldConve
|
|
|
1813
2144
|
*/
|
|
1814
2145
|
declare const string: StringConverter<string, IJsonConverterContext>;
|
|
1815
2146
|
|
|
2147
|
+
/**
|
|
2148
|
+
* Creates a schema node for a JSON `string`.
|
|
2149
|
+
* @param opts - Optional description.
|
|
2150
|
+
* @returns An `ISchemaValidator` whose `Static` type is `string`.
|
|
2151
|
+
* @public
|
|
2152
|
+
*/
|
|
2153
|
+
declare function string_2(opts?: ISchemaOptions): ISchemaValidator<string>;
|
|
2154
|
+
|
|
1816
2155
|
/**
|
|
1817
2156
|
* A `StringValidator` which validates a string in place.
|
|
1818
2157
|
* Accepts {@link Validators.IJsonValidatorContext | IJsonValidatorContext} but ignores it.
|
|
1819
2158
|
* @public
|
|
1820
2159
|
*/
|
|
1821
|
-
declare const
|
|
2160
|
+
declare const string_3: Validation.Classes.StringValidator<string, IJsonValidatorContext>;
|
|
1822
2161
|
|
|
1823
2162
|
/**
|
|
1824
2163
|
* Creates a converter that accepts a string, parses it as JSON, and optionally
|
|
@@ -1863,9 +2202,9 @@ declare namespace Validators {
|
|
|
1863
2202
|
jsonObject_2 as jsonObject,
|
|
1864
2203
|
jsonArray_2 as jsonArray,
|
|
1865
2204
|
jsonValue_2 as jsonValue,
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2205
|
+
string_3 as string,
|
|
2206
|
+
number_3 as number,
|
|
2207
|
+
boolean_3 as boolean
|
|
1869
2208
|
}
|
|
1870
2209
|
}
|
|
1871
2210
|
export { Validators }
|
package/lib/index.browser.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as Converters from './packlets/converters';
|
|
|
2
2
|
import * as FileTree from './packlets/file-tree/index.browser';
|
|
3
3
|
import * as JsonCompatible from './packlets/json-compatible';
|
|
4
4
|
import * as JsonFile from './packlets/json-file/index.browser';
|
|
5
|
+
import * as JsonSchema from './packlets/json-schema-builder';
|
|
5
6
|
import * as Validators from './packlets/validators';
|
|
6
7
|
export * from './packlets/json';
|
|
7
|
-
export { Converters, FileTree, JsonCompatible, JsonFile, Validators };
|
|
8
|
+
export { Converters, FileTree, JsonCompatible, JsonFile, JsonSchema, Validators };
|
|
8
9
|
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,QAAQ,MAAM,oCAAoC,CAAC;AAC/D,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
|
package/lib/index.browser.js
CHANGED
|
@@ -57,7 +57,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
57
57
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.Validators = exports.JsonFile = exports.JsonCompatible = exports.FileTree = exports.Converters = void 0;
|
|
60
|
+
exports.Validators = exports.JsonSchema = exports.JsonFile = exports.JsonCompatible = exports.FileTree = exports.Converters = void 0;
|
|
61
61
|
const Converters = __importStar(require("./packlets/converters"));
|
|
62
62
|
exports.Converters = Converters;
|
|
63
63
|
// eslint-disable-next-line @rushstack/packlets/mechanics
|
|
@@ -68,6 +68,8 @@ exports.JsonCompatible = JsonCompatible;
|
|
|
68
68
|
// eslint-disable-next-line @rushstack/packlets/mechanics
|
|
69
69
|
const JsonFile = __importStar(require("./packlets/json-file/index.browser"));
|
|
70
70
|
exports.JsonFile = JsonFile;
|
|
71
|
+
const JsonSchema = __importStar(require("./packlets/json-schema-builder"));
|
|
72
|
+
exports.JsonSchema = JsonSchema;
|
|
71
73
|
const Validators = __importStar(require("./packlets/validators"));
|
|
72
74
|
exports.Validators = Validators;
|
|
73
75
|
__exportStar(require("./packlets/json"), exports);
|
package/lib/index.browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../src/index.browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;AAU3C,gCAAU;AATnB,yDAAyD;AACzD,6EAA+D;AAQ1C,4BAAQ;AAP7B,2EAA6D;AAO9B,wCAAc;AAN7C,yDAAyD;AACzD,6EAA+D;AAKhB,4BAAQ;AAJvD,2EAA6D;AAIJ,gCAAU;AAHnE,kEAAoD;AAGiB,gCAAU;AAD/E,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './packlets/converters';\n// eslint-disable-next-line @rushstack/packlets/mechanics\nimport * as FileTree from './packlets/file-tree/index.browser';\nimport * as JsonCompatible from './packlets/json-compatible';\n// eslint-disable-next-line @rushstack/packlets/mechanics\nimport * as JsonFile from './packlets/json-file/index.browser';\nimport * as JsonSchema from './packlets/json-schema-builder';\nimport * as Validators from './packlets/validators';\n\nexport * from './packlets/json';\nexport { Converters, FileTree, JsonCompatible, JsonFile, JsonSchema, Validators };\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import * as Converters from './packlets/converters';
|
|
|
2
2
|
import * as FileTree from './packlets/file-tree';
|
|
3
3
|
import * as JsonCompatible from './packlets/json-compatible';
|
|
4
4
|
import * as JsonFile from './packlets/json-file';
|
|
5
|
+
import * as JsonSchema from './packlets/json-schema-builder';
|
|
5
6
|
import * as Validators from './packlets/validators';
|
|
6
7
|
export * from './packlets/json';
|
|
7
|
-
export { Converters, FileTree, JsonCompatible, JsonFile, Validators };
|
|
8
|
+
export { Converters, FileTree, JsonCompatible, JsonFile, JsonSchema, Validators };
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,cAAc,MAAM,4BAA4B,CAAC;AAC7D,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,UAAU,MAAM,gCAAgC,CAAC;AAC7D,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AAEpD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -57,7 +57,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
57
57
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
-
exports.Validators = exports.JsonFile = exports.JsonCompatible = exports.FileTree = exports.Converters = void 0;
|
|
60
|
+
exports.Validators = exports.JsonSchema = exports.JsonFile = exports.JsonCompatible = exports.FileTree = exports.Converters = void 0;
|
|
61
61
|
const Converters = __importStar(require("./packlets/converters"));
|
|
62
62
|
exports.Converters = Converters;
|
|
63
63
|
const FileTree = __importStar(require("./packlets/file-tree"));
|
|
@@ -66,6 +66,8 @@ const JsonCompatible = __importStar(require("./packlets/json-compatible"));
|
|
|
66
66
|
exports.JsonCompatible = JsonCompatible;
|
|
67
67
|
const JsonFile = __importStar(require("./packlets/json-file"));
|
|
68
68
|
exports.JsonFile = JsonFile;
|
|
69
|
+
const JsonSchema = __importStar(require("./packlets/json-schema-builder"));
|
|
70
|
+
exports.JsonSchema = JsonSchema;
|
|
69
71
|
const Validators = __importStar(require("./packlets/validators"));
|
|
70
72
|
exports.Validators = Validators;
|
|
71
73
|
__exportStar(require("./packlets/json"), exports);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAoD;AAQ3C,gCAAU;AAPnB,+DAAiD;AAO5B,4BAAQ;AAN7B,2EAA6D;AAM9B,wCAAc;AAL7C,+DAAiD;AAKF,4BAAQ;AAJvD,2EAA6D;AAIJ,gCAAU;AAHnE,kEAAoD;AAGiB,gCAAU;AAD/E,kDAAgC","sourcesContent":["/*\n * Copyright (c) 2023 Erik Fortune\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n\nimport * as Converters from './packlets/converters';\nimport * as FileTree from './packlets/file-tree';\nimport * as JsonCompatible from './packlets/json-compatible';\nimport * as JsonFile from './packlets/json-file';\nimport * as JsonSchema from './packlets/json-schema-builder';\nimport * as Validators from './packlets/validators';\n\nexport * from './packlets/json';\nexport { Converters, FileTree, JsonCompatible, JsonFile, JsonSchema, Validators };\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { ILlmProperties, ISchemaValidator, ObjectStatic, Static } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Common options accepted by every schema factory.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface ISchemaOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Optional human-readable description emitted into the wire JSON Schema.
|
|
9
|
+
*/
|
|
10
|
+
description?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Options for the `number` and `integer` factories.
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export interface INumberSchemaOptions extends ISchemaOptions {
|
|
17
|
+
/**
|
|
18
|
+
* When `true` (default), the derived validator rejects numeric strings such as `'42'` and
|
|
19
|
+
* accepts only genuine JSON numbers. Set `false` to opt into permissive coercion (numeric
|
|
20
|
+
* strings are accepted and converted to their numeric value).
|
|
21
|
+
*/
|
|
22
|
+
strict?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Options for the `object` factory.
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export interface IObjectSchemaOptions extends ISchemaOptions {
|
|
29
|
+
/**
|
|
30
|
+
* When `false` (default), the validator rejects unrecognized properties and the emitted schema
|
|
31
|
+
* sets `additionalProperties: false`. Set `true` to allow extra fields.
|
|
32
|
+
*/
|
|
33
|
+
additionalProperties?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a schema node for a JSON `string`.
|
|
37
|
+
* @param opts - Optional description.
|
|
38
|
+
* @returns An `ISchemaValidator` whose `Static` type is `string`.
|
|
39
|
+
* @public
|
|
40
|
+
*/
|
|
41
|
+
export declare function string(opts?: ISchemaOptions): ISchemaValidator<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a schema node for a JSON `number`.
|
|
44
|
+
* @param opts - Optional description and strict mode (see `INumberSchemaOptions`).
|
|
45
|
+
* @returns An `ISchemaValidator` whose `Static` type is `number`.
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export declare function number(opts?: INumberSchemaOptions): ISchemaValidator<number>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a schema node for a JSON `integer`.
|
|
51
|
+
* @param opts - Optional description and strict mode (see `INumberSchemaOptions`).
|
|
52
|
+
* @returns An `ISchemaValidator` (tagged `integer`) whose `Static` type is `number`.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export declare function integer(opts?: INumberSchemaOptions): ISchemaValidator<number>;
|
|
56
|
+
/**
|
|
57
|
+
* Creates a schema node for a JSON `boolean`.
|
|
58
|
+
* @param opts - Optional description.
|
|
59
|
+
* @returns An `ISchemaValidator` whose `Static` type is `boolean`.
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare function boolean(opts?: ISchemaOptions): ISchemaValidator<boolean>;
|
|
63
|
+
/**
|
|
64
|
+
* Creates a schema node for a closed set of string literals.
|
|
65
|
+
* @param values - The allowed string values.
|
|
66
|
+
* @param opts - Optional description.
|
|
67
|
+
* @returns An `ISchemaValidator` whose `Static` type is the union of `values`.
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export declare function enumOf<T extends string>(values: readonly T[], opts?: ISchemaOptions): ISchemaValidator<T>;
|
|
71
|
+
/**
|
|
72
|
+
* Marks a property schema as optional within an `object` schema.
|
|
73
|
+
* @param schema - The inner schema to make optional.
|
|
74
|
+
* @returns An `ISchemaValidator` whose `Static` type is `Static<S> | undefined`.
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export declare function optional<S extends ISchemaValidator<unknown>>(schema: S): ISchemaValidator<Static<S> | undefined>;
|
|
78
|
+
/**
|
|
79
|
+
* Creates a schema node for a JSON `array` whose elements all match `items`.
|
|
80
|
+
* @param items - The schema applied to every element.
|
|
81
|
+
* @param opts - Optional description.
|
|
82
|
+
* @returns An `ISchemaValidator` whose `Static` type is `Array<Static<S>>`.
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
export declare function array<S extends ISchemaValidator<unknown>>(items: S, opts?: ISchemaOptions): ISchemaValidator<Static<S>[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a schema node for a JSON `object` with a fixed set of typed properties.
|
|
88
|
+
* @param properties - A record mapping property names to their schemas. Wrap a property with
|
|
89
|
+
* `optional` to make it optional.
|
|
90
|
+
* @param opts - Optional description and `additionalProperties` flag.
|
|
91
|
+
* @returns An `ISchemaValidator` whose `Static` type derives the required/optional split.
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
export declare function object<P extends ILlmProperties>(properties: P, opts?: IObjectSchemaOptions): ISchemaValidator<ObjectStatic<P>>;
|
|
95
|
+
//# sourceMappingURL=factories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/packlets/json-schema-builder/factories.ts"],"names":[],"mappings":"AAkCA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,YAAY,EAAkB,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjG;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;;OAIG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D;;;OAGG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAkVD;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAE5E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,oBAAoB,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAE7E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAExE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAEzG;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EAC1D,MAAM,EAAE,CAAC,GACR,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,SAAS,gBAAgB,CAAC,OAAO,CAAC,EACvD,KAAK,EAAE,CAAC,EACR,IAAI,CAAC,EAAE,cAAc,GACpB,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAE/B;AAED;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,cAAc,EAC7C,UAAU,EAAE,CAAC,EACb,IAAI,CAAC,EAAE,oBAAoB,GAC1B,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAEnC"}
|