@stndrds/cli 1.0.0-alpha.142 → 1.0.0-alpha.143
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/bin.mjs +13 -13
- package/package.json +1 -1
package/dist/bin.mjs
CHANGED
|
@@ -277,18 +277,18 @@ function registerKeysCommand(program) {
|
|
|
277
277
|
// src/commands/records.ts
|
|
278
278
|
function parseSortFlag(sort) {
|
|
279
279
|
const [attribute, direction = "asc"] = sort.split(":");
|
|
280
|
-
return
|
|
280
|
+
return [{ attribute, direction }];
|
|
281
281
|
}
|
|
282
282
|
function registerRecordsCommand(program) {
|
|
283
283
|
const records = program.command("records").description("Manage records (CRUD + search)");
|
|
284
284
|
records.command("list").description("List records for an object").argument("<object>", "object name (e.g. contacts)").option("--limit <n>", "max records to return").option("--offset <n>", "number of records to skip").option("--sort <sort>", 'sort rule as "attribute:direction"').option("--filter <json>", "filter state as JSON string").action(async (objectName, opts, cmd) => {
|
|
285
285
|
const client = getClientFromCommand(cmd);
|
|
286
|
-
const
|
|
287
|
-
if (opts.limit)
|
|
288
|
-
if (opts.offset)
|
|
289
|
-
if (opts.sort)
|
|
290
|
-
if (opts.filter)
|
|
291
|
-
const result = await client.
|
|
286
|
+
const body = {};
|
|
287
|
+
if (opts.limit) body.limit = Number(opts.limit);
|
|
288
|
+
if (opts.offset) body.offset = Number(opts.offset);
|
|
289
|
+
if (opts.sort) body.sorts = parseSortFlag(opts.sort);
|
|
290
|
+
if (opts.filter) body.filters = JSON.parse(opts.filter);
|
|
291
|
+
const result = await client.post(`/records/${objectName}/list`, body);
|
|
292
292
|
formatOutput(result, getFormat(cmd));
|
|
293
293
|
});
|
|
294
294
|
records.command("get").description("Get a record by ID").argument("<object>", "object name").argument("<id>", "record ID").action(async (objectName, id, _opts, cmd) => {
|
|
@@ -316,12 +316,12 @@ function registerRecordsCommand(program) {
|
|
|
316
316
|
});
|
|
317
317
|
records.command("search").description("Full-text search records").argument("<object>", "object name").requiredOption("--query <q>", "search query string").option("--limit <n>", "max records to return").option("--offset <n>", "number of records to skip").option("--sort <sort>", 'sort rule as "attribute:direction"').option("--filter <json>", "filter state as JSON string").action(async (objectName, opts, cmd) => {
|
|
318
318
|
const client = getClientFromCommand(cmd);
|
|
319
|
-
const
|
|
320
|
-
if (opts.limit)
|
|
321
|
-
if (opts.offset)
|
|
322
|
-
if (opts.sort)
|
|
323
|
-
if (opts.filter)
|
|
324
|
-
const result = await client.
|
|
319
|
+
const body = { q: opts.query };
|
|
320
|
+
if (opts.limit) body.limit = Number(opts.limit);
|
|
321
|
+
if (opts.offset) body.offset = Number(opts.offset);
|
|
322
|
+
if (opts.sort) body.sorts = parseSortFlag(opts.sort);
|
|
323
|
+
if (opts.filter) body.filters = JSON.parse(opts.filter);
|
|
324
|
+
const result = await client.post(`/records/${objectName}/search`, body);
|
|
325
325
|
formatOutput(result, getFormat(cmd));
|
|
326
326
|
});
|
|
327
327
|
}
|