Skip to content

Commit aac3133

Browse files
committed
feat: Use Blueprint omitUndocumented option in codegen
Build the Blueprint with the omitUndocumented option (added in @seamapi/blueprint 0.61.0) and remove the manual isUndocumented filters from the route generator. Since @seamapi/smith does not forward this option, call createBlueprint directly. Bump @seamapi/blueprint to ^0.61.0 and @seamapi/types to 1.975.0 to satisfy the stricter undocumented-reference validation added in the newer Blueprint. Applying omitUndocumented at the Blueprint level also strips undocumented resources and properties from models.py, which the route-only filters never covered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ASErrFWD4qfnmhzYZNuwYb
1 parent ac5f577 commit aac3133

5 files changed

Lines changed: 36 additions & 473 deletions

File tree

codegen/lib/routes.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@ export const routes = (
3232
const metadata = metalsmith.metadata() as Metadata
3333
const { blueprint } = metadata
3434

35-
const documentedRoutes = blueprint.routes.filter(
36-
(route) => !route.isUndocumented,
37-
)
35+
// The blueprint is built with omitUndocumented, so undocumented routes,
36+
// namespaces, endpoints, and parameters are already stripped out.
3837

3938
// Namespaces group routes without endpoints of their own (e.g. /acs) but
4039
// still produce a route class so their child classes are reachable.
41-
const classEntries = [
42-
...blueprint.namespaces.filter((namespace) => !namespace.isUndocumented),
43-
...documentedRoutes,
44-
]
40+
const classEntries = [...blueprint.namespaces, ...blueprint.routes]
4541
.map(({ path, parentPath }) => ({ path, parentPath }))
4642
.sort((a, b) => (a.path < b.path ? -1 : 1))
4743

@@ -70,13 +66,11 @@ export const routes = (
7066
})
7167
}
7268

73-
for (const route of documentedRoutes) {
69+
for (const route of blueprint.routes) {
7470
const cls = classMap.get(pascalCase(toNamespace(route.path)))
7571
if (cls == null) continue
7672

7773
for (const endpoint of route.endpoints) {
78-
if (endpoint.isUndocumented) continue
79-
8074
const { response } = endpoint
8175
const idParameterName =
8276
endpoint.name === 'get' && response.responseType !== 'void'
@@ -86,14 +80,12 @@ export const routes = (
8680
cls.methods.push({
8781
methodName: endpoint.name,
8882
path: endpoint.path,
89-
parameters: endpoint.request.parameters
90-
.filter((parameter) => !parameter.isUndocumented)
91-
.map((parameter) => ({
92-
name: parameter.name,
93-
type: mapParameterToPythonType(parameter),
94-
position: parameter.name === idParameterName ? 0 : undefined,
95-
required: parameter.isRequired,
96-
})),
83+
parameters: endpoint.request.parameters.map((parameter) => ({
84+
name: parameter.name,
85+
type: mapParameterToPythonType(parameter),
86+
position: parameter.name === idParameterName ? 0 : undefined,
87+
required: parameter.isRequired,
88+
})),
9789
...resolveResponse(response),
9890
})
9991
}

codegen/smith.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { dirname } from 'node:path'
22
import { fileURLToPath } from 'node:url'
33

44
import layouts from '@metalsmith/layouts'
5-
import { blueprint, getHandlebarsPartials } from '@seamapi/smith'
5+
import { createBlueprint, type TypesModuleInput } from '@seamapi/blueprint'
6+
import { getHandlebarsPartials } from '@seamapi/smith'
67
import * as types from '@seamapi/types/connect'
78
import { deleteAsync } from 'del'
89
import Metalsmith from 'metalsmith'
@@ -15,11 +16,24 @@ await Promise.all([deleteAsync('./seam/routes')])
1516

1617
const partials = await getHandlebarsPartials(`${rootDir}/layouts/partials`)
1718

19+
// Build the Blueprint with omitUndocumented so undocumented routes,
20+
// namespaces, endpoints, parameters, resources, events, action attempts, and
21+
// properties are stripped out before codegen runs.
22+
const setBlueprint = async (
23+
_files: Metalsmith.Files,
24+
metalsmith: Metalsmith,
25+
): Promise<void> => {
26+
const blueprint = await createBlueprint(types as TypesModuleInput, {
27+
omitUndocumented: true,
28+
})
29+
Object.assign(metalsmith.metadata(), { blueprint })
30+
}
31+
1832
Metalsmith(rootDir)
1933
.source('./content')
2034
.destination('../')
2135
.clean(false)
22-
.use(blueprint({ types }))
36+
.use(setBlueprint)
2337
.use(routes)
2438
.use(
2539
layouts({

package-lock.json

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

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
"start": "fake-seam-connect --seed"
1515
},
1616
"devDependencies": {
17-
"@seamapi/blueprint": "^0.59.0",
17+
"@seamapi/blueprint": "^0.61.0",
1818
"@seamapi/fake-seam-connect": "1.86.0",
1919
"@seamapi/smith": "^0.5.2",
20-
"@seamapi/types": "1.970.0",
20+
"@seamapi/types": "1.975.0",
2121
"change-case": "^5.4.4",
2222
"prettier": "^3.2.5"
2323
}

0 commit comments

Comments
 (0)