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
@@ -1,116 +0,0 @@
1
- /**
2
- * Test the SQL logic for checking postgres_ai.pg_statistic view existence
3
- * across different permission scenarios.
4
- */
5
- import { describe, test, expect } from "bun:test";
6
-
7
- describe("postgres_ai.pg_statistic permission check SQL", () => {
8
- test("to_regclass() returns NULL when schema doesn't exist", () => {
9
- // Simulate the SQL check behavior
10
- const viewExists = null; // to_regclass('postgres_ai.pg_statistic') when schema doesn't exist
11
- const granted = viewExists !== null;
12
-
13
- expect(granted).toBe(false);
14
- });
15
-
16
- test("to_regclass() returns NULL when user lacks USAGE on schema", () => {
17
- // When user lacks USAGE on postgres_ai schema, to_regclass() returns NULL
18
- // even if the schema and view exist
19
- const viewExists = null; // to_regclass('postgres_ai.pg_statistic') when no USAGE
20
- const granted = viewExists !== null;
21
-
22
- expect(granted).toBe(false);
23
- });
24
-
25
- test("to_regclass() returns oid when view exists and user has access", () => {
26
- // When user has USAGE on schema and view exists
27
- const viewExists = 12345; // to_regclass('postgres_ai.pg_statistic') returns oid
28
- const granted = viewExists !== null;
29
-
30
- expect(granted).toBe(true);
31
- });
32
-
33
- test("has_table_privilege is skipped (returns null) when view doesn't exist", () => {
34
- const viewExists = null;
35
- const selectGranted = viewExists === null ? null : true; // skipped
36
-
37
- expect(selectGranted).toBeNull();
38
- });
39
-
40
- test("has_table_privilege is checked when view exists", () => {
41
- const viewExists = 12345;
42
- const userHasSelect = true;
43
- const selectGranted = viewExists === null ? null : userHasSelect;
44
-
45
- expect(selectGranted).toBe(true);
46
- });
47
- });
48
-
49
- describe("Expected behavior per scenario", () => {
50
- test("Scenario 1: Superuser with postgres_ai.pg_statistic", () => {
51
- // to_regclass returns oid, has_table_privilege returns true
52
- const checkViewExists = true; // to_regclass('postgres_ai.pg_statistic') is not null
53
- const checkSelectPrivilege = true; // has_table_privilege returns true
54
-
55
- const missingOptional: string[] = [];
56
- if (!checkViewExists) {
57
- missingOptional.push("postgres_ai.pg_statistic view exists");
58
- }
59
- if (checkSelectPrivilege === false) {
60
- missingOptional.push("select on postgres_ai.pg_statistic");
61
- }
62
-
63
- expect(missingOptional).toHaveLength(0);
64
- });
65
-
66
- test("Scenario 2: pg_monitor, no postgres_ai schema access (before prepare-db)", () => {
67
- // to_regclass returns NULL because user lacks USAGE on postgres_ai schema
68
- const checkViewExists = false; // to_regclass('postgres_ai.pg_statistic') is null
69
- const checkSelectPrivilege = null; // skipped because view doesn't exist
70
-
71
- const missingOptional: string[] = [];
72
- if (!checkViewExists) {
73
- missingOptional.push("postgres_ai.pg_statistic view exists");
74
- }
75
- if (checkSelectPrivilege === false) {
76
- missingOptional.push("select on postgres_ai.pg_statistic");
77
- }
78
-
79
- // Should show warning about missing view but NOT crash
80
- expect(missingOptional).toEqual(["postgres_ai.pg_statistic view exists"]);
81
- });
82
-
83
- test("Scenario 3: No pg_monitor (before prepare-db)", () => {
84
- // to_regclass returns NULL because schema doesn't exist yet
85
- const checkViewExists = false; // to_regclass('postgres_ai.pg_statistic') is null
86
- const checkSelectPrivilege = null; // skipped
87
-
88
- const missingOptional: string[] = [];
89
- if (!checkViewExists) {
90
- missingOptional.push("postgres_ai.pg_statistic view exists");
91
- }
92
- if (checkSelectPrivilege === false) {
93
- missingOptional.push("select on postgres_ai.pg_statistic");
94
- }
95
-
96
- // Should show warning but NOT crash
97
- expect(missingOptional).toEqual(["postgres_ai.pg_statistic view exists"]);
98
- });
99
-
100
- test("Scenario 8: After prepare-db with schema grants", () => {
101
- // to_regclass returns oid, has_table_privilege returns true
102
- const checkViewExists = true; // to_regclass('postgres_ai.pg_statistic') is not null
103
- const checkSelectPrivilege = true; // has_table_privilege returns true
104
-
105
- const missingOptional: string[] = [];
106
- if (!checkViewExists) {
107
- missingOptional.push("postgres_ai.pg_statistic view exists");
108
- }
109
- if (checkSelectPrivilege === false) {
110
- missingOptional.push("select on postgres_ai.pg_statistic");
111
- }
112
-
113
- // Should be clean, no warnings
114
- expect(missingOptional).toHaveLength(0);
115
- });
116
- });