Skip to content

Commit 2db5933

Browse files
committed
Add schemas and validation tooling
1 parent 82edc85 commit 2db5933

13 files changed

Lines changed: 433 additions & 1 deletion

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@ This repository contains the source for the APIOps Cycles method, including reso
66

77
## Requirements
88

9-
You can use the JSON files as is and download a .zip file or clone the repository. You can also install them using `npm install apiops-cycles-method-data`.
9+
You can use the JSON files as is and download a .zip file or clone the repository. You can also install them using `npm install apiops-cycles-method-data`.
10+
11+
This package can also be consumed directly from Git:
12+
13+
```bash
14+
npm install github:Osaango/apiops-cycles-method-data
15+
```
16+
17+
The module exposes top-level exports so you can import the data files directly, for example:
18+
19+
```js
20+
import stations from "apiops-cycles-method-data/method/stations.json";
21+
import canvasData from "apiops-cycles-method-data/canvasData";
22+
```
23+
24+
Validate the files locally with:
25+
26+
```bash
27+
npm test
28+
```
1029

1130
- **Node.js 22** or newer
1231
- npm

package-lock.json

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "apiops-cycles-method-data",
3+
"version": "1.0.0",
4+
"description": "APIOps Cycles Method data and canvases",
5+
"license": "Apache-2.0",
6+
"type": "module",
7+
"files": ["src/data"],
8+
"exports": {
9+
"./method/": "./src/data/method/",
10+
"./canvasData": "./src/data/canvas/canvasData.json",
11+
"./localizedData": "./src/data/canvas/localizedData.json",
12+
"./canvas/": "./src/data/canvas/import-export-templates/"
13+
},
14+
"scripts": {
15+
"test": "node scripts/validate.mjs"
16+
},
17+
"devDependencies": {
18+
"ajv": "^8.12.0"
19+
},
20+
"engines": {
21+
"node": ">=22"
22+
}
23+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"patternProperties": {
5+
".*": { "$ref": "#/definitions/locale" }
6+
},
7+
"additionalProperties": false,
8+
"definitions": {
9+
"locale": {
10+
"type": "object",
11+
"patternProperties": {
12+
".*": {
13+
"type": "object",
14+
"required": ["title", "purpose", "howToUse", "sections"],
15+
"additionalProperties": false,
16+
"properties": {
17+
"title": {"type": "string"},
18+
"purpose": {"type": "string"},
19+
"howToUse": {"type": "string"},
20+
"sections": {
21+
"type": "object",
22+
"additionalProperties": {
23+
"type": "object",
24+
"required": ["section", "description"],
25+
"additionalProperties": false,
26+
"properties": {
27+
"section": {"type": "string"},
28+
"description": {"type": "string"}
29+
}
30+
}
31+
}
32+
}
33+
}
34+
},
35+
"additionalProperties": false
36+
}
37+
}
38+
}

schemas/canvasData.schema.json

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"patternProperties": {
5+
".*": { "$ref": "#/definitions/canvas" }
6+
},
7+
"additionalProperties": false,
8+
"definitions": {
9+
"canvas": {
10+
"type": "object",
11+
"required": ["id", "layout", "metadata", "sections"],
12+
"additionalProperties": false,
13+
"properties": {
14+
"id": {"type": "string"},
15+
"layout": {
16+
"type": "object",
17+
"required": ["columns", "rows"],
18+
"properties": {
19+
"columns": {"type": "number"},
20+
"rows": {"type": "number"}
21+
},
22+
"additionalProperties": false
23+
},
24+
"metadata": {
25+
"type": "object",
26+
"required": ["source", "license", "authors", "website"],
27+
"properties": {
28+
"source": {"type": "string"},
29+
"license": {"type": "string"},
30+
"authors": {"type": "array", "items": {"type": "string"}},
31+
"website": {"type": "string"}
32+
},
33+
"additionalProperties": false
34+
},
35+
"sections": {
36+
"type": "array",
37+
"items": {
38+
"type": "object",
39+
"required": ["id", "gridPosition", "fillOrder"],
40+
"additionalProperties": false,
41+
"properties": {
42+
"id": {"type": "string"},
43+
"gridPosition": {
44+
"type": "object",
45+
"required": ["column", "row", "colSpan", "rowSpan"],
46+
"properties": {
47+
"column": {"type": "number"},
48+
"row": {"type": "number"},
49+
"colSpan": {"type": "number"},
50+
"rowSpan": {"type": "number"}
51+
},
52+
"additionalProperties": false
53+
},
54+
"fillOrder": {"type": "number"},
55+
"highlight": {"type": "boolean"},
56+
"journeySteps": {"type": "boolean"}
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}

schemas/criteria.schema.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "array",
4+
"items": {
5+
"type": "object",
6+
"required": ["id", "description"],
7+
"additionalProperties": false,
8+
"properties": {
9+
"id": {"type": "string"},
10+
"description": {"type": "string"}
11+
}
12+
}
13+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"required": ["templateId", "locale", "metadata", "sections"],
5+
"additionalProperties": false,
6+
"properties": {
7+
"templateId": {"type": "string"},
8+
"locale": {"type": "string"},
9+
"metadata": {
10+
"type": "object",
11+
"required": ["source", "license", "authors", "website"],
12+
"properties": {
13+
"source": {"type": "string"},
14+
"license": {"type": "string"},
15+
"authors": {"type": "array", "items": {"type": "string"}},
16+
"website": {"type": "string"}
17+
},
18+
"additionalProperties": false
19+
},
20+
"sections": {
21+
"type": "array",
22+
"items": {
23+
"type": "object",
24+
"required": ["sectionId", "stickyNotes"],
25+
"additionalProperties": false,
26+
"properties": {
27+
"sectionId": {"type": "string"},
28+
"stickyNotes": {
29+
"type": "array",
30+
"items": {
31+
"type": "object",
32+
"required": ["content", "size", "color"],
33+
"additionalProperties": false,
34+
"properties": {
35+
"content": {"type": "string"},
36+
"size": {"type": "number"},
37+
"color": {"type": "string"}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}

schemas/labels.schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"additionalProperties": {"type": "string"}
5+
}

schemas/lines.schema.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"required": ["lines"],
5+
"additionalProperties": false,
6+
"properties": {
7+
"lines": {
8+
"type": "object",
9+
"required": ["title", "slug", "order", "image", "description", "items"],
10+
"additionalProperties": false,
11+
"properties": {
12+
"title": {"type": "string"},
13+
"slug": {"type": "string"},
14+
"order": {"type": "number"},
15+
"image": {"type": "string"},
16+
"description": {"type": "string"},
17+
"items": {
18+
"type": "array",
19+
"items": {
20+
"type": "object",
21+
"required": ["id", "title", "slug", "order", "color", "description", "stations"],
22+
"additionalProperties": false,
23+
"properties": {
24+
"id": {"type": "string"},
25+
"title": {"type": "string"},
26+
"slug": {"type": "string"},
27+
"order": {"type": "number"},
28+
"color": {"type": "string"},
29+
"description": {"type": "string"},
30+
"stations": {
31+
"type": "array",
32+
"items": {"type": "string"}
33+
}
34+
}
35+
}
36+
}
37+
}
38+
}
39+
}
40+
}

schemas/resources.schema.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"required": ["resources"],
5+
"additionalProperties": false,
6+
"properties": {
7+
"resources": {
8+
"type": "array",
9+
"items": {
10+
"type": "object",
11+
"required": ["id", "title", "slug", "icon", "order", "description", "category"],
12+
"properties": {
13+
"id": {"type": "string"},
14+
"title": {"type": "string"},
15+
"slug": {"type": "string"},
16+
"icon": {"type": "string"},
17+
"order": {"type": "number"},
18+
"description": {"type": "string"},
19+
"category": {"type": "string"},
20+
"canvas": {"type": "string"},
21+
"image": {"type": "string"},
22+
"draft": {"type": ["string", "boolean"]},
23+
"outcomes": {
24+
"type": "array",
25+
"items": {"type": "string"}
26+
},
27+
"how_it_works": {
28+
"type": "object",
29+
"properties": {
30+
"steps": {
31+
"type": "array",
32+
"items": {"type": "string"}
33+
},
34+
"tips": {
35+
"type": "array",
36+
"items": {"type": "string"}
37+
}
38+
},
39+
"additionalProperties": false
40+
}
41+
},
42+
"additionalProperties": true
43+
}
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)