Skip to content

Commit 5700a51

Browse files
committed
chore: clean up dsl exports
1 parent f9fcf11 commit 5700a51

File tree

15 files changed

+33
-41
lines changed

15 files changed

+33
-41
lines changed

packages/openapi-ts/src/plugins/valibot/shared/pipesToAst.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type ts from 'typescript';
22

3-
import { CallTsDsl } from '~/ts-dsl';
4-
import { $ } from '~/ts-dsl';
3+
import { $, TsDsl } from '~/ts-dsl';
54

65
import type { ValibotPlugin } from '../types';
76
import { identifiers } from '../v1/constants';
@@ -10,11 +9,11 @@ export const pipesToAst = ({
109
pipes,
1110
plugin,
1211
}: {
13-
pipes: ReadonlyArray<ts.Expression | CallTsDsl>;
12+
pipes: ReadonlyArray<ts.Expression | ReturnType<typeof $.call>>;
1413
plugin: ValibotPlugin['Instance'];
1514
}): ts.Expression => {
1615
if (pipes.length === 1) {
17-
return pipes[0] instanceof CallTsDsl ? pipes[0].$render() : pipes[0]!;
16+
return pipes[0] instanceof TsDsl ? pipes[0].$render() : pipes[0]!;
1817
}
1918

2019
const v = plugin.referenceSymbol({

packages/openapi-ts/src/plugins/valibot/types.d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type ts from 'typescript';
33

44
import type { IR } from '~/ir/types';
55
import type { DefinePlugin, Plugin } from '~/plugins';
6-
import type { CallTsDsl, DollarTsDsl, ObjectTsDsl, TsDsl } from '~/ts-dsl';
6+
import type { $, DollarTsDsl, TsDsl } from '~/ts-dsl';
77
import type { StringCase, StringName } from '~/types/case';
88
import type { MaybeArray } from '~/types/utils';
99

@@ -332,7 +332,7 @@ type SharedResolverArgs = DollarTsDsl & {
332332
* resulting schema is constructed. Returning `undefined` from a resolver will
333333
* use the default generation behavior.
334334
*/
335-
pipes: Array<CallTsDsl>;
335+
pipes: Array<ReturnType<typeof $.call>>;
336336
plugin: ValibotPlugin['Instance'];
337337
};
338338

@@ -344,7 +344,7 @@ export type ObjectBaseResolverArgs = SharedResolverArgs & {
344344
/** Null = never */
345345
additional?: ts.Expression | null;
346346
schema: IR.SchemaObject;
347-
shape: ObjectTsDsl;
347+
shape: ReturnType<typeof $.object>;
348348
};
349349

350350
export type ValidatorResolverArgs = SharedResolverArgs & {
@@ -378,7 +378,9 @@ type Resolvers = Plugin.Resolvers<{
378378
*
379379
* Returning `undefined` will execute the default resolver logic.
380380
*/
381-
base?: (args: ObjectBaseResolverArgs) => CallTsDsl | undefined;
381+
base?: (
382+
args: ObjectBaseResolverArgs,
383+
) => ReturnType<typeof $.call> | undefined;
382384
};
383385
/**
384386
* Resolvers for string schemas.

packages/openapi-ts/src/plugins/valibot/v1/toAst/boolean.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type ts from 'typescript';
22

33
import type { SchemaWithType } from '~/plugins';
4-
import type { CallTsDsl } from '~/ts-dsl';
54
import { $ } from '~/ts-dsl';
65

76
import { pipesToAst } from '../../shared/pipesToAst';
@@ -14,7 +13,7 @@ export const booleanToAst = ({
1413
}: IrSchemaToAstOptions & {
1514
schema: SchemaWithType<'boolean'>;
1615
}): ts.Expression => {
17-
const pipes: Array<CallTsDsl> = [];
16+
const pipes: Array<ReturnType<typeof $.call>> = [];
1817

1918
const v = plugin.referenceSymbol({
2019
category: 'external',

packages/openapi-ts/src/plugins/valibot/v1/toAst/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type ts from 'typescript';
22

33
import type { SchemaWithType } from '~/plugins';
44
import { toRef } from '~/plugins/shared/utils/refs';
5-
import { $, type CallTsDsl } from '~/ts-dsl';
5+
import { $ } from '~/ts-dsl';
66

77
import { pipesToAst } from '../../shared/pipesToAst';
88
import type { Ast, IrSchemaToAstOptions } from '../../shared/types';
@@ -63,7 +63,7 @@ export const objectToAst = ({
6363
schema: SchemaWithType<'object'>;
6464
}): Omit<Ast, 'typeName'> => {
6565
const result: Partial<Omit<Ast, 'typeName'>> = {};
66-
const pipes: Array<CallTsDsl> = [];
66+
const pipes: Array<ReturnType<typeof $.call>> = [];
6767

6868
// TODO: parser - handle constants
6969

packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type ts from 'typescript';
22

33
import type { SchemaWithType } from '~/plugins';
4-
import type { CallTsDsl } from '~/ts-dsl';
54
import { $ } from '~/ts-dsl';
65

76
import { pipesToAst } from '../../shared/pipesToAst';
@@ -54,7 +53,7 @@ export const stringToAst = ({
5453
}: IrSchemaToAstOptions & {
5554
schema: SchemaWithType<'string'>;
5655
}): ts.Expression => {
57-
const pipes: Array<CallTsDsl> = [];
56+
const pipes: Array<ReturnType<typeof $.call>> = [];
5857

5958
const v = plugin.referenceSymbol({
6059
category: 'external',

packages/openapi-ts/src/plugins/zod/mini/toAst/boolean.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { SchemaWithType } from '~/plugins';
2-
import type { CallTsDsl } from '~/ts-dsl';
32
import { $ } from '~/ts-dsl';
43

54
import { identifiers } from '../../constants';
@@ -12,7 +11,7 @@ export const booleanToAst = ({
1211
schema: SchemaWithType<'boolean'>;
1312
}): Omit<Ast, 'typeName'> => {
1413
const result: Partial<Omit<Ast, 'typeName'>> = {};
15-
let chain: CallTsDsl;
14+
let chain: ReturnType<typeof $.call>;
1615

1716
const z = plugin.referenceSymbol({
1817
category: 'external',

packages/openapi-ts/src/plugins/zod/mini/toAst/object.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type ts from 'typescript';
22

33
import type { SchemaWithType } from '~/plugins';
44
import { toRef } from '~/plugins/shared/utils/refs';
5-
import type { CallTsDsl } from '~/ts-dsl';
65
import { $ } from '~/ts-dsl';
76

87
import { identifiers } from '../../constants';
@@ -14,7 +13,7 @@ function defaultObjectBaseResolver({
1413
additional,
1514
plugin,
1615
shape,
17-
}: ObjectBaseResolverArgs): CallTsDsl {
16+
}: ObjectBaseResolverArgs): ReturnType<typeof $.call> {
1817
const z = plugin.referenceSymbol({
1918
category: 'external',
2019
resource: 'zod.z',

packages/openapi-ts/src/plugins/zod/mini/toAst/string.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { SchemaWithType } from '~/plugins';
2-
import type { CallTsDsl } from '~/ts-dsl';
32
import { $ } from '~/ts-dsl';
43

54
import { identifiers } from '../../constants';
@@ -10,7 +9,7 @@ const defaultFormatResolver = ({
109
chain,
1110
plugin,
1211
schema,
13-
}: FormatResolverArgs): CallTsDsl => {
12+
}: FormatResolverArgs): ReturnType<typeof $.call> => {
1413
const z = plugin.referenceSymbol({
1514
category: 'external',
1615
resource: 'zod.z',
@@ -62,7 +61,7 @@ export const stringToAst = ({
6261
schema: SchemaWithType<'string'>;
6362
}): Omit<Ast, 'typeName'> => {
6463
const result: Partial<Omit<Ast, 'typeName'>> = {};
65-
let chain: CallTsDsl;
64+
let chain: ReturnType<typeof $.call>;
6665

6766
const z = plugin.referenceSymbol({
6867
category: 'external',
@@ -86,7 +85,7 @@ export const stringToAst = ({
8685
chain = resolver?.(args) ?? defaultFormatResolver(args);
8786
}
8887

89-
const checks: Array<CallTsDsl> = [];
88+
const checks: Array<ReturnType<typeof $.call>> = [];
9089

9190
if (schema.minLength === schema.maxLength && schema.minLength !== undefined) {
9291
checks.push(

packages/openapi-ts/src/plugins/zod/types.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type ts from 'typescript';
33

44
import type { IR } from '~/ir/types';
55
import type { DefinePlugin, Plugin } from '~/plugins';
6-
import type { CallTsDsl, DollarTsDsl, ObjectTsDsl, TsDsl } from '~/ts-dsl';
6+
import type { $, DollarTsDsl, TsDsl } from '~/ts-dsl';
77
import type { StringCase, StringName } from '~/types/case';
88
import type { MaybeArray } from '~/types/utils';
99

@@ -757,7 +757,7 @@ type SharedResolverArgs = DollarTsDsl & {
757757
* This chain can be extended, transformed, or replaced entirely to customize
758758
* the resulting output of the resolver.
759759
*/
760-
chain?: CallTsDsl;
760+
chain?: ReturnType<typeof $.call>;
761761
plugin: ZodPlugin['Instance'];
762762
};
763763

@@ -769,7 +769,7 @@ export type ObjectBaseResolverArgs = SharedResolverArgs & {
769769
/** Null = never */
770770
additional?: ts.Expression | null;
771771
schema: IR.SchemaObject;
772-
shape: ObjectTsDsl;
772+
shape: ReturnType<typeof $.object>;
773773
};
774774

775775
export type ValidatorResolverArgs = SharedResolverArgs & {
@@ -802,7 +802,9 @@ type Resolvers = Plugin.Resolvers<{
802802
*
803803
* Returning `undefined` will execute the default resolver logic.
804804
*/
805-
base?: (args: ObjectBaseResolverArgs) => CallTsDsl | undefined;
805+
base?: (
806+
args: ObjectBaseResolverArgs,
807+
) => ReturnType<typeof $.call> | undefined;
806808
};
807809
/**
808810
* Resolvers for string schemas.
@@ -824,7 +826,7 @@ type Resolvers = Plugin.Resolvers<{
824826
*/
825827
formats?: Record<
826828
string,
827-
(args: FormatResolverArgs) => CallTsDsl | undefined
829+
(args: FormatResolverArgs) => ReturnType<typeof $.call> | undefined
828830
>;
829831
};
830832
/**

packages/openapi-ts/src/plugins/zod/v3/toAst/boolean.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type ts from 'typescript';
22

33
import type { SchemaWithType } from '~/plugins';
4-
import type { CallTsDsl } from '~/ts-dsl';
54
import { $ } from '~/ts-dsl';
65

76
import { identifiers } from '../../constants';
@@ -13,7 +12,7 @@ export const booleanToAst = ({
1312
}: IrSchemaToAstOptions & {
1413
schema: SchemaWithType<'boolean'>;
1514
}): ts.CallExpression => {
16-
let chain: CallTsDsl;
15+
let chain: ReturnType<typeof $.call>;
1716

1817
const z = plugin.referenceSymbol({
1918
category: 'external',

0 commit comments

Comments
 (0)