Skip to content

Commit 8865ded

Browse files
razor-xclaude
andauthored
fix: Generate missing simulate endpoints (#527)
The Metalsmith codegen kept verbatim OpenAPI-parsing ports from the nextlove generator (marked TEMPORARY) so its output stayed byte-identical. Now that the output is allowed to change, generate everything from @seamapi/blueprint and delete the OpenAPI workarounds: - Delete codegen/lib/openapi/ and endpoint-rules.ts. The blueprint has no /health routes, and the endpoints that formerly returned a deprecated action attempt are modeled as void responses, so neither list is needed. - Generate resources from blueprint.resources, blueprint.actionAttempts, and blueprint.pagination. SeamEvent and ActionAttempt merge the union of their per-variant properties so every accessor is preserved. - Generate clients from blueprint.routes and blueprint.namespaces, using their isUndocumented flags for filtering and parentPath for wiring child clients, which now also wires deeply nested namespaces (AcsEncoders#simulate). - Fix the parameter sort so an explicit position sorts first, as originally intended. Resulting output changes: AcsEncoders#simulate is now reachable from its parent client, workspaces.update is generated, the unused phone_registration resource is dropped, SeamEvent accessors are alphabetized, and the primary id parameter of get methods moves to the front of the signature. Claude-Session: https://claude.ai/code/session_01RRu8RHUZqw3SvrGR7NJCki Co-authored-by: Claude <noreply@anthropic.com>
1 parent e6a5824 commit 8865ded

19 files changed

Lines changed: 218 additions & 751 deletions

codegen/lib/endpoint-rules.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

codegen/lib/layouts/client.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// (lib/seam/routes/clients/{snake_name}.rb).
33
// Mirrors the output of the nextlove RubyClient#serialize.
44

5-
import { endpointsReturningDeprecatedActionAttempt } from '../endpoint-rules.js'
65
import {
76
type ClientMethod,
87
type ClientModel,
@@ -37,10 +36,7 @@ const getMethodLayoutContext = (
3736
const { methodName, path, parameters, returnResource, returnPath } = method
3837

3938
const hasReturnValue = returnResource != null && returnPath !== ''
40-
const returnsDeprecatedActionAttempt =
41-
endpointsReturningDeprecatedActionAttempt.includes(path)
42-
const canPollActionAttempt =
43-
returnPath === 'action_attempt' && !returnsDeprecatedActionAttempt
39+
const canPollActionAttempt = returnPath === 'action_attempt'
4440
const hasParams = parameters.length > 0
4541

4642
const sortedParameters = sortClientMethodParameters(parameters)
@@ -54,13 +50,9 @@ const getMethodLayoutContext = (
5450
.map((p) => `${p.name}: ${p.name}`)
5551
.join(', ')}}`
5652

57-
// These three branches mirror the nextlove serializer and are independent by
58-
// design, not mutually exclusive: the resource line renders when there is a
59-
// return value that is not polled, and the nil line renders when there is no
60-
// return value or the endpoint returns a deprecated action attempt.
6153
const isResource = hasReturnValue && !canPollActionAttempt
6254
const isPoll = canPollActionAttempt
63-
const isNil = !hasReturnValue || returnsDeprecatedActionAttempt
55+
const isNil = !hasReturnValue
6456

6557
return {
6658
name: methodName,

codegen/lib/layouts/resource.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
// Builds the template context for resource files
22
// (lib/seam/routes/resources/{snake_name}.rb).
3-
// Mirrors the output of the nextlove resource.rb.template.ts.
43

4+
import type { Property } from '@seamapi/blueprint'
55
import { pascalCase } from 'change-case'
66

77
import { convertCustomResourceName } from '../custom-resource-name-conversions.js'
8-
import { flattenObjSchema } from '../openapi/flatten-obj-schema.js'
9-
import type { ObjSchema } from '../openapi/types.js'
108

119
export interface ResourceLayoutContext {
1210
className: string
@@ -20,22 +18,14 @@ export interface ResourceLayoutContext {
2018

2119
export const setResourceLayoutContext = (
2220
snakeName: string,
23-
schema: ObjSchema,
21+
properties: Property[],
2422
): ResourceLayoutContext => {
25-
// TODO: Use resource properties from @seamapi/blueprint once generated output
26-
// is allowed to change. Blueprint omits some schemas, reorders others, and
27-
// collapses integer to number, so the raw OpenAPI schema is used here to keep
28-
// the output identical.
29-
const properties = Object.entries(flattenObjSchema(schema).properties).map(
30-
([name, propertySchema]) => ({
31-
name,
32-
isDateTime:
33-
'format' in propertySchema && propertySchema.format === 'date-time',
34-
}),
35-
)
36-
37-
const attrs = properties.filter((p) => !p.isDateTime).map((p) => p.name)
38-
const dateAttrs = properties.filter((p) => p.isDateTime).map((p) => p.name)
23+
const attrs = properties
24+
.filter((property) => property.format !== 'datetime')
25+
.map((property) => property.name)
26+
const dateAttrs = properties
27+
.filter((property) => property.format === 'datetime')
28+
.map((property) => property.name)
3929
const noErrorWarningAttrs = attrs.filter(
4030
(attr) => attr !== 'errors' && attr !== 'warnings',
4131
)

codegen/lib/openapi/deep-flatten-one-of-and-all-of-schema.ts

Lines changed: 0 additions & 138 deletions
This file was deleted.

codegen/lib/openapi/flatten-obj-schema.ts

Lines changed: 0 additions & 129 deletions
This file was deleted.

codegen/lib/openapi/get-filtered-routes.ts

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)