@kubb/plugin-ts 3.0.0-alpha.21 → 3.0.0-alpha.25
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/{chunk-3IKQZT26.cjs → chunk-244JFDSP.cjs} +11 -4
- package/dist/chunk-244JFDSP.cjs.map +1 -0
- package/dist/{chunk-CPJWNK44.js → chunk-6RUGX3HO.js} +3 -3
- package/dist/{chunk-CPJWNK44.js.map → chunk-6RUGX3HO.js.map} +1 -1
- package/dist/{chunk-YLKAQOZ5.cjs → chunk-NZK6SFX6.cjs} +11 -11
- package/dist/{chunk-YLKAQOZ5.cjs.map → chunk-NZK6SFX6.cjs.map} +1 -1
- package/dist/{chunk-CAATRNVS.js → chunk-QYQBCICA.js} +11 -4
- package/dist/chunk-QYQBCICA.js.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/package.json +10 -10
- package/src/components/Type.tsx +1 -1
- package/src/generators/__snapshots__/createPet.ts +8 -1
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +8 -1
- package/src/generators/__snapshots__/nullConstNull.ts +3 -2
- package/src/generators/__snapshots__/petQuestionToken.ts +5 -1
- package/src/generators/__snapshots__/petQuestionTokenAndUndefined.ts +5 -1
- package/src/generators/__snapshots__/petUndefined.ts +5 -1
- package/src/generators/__snapshots__/petsStoreAdvancedDiscriminator.ts +31 -0
- package/src/generators/__snapshots__/readOnly.ts +20 -0
- package/src/parser/index.ts +11 -2
- package/dist/chunk-3IKQZT26.cjs.map +0 -1
- package/dist/chunk-CAATRNVS.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-ts",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.25",
|
|
4
4
|
"description": "Generator plugin-ts",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"zod",
|
|
@@ -58,23 +58,23 @@
|
|
|
58
58
|
"!/**/__tests__/**"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@kubb/core": "3.0.0-alpha.
|
|
62
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
63
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
64
|
-
"@kubb/parser-ts": "3.0.0-alpha.
|
|
65
|
-
"@kubb/plugin-oas": "3.0.0-alpha.
|
|
66
|
-
"@kubb/react": "3.0.0-alpha.
|
|
61
|
+
"@kubb/core": "3.0.0-alpha.25",
|
|
62
|
+
"@kubb/fs": "3.0.0-alpha.25",
|
|
63
|
+
"@kubb/oas": "3.0.0-alpha.25",
|
|
64
|
+
"@kubb/parser-ts": "3.0.0-alpha.25",
|
|
65
|
+
"@kubb/plugin-oas": "3.0.0-alpha.25",
|
|
66
|
+
"@kubb/react": "3.0.0-alpha.25"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/react": "^18.3.8",
|
|
70
70
|
"react": "^18.3.1",
|
|
71
71
|
"tsup": "^8.3.0",
|
|
72
72
|
"typescript": "^5.6.2",
|
|
73
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
74
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
73
|
+
"@kubb/config-ts": "3.0.0-alpha.25",
|
|
74
|
+
"@kubb/config-tsup": "3.0.0-alpha.25"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@kubb/react": "3.0.0-alpha.
|
|
77
|
+
"@kubb/react": "3.0.0-alpha.25"
|
|
78
78
|
},
|
|
79
79
|
"engines": {
|
|
80
80
|
"node": ">=20"
|
package/src/components/Type.tsx
CHANGED
|
@@ -79,7 +79,7 @@ export function Type({ name, typedName, tree, keysToOmit, optionalType, enumType
|
|
|
79
79
|
|
|
80
80
|
const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum)
|
|
81
81
|
|
|
82
|
-
const enums = enumSchemas.map((enumSchema) => {
|
|
82
|
+
const enums = [...new Set(enumSchemas)].map((enumSchema) => {
|
|
83
83
|
const name = enumType === 'asPascalConst' ? transformers.pascalCase(enumSchema.args.name) : transformers.camelCase(enumSchema.args.name)
|
|
84
84
|
const typeName = enumSchema.args.typeName
|
|
85
85
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
2
3
|
* @description Null response
|
|
3
4
|
*/
|
|
4
5
|
export type CreatePets201 = (error & {
|
|
6
|
+
/**
|
|
7
|
+
* @type object | undefined
|
|
8
|
+
*/
|
|
5
9
|
name?: errorCode;
|
|
6
10
|
});
|
|
7
11
|
|
|
@@ -25,6 +29,9 @@ export type CreatePetsError = error;
|
|
|
25
29
|
* @description Null response
|
|
26
30
|
*/
|
|
27
31
|
export type CreatePetsMutationResponse = (error & {
|
|
32
|
+
/**
|
|
33
|
+
* @type object | undefined
|
|
34
|
+
*/
|
|
28
35
|
name?: errorCode;
|
|
29
36
|
});
|
|
30
37
|
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
2
3
|
* @description Null response
|
|
3
4
|
*/
|
|
4
5
|
export type CreatePets201 = (error & {
|
|
6
|
+
/**
|
|
7
|
+
* @type object | undefined
|
|
8
|
+
*/
|
|
5
9
|
name?: errorCode;
|
|
6
10
|
});
|
|
7
11
|
|
|
@@ -25,6 +29,9 @@ export type CreatePetsError = error;
|
|
|
25
29
|
* @description Null response
|
|
26
30
|
*/
|
|
27
31
|
export type CreatePetsMutationResponse = (error & {
|
|
32
|
+
/**
|
|
33
|
+
* @type object | undefined
|
|
34
|
+
*/
|
|
28
35
|
name?: errorCode;
|
|
29
36
|
});
|
|
30
37
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @description The value of this keyword MAY be null.\nUse of this keyword is functionally equivalent to an \"enum\" (Section 6.1.2) with a single value.\nAn instance validates successfully against this keyword if its value is equal to the value of the keyword.\n
|
|
3
4
|
*/
|
|
4
5
|
export type nullConst = {
|
|
5
6
|
withoutValue?: null;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export type pet = {
|
|
2
3
|
/**
|
|
3
4
|
* @type integer, int64
|
|
4
5
|
*/
|
|
@@ -11,5 +12,8 @@ export type pet = {
|
|
|
11
12
|
* @type string | undefined
|
|
12
13
|
*/
|
|
13
14
|
tag?: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @type object | undefined
|
|
17
|
+
*/
|
|
14
18
|
category?: category | undefined;
|
|
15
19
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export type pet = {
|
|
2
3
|
/**
|
|
3
4
|
* @type integer, int64
|
|
4
5
|
*/
|
|
@@ -11,5 +12,8 @@ export type pet = {
|
|
|
11
12
|
* @type string | undefined
|
|
12
13
|
*/
|
|
13
14
|
tag: string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* @type object | undefined
|
|
17
|
+
*/
|
|
14
18
|
category: category | undefined;
|
|
15
19
|
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
export const advancedTypeEnum2 = {
|
|
3
|
+
"enum": "enum",
|
|
4
|
+
"range": "range",
|
|
5
|
+
"regex": "regex",
|
|
6
|
+
"slider": "slider"
|
|
7
|
+
} as const;
|
|
8
|
+
|
|
9
|
+
export type AdvancedTypeEnum2 = (typeof advancedTypeEnum2)[keyof typeof advancedTypeEnum2];
|
|
10
|
+
|
|
11
|
+
export type advanced = ((enumerationValueSpecificationDto & {
|
|
12
|
+
/**
|
|
13
|
+
* @type string
|
|
14
|
+
*/
|
|
15
|
+
readonly type: AdvancedTypeEnum2;
|
|
16
|
+
}) | (rangeValueSpecificationDto & {
|
|
17
|
+
/**
|
|
18
|
+
* @type string
|
|
19
|
+
*/
|
|
20
|
+
readonly type: AdvancedTypeEnum2;
|
|
21
|
+
}) | (regexValueSpecificationDto & {
|
|
22
|
+
/**
|
|
23
|
+
* @type string
|
|
24
|
+
*/
|
|
25
|
+
readonly type: AdvancedTypeEnum2;
|
|
26
|
+
}) | (sliderValueSpecificationDto & {
|
|
27
|
+
/**
|
|
28
|
+
* @type string
|
|
29
|
+
*/
|
|
30
|
+
readonly type: AdvancedTypeEnum2;
|
|
31
|
+
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
export type demo = {
|
|
3
|
+
/**
|
|
4
|
+
* @type integer | undefined
|
|
5
|
+
*/
|
|
6
|
+
readonly attribute_readonly?: number;
|
|
7
|
+
/**
|
|
8
|
+
* @description not required
|
|
9
|
+
* @type integer | undefined
|
|
10
|
+
*/
|
|
11
|
+
attribute_writeOnly?: number;
|
|
12
|
+
/**
|
|
13
|
+
* @type integer | undefined
|
|
14
|
+
*/
|
|
15
|
+
readonly attribute_with_ref?: attributeReadonly;
|
|
16
|
+
/**
|
|
17
|
+
* @type integer | undefined
|
|
18
|
+
*/
|
|
19
|
+
attribute_with_ref_readonly?: attributeWriteOnly;
|
|
20
|
+
};
|
package/src/parser/index.ts
CHANGED
|
@@ -54,12 +54,20 @@ export const typeKeywordMapper = {
|
|
|
54
54
|
nodes,
|
|
55
55
|
})
|
|
56
56
|
},
|
|
57
|
-
const: (name?: string | number, format?: 'string' | 'number') => {
|
|
57
|
+
const: (name?: string | number | boolean, format?: 'string' | 'number' | 'boolean') => {
|
|
58
58
|
if (!name) {
|
|
59
59
|
return undefined
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
if (format === '
|
|
62
|
+
if (format === 'boolean') {
|
|
63
|
+
if (name === true) {
|
|
64
|
+
return factory.createLiteralTypeNode(factory.createTrue())
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return factory.createLiteralTypeNode(factory.createFalse())
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (format === 'number' && typeof name === 'number') {
|
|
63
71
|
return factory.createLiteralTypeNode(factory.createNumericLiteral(name))
|
|
64
72
|
}
|
|
65
73
|
|
|
@@ -95,6 +103,7 @@ export const typeKeywordMapper = {
|
|
|
95
103
|
password: undefined,
|
|
96
104
|
phone: undefined,
|
|
97
105
|
readOnly: undefined,
|
|
106
|
+
writeOnly: undefined,
|
|
98
107
|
ref: (propertyName?: string) => {
|
|
99
108
|
if (!propertyName) {
|
|
100
109
|
return undefined
|