File tree Expand file tree Collapse file tree 5 files changed +13
-16
lines changed
plugins/@hey-api/transformers Expand file tree Collapse file tree 5 files changed +13
-16
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ export {
124
124
} from './plugins/@hey-api/client-core/config' ;
125
125
export { clientPluginHandler } from './plugins/@hey-api/client-core/plugin' ;
126
126
export type { Client } from './plugins/@hey-api/client-core/types' ;
127
- export type { expressionTransformer } from './plugins/@hey-api/transformers' ;
127
+ export type { ExpressionTransformer } from './plugins/@hey-api/transformers/expressions ' ;
128
128
export { definePluginConfig } from './plugins/shared/utils/config' ;
129
129
export type { DefinePlugin , Plugin } from './plugins/types' ;
130
130
export type { UserConfig } from './types/config' ;
Original file line number Diff line number Diff line change @@ -5,24 +5,24 @@ import type { TypeScriptFile } from '../../../generate/files';
5
5
import type { IR } from '../../../ir/types' ;
6
6
import type { Config } from './types' ;
7
7
8
- export type expressionTransformer = ( {
8
+ export type ExpressionTransformer = ( {
9
9
config,
10
10
dataExpression,
11
11
file,
12
12
schema,
13
13
} : {
14
- config : Config ;
14
+ config : Omit < Config , 'name' > ;
15
15
dataExpression ?: ts . Expression | string ;
16
16
file : TypeScriptFile ;
17
17
schema : IR . SchemaObject ;
18
18
} ) => Array < ts . Expression > | undefined ;
19
19
20
- export const bigIntExpressions : expressionTransformer = ( {
20
+ export const bigIntExpressions : ExpressionTransformer = ( {
21
21
dataExpression,
22
22
schema,
23
23
} ) => {
24
24
if ( schema . type !== 'integer' || schema . format !== 'int64' ) {
25
- return undefined ;
25
+ return ;
26
26
}
27
27
28
28
const bigIntCallExpression =
@@ -55,18 +55,18 @@ export const bigIntExpressions: expressionTransformer = ({
55
55
}
56
56
}
57
57
58
- return [ ] ;
58
+ return ;
59
59
} ;
60
60
61
- export const dateExpressions : expressionTransformer = ( {
61
+ export const dateExpressions : ExpressionTransformer = ( {
62
62
dataExpression,
63
63
schema,
64
64
} ) => {
65
65
if (
66
66
schema . type !== 'string' ||
67
67
! ( schema . format === 'date' || schema . format === 'date-time' )
68
68
) {
69
- return undefined ;
69
+ return ;
70
70
}
71
71
72
72
const identifierDate = compiler . identifier ( { text : 'Date' } ) ;
@@ -92,5 +92,5 @@ export const dateExpressions: expressionTransformer = ({
92
92
] ;
93
93
}
94
94
95
- return [ ] ;
95
+ return ;
96
96
} ;
Original file line number Diff line number Diff line change 1
1
export { compiler } from '../../../compiler' ;
2
2
export { defaultConfig , defineConfig } from './config' ;
3
- export { type expressionTransformer } from './expressions-transformers' ;
4
3
export type { HeyApiTransformersPlugin } from './types' ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import { irRef } from '../../../utils/ref';
10
10
import { stringCase } from '../../../utils/stringCase' ;
11
11
import { operationIrRef } from '../../shared/utils/ref' ;
12
12
import { typesId } from '../typescript/ref' ;
13
- import { bigIntExpressions , dateExpressions } from './expressions-transformers ' ;
13
+ import { bigIntExpressions , dateExpressions } from './expressions' ;
14
14
import type { HeyApiTransformersPlugin } from './types' ;
15
15
16
16
interface OperationIRRef {
Original file line number Diff line number Diff line change 1
1
import type { DefinePlugin , Plugin } from '../../types' ;
2
+ import type { ExpressionTransformer } from './expressions' ;
2
3
3
4
export type Config = Plugin . Name < '@hey-api/transformers' > & {
4
5
/**
@@ -26,13 +27,10 @@ export type Config = Plugin.Name<'@hey-api/transformers'> & {
26
27
* @default 'transformers'
27
28
*/
28
29
output ?: string ;
29
-
30
30
/**
31
- * transformers to apply to the generated code
32
- * @default []
31
+ * Custom transforms to apply to the generated code.
33
32
*/
34
-
35
- transformers ?: expressionTransformer [ ] ;
33
+ transformers ?: ReadonlyArray < ExpressionTransformer > ;
36
34
} ;
37
35
38
36
export type HeyApiTransformersPlugin = DefinePlugin < Config > ;
You can’t perform that action at this time.
0 commit comments