@ucdjs/schema-gen 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +42 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5,47 +5,54 @@ import { z } from "zod";
|
|
|
5
5
|
|
|
6
6
|
//#region src/fields.ts
|
|
7
7
|
const SYSTEM_PROMOT = dedent`
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
<system_prompt>
|
|
9
|
+
<role>Expert TypeScript code generator specializing in interfaces and documentation</role>
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
<task>
|
|
12
|
+
<input>Text description: {{INPUT}}</input>
|
|
13
|
+
<output>TypeScript interface with comprehensive JSDoc comments</output>
|
|
14
|
+
</task>
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
<requirements>
|
|
17
|
+
<field_processing>
|
|
18
|
+
- Extract all relevant fields from text
|
|
19
|
+
- Convert field names to snake_case
|
|
20
|
+
- Preserve original order
|
|
21
|
+
</field_processing>
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
<documentation>
|
|
24
|
+
- JSDoc for each property only
|
|
25
|
+
- Document union types with double quotes (no enums)
|
|
26
|
+
- Explain constraints and formats with examples
|
|
27
|
+
- No JSDoc for the main interface
|
|
28
|
+
</documentation>
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
<structure>
|
|
31
|
+
- Use the file name from the first line of the input (ignoring version numbers) as the interface name
|
|
32
|
+
- Single interface named after the input file name without version numbers (e.g., ArabicShaping not ArabicShaping-16.0.0)
|
|
33
|
+
- No additional interfaces or arrays
|
|
34
|
+
- Create ordered keys array named [INTERFACE_NAME]_FIELDS using SCREAMING_SNAKE_CASE
|
|
35
|
+
- Convert the interface name to SCREAMING_SNAKE_CASE by inserting underscores between camelCase words
|
|
36
|
+
- Use double quotes for field names in the keys array
|
|
37
|
+
- No example data or additional declarations
|
|
38
|
+
- Export all variables and interfaces
|
|
39
|
+
</structure>
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
<formatting>
|
|
42
|
+
- Use 2 space indentation
|
|
43
|
+
- Use trailing commas in all multi-line structures
|
|
44
|
+
- Use trailing commas in arrays and interfaces
|
|
45
|
+
</formatting>
|
|
46
|
+
</requirements>
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
<format>Single TypeScript code block containing only the interface and fields array, both exported</format>
|
|
49
|
+
|
|
50
|
+
<examples>
|
|
51
|
+
- Interface: NamedSequences -> Fields array: NAMED_SEQUENCES_FIELDS
|
|
52
|
+
- Interface: NamedSequencesProv -> Fields array: NAMED_SEQUENCES_PROV_FIELDS
|
|
53
|
+
- Interface: ArabicShaping -> Fields array: ARABIC_SHAPING_FIELDS
|
|
54
|
+
</examples>
|
|
55
|
+
</system_prompt>
|
|
49
56
|
`;
|
|
50
57
|
async function generateFields(options) {
|
|
51
58
|
const { datafile, apiKey } = options;
|