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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
wpt-repo
surveys
web-features-mappings.combined.json
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Examples of data sources which already map to web-features IDs and for which we

## The scripts folder

The `/script/` folder contains the JavaScript files that are responsible for updating the mapping files.
The `/scripts/` folder contains the JavaScript files that are responsible for updating the mapping files.

To run these scripts:

Expand All @@ -63,6 +63,20 @@ The mappings are JSON files that are formatted as follows:
}
```

## Combined data

The `combine` script generates a `web-features-mappings.combined.json` file in the root of the repository. This file contains all the mapping data from the `mappings` folder, combined into a single file.

The format of the combined file is as follows:

```json
{
"chrome-use-counters": { ... },
"interop": { ... },
...
}
```

## TODO

* Add mapping to origin trials.
Expand Down
303 changes: 303 additions & 0 deletions schemas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Web Feature Mappings Data",
"description": "A collection of schemas for each of the web feature mapping files.",
"type": "object",
"properties": {
"chrome-use-counters": {
"$ref": "#/$defs/chromeUseCountersFile"
},
"interop": {
"$ref": "#/$defs/interopFile"
},
"mdn-docs": {
"$ref": "#/$defs/mdnDocsFile"
},
"standards-positions": {
"$ref": "#/$defs/standardsPositionsFile"
},
"state-of-surveys": {
"$ref": "#/$defs/stateOfSurveysFile"
},
"wpt": {
"$ref": "#/$defs/wptFile"
}
},
"$comment": "The properties are the file names of the files in the mapping directory",
"additionalProperties": false,
"$defs": {
"chromeUseCountersFile": {
"description": "Schema for chrome-use-counters.json. An object where keys are feature IDs and values are usage metrics.",
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/useCounterValue"
}
},
"additionalProperties": false
},
"interopFile": {
"description": "Schema for interop.json. An object where keys are feature IDs and values are an array of interop records.",
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/interopHistory"
}
},
"additionalProperties": false
},
"mdnDocsFile": {
"description": "Schema for mdn-docs.json. An object where keys are feature IDs and values are an array of MDN documentation links.",
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/mdnLinkArray"
}
},
"additionalProperties": false
},
"standardsPositionsFile": {
"description": "Schema for standards-positions.json. An object where keys are feature IDs and values are an array of standards position records.",
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/standardsPositionArray"
}
},
"additionalProperties": false
},
"stateOfSurveysFile": {
"description": "Schema for state-of-surveys.json. An object where keys are feature IDs and values are an array of survey records.",
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/surveyRecordArray"
}
},
"additionalProperties": false
},
"wptFile": {
"description": "Schema for wpt.json. An object where keys are feature IDs and values are a record of Web Platform Tests.",
"type": "object",
"patternProperties": {
".*": {
"$ref": "#/$defs/wptRecord"
}
},
"additionalProperties": false
},
"useCounterValue": {
"type": "object",
"description": "The usage metrics for a single web feature from chrome-use-counters.json.",
"properties": {
"percentageOfPageLoad": {
"type": "number"
},
"url": {
"type": "string",
"format": "uri"
}
},
"required": [
"percentageOfPageLoad",
"url"
],
"additionalProperties": false
},
"interopHistory": {
"description": "An array of Interop records from interop.json.",
"type": "array",
"items": {
"$ref": "#/$defs/interopRecord"
},
"minItems": 1
},
"interopRecord": {
"type": "object",
"properties": {
"year": {
"type": "integer"
},
"label": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
}
},
"required": [
"year",
"label",
"url"
],
"additionalProperties": false
},
"mdnLinkArray": {
"description": "An array of MDN documentation links from mdn-docs.json.",
"type": "array",
"items": {
"$ref": "#/$defs/mdnLink"
},
"minItems": 1
},
"mdnLink": {
"type": "object",
"properties": {
"slug": {
"type": "string"
},
"title": {
"type": "string"
},
"anchor": {
"type": [
"string",
"null"
]
},
"url": {
"type": "string",
"format": "uri"
}
},
"required": [
"slug",
"title",
"anchor",
"url"
],
"additionalProperties": false
},
"standardsPositionArray": {
"description": "An array of standards position records from standards-positions.json.",
"type": "array",
"items": {
"$ref": "#/$defs/standardsPositionRecord"
},
"minItems": 1
},
"standardsPositionRecord": {
"type": "object",
"properties": {
"vendor": {
"type": "string",
"enum": [
"mozilla",
"webkit"
]
},
"url": {
"type": "string",
"format": "uri"
},
"position": {
"type": "string",
"enum": [
"",
"blocked",
"defer",
"negative",
"neutral",
"oppose",
"positive",
"support"
]
},
"concerns": {
"type": "array",
"items": {
"type": "string",
"enum": [
"API design",
"accessibility",
"annoyance",
"compatibility",
"complexity",
"dependencies",
"device independence",
"duplication",
"integration",
"internationalization",
"interoperability",
"maintenance",
"performance",
"portability",
"power",
"privacy",
"security",
"use cases",
"venue"
]
}
}
},
"required": [
"vendor",
"url",
"position",
"concerns"
],
"additionalProperties": false
},
"surveyRecordArray": {
"description": "An array of survey records from state-of-surveys.json.",
"type": "array",
"items": {
"$ref": "#/$defs/surveyRecord"
},
"minItems": 1
},
"surveyRecord": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"url": {
"type": "string",
"format": "uri"
},
"question": {
"type": "string"
},
"subQuestion": {
"type": "string"
},
"path": {
"type": "string"
}
},
"required": [
"name",
"url",
"question",
"subQuestion",
"path"
],
"additionalProperties": false
},
"wptRecord": {
"type": "object",
"description": "A record of Web Platform Tests from wpt.json.",
"properties": {
"url": {
"type": "string",
"format": "uri"
},
"tests": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
},
"required": [
"url",
"tests"
],
"additionalProperties": false
}
}
}
3 changes: 0 additions & 3 deletions scripts/.gitignore

This file was deleted.

30 changes: 30 additions & 0 deletions scripts/combine-mappings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import fs from "fs/promises";
import path from "path";
import { glob } from "glob";
import { fileURLToPath } from "url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

async function main() {
console.log("Combining mapping files...");

const mappingFiles = await glob(path.join(__dirname, "../mappings/*.json"));

const combinedData = {};

for (const file of mappingFiles) {
const fileKey = path.basename(file, ".json");
const data = JSON.parse(await fs.readFile(file, "utf-8"));
combinedData[fileKey] = data;
}

const outputFile = path.join(__dirname, "../web-features-mappings.combined.json");
await fs.writeFile(outputFile, JSON.stringify(combinedData, null, 2));

console.log(`Combined data written to ${outputFile}`);
}

main().catch((err) => {
console.error(err);
process.exit(1);
});
Loading