Skip to content

Commit 644606c

Browse files
authored
chore(schemas): host metadata schemas as the source of truth (#10927)
1 parent 486ccc1 commit 644606c

19 files changed

Lines changed: 4643 additions & 0 deletions

schemas/metadata/1.0.json

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "https://schemas.premid.app/metadata/1.0",
4+
5+
"title": "Metadata",
6+
"type": "object",
7+
"description": "Metadata that describes a presence.",
8+
9+
"definitions": {
10+
"user": {
11+
"type": "object",
12+
"description": "User information.",
13+
14+
"properties": {
15+
"name": {
16+
"type": "string",
17+
"description": "The name of the user."
18+
},
19+
20+
"id": {
21+
"type": "string",
22+
"description": "The Discord snowflake of the user.",
23+
"pattern": "^\\d+$"
24+
}
25+
},
26+
27+
"additionalProperties": false,
28+
"required": ["name", "id"]
29+
}
30+
},
31+
32+
"properties": {
33+
"$schema": {
34+
"$comment": "This is required otherwise the schema will fail itself when it is applied to a document via $schema. This is optional so that validators that use this schema don't fail if the metadata doesn't have the $schema property.",
35+
36+
"type": "string",
37+
"description": "The metadata schema URL."
38+
},
39+
40+
"author": {
41+
"$ref": "#/definitions/user",
42+
"description": "The author of this presence."
43+
},
44+
45+
"contributors": {
46+
"type": "array",
47+
"description": "Any extra contributors to this presence.",
48+
49+
"items": {
50+
"$ref": "#/definitions/user"
51+
}
52+
},
53+
54+
"service": {
55+
"type": "string",
56+
"description": "The service this presence is for."
57+
},
58+
59+
"description": {
60+
"type": "object",
61+
"description": "A description of the presence in multiple languages.",
62+
63+
"propertyNames": {
64+
"type": "string",
65+
"description": "The language key. The key must be languagecode(_REGIONCODE).",
66+
"pattern": "^[a-z]{2}(_[A-Z]{2})?$"
67+
},
68+
"patternProperties": {
69+
"^[a-z]{2}(_[A-Z]{2})?$": {
70+
"type": "string",
71+
"description": "The description of the presence in the key's language."
72+
}
73+
},
74+
75+
"additionalProperties": false,
76+
"required": ["en"]
77+
},
78+
79+
"url": {
80+
"type": ["string", "array"],
81+
"description": "The service's website URL, or an array of URLs. Protocols should not be added.",
82+
"pattern": "^(([a-z0-9-]+\\.)*[0-9a-z_-]+(\\.[a-z]+)+|(\\d{1,3}\\.){3}\\d{1,3}|localhost)$",
83+
84+
"items": {
85+
"type": "string",
86+
"description": "One of the service's website URLs.",
87+
"pattern": "^(([a-z0-9-]+\\.)*[0-9a-z_-]+(\\.[a-z]+)+|(\\d{1,3}\\.){3}\\d{1,3}|localhost)$"
88+
},
89+
"minItems": 2
90+
},
91+
92+
"version": {
93+
"type": "string",
94+
"description": "The SemVer version of the presence. Must just be major.minor.patch.",
95+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
96+
},
97+
98+
"logo": {
99+
"type": "string",
100+
"description": "The logo of the service this presence is for.",
101+
"pattern": "^https?:\\/\\/?(?:[a-z0-9-]+\\.)*[0-9a-z_-]+(?:\\.[a-z]+)+\\/.*$"
102+
},
103+
104+
"thumbnail": {
105+
"type": "string",
106+
"description": "A thumbnail of the service this presence is for.",
107+
"pattern": "^https?:\\/\\/?([a-z0-9-]+\\.)*[0-9a-z_-]+(\\.[a-z]+)+\\/.*$"
108+
},
109+
110+
"color": {
111+
"type": "string",
112+
"description": "The theme color of the service this presence is for. Must be either a 6 digit or a 3 digit hex code.",
113+
"pattern": "^#([A-Fa-f0-9]{3}){1,2}$"
114+
},
115+
116+
"tags": {
117+
"type": ["array"],
118+
"description": "The tags for the presence.",
119+
120+
"items": {
121+
"type": "string",
122+
"description": "A tag.",
123+
"pattern": "^[^A-Z\\s!\"#$%&'()*+,./:;<=>?@\\[\\\\\\]^_`{|}~]+$"
124+
},
125+
"minItems": 1
126+
},
127+
128+
"category": {
129+
"type": "string",
130+
"description": "The category the presence falls under.",
131+
"enum": ["anime", "games", "music", "socials", "videos", "other"]
132+
},
133+
134+
"iframe": {
135+
"type": "boolean",
136+
"description": "Whether or not the presence should run in IFrames."
137+
},
138+
139+
"regExp": {
140+
"type": "string",
141+
"description": "A regular expression used to match URLs for the presence to inject into."
142+
},
143+
144+
"iFrameRegExp": {
145+
"type": "string",
146+
"description": "A regular expression used to match IFrames for the presence to inject into."
147+
},
148+
149+
"button": {
150+
"type": "boolean",
151+
"description": "Controls whether the presence is automatically added when the extension is installed. For partner presences only."
152+
},
153+
154+
"warning": {
155+
"type": "boolean",
156+
"description": "Shows a warning saying that it requires additional steps for the presence to function correctly."
157+
},
158+
159+
"settings": {
160+
"type": "array",
161+
"description": "An array of settings the user can change in the presence.",
162+
163+
"items": {
164+
"type": "object",
165+
"description": "A setting.",
166+
167+
"properties": {
168+
"id": {
169+
"type": "string",
170+
"description": "The ID of the setting."
171+
},
172+
173+
"title": {
174+
"type": "string",
175+
"description": "The title of the setting. Required only if `multiLanguage` is disabled."
176+
},
177+
178+
"icon": {
179+
"type": "string",
180+
"description": "The icon of the setting. Required only if `multiLanguage` is disabled.",
181+
"pattern": "^fa[bs] fa-[0-9a-z-]+$"
182+
},
183+
184+
"if": {
185+
"type": "object",
186+
"description": "Restrict showing this setting if another setting is the defined value.",
187+
188+
"propertyNames": {
189+
"type": "string",
190+
"description": "The ID of the setting."
191+
},
192+
193+
"patternProperties": {
194+
"": {
195+
"type": ["string", "number", "boolean"],
196+
"description": "The value of the setting."
197+
}
198+
},
199+
200+
"additionalProperties": false
201+
},
202+
203+
"placeholder": {
204+
"type": "string",
205+
"description": "The placeholder for settings that require input. Shown when the input is empty."
206+
},
207+
208+
"value": {
209+
"type": ["string", "number", "boolean"],
210+
"description": "The default value of the setting. Not compatible with `values`."
211+
},
212+
213+
"values": {
214+
"type": "array",
215+
"description": "The default values of the setting. Not compatible with `value`.",
216+
217+
"items": {
218+
"type": ["string", "number", "boolean"],
219+
"description": "The value of the setting."
220+
}
221+
},
222+
223+
"multiLanguage": {
224+
"type": ["string", "boolean", "array"],
225+
"description": "When false, multi-localization is disabled. When true, strings from the `general.json` file are available for use. When a string, it is the name of a file (excluding .json) of a used language from the localization GitHub repo. When an array of strings, it is all of the file names (excluding .json) of used languages from the localization GitHub repo.",
226+
227+
"items": {
228+
"type": "string",
229+
"description": "The name of a file from the localization GitHub repository."
230+
}
231+
}
232+
},
233+
234+
"additionalProperties": false
235+
}
236+
}
237+
},
238+
239+
"additionalProperties": false,
240+
"required": ["author", "service", "description", "url", "version", "logo", "thumbnail", "color", "tags", "category"]
241+
}

0 commit comments

Comments
 (0)