Skip to content

Commit 0bd7cf9

Browse files
authored
Remove deprecated code (#2649)
1 parent 296c8e1 commit 0bd7cf9

File tree

9 files changed

+527
-2266
lines changed

9 files changed

+527
-2266
lines changed

compiler/src/model/build-model.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import {
4444
modelBehaviors,
4545
modelEnumDeclaration,
4646
modelGenerics,
47-
modelImplements,
4847
modelInherits,
4948
modelProperty,
5049
modelType,
@@ -77,8 +76,6 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
7776
visibility: spec.visibility
7877
}
7978
},
80-
stability: spec.stability,
81-
visibility: spec.visibility,
8279
request: null,
8380
requestBodyRequired: Boolean(spec.body?.required),
8481
response: null,
@@ -91,7 +88,7 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
9188
})
9289
}
9390
if (typeof spec.feature_flag === 'string') {
94-
map[api].featureFlag = spec.feature_flag
91+
map[api].availability.stack.featureFlag = spec.feature_flag
9592
}
9693
}
9794
return map
@@ -534,8 +531,6 @@ function compileClassOrInterfaceDeclaration (declaration: ClassDeclaration | Int
534531
for (const implement of declaration.getImplements()) {
535532
if (isKnownBehavior(implement)) {
536533
type.behaviors = (type.behaviors ?? []).concat(modelBehaviors(implement, jsDocs))
537-
} else {
538-
type.implements = (type.implements ?? []).concat(modelImplements(implement))
539534
}
540535
}
541536
}

compiler/src/model/metamodel.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,9 @@ export class Property {
126126
description?: string
127127
docUrl?: string
128128
docId?: string
129-
since?: string
130129
serverDefault?: boolean | string | number | string[] | number[]
131130
deprecation?: Deprecation
132131
availability?: Availabilities
133-
stability?: Stability
134132
/**
135133
* If specified takes precedence over `name` when generating code. `name` is always the value
136134
* to be sent over the wire
@@ -237,7 +235,6 @@ export class Interface extends BaseType {
237235
*/
238236
generics?: TypeName[]
239237
inherits?: Inherits
240-
implements?: Inherits[]
241238

242239
/**
243240
* Behaviors directly implemented by this interface
@@ -268,7 +265,6 @@ export class Request extends BaseType {
268265
generics?: TypeName[]
269266
/** The parent defines additional body properties that are added to the body, that has to be a PropertyBody */
270267
inherits?: Inherits
271-
implements?: Inherits[]
272268
/** URL path properties */
273269
path: Property[]
274270
/** Query string properties */
@@ -344,7 +340,6 @@ export class EnumMember {
344340
codegenName?: string
345341
description?: string
346342
deprecation?: Deprecation
347-
since?: string
348343
availability?: Availabilities
349344
}
350345

@@ -429,14 +424,6 @@ export class Endpoint {
429424

430425
urls: UrlTemplate[]
431426

432-
/**
433-
* The version when this endpoint reached its current stability level.
434-
* Missing data means "forever", i.e. before any of the target client versions produced from this spec.
435-
*/
436-
since?: string
437-
stability?: Stability
438-
visibility?: Visibility
439-
featureFlag?: string
440427
requestMediaType?: string[]
441428
responseMediaType?: string[]
442429
privileges?: {

compiler/src/model/utils.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -695,22 +695,6 @@ export function hoistRequestAnnotations (
695695
// Apply the availabilities to the Endpoint.
696696
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
697697
endpoint.availability[availabilityName] = availabilityValue
698-
699-
// Backfilling deprecated fields on an endpoint.
700-
if (availabilityName === 'stack') {
701-
if (availabilityValue.since !== undefined) {
702-
endpoint.since = availabilityValue.since
703-
}
704-
if (availabilityValue.stability !== undefined) {
705-
endpoint.stability = availabilityValue.stability
706-
}
707-
if (availabilityValue.visibility !== undefined) {
708-
endpoint.visibility = availabilityValue.visibility
709-
}
710-
if (availabilityValue.featureFlag !== undefined) {
711-
endpoint.featureFlag = availabilityValue.featureFlag
712-
}
713-
}
714698
}
715699
} else {
716700
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on request ${request.name.name}`)
@@ -813,16 +797,6 @@ function hoistPropertyAnnotations (property: model.Property, jsDocs: JSDoc[]): v
813797
property.availability = {}
814798
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
815799
property.availability[availabilityName] = availabilityValue
816-
817-
// Backfilling deprecated fields on a property.
818-
if (availabilityName === 'stack') {
819-
if (availabilityValue.since !== undefined) {
820-
property.since = availabilityValue.since
821-
}
822-
if (availabilityValue.stability !== undefined) {
823-
property.stability = availabilityValue.stability
824-
}
825-
}
826800
}
827801
} else if (tag === 'doc_id') {
828802
assert(jsDocs, value.trim() !== '', `Property ${property.name}'s @doc_id is cannot be empty`)
@@ -924,13 +898,6 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
924898
member.availability = {}
925899
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
926900
member.availability[availabilityName] = availabilityValue
927-
928-
// Backfilling deprecated fields on a property.
929-
if (availabilityName === 'stack') {
930-
if (availabilityValue.since !== undefined) {
931-
member.since = availabilityValue.since
932-
}
933-
}
934901
}
935902
} else {
936903
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on enum member ${member.name}`)

compiler/src/steps/validate-model.ts

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
135135
const parentTypes = new Set<string>()
136136
for (const type of apiModel.types) {
137137
if (type.kind === 'request' || type.kind === 'interface') {
138-
for (const parent of (type.implements ?? []).concat(type.inherits ?? [])) {
139-
parentTypes.add(fqn(parent.type))
138+
if (type.inherits != null) {
139+
parentTypes.add(fqn(type.inherits.type))
140140
}
141141
}
142142
}
@@ -380,7 +380,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
380380
const openGenerics = openGenericSet(typeDef)
381381

382382
validateInherits(typeDef.inherits, openGenerics)
383-
validateImplements(typeDef.implements, openGenerics)
384383
validateBehaviors(typeDef, openGenerics)
385384

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

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

508-
validateImplements(typeDef.implements, openGenerics)
509506
validateInherits(typeDef.inherits, openGenerics)
510507
validateBehaviors(typeDef, openGenerics)
511508
validateProperties(typeDef.properties, openGenerics, inheritedProperties(typeDef))
@@ -694,16 +691,6 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
694691
context.pop()
695692
}
696693

697-
function validateImplements (parents: (model.Inherits[] | undefined), openGenerics: Set<string>): void {
698-
if (parents == null || parents.length === 0) return
699-
700-
context.push('Implements')
701-
for (const parent of parents) {
702-
validateTypeRef(parent.type, parent.generics, openGenerics)
703-
}
704-
context.pop()
705-
}
706-
707694
function validateBehaviors (typeDef: model.Request | model.Response | model.Interface, openGenerics: Set<string>): void {
708695
if (typeDef.kind !== 'response' && typeDef.behaviors != null && typeDef.behaviors.length > 0) {
709696
context.push('Behaviors')
@@ -746,11 +733,10 @@ export default async function validateModel (apiModel: model.Model, restSpec: Ma
746733
}
747734

748735
// Does a parent have this behavior?
749-
const parents = (type.implements ?? []).concat(type.inherits ?? [])
750-
for (const parent of parents) {
751-
const parentDef = getTypeDef(parent.type)
736+
if (type.inherits != null) {
737+
const parentDef = getTypeDef(type.inherits.type)
752738
if (parentDef == null) {
753-
modelError(`No type definition for parent '${fqn(parent.type)}'`)
739+
modelError(`No type definition for parent '${fqn(type.inherits.type)}'`)
754740
return false
755741
}
756742
if (parentDef.kind === 'request' || parentDef.kind === 'interface') {

compiler/src/transform/filter-by-availability.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,6 @@ function filterModel (inputModel: Model, stack: boolean, serverless: boolean, vi
131131
if (typeDef.inherits !== undefined) {
132132
addTypeToOutput(typeDef.inherits.type)
133133
}
134-
typeDef.implements?.forEach((implemented) => {
135-
addTypeToOutput(implemented.type)
136-
})
137134
}
138135

139136
// handle body value and body properties for request and response

compiler/test/request-availability/test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,4 @@ test('Request @availability can fulfill all the fields', t => {
3535
stack: { stability: 'beta', visibility: 'feature_flag', featureFlag: 'abc', since: '1.2.3' },
3636
serverless: { visibility: 'private', stability: 'experimental' }
3737
});
38-
// Assert backfilled values are correct
39-
t.true(endpoint?.visibility === 'feature_flag');
40-
t.true(endpoint?.stability === 'beta');
41-
t.true(endpoint?.featureFlag === 'abc');
42-
t.true(endpoint?.since === '1.2.3');
4338
})

0 commit comments

Comments
 (0)