@getxflow/cli 1.7.0 → 1.8.1

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.
package/dist/bin.js CHANGED
@@ -179,6 +179,10 @@ async function run(args) {
179
179
  await (0, db_1.dbExec)({ ...args, words: args.words.slice(2) });
180
180
  return;
181
181
  }
182
+ if (second === 'logs') {
183
+ await (0, logs_1.dbLogs)(args);
184
+ return;
185
+ }
182
186
  if (second === undefined || second === 'status') {
183
187
  await (0, db_1.dbStatus)({ ...args, words: args.words.slice(2) });
184
188
  return;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.logs = logs;
4
4
  exports.functionsLogs = functionsLogs;
5
+ exports.dbLogs = dbLogs;
5
6
  const api_1 = require("../api");
6
7
  const args_1 = require("../args");
7
8
  const config_1 = require("../config");
@@ -17,7 +18,7 @@ function stamp(iso) {
17
18
  /** Newest at the bottom. */
18
19
  function render(rows, appLabel) {
19
20
  for (const row of [...rows].reverse()) {
20
- const label = row.source === 'function' ? (row.function ?? 'function') : appLabel(row.app_id ?? '');
21
+ const label = row.source === 'function' ? (row.function ?? 'function') : row.source === 'database' ? 'database' : appLabel(row.app_id ?? '');
21
22
  (0, ui_1.out)(`${(0, ui_1.dim)(stamp(row.timestamp))} ${(0, ui_1.bold)(label)} ${row.message}`);
22
23
  if (row.stack) {
23
24
  const lines = row.stack.split('\n');
@@ -67,3 +68,21 @@ async function functionsLogs(args) {
67
68
  if (next)
68
69
  (0, ui_1.note)((0, ui_1.dim)(`Older: xflow functions logs${name ? ` ${name}` : ''}${all ? ' --all' : ''} --cursor ${next}`));
69
70
  }
71
+ /** Errors the project database raised, with the SQL that failed. */
72
+ async function dbLogs(args) {
73
+ const { projectId, client } = await (0, session_1.projectTarget)(args);
74
+ const query = new URLSearchParams({ source: 'database', limit: String((0, args_1.flagNumber)(args, 'limit') ?? DEFAULT_LIMIT) });
75
+ const cursor = (0, args_1.flagString)(args, 'cursor');
76
+ if (cursor)
77
+ query.set('cursor', cursor);
78
+ const { logs: rows, cursor: next } = await (0, api_1.apiJson)(client, `/api/v1/projects/${projectId}/logs?${query.toString()}`);
79
+ if (rows.length === 0) {
80
+ (0, ui_1.note)('The database raised no errors in the kept period');
81
+ (0, ui_1.note)((0, ui_1.dim)(' Kept for 7 days, 1 day on the Free plan'));
82
+ }
83
+ else {
84
+ render(rows, () => 'database');
85
+ }
86
+ if (next)
87
+ (0, ui_1.note)((0, ui_1.dim)(`Older: xflow db logs --cursor ${next}`));
88
+ }
package/dist/flags.js CHANGED
@@ -80,6 +80,7 @@ exports.KNOWN = {
80
80
  'db schema': ['project'],
81
81
  'db query': ['json', 'project'],
82
82
  'db exec': ['allow-destructive', 'json', 'project'],
83
+ 'db logs': ['limit', 'project', 'cursor'],
83
84
  'db migrate': ['dry-run', 'allow-destructive'],
84
85
  storage: ['json', 'project'],
85
86
  'storage ls': ['json', 'project'],