@fairmint/captable-ai 0.1.17 → 0.1.18
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 +107 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15827,8 +15827,17 @@ var ocfObjectSchema = external_exports.object({
|
|
|
15827
15827
|
createdAt: external_exports.string().nullable().optional().describe("ISO timestamp of when the row was first inserted (DB `created_at`). Used by studiov2 as a last-resort date fallback for undated OCF objects (e.g. STAKEHOLDER, STOCK_CLASS). Present on list responses only.")
|
|
15828
15828
|
});
|
|
15829
15829
|
var objectPatchInputSchema = external_exports.object({
|
|
15830
|
-
ocfPatch: external_exports.record(external_exports.string(), external_exports.unknown()).describe("Partial OCF object payload. The server shallow-merges this object onto the latest stored OCF object and validates the merged result."),
|
|
15831
|
-
version: external_exports.number().int().nonnegative().optional().describe("Optional optimistic-concurrency version. If provided, it must match the latest version.")
|
|
15830
|
+
ocfPatch: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe("Partial OCF object payload. The server shallow-merges this object onto the latest stored OCF object and validates the merged result. May be omitted when only documentId changes."),
|
|
15831
|
+
version: external_exports.number().int().nonnegative().optional().describe("Optional optimistic-concurrency version. If provided, it must match the latest version."),
|
|
15832
|
+
documentId: external_exports.string().uuid().nullable().optional().describe("Optional source document for the draft. Pass a UUID to relink, null to unlink, or omit to preserve the current link.")
|
|
15833
|
+
}).refine((input) => input.ocfPatch !== void 0 || input.documentId !== void 0, {
|
|
15834
|
+
path: ["ocfPatch"],
|
|
15835
|
+
message: "Provide ocfPatch or documentId \u2014 nothing to apply."
|
|
15836
|
+
});
|
|
15837
|
+
var objectUpdateInputSchema = external_exports.object({
|
|
15838
|
+
ocf: external_exports.record(external_exports.string(), external_exports.unknown()).describe("Full OCF data payload."),
|
|
15839
|
+
version: external_exports.number().int().describe("Expected current version for optimistic concurrency. Must match the latest stored version."),
|
|
15840
|
+
documentId: external_exports.string().uuid().nullable().optional().describe("Optional source document for the new draft. Pass a UUID to relink, null to unlink, or omit to preserve the current link.")
|
|
15832
15841
|
});
|
|
15833
15842
|
var objectCreateInputSchema = external_exports.object({
|
|
15834
15843
|
objectId: external_exports.string().optional().describe("Optional OCF object ID. Defaults to ocf.id or ocf._id when omitted."),
|
|
@@ -16046,6 +16055,7 @@ var ERROR_CODES = {
|
|
|
16046
16055
|
MISSING_DEPENDENCIES: "MISSING_DEPENDENCIES",
|
|
16047
16056
|
BROKEN_REFERENCES: "BROKEN_REFERENCES",
|
|
16048
16057
|
DOCUMENT_INTEGRITY_FAILED: "DOCUMENT_INTEGRITY_FAILED",
|
|
16058
|
+
DOCUMENT_NOT_LINKED: "DOCUMENT_NOT_LINKED",
|
|
16049
16059
|
INVALID_CURSOR: "INVALID_CURSOR",
|
|
16050
16060
|
BATCH_TOO_LARGE: "BATCH_TOO_LARGE",
|
|
16051
16061
|
RATE_LIMITED: "RATE_LIMITED"
|
|
@@ -16068,6 +16078,7 @@ var ERROR_CODE_VALUES = [
|
|
|
16068
16078
|
ERROR_CODES.MISSING_DEPENDENCIES,
|
|
16069
16079
|
ERROR_CODES.BROKEN_REFERENCES,
|
|
16070
16080
|
ERROR_CODES.DOCUMENT_INTEGRITY_FAILED,
|
|
16081
|
+
ERROR_CODES.DOCUMENT_NOT_LINKED,
|
|
16071
16082
|
ERROR_CODES.INVALID_CURSOR,
|
|
16072
16083
|
ERROR_CODES.BATCH_TOO_LARGE,
|
|
16073
16084
|
ERROR_CODES.RATE_LIMITED
|
|
@@ -17542,6 +17553,9 @@ Input:
|
|
|
17542
17553
|
|
|
17543
17554
|
Options:
|
|
17544
17555
|
--version N Expected current version (auto-fetched if omitted)
|
|
17556
|
+
--document UUID Link the draft to this document (must be a portal cap-table document)
|
|
17557
|
+
--clear-document Unlink the source document (documentId: null); requires
|
|
17558
|
+
--stdin/--file because update always needs the full payload
|
|
17545
17559
|
|
|
17546
17560
|
Global:
|
|
17547
17561
|
--json Machine-readable JSON output
|
|
@@ -17550,12 +17564,19 @@ Examples:
|
|
|
17550
17564
|
# Read from a file:
|
|
17551
17565
|
captable-ai objects update abc-123 --file ./stakeholder.json
|
|
17552
17566
|
|
|
17567
|
+
# Relink the source document:
|
|
17568
|
+
captable-ai objects update abc-123 --file ./stakeholder.json --document 8c25f303-1f15-4b02-b9b2-0c41442643ee
|
|
17569
|
+
|
|
17570
|
+
# Remove a wrong or missing document link:
|
|
17571
|
+
captable-ai objects update abc-123 --file ./stakeholder.json --clear-document
|
|
17572
|
+
|
|
17553
17573
|
# Pipe from jq (extract the bare OCF payload first):
|
|
17554
17574
|
captable-ai objects get abc-123 --json | jq '.data.ocf | .legal_name = "Acme Corp"' | captable-ai objects update abc-123 --stdin`;
|
|
17555
17575
|
var HELP_OBJECTS_PATCH = `objects patch \u2014 Patch an OCF object
|
|
17556
17576
|
|
|
17557
17577
|
Usage:
|
|
17558
17578
|
captable-ai objects patch <object-id> (--stdin | --file <path>) [--version N] [--json]
|
|
17579
|
+
captable-ai objects patch <object-id> --document <uuid> | --clear-document [--version N] [--json]
|
|
17559
17580
|
|
|
17560
17581
|
Shallow-merges a partial OCF payload onto the latest stored object, validates the
|
|
17561
17582
|
merged object, and writes a draft. This is not RFC 6902 JSON Patch.
|
|
@@ -17566,12 +17587,21 @@ Input:
|
|
|
17566
17587
|
|
|
17567
17588
|
Options:
|
|
17568
17589
|
--version N Optional expected current version
|
|
17590
|
+
--document UUID Link the draft to this document (must be a portal cap-table document)
|
|
17591
|
+
--clear-document Unlink the source document (documentId: null); may be used
|
|
17592
|
+
without --stdin/--file for a document-only change
|
|
17569
17593
|
|
|
17570
17594
|
Global:
|
|
17571
17595
|
--json Machine-readable JSON output
|
|
17572
17596
|
|
|
17573
17597
|
Examples:
|
|
17574
|
-
echo '{"name":{"legal_name":"Acme Corp"}}' | captable-ai objects patch stakeholder-1 --stdin
|
|
17598
|
+
echo '{"name":{"legal_name":"Acme Corp"}}' | captable-ai objects patch stakeholder-1 --stdin
|
|
17599
|
+
|
|
17600
|
+
# Relink the source document (no payload needed):
|
|
17601
|
+
captable-ai objects patch tx-1 --document c0dcf3e3-5de0-46d1-aacf-d86e9e52f459
|
|
17602
|
+
|
|
17603
|
+
# Relink with an accompanying field edit:
|
|
17604
|
+
echo '{"comments":["fixed"]}' | captable-ai objects patch tx-1 --stdin --document c0dcf3e3-5de0-46d1-aacf-d86e9e52f459`;
|
|
17575
17605
|
var HELP_OBJECTS_REVERT = `objects revert \u2014 Preview or revert draft objects
|
|
17576
17606
|
|
|
17577
17607
|
Usage:
|
|
@@ -20398,6 +20428,14 @@ More results available. Next page:
|
|
|
20398
20428
|
|
|
20399
20429
|
// src/commands/objects-patch.ts
|
|
20400
20430
|
import { readFileSync } from "fs";
|
|
20431
|
+
|
|
20432
|
+
// src/uuid.ts
|
|
20433
|
+
var UUID_PATTERN = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/;
|
|
20434
|
+
function isUuid(value) {
|
|
20435
|
+
return UUID_PATTERN.test(value);
|
|
20436
|
+
}
|
|
20437
|
+
|
|
20438
|
+
// src/commands/objects-patch.ts
|
|
20401
20439
|
async function readStdin() {
|
|
20402
20440
|
const chunks = [];
|
|
20403
20441
|
for await (const chunk of process.stdin) {
|
|
@@ -20436,7 +20474,10 @@ async function runObjectsPatch(args, rawArgv) {
|
|
|
20436
20474
|
`);
|
|
20437
20475
|
process.exit(0);
|
|
20438
20476
|
}
|
|
20439
|
-
validateFlags(args, {
|
|
20477
|
+
validateFlags(args, {
|
|
20478
|
+
flags: ["file", "version", "document"],
|
|
20479
|
+
booleans: ["stdin", "clear-document"]
|
|
20480
|
+
});
|
|
20440
20481
|
const objectId = args.positional[0];
|
|
20441
20482
|
if (!objectId) {
|
|
20442
20483
|
exitWithUsage(
|
|
@@ -20452,7 +20493,18 @@ async function runObjectsPatch(args, rawArgv) {
|
|
|
20452
20493
|
}
|
|
20453
20494
|
const useStdin = hasFlag(args, "stdin");
|
|
20454
20495
|
const filePath = getFlagValue(args, "file") ?? "";
|
|
20455
|
-
|
|
20496
|
+
const documentFlag = getFlagValue(args, "document");
|
|
20497
|
+
const clearDocument = hasFlag(args, "clear-document");
|
|
20498
|
+
const hasDocumentFlag = documentFlag !== void 0 || clearDocument;
|
|
20499
|
+
if (documentFlag !== void 0 && clearDocument) {
|
|
20500
|
+
exitWithError(
|
|
20501
|
+
"Specify either --document <uuid> or --clear-document, not both.",
|
|
20502
|
+
"VALIDATION_FAILED",
|
|
20503
|
+
void 0,
|
|
20504
|
+
EXIT.VALIDATION
|
|
20505
|
+
);
|
|
20506
|
+
}
|
|
20507
|
+
if (!useStdin && !filePath && !hasDocumentFlag) {
|
|
20456
20508
|
exitWithUsage(
|
|
20457
20509
|
"Specify how to supply the OCF patch payload: --stdin (piped JSON) or --file <path>.",
|
|
20458
20510
|
"Usage: captable-ai objects patch <object-id> (--stdin | --file <path>) [--version N] [--json]"
|
|
@@ -20464,7 +20516,7 @@ async function runObjectsPatch(args, rawArgv) {
|
|
|
20464
20516
|
"Usage: captable-ai objects patch <object-id> (--stdin | --file <path>) [--version N] [--json]"
|
|
20465
20517
|
);
|
|
20466
20518
|
}
|
|
20467
|
-
let rawPatch;
|
|
20519
|
+
let rawPatch = "{}";
|
|
20468
20520
|
if (useStdin) {
|
|
20469
20521
|
if (process.stdin.isTTY) {
|
|
20470
20522
|
exitWithError(
|
|
@@ -20475,7 +20527,7 @@ async function runObjectsPatch(args, rawArgv) {
|
|
|
20475
20527
|
);
|
|
20476
20528
|
}
|
|
20477
20529
|
rawPatch = await readStdin();
|
|
20478
|
-
} else {
|
|
20530
|
+
} else if (filePath) {
|
|
20479
20531
|
try {
|
|
20480
20532
|
rawPatch = readFileSync(filePath, "utf-8");
|
|
20481
20533
|
} catch (err) {
|
|
@@ -20505,9 +20557,27 @@ async function runObjectsPatch(args, rawArgv) {
|
|
|
20505
20557
|
}
|
|
20506
20558
|
version2 = Number.parseInt(versionRaw, 10);
|
|
20507
20559
|
}
|
|
20560
|
+
let documentId;
|
|
20561
|
+
if (documentFlag !== void 0) {
|
|
20562
|
+
if (!isUuid(documentFlag.trim())) {
|
|
20563
|
+
exitWithError(
|
|
20564
|
+
"--document must be a document UUID",
|
|
20565
|
+
"VALIDATION_FAILED",
|
|
20566
|
+
void 0,
|
|
20567
|
+
EXIT.VALIDATION
|
|
20568
|
+
);
|
|
20569
|
+
}
|
|
20570
|
+
documentId = documentFlag.trim();
|
|
20571
|
+
} else if (clearDocument) {
|
|
20572
|
+
documentId = null;
|
|
20573
|
+
}
|
|
20508
20574
|
const res = await apiRequest(`/${portalId}/objects/${encodeURIComponent(objectId)}`, {
|
|
20509
20575
|
method: "PATCH",
|
|
20510
|
-
body: {
|
|
20576
|
+
body: {
|
|
20577
|
+
ocfPatch,
|
|
20578
|
+
version: version2,
|
|
20579
|
+
...documentId !== void 0 ? { documentId } : {}
|
|
20580
|
+
}
|
|
20511
20581
|
});
|
|
20512
20582
|
const obj = res.data;
|
|
20513
20583
|
if (!obj) {
|
|
@@ -20805,7 +20875,10 @@ async function runObjectsUpdate(args, rawArgv) {
|
|
|
20805
20875
|
`);
|
|
20806
20876
|
process.exit(0);
|
|
20807
20877
|
}
|
|
20808
|
-
validateFlags(args, {
|
|
20878
|
+
validateFlags(args, {
|
|
20879
|
+
flags: ["file", "version", "document"],
|
|
20880
|
+
booleans: ["stdin", "clear-document"]
|
|
20881
|
+
});
|
|
20809
20882
|
const objectId = args.positional[0];
|
|
20810
20883
|
if (!objectId) {
|
|
20811
20884
|
exitWithUsage(
|
|
@@ -20868,6 +20941,30 @@ async function runObjectsUpdate(args, rawArgv) {
|
|
|
20868
20941
|
}
|
|
20869
20942
|
}
|
|
20870
20943
|
const ocf = parseOcfPayload(rawOcf);
|
|
20944
|
+
const documentFlag = getFlagValue(args, "document");
|
|
20945
|
+
const clearDocument = hasFlag(args, "clear-document");
|
|
20946
|
+
if (documentFlag !== void 0 && clearDocument) {
|
|
20947
|
+
exitWithError(
|
|
20948
|
+
"Specify either --document <uuid> or --clear-document, not both.",
|
|
20949
|
+
"VALIDATION_FAILED",
|
|
20950
|
+
void 0,
|
|
20951
|
+
EXIT.VALIDATION
|
|
20952
|
+
);
|
|
20953
|
+
}
|
|
20954
|
+
let documentId;
|
|
20955
|
+
if (documentFlag !== void 0) {
|
|
20956
|
+
if (!isUuid(documentFlag.trim())) {
|
|
20957
|
+
exitWithError(
|
|
20958
|
+
"--document must be a document UUID",
|
|
20959
|
+
"VALIDATION_FAILED",
|
|
20960
|
+
void 0,
|
|
20961
|
+
EXIT.VALIDATION
|
|
20962
|
+
);
|
|
20963
|
+
}
|
|
20964
|
+
documentId = documentFlag.trim();
|
|
20965
|
+
} else if (clearDocument) {
|
|
20966
|
+
documentId = null;
|
|
20967
|
+
}
|
|
20871
20968
|
const versionRaw = getFlagValue(args, "version");
|
|
20872
20969
|
const portalId = await getActivePortalId();
|
|
20873
20970
|
let version2;
|
|
@@ -20892,7 +20989,7 @@ async function runObjectsUpdate(args, rawArgv) {
|
|
|
20892
20989
|
}
|
|
20893
20990
|
const res = await apiRequest(`/${portalId}/objects/${encodeURIComponent(objectId)}`, {
|
|
20894
20991
|
method: "POST",
|
|
20895
|
-
body: { ocf, version: version2 }
|
|
20992
|
+
body: { ocf, version: version2, ...documentId !== void 0 ? { documentId } : {} }
|
|
20896
20993
|
});
|
|
20897
20994
|
const obj = res.data;
|
|
20898
20995
|
if (!obj) {
|
package/package.json
CHANGED