Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated code #2649

Merged
merged 3 commits into from
Jul 10, 2024
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
7 changes: 1 addition & 6 deletions compiler/src/model/build-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import {
modelBehaviors,
modelEnumDeclaration,
modelGenerics,
modelImplements,
modelInherits,
modelProperty,
modelType,
Expand Down Expand Up @@ -77,8 +76,6 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
visibility: spec.visibility
}
},
stability: spec.stability,
visibility: spec.visibility,
request: null,
requestBodyRequired: Boolean(spec.body?.required),
response: null,
Expand All @@ -91,7 +88,7 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
})
}
if (typeof spec.feature_flag === 'string') {
map[api].featureFlag = spec.feature_flag
map[api].availability.stack.featureFlag = spec.feature_flag
}
}
return map
Expand Down Expand Up @@ -534,8 +531,6 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
for (const implement of declaration.getImplements()) {
if (isKnownBehavior(implement)) {
type.behaviors = (type.behaviors ?? []).concat(modelBehaviors(implement, jsDocs))
} else {
type.implements = (type.implements ?? []).concat(modelImplements(implement))
}
}
}
Expand Down
13 changes: 0 additions & 13 deletions compiler/src/model/metamodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,9 @@ export class Property {
description?: string
docUrl?: string
docId?: string
since?: string
serverDefault?: boolean | string | number | string[] | number[]
deprecation?: Deprecation
availability?: Availabilities
stability?: Stability
/**
* If specified takes precedence over `name` when generating code. `name` is always the value
* to be sent over the wire
Expand Down Expand Up @@ -237,7 +235,6 @@ export class Interface extends BaseType {
*/
generics?: TypeName[]
inherits?: Inherits
implements?: Inherits[]

/**
* Behaviors directly implemented by this interface
Expand Down Expand Up @@ -268,7 +265,6 @@ export class Request extends BaseType {
generics?: TypeName[]
/** The parent defines additional body properties that are added to the body, that has to be a PropertyBody */
inherits?: Inherits
implements?: Inherits[]
/** URL path properties */
path: Property[]
/** Query string properties */
Expand Down Expand Up @@ -344,7 +340,6 @@ export class EnumMember {
codegenName?: string
description?: string
deprecation?: Deprecation
since?: string
availability?: Availabilities
}

Expand Down Expand Up @@ -429,14 +424,6 @@ export class Endpoint {

urls: UrlTemplate[]

/**
* The version when this endpoint reached its current stability level.
* Missing data means "forever", i.e. before any of the target client versions produced from this spec.
*/
since?: string
stability?: Stability
visibility?: Visibility
featureFlag?: string
requestMediaType?: string[]
responseMediaType?: string[]
privileges?: {
Expand Down
33 changes: 0 additions & 33 deletions compiler/src/model/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -695,22 +695,6 @@ export function hoistRequestAnnotations (
// Apply the availabilities to the Endpoint.
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
endpoint.availability[availabilityName] = availabilityValue

// Backfilling deprecated fields on an endpoint.
if (availabilityName === 'stack') {
if (availabilityValue.since !== undefined) {
endpoint.since = availabilityValue.since
}
if (availabilityValue.stability !== undefined) {
endpoint.stability = availabilityValue.stability
}
if (availabilityValue.visibility !== undefined) {
endpoint.visibility = availabilityValue.visibility
}
if (availabilityValue.featureFlag !== undefined) {
endpoint.featureFlag = availabilityValue.featureFlag
}
}
}
} else {
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on request ${request.name.name}`)
Expand Down Expand Up @@ -813,16 +797,6 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
property.availability = {}
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
property.availability[availabilityName] = availabilityValue

// Backfilling deprecated fields on a property.
if (availabilityName === 'stack') {
if (availabilityValue.since !== undefined) {
property.since = availabilityValue.since
}
if (availabilityValue.stability !== undefined) {
property.stability = availabilityValue.stability
}
}
}
} else if (tag === 'doc_id') {
assert(jsDocs, value.trim() !== '', `Property ${property.name}'s @doc_id is cannot be empty`)
Expand Down Expand Up @@ -924,13 +898,6 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
member.availability = {}
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
member.availability[availabilityName] = availabilityValue

// Backfilling deprecated fields on a property.
if (availabilityName === 'stack') {
if (availabilityValue.since !== undefined) {
member.since = availabilityValue.since
}
}
}
} else {
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on enum member ${member.name}`)
Expand Down
24 changes: 5 additions & 19 deletions compiler/src/steps/validate-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
const parentTypes = new Set<string>()
for (const type of apiModel.types) {
if (type.kind === 'request' || type.kind === 'interface') {
for (const parent of (type.implements ?? []).concat(type.inherits ?? [])) {
parentTypes.add(fqn(parent.type))
if (type.inherits != null) {
parentTypes.add(fqn(type.inherits.type))
}
}
}
Expand Down Expand Up @@ -380,7 +380,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
const openGenerics = openGenericSet(typeDef)

validateInherits(typeDef.inherits, openGenerics)
validateImplements(typeDef.implements, openGenerics)
validateBehaviors(typeDef, openGenerics)

// Note: we validate codegen_name/name uniqueness independently in the path, query and body as there are some
Expand Down Expand Up @@ -495,7 +494,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
if (typeDef.inherits != null) {
addInherits(typeDef.inherits)
}
typeDef.implements?.forEach(addInherits)
typeDef.behaviors?.forEach(addInherits)
}

Expand All @@ -505,7 +503,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
function validateInterface (typeDef: model.Interface): void {
const openGenerics = openGenericSet(typeDef)

validateImplements(typeDef.implements, openGenerics)
validateInherits(typeDef.inherits, openGenerics)
validateBehaviors(typeDef, openGenerics)
validateProperties(typeDef.properties, openGenerics, inheritedProperties(typeDef))
Expand Down Expand Up @@ -694,16 +691,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
context.pop()
}

function validateImplements (parents: (model.Inherits[] | undefined), openGenerics: Set<string>): void {
if (parents == null || parents.length === 0) return

context.push('Implements')
for (const parent of parents) {
validateTypeRef(parent.type, parent.generics, openGenerics)
}
context.pop()
}

function validateBehaviors (typeDef: model.Request | model.Response | model.Interface, openGenerics: Set<string>): void {
if (typeDef.kind !== 'response' && typeDef.behaviors != null && typeDef.behaviors.length > 0) {
context.push('Behaviors')
Expand Down Expand Up @@ -746,11 +733,10 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
}

// Does a parent have this behavior?
const parents = (type.implements ?? []).concat(type.inherits ?? [])
for (const parent of parents) {
const parentDef = getTypeDef(parent.type)
if (type.inherits != null) {
const parentDef = getTypeDef(type.inherits.type)
if (parentDef == null) {
modelError(`No type definition for parent '${fqn(parent.type)}'`)
modelError(`No type definition for parent '${fqn(type.inherits.type)}'`)
return false
}
if (parentDef.kind === 'request' || parentDef.kind === 'interface') {
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/transform/filter-by-availability.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ function filterModel (inputModel: Model, stack: boolean, serverless: boolean, vi
if (typeDef.inherits !== undefined) {
addTypeToOutput(typeDef.inherits.type)
}
typeDef.implements?.forEach((implemented) => {
addTypeToOutput(implemented.type)
})
}

// handle body value and body properties for request and response
Expand Down
5 changes: 0 additions & 5 deletions compiler/test/request-availability/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,4 @@ test('Request @availability can fulfill all the fields', t => {
stack: { stability: 'beta', visibility: 'feature_flag', featureFlag: 'abc', since: '1.2.3' },
serverless: { visibility: 'private', stability: 'experimental' }
});
// Assert backfilled values are correct
t.true(endpoint?.visibility === 'feature_flag');
t.true(endpoint?.stability === 'beta');
t.true(endpoint?.featureFlag === 'abc');
t.true(endpoint?.since === '1.2.3');
})
Loading
Loading