Skip to content

Commit 45e7c95

Browse files
authored
feat(sdk): add @temps-sdk/api generated OpenAPI client package (#143)
Adds the publishable @temps-sdk/api package — the @hey-api generated TypeScript client (openapi-ts) that the apps/temps-e2e harness and external consumers link against. Generated sources (*.gen.ts) + openapi.json + build config; build output (dist/, node_modules/) is gitignored.
1 parent afbb71e commit 45e7c95

22 files changed

Lines changed: 50480 additions & 0 deletions

packages/api/bun.lock

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/openapi-ts.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from '@hey-api/openapi-ts'
2+
3+
// Generates the typed client into src/. Input is the checked-in openapi.json
4+
// (kept in sync with the server's spec — regenerate after API changes via
5+
// `bun run generate`). Mirrors the CLI's generator config so the output shape
6+
// is identical, but this package is the single shared source of truth.
7+
export default defineConfig({
8+
input: 'openapi.json',
9+
output: {
10+
path: 'src',
11+
format: 'prettier',
12+
},
13+
client: '@hey-api/client-fetch',
14+
plugins: ['@hey-api/sdk', '@hey-api/typescript'],
15+
})

packages/api/openapi.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

packages/api/package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "@temps-sdk/api",
3+
"version": "0.1.0",
4+
"description": "Typed OpenAPI client for the Temps platform REST API. Generated from the Temps OpenAPI spec with @hey-api/openapi-ts.",
5+
"license": "Apache-2.0",
6+
"type": "module",
7+
"main": "./dist/index.js",
8+
"module": "./dist/index.js",
9+
"types": "./dist/index.d.ts",
10+
"exports": {
11+
".": {
12+
"types": "./dist/index.d.ts",
13+
"import": "./dist/index.js"
14+
},
15+
"./client": {
16+
"types": "./dist/client/index.d.ts",
17+
"import": "./dist/client/index.js"
18+
}
19+
},
20+
"files": [
21+
"dist",
22+
"src",
23+
"README.md"
24+
],
25+
"publishConfig": {
26+
"access": "public"
27+
},
28+
"sideEffects": false,
29+
"scripts": {
30+
"generate": "openapi-ts",
31+
"build": "tsc -p tsconfig.build.json",
32+
"prepublishOnly": "bun run generate && bun run build",
33+
"typecheck": "tsc --noEmit"
34+
},
35+
"dependencies": {
36+
"@hey-api/client-fetch": "^0.13.1"
37+
},
38+
"devDependencies": {
39+
"@hey-api/openapi-ts": "^0.88.0",
40+
"typescript": "^5.6.0"
41+
},
42+
"keywords": [
43+
"temps",
44+
"openapi",
45+
"api-client",
46+
"sdk",
47+
"paas"
48+
]
49+
}

packages/api/src/client.gen.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
import { type ClientOptions, type Config, createClient, createConfig } from './client';
4+
import type { ClientOptions as ClientOptions2 } from './types.gen';
5+
6+
/**
7+
* The `createClientConfig()` function will be called on client initialization
8+
* and the returned object will become the client's initial configuration.
9+
*
10+
* You may want to initialize your client this way instead of calling
11+
* `setConfig()`. This is useful for example if you're using Next.js
12+
* to ensure your client always has the correct values.
13+
*/
14+
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;
15+
16+
export const client = createClient(createConfig<ClientOptions2>({ baseUrl: '/api' }));

0 commit comments

Comments
 (0)