@fairmint/captable-ai 0.1.16 → 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.
Files changed (2) hide show
  1. package/dist/index.js +117 -10
  2. 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
@@ -16957,6 +16968,16 @@ var warrantResolutionItemSchema = external_exports.object({
16957
16968
  shareQuantity: external_exports.number().nullable(),
16958
16969
  shareQuantitySource: external_exports.enum(["issuance_quantity_1_to_1", "converts_to_quantity", "fixed_percent"]).nullable(),
16959
16970
  formulaText: external_exports.string().nullable(),
16971
+ // Underlying share class the warrant converts into (ENG-2089). status "known"
16972
+ // means the OCF issuance pins the class via converts_to_stock_class_id;
16973
+ // "deferred" means the class does not exist yet (SAFE-paired warrants).
16974
+ underlyingClass: external_exports.object({
16975
+ stockClassId: external_exports.string().nullable(),
16976
+ status: external_exports.enum(["known", "deferred"]),
16977
+ source: external_exports.literal("converts_to_stock_class_id").nullable()
16978
+ }).nullable().optional(),
16979
+ underlyingClassName: external_exports.string().nullable().optional(),
16980
+ displayName: external_exports.string().optional(),
16960
16981
  exercisePrice: external_exports.object({
16961
16982
  amount: external_exports.string(),
16962
16983
  currency: external_exports.string()
@@ -17532,6 +17553,9 @@ Input:
17532
17553
 
17533
17554
  Options:
17534
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
17535
17559
 
17536
17560
  Global:
17537
17561
  --json Machine-readable JSON output
@@ -17540,12 +17564,19 @@ Examples:
17540
17564
  # Read from a file:
17541
17565
  captable-ai objects update abc-123 --file ./stakeholder.json
17542
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
+
17543
17573
  # Pipe from jq (extract the bare OCF payload first):
17544
17574
  captable-ai objects get abc-123 --json | jq '.data.ocf | .legal_name = "Acme Corp"' | captable-ai objects update abc-123 --stdin`;
17545
17575
  var HELP_OBJECTS_PATCH = `objects patch \u2014 Patch an OCF object
17546
17576
 
17547
17577
  Usage:
17548
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]
17549
17580
 
17550
17581
  Shallow-merges a partial OCF payload onto the latest stored object, validates the
17551
17582
  merged object, and writes a draft. This is not RFC 6902 JSON Patch.
@@ -17556,12 +17587,21 @@ Input:
17556
17587
 
17557
17588
  Options:
17558
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
17559
17593
 
17560
17594
  Global:
17561
17595
  --json Machine-readable JSON output
17562
17596
 
17563
17597
  Examples:
17564
- 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`;
17565
17605
  var HELP_OBJECTS_REVERT = `objects revert \u2014 Preview or revert draft objects
17566
17606
 
17567
17607
  Usage:
@@ -20388,6 +20428,14 @@ More results available. Next page:
20388
20428
 
20389
20429
  // src/commands/objects-patch.ts
20390
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
20391
20439
  async function readStdin() {
20392
20440
  const chunks = [];
20393
20441
  for await (const chunk of process.stdin) {
@@ -20426,7 +20474,10 @@ async function runObjectsPatch(args, rawArgv) {
20426
20474
  `);
20427
20475
  process.exit(0);
20428
20476
  }
20429
- validateFlags(args, { flags: ["file", "version"], booleans: ["stdin"] });
20477
+ validateFlags(args, {
20478
+ flags: ["file", "version", "document"],
20479
+ booleans: ["stdin", "clear-document"]
20480
+ });
20430
20481
  const objectId = args.positional[0];
20431
20482
  if (!objectId) {
20432
20483
  exitWithUsage(
@@ -20442,7 +20493,18 @@ async function runObjectsPatch(args, rawArgv) {
20442
20493
  }
20443
20494
  const useStdin = hasFlag(args, "stdin");
20444
20495
  const filePath = getFlagValue(args, "file") ?? "";
20445
- if (!useStdin && !filePath) {
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) {
20446
20508
  exitWithUsage(
20447
20509
  "Specify how to supply the OCF patch payload: --stdin (piped JSON) or --file <path>.",
20448
20510
  "Usage: captable-ai objects patch <object-id> (--stdin | --file <path>) [--version N] [--json]"
@@ -20454,7 +20516,7 @@ async function runObjectsPatch(args, rawArgv) {
20454
20516
  "Usage: captable-ai objects patch <object-id> (--stdin | --file <path>) [--version N] [--json]"
20455
20517
  );
20456
20518
  }
20457
- let rawPatch;
20519
+ let rawPatch = "{}";
20458
20520
  if (useStdin) {
20459
20521
  if (process.stdin.isTTY) {
20460
20522
  exitWithError(
@@ -20465,7 +20527,7 @@ async function runObjectsPatch(args, rawArgv) {
20465
20527
  );
20466
20528
  }
20467
20529
  rawPatch = await readStdin();
20468
- } else {
20530
+ } else if (filePath) {
20469
20531
  try {
20470
20532
  rawPatch = readFileSync(filePath, "utf-8");
20471
20533
  } catch (err) {
@@ -20495,9 +20557,27 @@ async function runObjectsPatch(args, rawArgv) {
20495
20557
  }
20496
20558
  version2 = Number.parseInt(versionRaw, 10);
20497
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
+ }
20498
20574
  const res = await apiRequest(`/${portalId}/objects/${encodeURIComponent(objectId)}`, {
20499
20575
  method: "PATCH",
20500
- body: { ocfPatch, version: version2 }
20576
+ body: {
20577
+ ocfPatch,
20578
+ version: version2,
20579
+ ...documentId !== void 0 ? { documentId } : {}
20580
+ }
20501
20581
  });
20502
20582
  const obj = res.data;
20503
20583
  if (!obj) {
@@ -20795,7 +20875,10 @@ async function runObjectsUpdate(args, rawArgv) {
20795
20875
  `);
20796
20876
  process.exit(0);
20797
20877
  }
20798
- validateFlags(args, { flags: ["file", "version"], booleans: ["stdin"] });
20878
+ validateFlags(args, {
20879
+ flags: ["file", "version", "document"],
20880
+ booleans: ["stdin", "clear-document"]
20881
+ });
20799
20882
  const objectId = args.positional[0];
20800
20883
  if (!objectId) {
20801
20884
  exitWithUsage(
@@ -20858,6 +20941,30 @@ async function runObjectsUpdate(args, rawArgv) {
20858
20941
  }
20859
20942
  }
20860
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
+ }
20861
20968
  const versionRaw = getFlagValue(args, "version");
20862
20969
  const portalId = await getActivePortalId();
20863
20970
  let version2;
@@ -20882,7 +20989,7 @@ async function runObjectsUpdate(args, rawArgv) {
20882
20989
  }
20883
20990
  const res = await apiRequest(`/${portalId}/objects/${encodeURIComponent(objectId)}`, {
20884
20991
  method: "POST",
20885
- body: { ocf, version: version2 }
20992
+ body: { ocf, version: version2, ...documentId !== void 0 ? { documentId } : {} }
20886
20993
  });
20887
20994
  const obj = res.data;
20888
20995
  if (!obj) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fairmint/captable-ai",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Agent-native CLI for Captable AI — manage companies, upload documents, run OCF extraction, and commit cap tables from the terminal.",
5
5
  "keywords": [
6
6
  "captable",