Skip to content

Commit 9297bfc

Browse files
authored
Merge pull request #44 from Flow-Launcher/add-json-schemas
Add schemas for plugin.json and SettingsTemplate.yaml
2 parents c486088 + e145c1f commit 9297bfc

File tree

2 files changed

+282
-0
lines changed

2 files changed

+282
-0
lines changed

schemas/plugin.schema.json

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"ID": {
6+
"type": "string",
7+
"oneOf": [
8+
{
9+
"pattern": "(?i)^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
10+
},
11+
{
12+
"pattern": "(?i)^[a-f0-9]{32}$"
13+
}
14+
],
15+
"description": "A unique identifier in the form of UUID so Flow Launcher can distinguish between plugins."
16+
},
17+
"ActionKeywords": {
18+
"type": "array",
19+
"description": "The keywords that trigger the plugin. If you want the plugin to trigger without a keyword, set this to [\"*\"]",
20+
"minItems": 1,
21+
"items": {
22+
"type": "string",
23+
"minLength": 1,
24+
"default": "*"
25+
}
26+
},
27+
"Name": {
28+
"type": "string",
29+
"minLength": 1
30+
},
31+
"Description": {
32+
"type": "string"
33+
},
34+
"Author": {
35+
"type": "string",
36+
"minLength": 1
37+
},
38+
"Version": {
39+
"type": "string",
40+
"minLength": 1
41+
},
42+
"Language": {
43+
"type": "string"
44+
},
45+
"Website": {
46+
"type": "string",
47+
"pattern": "^https?://.+$"
48+
},
49+
"ExecuteFileName": {
50+
"type": "string"
51+
},
52+
"IcoPath": {
53+
"type": "string",
54+
"pattern": "(?i)[.]png$"
55+
}
56+
},
57+
"oneOf": [
58+
{
59+
"properties": {
60+
"Language": {
61+
"enum": [
62+
"javascript",
63+
"javascript_v2"
64+
]
65+
},
66+
"ExecuteFileName": {
67+
"pattern": "(?i)[.][mc]?js$"
68+
}
69+
}
70+
},
71+
{
72+
"properties": {
73+
"Language": {
74+
"enum": [
75+
"typescript",
76+
"typescript_v2"
77+
]
78+
},
79+
"ExecuteFileName": {
80+
"pattern": "(?i)[.]([mc]?j|t)s$"
81+
}
82+
}
83+
},
84+
{
85+
"properties": {
86+
"Language": {
87+
"enum": [
88+
"python",
89+
"python_v2"
90+
]
91+
},
92+
"ExecuteFileName": {
93+
"pattern": "(?i)[.]pyc?$"
94+
}
95+
}
96+
},
97+
{
98+
"properties": {
99+
"Language": {
100+
"enum": [
101+
"executable",
102+
"executable_v2"
103+
]
104+
},
105+
"ExecuteFileName": {
106+
"pattern": "(?i)[.]exe$"
107+
}
108+
}
109+
},
110+
{
111+
"properties": {
112+
"Language": {
113+
"enum": [
114+
"csharp",
115+
"fsharp"
116+
]
117+
},
118+
"ExecuteFileName": {
119+
"pattern": "(?i)[.]dll$"
120+
}
121+
}
122+
}
123+
],
124+
"required": [
125+
"ID",
126+
"ActionKeywords",
127+
"Name",
128+
"Description",
129+
"Author",
130+
"Version",
131+
"Language",
132+
"Website",
133+
"ExecuteFileName",
134+
"IcoPath"
135+
]
136+
}

schemas/settings-template.schema.json

+146
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$defs": {
4+
"commonProperties": {
5+
"type": "object",
6+
"properties": {
7+
"name": {
8+
"type": "string",
9+
"pattern": "(?i)^[a-z_][a-z_0-9]*$",
10+
"maxLength": 64
11+
},
12+
"label": {
13+
"type": "string"
14+
},
15+
"description": {
16+
"type": "string"
17+
},
18+
"defaultValue": {
19+
"type": ["string", "number", "boolean"]
20+
}
21+
},
22+
"required": [
23+
"name"
24+
]
25+
},
26+
"commonPropertiesBool": {
27+
"type": "object",
28+
"properties": {
29+
"name": {
30+
"type": "string",
31+
"pattern": "(?i)^[a-z_][a-z_0-9]*$"
32+
},
33+
"label": {
34+
"type": "string"
35+
},
36+
"description": {
37+
"type": "string"
38+
},
39+
"defaultValue": {
40+
"type": "boolean"
41+
}
42+
},
43+
"required": [
44+
"name"
45+
]
46+
}
47+
},
48+
"type": "object",
49+
"properties": {
50+
"body": {
51+
"type": "array",
52+
"minItems": 1,
53+
"maxItems": 100,
54+
"items": {
55+
"type": "object",
56+
"required": [
57+
"type",
58+
"attributes"
59+
],
60+
"oneOf": [
61+
{
62+
"type": "object",
63+
"properties": {
64+
"type": {
65+
"const": "textBlock"
66+
},
67+
"attributes": {
68+
"type": "object",
69+
"properties": {
70+
"description": {
71+
"type": "string",
72+
"minLength": 1
73+
}
74+
},
75+
"required": ["description"]
76+
}
77+
},
78+
"required": [
79+
"type",
80+
"attributes"
81+
]
82+
},
83+
{
84+
"type": "object",
85+
"properties": {
86+
"type": {
87+
"enum": ["input", "inputWithFileBtn", "inputWithFolderBtn", "textarea", "passwordBox"]
88+
},
89+
"attributes": {
90+
"$ref": "#/$defs/commonProperties"
91+
}
92+
},
93+
"required": [
94+
"type",
95+
"attributes"
96+
]
97+
},
98+
{
99+
"type": "object",
100+
"properties": {
101+
"type": {
102+
"const": "dropdown"
103+
},
104+
"attributes": {
105+
"$ref": "#/$defs/commonProperties",
106+
"properties": {
107+
"options": {
108+
"type": "array",
109+
"minItems": 1,
110+
"uniqueItems": true,
111+
"items": {
112+
"type": ["string", "number", "boolean"]
113+
}
114+
}
115+
},
116+
"required": ["name", "options"]
117+
}
118+
},
119+
"required": [
120+
"type",
121+
"attributes"
122+
]
123+
},
124+
{
125+
"type": "object",
126+
"properties": {
127+
"type": {
128+
"const": "checkbox"
129+
},
130+
"attributes": {
131+
"$ref": "#/$defs/commonPropertiesBool"
132+
}
133+
},
134+
"required": [
135+
"type",
136+
"attributes"
137+
]
138+
}
139+
]
140+
}
141+
}
142+
},
143+
"required": [
144+
"body"
145+
]
146+
}

0 commit comments

Comments
 (0)