This repository has been archived by the owner on Jun 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.json
313 lines (313 loc) · 9.18 KB
/
schema.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
{
"title": "JSON schema for the TranslitRule file",
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/TranslitRule"
},
{
"items": {
"$ref": "#/definitions/TranslitRulePhase"
},
"type": "array"
},
{
"items": {
"$ref": "#/definitions/TranslitRuleItem"
},
"type": "array"
}
],
"definitions": {
"PostRulesStrategy": {
"description": "Post rules looping and matching strategy.",
"enum": [
"startMatch",
"whileMatch"
],
"type": "string"
},
"TplVar": {
"additionalProperties": {
"type": "string",
"minLength": 1
},
"description": "Template variables definition.",
"type": "object",
"propertyNames": {
"pattern": "^#[A-Za-z][A-Za-z0-9_]*$"
}
},
"TranslitRule": {
"additionalProperties": false,
"description": "Transliterate rule.",
"properties": {
"$schema": {
"description": "Link to schema file.",
"type": "string"
},
"description": {
"description": "Description for the rule.",
"type": "string"
},
"phases": {
"description": "Transliterate rule phases.",
"items": {
"$ref": "#/definitions/TranslitRulePhase"
},
"minItems": 1,
"type": "array"
},
"tplVar": {
"$ref": "#/definitions/TplVar",
"description": "Global template variables definition."
},
"version": {
"description": "The version for the rule.",
"type": "string"
}
},
"type": "object",
"required": [
"phases"
]
},
"TranslitRuleItem": {
"additionalProperties": false,
"description": "Transliterate rule item.",
"properties": {
"description": {
"description": "Description for the rule item.",
"type": "string"
},
"from": {
"description": "Regular expression pattern for input string searching.",
"minLength": 1,
"type": "string"
},
"hasLeft": {
"description": "Set `true` to replace only if there was any converted left part characters, set `false` for reverse purpose checking.",
"type": "boolean"
},
"left": {
"description": "Regular expression pattern for checking converted left part string.",
"type": "string"
},
"minLength": {
"description": "Minimum input string length matching for quick checking purpose.",
"minimum": 1,
"type": "integer"
},
"postRules": {
"description": "Sub-rule items to be processed after replaced.",
"items": {
"$ref": "#/definitions/TranslitSubRuleItem"
},
"minItems": 1,
"type": "array"
},
"postRulesRef": {
"description": "Set the name defined in `postRulesDef` for referencing post rules.",
"type": "string"
},
"postRulesStart": {
"additionalProperties": {
"type": "number"
},
"description": "The key value pair of `orGroup` and `start` index for `postRules` items.",
"type": "object"
},
"postRulesStrategy": {
"$ref": "#/definitions/PostRulesStrategy",
"description": "Post rules looping and matching strategy. Default is `startMatch`."
},
"quickTests": {
"description": "Array of input string character and index position matching for quick checking purpose.",
"items": {
"additionalItems": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"items": [
{
"type": "string",
"description": "Character for quick test checking.",
"minLength": 1
},
{
"type": "integer",
"description": "Index of the character for quick test checking.",
"minimum": 0
}
],
"minItems": 2,
"type": "array"
},
"type": "array"
},
"right": {
"description": "Regular expression pattern for checking right part string after input string matching.",
"type": "string"
},
"skip": {
"$ref": "#/definitions/WhenOrSkipOptions",
"description": "Apply the rule only if `skip` options and user options are met."
},
"to": {
"description": "The value to replace the matched string.",
"type": "string"
},
"when": {
"$ref": "#/definitions/WhenOrSkipOptions",
"description": "Apply the rule only if `when` options and user options are met."
}
},
"type": "object",
"required": [
"from"
]
},
"TranslitRulePhase": {
"additionalProperties": false,
"description": "Transliterate rule phase.",
"properties": {
"description": {
"description": "Description for the rule phase.",
"type": "string"
},
"postRulesDef": {
"additionalProperties": {
"items": {
"$ref": "#/definitions/TranslitSubRuleItem"
},
"type": "array"
},
"description": "Post rules definitions to be used with `postRulesRef`.",
"type": "object"
},
"rules": {
"description": "Array of Transliterate rule items.",
"items": {
"$ref": "#/definitions/TranslitRuleItem"
},
"minItems": 1,
"type": "array"
},
"skip": {
"$ref": "#/definitions/WhenOrSkipOptions",
"description": "Apply the phase only if `skip` options and user options are met."
},
"tplSeq": {
"additionalProperties": {
"items": {
"additionalItems": {
"anyOf": [
{
"type": "string"
},
{
"type": "string"
},
{
"type": "number"
}
]
},
"items": [
{
"type": "string",
"description": "'from' start character for sequence loop.",
"minLength": 1
},
{
"type": "string",
"description": "'to' start character for sequence loop."
},
{
"type": "integer",
"description": "Sequence loop count.",
"minimum": 1
}
],
"minItems": 3,
"type": "array"
},
"type": "array",
"minItems": 1
},
"description": "Template loop/sequence variables definition.",
"type": "object"
},
"tplVar": {
"$ref": "#/definitions/TplVar",
"description": "Phase level template variables definition."
},
"when": {
"$ref": "#/definitions/WhenOrSkipOptions",
"description": "Apply the phase only if `when` options and user options are met."
}
},
"type": "object",
"required": [
"rules"
]
},
"TranslitSubRuleItem": {
"additionalProperties": false,
"description": "Transliterate sub-rule item.",
"properties": {
"description": {
"description": "Description for the rule item.",
"type": "string"
},
"from": {
"description": "Regular expression pattern for input string searching.",
"minLength": 1,
"type": "string"
},
"orGroup": {
"description": "Group code for grouping `or` items.",
"type": "string"
},
"skip": {
"$ref": "#/definitions/WhenOrSkipOptions",
"description": "Apply the rule only if `skip` options and user options are met."
},
"start": {
"description": "Start index for searching. Set `-1` for skipping the rule. It works only when `postRulesStrategy` is `startMatch`.",
"minimum": -1,
"type": "integer"
},
"to": {
"description": "The value to replace the matched string.",
"type": "string"
},
"when": {
"$ref": "#/definitions/WhenOrSkipOptions",
"description": "Apply the rule only if `when` options and user options are met."
}
},
"type": "object",
"required": [
"from",
"to"
]
},
"WhenOrSkipOptions": {
"additionalProperties": {
"type": [
"string",
"boolean"
]
},
"description": "The `when` or `skip` options to apply only if it equals with user input option.",
"type": "object"
}
}
}