@wayai/cli 0.3.324 → 0.3.326
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/index.js +269 -301
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15956,10 +15956,10 @@ var init_chunk_N7TIWXUC = __esm({
|
|
|
15956
15956
|
}
|
|
15957
15957
|
});
|
|
15958
15958
|
|
|
15959
|
-
// ../../packages/core/dist/chunk-
|
|
15959
|
+
// ../../packages/core/dist/chunk-PZCHHX22.js
|
|
15960
15960
|
var CASE_FILE_SHA_PATTERN, caseFileShaSchema, CASE_REVISION_MESSAGE_MAX_LENGTH, CASE_REVISION_SESSION_MAX_LENGTH, CASE_REVISION_ENTRIES_MAX, caseRevisionEntryShape, caseRevisionShape;
|
|
15961
|
-
var
|
|
15962
|
-
"../../packages/core/dist/chunk-
|
|
15961
|
+
var init_chunk_PZCHHX22 = __esm({
|
|
15962
|
+
"../../packages/core/dist/chunk-PZCHHX22.js"() {
|
|
15963
15963
|
"use strict";
|
|
15964
15964
|
init_chunk_N7TIWXUC();
|
|
15965
15965
|
init_zod();
|
|
@@ -17744,7 +17744,7 @@ var init_contracts = __esm({
|
|
|
17744
17744
|
init_chunk_7CYHPF35();
|
|
17745
17745
|
init_chunk_NETRUHZF();
|
|
17746
17746
|
init_chunk_KHL7NZSL();
|
|
17747
|
-
|
|
17747
|
+
init_chunk_PZCHHX22();
|
|
17748
17748
|
init_chunk_QVZPT7ZX();
|
|
17749
17749
|
init_chunk_E4AVT2QI();
|
|
17750
17750
|
init_chunk_B2AXWIKU();
|
|
@@ -25213,13 +25213,14 @@ function parseDuration(input, flag = "duration") {
|
|
|
25213
25213
|
}
|
|
25214
25214
|
return value * unitMs;
|
|
25215
25215
|
}
|
|
25216
|
-
var DURATION_RE, DURATION_UNIT_MS;
|
|
25216
|
+
var BASE_SECRET_STORAGE_WHY, DURATION_RE, DURATION_UNIT_MS;
|
|
25217
25217
|
var init_helpers = __esm({
|
|
25218
25218
|
"src/data/helpers.ts"() {
|
|
25219
25219
|
"use strict";
|
|
25220
25220
|
init_base_id();
|
|
25221
25221
|
init_expected();
|
|
25222
25222
|
init_utils();
|
|
25223
|
+
BASE_SECRET_STORAGE_WHY = "a base's secrets are to be kept in the credentials vault, which does not hold them yet";
|
|
25223
25224
|
DURATION_RE = /^(\d+)([smhd])$/;
|
|
25224
25225
|
DURATION_UNIT_MS = {
|
|
25225
25226
|
s: 1e3,
|
|
@@ -25658,6 +25659,207 @@ var init_diff_format = __esm({
|
|
|
25658
25659
|
}
|
|
25659
25660
|
});
|
|
25660
25661
|
|
|
25662
|
+
// src/data/output.ts
|
|
25663
|
+
function printOutput(data, format) {
|
|
25664
|
+
if (format === "json") {
|
|
25665
|
+
console.log(JSON.stringify(data, null, 2));
|
|
25666
|
+
return;
|
|
25667
|
+
}
|
|
25668
|
+
if (Array.isArray(data)) {
|
|
25669
|
+
printRows(data);
|
|
25670
|
+
return;
|
|
25671
|
+
}
|
|
25672
|
+
if (typeof data === "object" && data !== null) {
|
|
25673
|
+
printFields(data);
|
|
25674
|
+
return;
|
|
25675
|
+
}
|
|
25676
|
+
console.log(formatCell(data));
|
|
25677
|
+
}
|
|
25678
|
+
function printRows(rows) {
|
|
25679
|
+
if (rows.length === 0) {
|
|
25680
|
+
console.log("(no results)");
|
|
25681
|
+
return;
|
|
25682
|
+
}
|
|
25683
|
+
const columns = [];
|
|
25684
|
+
const seen = /* @__PURE__ */ new Set();
|
|
25685
|
+
for (const row of rows) {
|
|
25686
|
+
for (const key of Object.keys(row ?? {})) {
|
|
25687
|
+
if (seen.has(key)) continue;
|
|
25688
|
+
seen.add(key);
|
|
25689
|
+
columns.push(key);
|
|
25690
|
+
}
|
|
25691
|
+
}
|
|
25692
|
+
const headers = columns.map((c) => sanitizeTerminalText(c));
|
|
25693
|
+
const cells = rows.map((row) => columns.map((c) => cellAt(row, c)));
|
|
25694
|
+
const widths = columns.map(
|
|
25695
|
+
(_, i) => cells.reduce((width, row) => Math.max(width, row[i].length), headers[i].length)
|
|
25696
|
+
);
|
|
25697
|
+
console.log(headers.map((c, i) => c.padEnd(widths[i])).join(" "));
|
|
25698
|
+
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
25699
|
+
for (const row of cells) {
|
|
25700
|
+
console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(" "));
|
|
25701
|
+
}
|
|
25702
|
+
}
|
|
25703
|
+
function printFields(obj) {
|
|
25704
|
+
const entries = Object.entries(obj).map(([key, value]) => ({
|
|
25705
|
+
key: sanitizeTerminalText(key),
|
|
25706
|
+
value
|
|
25707
|
+
}));
|
|
25708
|
+
if (entries.length === 0) {
|
|
25709
|
+
console.log("(empty)");
|
|
25710
|
+
return;
|
|
25711
|
+
}
|
|
25712
|
+
const width = entries.reduce((w, e) => Math.max(w, e.key.length), 0);
|
|
25713
|
+
for (const { key, value } of entries) {
|
|
25714
|
+
console.log(`${key.padEnd(width)} ${formatCell(value)}`);
|
|
25715
|
+
}
|
|
25716
|
+
}
|
|
25717
|
+
function printBatchResult(response) {
|
|
25718
|
+
const obj = response && typeof response === "object" ? response : {};
|
|
25719
|
+
const results = Array.isArray(obj.results) ? obj.results : [];
|
|
25720
|
+
const batchId = typeof obj.batch_id === "string" ? obj.batch_id : "(none)";
|
|
25721
|
+
console.log(
|
|
25722
|
+
`batch_id: ${sanitizeTerminalText(batchId)} \xB7 ${results.length} operation${results.length === 1 ? "" : "s"}`
|
|
25723
|
+
);
|
|
25724
|
+
if (results.length === 0) return;
|
|
25725
|
+
printRows(
|
|
25726
|
+
results.map((r, i) => ({
|
|
25727
|
+
"#": String(i),
|
|
25728
|
+
operation: r?.type ?? "",
|
|
25729
|
+
result: summarizeBatchResult(r)
|
|
25730
|
+
}))
|
|
25731
|
+
);
|
|
25732
|
+
}
|
|
25733
|
+
function summarizeBatchResult(r) {
|
|
25734
|
+
if (!r || typeof r !== "object") return String(r ?? "");
|
|
25735
|
+
if (r.deleted === true) return "deleted";
|
|
25736
|
+
const entity = r.record ?? r.relationship ?? r.record_type;
|
|
25737
|
+
if (entity && typeof entity === "object") {
|
|
25738
|
+
const e = entity;
|
|
25739
|
+
const id = typeof e.id === "string" ? e.id : void 0;
|
|
25740
|
+
const label3 = typeof e.record_type === "string" ? e.record_type : typeof e.rel_type === "string" ? e.rel_type : typeof e.name === "string" ? e.name : void 0;
|
|
25741
|
+
const version = e.version != null ? ` v${String(e.version)}` : "";
|
|
25742
|
+
if (id && label3) return `${label3}/${id}${version}`;
|
|
25743
|
+
if (id) return `${id}${version}`;
|
|
25744
|
+
}
|
|
25745
|
+
return JSON.stringify(r);
|
|
25746
|
+
}
|
|
25747
|
+
function cellAt(row, column) {
|
|
25748
|
+
return formatCell(row?.[column]);
|
|
25749
|
+
}
|
|
25750
|
+
function formatCell(value) {
|
|
25751
|
+
if (value === null || value === void 0) return "";
|
|
25752
|
+
if (typeof value === "object") return sanitizeTerminalText(JSON.stringify(value));
|
|
25753
|
+
return sanitizeTerminalText(String(value));
|
|
25754
|
+
}
|
|
25755
|
+
var init_output = __esm({
|
|
25756
|
+
"src/data/output.ts"() {
|
|
25757
|
+
"use strict";
|
|
25758
|
+
init_terminal_output();
|
|
25759
|
+
}
|
|
25760
|
+
});
|
|
25761
|
+
|
|
25762
|
+
// src/data/commands/triggers.ts
|
|
25763
|
+
import { randomUUID } from "crypto";
|
|
25764
|
+
import { Command } from "commander";
|
|
25765
|
+
function warnUnsignedTriggers(ids) {
|
|
25766
|
+
if (!ids || ids.length === 0) return;
|
|
25767
|
+
console.warn(
|
|
25768
|
+
`
|
|
25769
|
+
Webhook triggers that deliver unsigned, with no X-Data-Signature or X-Data-Timestamp header (no signing secret can be stored for now): ${ids.map((id) => sanitizeTerminalText(id)).join(", ")}. A receiver that verifies signatures will reject their deliveries.`
|
|
25770
|
+
);
|
|
25771
|
+
}
|
|
25772
|
+
function buildTriggersCommand() {
|
|
25773
|
+
const triggers = new Command("triggers").description(
|
|
25774
|
+
"Manage triggers (outbound webhooks, internal writes, external writes)"
|
|
25775
|
+
);
|
|
25776
|
+
triggers.command("create").description(
|
|
25777
|
+
"Create a trigger (a webhook, an internal_write that patches a referenced record, or an external_write that mirrors the record to an external source)"
|
|
25778
|
+
).requiredOption("--name <name>", "Trigger name").requiredOption("--events <events>", "Comma-separated event types").option("--url <url>", "Webhook target URL (webhook actions; delivered unsigned for now)").option("--secret-stdin", "Read the webhook signing secret from stdin (unavailable for now)").option("--secret-prompt", "Prompt for the webhook signing secret, masked (unavailable for now)").option(
|
|
25779
|
+
"--action <json>",
|
|
25780
|
+
`Action JSON. webhook {"type":"webhook","url":...}; internal_write {"type":"internal_write","target":"slots","match":{"source_field":"data.slot_id"},"patch":{"status":"busy"},"precondition":{"field":"data.status","op":"eq","value":"free"},"mode":"async"} (mode: "async" applies after the write, "transactional" applies atomically so a precondition miss rolls the write back); external_write {"type":"external_write","record_type":"upstream_appointments","source":"legacy","op":"create","watched_fields":"mapped"} (writes the triggering record through that source's write path \u2014 translation, endpoint, auth \u2014 and links the upstream-assigned id back as external_id; "record_type" defaults to the triggering record_type, "op" defaults from the event; "watched_fields" scopes UPDATE dispatch to writes that changed an upstream-mapped field \u2014 "mapped" = the source's to_external keys, or an explicit array of data fields \u2014 so an overlay-only write skips the redundant upstream push; omit to fire on every update)`
|
|
25781
|
+
).option("--id <id>", "Trigger ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option("--filter <json>", "Filter expression (JSON)").option(
|
|
25782
|
+
"--skip-cascade-writes <bool>",
|
|
25783
|
+
"Skip firing on cascade-originated (internal_write) writes (default true)"
|
|
25784
|
+
).action(async function(opts) {
|
|
25785
|
+
if (opts.secretStdin || opts.secretPrompt) throw expected(SIGNING_SECRET_UNAVAILABLE);
|
|
25786
|
+
if (!opts.action && !opts.url) {
|
|
25787
|
+
throw expected("Provide --url (webhook) or --action <json> (e.g. an internal_write action).");
|
|
25788
|
+
}
|
|
25789
|
+
const body = {
|
|
25790
|
+
name: opts.name,
|
|
25791
|
+
events: splitList(opts.events),
|
|
25792
|
+
enabled: true
|
|
25793
|
+
};
|
|
25794
|
+
if (opts.action) {
|
|
25795
|
+
body.action = parseData(opts.action);
|
|
25796
|
+
} else {
|
|
25797
|
+
body.url = opts.url;
|
|
25798
|
+
}
|
|
25799
|
+
if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
|
|
25800
|
+
if (opts.filter) body.filter = parseData(opts.filter);
|
|
25801
|
+
if (opts.skipCascadeWrites !== void 0) {
|
|
25802
|
+
body.skip_cascade_writes = opts.skipCascadeWrites !== "false";
|
|
25803
|
+
}
|
|
25804
|
+
const base = pathSegment(requireBase(this), "--base");
|
|
25805
|
+
const client = await createDataClient();
|
|
25806
|
+
const triggerId = opts.id ?? randomUUID();
|
|
25807
|
+
const trigger = await client.request(
|
|
25808
|
+
"PUT",
|
|
25809
|
+
`/v1/${base}/triggers/${pathSegment(triggerId, "--id")}`,
|
|
25810
|
+
body
|
|
25811
|
+
);
|
|
25812
|
+
printOutput(trigger, outputFormat(this));
|
|
25813
|
+
if (trigger?.warnings?.includes("unsigned_delivery")) warnUnsignedTriggers([triggerId]);
|
|
25814
|
+
});
|
|
25815
|
+
triggers.command("get <id>").description("Get a trigger").action(async function(id) {
|
|
25816
|
+
const base = pathSegment(requireBase(this), "--base");
|
|
25817
|
+
const client = await createDataClient();
|
|
25818
|
+
printOutput(await client.request("GET", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`), outputFormat(this));
|
|
25819
|
+
});
|
|
25820
|
+
triggers.command("list").description("List all triggers").action(async function() {
|
|
25821
|
+
const base = pathSegment(requireBase(this), "--base");
|
|
25822
|
+
const client = await createDataClient();
|
|
25823
|
+
printOutput(await client.request("GET", `/v1/${base}/triggers`), outputFormat(this));
|
|
25824
|
+
});
|
|
25825
|
+
triggers.command("deliveries").description("List trigger delivery attempts (status, retries, errors)").option("--status <status>", "Filter by status (pending | delivered | failed | dead)").option("--trigger-id <id>", "Filter by trigger id").action(async function(opts) {
|
|
25826
|
+
const base = pathSegment(requireBase(this), "--base");
|
|
25827
|
+
const client = await createDataClient();
|
|
25828
|
+
const params = new URLSearchParams();
|
|
25829
|
+
if (opts.status) params.set("status", opts.status);
|
|
25830
|
+
if (opts.triggerId) params.set("trigger_id", opts.triggerId);
|
|
25831
|
+
const qs = params.toString();
|
|
25832
|
+
printOutput(
|
|
25833
|
+
await client.request("GET", `/v1/${base}/triggers/deliveries${qs ? `?${qs}` : ""}`),
|
|
25834
|
+
outputFormat(this)
|
|
25835
|
+
);
|
|
25836
|
+
});
|
|
25837
|
+
triggers.command("delete <id>").description("Delete a trigger").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
|
|
25838
|
+
if (!opts.yes && !await confirm(`Delete trigger ${id}? This cannot be undone.`)) {
|
|
25839
|
+
console.log("Aborted");
|
|
25840
|
+
return;
|
|
25841
|
+
}
|
|
25842
|
+
const base = pathSegment(requireBase(this), "--base");
|
|
25843
|
+
const client = await createDataClient();
|
|
25844
|
+
await client.request("DELETE", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`);
|
|
25845
|
+
console.log("Deleted");
|
|
25846
|
+
});
|
|
25847
|
+
return triggers;
|
|
25848
|
+
}
|
|
25849
|
+
var SIGNING_SECRET_UNAVAILABLE;
|
|
25850
|
+
var init_triggers = __esm({
|
|
25851
|
+
"src/data/commands/triggers.ts"() {
|
|
25852
|
+
"use strict";
|
|
25853
|
+
init_expected();
|
|
25854
|
+
init_client();
|
|
25855
|
+
init_output();
|
|
25856
|
+
init_helpers();
|
|
25857
|
+
init_utils();
|
|
25858
|
+
init_terminal_output();
|
|
25859
|
+
SIGNING_SECRET_UNAVAILABLE = `Setting a webhook trigger's signing secret is unavailable for now: ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored. Omit --secret-stdin and --secret-prompt to create the trigger; it delivers unsigned.`;
|
|
25860
|
+
}
|
|
25861
|
+
});
|
|
25862
|
+
|
|
25661
25863
|
// src/data/config-as-code/sync.ts
|
|
25662
25864
|
var sync_exports = {};
|
|
25663
25865
|
__export(sync_exports, {
|
|
@@ -25842,19 +26044,7 @@ Apply these changes to preview "${sanitizeTerminalText(baseId)}"?`);
|
|
|
25842
26044
|
}
|
|
25843
26045
|
}
|
|
25844
26046
|
const result = await applyConfig(client, baseId, config);
|
|
25845
|
-
|
|
25846
|
-
["trigger", result.new_trigger_secrets],
|
|
25847
|
-
["inbound webhook", result.new_inbound_webhook_secrets]
|
|
25848
|
-
];
|
|
25849
|
-
if (secretGroups.some(([, map]) => map && Object.keys(map).length > 0)) {
|
|
25850
|
-
console.log(`
|
|
25851
|
-
${YELLOW}New secrets (shown once \u2014 save them now):${RESET}`);
|
|
25852
|
-
for (const [kind, map] of secretGroups) {
|
|
25853
|
-
for (const [id, secret] of Object.entries(map ?? {})) {
|
|
25854
|
-
console.log(` ${kind} ${sanitizeTerminalText(id)}: ${secret}`);
|
|
25855
|
-
}
|
|
25856
|
-
}
|
|
25857
|
-
}
|
|
26047
|
+
warnUnsignedTriggers(result.unsigned_triggers);
|
|
25858
26048
|
const removals = collectRemovals(diff);
|
|
25859
26049
|
if (removals.length > 0) {
|
|
25860
26050
|
const word = removals.length === 1 ? "entity" : "entities";
|
|
@@ -25896,6 +26086,7 @@ var init_sync = __esm({
|
|
|
25896
26086
|
init_diff_format();
|
|
25897
26087
|
init_base_workspace();
|
|
25898
26088
|
init_types2();
|
|
26089
|
+
init_triggers();
|
|
25899
26090
|
}
|
|
25900
26091
|
});
|
|
25901
26092
|
|
|
@@ -32409,12 +32600,12 @@ function printQueryRows(rows) {
|
|
|
32409
32600
|
return;
|
|
32410
32601
|
}
|
|
32411
32602
|
const columns = Object.keys(rows[0]);
|
|
32412
|
-
const widths = columns.map((c) => Math.max(c.length, ...rows.map((r) =>
|
|
32603
|
+
const widths = columns.map((c) => Math.max(c.length, ...rows.map((r) => formatCell2(r[c]).length)));
|
|
32413
32604
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
32414
32605
|
console.log(header);
|
|
32415
32606
|
console.log(columns.map((_, i) => "-".repeat(widths[i])).join(" "));
|
|
32416
32607
|
for (const row of rows) {
|
|
32417
|
-
console.log(columns.map((c, i) =>
|
|
32608
|
+
console.log(columns.map((c, i) => formatCell2(row[c]).padEnd(widths[i])).join(" "));
|
|
32418
32609
|
}
|
|
32419
32610
|
}
|
|
32420
32611
|
function printSqlSchema(data, pathsHeader) {
|
|
@@ -32443,7 +32634,7 @@ ${pathsHeader}`);
|
|
|
32443
32634
|
}
|
|
32444
32635
|
}
|
|
32445
32636
|
}
|
|
32446
|
-
function
|
|
32637
|
+
function formatCell2(value) {
|
|
32447
32638
|
if (value === null || value === void 0) return "";
|
|
32448
32639
|
if (typeof value === "number") return Number.isInteger(value) ? String(value) : value.toFixed(4);
|
|
32449
32640
|
if (typeof value === "object") return JSON.stringify(value);
|
|
@@ -37021,106 +37212,6 @@ var init_list = __esm({
|
|
|
37021
37212
|
}
|
|
37022
37213
|
});
|
|
37023
37214
|
|
|
37024
|
-
// src/data/output.ts
|
|
37025
|
-
function printOutput(data, format) {
|
|
37026
|
-
if (format === "json") {
|
|
37027
|
-
console.log(JSON.stringify(data, null, 2));
|
|
37028
|
-
return;
|
|
37029
|
-
}
|
|
37030
|
-
if (Array.isArray(data)) {
|
|
37031
|
-
printRows(data);
|
|
37032
|
-
return;
|
|
37033
|
-
}
|
|
37034
|
-
if (typeof data === "object" && data !== null) {
|
|
37035
|
-
printFields(data);
|
|
37036
|
-
return;
|
|
37037
|
-
}
|
|
37038
|
-
console.log(formatCell2(data));
|
|
37039
|
-
}
|
|
37040
|
-
function printRows(rows) {
|
|
37041
|
-
if (rows.length === 0) {
|
|
37042
|
-
console.log("(no results)");
|
|
37043
|
-
return;
|
|
37044
|
-
}
|
|
37045
|
-
const columns = [];
|
|
37046
|
-
const seen = /* @__PURE__ */ new Set();
|
|
37047
|
-
for (const row of rows) {
|
|
37048
|
-
for (const key of Object.keys(row ?? {})) {
|
|
37049
|
-
if (seen.has(key)) continue;
|
|
37050
|
-
seen.add(key);
|
|
37051
|
-
columns.push(key);
|
|
37052
|
-
}
|
|
37053
|
-
}
|
|
37054
|
-
const headers = columns.map((c) => sanitizeTerminalText(c));
|
|
37055
|
-
const cells = rows.map((row) => columns.map((c) => cellAt(row, c)));
|
|
37056
|
-
const widths = columns.map(
|
|
37057
|
-
(_, i) => cells.reduce((width, row) => Math.max(width, row[i].length), headers[i].length)
|
|
37058
|
-
);
|
|
37059
|
-
console.log(headers.map((c, i) => c.padEnd(widths[i])).join(" "));
|
|
37060
|
-
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
37061
|
-
for (const row of cells) {
|
|
37062
|
-
console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(" "));
|
|
37063
|
-
}
|
|
37064
|
-
}
|
|
37065
|
-
function printFields(obj) {
|
|
37066
|
-
const entries = Object.entries(obj).map(([key, value]) => ({
|
|
37067
|
-
key: sanitizeTerminalText(key),
|
|
37068
|
-
value
|
|
37069
|
-
}));
|
|
37070
|
-
if (entries.length === 0) {
|
|
37071
|
-
console.log("(empty)");
|
|
37072
|
-
return;
|
|
37073
|
-
}
|
|
37074
|
-
const width = entries.reduce((w, e) => Math.max(w, e.key.length), 0);
|
|
37075
|
-
for (const { key, value } of entries) {
|
|
37076
|
-
console.log(`${key.padEnd(width)} ${formatCell2(value)}`);
|
|
37077
|
-
}
|
|
37078
|
-
}
|
|
37079
|
-
function printBatchResult(response) {
|
|
37080
|
-
const obj = response && typeof response === "object" ? response : {};
|
|
37081
|
-
const results = Array.isArray(obj.results) ? obj.results : [];
|
|
37082
|
-
const batchId = typeof obj.batch_id === "string" ? obj.batch_id : "(none)";
|
|
37083
|
-
console.log(
|
|
37084
|
-
`batch_id: ${sanitizeTerminalText(batchId)} \xB7 ${results.length} operation${results.length === 1 ? "" : "s"}`
|
|
37085
|
-
);
|
|
37086
|
-
if (results.length === 0) return;
|
|
37087
|
-
printRows(
|
|
37088
|
-
results.map((r, i) => ({
|
|
37089
|
-
"#": String(i),
|
|
37090
|
-
operation: r?.type ?? "",
|
|
37091
|
-
result: summarizeBatchResult(r)
|
|
37092
|
-
}))
|
|
37093
|
-
);
|
|
37094
|
-
}
|
|
37095
|
-
function summarizeBatchResult(r) {
|
|
37096
|
-
if (!r || typeof r !== "object") return String(r ?? "");
|
|
37097
|
-
if (r.deleted === true) return "deleted";
|
|
37098
|
-
const entity = r.record ?? r.relationship ?? r.record_type;
|
|
37099
|
-
if (entity && typeof entity === "object") {
|
|
37100
|
-
const e = entity;
|
|
37101
|
-
const id = typeof e.id === "string" ? e.id : void 0;
|
|
37102
|
-
const label3 = typeof e.record_type === "string" ? e.record_type : typeof e.rel_type === "string" ? e.rel_type : typeof e.name === "string" ? e.name : void 0;
|
|
37103
|
-
const version = e.version != null ? ` v${String(e.version)}` : "";
|
|
37104
|
-
if (id && label3) return `${label3}/${id}${version}`;
|
|
37105
|
-
if (id) return `${id}${version}`;
|
|
37106
|
-
}
|
|
37107
|
-
return JSON.stringify(r);
|
|
37108
|
-
}
|
|
37109
|
-
function cellAt(row, column) {
|
|
37110
|
-
return formatCell2(row?.[column]);
|
|
37111
|
-
}
|
|
37112
|
-
function formatCell2(value) {
|
|
37113
|
-
if (value === null || value === void 0) return "";
|
|
37114
|
-
if (typeof value === "object") return sanitizeTerminalText(JSON.stringify(value));
|
|
37115
|
-
return sanitizeTerminalText(String(value));
|
|
37116
|
-
}
|
|
37117
|
-
var init_output = __esm({
|
|
37118
|
-
"src/data/output.ts"() {
|
|
37119
|
-
"use strict";
|
|
37120
|
-
init_terminal_output();
|
|
37121
|
-
}
|
|
37122
|
-
});
|
|
37123
|
-
|
|
37124
37215
|
// src/commands/communities.ts
|
|
37125
37216
|
var communities_exports = {};
|
|
37126
37217
|
__export(communities_exports, {
|
|
@@ -42781,9 +42872,9 @@ var init_update = __esm({
|
|
|
42781
42872
|
});
|
|
42782
42873
|
|
|
42783
42874
|
// src/data/commands/actions.ts
|
|
42784
|
-
import { Command } from "commander";
|
|
42875
|
+
import { Command as Command2 } from "commander";
|
|
42785
42876
|
function buildActionsCommand() {
|
|
42786
|
-
const actions = new
|
|
42877
|
+
const actions = new Command2("actions").description(
|
|
42787
42878
|
"Manage Actions \u2014 reusable, named definitions: one record_type + one operation, or a composite of atomic write steps (--config with `steps`)"
|
|
42788
42879
|
);
|
|
42789
42880
|
actions.command("upsert <id>").description(
|
|
@@ -42852,7 +42943,7 @@ var init_actions = __esm({
|
|
|
42852
42943
|
});
|
|
42853
42944
|
|
|
42854
42945
|
// src/data/commands/attachments.ts
|
|
42855
|
-
import { Command as
|
|
42946
|
+
import { Command as Command3 } from "commander";
|
|
42856
42947
|
import { readFileSync as readFileSync20 } from "fs";
|
|
42857
42948
|
function findAttachmentByFilename(attachments, filename) {
|
|
42858
42949
|
return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
|
|
@@ -42879,7 +42970,7 @@ function uploadPathFrom(uploadUrl) {
|
|
|
42879
42970
|
return uploadUrl;
|
|
42880
42971
|
}
|
|
42881
42972
|
function buildAttachmentsCommand() {
|
|
42882
|
-
const attachments = new
|
|
42973
|
+
const attachments = new Command3("attachments").description("Manage record attachments");
|
|
42883
42974
|
attachments.command("upload <record_type> <id>").description(
|
|
42884
42975
|
"Get a presigned upload URL for a record attachment. With --file, uploads the file content in one step."
|
|
42885
42976
|
).requiredOption("--filename <name>", "File name or path (e.g. docs/guide.md)").option("--content-type <type>", "MIME type", "application/octet-stream").option("--file <path>", "Local file to upload (skips presigned URL output, uploads directly)").action(async function(recordType2, id, opts) {
|
|
@@ -42959,9 +43050,9 @@ var init_attachments = __esm({
|
|
|
42959
43050
|
});
|
|
42960
43051
|
|
|
42961
43052
|
// src/data/commands/batch.ts
|
|
42962
|
-
import { Command as
|
|
43053
|
+
import { Command as Command4 } from "commander";
|
|
42963
43054
|
function buildBasesBatchCommand() {
|
|
42964
|
-
return withBaseOption(new
|
|
43055
|
+
return withBaseOption(new Command4("batch")).description("Execute atomic batch operations (up to 1,000 operations)").requiredOption("--operations <json>", "Operations array (inline JSON or @filename)").action(async function(opts) {
|
|
42965
43056
|
const base = pathSegment(requireBase(this), "--base");
|
|
42966
43057
|
const operations = parseData(opts.operations, "--operations");
|
|
42967
43058
|
const client = await createDataClient();
|
|
@@ -42989,8 +43080,8 @@ var init_batch = __esm({
|
|
|
42989
43080
|
import { createReadStream } from "fs";
|
|
42990
43081
|
import { access, constants, stat } from "fs/promises";
|
|
42991
43082
|
import { createInterface as createInterface3 } from "readline";
|
|
42992
|
-
import { randomUUID } from "crypto";
|
|
42993
|
-
import { Command as
|
|
43083
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
43084
|
+
import { Command as Command5 } from "commander";
|
|
42994
43085
|
function isRetryable(err) {
|
|
42995
43086
|
if (isNetworkError(err)) return true;
|
|
42996
43087
|
if (!(err instanceof ApiError)) return false;
|
|
@@ -43066,7 +43157,7 @@ async function beginSession(state, client, base, recordType2, requestKey) {
|
|
|
43066
43157
|
return res.session;
|
|
43067
43158
|
}
|
|
43068
43159
|
function buildBasesImportCommand() {
|
|
43069
|
-
const importCmd = withBaseOption(new
|
|
43160
|
+
const importCmd = withBaseOption(new Command5("import")).description(
|
|
43070
43161
|
"Bulk historical import: load an NDJSON backfill, list sessions, or undo one"
|
|
43071
43162
|
);
|
|
43072
43163
|
importCmd.command("run <record_type>").description(
|
|
@@ -43105,7 +43196,7 @@ function buildBasesImportCommand() {
|
|
|
43105
43196
|
throw expected(`--file ${opts.file}: not a readable file.`);
|
|
43106
43197
|
}
|
|
43107
43198
|
const client = await createDataClient();
|
|
43108
|
-
const requestKey = opts.requestKey ?? `cli-${
|
|
43199
|
+
const requestKey = opts.requestKey ?? `cli-${randomUUID2()}`;
|
|
43109
43200
|
if (!opts.requestKey) {
|
|
43110
43201
|
console.error(`request_key: ${requestKey} (pass --request-key to resume this run)`);
|
|
43111
43202
|
}
|
|
@@ -43310,7 +43401,7 @@ var init_import = __esm({
|
|
|
43310
43401
|
});
|
|
43311
43402
|
|
|
43312
43403
|
// src/data/commands/providers.ts
|
|
43313
|
-
import { Command as
|
|
43404
|
+
import { Command as Command6 } from "commander";
|
|
43314
43405
|
import { writeFileSync as writeFileSync10 } from "fs";
|
|
43315
43406
|
function providerSegment(provider) {
|
|
43316
43407
|
if (!VALID_PROVIDERS.includes(provider)) {
|
|
@@ -43319,7 +43410,7 @@ function providerSegment(provider) {
|
|
|
43319
43410
|
return pathSegment(provider, "provider");
|
|
43320
43411
|
}
|
|
43321
43412
|
function buildBasesProvidersCommand() {
|
|
43322
|
-
const providers = withBaseOption(new
|
|
43413
|
+
const providers = withBaseOption(new Command6("providers")).description(
|
|
43323
43414
|
"Import/export tool definitions between LLM providers and record types"
|
|
43324
43415
|
);
|
|
43325
43416
|
providers.command("import <provider>").description(`Import tool definitions as record types. Providers: ${VALID_PROVIDERS_HELP}`).requiredOption("--tools <json>", "Tool definitions (inline JSON or @filename)").action(async function(provider, opts) {
|
|
@@ -43390,7 +43481,7 @@ var init_providers = __esm({
|
|
|
43390
43481
|
});
|
|
43391
43482
|
|
|
43392
43483
|
// src/data/commands/credentials.ts
|
|
43393
|
-
import { Command as
|
|
43484
|
+
import { Command as Command7 } from "commander";
|
|
43394
43485
|
function withValueSourceOptions(cmd, what) {
|
|
43395
43486
|
return cmd.option("--file <path>", `Read ${what} from a file (unavailable for now)`).option("--value-stdin", `Read ${what} from stdin (unavailable for now)`).option("--value-prompt", `Prompt for ${what}, masked (unavailable for now)`);
|
|
43396
43487
|
}
|
|
@@ -43400,7 +43491,7 @@ function credentialPath(base, id) {
|
|
|
43400
43491
|
}
|
|
43401
43492
|
function buildBasesCredentialsCommand() {
|
|
43402
43493
|
const credentials = withBaseOption(
|
|
43403
|
-
new
|
|
43494
|
+
new Command7("credentials").description("Manage a base's integration credentials")
|
|
43404
43495
|
);
|
|
43405
43496
|
withValueSourceOptions(
|
|
43406
43497
|
credentials.command("create").description("Store a credential on this base \u2014 unavailable for now").option("--name <name>", "Credential name").option("--content-type <mime>", "MIME type of the value").option("--expires-at <date>", "Expiry as ISO-8601").option("--no-sync-to-production", "Do not publish this credential on promote (unavailable for now)"),
|
|
@@ -43459,15 +43550,15 @@ var init_credentials = __esm({
|
|
|
43459
43550
|
init_helpers();
|
|
43460
43551
|
init_utils();
|
|
43461
43552
|
init_expected();
|
|
43462
|
-
STORAGE_UNAVAILABLE =
|
|
43553
|
+
STORAGE_UNAVAILABLE = `Storing a base credential is unavailable for now: ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored.`;
|
|
43463
43554
|
}
|
|
43464
43555
|
});
|
|
43465
43556
|
|
|
43466
43557
|
// src/data/commands/sql.ts
|
|
43467
|
-
import { Command as
|
|
43558
|
+
import { Command as Command8 } from "commander";
|
|
43468
43559
|
import { readFileSync as readFileSync21 } from "fs";
|
|
43469
43560
|
function buildBasesSqlCommand() {
|
|
43470
|
-
return withBaseOption(new
|
|
43561
|
+
return withBaseOption(new Command8("sql")).description("Execute a read-only SQL query against base data").argument("[query]", "SQL query (SELECT only)").option("--file <path>", "Read SQL from a file instead of the argument").option(
|
|
43471
43562
|
"--param <kv...>",
|
|
43472
43563
|
"Named parameters as key=value pairs (e.g. --param status=issued)"
|
|
43473
43564
|
).action(async function(queryArg, opts) {
|
|
@@ -43510,7 +43601,7 @@ var init_sql = __esm({
|
|
|
43510
43601
|
});
|
|
43511
43602
|
|
|
43512
43603
|
// src/data/commands/tokens.ts
|
|
43513
|
-
import { Command as
|
|
43604
|
+
import { Command as Command9 } from "commander";
|
|
43514
43605
|
function rawTokenFrom(data) {
|
|
43515
43606
|
const token = typeof data === "object" && data !== null && "token" in data ? data.token : void 0;
|
|
43516
43607
|
if (typeof token !== "string" || !RAW_TOKEN_PATTERN.test(token)) {
|
|
@@ -43568,7 +43659,7 @@ function pruneRow(t, reason2) {
|
|
|
43568
43659
|
};
|
|
43569
43660
|
}
|
|
43570
43661
|
function buildBasesTokensCommand() {
|
|
43571
|
-
const tokens2 = new
|
|
43662
|
+
const tokens2 = new Command9("tokens").description("Manage API tokens");
|
|
43572
43663
|
addTokenLifecycleOptions(
|
|
43573
43664
|
tokens2.command("create").description("Create a scoped API token").requiredOption("--name <name>", "Token name").requiredOption("--grants <json>", "Grant definitions as JSON array").option(
|
|
43574
43665
|
"--token-only",
|
|
@@ -43810,7 +43901,7 @@ var init_base_tags = __esm({
|
|
|
43810
43901
|
});
|
|
43811
43902
|
|
|
43812
43903
|
// src/data/commands/bases.ts
|
|
43813
|
-
import { Command as
|
|
43904
|
+
import { Command as Command10 } from "commander";
|
|
43814
43905
|
function pageOf(path45, cursor) {
|
|
43815
43906
|
if (!cursor) return path45;
|
|
43816
43907
|
return `${path45}${path45.includes("?") ? "&" : "?"}cursor=${encodeURIComponent(cursor)}`;
|
|
@@ -43823,7 +43914,7 @@ function parseEnum(flag, value, allowed) {
|
|
|
43823
43914
|
return value;
|
|
43824
43915
|
}
|
|
43825
43916
|
function buildBasesCommand() {
|
|
43826
|
-
const bases = new
|
|
43917
|
+
const bases = new Command10("bases").description("Manage bases");
|
|
43827
43918
|
bases.command("list").description("List all bases").option("--tag <tag>", "Filter by tag").action(async function(opts) {
|
|
43828
43919
|
const client = await createDataClient();
|
|
43829
43920
|
const qs = opts.tag ? `?tag=${encodeURIComponent(opts.tag)}` : "";
|
|
@@ -43989,23 +44080,25 @@ function buildBasesCommand() {
|
|
|
43989
44080
|
printOutput(data, outputFormat(this));
|
|
43990
44081
|
const warnings = data?.source_credential_warnings ?? [];
|
|
43991
44082
|
if (warnings.length > 0) {
|
|
43992
|
-
console.warn("\nSources with an INLINE secret
|
|
44083
|
+
console.warn("\nSources with an INLINE secret, which have no usable credential on production:");
|
|
43993
44084
|
for (const w of warnings) console.warn(` - ${sanitizeTerminalText(w.message)}`);
|
|
43994
44085
|
}
|
|
43995
44086
|
const unresolved = data?.unresolved_credentials ?? [];
|
|
43996
44087
|
if (unresolved.length > 0) {
|
|
43997
|
-
console.warn("\nReferenced credentials production
|
|
44088
|
+
console.warn("\nReferenced credentials production cannot use:");
|
|
43998
44089
|
for (const w of unresolved) console.warn(` - ${sanitizeTerminalText(w.message)}`);
|
|
43999
44090
|
}
|
|
44091
|
+
warnUnsignedTriggers(data?.unsigned_triggers);
|
|
44000
44092
|
});
|
|
44001
44093
|
bases.command("rollback <production-id>").description("Roll back a promotion (human-only)").requiredOption("--promotion <promotion-id>", "Promotion id to roll back").action(async function(productionId, opts) {
|
|
44002
44094
|
const client = await createDataClient();
|
|
44003
|
-
|
|
44004
|
-
|
|
44005
|
-
|
|
44006
|
-
}
|
|
44007
|
-
outputFormat(this)
|
|
44095
|
+
const data = await client.request(
|
|
44096
|
+
"POST",
|
|
44097
|
+
`/v1/${pathSegment(productionId, "production base id")}/promote/rollback`,
|
|
44098
|
+
{ promotion_id: opts.promotion }
|
|
44008
44099
|
);
|
|
44100
|
+
printOutput(data, outputFormat(this));
|
|
44101
|
+
warnUnsignedTriggers(data?.unsigned_triggers);
|
|
44009
44102
|
});
|
|
44010
44103
|
bases.command("promotions <production-id>").description("List promotion history for a production base").action(async function(productionId) {
|
|
44011
44104
|
const client = await createDataClient();
|
|
@@ -44080,6 +44173,7 @@ var init_bases = __esm({
|
|
|
44080
44173
|
init_helpers();
|
|
44081
44174
|
init_utils();
|
|
44082
44175
|
init_terminal_output();
|
|
44176
|
+
init_triggers();
|
|
44083
44177
|
init_workspace();
|
|
44084
44178
|
init_base_workspace();
|
|
44085
44179
|
init_worktree_scope();
|
|
@@ -44088,9 +44182,9 @@ var init_bases = __esm({
|
|
|
44088
44182
|
});
|
|
44089
44183
|
|
|
44090
44184
|
// src/data/commands/file-types.ts
|
|
44091
|
-
import { Command as
|
|
44185
|
+
import { Command as Command11 } from "commander";
|
|
44092
44186
|
function buildFileTypesCommand() {
|
|
44093
|
-
const fileTypes = new
|
|
44187
|
+
const fileTypes = new Command11("file-types").description(
|
|
44094
44188
|
"Manage file types (Buckets) \u2014 storage policy + optional metadata schema for files"
|
|
44095
44189
|
);
|
|
44096
44190
|
fileTypes.command("list").description("List all file types in a base").action(async function() {
|
|
@@ -44150,7 +44244,7 @@ var init_file_types = __esm({
|
|
|
44150
44244
|
});
|
|
44151
44245
|
|
|
44152
44246
|
// src/data/commands/files.ts
|
|
44153
|
-
import { Command as
|
|
44247
|
+
import { Command as Command12 } from "commander";
|
|
44154
44248
|
import { readFileSync as readFileSync22, writeFileSync as writeFileSync11 } from "fs";
|
|
44155
44249
|
import { basename as basename29 } from "path";
|
|
44156
44250
|
function renderFileDiff(fileType, filePath3, from, to, d) {
|
|
@@ -44193,7 +44287,7 @@ function downloadTarget(remotePath2, to) {
|
|
|
44193
44287
|
return derived;
|
|
44194
44288
|
}
|
|
44195
44289
|
function buildFilesCommand() {
|
|
44196
|
-
const files = new
|
|
44290
|
+
const files = new Command12("files").description(
|
|
44197
44291
|
"Manage files (path-addressed, versioned content) within a file type"
|
|
44198
44292
|
);
|
|
44199
44293
|
files.command("put <file_type> <path>").description(
|
|
@@ -44400,13 +44494,12 @@ var init_files2 = __esm({
|
|
|
44400
44494
|
});
|
|
44401
44495
|
|
|
44402
44496
|
// src/data/commands/inbound-webhooks.ts
|
|
44403
|
-
import {
|
|
44404
|
-
import { Command as Command12 } from "commander";
|
|
44497
|
+
import { Command as Command13 } from "commander";
|
|
44405
44498
|
function buildInboundWebhooksCommand() {
|
|
44406
|
-
const inboundWebhooks = new
|
|
44499
|
+
const inboundWebhooks = new Command13("inbound-webhooks").description(
|
|
44407
44500
|
"Manage inbound webhook endpoints"
|
|
44408
44501
|
);
|
|
44409
|
-
inboundWebhooks.command("create").description("Create a new inbound webhook").
|
|
44502
|
+
inboundWebhooks.command("create").description("Create a new inbound webhook \u2014 unavailable for now").option("--name <name>", "Inbound webhook name").option("--secret-stdin", "Read the HMAC shared secret from stdin (unavailable for now)").option("--id <id>", "Inbound webhook ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option(
|
|
44410
44503
|
"--field-mapping <json>",
|
|
44411
44504
|
'Inline mapping applied to the payload before write \u2014 a field_mapping JSON, e.g. {"to_external":{"status":"state"}} (to_external renames auto-invert on read); an explicit inbound-rename block and {"computed":{...}} are also accepted. Mutually exclusive with --source-binding.'
|
|
44412
44505
|
).option(
|
|
@@ -44418,38 +44511,8 @@ function buildInboundWebhooksCommand() {
|
|
|
44418
44511
|
).option(
|
|
44419
44512
|
"--hydration <json>",
|
|
44420
44513
|
`Make this a reference-style ("notification + fetch") webhook: a thin delivery names a record id; the base fetches the full record via the bound source's read endpoint and stores it. Requires --source-binding and a single native --record-type-scope. JSON: {"id_path":"record_id","event_path":"event","event_map":{"ResourceDeleted":"delete"},"default_op":"upsert","merge":true}. Set "merge":true to refresh only the mapped (upstream-owned) fields on re-sync and preserve the locally-owned fields (status/tags/scores) on the same record.`
|
|
44421
|
-
).action(
|
|
44422
|
-
|
|
44423
|
-
{
|
|
44424
|
-
stdin: opts.secretStdin,
|
|
44425
|
-
// No prompt flag here — the prompt is this command's default.
|
|
44426
|
-
prompt: void 0,
|
|
44427
|
-
stdinFlag: "--secret-stdin",
|
|
44428
|
-
promptHint: "omit --secret-stdin to be prompted"
|
|
44429
|
-
},
|
|
44430
|
-
"HMAC shared secret"
|
|
44431
|
-
);
|
|
44432
|
-
const body = {
|
|
44433
|
-
name: opts.name,
|
|
44434
|
-
secret,
|
|
44435
|
-
enabled: true
|
|
44436
|
-
};
|
|
44437
|
-
if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
|
|
44438
|
-
if (opts.fieldMapping) body.field_mapping = parseData(opts.fieldMapping);
|
|
44439
|
-
if (opts.sourceBinding) body.source_binding = parseData(opts.sourceBinding);
|
|
44440
|
-
if (opts.ingestAuth) body.ingest_auth = parseData(opts.ingestAuth);
|
|
44441
|
-
if (opts.hydration) body.hydration = parseData(opts.hydration);
|
|
44442
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
44443
|
-
const client = await createDataClient();
|
|
44444
|
-
const inboundWebhookId = opts.id ?? randomUUID2();
|
|
44445
|
-
printOutput(
|
|
44446
|
-
await client.request(
|
|
44447
|
-
"PUT",
|
|
44448
|
-
`/v1/${base}/inbound-webhooks/${pathSegment(inboundWebhookId, "--id")}`,
|
|
44449
|
-
body
|
|
44450
|
-
),
|
|
44451
|
-
outputFormat(this)
|
|
44452
|
-
);
|
|
44514
|
+
).action(() => {
|
|
44515
|
+
throw expected(CREATE_UNAVAILABLE);
|
|
44453
44516
|
});
|
|
44454
44517
|
inboundWebhooks.command("get <id>").description("Get an inbound webhook").action(async function(id) {
|
|
44455
44518
|
const base = pathSegment(requireBase(this), "--base");
|
|
@@ -44490,20 +44553,23 @@ function buildInboundWebhooksCommand() {
|
|
|
44490
44553
|
});
|
|
44491
44554
|
return inboundWebhooks;
|
|
44492
44555
|
}
|
|
44556
|
+
var CREATE_UNAVAILABLE;
|
|
44493
44557
|
var init_inbound_webhooks = __esm({
|
|
44494
44558
|
"src/data/commands/inbound-webhooks.ts"() {
|
|
44495
44559
|
"use strict";
|
|
44560
|
+
init_expected();
|
|
44496
44561
|
init_client();
|
|
44497
44562
|
init_output();
|
|
44498
44563
|
init_helpers();
|
|
44499
44564
|
init_utils();
|
|
44565
|
+
CREATE_UNAVAILABLE = `Creating an inbound webhook is unavailable for now: it is verified against a secret, and ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored.`;
|
|
44500
44566
|
}
|
|
44501
44567
|
});
|
|
44502
44568
|
|
|
44503
44569
|
// src/data/commands/query-relationships.ts
|
|
44504
|
-
import { Command as
|
|
44570
|
+
import { Command as Command14 } from "commander";
|
|
44505
44571
|
function buildQueryRelationshipsCommand() {
|
|
44506
|
-
return new
|
|
44572
|
+
return new Command14("query-relationships").description("Query related records").argument("<record_type>", "RecordType of the source record").argument("<id>", "Source record ID").option("--type <type>", "Filter by relationship type").option("--direction <dir>", "Direction: outgoing, incoming, or both", "both").option("--limit <n>", "Max results", "50").option("--offset <n>", "Skip results", "0").action(async function(recordType2, id, opts) {
|
|
44507
44573
|
const base = pathSegment(requireBase(this), "--base");
|
|
44508
44574
|
const client = await createDataClient();
|
|
44509
44575
|
const params = new URLSearchParams();
|
|
@@ -44536,9 +44602,9 @@ var init_query_relationships = __esm({
|
|
|
44536
44602
|
});
|
|
44537
44603
|
|
|
44538
44604
|
// src/data/commands/record-types.ts
|
|
44539
|
-
import { Command as
|
|
44605
|
+
import { Command as Command15 } from "commander";
|
|
44540
44606
|
function buildRecordTypesCommand() {
|
|
44541
|
-
const recordTypes = new
|
|
44607
|
+
const recordTypes = new Command15("record-types").description("Manage record_types");
|
|
44542
44608
|
recordTypes.command("list").description("List all record_types in a base").action(async function() {
|
|
44543
44609
|
const base = pathSegment(requireBase(this), "--base");
|
|
44544
44610
|
const client = await createDataClient();
|
|
@@ -44596,12 +44662,12 @@ var init_record_types = __esm({
|
|
|
44596
44662
|
});
|
|
44597
44663
|
|
|
44598
44664
|
// src/data/commands/records.ts
|
|
44599
|
-
import { Command as
|
|
44665
|
+
import { Command as Command16 } from "commander";
|
|
44600
44666
|
function recordKey(id, externalSource) {
|
|
44601
44667
|
return externalSource ? foreignSegment(id, "external id") : pathSegment(id, "record id");
|
|
44602
44668
|
}
|
|
44603
44669
|
function buildRecordsCommand() {
|
|
44604
|
-
const records = new
|
|
44670
|
+
const records = new Command16("records").description("Manage records");
|
|
44605
44671
|
records.command("upsert <record_type>").description("Create or update a record").requiredOption("--data <json>", "Record data (inline JSON or @filename)").option("--id <id>", "Internal record ID (UUID) to update a known record").option("--external-id <id>", "External/agent-supplied ID for idempotent upsert").option("--external-source <source>", "Source system for external_id (e.g. stripe)").action(async function(recordType2, opts) {
|
|
44606
44672
|
const base = pathSegment(requireBase(this), "--base");
|
|
44607
44673
|
const client = await createDataClient();
|
|
@@ -44690,9 +44756,9 @@ var init_records = __esm({
|
|
|
44690
44756
|
});
|
|
44691
44757
|
|
|
44692
44758
|
// src/data/commands/relationship-types.ts
|
|
44693
|
-
import { Command as
|
|
44759
|
+
import { Command as Command17 } from "commander";
|
|
44694
44760
|
function buildRelationshipTypesCommand() {
|
|
44695
|
-
const relationshipTypes = new
|
|
44761
|
+
const relationshipTypes = new Command17("relationship-types").description(
|
|
44696
44762
|
"Manage relationship types (the schema for a relationship's metadata)"
|
|
44697
44763
|
);
|
|
44698
44764
|
relationshipTypes.command("list").description("List all relationship types in a base").action(async function() {
|
|
@@ -44769,7 +44835,7 @@ var init_relationship_types = __esm({
|
|
|
44769
44835
|
});
|
|
44770
44836
|
|
|
44771
44837
|
// src/data/commands/relationships.ts
|
|
44772
|
-
import { Command as
|
|
44838
|
+
import { Command as Command18 } from "commander";
|
|
44773
44839
|
function relationshipKey(id, relType) {
|
|
44774
44840
|
return relType ? foreignSegment(id, "external id") : pathSegment(id, "relationship id");
|
|
44775
44841
|
}
|
|
@@ -44805,7 +44871,7 @@ function byKeyQuery(relType, externalSource) {
|
|
|
44805
44871
|
return q ? `?${q}` : "";
|
|
44806
44872
|
}
|
|
44807
44873
|
function buildRelationshipsCommand() {
|
|
44808
|
-
const relationships = new
|
|
44874
|
+
const relationships = new Command18("relationships").description(
|
|
44809
44875
|
"Manage relationships between records"
|
|
44810
44876
|
);
|
|
44811
44877
|
relationships.command("upsert").description("Create or update a relationship").option("--source <record_type/id>", "Source record by internal id").option(
|
|
@@ -44890,9 +44956,9 @@ var init_relationships = __esm({
|
|
|
44890
44956
|
});
|
|
44891
44957
|
|
|
44892
44958
|
// src/data/commands/seed.ts
|
|
44893
|
-
import { Command as
|
|
44959
|
+
import { Command as Command19 } from "commander";
|
|
44894
44960
|
function buildSeedCommand() {
|
|
44895
|
-
const seed = new
|
|
44961
|
+
const seed = new Command19("seed").description(
|
|
44896
44962
|
"Apply, reset, or clear a seed fixture on a preview base (hermetic eval data)"
|
|
44897
44963
|
);
|
|
44898
44964
|
seed.command("apply <name>").description(
|
|
@@ -44984,7 +45050,7 @@ var init_seed = __esm({
|
|
|
44984
45050
|
});
|
|
44985
45051
|
|
|
44986
45052
|
// src/data/commands/toolsets.ts
|
|
44987
|
-
import { Command as
|
|
45053
|
+
import { Command as Command20 } from "commander";
|
|
44988
45054
|
function collect(value, previous) {
|
|
44989
45055
|
return [...previous, value];
|
|
44990
45056
|
}
|
|
@@ -45007,7 +45073,7 @@ function parseRelSpec(spec) {
|
|
|
45007
45073
|
return { rel_type: key, operations: ops };
|
|
45008
45074
|
}
|
|
45009
45075
|
function buildToolsetsCommand() {
|
|
45010
|
-
const toolsets = new
|
|
45076
|
+
const toolsets = new Command20("toolsets").description("Manage MCP toolsets");
|
|
45011
45077
|
toolsets.command("upsert <slug>").description("Create or update an MCP toolset").option("--name <name>", "Toolset display name (required unless using --config)").option("--description <desc>", "Toolset description").option(
|
|
45012
45078
|
"--action <ref>",
|
|
45013
45079
|
"Reference an Action by id, optionally renamed: <action_id> or <action_id>=<surface_name> (repeatable). Create Actions first with `wayai actions upsert`.",
|
|
@@ -45097,104 +45163,6 @@ var init_toolsets = __esm({
|
|
|
45097
45163
|
}
|
|
45098
45164
|
});
|
|
45099
45165
|
|
|
45100
|
-
// src/data/commands/triggers.ts
|
|
45101
|
-
import { randomUUID as randomUUID3 } from "crypto";
|
|
45102
|
-
import { Command as Command20 } from "commander";
|
|
45103
|
-
function buildTriggersCommand() {
|
|
45104
|
-
const triggers = new Command20("triggers").description(
|
|
45105
|
-
"Manage triggers (outbound webhooks, internal writes, external writes)"
|
|
45106
|
-
);
|
|
45107
|
-
triggers.command("create").description(
|
|
45108
|
-
"Create a trigger (a webhook, an internal_write that patches a referenced record, or an external_write that mirrors the record to an external source)"
|
|
45109
|
-
).requiredOption("--name <name>", "Trigger name").requiredOption("--events <events>", "Comma-separated event types").option("--url <url>", "Webhook target URL (webhook actions)").option("--secret-stdin", "Read the webhook HMAC signing secret from stdin (webhook actions)").option("--secret-prompt", "Prompt for the webhook HMAC signing secret, masked (webhook actions)").option(
|
|
45110
|
-
"--action <json>",
|
|
45111
|
-
`Action JSON. webhook {"type":"webhook","url":...,"secret":...}; internal_write {"type":"internal_write","target":"slots","match":{"source_field":"data.slot_id"},"patch":{"status":"busy"},"precondition":{"field":"data.status","op":"eq","value":"free"},"mode":"async"} (mode: "async" applies after the write, "transactional" applies atomically so a precondition miss rolls the write back); external_write {"type":"external_write","record_type":"upstream_appointments","source":"legacy","op":"create","watched_fields":"mapped"} (writes the triggering record through that source's write path \u2014 translation, endpoint, auth \u2014 and links the upstream-assigned id back as external_id; "record_type" defaults to the triggering record_type, "op" defaults from the event; "watched_fields" scopes UPDATE dispatch to writes that changed an upstream-mapped field \u2014 "mapped" = the source's to_external keys, or an explicit array of data fields \u2014 so an overlay-only write skips the redundant upstream push; omit to fire on every update)`
|
|
45112
|
-
).option("--id <id>", "Trigger ID (auto-generated if omitted)").option("--record-type-scope <record_types>", "Comma-separated record_type scope").option("--filter <json>", "Filter expression (JSON)").option(
|
|
45113
|
-
"--skip-cascade-writes <bool>",
|
|
45114
|
-
"Skip firing on cascade-originated (internal_write) writes (default true)"
|
|
45115
|
-
).action(async function(opts) {
|
|
45116
|
-
if (!opts.action && !opts.url) {
|
|
45117
|
-
throw expected("Provide --url (webhook) or --action <json> (e.g. an internal_write action).");
|
|
45118
|
-
}
|
|
45119
|
-
const body = {
|
|
45120
|
-
name: opts.name,
|
|
45121
|
-
events: splitList(opts.events),
|
|
45122
|
-
enabled: true
|
|
45123
|
-
};
|
|
45124
|
-
if (opts.action) {
|
|
45125
|
-
body.action = parseData(opts.action);
|
|
45126
|
-
} else {
|
|
45127
|
-
body.url = opts.url;
|
|
45128
|
-
if (opts.secretStdin || opts.secretPrompt) {
|
|
45129
|
-
body.secret = await readSecret(
|
|
45130
|
-
{
|
|
45131
|
-
stdin: opts.secretStdin,
|
|
45132
|
-
prompt: opts.secretPrompt,
|
|
45133
|
-
stdinFlag: "--secret-stdin",
|
|
45134
|
-
promptHint: "--secret-prompt"
|
|
45135
|
-
},
|
|
45136
|
-
"Webhook signing secret"
|
|
45137
|
-
);
|
|
45138
|
-
}
|
|
45139
|
-
}
|
|
45140
|
-
if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
|
|
45141
|
-
if (opts.filter) body.filter = parseData(opts.filter);
|
|
45142
|
-
if (opts.skipCascadeWrites !== void 0) {
|
|
45143
|
-
body.skip_cascade_writes = opts.skipCascadeWrites !== "false";
|
|
45144
|
-
}
|
|
45145
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45146
|
-
const client = await createDataClient();
|
|
45147
|
-
const triggerId = opts.id ?? randomUUID3();
|
|
45148
|
-
printOutput(
|
|
45149
|
-
await client.request("PUT", `/v1/${base}/triggers/${pathSegment(triggerId, "--id")}`, body),
|
|
45150
|
-
outputFormat(this)
|
|
45151
|
-
);
|
|
45152
|
-
});
|
|
45153
|
-
triggers.command("get <id>").description("Get a trigger").action(async function(id) {
|
|
45154
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45155
|
-
const client = await createDataClient();
|
|
45156
|
-
printOutput(await client.request("GET", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`), outputFormat(this));
|
|
45157
|
-
});
|
|
45158
|
-
triggers.command("list").description("List all triggers").action(async function() {
|
|
45159
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45160
|
-
const client = await createDataClient();
|
|
45161
|
-
printOutput(await client.request("GET", `/v1/${base}/triggers`), outputFormat(this));
|
|
45162
|
-
});
|
|
45163
|
-
triggers.command("deliveries").description("List trigger delivery attempts (status, retries, errors)").option("--status <status>", "Filter by status (pending | delivered | failed | dead)").option("--trigger-id <id>", "Filter by trigger id").action(async function(opts) {
|
|
45164
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45165
|
-
const client = await createDataClient();
|
|
45166
|
-
const params = new URLSearchParams();
|
|
45167
|
-
if (opts.status) params.set("status", opts.status);
|
|
45168
|
-
if (opts.triggerId) params.set("trigger_id", opts.triggerId);
|
|
45169
|
-
const qs = params.toString();
|
|
45170
|
-
printOutput(
|
|
45171
|
-
await client.request("GET", `/v1/${base}/triggers/deliveries${qs ? `?${qs}` : ""}`),
|
|
45172
|
-
outputFormat(this)
|
|
45173
|
-
);
|
|
45174
|
-
});
|
|
45175
|
-
triggers.command("delete <id>").description("Delete a trigger").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
|
|
45176
|
-
if (!opts.yes && !await confirm(`Delete trigger ${id}? This cannot be undone.`)) {
|
|
45177
|
-
console.log("Aborted");
|
|
45178
|
-
return;
|
|
45179
|
-
}
|
|
45180
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45181
|
-
const client = await createDataClient();
|
|
45182
|
-
await client.request("DELETE", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`);
|
|
45183
|
-
console.log("Deleted");
|
|
45184
|
-
});
|
|
45185
|
-
return triggers;
|
|
45186
|
-
}
|
|
45187
|
-
var init_triggers = __esm({
|
|
45188
|
-
"src/data/commands/triggers.ts"() {
|
|
45189
|
-
"use strict";
|
|
45190
|
-
init_expected();
|
|
45191
|
-
init_client();
|
|
45192
|
-
init_output();
|
|
45193
|
-
init_helpers();
|
|
45194
|
-
init_utils();
|
|
45195
|
-
}
|
|
45196
|
-
});
|
|
45197
|
-
|
|
45198
45166
|
// src/data/program.ts
|
|
45199
45167
|
var program_exports = {};
|
|
45200
45168
|
__export(program_exports, {
|