Skip to content

Commit 4ddffe9

Browse files
committed
🍱 Update json schemas
1 parent c91c1e0 commit 4ddffe9

File tree

5 files changed

+132
-22
lines changed

5 files changed

+132
-22
lines changed

cmd/schemas.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ var schemasCmd = &cobra.Command{
4242
printSchema(ortfodb.TechnologiesRepositoryJSONSchema())
4343
case "exporter":
4444
printSchema(ortfodb.ExporterManifestJSONSchema())
45+
case "importer":
46+
printSchema(ortfodb.ImporterManifestJSONSchema())
4547
}
4648
},
4749
}

jsonschema.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/invopop/jsonschema"
88
)
99

10-
var AvailableJSONSchemas = []string{"configuration", "database", "tags", "technologies", "exporter"}
10+
var AvailableJSONSchemas = []string{"configuration", "database", "tags", "technologies", "exporter", "importer"}
1111

1212
var yamlReflector = jsonschema.Reflector{
1313
FieldNameTag: "yaml",
@@ -56,3 +56,9 @@ func ExporterManifestJSONSchema() *jsonschema.Schema {
5656
setSchemaId(schema, "exporter")
5757
return schema
5858
}
59+
60+
func ImporterManifestJSONSchema() *jsonschema.Schema {
61+
schema := makeJSONSchema(&ImporterManifest{}, true)
62+
setSchemaId(schema, "importer")
63+
return schema
64+
}

schemas/configuration.schema.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
},
3737
"type": "object",
3838
"description": "Exporter-specific configuration. Maps exporter names to their configuration."
39+
},
40+
"importers": {
41+
"additionalProperties": {
42+
"type": "object"
43+
},
44+
"type": "object",
45+
"description": "Importer-specific configuration. Maps importer names to their configuration."
3946
}
4047
},
4148
"additionalProperties": false,
@@ -96,6 +103,12 @@
96103
"enabled": {
97104
"type": "boolean"
98105
},
106+
"pdf": {
107+
"type": "boolean"
108+
},
109+
"videos": {
110+
"type": "boolean"
111+
},
99112
"sizes": {
100113
"items": {
101114
"type": "integer"
@@ -113,6 +126,8 @@
113126
"type": "object",
114127
"required": [
115128
"enabled",
129+
"pdf",
130+
"videos",
116131
"sizes",
117132
"input file",
118133
"file name template"

schemas/exporter.schema.json

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,6 @@
33
"$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.1/schemas/exporter.schema.json",
44
"$ref": "#/$defs/ExporterManifest",
55
"$defs": {
6-
"ExporterCommand": {
7-
"properties": {
8-
"run": {
9-
"type": "string",
10-
"description": "Run a command in a shell"
11-
},
12-
"log": {
13-
"items": {
14-
"type": "string"
15-
},
16-
"type": "array",
17-
"description": "Log a message. The first argument is the verb, the second is the color, the third is the message."
18-
}
19-
},
20-
"additionalProperties": false,
21-
"type": "object",
22-
"title": "ExporterCommand"
23-
},
246
"ExporterManifest": {
257
"properties": {
268
"name": {
@@ -33,21 +15,21 @@
3315
},
3416
"before": {
3517
"items": {
36-
"$ref": "#/$defs/ExporterCommand"
18+
"$ref": "#/$defs/PluginCommand"
3719
},
3820
"type": "array",
3921
"description": "Commands to run before the build starts. Go text template that receives .Data"
4022
},
4123
"after": {
4224
"items": {
43-
"$ref": "#/$defs/ExporterCommand"
25+
"$ref": "#/$defs/PluginCommand"
4426
},
4527
"type": "array",
4628
"description": "Commands to run after the build finishes. Go text template that receives .Data and .Database, the built database."
4729
},
4830
"work": {
4931
"items": {
50-
"$ref": "#/$defs/ExporterCommand"
32+
"$ref": "#/$defs/PluginCommand"
5133
},
5234
"type": "array",
5335
"description": "Commands to run during the build, for each work. Go text template that receives .Data and .Work, the current work."
@@ -75,6 +57,31 @@
7557
"description"
7658
],
7759
"title": "ExporterManifest"
60+
},
61+
"PluginCommand": {
62+
"properties": {
63+
"run": {
64+
"type": "string",
65+
"description": "Run a command in a shell"
66+
},
67+
"log": {
68+
"items": {
69+
"type": "string"
70+
},
71+
"type": "array",
72+
"description": "Log a message. The first argument is the verb, the second is the color, the third is the message."
73+
},
74+
"env": {
75+
"additionalProperties": {
76+
"type": "string"
77+
},
78+
"type": "object",
79+
"description": "Set environment variables"
80+
}
81+
},
82+
"additionalProperties": false,
83+
"type": "object",
84+
"title": "PluginCommand"
7885
}
7986
}
8087
}

schemas/importer.schema.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://raw.githubusercontent.com/ortfo/db/v1.6.1/schemas/importer.schema.json",
4+
"$ref": "#/$defs/ImporterManifest",
5+
"$defs": {
6+
"ImporterManifest": {
7+
"properties": {
8+
"name": {
9+
"type": "string",
10+
"description": "The name of the importer"
11+
},
12+
"description": {
13+
"type": "string",
14+
"description": "Some documentation about the importer"
15+
},
16+
"list": {
17+
"items": {
18+
"$ref": "#/$defs/PluginCommand"
19+
},
20+
"type": "array",
21+
"description": "Commands to run to list work IDs to import. Go text template that receives .Data."
22+
},
23+
"import": {
24+
"items": {
25+
"$ref": "#/$defs/PluginCommand"
26+
},
27+
"type": "array",
28+
"description": "Commands to run to import a work. Go text template that receives .Data and .ID, the current work ID."
29+
},
30+
"data": {
31+
"type": "object",
32+
"description": "Initial data"
33+
},
34+
"verbose": {
35+
"type": "boolean",
36+
"description": "If true, will show every command that is run"
37+
},
38+
"requires": {
39+
"items": {
40+
"type": "string"
41+
},
42+
"type": "array",
43+
"description": "List of programs that are required to be available in the PATH for the importer to run."
44+
}
45+
},
46+
"additionalProperties": false,
47+
"type": "object",
48+
"required": [
49+
"name",
50+
"description"
51+
],
52+
"title": "ImporterManifest"
53+
},
54+
"PluginCommand": {
55+
"properties": {
56+
"run": {
57+
"type": "string",
58+
"description": "Run a command in a shell"
59+
},
60+
"log": {
61+
"items": {
62+
"type": "string"
63+
},
64+
"type": "array",
65+
"description": "Log a message. The first argument is the verb, the second is the color, the third is the message."
66+
},
67+
"env": {
68+
"additionalProperties": {
69+
"type": "string"
70+
},
71+
"type": "object",
72+
"description": "Set environment variables"
73+
}
74+
},
75+
"additionalProperties": false,
76+
"type": "object",
77+
"title": "PluginCommand"
78+
}
79+
}
80+
}

0 commit comments

Comments
 (0)