@polardbx/pxbaas 0.1.0-beta.3 → 0.1.0-beta.4

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 (103) hide show
  1. package/README.md +40 -8
  2. package/dist/app/local-index.d.ts +70 -0
  3. package/dist/app/local-index.d.ts.map +1 -0
  4. package/dist/app/local-index.js +140 -0
  5. package/dist/app/local-index.js.map +1 -0
  6. package/dist/app/preflight.d.ts +12 -0
  7. package/dist/app/preflight.d.ts.map +1 -1
  8. package/dist/app/preflight.js +30 -17
  9. package/dist/app/preflight.js.map +1 -1
  10. package/dist/cli/root.d.ts.map +1 -1
  11. package/dist/cli/root.js +3 -0
  12. package/dist/cli/root.js.map +1 -1
  13. package/dist/commands/app/index.d.ts.map +1 -1
  14. package/dist/commands/app/index.js +398 -46
  15. package/dist/commands/app/index.js.map +1 -1
  16. package/dist/commands/completion/index.d.ts.map +1 -1
  17. package/dist/commands/completion/index.js +5 -1
  18. package/dist/commands/completion/index.js.map +1 -1
  19. package/dist/commands/data/index.d.ts +52 -0
  20. package/dist/commands/data/index.d.ts.map +1 -1
  21. package/dist/commands/data/index.js +201 -39
  22. package/dist/commands/data/index.js.map +1 -1
  23. package/dist/commands/db/index.d.ts +14 -0
  24. package/dist/commands/db/index.d.ts.map +1 -1
  25. package/dist/commands/db/index.js +126 -28
  26. package/dist/commands/db/index.js.map +1 -1
  27. package/dist/commands/functions/new.d.ts +4 -0
  28. package/dist/commands/functions/new.d.ts.map +1 -1
  29. package/dist/commands/functions/new.js +24 -9
  30. package/dist/commands/functions/new.js.map +1 -1
  31. package/dist/commands/login/index.d.ts.map +1 -1
  32. package/dist/commands/login/index.js +15 -30
  33. package/dist/commands/login/index.js.map +1 -1
  34. package/dist/commands/profile/import-env.d.ts +7 -2
  35. package/dist/commands/profile/import-env.d.ts.map +1 -1
  36. package/dist/commands/profile/import-env.js +141 -16
  37. package/dist/commands/profile/import-env.js.map +1 -1
  38. package/dist/commands/profile/index.d.ts.map +1 -1
  39. package/dist/commands/profile/index.js +13 -1
  40. package/dist/commands/profile/index.js.map +1 -1
  41. package/dist/commands/storage/index.d.ts.map +1 -1
  42. package/dist/commands/storage/index.js +209 -7
  43. package/dist/commands/storage/index.js.map +1 -1
  44. package/dist/commands/tenant/index.d.ts +19 -0
  45. package/dist/commands/tenant/index.d.ts.map +1 -0
  46. package/dist/commands/tenant/index.js +662 -0
  47. package/dist/commands/tenant/index.js.map +1 -0
  48. package/dist/commands/whoami/index.js +19 -0
  49. package/dist/commands/whoami/index.js.map +1 -1
  50. package/dist/credentials/credential-store.d.ts +30 -1
  51. package/dist/credentials/credential-store.d.ts.map +1 -1
  52. package/dist/credentials/credential-store.js +114 -12
  53. package/dist/credentials/credential-store.js.map +1 -1
  54. package/dist/credentials/env-file.d.ts +48 -7
  55. package/dist/credentials/env-file.d.ts.map +1 -1
  56. package/dist/credentials/env-file.js +91 -16
  57. package/dist/credentials/env-file.js.map +1 -1
  58. package/dist/credentials/jwt-introspect.d.ts +7 -0
  59. package/dist/credentials/jwt-introspect.d.ts.map +1 -1
  60. package/dist/credentials/jwt-introspect.js.map +1 -1
  61. package/dist/credentials/masker.d.ts +3 -0
  62. package/dist/credentials/masker.d.ts.map +1 -1
  63. package/dist/credentials/masker.js +3 -0
  64. package/dist/credentials/masker.js.map +1 -1
  65. package/dist/credentials/profile.d.ts +12 -0
  66. package/dist/credentials/profile.d.ts.map +1 -1
  67. package/dist/credentials/profile.js +23 -0
  68. package/dist/credentials/profile.js.map +1 -1
  69. package/dist/credentials/tty-guard.d.ts +10 -0
  70. package/dist/credentials/tty-guard.d.ts.map +1 -1
  71. package/dist/credentials/tty-guard.js +32 -0
  72. package/dist/credentials/tty-guard.js.map +1 -1
  73. package/dist/main.js +21 -2
  74. package/dist/main.js.map +1 -1
  75. package/dist/tenant/bundle.d.ts +66 -0
  76. package/dist/tenant/bundle.d.ts.map +1 -0
  77. package/dist/tenant/bundle.js +132 -0
  78. package/dist/tenant/bundle.js.map +1 -0
  79. package/dist/tenant/guide.d.ts +50 -0
  80. package/dist/tenant/guide.d.ts.map +1 -0
  81. package/dist/tenant/guide.js +152 -0
  82. package/dist/tenant/guide.js.map +1 -0
  83. package/dist/tenant/probe.d.ts +65 -0
  84. package/dist/tenant/probe.d.ts.map +1 -0
  85. package/dist/tenant/probe.js +159 -0
  86. package/dist/tenant/probe.js.map +1 -0
  87. package/dist/tenant/verify.d.ts +37 -0
  88. package/dist/tenant/verify.d.ts.map +1 -0
  89. package/dist/tenant/verify.js +132 -0
  90. package/dist/tenant/verify.js.map +1 -0
  91. package/dist/version.d.ts +29 -0
  92. package/dist/version.d.ts.map +1 -0
  93. package/dist/version.js +65 -0
  94. package/dist/version.js.map +1 -0
  95. package/package.json +2 -2
  96. package/skills/pxbaas-app-spec/references/runtime-contract.md +1 -1
  97. package/skills/pxbaas-cli/SKILL.md +14 -5
  98. package/skills/pxbaas-cli/references/auth-and-credentials.md +19 -3
  99. package/skills/pxbaas-cli/references/data-postgrest.md +4 -3
  100. package/skills/pxbaas-cli/references/db-and-meta.md +5 -0
  101. package/skills/pxbaas-cli/references/safety-and-two-phase.md +42 -13
  102. package/skills/pxbaas-cli/references/tenant-admin.md +122 -0
  103. package/skills/pxbaas-cli/references/troubleshooting.md +4 -1
@@ -1,5 +1,24 @@
1
1
  import axios from 'axios';
2
- import { CredentialStore, ProfileManager, formatSuccess, formatError, } from '../../credentials/index.js';
2
+ import inquirer from 'inquirer';
3
+ import { CredentialStore, ProfileManager, formatSuccess, formatError, formatWarning, } from '../../credentials/index.js';
4
+ /** Rows fetched by the read-only preview; the count itself comes from Content-Range. */
5
+ const DELETE_PREVIEW_LIMIT = 1000;
6
+ /**
7
+ * Failure of the delete gate (missing filter, or execution not authorized).
8
+ *
9
+ * Carries the preview so `--json` callers still get the audit trail of what was
10
+ * NOT deleted — the whole point of the two-phase flow.
11
+ */
12
+ export class DataDeleteError extends Error {
13
+ code;
14
+ preview;
15
+ constructor(code, message, preview) {
16
+ super(message);
17
+ this.code = code;
18
+ this.preview = preview;
19
+ this.name = 'DataDeleteError';
20
+ }
21
+ }
3
22
  export function registerDataCommands(program) {
4
23
  const dataCmd = program
5
24
  .command('data')
@@ -60,20 +79,196 @@ export function registerDataCommands(program) {
60
79
  // data delete
61
80
  dataCmd
62
81
  .command('delete <table>')
63
- .description('Delete rows from table (two-phase confirmation)')
64
- .requiredOption('--filter <filter>', 'PostgREST filter (e.g., "id=eq.1")')
82
+ .description('Delete rows from table. Previews the affected row count and the exact request URL, then requires confirmation (--yes to authorize non-interactively)')
83
+ .requiredOption('--filter <filter>', 'PostgREST condition passed through verbatim; repeat to combine (e.g. --filter "id=eq.1" --filter "or=(a.eq.1,b.eq.2)"). Required: without it every row would be deleted', collectFilter)
84
+ .option('--yes', 'Authorize non-interactively (skip the confirm prompt)')
65
85
  .option('--json', 'Output in JSON format')
66
86
  .action(async (table, options) => {
87
+ const json = Boolean(options.json || program.opts().json);
67
88
  try {
68
- await handleDataDelete(table, { ...options, json: options.json || program.opts().json });
89
+ await handleDataDelete(table, { ...options, json });
69
90
  }
70
91
  catch (error) {
71
- const message = error instanceof Error ? error.message : String(error);
72
- console.error(formatError(message));
92
+ // Keep the preview in the machine-readable payload: an audit consumer must
93
+ // be able to tell what was refused, not just that something was.
94
+ if (json && error instanceof DataDeleteError) {
95
+ console.log(JSON.stringify({
96
+ code: error.code,
97
+ message: error.message,
98
+ ...(error.preview ? { preview: error.preview } : {}),
99
+ }, null, 2));
100
+ }
101
+ else {
102
+ const message = error instanceof Error ? error.message : String(error);
103
+ console.error(formatError(message));
104
+ }
73
105
  process.exit(1);
74
106
  }
75
107
  });
76
108
  }
109
+ /** Accumulate repeated `--filter` flags instead of letting the last one win. */
110
+ function collectFilter(value, previous) {
111
+ return [...(previous ?? []), value];
112
+ }
113
+ /**
114
+ * Normalize the `--filter` flags into the PostgREST query string, verbatim.
115
+ *
116
+ * The previous implementation did `filter.split('=')` and rebuilt ONE key/value
117
+ * pair, so a condition containing `&` (e.g. `id=eq.1&name=like.a%`) had
118
+ * everything after the first `&` percent-encoded INTO the value: the extra
119
+ * condition silently disappeared and the DELETE matched strictly more rows than
120
+ * the operator asked for. Filters are therefore split on `&` only, each fragment
121
+ * is validated to be a `column=operator.value` pair, and nothing is re-encoded.
122
+ *
123
+ * An empty/absent filter is a hard error — it would delete the whole table. A
124
+ * blank fragment is an error too rather than something to skip: `--filter "$VAR"`
125
+ * with an unset VAR must fail loudly, not silently narrow to the other flags.
126
+ */
127
+ export function normalizeDeleteFilters(raw) {
128
+ const given = typeof raw === 'string' ? [raw] : raw ?? [];
129
+ const parts = [];
130
+ for (const item of given) {
131
+ const value = String(item ?? '');
132
+ if (!value.trim()) {
133
+ throw new DataDeleteError('DATA_DELETE_FILTER_INVALID', 'Empty --filter value. Expected a PostgREST condition such as "id=eq.1"; ' +
134
+ 'an empty filter would delete the whole table.');
135
+ }
136
+ for (const condition of value.split('&')) {
137
+ const trimmed = condition.trim();
138
+ if (!trimmed || trimmed.indexOf('=') <= 0) {
139
+ throw new DataDeleteError('DATA_DELETE_FILTER_INVALID', `Invalid --filter '${trimmed || value}'. Expected a PostgREST condition such as ` +
140
+ '"id=eq.1", "created_at=lt.2026-01-01" or "or=(a.eq.1,b.eq.2)".');
141
+ }
142
+ parts.push(trimmed);
143
+ }
144
+ }
145
+ if (parts.length === 0) {
146
+ throw new DataDeleteError('DATA_DELETE_FILTER_REQUIRED', 'Refusing to delete without a filter: that would delete EVERY row of the table. ' +
147
+ 'Pass at least one --filter "column=operator.value" (repeatable), e.g. --filter "id=eq.1".');
148
+ }
149
+ return parts;
150
+ }
151
+ /** Total row count from a PostgREST `Content-Range: 0-9/42` header; null when unknown. */
152
+ function parseContentRangeTotal(header) {
153
+ if (typeof header !== 'string' || header === '')
154
+ return null;
155
+ const total = header.split('/')[1]?.trim();
156
+ if (!total || total === '*')
157
+ return null;
158
+ const parsed = Number(total);
159
+ return Number.isFinite(parsed) ? parsed : null;
160
+ }
161
+ /**
162
+ * Decide whether the DELETE is authorized. Same contract as `db push --yes`
163
+ * (src/db/apply-schema.ts authorize): `--yes` authorizes outright; `--json` and
164
+ * non-TTY sessions cannot prompt, so they require `--yes` explicitly.
165
+ */
166
+ async function authorizeDelete(preview, options) {
167
+ if (options.yes)
168
+ return;
169
+ if (options.json) {
170
+ throw new DataDeleteError('DATA_DELETE_NOT_AUTHORIZED', 'Refusing to delete rows in --json mode without explicit authorization. ' +
171
+ 'Re-run with --yes to apply. Nothing was deleted.', preview);
172
+ }
173
+ if (!process.stdin.isTTY) {
174
+ throw new DataDeleteError('DATA_DELETE_NOT_AUTHORIZED', 'Refusing to delete rows without explicit authorization: pass --yes for ' +
175
+ 'non-interactive use, or run in a TTY to confirm. Nothing was deleted.', preview);
176
+ }
177
+ const described = preview.rowCount === null
178
+ ? 'an unknown number of row(s)'
179
+ : preview.countExact
180
+ ? `${preview.rowCount} row(s)`
181
+ : `at least ${preview.rowCount} row(s)`;
182
+ const { ok } = await inquirer.prompt([
183
+ {
184
+ type: 'confirm',
185
+ name: 'ok',
186
+ message: `Delete ${described} from '${preview.table}' (filter: ${preview.filters.join(' & ')})? This cannot be undone`,
187
+ default: false,
188
+ },
189
+ ]);
190
+ if (!ok) {
191
+ throw new DataDeleteError('DATA_DELETE_CANCELLED', `Cancelled by operator; nothing was deleted from '${preview.table}'.`, preview);
192
+ }
193
+ }
194
+ function printPreview(preview) {
195
+ const described = preview.rowCount === null
196
+ ? 'an unknown number of row(s)'
197
+ : preview.countExact
198
+ ? `${preview.rowCount} row(s)`
199
+ : `at least ${preview.rowCount} row(s)`;
200
+ console.log(formatWarning(`Preview: will delete ${described} from '${preview.table}'`));
201
+ console.log(` Filter: ${preview.filters.join(' & ')}`);
202
+ console.log(` Request: DELETE ${preview.url}`);
203
+ if (preview.previewError) {
204
+ console.log(` Note: the read-only count failed (${preview.previewError}); the delete is still gated.`);
205
+ }
206
+ }
207
+ export async function handleDataDelete(table, options) {
208
+ // Get current profile
209
+ const profileManager = new ProfileManager();
210
+ const currentProfile = await profileManager.getCurrentProfile();
211
+ if (!currentProfile) {
212
+ throw new Error('No active profile. Use "pxbaas login" to authenticate first.');
213
+ }
214
+ // Get credentials
215
+ const credentialStore = new CredentialStore();
216
+ const credentials = await credentialStore.getCredentials(currentProfile.name);
217
+ if (!credentials) {
218
+ throw new Error(`No credentials found for profile: ${currentProfile.name}. Use "pxbaas login" to authenticate.`);
219
+ }
220
+ const filters = normalizeDeleteFilters(options.filter);
221
+ const query = filters.join('&');
222
+ const url = `${currentProfile.endpoint}/rest/v1/${table}?${query}`;
223
+ const headers = {
224
+ 'apikey': credentials.anonKey,
225
+ 'Authorization': `Bearer ${credentials.anonKey}`,
226
+ };
227
+ // Phase 1: read-only preview against the SAME filter, so the operator sees the
228
+ // blast radius before anything is destroyed. A failing count (e.g. RLS allows
229
+ // DELETE but not SELECT) degrades to "unknown" instead of skipping the gate.
230
+ const preview = {
231
+ table,
232
+ filters,
233
+ rowCount: null,
234
+ countExact: false,
235
+ url,
236
+ };
237
+ try {
238
+ const probe = await axios.get(`${currentProfile.endpoint}/rest/v1/${table}?select=*&limit=${DELETE_PREVIEW_LIMIT}&${query}`, { headers: { ...headers, 'Prefer': 'count=exact' } });
239
+ const fromRange = parseContentRangeTotal(probe.headers?.['content-range']);
240
+ if (fromRange !== null) {
241
+ preview.rowCount = fromRange;
242
+ preview.countExact = true;
243
+ }
244
+ else if (Array.isArray(probe.data)) {
245
+ preview.rowCount = probe.data.length;
246
+ preview.countExact = probe.data.length < DELETE_PREVIEW_LIMIT;
247
+ }
248
+ }
249
+ catch (error) {
250
+ preview.previewError = error instanceof Error ? error.message : String(error);
251
+ }
252
+ if (!options.json)
253
+ printPreview(preview);
254
+ // Phase 2: explicit authorization (--yes, or an interactive confirm).
255
+ await authorizeDelete(preview, options);
256
+ const response = await axios.delete(url, {
257
+ headers: { ...headers, 'Prefer': 'return=representation' },
258
+ });
259
+ const rows = Array.isArray(response.data) ? response.data : [];
260
+ const result = {
261
+ preview,
262
+ deleted: { table, count: rows.length, url },
263
+ };
264
+ if (options.json) {
265
+ console.log(JSON.stringify(result, null, 2));
266
+ }
267
+ else {
268
+ console.log(formatSuccess(`Deleted ${rows.length} row(s) from '${table}'`));
269
+ }
270
+ return result;
271
+ }
77
272
  async function handleDataSelect(table, options) {
78
273
  // Get current profile
79
274
  const profileManager = new ProfileManager();
@@ -209,37 +404,4 @@ async function handleDataUpdate(table, options) {
209
404
  console.log(formatSuccess(`Updated ${rows.length} row(s) in ${table}`));
210
405
  }
211
406
  }
212
- async function handleDataDelete(table, options) {
213
- // Get current profile
214
- const profileManager = new ProfileManager();
215
- const currentProfile = await profileManager.getCurrentProfile();
216
- if (!currentProfile) {
217
- throw new Error('No active profile. Use "pxbaas login" to authenticate first.');
218
- }
219
- // Get credentials
220
- const credentialStore = new CredentialStore();
221
- const credentials = await credentialStore.getCredentials(currentProfile.name);
222
- if (!credentials) {
223
- throw new Error(`No credentials found for profile: ${currentProfile.name}. Use "pxbaas login" to authenticate.`);
224
- }
225
- // Build query URL with filter
226
- const params = new URLSearchParams();
227
- params.append(options.filter.split('=')[0], options.filter.split('=').slice(1).join('='));
228
- const url = `${currentProfile.endpoint}/rest/v1/${table}?${params.toString()}`;
229
- // Make request
230
- const response = await axios.delete(url, {
231
- headers: {
232
- 'apikey': credentials.anonKey,
233
- 'Authorization': `Bearer ${credentials.anonKey}`,
234
- 'Prefer': 'return=representation',
235
- },
236
- });
237
- if (options.json) {
238
- console.log(JSON.stringify(response.data, null, 2));
239
- }
240
- else {
241
- const rows = response.data;
242
- console.log(formatSuccess(`Deleted ${rows.length} row(s) from ${table}`));
243
- }
244
- }
245
407
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/data/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,eAAe,EACf,cAAc,EACd,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EAAE,WAAW,CAAC,OAAO;YAC7B,eAAe,EAAE,UAAU,WAAW,CAAC,OAAO,EAAE;YAChD,cAAc,EAAE,kBAAkB;YAClC,QAAQ,EAAE,uBAAuB;SAClC;KACF,CAAC,CAAC;IAEH,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAiC,CAAC;QACxD,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,IAAI,CAAC,MAAM,cAAc,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC"}
@@ -4,6 +4,20 @@ export declare function handleDbQuery(sql: string, options: {
4
4
  role: string;
5
5
  json?: boolean;
6
6
  }, program: Command): Promise<void>;
7
+ export declare function handleDbCreateTable(name: string, options: {
8
+ columns?: string;
9
+ schema?: string;
10
+ role: string;
11
+ json?: boolean;
12
+ }, program: Command): Promise<void>;
13
+ export declare function handleDbAddColumn(table: string, column: string, options: {
14
+ type: string;
15
+ nullable: boolean;
16
+ default?: string;
17
+ schema?: string;
18
+ role: string;
19
+ json?: boolean;
20
+ }, program: Command): Promise<void>;
7
21
  export declare function handleDbPush(file: string, options: {
8
22
  schema: string;
9
23
  rls?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmBpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA8HzD;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CA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AC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,EACD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAgDf;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,EACD,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,IAAI,CAAC,CAsDf"}
@@ -58,9 +58,9 @@ export function registerDbCommands(program) {
58
58
  });
59
59
  db
60
60
  .command('create-table <name>')
61
- .description('Create a new table (requires service_role, two-phase confirmation)')
61
+ .description('Create a new table (requires service_role; executes immediately, no confirmation prompt)')
62
62
  .option('--columns <json>', 'Column definitions (JSON array)')
63
- .option('--schema <schema>', 'Schema name', 'public')
63
+ .option('--schema <schema>', 'Schema name (single-tenant only; multi-tenant always targets the tenant database)')
64
64
  .option('--role <role>', 'Role to use (anon or service_role)', 'service_role')
65
65
  .option('--json', 'Output in JSON format')
66
66
  .action(async (name, options) => {
@@ -75,11 +75,11 @@ export function registerDbCommands(program) {
75
75
  });
76
76
  db
77
77
  .command('add-column <table> <column>')
78
- .description('Add a column to a table (requires service_role, two-phase confirmation)')
78
+ .description('Add a column to a table (requires service_role; executes immediately, no confirmation prompt)')
79
79
  .option('--type <type>', 'Column data type', 'text')
80
80
  .option('--nullable', 'Allow NULL values', true)
81
81
  .option('--default <value>', 'Default value')
82
- .option('--schema <schema>', 'Schema name', 'public')
82
+ .option('--schema <schema>', 'Schema name (single-tenant only; multi-tenant always targets the tenant database)')
83
83
  .option('--role <role>', 'Role to use (anon or service_role)', 'service_role')
84
84
  .option('--json', 'Output in JSON format')
85
85
  .action(async (table, column, options) => {
@@ -274,7 +274,86 @@ async function handleDbSchema(table, options, program) {
274
274
  }
275
275
  }
276
276
  }
277
- async function handleDbCreateTable(name, options, program) {
277
+ /** Same actionable error as `handleDbQuery` for a malformed multi-tenant profile. */
278
+ function assertTenantId(profile) {
279
+ if (!profile.tenantId) {
280
+ throw new Error('Multi-tenant profile is missing tenantId; re-run "pxbaas login --tenant-id <id>" with per-tenant keys.');
281
+ }
282
+ }
283
+ /**
284
+ * D1 fix: run one DDL statement through the channel the profile can actually
285
+ * authenticate on. Mirrors the mode dispatch of `handleDbQuery`: in
286
+ * multi-tenant the Meta API (/pg/*) only accepts the platform global
287
+ * service_role key (per-tenant keys get 401), so tenant DDL must go through
288
+ * /api/tenant-ddl with the per-tenant service_role key.
289
+ */
290
+ async function runDdl(profile, credentials, sql, options) {
291
+ const useServiceRole = options.role === 'service_role';
292
+ if (profile.mode === 'multi-tenant') {
293
+ assertTenantId(profile);
294
+ // tenant-ddl role-gates on service_role, so --role anon is not applicable
295
+ // and the statement always runs as the tenant's service_role.
296
+ if (!useServiceRole) {
297
+ console.error(formatWarning(`${options.command} in multi-tenant mode always runs as the tenant service_role (tenant-ddl ignores --role anon).`));
298
+ }
299
+ const tenantDriver = new TenantDdlDriver({
300
+ endpoint: profile.endpoint,
301
+ serviceRoleKey: credentials.serviceRoleKey,
302
+ });
303
+ const rows = (await tenantDriver.query(sql));
304
+ return { rows, rowCount: rows.length };
305
+ }
306
+ const metaDriver = new MetaDriver({
307
+ endpoint: profile.endpoint,
308
+ anonKey: credentials.anonKey,
309
+ serviceRoleKey: credentials.serviceRoleKey,
310
+ tenantId: profile.tenantId,
311
+ });
312
+ return metaDriver.query(sql, useServiceRole);
313
+ }
314
+ /**
315
+ * D3 / 06-§3 fix: the REAL target database name in multi-tenant mode, via the
316
+ * same route `db tables` uses (tenant-ddl `SELECT DATABASE()`). Falls back to
317
+ * the platform's `tenant_<id>` naming convention so a failed read-only probe
318
+ * never hard-fails an otherwise successful DDL.
319
+ */
320
+ async function resolveTenantSchemaLabel(profile, credentials) {
321
+ assertTenantId(profile);
322
+ try {
323
+ const introspector = makeIntrospector({
324
+ mode: profile.mode,
325
+ endpoint: profile.endpoint,
326
+ anonKey: credentials.anonKey,
327
+ serviceRoleKey: credentials.serviceRoleKey,
328
+ tenantId: profile.tenantId,
329
+ });
330
+ const label = await introspector.currentSchema();
331
+ if (label)
332
+ return label;
333
+ }
334
+ catch {
335
+ // fall through to the convention-based label
336
+ }
337
+ return `tenant_${profile.tenantId}`;
338
+ }
339
+ /**
340
+ * D2/D3 fix: resolve the schema a DDL command actually targets. Multi-tenant
341
+ * DDL always lands in the tenant's own database, so report that real name and
342
+ * warn when the user explicitly asked for a different --schema (instead of
343
+ * silently dropping the input). Single-tenant keeps the requested value with
344
+ * the historical `public` default.
345
+ */
346
+ async function resolveDdlSchema(profile, credentials, requestedSchema) {
347
+ if (profile.mode !== 'multi-tenant') {
348
+ return requestedSchema ?? 'public';
349
+ }
350
+ const effective = await resolveTenantSchemaLabel(profile, credentials);
351
+ if (requestedSchema && requestedSchema !== effective) {
352
+ console.error(formatWarning(`--schema is ignored in multi-tenant mode: DDL always targets the tenant database "${effective}" (requested "${requestedSchema}").`));
353
+ }
354
+ return effective;
355
+ }
356
+ export async function handleDbCreateTable(name, options, program) {
278
357
  const profileManager = new ProfileManager();
279
358
  const currentProfile = await profileManager.getCurrentProfile();
280
359
  if (!currentProfile) {
@@ -302,6 +381,9 @@ async function handleDbCreateTable(name, options, program) {
302
381
  { name: 'created_at', type: 'timestamp', nullable: false },
303
382
  ];
304
383
  }
384
+ // D2/D3 fix: the effective target schema (tenant db in multi-tenant).
385
+ const effectiveSchema = await resolveDdlSchema(currentProfile, credentials, options.schema);
386
+ const isMultiTenant = currentProfile.mode === 'multi-tenant';
305
387
  // Build SQL
306
388
  const columnSql = columnDefs.map(col => {
307
389
  let sql = `${col.name} ${col.type}`;
@@ -311,25 +393,26 @@ async function handleDbCreateTable(name, options, program) {
311
393
  sql += ' NOT NULL';
312
394
  return sql;
313
395
  }).join(', ');
314
- const sql = `CREATE TABLE ${options.schema}.${name} (${columnSql})`;
315
- const useServiceRole = options.role === 'service_role';
316
- const metaDriver = new MetaDriver({
317
- endpoint: currentProfile.endpoint,
318
- anonKey: credentials.anonKey,
319
- serviceRoleKey: credentials.serviceRoleKey,
320
- tenantId: currentProfile.tenantId,
396
+ // Multi-tenant: NO schema qualifier — the tenant-ddl connection is bound to
397
+ // the tenant's own database and a `public.` prefix would be rejected (or
398
+ // would write into the shared public db). Single-tenant shape is unchanged.
399
+ const sql = isMultiTenant
400
+ ? `CREATE TABLE \`${name}\` (${columnSql})`
401
+ : `CREATE TABLE ${effectiveSchema}.${name} (${columnSql})`;
402
+ const result = await runDdl(currentProfile, credentials, sql, {
403
+ role: options.role,
404
+ command: 'db create-table',
321
405
  });
322
- const result = await metaDriver.query(sql, useServiceRole);
323
406
  if (options.json || program.opts().json) {
324
- console.log(JSON.stringify({ table: name, schema: options.schema, sql, result }, null, 2));
407
+ console.log(JSON.stringify({ table: name, schema: effectiveSchema, sql, result }, null, 2));
325
408
  }
326
409
  else {
327
- console.log(formatSuccess(`Created table "${options.schema}.${name}"`));
410
+ console.log(formatSuccess(`Created table "${effectiveSchema}.${name}"`));
328
411
  console.log(` SQL: ${sql}`);
329
412
  console.log(formatWarning(' Note: the REST schema cache re-introspects after DDL; the new table is visible to /rest/v1 within a few seconds.'));
330
413
  }
331
414
  }
332
- async function handleDbAddColumn(table, column, options, program) {
415
+ export async function handleDbAddColumn(table, column, options, program) {
333
416
  const profileManager = new ProfileManager();
334
417
  const currentProfile = await profileManager.getCurrentProfile();
335
418
  if (!currentProfile) {
@@ -340,27 +423,28 @@ async function handleDbAddColumn(table, column, options, program) {
340
423
  if (!credentials) {
341
424
  throw new Error(`No credentials found for profile: ${currentProfile.name}. Use "pxbaas login" to authenticate.`);
342
425
  }
343
- // Build SQL
344
- let sql = `ALTER TABLE ${options.schema}.${table} ADD COLUMN ${column} ${options.type}`;
426
+ // D2/D3 fix: the effective target schema (tenant db in multi-tenant).
427
+ const effectiveSchema = await resolveDdlSchema(currentProfile, credentials, options.schema);
428
+ const isMultiTenant = currentProfile.mode === 'multi-tenant';
429
+ // Build SQL. Multi-tenant: NO schema qualifier (see handleDbCreateTable).
430
+ let sql = isMultiTenant
431
+ ? `ALTER TABLE \`${table}\` ADD COLUMN ${column} ${options.type}`
432
+ : `ALTER TABLE ${effectiveSchema}.${table} ADD COLUMN ${column} ${options.type}`;
345
433
  if (!options.nullable) {
346
434
  sql += ' NOT NULL';
347
435
  }
348
436
  if (options.default !== undefined) {
349
437
  sql += ` DEFAULT ${options.default}`;
350
438
  }
351
- const useServiceRole = options.role === 'service_role';
352
- const metaDriver = new MetaDriver({
353
- endpoint: currentProfile.endpoint,
354
- anonKey: credentials.anonKey,
355
- serviceRoleKey: credentials.serviceRoleKey,
356
- tenantId: currentProfile.tenantId,
439
+ const result = await runDdl(currentProfile, credentials, sql, {
440
+ role: options.role,
441
+ command: 'db add-column',
357
442
  });
358
- const result = await metaDriver.query(sql, useServiceRole);
359
443
  if (options.json || program.opts().json) {
360
- console.log(JSON.stringify({ table, column, schema: options.schema, sql, result }, null, 2));
444
+ console.log(JSON.stringify({ table, column, schema: effectiveSchema, sql, result }, null, 2));
361
445
  }
362
446
  else {
363
- console.log(formatSuccess(`Added column "${column}" to table "${options.schema}.${table}"`));
447
+ console.log(formatSuccess(`Added column "${column}" to table "${effectiveSchema}.${table}"`));
364
448
  console.log(` SQL: ${sql}`);
365
449
  console.log(formatWarning(' Note: REST select=* re-introspects columns after DDL. If a query still omits the new column, select it explicitly or retry in a few seconds (schema cache refresh).'));
366
450
  }
@@ -374,6 +458,20 @@ export async function handleDbPush(file, options, program) {
374
458
  // Mode-aware: single-tenant -> /pg/query (global admin); multi-tenant ->
375
459
  // /api/tenant-ddl (per-tenant service_role). RLS is diverted appropriately.
376
460
  const sink = await getSchemaSink(options.role === 'anon' ? 'anon' : 'service_role');
461
+ // 06-§3 fix: in multi-tenant the statements execute in the tenant's OWN
462
+ // database, so the plan/JSON must report that real target instead of
463
+ // echoing the --schema default ("public"), which misleads audits.
464
+ let effectiveSchema = options.schema;
465
+ if (sink.mode === 'multi-tenant') {
466
+ const profileManager = new ProfileManager();
467
+ const currentProfile = await profileManager.getCurrentProfile();
468
+ const credentials = currentProfile
469
+ ? await new CredentialStore().getCredentials(currentProfile.name)
470
+ : null;
471
+ if (currentProfile && credentials) {
472
+ effectiveSchema = await resolveTenantSchemaLabel(currentProfile, credentials);
473
+ }
474
+ }
377
475
  let rls = null;
378
476
  if (options.rls) {
379
477
  if (!existsSync(options.rls)) {
@@ -385,7 +483,7 @@ export async function handleDbPush(file, options, program) {
385
483
  rawSql: raw,
386
484
  source: file,
387
485
  rls,
388
- schema: options.schema,
486
+ schema: effectiveSchema,
389
487
  dryRun: Boolean(options.dryRun),
390
488
  assumeYes: Boolean(options.yes),
391
489
  json,