Skip to content

Commit 3b92227

Browse files
Merge remote-tracking branch 'origin/main' into google-model-garden-integration
2 parents 738a415 + c3b0692 commit 3b92227

File tree

25 files changed

+2183
-496
lines changed

25 files changed

+2183
-496
lines changed

compiler/src/compiler.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import { writeFile, mkdir } from 'fs/promises'
2121
import { join } from 'path'
2222
import stringify from 'safe-stable-stringify'
2323
import { Model } from './model/metamodel'
24-
import { compileEndpoints, compileSpecification } from './model/build-model'
24+
import {
25+
compileEndpoints,
26+
compileSpecification,
27+
reAddAvailability
28+
} from './model/build-model'
2529
import buildJsonSpec, { JsonSpec } from './model/json-spec'
2630
import { ValidationErrors } from './validation-errors'
2731

@@ -54,6 +58,7 @@ export default class Compiler {
5458
this.jsonSpec = buildJsonSpec()
5559
const endpoints = compileEndpoints()
5660
this.model = compileSpecification(endpoints, this.specsFolder, this.outputFolder)
61+
this.model = reAddAvailability(this.model) // resync availability information based on json spec if typescript has none.
5762
return this
5863
}
5964

compiler/src/model/build-model.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@ import {
5858

5959
const jsonSpec = buildJsonSpec()
6060

61+
export function reAddAvailability (model: model.Model): model.Model {
62+
for (const [api, spec] of jsonSpec.entries()) {
63+
for (const endpoint of model.endpoints) {
64+
if (endpoint.name === api) {
65+
if ((spec.stability != null || spec.visibility != null) && (endpoint.availability.stack === undefined && endpoint.availability.serverless === undefined)) {
66+
endpoint.availability = {
67+
stack: {
68+
stability: spec.stability,
69+
visibility: spec.visibility
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
return model
77+
}
78+
6179
export function compileEndpoints (): Record<string, model.Endpoint> {
6280
// Create endpoints and merge them with
6381
// the recorded mappings if present.
@@ -72,12 +90,7 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
7290
// Setting these values by default should be removed
7391
// when we no longer use rest-api-spec stubs as the
7492
// source of truth for stability/visibility.
75-
availability: {
76-
stack: {
77-
stability: spec.stability,
78-
visibility: spec.visibility
79-
}
80-
},
93+
availability: {},
8194
request: null,
8295
requestBodyRequired: Boolean(spec.body?.required),
8396
response: null,
@@ -89,8 +102,15 @@ export function compileEndpoints (): Record<string, model.Endpoint> {
89102
}
90103
})
91104
}
105+
106+
// temporary workaround for APIs that are serverless-only
107+
// until we can stop depending on rest-api-spec for availability
108+
if (api === 'project.tags') {
109+
delete map[api].availability.stack
110+
}
111+
92112
if (typeof spec.feature_flag === 'string') {
93-
map[api].availability.stack.featureFlag = spec.feature_flag
113+
map[api].availability.stack = { featureFlag: spec.feature_flag }
94114
}
95115
}
96116
return map

docs/overlays/elasticsearch-shared-overlays.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,3 +1152,11 @@ actions:
11521152
- target: "$.components['schemas']['cat._types.CatTransformColumn'].enum"
11531153
description: Remove enum array from cat transforms
11541154
remove: true
1155+
# Simplify duration type
1156+
- target: "$.components['schemas']['_types.Duration'].oneOf"
1157+
description: Remove existing oneOf definition for Duration
1158+
remove: true
1159+
- target: "$.components['schemas']['_types.Duration']"
1160+
description: Re-add a simple string type for Duration
1161+
update:
1162+
type: string

0 commit comments

Comments
 (0)