@wayai/cli 0.3.323 → 0.3.325
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 +282 -393
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6244,15 +6244,11 @@ var init_chunk_IPXBFWUU = __esm({
|
|
|
6244
6244
|
});
|
|
6245
6245
|
|
|
6246
6246
|
// ../../packages/core/dist/chunk-AYLAGFAD.js
|
|
6247
|
-
var
|
|
6247
|
+
var BASE_CREDENTIAL_NAME_MAX, BASE_CREDENTIAL_NAME_PATTERN, BASE_CREDENTIAL_NAME_CHARSET, baseCredentialNameSchema;
|
|
6248
6248
|
var init_chunk_AYLAGFAD = __esm({
|
|
6249
6249
|
"../../packages/core/dist/chunk-AYLAGFAD.js"() {
|
|
6250
6250
|
"use strict";
|
|
6251
6251
|
init_zod();
|
|
6252
|
-
BASE_CREDENTIAL_MANAGED_BY = {
|
|
6253
|
-
DIRECT: "direct",
|
|
6254
|
-
ORG_LINK: "org-link"
|
|
6255
|
-
};
|
|
6256
6252
|
BASE_CREDENTIAL_NAME_MAX = 100;
|
|
6257
6253
|
BASE_CREDENTIAL_NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:@+~=-]*$/;
|
|
6258
6254
|
BASE_CREDENTIAL_NAME_CHARSET = "letters, digits and '. _ : @ + ~ = -', starting with a letter or digit";
|
|
@@ -25217,13 +25213,14 @@ function parseDuration(input, flag = "duration") {
|
|
|
25217
25213
|
}
|
|
25218
25214
|
return value * unitMs;
|
|
25219
25215
|
}
|
|
25220
|
-
var DURATION_RE, DURATION_UNIT_MS;
|
|
25216
|
+
var BASE_SECRET_STORAGE_WHY, DURATION_RE, DURATION_UNIT_MS;
|
|
25221
25217
|
var init_helpers = __esm({
|
|
25222
25218
|
"src/data/helpers.ts"() {
|
|
25223
25219
|
"use strict";
|
|
25224
25220
|
init_base_id();
|
|
25225
25221
|
init_expected();
|
|
25226
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";
|
|
25227
25224
|
DURATION_RE = /^(\d+)([smhd])$/;
|
|
25228
25225
|
DURATION_UNIT_MS = {
|
|
25229
25226
|
s: 1e3,
|
|
@@ -25662,6 +25659,207 @@ var init_diff_format = __esm({
|
|
|
25662
25659
|
}
|
|
25663
25660
|
});
|
|
25664
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
|
+
|
|
25665
25863
|
// src/data/config-as-code/sync.ts
|
|
25666
25864
|
var sync_exports = {};
|
|
25667
25865
|
__export(sync_exports, {
|
|
@@ -25846,19 +26044,7 @@ Apply these changes to preview "${sanitizeTerminalText(baseId)}"?`);
|
|
|
25846
26044
|
}
|
|
25847
26045
|
}
|
|
25848
26046
|
const result = await applyConfig(client, baseId, config);
|
|
25849
|
-
|
|
25850
|
-
["trigger", result.new_trigger_secrets],
|
|
25851
|
-
["inbound webhook", result.new_inbound_webhook_secrets]
|
|
25852
|
-
];
|
|
25853
|
-
if (secretGroups.some(([, map]) => map && Object.keys(map).length > 0)) {
|
|
25854
|
-
console.log(`
|
|
25855
|
-
${YELLOW}New secrets (shown once \u2014 save them now):${RESET}`);
|
|
25856
|
-
for (const [kind, map] of secretGroups) {
|
|
25857
|
-
for (const [id, secret] of Object.entries(map ?? {})) {
|
|
25858
|
-
console.log(` ${kind} ${sanitizeTerminalText(id)}: ${secret}`);
|
|
25859
|
-
}
|
|
25860
|
-
}
|
|
25861
|
-
}
|
|
26047
|
+
warnUnsignedTriggers(result.unsigned_triggers);
|
|
25862
26048
|
const removals = collectRemovals(diff);
|
|
25863
26049
|
if (removals.length > 0) {
|
|
25864
26050
|
const word = removals.length === 1 ? "entity" : "entities";
|
|
@@ -25900,6 +26086,7 @@ var init_sync = __esm({
|
|
|
25900
26086
|
init_diff_format();
|
|
25901
26087
|
init_base_workspace();
|
|
25902
26088
|
init_types2();
|
|
26089
|
+
init_triggers();
|
|
25903
26090
|
}
|
|
25904
26091
|
});
|
|
25905
26092
|
|
|
@@ -32413,12 +32600,12 @@ function printQueryRows(rows) {
|
|
|
32413
32600
|
return;
|
|
32414
32601
|
}
|
|
32415
32602
|
const columns = Object.keys(rows[0]);
|
|
32416
|
-
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)));
|
|
32417
32604
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
32418
32605
|
console.log(header);
|
|
32419
32606
|
console.log(columns.map((_, i) => "-".repeat(widths[i])).join(" "));
|
|
32420
32607
|
for (const row of rows) {
|
|
32421
|
-
console.log(columns.map((c, i) =>
|
|
32608
|
+
console.log(columns.map((c, i) => formatCell2(row[c]).padEnd(widths[i])).join(" "));
|
|
32422
32609
|
}
|
|
32423
32610
|
}
|
|
32424
32611
|
function printSqlSchema(data, pathsHeader) {
|
|
@@ -32447,7 +32634,7 @@ ${pathsHeader}`);
|
|
|
32447
32634
|
}
|
|
32448
32635
|
}
|
|
32449
32636
|
}
|
|
32450
|
-
function
|
|
32637
|
+
function formatCell2(value) {
|
|
32451
32638
|
if (value === null || value === void 0) return "";
|
|
32452
32639
|
if (typeof value === "number") return Number.isInteger(value) ? String(value) : value.toFixed(4);
|
|
32453
32640
|
if (typeof value === "object") return JSON.stringify(value);
|
|
@@ -37025,106 +37212,6 @@ var init_list = __esm({
|
|
|
37025
37212
|
}
|
|
37026
37213
|
});
|
|
37027
37214
|
|
|
37028
|
-
// src/data/output.ts
|
|
37029
|
-
function printOutput(data, format) {
|
|
37030
|
-
if (format === "json") {
|
|
37031
|
-
console.log(JSON.stringify(data, null, 2));
|
|
37032
|
-
return;
|
|
37033
|
-
}
|
|
37034
|
-
if (Array.isArray(data)) {
|
|
37035
|
-
printRows(data);
|
|
37036
|
-
return;
|
|
37037
|
-
}
|
|
37038
|
-
if (typeof data === "object" && data !== null) {
|
|
37039
|
-
printFields(data);
|
|
37040
|
-
return;
|
|
37041
|
-
}
|
|
37042
|
-
console.log(formatCell2(data));
|
|
37043
|
-
}
|
|
37044
|
-
function printRows(rows) {
|
|
37045
|
-
if (rows.length === 0) {
|
|
37046
|
-
console.log("(no results)");
|
|
37047
|
-
return;
|
|
37048
|
-
}
|
|
37049
|
-
const columns = [];
|
|
37050
|
-
const seen = /* @__PURE__ */ new Set();
|
|
37051
|
-
for (const row of rows) {
|
|
37052
|
-
for (const key of Object.keys(row ?? {})) {
|
|
37053
|
-
if (seen.has(key)) continue;
|
|
37054
|
-
seen.add(key);
|
|
37055
|
-
columns.push(key);
|
|
37056
|
-
}
|
|
37057
|
-
}
|
|
37058
|
-
const headers = columns.map((c) => sanitizeTerminalText(c));
|
|
37059
|
-
const cells = rows.map((row) => columns.map((c) => cellAt(row, c)));
|
|
37060
|
-
const widths = columns.map(
|
|
37061
|
-
(_, i) => cells.reduce((width, row) => Math.max(width, row[i].length), headers[i].length)
|
|
37062
|
-
);
|
|
37063
|
-
console.log(headers.map((c, i) => c.padEnd(widths[i])).join(" "));
|
|
37064
|
-
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
37065
|
-
for (const row of cells) {
|
|
37066
|
-
console.log(row.map((cell, i) => cell.padEnd(widths[i])).join(" "));
|
|
37067
|
-
}
|
|
37068
|
-
}
|
|
37069
|
-
function printFields(obj) {
|
|
37070
|
-
const entries = Object.entries(obj).map(([key, value]) => ({
|
|
37071
|
-
key: sanitizeTerminalText(key),
|
|
37072
|
-
value
|
|
37073
|
-
}));
|
|
37074
|
-
if (entries.length === 0) {
|
|
37075
|
-
console.log("(empty)");
|
|
37076
|
-
return;
|
|
37077
|
-
}
|
|
37078
|
-
const width = entries.reduce((w, e) => Math.max(w, e.key.length), 0);
|
|
37079
|
-
for (const { key, value } of entries) {
|
|
37080
|
-
console.log(`${key.padEnd(width)} ${formatCell2(value)}`);
|
|
37081
|
-
}
|
|
37082
|
-
}
|
|
37083
|
-
function printBatchResult(response) {
|
|
37084
|
-
const obj = response && typeof response === "object" ? response : {};
|
|
37085
|
-
const results = Array.isArray(obj.results) ? obj.results : [];
|
|
37086
|
-
const batchId = typeof obj.batch_id === "string" ? obj.batch_id : "(none)";
|
|
37087
|
-
console.log(
|
|
37088
|
-
`batch_id: ${sanitizeTerminalText(batchId)} \xB7 ${results.length} operation${results.length === 1 ? "" : "s"}`
|
|
37089
|
-
);
|
|
37090
|
-
if (results.length === 0) return;
|
|
37091
|
-
printRows(
|
|
37092
|
-
results.map((r, i) => ({
|
|
37093
|
-
"#": String(i),
|
|
37094
|
-
operation: r?.type ?? "",
|
|
37095
|
-
result: summarizeBatchResult(r)
|
|
37096
|
-
}))
|
|
37097
|
-
);
|
|
37098
|
-
}
|
|
37099
|
-
function summarizeBatchResult(r) {
|
|
37100
|
-
if (!r || typeof r !== "object") return String(r ?? "");
|
|
37101
|
-
if (r.deleted === true) return "deleted";
|
|
37102
|
-
const entity = r.record ?? r.relationship ?? r.record_type;
|
|
37103
|
-
if (entity && typeof entity === "object") {
|
|
37104
|
-
const e = entity;
|
|
37105
|
-
const id = typeof e.id === "string" ? e.id : void 0;
|
|
37106
|
-
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;
|
|
37107
|
-
const version = e.version != null ? ` v${String(e.version)}` : "";
|
|
37108
|
-
if (id && label3) return `${label3}/${id}${version}`;
|
|
37109
|
-
if (id) return `${id}${version}`;
|
|
37110
|
-
}
|
|
37111
|
-
return JSON.stringify(r);
|
|
37112
|
-
}
|
|
37113
|
-
function cellAt(row, column) {
|
|
37114
|
-
return formatCell2(row?.[column]);
|
|
37115
|
-
}
|
|
37116
|
-
function formatCell2(value) {
|
|
37117
|
-
if (value === null || value === void 0) return "";
|
|
37118
|
-
if (typeof value === "object") return sanitizeTerminalText(JSON.stringify(value));
|
|
37119
|
-
return sanitizeTerminalText(String(value));
|
|
37120
|
-
}
|
|
37121
|
-
var init_output = __esm({
|
|
37122
|
-
"src/data/output.ts"() {
|
|
37123
|
-
"use strict";
|
|
37124
|
-
init_terminal_output();
|
|
37125
|
-
}
|
|
37126
|
-
});
|
|
37127
|
-
|
|
37128
37215
|
// src/commands/communities.ts
|
|
37129
37216
|
var communities_exports = {};
|
|
37130
37217
|
__export(communities_exports, {
|
|
@@ -42785,9 +42872,9 @@ var init_update = __esm({
|
|
|
42785
42872
|
});
|
|
42786
42873
|
|
|
42787
42874
|
// src/data/commands/actions.ts
|
|
42788
|
-
import { Command } from "commander";
|
|
42875
|
+
import { Command as Command2 } from "commander";
|
|
42789
42876
|
function buildActionsCommand() {
|
|
42790
|
-
const actions = new
|
|
42877
|
+
const actions = new Command2("actions").description(
|
|
42791
42878
|
"Manage Actions \u2014 reusable, named definitions: one record_type + one operation, or a composite of atomic write steps (--config with `steps`)"
|
|
42792
42879
|
);
|
|
42793
42880
|
actions.command("upsert <id>").description(
|
|
@@ -42856,7 +42943,7 @@ var init_actions = __esm({
|
|
|
42856
42943
|
});
|
|
42857
42944
|
|
|
42858
42945
|
// src/data/commands/attachments.ts
|
|
42859
|
-
import { Command as
|
|
42946
|
+
import { Command as Command3 } from "commander";
|
|
42860
42947
|
import { readFileSync as readFileSync20 } from "fs";
|
|
42861
42948
|
function findAttachmentByFilename(attachments, filename) {
|
|
42862
42949
|
return attachments.find((a) => a.key.endsWith(`/${filename}`)) ?? null;
|
|
@@ -42883,7 +42970,7 @@ function uploadPathFrom(uploadUrl) {
|
|
|
42883
42970
|
return uploadUrl;
|
|
42884
42971
|
}
|
|
42885
42972
|
function buildAttachmentsCommand() {
|
|
42886
|
-
const attachments = new
|
|
42973
|
+
const attachments = new Command3("attachments").description("Manage record attachments");
|
|
42887
42974
|
attachments.command("upload <record_type> <id>").description(
|
|
42888
42975
|
"Get a presigned upload URL for a record attachment. With --file, uploads the file content in one step."
|
|
42889
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) {
|
|
@@ -42963,9 +43050,9 @@ var init_attachments = __esm({
|
|
|
42963
43050
|
});
|
|
42964
43051
|
|
|
42965
43052
|
// src/data/commands/batch.ts
|
|
42966
|
-
import { Command as
|
|
43053
|
+
import { Command as Command4 } from "commander";
|
|
42967
43054
|
function buildBasesBatchCommand() {
|
|
42968
|
-
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) {
|
|
42969
43056
|
const base = pathSegment(requireBase(this), "--base");
|
|
42970
43057
|
const operations = parseData(opts.operations, "--operations");
|
|
42971
43058
|
const client = await createDataClient();
|
|
@@ -42993,8 +43080,8 @@ var init_batch = __esm({
|
|
|
42993
43080
|
import { createReadStream } from "fs";
|
|
42994
43081
|
import { access, constants, stat } from "fs/promises";
|
|
42995
43082
|
import { createInterface as createInterface3 } from "readline";
|
|
42996
|
-
import { randomUUID } from "crypto";
|
|
42997
|
-
import { Command as
|
|
43083
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
43084
|
+
import { Command as Command5 } from "commander";
|
|
42998
43085
|
function isRetryable(err) {
|
|
42999
43086
|
if (isNetworkError(err)) return true;
|
|
43000
43087
|
if (!(err instanceof ApiError)) return false;
|
|
@@ -43070,7 +43157,7 @@ async function beginSession(state, client, base, recordType2, requestKey) {
|
|
|
43070
43157
|
return res.session;
|
|
43071
43158
|
}
|
|
43072
43159
|
function buildBasesImportCommand() {
|
|
43073
|
-
const importCmd = withBaseOption(new
|
|
43160
|
+
const importCmd = withBaseOption(new Command5("import")).description(
|
|
43074
43161
|
"Bulk historical import: load an NDJSON backfill, list sessions, or undo one"
|
|
43075
43162
|
);
|
|
43076
43163
|
importCmd.command("run <record_type>").description(
|
|
@@ -43109,7 +43196,7 @@ function buildBasesImportCommand() {
|
|
|
43109
43196
|
throw expected(`--file ${opts.file}: not a readable file.`);
|
|
43110
43197
|
}
|
|
43111
43198
|
const client = await createDataClient();
|
|
43112
|
-
const requestKey = opts.requestKey ?? `cli-${
|
|
43199
|
+
const requestKey = opts.requestKey ?? `cli-${randomUUID2()}`;
|
|
43113
43200
|
if (!opts.requestKey) {
|
|
43114
43201
|
console.error(`request_key: ${requestKey} (pass --request-key to resume this run)`);
|
|
43115
43202
|
}
|
|
@@ -43314,7 +43401,7 @@ var init_import = __esm({
|
|
|
43314
43401
|
});
|
|
43315
43402
|
|
|
43316
43403
|
// src/data/commands/providers.ts
|
|
43317
|
-
import { Command as
|
|
43404
|
+
import { Command as Command6 } from "commander";
|
|
43318
43405
|
import { writeFileSync as writeFileSync10 } from "fs";
|
|
43319
43406
|
function providerSegment(provider) {
|
|
43320
43407
|
if (!VALID_PROVIDERS.includes(provider)) {
|
|
@@ -43323,7 +43410,7 @@ function providerSegment(provider) {
|
|
|
43323
43410
|
return pathSegment(provider, "provider");
|
|
43324
43411
|
}
|
|
43325
43412
|
function buildBasesProvidersCommand() {
|
|
43326
|
-
const providers = withBaseOption(new
|
|
43413
|
+
const providers = withBaseOption(new Command6("providers")).description(
|
|
43327
43414
|
"Import/export tool definitions between LLM providers and record types"
|
|
43328
43415
|
);
|
|
43329
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) {
|
|
@@ -43394,34 +43481,9 @@ var init_providers = __esm({
|
|
|
43394
43481
|
});
|
|
43395
43482
|
|
|
43396
43483
|
// src/data/commands/credentials.ts
|
|
43397
|
-
import { Command as
|
|
43398
|
-
import { readFileSync as readFileSync21 } from "fs";
|
|
43484
|
+
import { Command as Command7 } from "commander";
|
|
43399
43485
|
function withValueSourceOptions(cmd, what) {
|
|
43400
|
-
return cmd.option(
|
|
43401
|
-
"--file <path>",
|
|
43402
|
-
`Read ${what} from a file and base64-encode it (certificates, keystores, service-account JSON)`
|
|
43403
|
-
).option("--value-stdin", `Read ${what} from stdin (recommended for CI)`).option("--value-prompt", `Prompt for ${what}, masked`);
|
|
43404
|
-
}
|
|
43405
|
-
async function resolveValue(opts, label3) {
|
|
43406
|
-
if (opts.file !== void 0) {
|
|
43407
|
-
if (opts.valueStdin || opts.valuePrompt) {
|
|
43408
|
-
throw expected("--file cannot be combined with --value-stdin or --value-prompt \u2014 pass one.");
|
|
43409
|
-
}
|
|
43410
|
-
try {
|
|
43411
|
-
return readFileSync21(opts.file).toString("base64");
|
|
43412
|
-
} catch (e) {
|
|
43413
|
-
throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
|
|
43414
|
-
}
|
|
43415
|
-
}
|
|
43416
|
-
return readSecret(
|
|
43417
|
-
{
|
|
43418
|
-
stdin: opts.valueStdin,
|
|
43419
|
-
prompt: opts.valuePrompt,
|
|
43420
|
-
stdinFlag: "--value-stdin",
|
|
43421
|
-
promptHint: "--value-prompt"
|
|
43422
|
-
},
|
|
43423
|
-
label3
|
|
43424
|
-
);
|
|
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)`);
|
|
43425
43487
|
}
|
|
43426
43488
|
function credentialPath(base, id) {
|
|
43427
43489
|
const root = `/v1/${pathSegment(base, "base id")}/credentials`;
|
|
@@ -43429,31 +43491,13 @@ function credentialPath(base, id) {
|
|
|
43429
43491
|
}
|
|
43430
43492
|
function buildBasesCredentialsCommand() {
|
|
43431
43493
|
const credentials = withBaseOption(
|
|
43432
|
-
new
|
|
43494
|
+
new Command7("credentials").description("Manage a base's integration credentials")
|
|
43433
43495
|
);
|
|
43434
43496
|
withValueSourceOptions(
|
|
43435
|
-
credentials.command("create").description("Store a credential on this base
|
|
43436
|
-
"--expires-at <date>",
|
|
43437
|
-
"Expiry as ISO-8601 (e.g. 2027-01-01T00:00:00Z) \u2014 informational; nothing is auto-disabled"
|
|
43438
|
-
).option(
|
|
43439
|
-
"--no-sync-to-production",
|
|
43440
|
-
"Do not publish this credential on promote \u2014 production owns its own value"
|
|
43441
|
-
),
|
|
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)"),
|
|
43442
43498
|
"the credential value"
|
|
43443
|
-
).action(
|
|
43444
|
-
|
|
43445
|
-
const body = {
|
|
43446
|
-
name: opts.name,
|
|
43447
|
-
value: await resolveValue(opts, "Credential value")
|
|
43448
|
-
};
|
|
43449
|
-
if (opts.contentType) body.content_type = opts.contentType;
|
|
43450
|
-
if (opts.expiresAt) body.expires_at = opts.expiresAt;
|
|
43451
|
-
if (opts.syncToProduction === false) body.sync_to_production = false;
|
|
43452
|
-
const client = await createDataClient();
|
|
43453
|
-
printOutput(
|
|
43454
|
-
await client.request("POST", credentialPath(base), body),
|
|
43455
|
-
outputFormat(this)
|
|
43456
|
-
);
|
|
43499
|
+
).action(() => {
|
|
43500
|
+
throw expected(STORAGE_UNAVAILABLE);
|
|
43457
43501
|
});
|
|
43458
43502
|
credentials.command("list").description("List this base's credentials (values are never returned)").action(async function() {
|
|
43459
43503
|
const base = requireBase(this);
|
|
@@ -43472,42 +43516,13 @@ function buildBasesCredentialsCommand() {
|
|
|
43472
43516
|
);
|
|
43473
43517
|
});
|
|
43474
43518
|
withValueSourceOptions(
|
|
43475
|
-
credentials.command("rotate <id>").description("Install a new
|
|
43519
|
+
credentials.command("rotate <id>").description("Install a new value \u2014 unavailable for now").option("--expires-at <date>", "Set the rotated credential's new expiry (ISO-8601)"),
|
|
43476
43520
|
"the new credential value"
|
|
43477
|
-
).action(
|
|
43478
|
-
|
|
43479
|
-
const client = await createDataClient();
|
|
43480
|
-
const existing = await client.request(
|
|
43481
|
-
"GET",
|
|
43482
|
-
credentialPath(base, id)
|
|
43483
|
-
);
|
|
43484
|
-
if (existing?.managed_by === BASE_CREDENTIAL_MANAGED_BY.ORG_LINK) {
|
|
43485
|
-
throw expected(
|
|
43486
|
-
`"${existing.name ?? id}" mirrors an organization credential, and linking organization credentials into bases is retired. Create a direct credential under another name, and point the references at it; deleting the organization credential removes this row.`
|
|
43487
|
-
);
|
|
43488
|
-
}
|
|
43489
|
-
const body = { value: await resolveValue(opts, "New credential value") };
|
|
43490
|
-
if (opts.expiresAt) body.expires_at = opts.expiresAt;
|
|
43491
|
-
printOutput(
|
|
43492
|
-
await client.request(
|
|
43493
|
-
"POST",
|
|
43494
|
-
`${credentialPath(base, id)}/rotate`,
|
|
43495
|
-
body
|
|
43496
|
-
),
|
|
43497
|
-
outputFormat(this)
|
|
43498
|
-
);
|
|
43521
|
+
).action(() => {
|
|
43522
|
+
throw expected(STORAGE_UNAVAILABLE);
|
|
43499
43523
|
});
|
|
43500
|
-
credentials.command("set-sync <id>").description(
|
|
43501
|
-
"
|
|
43502
|
-
).option("--no-sync-to-production", "Do not publish this credential on promote").action(async function(id, opts) {
|
|
43503
|
-
const base = requireBase(this);
|
|
43504
|
-
const client = await createDataClient();
|
|
43505
|
-
printOutput(
|
|
43506
|
-
await client.request("PUT", credentialPath(base, id), {
|
|
43507
|
-
sync_to_production: opts.syncToProduction
|
|
43508
|
-
}),
|
|
43509
|
-
outputFormat(this)
|
|
43510
|
-
);
|
|
43524
|
+
credentials.command("set-sync <id>").description("Set the promote-time publish flag \u2014 unavailable for now: promotion carries no credential").option("--no-sync-to-production", "Do not publish this credential on promote (unavailable for now)").action(() => {
|
|
43525
|
+
throw expected("Promotion carries no base credential for now, so the publish flag has no effect. Nothing was changed.");
|
|
43511
43526
|
});
|
|
43512
43527
|
credentials.command("delete <id>").description("Delete a direct credential").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
|
|
43513
43528
|
const base = requireBase(this);
|
|
@@ -43526,6 +43541,7 @@ function buildBasesCredentialsCommand() {
|
|
|
43526
43541
|
});
|
|
43527
43542
|
return credentials;
|
|
43528
43543
|
}
|
|
43544
|
+
var STORAGE_UNAVAILABLE;
|
|
43529
43545
|
var init_credentials = __esm({
|
|
43530
43546
|
"src/data/commands/credentials.ts"() {
|
|
43531
43547
|
"use strict";
|
|
@@ -43534,15 +43550,15 @@ var init_credentials = __esm({
|
|
|
43534
43550
|
init_helpers();
|
|
43535
43551
|
init_utils();
|
|
43536
43552
|
init_expected();
|
|
43537
|
-
|
|
43553
|
+
STORAGE_UNAVAILABLE = `Storing a base credential is unavailable for now: ${BASE_SECRET_STORAGE_WHY}. Nothing was read or stored.`;
|
|
43538
43554
|
}
|
|
43539
43555
|
});
|
|
43540
43556
|
|
|
43541
43557
|
// src/data/commands/sql.ts
|
|
43542
|
-
import { Command as
|
|
43543
|
-
import { readFileSync as
|
|
43558
|
+
import { Command as Command8 } from "commander";
|
|
43559
|
+
import { readFileSync as readFileSync21 } from "fs";
|
|
43544
43560
|
function buildBasesSqlCommand() {
|
|
43545
|
-
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(
|
|
43546
43562
|
"--param <kv...>",
|
|
43547
43563
|
"Named parameters as key=value pairs (e.g. --param status=issued)"
|
|
43548
43564
|
).action(async function(queryArg, opts) {
|
|
@@ -43550,7 +43566,7 @@ function buildBasesSqlCommand() {
|
|
|
43550
43566
|
let query;
|
|
43551
43567
|
if (opts.file) {
|
|
43552
43568
|
try {
|
|
43553
|
-
query =
|
|
43569
|
+
query = readFileSync21(opts.file, "utf-8").trim();
|
|
43554
43570
|
} catch (e) {
|
|
43555
43571
|
throw expected(`--file ${opts.file}: ${e instanceof Error ? e.message : "could not be read"}`);
|
|
43556
43572
|
}
|
|
@@ -43585,7 +43601,7 @@ var init_sql = __esm({
|
|
|
43585
43601
|
});
|
|
43586
43602
|
|
|
43587
43603
|
// src/data/commands/tokens.ts
|
|
43588
|
-
import { Command as
|
|
43604
|
+
import { Command as Command9 } from "commander";
|
|
43589
43605
|
function rawTokenFrom(data) {
|
|
43590
43606
|
const token = typeof data === "object" && data !== null && "token" in data ? data.token : void 0;
|
|
43591
43607
|
if (typeof token !== "string" || !RAW_TOKEN_PATTERN.test(token)) {
|
|
@@ -43643,7 +43659,7 @@ function pruneRow(t, reason2) {
|
|
|
43643
43659
|
};
|
|
43644
43660
|
}
|
|
43645
43661
|
function buildBasesTokensCommand() {
|
|
43646
|
-
const tokens2 = new
|
|
43662
|
+
const tokens2 = new Command9("tokens").description("Manage API tokens");
|
|
43647
43663
|
addTokenLifecycleOptions(
|
|
43648
43664
|
tokens2.command("create").description("Create a scoped API token").requiredOption("--name <name>", "Token name").requiredOption("--grants <json>", "Grant definitions as JSON array").option(
|
|
43649
43665
|
"--token-only",
|
|
@@ -43885,7 +43901,7 @@ var init_base_tags = __esm({
|
|
|
43885
43901
|
});
|
|
43886
43902
|
|
|
43887
43903
|
// src/data/commands/bases.ts
|
|
43888
|
-
import { Command as
|
|
43904
|
+
import { Command as Command10 } from "commander";
|
|
43889
43905
|
function pageOf(path45, cursor) {
|
|
43890
43906
|
if (!cursor) return path45;
|
|
43891
43907
|
return `${path45}${path45.includes("?") ? "&" : "?"}cursor=${encodeURIComponent(cursor)}`;
|
|
@@ -43898,7 +43914,7 @@ function parseEnum(flag, value, allowed) {
|
|
|
43898
43914
|
return value;
|
|
43899
43915
|
}
|
|
43900
43916
|
function buildBasesCommand() {
|
|
43901
|
-
const bases = new
|
|
43917
|
+
const bases = new Command10("bases").description("Manage bases");
|
|
43902
43918
|
bases.command("list").description("List all bases").option("--tag <tag>", "Filter by tag").action(async function(opts) {
|
|
43903
43919
|
const client = await createDataClient();
|
|
43904
43920
|
const qs = opts.tag ? `?tag=${encodeURIComponent(opts.tag)}` : "";
|
|
@@ -44064,27 +44080,25 @@ function buildBasesCommand() {
|
|
|
44064
44080
|
printOutput(data, outputFormat(this));
|
|
44065
44081
|
const warnings = data?.source_credential_warnings ?? [];
|
|
44066
44082
|
if (warnings.length > 0) {
|
|
44067
|
-
console.warn(
|
|
44068
|
-
"\nINLINE external-source secrets are NOT carried over by promotion \u2014 set these on production before the source will work:"
|
|
44069
|
-
);
|
|
44083
|
+
console.warn("\nSources with an INLINE secret that production will lack:");
|
|
44070
44084
|
for (const w of warnings) console.warn(` - ${sanitizeTerminalText(w.message)}`);
|
|
44071
44085
|
}
|
|
44072
44086
|
const unresolved = data?.unresolved_credentials ?? [];
|
|
44073
44087
|
if (unresolved.length > 0) {
|
|
44074
|
-
console.warn(
|
|
44075
|
-
"\nReferenced credentials production will still lack after this promotion:"
|
|
44076
|
-
);
|
|
44088
|
+
console.warn("\nReferenced credentials production lacks:");
|
|
44077
44089
|
for (const w of unresolved) console.warn(` - ${sanitizeTerminalText(w.message)}`);
|
|
44078
44090
|
}
|
|
44091
|
+
warnUnsignedTriggers(data?.unsigned_triggers);
|
|
44079
44092
|
});
|
|
44080
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) {
|
|
44081
44094
|
const client = await createDataClient();
|
|
44082
|
-
|
|
44083
|
-
|
|
44084
|
-
|
|
44085
|
-
}
|
|
44086
|
-
outputFormat(this)
|
|
44095
|
+
const data = await client.request(
|
|
44096
|
+
"POST",
|
|
44097
|
+
`/v1/${pathSegment(productionId, "production base id")}/promote/rollback`,
|
|
44098
|
+
{ promotion_id: opts.promotion }
|
|
44087
44099
|
);
|
|
44100
|
+
printOutput(data, outputFormat(this));
|
|
44101
|
+
warnUnsignedTriggers(data?.unsigned_triggers);
|
|
44088
44102
|
});
|
|
44089
44103
|
bases.command("promotions <production-id>").description("List promotion history for a production base").action(async function(productionId) {
|
|
44090
44104
|
const client = await createDataClient();
|
|
@@ -44159,6 +44173,7 @@ var init_bases = __esm({
|
|
|
44159
44173
|
init_helpers();
|
|
44160
44174
|
init_utils();
|
|
44161
44175
|
init_terminal_output();
|
|
44176
|
+
init_triggers();
|
|
44162
44177
|
init_workspace();
|
|
44163
44178
|
init_base_workspace();
|
|
44164
44179
|
init_worktree_scope();
|
|
@@ -44167,9 +44182,9 @@ var init_bases = __esm({
|
|
|
44167
44182
|
});
|
|
44168
44183
|
|
|
44169
44184
|
// src/data/commands/file-types.ts
|
|
44170
|
-
import { Command as
|
|
44185
|
+
import { Command as Command11 } from "commander";
|
|
44171
44186
|
function buildFileTypesCommand() {
|
|
44172
|
-
const fileTypes = new
|
|
44187
|
+
const fileTypes = new Command11("file-types").description(
|
|
44173
44188
|
"Manage file types (Buckets) \u2014 storage policy + optional metadata schema for files"
|
|
44174
44189
|
);
|
|
44175
44190
|
fileTypes.command("list").description("List all file types in a base").action(async function() {
|
|
@@ -44229,8 +44244,8 @@ var init_file_types = __esm({
|
|
|
44229
44244
|
});
|
|
44230
44245
|
|
|
44231
44246
|
// src/data/commands/files.ts
|
|
44232
|
-
import { Command as
|
|
44233
|
-
import { readFileSync as
|
|
44247
|
+
import { Command as Command12 } from "commander";
|
|
44248
|
+
import { readFileSync as readFileSync22, writeFileSync as writeFileSync11 } from "fs";
|
|
44234
44249
|
import { basename as basename29 } from "path";
|
|
44235
44250
|
function renderFileDiff(fileType, filePath3, from, to, d) {
|
|
44236
44251
|
console.log(sanitizeTerminalText(`${fileType}/${filePath3}: v${from} \u2192 v${to}`));
|
|
@@ -44272,7 +44287,7 @@ function downloadTarget(remotePath2, to) {
|
|
|
44272
44287
|
return derived;
|
|
44273
44288
|
}
|
|
44274
44289
|
function buildFilesCommand() {
|
|
44275
|
-
const files = new
|
|
44290
|
+
const files = new Command12("files").description(
|
|
44276
44291
|
"Manage files (path-addressed, versioned content) within a file type"
|
|
44277
44292
|
);
|
|
44278
44293
|
files.command("put <file_type> <path>").description(
|
|
@@ -44287,7 +44302,7 @@ function buildFilesCommand() {
|
|
|
44287
44302
|
label: opts.label,
|
|
44288
44303
|
metadata: opts.metadata === void 0 ? void 0 : parseData(opts.metadata, "--metadata")
|
|
44289
44304
|
});
|
|
44290
|
-
const body =
|
|
44305
|
+
const body = readFileSync22(opts.file);
|
|
44291
44306
|
const client = await createDataClient();
|
|
44292
44307
|
printOutput(
|
|
44293
44308
|
await client.upload(
|
|
@@ -44479,13 +44494,12 @@ var init_files2 = __esm({
|
|
|
44479
44494
|
});
|
|
44480
44495
|
|
|
44481
44496
|
// src/data/commands/inbound-webhooks.ts
|
|
44482
|
-
import {
|
|
44483
|
-
import { Command as Command12 } from "commander";
|
|
44497
|
+
import { Command as Command13 } from "commander";
|
|
44484
44498
|
function buildInboundWebhooksCommand() {
|
|
44485
|
-
const inboundWebhooks = new
|
|
44499
|
+
const inboundWebhooks = new Command13("inbound-webhooks").description(
|
|
44486
44500
|
"Manage inbound webhook endpoints"
|
|
44487
44501
|
);
|
|
44488
|
-
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(
|
|
44489
44503
|
"--field-mapping <json>",
|
|
44490
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.'
|
|
44491
44505
|
).option(
|
|
@@ -44497,38 +44511,8 @@ function buildInboundWebhooksCommand() {
|
|
|
44497
44511
|
).option(
|
|
44498
44512
|
"--hydration <json>",
|
|
44499
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.`
|
|
44500
|
-
).action(
|
|
44501
|
-
|
|
44502
|
-
{
|
|
44503
|
-
stdin: opts.secretStdin,
|
|
44504
|
-
// No prompt flag here — the prompt is this command's default.
|
|
44505
|
-
prompt: void 0,
|
|
44506
|
-
stdinFlag: "--secret-stdin",
|
|
44507
|
-
promptHint: "omit --secret-stdin to be prompted"
|
|
44508
|
-
},
|
|
44509
|
-
"HMAC shared secret"
|
|
44510
|
-
);
|
|
44511
|
-
const body = {
|
|
44512
|
-
name: opts.name,
|
|
44513
|
-
secret,
|
|
44514
|
-
enabled: true
|
|
44515
|
-
};
|
|
44516
|
-
if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
|
|
44517
|
-
if (opts.fieldMapping) body.field_mapping = parseData(opts.fieldMapping);
|
|
44518
|
-
if (opts.sourceBinding) body.source_binding = parseData(opts.sourceBinding);
|
|
44519
|
-
if (opts.ingestAuth) body.ingest_auth = parseData(opts.ingestAuth);
|
|
44520
|
-
if (opts.hydration) body.hydration = parseData(opts.hydration);
|
|
44521
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
44522
|
-
const client = await createDataClient();
|
|
44523
|
-
const inboundWebhookId = opts.id ?? randomUUID2();
|
|
44524
|
-
printOutput(
|
|
44525
|
-
await client.request(
|
|
44526
|
-
"PUT",
|
|
44527
|
-
`/v1/${base}/inbound-webhooks/${pathSegment(inboundWebhookId, "--id")}`,
|
|
44528
|
-
body
|
|
44529
|
-
),
|
|
44530
|
-
outputFormat(this)
|
|
44531
|
-
);
|
|
44514
|
+
).action(() => {
|
|
44515
|
+
throw expected(CREATE_UNAVAILABLE);
|
|
44532
44516
|
});
|
|
44533
44517
|
inboundWebhooks.command("get <id>").description("Get an inbound webhook").action(async function(id) {
|
|
44534
44518
|
const base = pathSegment(requireBase(this), "--base");
|
|
@@ -44569,20 +44553,23 @@ function buildInboundWebhooksCommand() {
|
|
|
44569
44553
|
});
|
|
44570
44554
|
return inboundWebhooks;
|
|
44571
44555
|
}
|
|
44556
|
+
var CREATE_UNAVAILABLE;
|
|
44572
44557
|
var init_inbound_webhooks = __esm({
|
|
44573
44558
|
"src/data/commands/inbound-webhooks.ts"() {
|
|
44574
44559
|
"use strict";
|
|
44560
|
+
init_expected();
|
|
44575
44561
|
init_client();
|
|
44576
44562
|
init_output();
|
|
44577
44563
|
init_helpers();
|
|
44578
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.`;
|
|
44579
44566
|
}
|
|
44580
44567
|
});
|
|
44581
44568
|
|
|
44582
44569
|
// src/data/commands/query-relationships.ts
|
|
44583
|
-
import { Command as
|
|
44570
|
+
import { Command as Command14 } from "commander";
|
|
44584
44571
|
function buildQueryRelationshipsCommand() {
|
|
44585
|
-
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) {
|
|
44586
44573
|
const base = pathSegment(requireBase(this), "--base");
|
|
44587
44574
|
const client = await createDataClient();
|
|
44588
44575
|
const params = new URLSearchParams();
|
|
@@ -44615,9 +44602,9 @@ var init_query_relationships = __esm({
|
|
|
44615
44602
|
});
|
|
44616
44603
|
|
|
44617
44604
|
// src/data/commands/record-types.ts
|
|
44618
|
-
import { Command as
|
|
44605
|
+
import { Command as Command15 } from "commander";
|
|
44619
44606
|
function buildRecordTypesCommand() {
|
|
44620
|
-
const recordTypes = new
|
|
44607
|
+
const recordTypes = new Command15("record-types").description("Manage record_types");
|
|
44621
44608
|
recordTypes.command("list").description("List all record_types in a base").action(async function() {
|
|
44622
44609
|
const base = pathSegment(requireBase(this), "--base");
|
|
44623
44610
|
const client = await createDataClient();
|
|
@@ -44675,12 +44662,12 @@ var init_record_types = __esm({
|
|
|
44675
44662
|
});
|
|
44676
44663
|
|
|
44677
44664
|
// src/data/commands/records.ts
|
|
44678
|
-
import { Command as
|
|
44665
|
+
import { Command as Command16 } from "commander";
|
|
44679
44666
|
function recordKey(id, externalSource) {
|
|
44680
44667
|
return externalSource ? foreignSegment(id, "external id") : pathSegment(id, "record id");
|
|
44681
44668
|
}
|
|
44682
44669
|
function buildRecordsCommand() {
|
|
44683
|
-
const records = new
|
|
44670
|
+
const records = new Command16("records").description("Manage records");
|
|
44684
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) {
|
|
44685
44672
|
const base = pathSegment(requireBase(this), "--base");
|
|
44686
44673
|
const client = await createDataClient();
|
|
@@ -44769,9 +44756,9 @@ var init_records = __esm({
|
|
|
44769
44756
|
});
|
|
44770
44757
|
|
|
44771
44758
|
// src/data/commands/relationship-types.ts
|
|
44772
|
-
import { Command as
|
|
44759
|
+
import { Command as Command17 } from "commander";
|
|
44773
44760
|
function buildRelationshipTypesCommand() {
|
|
44774
|
-
const relationshipTypes = new
|
|
44761
|
+
const relationshipTypes = new Command17("relationship-types").description(
|
|
44775
44762
|
"Manage relationship types (the schema for a relationship's metadata)"
|
|
44776
44763
|
);
|
|
44777
44764
|
relationshipTypes.command("list").description("List all relationship types in a base").action(async function() {
|
|
@@ -44848,7 +44835,7 @@ var init_relationship_types = __esm({
|
|
|
44848
44835
|
});
|
|
44849
44836
|
|
|
44850
44837
|
// src/data/commands/relationships.ts
|
|
44851
|
-
import { Command as
|
|
44838
|
+
import { Command as Command18 } from "commander";
|
|
44852
44839
|
function relationshipKey(id, relType) {
|
|
44853
44840
|
return relType ? foreignSegment(id, "external id") : pathSegment(id, "relationship id");
|
|
44854
44841
|
}
|
|
@@ -44884,7 +44871,7 @@ function byKeyQuery(relType, externalSource) {
|
|
|
44884
44871
|
return q ? `?${q}` : "";
|
|
44885
44872
|
}
|
|
44886
44873
|
function buildRelationshipsCommand() {
|
|
44887
|
-
const relationships = new
|
|
44874
|
+
const relationships = new Command18("relationships").description(
|
|
44888
44875
|
"Manage relationships between records"
|
|
44889
44876
|
);
|
|
44890
44877
|
relationships.command("upsert").description("Create or update a relationship").option("--source <record_type/id>", "Source record by internal id").option(
|
|
@@ -44969,9 +44956,9 @@ var init_relationships = __esm({
|
|
|
44969
44956
|
});
|
|
44970
44957
|
|
|
44971
44958
|
// src/data/commands/seed.ts
|
|
44972
|
-
import { Command as
|
|
44959
|
+
import { Command as Command19 } from "commander";
|
|
44973
44960
|
function buildSeedCommand() {
|
|
44974
|
-
const seed = new
|
|
44961
|
+
const seed = new Command19("seed").description(
|
|
44975
44962
|
"Apply, reset, or clear a seed fixture on a preview base (hermetic eval data)"
|
|
44976
44963
|
);
|
|
44977
44964
|
seed.command("apply <name>").description(
|
|
@@ -45063,7 +45050,7 @@ var init_seed = __esm({
|
|
|
45063
45050
|
});
|
|
45064
45051
|
|
|
45065
45052
|
// src/data/commands/toolsets.ts
|
|
45066
|
-
import { Command as
|
|
45053
|
+
import { Command as Command20 } from "commander";
|
|
45067
45054
|
function collect(value, previous) {
|
|
45068
45055
|
return [...previous, value];
|
|
45069
45056
|
}
|
|
@@ -45086,7 +45073,7 @@ function parseRelSpec(spec) {
|
|
|
45086
45073
|
return { rel_type: key, operations: ops };
|
|
45087
45074
|
}
|
|
45088
45075
|
function buildToolsetsCommand() {
|
|
45089
|
-
const toolsets = new
|
|
45076
|
+
const toolsets = new Command20("toolsets").description("Manage MCP toolsets");
|
|
45090
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(
|
|
45091
45078
|
"--action <ref>",
|
|
45092
45079
|
"Reference an Action by id, optionally renamed: <action_id> or <action_id>=<surface_name> (repeatable). Create Actions first with `wayai actions upsert`.",
|
|
@@ -45176,104 +45163,6 @@ var init_toolsets = __esm({
|
|
|
45176
45163
|
}
|
|
45177
45164
|
});
|
|
45178
45165
|
|
|
45179
|
-
// src/data/commands/triggers.ts
|
|
45180
|
-
import { randomUUID as randomUUID3 } from "crypto";
|
|
45181
|
-
import { Command as Command20 } from "commander";
|
|
45182
|
-
function buildTriggersCommand() {
|
|
45183
|
-
const triggers = new Command20("triggers").description(
|
|
45184
|
-
"Manage triggers (outbound webhooks, internal writes, external writes)"
|
|
45185
|
-
);
|
|
45186
|
-
triggers.command("create").description(
|
|
45187
|
-
"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)"
|
|
45188
|
-
).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(
|
|
45189
|
-
"--action <json>",
|
|
45190
|
-
`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)`
|
|
45191
|
-
).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(
|
|
45192
|
-
"--skip-cascade-writes <bool>",
|
|
45193
|
-
"Skip firing on cascade-originated (internal_write) writes (default true)"
|
|
45194
|
-
).action(async function(opts) {
|
|
45195
|
-
if (!opts.action && !opts.url) {
|
|
45196
|
-
throw expected("Provide --url (webhook) or --action <json> (e.g. an internal_write action).");
|
|
45197
|
-
}
|
|
45198
|
-
const body = {
|
|
45199
|
-
name: opts.name,
|
|
45200
|
-
events: splitList(opts.events),
|
|
45201
|
-
enabled: true
|
|
45202
|
-
};
|
|
45203
|
-
if (opts.action) {
|
|
45204
|
-
body.action = parseData(opts.action);
|
|
45205
|
-
} else {
|
|
45206
|
-
body.url = opts.url;
|
|
45207
|
-
if (opts.secretStdin || opts.secretPrompt) {
|
|
45208
|
-
body.secret = await readSecret(
|
|
45209
|
-
{
|
|
45210
|
-
stdin: opts.secretStdin,
|
|
45211
|
-
prompt: opts.secretPrompt,
|
|
45212
|
-
stdinFlag: "--secret-stdin",
|
|
45213
|
-
promptHint: "--secret-prompt"
|
|
45214
|
-
},
|
|
45215
|
-
"Webhook signing secret"
|
|
45216
|
-
);
|
|
45217
|
-
}
|
|
45218
|
-
}
|
|
45219
|
-
if (opts.recordTypeScope) body.record_type_scope = splitList(opts.recordTypeScope);
|
|
45220
|
-
if (opts.filter) body.filter = parseData(opts.filter);
|
|
45221
|
-
if (opts.skipCascadeWrites !== void 0) {
|
|
45222
|
-
body.skip_cascade_writes = opts.skipCascadeWrites !== "false";
|
|
45223
|
-
}
|
|
45224
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45225
|
-
const client = await createDataClient();
|
|
45226
|
-
const triggerId = opts.id ?? randomUUID3();
|
|
45227
|
-
printOutput(
|
|
45228
|
-
await client.request("PUT", `/v1/${base}/triggers/${pathSegment(triggerId, "--id")}`, body),
|
|
45229
|
-
outputFormat(this)
|
|
45230
|
-
);
|
|
45231
|
-
});
|
|
45232
|
-
triggers.command("get <id>").description("Get a trigger").action(async function(id) {
|
|
45233
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45234
|
-
const client = await createDataClient();
|
|
45235
|
-
printOutput(await client.request("GET", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`), outputFormat(this));
|
|
45236
|
-
});
|
|
45237
|
-
triggers.command("list").description("List all triggers").action(async function() {
|
|
45238
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45239
|
-
const client = await createDataClient();
|
|
45240
|
-
printOutput(await client.request("GET", `/v1/${base}/triggers`), outputFormat(this));
|
|
45241
|
-
});
|
|
45242
|
-
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) {
|
|
45243
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45244
|
-
const client = await createDataClient();
|
|
45245
|
-
const params = new URLSearchParams();
|
|
45246
|
-
if (opts.status) params.set("status", opts.status);
|
|
45247
|
-
if (opts.triggerId) params.set("trigger_id", opts.triggerId);
|
|
45248
|
-
const qs = params.toString();
|
|
45249
|
-
printOutput(
|
|
45250
|
-
await client.request("GET", `/v1/${base}/triggers/deliveries${qs ? `?${qs}` : ""}`),
|
|
45251
|
-
outputFormat(this)
|
|
45252
|
-
);
|
|
45253
|
-
});
|
|
45254
|
-
triggers.command("delete <id>").description("Delete a trigger").option("-y, --yes", "Skip confirmation prompt").action(async function(id, opts) {
|
|
45255
|
-
if (!opts.yes && !await confirm(`Delete trigger ${id}? This cannot be undone.`)) {
|
|
45256
|
-
console.log("Aborted");
|
|
45257
|
-
return;
|
|
45258
|
-
}
|
|
45259
|
-
const base = pathSegment(requireBase(this), "--base");
|
|
45260
|
-
const client = await createDataClient();
|
|
45261
|
-
await client.request("DELETE", `/v1/${base}/triggers/${pathSegment(id, "trigger id")}`);
|
|
45262
|
-
console.log("Deleted");
|
|
45263
|
-
});
|
|
45264
|
-
return triggers;
|
|
45265
|
-
}
|
|
45266
|
-
var init_triggers = __esm({
|
|
45267
|
-
"src/data/commands/triggers.ts"() {
|
|
45268
|
-
"use strict";
|
|
45269
|
-
init_expected();
|
|
45270
|
-
init_client();
|
|
45271
|
-
init_output();
|
|
45272
|
-
init_helpers();
|
|
45273
|
-
init_utils();
|
|
45274
|
-
}
|
|
45275
|
-
});
|
|
45276
|
-
|
|
45277
45166
|
// src/data/program.ts
|
|
45278
45167
|
var program_exports = {};
|
|
45279
45168
|
__export(program_exports, {
|
|
@@ -45376,7 +45265,7 @@ init_errors3();
|
|
|
45376
45265
|
init_mask_secrets();
|
|
45377
45266
|
init_utils();
|
|
45378
45267
|
init_registry();
|
|
45379
|
-
import { readFileSync as
|
|
45268
|
+
import { readFileSync as readFileSync23 } from "fs";
|
|
45380
45269
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
45381
45270
|
import { dirname as dirname16, join as join39 } from "path";
|
|
45382
45271
|
|
|
@@ -45534,7 +45423,7 @@ Run \`wayai admin skill install\` to update.`);
|
|
|
45534
45423
|
|
|
45535
45424
|
// src/index.ts
|
|
45536
45425
|
var __dirname = dirname16(fileURLToPath2(import.meta.url));
|
|
45537
|
-
var pkg = JSON.parse(
|
|
45426
|
+
var pkg = JSON.parse(readFileSync23(join39(__dirname, "..", "package.json"), "utf-8"));
|
|
45538
45427
|
var [, , command, ...args] = process.argv;
|
|
45539
45428
|
var isBackgroundRefresh = command === REFRESH_COMMAND;
|
|
45540
45429
|
if (!isBackgroundRefresh) initSentry(command, pkg.version);
|