Skip to content

Commit 3b4ee7a

Browse files
committed
feat: Presets API
1 parent a2474dd commit 3b4ee7a

14 files changed

Lines changed: 80 additions & 16 deletions

File tree

‎.changeset/cuddly-dodos-look.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/openapi-ts": patch
3+
---
4+
5+
**config**: add Presets API

‎.changeset/fruity-bottles-kiss.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/shared": patch
3+
---
4+
5+
**config**: add Presets API

‎.changeset/open-towns-swim.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/json-schema-ref-parser": patch
3+
---
4+
5+
**package**: remove `cjs` from files array

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ debug/
3535
specs/**/*.debug.json
3636
specs/**/*.debug.yaml
3737
specs/**/*.debug.yml
38+
presets/**/*
39+
!presets/.keep
3840
# error files
3941
logs
4042
openapi-ts-error-*

‎dev/python/presets.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import type { UserConfig } from '@hey-api/openapi-python';
33
export type PluginConfig = NonNullable<NonNullable<UserConfig['plugins']>[number]>;
44

55
export const presets = {
6+
client: () => [
7+
/** Just the client */
8+
'@hey-api/client-httpx',
9+
],
10+
none: () => [
11+
/** No plugins at all */
12+
],
613
sdk: () => [
714
/** SDK */
815
{

‎dev/typescript/presets.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ export const presets = {
99
name: '@angular/common',
1010
},
1111
],
12+
client: () => [
13+
/** Just the client */
14+
'@hey-api/client-axios',
15+
],
1216
full: () => [
1317
/** Full kitchen sink for comprehensive testing */
1418
'@hey-api/typescript',
@@ -31,6 +35,9 @@ export const presets = {
3135
},
3236
},
3337
],
38+
none: () => [
39+
/** No plugins at all */
40+
],
3441
rpc: () => [
3542
/** RPC-style SDK with Zod validation */
3643
'orpc',

‎packages/json-schema-ref-parser/package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
"funding": "https://github.com/sponsors/hey-api",
3030
"files": [
3131
"src",
32-
"dist",
33-
"cjs"
32+
"dist"
3433
],
3534
"type": "module",
3635
"main": "./dist/index.mjs",

‎packages/openapi-python/src/config/resolve.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function resolveConfig(
5151
parser,
5252
pluginOrder: plugins.pluginOrder,
5353
plugins: plugins.plugins,
54+
presets: validated.job.config.presets ?? [],
5455
};
5556

5657
if (logs.level === 'debug') {

‎packages/openapi-ts/src/config/resolve.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export function resolveConfig(
5151
parser,
5252
pluginOrder: plugins.pluginOrder,
5353
plugins: plugins.plugins,
54+
presets: validated.job.config.presets ?? [],
5455
};
5556

5657
if (logs.level === 'debug') {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export interface PresetPlugin {
2+
[key: string]: unknown;
3+
name: string;
4+
}
5+
6+
export interface Preset {
7+
/** Plugin configurations contributed by this preset. */
8+
plugins?: ReadonlyArray<string | PresetPlugin>;
9+
}

0 commit comments

Comments
 (0)