Skip to content

Commit cd5d653

Browse files
authored
Merge pull request #1934 from seriouslag/feat/add-shared-exports
feat(openapi-ts): export additional functions from openapi-ts
2 parents 729488e + d4df550 commit cd5d653

File tree

9 files changed

+55
-2
lines changed

9 files changed

+55
-2
lines changed

.changeset/three-rats-count.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+
fix: export some internal functions

packages/openapi-ts/package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@
5252
"default": "./dist/index.cjs"
5353
}
5454
},
55+
"./internal": {
56+
"import": {
57+
"types": "./dist/internal.d.ts",
58+
"default": "./dist/internal.js"
59+
},
60+
"require": {
61+
"types": "./dist/internal.d.cts",
62+
"default": "./dist/internal.cjs"
63+
}
64+
},
5565
"./package.json": "./package.json"
5666
},
5767
"bin": {
@@ -64,7 +74,7 @@
6474
],
6575
"scripts": {
6676
"build": "tsup && pnpm check-exports",
67-
"check-exports": "attw --pack .",
77+
"check-exports": "attw --pack . --profile node16",
6878
"dev": "tsup --watch",
6979
"handlebars": "node src/legacy/handlebars/handlebars.cjs",
7080
"prepublishOnly": "pnpm build",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
describe('main entry index', () => {
4+
describe('createClient', () => {
5+
it('should be exported', async () => {
6+
const { createClient } = await import('../index');
7+
expect(createClient).toBeDefined();
8+
});
9+
});
10+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { describe, expect, it } from 'vitest';
2+
3+
describe('internal entry index', () => {
4+
it('getSpec should be exported', async () => {
5+
const { getSpec } = await import('../internal');
6+
expect(getSpec).toBeDefined();
7+
});
8+
9+
it('initConfigs should be exported', async () => {
10+
const { initConfigs } = await import('../internal');
11+
expect(initConfigs).toBeDefined();
12+
});
13+
14+
it('parseOpenApiSpec should be exported', async () => {
15+
const { parseOpenApiSpec } = await import('../internal');
16+
expect(parseOpenApiSpec).toBeDefined();
17+
});
18+
});

packages/openapi-ts/src/getSpec.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ interface SpecError {
2121
response: Response;
2222
}
2323

24+
/**
25+
* @internal
26+
*/
2427
export const getSpec = async ({
2528
fetchOptions,
2629
inputPath,

packages/openapi-ts/src/initConfigs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ const getWatch = (
253253
return watch;
254254
};
255255

256+
/**
257+
* @internal
258+
*/
256259
export const initConfigs = async (
257260
userConfig: UserConfig | undefined,
258261
): Promise<Config[]> => {

packages/openapi-ts/src/internal.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { getSpec } from './getSpec';
2+
export { initConfigs } from './initConfigs';
3+
export { parseOpenApiSpec } from './openApi';

packages/openapi-ts/src/openApi/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export function parseLegacy({
5757
}
5858

5959
/**
60+
* @internal
6061
* Parse the resolved OpenAPI specification. This will populate and return
6162
* `context` with intermediate representation obtained from the parsed spec.
6263
*/

packages/openapi-ts/tsup.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig((options) => ({
1414
},
1515
clean: true,
1616
dts: true,
17-
entry: ['src/index.ts'],
17+
entry: ['src/index.ts', 'src/internal.ts'],
1818
format: ['cjs', 'esm'],
1919
minify: !options.watch,
2020
shims: false,

0 commit comments

Comments
 (0)