Skip to content

Commit c2db368

Browse files
committed
feat(config): add configuration schema for JSON validation
1 parent b1a5e4e commit c2db368

File tree

2 files changed

+128
-1
lines changed

2 files changed

+128
-1
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"amphp/mysql": "~3.0",
99
"amphp/amp": "~3.0",
1010
"revolt/event-loop": "~1.0",
11-
"symfony/console": "~7.2"
11+
"symfony/console": "~7.2",
12+
"justinrainbow/json-schema": "^6.0"
1213
},
1314
"require-dev": {
1415
"squizlabs/php_codesniffer": "^3.0",

schema.json

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"$schema": "https://json-schema.org/draft-04/schema#",
3+
"title": "MySQL2JSONL configuration file",
4+
"type": "object",
5+
"properties": {
6+
"connection": {
7+
"$ref": "#/definitions/connection",
8+
"description": "MySQL connections settings"
9+
},
10+
"includeTables": {
11+
"$ref": "#/definitions/tableConditions",
12+
"description": "List of tables to include from the database dump"
13+
},
14+
"excludeTables": {
15+
"$ref": "#/definitions/tableConditions",
16+
"description": "List of tables to exclude from the database dump"
17+
}
18+
},
19+
"definitions": {
20+
"matchExpression": {
21+
"type": "object",
22+
"description": "Match condition for table name",
23+
"properties": {
24+
"regexp": {
25+
"type": "string",
26+
"description": "Valid regular expression for a table name with qualifiers"
27+
},
28+
"startsWith": {
29+
"type": "string",
30+
"description": "Table name starts with"
31+
},
32+
"endsWith": {
33+
"type": "string",
34+
"description": "Table name ends with"
35+
},
36+
"contains": {
37+
"type": "string",
38+
"description": "Table name contains"
39+
}
40+
},
41+
"minProperties": 1,
42+
"maxProperties": 1
43+
},
44+
"rowCount": {
45+
"type": "object",
46+
"properties": {
47+
"min": {
48+
"type": "integer",
49+
"description": "Minimum number of rows for table to be exported"
50+
},
51+
"max": {
52+
"type": "integer",
53+
"description": "Maximum number of rows for table to be exported"
54+
}
55+
},
56+
"minProperties": 1,
57+
"maxProperties": 1
58+
} ,
59+
"tableName": {
60+
"type": "string",
61+
"pattern": "^[0-9a-zA-Z$_\u0080-\uFFFF]+$"
62+
},
63+
"tableConditions": {
64+
"type": "array",
65+
"description": "Table matching conditions",
66+
"oneOf": [
67+
{ "$ref": "#/definitions/matchExpression" },
68+
{ "$ref": "#/definitions/rowCount" },
69+
{ "$ref": "#/definitions/tableName" }
70+
]
71+
},
72+
"connection": {
73+
"type": "object",
74+
"properties": {
75+
"host": {
76+
"type": "string",
77+
"description": "Host for MySQL host"
78+
},
79+
"port": {
80+
"type": "integer",
81+
"description": "Port for MySQL connection",
82+
"default": 3306
83+
},
84+
"user": {
85+
"type": "string",
86+
"description": "Username for MySQL connection",
87+
"default": "root"
88+
},
89+
"password": {
90+
"type": "string",
91+
"description": "Password for MySQL connection",
92+
"default": ""
93+
},
94+
"database": {
95+
"type": "string",
96+
"description": "Database for MySQL connection"
97+
},
98+
"charset": {
99+
"type": "string",
100+
"description": "Charset for MySQL connection",
101+
"default": "utf8mb4"
102+
},
103+
"collate": {
104+
"type": "string",
105+
"description": "Collation for MySQL connection",
106+
"default": "utf8mb4_unicode_ci"
107+
},
108+
"sqlMode": {
109+
"type": "string",
110+
"description": "SQL_MODE to set for the connection"
111+
},
112+
"useCompression": {
113+
"type": "boolean",
114+
"description": "Use compression for MySQL connection"
115+
},
116+
"key": {
117+
"type": "string",
118+
"description": "Private key to use for sha256_password auth method in MySQL connection"
119+
}
120+
},
121+
"required": [
122+
"host", "database"
123+
]
124+
}
125+
}
126+
}

0 commit comments

Comments
 (0)