@kubb/plugin-ts 3.0.0-beta.9 → 3.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.
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chunkYQQHBU3L_cjs = require('./chunk-YQQHBU3L.cjs');
3
+ var chunkRORQTUX5_cjs = require('./chunk-RORQTUX5.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "OasType", {
8
8
  enumerable: true,
9
- get: function () { return chunkYQQHBU3L_cjs.OasType; }
9
+ get: function () { return chunkRORQTUX5_cjs.OasType; }
10
10
  });
11
11
  Object.defineProperty(exports, "Type", {
12
12
  enumerable: true,
13
- get: function () { return chunkYQQHBU3L_cjs.Type; }
13
+ get: function () { return chunkRORQTUX5_cjs.Type; }
14
14
  });
15
15
  //# sourceMappingURL=components.cjs.map
16
16
  //# sourceMappingURL=components.cjs.map
@@ -1,3 +1,3 @@
1
- export { OasType, Type } from './chunk-6MLSMIUW.js';
1
+ export { OasType, Type } from './chunk-HZ6BGJL7.js';
2
2
  //# sourceMappingURL=components.js.map
3
3
  //# sourceMappingURL=components.js.map
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk7BLSACBB_cjs = require('./chunk-7BLSACBB.cjs');
4
- require('./chunk-YQQHBU3L.cjs');
3
+ var chunkPTC7IOBI_cjs = require('./chunk-PTC7IOBI.cjs');
4
+ require('./chunk-RORQTUX5.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "oasGenerator", {
9
9
  enumerable: true,
10
- get: function () { return chunk7BLSACBB_cjs.oasGenerator; }
10
+ get: function () { return chunkPTC7IOBI_cjs.oasGenerator; }
11
11
  });
12
12
  Object.defineProperty(exports, "typeGenerator", {
13
13
  enumerable: true,
14
- get: function () { return chunk7BLSACBB_cjs.typeGenerator; }
14
+ get: function () { return chunkPTC7IOBI_cjs.typeGenerator; }
15
15
  });
16
16
  //# sourceMappingURL=generators.cjs.map
17
17
  //# sourceMappingURL=generators.cjs.map
@@ -1,4 +1,4 @@
1
- export { oasGenerator, typeGenerator } from './chunk-WIPOSZRK.js';
2
- import './chunk-6MLSMIUW.js';
1
+ export { oasGenerator, typeGenerator } from './chunk-HJ6SFXKJ.js';
2
+ import './chunk-HZ6BGJL7.js';
3
3
  //# sourceMappingURL=generators.js.map
4
4
  //# sourceMappingURL=generators.js.map
package/dist/index.cjs CHANGED
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var chunk7BLSACBB_cjs = require('./chunk-7BLSACBB.cjs');
4
- require('./chunk-YQQHBU3L.cjs');
3
+ var chunkPTC7IOBI_cjs = require('./chunk-PTC7IOBI.cjs');
4
+ require('./chunk-RORQTUX5.cjs');
5
5
 
6
6
 
7
7
 
8
8
  Object.defineProperty(exports, "pluginTs", {
9
9
  enumerable: true,
10
- get: function () { return chunk7BLSACBB_cjs.pluginTs; }
10
+ get: function () { return chunkPTC7IOBI_cjs.pluginTs; }
11
11
  });
12
12
  Object.defineProperty(exports, "pluginTsName", {
13
13
  enumerable: true,
14
- get: function () { return chunk7BLSACBB_cjs.pluginTsName; }
14
+ get: function () { return chunkPTC7IOBI_cjs.pluginTsName; }
15
15
  });
16
16
  //# sourceMappingURL=index.cjs.map
17
17
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { pluginTs, pluginTsName } from './chunk-WIPOSZRK.js';
2
- import './chunk-6MLSMIUW.js';
1
+ export { pluginTs, pluginTsName } from './chunk-HJ6SFXKJ.js';
2
+ import './chunk-HZ6BGJL7.js';
3
3
  //# sourceMappingURL=index.js.map
4
4
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-ts",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.0",
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-beta.9",
62
- "@kubb/fs": "3.0.0-beta.9",
63
- "@kubb/oas": "3.0.0-beta.9",
64
- "@kubb/parser-ts": "3.0.0-beta.9",
65
- "@kubb/plugin-oas": "3.0.0-beta.9",
66
- "@kubb/react": "3.0.0-beta.9"
61
+ "@kubb/core": "3.0.0",
62
+ "@kubb/fs": "3.0.0",
63
+ "@kubb/oas": "3.0.0",
64
+ "@kubb/plugin-oas": "3.0.0",
65
+ "@kubb/parser-ts": "3.0.0",
66
+ "@kubb/react": "3.0.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/react": "^18.3.12",
70
70
  "react": "^18.3.1",
71
- "tsup": "^8.3.4",
71
+ "tsup": "^8.3.5",
72
72
  "typescript": "^5.6.3",
73
- "@kubb/config-ts": "3.0.0-beta.9",
74
- "@kubb/config-tsup": "3.0.0-beta.9"
73
+ "@kubb/config-ts": "3.0.0",
74
+ "@kubb/config-tsup": "3.0.0"
75
75
  },
76
76
  "peerDependencies": {
77
- "@kubb/react": "3.0.0-beta.9"
77
+ "@kubb/react": "3.0.0"
78
78
  },
79
79
  "engines": {
80
80
  "node": ">=20"
@@ -33,16 +33,19 @@ export function Type({ name, typedName, tree, keysToOmit, optionalType, enumType
33
33
 
34
34
  let type =
35
35
  (tree
36
- .map((schema) =>
37
- parse(undefined, schema, {
38
- name,
39
- typeName: typedName,
40
- description,
41
- keysToOmit,
42
- optionalType,
43
- enumType,
44
- mapper,
45
- }),
36
+ .map((schema, _index, siblings) =>
37
+ parse(
38
+ { parent: undefined, current: schema, siblings },
39
+ {
40
+ name,
41
+ typeName: typedName,
42
+ description,
43
+ keysToOmit,
44
+ optionalType,
45
+ enumType,
46
+ mapper,
47
+ },
48
+ ),
46
49
  )
47
50
  .filter(Boolean)
48
51
  .at(0) as ts.TypeNode) || typeKeywordMapper.undefined()
@@ -117,7 +120,12 @@ export function Type({ name, typedName, tree, keysToOmit, optionalType, enumType
117
120
  </File.Source>
118
121
  )}
119
122
  {
120
- <File.Source name={typeName} isIndexable isExportable={['enum', 'asConst', 'constEnum', 'literal', undefined].includes(enumType)} isTypeOnly>
123
+ <File.Source
124
+ name={typeName}
125
+ isIndexable
126
+ isExportable={['enum', 'asConst', 'constEnum', 'literal', undefined].includes(enumType)}
127
+ isTypeOnly={['asConst', 'constEnum', 'literal', undefined].includes(enumType)}
128
+ >
121
129
  {print([typeNode])}
122
130
  </File.Source>
123
131
  }
@@ -1,6 +1,6 @@
1
1
  import transformers from '@kubb/core/transformers'
2
2
  import * as factory from '@kubb/parser-ts/factory'
3
- import { isKeyword, schemaKeywords } from '@kubb/plugin-oas'
3
+ import { type SchemaTree, isKeyword, schemaKeywords } from '@kubb/plugin-oas'
4
4
 
5
5
  import type { Schema, SchemaKeywordMapper, SchemaMapper } from '@kubb/plugin-oas'
6
6
  import type ts from 'typescript'
@@ -136,7 +136,7 @@ type ParserOptions = {
136
136
  mapper?: Record<string, ts.PropertySignature>
137
137
  }
138
138
 
139
- export function parse(parent: Schema | undefined, current: Schema, options: ParserOptions): ts.Node | null | undefined {
139
+ export function parse({ parent, current, siblings }: SchemaTree, options: ParserOptions): ts.Node | null | undefined {
140
140
  const value = typeKeywordMapper[current.keyword as keyof typeof typeKeywordMapper]
141
141
 
142
142
  if (!value) {
@@ -144,15 +144,19 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
144
144
  }
145
145
 
146
146
  if (isKeyword(current, schemaKeywords.union)) {
147
- return typeKeywordMapper.union(current.args.map((schema) => parse(current, schema, options)).filter(Boolean) as ts.TypeNode[])
147
+ return typeKeywordMapper.union(
148
+ current.args.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
149
+ )
148
150
  }
149
151
 
150
152
  if (isKeyword(current, schemaKeywords.and)) {
151
- return typeKeywordMapper.and(current.args.map((schema) => parse(current, schema, options)).filter(Boolean) as ts.TypeNode[])
153
+ return typeKeywordMapper.and(current.args.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[])
152
154
  }
153
155
 
154
156
  if (isKeyword(current, schemaKeywords.array)) {
155
- return typeKeywordMapper.array(current.args.items.map((schema) => parse(current, schema, options)).filter(Boolean) as ts.TypeNode[])
157
+ return typeKeywordMapper.array(
158
+ current.args.items.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
159
+ )
156
160
  }
157
161
 
158
162
  if (isKeyword(current, schemaKeywords.enum)) {
@@ -168,7 +172,9 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
168
172
  }
169
173
 
170
174
  if (isKeyword(current, schemaKeywords.tuple)) {
171
- return typeKeywordMapper.tuple(current.args.items.map((schema) => parse(current, schema, options)).filter(Boolean) as ts.TypeNode[])
175
+ return typeKeywordMapper.tuple(
176
+ current.args.items.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean) as ts.TypeNode[],
177
+ )
172
178
  }
173
179
 
174
180
  if (isKeyword(current, schemaKeywords.const)) {
@@ -200,7 +206,7 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
200
206
  const exampleSchema = schemas.find((schema) => schema.keyword === schemaKeywords.example) as SchemaKeywordMapper['example'] | undefined
201
207
  const schemaSchema = schemas.find((schema) => schema.keyword === schemaKeywords.schema) as SchemaKeywordMapper['schema'] | undefined
202
208
 
203
- let type = schemas.map((schema) => parse(current, schema, options)).filter(Boolean)[0] as ts.TypeNode
209
+ let type = schemas.map((schema) => parse({ parent: current, current: schema, siblings }, options)).filter(Boolean)[0] as ts.TypeNode
204
210
 
205
211
  if (isNullable) {
206
212
  type = factory.createUnionDeclaration({
@@ -244,7 +250,7 @@ export function parse(parent: Schema | undefined, current: Schema, options: Pars
244
250
  const additionalProperties = current.args?.additionalProperties?.length
245
251
  ? factory.createIndexSignature(
246
252
  current.args.additionalProperties
247
- .map((schema) => parse(current, schema, options))
253
+ .map((schema) => parse({ parent: current, current: schema, siblings }, options))
248
254
  .filter(Boolean)
249
255
  .at(0) as ts.TypeNode,
250
256
  )