typia 6.9.0 → 6.10.0-dev.20240906

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.
Files changed (65) hide show
  1. package/lib/factories/internal/metadata/emplace_metadata_object.js +1 -1
  2. package/lib/factories/internal/metadata/emplace_metadata_object.js.map +1 -1
  3. package/lib/index.mjs +2 -0
  4. package/lib/index.mjs.map +1 -1
  5. package/lib/json.d.ts +1 -1
  6. package/lib/llm.d.ts +5 -0
  7. package/lib/llm.js +23 -0
  8. package/lib/llm.js.map +1 -0
  9. package/lib/llm.mjs +21 -0
  10. package/lib/llm.mjs.map +1 -0
  11. package/lib/module.d.ts +1 -0
  12. package/lib/module.js +2 -1
  13. package/lib/module.js.map +1 -1
  14. package/lib/module.mjs +2 -0
  15. package/lib/module.mjs.map +1 -1
  16. package/lib/programmers/internal/application_escaped.js +4 -6
  17. package/lib/programmers/internal/application_escaped.js.map +1 -1
  18. package/lib/programmers/internal/llm_schema_array.d.ts +1 -0
  19. package/lib/programmers/internal/llm_schema_array.js +20 -0
  20. package/lib/programmers/internal/llm_schema_array.js.map +1 -0
  21. package/lib/programmers/internal/llm_schema_escaped.d.ts +1 -0
  22. package/lib/programmers/internal/llm_schema_escaped.js +56 -0
  23. package/lib/programmers/internal/llm_schema_escaped.js.map +1 -0
  24. package/lib/programmers/internal/llm_schema_native.d.ts +1 -0
  25. package/lib/programmers/internal/llm_schema_native.js +19 -0
  26. package/lib/programmers/internal/llm_schema_native.js.map +1 -0
  27. package/lib/programmers/internal/llm_schema_object.d.ts +1 -0
  28. package/lib/programmers/internal/llm_schema_object.js +134 -0
  29. package/lib/programmers/internal/llm_schema_object.js.map +1 -0
  30. package/lib/programmers/internal/llm_schema_station.d.ts +1 -0
  31. package/lib/programmers/internal/llm_schema_station.js +238 -0
  32. package/lib/programmers/internal/llm_schema_station.js.map +1 -0
  33. package/lib/programmers/internal/llm_schema_tuple.d.ts +6 -0
  34. package/lib/programmers/internal/llm_schema_tuple.js +30 -0
  35. package/lib/programmers/internal/llm_schema_tuple.js.map +1 -0
  36. package/lib/programmers/llm/LlmSchemaProgrammer.d.ts +6 -0
  37. package/lib/programmers/llm/LlmSchemaProgrammer.js +66 -0
  38. package/lib/programmers/llm/LlmSchemaProgrammer.js.map +1 -0
  39. package/lib/schemas/json/IJsonApplication.d.ts +5 -3
  40. package/lib/transformers/CallExpressionTransformer.js +7 -1
  41. package/lib/transformers/CallExpressionTransformer.js.map +1 -1
  42. package/lib/transformers/features/llm/LlmSchemaTransformer.d.ts +5 -0
  43. package/lib/transformers/features/llm/LlmSchemaTransformer.js +45 -0
  44. package/lib/transformers/features/llm/LlmSchemaTransformer.js.map +1 -0
  45. package/lib/utils/Escaper.js +4 -0
  46. package/lib/utils/Escaper.js.map +1 -1
  47. package/package.json +2 -2
  48. package/src/factories/MetadataCommentTagFactory.ts +534 -534
  49. package/src/factories/internal/metadata/emplace_metadata_object.ts +2 -2
  50. package/src/json.ts +738 -738
  51. package/src/llm.ts +30 -0
  52. package/src/module.ts +1 -0
  53. package/src/programmers/internal/application_escaped.ts +4 -6
  54. package/src/programmers/internal/llm_schema_array.ts +22 -0
  55. package/src/programmers/internal/llm_schema_escaped.ts +61 -0
  56. package/src/programmers/internal/llm_schema_native.ts +17 -0
  57. package/src/programmers/internal/llm_schema_object.ts +129 -0
  58. package/src/programmers/internal/llm_schema_station.ts +185 -0
  59. package/src/programmers/internal/llm_schema_tuple.ts +31 -0
  60. package/src/programmers/json/JsonApplicationProgrammer.ts +1 -1
  61. package/src/programmers/llm/LlmSchemaProgrammer.ts +49 -0
  62. package/src/schemas/json/IJsonApplication.ts +22 -16
  63. package/src/transformers/CallExpressionTransformer.ts +6 -1
  64. package/src/transformers/features/llm/LlmSchemaTransformer.ts +52 -0
  65. package/src/utils/Escaper.ts +50 -46
package/src/llm.ts ADDED
@@ -0,0 +1,30 @@
1
+ import { ILlmApplication, ILlmSchema } from "@samchon/openapi";
2
+
3
+ export function application(): never;
4
+ export function application<T extends object>(): ILlmApplication;
5
+
6
+ /**
7
+ * @internal
8
+ */
9
+ export function application(): never {
10
+ halt("application");
11
+ }
12
+
13
+ export function schema(): never;
14
+ export function schema<T>(): ILlmSchema;
15
+
16
+ /**
17
+ * @internal
18
+ */
19
+ export function schema(): never {
20
+ halt("schema");
21
+ }
22
+
23
+ /**
24
+ * @internal
25
+ */
26
+ function halt(name: string): never {
27
+ throw new Error(
28
+ `Error on typia.llm.${name}(): no transform has been configured. Read and follow https://typia.io/docs/setup please.`,
29
+ );
30
+ }
package/src/module.ts CHANGED
@@ -8,6 +8,7 @@ import { TypeGuardError } from "./TypeGuardError";
8
8
 
9
9
  export * as functional from "./functional";
10
10
  export * as http from "./http";
11
+ export * as llm from "./llm";
11
12
  export * as json from "./json";
12
13
  export * as misc from "./misc";
13
14
  export * as notations from "./notations";
@@ -10,11 +10,11 @@ export const application_escaped =
10
10
  <Version extends "3.0" | "3.1">(
11
11
  generator: (meta: Metadata) => Schema<Version>,
12
12
  ) =>
13
- (resolved: MetadataEscaped): Schema<Version>[] => {
14
- const output: Schema<Version> | null = generator(resolved.returns);
13
+ (escaped: MetadataEscaped): Schema<Version>[] => {
14
+ const output: Schema<Version> | null = generator(escaped.returns);
15
15
  if (output === null) return [];
16
16
 
17
- if (is_date(new Set())(resolved.original)) {
17
+ if (is_date(new Set())(escaped.original)) {
18
18
  const string: StringSchema<Version> | undefined = is_string(output)
19
19
  ? output
20
20
  : is_one_of(output)
@@ -27,9 +27,7 @@ export const application_escaped =
27
27
  )
28
28
  string.format = "date-time";
29
29
  }
30
- return is_one_of(output)
31
- ? (output.oneOf as OneOfSchema<Version>[])
32
- : [output];
30
+ return is_one_of(output) ? (output.oneOf as Schema<Version>[]) : [output];
33
31
  };
34
32
 
35
33
  /**
@@ -0,0 +1,22 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { MetadataArray } from "../../schemas/metadata/MetadataArray";
4
+
5
+ import { application_plugin } from "./application_plugin";
6
+ import { llm_schema_station } from "./llm_schema_station";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const llm_schema_array = (array: MetadataArray): ILlmSchema.IArray[] =>
12
+ application_plugin(
13
+ {
14
+ type: "array",
15
+ items: llm_schema_station({
16
+ metadata: array.type.value,
17
+ blockNever: false,
18
+ attribute: {},
19
+ }),
20
+ },
21
+ array.tags,
22
+ );
@@ -0,0 +1,61 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+ import { MetadataEscaped } from "../../schemas/metadata/MetadataEscaped";
5
+
6
+ import { llm_schema_station } from "./llm_schema_station";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const llm_schema_escaped = (escaped: MetadataEscaped): ILlmSchema[] => {
12
+ const output: ILlmSchema | null = llm_schema_station({
13
+ metadata: escaped.returns,
14
+ blockNever: false,
15
+ attribute: {},
16
+ });
17
+ if (output === null) return [];
18
+ else if (is_date(new Set())(escaped.original)) {
19
+ const string: ILlmSchema.IString | undefined = is_string(output)
20
+ ? output
21
+ : is_one_of(output)
22
+ ? (output.oneOf.find(is_string) as ILlmSchema.IString)
23
+ : undefined;
24
+ if (
25
+ string !== undefined &&
26
+ string.format !== "date" &&
27
+ string.format !== "date-time"
28
+ )
29
+ string.format = "date-time";
30
+ }
31
+ return is_one_of(output) ? (output.oneOf as ILlmSchema[]) : [output];
32
+ };
33
+
34
+ /**
35
+ * @internal
36
+ */
37
+ const is_string = (elem: ILlmSchema): elem is ILlmSchema.IString =>
38
+ (elem as ILlmSchema.IString).type === "string";
39
+
40
+ /**
41
+ * @internal
42
+ */
43
+ const is_one_of = (elem: ILlmSchema): elem is ILlmSchema.IOneOf =>
44
+ Array.isArray((elem as ILlmSchema.IOneOf).oneOf);
45
+
46
+ /**
47
+ * @internal
48
+ */
49
+ const is_date =
50
+ (visited: Set<Metadata>) =>
51
+ (meta: Metadata): boolean => {
52
+ if (visited.has(meta)) return false;
53
+ visited.add(meta);
54
+
55
+ return (
56
+ meta.natives.some((name) => name === "Date") ||
57
+ meta.arrays.some((array) => is_date(visited)(array.type.value)) ||
58
+ meta.tuples.some((tuple) => tuple.type.elements.some(is_date(visited))) ||
59
+ meta.aliases.some((alias) => is_date(visited)(alias.value))
60
+ );
61
+ };
@@ -0,0 +1,17 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ /**
4
+ * @internal
5
+ */
6
+ export const llm_schema_native = (
7
+ name: string,
8
+ ): ILlmSchema.IString | ILlmSchema.IObject =>
9
+ name === "Blob" || name === "File"
10
+ ? {
11
+ type: "string",
12
+ format: "binary",
13
+ }
14
+ : {
15
+ type: "object",
16
+ properties: {},
17
+ };
@@ -0,0 +1,129 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { CommentFactory } from "../../factories/CommentFactory";
4
+
5
+ import { IJsDocTagInfo } from "../../schemas/metadata/IJsDocTagInfo";
6
+ import { Metadata } from "../../schemas/metadata/Metadata";
7
+ import { MetadataObject } from "../../schemas/metadata/MetadataObject";
8
+
9
+ import { PatternUtil } from "../../utils/PatternUtil";
10
+
11
+ import { application_description } from "./application_description";
12
+ import { llm_schema_station } from "./llm_schema_station";
13
+ import { metadata_to_pattern } from "./metadata_to_pattern";
14
+
15
+ /**
16
+ * @internal
17
+ */
18
+ export const llm_schema_object = (props: {
19
+ object: MetadataObject;
20
+ nullable: boolean;
21
+ }): ILlmSchema.IObject => {
22
+ // ITERATE PROPERTIES
23
+ const properties: Record<string, any> = {};
24
+ const extraMeta: ISuperfluous = {
25
+ patternProperties: {},
26
+ additionalProperties: undefined,
27
+ };
28
+ const required: string[] = [];
29
+
30
+ for (const property of props.object.properties) {
31
+ if (
32
+ // FUNCTIONAL TYPE
33
+ property.value.functional === true &&
34
+ property.value.nullable === false &&
35
+ property.value.isRequired() === true &&
36
+ property.value.size() === 0
37
+ )
38
+ continue;
39
+ else if (property.jsDocTags.find((tag) => tag.name === "hidden")) continue; // THE HIDDEN TAG
40
+
41
+ const key: string | null = property.key.getSoleLiteral();
42
+ const schema: ILlmSchema | null = llm_schema_station({
43
+ blockNever: true,
44
+ attribute: {
45
+ deprecated:
46
+ property.jsDocTags.some((tag) => tag.name === "deprecated") ||
47
+ undefined,
48
+ title: (() => {
49
+ const info: IJsDocTagInfo | undefined = property.jsDocTags.find(
50
+ (tag) => tag.name === "title",
51
+ );
52
+ if (info?.text?.length) return CommentFactory.merge(info.text);
53
+ else if (!property.description?.length) return undefined;
54
+
55
+ const index: number = property.description.indexOf("\n");
56
+ const top: string = (
57
+ index === -1
58
+ ? property.description
59
+ : property.description.substring(0, index)
60
+ ).trim();
61
+ return top.endsWith(".")
62
+ ? top.substring(0, top.length - 1)
63
+ : undefined;
64
+ })(),
65
+ description: application_description(property),
66
+ },
67
+ metadata: property.value,
68
+ });
69
+
70
+ if (schema === null) continue;
71
+ if (key !== null) {
72
+ properties[key] = schema;
73
+ if (property.value.isRequired() === true) required.push(key);
74
+ } else {
75
+ const pattern: string = metadata_to_pattern(true)(property.key);
76
+ if (pattern === PatternUtil.STRING)
77
+ extraMeta.additionalProperties = [property.value, schema];
78
+ else extraMeta.patternProperties[pattern] = [property.value, schema];
79
+ }
80
+ }
81
+
82
+ return {
83
+ type: "object",
84
+ properties,
85
+ nullable: props.nullable,
86
+ required: required.length ? required : undefined,
87
+ title: (() => {
88
+ const info: IJsDocTagInfo | undefined = props.object.jsDocTags.find(
89
+ (tag) => tag.name === "title",
90
+ );
91
+ return info?.text?.length ? CommentFactory.merge(info.text) : undefined;
92
+ })(),
93
+ description: application_description(props.object),
94
+ additionalProperties: join(extraMeta),
95
+ };
96
+ };
97
+
98
+ /**
99
+ * @internal
100
+ */
101
+ const join = (extra: ISuperfluous): ILlmSchema | undefined => {
102
+ // LIST UP METADATA
103
+ const elements: [Metadata, ILlmSchema][] = Object.values(
104
+ extra.patternProperties || {},
105
+ );
106
+ if (extra.additionalProperties) elements.push(extra.additionalProperties);
107
+
108
+ // SHORT RETURN
109
+ if (elements.length === 0) return undefined;
110
+ else if (elements.length === 1) return elements[0]![1]!;
111
+
112
+ // MERGE METADATA AND GENERATE VULNERABLE SCHEMA
113
+ const meta: Metadata = elements
114
+ .map((tuple) => tuple[0])
115
+ .reduce((x, y) => Metadata.merge(x, y));
116
+ return llm_schema_station({
117
+ blockNever: true,
118
+ attribute: {},
119
+ metadata: meta,
120
+ });
121
+ };
122
+
123
+ /**
124
+ * @internal
125
+ */
126
+ interface ISuperfluous {
127
+ additionalProperties?: undefined | [Metadata, ILlmSchema];
128
+ patternProperties: Record<string, [Metadata, ILlmSchema]>;
129
+ }
@@ -0,0 +1,185 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+ import { MetadataAtomic } from "../../schemas/metadata/MetadataAtomic";
5
+
6
+ import { AtomicPredicator } from "../helpers/AtomicPredicator";
7
+ import { application_bigint } from "./application_bigint";
8
+ import { application_boolean } from "./application_boolean";
9
+ import { application_number } from "./application_number";
10
+ import { application_string } from "./application_string";
11
+ import { application_templates } from "./application_templates";
12
+ import { application_v30_constant } from "./application_v30_constant";
13
+ import { llm_schema_array } from "./llm_schema_array";
14
+ import { llm_schema_escaped } from "./llm_schema_escaped";
15
+ import { llm_schema_native } from "./llm_schema_native";
16
+ import { llm_schema_object } from "./llm_schema_object";
17
+ import { llm_schema_tuple } from "./llm_schema_tuple";
18
+
19
+ /**
20
+ * @internal
21
+ */
22
+ export const llm_schema_station = (props: {
23
+ metadata: Metadata;
24
+ blockNever: boolean;
25
+ attribute: ILlmSchema.__IAttribute;
26
+ }): ILlmSchema => {
27
+ // VULNERABLE CASE
28
+ if (props.metadata.any === true)
29
+ return {
30
+ ...props.attribute,
31
+ type: undefined,
32
+ };
33
+ else if (props.metadata.nullable === true && props.metadata.empty() === true)
34
+ return {
35
+ ...props.attribute,
36
+ type: "null",
37
+ };
38
+
39
+ //----
40
+ // GATHER UNION SCHEMAS
41
+ //----
42
+ const union: ILlmSchema[] = [];
43
+ const insert = props.metadata.nullable
44
+ ? (schema: ILlmSchema) =>
45
+ union.push({
46
+ ...schema,
47
+ nullable: (schema as ILlmSchema.__ISignificant<any>).type
48
+ ? true
49
+ : undefined,
50
+ } as ILlmSchema)
51
+ : (schema: ILlmSchema) => union.push(schema);
52
+
53
+ // toJSON() METHOD
54
+ if (props.metadata.escaped !== null)
55
+ llm_schema_escaped(props.metadata.escaped).forEach(insert);
56
+
57
+ // ATOMIC TYPES
58
+ if (
59
+ props.metadata.templates.length &&
60
+ AtomicPredicator.template(props.metadata)
61
+ )
62
+ application_templates<"3.0">(props.metadata).map(insert);
63
+ for (const constant of props.metadata.constants)
64
+ if (AtomicPredicator.constant(props.metadata)(constant.type) === false)
65
+ continue;
66
+ else insert(application_v30_constant(constant));
67
+ for (const a of props.metadata.atomics)
68
+ if (a.type === "boolean") application_boolean<"3.0">(a).forEach(insert);
69
+ else if (a.type === "bigint") application_bigint<"3.0">(a).forEach(insert);
70
+ else if (a.type === "number") application_number<"3.0">(a).forEach(insert);
71
+ else if (a.type === "string") application_string<"3.0">(a).forEach(insert);
72
+
73
+ // ARRAY
74
+ for (const array of props.metadata.arrays)
75
+ if (array.type.recursive)
76
+ throw new Error(
77
+ "Error on LlmSchemaProgrammer.write(): LLM schema does not allow recursive array type.",
78
+ );
79
+ else llm_schema_array(array).forEach(insert);
80
+
81
+ // TUPLE
82
+ for (const tuple of props.metadata.tuples)
83
+ if (tuple.type.recursive)
84
+ throw new Error(
85
+ "Error on LlmSchemaProgrammer.write(): LLM schema does not allow recursive tuple type.",
86
+ );
87
+ else
88
+ insert(
89
+ llm_schema_tuple({
90
+ tuple,
91
+ attribute: props.attribute,
92
+ }),
93
+ );
94
+
95
+ // NATIVES
96
+ for (const native of props.metadata.natives)
97
+ if (AtomicPredicator.native(native)) {
98
+ const type: string = native.toLowerCase();
99
+ if (props.metadata.atomics.some((a) => a.type === type)) continue;
100
+ else if (type === "boolean")
101
+ insert(
102
+ application_boolean<"3.0">(
103
+ MetadataAtomic.create({
104
+ type: "boolean",
105
+ tags: [],
106
+ }),
107
+ )[0]!,
108
+ );
109
+ else if (type === "bigint")
110
+ insert(
111
+ application_bigint(
112
+ MetadataAtomic.create({
113
+ type: "bigint",
114
+ tags: [],
115
+ }),
116
+ )[0]!,
117
+ );
118
+ else if (type === "number")
119
+ insert(
120
+ application_number(
121
+ MetadataAtomic.create({
122
+ type: "number",
123
+ tags: [],
124
+ }),
125
+ )[0]!,
126
+ );
127
+ else if (type === "string")
128
+ insert(
129
+ application_string(
130
+ MetadataAtomic.create({
131
+ type: "string",
132
+ tags: [],
133
+ }),
134
+ )[0]!,
135
+ );
136
+ } else insert(llm_schema_native(native));
137
+ if (props.metadata.sets.length) insert(llm_schema_native("Set"));
138
+ if (props.metadata.maps.length) insert(llm_schema_native("Map"));
139
+
140
+ // OBJECT
141
+ for (const object of props.metadata.objects)
142
+ if (object.recursive)
143
+ throw new Error(
144
+ "Error on LlmSchemaProgrammer.write(): LLM schema does not allow recursive object type.",
145
+ );
146
+ else
147
+ insert(
148
+ llm_schema_object({
149
+ object,
150
+ nullable: props.metadata.nullable,
151
+ }),
152
+ );
153
+
154
+ // ALIASES
155
+ for (const alias of props.metadata.aliases)
156
+ if (alias.recursive)
157
+ throw new Error(
158
+ "Error on LlmSchemaProgrammer.write(): LLM schema does not allow recursive alias type.",
159
+ );
160
+ else
161
+ insert(
162
+ llm_schema_station({
163
+ ...props,
164
+ metadata: alias.value,
165
+ }),
166
+ );
167
+
168
+ //----
169
+ // RETURNS
170
+ //----
171
+ if (union.length === 0 && props.blockNever === true) return null!;
172
+ const schema: ILlmSchema =
173
+ union.length === 0
174
+ ? { type: undefined }
175
+ : union.length === 1
176
+ ? union[0]!
177
+ : { oneOf: union };
178
+ return {
179
+ ...schema,
180
+ ...props.attribute,
181
+ title: props.attribute.title ?? schema.title,
182
+ description: props.attribute.description ?? schema.description,
183
+ deprecated: props.attribute.deprecated ?? schema.deprecated,
184
+ };
185
+ };
@@ -0,0 +1,31 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+ import { MetadataTuple } from "../../schemas/metadata/MetadataTuple";
5
+
6
+ import { llm_schema_station } from "./llm_schema_station";
7
+
8
+ /**
9
+ * @internal
10
+ */
11
+ export const llm_schema_tuple = (props: {
12
+ tuple: MetadataTuple;
13
+ attribute: ILlmSchema.__IAttribute;
14
+ }): ILlmSchema.IArray => ({
15
+ ...props.attribute,
16
+ type: "array",
17
+ items: llm_schema_station({
18
+ blockNever: false,
19
+ attribute: props.attribute,
20
+ metadata: props.tuple.type.elements.reduce(
21
+ (x, y) => Metadata.merge(x.rest ?? x, y.rest ?? y),
22
+ Metadata.initialize(),
23
+ ),
24
+ }),
25
+ minItems: !!props.tuple.type.elements.at(-1)?.rest
26
+ ? props.tuple.type.elements.length - 1
27
+ : props.tuple.type.elements.filter((x) => !x.optional).length,
28
+ maxItems: !!props.tuple.type.elements.at(-1)?.rest
29
+ ? undefined!
30
+ : props.tuple.type.elements.length,
31
+ });
@@ -10,7 +10,7 @@ import { application_v30_schema } from "../internal/application_v30_schema";
10
10
  import { application_v31_schema } from "../internal/application_v31_schema";
11
11
 
12
12
  export namespace JsonApplicationProgrammer {
13
- export const validate = (meta: Metadata) => {
13
+ export const validate = (meta: Metadata): string[] => {
14
14
  const output: string[] = [];
15
15
  if (
16
16
  meta.atomics.some((a) => a.type === "bigint") ||
@@ -0,0 +1,49 @@
1
+ import { ILlmSchema } from "@samchon/openapi";
2
+
3
+ import { Metadata } from "../../schemas/metadata/Metadata";
4
+
5
+ import { AtomicPredicator } from "../helpers/AtomicPredicator";
6
+ import { llm_schema_station } from "../internal/llm_schema_station";
7
+
8
+ export namespace LlmSchemaProgrammer {
9
+ export const validate = (meta: Metadata): string[] => {
10
+ const output: string[] = [];
11
+ if (
12
+ meta.atomics.some((a) => a.type === "bigint") ||
13
+ meta.constants.some((c) => c.type === "bigint")
14
+ )
15
+ output.push("LLM schema does not support bigint type.");
16
+ if (
17
+ meta.tuples.some((t) =>
18
+ t.type.elements.some((e) => e.isRequired() === false),
19
+ ) ||
20
+ meta.arrays.some((a) => a.type.value.isRequired() === false)
21
+ )
22
+ output.push("LLM schema does not support undefined type in array.");
23
+ if (meta.maps.length) output.push("LLM schema does not support Map type.");
24
+ if (meta.sets.length) output.push("LLM schema does not support Set type.");
25
+ for (const native of meta.natives)
26
+ if (
27
+ AtomicPredicator.native(native) === false &&
28
+ native !== "Date" &&
29
+ native !== "Blob" &&
30
+ native !== "File"
31
+ )
32
+ output.push(`LLM schema does not support ${native} type.`);
33
+ if (
34
+ meta.aliases.some((a) => a.recursive) ||
35
+ meta.arrays.some((a) => a.type.recursive) ||
36
+ meta.objects.some((o) => o.recursive) ||
37
+ meta.tuples.some((t) => t.type.recursive)
38
+ )
39
+ output.push("LLM schema does not support recursive type.");
40
+ return output;
41
+ };
42
+
43
+ export const write = (metadata: Metadata): ILlmSchema =>
44
+ llm_schema_station({
45
+ metadata,
46
+ blockNever: true,
47
+ attribute: {},
48
+ });
49
+ }
@@ -1,16 +1,22 @@
1
- import type { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
-
3
- export type IJsonApplication<Version extends "3.0" | "3.1" = "3.1"> =
4
- Version extends "3.0" ? IJsonApplication.IV3_0 : IJsonApplication.IV3_1;
5
- export namespace IJsonApplication {
6
- export interface IV3_0 {
7
- version: "3.0";
8
- schemas: OpenApiV3.IJsonSchema[];
9
- components: OpenApiV3.IComponents;
10
- }
11
- export interface IV3_1 {
12
- version: "3.1";
13
- components: OpenApi.IComponents;
14
- schemas: OpenApi.IJsonSchema[];
15
- }
16
- }
1
+ import type { OpenApi, OpenApiV3 } from "@samchon/openapi";
2
+
3
+ export type IJsonApplication<
4
+ Version extends "3.0" | "3.1" = "3.1",
5
+ Types = unknown[],
6
+ > = Version extends "3.0"
7
+ ? IJsonApplication.IV3_0<Types>
8
+ : IJsonApplication.IV3_1<Types>;
9
+ export namespace IJsonApplication {
10
+ export interface IV3_0<Types = unknown[]> {
11
+ version: "3.0";
12
+ schemas: OpenApiV3.IJsonSchema[];
13
+ components: OpenApiV3.IComponents;
14
+ __types?: Types | undefined;
15
+ }
16
+ export interface IV3_1<Types = unknown[]> {
17
+ version: "3.1";
18
+ components: OpenApi.IComponents;
19
+ schemas: OpenApi.IJsonSchema[];
20
+ __types?: Types | undefined;
21
+ }
22
+ }
@@ -64,6 +64,7 @@ import { JsonIsStringifyTransformer } from "./features/json/JsonIsStringifyTrans
64
64
  import { JsonStringifyTransformer } from "./features/json/JsonStringifyTransformer";
65
65
  import { JsonValidateParseTransformer } from "./features/json/JsonValidateParseTransformer";
66
66
  import { JsonValidateStringifyTransformer } from "./features/json/JsonValidateStringifyTransformer";
67
+ import { LlmSchemaTransformer } from "./features/llm/LlmSchemaTransformer";
67
68
  import { MiscAssertCloneTransformer } from "./features/misc/MiscAssertCloneTransformer";
68
69
  import { MiscAssertPruneTransformer } from "./features/misc/MiscAssertPruneTransformer";
69
70
  import { MiscCloneTransformer } from "./features/misc/MiscCloneTransformer";
@@ -353,9 +354,13 @@ const FUNCTORS: Record<string, Record<string, () => Task>> = {
353
354
  createAssertQuery: () => CreateHttpAssertQueryTransformer.transform,
354
355
  createValidateQuery: () => CreateHttpValidateQueryTransformer.transform,
355
356
  },
357
+ llm: {
358
+ schema: () => (project) => () => LlmSchemaTransformer.transform(project),
359
+ },
356
360
  json: {
357
361
  // SCHEMA
358
- application: () => (P) => () => JsonApplicationTransformer.transform(P),
362
+ application: () => (project) => () =>
363
+ JsonApplicationTransformer.transform(project),
359
364
 
360
365
  // PARSER
361
366
  isParse: () => JsonIsParseTransformer.transform,