@sortlist/cli 0.34.0 → 0.35.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.
- package/package.json +4 -1
- package/src/commands/dynamic.ts +16 -3
- package/src/graphql/client.ts +3 -1
- package/src/graphql/generated/graphql.ts +391 -4132
- package/src/graphql/query-builder.ts +1 -1
- package/src/lib/browser.ts +8 -3
- package/src/lib/output.ts +0 -26
- package/src/lib/sentry.ts +0 -7
- package/src/lib/parse.ts +0 -8
- package/src/lib/sequence-buffer.ts +0 -95
|
@@ -38,7 +38,7 @@ const PAYLOAD_TYPE_PATTERN = /(?:Response|Payload|MutationPayload)$/;
|
|
|
38
38
|
// ── Selection set builder ──
|
|
39
39
|
|
|
40
40
|
export interface QueryOptions {
|
|
41
|
-
/** Max nesting depth for sub-objects (default:
|
|
41
|
+
/** Max nesting depth for sub-objects (default: 0) */
|
|
42
42
|
depth?: number;
|
|
43
43
|
/** Only include these fields (dot-notation for nested, e.g. "organization.name") */
|
|
44
44
|
fields?: string[];
|
package/src/lib/browser.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
2
|
|
|
3
3
|
export function openBrowser(url: string): void {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
if (process.platform === 'win32') {
|
|
5
|
+
// `start` is a cmd built-in; the empty string is the window title slot.
|
|
6
|
+
execFile('cmd', ['/c', 'start', '', url], () => {});
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const cmd = process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
10
|
+
execFile(cmd, [url], () => {});
|
|
6
11
|
}
|
package/src/lib/output.ts
CHANGED
|
@@ -10,7 +10,6 @@ const ansi = {
|
|
|
10
10
|
red: '\x1b[31m',
|
|
11
11
|
green: '\x1b[32m',
|
|
12
12
|
yellow: '\x1b[33m',
|
|
13
|
-
cyan: '\x1b[36m',
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
function c(code: keyof typeof ansi, text: string): string {
|
|
@@ -29,21 +28,6 @@ export function printJson(data: unknown): void {
|
|
|
29
28
|
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
// ── Table output (human-readable, no box-drawing characters) ──
|
|
33
|
-
|
|
34
|
-
export function printTable(headers: string[], rows: string[][]): void {
|
|
35
|
-
const colWidths = headers.map((h, i) => Math.max(h.length, ...rows.map((r) => (r[i] ?? '').length)));
|
|
36
|
-
|
|
37
|
-
const separator = colWidths.map((w) => '-'.repeat(w + 2)).join('+');
|
|
38
|
-
const formatRow = (row: string[]) => row.map((cell, i) => ` ${(cell ?? '').padEnd(colWidths[i])} `).join('|');
|
|
39
|
-
|
|
40
|
-
process.stdout.write(formatRow(headers) + '\n');
|
|
41
|
-
process.stdout.write(separator + '\n');
|
|
42
|
-
for (const row of rows) {
|
|
43
|
-
process.stdout.write(formatRow(row) + '\n');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
31
|
// ── Message helpers ──
|
|
48
32
|
// Every function uses a text prefix so status is conveyed independent of color.
|
|
49
33
|
// Color is enhancement only — never the sole status indicator.
|
|
@@ -72,13 +56,3 @@ export function error(msg: string): void {
|
|
|
72
56
|
export function hint(msg: string): void {
|
|
73
57
|
process.stderr.write(`${c('dim', ' ' + msg)}\n`);
|
|
74
58
|
}
|
|
75
|
-
|
|
76
|
-
/** Dim text (e.g. secondary details, IDs). */
|
|
77
|
-
export function dim(msg: string): void {
|
|
78
|
-
process.stderr.write(`${c('dim', msg)}\n`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Section heading for grouping output. */
|
|
82
|
-
export function heading(msg: string): void {
|
|
83
|
-
process.stderr.write(`\n${c('cyan', msg)}\n`);
|
|
84
|
-
}
|
package/src/lib/sentry.ts
CHANGED
|
@@ -55,13 +55,6 @@ export function captureException(error: unknown, extra?: Record<string, unknown>
|
|
|
55
55
|
Sentry.captureException(error, extra ? { extra } : undefined);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
export function setUser(user: { id?: string; email?: string }): void {
|
|
59
|
-
if (isLocalDev) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
Sentry.setUser(user);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
58
|
export function addBreadcrumb(breadcrumb: Sentry.Breadcrumb): void {
|
|
66
59
|
if (isLocalDev) {
|
|
67
60
|
return;
|
package/src/lib/parse.ts
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reorders out-of-sequence streaming events before they reach the event handler.
|
|
3
|
-
*
|
|
4
|
-
* Every subscription event carries an `agentLoopSequence` (monotonic integer starting
|
|
5
|
-
* at 1) and an `agentLoopId` (UUID constant for a single outer agent loop run). When
|
|
6
|
-
* an event arrives with a sequence higher than expected, it is buffered. If the
|
|
7
|
-
* expected event arrives within the timeout, all buffered events are flushed in order.
|
|
8
|
-
* If the timeout expires, the gap is marked as unrecoverable and buffered events are
|
|
9
|
-
* flushed anyway.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
const SEQUENCE_WAIT_MS = 1500;
|
|
13
|
-
|
|
14
|
-
export interface SequencedEvent {
|
|
15
|
-
agentLoopSequence?: number | null;
|
|
16
|
-
agentLoopId?: string | null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface SequenceBufferOptions<T extends SequencedEvent> {
|
|
20
|
-
onEvent: (event: T) => void;
|
|
21
|
-
onGap: (from: number, to: number) => void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export class SequenceBuffer<T extends SequencedEvent> {
|
|
25
|
-
private buffer = new Map<number, T>();
|
|
26
|
-
private expected = 1;
|
|
27
|
-
private timer: ReturnType<typeof setTimeout> | null = null;
|
|
28
|
-
private onEvent: (event: T) => void;
|
|
29
|
-
private onGap: (from: number, to: number) => void;
|
|
30
|
-
|
|
31
|
-
constructor({ onEvent, onGap }: SequenceBufferOptions<T>) {
|
|
32
|
-
this.onEvent = onEvent;
|
|
33
|
-
this.onGap = onGap;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
push(event: T): void {
|
|
37
|
-
const seq = event.agentLoopSequence;
|
|
38
|
-
|
|
39
|
-
// No sequence info — pass through (old server or non-sequenced event)
|
|
40
|
-
if (seq == null) {
|
|
41
|
-
this.onEvent(event);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (seq === this.expected) {
|
|
46
|
-
this.clearTimer();
|
|
47
|
-
this.onEvent(event);
|
|
48
|
-
this.expected++;
|
|
49
|
-
this.flush();
|
|
50
|
-
} else if (seq > this.expected) {
|
|
51
|
-
this.buffer.set(seq, event);
|
|
52
|
-
this.startTimer();
|
|
53
|
-
}
|
|
54
|
-
// seq < expected: duplicate, ignore
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
reset(): void {
|
|
58
|
-
this.buffer.clear();
|
|
59
|
-
this.expected = 1;
|
|
60
|
-
this.clearTimer();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private flush(): void {
|
|
64
|
-
while (this.buffer.has(this.expected)) {
|
|
65
|
-
const event = this.buffer.get(this.expected)!;
|
|
66
|
-
this.buffer.delete(this.expected);
|
|
67
|
-
this.onEvent(event);
|
|
68
|
-
this.expected++;
|
|
69
|
-
}
|
|
70
|
-
if (this.buffer.size > 0) {
|
|
71
|
-
this.startTimer();
|
|
72
|
-
} else {
|
|
73
|
-
this.clearTimer();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private startTimer(): void {
|
|
78
|
-
if (this.timer) return;
|
|
79
|
-
this.timer = setTimeout(() => {
|
|
80
|
-
this.timer = null;
|
|
81
|
-
const missing = this.expected;
|
|
82
|
-
const nextAvailable = Math.min(...this.buffer.keys());
|
|
83
|
-
this.onGap(missing, nextAvailable - 1);
|
|
84
|
-
this.expected = nextAvailable;
|
|
85
|
-
this.flush();
|
|
86
|
-
}, SEQUENCE_WAIT_MS);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
private clearTimer(): void {
|
|
90
|
-
if (this.timer) {
|
|
91
|
-
clearTimeout(this.timer);
|
|
92
|
-
this.timer = null;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
}
|