zinkee 0.1.26 → 0.1.27
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 +3 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/api/records.ts +1 -0
- package/src/commands/records.test.ts +40 -0
- package/src/commands/records.ts +9 -0
- package/src/utils/examples.test.ts +6 -0
- package/src/utils/examples.ts +1 -1
package/package.json
CHANGED
package/src/api/records.ts
CHANGED
|
@@ -196,6 +196,46 @@ describe("records commands", () => {
|
|
|
196
196
|
});
|
|
197
197
|
});
|
|
198
198
|
|
|
199
|
+
it("maps --search to a search.term object in the query body", async () => {
|
|
200
|
+
const configPath = createApiConfig();
|
|
201
|
+
const output = createStdoutBuffer();
|
|
202
|
+
const fetchMock = createFetchMock();
|
|
203
|
+
mockSchemaLookup(fetchMock);
|
|
204
|
+
fetchMock.mockResolvedValueOnce(
|
|
205
|
+
jsonResponse({
|
|
206
|
+
records: [{ recordId: "record-1", values: { name: "Ana Garcia" } }],
|
|
207
|
+
page: { offset: 0, limit: 25, total: 1, count: 1, hasMore: false },
|
|
208
|
+
}),
|
|
209
|
+
);
|
|
210
|
+
const program = buildProgram({ configPath, stdout: output.stdout });
|
|
211
|
+
|
|
212
|
+
await program.parseAsync([
|
|
213
|
+
"node",
|
|
214
|
+
"zinkee",
|
|
215
|
+
"--json",
|
|
216
|
+
"records",
|
|
217
|
+
"query",
|
|
218
|
+
"contacts",
|
|
219
|
+
"--select",
|
|
220
|
+
"id,name,status",
|
|
221
|
+
"--where",
|
|
222
|
+
"status in OPEN",
|
|
223
|
+
"--search",
|
|
224
|
+
"garcia",
|
|
225
|
+
"--limit",
|
|
226
|
+
"25",
|
|
227
|
+
]);
|
|
228
|
+
|
|
229
|
+
const init = fetchMock.mock.calls[1]?.[1];
|
|
230
|
+
|
|
231
|
+
expect(JSON.parse(String(init?.body))).toEqual({
|
|
232
|
+
select: ["id", "name", "status"],
|
|
233
|
+
where: [{ field: "status", op: "in", value: ["OPEN"] }],
|
|
234
|
+
search: { term: "garcia" },
|
|
235
|
+
page: { limit: 25 },
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
|
|
199
239
|
it("normalizes UUID selectors for records get", async () => {
|
|
200
240
|
const configPath = createApiConfig();
|
|
201
241
|
const output = createStdoutBuffer();
|
package/src/commands/records.ts
CHANGED
|
@@ -48,6 +48,7 @@ interface GlobalOptions extends RuntimeOverrides {}
|
|
|
48
48
|
interface RecordsQueryCommandOptions {
|
|
49
49
|
select?: string[];
|
|
50
50
|
where?: ParsedExpression[];
|
|
51
|
+
search?: string;
|
|
51
52
|
sort?: string[];
|
|
52
53
|
limit?: number;
|
|
53
54
|
offset?: number;
|
|
@@ -375,6 +376,10 @@ function buildRecordQueryInput(
|
|
|
375
376
|
input.where = where;
|
|
376
377
|
}
|
|
377
378
|
|
|
379
|
+
if (options.search !== undefined) {
|
|
380
|
+
input.search = { term: options.search };
|
|
381
|
+
}
|
|
382
|
+
|
|
378
383
|
if (options.sort && options.sort.length > 0) {
|
|
379
384
|
input.sort = [...options.sort];
|
|
380
385
|
}
|
|
@@ -577,6 +582,10 @@ export function registerRecordsCommands(
|
|
|
577
582
|
parseCommaSeparatedValues(value, "--select")
|
|
578
583
|
))
|
|
579
584
|
.option("--where <expression>", "where expression", collectWhereExpressions, [])
|
|
585
|
+
.option(
|
|
586
|
+
"--search <term>",
|
|
587
|
+
"free-text search term (matched across the schema's searchable fields)",
|
|
588
|
+
)
|
|
580
589
|
.option("--sort <field:direction>", "sort field(s)", collectSortValues, [])
|
|
581
590
|
.option("--limit <number>", "limit results", parseNonNegativeInteger)
|
|
582
591
|
.option("--offset <number>", "offset results", parseNonNegativeInteger)
|
|
@@ -9,6 +9,12 @@ describe("getCommandExamples", () => {
|
|
|
9
9
|
|
|
10
10
|
expect(examples.length).toBeGreaterThan(0);
|
|
11
11
|
expect(examples[0]?.command).toContain("records query");
|
|
12
|
+
|
|
13
|
+
const searchExample = examples.find((example) =>
|
|
14
|
+
example.command.includes("--search"),
|
|
15
|
+
);
|
|
16
|
+
expect(searchExample?.command).toContain("--search garcia");
|
|
17
|
+
expect(searchExample?.raw).toContain('"search": { "term": "garcia" }');
|
|
12
18
|
});
|
|
13
19
|
|
|
14
20
|
it("returns fallback examples for simple commands", () => {
|
package/src/utils/examples.ts
CHANGED
|
@@ -502,7 +502,7 @@ const specificExamples: Record<string, readonly CommandExample[]> = {
|
|
|
502
502
|
{
|
|
503
503
|
description: "Filter by status with a free-text search term.",
|
|
504
504
|
command:
|
|
505
|
-
`zinkee --json records query contacts --select id,contact-name,status --where "status in OPEN" --
|
|
505
|
+
`zinkee --json records query contacts --select id,contact-name,status --where "status in OPEN" --search garcia --limit 25`,
|
|
506
506
|
raw: `{
|
|
507
507
|
"select": ["id", "contact-name", "status"],
|
|
508
508
|
"where": [
|