omgbase 0.30.3 → 0.31.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/dist/build-info.json +2 -2
- package/dist/src/cmd/oqx.js +2 -2
- package/dist/src/output.d.ts +9 -2
- package/dist/src/output.js +12 -0
- package/package.json +4 -4
package/dist/build-info.json
CHANGED
package/dist/src/cmd/oqx.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
3
|
import { oqxRun, oqxRunAsync, collectSemanticPhrases } from "@omgbase/core";
|
|
4
|
-
import { truncationFooter, CliUsageError, EngineErrorLike, EXIT_OK, emitMachine, renderHelp, renderHits, renderBareHits } from "../output.js";
|
|
4
|
+
import { truncationFooter, CliUsageError, EngineErrorLike, EXIT_OK, emitMachine, renderHelp, renderHits, renderBareHits, hasEnvelope } from "../output.js";
|
|
5
5
|
import { loadEmbedding } from "./_embed.js";
|
|
6
6
|
import { remoteCall } from "./_remote.js";
|
|
7
7
|
import { readStdin } from "./_mutate.js";
|
|
@@ -171,7 +171,7 @@ export function renderOqxResult(cli, result, bare = false) {
|
|
|
171
171
|
const list = result.values ?? (result.consumer === "collect" || result.consumer === "first" || result.consumer === "single" ? result.hits : undefined);
|
|
172
172
|
return emitMachine(cli, result, {
|
|
173
173
|
...(list ? { items: list } : {}),
|
|
174
|
-
...(list && !result.values && !bare ? { ids: result.hits.map((h) => h._id) } : {}),
|
|
174
|
+
...(list && !result.values && !bare && hasEnvelope(result.hits) ? { ids: result.hits.map((h) => h._id) } : {}),
|
|
175
175
|
cursor,
|
|
176
176
|
});
|
|
177
177
|
}
|
package/dist/src/output.d.ts
CHANGED
|
@@ -82,11 +82,18 @@ interface MachineIO {
|
|
|
82
82
|
}
|
|
83
83
|
/** Print `doc` in the current machine mode (`--json`/`--jsonl`/`--ids`); returns EXIT_OK. */
|
|
84
84
|
export declare function emitMachine(cli: MachineIO, doc: unknown, shape?: MachineShape): number;
|
|
85
|
+
/** `_id`/`_path` are optional: a grouped row (spec/surface §1.4) carries
|
|
86
|
+
* neither — "a grouped row is not a store row" — so every renderer below
|
|
87
|
+
* must check before assuming the envelope. */
|
|
85
88
|
export interface HitLike {
|
|
86
|
-
_id
|
|
87
|
-
_path
|
|
89
|
+
_id?: string;
|
|
90
|
+
_path?: string;
|
|
88
91
|
[k: string]: unknown;
|
|
89
92
|
}
|
|
93
|
+
/** Does every hit carry the store envelope (`_id`/`_path`)? False for a
|
|
94
|
+
* grouped query's hits (spec/surface §1.4) — empty counts as enveloped
|
|
95
|
+
* (nothing to contradict it), matching the bare-render decision below. */
|
|
96
|
+
export declare function hasEnvelope(hits: readonly HitLike[]): boolean;
|
|
90
97
|
export declare const HIT_CELL_MAX = 60;
|
|
91
98
|
/** Clip `s` to `max` visible characters, marking the cut with `…`. */
|
|
92
99
|
export declare function truncateCell(s: string, max?: number): string;
|
package/dist/src/output.js
CHANGED
|
@@ -171,6 +171,12 @@ function indent(s, pad) {
|
|
|
171
171
|
.map((l) => pad + l)
|
|
172
172
|
.join("\n");
|
|
173
173
|
}
|
|
174
|
+
/** Does every hit carry the store envelope (`_id`/`_path`)? False for a
|
|
175
|
+
* grouped query's hits (spec/surface §1.4) — empty counts as enveloped
|
|
176
|
+
* (nothing to contradict it), matching the bare-render decision below. */
|
|
177
|
+
export function hasEnvelope(hits) {
|
|
178
|
+
return hits.every((h) => h._id !== undefined);
|
|
179
|
+
}
|
|
174
180
|
export const HIT_CELL_MAX = 60;
|
|
175
181
|
/** Clip `s` to `max` visible characters, marking the cut with `…`. */
|
|
176
182
|
export function truncateCell(s, max = HIT_CELL_MAX) {
|
|
@@ -211,8 +217,14 @@ export function hitColumns(hits) {
|
|
|
211
217
|
* (header `_id`, `_path`, then the projected keys — spec/cli §4, 5.0). */
|
|
212
218
|
export function renderHits(cli, hits) {
|
|
213
219
|
const { io, style } = cli;
|
|
220
|
+
// A grouped query's hits carry no envelope at all (spec/surface §1.4) — the
|
|
221
|
+
// projection-only table is the only correct rendering for them, same as
|
|
222
|
+
// `--bare` chooses explicitly for an enveloped result.
|
|
223
|
+
if (!hasEnvelope(hits))
|
|
224
|
+
return renderBareHits(cli, hits);
|
|
214
225
|
const projected = hitColumns(hits);
|
|
215
226
|
if (projected.length === 0) {
|
|
227
|
+
// hasEnvelope guarantees every hit's `_id`/`_path` are defined here.
|
|
216
228
|
for (const h of hits)
|
|
217
229
|
io.out(`${style.id(h._id)} ${style.accent(h._path)}`.trimEnd());
|
|
218
230
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omgbase",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0",
|
|
4
4
|
"description": "Open Markdown Graph Base — CLI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"omg": "./dist/src/main.js"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@omgbase/core": "^0.
|
|
48
|
+
"@omgbase/core": "^0.36.0",
|
|
49
49
|
"@omgbase/fs-adapter": "^0.2.0",
|
|
50
|
-
"@omgbase/git-adapter": "^0.1.
|
|
51
|
-
"@omgbase/sync": "^0.7.
|
|
50
|
+
"@omgbase/git-adapter": "^0.1.5",
|
|
51
|
+
"@omgbase/sync": "^0.7.8",
|
|
52
52
|
"yaml": "^2.9.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|