@fairmint/captable-ai 0.1.36 → 0.1.38
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 +39 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -15113,22 +15113,27 @@ function deriveExtractionReadinessPhase(summary) {
|
|
|
15113
15113
|
return "complete";
|
|
15114
15114
|
}
|
|
15115
15115
|
var IMPORT_SESSION_CLOCK_SKEW_MS = 5e3;
|
|
15116
|
-
function
|
|
15117
|
-
|
|
15118
|
-
|
|
15119
|
-
|
|
15120
|
-
|
|
15121
|
-
|
|
15122
|
-
const cutoffMs = sessionMs - IMPORT_SESSION_CLOCK_SKEW_MS;
|
|
15116
|
+
function sameUuid(a, b) {
|
|
15117
|
+
return typeof b === "string" && a.toLowerCase() === b.toLowerCase();
|
|
15118
|
+
}
|
|
15119
|
+
function documentsForImportSession(documents, sessionCreatedAt, sessionId) {
|
|
15120
|
+
const sessionMs = typeof sessionCreatedAt === "string" ? parseTimestampMs(sessionCreatedAt) : null;
|
|
15121
|
+
const cutoffMs = sessionMs === null ? null : sessionMs - IMPORT_SESSION_CLOCK_SKEW_MS;
|
|
15123
15122
|
return documents.filter((document) => {
|
|
15124
|
-
if (typeof document.
|
|
15123
|
+
if (typeof document.importSessionId === "string") {
|
|
15124
|
+
return sameUuid(document.importSessionId, sessionId);
|
|
15125
|
+
}
|
|
15126
|
+
if (cutoffMs === null || typeof document.createdAt !== "string")
|
|
15125
15127
|
return false;
|
|
15126
15128
|
const createdMs = parseTimestampMs(document.createdAt);
|
|
15127
15129
|
return createdMs !== null && createdMs >= cutoffMs;
|
|
15128
15130
|
});
|
|
15129
15131
|
}
|
|
15130
15132
|
function importSessionScopeUnknown(documents) {
|
|
15131
|
-
return documents.length > 0 && documents.every((document) =>
|
|
15133
|
+
return documents.length > 0 && documents.every((document) => (
|
|
15134
|
+
// A stamped document is attributable without a creation time.
|
|
15135
|
+
typeof document.importSessionId !== "string" && (typeof document.createdAt !== "string" || parseTimestampMs(document.createdAt) === null)
|
|
15136
|
+
));
|
|
15132
15137
|
}
|
|
15133
15138
|
var HAS_ZONE = /(?:Z|[+-]\d{2}(?::?\d{2})?)$/i;
|
|
15134
15139
|
function parseTimestampMs(value) {
|
|
@@ -15608,6 +15613,7 @@ var documentProcessingStatusItemSchema = external_exports.object({
|
|
|
15608
15613
|
name: external_exports.string().nullable().optional().describe("Original file name; absent on older servers."),
|
|
15609
15614
|
status: external_exports.string().describe("Document processing status."),
|
|
15610
15615
|
createdAt: external_exports.string().nullable().optional().describe("Immutable document creation timestamp; absent on older servers."),
|
|
15616
|
+
importSessionId: external_exports.string().nullable().optional().describe("Import session the upload named (set when the document is uploaded or re-uploaded into that session); null for older uploads and uploads that named none; absent on older servers."),
|
|
15611
15617
|
lastActivityAt: external_exports.string().nullable().describe("Last backend activity timestamp (updated_at / heartbeat); null if unknown."),
|
|
15612
15618
|
queuePosition: external_exports.number().int().min(0).nullable().describe("0 = at the head (processing); >0 = waiting behind others; null = not in pipeline."),
|
|
15613
15619
|
health: external_exports.enum(DOCUMENT_HEALTH_VALUES).describe("Derived health from backend heartbeat + queue position.")
|
|
@@ -20918,6 +20924,20 @@ async function hashFile(path) {
|
|
|
20918
20924
|
const data = await readFile4(path);
|
|
20919
20925
|
return createHash2("sha256").update(data).digest("hex");
|
|
20920
20926
|
}
|
|
20927
|
+
async function openImportSession(portalId) {
|
|
20928
|
+
try {
|
|
20929
|
+
const res = await apiRequest("/import-sessions", {
|
|
20930
|
+
method: "POST",
|
|
20931
|
+
body: { portalId },
|
|
20932
|
+
// Optional: a failure must throw to the catch below, not exit the process.
|
|
20933
|
+
softFail: true
|
|
20934
|
+
});
|
|
20935
|
+
const id = res.data?.session?.id;
|
|
20936
|
+
return typeof id === "string" ? id : null;
|
|
20937
|
+
} catch {
|
|
20938
|
+
return null;
|
|
20939
|
+
}
|
|
20940
|
+
}
|
|
20921
20941
|
async function runDocumentsUpload(args, rawArgv) {
|
|
20922
20942
|
if (rawArgv.includes("--help") || rawArgv.includes("-h")) {
|
|
20923
20943
|
process.stdout.write(
|
|
@@ -20947,11 +20967,15 @@ async function runDocumentsUpload(args, rawArgv) {
|
|
|
20947
20967
|
});
|
|
20948
20968
|
}
|
|
20949
20969
|
if (!isJsonMode()) printLine(`Preparing ${files.length} file(s)...`);
|
|
20970
|
+
const importSessionId = await openImportSession(portalId);
|
|
20950
20971
|
const prepareRes = await apiRequest(
|
|
20951
20972
|
`/${portalId}/documents/prepare`,
|
|
20952
20973
|
{
|
|
20953
20974
|
method: "POST",
|
|
20954
|
-
body: {
|
|
20975
|
+
body: {
|
|
20976
|
+
files: files.map(({ path: _, ...f }) => f),
|
|
20977
|
+
...importSessionId === null ? {} : { importSessionId }
|
|
20978
|
+
}
|
|
20955
20979
|
}
|
|
20956
20980
|
);
|
|
20957
20981
|
const documents = prepareRes.data?.documents ?? [];
|
|
@@ -23344,7 +23368,11 @@ async function runImportStatus(args) {
|
|
|
23344
23368
|
`/import-sessions/${encodeURIComponent(sessionId)}/status`
|
|
23345
23369
|
);
|
|
23346
23370
|
const portalDocuments = response.data?.processing?.documents ?? [];
|
|
23347
|
-
const documents = documentsForImportSession(
|
|
23371
|
+
const documents = documentsForImportSession(
|
|
23372
|
+
portalDocuments,
|
|
23373
|
+
response.data?.session?.createdAt,
|
|
23374
|
+
sessionId
|
|
23375
|
+
);
|
|
23348
23376
|
const documentIds = documents.flatMap(
|
|
23349
23377
|
(document) => typeof document.s3AssetId === "string" ? [document.s3AssetId] : []
|
|
23350
23378
|
);
|
package/package.json
CHANGED