ajsc 4.0.0 → 5.0.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/TypescriptBaseConverter.d.ts +14 -1
- package/dist/TypescriptBaseConverter.js +28 -3
- package/dist/TypescriptBaseConverter.js.map +1 -1
- package/dist/TypescriptConverter.additionalProperties.test.js +110 -0
- package/dist/TypescriptConverter.additionalProperties.test.js.map +1 -0
- package/dist/TypescriptConverter.arrays.test.js +130 -0
- package/dist/TypescriptConverter.arrays.test.js.map +1 -0
- package/dist/TypescriptConverter.composites.test.d.ts +1 -0
- package/dist/TypescriptConverter.composites.test.js +13 -0
- package/dist/TypescriptConverter.composites.test.js.map +1 -0
- package/dist/TypescriptConverter.d.ts +56 -9
- package/dist/TypescriptConverter.js +105 -7
- package/dist/TypescriptConverter.js.map +1 -1
- package/dist/TypescriptConverter.objects.test.d.ts +1 -0
- package/dist/TypescriptConverter.objects.test.js +258 -0
- package/dist/TypescriptConverter.objects.test.js.map +1 -0
- package/dist/TypescriptConverter.options.test.d.ts +1 -0
- package/dist/TypescriptConverter.options.test.js +430 -0
- package/dist/TypescriptConverter.options.test.js.map +1 -0
- package/dist/TypescriptConverter.primitives.test.d.ts +1 -0
- package/dist/TypescriptConverter.primitives.test.js +26 -0
- package/dist/TypescriptConverter.primitives.test.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/dist/TypescriptConverter.test.js +0 -325
- package/dist/TypescriptConverter.test.js.map +0 -1
- package/dist/TypescriptProcedureConverter.d.ts +0 -19
- package/dist/TypescriptProcedureConverter.js +0 -54
- package/dist/TypescriptProcedureConverter.js.map +0 -1
- package/dist/TypescriptProcedureConverter.test.js +0 -997
- package/dist/TypescriptProcedureConverter.test.js.map +0 -1
- /package/dist/{TypescriptConverter.test.d.ts → TypescriptConverter.additionalProperties.test.d.ts} +0 -0
- /package/dist/{TypescriptProcedureConverter.test.d.ts → TypescriptConverter.arrays.test.d.ts} +0 -0
|
@@ -10,12 +10,24 @@ export type RefTypes = [
|
|
|
10
10
|
export interface RefTypeNamingConfig {
|
|
11
11
|
/** Base postfixes to try for name collision resolution */
|
|
12
12
|
postfixes: string[];
|
|
13
|
-
/** If true,
|
|
13
|
+
/** If true, singularize array item path segments (e.g. "entries" → "entry", "people" → "person") */
|
|
14
14
|
depluralize?: boolean;
|
|
15
15
|
/** If true, handle "*" path endings with AnyKey/AnyProperty postfixes */
|
|
16
16
|
handleAnySymbol?: boolean;
|
|
17
17
|
/** If true, strip leading "*" from proposed names */
|
|
18
18
|
stripLeadingAnySymbol?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Controls the postfix added to array item type names.
|
|
21
|
+
* - `false` (default) → no postfix, uses property name directly
|
|
22
|
+
* - `string` → custom postfix (e.g. "Item" → ContactsItem, "Element" → ContactsElement)
|
|
23
|
+
*/
|
|
24
|
+
arrayItemNaming?: string | false;
|
|
25
|
+
/**
|
|
26
|
+
* Additional words that should not be singularized when `depluralize` is true.
|
|
27
|
+
* Built-in uncountables: "data", "metadata".
|
|
28
|
+
* @example ["criteria", "alumni", "corpus"]
|
|
29
|
+
*/
|
|
30
|
+
uncountableWords?: string[];
|
|
19
31
|
}
|
|
20
32
|
export type GenerateTypeUtils = {
|
|
21
33
|
getReferencedType(ir: IRNode): string | undefined;
|
|
@@ -41,6 +53,7 @@ export declare abstract class TypescriptBaseConverter {
|
|
|
41
53
|
*/
|
|
42
54
|
protected generateObjectType(ir: IRNode, utils: GenerateTypeUtils): string;
|
|
43
55
|
protected isValidIdentifier(name: string): boolean;
|
|
56
|
+
private singularize;
|
|
44
57
|
protected makeTypeReferenceName(signatureOccurrences: SignatureOccurrenceValue["occurrences"]): string;
|
|
45
58
|
protected getUniqueRefTypeName(signature: string, nodePath: string): RefTypeName;
|
|
46
59
|
protected getReferencedType(ir: IRNode): string | undefined;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import pluralize from "pluralize";
|
|
1
2
|
import { PathUtils } from "./utils/path-utils.js";
|
|
2
3
|
import { toPascalCase } from "./utils/to-pascal-case.js";
|
|
4
|
+
/** Default words that should not be singularized (common programming/API terms). */
|
|
5
|
+
const DEFAULT_UNCOUNTABLE_WORDS = ["data", "metadata"];
|
|
3
6
|
export class TypescriptBaseConverter {
|
|
4
7
|
constructor() {
|
|
5
8
|
this.refTypes = [];
|
|
@@ -14,7 +17,8 @@ export class TypescriptBaseConverter {
|
|
|
14
17
|
],
|
|
15
18
|
handleAnySymbol: true,
|
|
16
19
|
stripLeadingAnySymbol: true,
|
|
17
|
-
depluralize:
|
|
20
|
+
depluralize: true,
|
|
21
|
+
arrayItemNaming: false,
|
|
18
22
|
};
|
|
19
23
|
}
|
|
20
24
|
/**
|
|
@@ -152,6 +156,13 @@ export class TypescriptBaseConverter {
|
|
|
152
156
|
isValidIdentifier(name) {
|
|
153
157
|
return /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
|
|
154
158
|
}
|
|
159
|
+
singularize(word, extraUncountable) {
|
|
160
|
+
const uncountable = [...DEFAULT_UNCOUNTABLE_WORDS, ...(extraUncountable ?? [])];
|
|
161
|
+
if (uncountable.some((u) => word.toLowerCase().endsWith(u.toLowerCase()))) {
|
|
162
|
+
return word;
|
|
163
|
+
}
|
|
164
|
+
return pluralize.singular(word);
|
|
165
|
+
}
|
|
155
166
|
makeTypeReferenceName(signatureOccurrences) {
|
|
156
167
|
const paths = PathUtils.parsePaths(signatureOccurrences.map((occurrence) => occurrence.nodePath));
|
|
157
168
|
const common = PathUtils.commonSequence(paths);
|
|
@@ -165,9 +176,14 @@ export class TypescriptBaseConverter {
|
|
|
165
176
|
const isAnySymbol = lastPathItem === "*";
|
|
166
177
|
const postFixes = [...config.postfixes];
|
|
167
178
|
if (isArrayItem) {
|
|
168
|
-
|
|
179
|
+
if (config.arrayItemNaming !== false) {
|
|
180
|
+
postFixes.unshift(config.arrayItemNaming ?? "Item");
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
postFixes.unshift("");
|
|
184
|
+
}
|
|
169
185
|
if (config.depluralize && path.length > 0 && path[path.length - 1]) {
|
|
170
|
-
path[path.length - 1] = path[path.length - 1].
|
|
186
|
+
path[path.length - 1] = this.singularize(path[path.length - 1], config.uncountableWords);
|
|
171
187
|
}
|
|
172
188
|
}
|
|
173
189
|
else if (config.handleAnySymbol && isAnySymbol) {
|
|
@@ -189,6 +205,15 @@ export class TypescriptBaseConverter {
|
|
|
189
205
|
if (foundSignatureMatch) {
|
|
190
206
|
return foundSignatureMatch[1];
|
|
191
207
|
}
|
|
208
|
+
// Skip empty proposed names (e.g. empty path with no postfix)
|
|
209
|
+
if (!proposedName) {
|
|
210
|
+
postFixIndexToTry++;
|
|
211
|
+
if (postFixIndexToTry >= postFixes.length) {
|
|
212
|
+
this.fallbackCounter++;
|
|
213
|
+
name = "Type" + this.fallbackCounter;
|
|
214
|
+
}
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
192
217
|
const nameAlreadyUsed = this.refTypes.find(([_sig, n]) => n === proposedName);
|
|
193
218
|
if (nameAlreadyUsed) {
|
|
194
219
|
pathsSegmentsToInclude++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypescriptBaseConverter.js","sourceRoot":"","sources":["../src/TypescriptBaseConverter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TypescriptBaseConverter.js","sourceRoot":"","sources":["../src/TypescriptBaseConverter.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,oFAAoF;AACpF,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AAqCvD,MAAM,OAAgB,uBAAuB;IAA7C;QAGY,aAAQ,G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KAAK,GAAqB,CAAC,SAAS,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE1B,MAAM,IAAI,GAAG,IAAI,CAAC,kBAAkB,CAAC,EAAE,EAAE;YACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC;SACrD,CAAC,CAAC;QAEH,uCAAuC;QACvC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;QAErB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { TypescriptConverter } from "./TypescriptConverter.js";
|
|
3
|
+
describe("TypescriptConverter - additionalProperties and patternProperties", () => {
|
|
4
|
+
it("should convert objects with only additionalProperties", async () => {
|
|
5
|
+
expect(new TypescriptConverter({
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
metadata: {
|
|
9
|
+
type: "object",
|
|
10
|
+
additionalProperties: { type: "string" },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
required: ["metadata"],
|
|
14
|
+
}, {
|
|
15
|
+
inlineTypes: true,
|
|
16
|
+
}).code.replace(/\s/g, "")).toEqual(`{metadata: Record<string, string>; }`.replace(/\s/g, ""));
|
|
17
|
+
});
|
|
18
|
+
it("should convert objects with mixed properties & additionalProperties", async () => {
|
|
19
|
+
expect(new TypescriptConverter({
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
metadata: {
|
|
23
|
+
type: "object",
|
|
24
|
+
additionalProperties: { type: "string" },
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
additionalProperties: { type: "string" },
|
|
28
|
+
required: ["metadata"],
|
|
29
|
+
}, {
|
|
30
|
+
inlineTypes: true,
|
|
31
|
+
}).code.replace(/\s/g, "")).toEqual(`({metadata:Record<string,string>;}&(Record<string,string>))`.replace(/\s/g, ""));
|
|
32
|
+
});
|
|
33
|
+
it("should convert objects with complex additionalProperties", async () => {
|
|
34
|
+
expect(new TypescriptConverter({
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
specificProp: {
|
|
38
|
+
type: "string",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
additionalProperties: {
|
|
42
|
+
type: "object",
|
|
43
|
+
properties: {
|
|
44
|
+
subAdditionalProp: { type: "string" },
|
|
45
|
+
},
|
|
46
|
+
additionalProperties: { type: "string" },
|
|
47
|
+
},
|
|
48
|
+
required: ["metadata"],
|
|
49
|
+
}, {
|
|
50
|
+
inlineTypes: true,
|
|
51
|
+
}).code.replace(/\s/g, "")).toEqual(`({specificProp?:string;}&(Record<string,({subAdditionalProp?:string;}&(Record<string,string>))>))`.replace(/\s/g, ""));
|
|
52
|
+
});
|
|
53
|
+
it("should convert { type: 'object', additionalProperties: true } to Record<string, any>", () => {
|
|
54
|
+
expect(new TypescriptConverter({
|
|
55
|
+
type: "object",
|
|
56
|
+
additionalProperties: true,
|
|
57
|
+
}, { inlineTypes: true }).code.replace(/\s/g, "")).toEqual("Record<string,any>".replace(/\s/g, ""));
|
|
58
|
+
});
|
|
59
|
+
it("should render additionalProperties: false without extra Record types", () => {
|
|
60
|
+
expect(new TypescriptConverter({
|
|
61
|
+
type: "object",
|
|
62
|
+
properties: {
|
|
63
|
+
name: { type: "string" },
|
|
64
|
+
},
|
|
65
|
+
additionalProperties: false,
|
|
66
|
+
required: ["name"],
|
|
67
|
+
}, { inlineTypes: true }).code.replace(/\s/g, "")).toEqual("{ name: string; }".replace(/\s/g, ""));
|
|
68
|
+
});
|
|
69
|
+
it("should convert a JSON schema with pattern properties", () => {
|
|
70
|
+
expect(new TypescriptConverter({
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: {
|
|
73
|
+
totalTodo: {
|
|
74
|
+
type: "number",
|
|
75
|
+
},
|
|
76
|
+
totalPastDue: {
|
|
77
|
+
type: "number",
|
|
78
|
+
},
|
|
79
|
+
unassignedTodo: {
|
|
80
|
+
type: "number",
|
|
81
|
+
},
|
|
82
|
+
todoByAssignee: {
|
|
83
|
+
type: "object",
|
|
84
|
+
patternProperties: {
|
|
85
|
+
"^(.*)$": {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: {
|
|
88
|
+
todo: {
|
|
89
|
+
type: "number",
|
|
90
|
+
},
|
|
91
|
+
pastDue: {
|
|
92
|
+
type: "number",
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
required: ["todo", "pastDue"],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: [
|
|
101
|
+
"totalTodo",
|
|
102
|
+
"totalPastDue",
|
|
103
|
+
"unassignedTodo",
|
|
104
|
+
"todoByAssignee",
|
|
105
|
+
],
|
|
106
|
+
title: "Root",
|
|
107
|
+
}).code.replace(/\s/g, "")).toEqual("export type TodoByAssignee = Record<string, { todo: number; pastDue: number; }>;export type Root = { totalTodo: number; totalPastDue: number; unassignedTodo: number; todoByAssignee: TodoByAssignee; };".replace(/\s/g, ""));
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
//# sourceMappingURL=TypescriptConverter.additionalProperties.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypescriptConverter.additionalProperties.test.js","sourceRoot":"","sources":["../src/TypescriptConverter.additionalProperties.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,QAAQ,CAAC,kEAAkE,EAAE,GAAG,EAAE;IAChF,EAAE,CAAC,uDAAuD,EAAE,KAAK,IAAI,EAAE;QACrE,MAAM,CACJ,IAA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;YACd,UAAU,EAAE;gBACV,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;iBACf;gBACD,YAAY,EAAE;oBACZ,IAAI,EAAE,QAAQ;iBACf;gBACD,cAAc,EAAE;oBACd,IAAI,EAAE,QAAQ;iBACf;gBACD,cAAc,EAAE;oBACd,IAAI,EAAE,QAAQ;oBACd,iBAAiB,EAAE;wBACjB,QAAQ,EAAE;4BACR,IAAI,EAAE,QAAQ;4BACd,UAAU,EAAE;gCACV,IAAI,EAAE;oCACJ,IAAI,EAAE,QAAQ;iCACf;gCACD,OAAO,EAAE;oCACP,IAAI,EAAE,QAAQ;iCACf;6BACF;4BACD,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;yBAC9B;qBACF;iBACF;aACF;YACD,QAAQ,EAAE;gBACR,WAAW;gBACX,cAAc;gBACd,gBAAgB;gBAChB,gBAAgB;aACjB;YACD,KAAK,EAAE,MAAM;SACd,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3B,CAAC,OAAO,CACP,0MAA0M,CAAC,OAAO,CAChN,KAAK,EACL,EAAE,CACH,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { TypescriptConverter } from "./TypescriptConverter.js";
|
|
3
|
+
describe("TypescriptConverter - arrays (inlineTypes)", () => {
|
|
4
|
+
it("should convert arrays", () => {
|
|
5
|
+
expect(new TypescriptConverter({
|
|
6
|
+
title: "MyArray",
|
|
7
|
+
type: "array",
|
|
8
|
+
items: {
|
|
9
|
+
type: "object",
|
|
10
|
+
properties: { name: { type: "string" } },
|
|
11
|
+
required: ["name"],
|
|
12
|
+
},
|
|
13
|
+
}, {
|
|
14
|
+
inlineTypes: true,
|
|
15
|
+
}).code.replace(/\s/g, "")).toEqual("Array<{name:string;}>".replace(/\s/g, ""));
|
|
16
|
+
});
|
|
17
|
+
it("should convert an array of objects", () => {
|
|
18
|
+
expect(new TypescriptConverter({
|
|
19
|
+
type: "array",
|
|
20
|
+
items: {
|
|
21
|
+
anyOf: [
|
|
22
|
+
{
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
year: { type: "number" },
|
|
26
|
+
},
|
|
27
|
+
required: ["year"],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
title: { type: "string" },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
}, {
|
|
38
|
+
inlineTypes: true,
|
|
39
|
+
}).code).toMatch(`Array<{ year: number; } | { title?: string; }>`);
|
|
40
|
+
});
|
|
41
|
+
it("should convert a named JSON schema top-level array to Typescript", () => {
|
|
42
|
+
expect(new TypescriptConverter({
|
|
43
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
44
|
+
title: "People",
|
|
45
|
+
type: "array",
|
|
46
|
+
items: {
|
|
47
|
+
type: "object",
|
|
48
|
+
properties: {
|
|
49
|
+
name: { type: "string" },
|
|
50
|
+
age: { type: "number" },
|
|
51
|
+
},
|
|
52
|
+
required: ["name", "age"],
|
|
53
|
+
},
|
|
54
|
+
}, {
|
|
55
|
+
inlineTypes: true,
|
|
56
|
+
}).code.replace(/\s/g, "")).toEqual(`Array<{ name: string; age: number; }>`.replace(/\s/g, ""));
|
|
57
|
+
});
|
|
58
|
+
it("should render tuple types as [T1, T2, ...]", () => {
|
|
59
|
+
expect(new TypescriptConverter({
|
|
60
|
+
type: "array",
|
|
61
|
+
items: [{ type: "string" }, { type: "number" }],
|
|
62
|
+
}, { inlineTypes: true }).code).toBe("[string, number]");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe("TypescriptConverter - arrays (full type defs)", () => {
|
|
66
|
+
it("should convert arrays", () => {
|
|
67
|
+
expect(new TypescriptConverter({
|
|
68
|
+
title: "MyArray",
|
|
69
|
+
type: "array",
|
|
70
|
+
items: {
|
|
71
|
+
type: "object",
|
|
72
|
+
properties: { name: { type: "string" } },
|
|
73
|
+
required: ["name"],
|
|
74
|
+
},
|
|
75
|
+
}, {}).code.replace(/\s/g, "")).toEqual("export type Type={name:string;}; export type MyArray=Array<Type>;".replace(/\s/g, ""));
|
|
76
|
+
});
|
|
77
|
+
it("should convert an array of objects", () => {
|
|
78
|
+
expect(new TypescriptConverter({
|
|
79
|
+
type: "array",
|
|
80
|
+
items: {
|
|
81
|
+
anyOf: [
|
|
82
|
+
{
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: {
|
|
85
|
+
year: { type: "number" },
|
|
86
|
+
},
|
|
87
|
+
required: ["year"],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: "object",
|
|
91
|
+
properties: {
|
|
92
|
+
title: { type: "string" },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
}, {}).code.replace(/\s/g, "")).toMatch(`
|
|
98
|
+
export type Type = { year: number; };
|
|
99
|
+
|
|
100
|
+
export type Element = { title?: string; };
|
|
101
|
+
|
|
102
|
+
export type Root = Array<Type | Element>;
|
|
103
|
+
`.replace(/\s/g, ""));
|
|
104
|
+
});
|
|
105
|
+
it("should convert a named JSON schema top-level array to Typescript", () => {
|
|
106
|
+
expect(new TypescriptConverter({
|
|
107
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
108
|
+
title: "People",
|
|
109
|
+
type: "array",
|
|
110
|
+
items: {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: {
|
|
113
|
+
name: { type: "string" },
|
|
114
|
+
age: { type: "number" },
|
|
115
|
+
},
|
|
116
|
+
required: ["name", "age"],
|
|
117
|
+
},
|
|
118
|
+
}, {}).code.replace(/\s/g, "")).toEqual(`
|
|
119
|
+
export type Type = {name:string;age:number;};
|
|
120
|
+
|
|
121
|
+
export type People = Array<Type>;`.replace(/\s/g, ""));
|
|
122
|
+
});
|
|
123
|
+
it("should render tuple types as [T1, T2, ...]", () => {
|
|
124
|
+
expect(new TypescriptConverter({
|
|
125
|
+
type: "array",
|
|
126
|
+
items: [{ type: "string" }, { type: "number" }],
|
|
127
|
+
}, {}).code.replace(/\s/g, "")).toBe(`export type Root = [string, number];`.replace(/\s/g, ""));
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
//# sourceMappingURL=TypescriptConverter.arrays.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypescriptConverter.arrays.test.js","sourceRoot":"","sources":["../src/TypescriptConverter.arrays.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IAC1D,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,CACJ,IAAI,mBAAmB,CACrB;YACE,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;gBACxC,QAAQ,EAAE,CAAC,MAAM,CAAC;aACnB;SACF,EACD;YACE,WAAW,EAAE,IAAI;SAClB,CACF,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1B,CAAC,OAAO,CAAC,uBAAuB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CACJ,IAAI,mBAAmB,CACrB;YACE,IAAI,EAAE,OAAO;YACb,KAAK,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AC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,CACJ,IAAI,mBAAmB,CACrB;YACE,OAAO,EAAE,yCAAyC;YAClD,KAAK,EAAE,QAAQ;YACf,IAAI,EAAE,OAAO;YACb,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;oBACxB,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;iBACxB;gBACD,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;aAC1B;SACF,EACD,EAAE,CACH,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1B,CAAC,OAAO,CACP;;;kCAG4B,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAChD,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;QACpD,MAAM,CACJ,IAAI,mBAAmB,CACrB;YACE,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SAChD,EACD,EAAE,CACH,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAC1B,CAAC,IAAI,CAAC,sCAAsC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { TypescriptConverter } from "./TypescriptConverter.js";
|
|
3
|
+
describe("TypescriptConverter - unions and intersections", () => {
|
|
4
|
+
it("should convert unions", () => {
|
|
5
|
+
expect(new TypescriptConverter({ type: ["string", "number"] }).code).toMatch(`string | number`);
|
|
6
|
+
});
|
|
7
|
+
it("should convert intersections", () => {
|
|
8
|
+
expect(new TypescriptConverter({
|
|
9
|
+
allOf: [{ type: "string" }, { type: "number" }],
|
|
10
|
+
}).code).toMatch(`string & number`);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=TypescriptConverter.composites.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypescriptConverter.composites.test.js","sourceRoot":"","sources":["../src/TypescriptConverter.composites.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;IAC9D,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;QAC/B,MAAM,CACJ,IAAI,mBAAmB,CAAC,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,IAAI,CAC7D,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CACJ,IAAI,mBAAmB,CAAC;YACtB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SAChD,CAAC,CAAC,IAAI,CACR,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,18 +1,65 @@
|
|
|
1
|
-
import { ILanguageConverter } from "./types.js";
|
|
2
|
-
import { TypescriptBaseConverter } from "./TypescriptBaseConverter.js";
|
|
1
|
+
import { ILanguageConverter, IRNode } from "./types.js";
|
|
2
|
+
import { RefTypeNamingConfig, TypescriptBaseConverter } from "./TypescriptBaseConverter.js";
|
|
3
3
|
import { JSONSchema7Definition } from "json-schema";
|
|
4
|
+
export interface TypescriptConverterOpts {
|
|
5
|
+
/**
|
|
6
|
+
* If true, referenced types will not be created for objects and instead
|
|
7
|
+
* the object type will be inlined.
|
|
8
|
+
*/
|
|
9
|
+
inlineTypes?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Controls the postfix added to array item type names.
|
|
12
|
+
* - `false` (default) → no postfix, uses property name directly
|
|
13
|
+
* - `string` → custom postfix (e.g. "Item" → ContactsItem, "Element" → ContactsElement)
|
|
14
|
+
*/
|
|
15
|
+
arrayItemNaming?: string | false;
|
|
16
|
+
/**
|
|
17
|
+
* If true (default), singularize array item path segments when generating type names.
|
|
18
|
+
* Handles irregular plurals (e.g. "entries" → "Entry", "people" → "Person").
|
|
19
|
+
*/
|
|
20
|
+
depluralize?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Controls how enum values are emitted.
|
|
23
|
+
* - `"union"` (default) → `"a" | "b" | "c"`
|
|
24
|
+
* - `"enum"` → `export enum Status { A = "a", B = "b", C = "c" }`
|
|
25
|
+
* Only applies when `inlineTypes` is false and all values are strings.
|
|
26
|
+
*/
|
|
27
|
+
enumStyle?: "union" | "enum";
|
|
28
|
+
/**
|
|
29
|
+
* Additional words that should not be singularized when `depluralize` is true.
|
|
30
|
+
* Built-in uncountables: "data", "metadata".
|
|
31
|
+
* @example ["criteria", "alumni", "corpus"]
|
|
32
|
+
*/
|
|
33
|
+
uncountableWords?: string[];
|
|
34
|
+
}
|
|
4
35
|
/**
|
|
5
36
|
* A TypeScript language converter plugin.
|
|
6
37
|
*/
|
|
7
38
|
export declare class TypescriptConverter extends TypescriptBaseConverter implements ILanguageConverter {
|
|
8
39
|
readonly language = "typescript";
|
|
9
40
|
private schemaConverter;
|
|
41
|
+
private opts;
|
|
42
|
+
private inlineTypes;
|
|
43
|
+
private enumStyle;
|
|
44
|
+
/**
|
|
45
|
+
* Stores enum declarations keyed by canonical signature (sorted JSON values)
|
|
46
|
+
* for deduplication across the schema.
|
|
47
|
+
*/
|
|
48
|
+
private enumDeclarations;
|
|
49
|
+
/** Tracks all enum declaration names for collision resolution */
|
|
50
|
+
private usedEnumNames;
|
|
10
51
|
readonly code: string;
|
|
11
|
-
constructor(schema: JSONSchema7Definition, opts?:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
52
|
+
constructor(schema: JSONSchema7Definition, opts?: TypescriptConverterOpts);
|
|
53
|
+
protected getRefTypeNamingConfig(): RefTypeNamingConfig;
|
|
54
|
+
protected generateEnumType(ir: IRNode): string;
|
|
55
|
+
protected generateLiteralType(ir: IRNode): string;
|
|
56
|
+
/**
|
|
57
|
+
* Returns (or creates) a deduplicated enum declaration for the given string values.
|
|
58
|
+
* Same set of values at different paths reuses the same enum.
|
|
59
|
+
*/
|
|
60
|
+
private getOrCreateEnumDeclaration;
|
|
61
|
+
/**
|
|
62
|
+
* Converts a string value to a valid PascalCase enum member name.
|
|
63
|
+
*/
|
|
64
|
+
private toEnumMemberName;
|
|
18
65
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TypescriptBaseConverter, } from "./TypescriptBaseConverter.js";
|
|
2
2
|
import { JSONSchemaConverter } from "./JSONSchemaConverter.js";
|
|
3
|
+
import { toPascalCase } from "./utils/to-pascal-case.js";
|
|
3
4
|
/**
|
|
4
5
|
* A TypeScript language converter plugin.
|
|
5
6
|
*/
|
|
@@ -7,27 +8,124 @@ export class TypescriptConverter extends TypescriptBaseConverter {
|
|
|
7
8
|
constructor(schema, opts) {
|
|
8
9
|
super();
|
|
9
10
|
this.language = "typescript";
|
|
11
|
+
/**
|
|
12
|
+
* Stores enum declarations keyed by canonical signature (sorted JSON values)
|
|
13
|
+
* for deduplication across the schema.
|
|
14
|
+
*/
|
|
15
|
+
this.enumDeclarations = new Map();
|
|
16
|
+
/** Tracks all enum declaration names for collision resolution */
|
|
17
|
+
this.usedEnumNames = new Set();
|
|
18
|
+
this.opts = opts;
|
|
19
|
+
this.inlineTypes = opts?.inlineTypes ?? false;
|
|
20
|
+
this.enumStyle = opts?.enumStyle ?? "union";
|
|
10
21
|
this.schemaConverter = new JSONSchemaConverter(schema);
|
|
11
22
|
if (!this.schemaConverter.irNode.name) {
|
|
12
23
|
this.schemaConverter.irNode.name = "Root";
|
|
13
24
|
}
|
|
14
25
|
const code = this.generateType(this.schemaConverter.irNode, {
|
|
15
|
-
getReferencedType:
|
|
26
|
+
getReferencedType: this.inlineTypes
|
|
16
27
|
? () => undefined
|
|
17
28
|
: this.getReferencedType.bind(this),
|
|
18
29
|
});
|
|
19
30
|
const rootName = this.schemaConverter.irNode.name;
|
|
20
|
-
if (!
|
|
21
|
-
|
|
31
|
+
if (!this.inlineTypes) {
|
|
32
|
+
const enumCode = [...this.enumDeclarations.values()]
|
|
33
|
+
.map(({ name, members }) => {
|
|
34
|
+
const body = members
|
|
35
|
+
.map(({ key, value }) => `${key} = ${JSON.stringify(value)}`)
|
|
36
|
+
.join(", ");
|
|
37
|
+
return `export enum ${name} { ${body} }`;
|
|
38
|
+
})
|
|
39
|
+
.join("\n");
|
|
40
|
+
const typeCode = this.refTypes
|
|
22
41
|
.map(([_sig, name, { code }]) => `export type ${name} = ${code};`)
|
|
23
|
-
.join("\n")
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`;
|
|
42
|
+
.join("\n");
|
|
43
|
+
const allDecls = [enumCode, typeCode].filter(Boolean).join("\n");
|
|
44
|
+
this.code = `${allDecls}\n\nexport type ${rootName} = ${code};\n`;
|
|
27
45
|
}
|
|
28
46
|
else {
|
|
29
47
|
this.code = `${code}`;
|
|
30
48
|
}
|
|
31
49
|
}
|
|
50
|
+
getRefTypeNamingConfig() {
|
|
51
|
+
const base = super.getRefTypeNamingConfig();
|
|
52
|
+
return {
|
|
53
|
+
...base,
|
|
54
|
+
...(this.opts?.arrayItemNaming !== undefined && {
|
|
55
|
+
arrayItemNaming: this.opts.arrayItemNaming,
|
|
56
|
+
}),
|
|
57
|
+
...(this.opts?.depluralize !== undefined && {
|
|
58
|
+
depluralize: this.opts.depluralize,
|
|
59
|
+
}),
|
|
60
|
+
...(this.opts?.uncountableWords !== undefined && {
|
|
61
|
+
uncountableWords: this.opts.uncountableWords,
|
|
62
|
+
}),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
generateEnumType(ir) {
|
|
66
|
+
if (this.enumStyle === "enum" &&
|
|
67
|
+
!this.inlineTypes &&
|
|
68
|
+
ir.values?.every((v) => typeof v === "string")) {
|
|
69
|
+
return this.getOrCreateEnumDeclaration(ir.values, ir.path);
|
|
70
|
+
}
|
|
71
|
+
return super.generateEnumType(ir);
|
|
72
|
+
}
|
|
73
|
+
generateLiteralType(ir) {
|
|
74
|
+
if (this.enumStyle === "enum" &&
|
|
75
|
+
!this.inlineTypes &&
|
|
76
|
+
typeof ir.constraints?.value === "string") {
|
|
77
|
+
return this.getOrCreateEnumDeclaration([ir.constraints.value], ir.path);
|
|
78
|
+
}
|
|
79
|
+
return super.generateLiteralType(ir);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns (or creates) a deduplicated enum declaration for the given string values.
|
|
83
|
+
* Same set of values at different paths reuses the same enum.
|
|
84
|
+
*/
|
|
85
|
+
getOrCreateEnumDeclaration(values, path) {
|
|
86
|
+
const canonicalKey = JSON.stringify([...values].sort());
|
|
87
|
+
const existing = this.enumDeclarations.get(canonicalKey);
|
|
88
|
+
if (existing) {
|
|
89
|
+
return existing.name;
|
|
90
|
+
}
|
|
91
|
+
// Derive name from last path segment
|
|
92
|
+
const lastSegment = path.split(".").filter(Boolean).slice(-1)[0] || "Value";
|
|
93
|
+
let baseName = toPascalCase(lastSegment);
|
|
94
|
+
// Resolve naming collisions with counter suffix
|
|
95
|
+
let enumName = baseName;
|
|
96
|
+
let counter = 2;
|
|
97
|
+
while (this.usedEnumNames.has(enumName)) {
|
|
98
|
+
enumName = baseName + counter;
|
|
99
|
+
counter++;
|
|
100
|
+
}
|
|
101
|
+
this.usedEnumNames.add(enumName);
|
|
102
|
+
// Build members with collision resolution
|
|
103
|
+
const usedMemberNames = new Set();
|
|
104
|
+
const members = values.map((value) => {
|
|
105
|
+
let memberName = this.toEnumMemberName(value);
|
|
106
|
+
let memberBase = memberName;
|
|
107
|
+
let memberCounter = 2;
|
|
108
|
+
while (usedMemberNames.has(memberName)) {
|
|
109
|
+
memberName = memberBase + memberCounter;
|
|
110
|
+
memberCounter++;
|
|
111
|
+
}
|
|
112
|
+
usedMemberNames.add(memberName);
|
|
113
|
+
return { key: memberName, value };
|
|
114
|
+
});
|
|
115
|
+
this.enumDeclarations.set(canonicalKey, { name: enumName, members });
|
|
116
|
+
return enumName;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Converts a string value to a valid PascalCase enum member name.
|
|
120
|
+
*/
|
|
121
|
+
toEnumMemberName(value) {
|
|
122
|
+
let name = toPascalCase(value);
|
|
123
|
+
name = name.replace(/[^a-zA-Z0-9_]/g, "");
|
|
124
|
+
if (/^\d/.test(name))
|
|
125
|
+
name = "_" + name;
|
|
126
|
+
if (!name)
|
|
127
|
+
name = "Value";
|
|
128
|
+
return name;
|
|
129
|
+
}
|
|
32
130
|
}
|
|
33
131
|
//# sourceMappingURL=TypescriptConverter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypescriptConverter.js","sourceRoot":"","sources":["../src/TypescriptConverter.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"TypescriptConverter.js","sourceRoot":"","sources":["../src/TypescriptConverter.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAA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