@apotech-os/cli 2.3.0 → 2.4.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/README.md +19 -0
- package/dist/index.js +321 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -77,6 +77,25 @@ WOPILO_API_KEY=$SECRET apotech-os deploy --remote production
|
|
|
77
77
|
| `apotech-os app:install --remote <name>` | Install/upgrade a published version |
|
|
78
78
|
| `apotech-os remote add --url <url> --as <name>` | Register a remote |
|
|
79
79
|
| `apotech-os login --remote <name>` | Obtain and store an API key |
|
|
80
|
+
| `apotech-os data objects` | List the objects the explorer can query |
|
|
81
|
+
| `apotech-os data schema <app>/<object>` | Fields, types, required and indexed flags |
|
|
82
|
+
| `apotech-os data list <app>/<object>` | Read rows, with `--filter` / `--sort` / `--json` |
|
|
83
|
+
| `apotech-os data count <app>/<object>` | Count rows matching a filter |
|
|
84
|
+
|
|
85
|
+
The `data` group is strictly read-only. It needs a key **linked to a user**
|
|
86
|
+
(`apotech-os login`, not a key pasted from the admin UI) whose platform role is
|
|
87
|
+
**ADMIN** — it reads raw rows across every app space. Core objects are addressed
|
|
88
|
+
under the reserved slug `_core`:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
apotech-os data list _core/shopify-order --filter '{"name":{"contains":"1001"}}' --json
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
`--filter` / `--search` / `--sort` are the server's own JSON grammar, passed
|
|
95
|
+
through untouched; operators are `eq neq contains ncontains gt lt gte lte empty
|
|
96
|
+
nempty`. `--limit` is a total row count (default 50, max 1000) — the command
|
|
97
|
+
pages for you. `--json` prints the raw `{items, nextCursor}` envelope, which is
|
|
98
|
+
what a script or an agent should read.
|
|
80
99
|
|
|
81
100
|
`app:upgrade` is an alias of `app:install` — an upgrade is just an install at a
|
|
82
101
|
higher version. `app:build` / `app:publish` / `app:install` are the discrete
|
package/dist/index.js
CHANGED
|
@@ -22895,7 +22895,16 @@ var FunctionDefFieldsSchema = external_exports.object({
|
|
|
22895
22895
|
* function without them behaves identically, its card simply stays empty.
|
|
22896
22896
|
*/
|
|
22897
22897
|
when: external_exports.string().min(1).describe('Human "quand" narrative \u2014 what makes this function run (UI only).').optional(),
|
|
22898
|
-
then: external_exports.string().min(1).describe('Human "alors" narrative \u2014 what this function does when it runs (UI only).').optional()
|
|
22898
|
+
then: external_exports.string().min(1).describe('Human "alors" narrative \u2014 what this function does when it runs (UI only).').optional(),
|
|
22899
|
+
/**
|
|
22900
|
+
* Opt-in projection of this function as an agent tool. Only meaningful on a
|
|
22901
|
+
* `uiInvoke` function — enforced by `checkManifestSemantics`, not a Zod
|
|
22902
|
+
* refinement, so a manifest already persisted with this field keeps parsing.
|
|
22903
|
+
* `description` is the tool's documentation surfaced to the calling agent.
|
|
22904
|
+
*/
|
|
22905
|
+
agentTool: external_exports.object({
|
|
22906
|
+
description: external_exports.string().min(1)
|
|
22907
|
+
}).optional()
|
|
22899
22908
|
});
|
|
22900
22909
|
var FunctionDefSchema = FunctionDefFieldsSchema.superRefine((fn, ctx) => {
|
|
22901
22910
|
if (fn.input && fn.trigger.type !== "uiInvoke" && fn.trigger.type !== "httpRoute") {
|
|
@@ -22963,7 +22972,13 @@ var AppRoleSchema = external_exports.object({
|
|
|
22963
22972
|
* Unlike `reads`/`writes`, entries here are EXPECTED to name a foreign app —
|
|
22964
22973
|
* `findForeignRoleRefs` does not (and must not) inspect this field.
|
|
22965
22974
|
*/
|
|
22966
|
-
calls: external_exports.array(external_exports.string()).optional()
|
|
22975
|
+
calls: external_exports.array(external_exports.string()).optional(),
|
|
22976
|
+
/**
|
|
22977
|
+
* Agent slugs the app is allowed to invoke via ctx.api.agents.invoke().
|
|
22978
|
+
* '*' grants access to all agents (wildcard). Requires role.capabilities to
|
|
22979
|
+
* include 'agents' — checked by `checkManifestSemantics`, not by this schema.
|
|
22980
|
+
*/
|
|
22981
|
+
agents: external_exports.array(external_exports.string()).optional()
|
|
22967
22982
|
});
|
|
22968
22983
|
var UI_ENTRY_REGEX = /^dist\/ui\/[A-Za-z0-9_-]+\.js$/;
|
|
22969
22984
|
var PageDefSchema = external_exports.object({
|
|
@@ -23531,6 +23546,18 @@ function checkManifestSemantics(manifest) {
|
|
|
23531
23546
|
`functions."${fn.name}".onFailure: "${fn.onFailure}" is not declared in manifest.emits. onFailure travels on the app custom-event bus; naming an integration or platform event would re-invoke that handler with a failure payload.`
|
|
23532
23547
|
);
|
|
23533
23548
|
}
|
|
23549
|
+
if (fn.agentTool !== void 0 && fn.trigger.type !== "uiInvoke") {
|
|
23550
|
+
errors.push(`function '${fn.name}': agentTool requires a uiInvoke trigger`);
|
|
23551
|
+
}
|
|
23552
|
+
}
|
|
23553
|
+
const role = manifest.role;
|
|
23554
|
+
const hasAgentsAllowlist = (role?.agents ?? []).length > 0;
|
|
23555
|
+
const hasAgentsCapability = (role?.capabilities ?? []).includes("agents");
|
|
23556
|
+
if (hasAgentsAllowlist && !hasAgentsCapability) {
|
|
23557
|
+
errors.push("role.agents requires role.capabilities to include 'agents'");
|
|
23558
|
+
}
|
|
23559
|
+
if (hasAgentsCapability && !hasAgentsAllowlist) {
|
|
23560
|
+
errors.push("role.capabilities includes 'agents' but role.agents is empty");
|
|
23534
23561
|
}
|
|
23535
23562
|
return errors;
|
|
23536
23563
|
}
|
|
@@ -23957,6 +23984,38 @@ async function triggerJob(opts) {
|
|
|
23957
23984
|
opts.apiKey
|
|
23958
23985
|
);
|
|
23959
23986
|
}
|
|
23987
|
+
async function fetchDataModel(opts) {
|
|
23988
|
+
return getJson(opts.baseUrl, "/platform/data-model", void 0, opts.apiKey);
|
|
23989
|
+
}
|
|
23990
|
+
function explorerPath(target, leaf) {
|
|
23991
|
+
return `/platform/data-explorer/${encodeURIComponent(target.appSlug)}/${encodeURIComponent(
|
|
23992
|
+
target.objectKey
|
|
23993
|
+
)}/${leaf}`;
|
|
23994
|
+
}
|
|
23995
|
+
async function fetchObjectMeta(target) {
|
|
23996
|
+
return getJson(
|
|
23997
|
+
target.baseUrl,
|
|
23998
|
+
explorerPath(target, "meta"),
|
|
23999
|
+
void 0,
|
|
24000
|
+
target.apiKey
|
|
24001
|
+
);
|
|
24002
|
+
}
|
|
24003
|
+
async function fetchRecords(opts) {
|
|
24004
|
+
const params = new URLSearchParams();
|
|
24005
|
+
if (opts.cursor) params.set("cursor", opts.cursor);
|
|
24006
|
+
if (opts.limit !== void 0) params.set("limit", String(opts.limit));
|
|
24007
|
+
if (opts.id) params.set("id", opts.id);
|
|
24008
|
+
if (opts.filter) params.set("filter", opts.filter);
|
|
24009
|
+
if (opts.search) params.set("search", opts.search);
|
|
24010
|
+
if (opts.sort) params.set("sort", opts.sort);
|
|
24011
|
+
return getJson(opts.baseUrl, explorerPath(opts, "records"), params, opts.apiKey);
|
|
24012
|
+
}
|
|
24013
|
+
async function countRecords(opts) {
|
|
24014
|
+
const params = new URLSearchParams();
|
|
24015
|
+
if (opts.filter) params.set("filter", opts.filter);
|
|
24016
|
+
if (opts.search) params.set("search", opts.search);
|
|
24017
|
+
return getJson(opts.baseUrl, explorerPath(opts, "count"), params, opts.apiKey);
|
|
24018
|
+
}
|
|
23960
24019
|
async function getJson(baseUrl, path, params, apiKey) {
|
|
23961
24020
|
const query = params?.toString();
|
|
23962
24021
|
const url2 = `${baseUrl.replace(/\/$/, "")}${path}${query ? `?${query}` : ""}`;
|
|
@@ -24906,6 +24965,15 @@ function buildLogsCommand() {
|
|
|
24906
24965
|
});
|
|
24907
24966
|
}
|
|
24908
24967
|
|
|
24968
|
+
// src/table.ts
|
|
24969
|
+
function renderTable(headers, rows) {
|
|
24970
|
+
const widths = headers.map(
|
|
24971
|
+
(header, i) => Math.max(header.length, ...rows.map((row) => (row[i] ?? "").length))
|
|
24972
|
+
);
|
|
24973
|
+
const renderRow = (cells) => cells.map((cell, i) => cell.padEnd(widths[i] ?? 0)).join(" ").trimEnd();
|
|
24974
|
+
return [renderRow(headers), ...rows.map(renderRow)].join("\n");
|
|
24975
|
+
}
|
|
24976
|
+
|
|
24909
24977
|
// src/commands/runs-start.ts
|
|
24910
24978
|
var import_fs8 = require("fs");
|
|
24911
24979
|
var RUN_LOOKUP_INTERVAL_MS = 1e3;
|
|
@@ -25268,13 +25336,6 @@ function triggerLabel(run) {
|
|
|
25268
25336
|
if (run.eventName) return run.eventName;
|
|
25269
25337
|
return "-";
|
|
25270
25338
|
}
|
|
25271
|
-
function renderTable(headers, rows) {
|
|
25272
|
-
const widths = headers.map(
|
|
25273
|
-
(header, i) => Math.max(header.length, ...rows.map((row) => (row[i] ?? "").length))
|
|
25274
|
-
);
|
|
25275
|
-
const renderRow = (cells) => cells.map((cell, i) => cell.padEnd(widths[i] ?? 0)).join(" ").trimEnd();
|
|
25276
|
-
return [renderRow(headers), ...rows.map(renderRow)].join("\n");
|
|
25277
|
-
}
|
|
25278
25339
|
function renderRunsTable(runs) {
|
|
25279
25340
|
if (runs.length === 0) return "No runs found.";
|
|
25280
25341
|
const headers = ["STATUS", "RUN ID", "APP/FUNCTION", "TRIGGER", "STARTED", "DURATION"];
|
|
@@ -25368,6 +25429,256 @@ function buildRunsCommand() {
|
|
|
25368
25429
|
return runs;
|
|
25369
25430
|
}
|
|
25370
25431
|
|
|
25432
|
+
// src/commands/data.ts
|
|
25433
|
+
var CORE_SLUG = "_core";
|
|
25434
|
+
var DEFAULT_LIMIT = 50;
|
|
25435
|
+
var MAX_LIMIT = 1e3;
|
|
25436
|
+
var SERVER_PAGE_MAX = 100;
|
|
25437
|
+
var MAX_TABLE_COLUMNS = 6;
|
|
25438
|
+
var MAX_CELL_WIDTH = 40;
|
|
25439
|
+
var TOP_LEVEL_COLUMNS = ["id", "coreRefId", "createdAt", "updatedAt"];
|
|
25440
|
+
function resolveTransport(opts) {
|
|
25441
|
+
return {
|
|
25442
|
+
baseUrl: opts.remote ? getRemoteUrl(opts.remote) : DEFAULT_REMOTE_URL,
|
|
25443
|
+
apiKey: resolveApiKey(opts.remote)
|
|
25444
|
+
};
|
|
25445
|
+
}
|
|
25446
|
+
function fail2(code, ...lines) {
|
|
25447
|
+
for (const line of lines) console.error(line);
|
|
25448
|
+
process.exit(code);
|
|
25449
|
+
}
|
|
25450
|
+
function parseTarget2(target) {
|
|
25451
|
+
const [appSlug, objectKey, ...rest] = target.split("/");
|
|
25452
|
+
if (!appSlug || !objectKey || rest.length > 0) {
|
|
25453
|
+
fail2(
|
|
25454
|
+
2,
|
|
25455
|
+
`Error: expected <appSlug>/<objectKey>, got "${target}".`,
|
|
25456
|
+
`Core objects live under "${CORE_SLUG}", e.g. ${CORE_SLUG}/shopify-order.`
|
|
25457
|
+
);
|
|
25458
|
+
}
|
|
25459
|
+
return { appSlug, objectKey };
|
|
25460
|
+
}
|
|
25461
|
+
function requireJson(raw, flag, shape) {
|
|
25462
|
+
let parsed;
|
|
25463
|
+
try {
|
|
25464
|
+
parsed = JSON.parse(raw);
|
|
25465
|
+
} catch (err) {
|
|
25466
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
25467
|
+
fail2(2, `Error: ${flag} is not valid JSON: ${detail}`);
|
|
25468
|
+
}
|
|
25469
|
+
const ok = shape === "array" ? Array.isArray(parsed) : typeof parsed === "object" && parsed !== null && !Array.isArray(parsed);
|
|
25470
|
+
if (!ok) {
|
|
25471
|
+
fail2(2, `Error: ${flag} must be a JSON ${shape}.`);
|
|
25472
|
+
}
|
|
25473
|
+
return raw;
|
|
25474
|
+
}
|
|
25475
|
+
function parseLimit(raw) {
|
|
25476
|
+
const limit = Number(raw);
|
|
25477
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_LIMIT) {
|
|
25478
|
+
fail2(2, `Error: --limit must be an integer between 1 and ${MAX_LIMIT}, got "${raw}".`);
|
|
25479
|
+
}
|
|
25480
|
+
return limit;
|
|
25481
|
+
}
|
|
25482
|
+
function parseFields(raw) {
|
|
25483
|
+
const fields = raw.split(",").map((field) => field.trim()).filter((field) => field.length > 0);
|
|
25484
|
+
if (fields.length === 0) {
|
|
25485
|
+
fail2(2, "Error: --fields must name at least one column.");
|
|
25486
|
+
}
|
|
25487
|
+
return fields;
|
|
25488
|
+
}
|
|
25489
|
+
function buildObjectsCommand() {
|
|
25490
|
+
return new Command("objects").description("List the objects the explorer can query (core + app)").option("--app <slug>", `Only this app's objects ("${CORE_SLUG}" for core)`).option("--json", "Output the raw response as JSON").option("--remote <name>", "Named remote server to target").action(async (opts) => {
|
|
25491
|
+
const { baseUrl, apiKey } = resolveTransport(opts);
|
|
25492
|
+
try {
|
|
25493
|
+
const model = await fetchDataModel({ baseUrl, apiKey });
|
|
25494
|
+
const objects = model.groups.filter((group) => group.kind === "core" || group.kind === "app").flatMap(
|
|
25495
|
+
(group) => group.objects.map((object2) => ({
|
|
25496
|
+
appSlug: group.kind === "core" ? CORE_SLUG : group.owner,
|
|
25497
|
+
objectKey: object2.key,
|
|
25498
|
+
owner: group.label,
|
|
25499
|
+
fieldCount: object2.fields.length,
|
|
25500
|
+
coreRef: object2.coreRef ?? null
|
|
25501
|
+
}))
|
|
25502
|
+
).filter((object2) => !opts.app || object2.appSlug === opts.app);
|
|
25503
|
+
if (opts.json) {
|
|
25504
|
+
console.log(JSON.stringify({ objects }));
|
|
25505
|
+
return;
|
|
25506
|
+
}
|
|
25507
|
+
if (objects.length === 0) {
|
|
25508
|
+
console.log(opts.app ? `No queryable objects for "${opts.app}".` : "No objects found.");
|
|
25509
|
+
return;
|
|
25510
|
+
}
|
|
25511
|
+
console.log(
|
|
25512
|
+
renderTable(
|
|
25513
|
+
["OBJECT", "OWNER", "FIELDS", "CORE REF"],
|
|
25514
|
+
objects.map((object2) => [
|
|
25515
|
+
`${object2.appSlug}/${object2.objectKey}`,
|
|
25516
|
+
object2.owner,
|
|
25517
|
+
String(object2.fieldCount),
|
|
25518
|
+
object2.coreRef ?? "-"
|
|
25519
|
+
])
|
|
25520
|
+
)
|
|
25521
|
+
);
|
|
25522
|
+
} catch (err) {
|
|
25523
|
+
reportApiError(err);
|
|
25524
|
+
}
|
|
25525
|
+
});
|
|
25526
|
+
}
|
|
25527
|
+
function schemaType(definition) {
|
|
25528
|
+
if (typeof definition !== "object" || definition === null) return "any";
|
|
25529
|
+
const def = definition;
|
|
25530
|
+
const type = def["type"];
|
|
25531
|
+
if (typeof type === "string") return type;
|
|
25532
|
+
if (Array.isArray(type)) return type.map(String).join("|");
|
|
25533
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
25534
|
+
const variants = def[key];
|
|
25535
|
+
if (Array.isArray(variants)) {
|
|
25536
|
+
const types = [...new Set(variants.map((variant) => schemaType(variant)))];
|
|
25537
|
+
if (types.length > 0) return types.join("|");
|
|
25538
|
+
}
|
|
25539
|
+
}
|
|
25540
|
+
if (Array.isArray(def["enum"])) return "enum";
|
|
25541
|
+
return "any";
|
|
25542
|
+
}
|
|
25543
|
+
function buildSchemaCommand() {
|
|
25544
|
+
return new Command("schema").description("Show the declared fields of one object").argument("<target>", `<appSlug>/<objectKey> (e.g. ${CORE_SLUG}/shopify-order)`).option("--json", "Output the raw response as JSON").option("--remote <name>", "Named remote server to target").action(async (target, opts) => {
|
|
25545
|
+
const { appSlug, objectKey } = parseTarget2(target);
|
|
25546
|
+
const { baseUrl, apiKey } = resolveTransport(opts);
|
|
25547
|
+
try {
|
|
25548
|
+
const meta3 = await fetchObjectMeta({ baseUrl, apiKey, appSlug, objectKey });
|
|
25549
|
+
if (opts.json) {
|
|
25550
|
+
console.log(JSON.stringify(meta3));
|
|
25551
|
+
return;
|
|
25552
|
+
}
|
|
25553
|
+
const properties = meta3.jsonSchema["properties"] ?? {};
|
|
25554
|
+
const required2 = new Set(
|
|
25555
|
+
Array.isArray(meta3.jsonSchema["required"]) ? meta3.jsonSchema["required"].map(String) : []
|
|
25556
|
+
);
|
|
25557
|
+
const indexed = new Set(meta3.indexedFields);
|
|
25558
|
+
const entries = Object.entries(properties);
|
|
25559
|
+
if (entries.length === 0) {
|
|
25560
|
+
console.log(`Object "${appSlug}/${objectKey}" declares no fields.`);
|
|
25561
|
+
return;
|
|
25562
|
+
}
|
|
25563
|
+
console.log(
|
|
25564
|
+
renderTable(
|
|
25565
|
+
["FIELD", "TYPE", "REQUIRED", "INDEXED"],
|
|
25566
|
+
entries.map(([name, definition]) => [
|
|
25567
|
+
name,
|
|
25568
|
+
schemaType(definition),
|
|
25569
|
+
required2.has(name) ? "yes" : "no",
|
|
25570
|
+
indexed.has(name) ? "yes" : "no"
|
|
25571
|
+
])
|
|
25572
|
+
)
|
|
25573
|
+
);
|
|
25574
|
+
} catch (err) {
|
|
25575
|
+
reportApiError(err);
|
|
25576
|
+
}
|
|
25577
|
+
});
|
|
25578
|
+
}
|
|
25579
|
+
function chooseColumns(items, fields) {
|
|
25580
|
+
if (fields) return fields;
|
|
25581
|
+
const head = ["id", "createdAt"];
|
|
25582
|
+
const dataFields = Object.keys(items[0]?.data ?? {}).slice(0, MAX_TABLE_COLUMNS - head.length);
|
|
25583
|
+
return [...head, ...dataFields];
|
|
25584
|
+
}
|
|
25585
|
+
function cellValue(row, column) {
|
|
25586
|
+
if (TOP_LEVEL_COLUMNS.includes(column)) {
|
|
25587
|
+
return row[column];
|
|
25588
|
+
}
|
|
25589
|
+
return row.data[column];
|
|
25590
|
+
}
|
|
25591
|
+
function formatCell(value) {
|
|
25592
|
+
if (value === null || value === void 0) return "-";
|
|
25593
|
+
const raw = typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
25594
|
+
return raw.length > MAX_CELL_WIDTH ? `${raw.slice(0, MAX_CELL_WIDTH - 1)}\u2026` : raw;
|
|
25595
|
+
}
|
|
25596
|
+
function buildListCommand2() {
|
|
25597
|
+
return new Command("list").description("List records of one object").argument("<target>", `<appSlug>/<objectKey> (e.g. ${CORE_SLUG}/shopify-order)`).option("--filter <json>", `Per-field operator map, e.g. '{"name":{"contains":"1001"}}'`).option("--search <json>", `Free-text OR, e.g. '{"q":"ann","fields":["email"]}'`).option("--sort <json>", `Sort specs, e.g. '[{"field":"createdAt","direction":"desc"}]'`).option("--id <id>", "Fetch one row by primary key; bypasses filters").option("--limit <n>", `Total rows to fetch (max ${MAX_LIMIT})`, String(DEFAULT_LIMIT)).option("--cursor <cursor>", "Resume from a previous nextCursor").option("--fields <a,b,c>", "Columns to render, in order").option("--json", "Output the raw {items, nextCursor} envelope as JSON").option("--remote <name>", "Named remote server to target").action(async (target, opts) => {
|
|
25598
|
+
const { appSlug, objectKey } = parseTarget2(target);
|
|
25599
|
+
const filter = opts.filter && requireJson(opts.filter, "--filter", "object");
|
|
25600
|
+
const search = opts.search && requireJson(opts.search, "--search", "object");
|
|
25601
|
+
const sort = opts.sort && requireJson(opts.sort, "--sort", "array");
|
|
25602
|
+
const limit = parseLimit(opts.limit);
|
|
25603
|
+
const fields = opts.fields ? parseFields(opts.fields) : void 0;
|
|
25604
|
+
const { baseUrl, apiKey } = resolveTransport(opts);
|
|
25605
|
+
try {
|
|
25606
|
+
const items = [];
|
|
25607
|
+
let cursor = opts.cursor;
|
|
25608
|
+
let nextCursor = null;
|
|
25609
|
+
for (; ; ) {
|
|
25610
|
+
const page = await fetchRecords({
|
|
25611
|
+
baseUrl,
|
|
25612
|
+
apiKey,
|
|
25613
|
+
appSlug,
|
|
25614
|
+
objectKey,
|
|
25615
|
+
cursor,
|
|
25616
|
+
limit: Math.min(SERVER_PAGE_MAX, limit - items.length),
|
|
25617
|
+
id: opts.id,
|
|
25618
|
+
filter,
|
|
25619
|
+
search,
|
|
25620
|
+
sort
|
|
25621
|
+
});
|
|
25622
|
+
items.push(...page.items);
|
|
25623
|
+
nextCursor = page.nextCursor;
|
|
25624
|
+
if (!page.nextCursor || page.items.length === 0 || items.length >= limit) break;
|
|
25625
|
+
cursor = page.nextCursor;
|
|
25626
|
+
}
|
|
25627
|
+
if (opts.json) {
|
|
25628
|
+
console.log(JSON.stringify({ items, nextCursor }));
|
|
25629
|
+
return;
|
|
25630
|
+
}
|
|
25631
|
+
if (items.length === 0) {
|
|
25632
|
+
console.log("No records found.");
|
|
25633
|
+
return;
|
|
25634
|
+
}
|
|
25635
|
+
const columns = chooseColumns(items, fields);
|
|
25636
|
+
console.log(
|
|
25637
|
+
renderTable(
|
|
25638
|
+
columns.map((column) => column.toUpperCase()),
|
|
25639
|
+
items.map((row) => columns.map((column) => formatCell(cellValue(row, column))))
|
|
25640
|
+
)
|
|
25641
|
+
);
|
|
25642
|
+
if (nextCursor) {
|
|
25643
|
+
console.error(`note: more rows available \u2014 resume with --cursor ${nextCursor}`);
|
|
25644
|
+
}
|
|
25645
|
+
} catch (err) {
|
|
25646
|
+
reportApiError(err);
|
|
25647
|
+
}
|
|
25648
|
+
});
|
|
25649
|
+
}
|
|
25650
|
+
function buildCountCommand() {
|
|
25651
|
+
return new Command("count").description("Count records matching a filter").argument("<target>", `<appSlug>/<objectKey> (e.g. ${CORE_SLUG}/shopify-order)`).option("--filter <json>", `Per-field operator map, e.g. '{"name":{"contains":"1001"}}'`).option("--search <json>", `Free-text OR, e.g. '{"q":"ann","fields":["email"]}'`).option("--json", "Output the raw response as JSON").option("--remote <name>", "Named remote server to target").action(async (target, opts) => {
|
|
25652
|
+
const { appSlug, objectKey } = parseTarget2(target);
|
|
25653
|
+
const filter = opts.filter && requireJson(opts.filter, "--filter", "object");
|
|
25654
|
+
const search = opts.search && requireJson(opts.search, "--search", "object");
|
|
25655
|
+
const { baseUrl, apiKey } = resolveTransport(opts);
|
|
25656
|
+
try {
|
|
25657
|
+
const result = await countRecords({
|
|
25658
|
+
baseUrl,
|
|
25659
|
+
apiKey,
|
|
25660
|
+
appSlug,
|
|
25661
|
+
objectKey,
|
|
25662
|
+
filter,
|
|
25663
|
+
search
|
|
25664
|
+
});
|
|
25665
|
+
console.log(opts.json ? JSON.stringify(result) : String(result.count));
|
|
25666
|
+
} catch (err) {
|
|
25667
|
+
reportApiError(err);
|
|
25668
|
+
}
|
|
25669
|
+
});
|
|
25670
|
+
}
|
|
25671
|
+
function buildDataCommand() {
|
|
25672
|
+
const data = new Command("data").description(
|
|
25673
|
+
"Read platform data (read-only; needs a user-bound key and platform ADMIN)"
|
|
25674
|
+
);
|
|
25675
|
+
data.addCommand(buildObjectsCommand());
|
|
25676
|
+
data.addCommand(buildSchemaCommand());
|
|
25677
|
+
data.addCommand(buildListCommand2());
|
|
25678
|
+
data.addCommand(buildCountCommand());
|
|
25679
|
+
return data;
|
|
25680
|
+
}
|
|
25681
|
+
|
|
25371
25682
|
// src/index.ts
|
|
25372
25683
|
function readVersion() {
|
|
25373
25684
|
try {
|
|
@@ -25388,6 +25699,7 @@ program2.addCommand(buildPublishCommand());
|
|
|
25388
25699
|
program2.addCommand(buildInstallCommand());
|
|
25389
25700
|
program2.addCommand(buildLogsCommand());
|
|
25390
25701
|
program2.addCommand(buildRunsCommand());
|
|
25702
|
+
program2.addCommand(buildDataCommand());
|
|
25391
25703
|
program2.parseAsync(process.argv).catch((err) => {
|
|
25392
25704
|
console.error(err instanceof Error ? err.message : String(err));
|
|
25393
25705
|
process.exit(1);
|