@sellable/mcp 0.1.518 → 0.1.519
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,44 @@ 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
|
+
if (apiErrorStatus(error) !== 409)
|
|
103
|
+
return null;
|
|
104
|
+
const body = apiErrorBody(error);
|
|
105
|
+
if (!body)
|
|
106
|
+
return null;
|
|
107
|
+
try {
|
|
108
|
+
const parsed = JSON.parse(body);
|
|
109
|
+
const message = stringValue(parsed.error);
|
|
110
|
+
if (message !== "Import already in progress")
|
|
111
|
+
return null;
|
|
112
|
+
return {
|
|
113
|
+
error: message,
|
|
114
|
+
jobId: stringValue(parsed.jobId),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
if (!body.includes("Import already in progress"))
|
|
119
|
+
return null;
|
|
120
|
+
return {
|
|
121
|
+
error: "Import already in progress",
|
|
122
|
+
jobId: null,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
88
126
|
export function paidRefreshActionFrom(value) {
|
|
89
127
|
const action = recordValue(value);
|
|
90
128
|
if (!action || action.type !== "refresh_paid_inmail_credits")
|
|
@@ -707,6 +745,18 @@ export async function executeOneYoloPrimitive(action, workspaceId) {
|
|
|
707
745
|
result = await confirmLeadList(copyInput);
|
|
708
746
|
}
|
|
709
747
|
catch (error) {
|
|
748
|
+
const sourceImportInProgress = sourceImportInProgressPayloadFromError(error);
|
|
749
|
+
if (sourceImportInProgress) {
|
|
750
|
+
return {
|
|
751
|
+
status: "read_only_reread",
|
|
752
|
+
result: {
|
|
753
|
+
waited: true,
|
|
754
|
+
reason: "source_import_in_progress",
|
|
755
|
+
jobId: sourceImportInProgress.jobId ?? null,
|
|
756
|
+
error: sourceImportInProgress.error,
|
|
757
|
+
},
|
|
758
|
+
};
|
|
759
|
+
}
|
|
710
760
|
const rowLimitPayload = userAddedRowsLimitPayloadFromError(error);
|
|
711
761
|
if (!rowLimitPayload)
|
|
712
762
|
throw error;
|