You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
HYPERFLEET-1103 - feat: restructure TypeSpec sources into core and shared
- Move GCP-specific models out of this repo (now in hyperfleet-api-spec-gcp)
- Restructure sources into core/ (core-specific) and shared/ (cross-provider)
- Add generic Resource model and CRUD service (from main reconciliation)
- Add force-delete endpoints for clusters, nodepools, and resources (internal)
- Add ResourceStatusesInternal for adapter resource status reporting
- Simplify build script: single provider (core only), openapi output only
- Add npm sub-path exports to enable downstream package imports
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
chore: fix CI/CD workflow path for version extraction
main.tsp moved from core/main.tsp to root main.tsp as part of restructuring.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+47-87Lines changed: 47 additions & 87 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,60 +1,51 @@
1
1
# HyperFleet API Spec - AI Agent Context
2
2
3
-
This repository generates OpenAPI specifications from TypeSpec definitions. It supports multiple provider variants (core, GCP) using a shared codebase with provider-specific type aliases.
3
+
This repository generates the HyperFleet core OpenAPI specification from TypeSpec definitions. The GCP-specific contract lives in [hyperfleet-api-spec-gcp](https://github.com/openshift-hyperfleet/hyperfleet-api-spec-gcp), which imports shared models from this repo as the `hyperfleet` npm package.
4
4
5
5
## Quick Reference
6
6
7
7
**Build commands:**
8
8
```bash
9
-
npm run build:core # Generate core OpenAPI spec
10
-
npm run build:gcp # Generate GCP OpenAPI spec
11
-
npm run build:all # Generate all variants with Swagger
The `aliases.tsp` symlink determines which provider types are active. The `build-schema.sh` script automatically re-links this during builds. The symlink is tracked in git and should always point to `aliases-core.tsp` by default. Do not remove it from version control or add it to `.gitignore`.
25
+
shared/ # Cross-provider models and services (published as the `hyperfleet` npm package)
26
+
core/ # Core-only models and internal services
27
+
main.tsp # Entry point — imports shared + core
28
+
schemas/core/ # Generated output (committed)
29
+
```
39
30
40
31
**When adding new models:**
41
-
-Shared models → `models/`
42
-
-Provider-specific → `models-{provider}/`
43
-
-Always update alias files if you introduce provider-specific types
32
+
-Cross-provider models → `shared/models/`
33
+
-Core-only models → `core/models/`
34
+
-GCP-specific → separate repo (`hyperfleet-api-spec-gcp`)
44
35
45
36
### Public vs Internal APIs
46
37
47
38
Status endpoints are split:
48
-
-`services/statuses.tsp` - GET operations (external clients)
49
-
-`services/statuses-internal.tsp` - PUT operations (internal adapters only)
39
+
-`shared/services/statuses.tsp` - GET operations (external clients)
40
+
-`core/services/statuses-internal.tsp` - PUT operations (internal adapters only) and resource force-delete
50
41
51
42
The split allows generating different API contracts per audience. Only `statuses.tsp` is imported by default.
52
43
53
44
## Code Style
54
45
55
46
### TypeSpec Conventions
56
47
57
-
**Imports first, namespace second:**
48
+
**Imports first, namespace second** (applies to service and model files; example `const` files do not declare a namespace):
- Modify generated files in `schemas/` or `tsp-output/` directly
90
+
- Modify generated files in `schemas/` or `tsp-output-core/` directly
97
91
- Add dependencies without checking TypeSpec version compatibility
98
92
- Auto-generate documentation - it degrades agent performance per research
99
-
- Use `--swagger` flag unless you need OpenAPI 2.0 for legacy tools
100
93
- Commit `node_modules/` or build artifacts
101
94
102
95
**DO:**
103
-
- Run builds in this order before committing schema changes:
104
-
1.`./build-schema.sh gcp`
105
-
2.`./build-schema.sh gcp --swagger`
106
-
3.`./build-schema.sh core`
107
-
4.`./build-schema.sh core --swagger`
108
-
- Test both provider variants when modifying shared models
96
+
- Run `./build-schema.sh` and commit `schemas/core/openapi.yaml` with your changes
109
97
- Keep TypeSpec files focused (one resource per service file)
110
98
- Use semantic versioning for releases (automated on merge to main)
111
99
@@ -114,7 +102,7 @@ services/
114
102
### Add a new endpoint to existing service
115
103
116
104
```typescript
117
-
// services/clusters.tsp
105
+
//shared/services/clusters.tsp
118
106
namespaceHyperFleet;
119
107
120
108
@route("/clusters")
@@ -131,7 +119,7 @@ interface Clusters {
131
119
132
120
1. Create model:
133
121
```typescript
134
-
// models/health/model.tsp
122
+
//shared/models/health/model.tsp
135
123
import"@typespec/http";
136
124
137
125
modelHealthStatus {
@@ -143,7 +131,7 @@ model HealthStatus {
143
131
144
132
2. Create service:
145
133
```typescript
146
-
// services/health.tsp
134
+
//shared/services/health.tsp
147
135
import"@typespec/http";
148
136
import"../models/health/model.tsp";
149
137
import"../models/common/model.tsp";
@@ -158,35 +146,14 @@ interface Health {
158
146
159
147
3. Import in `main.tsp`:
160
148
```typescript
161
-
import"./services/health.tsp";
149
+
import"./shared/services/health.tsp";
162
150
```
163
151
164
-
4. Build: `npm run build:core`
152
+
4. Build: `npm run build`
165
153
166
154
### Add provider-specific fields
167
155
168
-
```typescript
169
-
// models-gcp/cluster/model.tsp
170
-
modelGCPClusterSpec {
171
-
projectId: string;
172
-
region: string;
173
-
network?:GCPNetwork;
174
-
}
175
-
176
-
modelGCPNetwork {
177
-
vpcId: string;
178
-
subnetId: string;
179
-
}
180
-
```
181
-
182
-
Update alias:
183
-
```typescript
184
-
// aliases-gcp.tsp
185
-
import"./models-gcp/cluster/model.tsp";
186
-
aliasClusterSpec=GCPClusterSpec;
187
-
```
188
-
189
-
Build: `npm run build:gcp`
156
+
Provider-specific models live in the provider's own repository (e.g., `hyperfleet-api-spec-gcp`). See that repo for examples of how to extend core shared models.
190
157
191
158
## Version Bump and Changelog
192
159
@@ -202,36 +169,29 @@ When bumping the version in `main.tsp`, always update `CHANGELOG.md`:
**Version sync:**`package.json` version is kept in lockstep with `main.tsp` automatically on every build. The CI consistency check (`git diff --exit-code`) enforces that both are committed together.
0 commit comments