structured-outputs 0.1.0-beta.20 → 0.1.0-beta.22
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +46 -40
- package/esm/ResponseFormat.d.ts +21 -0
- package/esm/ResponseFormat.d.ts.map +1 -0
- package/esm/ResponseFormat.js +43 -19
- package/esm/ResponseFormat.js.map +1 -1
- package/{types → esm}/Tool.d.ts +1 -0
- package/esm/Tool.d.ts.map +1 -0
- package/esm/Tool.js +1 -0
- package/esm/Tool.js.map +1 -1
- package/esm/oai.d.ts +5 -0
- package/esm/oai.d.ts.map +1 -0
- package/esm/oai.js +2 -0
- package/esm/oai.js.map +1 -0
- package/esm/types/Ref.d.ts.map +1 -0
- package/esm/types/Ref.js +6 -3
- package/esm/types/Ref.js.map +1 -1
- package/esm/types/RootTy.d.ts +8 -0
- package/esm/types/RootTy.d.ts.map +1 -0
- package/esm/types/RootTy.js +5 -7
- package/esm/types/RootTy.js.map +1 -1
- package/esm/types/Ty.d.ts +23 -0
- package/esm/types/Ty.d.ts.map +1 -0
- package/esm/types/Ty.js +5 -9
- package/esm/types/Ty.js.map +1 -1
- package/{types → esm}/types/array.d.ts +1 -1
- package/{types → esm}/types/array.d.ts.map +1 -1
- package/esm/types/array.js +1 -2
- package/esm/types/array.js.map +1 -1
- package/{types → esm}/types/constant.d.ts.map +1 -1
- package/esm/types/constant.js +1 -2
- package/esm/types/constant.js.map +1 -1
- package/{types → esm}/types/constantUnion.d.ts.map +1 -1
- package/esm/types/constantUnion.js +16 -19
- package/esm/types/constantUnion.js.map +1 -1
- package/{types → esm}/types/mod.d.ts +3 -3
- package/esm/types/mod.d.ts.map +1 -0
- package/esm/types/mod.js +3 -3
- package/esm/types/mod.js.map +1 -1
- package/{types → esm}/types/object.d.ts +2 -2
- package/{types → esm}/types/object.d.ts.map +1 -1
- package/esm/types/object.js +1 -2
- package/esm/types/object.js.map +1 -1
- package/{types/types/leaves.d.ts → esm/types/primitives.d.ts} +1 -1
- package/esm/types/primitives.d.ts.map +1 -0
- package/esm/types/primitives.js +14 -0
- package/esm/types/primitives.js.map +1 -0
- package/esm/types/std/Option.js +1 -1
- package/esm/types/std/Option.js.map +1 -1
- package/{types → esm}/types/std/Wrapper.d.ts +0 -1
- package/esm/types/std/Wrapper.d.ts.map +1 -0
- package/esm/types/std/Wrapper.js.map +1 -1
- package/{types → esm}/types/taggedUnion.d.ts +2 -2
- package/{types → esm}/types/taggedUnion.d.ts.map +1 -1
- package/esm/types/taggedUnion.js +1 -2
- package/esm/types/taggedUnion.js.map +1 -1
- package/package.json +6 -11
- package/src/ResponseFormat.ts +48 -41
- package/src/Tool.ts +1 -0
- package/src/oai.ts +5 -0
- package/src/types/Ref.ts +7 -4
- package/src/types/RootTy.ts +11 -13
- package/src/types/Ty.ts +23 -30
- package/src/types/array.ts +2 -3
- package/src/types/constant.ts +1 -2
- package/src/types/constantUnion.ts +16 -19
- package/src/types/mod.ts +3 -3
- package/src/types/object.ts +4 -6
- package/src/types/primitives.ts +17 -0
- package/src/types/std/Option.ts +1 -1
- package/src/types/std/Wrapper.ts +0 -2
- package/src/types/taggedUnion.ts +3 -4
- package/esm/_dnt.shims.js +0 -58
- package/esm/_dnt.shims.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/almost_equals.js +0 -47
- package/esm/deps/jsr.io/@std/assert/1.0.8/almost_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/array_includes.js +0 -47
- package/esm/deps/jsr.io/@std/assert/1.0.8/array_includes.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/assert.js +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.8/assert.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/assertion_error.js +0 -31
- package/esm/deps/jsr.io/@std/assert/1.0.8/assertion_error.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/equal.js +0 -184
- package/esm/deps/jsr.io/@std/assert/1.0.8/equal.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/equals.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.8/equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/exists.js +0 -28
- package/esm/deps/jsr.io/@std/assert/1.0.8/exists.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/fail.js +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.8/fail.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/false.js +0 -23
- package/esm/deps/jsr.io/@std/assert/1.0.8/false.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/instance_of.js +0 -53
- package/esm/deps/jsr.io/@std/assert/1.0.8/instance_of.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/is_error.js +0 -54
- package/esm/deps/jsr.io/@std/assert/1.0.8/is_error.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/less.js +0 -29
- package/esm/deps/jsr.io/@std/assert/1.0.8/less.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/less_or_equal.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/less_or_equal.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/match.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.8/match.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/mod.js +0 -46
- package/esm/deps/jsr.io/@std/assert/1.0.8/mod.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_equals.js +0 -33
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_instance_of.js +0 -30
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_instance_of.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_match.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_match.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.js +0 -33
- package/esm/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/object_match.js +0 -160
- package/esm/deps/jsr.io/@std/assert/1.0.8/object_match.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/rejects.js +0 -54
- package/esm/deps/jsr.io/@std/assert/1.0.8/rejects.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/strict_equals.js +0 -58
- package/esm/deps/jsr.io/@std/assert/1.0.8/strict_equals.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/string_includes.js +0 -27
- package/esm/deps/jsr.io/@std/assert/1.0.8/string_includes.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/throws.js +0 -45
- package/esm/deps/jsr.io/@std/assert/1.0.8/throws.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/unimplemented.js +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.8/unimplemented.js.map +0 -1
- package/esm/deps/jsr.io/@std/assert/1.0.8/unreachable.js +0 -21
- package/esm/deps/jsr.io/@std/assert/1.0.8/unreachable.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js +0 -111
- package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js +0 -277
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js +0 -180
- package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.js +0 -38
- package/esm/deps/jsr.io/@std/internal/1.0.5/format.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js +0 -208
- package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.js +0 -3
- package/esm/deps/jsr.io/@std/internal/1.0.5/types.js.map +0 -1
- package/esm/types/leaves.js +0 -18
- package/esm/types/leaves.js.map +0 -1
- package/src/_dnt.shims.ts +0 -60
- package/src/deps/jsr.io/@std/assert/1.0.8/almost_equals.ts +0 -55
- package/src/deps/jsr.io/@std/assert/1.0.8/array_includes.ts +0 -57
- package/src/deps/jsr.io/@std/assert/1.0.8/assert.ts +0 -23
- package/src/deps/jsr.io/@std/assert/1.0.8/assertion_error.ts +0 -31
- package/src/deps/jsr.io/@std/assert/1.0.8/equal.ts +0 -210
- package/src/deps/jsr.io/@std/assert/1.0.8/equals.ts +0 -52
- package/src/deps/jsr.io/@std/assert/1.0.8/exists.ts +0 -31
- package/src/deps/jsr.io/@std/assert/1.0.8/fail.ts +0 -21
- package/src/deps/jsr.io/@std/assert/1.0.8/false.ts +0 -26
- package/src/deps/jsr.io/@std/assert/1.0.8/greater.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.ts +0 -36
- package/src/deps/jsr.io/@std/assert/1.0.8/instance_of.ts +0 -64
- package/src/deps/jsr.io/@std/assert/1.0.8/is_error.ts +0 -65
- package/src/deps/jsr.io/@std/assert/1.0.8/less.ts +0 -29
- package/src/deps/jsr.io/@std/assert/1.0.8/less_or_equal.ts +0 -36
- package/src/deps/jsr.io/@std/assert/1.0.8/match.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/mod.ts +0 -47
- package/src/deps/jsr.io/@std/assert/1.0.8/not_equals.ts +0 -36
- package/src/deps/jsr.io/@std/assert/1.0.8/not_instance_of.ts +0 -33
- package/src/deps/jsr.io/@std/assert/1.0.8/not_match.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.ts +0 -42
- package/src/deps/jsr.io/@std/assert/1.0.8/object_match.ts +0 -202
- package/src/deps/jsr.io/@std/assert/1.0.8/rejects.ts +0 -123
- package/src/deps/jsr.io/@std/assert/1.0.8/strict_equals.ts +0 -67
- package/src/deps/jsr.io/@std/assert/1.0.8/string_includes.ts +0 -30
- package/src/deps/jsr.io/@std/assert/1.0.8/throws.ts +0 -111
- package/src/deps/jsr.io/@std/assert/1.0.8/unimplemented.ts +0 -21
- package/src/deps/jsr.io/@std/assert/1.0.8/unreachable.ts +0 -21
- package/src/deps/jsr.io/@std/internal/1.0.5/build_message.ts +0 -134
- package/src/deps/jsr.io/@std/internal/1.0.5/diff.ts +0 -317
- package/src/deps/jsr.io/@std/internal/1.0.5/diff_str.ts +0 -204
- package/src/deps/jsr.io/@std/internal/1.0.5/format.ts +0 -39
- package/src/deps/jsr.io/@std/internal/1.0.5/styles.ts +0 -233
- package/src/deps/jsr.io/@std/internal/1.0.5/types.ts +0 -18
- package/src/types/leaves.ts +0 -21
- package/types/ResponseFormat.d.ts +0 -26
- package/types/ResponseFormat.d.ts.map +0 -1
- package/types/Tool.d.ts.map +0 -1
- package/types/_dnt.shims.d.ts +0 -2
- package/types/_dnt.shims.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/almost_equals.d.ts +0 -29
- package/types/deps/jsr.io/@std/assert/1.0.8/almost_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/array_includes.d.ts +0 -24
- package/types/deps/jsr.io/@std/assert/1.0.8/array_includes.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/assert.d.ts +0 -16
- package/types/deps/jsr.io/@std/assert/1.0.8/assert.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/assertion_error.d.ts +0 -26
- package/types/deps/jsr.io/@std/assert/1.0.8/assertion_error.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/equal.d.ts +0 -17
- package/types/deps/jsr.io/@std/assert/1.0.8/equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/equals.d.ts +0 -22
- package/types/deps/jsr.io/@std/assert/1.0.8/equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/exists.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/exists.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/fail.d.ts +0 -15
- package/types/deps/jsr.io/@std/assert/1.0.8/fail.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/false.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/false.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/greater.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/greater.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/greater_or_equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/instance_of.d.ts +0 -23
- package/types/deps/jsr.io/@std/assert/1.0.8/instance_of.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/is_error.d.ts +0 -25
- package/types/deps/jsr.io/@std/assert/1.0.8/is_error.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/less.d.ts +0 -19
- package/types/deps/jsr.io/@std/assert/1.0.8/less.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/less_or_equal.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/less_or_equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/match.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/match.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/mod.d.ts +0 -44
- package/types/deps/jsr.io/@std/assert/1.0.8/mod.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_equals.d.ts +0 -21
- package/types/deps/jsr.io/@std/assert/1.0.8/not_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_instance_of.d.ts +0 -20
- package/types/deps/jsr.io/@std/assert/1.0.8/not_instance_of.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_match.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/not_match.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.d.ts +0 -23
- package/types/deps/jsr.io/@std/assert/1.0.8/not_strict_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/object_match.d.ts +0 -28
- package/types/deps/jsr.io/@std/assert/1.0.8/object_match.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/rejects.d.ts +0 -42
- package/types/deps/jsr.io/@std/assert/1.0.8/rejects.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/strict_equals.d.ts +0 -24
- package/types/deps/jsr.io/@std/assert/1.0.8/strict_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/string_includes.d.ts +0 -18
- package/types/deps/jsr.io/@std/assert/1.0.8/string_includes.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/throws.d.ts +0 -45
- package/types/deps/jsr.io/@std/assert/1.0.8/throws.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/unimplemented.d.ts +0 -15
- package/types/deps/jsr.io/@std/assert/1.0.8/unimplemented.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/assert/1.0.8/unreachable.d.ts +0 -15
- package/types/deps/jsr.io/@std/assert/1.0.8/unreachable.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +0 -82
- package/types/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +0 -140
- package/types/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +0 -99
- package/types/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/format.d.ts +0 -2
- package/types/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +0 -159
- package/types/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/internal/1.0.5/types.d.ts +0 -16
- package/types/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +0 -1
- package/types/types/Ref.d.ts.map +0 -1
- package/types/types/RootTy.d.ts +0 -8
- package/types/types/RootTy.d.ts.map +0 -1
- package/types/types/Ty.d.ts +0 -27
- package/types/types/Ty.d.ts.map +0 -1
- package/types/types/leaves.d.ts.map +0 -1
- package/types/types/mod.d.ts.map +0 -1
- package/types/types/std/Wrapper.d.ts.map +0 -1
- /package/{types → esm}/_dnt.polyfills.d.ts +0 -0
- /package/{types → esm}/_dnt.polyfills.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/_utils.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/aggregate_groups.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/associate_with.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/chunk.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/deep_merge.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/distinct_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_last_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/drop_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_entries.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_keys.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/filter_values.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/find_single.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/first_not_nullish_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/includes_value.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/intersect.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/invert_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/join_to_string.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_entries.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_keys.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_not_nullish.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/map_values.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/max_with.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/min_with.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/mod.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/mod.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/omit.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/omit.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/partition_entries.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/permutations.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/pick.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/pick.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/reduce_groups.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/running_reduce.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sample.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sample.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sliding_windows.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sort_by.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/sum_of.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_last_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/take_while.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/union.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/union.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/unzip.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/without_all.d.ts.map +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/zip.d.ts +0 -0
- /package/{types → esm}/deps/jsr.io/@std/collections/1.0.9/zip.d.ts.map +0 -0
- /package/{types → esm}/mod.d.ts +0 -0
- /package/{types → esm}/mod.d.ts.map +0 -0
- /package/{types → esm}/types/Ref.d.ts +0 -0
- /package/{types → esm}/types/constant.d.ts +0 -0
- /package/{types → esm}/types/constantUnion.d.ts +0 -0
- /package/{types → esm}/types/std/Option.d.ts +0 -0
- /package/{types → esm}/types/std/Option.d.ts.map +0 -0
- /package/{types → esm}/types/std/mod.d.ts +0 -0
- /package/{types → esm}/types/std/mod.d.ts.map +0 -0
- /package/{types → esm}/util/phantoms.d.ts +0 -0
- /package/{types → esm}/util/phantoms.d.ts.map +0 -0
- /package/{types → esm}/util/recombineTaggedTemplateArgs.d.ts +0 -0
- /package/{types → esm}/util/recombineTaggedTemplateArgs.d.ts.map +0 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
import { Ty } from "./Ty.js";
|
2
|
+
export const none = Ty(() => ({
|
3
|
+
type: "null",
|
4
|
+
}));
|
5
|
+
export const boolean = Ty(() => ({
|
6
|
+
type: "boolean",
|
7
|
+
}));
|
8
|
+
export const number = Ty(() => ({
|
9
|
+
type: "number",
|
10
|
+
}));
|
11
|
+
export const string = Ty(() => ({
|
12
|
+
type: "string",
|
13
|
+
}));
|
14
|
+
//# sourceMappingURL=primitives.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"primitives.js","sourceRoot":"","sources":["../../src/types/primitives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,MAAM,CAAC,MAAM,IAAI,GAAoB,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IAC7C,IAAI,EAAE,MAAM;CACb,CAAC,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,OAAO,GAAuB,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,IAAI,EAAE,SAAS;CAChB,CAAC,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,MAAM,GAAsB,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,IAAI,EAAE,QAAQ;CACf,CAAC,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,MAAM,GAAsB,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;IACjD,IAAI,EAAE,QAAQ;CACf,CAAC,CAAC,CAAA"}
|
package/esm/types/std/Option.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../src/types/std/Option.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"Option.js","sourceRoot":"","sources":["../../../src/types/std/Option.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAG/C,MAAM,UAAU,MAAM,CAAe,IAAO;IAM1C,OAAO,WAAW,CAAC;QACjB,IAAI;QACJ,IAAI,EAAE,IAAI;KACX,CAAC,CAAA,uCAAuC,CAAA;AAC3C,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"Wrapper.d.ts","sourceRoot":"","sources":["../../../src/types/std/Wrapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,wBAAgB,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC,CAEvF"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Wrapper.js","sourceRoot":"","sources":["../../../src/types/std/Wrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
1
|
+
{"version":3,"file":"Wrapper.js","sourceRoot":"","sources":["../../../src/types/std/Wrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,MAAM,UAAU,OAAO,CAAe,KAAQ;IAC5C,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAC1B,CAAC"}
|
@@ -2,7 +2,7 @@ import { Ty } from "./Ty.js";
|
|
2
2
|
export declare function taggedUnion<M extends Record<string, Ty>>(members: M): Ty<{
|
3
3
|
[K in keyof M]: {
|
4
4
|
type: K;
|
5
|
-
value: M[K][
|
5
|
+
value: M[K]["T"];
|
6
6
|
};
|
7
|
-
}[keyof M], M[keyof M][
|
7
|
+
}[keyof M], M[keyof M]["P"]>;
|
8
8
|
//# sourceMappingURL=taggedUnion.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"taggedUnion.d.ts","sourceRoot":"","sources":["../../src/types/taggedUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CACvE;KACG,CAAC,IAAI,MAAM,CAAC,GAAG;QACd,IAAI,EAAE,CAAC,CAAA;QACP,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,
|
1
|
+
{"version":3,"file":"taggedUnion.d.ts","sourceRoot":"","sources":["../../src/types/taggedUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CACvE;KACG,CAAC,IAAI,MAAM,CAAC,GAAG;QACd,IAAI,EAAE,CAAC,CAAA;QACP,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;KACjB;CACF,CAAC,MAAM,CAAC,CAAC,EACV,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAChB,CAgBA"}
|
package/esm/types/taggedUnion.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"taggedUnion.js","sourceRoot":"","sources":["../../src/types/taggedUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,MAAM,UAAU,WAAW,CAA+B,OAAU;IASlE,OAAO,EAAE,CAAC,CAAC,
|
1
|
+
{"version":3,"file":"taggedUnion.js","sourceRoot":"","sources":["../../src/types/taggedUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,MAAM,UAAU,WAAW,CAA+B,OAAU;IASlE,OAAO,EAAE,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAClB,aAAa,EAAE,MAAM;QACrB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9C,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,CAAC;iBACT;gBACD,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;aACd;YACD,QAAQ,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;YAC3B,oBAAoB,EAAE,KAAK;SAC5B,CAAC,CAAC;KACJ,CAAC,CAAC,CAAA;AACL,CAAC"}
|
package/package.json
CHANGED
@@ -1,23 +1,18 @@
|
|
1
1
|
{
|
2
2
|
"name": "structured-outputs",
|
3
|
-
"version": "0.1.0-beta.
|
4
|
-
"description": "
|
3
|
+
"version": "0.1.0-beta.22",
|
4
|
+
"description": "A library for working with OpenAI's structured outputs.",
|
5
5
|
"repository": "github:harrysolovay/structured-outputs.git",
|
6
6
|
"license": "Apache-2.0",
|
7
7
|
"main": "./esm/mod.js",
|
8
8
|
"module": "./esm/mod.js",
|
9
|
-
"types": "./types/mod.d.ts",
|
10
9
|
"exports": {
|
11
10
|
".": {
|
12
|
-
"import":
|
13
|
-
"types": "./types/mod.d.ts",
|
14
|
-
"default": "./esm/mod.js"
|
15
|
-
}
|
11
|
+
"import": "./esm/mod.js"
|
16
12
|
}
|
17
13
|
},
|
18
|
-
"
|
19
|
-
|
14
|
+
"_generatedBy": "dnt@dev",
|
15
|
+
"peerDependencies": {
|
20
16
|
"openai": "^4.68.1"
|
21
|
-
}
|
22
|
-
"_generatedBy": "dnt@dev"
|
17
|
+
}
|
23
18
|
}
|
package/src/ResponseFormat.ts
CHANGED
@@ -1,9 +1,18 @@
|
|
1
|
-
import {
|
2
|
-
import type Openai from "openai"
|
3
|
-
import type { ResponseFormatJSONSchema } from "openai/resources/index.js"
|
1
|
+
import type { ChatCompletion, ChatCompletionChoice, JsonSchema } from "./oai.js"
|
4
2
|
import type { RootTy } from "./types/mod.js"
|
5
3
|
import { recombineTaggedTemplateArgs } from "./util/recombineTaggedTemplateArgs.js"
|
6
4
|
|
5
|
+
export interface ResponseFormat<T> {
|
6
|
+
(template: TemplateStringsArray, ...quasis: Array<string>): ResponseFormat<T>
|
7
|
+
type: "json_schema"
|
8
|
+
/** The desired return type in JSON Schema. */
|
9
|
+
json_schema: JsonSchema
|
10
|
+
/** Parse the content of the first choice into a typed object. */
|
11
|
+
parseFirstChoice(completion: ChatCompletion): T
|
12
|
+
/** Parse all choice contents into an array of typed object. */
|
13
|
+
parseChoices(completion: ChatCompletion): Array<T>
|
14
|
+
}
|
15
|
+
|
7
16
|
export function ResponseFormat<T>(name: string, ty: RootTy<T, never>): ResponseFormat<T> {
|
8
17
|
return ResponseFormat_(name, ty)
|
9
18
|
}
|
@@ -28,25 +37,11 @@ function ResponseFormat_<T>(
|
|
28
37
|
schema: ty.schema(),
|
29
38
|
strict: true,
|
30
39
|
},
|
31
|
-
|
32
|
-
return
|
33
|
-
...completion,
|
34
|
-
choices: completion.choices.map((choice) => ({
|
35
|
-
...choice,
|
36
|
-
message: {
|
37
|
-
...choice.message,
|
38
|
-
content: choice.message.content ? JSON.parse(choice.message.content) : null,
|
39
|
-
},
|
40
|
-
})),
|
41
|
-
}
|
40
|
+
parseFirstChoice: (completion: ChatCompletion): T => {
|
41
|
+
return JSON.parse(ResponseFormat.unwrapFirstChoice(completion))
|
42
42
|
},
|
43
|
-
|
44
|
-
|
45
|
-
assert(firstChoice)
|
46
|
-
const { finish_reason, message } = firstChoice
|
47
|
-
const { content, refusal } = message
|
48
|
-
assert(content, JSON.stringify({ finish_reason, refusal, usage }))
|
49
|
-
return JSON.parse(content)
|
43
|
+
parseChoices: (completion: ChatCompletion): Array<T> => {
|
44
|
+
return ResponseFormat.unwrapChoices(completion).map((content) => JSON.parse(content))
|
50
45
|
},
|
51
46
|
toJSON() {
|
52
47
|
const { type, json_schema } = this
|
@@ -56,27 +51,39 @@ function ResponseFormat_<T>(
|
|
56
51
|
)
|
57
52
|
}
|
58
53
|
|
59
|
-
export
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
parseFirstOrThrow(completion: ChatCompletion): T
|
68
|
-
}
|
54
|
+
export namespace ResponseFormat {
|
55
|
+
export function unwrapFirstChoice(completion: ChatCompletion): string {
|
56
|
+
const { choices: [firstChoice] } = completion
|
57
|
+
if (!firstChoice) {
|
58
|
+
throw new ResponseFormatUnwrapError("No choices contained within the completion response.")
|
59
|
+
}
|
60
|
+
return unwrapChoice(firstChoice)
|
61
|
+
}
|
69
62
|
|
70
|
-
export
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
63
|
+
export function unwrapChoices(completions: ChatCompletion): string[] {
|
64
|
+
return completions.choices.map(unwrapChoice)
|
65
|
+
}
|
66
|
+
|
67
|
+
function unwrapChoice(choice: ChatCompletionChoice) {
|
68
|
+
const { finish_reason, message } = choice
|
69
|
+
if (finish_reason !== "stop") {
|
70
|
+
throw new ResponseFormatUnwrapError(
|
71
|
+
`Completion responded with "${finish_reason}" as finish reason; ${message}`,
|
72
|
+
)
|
73
|
+
}
|
74
|
+
const { content, refusal } = message
|
75
|
+
if (refusal) {
|
76
|
+
throw new ResponseFormatUnwrapError(
|
77
|
+
`Openai refused to fulfill completion request; ${refusal}`,
|
78
|
+
)
|
76
79
|
}
|
77
|
-
|
80
|
+
if (!content) {
|
81
|
+
throw new ResponseFormatUnwrapError("First response choice contained no content.")
|
82
|
+
}
|
83
|
+
return content
|
84
|
+
}
|
78
85
|
}
|
79
86
|
|
80
|
-
|
81
|
-
|
82
|
-
|
87
|
+
export class ResponseFormatUnwrapError extends Error {
|
88
|
+
override readonly name = "UnwrapResponseError"
|
89
|
+
}
|
package/src/Tool.ts
CHANGED
package/src/oai.ts
ADDED
package/src/types/Ref.ts
CHANGED
@@ -1,16 +1,19 @@
|
|
1
|
-
import type { Applied, Schema, Ty } from "./Ty.js"
|
2
1
|
import { recombineTaggedTemplateArgs } from "../util/recombineTaggedTemplateArgs.js"
|
2
|
+
import type { Applied, Schema, Ty } from "./Ty.js"
|
3
3
|
|
4
4
|
export type Ref = (ty: Ty) => Schema
|
5
5
|
|
6
6
|
export function Ref(applied: Applied): Ref {
|
7
7
|
return (ty) => {
|
8
|
-
applied = { ...applied, ...ty.applied }
|
9
|
-
const description = ty.
|
8
|
+
applied = { ...applied, ...ty[""].applied }
|
9
|
+
const description = ty[""].context
|
10
10
|
.map(({ template, placeheld }) =>
|
11
11
|
recombineTaggedTemplateArgs(template, placeheld.map((k) => applied[k]!))
|
12
12
|
)
|
13
13
|
.join(" ")
|
14
|
-
return
|
14
|
+
return {
|
15
|
+
...ty[""].toSchema(Ref(applied)),
|
16
|
+
...description ? { description } : {},
|
17
|
+
}
|
15
18
|
}
|
16
19
|
}
|
package/src/types/RootTy.ts
CHANGED
@@ -1,22 +1,20 @@
|
|
1
1
|
import { phantoms } from "../util/phantoms.js"
|
2
2
|
import { Ref } from "./Ref.js"
|
3
|
-
import type { Applied,
|
3
|
+
import type { Applied, Context, Schema, ToSchema, Ty } from "./Ty.js"
|
4
4
|
|
5
|
-
export function RootTy<T, P extends
|
5
|
+
export function RootTy<T, P extends keyof any = never>(
|
6
6
|
toSchema: ToSchema,
|
7
|
-
|
7
|
+
context: Array<Context> = [],
|
8
8
|
applied: Applied = {},
|
9
9
|
): RootTy<T, P> {
|
10
10
|
return Object.assign(
|
11
11
|
<P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
|
12
|
-
RootTy<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...
|
13
|
-
phantoms<{
|
12
|
+
RootTy<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...context], applied),
|
13
|
+
phantoms<{ T: T; P: P }>(),
|
14
14
|
{
|
15
|
-
toSchema,
|
16
|
-
|
17
|
-
|
18
|
-
apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
19
|
-
return RootTy<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
|
15
|
+
"": { toSchema, context, applied },
|
16
|
+
fill: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
17
|
+
return RootTy<T, Exclude<P, keyof A>>(toSchema, context, { ...applied, ...values })
|
20
18
|
},
|
21
19
|
schema(this: RootTy<T, never>) {
|
22
20
|
return Ref({})(this)
|
@@ -28,12 +26,12 @@ export function RootTy<T, P extends string = never>(
|
|
28
26
|
)
|
29
27
|
}
|
30
28
|
|
31
|
-
export interface RootTy<T = any, P extends
|
32
|
-
<P2 extends Array<
|
29
|
+
export interface RootTy<T = any, P extends keyof any = keyof any> extends Ty<T, P> {
|
30
|
+
<P2 extends Array<keyof any>>(
|
33
31
|
template: TemplateStringsArray,
|
34
32
|
...placeheld: P2
|
35
33
|
): RootTy<T, P | P2[number]>
|
36
|
-
|
34
|
+
fill: <A extends Partial<Record<P, number | string>>>(
|
37
35
|
values: A,
|
38
36
|
) => RootTy<T, Exclude<P, keyof A>>
|
39
37
|
schema(this: RootTy<T, never>): Schema
|
package/src/types/Ty.ts
CHANGED
@@ -1,22 +1,20 @@
|
|
1
|
-
import type { Ref } from "./Ref.js"
|
2
1
|
import { phantoms } from "../util/phantoms.js"
|
2
|
+
import type { Ref } from "./Ref.js"
|
3
3
|
import type { RootTy } from "./RootTy.js"
|
4
4
|
|
5
|
-
export function Ty<T, P extends
|
5
|
+
export function Ty<T, P extends keyof any = never>(
|
6
6
|
toSchema: ToSchema,
|
7
|
-
|
7
|
+
context: Array<Context> = [],
|
8
8
|
applied: Applied = {},
|
9
9
|
): Ty<T, P> {
|
10
10
|
return Object.assign(
|
11
|
-
<P2 extends Array<
|
12
|
-
Ty<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...
|
13
|
-
phantoms<{
|
11
|
+
<P2 extends Array<keyof any>>(template: TemplateStringsArray, ...placeheld: P2) =>
|
12
|
+
Ty<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...context], applied),
|
13
|
+
phantoms<{ T: T; P: P }>(),
|
14
14
|
{
|
15
|
-
toSchema,
|
16
|
-
|
17
|
-
|
18
|
-
apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
19
|
-
return Ty<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
|
15
|
+
"": { toSchema, context, applied },
|
16
|
+
fill: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
17
|
+
return Ty<T, Exclude<P, keyof A>>(toSchema, context, { ...applied, ...values })
|
20
18
|
},
|
21
19
|
isRoot(): this is RootTy {
|
22
20
|
return false
|
@@ -25,33 +23,28 @@ export function Ty<T, P extends string = never>(
|
|
25
23
|
)
|
26
24
|
}
|
27
25
|
|
28
|
-
export interface Ty<T = any, P extends
|
29
|
-
<P2 extends Array<
|
26
|
+
export interface Ty<T = any, P extends keyof any = keyof any> {
|
27
|
+
<P2 extends Array<keyof any>>(
|
30
28
|
template: TemplateStringsArray,
|
31
29
|
...placeheld: P2
|
32
30
|
): Ty<T, P | P2[number]>
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
T: T
|
32
|
+
P: P
|
33
|
+
"": {
|
34
|
+
toSchema: ToSchema
|
35
|
+
context: Array<Context>
|
36
|
+
applied: Applied
|
37
|
+
}
|
38
|
+
fill: <A extends Partial<Record<P, number | string>>>(values: A) => Ty<T, Exclude<P, keyof A>>
|
39
39
|
isRoot(): this is RootTy
|
40
40
|
}
|
41
41
|
|
42
|
-
export
|
43
|
-
export type T = typeof T
|
44
|
-
export declare const T: unique symbol
|
45
|
-
export type P = typeof P
|
46
|
-
export declare const P: unique symbol
|
47
|
-
}
|
48
|
-
|
49
|
-
export type ToSchema = (description: string | undefined, ref: Ref) => Schema
|
42
|
+
export type ToSchema = (ref: Ref) => Schema
|
50
43
|
export type Schema = Record<string, unknown>
|
51
44
|
|
52
|
-
export interface
|
45
|
+
export interface Context {
|
53
46
|
template: TemplateStringsArray
|
54
|
-
placeheld: Array<
|
47
|
+
placeheld: Array<keyof any>
|
55
48
|
}
|
56
49
|
|
57
|
-
export type Applied = Record<
|
50
|
+
export type Applied = Record<keyof any, number | string>
|
package/src/types/array.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import { Ty } from "./Ty.js"
|
2
2
|
|
3
|
-
export function array<E extends Ty>(element: E): Ty<Array<E[
|
4
|
-
return Ty((
|
3
|
+
export function array<E extends Ty>(element: E): Ty<Array<E["T"]>, E["P"]> {
|
4
|
+
return Ty((ref) => ({
|
5
5
|
type: "array",
|
6
|
-
description,
|
7
6
|
items: ref(element),
|
8
7
|
}))
|
9
8
|
}
|
package/src/types/constant.ts
CHANGED
@@ -5,23 +5,20 @@ export function constantUnion<M extends Array<number | string>>(
|
|
5
5
|
...members: M
|
6
6
|
): Ty<M[number], never> {
|
7
7
|
const [strings, numbers] = partition(members, (v) => typeof v === "string")
|
8
|
-
return Ty((
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
description,
|
25
|
-
}
|
26
|
-
})
|
8
|
+
return Ty(() => ({
|
9
|
+
anyOf: [
|
10
|
+
...strings.length
|
11
|
+
? [{
|
12
|
+
type: "string",
|
13
|
+
enum: strings,
|
14
|
+
}]
|
15
|
+
: [],
|
16
|
+
...numbers.length
|
17
|
+
? [{
|
18
|
+
type: "number",
|
19
|
+
enum: numbers,
|
20
|
+
}]
|
21
|
+
: [],
|
22
|
+
],
|
23
|
+
}))
|
27
24
|
}
|
package/src/types/mod.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
export * from "./array.js"
|
2
|
-
export * from "./leaves.js"
|
3
2
|
export * from "./constant.js"
|
4
3
|
export * from "./constantUnion.js"
|
5
|
-
export * from "./std/mod.js"
|
6
4
|
export * from "./object.js"
|
5
|
+
export * from "./primitives.js"
|
7
6
|
export * from "./Ref.js"
|
7
|
+
export * from "./RootTy.js"
|
8
|
+
export * from "./std/mod.js"
|
8
9
|
export * from "./taggedUnion.js"
|
9
10
|
export * from "./Ty.js"
|
10
|
-
export * from "./RootTy.js"
|
package/src/types/object.ts
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
import { RootTy } from "./RootTy.js"
|
2
2
|
import type { Ty } from "./Ty.js"
|
3
3
|
|
4
|
-
export function object<F extends Record<string, Ty>>(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
return RootTy((description, ref) => ({
|
4
|
+
export function object<F extends Record<string, Ty>>(
|
5
|
+
fields: F,
|
6
|
+
): RootTy<{ [K in keyof F]: F[K]["T"] }, F[keyof F]["P"]> {
|
7
|
+
return RootTy((ref) => ({
|
9
8
|
type: "object",
|
10
|
-
description,
|
11
9
|
properties: Object.fromEntries(Object.entries(fields).map(([k, v]) => [k, ref(v)])),
|
12
10
|
additionalProperties: false,
|
13
11
|
required: Object.keys(fields),
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Ty } from "./Ty.js"
|
2
|
+
|
3
|
+
export const none: Ty<null, never> = Ty(() => ({
|
4
|
+
type: "null",
|
5
|
+
}))
|
6
|
+
|
7
|
+
export const boolean: Ty<boolean, never> = Ty(() => ({
|
8
|
+
type: "boolean",
|
9
|
+
}))
|
10
|
+
|
11
|
+
export const number: Ty<number, never> = Ty(() => ({
|
12
|
+
type: "number",
|
13
|
+
}))
|
14
|
+
|
15
|
+
export const string: Ty<string, never> = Ty(() => ({
|
16
|
+
type: "string",
|
17
|
+
}))
|
package/src/types/std/Option.ts
CHANGED
package/src/types/std/Wrapper.ts
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
import type { Ty } from "../mod.js"
|
2
2
|
import { object } from "../object.js"
|
3
3
|
|
4
|
-
export type Wrapper<X extends Ty = Ty> = ReturnType<typeof Wrapper<X>>
|
5
|
-
|
6
4
|
export function Wrapper<X extends Ty>(value: X): ReturnType<typeof object<{ value: X }>> {
|
7
5
|
return object({ value })
|
8
6
|
}
|
package/src/types/taggedUnion.ts
CHANGED
@@ -4,13 +4,12 @@ export function taggedUnion<M extends Record<string, Ty>>(members: M): Ty<
|
|
4
4
|
{
|
5
5
|
[K in keyof M]: {
|
6
6
|
type: K
|
7
|
-
value: M[K][
|
7
|
+
value: M[K]["T"]
|
8
8
|
}
|
9
9
|
}[keyof M],
|
10
|
-
M[keyof M][
|
10
|
+
M[keyof M]["P"]
|
11
11
|
> {
|
12
|
-
return Ty((
|
13
|
-
description,
|
12
|
+
return Ty((ref) => ({
|
14
13
|
discriminator: "type",
|
15
14
|
anyOf: Object.entries(members).map(([k, v]) => ({
|
16
15
|
type: "object",
|
package/esm/_dnt.shims.js
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
const dntGlobals = {};
|
2
|
-
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
3
|
-
function createMergeProxy(baseObj, extObj) {
|
4
|
-
return new Proxy(baseObj, {
|
5
|
-
get(_target, prop, _receiver) {
|
6
|
-
if (prop in extObj) {
|
7
|
-
return extObj[prop];
|
8
|
-
}
|
9
|
-
else {
|
10
|
-
return baseObj[prop];
|
11
|
-
}
|
12
|
-
},
|
13
|
-
set(_target, prop, value) {
|
14
|
-
if (prop in extObj) {
|
15
|
-
delete extObj[prop];
|
16
|
-
}
|
17
|
-
baseObj[prop] = value;
|
18
|
-
return true;
|
19
|
-
},
|
20
|
-
deleteProperty(_target, prop) {
|
21
|
-
let success = false;
|
22
|
-
if (prop in extObj) {
|
23
|
-
delete extObj[prop];
|
24
|
-
success = true;
|
25
|
-
}
|
26
|
-
if (prop in baseObj) {
|
27
|
-
delete baseObj[prop];
|
28
|
-
success = true;
|
29
|
-
}
|
30
|
-
return success;
|
31
|
-
},
|
32
|
-
ownKeys(_target) {
|
33
|
-
const baseKeys = Reflect.ownKeys(baseObj);
|
34
|
-
const extKeys = Reflect.ownKeys(extObj);
|
35
|
-
const extKeysSet = new Set(extKeys);
|
36
|
-
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
37
|
-
},
|
38
|
-
defineProperty(_target, prop, desc) {
|
39
|
-
if (prop in extObj) {
|
40
|
-
delete extObj[prop];
|
41
|
-
}
|
42
|
-
Reflect.defineProperty(baseObj, prop, desc);
|
43
|
-
return true;
|
44
|
-
},
|
45
|
-
getOwnPropertyDescriptor(_target, prop) {
|
46
|
-
if (prop in extObj) {
|
47
|
-
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
48
|
-
}
|
49
|
-
else {
|
50
|
-
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
51
|
-
}
|
52
|
-
},
|
53
|
-
has(_target, prop) {
|
54
|
-
return prop in extObj || prop in baseObj;
|
55
|
-
},
|
56
|
-
});
|
57
|
-
}
|
58
|
-
//# sourceMappingURL=_dnt.shims.js.map
|
package/esm/_dnt.shims.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"_dnt.shims.js","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,GAAG,EAClB,CAAC;AACF,MAAM,CAAC,MAAM,aAAa,GAAG,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAEtE,SAAS,gBAAgB,CACvB,OAAU,EACV,MAAS;IAET,OAAO,IAAI,KAAK,CAAC,OAAO,EAAE;QACxB,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,SAAS;YAC1B,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;iBAAM,CAAC;gBACN,OAAQ,OAAe,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK;YACtB,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACA,OAAe,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;YAC/B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,cAAc,CAAC,OAAO,EAAE,IAAI;YAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;YACpB,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;gBACpB,OAAQ,OAAe,CAAC,IAAI,CAAC,CAAC;gBAC9B,OAAO,GAAG,IAAI,CAAC;YACjB,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,CAAC,OAAO;YACb,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACxC,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,CAAC;QACrE,CAAC;QACD,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI;YAChC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAQ,MAAc,CAAC,IAAI,CAAC,CAAC;YAC/B,CAAC;YACD,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC5C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,wBAAwB,CAAC,OAAO,EAAE,IAAI;YACpC,IAAI,IAAI,IAAI,MAAM,EAAE,CAAC;gBACnB,OAAO,OAAO,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YACxD,CAAC;iBAAM,CAAC;gBACN,OAAO,OAAO,CAAC,wBAAwB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;YACzD,CAAC;QACH,CAAC;QACD,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,OAAO,CAAC;QAC3C,CAAC;KACF,CAAQ,CAAC;AACZ,CAAC"}
|