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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zinkee",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "CLI for Zinkee API v2",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,6 +27,7 @@ export interface RecordQueryInput {
27
27
  [key: string]: unknown;
28
28
  select?: string[];
29
29
  where?: RecordQueryExpression[];
30
+ search?: { term: string };
30
31
  sort?: string[];
31
32
  limit?: number;
32
33
  offset?: number;
@@ -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();
@@ -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", () => {
@@ -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" --limit 25 --raw '{"search":{"term":"garcia"}}'`,
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": [