Skip to content

Commit 487ea9a

Browse files
authored
Add @availability tag to EnumMembers
1 parent 328513c commit 487ea9a

File tree

7 files changed

+69
-13
lines changed

7 files changed

+69
-13
lines changed

compiler/src/model/metamodel.ts

+1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ export class EnumMember {
334334
description?: string
335335
deprecation?: Deprecation
336336
since?: string
337+
availability?: Availabilities
337338
}
338339

339340
/**

compiler/src/model/utils.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
850850
// We want to enforce a single jsDoc block.
851851
assert(jsDocs, jsDocs.length < 2, 'Use a single multiline jsDoc block instead of multiple single line blocks')
852852

853-
const validTags = ['obsolete', 'obsolete_description', 'codegen_name', 'since', 'aliases']
853+
const validTags = ['obsolete', 'obsolete_description', 'codegen_name', 'availability', 'aliases']
854854
const tags = parseJsDocTags(jsDocs)
855855
if (jsDocs.length === 1) {
856856
const description = jsDocs[0].getDescription()
@@ -862,9 +862,26 @@ function hoistEnumMemberAnnotations (member: model.EnumMember, jsDocs: JSDoc[]):
862862
member.codegenName = value
863863
} else if (tag === 'aliases') {
864864
member.aliases = parseCommaSeparated(value)
865-
} else if (tag === 'since') {
866-
assert(jsDocs, semver.valid(value), `${member.name}'s @since is not valid semver: ${value}`)
867-
member.since = value
865+
} else if (tag === 'availability') {
866+
// The @availability jsTag is different than most because it allows
867+
// multiple values within the same docstring, hence needing to parse
868+
// the values again in order to preserve multiple values.
869+
const jsDocsMulti = parseJsDocTagsAllowDuplicates(jsDocs)
870+
const availabilities = parseAvailabilityTags(jsDocs, jsDocsMulti.availability)
871+
872+
// The absence of an 'availability' field on a property implies that
873+
// the property is available in all flavors.
874+
member.availability = {}
875+
for (const [availabilityName, availabilityValue] of Object.entries(availabilities)) {
876+
member.availability[availabilityName] = availabilityValue
877+
878+
// Backfilling deprecated fields on a property.
879+
if (availabilityName === 'stack') {
880+
if (availabilityValue.since !== undefined) {
881+
member.since = availabilityValue.since
882+
}
883+
}
884+
}
868885
} else {
869886
assert(jsDocs, false, `Unhandled tag: '${tag}' with value: '${value}' on enum member ${member.name}`)
870887
}

output/schema/schema.json

+28-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

specification/_global/search_mvt/_types/GridType.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
export enum GridType {
2121
grid,
2222
point,
23-
/** @since 7.16.0 */
23+
/**
24+
* @availability stack since=7.16.0
25+
* @availability serverless
26+
*/
2427
centroid
2528
}
2629

specification/indices/stats/types.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ export class ShardStats {
223223
}
224224

225225
/**
226-
* @since 8.1.0
226+
* @availability stack since=8.1.0
227+
* @availability serverless
227228
*/
228229
export enum IndexMetadataState {
229230
open,

specification/snapshot/_types/SnapshotInfo.ts

+12-3
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,19 @@ export enum SnapshotSort {
7575
duration,
7676
name,
7777
index_count,
78-
/** @since 7.16.0 */
78+
/**
79+
* @availability stack since=7.16.0
80+
* @availability serverless
81+
*/
7982
repository,
80-
/** @since 7.16.0 */
83+
/**
84+
* @availability stack since=7.16.0
85+
* @availability serverless
86+
*/
8187
shard_count,
82-
/** @since 7.16.0 */
88+
/**
89+
* @availability stack since=7.16.0
90+
* @availability serverless
91+
*/
8392
failed_shard_count
8493
}

typescript-generator/src/metamodel.ts

+1
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ export class EnumMember {
334334
description?: string
335335
deprecation?: Deprecation
336336
since?: string
337+
availability?: Availabilities
337338
}
338339

339340
/**

0 commit comments

Comments
 (0)