@thecorporation/cli 26.3.45 → 26.3.47
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 +559 -642
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9,174 +9,6 @@ var __export = (target, all) => {
|
|
|
9
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
// src/animation.ts
|
|
13
|
-
function renderFrame(frame) {
|
|
14
|
-
const cols = [];
|
|
15
|
-
for (let i = 0; i < BUILDINGS.length; i++) {
|
|
16
|
-
const building = BUILDINGS[i];
|
|
17
|
-
const h = building.length;
|
|
18
|
-
const visible = Math.max(0, Math.min(h, frame - i));
|
|
19
|
-
const width = building[0]?.length ?? 6;
|
|
20
|
-
const blank = " ".repeat(width);
|
|
21
|
-
const col = Array(MAX_HEIGHT - visible).fill(blank);
|
|
22
|
-
col.push(...building.slice(h - visible));
|
|
23
|
-
cols.push(col);
|
|
24
|
-
}
|
|
25
|
-
const lines = [];
|
|
26
|
-
for (let row = 0; row < MAX_HEIGHT; row++) {
|
|
27
|
-
lines.push(cols.map((col) => col[row]).join(""));
|
|
28
|
-
}
|
|
29
|
-
return lines.join("\n");
|
|
30
|
-
}
|
|
31
|
-
async function withAnimation(fn) {
|
|
32
|
-
if (!process.stdout.isTTY) {
|
|
33
|
-
return fn();
|
|
34
|
-
}
|
|
35
|
-
let frame = 0;
|
|
36
|
-
let animDone = false;
|
|
37
|
-
const spinChars = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
38
|
-
let spinIdx = 0;
|
|
39
|
-
let lastLineCount = 0;
|
|
40
|
-
const clearPrev = () => {
|
|
41
|
-
if (lastLineCount > 0) {
|
|
42
|
-
process.stdout.write(`\x1B[${lastLineCount}A\x1B[0J`);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const drawFrame = () => {
|
|
46
|
-
clearPrev();
|
|
47
|
-
if (!animDone) {
|
|
48
|
-
const art = renderFrame(frame);
|
|
49
|
-
const output = `${GOLD}${art}${RESET}
|
|
50
|
-
`;
|
|
51
|
-
process.stdout.write(output);
|
|
52
|
-
lastLineCount = MAX_HEIGHT + 1;
|
|
53
|
-
frame++;
|
|
54
|
-
if (frame >= TOTAL_FRAMES) {
|
|
55
|
-
animDone = true;
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
const line = `${GOLD}${spinChars[spinIdx % spinChars.length]} Loading...${RESET}
|
|
59
|
-
`;
|
|
60
|
-
process.stdout.write(line);
|
|
61
|
-
lastLineCount = 1;
|
|
62
|
-
spinIdx++;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
drawFrame();
|
|
66
|
-
const timer = setInterval(drawFrame, 100);
|
|
67
|
-
try {
|
|
68
|
-
const result = await fn();
|
|
69
|
-
return result;
|
|
70
|
-
} finally {
|
|
71
|
-
clearInterval(timer);
|
|
72
|
-
clearPrev();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
var BUILDINGS, MAX_HEIGHT, TOTAL_FRAMES, GOLD, RESET;
|
|
76
|
-
var init_animation = __esm({
|
|
77
|
-
"src/animation.ts"() {
|
|
78
|
-
"use strict";
|
|
79
|
-
BUILDINGS = [
|
|
80
|
-
[
|
|
81
|
-
" \u250C\u2510 ",
|
|
82
|
-
" \u2502\u2502 ",
|
|
83
|
-
" \u2502\u2502 ",
|
|
84
|
-
" \u250C\u2524\u251C\u2510 ",
|
|
85
|
-
" \u2502\u2502\u2502\u2502\u2502",
|
|
86
|
-
" \u2502\u2502\u2502\u2502\u2502"
|
|
87
|
-
],
|
|
88
|
-
[
|
|
89
|
-
" \u2554\u2550\u2550\u2557 ",
|
|
90
|
-
" \u2551\u25AA\u25AA\u2551 ",
|
|
91
|
-
" \u2551\u25AA\u25AA\u2551 ",
|
|
92
|
-
" \u2551\u25AA\u25AA\u2551 ",
|
|
93
|
-
" \u2551\u25AA\u25AA\u2551 ",
|
|
94
|
-
" \u2551\u25AA\u25AA\u2551 ",
|
|
95
|
-
" \u2551\u25AA\u25AA\u2551 ",
|
|
96
|
-
" \u2551\u25AA\u25AA\u2551 "
|
|
97
|
-
],
|
|
98
|
-
[
|
|
99
|
-
" /\\ ",
|
|
100
|
-
" / \\ ",
|
|
101
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
102
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
103
|
-
" \u2502\u25AA\u25AA\u2502 "
|
|
104
|
-
],
|
|
105
|
-
[
|
|
106
|
-
" \u250C\u2500\u2500\u2510 ",
|
|
107
|
-
" \u2502\u224B\u224B\u2502 ",
|
|
108
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
109
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
110
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
111
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
112
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
113
|
-
" \u2502\u25AA\u25AA\u2502 ",
|
|
114
|
-
" \u2502\u25AA\u25AA\u2502 "
|
|
115
|
-
],
|
|
116
|
-
[
|
|
117
|
-
" \u257B ",
|
|
118
|
-
" \u2503 ",
|
|
119
|
-
" \u250C\u2524\u2510 ",
|
|
120
|
-
" \u2502\u25AA\u2502 ",
|
|
121
|
-
" \u2502\u25AA\u2502 ",
|
|
122
|
-
" \u2502\u25AA\u2502 ",
|
|
123
|
-
" \u2502\u25AA\u2502 ",
|
|
124
|
-
" \u2502\u25AA\u2502 ",
|
|
125
|
-
" \u2502\u25AA\u2502 ",
|
|
126
|
-
" \u2502\u25AA\u2502 ",
|
|
127
|
-
" \u2502\u25AA\u2502 "
|
|
128
|
-
],
|
|
129
|
-
[
|
|
130
|
-
" \u250C\u2510 ",
|
|
131
|
-
" \u251C\u2524 ",
|
|
132
|
-
" \u2502\u25AA\u2502 ",
|
|
133
|
-
" \u2502\u25AA\u2502 ",
|
|
134
|
-
" \u2502\u25AA\u2502 ",
|
|
135
|
-
" \u2502\u25AA\u2502 "
|
|
136
|
-
],
|
|
137
|
-
[
|
|
138
|
-
" \u2554\u2550\u2550\u2550\u2557",
|
|
139
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
140
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
141
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
142
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
143
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
144
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
145
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
146
|
-
" \u2551\u25AA \u25AA\u2551",
|
|
147
|
-
" \u2551\u25AA \u25AA\u2551"
|
|
148
|
-
],
|
|
149
|
-
[
|
|
150
|
-
" \u252C\u2500\u252C ",
|
|
151
|
-
" \u2502~\u2502 ",
|
|
152
|
-
" \u2502\u25AA\u2502 ",
|
|
153
|
-
" \u2502\u25AA\u2502 ",
|
|
154
|
-
" \u2502\u25AA\u2502 ",
|
|
155
|
-
" \u2502\u25AA\u2502 ",
|
|
156
|
-
" \u2502\u25AA\u2502 "
|
|
157
|
-
]
|
|
158
|
-
];
|
|
159
|
-
MAX_HEIGHT = Math.max(...BUILDINGS.map((b) => b.length));
|
|
160
|
-
TOTAL_FRAMES = MAX_HEIGHT + 4;
|
|
161
|
-
GOLD = "\x1B[38;2;212;160;23m";
|
|
162
|
-
RESET = "\x1B[0m";
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
// src/spinner.ts
|
|
167
|
-
async function withSpinner(_label, fn, json) {
|
|
168
|
-
if (json) {
|
|
169
|
-
return fn();
|
|
170
|
-
}
|
|
171
|
-
return withAnimation(fn);
|
|
172
|
-
}
|
|
173
|
-
var init_spinner = __esm({
|
|
174
|
-
"src/spinner.ts"() {
|
|
175
|
-
"use strict";
|
|
176
|
-
init_animation();
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
|
|
180
12
|
// src/config.ts
|
|
181
13
|
import {
|
|
182
14
|
chmodSync,
|
|
@@ -190,8 +22,10 @@ import {
|
|
|
190
22
|
} from "fs";
|
|
191
23
|
import { homedir } from "os";
|
|
192
24
|
import { join } from "path";
|
|
193
|
-
function
|
|
194
|
-
|
|
25
|
+
function spinWaitMs(ms) {
|
|
26
|
+
const end = Date.now() + ms;
|
|
27
|
+
while (Date.now() < end) {
|
|
28
|
+
}
|
|
195
29
|
}
|
|
196
30
|
function withConfigLock(fn) {
|
|
197
31
|
mkdirSync(CONFIG_DIR, { recursive: true, mode: 448 });
|
|
@@ -215,7 +49,7 @@ function withConfigLock(fn) {
|
|
|
215
49
|
if (Date.now() - startedAt >= CONFIG_LOCK_TIMEOUT_MS) {
|
|
216
50
|
throw new Error("timed out waiting for the corp config lock");
|
|
217
51
|
}
|
|
218
|
-
|
|
52
|
+
spinWaitMs(CONFIG_LOCK_RETRY_MS);
|
|
219
53
|
}
|
|
220
54
|
}
|
|
221
55
|
try {
|
|
@@ -667,7 +501,7 @@ function resolveEntityId(cfg, explicitId) {
|
|
|
667
501
|
}
|
|
668
502
|
return eid;
|
|
669
503
|
}
|
|
670
|
-
var CONFIG_DIR, CONFIG_FILE, AUTH_FILE, CONFIG_LOCK_DIR, CONFIG_LOCK_TIMEOUT_MS, CONFIG_LOCK_RETRY_MS, CONFIG_STALE_LOCK_MS, MAX_LAST_REFERENCES, TRUSTED_API_HOST_SUFFIXES,
|
|
504
|
+
var CONFIG_DIR, CONFIG_FILE, AUTH_FILE, CONFIG_LOCK_DIR, CONFIG_LOCK_TIMEOUT_MS, CONFIG_LOCK_RETRY_MS, CONFIG_STALE_LOCK_MS, MAX_LAST_REFERENCES, TRUSTED_API_HOST_SUFFIXES, ALLOWED_CONFIG_KEYS, SENSITIVE_CONFIG_KEYS, DEFAULTS;
|
|
671
505
|
var init_config = __esm({
|
|
672
506
|
"src/config.ts"() {
|
|
673
507
|
"use strict";
|
|
@@ -680,8 +514,6 @@ var init_config = __esm({
|
|
|
680
514
|
CONFIG_STALE_LOCK_MS = 6e4;
|
|
681
515
|
MAX_LAST_REFERENCES = 4096;
|
|
682
516
|
TRUSTED_API_HOST_SUFFIXES = ["thecorporation.ai"];
|
|
683
|
-
CONFIG_WAIT_BUFFER = new SharedArrayBuffer(4);
|
|
684
|
-
CONFIG_WAIT_SIGNAL = new Int32Array(CONFIG_WAIT_BUFFER);
|
|
685
517
|
ALLOWED_CONFIG_KEYS = /* @__PURE__ */ new Set([
|
|
686
518
|
"api_url",
|
|
687
519
|
"api_key",
|
|
@@ -717,7 +549,7 @@ var init_config = __esm({
|
|
|
717
549
|
|
|
718
550
|
// src/references.ts
|
|
719
551
|
import {
|
|
720
|
-
shortId
|
|
552
|
+
shortId,
|
|
721
553
|
slugify,
|
|
722
554
|
describeReferenceRecord,
|
|
723
555
|
getReferenceId,
|
|
@@ -727,7 +559,7 @@ import {
|
|
|
727
559
|
} from "@thecorporation/corp-tools";
|
|
728
560
|
import {
|
|
729
561
|
ReferenceTracker,
|
|
730
|
-
shortId as
|
|
562
|
+
shortId as shortId2,
|
|
731
563
|
normalize,
|
|
732
564
|
validateReferenceInput,
|
|
733
565
|
describeReferenceRecord as describeReferenceRecord2,
|
|
@@ -792,6 +624,14 @@ var init_references = __esm({
|
|
|
792
624
|
this.cfg = cfg;
|
|
793
625
|
this.tracker = new ReferenceTracker(new NodeReferenceStorage(cfg));
|
|
794
626
|
}
|
|
627
|
+
/**
|
|
628
|
+
* Public generic resolver for any resource kind.
|
|
629
|
+
* Used by the generic executor when a positional arg declares `posKind`.
|
|
630
|
+
* Entity-scoped kinds require an entityId in the scope.
|
|
631
|
+
*/
|
|
632
|
+
async resolveByKind(kind, ref, entityId) {
|
|
633
|
+
return this.resolve(kind, ref, { entityId });
|
|
634
|
+
}
|
|
795
635
|
async resolveEntity(ref) {
|
|
796
636
|
if (ref !== void 0 && ref !== null && !ref.trim()) {
|
|
797
637
|
throw new Error(
|
|
@@ -1002,7 +842,7 @@ var init_references = __esm({
|
|
|
1002
842
|
);
|
|
1003
843
|
}
|
|
1004
844
|
ambiguousMessage(kind, ref, matches) {
|
|
1005
|
-
const previews = matches.slice(0, 5).map((match) => `${match.label} [${
|
|
845
|
+
const previews = matches.slice(0, 5).map((match) => `${match.label} [${shortId2(match.id)}]`).join(", ");
|
|
1006
846
|
return `Ambiguous ${kindLabel(kind)} reference "${ref}". Matches: ${previews}. Try: corp find ${kind} ${JSON.stringify(ref)}`;
|
|
1007
847
|
}
|
|
1008
848
|
async listRecords(kind, scope) {
|
|
@@ -1383,13 +1223,13 @@ function formatReferenceCell(kind, record) {
|
|
|
1383
1223
|
const id = getReferenceId(kind, record);
|
|
1384
1224
|
if (!id) return "";
|
|
1385
1225
|
const alias = getReferenceAlias(kind, record);
|
|
1386
|
-
return alias ? `${alias} [${
|
|
1226
|
+
return alias ? `${alias} [${shortId(id)}]` : shortId(id);
|
|
1387
1227
|
}
|
|
1388
1228
|
function printReferenceSummary(kind, record, opts = {}) {
|
|
1389
1229
|
const id = getReferenceId(kind, record);
|
|
1390
1230
|
if (!id) return;
|
|
1391
1231
|
const alias = getReferenceAlias(kind, record);
|
|
1392
|
-
const token = alias ? `${alias} [${
|
|
1232
|
+
const token = alias ? `${alias} [${shortId(id)}]` : shortId(id);
|
|
1393
1233
|
console.log(` ${chalk.bold(opts.label ?? "Ref:")} ${token}`);
|
|
1394
1234
|
console.log(` ${chalk.bold("ID:")} ${id}`);
|
|
1395
1235
|
if (opts.showReuseHint) {
|
|
@@ -1477,17 +1317,17 @@ function printFinanceSummaryPanel(data) {
|
|
|
1477
1317
|
console.log(chalk.green("\u2500".repeat(54)));
|
|
1478
1318
|
console.log(chalk.green.bold(" Finance Summary"));
|
|
1479
1319
|
console.log(chalk.green("\u2500".repeat(54)));
|
|
1480
|
-
console.log(` ${chalk.bold("Entity:")} ${
|
|
1481
|
-
console.log(` ${chalk.bold("Invoices:")} ${
|
|
1320
|
+
console.log(` ${chalk.bold("Entity:")} ${s(data.entity_id) || "N/A"}`);
|
|
1321
|
+
console.log(` ${chalk.bold("Invoices:")} ${s(invoices.count)} total, ${s(invoices.open_count)} open, ${money(invoices.total_amount_cents)}`);
|
|
1482
1322
|
if (invoices.latest_due_date) {
|
|
1483
1323
|
console.log(` ${chalk.bold("Invoice Horizon:")} next due ${date(invoices.latest_due_date)}`);
|
|
1484
1324
|
}
|
|
1485
|
-
console.log(` ${chalk.bold("Bank Accounts:")} ${
|
|
1486
|
-
console.log(` ${chalk.bold("Payments:")} ${
|
|
1487
|
-
console.log(` ${chalk.bold("Payroll Runs:")} ${
|
|
1488
|
-
console.log(` ${chalk.bold("Distributions:")} ${
|
|
1489
|
-
console.log(` ${chalk.bold("Reconciliations:")} ${
|
|
1490
|
-
console.log(` ${chalk.bold("Contractors:")} ${
|
|
1325
|
+
console.log(` ${chalk.bold("Bank Accounts:")} ${s(bankAccounts.active_count)}/${s(bankAccounts.count)} active`);
|
|
1326
|
+
console.log(` ${chalk.bold("Payments:")} ${s(payments.count)} total, ${s(payments.pending_count)} pending, ${money(payments.total_amount_cents)}`);
|
|
1327
|
+
console.log(` ${chalk.bold("Payroll Runs:")} ${s(payrollRuns.count)} total${payrollRuns.latest_period_end ? `, latest ${date(payrollRuns.latest_period_end)}` : ""}`);
|
|
1328
|
+
console.log(` ${chalk.bold("Distributions:")} ${s(distributions.count)} total, ${money(distributions.total_amount_cents)}`);
|
|
1329
|
+
console.log(` ${chalk.bold("Reconciliations:")} ${s(reconciliations.balanced_count)}/${s(reconciliations.count)} balanced`);
|
|
1330
|
+
console.log(` ${chalk.bold("Contractors:")} ${s(classifications.count)} classifications, ${s(classifications.high_risk_count)} high risk`);
|
|
1491
1331
|
console.log(chalk.green("\u2500".repeat(54)));
|
|
1492
1332
|
}
|
|
1493
1333
|
function printNextSteps(data) {
|
|
@@ -1542,12 +1382,12 @@ function makeTable(title, columns) {
|
|
|
1542
1382
|
${chalk.bold(title)}`);
|
|
1543
1383
|
return new Table({ head: columns.map((c) => chalk.dim(c)) });
|
|
1544
1384
|
}
|
|
1545
|
-
function
|
|
1385
|
+
function s(val, maxLen) {
|
|
1546
1386
|
const str = val == null ? "" : String(val);
|
|
1547
1387
|
if (maxLen && str.length > maxLen) return str.slice(0, maxLen);
|
|
1548
1388
|
return str;
|
|
1549
1389
|
}
|
|
1550
|
-
function
|
|
1390
|
+
function money(val, cents = true) {
|
|
1551
1391
|
if (typeof val === "number") {
|
|
1552
1392
|
const dollars = cents ? val / 100 : val;
|
|
1553
1393
|
return `$${dollars.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
@@ -1555,7 +1395,7 @@ function money2(val, cents = true) {
|
|
|
1555
1395
|
return String(val ?? "");
|
|
1556
1396
|
}
|
|
1557
1397
|
function date(val) {
|
|
1558
|
-
const str =
|
|
1398
|
+
const str = s(val);
|
|
1559
1399
|
if (!str) return "";
|
|
1560
1400
|
const parsed = new Date(str);
|
|
1561
1401
|
return Number.isNaN(parsed.getTime()) ? str : parsed.toISOString().slice(0, 10);
|
|
@@ -1563,23 +1403,23 @@ function date(val) {
|
|
|
1563
1403
|
function actorLabel(record, field) {
|
|
1564
1404
|
const actor = record[`${field}_actor`];
|
|
1565
1405
|
if (actor && typeof actor === "object" && !Array.isArray(actor)) {
|
|
1566
|
-
const label =
|
|
1567
|
-
const actorType =
|
|
1406
|
+
const label = s(actor.label);
|
|
1407
|
+
const actorType = s(actor.actor_type);
|
|
1568
1408
|
if (label) {
|
|
1569
1409
|
return actorType ? `${label} (${actorType})` : label;
|
|
1570
1410
|
}
|
|
1571
1411
|
}
|
|
1572
|
-
return
|
|
1412
|
+
return s(record[field]);
|
|
1573
1413
|
}
|
|
1574
1414
|
function printEntitiesTable(entities) {
|
|
1575
1415
|
const table = makeTable("Entities", ["Ref", "Name", "Type", "Jurisdiction", "Status"]);
|
|
1576
1416
|
for (const e of entities) {
|
|
1577
1417
|
table.push([
|
|
1578
1418
|
formatReferenceCell("entity", e),
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1419
|
+
s(e.legal_name ?? e.name),
|
|
1420
|
+
s(e.entity_type),
|
|
1421
|
+
s(e.jurisdiction),
|
|
1422
|
+
s(e.formation_status ?? e.status)
|
|
1583
1423
|
]);
|
|
1584
1424
|
}
|
|
1585
1425
|
console.log(table.toString());
|
|
@@ -1587,9 +1427,9 @@ function printEntitiesTable(entities) {
|
|
|
1587
1427
|
function printObligationsTable(obligations) {
|
|
1588
1428
|
const table = makeTable("Obligations", ["ID", "Type", "Urgency", "Due", "Status"]);
|
|
1589
1429
|
for (const o of obligations) {
|
|
1590
|
-
const urg =
|
|
1430
|
+
const urg = s(o.urgency) || "upcoming";
|
|
1591
1431
|
const colorFn = URGENCY_COLORS[urg] ?? ((x) => x);
|
|
1592
|
-
table.push([
|
|
1432
|
+
table.push([s(o.obligation_id, 12), s(o.obligation_type), colorFn(urg), s(o.due_at), s(o.status)]);
|
|
1593
1433
|
}
|
|
1594
1434
|
console.log(table.toString());
|
|
1595
1435
|
}
|
|
@@ -1598,27 +1438,27 @@ function printContactsTable(contacts) {
|
|
|
1598
1438
|
for (const c of contacts) {
|
|
1599
1439
|
table.push([
|
|
1600
1440
|
formatReferenceCell("contact", c),
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1441
|
+
s(c.name),
|
|
1442
|
+
s(c.email),
|
|
1443
|
+
s(c.category),
|
|
1444
|
+
s(c.entity_name ?? c.entity_id)
|
|
1605
1445
|
]);
|
|
1606
1446
|
}
|
|
1607
1447
|
console.log(table.toString());
|
|
1608
1448
|
}
|
|
1609
1449
|
function printCapTable(data) {
|
|
1610
|
-
const accessLevel =
|
|
1450
|
+
const accessLevel = s(data.access_level) || "admin";
|
|
1611
1451
|
const instruments = data.instruments ?? [];
|
|
1612
1452
|
if (instruments.length > 0) {
|
|
1613
1453
|
const table = makeTable("Cap Table \u2014 Instruments", ["Ref", "Symbol", "Kind", "Authorized", "Issued", "Diluted"]);
|
|
1614
1454
|
for (const instrument of instruments) {
|
|
1615
1455
|
table.push([
|
|
1616
1456
|
formatReferenceCell("instrument", instrument),
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1457
|
+
s(instrument.symbol),
|
|
1458
|
+
s(instrument.kind),
|
|
1459
|
+
s(instrument.authorized_units ?? "unlimited"),
|
|
1460
|
+
s(instrument.issued_units),
|
|
1461
|
+
s(instrument.diluted_units)
|
|
1622
1462
|
]);
|
|
1623
1463
|
}
|
|
1624
1464
|
console.log(table.toString());
|
|
@@ -1632,10 +1472,10 @@ function printCapTable(data) {
|
|
|
1632
1472
|
for (const holder of holders) {
|
|
1633
1473
|
const dilutedBps = typeof holder.fully_diluted_bps === "number" ? `${(holder.fully_diluted_bps / 100).toFixed(2)}%` : "";
|
|
1634
1474
|
table.push([
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1475
|
+
s(holder.name),
|
|
1476
|
+
s(holder.outstanding_units),
|
|
1477
|
+
s(holder.as_converted_units),
|
|
1478
|
+
s(holder.fully_diluted_units),
|
|
1639
1479
|
dilutedBps
|
|
1640
1480
|
]);
|
|
1641
1481
|
}
|
|
@@ -1649,9 +1489,9 @@ function printCapTable(data) {
|
|
|
1649
1489
|
for (const sc of shareClasses) {
|
|
1650
1490
|
const row = [
|
|
1651
1491
|
formatReferenceCell("share_class", sc),
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1492
|
+
s(sc.class_code ?? sc.name),
|
|
1493
|
+
s(sc.authorized),
|
|
1494
|
+
s(sc.outstanding)
|
|
1655
1495
|
];
|
|
1656
1496
|
if (accessLevel !== "summary") {
|
|
1657
1497
|
const holders2 = sc.holders ?? [];
|
|
@@ -1665,7 +1505,7 @@ function printCapTable(data) {
|
|
|
1665
1505
|
if (ownership.length > 0 && accessLevel !== "summary") {
|
|
1666
1506
|
const table = makeTable("Ownership Breakdown", ["Holder", "Shares", "Percentage", "Class"]);
|
|
1667
1507
|
for (const o of ownership) {
|
|
1668
|
-
table.push([
|
|
1508
|
+
table.push([s(o.holder_name ?? o.name), s(o.shares), `${o.percentage ?? ""}%`, s(o.share_class)]);
|
|
1669
1509
|
}
|
|
1670
1510
|
console.log(table.toString());
|
|
1671
1511
|
}
|
|
@@ -1673,7 +1513,7 @@ function printCapTable(data) {
|
|
|
1673
1513
|
if (pools.length > 0) {
|
|
1674
1514
|
const table = makeTable("Option Pools", ["Name", "Authorized", "Granted", "Available"]);
|
|
1675
1515
|
for (const p of pools) {
|
|
1676
|
-
table.push([
|
|
1516
|
+
table.push([s(p.name), s(p.authorized), s(p.granted), s(p.available)]);
|
|
1677
1517
|
}
|
|
1678
1518
|
console.log(table.toString());
|
|
1679
1519
|
}
|
|
@@ -1684,7 +1524,7 @@ ${chalk.bold("Fully Diluted Shares:")} ${typeof fd === "number" ? fd.toLocaleStr
|
|
|
1684
1524
|
}
|
|
1685
1525
|
if (data.total_units != null) {
|
|
1686
1526
|
console.log(`
|
|
1687
|
-
${chalk.bold("Cap Table Basis:")} ${
|
|
1527
|
+
${chalk.bold("Cap Table Basis:")} ${s(data.basis) || "outstanding"}`);
|
|
1688
1528
|
console.log(`${chalk.bold("Total Units:")} ${typeof data.total_units === "number" ? data.total_units.toLocaleString() : data.total_units}`);
|
|
1689
1529
|
}
|
|
1690
1530
|
}
|
|
@@ -1693,11 +1533,11 @@ function printSafesTable(safes) {
|
|
|
1693
1533
|
for (const s_ of safes) {
|
|
1694
1534
|
table.push([
|
|
1695
1535
|
formatReferenceCell("safe_note", s_),
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1536
|
+
s(s_.investor_name ?? s_.investor),
|
|
1537
|
+
money(s_.principal_amount_cents ?? s_.investment_amount ?? s_.amount),
|
|
1538
|
+
money(s_.valuation_cap_cents ?? s_.valuation_cap ?? s_.cap),
|
|
1539
|
+
s(s_.discount_rate ?? s_.discount),
|
|
1540
|
+
s(s_.issued_at ?? s_.date ?? s_.created_at)
|
|
1701
1541
|
]);
|
|
1702
1542
|
}
|
|
1703
1543
|
console.log(table.toString());
|
|
@@ -1707,11 +1547,11 @@ function printTransfersTable(transfers) {
|
|
|
1707
1547
|
for (const t of transfers) {
|
|
1708
1548
|
table.push([
|
|
1709
1549
|
formatReferenceCell("share_transfer", t),
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1550
|
+
s(t.from_holder ?? t.from),
|
|
1551
|
+
s(t.to_holder ?? t.to),
|
|
1552
|
+
s(t.shares ?? t.share_count),
|
|
1553
|
+
s(t.transfer_type),
|
|
1554
|
+
s(t.status)
|
|
1715
1555
|
]);
|
|
1716
1556
|
}
|
|
1717
1557
|
console.log(table.toString());
|
|
@@ -1721,11 +1561,11 @@ function printInstrumentsTable(instruments) {
|
|
|
1721
1561
|
for (const instrument of instruments) {
|
|
1722
1562
|
table.push([
|
|
1723
1563
|
formatReferenceCell("instrument", instrument),
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1564
|
+
s(instrument.symbol),
|
|
1565
|
+
s(instrument.kind),
|
|
1566
|
+
s(instrument.authorized_units ?? "unlimited"),
|
|
1567
|
+
s(instrument.issued_units),
|
|
1568
|
+
s(instrument.status)
|
|
1729
1569
|
]);
|
|
1730
1570
|
}
|
|
1731
1571
|
console.log(table.toString());
|
|
@@ -1735,9 +1575,9 @@ function printShareClassesTable(shareClasses) {
|
|
|
1735
1575
|
for (const shareClass of shareClasses) {
|
|
1736
1576
|
table.push([
|
|
1737
1577
|
formatReferenceCell("share_class", shareClass),
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1578
|
+
s(shareClass.class_code ?? shareClass.name ?? shareClass.share_class),
|
|
1579
|
+
s(shareClass.authorized),
|
|
1580
|
+
s(shareClass.outstanding)
|
|
1741
1581
|
]);
|
|
1742
1582
|
}
|
|
1743
1583
|
console.log(table.toString());
|
|
@@ -1747,9 +1587,9 @@ function printRoundsTable(rounds) {
|
|
|
1747
1587
|
for (const round of rounds) {
|
|
1748
1588
|
table.push([
|
|
1749
1589
|
formatReferenceCell("round", round),
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1590
|
+
s(round.name),
|
|
1591
|
+
s(round.status),
|
|
1592
|
+
s(round.issuer_legal_entity_id),
|
|
1753
1593
|
date(round.created_at)
|
|
1754
1594
|
]);
|
|
1755
1595
|
}
|
|
@@ -1760,10 +1600,10 @@ function printInvoicesTable(invoices) {
|
|
|
1760
1600
|
for (const invoice of invoices) {
|
|
1761
1601
|
table.push([
|
|
1762
1602
|
formatReferenceCell("invoice", invoice),
|
|
1763
|
-
|
|
1764
|
-
|
|
1603
|
+
s(invoice.customer_name),
|
|
1604
|
+
money(invoice.amount_cents),
|
|
1765
1605
|
date(invoice.due_date),
|
|
1766
|
-
|
|
1606
|
+
s(invoice.status)
|
|
1767
1607
|
]);
|
|
1768
1608
|
}
|
|
1769
1609
|
console.log(table.toString());
|
|
@@ -1773,9 +1613,9 @@ function printBankAccountsTable(accounts) {
|
|
|
1773
1613
|
for (const account of accounts) {
|
|
1774
1614
|
table.push([
|
|
1775
1615
|
formatReferenceCell("bank_account", account),
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1616
|
+
s(account.bank_name),
|
|
1617
|
+
s(account.account_type),
|
|
1618
|
+
s(account.status),
|
|
1779
1619
|
date(account.created_at)
|
|
1780
1620
|
]);
|
|
1781
1621
|
}
|
|
@@ -1786,10 +1626,10 @@ function printPaymentsTable(payments) {
|
|
|
1786
1626
|
for (const payment of payments) {
|
|
1787
1627
|
table.push([
|
|
1788
1628
|
formatReferenceCell("payment", payment),
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1629
|
+
s(payment.recipient),
|
|
1630
|
+
money(payment.amount_cents),
|
|
1631
|
+
s(payment.payment_method),
|
|
1632
|
+
s(payment.status)
|
|
1793
1633
|
]);
|
|
1794
1634
|
}
|
|
1795
1635
|
console.log(table.toString());
|
|
@@ -1801,7 +1641,7 @@ function printPayrollRunsTable(runs) {
|
|
|
1801
1641
|
formatReferenceCell("payroll_run", run),
|
|
1802
1642
|
date(run.pay_period_start),
|
|
1803
1643
|
date(run.pay_period_end),
|
|
1804
|
-
|
|
1644
|
+
s(run.status),
|
|
1805
1645
|
date(run.created_at)
|
|
1806
1646
|
]);
|
|
1807
1647
|
}
|
|
@@ -1812,10 +1652,10 @@ function printDistributionsTable(distributions) {
|
|
|
1812
1652
|
for (const distribution of distributions) {
|
|
1813
1653
|
table.push([
|
|
1814
1654
|
formatReferenceCell("distribution", distribution),
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1655
|
+
s(distribution.distribution_type),
|
|
1656
|
+
money(distribution.total_amount_cents),
|
|
1657
|
+
s(distribution.status),
|
|
1658
|
+
s(distribution.description)
|
|
1819
1659
|
]);
|
|
1820
1660
|
}
|
|
1821
1661
|
console.log(table.toString());
|
|
@@ -1826,9 +1666,9 @@ function printReconciliationsTable(reconciliations) {
|
|
|
1826
1666
|
table.push([
|
|
1827
1667
|
formatReferenceCell("reconciliation", reconciliation),
|
|
1828
1668
|
date(reconciliation.as_of_date),
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1669
|
+
money(reconciliation.total_debits_cents),
|
|
1670
|
+
money(reconciliation.total_credits_cents),
|
|
1671
|
+
s(reconciliation.status)
|
|
1832
1672
|
]);
|
|
1833
1673
|
}
|
|
1834
1674
|
console.log(table.toString());
|
|
@@ -1839,9 +1679,9 @@ function printValuationsTable(valuations) {
|
|
|
1839
1679
|
table.push([
|
|
1840
1680
|
formatReferenceCell("valuation", v),
|
|
1841
1681
|
date(v.effective_date ?? v.valuation_date ?? v.date),
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1682
|
+
s(v.valuation_type ?? v.type),
|
|
1683
|
+
money(v.enterprise_value_cents ?? v.enterprise_value ?? v.valuation),
|
|
1684
|
+
money(v.fmv_per_share_cents ?? v.price_per_share ?? v.pps ?? v.fmv_per_share)
|
|
1845
1685
|
]);
|
|
1846
1686
|
}
|
|
1847
1687
|
console.log(table.toString());
|
|
@@ -1851,10 +1691,10 @@ function printTaxFilingsTable(filings) {
|
|
|
1851
1691
|
for (const filing of filings) {
|
|
1852
1692
|
table.push([
|
|
1853
1693
|
formatReferenceCell("tax_filing", filing),
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1694
|
+
s(filing.document_type),
|
|
1695
|
+
s(filing.tax_year),
|
|
1696
|
+
s(filing.status),
|
|
1697
|
+
s(filing.document_id, 12)
|
|
1858
1698
|
]);
|
|
1859
1699
|
}
|
|
1860
1700
|
console.log(table.toString());
|
|
@@ -1864,10 +1704,10 @@ function printDeadlinesTable(deadlines) {
|
|
|
1864
1704
|
for (const deadline of deadlines) {
|
|
1865
1705
|
table.push([
|
|
1866
1706
|
formatReferenceCell("deadline", deadline),
|
|
1867
|
-
|
|
1707
|
+
s(deadline.deadline_type),
|
|
1868
1708
|
date(deadline.due_date),
|
|
1869
|
-
|
|
1870
|
-
|
|
1709
|
+
s(deadline.status),
|
|
1710
|
+
s(deadline.description)
|
|
1871
1711
|
]);
|
|
1872
1712
|
}
|
|
1873
1713
|
console.log(table.toString());
|
|
@@ -1877,10 +1717,10 @@ function printClassificationsTable(classifications) {
|
|
|
1877
1717
|
for (const classification of classifications) {
|
|
1878
1718
|
table.push([
|
|
1879
1719
|
formatReferenceCell("classification", classification),
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1720
|
+
s(classification.contractor_name),
|
|
1721
|
+
s(classification.state),
|
|
1722
|
+
s(classification.risk_level),
|
|
1723
|
+
s(classification.classification)
|
|
1884
1724
|
]);
|
|
1885
1725
|
}
|
|
1886
1726
|
console.log(table.toString());
|
|
@@ -1890,10 +1730,10 @@ function printGovernanceTable(bodies) {
|
|
|
1890
1730
|
for (const b of bodies) {
|
|
1891
1731
|
table.push([
|
|
1892
1732
|
formatReferenceCell("body", b),
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1733
|
+
s(b.name),
|
|
1734
|
+
s(b.body_type ?? b.type),
|
|
1735
|
+
s(b.seat_count ?? b.seats),
|
|
1736
|
+
s(b.meeting_count ?? b.meetings)
|
|
1897
1737
|
]);
|
|
1898
1738
|
}
|
|
1899
1739
|
console.log(table.toString());
|
|
@@ -1903,9 +1743,9 @@ function printSeatsTable(seats) {
|
|
|
1903
1743
|
for (const st of seats) {
|
|
1904
1744
|
table.push([
|
|
1905
1745
|
formatReferenceCell("seat", st),
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1746
|
+
s(st.holder_name ?? st.holder ?? st.holder_id),
|
|
1747
|
+
s(st.role),
|
|
1748
|
+
s(st.status)
|
|
1909
1749
|
]);
|
|
1910
1750
|
}
|
|
1911
1751
|
console.log(table.toString());
|
|
@@ -1915,10 +1755,10 @@ function printMeetingsTable(meetings) {
|
|
|
1915
1755
|
for (const m of meetings) {
|
|
1916
1756
|
table.push([
|
|
1917
1757
|
formatReferenceCell("meeting", m),
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1758
|
+
s(m.title ?? m.name),
|
|
1759
|
+
s(m.scheduled_date ?? m.meeting_date ?? m.date),
|
|
1760
|
+
s(m.status),
|
|
1761
|
+
s(m.resolution_count ?? m.resolutions)
|
|
1922
1762
|
]);
|
|
1923
1763
|
}
|
|
1924
1764
|
console.log(table.toString());
|
|
@@ -1928,11 +1768,11 @@ function printResolutionsTable(resolutions) {
|
|
|
1928
1768
|
for (const r of resolutions) {
|
|
1929
1769
|
table.push([
|
|
1930
1770
|
formatReferenceCell("resolution", r),
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1771
|
+
s(r.title),
|
|
1772
|
+
s(r.resolution_type ?? r.type),
|
|
1773
|
+
s(r.status),
|
|
1774
|
+
s(r.votes_for),
|
|
1775
|
+
s(r.votes_against)
|
|
1936
1776
|
]);
|
|
1937
1777
|
}
|
|
1938
1778
|
console.log(table.toString());
|
|
@@ -1942,9 +1782,9 @@ function printAgendaItemsTable(items) {
|
|
|
1942
1782
|
for (const item of items) {
|
|
1943
1783
|
table.push([
|
|
1944
1784
|
formatReferenceCell("agenda_item", item),
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1785
|
+
s(item.title),
|
|
1786
|
+
s(item.status),
|
|
1787
|
+
s(item.item_type ?? item.type)
|
|
1948
1788
|
]);
|
|
1949
1789
|
}
|
|
1950
1790
|
console.log(table.toString());
|
|
@@ -1953,13 +1793,13 @@ function printDocumentsTable(docs) {
|
|
|
1953
1793
|
const table = makeTable("Documents", ["Ref", "Title", "Type", "Date", "Status", "Signatures"]);
|
|
1954
1794
|
for (const d of docs) {
|
|
1955
1795
|
const sigs = d.signatures;
|
|
1956
|
-
const sigStr = Array.isArray(sigs) ? `${sigs.length} signed` :
|
|
1796
|
+
const sigStr = Array.isArray(sigs) ? `${sigs.length} signed` : s(sigs);
|
|
1957
1797
|
table.push([
|
|
1958
1798
|
formatReferenceCell("document", d),
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1799
|
+
s(d.title ?? d.name),
|
|
1800
|
+
s(d.document_type ?? d.type),
|
|
1801
|
+
s(d.date ?? d.created_at),
|
|
1802
|
+
s(d.status),
|
|
1963
1803
|
sigStr
|
|
1964
1804
|
]);
|
|
1965
1805
|
}
|
|
@@ -1968,14 +1808,14 @@ function printDocumentsTable(docs) {
|
|
|
1968
1808
|
function printWorkItemsTable(items) {
|
|
1969
1809
|
const table = makeTable("Work Items", ["Ref", "Title", "Category", "Status", "Deadline", "Claimed By"]);
|
|
1970
1810
|
for (const w of items) {
|
|
1971
|
-
const status =
|
|
1811
|
+
const status = s(w.effective_status ?? w.status);
|
|
1972
1812
|
const colored = status === "completed" ? chalk.green(status) : status === "claimed" ? chalk.yellow(status) : status === "cancelled" ? chalk.dim(status) : status;
|
|
1973
1813
|
table.push([
|
|
1974
1814
|
formatReferenceCell("work_item", w),
|
|
1975
|
-
|
|
1976
|
-
|
|
1815
|
+
s(w.title),
|
|
1816
|
+
s(w.category),
|
|
1977
1817
|
colored,
|
|
1978
|
-
w.asap ? chalk.red.bold("ASAP") :
|
|
1818
|
+
w.asap ? chalk.red.bold("ASAP") : s(w.deadline ?? ""),
|
|
1979
1819
|
actorLabel(w, "claimed_by")
|
|
1980
1820
|
]);
|
|
1981
1821
|
}
|
|
@@ -1984,9 +1824,9 @@ function printWorkItemsTable(items) {
|
|
|
1984
1824
|
function printAgentsTable(agents) {
|
|
1985
1825
|
const table = makeTable("Agents", ["Ref", "Name", "Status", "Model"]);
|
|
1986
1826
|
for (const a of agents) {
|
|
1987
|
-
const status =
|
|
1827
|
+
const status = s(a.status);
|
|
1988
1828
|
const colored = status === "active" ? chalk.green(status) : status === "paused" ? chalk.yellow(status) : status;
|
|
1989
|
-
table.push([formatReferenceCell("agent", a),
|
|
1829
|
+
table.push([formatReferenceCell("agent", a), s(a.name), colored, s(a.model)]);
|
|
1990
1830
|
}
|
|
1991
1831
|
console.log(table.toString());
|
|
1992
1832
|
}
|
|
@@ -1994,10 +1834,10 @@ function printServiceCatalogTable(items) {
|
|
|
1994
1834
|
const table = makeTable("Service Catalog", ["Slug", "Name", "Price", "Type"]);
|
|
1995
1835
|
for (const item of items) {
|
|
1996
1836
|
table.push([
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
1837
|
+
s(item.slug),
|
|
1838
|
+
s(item.name),
|
|
1839
|
+
money(item.amount_cents),
|
|
1840
|
+
s(item.price_type)
|
|
2001
1841
|
]);
|
|
2002
1842
|
}
|
|
2003
1843
|
console.log(table.toString());
|
|
@@ -2005,12 +1845,12 @@ function printServiceCatalogTable(items) {
|
|
|
2005
1845
|
function printServiceRequestsTable(requests) {
|
|
2006
1846
|
const table = makeTable("Service Requests", ["Ref", "Service", "Amount", "Status", "Created"]);
|
|
2007
1847
|
for (const r of requests) {
|
|
2008
|
-
const status =
|
|
1848
|
+
const status = s(r.status);
|
|
2009
1849
|
const colored = status === "fulfilled" ? chalk.green(status) : status === "paid" ? chalk.cyan(status) : status === "checkout" ? chalk.yellow(status) : status === "failed" ? chalk.dim(status) : status;
|
|
2010
1850
|
table.push([
|
|
2011
1851
|
formatReferenceCell("service_request", r),
|
|
2012
|
-
|
|
2013
|
-
|
|
1852
|
+
s(r.service_slug),
|
|
1853
|
+
money(r.amount_cents),
|
|
2014
1854
|
colored,
|
|
2015
1855
|
date(r.created_at)
|
|
2016
1856
|
]);
|
|
@@ -2018,10 +1858,10 @@ function printServiceRequestsTable(requests) {
|
|
|
2018
1858
|
console.log(table.toString());
|
|
2019
1859
|
}
|
|
2020
1860
|
function printBillingPanel(status, plans) {
|
|
2021
|
-
const plan =
|
|
2022
|
-
const subStatus =
|
|
2023
|
-
const periodEnd =
|
|
2024
|
-
const explanation =
|
|
1861
|
+
const plan = s(status.plan ?? status.tier) || "free";
|
|
1862
|
+
const subStatus = s(status.status) || "active";
|
|
1863
|
+
const periodEnd = s(status.current_period_end);
|
|
1864
|
+
const explanation = s(status.status_explanation);
|
|
2025
1865
|
console.log(chalk.green("\u2500".repeat(50)));
|
|
2026
1866
|
console.log(chalk.green.bold(" Billing Status"));
|
|
2027
1867
|
console.log(chalk.green("\u2500".repeat(50)));
|
|
@@ -2036,13 +1876,13 @@ function printBillingPanel(status, plans) {
|
|
|
2036
1876
|
const table = makeTable("Available Plans", ["Plan", "Price", "Features"]);
|
|
2037
1877
|
for (const p of plans) {
|
|
2038
1878
|
const amount = p.price_cents ?? p.amount ?? 0;
|
|
2039
|
-
const interval =
|
|
1879
|
+
const interval = s(p.interval);
|
|
2040
1880
|
let priceStr = "Free";
|
|
2041
1881
|
if (amount > 0) {
|
|
2042
1882
|
priceStr = interval ? `$${Math.round(amount / 100)}/${interval}` : `$${Math.round(amount / 100)}`;
|
|
2043
1883
|
}
|
|
2044
|
-
const name =
|
|
2045
|
-
const features = Array.isArray(p.features) ? p.features.join(", ") :
|
|
1884
|
+
const name = s(p.name ?? p.plan_id ?? p.tier);
|
|
1885
|
+
const features = Array.isArray(p.features) ? p.features.join(", ") : s(p.description);
|
|
2046
1886
|
table.push([name, priceStr, features]);
|
|
2047
1887
|
}
|
|
2048
1888
|
console.log(table.toString());
|
|
@@ -2081,6 +1921,174 @@ var init_output = __esm({
|
|
|
2081
1921
|
}
|
|
2082
1922
|
});
|
|
2083
1923
|
|
|
1924
|
+
// src/animation.ts
|
|
1925
|
+
function renderFrame(frame) {
|
|
1926
|
+
const cols = [];
|
|
1927
|
+
for (let i = 0; i < BUILDINGS.length; i++) {
|
|
1928
|
+
const building = BUILDINGS[i];
|
|
1929
|
+
const h = building.length;
|
|
1930
|
+
const visible = Math.max(0, Math.min(h, frame - i));
|
|
1931
|
+
const width = building[0]?.length ?? 6;
|
|
1932
|
+
const blank = " ".repeat(width);
|
|
1933
|
+
const col = Array(MAX_HEIGHT - visible).fill(blank);
|
|
1934
|
+
col.push(...building.slice(h - visible));
|
|
1935
|
+
cols.push(col);
|
|
1936
|
+
}
|
|
1937
|
+
const lines = [];
|
|
1938
|
+
for (let row = 0; row < MAX_HEIGHT; row++) {
|
|
1939
|
+
lines.push(cols.map((col) => col[row]).join(""));
|
|
1940
|
+
}
|
|
1941
|
+
return lines.join("\n");
|
|
1942
|
+
}
|
|
1943
|
+
async function withAnimation(fn) {
|
|
1944
|
+
if (!process.stdout.isTTY) {
|
|
1945
|
+
return fn();
|
|
1946
|
+
}
|
|
1947
|
+
let frame = 0;
|
|
1948
|
+
let animDone = false;
|
|
1949
|
+
const spinChars = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
1950
|
+
let spinIdx = 0;
|
|
1951
|
+
let lastLineCount = 0;
|
|
1952
|
+
const clearPrev = () => {
|
|
1953
|
+
if (lastLineCount > 0) {
|
|
1954
|
+
process.stdout.write(`\x1B[${lastLineCount}A\x1B[0J`);
|
|
1955
|
+
}
|
|
1956
|
+
};
|
|
1957
|
+
const drawFrame = () => {
|
|
1958
|
+
clearPrev();
|
|
1959
|
+
if (!animDone) {
|
|
1960
|
+
const art = renderFrame(frame);
|
|
1961
|
+
const output = `${GOLD}${art}${RESET}
|
|
1962
|
+
`;
|
|
1963
|
+
process.stdout.write(output);
|
|
1964
|
+
lastLineCount = MAX_HEIGHT + 1;
|
|
1965
|
+
frame++;
|
|
1966
|
+
if (frame >= TOTAL_FRAMES) {
|
|
1967
|
+
animDone = true;
|
|
1968
|
+
}
|
|
1969
|
+
} else {
|
|
1970
|
+
const line = `${GOLD}${spinChars[spinIdx % spinChars.length]} Loading...${RESET}
|
|
1971
|
+
`;
|
|
1972
|
+
process.stdout.write(line);
|
|
1973
|
+
lastLineCount = 1;
|
|
1974
|
+
spinIdx++;
|
|
1975
|
+
}
|
|
1976
|
+
};
|
|
1977
|
+
drawFrame();
|
|
1978
|
+
const timer = setInterval(drawFrame, 100);
|
|
1979
|
+
try {
|
|
1980
|
+
const result = await fn();
|
|
1981
|
+
return result;
|
|
1982
|
+
} finally {
|
|
1983
|
+
clearInterval(timer);
|
|
1984
|
+
clearPrev();
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
var BUILDINGS, MAX_HEIGHT, TOTAL_FRAMES, GOLD, RESET;
|
|
1988
|
+
var init_animation = __esm({
|
|
1989
|
+
"src/animation.ts"() {
|
|
1990
|
+
"use strict";
|
|
1991
|
+
BUILDINGS = [
|
|
1992
|
+
[
|
|
1993
|
+
" \u250C\u2510 ",
|
|
1994
|
+
" \u2502\u2502 ",
|
|
1995
|
+
" \u2502\u2502 ",
|
|
1996
|
+
" \u250C\u2524\u251C\u2510 ",
|
|
1997
|
+
" \u2502\u2502\u2502\u2502\u2502",
|
|
1998
|
+
" \u2502\u2502\u2502\u2502\u2502"
|
|
1999
|
+
],
|
|
2000
|
+
[
|
|
2001
|
+
" \u2554\u2550\u2550\u2557 ",
|
|
2002
|
+
" \u2551\u25AA\u25AA\u2551 ",
|
|
2003
|
+
" \u2551\u25AA\u25AA\u2551 ",
|
|
2004
|
+
" \u2551\u25AA\u25AA\u2551 ",
|
|
2005
|
+
" \u2551\u25AA\u25AA\u2551 ",
|
|
2006
|
+
" \u2551\u25AA\u25AA\u2551 ",
|
|
2007
|
+
" \u2551\u25AA\u25AA\u2551 ",
|
|
2008
|
+
" \u2551\u25AA\u25AA\u2551 "
|
|
2009
|
+
],
|
|
2010
|
+
[
|
|
2011
|
+
" /\\ ",
|
|
2012
|
+
" / \\ ",
|
|
2013
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2014
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2015
|
+
" \u2502\u25AA\u25AA\u2502 "
|
|
2016
|
+
],
|
|
2017
|
+
[
|
|
2018
|
+
" \u250C\u2500\u2500\u2510 ",
|
|
2019
|
+
" \u2502\u224B\u224B\u2502 ",
|
|
2020
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2021
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2022
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2023
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2024
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2025
|
+
" \u2502\u25AA\u25AA\u2502 ",
|
|
2026
|
+
" \u2502\u25AA\u25AA\u2502 "
|
|
2027
|
+
],
|
|
2028
|
+
[
|
|
2029
|
+
" \u257B ",
|
|
2030
|
+
" \u2503 ",
|
|
2031
|
+
" \u250C\u2524\u2510 ",
|
|
2032
|
+
" \u2502\u25AA\u2502 ",
|
|
2033
|
+
" \u2502\u25AA\u2502 ",
|
|
2034
|
+
" \u2502\u25AA\u2502 ",
|
|
2035
|
+
" \u2502\u25AA\u2502 ",
|
|
2036
|
+
" \u2502\u25AA\u2502 ",
|
|
2037
|
+
" \u2502\u25AA\u2502 ",
|
|
2038
|
+
" \u2502\u25AA\u2502 ",
|
|
2039
|
+
" \u2502\u25AA\u2502 "
|
|
2040
|
+
],
|
|
2041
|
+
[
|
|
2042
|
+
" \u250C\u2510 ",
|
|
2043
|
+
" \u251C\u2524 ",
|
|
2044
|
+
" \u2502\u25AA\u2502 ",
|
|
2045
|
+
" \u2502\u25AA\u2502 ",
|
|
2046
|
+
" \u2502\u25AA\u2502 ",
|
|
2047
|
+
" \u2502\u25AA\u2502 "
|
|
2048
|
+
],
|
|
2049
|
+
[
|
|
2050
|
+
" \u2554\u2550\u2550\u2550\u2557",
|
|
2051
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2052
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2053
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2054
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2055
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2056
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2057
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2058
|
+
" \u2551\u25AA \u25AA\u2551",
|
|
2059
|
+
" \u2551\u25AA \u25AA\u2551"
|
|
2060
|
+
],
|
|
2061
|
+
[
|
|
2062
|
+
" \u252C\u2500\u252C ",
|
|
2063
|
+
" \u2502~\u2502 ",
|
|
2064
|
+
" \u2502\u25AA\u2502 ",
|
|
2065
|
+
" \u2502\u25AA\u2502 ",
|
|
2066
|
+
" \u2502\u25AA\u2502 ",
|
|
2067
|
+
" \u2502\u25AA\u2502 ",
|
|
2068
|
+
" \u2502\u25AA\u2502 "
|
|
2069
|
+
]
|
|
2070
|
+
];
|
|
2071
|
+
MAX_HEIGHT = Math.max(...BUILDINGS.map((b) => b.length));
|
|
2072
|
+
TOTAL_FRAMES = MAX_HEIGHT + 4;
|
|
2073
|
+
GOLD = "\x1B[38;2;212;160;23m";
|
|
2074
|
+
RESET = "\x1B[0m";
|
|
2075
|
+
}
|
|
2076
|
+
});
|
|
2077
|
+
|
|
2078
|
+
// src/spinner.ts
|
|
2079
|
+
async function withSpinner(_label, fn, json) {
|
|
2080
|
+
if (json) {
|
|
2081
|
+
return fn();
|
|
2082
|
+
}
|
|
2083
|
+
return withAnimation(fn);
|
|
2084
|
+
}
|
|
2085
|
+
var init_spinner = __esm({
|
|
2086
|
+
"src/spinner.ts"() {
|
|
2087
|
+
"use strict";
|
|
2088
|
+
init_animation();
|
|
2089
|
+
}
|
|
2090
|
+
});
|
|
2091
|
+
|
|
2084
2092
|
// src/api-client.ts
|
|
2085
2093
|
import { CorpAPIClient, SessionExpiredError, provisionWorkspace } from "@thecorporation/corp-tools";
|
|
2086
2094
|
var init_api_client = __esm({
|
|
@@ -2174,8 +2182,7 @@ var init_workspace = __esm({
|
|
|
2174
2182
|
printStatusPanel(data);
|
|
2175
2183
|
}
|
|
2176
2184
|
} catch (err) {
|
|
2177
|
-
|
|
2178
|
-
process.exit(1);
|
|
2185
|
+
throw new Error(`Failed to fetch status: ${err}`);
|
|
2179
2186
|
}
|
|
2180
2187
|
},
|
|
2181
2188
|
examples: ["corp status"]
|
|
@@ -2247,8 +2254,7 @@ var init_workspace = __esm({
|
|
|
2247
2254
|
}
|
|
2248
2255
|
console.log(chalk3.blue("\u2500".repeat(50)));
|
|
2249
2256
|
} catch (err) {
|
|
2250
|
-
|
|
2251
|
-
process.exit(1);
|
|
2257
|
+
throw new Error(`Failed to fetch context: ${err}`);
|
|
2252
2258
|
}
|
|
2253
2259
|
},
|
|
2254
2260
|
examples: ["corp context", "corp context --json"]
|
|
@@ -2270,8 +2276,7 @@ var init_workspace = __esm({
|
|
|
2270
2276
|
const alias = getReferenceAlias("entity", { entity_id: entityId }) ?? entityId;
|
|
2271
2277
|
ctx.writer.success(`Active entity set to ${alias} (${entityId})`);
|
|
2272
2278
|
} catch (err) {
|
|
2273
|
-
|
|
2274
|
-
process.exit(1);
|
|
2279
|
+
throw new Error(`Failed to resolve entity: ${err}`);
|
|
2275
2280
|
}
|
|
2276
2281
|
},
|
|
2277
2282
|
examples: ["corp use", "corp use --json"]
|
|
@@ -2293,8 +2298,7 @@ var init_workspace = __esm({
|
|
|
2293
2298
|
handler: async (ctx) => {
|
|
2294
2299
|
const opts = ctx.opts;
|
|
2295
2300
|
if (opts.entityId && opts.workspace) {
|
|
2296
|
-
|
|
2297
|
-
process.exit(1);
|
|
2301
|
+
throw new Error("--entity-id and --workspace are mutually exclusive");
|
|
2298
2302
|
}
|
|
2299
2303
|
const localItems = localChecks();
|
|
2300
2304
|
const hasCriticalLocal = localItems.some((i) => i.urgency === "critical");
|
|
@@ -2364,8 +2368,7 @@ var init_workspace = __esm({
|
|
|
2364
2368
|
console.log(" corp form finalize @last");
|
|
2365
2369
|
}
|
|
2366
2370
|
} else {
|
|
2367
|
-
|
|
2368
|
-
process.exit(1);
|
|
2371
|
+
throw new Error(`Failed to fetch next steps: ${err}`);
|
|
2369
2372
|
}
|
|
2370
2373
|
}
|
|
2371
2374
|
}
|
|
@@ -2433,8 +2436,7 @@ var init_workspace = __esm({
|
|
|
2433
2436
|
}
|
|
2434
2437
|
}
|
|
2435
2438
|
} catch (err) {
|
|
2436
|
-
|
|
2437
|
-
process.exit(1);
|
|
2439
|
+
throw new Error(`Failed: ${err}`);
|
|
2438
2440
|
}
|
|
2439
2441
|
},
|
|
2440
2442
|
examples: ["corp digest"]
|
|
@@ -2457,8 +2459,7 @@ var init_workspace = __esm({
|
|
|
2457
2459
|
printBillingPanel(enrichedStatus, plans);
|
|
2458
2460
|
}
|
|
2459
2461
|
} catch (err) {
|
|
2460
|
-
|
|
2461
|
-
process.exit(1);
|
|
2462
|
+
throw new Error(`Failed to fetch billing info: ${err}`);
|
|
2462
2463
|
}
|
|
2463
2464
|
},
|
|
2464
2465
|
examples: ["corp billing"]
|
|
@@ -2473,14 +2474,12 @@ var init_workspace = __esm({
|
|
|
2473
2474
|
const result = await ctx.client.createBillingPortal();
|
|
2474
2475
|
const url = result.portal_url;
|
|
2475
2476
|
if (!url) {
|
|
2476
|
-
|
|
2477
|
-
process.exit(1);
|
|
2477
|
+
throw new Error("No portal URL returned. Ensure you have an active subscription.");
|
|
2478
2478
|
}
|
|
2479
2479
|
ctx.writer.success("Stripe Customer Portal URL:");
|
|
2480
2480
|
ctx.writer.writeln(url);
|
|
2481
2481
|
} catch (err) {
|
|
2482
|
-
|
|
2483
|
-
process.exit(1);
|
|
2482
|
+
throw new Error(`Failed to create portal session: ${err}`);
|
|
2484
2483
|
}
|
|
2485
2484
|
},
|
|
2486
2485
|
examples: ["corp billing portal"]
|
|
@@ -2504,14 +2503,12 @@ var init_workspace = __esm({
|
|
|
2504
2503
|
const result = await ctx.client.createBillingCheckout(opts.plan);
|
|
2505
2504
|
const url = result.checkout_url;
|
|
2506
2505
|
if (!url) {
|
|
2507
|
-
|
|
2508
|
-
process.exit(1);
|
|
2506
|
+
throw new Error("No checkout URL returned.");
|
|
2509
2507
|
}
|
|
2510
2508
|
ctx.writer.success(`Stripe Checkout URL for ${opts.plan}:`);
|
|
2511
2509
|
ctx.writer.writeln(url);
|
|
2512
2510
|
} catch (err) {
|
|
2513
|
-
|
|
2514
|
-
process.exit(1);
|
|
2511
|
+
throw new Error(`Failed to create checkout session: ${err}`);
|
|
2515
2512
|
}
|
|
2516
2513
|
},
|
|
2517
2514
|
examples: ["corp billing upgrade"]
|
|
@@ -2552,8 +2549,7 @@ async function entitiesHandler(ctx) {
|
|
|
2552
2549
|
printEntitiesTable(entities);
|
|
2553
2550
|
}
|
|
2554
2551
|
} catch (err) {
|
|
2555
|
-
|
|
2556
|
-
process.exit(1);
|
|
2552
|
+
throw new Error(`Failed to fetch entities: ${err}`);
|
|
2557
2553
|
}
|
|
2558
2554
|
}
|
|
2559
2555
|
async function entitiesShowHandler(ctx) {
|
|
@@ -2565,8 +2561,7 @@ async function entitiesShowHandler(ctx) {
|
|
|
2565
2561
|
const entities = await ctx.client.listEntities();
|
|
2566
2562
|
const entity = entities.find((e) => e.entity_id === resolvedEntityId);
|
|
2567
2563
|
if (!entity) {
|
|
2568
|
-
|
|
2569
|
-
process.exit(1);
|
|
2564
|
+
throw new Error(`Entity not found: ${entityRef}`);
|
|
2570
2565
|
}
|
|
2571
2566
|
await ctx.resolver.stabilizeRecord("entity", entity);
|
|
2572
2567
|
if (quiet) {
|
|
@@ -2590,8 +2585,7 @@ async function entitiesShowHandler(ctx) {
|
|
|
2590
2585
|
console.log(chalk4.blue("\u2500".repeat(40)));
|
|
2591
2586
|
}
|
|
2592
2587
|
} catch (err) {
|
|
2593
|
-
|
|
2594
|
-
process.exit(1);
|
|
2588
|
+
throw new Error(`Failed to fetch entities: ${err}`);
|
|
2595
2589
|
}
|
|
2596
2590
|
}
|
|
2597
2591
|
async function entitiesConvertHandler(ctx) {
|
|
@@ -2604,8 +2598,7 @@ async function entitiesConvertHandler(ctx) {
|
|
|
2604
2598
|
printSuccess(`Entity conversion initiated: ${result.conversion_id ?? "OK"}`);
|
|
2605
2599
|
printJson(result);
|
|
2606
2600
|
} catch (err) {
|
|
2607
|
-
|
|
2608
|
-
process.exit(1);
|
|
2601
|
+
throw new Error(`Failed to convert entity: ${err}`);
|
|
2609
2602
|
}
|
|
2610
2603
|
}
|
|
2611
2604
|
async function entitiesDissolveHandler(ctx) {
|
|
@@ -2630,11 +2623,10 @@ async function entitiesDissolveHandler(ctx) {
|
|
|
2630
2623
|
} catch (err) {
|
|
2631
2624
|
const msg = String(err);
|
|
2632
2625
|
if (msg.includes("InvalidTransition") || msg.includes("422")) {
|
|
2633
|
-
|
|
2626
|
+
throw new Error(`Cannot dissolve entity: only entities with 'active' status can be dissolved. Check the entity's current status with: corp entities show ${entityRef}`);
|
|
2634
2627
|
} else {
|
|
2635
|
-
|
|
2628
|
+
throw new Error(`Failed to dissolve entity: ${err}`);
|
|
2636
2629
|
}
|
|
2637
|
-
process.exit(1);
|
|
2638
2630
|
}
|
|
2639
2631
|
}
|
|
2640
2632
|
async function contactsHandler(ctx) {
|
|
@@ -2647,8 +2639,7 @@ async function contactsHandler(ctx) {
|
|
|
2647
2639
|
else if (contacts.length === 0) console.log("No contacts found.");
|
|
2648
2640
|
else printContactsTable(contacts);
|
|
2649
2641
|
} catch (err) {
|
|
2650
|
-
|
|
2651
|
-
process.exit(1);
|
|
2642
|
+
throw new Error(`Failed to fetch contacts: ${err}`);
|
|
2652
2643
|
}
|
|
2653
2644
|
}
|
|
2654
2645
|
async function contactsShowHandler(ctx) {
|
|
@@ -2683,8 +2674,7 @@ async function contactsShowHandler(ctx) {
|
|
|
2683
2674
|
console.log(chalk4.cyan("\u2500".repeat(40)));
|
|
2684
2675
|
}
|
|
2685
2676
|
} catch (err) {
|
|
2686
|
-
|
|
2687
|
-
process.exit(1);
|
|
2677
|
+
throw new Error(`Failed to fetch contact: ${err}`);
|
|
2688
2678
|
}
|
|
2689
2679
|
}
|
|
2690
2680
|
async function contactsAddHandler(ctx) {
|
|
@@ -2711,8 +2701,7 @@ async function contactsAddHandler(ctx) {
|
|
|
2711
2701
|
{ jsonOnly: jsonOutput, referenceKind: "contact", showReuseHint: true }
|
|
2712
2702
|
);
|
|
2713
2703
|
} catch (err) {
|
|
2714
|
-
|
|
2715
|
-
process.exit(1);
|
|
2704
|
+
throw new Error(`Failed to create contact: ${err}`);
|
|
2716
2705
|
}
|
|
2717
2706
|
}
|
|
2718
2707
|
async function contactsEditHandler(ctx) {
|
|
@@ -2759,8 +2748,7 @@ async function contactsEditHandler(ctx) {
|
|
|
2759
2748
|
ctx.resolver.remember("contact", resolvedContactId, eid);
|
|
2760
2749
|
printWriteResult(result, "Contact updated.", jsonOutput);
|
|
2761
2750
|
} catch (err) {
|
|
2762
|
-
|
|
2763
|
-
process.exit(1);
|
|
2751
|
+
throw new Error(`Failed to update contact: ${err}`);
|
|
2764
2752
|
}
|
|
2765
2753
|
}
|
|
2766
2754
|
var entityCommands;
|
|
@@ -2804,7 +2792,7 @@ var init_entities = __esm({
|
|
|
2804
2792
|
options: [
|
|
2805
2793
|
{ flags: "--reason <reason>", description: "Dissolution reason", required: true },
|
|
2806
2794
|
{ flags: "--effective-date <date>", description: "Effective date (ISO 8601)" },
|
|
2807
|
-
{ flags: "--yes
|
|
2795
|
+
{ flags: "--yes -y", description: "Skip confirmation prompt" }
|
|
2808
2796
|
],
|
|
2809
2797
|
handler: entitiesDissolveHandler,
|
|
2810
2798
|
examples: ["corp entities dissolve <entity-ref> --reason 'reason'", "corp entities dissolve --json"]
|
|
@@ -2877,7 +2865,7 @@ var init_entities = __esm({
|
|
|
2877
2865
|
name: "contacts notification-prefs",
|
|
2878
2866
|
description: "View notification preferences for a contact",
|
|
2879
2867
|
route: { method: "GET", path: "/v1/contacts/{pos}/notification-prefs" },
|
|
2880
|
-
args: [{ name: "contact-id", required: true, description: "Contact ID" }],
|
|
2868
|
+
args: [{ name: "contact-id", required: true, description: "Contact ID", posKind: "contact" }],
|
|
2881
2869
|
display: { title: "Contacts Notification Prefs", cols: ["#contact_id>ID", "email_enabled>Email Enabled", "sms_enabled>Sms Enabled", "@updated_at>Updated At", "webhook_enabled>Webhook Enabled"] },
|
|
2882
2870
|
examples: ["corp contacts notification-prefs"]
|
|
2883
2871
|
},
|
|
@@ -2885,13 +2873,13 @@ var init_entities = __esm({
|
|
|
2885
2873
|
name: "contacts update-notification-prefs",
|
|
2886
2874
|
description: "View notification preferences for a contact",
|
|
2887
2875
|
route: { method: "PATCH", path: "/v1/contacts/{pos}/notification-prefs" },
|
|
2888
|
-
args: [{ name: "contact-id", required: true, description: "Contact ID" }],
|
|
2876
|
+
args: [{ name: "contact-id", required: true, description: "Contact ID", posKind: "contact" }],
|
|
2889
2877
|
options: [
|
|
2890
2878
|
{ flags: "--email-enabled <email-enabled>", description: "Email Enabled" },
|
|
2891
2879
|
{ flags: "--sms-enabled <sms-enabled>", description: "Sms Enabled" },
|
|
2892
2880
|
{ flags: "--webhook-enabled <webhook-enabled>", description: "Webhook Enabled" }
|
|
2893
2881
|
],
|
|
2894
|
-
examples: ["corp contacts notification-prefs <contact-id>", "corp contacts notification-prefs --json"],
|
|
2882
|
+
examples: ["corp contacts update-notification-prefs <contact-id>", "corp contacts update-notification-prefs --json"],
|
|
2895
2883
|
successTemplate: "Notification Prefs updated"
|
|
2896
2884
|
}
|
|
2897
2885
|
];
|
|
@@ -3945,28 +3933,23 @@ async function resolveEntityRefForFormCommand2(resolver, entityRef, dryRun) {
|
|
|
3945
3933
|
async function formCreateHandler(ctx) {
|
|
3946
3934
|
const opts = ctx.opts;
|
|
3947
3935
|
if (opts.shares || opts.authorizedShares) {
|
|
3948
|
-
|
|
3936
|
+
throw new Error(
|
|
3949
3937
|
"--shares / --authorized-shares is not accepted on form create.\n Set authorized shares during finalize:\n corp form finalize @last:entity --authorized-shares 10000000"
|
|
3950
3938
|
);
|
|
3951
|
-
process.exit(1);
|
|
3952
3939
|
}
|
|
3953
3940
|
const resolvedType = opts.type;
|
|
3954
3941
|
const resolvedName = opts.name;
|
|
3955
3942
|
if (!resolvedType) {
|
|
3956
|
-
|
|
3957
|
-
process.exit(1);
|
|
3943
|
+
throw new Error("required option '--type <type>' not specified");
|
|
3958
3944
|
}
|
|
3959
3945
|
if (!SUPPORTED_ENTITY_TYPES2.includes(resolvedType)) {
|
|
3960
|
-
|
|
3961
|
-
process.exit(1);
|
|
3946
|
+
throw new Error(`unsupported entity type '${resolvedType}'. Supported types: ${SUPPORTED_ENTITY_TYPES2.join(", ")}`);
|
|
3962
3947
|
}
|
|
3963
3948
|
if (!resolvedName) {
|
|
3964
|
-
|
|
3965
|
-
process.exit(1);
|
|
3949
|
+
throw new Error("required option '--name <name>' not specified");
|
|
3966
3950
|
}
|
|
3967
3951
|
if (!resolvedName.trim()) {
|
|
3968
|
-
|
|
3969
|
-
process.exit(1);
|
|
3952
|
+
throw new Error("--name cannot be empty or whitespace");
|
|
3970
3953
|
}
|
|
3971
3954
|
const cfg = requireConfig("api_url", "api_key", "workspace_id");
|
|
3972
3955
|
try {
|
|
@@ -4018,8 +4001,7 @@ async function formCreateHandler(ctx) {
|
|
|
4018
4001
|
console.log(chalk6.yellow(`
|
|
4019
4002
|
Next: corp form add-founder @last:entity --name "..." --email "..." --role member --pct 50`));
|
|
4020
4003
|
} catch (err) {
|
|
4021
|
-
|
|
4022
|
-
process.exit(1);
|
|
4004
|
+
throw new Error(`Failed to create pending entity: ${err}`);
|
|
4023
4005
|
}
|
|
4024
4006
|
}
|
|
4025
4007
|
async function formAddFounderHandler(ctx) {
|
|
@@ -4029,13 +4011,11 @@ async function formAddFounderHandler(ctx) {
|
|
|
4029
4011
|
const resolvedEntityId = await resolveEntityRefForFormCommand2(ctx.resolver, entityRef, ctx.dryRun);
|
|
4030
4012
|
const rawPct = opts.ownershipPct ?? opts.pct;
|
|
4031
4013
|
if (!rawPct) {
|
|
4032
|
-
|
|
4033
|
-
process.exit(1);
|
|
4014
|
+
throw new Error("required option '--ownership-pct <percent>' not specified");
|
|
4034
4015
|
}
|
|
4035
4016
|
const pctValue = parseFloat(rawPct);
|
|
4036
4017
|
if (isNaN(pctValue) || pctValue <= 0 || pctValue > 100) {
|
|
4037
|
-
|
|
4038
|
-
process.exit(1);
|
|
4018
|
+
throw new Error(`--ownership-pct must be between 0 and 100 (e.g. 60 for 60%), got: ${rawPct}`);
|
|
4039
4019
|
}
|
|
4040
4020
|
const payload = {
|
|
4041
4021
|
name: opts.name,
|
|
@@ -4065,8 +4045,7 @@ async function formAddFounderHandler(ctx) {
|
|
|
4065
4045
|
console.log(chalk6.yellow(`
|
|
4066
4046
|
Next: add more founders or run: corp form finalize @last:entity`));
|
|
4067
4047
|
} catch (err) {
|
|
4068
|
-
|
|
4069
|
-
process.exit(1);
|
|
4048
|
+
throw new Error(`Failed to add founder: ${err}`);
|
|
4070
4049
|
}
|
|
4071
4050
|
}
|
|
4072
4051
|
async function formFinalizeHandler(ctx) {
|
|
@@ -4157,7 +4136,7 @@ async function formFinalizeHandler(ctx) {
|
|
|
4157
4136
|
hints.push('--incorporator-name "Incorporator Name"');
|
|
4158
4137
|
}
|
|
4159
4138
|
if (hints.length > 0) {
|
|
4160
|
-
|
|
4139
|
+
throw new Error(
|
|
4161
4140
|
`Finalization failed: ${msg}
|
|
4162
4141
|
|
|
4163
4142
|
To fix, re-run finalize with the missing fields:
|
|
@@ -4167,9 +4146,8 @@ async function formFinalizeHandler(ctx) {
|
|
|
4167
4146
|
corp form finalize @last ${hints.filter((h) => h.startsWith("--")).join(" ")}`
|
|
4168
4147
|
);
|
|
4169
4148
|
} else {
|
|
4170
|
-
|
|
4149
|
+
throw new Error(`Failed to finalize formation: ${err}`);
|
|
4171
4150
|
}
|
|
4172
|
-
process.exit(1);
|
|
4173
4151
|
}
|
|
4174
4152
|
}
|
|
4175
4153
|
async function formActivateHandler(ctx) {
|
|
@@ -4220,8 +4198,7 @@ async function formActivateHandler(ctx) {
|
|
|
4220
4198
|
console.log(chalk6.yellow(" corp next See all recommended actions"));
|
|
4221
4199
|
}
|
|
4222
4200
|
} catch (err) {
|
|
4223
|
-
|
|
4224
|
-
process.exit(1);
|
|
4201
|
+
throw new Error(`Failed to activate formation: ${err}`);
|
|
4225
4202
|
}
|
|
4226
4203
|
}
|
|
4227
4204
|
var SUPPORTED_ENTITY_TYPES2, formationCommands;
|
|
@@ -4374,7 +4351,7 @@ var init_formation = __esm({
|
|
|
4374
4351
|
description: "View a document by ID",
|
|
4375
4352
|
route: { method: "GET", path: "/v1/documents/{pos}" },
|
|
4376
4353
|
entity: true,
|
|
4377
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4354
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4378
4355
|
display: { title: "Document", cols: ["document_type>Type", "status>Status", "title>Title", "signature_count>Signatures", "@created_at>Created", "#document_id>ID"] },
|
|
4379
4356
|
examples: ["corp documents show <document-id>", "corp documents show <document-id> --json"]
|
|
4380
4357
|
},
|
|
@@ -4383,7 +4360,7 @@ var init_formation = __esm({
|
|
|
4383
4360
|
description: "View amendment history for a document",
|
|
4384
4361
|
route: { method: "GET", path: "/v1/documents/{pos}/amendment-history" },
|
|
4385
4362
|
entity: true,
|
|
4386
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4363
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4387
4364
|
display: { title: "Documents Amendment History", cols: ["amended_at>Amended At", "description>Description", "version>Version"] },
|
|
4388
4365
|
examples: ["corp documents amendment-history", "corp documents amendment-history --json"]
|
|
4389
4366
|
},
|
|
@@ -4392,14 +4369,14 @@ var init_formation = __esm({
|
|
|
4392
4369
|
description: "Download a document as PDF",
|
|
4393
4370
|
route: { method: "GET", path: "/v1/documents/{pos}/pdf" },
|
|
4394
4371
|
entity: true,
|
|
4395
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4372
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4396
4373
|
examples: ["corp documents pdf", "corp documents pdf --json"]
|
|
4397
4374
|
},
|
|
4398
4375
|
{
|
|
4399
4376
|
name: "documents request-copy",
|
|
4400
4377
|
description: "Request a certified copy of a document",
|
|
4401
4378
|
route: { method: "POST", path: "/v1/documents/{pos}/request-copy" },
|
|
4402
|
-
args: [{ name: "document-id", required: true, description: "Document ID" }],
|
|
4379
|
+
args: [{ name: "document-id", required: true, description: "Document ID", posKind: "document" }],
|
|
4403
4380
|
options: [
|
|
4404
4381
|
{ flags: "--recipient-email <recipient-email>", description: "Recipient Email" }
|
|
4405
4382
|
],
|
|
@@ -4454,7 +4431,7 @@ var init_formation = __esm({
|
|
|
4454
4431
|
},
|
|
4455
4432
|
{
|
|
4456
4433
|
name: "formations pending",
|
|
4457
|
-
description: "
|
|
4434
|
+
description: "Create a pending formation",
|
|
4458
4435
|
route: { method: "POST", path: "/v1/formations/pending" },
|
|
4459
4436
|
options: [
|
|
4460
4437
|
{ flags: "--company-address <company-address>", description: "Company mailing address" },
|
|
@@ -4470,7 +4447,7 @@ var init_formation = __esm({
|
|
|
4470
4447
|
{ flags: "--transfer-restrictions <transfer-restrictions>", description: "Transfer Restrictions" }
|
|
4471
4448
|
],
|
|
4472
4449
|
examples: ["corp formations pending --entity-type c_corp --legal-name 'legal-name'", "corp formations pending --json"],
|
|
4473
|
-
successTemplate: "Pending created"
|
|
4450
|
+
successTemplate: "Pending formation created"
|
|
4474
4451
|
},
|
|
4475
4452
|
{
|
|
4476
4453
|
name: "formations with-cap-table",
|
|
@@ -4715,8 +4692,7 @@ var init_cap_table = __esm({
|
|
|
4715
4692
|
return;
|
|
4716
4693
|
}
|
|
4717
4694
|
if (data.access_level === "none") {
|
|
4718
|
-
|
|
4719
|
-
process.exit(1);
|
|
4695
|
+
throw new Error("You do not have access to this entity's cap table.");
|
|
4720
4696
|
}
|
|
4721
4697
|
printCapTable(data);
|
|
4722
4698
|
try {
|
|
@@ -4936,10 +4912,10 @@ var init_cap_table = __esm({
|
|
|
4936
4912
|
"No 409A valuation found for this entity. Create one with:\n corp cap-table create-valuation --type four_oh_nine_a --date YYYY-MM-DD --methodology <method>"
|
|
4937
4913
|
);
|
|
4938
4914
|
}
|
|
4915
|
+
return;
|
|
4939
4916
|
} else {
|
|
4940
|
-
|
|
4917
|
+
throw new Error(`Failed to fetch 409A valuation: ${err}`);
|
|
4941
4918
|
}
|
|
4942
|
-
process.exit(1);
|
|
4943
4919
|
}
|
|
4944
4920
|
},
|
|
4945
4921
|
examples: ["corp cap-table 409a", "corp cap-table 409a --json"]
|
|
@@ -5512,7 +5488,7 @@ var init_cap_table = __esm({
|
|
|
5512
5488
|
if (resolutionId) body.resolution_id = resolutionId;
|
|
5513
5489
|
const result = await ctx.client.issueRound(roundId, body);
|
|
5514
5490
|
ctx.resolver.remember("round", roundId, eid);
|
|
5515
|
-
const roundMatch = (await ctx.resolver.find("round",
|
|
5491
|
+
const roundMatch = (await ctx.resolver.find("round", shortId(roundId), { entityId: eid })).find((match) => match.id === roundId);
|
|
5516
5492
|
if (ctx.opts.json) {
|
|
5517
5493
|
ctx.writer.json(result);
|
|
5518
5494
|
return;
|
|
@@ -5615,7 +5591,7 @@ var init_cap_table = __esm({
|
|
|
5615
5591
|
ctx.writer.success(`Valuation submitted for approval: ${result.valuation_id ?? valuationId ?? "OK"}`);
|
|
5616
5592
|
printReferenceSummary("valuation", result, { showReuseHint: true });
|
|
5617
5593
|
if (result.meeting_id) {
|
|
5618
|
-
const meetingMatch = (await ctx.resolver.find("meeting",
|
|
5594
|
+
const meetingMatch = (await ctx.resolver.find("meeting", shortId(String(result.meeting_id)), { entityId: eid })).find((match) => match.id === String(result.meeting_id));
|
|
5619
5595
|
if (meetingMatch) {
|
|
5620
5596
|
printReferenceSummary("meeting", meetingMatch.raw, { label: "Meeting Ref:" });
|
|
5621
5597
|
} else {
|
|
@@ -5623,7 +5599,7 @@ var init_cap_table = __esm({
|
|
|
5623
5599
|
}
|
|
5624
5600
|
}
|
|
5625
5601
|
if (result.agenda_item_id) {
|
|
5626
|
-
const agendaMatch = (await ctx.resolver.find("agenda_item",
|
|
5602
|
+
const agendaMatch = (await ctx.resolver.find("agenda_item", shortId(String(result.agenda_item_id)), {
|
|
5627
5603
|
entityId: eid,
|
|
5628
5604
|
meetingId: result.meeting_id ? String(result.meeting_id) : void 0
|
|
5629
5605
|
})).find((match) => match.id === String(result.agenda_item_id));
|
|
@@ -5636,11 +5612,10 @@ var init_cap_table = __esm({
|
|
|
5636
5612
|
} catch (err) {
|
|
5637
5613
|
const msg = String(err);
|
|
5638
5614
|
if (msg.includes("404") || msg.includes("Not found") || msg.includes("not found")) {
|
|
5639
|
-
|
|
5615
|
+
throw new Error(`Valuation not found. List valuations with: corp cap-table valuations`);
|
|
5640
5616
|
} else {
|
|
5641
|
-
|
|
5617
|
+
throw new Error(`Failed to submit valuation: ${err}`);
|
|
5642
5618
|
}
|
|
5643
|
-
process.exit(1);
|
|
5644
5619
|
}
|
|
5645
5620
|
},
|
|
5646
5621
|
examples: ["corp cap-table submit-valuation <valuation-ref>"]
|
|
@@ -5681,11 +5656,10 @@ var init_cap_table = __esm({
|
|
|
5681
5656
|
} catch (err) {
|
|
5682
5657
|
const msg = String(err);
|
|
5683
5658
|
if (msg.includes("400")) {
|
|
5684
|
-
|
|
5659
|
+
throw new Error(`Bad request \u2014 a --resolution-id from a board vote may be required. Submit for approval first: corp cap-table submit-valuation <valuation-ref>`);
|
|
5685
5660
|
} else {
|
|
5686
|
-
|
|
5661
|
+
throw new Error(`Failed to approve valuation: ${err}`);
|
|
5687
5662
|
}
|
|
5688
|
-
process.exit(1);
|
|
5689
5663
|
}
|
|
5690
5664
|
},
|
|
5691
5665
|
examples: ["corp cap-table approve-valuation <valuation-ref>", "corp cap-table approve-valuation --json"]
|
|
@@ -6529,13 +6503,11 @@ var init_finance = __esm({
|
|
|
6529
6503
|
handler: async (ctx) => {
|
|
6530
6504
|
const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
|
|
6531
6505
|
if (ctx.opts.amountCents != null && ctx.opts.amountDollars != null) {
|
|
6532
|
-
|
|
6533
|
-
process.exit(1);
|
|
6506
|
+
throw new Error("--amount-cents and --amount-dollars are mutually exclusive. Use one or the other.");
|
|
6534
6507
|
}
|
|
6535
6508
|
const amountCents = ctx.opts.amountCents ?? (ctx.opts.amountDollars != null ? ctx.opts.amountDollars * 100 : void 0);
|
|
6536
6509
|
if (amountCents == null) {
|
|
6537
|
-
|
|
6538
|
-
process.exit(1);
|
|
6510
|
+
throw new Error("required: --amount-cents <n> or --amount-dollars <n>");
|
|
6539
6511
|
}
|
|
6540
6512
|
const result = await ctx.client.createInvoice({
|
|
6541
6513
|
entity_id: eid,
|
|
@@ -6597,13 +6569,11 @@ var init_finance = __esm({
|
|
|
6597
6569
|
handler: async (ctx) => {
|
|
6598
6570
|
const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
|
|
6599
6571
|
if (ctx.opts.amountCents != null && ctx.opts.amountDollars != null) {
|
|
6600
|
-
|
|
6601
|
-
process.exit(1);
|
|
6572
|
+
throw new Error("--amount-cents and --amount-dollars are mutually exclusive. Use one or the other.");
|
|
6602
6573
|
}
|
|
6603
6574
|
const amountCents = ctx.opts.amountCents ?? (ctx.opts.amountDollars != null ? ctx.opts.amountDollars * 100 : void 0);
|
|
6604
6575
|
if (amountCents == null) {
|
|
6605
|
-
|
|
6606
|
-
process.exit(1);
|
|
6576
|
+
throw new Error("required: --amount-cents <n> or --amount-dollars <n>");
|
|
6607
6577
|
}
|
|
6608
6578
|
const method = ctx.opts.method;
|
|
6609
6579
|
const result = await ctx.client.submitPayment({
|
|
@@ -6915,7 +6885,17 @@ var init_finance = __esm({
|
|
|
6915
6885
|
ctx.writer.json(result);
|
|
6916
6886
|
return;
|
|
6917
6887
|
}
|
|
6918
|
-
|
|
6888
|
+
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
6889
|
+
const rec = result;
|
|
6890
|
+
const lines = Object.entries(rec).map(([key, val]) => {
|
|
6891
|
+
const label = key.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
|
|
6892
|
+
const formatted = typeof val === "object" ? JSON.stringify(val) : String(val ?? "");
|
|
6893
|
+
return `${label}: ${formatted}`;
|
|
6894
|
+
});
|
|
6895
|
+
ctx.writer.panel("Financial Statements", "green", lines);
|
|
6896
|
+
} else {
|
|
6897
|
+
ctx.writer.json(result);
|
|
6898
|
+
}
|
|
6919
6899
|
},
|
|
6920
6900
|
examples: ["corp finance statements", "corp finance statements --json"]
|
|
6921
6901
|
}
|
|
@@ -7419,7 +7399,7 @@ var init_governance = __esm({
|
|
|
7419
7399
|
}
|
|
7420
7400
|
}
|
|
7421
7401
|
},
|
|
7422
|
-
examples: ["corp governance vote <meeting-ref> <item-ref> --voter
|
|
7402
|
+
examples: ["corp governance vote <meeting-ref> <item-ref> --voter <contact-ref> --vote for"]
|
|
7423
7403
|
},
|
|
7424
7404
|
// --- governance notice <meeting-ref> ---
|
|
7425
7405
|
{
|
|
@@ -7505,7 +7485,7 @@ var init_governance = __esm({
|
|
|
7505
7485
|
dryRun: true,
|
|
7506
7486
|
args: [{ name: "meeting-ref", required: true, description: "Meeting reference" }],
|
|
7507
7487
|
options: [
|
|
7508
|
-
{ flags: "--yes
|
|
7488
|
+
{ flags: "--yes -y", description: "Skip confirmation prompt" }
|
|
7509
7489
|
],
|
|
7510
7490
|
handler: async (ctx) => {
|
|
7511
7491
|
const meetingRef = ctx.positional[0];
|
|
@@ -7878,7 +7858,7 @@ var init_governance = __esm({
|
|
|
7878
7858
|
},
|
|
7879
7859
|
{
|
|
7880
7860
|
name: "governance-bodies create",
|
|
7881
|
-
description: "
|
|
7861
|
+
description: "Create a governance body",
|
|
7882
7862
|
route: { method: "POST", path: "/v1/governance-bodies" },
|
|
7883
7863
|
options: [
|
|
7884
7864
|
{ flags: "--body-type <body-type>", description: "The type of governance body.", required: true, choices: ["board_of_directors", "llc_member_vote"] },
|
|
@@ -7887,7 +7867,7 @@ var init_governance = __esm({
|
|
|
7887
7867
|
{ flags: "--voting-method <voting-method>", description: "How votes are counted.", required: true, choices: ["per_capita", "per_unit"] }
|
|
7888
7868
|
],
|
|
7889
7869
|
examples: ["corp governance-bodies --body-type board_of_directors --name majority --quorum-rule majority --voting-method per_capita"],
|
|
7890
|
-
successTemplate: "Governance
|
|
7870
|
+
successTemplate: "Governance body created"
|
|
7891
7871
|
},
|
|
7892
7872
|
{
|
|
7893
7873
|
name: "governance-seats scan-expired",
|
|
@@ -7895,7 +7875,7 @@ var init_governance = __esm({
|
|
|
7895
7875
|
route: { method: "POST", path: "/v1/governance-seats/scan-expired" },
|
|
7896
7876
|
entity: true,
|
|
7897
7877
|
examples: ["corp governance-seats scan-expired"],
|
|
7898
|
-
successTemplate: "
|
|
7878
|
+
successTemplate: "Expired seats scanned"
|
|
7899
7879
|
},
|
|
7900
7880
|
{
|
|
7901
7881
|
name: "governance-seats resign",
|
|
@@ -7904,7 +7884,7 @@ var init_governance = __esm({
|
|
|
7904
7884
|
entity: true,
|
|
7905
7885
|
args: [{ name: "seat-id", required: true, description: "Governance seat ID" }],
|
|
7906
7886
|
examples: ["corp governance-seats resign <seat-id>"],
|
|
7907
|
-
successTemplate: "
|
|
7887
|
+
successTemplate: "Seat resigned"
|
|
7908
7888
|
},
|
|
7909
7889
|
{
|
|
7910
7890
|
name: "governance audit-checkpoints",
|
|
@@ -7995,7 +7975,7 @@ var init_governance = __esm({
|
|
|
7995
7975
|
{ flags: "--metadata <metadata>", description: "Additional metadata (JSON)" }
|
|
7996
7976
|
],
|
|
7997
7977
|
examples: ["corp governance evaluate --intent-type 'intent-type'", "corp governance evaluate --json"],
|
|
7998
|
-
successTemplate: "
|
|
7978
|
+
successTemplate: "Governance evaluated"
|
|
7999
7979
|
},
|
|
8000
7980
|
{
|
|
8001
7981
|
name: "governance report-incident",
|
|
@@ -8147,12 +8127,10 @@ var init_documents = __esm({
|
|
|
8147
8127
|
try {
|
|
8148
8128
|
resolvedDocumentId = await ctx.resolver.resolveDocument(eid, docRef);
|
|
8149
8129
|
} catch {
|
|
8150
|
-
|
|
8130
|
+
throw new Error(
|
|
8151
8131
|
`Could not resolve '${docRef}' as a document. If you just generated a contract, use the document_id from the generate output, not @last (which may reference the contract_id).
|
|
8152
8132
|
List documents with: corp documents`
|
|
8153
8133
|
);
|
|
8154
|
-
process.exit(1);
|
|
8155
|
-
return;
|
|
8156
8134
|
}
|
|
8157
8135
|
const result = await ctx.client.getSigningLink(resolvedDocumentId, eid);
|
|
8158
8136
|
const shareUrl = formatSigningLink(resolvedDocumentId, result);
|
|
@@ -8299,7 +8277,7 @@ var init_documents = __esm({
|
|
|
8299
8277
|
} catch (err) {
|
|
8300
8278
|
const msg = String(err);
|
|
8301
8279
|
if (template === "employment_offer" && (msg.includes("base_salary") || msg.includes("required"))) {
|
|
8302
|
-
|
|
8280
|
+
throw new Error(
|
|
8303
8281
|
`Failed to generate employment_offer: ${msg}
|
|
8304
8282
|
Hint: employment_offer requires base_salary. Use:
|
|
8305
8283
|
--base-salary 150000
|
|
@@ -8308,16 +8286,15 @@ var init_documents = __esm({
|
|
|
8308
8286
|
bonus_terms, equity_terms, benefits_summary, governing_law`
|
|
8309
8287
|
);
|
|
8310
8288
|
} else if (template === "safe_agreement" && (msg.includes("purchase_amount") || msg.includes("investment_amount") || msg.includes("valuation_cap") || msg.includes("investor_notice") || msg.includes("required"))) {
|
|
8311
|
-
|
|
8289
|
+
throw new Error(
|
|
8312
8290
|
`Failed to generate safe_agreement: ${msg}
|
|
8313
8291
|
Hint: safe_agreement requires purchase_amount, valuation_cap, and investor_notice_address. Use:
|
|
8314
8292
|
--param purchase_amount=50000000 --param valuation_cap=10000000
|
|
8315
8293
|
--param investor_notice_address="123 Main St, City, ST 12345"`
|
|
8316
8294
|
);
|
|
8317
8295
|
} else {
|
|
8318
|
-
|
|
8296
|
+
throw new Error(`Failed to generate contract: ${err}`);
|
|
8319
8297
|
}
|
|
8320
|
-
process.exit(1);
|
|
8321
8298
|
}
|
|
8322
8299
|
},
|
|
8323
8300
|
produces: { kind: "document" },
|
|
@@ -8337,8 +8314,7 @@ var init_documents = __esm({
|
|
|
8337
8314
|
handler: async (ctx) => {
|
|
8338
8315
|
const documentId = ctx.opts.definitionId ?? ctx.opts.documentId;
|
|
8339
8316
|
if (!documentId || documentId.trim().length === 0) {
|
|
8340
|
-
|
|
8341
|
-
process.exit(1);
|
|
8317
|
+
throw new Error("preview-pdf requires --definition-id (or deprecated alias --document-id)");
|
|
8342
8318
|
}
|
|
8343
8319
|
const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
|
|
8344
8320
|
await ctx.client.validatePreviewPdf(eid, documentId);
|
|
@@ -8418,7 +8394,7 @@ var init_compliance = __esm({
|
|
|
8418
8394
|
// --- tax filings ---
|
|
8419
8395
|
{
|
|
8420
8396
|
name: "tax filings",
|
|
8421
|
-
description: "
|
|
8397
|
+
description: "List tax filing records",
|
|
8422
8398
|
route: { method: "GET", path: "/v1/entities/{eid}/tax-filings" },
|
|
8423
8399
|
entity: true,
|
|
8424
8400
|
display: {
|
|
@@ -8479,7 +8455,7 @@ var init_compliance = __esm({
|
|
|
8479
8455
|
},
|
|
8480
8456
|
produces: { kind: "tax_filing" },
|
|
8481
8457
|
successTemplate: "Tax filing created",
|
|
8482
|
-
examples: ["corp tax file --year 'year'"]
|
|
8458
|
+
examples: ["corp tax file --type 1120 --year 'year'"]
|
|
8483
8459
|
},
|
|
8484
8460
|
// --- tax deadlines ---
|
|
8485
8461
|
{
|
|
@@ -8551,7 +8527,7 @@ var init_compliance = __esm({
|
|
|
8551
8527
|
description: "Scan for compliance issues and create escalations",
|
|
8552
8528
|
route: { method: "POST", path: "/v1/compliance/escalations/scan" },
|
|
8553
8529
|
examples: ["corp compliance escalations-scan"],
|
|
8554
|
-
successTemplate: "
|
|
8530
|
+
successTemplate: "Escalation scan complete"
|
|
8555
8531
|
},
|
|
8556
8532
|
{
|
|
8557
8533
|
name: "compliance escalations-resolve-with-evidence",
|
|
@@ -8617,7 +8593,7 @@ var init_compliance = __esm({
|
|
|
8617
8593
|
{ flags: "--document-type <document-type>", description: "Type of document required", required: true },
|
|
8618
8594
|
{ flags: "--tax-year <tax-year>", description: "Tax Year", required: true, type: "int" }
|
|
8619
8595
|
],
|
|
8620
|
-
examples: ["corp tax
|
|
8596
|
+
examples: ["corp tax create-filing --document-type 'document-type' --tax-year 'tax-year'"],
|
|
8621
8597
|
successTemplate: "Filings created"
|
|
8622
8598
|
}
|
|
8623
8599
|
];
|
|
@@ -8751,14 +8727,13 @@ var init_agents = __esm({
|
|
|
8751
8727
|
} catch (err) {
|
|
8752
8728
|
const msg = String(err);
|
|
8753
8729
|
if (msg.includes("409") || msg.includes("conflict") || msg.includes("already exists")) {
|
|
8754
|
-
|
|
8730
|
+
throw new Error(
|
|
8755
8731
|
`Agent name '${ctx.opts.name}' is already in use (deleted agents still reserve their name).
|
|
8756
8732
|
Choose a different name, e.g.: corp agents create --name '...-v2' --prompt '...'`
|
|
8757
8733
|
);
|
|
8758
8734
|
} else {
|
|
8759
|
-
|
|
8735
|
+
throw new Error(`Failed to create agent: ${err}`);
|
|
8760
8736
|
}
|
|
8761
|
-
process.exit(1);
|
|
8762
8737
|
}
|
|
8763
8738
|
},
|
|
8764
8739
|
produces: { kind: "agent" },
|
|
@@ -8794,15 +8769,14 @@ var init_agents = __esm({
|
|
|
8794
8769
|
} catch (err) {
|
|
8795
8770
|
const msg = String(err);
|
|
8796
8771
|
if (msg.includes("409") || msg.includes("disabled") || msg.includes("deleted")) {
|
|
8797
|
-
|
|
8772
|
+
throw new Error(
|
|
8798
8773
|
`Cannot resume agent ${agentRef}: the agent may be disabled or deleted.
|
|
8799
8774
|
Disabled/deleted agents cannot be resumed. Create a new agent instead:
|
|
8800
8775
|
corp agents create --name '...' --prompt '...'`
|
|
8801
8776
|
);
|
|
8802
8777
|
} else {
|
|
8803
|
-
|
|
8778
|
+
throw new Error(`Failed to resume agent: ${err}`);
|
|
8804
8779
|
}
|
|
8805
|
-
process.exit(1);
|
|
8806
8780
|
}
|
|
8807
8781
|
},
|
|
8808
8782
|
examples: ["corp agents resume <agent-ref>"]
|
|
@@ -8814,7 +8788,7 @@ var init_agents = __esm({
|
|
|
8814
8788
|
route: { method: "DELETE", path: "/v1/agents/{pos}" },
|
|
8815
8789
|
args: [{ name: "agent-ref", required: true, description: "Agent reference" }],
|
|
8816
8790
|
options: [
|
|
8817
|
-
{ flags: "--yes
|
|
8791
|
+
{ flags: "--yes -y", description: "Skip confirmation prompt" }
|
|
8818
8792
|
],
|
|
8819
8793
|
handler: async (ctx) => {
|
|
8820
8794
|
const agentRef = ctx.positional[0];
|
|
@@ -8854,14 +8828,13 @@ var init_agents = __esm({
|
|
|
8854
8828
|
} catch (err) {
|
|
8855
8829
|
const msg = String(err);
|
|
8856
8830
|
if (msg.includes("409")) {
|
|
8857
|
-
|
|
8831
|
+
throw new Error(
|
|
8858
8832
|
`Cannot message agent: the agent must be active or paused (not disabled/deleted).
|
|
8859
8833
|
Check agent status: corp agents show ` + agentRef + "\n Resume a paused agent: corp agents resume " + agentRef
|
|
8860
8834
|
);
|
|
8861
8835
|
} else {
|
|
8862
|
-
|
|
8836
|
+
throw new Error(`Failed to send message: ${err}`);
|
|
8863
8837
|
}
|
|
8864
|
-
process.exit(1);
|
|
8865
8838
|
}
|
|
8866
8839
|
},
|
|
8867
8840
|
examples: ["corp agents message <agent-ref>", "corp agents message --json"]
|
|
@@ -8983,7 +8956,7 @@ var init_agents = __esm({
|
|
|
8983
8956
|
name: "agents executions-logs",
|
|
8984
8957
|
description: "View execution logs for an agent run",
|
|
8985
8958
|
route: { method: "GET", path: "/v1/agents/{pos}/executions/{pos2}/logs" },
|
|
8986
|
-
args: [{ name: "agent-id", required: true, description: "Agent ID" }, { name: "execution-id", required: true, description: "Agent execution ID" }],
|
|
8959
|
+
args: [{ name: "agent-id", required: true, description: "Agent ID", posKind: "agent" }, { name: "execution-id", required: true, description: "Agent execution ID" }],
|
|
8987
8960
|
display: { title: "Execution Logs", cols: ["@timestamp>Time", "level>Level", "message>Message"] },
|
|
8988
8961
|
examples: ["corp agents executions-logs"]
|
|
8989
8962
|
},
|
|
@@ -8992,7 +8965,7 @@ var init_agents = __esm({
|
|
|
8992
8965
|
name: "agents messages",
|
|
8993
8966
|
description: "View a specific agent message",
|
|
8994
8967
|
route: { method: "GET", path: "/v1/agents/{pos}/messages/{pos2}" },
|
|
8995
|
-
args: [{ name: "agent-id", required: true, description: "Agent ID" }, { name: "message-id", required: true, description: "Message Id" }],
|
|
8968
|
+
args: [{ name: "agent-id", required: true, description: "Agent ID", posKind: "agent" }, { name: "message-id", required: true, description: "Message Id" }],
|
|
8996
8969
|
display: { title: "Agent Message" },
|
|
8997
8970
|
examples: ["corp agents messages"]
|
|
8998
8971
|
}
|
|
@@ -9121,8 +9094,7 @@ var init_work_items = __esm({
|
|
|
9121
9094
|
const eid = await ctx.resolver.resolveEntity(ctx.opts.entityId);
|
|
9122
9095
|
const category = ctx.opts.category;
|
|
9123
9096
|
if (!category) {
|
|
9124
|
-
|
|
9125
|
-
process.exit(1);
|
|
9097
|
+
throw new Error("required option '--category <category>' not specified");
|
|
9126
9098
|
}
|
|
9127
9099
|
const data = { title: ctx.opts.title, category };
|
|
9128
9100
|
if (ctx.opts.description) data.description = ctx.opts.description;
|
|
@@ -9160,8 +9132,7 @@ var init_work_items = __esm({
|
|
|
9160
9132
|
const resolvedWorkItemId = await ctx.resolver.resolveWorkItem(eid, itemRef);
|
|
9161
9133
|
const claimedBy = ctx.opts.by ?? ctx.opts.claimer;
|
|
9162
9134
|
if (!claimedBy) {
|
|
9163
|
-
|
|
9164
|
-
process.exit(1);
|
|
9135
|
+
throw new Error("required option '--by <name>' not specified");
|
|
9165
9136
|
}
|
|
9166
9137
|
const data = {
|
|
9167
9138
|
claimed_by_actor: await ctx.resolver.resolveWorkItemActor(eid, claimedBy)
|
|
@@ -9191,8 +9162,7 @@ var init_work_items = __esm({
|
|
|
9191
9162
|
const resolvedWorkItemId = await ctx.resolver.resolveWorkItem(eid, itemRef);
|
|
9192
9163
|
const completedBy = ctx.opts.by ?? ctx.opts.completedBy;
|
|
9193
9164
|
if (!completedBy) {
|
|
9194
|
-
|
|
9195
|
-
process.exit(1);
|
|
9165
|
+
throw new Error("required option '--by <name>' not specified");
|
|
9196
9166
|
}
|
|
9197
9167
|
const data = {
|
|
9198
9168
|
completed_by_actor: await ctx.resolver.resolveWorkItemActor(eid, completedBy)
|
|
@@ -9228,7 +9198,7 @@ var init_work_items = __esm({
|
|
|
9228
9198
|
entity: true,
|
|
9229
9199
|
args: [{ name: "item-ref", required: true, description: "Work item reference" }],
|
|
9230
9200
|
options: [
|
|
9231
|
-
{ flags: "--yes
|
|
9201
|
+
{ flags: "--yes -y", description: "Skip confirmation prompt" }
|
|
9232
9202
|
],
|
|
9233
9203
|
handler: async (ctx) => {
|
|
9234
9204
|
const itemRef = ctx.positional[0];
|
|
@@ -9281,25 +9251,6 @@ var init_services = __esm({
|
|
|
9281
9251
|
},
|
|
9282
9252
|
examples: ["corp services", "corp services --json"]
|
|
9283
9253
|
},
|
|
9284
|
-
// --- services catalog ---
|
|
9285
|
-
{
|
|
9286
|
-
name: "services catalog",
|
|
9287
|
-
description: "List the service catalog",
|
|
9288
|
-
route: { method: "GET", path: "/v1/services/catalog" },
|
|
9289
|
-
display: {
|
|
9290
|
-
title: "Service Catalog",
|
|
9291
|
-
cols: ["name>Name", "slug>Slug", "$price_cents>Price", "#service_id|id>ID"]
|
|
9292
|
-
},
|
|
9293
|
-
handler: async (ctx) => {
|
|
9294
|
-
const items = await ctx.client.listServiceCatalog();
|
|
9295
|
-
if (ctx.opts.json) {
|
|
9296
|
-
ctx.writer.json(items);
|
|
9297
|
-
return;
|
|
9298
|
-
}
|
|
9299
|
-
printServiceCatalogTable(items);
|
|
9300
|
-
},
|
|
9301
|
-
examples: ["corp services catalog"]
|
|
9302
|
-
},
|
|
9303
9254
|
// --- services list ---
|
|
9304
9255
|
{
|
|
9305
9256
|
name: "services list",
|
|
@@ -9462,10 +9413,10 @@ var init_services = __esm({
|
|
|
9462
9413
|
},
|
|
9463
9414
|
{
|
|
9464
9415
|
name: "services requests",
|
|
9465
|
-
description: "
|
|
9416
|
+
description: "View a service request by ID",
|
|
9466
9417
|
route: { method: "GET", path: "/v1/services/requests/{pos}" },
|
|
9467
9418
|
entity: true,
|
|
9468
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9419
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9469
9420
|
display: { title: "Services Requests", cols: ["amount_cents>Amount Cents", "checkout_url>Checkout Url", "failed_at>Failed At", "fulfilled_at>Fulfilled At", "@created_at>Created At", "#entity_id>ID"] },
|
|
9470
9421
|
examples: ["corp services requests", "corp services requests --json"]
|
|
9471
9422
|
},
|
|
@@ -9473,23 +9424,23 @@ var init_services = __esm({
|
|
|
9473
9424
|
name: "services requests-cancel",
|
|
9474
9425
|
description: "Cancel a service request",
|
|
9475
9426
|
route: { method: "POST", path: "/v1/services/requests/{pos}/cancel" },
|
|
9476
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9427
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9477
9428
|
examples: ["corp services requests-cancel <request-id>"],
|
|
9478
|
-
successTemplate: "
|
|
9429
|
+
successTemplate: "Request cancelled"
|
|
9479
9430
|
},
|
|
9480
9431
|
{
|
|
9481
9432
|
name: "services requests-checkout",
|
|
9482
9433
|
description: "Start checkout for a service request",
|
|
9483
9434
|
route: { method: "POST", path: "/v1/services/requests/{pos}/checkout" },
|
|
9484
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9435
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9485
9436
|
examples: ["corp services requests-checkout <request-id>"],
|
|
9486
|
-
successTemplate: "
|
|
9437
|
+
successTemplate: "Checkout started"
|
|
9487
9438
|
},
|
|
9488
9439
|
{
|
|
9489
9440
|
name: "services requests-fulfill",
|
|
9490
9441
|
description: "Fulfill a service request",
|
|
9491
9442
|
route: { method: "POST", path: "/v1/services/requests/{pos}/fulfill" },
|
|
9492
|
-
args: [{ name: "request-id", required: true, description: "Document request ID" }],
|
|
9443
|
+
args: [{ name: "request-id", required: true, description: "Document request ID", posKind: "service_request" }],
|
|
9493
9444
|
options: [
|
|
9494
9445
|
{ flags: "--note <note>", description: "Note" }
|
|
9495
9446
|
],
|
|
@@ -9814,7 +9765,7 @@ async function serveCommand(opts) {
|
|
|
9814
9765
|
process.exit(1);
|
|
9815
9766
|
}
|
|
9816
9767
|
const port = parseInt(opts.port, 10);
|
|
9817
|
-
if (isNaN(port) || port > 65535) {
|
|
9768
|
+
if (isNaN(port) || port < 1 || port > 65535) {
|
|
9818
9769
|
console.error(`Error: Invalid port "${opts.port}"`);
|
|
9819
9770
|
process.exit(1);
|
|
9820
9771
|
}
|
|
@@ -10088,7 +10039,7 @@ async function demoCommand(opts) {
|
|
|
10088
10039
|
entity_id: entityId,
|
|
10089
10040
|
template_type: "nda",
|
|
10090
10041
|
counterparty_name: "Example Counterparty",
|
|
10091
|
-
effective_date:
|
|
10042
|
+
effective_date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10),
|
|
10092
10043
|
parameters: {}
|
|
10093
10044
|
});
|
|
10094
10045
|
await resolver.stabilizeRecord("document", contract, entityId);
|
|
@@ -10137,7 +10088,12 @@ var init_demo = __esm({
|
|
|
10137
10088
|
|
|
10138
10089
|
// src/llm.ts
|
|
10139
10090
|
async function chat(messages, tools, provider = "openrouter", apiKey = "", model = "", baseUrl) {
|
|
10140
|
-
const effectiveUrl = baseUrl ?? PROVIDER_BASE_URLS[provider]
|
|
10091
|
+
const effectiveUrl = baseUrl ?? PROVIDER_BASE_URLS[provider];
|
|
10092
|
+
if (!effectiveUrl) {
|
|
10093
|
+
throw new Error(
|
|
10094
|
+
`Unknown LLM provider "${provider}". Supported providers: ${Object.keys(PROVIDER_BASE_URLS).join(", ")}. Set llm.base_url in your config to use a custom provider.`
|
|
10095
|
+
);
|
|
10096
|
+
}
|
|
10141
10097
|
const { default: OpenAIClient } = await import("openai");
|
|
10142
10098
|
const client = new OpenAIClient({ apiKey, baseURL: effectiveUrl });
|
|
10143
10099
|
const params = {
|
|
@@ -10180,6 +10136,8 @@ var init_llm = __esm({
|
|
|
10180
10136
|
"src/llm.ts"() {
|
|
10181
10137
|
"use strict";
|
|
10182
10138
|
PROVIDER_BASE_URLS = {
|
|
10139
|
+
anthropic: "https://api.anthropic.com/v1",
|
|
10140
|
+
openai: "https://api.openai.com/v1",
|
|
10183
10141
|
openrouter: "https://openrouter.ai/api/v1"
|
|
10184
10142
|
};
|
|
10185
10143
|
}
|
|
@@ -10600,6 +10558,66 @@ var init_feedback = __esm({
|
|
|
10600
10558
|
}
|
|
10601
10559
|
});
|
|
10602
10560
|
|
|
10561
|
+
// src/resource-kinds.ts
|
|
10562
|
+
var KINDS, ENTITY_SCOPED_KINDS;
|
|
10563
|
+
var init_resource_kinds = __esm({
|
|
10564
|
+
"src/resource-kinds.ts"() {
|
|
10565
|
+
"use strict";
|
|
10566
|
+
KINDS = /* @__PURE__ */ new Set([
|
|
10567
|
+
"entity",
|
|
10568
|
+
"contact",
|
|
10569
|
+
"share_transfer",
|
|
10570
|
+
"invoice",
|
|
10571
|
+
"bank_account",
|
|
10572
|
+
"payment",
|
|
10573
|
+
"payroll_run",
|
|
10574
|
+
"distribution",
|
|
10575
|
+
"reconciliation",
|
|
10576
|
+
"tax_filing",
|
|
10577
|
+
"deadline",
|
|
10578
|
+
"classification",
|
|
10579
|
+
"body",
|
|
10580
|
+
"meeting",
|
|
10581
|
+
"seat",
|
|
10582
|
+
"agenda_item",
|
|
10583
|
+
"resolution",
|
|
10584
|
+
"document",
|
|
10585
|
+
"work_item",
|
|
10586
|
+
"agent",
|
|
10587
|
+
"valuation",
|
|
10588
|
+
"safe_note",
|
|
10589
|
+
"instrument",
|
|
10590
|
+
"share_class",
|
|
10591
|
+
"round"
|
|
10592
|
+
]);
|
|
10593
|
+
ENTITY_SCOPED_KINDS = /* @__PURE__ */ new Set([
|
|
10594
|
+
"contact",
|
|
10595
|
+
"share_transfer",
|
|
10596
|
+
"invoice",
|
|
10597
|
+
"bank_account",
|
|
10598
|
+
"payment",
|
|
10599
|
+
"payroll_run",
|
|
10600
|
+
"distribution",
|
|
10601
|
+
"reconciliation",
|
|
10602
|
+
"tax_filing",
|
|
10603
|
+
"deadline",
|
|
10604
|
+
"classification",
|
|
10605
|
+
"body",
|
|
10606
|
+
"meeting",
|
|
10607
|
+
"seat",
|
|
10608
|
+
"agenda_item",
|
|
10609
|
+
"resolution",
|
|
10610
|
+
"document",
|
|
10611
|
+
"work_item",
|
|
10612
|
+
"valuation",
|
|
10613
|
+
"safe_note",
|
|
10614
|
+
"instrument",
|
|
10615
|
+
"share_class",
|
|
10616
|
+
"round"
|
|
10617
|
+
]);
|
|
10618
|
+
}
|
|
10619
|
+
});
|
|
10620
|
+
|
|
10603
10621
|
// src/commands/resolve.ts
|
|
10604
10622
|
var resolve_exports = {};
|
|
10605
10623
|
__export(resolve_exports, {
|
|
@@ -10706,7 +10724,7 @@ async function resolveCommand(kind, ref, opts) {
|
|
|
10706
10724
|
kind: normalizedKind,
|
|
10707
10725
|
input: ref,
|
|
10708
10726
|
resolved_id: resolvedId,
|
|
10709
|
-
short_id:
|
|
10727
|
+
short_id: shortId(resolvedId),
|
|
10710
10728
|
...entityId ? { entity_id: entityId } : {},
|
|
10711
10729
|
...bodyId ? { body_id: bodyId } : {},
|
|
10712
10730
|
...meetingId ? { meeting_id: meetingId } : {}
|
|
@@ -10728,7 +10746,6 @@ function requiredMeeting(meetingId, kind) {
|
|
|
10728
10746
|
}
|
|
10729
10747
|
return meetingId;
|
|
10730
10748
|
}
|
|
10731
|
-
var KINDS, ENTITY_SCOPED_KINDS;
|
|
10732
10749
|
var init_resolve = __esm({
|
|
10733
10750
|
"src/commands/resolve.ts"() {
|
|
10734
10751
|
"use strict";
|
|
@@ -10736,58 +10753,7 @@ var init_resolve = __esm({
|
|
|
10736
10753
|
init_api_client();
|
|
10737
10754
|
init_output();
|
|
10738
10755
|
init_references();
|
|
10739
|
-
|
|
10740
|
-
"entity",
|
|
10741
|
-
"contact",
|
|
10742
|
-
"share_transfer",
|
|
10743
|
-
"invoice",
|
|
10744
|
-
"bank_account",
|
|
10745
|
-
"payment",
|
|
10746
|
-
"payroll_run",
|
|
10747
|
-
"distribution",
|
|
10748
|
-
"reconciliation",
|
|
10749
|
-
"tax_filing",
|
|
10750
|
-
"deadline",
|
|
10751
|
-
"classification",
|
|
10752
|
-
"body",
|
|
10753
|
-
"meeting",
|
|
10754
|
-
"seat",
|
|
10755
|
-
"agenda_item",
|
|
10756
|
-
"resolution",
|
|
10757
|
-
"document",
|
|
10758
|
-
"work_item",
|
|
10759
|
-
"agent",
|
|
10760
|
-
"valuation",
|
|
10761
|
-
"safe_note",
|
|
10762
|
-
"instrument",
|
|
10763
|
-
"share_class",
|
|
10764
|
-
"round"
|
|
10765
|
-
]);
|
|
10766
|
-
ENTITY_SCOPED_KINDS = /* @__PURE__ */ new Set([
|
|
10767
|
-
"contact",
|
|
10768
|
-
"share_transfer",
|
|
10769
|
-
"invoice",
|
|
10770
|
-
"bank_account",
|
|
10771
|
-
"payment",
|
|
10772
|
-
"payroll_run",
|
|
10773
|
-
"distribution",
|
|
10774
|
-
"reconciliation",
|
|
10775
|
-
"tax_filing",
|
|
10776
|
-
"deadline",
|
|
10777
|
-
"classification",
|
|
10778
|
-
"body",
|
|
10779
|
-
"meeting",
|
|
10780
|
-
"seat",
|
|
10781
|
-
"agenda_item",
|
|
10782
|
-
"resolution",
|
|
10783
|
-
"document",
|
|
10784
|
-
"work_item",
|
|
10785
|
-
"valuation",
|
|
10786
|
-
"safe_note",
|
|
10787
|
-
"instrument",
|
|
10788
|
-
"share_class",
|
|
10789
|
-
"round"
|
|
10790
|
-
]);
|
|
10756
|
+
init_resource_kinds();
|
|
10791
10757
|
}
|
|
10792
10758
|
});
|
|
10793
10759
|
|
|
@@ -10800,7 +10766,7 @@ import chalk14 from "chalk";
|
|
|
10800
10766
|
import Table5 from "cli-table3";
|
|
10801
10767
|
async function findCommand(kind, query, opts) {
|
|
10802
10768
|
const normalizedKind = kind.trim().toLowerCase();
|
|
10803
|
-
if (!
|
|
10769
|
+
if (!KINDS.has(normalizedKind)) {
|
|
10804
10770
|
printError(`Unsupported find kind: ${kind}`);
|
|
10805
10771
|
process.exit(1);
|
|
10806
10772
|
}
|
|
@@ -10808,7 +10774,7 @@ async function findCommand(kind, query, opts) {
|
|
|
10808
10774
|
const client = new CorpAPIClient(cfg.api_url, cfg.api_key, cfg.workspace_id);
|
|
10809
10775
|
const resolver = new ReferenceResolver(client, cfg);
|
|
10810
10776
|
try {
|
|
10811
|
-
const entityId =
|
|
10777
|
+
const entityId = ENTITY_SCOPED_KINDS.has(normalizedKind) || opts.entityId || opts.bodyId || opts.meetingId ? await resolver.resolveEntity(opts.entityId) : void 0;
|
|
10812
10778
|
const bodyId = entityId && opts.bodyId ? await resolver.resolveBody(entityId, opts.bodyId) : void 0;
|
|
10813
10779
|
const meetingId = entityId && opts.meetingId ? await resolver.resolveMeeting(entityId, opts.meetingId, bodyId) : void 0;
|
|
10814
10780
|
const matches = await resolver.find(normalizedKind, query, { entityId, bodyId, meetingId });
|
|
@@ -10855,7 +10821,6 @@ async function findCommand(kind, query, opts) {
|
|
|
10855
10821
|
process.exit(1);
|
|
10856
10822
|
}
|
|
10857
10823
|
}
|
|
10858
|
-
var KINDS2, ENTITY_SCOPED_KINDS2;
|
|
10859
10824
|
var init_find = __esm({
|
|
10860
10825
|
"src/commands/find.ts"() {
|
|
10861
10826
|
"use strict";
|
|
@@ -10863,58 +10828,7 @@ var init_find = __esm({
|
|
|
10863
10828
|
init_api_client();
|
|
10864
10829
|
init_output();
|
|
10865
10830
|
init_references();
|
|
10866
|
-
|
|
10867
|
-
"entity",
|
|
10868
|
-
"contact",
|
|
10869
|
-
"share_transfer",
|
|
10870
|
-
"invoice",
|
|
10871
|
-
"bank_account",
|
|
10872
|
-
"payment",
|
|
10873
|
-
"payroll_run",
|
|
10874
|
-
"distribution",
|
|
10875
|
-
"reconciliation",
|
|
10876
|
-
"tax_filing",
|
|
10877
|
-
"deadline",
|
|
10878
|
-
"classification",
|
|
10879
|
-
"body",
|
|
10880
|
-
"meeting",
|
|
10881
|
-
"seat",
|
|
10882
|
-
"agenda_item",
|
|
10883
|
-
"resolution",
|
|
10884
|
-
"document",
|
|
10885
|
-
"work_item",
|
|
10886
|
-
"agent",
|
|
10887
|
-
"valuation",
|
|
10888
|
-
"safe_note",
|
|
10889
|
-
"instrument",
|
|
10890
|
-
"share_class",
|
|
10891
|
-
"round"
|
|
10892
|
-
]);
|
|
10893
|
-
ENTITY_SCOPED_KINDS2 = /* @__PURE__ */ new Set([
|
|
10894
|
-
"contact",
|
|
10895
|
-
"share_transfer",
|
|
10896
|
-
"invoice",
|
|
10897
|
-
"bank_account",
|
|
10898
|
-
"payment",
|
|
10899
|
-
"payroll_run",
|
|
10900
|
-
"distribution",
|
|
10901
|
-
"reconciliation",
|
|
10902
|
-
"tax_filing",
|
|
10903
|
-
"deadline",
|
|
10904
|
-
"classification",
|
|
10905
|
-
"body",
|
|
10906
|
-
"meeting",
|
|
10907
|
-
"seat",
|
|
10908
|
-
"agenda_item",
|
|
10909
|
-
"resolution",
|
|
10910
|
-
"document",
|
|
10911
|
-
"work_item",
|
|
10912
|
-
"valuation",
|
|
10913
|
-
"safe_note",
|
|
10914
|
-
"instrument",
|
|
10915
|
-
"share_class",
|
|
10916
|
-
"round"
|
|
10917
|
-
]);
|
|
10831
|
+
init_resource_kinds();
|
|
10918
10832
|
}
|
|
10919
10833
|
});
|
|
10920
10834
|
|
|
@@ -11258,7 +11172,7 @@ var init_admin = __esm({
|
|
|
11258
11172
|
process.stderr.write(
|
|
11259
11173
|
'Approvals are managed through governance meetings and execution intents.\nUse these commands to manage approvals:\n\n Board approval via meeting vote:\n corp governance convene --body <body> --type board_meeting --title "Approve X"\n corp governance vote <meeting> <item> --voter <contact> --vote for\n\n Written consent (no meeting needed):\n corp governance written-consent --body <body> --title "Approve X" --description "..."\n\n View pending items:\n corp governance meetings <body> # see scheduled meetings\n corp governance agenda-items <meeting> # see items awaiting votes\n corp cap-table valuations # see pending valuations\n'
|
|
11260
11174
|
);
|
|
11261
|
-
process.exit(
|
|
11175
|
+
process.exit(0);
|
|
11262
11176
|
},
|
|
11263
11177
|
examples: ["corp approvals"]
|
|
11264
11178
|
},
|
|
@@ -11386,7 +11300,7 @@ var init_admin = __esm({
|
|
|
11386
11300
|
{ flags: "--ttl-seconds <ttl-seconds>", description: "Token TTL in seconds (60-86400)", type: "int" }
|
|
11387
11301
|
],
|
|
11388
11302
|
examples: ["corp auth token-exchange --api-key 'api-key'", "corp auth token-exchange --json"],
|
|
11389
|
-
successTemplate: "Token
|
|
11303
|
+
successTemplate: "Token exchanged"
|
|
11390
11304
|
},
|
|
11391
11305
|
{
|
|
11392
11306
|
name: "ssh-keys",
|
|
@@ -11438,7 +11352,7 @@ var init_admin = __esm({
|
|
|
11438
11352
|
{ flags: "--kind <kind>", description: "Resource kind", required: true, choices: ["entity", "contact", "share_transfer", "invoice", "bank_account", "payment", "payroll_run", "distribution", "reconciliation", "tax_filing", "deadline", "classification", "body", "meeting", "seat", "agenda_item", "resolution", "document", "work_item", "agent", "valuation", "safe_note", "instrument", "share_class", "round"] }
|
|
11439
11353
|
],
|
|
11440
11354
|
examples: ["corp references sync --items 'items' --kind 'kind'"],
|
|
11441
|
-
successTemplate: "
|
|
11355
|
+
successTemplate: "References synced"
|
|
11442
11356
|
},
|
|
11443
11357
|
// ── Auto-generated from OpenAPI ──────────────────────────────
|
|
11444
11358
|
{
|
|
@@ -11610,7 +11524,7 @@ var init_execution = __esm({
|
|
|
11610
11524
|
entity: true,
|
|
11611
11525
|
args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
|
|
11612
11526
|
examples: ["corp intents authorize <intent-id>"],
|
|
11613
|
-
successTemplate: "
|
|
11527
|
+
successTemplate: "Intent authorized"
|
|
11614
11528
|
},
|
|
11615
11529
|
{
|
|
11616
11530
|
name: "intents bind-approval-artifact",
|
|
@@ -11641,7 +11555,7 @@ var init_execution = __esm({
|
|
|
11641
11555
|
entity: true,
|
|
11642
11556
|
args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
|
|
11643
11557
|
examples: ["corp intents cancel <intent-id>"],
|
|
11644
|
-
successTemplate: "
|
|
11558
|
+
successTemplate: "Intent cancelled"
|
|
11645
11559
|
},
|
|
11646
11560
|
{
|
|
11647
11561
|
name: "intents evaluate",
|
|
@@ -11650,7 +11564,7 @@ var init_execution = __esm({
|
|
|
11650
11564
|
entity: true,
|
|
11651
11565
|
args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
|
|
11652
11566
|
examples: ["corp intents evaluate <intent-id>"],
|
|
11653
|
-
successTemplate: "
|
|
11567
|
+
successTemplate: "Intent evaluated"
|
|
11654
11568
|
},
|
|
11655
11569
|
{
|
|
11656
11570
|
name: "intents execute",
|
|
@@ -11659,7 +11573,7 @@ var init_execution = __esm({
|
|
|
11659
11573
|
entity: true,
|
|
11660
11574
|
args: [{ name: "intent-id", required: true, description: "Execution intent ID" }],
|
|
11661
11575
|
examples: ["corp intents execute <intent-id>"],
|
|
11662
|
-
successTemplate: "
|
|
11576
|
+
successTemplate: "Intent executed"
|
|
11663
11577
|
},
|
|
11664
11578
|
{
|
|
11665
11579
|
name: "intents receipts",
|
|
@@ -11684,7 +11598,7 @@ var init_execution = __esm({
|
|
|
11684
11598
|
},
|
|
11685
11599
|
{
|
|
11686
11600
|
name: "obligations document-requests",
|
|
11687
|
-
description: "List
|
|
11601
|
+
description: "List document requests for an obligation",
|
|
11688
11602
|
route: { method: "GET", path: "/v1/obligations/{pos}/document-requests" },
|
|
11689
11603
|
entity: true,
|
|
11690
11604
|
args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
|
|
@@ -11693,7 +11607,7 @@ var init_execution = __esm({
|
|
|
11693
11607
|
},
|
|
11694
11608
|
{
|
|
11695
11609
|
name: "obligations create-document-request",
|
|
11696
|
-
description: "
|
|
11610
|
+
description: "Create a document request for an obligation",
|
|
11697
11611
|
route: { method: "POST", path: "/v1/obligations/{pos}/document-requests" },
|
|
11698
11612
|
entity: true,
|
|
11699
11613
|
args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
|
|
@@ -11711,7 +11625,7 @@ var init_execution = __esm({
|
|
|
11711
11625
|
entity: true,
|
|
11712
11626
|
args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
|
|
11713
11627
|
examples: ["corp obligations expire <obligation-id>"],
|
|
11714
|
-
successTemplate: "
|
|
11628
|
+
successTemplate: "Obligation expired"
|
|
11715
11629
|
},
|
|
11716
11630
|
{
|
|
11717
11631
|
name: "obligations fulfill",
|
|
@@ -11720,7 +11634,7 @@ var init_execution = __esm({
|
|
|
11720
11634
|
entity: true,
|
|
11721
11635
|
args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
|
|
11722
11636
|
examples: ["corp obligations fulfill <obligation-id>"],
|
|
11723
|
-
successTemplate: "
|
|
11637
|
+
successTemplate: "Obligation fulfilled"
|
|
11724
11638
|
},
|
|
11725
11639
|
{
|
|
11726
11640
|
name: "obligations waive",
|
|
@@ -11729,7 +11643,7 @@ var init_execution = __esm({
|
|
|
11729
11643
|
entity: true,
|
|
11730
11644
|
args: [{ name: "obligation-id", required: true, description: "Obligation ID" }],
|
|
11731
11645
|
examples: ["corp obligations waive <obligation-id>"],
|
|
11732
|
-
successTemplate: "
|
|
11646
|
+
successTemplate: "Obligation waived"
|
|
11733
11647
|
},
|
|
11734
11648
|
{
|
|
11735
11649
|
name: "receipts",
|
|
@@ -11847,9 +11761,9 @@ var init_treasury = __esm({
|
|
|
11847
11761
|
description: "Close a bank account",
|
|
11848
11762
|
route: { method: "POST", path: "/v1/bank-accounts/{pos}/close" },
|
|
11849
11763
|
entity: true,
|
|
11850
|
-
args: [{ name: "bank-account-id", required: true, description: "Bank account ID" }],
|
|
11764
|
+
args: [{ name: "bank-account-id", required: true, description: "Bank account ID", posKind: "bank_account" }],
|
|
11851
11765
|
examples: ["corp bank-accounts close <bank-account-id>"],
|
|
11852
|
-
successTemplate: "
|
|
11766
|
+
successTemplate: "Account closed"
|
|
11853
11767
|
},
|
|
11854
11768
|
{
|
|
11855
11769
|
name: "distributions",
|
|
@@ -11911,10 +11825,10 @@ var init_treasury = __esm({
|
|
|
11911
11825
|
},
|
|
11912
11826
|
{
|
|
11913
11827
|
name: "invoices",
|
|
11914
|
-
description: "
|
|
11828
|
+
description: "View an invoice by ID",
|
|
11915
11829
|
route: { method: "GET", path: "/v1/invoices/{pos}" },
|
|
11916
11830
|
entity: true,
|
|
11917
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11831
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11918
11832
|
display: { title: "Invoices", cols: ["amount_cents>Amount Cents", "customer_name>Customer Name", "description>Description", "status>Status", "@created_at>Created At", "#entity_id>ID"] },
|
|
11919
11833
|
examples: ["corp invoices", "corp invoices --json"]
|
|
11920
11834
|
},
|
|
@@ -11923,16 +11837,16 @@ var init_treasury = __esm({
|
|
|
11923
11837
|
description: "Mark an invoice as paid",
|
|
11924
11838
|
route: { method: "POST", path: "/v1/invoices/{pos}/mark-paid" },
|
|
11925
11839
|
entity: true,
|
|
11926
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11840
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11927
11841
|
examples: ["corp invoices mark-paid <invoice-id>"],
|
|
11928
|
-
successTemplate: "
|
|
11842
|
+
successTemplate: "Invoice marked as paid"
|
|
11929
11843
|
},
|
|
11930
11844
|
{
|
|
11931
11845
|
name: "invoices pay-instructions",
|
|
11932
11846
|
description: "Get payment instructions for an invoice",
|
|
11933
11847
|
route: { method: "GET", path: "/v1/invoices/{pos}/pay-instructions" },
|
|
11934
11848
|
entity: true,
|
|
11935
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11849
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11936
11850
|
display: { title: "Invoices Pay Instructions", cols: ["amount_cents>Amount Cents", "currency>Currency", "instructions>Instructions", "#invoice_id>ID", "payment_method>Payment Method"] },
|
|
11937
11851
|
examples: ["corp invoices pay-instructions", "corp invoices pay-instructions --json"]
|
|
11938
11852
|
},
|
|
@@ -11941,16 +11855,16 @@ var init_treasury = __esm({
|
|
|
11941
11855
|
description: "Send an invoice to the recipient",
|
|
11942
11856
|
route: { method: "POST", path: "/v1/invoices/{pos}/send" },
|
|
11943
11857
|
entity: true,
|
|
11944
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11858
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11945
11859
|
examples: ["corp invoices send <invoice-id>"],
|
|
11946
|
-
successTemplate: "
|
|
11860
|
+
successTemplate: "Invoice sent"
|
|
11947
11861
|
},
|
|
11948
11862
|
{
|
|
11949
11863
|
name: "invoices status",
|
|
11950
11864
|
description: "Check invoice payment status",
|
|
11951
11865
|
route: { method: "GET", path: "/v1/invoices/{pos}/status" },
|
|
11952
11866
|
entity: true,
|
|
11953
|
-
args: [{ name: "invoice-id", required: true, description: "Invoice ID" }],
|
|
11867
|
+
args: [{ name: "invoice-id", required: true, description: "Invoice ID", posKind: "invoice" }],
|
|
11954
11868
|
display: { title: "Invoices Status", cols: ["amount_cents>Amount Cents", "customer_name>Customer Name", "description>Description", "status>Status", "@created_at>Created At", "#entity_id>ID"] },
|
|
11955
11869
|
examples: ["corp invoices status", "corp invoices status --json"]
|
|
11956
11870
|
},
|
|
@@ -11961,7 +11875,7 @@ var init_treasury = __esm({
|
|
|
11961
11875
|
entity: true,
|
|
11962
11876
|
args: [{ name: "entry-id", required: true, description: "Journal entry ID" }],
|
|
11963
11877
|
examples: ["corp journal-entries post <entry-id>"],
|
|
11964
|
-
successTemplate: "
|
|
11878
|
+
successTemplate: "Journal entry posted"
|
|
11965
11879
|
},
|
|
11966
11880
|
{
|
|
11967
11881
|
name: "journal-entries void",
|
|
@@ -11970,7 +11884,7 @@ var init_treasury = __esm({
|
|
|
11970
11884
|
entity: true,
|
|
11971
11885
|
args: [{ name: "entry-id", required: true, description: "Journal entry ID" }],
|
|
11972
11886
|
examples: ["corp journal-entries void <entry-id>"],
|
|
11973
|
-
successTemplate: "
|
|
11887
|
+
successTemplate: "Journal entry voided"
|
|
11974
11888
|
},
|
|
11975
11889
|
{
|
|
11976
11890
|
name: "ledger reconcile",
|
|
@@ -12011,7 +11925,7 @@ var init_treasury = __esm({
|
|
|
12011
11925
|
{ flags: "--recipient <recipient>", description: "Recipient", required: true }
|
|
12012
11926
|
],
|
|
12013
11927
|
examples: ["corp payments execute --amount-cents 'amount-cents' --description bank_transfer --recipient 'recipient'", "corp payments execute --json"],
|
|
12014
|
-
successTemplate: "
|
|
11928
|
+
successTemplate: "Payment executed"
|
|
12015
11929
|
},
|
|
12016
11930
|
{
|
|
12017
11931
|
name: "payroll runs",
|
|
@@ -12023,7 +11937,7 @@ var init_treasury = __esm({
|
|
|
12023
11937
|
{ flags: "--pay-period-start <pay-period-start>", description: "Pay Period Start", required: true }
|
|
12024
11938
|
],
|
|
12025
11939
|
examples: ["corp payroll runs --pay-period-end 'pay-period-end' --pay-period-start 'pay-period-start'"],
|
|
12026
|
-
successTemplate: "
|
|
11940
|
+
successTemplate: "Payroll run created"
|
|
12027
11941
|
},
|
|
12028
11942
|
{
|
|
12029
11943
|
name: "spending-limits",
|
|
@@ -12128,7 +12042,7 @@ var init_treasury = __esm({
|
|
|
12128
12042
|
route: { method: "POST", path: "/v1/treasury/seed-chart-of-accounts" },
|
|
12129
12043
|
entity: true,
|
|
12130
12044
|
options: [
|
|
12131
|
-
{ flags: "--template <template>", description: "
|
|
12045
|
+
{ flags: "--template <template>", description: "Chart of accounts template name to seed from" }
|
|
12132
12046
|
],
|
|
12133
12047
|
examples: ["corp treasury seed-chart-of-accounts", "corp treasury seed-chart-of-accounts --json"],
|
|
12134
12048
|
successTemplate: "Seed Chart Of Accounts created"
|
|
@@ -12388,28 +12302,9 @@ import { createRequire } from "module";
|
|
|
12388
12302
|
import { Command, Option } from "commander";
|
|
12389
12303
|
|
|
12390
12304
|
// src/generic-executor.ts
|
|
12305
|
+
init_references();
|
|
12306
|
+
init_output();
|
|
12391
12307
|
init_spinner();
|
|
12392
|
-
function s(val, maxLen) {
|
|
12393
|
-
const str = val == null ? "" : String(val);
|
|
12394
|
-
if (maxLen && str.length > maxLen) return str.slice(0, maxLen);
|
|
12395
|
-
return str;
|
|
12396
|
-
}
|
|
12397
|
-
function money(val) {
|
|
12398
|
-
if (typeof val === "number") {
|
|
12399
|
-
const dollars = val / 100;
|
|
12400
|
-
return `$${dollars.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
12401
|
-
}
|
|
12402
|
-
return s(val);
|
|
12403
|
-
}
|
|
12404
|
-
function fmtDate(val) {
|
|
12405
|
-
const str = s(val);
|
|
12406
|
-
if (!str) return "";
|
|
12407
|
-
const parsed = new Date(str);
|
|
12408
|
-
return Number.isNaN(parsed.getTime()) ? str : parsed.toISOString().slice(0, 10);
|
|
12409
|
-
}
|
|
12410
|
-
function shortId(val) {
|
|
12411
|
-
return val.length > 8 ? val.slice(0, 8) + "\u2026" : val;
|
|
12412
|
-
}
|
|
12413
12308
|
function parseCol(spec) {
|
|
12414
12309
|
let fmt = null;
|
|
12415
12310
|
let rest = spec;
|
|
@@ -12435,7 +12330,7 @@ function getField(obj, keys) {
|
|
|
12435
12330
|
function fmtField(val, fmt) {
|
|
12436
12331
|
if (val == null) return "";
|
|
12437
12332
|
if (fmt === "money") return money(val);
|
|
12438
|
-
if (fmt === "date") return
|
|
12333
|
+
if (fmt === "date") return date(val);
|
|
12439
12334
|
if (fmt === "id") return shortId(String(val));
|
|
12440
12335
|
return String(val);
|
|
12441
12336
|
}
|
|
@@ -12490,13 +12385,29 @@ function displayPanel(data, title, ctx) {
|
|
|
12490
12385
|
const label = k.replace(/_/g, " ").replace(/\b\w/g, (ch) => ch.toUpperCase());
|
|
12491
12386
|
let formatted;
|
|
12492
12387
|
if (k.endsWith("_cents") && typeof v === "number") formatted = money(v);
|
|
12493
|
-
else if ((k.includes("date") || k.endsWith("_at")) && v) formatted =
|
|
12388
|
+
else if ((k.includes("date") || k.endsWith("_at")) && v) formatted = date(v);
|
|
12494
12389
|
else if (k.endsWith("_id")) formatted = shortId(String(v));
|
|
12495
12390
|
else formatted = String(v);
|
|
12496
12391
|
return `${label}: ${formatted}`;
|
|
12497
12392
|
});
|
|
12498
12393
|
ctx.writer.panel(title, "blue", lines);
|
|
12499
12394
|
}
|
|
12395
|
+
function getPosKind(def, posIndex) {
|
|
12396
|
+
if (!def.args) return void 0;
|
|
12397
|
+
let argIdx = 0;
|
|
12398
|
+
for (const arg of def.args) {
|
|
12399
|
+
if (argIdx === posIndex) {
|
|
12400
|
+
return arg.posKind;
|
|
12401
|
+
}
|
|
12402
|
+
argIdx++;
|
|
12403
|
+
}
|
|
12404
|
+
return void 0;
|
|
12405
|
+
}
|
|
12406
|
+
async function resolvePositional(def, posIndex, rawValue, ctx) {
|
|
12407
|
+
const kind = getPosKind(def, posIndex);
|
|
12408
|
+
if (!kind) return rawValue;
|
|
12409
|
+
return ctx.resolver.resolveByKind(kind, rawValue, ctx.entityId);
|
|
12410
|
+
}
|
|
12500
12411
|
async function executeGenericRead(def, ctx) {
|
|
12501
12412
|
if (!def.route?.path) {
|
|
12502
12413
|
ctx.writer.error("No route defined for this command");
|
|
@@ -12528,7 +12439,9 @@ async function executeGenericRead(def, ctx) {
|
|
|
12528
12439
|
ctx.writer.error("Missing required argument (ID or reference).");
|
|
12529
12440
|
return;
|
|
12530
12441
|
}
|
|
12531
|
-
|
|
12442
|
+
const resolved = await resolvePositional(def, posIdx, ctx.positional[posIdx], ctx);
|
|
12443
|
+
posIdx++;
|
|
12444
|
+
path = path.replace("{pos}", encodeURIComponent(resolved));
|
|
12532
12445
|
}
|
|
12533
12446
|
path = path.replace("{wid}", encodeURIComponent(ctx.client.workspaceId));
|
|
12534
12447
|
path = path.replace("{workspace_id}", encodeURIComponent(ctx.client.workspaceId));
|
|
@@ -12598,14 +12511,18 @@ async function executeGenericWrite(def, ctx) {
|
|
|
12598
12511
|
ctx.writer.error("Missing required argument (ID or reference).");
|
|
12599
12512
|
return;
|
|
12600
12513
|
}
|
|
12601
|
-
|
|
12514
|
+
const resolved = await resolvePositional(def, posIdx, ctx.positional[posIdx], ctx);
|
|
12515
|
+
posIdx++;
|
|
12516
|
+
path = path.replace("{pos}", encodeURIComponent(resolved));
|
|
12602
12517
|
}
|
|
12603
12518
|
if (path.includes("{pos2}")) {
|
|
12604
12519
|
if (!ctx.positional[posIdx]) {
|
|
12605
12520
|
ctx.writer.error("Missing required second argument (ID or reference).");
|
|
12606
12521
|
return;
|
|
12607
12522
|
}
|
|
12608
|
-
|
|
12523
|
+
const resolved = await resolvePositional(def, posIdx, ctx.positional[posIdx], ctx);
|
|
12524
|
+
posIdx++;
|
|
12525
|
+
path = path.replace("{pos2}", encodeURIComponent(resolved));
|
|
12609
12526
|
}
|
|
12610
12527
|
path = path.replace("{wid}", encodeURIComponent(ctx.client.workspaceId));
|
|
12611
12528
|
path = path.replace("{workspace_id}", encodeURIComponent(ctx.client.workspaceId));
|