@kubb/plugin-faker 3.0.0-alpha.11 → 3.0.0-alpha.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-faker",
3
- "version": "3.0.0-alpha.11",
3
+ "version": "3.0.0-alpha.13",
4
4
  "description": "Generator plugin-faker",
5
5
  "keywords": [
6
6
  "faker",
@@ -53,25 +53,25 @@
53
53
  "!/**/__tests__/**"
54
54
  ],
55
55
  "dependencies": {
56
- "@kubb/core": "3.0.0-alpha.11",
57
- "@kubb/fs": "3.0.0-alpha.11",
58
- "@kubb/oas": "3.0.0-alpha.11",
59
- "@kubb/parser-ts": "3.0.0-alpha.11",
60
- "@kubb/plugin-oas": "3.0.0-alpha.11",
61
- "@kubb/plugin-ts": "3.0.0-alpha.11",
62
- "@kubb/react": "3.0.0-alpha.11"
56
+ "@kubb/core": "3.0.0-alpha.13",
57
+ "@kubb/fs": "3.0.0-alpha.13",
58
+ "@kubb/oas": "3.0.0-alpha.13",
59
+ "@kubb/parser-ts": "3.0.0-alpha.13",
60
+ "@kubb/plugin-oas": "3.0.0-alpha.13",
61
+ "@kubb/plugin-ts": "3.0.0-alpha.13",
62
+ "@kubb/react": "3.0.0-alpha.13"
63
63
  },
64
64
  "devDependencies": {
65
65
  "@types/react": "^18.3.5",
66
66
  "react": "^18.3.1",
67
67
  "tsup": "^8.2.4",
68
68
  "typescript": "^5.5.4",
69
- "@kubb/config-biome": "3.0.0-alpha.11",
70
- "@kubb/config-ts": "3.0.0-alpha.11",
71
- "@kubb/config-tsup": "3.0.0-alpha.11"
69
+ "@kubb/config-biome": "3.0.0-alpha.13",
70
+ "@kubb/config-ts": "3.0.0-alpha.13",
71
+ "@kubb/config-tsup": "3.0.0-alpha.13"
72
72
  },
73
73
  "peerDependencies": {
74
- "@kubb/react": "3.0.0-alpha.11"
74
+ "@kubb/react": "3.0.0-alpha.13"
75
75
  },
76
76
  "engines": {
77
77
  "node": ">=20"
@@ -74,7 +74,6 @@ OperationSchema.File = function ({}: FileProps): ReactNode {
74
74
 
75
75
  return (
76
76
  <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
77
- <File.Import name={['faker']} path="@faker-js/faker" />
78
77
  {plugin.options.regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}
79
78
  {items.map(mapItem)}
80
79
  </File>
@@ -65,21 +65,26 @@ export function Schema(props: Props): ReactNode {
65
65
 
66
66
  const params = fakerDefaultOverride ? `data: NonNullable<Partial<${typeName}>> = ${fakerDefaultOverride}` : `data?: NonNullable<Partial<${typeName}>>`
67
67
 
68
+ const containsFaker = !!fakerTextWithOverride.match(/faker/) || !!seed
69
+
68
70
  return (
69
- <File.Source name={resolvedName} isExportable isIndexable>
70
- <Function
71
- export
72
- name={resolvedName}
73
- JSDoc={{ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean) }}
74
- params={withData ? params : ''}
75
- returnType={typeName ? `NonNullable<${typeName}>` : ''}
76
- >
77
- {seed ? `faker.seed(${JSON.stringify(seed)})` : ''}
71
+ <>
72
+ {containsFaker && <File.Import name={['faker']} path="@faker-js/faker" />}
73
+ <File.Source name={resolvedName} isExportable isIndexable>
74
+ <Function
75
+ export
76
+ name={resolvedName}
77
+ JSDoc={{ comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean) }}
78
+ params={withData ? params : ''}
79
+ returnType={typeName ? `NonNullable<${typeName}>` : ''}
80
+ >
81
+ {seed ? `faker.seed(${JSON.stringify(seed)})` : ''}
82
+ <br />
83
+ <Function.Return>{fakerTextWithOverride}</Function.Return>
84
+ </Function>
78
85
  <br />
79
- <Function.Return>{fakerTextWithOverride}</Function.Return>
80
- </Function>
81
- <br />
82
- </File.Source>
86
+ </File.Source>
87
+ </>
83
88
  )
84
89
  }
85
90
 
@@ -135,7 +140,6 @@ Schema.Imports = (): ReactNode => {
135
140
 
136
141
  return (
137
142
  <>
138
- <File.Import name={['faker']} path="@faker-js/faker" />
139
143
  {regexGenerator === 'randexp' && <File.Import name={'RandExp'} path={'randexp'} />}
140
144
  {dateParser && <File.Import path={dateParser} name={dateParser} />}
141
145
  {typeName && typePath && <File.Import isTypeOnly root={root} path={typePath} name={[typeName]} />}