Skip to content

Commit

Permalink
chore: update web-features from 1.0.0 to 2.15.0 (#1020)
Browse files Browse the repository at this point in the history
Notable things that have been added:
- Browser Release data. Now, we could actually remove the bcd job and migrate the logic into the web features job since we can get the same data from the v2.15.0 of the schema.

This commit also modifies the go code to add the new fields with sensible null / zero values since we don't need them yet. We have to add these fields to satisfy the [exhaustruct](https://github.com/GaijinEntertainment/go-exhaustruct) linter

Manual changes that we kept from #531:
- Add an explicit StringorStringArray definition. Because it otherwise it takes the name of the first variable of it (previously Alias and now Caniuse) and uses it everywhere else. So all the usages would use Caniuse And that does not explain that the value could be a String of String Array.
  • Loading branch information
jcscottiii authored Dec 30, 2024
1 parent 93b87c1 commit 489104c
Show file tree
Hide file tree
Showing 9 changed files with 370 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ JSONSCHEMA_OUT_DIR = lib/gen/jsonschema

download-schemas:
wget -O jsonschema/web-platform-dx_web-features/defs.schema.json \
https://raw.githubusercontent.com/web-platform-dx/feature-set/main/schemas/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 \
https://raw.githubusercontent.com/mdn/browser-compat-data/main/schemas/browsers.schema.json

Expand Down
197 changes: 176 additions & 21 deletions jsonschema/web-platform-dx_web-features/defs.schema.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"$id": "defs",
"$ref": "#/definitions/WebFeaturesData",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
Expand All @@ -18,12 +17,34 @@
}
]
},
"BrowserData": {
"additionalProperties": false,
"description": "Browser information",
"properties": {
"name": {
"description": "The name of the browser, as in \"Edge\" or \"Safari on iOS\"",
"type": "string"
},
"releases": {
"description": "The browser's releases",
"items": {
"$ref": "#/definitions/Release"
},
"type": "array"
}
},
"required": [
"name",
"releases"
],
"type": "object"
},
"FeatureData": {
"additionalProperties": false,
"properties": {
"caniuse": {
"$ref": "#/definitions/StringOrStringArray",
"description": "caniuse.com identifier"
"description": "caniuse.com identifier(s)"
},
"compat_features": {
"description": "Sources of support data for this feature",
Expand All @@ -40,43 +61,59 @@
"description": "Short description of the feature, as an HTML string",
"type": "string"
},
"discouraged": {
"additionalProperties": false,
"description": "Whether developers are formally discouraged from using this feature",
"properties": {
"according_to": {
"description": "Links to a formal discouragement notice, such as specification text, intent-to-unship, etc.",
"items": {
"type": "string"
},
"type": "array"
},
"alternatives": {
"description": "IDs for features that substitute some or all of this feature's utility",
"items": {},
"type": "array"
}
},
"required": [
"according_to"
],
"type": "object"
},
"group": {
"$ref": "#/definitions/StringOrStringArray",
"description": "Group identifier"
"description": "Group identifier(s)"
},
"name": {
"description": "Short name",
"type": "string"
},
"snapshot": {
"$ref": "#/definitions/StringOrStringArray",
"description": "Snapshot identifier"
"description": "Snapshot identifier(s)"
},
"spec": {
"$ref": "#/definitions/StringOrStringArray",
"description": "Specification"
"description": "Specification URL(s)"
},
"status": {
"additionalProperties": false,
"description": "Whether a feature is considered a \"baseline\" web platform feature and when it achieved that status",
"properties": {
"baseline": {
"anyOf": [
{
"enum": [
"high",
"low"
],
"type": "string"
},
{
"enum": [
false
],
"type": "boolean"
}
"description": "Whether the feature is Baseline (low substatus), Baseline (high substatus), or not (false)",
"enum": [
"high",
"low",
false
],
"description": "Whether the feature is Baseline (low substatus), Baseline (high substatus), or not (false)"
"type": [
"string",
"boolean"
]
},
"baseline_high_date": {
"description": "Date the feature achieved Baseline high status",
Expand All @@ -86,6 +123,68 @@
"description": "Date the feature achieved Baseline low status",
"type": "string"
},
"by_compat_key": {
"additionalProperties": {
"additionalProperties": false,
"properties": {
"baseline": {
"description": "Whether the feature is Baseline (low substatus), Baseline (high substatus), or not (false)",
"enum": [
"high",
"low",
false
],
"type": [
"string",
"boolean"
]
},
"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": {
"additionalProperties": false,
"description": "Browser versions that most-recently introduced the feature",
"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"
}
},
"type": "object"
}
},
"required": [
"baseline",
"support"
],
"type": "object"
},
"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"
},
"support": {
"additionalProperties": false,
"description": "Browser versions that most-recently introduced the feature",
Expand Down Expand Up @@ -148,6 +247,25 @@
],
"type": "object"
},
"Release": {
"additionalProperties": false,
"description": "Browser release information",
"properties": {
"date": {
"description": "The release date, as in \"2023-12-11\"",
"type": "string"
},
"version": {
"description": "The version string, as in \"10\" or \"17.1\"",
"type": "string"
}
},
"required": [
"version",
"date"
],
"type": "object"
},
"SnapshotData": {
"additionalProperties": false,
"properties": {
Expand All @@ -157,7 +275,6 @@
},
"spec": {
"description": "Specification",
"format": "uri",
"type": "string"
}
},
Expand All @@ -170,6 +287,43 @@
"WebFeaturesData": {
"additionalProperties": false,
"properties": {
"browsers": {
"additionalProperties": false,
"description": "Browsers and browser release data",
"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"
],
"type": "object"
},
"features": {
"additionalProperties": {
"$ref": "#/definitions/FeatureData"
Expand All @@ -193,6 +347,7 @@
}
},
"required": [
"browsers",
"features",
"groups",
"snapshots"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,16 @@ func TestInsertWebFeatureGroups(t *testing.T) {
CompatFeatures: nil,
Description: "",
DescriptionHTML: "",
Discouraged: nil,
Name: "",
Snapshot: nil,
Spec: nil,
Status: web_platform_dx__web_features.Status{
Baseline: nil,
BaselineHighDate: nil,
BaselineLowDate: nil,
Support: web_platform_dx__web_features.Support{
ByCompatKey: nil,
Support: web_platform_dx__web_features.StatusSupport{
Chrome: nil,
ChromeAndroid: nil,
Edge: nil,
Expand All @@ -235,14 +237,16 @@ func TestInsertWebFeatureGroups(t *testing.T) {
CompatFeatures: nil,
Description: "",
DescriptionHTML: "",
Discouraged: nil,
Name: "",
Snapshot: nil,
Spec: nil,
Status: web_platform_dx__web_features.Status{
Baseline: nil,
BaselineHighDate: nil,
BaselineLowDate: nil,
Support: web_platform_dx__web_features.Support{
ByCompatKey: nil,
Support: web_platform_dx__web_features.StatusSupport{
Chrome: nil,
ChromeAndroid: nil,
Edge: nil,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func TestInsertWebFeatureSnapshots(t *testing.T) {
},
featureData: map[string]web_platform_dx__web_features.FeatureValue{
"feature1": {
Discouraged: nil,
Snapshot: &web_platform_dx__web_features.StringOrStringArray{
StringArray: []string{"snapshot1", "snapshot2"},
String: nil,
Expand All @@ -160,10 +161,11 @@ func TestInsertWebFeatureSnapshots(t *testing.T) {
Group: nil,
Spec: nil,
Status: web_platform_dx__web_features.Status{
ByCompatKey: nil,
Baseline: nil,
BaselineHighDate: nil,
BaselineLowDate: nil,
Support: web_platform_dx__web_features.Support{
Support: web_platform_dx__web_features.StatusSupport{
Chrome: nil,
ChromeAndroid: nil,
Edge: nil,
Expand All @@ -175,6 +177,7 @@ func TestInsertWebFeatureSnapshots(t *testing.T) {
},
},
"feature2": {
Discouraged: nil,
Snapshot: &web_platform_dx__web_features.StringOrStringArray{
String: valuePtr("snapshot1"),
StringArray: nil,
Expand All @@ -190,7 +193,8 @@ func TestInsertWebFeatureSnapshots(t *testing.T) {
Baseline: nil,
BaselineHighDate: nil,
BaselineLowDate: nil,
Support: web_platform_dx__web_features.Support{
ByCompatKey: nil,
Support: web_platform_dx__web_features.StatusSupport{
Chrome: nil,
ChromeAndroid: nil,
Edge: nil,
Expand Down
Loading

0 comments on commit 489104c

Please sign in to comment.