Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions codegen/lib/endpoint-rules.ts

This file was deleted.

12 changes: 2 additions & 10 deletions codegen/lib/layouts/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// (lib/seam/routes/clients/{snake_name}.rb).
// Mirrors the output of the nextlove RubyClient#serialize.

import { endpointsReturningDeprecatedActionAttempt } from '../endpoint-rules.js'
import {
type ClientMethod,
type ClientModel,
Expand Down Expand Up @@ -37,10 +36,7 @@ const getMethodLayoutContext = (
const { methodName, path, parameters, returnResource, returnPath } = method

const hasReturnValue = returnResource != null && returnPath !== ''
const returnsDeprecatedActionAttempt =
endpointsReturningDeprecatedActionAttempt.includes(path)
const canPollActionAttempt =
returnPath === 'action_attempt' && !returnsDeprecatedActionAttempt
const canPollActionAttempt = returnPath === 'action_attempt'
const hasParams = parameters.length > 0

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

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

return {
name: methodName,
Expand Down
26 changes: 8 additions & 18 deletions codegen/lib/layouts/resource.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Builds the template context for resource files
// (lib/seam/routes/resources/{snake_name}.rb).
// Mirrors the output of the nextlove resource.rb.template.ts.

import type { Property } from '@seamapi/blueprint'
import { pascalCase } from 'change-case'

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

export interface ResourceLayoutContext {
className: string
Expand All @@ -20,22 +18,14 @@ export interface ResourceLayoutContext {

export const setResourceLayoutContext = (
snakeName: string,
schema: ObjSchema,
properties: Property[],
): ResourceLayoutContext => {
// TODO: Use resource properties from @seamapi/blueprint once generated output
// is allowed to change. Blueprint omits some schemas, reorders others, and
// collapses integer to number, so the raw OpenAPI schema is used here to keep
// the output identical.
const properties = Object.entries(flattenObjSchema(schema).properties).map(
([name, propertySchema]) => ({
name,
isDateTime:
'format' in propertySchema && propertySchema.format === 'date-time',
}),
)

const attrs = properties.filter((p) => !p.isDateTime).map((p) => p.name)
const dateAttrs = properties.filter((p) => p.isDateTime).map((p) => p.name)
const attrs = properties
.filter((property) => property.format !== 'datetime')
.map((property) => property.name)
const dateAttrs = properties
.filter((property) => property.format === 'datetime')
.map((property) => property.name)
const noErrorWarningAttrs = attrs.filter(
(attr) => attr !== 'errors' && attr !== 'warnings',
)
Expand Down
138 changes: 0 additions & 138 deletions codegen/lib/openapi/deep-flatten-one-of-and-all-of-schema.ts

This file was deleted.

129 changes: 0 additions & 129 deletions codegen/lib/openapi/flatten-obj-schema.ts

This file was deleted.

23 changes: 0 additions & 23 deletions codegen/lib/openapi/get-filtered-routes.ts

This file was deleted.

Loading
Loading