postgresai 0.16.0-rc.4 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/README.md +154 -0
  2. package/dist/bin/postgres-ai.js +2911 -255
  3. package/package.json +12 -3
  4. package/schemas/A002.schema.json +63 -0
  5. package/schemas/A003.schema.json +73 -0
  6. package/schemas/A004.schema.json +81 -0
  7. package/schemas/A007.schema.json +71 -0
  8. package/schemas/A013.schema.json +61 -0
  9. package/schemas/D001.schema.json +71 -0
  10. package/schemas/D004.schema.json +136 -0
  11. package/schemas/F001.schema.json +73 -0
  12. package/schemas/F002.schema.json +108 -0
  13. package/schemas/F003.schema.json +138 -0
  14. package/schemas/F004.schema.json +125 -0
  15. package/schemas/F005.schema.json +131 -0
  16. package/schemas/F009.schema.json +155 -0
  17. package/schemas/G001.schema.json +135 -0
  18. package/schemas/G003.schema.json +90 -0
  19. package/schemas/H001.schema.json +141 -0
  20. package/schemas/H002.schema.json +129 -0
  21. package/schemas/H004.schema.json +128 -0
  22. package/schemas/I001.schema.json +149 -0
  23. package/schemas/K001.schema.json +161 -0
  24. package/schemas/K003.schema.json +163 -0
  25. package/schemas/K004.schema.json +110 -0
  26. package/schemas/K005.schema.json +110 -0
  27. package/schemas/K006.schema.json +110 -0
  28. package/schemas/K007.schema.json +110 -0
  29. package/schemas/K008.schema.json +110 -0
  30. package/schemas/M001.schema.json +119 -0
  31. package/schemas/M002.schema.json +110 -0
  32. package/schemas/M003.schema.json +128 -0
  33. package/schemas/N001.schema.json +161 -0
  34. package/schemas/query.schema.json +62 -0
  35. package/CHANGELOG.md +0 -11
  36. package/bin/postgres-ai.ts +0 -5578
  37. package/bun.lock +0 -258
  38. package/bunfig.toml +0 -20
  39. package/lib/aas-onboard.ts +0 -251
  40. package/lib/auth-server.ts +0 -285
  41. package/lib/checkup-api.ts +0 -526
  42. package/lib/checkup-dictionary.ts +0 -103
  43. package/lib/checkup-summary.ts +0 -338
  44. package/lib/checkup.ts +0 -2261
  45. package/lib/config.ts +0 -171
  46. package/lib/init.ts +0 -1152
  47. package/lib/instances.ts +0 -245
  48. package/lib/issues.ts +0 -1060
  49. package/lib/mcp-server.ts +0 -667
  50. package/lib/metrics-loader.ts +0 -134
  51. package/lib/pkce.ts +0 -79
  52. package/lib/reports.ts +0 -373
  53. package/lib/storage.ts +0 -367
  54. package/lib/supabase.ts +0 -826
  55. package/lib/util.ts +0 -134
  56. package/packages/postgres-ai/README.md +0 -26
  57. package/packages/postgres-ai/bin/postgres-ai.js +0 -27
  58. package/packages/postgres-ai/package.json +0 -27
  59. package/scripts/embed-checkup-dictionary.ts +0 -115
  60. package/scripts/embed-metrics.ts +0 -160
  61. package/scripts/generate-release-notes.ts +0 -668
  62. package/test/PERMISSION_CHECK_TEST_SUMMARY.md +0 -139
  63. package/test/aas-onboard.test.ts +0 -301
  64. package/test/auth.test.ts +0 -287
  65. package/test/checkup.integration.test.ts +0 -413
  66. package/test/checkup.test.ts +0 -3626
  67. package/test/compose-cmd.test.ts +0 -120
  68. package/test/config-consistency.test.ts +0 -352
  69. package/test/init.integration.test.ts +0 -438
  70. package/test/init.test.ts +0 -1816
  71. package/test/issues.cli.test.ts +0 -1162
  72. package/test/issues.test.ts +0 -456
  73. package/test/mcp-server.test.ts +0 -2530
  74. package/test/monitoring.test.ts +0 -746
  75. package/test/permission-check-sql.test.ts +0 -116
  76. package/test/reports.cli.test.ts +0 -793
  77. package/test/reports.test.ts +0 -977
  78. package/test/schema-validation.test.ts +0 -231
  79. package/test/storage.test.ts +0 -935
  80. package/test/supabase.test.ts +0 -709
  81. package/test/targets-add-config.test.ts +0 -28
  82. package/test/test-utils.ts +0 -190
  83. package/test/upgrade.test.ts +0 -1056
  84. package/test/util.test.ts +0 -44
  85. package/tsconfig.json +0 -20
@@ -0,0 +1,155 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "F009 report schema",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["checkId", "checkTitle", "timestamptz", "nodes", "results"],
7
+ "properties": {
8
+ "contract_version": { "type": ["string", "null"] },
9
+ "summary": { "type": "object", "additionalProperties": false, "required": ["status", "message"], "properties": { "status": { "enum": ["ok", "warning", "info"] }, "message": { "type": "string" } } },
10
+ "version": { "type": ["string", "null"] },
11
+ "build_ts": { "type": ["string", "null"] },
12
+ "generation_mode": { "type": ["string", "null"] },
13
+ "checkId": { "const": "F009" },
14
+ "checkTitle": { "const": "Xmin horizon and blockers" },
15
+ "timestamptz": { "type": "string" },
16
+ "nodes": { "$ref": "#/$defs/nodes" },
17
+ "results": {
18
+ "type": "object",
19
+ "minProperties": 1,
20
+ "additionalProperties": { "$ref": "#/$defs/nodeResult" }
21
+ }
22
+ },
23
+ "$defs": {
24
+ "nodes": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["primary", "standbys"],
28
+ "properties": {
29
+ "primary": { "type": "string" },
30
+ "standbys": { "type": "array", "items": { "type": "string" } }
31
+ }
32
+ },
33
+ "postgresVersion": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["version", "server_version_num", "server_major_ver", "server_minor_ver"],
37
+ "properties": {
38
+ "version": { "type": "string" },
39
+ "server_version_num": { "type": "string" },
40
+ "server_major_ver": { "type": "string" },
41
+ "server_minor_ver": { "type": "string" }
42
+ }
43
+ },
44
+ "blocker": {
45
+ "type": ["object", "null"],
46
+ "additionalProperties": true
47
+ },
48
+ "component": {
49
+ "type": "object",
50
+ "additionalProperties": false,
51
+ "required": ["age_tx", "count", "top_blocker"],
52
+ "properties": {
53
+ "age_tx": { "type": "number", "minimum": 0 },
54
+ "count": { "type": "number", "minimum": 0 },
55
+ "top_blocker": { "$ref": "#/$defs/blocker" }
56
+ }
57
+ },
58
+ "components": {
59
+ "type": "object",
60
+ "additionalProperties": false,
61
+ "required": [
62
+ "pg_stat_activity",
63
+ "pg_replication_slots",
64
+ "pg_replication_slots_catalog",
65
+ "pg_stat_replication",
66
+ "pg_prepared_xacts"
67
+ ],
68
+ "properties": {
69
+ "pg_stat_activity": { "$ref": "#/$defs/component" },
70
+ "pg_replication_slots": { "$ref": "#/$defs/component" },
71
+ "pg_replication_slots_catalog": { "$ref": "#/$defs/component" },
72
+ "pg_stat_replication": { "$ref": "#/$defs/component" },
73
+ "pg_prepared_xacts": { "$ref": "#/$defs/component" }
74
+ }
75
+ },
76
+ "dominantHolder": {
77
+ "type": ["object", "null"],
78
+ "additionalProperties": false,
79
+ "required": ["source", "component", "horizon_type", "age_tx", "detail"],
80
+ "properties": {
81
+ "source": { "enum": ["slot", "prepared", "activity", "replication"] },
82
+ "component": {
83
+ "enum": [
84
+ "pg_stat_activity",
85
+ "pg_replication_slots",
86
+ "pg_replication_slots_catalog",
87
+ "pg_stat_replication",
88
+ "pg_prepared_xacts"
89
+ ]
90
+ },
91
+ "horizon_type": { "enum": ["data", "catalog"] },
92
+ "age_tx": { "type": "number", "minimum": 0 },
93
+ "detail": { "type": "object", "additionalProperties": true }
94
+ }
95
+ },
96
+ "history": {
97
+ "type": "object",
98
+ "additionalProperties": false,
99
+ "required": ["available", "source", "message"],
100
+ "properties": {
101
+ "available": { "const": true },
102
+ "source": { "type": "string" },
103
+ "message": { "type": "string" }
104
+ }
105
+ },
106
+ "data": {
107
+ "type": "object",
108
+ "additionalProperties": false,
109
+ "required": [
110
+ "skipped",
111
+ "skip_reason",
112
+ "snapshot_xmin",
113
+ "data_horizon_age_tx",
114
+ "catalog_horizon_age_tx",
115
+ "autovacuum_freeze_max_age",
116
+ "severity",
117
+ "data_horizon_severity",
118
+ "catalog_horizon_severity",
119
+ "visibility",
120
+ "query_preview_captured",
121
+ "components",
122
+ "dominant_holder",
123
+ "conclusions",
124
+ "recommendations"
125
+ ],
126
+ "properties": {
127
+ "skipped": { "type": "boolean" },
128
+ "skip_reason": { "type": ["string", "null"] },
129
+ "snapshot_xmin": { "type": ["number", "null"] },
130
+ "data_horizon_age_tx": { "type": "number", "minimum": 0 },
131
+ "catalog_horizon_age_tx": { "type": "number", "minimum": 0 },
132
+ "autovacuum_freeze_max_age": { "type": "number", "minimum": 0 },
133
+ "severity": { "enum": ["OK", "NOTICE", "WARNING", "CRITICAL"] },
134
+ "data_horizon_severity": { "enum": ["OK", "NOTICE", "WARNING", "CRITICAL"] },
135
+ "catalog_horizon_severity": { "enum": ["OK", "NOTICE", "WARNING", "CRITICAL"] },
136
+ "visibility": { "enum": ["full", "limited"] },
137
+ "query_preview_captured": { "type": "boolean" },
138
+ "components": { "$ref": "#/$defs/components" },
139
+ "dominant_holder": { "$ref": "#/$defs/dominantHolder" },
140
+ "conclusions": { "type": "array", "items": { "type": "string" } },
141
+ "recommendations": { "type": "array", "items": { "type": "string" } },
142
+ "history": { "$ref": "#/$defs/history" }
143
+ }
144
+ },
145
+ "nodeResult": {
146
+ "type": "object",
147
+ "additionalProperties": false,
148
+ "required": ["data"],
149
+ "properties": {
150
+ "data": { "$ref": "#/$defs/data" },
151
+ "postgres_version": { "$ref": "#/$defs/postgresVersion" }
152
+ }
153
+ }
154
+ }
155
+ }
@@ -0,0 +1,135 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "G001 report schema",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["checkId", "checkTitle", "timestamptz", "nodes", "results"],
7
+ "properties": {
8
+ "contract_version": { "type": ["string", "null"] },
9
+ "summary": { "type": "object", "additionalProperties": false, "required": ["status", "message"], "properties": { "status": { "enum": ["ok", "warning", "info"] }, "message": { "type": "string" } } },
10
+ "version": { "type": ["string", "null"] },
11
+ "build_ts": { "type": ["string", "null"] },
12
+ "generation_mode": { "type": ["string", "null"] },
13
+ "checkId": { "const": "G001" },
14
+ "checkTitle": { "const": "Memory-related settings" },
15
+ "timestamptz": { "type": "string" },
16
+ "nodes": { "$ref": "#/$defs/nodes" },
17
+ "results": {
18
+ "type": "object",
19
+ "minProperties": 1,
20
+ "additionalProperties": { "$ref": "#/$defs/nodeResult" }
21
+ }
22
+ },
23
+ "$defs": {
24
+ "nodes": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["primary", "standbys"],
28
+ "properties": {
29
+ "primary": { "type": "string" },
30
+ "standbys": { "type": "array", "items": { "type": "string" } }
31
+ }
32
+ },
33
+ "postgresVersion": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["version", "server_version_num", "server_major_ver", "server_minor_ver"],
37
+ "properties": {
38
+ "version": { "type": "string" },
39
+ "server_version_num": { "type": "string" },
40
+ "server_major_ver": { "type": "string" },
41
+ "server_minor_ver": { "type": "string" }
42
+ }
43
+ },
44
+ "setting": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": ["setting", "unit", "category", "context", "vartype", "pretty_value"],
48
+ "properties": {
49
+ "setting": { "type": "string" },
50
+ "unit": { "type": "string" },
51
+ "category": { "type": "string" },
52
+ "context": { "type": "string" },
53
+ "vartype": { "type": "string" },
54
+ "pretty_value": { "type": "string" }
55
+ }
56
+ },
57
+ "estimatedTotalMemoryUsageFull": {
58
+ "type": "object",
59
+ "additionalProperties": false,
60
+ "required": [
61
+ "shared_buffers_bytes",
62
+ "shared_buffers_pretty",
63
+ "wal_buffers_bytes",
64
+ "wal_buffers_pretty",
65
+ "shared_memory_total_bytes",
66
+ "shared_memory_total_pretty",
67
+ "work_mem_per_connection_bytes",
68
+ "work_mem_per_connection_pretty",
69
+ "max_work_mem_usage_bytes",
70
+ "max_work_mem_usage_pretty",
71
+ "maintenance_work_mem_bytes",
72
+ "maintenance_work_mem_pretty",
73
+ "effective_cache_size_bytes",
74
+ "effective_cache_size_pretty"
75
+ ],
76
+ "properties": {
77
+ "shared_buffers_bytes": { "type": "number" },
78
+ "shared_buffers_pretty": { "type": "string" },
79
+ "wal_buffers_bytes": { "type": "number" },
80
+ "wal_buffers_pretty": { "type": "string" },
81
+ "shared_memory_total_bytes": { "type": "number" },
82
+ "shared_memory_total_pretty": { "type": "string" },
83
+ "work_mem_per_connection_bytes": { "type": "number" },
84
+ "work_mem_per_connection_pretty": { "type": "string" },
85
+ "max_work_mem_usage_bytes": { "type": "number" },
86
+ "max_work_mem_usage_pretty": { "type": "string" },
87
+ "maintenance_work_mem_bytes": { "type": "number" },
88
+ "maintenance_work_mem_pretty": { "type": "string" },
89
+ "effective_cache_size_bytes": { "type": "number" },
90
+ "effective_cache_size_pretty": { "type": "string" }
91
+ }
92
+ },
93
+ "estimatedTotalMemoryUsageEmpty": {
94
+ "type": "object",
95
+ "additionalProperties": false,
96
+ "maxProperties": 0
97
+ },
98
+ "analysis": {
99
+ "type": "object",
100
+ "additionalProperties": false,
101
+ "required": ["estimated_total_memory_usage"],
102
+ "properties": {
103
+ "estimated_total_memory_usage": {
104
+ "oneOf": [
105
+ { "$ref": "#/$defs/estimatedTotalMemoryUsageEmpty" },
106
+ { "$ref": "#/$defs/estimatedTotalMemoryUsageFull" }
107
+ ]
108
+ }
109
+ }
110
+ },
111
+ "data": {
112
+ "type": "object",
113
+ "additionalProperties": false,
114
+ "required": ["settings", "analysis"],
115
+ "properties": {
116
+ "settings": {
117
+ "type": "object",
118
+ "additionalProperties": { "$ref": "#/$defs/setting" }
119
+ },
120
+ "analysis": { "$ref": "#/$defs/analysis" }
121
+ }
122
+ },
123
+ "nodeResult": {
124
+ "type": "object",
125
+ "additionalProperties": false,
126
+ "required": ["data"],
127
+ "properties": {
128
+ "data": { "$ref": "#/$defs/data" },
129
+ "postgres_version": { "$ref": "#/$defs/postgresVersion" }
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+
@@ -0,0 +1,90 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "G003 report schema",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["checkId", "checkTitle", "timestamptz", "nodes", "results"],
7
+ "properties": {
8
+ "contract_version": { "type": ["string", "null"] },
9
+ "summary": { "type": "object", "additionalProperties": false, "required": ["status", "message"], "properties": { "status": { "enum": ["ok", "warning", "info"] }, "message": { "type": "string" } } },
10
+ "version": { "type": ["string", "null"] },
11
+ "build_ts": { "type": ["string", "null"] },
12
+ "generation_mode": { "type": ["string", "null"] },
13
+ "checkId": { "const": "G003" },
14
+ "checkTitle": { "const": "Timeouts, locks, deadlocks" },
15
+ "timestamptz": { "type": "string" },
16
+ "nodes": { "$ref": "#/$defs/nodes" },
17
+ "results": {
18
+ "type": "object",
19
+ "minProperties": 1,
20
+ "additionalProperties": { "$ref": "#/$defs/nodeResult" }
21
+ }
22
+ },
23
+ "$defs": {
24
+ "nodes": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["primary", "standbys"],
28
+ "properties": {
29
+ "primary": { "type": "string" },
30
+ "standbys": { "type": "array", "items": { "type": "string" } }
31
+ }
32
+ },
33
+ "postgresVersion": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["version", "server_version_num", "server_major_ver", "server_minor_ver"],
37
+ "properties": {
38
+ "version": { "type": "string" },
39
+ "server_version_num": { "type": "string" },
40
+ "server_major_ver": { "type": "string" },
41
+ "server_minor_ver": { "type": "string" }
42
+ }
43
+ },
44
+ "setting": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": ["setting", "unit", "category", "context", "vartype", "pretty_value"],
48
+ "properties": {
49
+ "setting": { "type": "string" },
50
+ "unit": { "type": "string" },
51
+ "category": { "type": "string" },
52
+ "context": { "type": "string" },
53
+ "vartype": { "type": "string" },
54
+ "pretty_value": { "type": "string" }
55
+ }
56
+ },
57
+ "deadlockStats": {
58
+ "type": ["object", "null"],
59
+ "additionalProperties": false,
60
+ "required": ["deadlocks", "conflicts", "stats_reset"],
61
+ "properties": {
62
+ "deadlocks": { "type": "number" },
63
+ "conflicts": { "type": "number" },
64
+ "stats_reset": { "type": ["string", "null"] }
65
+ }
66
+ },
67
+ "data": {
68
+ "type": "object",
69
+ "additionalProperties": false,
70
+ "required": ["settings", "deadlock_stats"],
71
+ "properties": {
72
+ "settings": {
73
+ "type": "object",
74
+ "additionalProperties": { "$ref": "#/$defs/setting" }
75
+ },
76
+ "deadlock_stats": { "$ref": "#/$defs/deadlockStats" },
77
+ "deadlock_stats_error": { "type": "string" }
78
+ }
79
+ },
80
+ "nodeResult": {
81
+ "type": "object",
82
+ "additionalProperties": false,
83
+ "required": ["data"],
84
+ "properties": {
85
+ "data": { "$ref": "#/$defs/data" },
86
+ "postgres_version": { "$ref": "#/$defs/postgresVersion" }
87
+ }
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,141 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "H001 report schema",
4
+ "description": "Invalid indexes report with remediation decision tree recommendations",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["checkId", "checkTitle", "timestamptz", "nodes", "results"],
8
+ "properties": {
9
+ "contract_version": { "type": ["string", "null"] },
10
+ "summary": { "type": "object", "additionalProperties": false, "required": ["status", "message"], "properties": { "status": { "enum": ["ok", "warning", "info"] }, "message": { "type": "string" } } },
11
+ "version": { "type": ["string", "null"] },
12
+ "build_ts": { "type": ["string", "null"] },
13
+ "generation_mode": { "type": ["string", "null"] },
14
+ "checkId": { "const": "H001" },
15
+ "checkTitle": { "const": "Invalid indexes" },
16
+ "timestamptz": { "type": "string" },
17
+ "nodes": { "$ref": "#/$defs/nodes" },
18
+ "results": {
19
+ "type": "object",
20
+ "minProperties": 1,
21
+ "additionalProperties": { "$ref": "#/$defs/nodeResult" }
22
+ }
23
+ },
24
+ "$defs": {
25
+ "nodes": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["primary", "standbys"],
29
+ "properties": {
30
+ "primary": { "type": "string" },
31
+ "standbys": { "type": "array", "items": { "type": "string" } }
32
+ }
33
+ },
34
+ "postgresVersion": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "required": ["version", "server_version_num", "server_major_ver", "server_minor_ver"],
38
+ "properties": {
39
+ "version": { "type": "string" },
40
+ "server_version_num": { "type": "string" },
41
+ "server_major_ver": { "type": "string" },
42
+ "server_minor_ver": { "type": "string" }
43
+ }
44
+ },
45
+ "invalidIndex": {
46
+ "type": "object",
47
+ "additionalProperties": false,
48
+ "required": [
49
+ "schema_name",
50
+ "table_name",
51
+ "index_name",
52
+ "relation_name",
53
+ "index_size_bytes",
54
+ "index_size_pretty",
55
+ "index_definition",
56
+ "supports_fk",
57
+ "is_pk",
58
+ "is_unique",
59
+ "constraint_name",
60
+ "table_row_estimate",
61
+ "has_valid_duplicate",
62
+ "valid_duplicate_name",
63
+ "valid_duplicate_definition"
64
+ ],
65
+ "properties": {
66
+ "schema_name": { "type": "string" },
67
+ "table_name": { "type": "string" },
68
+ "index_name": { "type": "string" },
69
+ "relation_name": { "type": "string" },
70
+ "index_size_bytes": { "type": "number" },
71
+ "index_size_pretty": { "type": "string" },
72
+ "index_definition": {
73
+ "type": "string",
74
+ "description": "Full CREATE INDEX statement from pg_get_indexdef()"
75
+ },
76
+ "supports_fk": { "type": "boolean" },
77
+ "is_pk": {
78
+ "type": "boolean",
79
+ "description": "True if this index backs a PRIMARY KEY constraint"
80
+ },
81
+ "is_unique": {
82
+ "type": "boolean",
83
+ "description": "True if this is a UNIQUE index (includes PK indexes)"
84
+ },
85
+ "constraint_name": {
86
+ "type": ["string", "null"],
87
+ "description": "Name of the constraint this index backs, or null if none"
88
+ },
89
+ "table_row_estimate": {
90
+ "type": "integer",
91
+ "description": "Estimated row count of the table from pg_class.reltuples"
92
+ },
93
+ "has_valid_duplicate": {
94
+ "type": "boolean",
95
+ "description": "True if there is a valid index on the same column(s)"
96
+ },
97
+ "valid_duplicate_name": {
98
+ "type": ["string", "null"],
99
+ "description": "Name of the valid duplicate index if one exists"
100
+ },
101
+ "valid_duplicate_definition": {
102
+ "type": ["string", "null"],
103
+ "description": "Full CREATE INDEX statement of the valid duplicate index from pg_get_indexdef()"
104
+ }
105
+ }
106
+ },
107
+ "dbEntry": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "required": [
111
+ "invalid_indexes",
112
+ "total_count",
113
+ "total_size_bytes",
114
+ "total_size_pretty",
115
+ "database_size_bytes",
116
+ "database_size_pretty"
117
+ ],
118
+ "properties": {
119
+ "invalid_indexes": { "type": "array", "items": { "$ref": "#/$defs/invalidIndex" } },
120
+ "total_count": { "type": "integer" },
121
+ "total_size_bytes": { "type": "number" },
122
+ "total_size_pretty": { "type": "string" },
123
+ "database_size_bytes": { "type": "number" },
124
+ "database_size_pretty": { "type": "string" }
125
+ }
126
+ },
127
+ "data": {
128
+ "type": "object",
129
+ "additionalProperties": { "$ref": "#/$defs/dbEntry" }
130
+ },
131
+ "nodeResult": {
132
+ "type": "object",
133
+ "additionalProperties": false,
134
+ "required": ["data"],
135
+ "properties": {
136
+ "data": { "$ref": "#/$defs/data" },
137
+ "postgres_version": { "$ref": "#/$defs/postgresVersion" }
138
+ }
139
+ }
140
+ }
141
+ }
@@ -0,0 +1,129 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "H002 report schema",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["checkId", "checkTitle", "timestamptz", "nodes", "results"],
7
+ "properties": {
8
+ "contract_version": { "type": ["string", "null"] },
9
+ "summary": { "type": "object", "additionalProperties": false, "required": ["status", "message"], "properties": { "status": { "enum": ["ok", "warning", "info"] }, "message": { "type": "string" } } },
10
+ "version": { "type": ["string", "null"] },
11
+ "build_ts": { "type": ["string", "null"] },
12
+ "generation_mode": { "type": ["string", "null"] },
13
+ "checkId": { "const": "H002" },
14
+ "checkTitle": { "const": "Unused indexes" },
15
+ "timestamptz": { "type": "string" },
16
+ "nodes": { "$ref": "#/$defs/nodes" },
17
+ "results": {
18
+ "type": "object",
19
+ "minProperties": 1,
20
+ "additionalProperties": { "$ref": "#/$defs/nodeResult" }
21
+ }
22
+ },
23
+ "$defs": {
24
+ "nodes": {
25
+ "type": "object",
26
+ "additionalProperties": false,
27
+ "required": ["primary", "standbys"],
28
+ "properties": {
29
+ "primary": { "type": "string" },
30
+ "standbys": { "type": "array", "items": { "type": "string" } }
31
+ }
32
+ },
33
+ "postgresVersion": {
34
+ "type": "object",
35
+ "additionalProperties": false,
36
+ "required": ["version", "server_version_num", "server_major_ver", "server_minor_ver"],
37
+ "properties": {
38
+ "version": { "type": "string" },
39
+ "server_version_num": { "type": "string" },
40
+ "server_major_ver": { "type": "string" },
41
+ "server_minor_ver": { "type": "string" }
42
+ }
43
+ },
44
+ "unusedIndex": {
45
+ "type": "object",
46
+ "additionalProperties": false,
47
+ "required": [
48
+ "schema_name",
49
+ "table_name",
50
+ "index_name",
51
+ "index_definition",
52
+ "reason",
53
+ "idx_scan",
54
+ "index_size_bytes",
55
+ "idx_is_btree",
56
+ "supports_fk",
57
+ "index_size_pretty"
58
+ ],
59
+ "properties": {
60
+ "schema_name": { "type": "string" },
61
+ "table_name": { "type": "string" },
62
+ "index_name": { "type": "string" },
63
+ "index_definition": { "type": "string" },
64
+ "reason": { "type": "string" },
65
+ "idx_scan": { "type": "number" },
66
+ "index_size_bytes": { "type": "number" },
67
+ "idx_is_btree": { "type": "boolean" },
68
+ "supports_fk": { "type": "boolean" },
69
+ "index_size_pretty": { "type": "string" }
70
+ }
71
+ },
72
+ "statsReset": {
73
+ "type": "object",
74
+ "additionalProperties": false,
75
+ "required": [
76
+ "stats_reset_epoch",
77
+ "stats_reset_time",
78
+ "days_since_reset",
79
+ "postmaster_startup_epoch",
80
+ "postmaster_startup_time"
81
+ ],
82
+ "properties": {
83
+ "stats_reset_epoch": { "type": ["number", "null"] },
84
+ "stats_reset_time": { "type": ["string", "null"] },
85
+ "days_since_reset": { "type": ["integer", "null"] },
86
+ "postmaster_startup_epoch": { "type": ["number", "null"] },
87
+ "postmaster_startup_time": { "type": ["string", "null"] },
88
+ "postmaster_startup_error": { "type": "string" }
89
+ }
90
+ },
91
+ "dbEntry": {
92
+ "type": "object",
93
+ "additionalProperties": false,
94
+ "required": [
95
+ "unused_indexes",
96
+ "total_count",
97
+ "total_size_bytes",
98
+ "total_size_pretty",
99
+ "database_size_bytes",
100
+ "database_size_pretty",
101
+ "stats_reset"
102
+ ],
103
+ "properties": {
104
+ "unused_indexes": { "type": "array", "items": { "$ref": "#/$defs/unusedIndex" } },
105
+ "total_count": { "type": "integer" },
106
+ "total_size_bytes": { "type": "number" },
107
+ "total_size_pretty": { "type": "string" },
108
+ "database_size_bytes": { "type": "number" },
109
+ "database_size_pretty": { "type": "string" },
110
+ "stats_reset": { "$ref": "#/$defs/statsReset" }
111
+ }
112
+ },
113
+ "data": {
114
+ "type": "object",
115
+ "additionalProperties": { "$ref": "#/$defs/dbEntry" }
116
+ },
117
+ "nodeResult": {
118
+ "type": "object",
119
+ "additionalProperties": false,
120
+ "required": ["data"],
121
+ "properties": {
122
+ "data": { "$ref": "#/$defs/data" },
123
+ "postgres_version": { "$ref": "#/$defs/postgresVersion" }
124
+ }
125
+ }
126
+ }
127
+ }
128
+
129
+