@kaito-http/core 4.0.0-beta.25 → 4.0.0-beta.26

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.
@@ -830,6 +830,88 @@ var KLiteral = class _KLiteral extends BaseSchema {
830
830
  visit() {
831
831
  }
832
832
  };
833
+ var KRecord = class _KRecord extends BaseSchema {
834
+ static create = (keys, values) => new _KRecord({ keys, values });
835
+ serialize(value) {
836
+ const result = {};
837
+ for (const key in value) {
838
+ if (!Object.prototype.hasOwnProperty.call(value, key)) continue;
839
+ const keySerialize = this.def.keys.serialize(key);
840
+ const valueSerialize = this.def.values.serialize(value[key]);
841
+ result[keySerialize] = valueSerialize;
842
+ }
843
+ return result;
844
+ }
845
+ toOpenAPI() {
846
+ const baseSchema = this.getSchemaObject();
847
+ return {
848
+ ...baseSchema,
849
+ type: "object",
850
+ propertyNames: this.def.keys.toOpenAPI(),
851
+ additionalProperties: this.def.values.toOpenAPI()
852
+ };
853
+ }
854
+ parseSafe(json) {
855
+ return ParseContext.result((ctx) => {
856
+ if (typeof json !== "object" || json === null || Array.isArray(json)) {
857
+ return ctx.addIssue("Expected object", []);
858
+ }
859
+ const result = {};
860
+ for (const key in json) {
861
+ if (!Object.prototype.hasOwnProperty.call(json, key)) continue;
862
+ const keyParse = this.def.keys.parseSafe(key);
863
+ if (!keyParse.success) {
864
+ return ctx.addIssues(keyParse.issues, [key]);
865
+ }
866
+ const value = json[keyParse.result];
867
+ const valueParse = this.def.values.parseSafe(value);
868
+ if (!valueParse.success) {
869
+ return ctx.addIssues(valueParse.issues, [key]);
870
+ }
871
+ result[keyParse.result] = valueParse.result;
872
+ }
873
+ return result;
874
+ });
875
+ }
876
+ parse(json) {
877
+ const result = this.parseSafe(json);
878
+ if (!result.success) {
879
+ throw new SchemaError(result.issues);
880
+ }
881
+ return result.result;
882
+ }
883
+ visit(visitor) {
884
+ visitor(this.def.keys);
885
+ visitor(this.def.values);
886
+ }
887
+ };
888
+ var KLazy = class _KLazy extends BaseSchema {
889
+ schema;
890
+ static create = (getter) => new _KLazy({ getter });
891
+ getSchema() {
892
+ if (!this.schema) {
893
+ this.schema = this.def.getter();
894
+ }
895
+ return this.schema;
896
+ }
897
+ serialize(value) {
898
+ return this.getSchema().serialize(value);
899
+ }
900
+ toOpenAPI() {
901
+ return this.getSchema().toOpenAPI();
902
+ }
903
+ parseSafe(json) {
904
+ return this.getSchema().parseSafe(json);
905
+ }
906
+ parse(json) {
907
+ return this.getSchema().parse(json);
908
+ }
909
+ visit(visitor) {
910
+ const schema = this.getSchema();
911
+ visitor(schema);
912
+ schema.visit(visitor);
913
+ }
914
+ };
833
915
  var k = {
834
916
  string: KString.create,
835
917
  number: KNumber.create,
@@ -837,10 +919,21 @@ var k = {
837
919
  array: KArray.create,
838
920
  null: KNull.create,
839
921
  ref: KRef.create,
922
+ record: KRecord.create,
840
923
  object: KObject.create,
841
924
  scalar: KScalar.create,
842
925
  literal: KLiteral.create,
843
926
  union: KUnion.create,
927
+ lazy: KLazy.create,
928
+ /**
929
+ * Schema for any valid JSON value
930
+ */
931
+ json: () => {
932
+ const jsonSchema = k.lazy(
933
+ () => k.union([k.string(), k.number(), k.boolean(), k.null(), k.array(jsonSchema), k.record(k.string(), jsonSchema)])
934
+ );
935
+ return jsonSchema;
936
+ },
844
937
  /**
845
938
  * @internal
846
939
  * @experimental
@@ -865,5 +958,7 @@ export {
865
958
  KScalar,
866
959
  KUnion,
867
960
  KLiteral,
961
+ KRecord,
962
+ KLazy,
868
963
  k
869
964
  };
package/dist/index.cjs CHANGED
@@ -23,11 +23,13 @@ __export(index_exports, {
23
23
  BaseSchema: () => BaseSchema,
24
24
  KArray: () => KArray,
25
25
  KBoolean: () => KBoolean,
26
+ KLazy: () => KLazy,
26
27
  KLiteral: () => KLiteral,
27
28
  KNull: () => KNull,
28
29
  KNumber: () => KNumber,
29
30
  KObject: () => KObject,
30
31
  KObjectFromURLSearchParams: () => KObjectFromURLSearchParams,
32
+ KRecord: () => KRecord,
31
33
  KRef: () => KRef,
32
34
  KScalar: () => KScalar,
33
35
  KString: () => KString,
@@ -988,6 +990,88 @@ var KLiteral = class _KLiteral extends BaseSchema {
988
990
  visit() {
989
991
  }
990
992
  };
993
+ var KRecord = class _KRecord extends BaseSchema {
994
+ static create = (keys, values) => new _KRecord({ keys, values });
995
+ serialize(value) {
996
+ const result = {};
997
+ for (const key in value) {
998
+ if (!Object.prototype.hasOwnProperty.call(value, key)) continue;
999
+ const keySerialize = this.def.keys.serialize(key);
1000
+ const valueSerialize = this.def.values.serialize(value[key]);
1001
+ result[keySerialize] = valueSerialize;
1002
+ }
1003
+ return result;
1004
+ }
1005
+ toOpenAPI() {
1006
+ const baseSchema = this.getSchemaObject();
1007
+ return {
1008
+ ...baseSchema,
1009
+ type: "object",
1010
+ propertyNames: this.def.keys.toOpenAPI(),
1011
+ additionalProperties: this.def.values.toOpenAPI()
1012
+ };
1013
+ }
1014
+ parseSafe(json) {
1015
+ return ParseContext.result((ctx) => {
1016
+ if (typeof json !== "object" || json === null || Array.isArray(json)) {
1017
+ return ctx.addIssue("Expected object", []);
1018
+ }
1019
+ const result = {};
1020
+ for (const key in json) {
1021
+ if (!Object.prototype.hasOwnProperty.call(json, key)) continue;
1022
+ const keyParse = this.def.keys.parseSafe(key);
1023
+ if (!keyParse.success) {
1024
+ return ctx.addIssues(keyParse.issues, [key]);
1025
+ }
1026
+ const value = json[keyParse.result];
1027
+ const valueParse = this.def.values.parseSafe(value);
1028
+ if (!valueParse.success) {
1029
+ return ctx.addIssues(valueParse.issues, [key]);
1030
+ }
1031
+ result[keyParse.result] = valueParse.result;
1032
+ }
1033
+ return result;
1034
+ });
1035
+ }
1036
+ parse(json) {
1037
+ const result = this.parseSafe(json);
1038
+ if (!result.success) {
1039
+ throw new SchemaError(result.issues);
1040
+ }
1041
+ return result.result;
1042
+ }
1043
+ visit(visitor) {
1044
+ visitor(this.def.keys);
1045
+ visitor(this.def.values);
1046
+ }
1047
+ };
1048
+ var KLazy = class _KLazy extends BaseSchema {
1049
+ schema;
1050
+ static create = (getter) => new _KLazy({ getter });
1051
+ getSchema() {
1052
+ if (!this.schema) {
1053
+ this.schema = this.def.getter();
1054
+ }
1055
+ return this.schema;
1056
+ }
1057
+ serialize(value) {
1058
+ return this.getSchema().serialize(value);
1059
+ }
1060
+ toOpenAPI() {
1061
+ return this.getSchema().toOpenAPI();
1062
+ }
1063
+ parseSafe(json) {
1064
+ return this.getSchema().parseSafe(json);
1065
+ }
1066
+ parse(json) {
1067
+ return this.getSchema().parse(json);
1068
+ }
1069
+ visit(visitor) {
1070
+ const schema = this.getSchema();
1071
+ visitor(schema);
1072
+ schema.visit(visitor);
1073
+ }
1074
+ };
991
1075
  var k = {
992
1076
  string: KString.create,
993
1077
  number: KNumber.create,
@@ -995,10 +1079,21 @@ var k = {
995
1079
  array: KArray.create,
996
1080
  null: KNull.create,
997
1081
  ref: KRef.create,
1082
+ record: KRecord.create,
998
1083
  object: KObject.create,
999
1084
  scalar: KScalar.create,
1000
1085
  literal: KLiteral.create,
1001
1086
  union: KUnion.create,
1087
+ lazy: KLazy.create,
1088
+ /**
1089
+ * Schema for any valid JSON value
1090
+ */
1091
+ json: () => {
1092
+ const jsonSchema = k.lazy(
1093
+ () => k.union([k.string(), k.number(), k.boolean(), k.null(), k.array(jsonSchema), k.record(k.string(), jsonSchema)])
1094
+ );
1095
+ return jsonSchema;
1096
+ },
1002
1097
  /**
1003
1098
  * @internal
1004
1099
  * @experimental
@@ -1327,11 +1422,13 @@ var create = Router.create;
1327
1422
  BaseSchema,
1328
1423
  KArray,
1329
1424
  KBoolean,
1425
+ KLazy,
1330
1426
  KLiteral,
1331
1427
  KNull,
1332
1428
  KNumber,
1333
1429
  KObject,
1334
1430
  KObjectFromURLSearchParams,
1431
+ KRecord,
1335
1432
  KRef,
1336
1433
  KScalar,
1337
1434
  KString,
package/dist/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as OpenAPI from 'openapi3-ts/oas31';
2
2
  import { JSONValue as JSONValue$1, AnySchemaFor, BaseSchema, BaseSchemaDef } from './schema/schema.cjs';
3
- export { ArrayChecks, ArrayDef, BooleanDef, Issue, JSONPrimitive, KArray, KBoolean, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRef, KScalar, KString, KUnion, LiteralDef, NullDef, NumberChecks, NumberDef, NumberFormat, ObjectDef, ParseContext, ParseResult, RefDef, STRING_FORMAT_REGEXES, ScalarDef, ScalarOptions, SchemaError, StringChecks, StringDef, StringFormat, UnionDef, isPrimitiveJSONValue, k } from './schema/schema.cjs';
3
+ export { ArrayChecks, ArrayDef, BooleanDef, Issue, JSONPrimitive, KArray, KBoolean, KLazy, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRecord, KRef, KScalar, KString, KUnion, LazyDef, LiteralDef, NullDef, NumberChecks, NumberDef, NumberFormat, ObjectDef, ParseContext, ParseResult, RecordDef, RefDef, STRING_FORMAT_REGEXES, ScalarDef, ScalarOptions, SchemaError, StringChecks, StringDef, StringFormat, UnionDef, isPrimitiveJSONValue, k } from './schema/schema.cjs';
4
4
  import { KaitoSSEResponse } from './stream/stream.cjs';
5
5
 
6
6
  declare class WrappedError<T> extends Error {
@@ -158,11 +158,7 @@ type JSONOutputSpec<ResultInput, ResultOutput extends JSONValue$1> = {
158
158
  schema: BaseSchema<ResultOutput, ResultInput, BaseSchemaDef<ResultOutput>>;
159
159
  description?: string | undefined;
160
160
  };
161
- type OutputSpec<ResultInput, ResultOutput> = ResultInput extends KaitoSSEResponse<infer R> ? SSEOutputSpec<Extract<R, JSONValue$1>> & {
162
- description?: string;
163
- } : JSONOutputSpec<ResultOutput, Extract<ResultInput, JSONValue$1>> & {
164
- description?: string;
165
- };
161
+ type OutputSpec<ResultInput, ResultOutput> = ResultInput extends KaitoSSEResponse<infer R> ? SSEOutputSpec<Extract<R, JSONValue$1>> : JSONOutputSpec<ResultOutput, Extract<ResultInput, JSONValue$1>>;
166
162
  type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultInput, ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue$1>, Body extends JSONValue$1> = {
167
163
  body?: AnySchemaFor<Body>;
168
164
  query?: {
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as OpenAPI from 'openapi3-ts/oas31';
2
2
  import { JSONValue as JSONValue$1, AnySchemaFor, BaseSchema, BaseSchemaDef } from './schema/schema.js';
3
- export { ArrayChecks, ArrayDef, BooleanDef, Issue, JSONPrimitive, KArray, KBoolean, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRef, KScalar, KString, KUnion, LiteralDef, NullDef, NumberChecks, NumberDef, NumberFormat, ObjectDef, ParseContext, ParseResult, RefDef, STRING_FORMAT_REGEXES, ScalarDef, ScalarOptions, SchemaError, StringChecks, StringDef, StringFormat, UnionDef, isPrimitiveJSONValue, k } from './schema/schema.js';
3
+ export { ArrayChecks, ArrayDef, BooleanDef, Issue, JSONPrimitive, KArray, KBoolean, KLazy, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRecord, KRef, KScalar, KString, KUnion, LazyDef, LiteralDef, NullDef, NumberChecks, NumberDef, NumberFormat, ObjectDef, ParseContext, ParseResult, RecordDef, RefDef, STRING_FORMAT_REGEXES, ScalarDef, ScalarOptions, SchemaError, StringChecks, StringDef, StringFormat, UnionDef, isPrimitiveJSONValue, k } from './schema/schema.js';
4
4
  import { KaitoSSEResponse } from './stream/stream.js';
5
5
 
6
6
  declare class WrappedError<T> extends Error {
@@ -158,11 +158,7 @@ type JSONOutputSpec<ResultInput, ResultOutput extends JSONValue$1> = {
158
158
  schema: BaseSchema<ResultOutput, ResultInput, BaseSchemaDef<ResultOutput>>;
159
159
  description?: string | undefined;
160
160
  };
161
- type OutputSpec<ResultInput, ResultOutput> = ResultInput extends KaitoSSEResponse<infer R> ? SSEOutputSpec<Extract<R, JSONValue$1>> & {
162
- description?: string;
163
- } : JSONOutputSpec<ResultOutput, Extract<ResultInput, JSONValue$1>> & {
164
- description?: string;
165
- };
161
+ type OutputSpec<ResultInput, ResultOutput> = ResultInput extends KaitoSSEResponse<infer R> ? SSEOutputSpec<Extract<R, JSONValue$1>> : JSONOutputSpec<ResultOutput, Extract<ResultInput, JSONValue$1>>;
166
162
  type Route<ContextFrom, ContextTo, RouterInput extends readonly unknown[], ResultInput, ResultOutput, Path extends string, AdditionalParams extends string, Method extends KaitoMethod, Query extends Record<string, JSONValue$1>, Body extends JSONValue$1> = {
167
163
  body?: AnySchemaFor<Body>;
168
164
  query?: {
package/dist/index.js CHANGED
@@ -2,11 +2,13 @@ import {
2
2
  BaseSchema,
3
3
  KArray,
4
4
  KBoolean,
5
+ KLazy,
5
6
  KLiteral,
6
7
  KNull,
7
8
  KNumber,
8
9
  KObject,
9
10
  KObjectFromURLSearchParams,
11
+ KRecord,
10
12
  KRef,
11
13
  KScalar,
12
14
  KString,
@@ -16,7 +18,7 @@ import {
16
18
  SchemaError,
17
19
  isPrimitiveJSONValue,
18
20
  k
19
- } from "./chunk-IEGYJT4R.js";
21
+ } from "./chunk-BJVNFSCY.js";
20
22
 
21
23
  // src/router/router.ts
22
24
  import "openapi3-ts/oas31";
@@ -447,11 +449,13 @@ export {
447
449
  BaseSchema,
448
450
  KArray,
449
451
  KBoolean,
452
+ KLazy,
450
453
  KLiteral,
451
454
  KNull,
452
455
  KNumber,
453
456
  KObject,
454
457
  KObjectFromURLSearchParams,
458
+ KRecord,
455
459
  KRef,
456
460
  KScalar,
457
461
  KString,
@@ -23,11 +23,13 @@ __export(schema_exports, {
23
23
  BaseSchema: () => BaseSchema,
24
24
  KArray: () => KArray,
25
25
  KBoolean: () => KBoolean,
26
+ KLazy: () => KLazy,
26
27
  KLiteral: () => KLiteral,
27
28
  KNull: () => KNull,
28
29
  KNumber: () => KNumber,
29
30
  KObject: () => KObject,
30
31
  KObjectFromURLSearchParams: () => KObjectFromURLSearchParams,
32
+ KRecord: () => KRecord,
31
33
  KRef: () => KRef,
32
34
  KScalar: () => KScalar,
33
35
  KString: () => KString,
@@ -870,6 +872,88 @@ var KLiteral = class _KLiteral extends BaseSchema {
870
872
  visit() {
871
873
  }
872
874
  };
875
+ var KRecord = class _KRecord extends BaseSchema {
876
+ static create = (keys, values) => new _KRecord({ keys, values });
877
+ serialize(value) {
878
+ const result = {};
879
+ for (const key in value) {
880
+ if (!Object.prototype.hasOwnProperty.call(value, key)) continue;
881
+ const keySerialize = this.def.keys.serialize(key);
882
+ const valueSerialize = this.def.values.serialize(value[key]);
883
+ result[keySerialize] = valueSerialize;
884
+ }
885
+ return result;
886
+ }
887
+ toOpenAPI() {
888
+ const baseSchema = this.getSchemaObject();
889
+ return {
890
+ ...baseSchema,
891
+ type: "object",
892
+ propertyNames: this.def.keys.toOpenAPI(),
893
+ additionalProperties: this.def.values.toOpenAPI()
894
+ };
895
+ }
896
+ parseSafe(json) {
897
+ return ParseContext.result((ctx) => {
898
+ if (typeof json !== "object" || json === null || Array.isArray(json)) {
899
+ return ctx.addIssue("Expected object", []);
900
+ }
901
+ const result = {};
902
+ for (const key in json) {
903
+ if (!Object.prototype.hasOwnProperty.call(json, key)) continue;
904
+ const keyParse = this.def.keys.parseSafe(key);
905
+ if (!keyParse.success) {
906
+ return ctx.addIssues(keyParse.issues, [key]);
907
+ }
908
+ const value = json[keyParse.result];
909
+ const valueParse = this.def.values.parseSafe(value);
910
+ if (!valueParse.success) {
911
+ return ctx.addIssues(valueParse.issues, [key]);
912
+ }
913
+ result[keyParse.result] = valueParse.result;
914
+ }
915
+ return result;
916
+ });
917
+ }
918
+ parse(json) {
919
+ const result = this.parseSafe(json);
920
+ if (!result.success) {
921
+ throw new SchemaError(result.issues);
922
+ }
923
+ return result.result;
924
+ }
925
+ visit(visitor) {
926
+ visitor(this.def.keys);
927
+ visitor(this.def.values);
928
+ }
929
+ };
930
+ var KLazy = class _KLazy extends BaseSchema {
931
+ schema;
932
+ static create = (getter) => new _KLazy({ getter });
933
+ getSchema() {
934
+ if (!this.schema) {
935
+ this.schema = this.def.getter();
936
+ }
937
+ return this.schema;
938
+ }
939
+ serialize(value) {
940
+ return this.getSchema().serialize(value);
941
+ }
942
+ toOpenAPI() {
943
+ return this.getSchema().toOpenAPI();
944
+ }
945
+ parseSafe(json) {
946
+ return this.getSchema().parseSafe(json);
947
+ }
948
+ parse(json) {
949
+ return this.getSchema().parse(json);
950
+ }
951
+ visit(visitor) {
952
+ const schema = this.getSchema();
953
+ visitor(schema);
954
+ schema.visit(visitor);
955
+ }
956
+ };
873
957
  var k = {
874
958
  string: KString.create,
875
959
  number: KNumber.create,
@@ -877,10 +961,21 @@ var k = {
877
961
  array: KArray.create,
878
962
  null: KNull.create,
879
963
  ref: KRef.create,
964
+ record: KRecord.create,
880
965
  object: KObject.create,
881
966
  scalar: KScalar.create,
882
967
  literal: KLiteral.create,
883
968
  union: KUnion.create,
969
+ lazy: KLazy.create,
970
+ /**
971
+ * Schema for any valid JSON value
972
+ */
973
+ json: () => {
974
+ const jsonSchema = k.lazy(
975
+ () => k.union([k.string(), k.number(), k.boolean(), k.null(), k.array(jsonSchema), k.record(k.string(), jsonSchema)])
976
+ );
977
+ return jsonSchema;
978
+ },
884
979
  /**
885
980
  * @internal
886
981
  * @experimental
@@ -892,11 +987,13 @@ var k = {
892
987
  BaseSchema,
893
988
  KArray,
894
989
  KBoolean,
990
+ KLazy,
895
991
  KLiteral,
896
992
  KNull,
897
993
  KNumber,
898
994
  KObject,
899
995
  KObjectFromURLSearchParams,
996
+ KRecord,
900
997
  KRef,
901
998
  KScalar,
902
999
  KString,
@@ -53,7 +53,10 @@ declare abstract class BaseSchema<Input extends JSONValue, Output, Def extends B
53
53
  abstract serialize(value: Output): Input;
54
54
  protected readonly def: Def;
55
55
  abstract toOpenAPI(): SchemaObject | ReferenceObject;
56
- protected getSchemaObject(): SchemaObject;
56
+ protected getSchemaObject(): {
57
+ description?: string;
58
+ example?: Input;
59
+ };
57
60
  protected clone(def: Partial<Def>): this;
58
61
  protected constructor(def: Def);
59
62
  or<OtherInput extends JSONValue, OtherOutput, Def extends BaseSchemaDef<OtherInput>>(other: BaseSchema<OtherInput, OtherOutput, Def>): KUnion<(this | BaseSchema<OtherInput, OtherOutput, Def>)["_input"], (this | BaseSchema<OtherInput, OtherOutput, Def>)["_output"]>;
@@ -322,6 +325,31 @@ declare class KLiteral<Value extends string | number | boolean> extends BaseSche
322
325
  parseSafe(json: unknown): ParseResult<Value>;
323
326
  visit(): void;
324
327
  }
328
+ interface RecordDef<KeyInput extends string, KeyOutput extends string, ValueInput extends JSONValue, ValueOutput> extends BaseSchemaDef<Record<KeyInput, ValueInput>> {
329
+ keys: BaseSchema<KeyInput, KeyOutput, BaseSchemaDef<KeyInput>>;
330
+ values: BaseSchema<ValueInput, ValueOutput, BaseSchemaDef<ValueInput>>;
331
+ }
332
+ declare class KRecord<KeyInput extends string, KeyOutput extends string, ValueInput extends JSONValue, ValueOutput> extends BaseSchema<Record<KeyInput, ValueInput>, Record<KeyOutput, ValueOutput>, RecordDef<KeyInput, KeyOutput, ValueInput, ValueOutput>> {
333
+ static create: <KeyInput_1 extends string, KeyOutput_1 extends string, ValueInput_1 extends JSONValue, ValueOutput_1>(keys: BaseSchema<KeyInput_1, KeyOutput_1, BaseSchemaDef<KeyInput_1>>, values: BaseSchema<ValueInput_1, ValueOutput_1, BaseSchemaDef<ValueInput_1>>) => KRecord<KeyInput_1, KeyOutput_1, ValueInput_1, ValueOutput_1>;
334
+ serialize(value: Record<KeyOutput, ValueOutput>): Record<KeyInput, ValueInput>;
335
+ toOpenAPI(): SchemaObject;
336
+ parseSafe(json: unknown): ParseResult<Record<KeyOutput, ValueOutput>>;
337
+ parse(json: unknown): Record<KeyOutput, ValueOutput>;
338
+ visit(visitor: (schema: BaseSchema<any, any, any>) => void): void;
339
+ }
340
+ interface LazyDef<Input extends JSONValue, Output> extends BaseSchemaDef<Input> {
341
+ getter: () => BaseSchema<Input, Output, BaseSchemaDef<Input>>;
342
+ }
343
+ declare class KLazy<Input extends JSONValue, Output> extends BaseSchema<Input, Output, LazyDef<Input, Output>> {
344
+ private schema?;
345
+ static create: <Input_1 extends JSONValue, Output_1>(getter: () => BaseSchema<Input_1, Output_1, BaseSchemaDef<Input_1>>) => KLazy<Input_1, Output_1>;
346
+ private getSchema;
347
+ serialize(value: Output): Input;
348
+ toOpenAPI(): SchemaObject | ReferenceObject;
349
+ parseSafe(json: unknown): ParseResult<Output>;
350
+ parse(json: unknown): Output;
351
+ visit(visitor: (schema: BaseSchema<any, any, any>) => void): void;
352
+ }
325
353
  declare const k: {
326
354
  string: () => KString;
327
355
  number: () => KNumber;
@@ -329,10 +357,16 @@ declare const k: {
329
357
  array: <ItemsInput extends JSONValue, ItemsOutput, Def extends BaseSchemaDef<ItemsInput>>(items: BaseSchema<ItemsInput, ItemsOutput, Def>) => KArray<ItemsInput, ItemsOutput>;
330
358
  null: () => KNull;
331
359
  ref: <Input extends Record<keyof Output, JSONValue>, Output extends Record<keyof Input, any>>(name: string, shape: { [K in keyof Input | keyof Output]: BaseSchema<Input[K], Output[K], BaseSchemaDef<Input[K]>>; }) => KRef<Input, Output>;
360
+ record: <KeyInput extends string, KeyOutput extends string, ValueInput extends JSONValue, ValueOutput>(keys: BaseSchema<KeyInput, KeyOutput, BaseSchemaDef<KeyInput>>, values: BaseSchema<ValueInput, ValueOutput, BaseSchemaDef<ValueInput>>) => KRecord<KeyInput, KeyOutput, ValueInput, ValueOutput>;
332
361
  object: <Input extends Record<keyof Output, any>, Output extends Record<keyof Input, any>>(shape: { [K in keyof Input | keyof Output]: BaseSchema<Input[K], Output[K], BaseSchemaDef<Input[K]>>; }) => KObject<Input, Output>;
333
362
  scalar: <ClientRepresentation extends JSONPrimitive, ServerRepresentation>(options: ScalarOptions<ClientRepresentation, ServerRepresentation>) => KScalar<ClientRepresentation, ServerRepresentation>;
334
363
  literal: <Value extends string | number | boolean>(value: Value) => KLiteral<Value>;
335
364
  union: <Items extends [a: BaseSchema<JSONValue, unknown, BaseSchemaDef<JSONValue>>, b: BaseSchema<JSONValue, unknown, BaseSchemaDef<JSONValue>>, ...remaining: BaseSchema<JSONValue, unknown, BaseSchemaDef<JSONValue>>[]]>(items: Items) => KUnion<Items[number]["_input"], Items[number]["_output"]>;
365
+ lazy: <Input extends JSONValue, Output>(getter: () => BaseSchema<Input, Output, BaseSchemaDef<Input>>) => KLazy<Input, Output>;
366
+ /**
367
+ * Schema for any valid JSON value
368
+ */
369
+ json: () => BaseSchema<JSONValue, JSONValue, BaseSchemaDef<JSONValue>>;
336
370
  /**
337
371
  * @internal
338
372
  * @experimental
@@ -340,4 +374,4 @@ declare const k: {
340
374
  objectFromURLSearchParams: <Input extends Record<keyof Output, JSONValue>, Output extends Record<keyof Input, JSONValue>>(shape: { [K in keyof Input | keyof Output]: BaseSchema<Input[K], Output[K], BaseSchemaDef<Input[K]>>; }) => KObjectFromURLSearchParams<Input, Output>;
341
375
  };
342
376
 
343
- export { type AnySchemaFor, type ArrayChecks, type ArrayDef, BaseSchema, type BaseSchemaDef, type BooleanDef, type Issue, type JSONPrimitive, type JSONValue, KArray, KBoolean, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRef, KScalar, KString, KUnion, type LiteralDef, type NullDef, type NumberChecks, type NumberDef, type NumberFormat, type ObjectDef, ParseContext, type ParseResult, type RefDef, STRING_FORMAT_REGEXES, type ScalarDef, type ScalarOptions, SchemaError, type StringChecks, type StringDef, type StringFormat, type UnionDef, isPrimitiveJSONValue, k };
377
+ export { type AnySchemaFor, type ArrayChecks, type ArrayDef, BaseSchema, type BaseSchemaDef, type BooleanDef, type Issue, type JSONPrimitive, type JSONValue, KArray, KBoolean, KLazy, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRecord, KRef, KScalar, KString, KUnion, type LazyDef, type LiteralDef, type NullDef, type NumberChecks, type NumberDef, type NumberFormat, type ObjectDef, ParseContext, type ParseResult, type RecordDef, type RefDef, STRING_FORMAT_REGEXES, type ScalarDef, type ScalarOptions, SchemaError, type StringChecks, type StringDef, type StringFormat, type UnionDef, isPrimitiveJSONValue, k };
@@ -53,7 +53,10 @@ declare abstract class BaseSchema<Input extends JSONValue, Output, Def extends B
53
53
  abstract serialize(value: Output): Input;
54
54
  protected readonly def: Def;
55
55
  abstract toOpenAPI(): SchemaObject | ReferenceObject;
56
- protected getSchemaObject(): SchemaObject;
56
+ protected getSchemaObject(): {
57
+ description?: string;
58
+ example?: Input;
59
+ };
57
60
  protected clone(def: Partial<Def>): this;
58
61
  protected constructor(def: Def);
59
62
  or<OtherInput extends JSONValue, OtherOutput, Def extends BaseSchemaDef<OtherInput>>(other: BaseSchema<OtherInput, OtherOutput, Def>): KUnion<(this | BaseSchema<OtherInput, OtherOutput, Def>)["_input"], (this | BaseSchema<OtherInput, OtherOutput, Def>)["_output"]>;
@@ -322,6 +325,31 @@ declare class KLiteral<Value extends string | number | boolean> extends BaseSche
322
325
  parseSafe(json: unknown): ParseResult<Value>;
323
326
  visit(): void;
324
327
  }
328
+ interface RecordDef<KeyInput extends string, KeyOutput extends string, ValueInput extends JSONValue, ValueOutput> extends BaseSchemaDef<Record<KeyInput, ValueInput>> {
329
+ keys: BaseSchema<KeyInput, KeyOutput, BaseSchemaDef<KeyInput>>;
330
+ values: BaseSchema<ValueInput, ValueOutput, BaseSchemaDef<ValueInput>>;
331
+ }
332
+ declare class KRecord<KeyInput extends string, KeyOutput extends string, ValueInput extends JSONValue, ValueOutput> extends BaseSchema<Record<KeyInput, ValueInput>, Record<KeyOutput, ValueOutput>, RecordDef<KeyInput, KeyOutput, ValueInput, ValueOutput>> {
333
+ static create: <KeyInput_1 extends string, KeyOutput_1 extends string, ValueInput_1 extends JSONValue, ValueOutput_1>(keys: BaseSchema<KeyInput_1, KeyOutput_1, BaseSchemaDef<KeyInput_1>>, values: BaseSchema<ValueInput_1, ValueOutput_1, BaseSchemaDef<ValueInput_1>>) => KRecord<KeyInput_1, KeyOutput_1, ValueInput_1, ValueOutput_1>;
334
+ serialize(value: Record<KeyOutput, ValueOutput>): Record<KeyInput, ValueInput>;
335
+ toOpenAPI(): SchemaObject;
336
+ parseSafe(json: unknown): ParseResult<Record<KeyOutput, ValueOutput>>;
337
+ parse(json: unknown): Record<KeyOutput, ValueOutput>;
338
+ visit(visitor: (schema: BaseSchema<any, any, any>) => void): void;
339
+ }
340
+ interface LazyDef<Input extends JSONValue, Output> extends BaseSchemaDef<Input> {
341
+ getter: () => BaseSchema<Input, Output, BaseSchemaDef<Input>>;
342
+ }
343
+ declare class KLazy<Input extends JSONValue, Output> extends BaseSchema<Input, Output, LazyDef<Input, Output>> {
344
+ private schema?;
345
+ static create: <Input_1 extends JSONValue, Output_1>(getter: () => BaseSchema<Input_1, Output_1, BaseSchemaDef<Input_1>>) => KLazy<Input_1, Output_1>;
346
+ private getSchema;
347
+ serialize(value: Output): Input;
348
+ toOpenAPI(): SchemaObject | ReferenceObject;
349
+ parseSafe(json: unknown): ParseResult<Output>;
350
+ parse(json: unknown): Output;
351
+ visit(visitor: (schema: BaseSchema<any, any, any>) => void): void;
352
+ }
325
353
  declare const k: {
326
354
  string: () => KString;
327
355
  number: () => KNumber;
@@ -329,10 +357,16 @@ declare const k: {
329
357
  array: <ItemsInput extends JSONValue, ItemsOutput, Def extends BaseSchemaDef<ItemsInput>>(items: BaseSchema<ItemsInput, ItemsOutput, Def>) => KArray<ItemsInput, ItemsOutput>;
330
358
  null: () => KNull;
331
359
  ref: <Input extends Record<keyof Output, JSONValue>, Output extends Record<keyof Input, any>>(name: string, shape: { [K in keyof Input | keyof Output]: BaseSchema<Input[K], Output[K], BaseSchemaDef<Input[K]>>; }) => KRef<Input, Output>;
360
+ record: <KeyInput extends string, KeyOutput extends string, ValueInput extends JSONValue, ValueOutput>(keys: BaseSchema<KeyInput, KeyOutput, BaseSchemaDef<KeyInput>>, values: BaseSchema<ValueInput, ValueOutput, BaseSchemaDef<ValueInput>>) => KRecord<KeyInput, KeyOutput, ValueInput, ValueOutput>;
332
361
  object: <Input extends Record<keyof Output, any>, Output extends Record<keyof Input, any>>(shape: { [K in keyof Input | keyof Output]: BaseSchema<Input[K], Output[K], BaseSchemaDef<Input[K]>>; }) => KObject<Input, Output>;
333
362
  scalar: <ClientRepresentation extends JSONPrimitive, ServerRepresentation>(options: ScalarOptions<ClientRepresentation, ServerRepresentation>) => KScalar<ClientRepresentation, ServerRepresentation>;
334
363
  literal: <Value extends string | number | boolean>(value: Value) => KLiteral<Value>;
335
364
  union: <Items extends [a: BaseSchema<JSONValue, unknown, BaseSchemaDef<JSONValue>>, b: BaseSchema<JSONValue, unknown, BaseSchemaDef<JSONValue>>, ...remaining: BaseSchema<JSONValue, unknown, BaseSchemaDef<JSONValue>>[]]>(items: Items) => KUnion<Items[number]["_input"], Items[number]["_output"]>;
365
+ lazy: <Input extends JSONValue, Output>(getter: () => BaseSchema<Input, Output, BaseSchemaDef<Input>>) => KLazy<Input, Output>;
366
+ /**
367
+ * Schema for any valid JSON value
368
+ */
369
+ json: () => BaseSchema<JSONValue, JSONValue, BaseSchemaDef<JSONValue>>;
336
370
  /**
337
371
  * @internal
338
372
  * @experimental
@@ -340,4 +374,4 @@ declare const k: {
340
374
  objectFromURLSearchParams: <Input extends Record<keyof Output, JSONValue>, Output extends Record<keyof Input, JSONValue>>(shape: { [K in keyof Input | keyof Output]: BaseSchema<Input[K], Output[K], BaseSchemaDef<Input[K]>>; }) => KObjectFromURLSearchParams<Input, Output>;
341
375
  };
342
376
 
343
- export { type AnySchemaFor, type ArrayChecks, type ArrayDef, BaseSchema, type BaseSchemaDef, type BooleanDef, type Issue, type JSONPrimitive, type JSONValue, KArray, KBoolean, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRef, KScalar, KString, KUnion, type LiteralDef, type NullDef, type NumberChecks, type NumberDef, type NumberFormat, type ObjectDef, ParseContext, type ParseResult, type RefDef, STRING_FORMAT_REGEXES, type ScalarDef, type ScalarOptions, SchemaError, type StringChecks, type StringDef, type StringFormat, type UnionDef, isPrimitiveJSONValue, k };
377
+ export { type AnySchemaFor, type ArrayChecks, type ArrayDef, BaseSchema, type BaseSchemaDef, type BooleanDef, type Issue, type JSONPrimitive, type JSONValue, KArray, KBoolean, KLazy, KLiteral, KNull, KNumber, KObject, KObjectFromURLSearchParams, KRecord, KRef, KScalar, KString, KUnion, type LazyDef, type LiteralDef, type NullDef, type NumberChecks, type NumberDef, type NumberFormat, type ObjectDef, ParseContext, type ParseResult, type RecordDef, type RefDef, STRING_FORMAT_REGEXES, type ScalarDef, type ScalarOptions, SchemaError, type StringChecks, type StringDef, type StringFormat, type UnionDef, isPrimitiveJSONValue, k };
@@ -2,11 +2,13 @@ import {
2
2
  BaseSchema,
3
3
  KArray,
4
4
  KBoolean,
5
+ KLazy,
5
6
  KLiteral,
6
7
  KNull,
7
8
  KNumber,
8
9
  KObject,
9
10
  KObjectFromURLSearchParams,
11
+ KRecord,
10
12
  KRef,
11
13
  KScalar,
12
14
  KString,
@@ -16,16 +18,18 @@ import {
16
18
  SchemaError,
17
19
  isPrimitiveJSONValue,
18
20
  k
19
- } from "../chunk-IEGYJT4R.js";
21
+ } from "../chunk-BJVNFSCY.js";
20
22
  export {
21
23
  BaseSchema,
22
24
  KArray,
23
25
  KBoolean,
26
+ KLazy,
24
27
  KLiteral,
25
28
  KNull,
26
29
  KNumber,
27
30
  KObject,
28
31
  KObjectFromURLSearchParams,
32
+ KRecord,
29
33
  KRef,
30
34
  KScalar,
31
35
  KString,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaito-http/core",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.25",
4
+ "version": "4.0.0-beta.26",
5
5
  "author": "Alistair Smith <hi@alistair.sh>",
6
6
  "repository": "https://github.com/kaito-http/kaito",
7
7
  "dependencies": {