neon 8.18.0 → 8.18.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/README.md +6 -3
- package/dist/commands/subscribe.js +28 -15
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -330,9 +330,12 @@ neon realtime subscribe "SELECT id, title, completed FROM realtime_todos ORDER B
|
|
|
330
330
|
The default terminal output is append-only. It identifies the selected project,
|
|
331
331
|
branch, and database; prints the initial result once; reports connection-state
|
|
332
332
|
changes; and then prints each published change set with its transaction IDs, a compact
|
|
333
|
-
`+insert ~update -delete` summary, and the affected rows.
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
`+insert ~update -delete` summary, and the affected rows. Row moves appear as
|
|
334
|
+
`↔ move` with a separate `↔` count and retain the row's values. It does not take
|
|
335
|
+
over the terminal or require keyboard navigation. Pass `--changes` to display the
|
|
336
|
+
raw `rows` and `changes` events instead of the materialized view. Raw table output
|
|
337
|
+
includes each move's `after_row_id` destination, with `(head)` for the first
|
|
338
|
+
position, and counts moves separately from removals.
|
|
336
339
|
|
|
337
340
|
For scripts and agents, JSON output is a JSON Lines stream with one complete event
|
|
338
341
|
per line. YAML output uses one document per event:
|
|
@@ -171,11 +171,13 @@ const renderTableEvent = (out, event, now) => {
|
|
|
171
171
|
const rows = event.changes.map((change) => ({
|
|
172
172
|
type: change.type,
|
|
173
173
|
row_id: change.rowId,
|
|
174
|
+
after_row_id: change.type === "move" ? change.afterRowId ?? "(head)" : void 0,
|
|
174
175
|
row: change.type === "upsert" ? change.row : void 0
|
|
175
176
|
}));
|
|
176
177
|
renderRows(out, rows, [
|
|
177
178
|
"type",
|
|
178
179
|
"row_id",
|
|
180
|
+
"after_row_id",
|
|
179
181
|
"row"
|
|
180
182
|
], `${timestamp(now)} ${transactionLabel(event.txids)} · ${rawChangeSummary(event.changes)}`, "Changes event contains no row changes.");
|
|
181
183
|
};
|
|
@@ -210,13 +212,14 @@ const renderHumanChanges = (out, event, rowsById, now) => {
|
|
|
210
212
|
const inserted = changes.filter((change) => change.operation === "+ insert");
|
|
211
213
|
const updated = changes.filter((change) => change.operation === "~ update");
|
|
212
214
|
const deleted = changes.filter((change) => change.operation === "- delete");
|
|
215
|
+
const moved = changes.filter((change) => change.operation === "↔ move");
|
|
213
216
|
const rowFieldsInChanges = rowFields(changes.flatMap((change) => change.row ? [change.row] : []));
|
|
214
217
|
const operationField = uniqueOperationField(rowFieldsInChanges);
|
|
215
218
|
const rows = changes.map((change) => ({
|
|
216
219
|
...change.row ?? {},
|
|
217
220
|
[operationField]: change.operation
|
|
218
221
|
}));
|
|
219
|
-
renderRows(out, rows, [operationField, ...rowFieldsInChanges], `${timestamp(now)} ${transactionLabel(event.txids)} · +${inserted.length} ~${updated.length} -${deleted.length}`, "Transaction contains no row changes.");
|
|
222
|
+
renderRows(out, rows, [operationField, ...rowFieldsInChanges], `${timestamp(now)} ${transactionLabel(event.txids)} · +${inserted.length} ~${updated.length} -${deleted.length}${moved.length ? ` ↔${moved.length}` : ""}`, "Transaction contains no row changes.");
|
|
220
223
|
};
|
|
221
224
|
const renderRows = (out, rows, fields, title, emptyMessage) => {
|
|
222
225
|
writer({
|
|
@@ -229,20 +232,29 @@ const renderRows = (out, rows, fields, title, emptyMessage) => {
|
|
|
229
232
|
if (rows.length === 0) out.write(`${emptyMessage}\n`);
|
|
230
233
|
};
|
|
231
234
|
const classifyChanges = (changes, rowsById) => changes.map((change) => {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
switch (change.type) {
|
|
236
|
+
case "upsert": {
|
|
237
|
+
const operation = rowsById.has(change.rowId) ? "~ update" : "+ insert";
|
|
238
|
+
rowsById.set(change.rowId, change.row);
|
|
239
|
+
return {
|
|
240
|
+
operation,
|
|
241
|
+
row: change.row
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
case "remove": {
|
|
245
|
+
const row = rowsById.get(change.rowId);
|
|
246
|
+
rowsById.delete(change.rowId);
|
|
247
|
+
return {
|
|
248
|
+
operation: "- delete",
|
|
249
|
+
...row ? { row } : {}
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
case "move": return {
|
|
253
|
+
operation: "↔ move",
|
|
254
|
+
row: rowsById.get(change.rowId)
|
|
238
255
|
};
|
|
256
|
+
default: throw new Error(`Unsupported Realtime change: ${change}`);
|
|
239
257
|
}
|
|
240
|
-
const row = rowsById.get(change.rowId);
|
|
241
|
-
rowsById.delete(change.rowId);
|
|
242
|
-
return {
|
|
243
|
-
operation: "- delete",
|
|
244
|
-
...row ? { row } : {}
|
|
245
|
-
};
|
|
246
258
|
});
|
|
247
259
|
const uniqueOperationField = (fields) => {
|
|
248
260
|
for (const candidate of [
|
|
@@ -260,8 +272,9 @@ const transactionLabel = (txids) => {
|
|
|
260
272
|
};
|
|
261
273
|
const rawChangeSummary = (changes) => {
|
|
262
274
|
const upserts = changes.filter((change) => change.type === "upsert").length;
|
|
263
|
-
const removals = changes.
|
|
264
|
-
|
|
275
|
+
const removals = changes.filter((change) => change.type === "remove").length;
|
|
276
|
+
const moves = changes.filter((change) => change.type === "move").length;
|
|
277
|
+
return `${upserts} upsert${upserts === 1 ? "" : "s"}, ${removals} removal${removals === 1 ? "" : "s"}${moves ? `, ${moves} move${moves === 1 ? "" : "s"}` : ""}`;
|
|
265
278
|
};
|
|
266
279
|
const rowCount = (count) => `${count} ${count === 1 ? "row" : "rows"}`;
|
|
267
280
|
const timestamp = (now) => `[${now().toISOString()}]`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "neon",
|
|
3
|
-
"version": "8.18.
|
|
3
|
+
"version": "8.18.1",
|
|
4
4
|
"description": "CLI tool for Neon, the cloud backend primitives built around Lakebase Postgres",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"neon",
|
|
@@ -73,10 +73,10 @@
|
|
|
73
73
|
"yaml": "^2.9.0",
|
|
74
74
|
"yargs": "17.7.2",
|
|
75
75
|
"yoctocolors": "^2.1.2",
|
|
76
|
-
"@neon/config-runtime": "1.11.
|
|
76
|
+
"@neon/config-runtime": "1.11.2",
|
|
77
77
|
"@neon/realtime": "0.1.2",
|
|
78
78
|
"@neon/sdk": "7.8.0",
|
|
79
|
-
"@neon/config": "1.10.
|
|
79
|
+
"@neon/config": "1.10.2"
|
|
80
80
|
},
|
|
81
81
|
"optionalDependencies": {
|
|
82
82
|
"@napi-rs/keyring": "1.3.0",
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
"typescript": "^5.9.0",
|
|
114
114
|
"vitest": "^3.0.9",
|
|
115
115
|
"@neon-internals/cli-core": "0.0.0",
|
|
116
|
-
"@neon-internals/env-core": "0.0.
|
|
116
|
+
"@neon-internals/env-core": "0.0.40",
|
|
117
117
|
"@neon/e2e-harness": "0.0.0",
|
|
118
|
-
"@neon/env": "1.6.
|
|
118
|
+
"@neon/env": "1.6.10",
|
|
119
119
|
"@neon/functions": "0.11.0"
|
|
120
120
|
},
|
|
121
121
|
"publishConfig": {
|