structured-outputs 0.1.0-beta.21 → 0.1.0-beta.23
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 +8 -8
- package/esm/ResponseFormat.d.ts.map +1 -1
- package/esm/ResponseFormat.js +4 -7
- package/esm/ResponseFormat.js.map +1 -1
- package/esm/Tool.d.ts +2 -2
- package/esm/Tool.d.ts.map +1 -1
- package/esm/Tool.js +2 -2
- package/esm/Tool.js.map +1 -1
- package/esm/types/Ty.d.ts +26 -23
- package/esm/types/Ty.d.ts.map +1 -1
- package/esm/types/Ty.js +29 -12
- package/esm/types/Ty.js.map +1 -1
- package/esm/types/array.d.ts +1 -1
- package/esm/types/array.d.ts.map +1 -1
- package/esm/types/array.js +2 -3
- package/esm/types/array.js.map +1 -1
- package/esm/types/constantUnion.d.ts +1 -1
- package/esm/types/constantUnion.d.ts.map +1 -1
- package/esm/types/constantUnion.js +16 -19
- package/esm/types/constantUnion.js.map +1 -1
- package/esm/types/mod.d.ts +4 -5
- package/esm/types/mod.d.ts.map +1 -1
- package/esm/types/mod.js +4 -5
- package/esm/types/mod.js.map +1 -1
- package/esm/types/object.d.ts +4 -5
- package/esm/types/object.d.ts.map +1 -1
- package/esm/types/object.js +3 -4
- package/esm/types/object.js.map +1 -1
- package/esm/types/primitives.d.ts +6 -0
- 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/Date.d.ts +4 -0
- package/esm/types/std/Date.d.ts.map +1 -0
- package/esm/types/std/Date.js +14 -0
- package/esm/types/std/Date.js.map +1 -0
- package/esm/types/std/Option.d.ts +3 -2
- package/esm/types/std/Option.d.ts.map +1 -1
- package/esm/types/std/Option.js +2 -2
- package/esm/types/std/Option.js.map +1 -1
- package/esm/types/std/Wrapper.d.ts +0 -1
- package/esm/types/std/Wrapper.d.ts.map +1 -1
- package/esm/types/std/Wrapper.js.map +1 -1
- package/esm/types/std/color.d.ts +8 -0
- package/esm/types/std/color.d.ts.map +1 -0
- package/esm/types/std/color.js +13 -0
- package/esm/types/std/color.js.map +1 -0
- package/esm/types/std/mod.d.ts +2 -0
- package/esm/types/std/mod.d.ts.map +1 -1
- package/esm/types/std/mod.js +2 -0
- package/esm/types/std/mod.js.map +1 -1
- package/esm/types/taggedUnion.d.ts +2 -2
- package/esm/types/taggedUnion.d.ts.map +1 -1
- package/esm/types/taggedUnion.js +20 -15
- package/esm/types/taggedUnion.js.map +1 -1
- package/esm/types/transform.d.ts +3 -0
- package/esm/types/transform.d.ts.map +1 -0
- package/esm/types/transform.js +5 -0
- package/esm/types/transform.js.map +1 -0
- package/esm/types/tuple.d.ts +5 -0
- package/esm/types/tuple.d.ts.map +1 -0
- package/esm/types/tuple.js +11 -0
- package/esm/types/tuple.js.map +1 -0
- package/esm/util/recombine.d.ts +2 -0
- package/esm/util/recombine.d.ts.map +1 -0
- package/esm/util/recombine.js +4 -0
- package/esm/util/recombine.js.map +1 -0
- package/package.json +2 -2
- package/src/ResponseFormat.ts +14 -17
- package/src/Tool.ts +5 -5
- package/src/types/Ty.ts +75 -41
- package/src/types/array.ts +9 -6
- package/src/types/constantUnion.ts +17 -20
- package/src/types/mod.ts +4 -5
- package/src/types/object.ts +17 -13
- package/src/types/primitives.ts +17 -0
- package/src/types/std/Date.ts +19 -0
- package/src/types/std/Option.ts +3 -3
- package/src/types/std/Wrapper.ts +0 -2
- package/src/types/std/color.ts +27 -0
- package/src/types/std/mod.ts +2 -0
- package/src/types/taggedUnion.ts +29 -17
- package/src/types/transform.ts +8 -0
- package/src/types/tuple.ts +17 -0
- package/src/util/recombine.ts +3 -0
- package/esm/oai.d.ts +0 -5
- package/esm/oai.d.ts.map +0 -1
- package/esm/oai.js +0 -2
- package/esm/oai.js.map +0 -1
- package/esm/types/Ref.d.ts +0 -4
- package/esm/types/Ref.d.ts.map +0 -1
- package/esm/types/Ref.js +0 -11
- package/esm/types/Ref.js.map +0 -1
- package/esm/types/RootTy.d.ts +0 -8
- package/esm/types/RootTy.d.ts.map +0 -1
- package/esm/types/RootTy.js +0 -19
- package/esm/types/RootTy.js.map +0 -1
- package/esm/types/constant.d.ts +0 -3
- package/esm/types/constant.d.ts.map +0 -1
- package/esm/types/constant.js +0 -8
- package/esm/types/constant.js.map +0 -1
- package/esm/types/leaves.d.ts +0 -6
- package/esm/types/leaves.d.ts.map +0 -1
- package/esm/types/leaves.js +0 -18
- package/esm/types/leaves.js.map +0 -1
- package/esm/util/phantoms.d.ts +0 -2
- package/esm/util/phantoms.d.ts.map +0 -1
- package/esm/util/phantoms.js +0 -4
- package/esm/util/phantoms.js.map +0 -1
- package/esm/util/recombineTaggedTemplateArgs.d.ts +0 -2
- package/esm/util/recombineTaggedTemplateArgs.d.ts.map +0 -1
- package/esm/util/recombineTaggedTemplateArgs.js +0 -4
- package/esm/util/recombineTaggedTemplateArgs.js.map +0 -1
- package/src/oai.ts +0 -5
- package/src/types/Ref.ts +0 -16
- package/src/types/RootTy.ts +0 -40
- package/src/types/constant.ts +0 -8
- package/src/types/leaves.ts +0 -21
- package/src/util/phantoms.ts +0 -3
- package/src/util/recombineTaggedTemplateArgs.ts +0 -6
@@ -0,0 +1,19 @@
|
|
1
|
+
import { object } from "../object.js"
|
2
|
+
import { number } from "../primitives.js"
|
3
|
+
import { transform } from "../transform.js"
|
4
|
+
import type { Ty } from "../Ty.js"
|
5
|
+
|
6
|
+
export { Date_ as Date }
|
7
|
+
const Date_: Ty<Date, never, true> = transform(
|
8
|
+
object({
|
9
|
+
year: number,
|
10
|
+
month: number`Zero-based (0 for January, 11 for December).`,
|
11
|
+
day: number`Day of the month (1-31). Ensure within available range for the specified month.`,
|
12
|
+
hour: number`Zero-based (0-23)`,
|
13
|
+
minute: number`Zero-based (0-59)`,
|
14
|
+
second: number`Zero-based (0-59)`,
|
15
|
+
millisecond: number`Zero-based (0-999)`,
|
16
|
+
}),
|
17
|
+
({ year, month, day, hour, minute, second, millisecond }) =>
|
18
|
+
new Date(year, month, day, hour, minute, second, millisecond),
|
19
|
+
)
|
package/src/types/std/Option.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
import { none } from "../
|
1
|
+
import { none } from "../primitives.js"
|
2
2
|
import { taggedUnion } from "../taggedUnion.js"
|
3
3
|
import type { Ty } from "../Ty.js"
|
4
4
|
|
5
|
-
export function
|
5
|
+
export function Option<S extends Ty>(Some: S): ReturnType<
|
6
6
|
typeof taggedUnion<{
|
7
7
|
Some: S
|
8
|
-
None:
|
8
|
+
None: typeof none
|
9
9
|
}>
|
10
10
|
> {
|
11
11
|
return taggedUnion({
|
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
|
}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { object } from "../object.js"
|
2
|
+
import { number } from "../primitives.js"
|
3
|
+
import { transform } from "../transform.js"
|
4
|
+
import type { Ty } from "../Ty.js"
|
5
|
+
|
6
|
+
export const Rgb: Ty<
|
7
|
+
{
|
8
|
+
r: number
|
9
|
+
g: number
|
10
|
+
b: number
|
11
|
+
},
|
12
|
+
never,
|
13
|
+
true
|
14
|
+
> = object({
|
15
|
+
r: number`Between 0 and 255`,
|
16
|
+
g: number`Between 0 and 255`,
|
17
|
+
b: number`Between 0 and 255`,
|
18
|
+
})
|
19
|
+
|
20
|
+
export const Hex: Ty<string, never, true> = transform(
|
21
|
+
Rgb,
|
22
|
+
({ r, g, b }) => `${toHex(r)}${toHex(g)}${toHex(b)}"`,
|
23
|
+
)
|
24
|
+
|
25
|
+
function toHex(value: number): string {
|
26
|
+
return value.toString(16).padStart(2, "0")
|
27
|
+
}
|
package/src/types/std/mod.ts
CHANGED
package/src/types/taggedUnion.ts
CHANGED
@@ -1,28 +1,40 @@
|
|
1
|
-
import { Ty } from "./Ty.js"
|
1
|
+
import { type Schema, Ty } from "./Ty.js"
|
2
2
|
|
3
3
|
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
|
+
false
|
11
12
|
> {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
const: k,
|
13
|
+
const entries = Object.entries(members)
|
14
|
+
return Ty(
|
15
|
+
(subschema) =>
|
16
|
+
entries.length === 1
|
17
|
+
? variant(entries[0]![0], subschema(entries[0]![1]))
|
18
|
+
: {
|
19
|
+
discriminator: "type",
|
20
|
+
anyOf: entries.map(([k, v]) => variant(k, subschema(v))),
|
21
21
|
},
|
22
|
-
|
22
|
+
false,
|
23
|
+
(v) => members[v.type]![""].transform(v),
|
24
|
+
)
|
25
|
+
}
|
26
|
+
|
27
|
+
function variant(type: string, value: Schema) {
|
28
|
+
return {
|
29
|
+
type: "object",
|
30
|
+
properties: {
|
31
|
+
type: {
|
32
|
+
type: "string",
|
33
|
+
const: type,
|
23
34
|
},
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
35
|
+
value,
|
36
|
+
},
|
37
|
+
required: ["type", "value"],
|
38
|
+
additionalProperties: false,
|
39
|
+
}
|
28
40
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { Ty } from "./Ty.js"
|
2
|
+
|
3
|
+
export function tuple<F extends Ty[]>(
|
4
|
+
...elements: F
|
5
|
+
): Ty<{ [K in keyof F]: F[K]["T"] }, F[number]["P"], true> {
|
6
|
+
const { length } = elements
|
7
|
+
return Ty(
|
8
|
+
(ref) => ({
|
9
|
+
type: "object",
|
10
|
+
properties: Object.fromEntries(Array.from({ length }, (_0, i) => [i, ref(elements[i]!)])),
|
11
|
+
additionalProperties: false,
|
12
|
+
required: Object.keys(Array.from({ length }, (_0, i) => i)),
|
13
|
+
}),
|
14
|
+
true,
|
15
|
+
(v) => Array.from({ length }, (_0, i) => elements[i]![""].transform(v[i])) as never,
|
16
|
+
)
|
17
|
+
}
|
package/esm/oai.d.ts
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
import type Openai from "openai";
|
2
|
-
export type JsonSchema = Openai.ResponseFormatJSONSchema["json_schema"];
|
3
|
-
export type ChatCompletion = Openai.Chat.ChatCompletion;
|
4
|
-
export type ChatCompletionChoice = Openai.Chat.Completions.ChatCompletion.Choice;
|
5
|
-
//# sourceMappingURL=oai.d.ts.map
|
package/esm/oai.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"oai.d.ts","sourceRoot":"","sources":["../src/oai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAEhC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,aAAa,CAAC,CAAA;AACvE,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,cAAc,CAAA;AACvD,MAAM,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,MAAM,CAAA"}
|
package/esm/oai.js
DELETED
package/esm/oai.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"oai.js","sourceRoot":"","sources":["../src/oai.ts"],"names":[],"mappings":""}
|
package/esm/types/Ref.d.ts
DELETED
package/esm/types/Ref.d.ts.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Ref.d.ts","sourceRoot":"","sources":["../../src/types/Ref.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAGlD,MAAM,MAAM,GAAG,GAAG,CAAC,EAAE,EAAE,EAAE,KAAK,MAAM,CAAA;AAEpC,wBAAgB,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,GAAG,CAUzC"}
|
package/esm/types/Ref.js
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import { recombineTaggedTemplateArgs } from "../util/recombineTaggedTemplateArgs.js";
|
2
|
-
export function Ref(applied) {
|
3
|
-
return (ty) => {
|
4
|
-
applied = { ...applied, ...ty.applied };
|
5
|
-
const description = ty.descriptions
|
6
|
-
.map(({ template, placeheld }) => recombineTaggedTemplateArgs(template, placeheld.map((k) => applied[k])))
|
7
|
-
.join(" ");
|
8
|
-
return ty.toSchema(description, Ref(applied));
|
9
|
-
};
|
10
|
-
}
|
11
|
-
//# sourceMappingURL=Ref.js.map
|
package/esm/types/Ref.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"Ref.js","sourceRoot":"","sources":["../../src/types/Ref.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAA;AAIpF,MAAM,UAAU,GAAG,CAAC,OAAgB;IAClC,OAAO,CAAC,EAAE,EAAE,EAAE;QACZ,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAA;QACvC,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY;aAChC,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,CAC/B,2BAA2B,CAAC,QAAQ,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAE,CAAC,CAAC,CACzE;aACA,IAAI,CAAC,GAAG,CAAC,CAAA;QACZ,OAAO,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC/C,CAAC,CAAA;AACH,CAAC"}
|
package/esm/types/RootTy.d.ts
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
import type { Applied, Description, Schema, ToSchema, Ty } from "./Ty.js";
|
2
|
-
export declare function RootTy<T, P extends string = never>(toSchema: ToSchema, descriptions?: Array<Description>, applied?: Applied): RootTy<T, P>;
|
3
|
-
export interface RootTy<T = any, P extends string = string> extends Ty<T, P> {
|
4
|
-
<P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2): RootTy<T, P | P2[number]>;
|
5
|
-
apply: <A extends Partial<Record<P, number | string>>>(values: A) => RootTy<T, Exclude<P, keyof A>>;
|
6
|
-
schema(this: RootTy<T, never>): Schema;
|
7
|
-
}
|
8
|
-
//# sourceMappingURL=RootTy.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"RootTy.d.ts","sourceRoot":"","sources":["../../src/types/RootTy.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAEzE,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,KAAK,EAChD,QAAQ,EAAE,QAAQ,EAClB,YAAY,GAAE,KAAK,CAAC,WAAW,CAAM,EACrC,OAAO,GAAE,OAAY,GACpB,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAoBd;AAED,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC,EAAE,SAAS,KAAK,CAAC,MAAM,CAAC,EACvB,QAAQ,EAAE,oBAAoB,EAC9B,GAAG,SAAS,EAAE,EAAE,GACf,MAAM,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,KAAK,EAAE,CAAC,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,EACnD,MAAM,EAAE,CAAC,KACN,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAA;IACnC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,CAAA;CACvC"}
|
package/esm/types/RootTy.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
import { phantoms } from "../util/phantoms.js";
|
2
|
-
import { Ref } from "./Ref.js";
|
3
|
-
export function RootTy(toSchema, descriptions = [], applied = {}) {
|
4
|
-
return Object.assign((template, ...placeheld) => RootTy(toSchema, [{ template, placeheld }, ...descriptions], applied), phantoms(), {
|
5
|
-
toSchema,
|
6
|
-
descriptions,
|
7
|
-
applied,
|
8
|
-
apply: (values) => {
|
9
|
-
return RootTy(toSchema, descriptions, { ...applied, ...values });
|
10
|
-
},
|
11
|
-
schema() {
|
12
|
-
return Ref({})(this);
|
13
|
-
},
|
14
|
-
isRoot() {
|
15
|
-
return true;
|
16
|
-
},
|
17
|
-
});
|
18
|
-
}
|
19
|
-
//# sourceMappingURL=RootTy.js.map
|
package/esm/types/RootTy.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"RootTy.js","sourceRoot":"","sources":["../../src/types/RootTy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAG9B,MAAM,UAAU,MAAM,CACpB,QAAkB,EAClB,eAAmC,EAAE,EACrC,UAAmB,EAAE;IAErB,OAAO,MAAM,CAAC,MAAM,CAClB,CAA2B,QAA8B,EAAE,GAAG,SAAa,EAAE,EAAE,CAC7E,MAAM,CAAoB,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,GAAG,YAAY,CAAC,EAAE,OAAO,CAAC,EAC1F,QAAQ,EAA4B,EACpC;QACE,QAAQ;QACR,YAAY;QACZ,OAAO;QACP,KAAK,EAAE,CAAgD,MAAS,EAAE,EAAE;YAClE,OAAO,MAAM,CAAyB,QAAQ,EAAE,YAAY,EAAE,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;QAC1F,CAAC;QACD,MAAM;YACJ,OAAO,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;QACtB,CAAC;QACD,MAAM;YACJ,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CACF,CAAA;AACH,CAAC"}
|
package/esm/types/constant.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../src/types/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,CAK1E"}
|
package/esm/types/constant.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../src/types/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,MAAM,UAAU,QAAQ,CAA4B,KAAQ;IAC1D,OAAO,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC1B,KAAK,EAAE,KAAK;QACZ,WAAW;KACZ,CAAC,CAAC,CAAA;AACL,CAAC"}
|
package/esm/types/leaves.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"leaves.d.ts","sourceRoot":"","sources":["../../src/types/leaves.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,IAAI,EAAE,KAAK,CAG9B,CAAA;AAEH,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,CAGpC,CAAA;AAEH,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAGlC,CAAA;AAEH,eAAO,MAAM,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,CAGlC,CAAA"}
|
package/esm/types/leaves.js
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
import { Ty } from "./Ty.js";
|
2
|
-
export const none = Ty((description) => ({
|
3
|
-
type: "null",
|
4
|
-
description,
|
5
|
-
}));
|
6
|
-
export const boolean = Ty((description) => ({
|
7
|
-
type: "boolean",
|
8
|
-
description,
|
9
|
-
}));
|
10
|
-
export const number = Ty((description) => ({
|
11
|
-
type: "number",
|
12
|
-
description,
|
13
|
-
}));
|
14
|
-
export const string = Ty((description) => ({
|
15
|
-
type: "string",
|
16
|
-
description,
|
17
|
-
}));
|
18
|
-
//# sourceMappingURL=leaves.js.map
|
package/esm/types/leaves.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"leaves.js","sourceRoot":"","sources":["../../src/types/leaves.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAE5B,MAAM,CAAC,MAAM,IAAI,GAAoB,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACxD,IAAI,EAAE,MAAM;IACZ,WAAW;CACZ,CAAC,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,OAAO,GAAuB,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC9D,IAAI,EAAE,SAAS;IACf,WAAW;CACZ,CAAC,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,MAAM,GAAsB,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC5D,IAAI,EAAE,QAAQ;IACd,WAAW;CACZ,CAAC,CAAC,CAAA;AAEH,MAAM,CAAC,MAAM,MAAM,GAAsB,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC5D,IAAI,EAAE,QAAQ;IACd,WAAW;CACZ,CAAC,CAAC,CAAA"}
|
package/esm/util/phantoms.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"phantoms.d.ts","sourceRoot":"","sources":["../../src/util/phantoms.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,CAAC,KAAK,CAAC,CAE/B"}
|
package/esm/util/phantoms.js
DELETED
package/esm/util/phantoms.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"phantoms.js","sourceRoot":"","sources":["../../src/util/phantoms.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ;IACtB,OAAO,EAAO,CAAA;AAChB,CAAC"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"recombineTaggedTemplateArgs.d.ts","sourceRoot":"","sources":["../../src/util/recombineTaggedTemplateArgs.ts"],"names":[],"mappings":"AAAA,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,oBAAoB,EAC7B,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAC7B,MAAM,CAER"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"recombineTaggedTemplateArgs.js","sourceRoot":"","sources":["../../src/util/recombineTaggedTemplateArgs.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,2BAA2B,CACzC,OAA6B,EAC7B,MAA8B;IAE9B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;AAC9E,CAAC"}
|
package/src/oai.ts
DELETED
package/src/types/Ref.ts
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
import type { Applied, Schema, Ty } from "./Ty.js"
|
2
|
-
import { recombineTaggedTemplateArgs } from "../util/recombineTaggedTemplateArgs.js"
|
3
|
-
|
4
|
-
export type Ref = (ty: Ty) => Schema
|
5
|
-
|
6
|
-
export function Ref(applied: Applied): Ref {
|
7
|
-
return (ty) => {
|
8
|
-
applied = { ...applied, ...ty.applied }
|
9
|
-
const description = ty.descriptions
|
10
|
-
.map(({ template, placeheld }) =>
|
11
|
-
recombineTaggedTemplateArgs(template, placeheld.map((k) => applied[k]!))
|
12
|
-
)
|
13
|
-
.join(" ")
|
14
|
-
return ty.toSchema(description, Ref(applied))
|
15
|
-
}
|
16
|
-
}
|
package/src/types/RootTy.ts
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
import { phantoms } from "../util/phantoms.js"
|
2
|
-
import { Ref } from "./Ref.js"
|
3
|
-
import type { Applied, Description, Schema, ToSchema, Ty } from "./Ty.js"
|
4
|
-
|
5
|
-
export function RootTy<T, P extends string = never>(
|
6
|
-
toSchema: ToSchema,
|
7
|
-
descriptions: Array<Description> = [],
|
8
|
-
applied: Applied = {},
|
9
|
-
): RootTy<T, P> {
|
10
|
-
return Object.assign(
|
11
|
-
<P2 extends Array<string>>(template: TemplateStringsArray, ...placeheld: P2) =>
|
12
|
-
RootTy<T, P | P2[number]>(toSchema, [{ template, placeheld }, ...descriptions], applied),
|
13
|
-
phantoms<{ [Ty.T]: T; [Ty.P]: P }>(),
|
14
|
-
{
|
15
|
-
toSchema,
|
16
|
-
descriptions,
|
17
|
-
applied,
|
18
|
-
apply: <A extends Partial<Record<P, string | number>>>(values: A) => {
|
19
|
-
return RootTy<T, Exclude<P, keyof A>>(toSchema, descriptions, { ...applied, ...values })
|
20
|
-
},
|
21
|
-
schema(this: RootTy<T, never>) {
|
22
|
-
return Ref({})(this)
|
23
|
-
},
|
24
|
-
isRoot(): this is RootTy {
|
25
|
-
return true
|
26
|
-
},
|
27
|
-
},
|
28
|
-
)
|
29
|
-
}
|
30
|
-
|
31
|
-
export interface RootTy<T = any, P extends string = string> extends Ty<T, P> {
|
32
|
-
<P2 extends Array<string>>(
|
33
|
-
template: TemplateStringsArray,
|
34
|
-
...placeheld: P2
|
35
|
-
): RootTy<T, P | P2[number]>
|
36
|
-
apply: <A extends Partial<Record<P, number | string>>>(
|
37
|
-
values: A,
|
38
|
-
) => RootTy<T, Exclude<P, keyof A>>
|
39
|
-
schema(this: RootTy<T, never>): Schema
|
40
|
-
}
|
package/src/types/constant.ts
DELETED
package/src/types/leaves.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import { Ty } from "./Ty.js"
|
2
|
-
|
3
|
-
export const none: Ty<null, never> = Ty((description) => ({
|
4
|
-
type: "null",
|
5
|
-
description,
|
6
|
-
}))
|
7
|
-
|
8
|
-
export const boolean: Ty<boolean, never> = Ty((description) => ({
|
9
|
-
type: "boolean",
|
10
|
-
description,
|
11
|
-
}))
|
12
|
-
|
13
|
-
export const number: Ty<number, never> = Ty((description) => ({
|
14
|
-
type: "number",
|
15
|
-
description,
|
16
|
-
}))
|
17
|
-
|
18
|
-
export const string: Ty<string, never> = Ty((description) => ({
|
19
|
-
type: "string",
|
20
|
-
description,
|
21
|
-
}))
|
package/src/util/phantoms.ts
DELETED