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
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ node-openapi:
################################
JSONSCHEMA_OUT_DIR = lib/gen/jsonschema

# TODO: Once v3 is merged into main, removed the old defs.schema.json and change the ref from v3.0 to main.
download-schemas:
wget -O jsonschema/web-platform-dx_web-features/v3.data.schema.json \
https://raw.githubusercontent.com/web-platform-dx/web-features/refs/heads/v3.0/schemas/data.schema.json
wget -O jsonschema/web-platform-dx_web-features/defs.schema.json \
https://raw.githubusercontent.com/web-platform-dx/web-features/refs/heads/main/schemas/data.schema.json
wget -O jsonschema/mdn_browser-compat-data/browsers.schema.json \
Expand All @@ -185,7 +188,15 @@ jsonschema: clean-jsonschema
--out $(JSONSCHEMA_OUT_DIR)/web_platform_dx__web_features/feature_data.go \
--package web_platform_dx__web_features \
--field-tags json
cp web_platform_dx__web_features_extras.txt $(JSONSCHEMA_OUT_DIR)/web_platform_dx__web_features/extras.go

npx quicktype \
--src jsonschema/web-platform-dx_web-features/v3.data.schema.json \
--src-lang schema \
--lang go \
--top-level FeatureData \
--out $(JSONSCHEMA_OUT_DIR)/web_platform_dx__web_features_v3/feature_data.go \
--package web_platform_dx__web_features_v3 \
--field-tags json

npx quicktype \
--src jsonschema/mdn_browser-compat-data/browsers.schema.json \
Expand Down
319 changes: 319 additions & 0 deletions jsonschema/web-platform-dx_web-features/v3.data.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,319 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"description": "The top-level web-features data package",
"type": "object",
"properties": {
"browsers": {
"description": "Browsers and browser release data",
"type": "object",
"properties": {
"chrome": {
"$ref": "#/definitions/BrowserData"
},
"chrome_android": {
"$ref": "#/definitions/BrowserData"
},
"edge": {
"$ref": "#/definitions/BrowserData"
},
"firefox": {
"$ref": "#/definitions/BrowserData"
},
"firefox_android": {
"$ref": "#/definitions/BrowserData"
},
"safari": {
"$ref": "#/definitions/BrowserData"
},
"safari_ios": {
"$ref": "#/definitions/BrowserData"
}
},
"required": [
"chrome",
"chrome_android",
"edge",
"firefox",
"firefox_android",
"safari",
"safari_ios"
],
"additionalProperties": false
},
"features": {
"description": "Feature identifiers and data",
"type": "object",
"additionalProperties": {
"oneOf": [
{
"$ref": "#/definitions/FeatureData"
},
{
"$ref": "#/definitions/FeatureMovedData"
},
{
"$ref": "#/definitions/FeatureSplitData"
}
],
"$comment": "Use the `kind` property as a discriminator."
}
},
"groups": {
"description": "Group identifiers and data",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/GroupData"
}
},
"snapshots": {
"description": "Snapshot identifiers and data",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/SnapshotData"
}
}
},
"required": ["browsers", "features", "groups", "snapshots"],
"additionalProperties": false,
"definitions": {
"Discouraged": {
"type": "object",
"properties": {
"according_to": {
"description": "Links to a formal discouragement notice, such as specification text, intent-to-unship, etc.",
"$ref": "#/definitions/Strings"
},
"alternatives": {
"description": "IDs for features that substitute some or all of this feature's utility",
"$ref": "#/definitions/Strings"
}
},
"required": ["according_to"],
"additionalProperties": false
},
"BrowserData": {
"description": "Browser information",
"type": "object",
"properties": {
"name": {
"description": "The name of the browser, as in \"Edge\" or \"Safari on iOS\"",
"type": "string"
},
"releases": {
"type": "array",
"items": {
"$ref": "#/definitions/Release"
}
}
},
"required": ["name", "releases"],
"additionalProperties": false
},
"FeatureData": {
"description": "A feature data entry",
"type": "object",
"properties": {
"kind": {
"const": "feature"
},
"name": {
"description": "Short name",
"type": "string"
},
"description": {
"description": "Short description of the feature, as a plain text string",
"type": "string"
},
"description_html": {
"description": "Short description of the feature, as an HTML string",
"type": "string"
},
"spec": {
"description": "Specification URLs",
"$ref": "#/definitions/Strings"
},
"group": {
"description": "Group identifiers",
"$ref": "#/definitions/Strings"
},
"snapshot": {
"description": "Snapshot identifiers",
"$ref": "#/definitions/Strings"
},
"caniuse": {
"description": "caniuse.com identifiers",
"$ref": "#/definitions/Strings"
},
"compat_features": {
"description": "Sources of support data for this feature",
"$ref": "#/definitions/Strings"
},
"status": {
"description": "Whether a feature is considered a \"Baseline\" web platform feature and when it achieved that status",
"$ref": "#/definitions/StatusHeadline"
},
"discouraged": {
"description": "Whether developers are formally discouraged from using this feature",
"$ref": "#/definitions/Discouraged"
}
},
"required": [
"kind",
"name",
"description",
"description_html",
"spec",
"status"
],
"additionalProperties": false
},
"FeatureMovedData": {
"description": "A feature has permanently moved to exactly one other ID",
"type": "object",
"properties": {
"kind": {
"const": "moved"
},
"redirect_target": {
"description": "The new ID for this feature",
"type": "string"
}
},
"required": ["kind", "redirect_target"],
"additionalProperties": false
},
"FeatureSplitData": {
"description": "A feature has split into two or more other features",
"type": "object",
"properties": {
"kind": {
"const": "split"
},
"redirect_targets": {
"description": "The new IDs for this feature",
"$ref": "#/definitions/Strings"
}
},
"required": ["kind", "redirect_targets"],
"additionalProperties": false
},
"GroupData": {
"type": "object",
"properties": {
"name": {
"description": "Short name",
"type": "string"
},
"parent": {
"description": "Identifier of parent group",
"type": "string"
}
},
"required": ["name"],
"additionalProperties": false
},
"Release": {
"description": "Browser release information",
"type": "object",
"properties": {
"version": {
"description": "The version string, as in \"10\" or \"17.1\"",
"type": "string"
},
"date": {
"description": " The release date, as in \"2023-12-11\"",
"type": "string"
}
},
"required": ["version", "date"],
"additionalProperties": false
},
"SnapshotData": {
"type": "object",
"properties": {
"name": {
"description": "Short name",
"type": "string"
},
"spec": {
"description": "Specification",
"type": "string"
}
},
"required": ["name", "spec"],
"additionalProperties": false
},
"Status": {
"type": "object",
"properties": {
"baseline": {
"description": "Whether the feature is Baseline (low substatus), Baseline (high substatus), or not (false)",
"enum": ["high", "low", false]
},
"baseline_high_date": {
"description": "Date the feature achieved Baseline high status",
"type": "string"
},
"baseline_low_date": {
"description": "Date the feature achieved Baseline low status",
"type": "string"
},
"support": {
"description": "Browser versions that most-recently introduced the feature",
"type": "object",
"properties": {
"chrome": {
"type": "string"
},
"chrome_android": {
"type": "string"
},
"edge": {
"type": "string"
},
"firefox": {
"type": "string"
},
"firefox_android": {
"type": "string"
},
"safari": {
"type": "string"
},
"safari_ios": {
"type": "string"
}
},
"additionalProperties": false
}
},
"required": ["baseline", "support"]
},
"StatusHeadline": {
"type": "object",
"allOf": [{ "$ref": "#/definitions/Status" }],
"properties": {
"baseline": {},
"baseline_high_date": {},
"baseline_low_date": {},
"support": {},
"by_compat_key": {
"description": "Statuses for each key in the feature's compat_features list, if applicable. Not available to the npm release of web-features.",
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/Status"
}
}
},
"required": ["baseline", "support"],
"additionalProperties": false
},
"Strings": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"strings"

"github.com/GoogleChrome/webstatus.dev/lib/gcpspanner"
"github.com/GoogleChrome/webstatus.dev/lib/gen/jsonschema/web_platform_dx__web_features"
"github.com/GoogleChrome/webstatus.dev/lib/metricdatatypes"
"github.com/GoogleChrome/webstatus.dev/lib/webdxfeaturetypes"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
Expand Down Expand Up @@ -53,7 +53,7 @@ type ChromiumHistogramEnumsClient interface {
const logMissingFeatureIDMetricMsg = "unable to find feature ID. skipping mapping"

func (c *ChromiumHistogramEnumConsumer) GetAllMovedWebFeatures(
ctx context.Context) (map[string]web_platform_dx__web_features.FeatureMovedData, error) {
ctx context.Context) (map[string]webdxfeaturetypes.FeatureMovedData, error) {
movedFeatures, err := c.client.GetAllMovedWebFeatures(ctx)
if err != nil {
return nil, err
Expand Down Expand Up @@ -165,7 +165,7 @@ func migrateMovedFeaturesForChromiumHistograms(
ctx context.Context,
histogramsToEnumMap map[metricdatatypes.HistogramName]map[int64]*string,
histogramsToAllFeatureKeySet map[metricdatatypes.HistogramName]map[string]metricdatatypes.HistogramEnumValue,
movedFeatures map[string]web_platform_dx__web_features.FeatureMovedData,
movedFeatures map[string]webdxfeaturetypes.FeatureMovedData,
) error {
for histogram, allFeaturesKeySet := range histogramsToAllFeatureKeySet {
logger := slog.With("histogram", histogram)
Expand Down
Loading
Loading