@sellable/mcp 0.1.518 → 0.1.520
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.
|
@@ -33,6 +33,10 @@ export type UserAddedRowsLimitPayload = {
|
|
|
33
33
|
attemptedRows?: number;
|
|
34
34
|
remainingRows?: number;
|
|
35
35
|
};
|
|
36
|
+
export type SourceImportInProgressPayload = {
|
|
37
|
+
error?: string;
|
|
38
|
+
jobId?: string | null;
|
|
39
|
+
};
|
|
36
40
|
export type PrepareRowSelector = {
|
|
37
41
|
type: "needsEnrichment";
|
|
38
42
|
limit?: number;
|
|
@@ -119,6 +123,7 @@ export declare function stringArray(value: unknown): string[];
|
|
|
119
123
|
export declare function prepareRowSelectorValue(value: unknown): PrepareRowSelector | undefined;
|
|
120
124
|
export declare function uniqueStrings(values: Array<string | null | undefined>): string[];
|
|
121
125
|
export declare function userAddedRowsLimitPayloadFromError(error: unknown): UserAddedRowsLimitPayload | null;
|
|
126
|
+
export declare function sourceImportInProgressPayloadFromError(error: unknown): SourceImportInProgressPayload | null;
|
|
122
127
|
export declare function paidRefreshActionFrom(value: unknown): PaidInmailRefreshAction | null;
|
|
123
128
|
export declare function collectPaidInmailRefreshActions(plan: unknown): PaidInmailRefreshAction[];
|
|
124
129
|
export declare function firstGlobalAction(plan: unknown): Record<string, unknown> | null;
|
|
@@ -85,6 +85,51 @@ export function userAddedRowsLimitPayloadFromError(error) {
|
|
|
85
85
|
return null;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
+
function apiErrorStatus(error) {
|
|
89
|
+
if (error instanceof SellableApiError)
|
|
90
|
+
return error.status;
|
|
91
|
+
const record = recordValue(error);
|
|
92
|
+
const status = record?.status;
|
|
93
|
+
return typeof status === "number" && Number.isFinite(status) ? status : null;
|
|
94
|
+
}
|
|
95
|
+
function apiErrorBody(error) {
|
|
96
|
+
if (error instanceof SellableApiError)
|
|
97
|
+
return error.body;
|
|
98
|
+
const record = recordValue(error);
|
|
99
|
+
return stringValue(record?.body) ?? stringValue(record?.message);
|
|
100
|
+
}
|
|
101
|
+
export function sourceImportInProgressPayloadFromError(error) {
|
|
102
|
+
const body = apiErrorBody(error);
|
|
103
|
+
if (!body)
|
|
104
|
+
return null;
|
|
105
|
+
if (body.includes("Source import still running") &&
|
|
106
|
+
body.includes("Import still in progress")) {
|
|
107
|
+
return {
|
|
108
|
+
error: body,
|
|
109
|
+
jobId: null,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (apiErrorStatus(error) !== 409)
|
|
113
|
+
return null;
|
|
114
|
+
try {
|
|
115
|
+
const parsed = JSON.parse(body);
|
|
116
|
+
const message = stringValue(parsed.error);
|
|
117
|
+
if (message !== "Import already in progress")
|
|
118
|
+
return null;
|
|
119
|
+
return {
|
|
120
|
+
error: message,
|
|
121
|
+
jobId: stringValue(parsed.jobId),
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
if (!body.includes("Import already in progress"))
|
|
126
|
+
return null;
|
|
127
|
+
return {
|
|
128
|
+
error: "Import already in progress",
|
|
129
|
+
jobId: null,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
88
133
|
export function paidRefreshActionFrom(value) {
|
|
89
134
|
const action = recordValue(value);
|
|
90
135
|
if (!action || action.type !== "refresh_paid_inmail_credits")
|
|
@@ -707,6 +752,18 @@ export async function executeOneYoloPrimitive(action, workspaceId) {
|
|
|
707
752
|
result = await confirmLeadList(copyInput);
|
|
708
753
|
}
|
|
709
754
|
catch (error) {
|
|
755
|
+
const sourceImportInProgress = sourceImportInProgressPayloadFromError(error);
|
|
756
|
+
if (sourceImportInProgress) {
|
|
757
|
+
return {
|
|
758
|
+
status: "read_only_reread",
|
|
759
|
+
result: {
|
|
760
|
+
waited: true,
|
|
761
|
+
reason: "source_import_in_progress",
|
|
762
|
+
jobId: sourceImportInProgress.jobId ?? null,
|
|
763
|
+
error: sourceImportInProgress.error,
|
|
764
|
+
},
|
|
765
|
+
};
|
|
766
|
+
}
|
|
710
767
|
const rowLimitPayload = userAddedRowsLimitPayloadFromError(error);
|
|
711
768
|
if (!rowLimitPayload)
|
|
712
769
|
throw error;
|