@acquis-consulting/asm 1.0.15 → 1.0.16
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 +24 -3
- package/dist/index.js.map +1 -1
- package/dist/tools/apiRequest.d.ts +70 -0
- package/dist/tools/apiRequest.js +67 -0
- package/dist/tools/apiRequest.js.map +1 -0
- package/dist/tools/auditTrailDownload.d.ts +57 -0
- package/dist/tools/auditTrailDownload.js +128 -0
- package/dist/tools/auditTrailDownload.js.map +1 -0
- package/dist/tools/auditTrailSearch.d.ts +102 -0
- package/dist/tools/auditTrailSearch.js +215 -0
- package/dist/tools/auditTrailSearch.js.map +1 -0
- package/dist/tools/bulkExportResults.js +49 -10
- package/dist/tools/bulkExportResults.js.map +1 -1
- package/dist/tools/bulkImportAbort.d.ts +37 -0
- package/dist/tools/bulkImportAbort.js +46 -0
- package/dist/tools/bulkImportAbort.js.map +1 -0
- package/dist/tools/bulkImportResults.d.ts +51 -0
- package/dist/tools/bulkImportResults.js +168 -0
- package/dist/tools/bulkImportResults.js.map +1 -0
- package/dist/tools/bulkImportStart.d.ts +120 -0
- package/dist/tools/bulkImportStart.js +183 -0
- package/dist/tools/bulkImportStart.js.map +1 -0
- package/dist/tools/bulkImportStatus.d.ts +37 -0
- package/dist/tools/bulkImportStatus.js +56 -0
- package/dist/tools/bulkImportStatus.js.map +1 -0
- package/dist/tools/salesforceCliLogin.d.ts +36 -0
- package/dist/tools/salesforceCliLogin.js +73 -0
- package/dist/tools/salesforceCliLogin.js.map +1 -0
- package/dist/tools/salesforceCliLoginStatus.d.ts +25 -0
- package/dist/tools/salesforceCliLoginStatus.js +66 -0
- package/dist/tools/salesforceCliLoginStatus.js.map +1 -0
- package/dist/tools/salesforceLogin.js +2 -1
- package/dist/tools/salesforceLogin.js.map +1 -1
- package/dist/utils/auditTrailCsv.d.ts +42 -0
- package/dist/utils/auditTrailCsv.js +165 -0
- package/dist/utils/auditTrailCsv.js.map +1 -0
- package/dist/utils/errors.d.ts +1 -0
- package/dist/utils/errors.js +14 -0
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/sfCliWebLogin.d.ts +56 -0
- package/dist/utils/sfCliWebLogin.js +208 -0
- package/dist/utils/sfCliWebLogin.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { toolResponse } from '../utils/index.js';
|
|
3
|
+
import { countInto, formatTopCounts, formatUserActivity, normalizeAuditDate, readAuditTrailCsv, trackUserActivity, } from '../utils/auditTrailCsv.js';
|
|
4
|
+
import * as fs from 'node:fs';
|
|
5
|
+
export const auditTrailSearchTool = {
|
|
6
|
+
name: 'salesforce_audit_trail_search',
|
|
7
|
+
description: 'Search a Setup Audit Trail CSV created by salesforce_audit_trail_download without loading it into context. Filters by user (username or name substring, default "acquis"), date range, section, and text. mode "users" groups changes by user (count, date range, main sections; all users unless "user" is set) so the user can pick whose changes and which timeline to list; mode "summary" (default) returns counts by section, user, and day; mode "rows" returns a paged list of changes (date | user | section | change) suitable for a Jira story or Excel.',
|
|
8
|
+
inputSchema: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
properties: {
|
|
11
|
+
filePath: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'Path to the CSV returned by salesforce_audit_trail_download.',
|
|
14
|
+
},
|
|
15
|
+
user: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Case-insensitive substring matched against the username or full name. Defaults to "acquis" ("*" in "users" mode). Use "*" for all users.',
|
|
18
|
+
},
|
|
19
|
+
startDate: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'Only include changes on or after this date (YYYY-MM-DD or ISO 8601 datetime, UTC).',
|
|
22
|
+
},
|
|
23
|
+
endDate: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Only include changes on or before this date, inclusive (YYYY-MM-DD or ISO 8601 datetime, UTC).',
|
|
26
|
+
},
|
|
27
|
+
section: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'Case-insensitive substring of the Setup section (e.g. "Customize Accounts", "Apex Class", "Manage Users").',
|
|
30
|
+
},
|
|
31
|
+
text: {
|
|
32
|
+
type: 'string',
|
|
33
|
+
description: 'Case-insensitive substring matched against the change description (Display) or Action.',
|
|
34
|
+
},
|
|
35
|
+
mode: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
enum: ['users', 'summary', 'rows'],
|
|
38
|
+
description: '"users" groups changes by user; "summary" (default) returns counts only; "rows" returns a page of matching changes.',
|
|
39
|
+
},
|
|
40
|
+
limit: {
|
|
41
|
+
type: 'number',
|
|
42
|
+
description: 'Rows per page in "rows" mode (default 50, max 200).',
|
|
43
|
+
},
|
|
44
|
+
offset: {
|
|
45
|
+
type: 'number',
|
|
46
|
+
description: 'Number of matching rows to skip in "rows" mode (default 0). Use nextOffset from the previous page.',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
required: ['filePath'],
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const DEFAULT_USER = 'acquis';
|
|
53
|
+
const DEFAULT_LIMIT = 50;
|
|
54
|
+
const MAX_LIMIT = 200;
|
|
55
|
+
const MAX_DISPLAY_CHARS = 300;
|
|
56
|
+
const MAX_USERS_LISTED = 50;
|
|
57
|
+
// Hard cap on the size of a "rows" page so a single call can never flood the agent's context
|
|
58
|
+
const MAX_PAGE_CHARS = 20000;
|
|
59
|
+
function defaultUser(args) {
|
|
60
|
+
return args.mode === 'users' ? '*' : DEFAULT_USER;
|
|
61
|
+
}
|
|
62
|
+
function buildMatcher(args) {
|
|
63
|
+
const user = (args.user ?? defaultUser(args)).trim().toLowerCase();
|
|
64
|
+
const section = args.section?.trim().toLowerCase();
|
|
65
|
+
const text = args.text?.trim().toLowerCase();
|
|
66
|
+
const start = args.startDate ? Date.parse(normalizeAuditDate(args.startDate, 'start')) : undefined;
|
|
67
|
+
const end = args.endDate ? Date.parse(normalizeAuditDate(args.endDate, 'end')) : undefined;
|
|
68
|
+
return (row) => {
|
|
69
|
+
if (user && user !== '*') {
|
|
70
|
+
const who = `${row.Username}\n${row.UserFullName}`.toLowerCase();
|
|
71
|
+
if (!who.includes(user))
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (start !== undefined || end !== undefined) {
|
|
75
|
+
const created = Date.parse(row.CreatedDate);
|
|
76
|
+
if (start !== undefined && created < start)
|
|
77
|
+
return false;
|
|
78
|
+
if (end !== undefined && created > end)
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (section && !row.Section.toLowerCase().includes(section))
|
|
82
|
+
return false;
|
|
83
|
+
if (text && !`${row.Display}\n${row.Action}`.toLowerCase().includes(text))
|
|
84
|
+
return false;
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function describeFilters(args) {
|
|
89
|
+
const parts = [`user~"${args.user ?? defaultUser(args)}"`];
|
|
90
|
+
if (args.startDate)
|
|
91
|
+
parts.push(`from ${args.startDate}`);
|
|
92
|
+
if (args.endDate)
|
|
93
|
+
parts.push(`to ${args.endDate}`);
|
|
94
|
+
if (args.section)
|
|
95
|
+
parts.push(`section~"${args.section}"`);
|
|
96
|
+
if (args.text)
|
|
97
|
+
parts.push(`text~"${args.text}"`);
|
|
98
|
+
return parts.join(', ');
|
|
99
|
+
}
|
|
100
|
+
function formatRow(row) {
|
|
101
|
+
const display = row.Display.replace(/\s+/g, ' ').trim();
|
|
102
|
+
const truncated = display.length > MAX_DISPLAY_CHARS ? `${display.slice(0, MAX_DISPLAY_CHARS)}…` : display;
|
|
103
|
+
const who = row.DelegateUser ? `${row.Username} (as ${row.DelegateUser})` : row.Username;
|
|
104
|
+
return `${row.CreatedDate} | ${who} | ${row.Section} | ${truncated || row.Action}`;
|
|
105
|
+
}
|
|
106
|
+
export async function handleAuditTrailSearch(args) {
|
|
107
|
+
const { filePath, mode = 'summary' } = args;
|
|
108
|
+
try {
|
|
109
|
+
if (!fs.existsSync(filePath)) {
|
|
110
|
+
return toolResponse(`File not found: ${filePath}\nUse salesforce_audit_trail_download first and pass the returned file path.`, true);
|
|
111
|
+
}
|
|
112
|
+
const matches = buildMatcher(args);
|
|
113
|
+
const filters = describeFilters(args);
|
|
114
|
+
if (mode === 'users') {
|
|
115
|
+
const users = new Map();
|
|
116
|
+
let total = 0;
|
|
117
|
+
for await (const row of readAuditTrailCsv(filePath)) {
|
|
118
|
+
if (!matches(row))
|
|
119
|
+
continue;
|
|
120
|
+
total++;
|
|
121
|
+
trackUserActivity(users, row);
|
|
122
|
+
}
|
|
123
|
+
const lines = [`Filters: ${filters}`, `Matching changes: ${total}`];
|
|
124
|
+
if (total > 0) {
|
|
125
|
+
lines.push('', `Changes by user (${users.size} user${users.size === 1 ? '' : 's'}):`, ...formatUserActivity(users, MAX_USERS_LISTED), '', `Next step: ask the user which user(s) and timeline they are interested in, then call again with ` +
|
|
126
|
+
`that user, startDate/endDate, and mode "summary" or "rows".`);
|
|
127
|
+
}
|
|
128
|
+
return toolResponse(lines.join('\n'));
|
|
129
|
+
}
|
|
130
|
+
if (mode === 'rows') {
|
|
131
|
+
const limit = Math.min(Math.max(Math.floor(args.limit ?? DEFAULT_LIMIT), 1), MAX_LIMIT);
|
|
132
|
+
const offset = Math.max(Math.floor(args.offset ?? 0), 0);
|
|
133
|
+
const page = [];
|
|
134
|
+
let pageChars = 0;
|
|
135
|
+
let total = 0;
|
|
136
|
+
let truncatedBySize = false;
|
|
137
|
+
for await (const row of readAuditTrailCsv(filePath)) {
|
|
138
|
+
if (!matches(row))
|
|
139
|
+
continue;
|
|
140
|
+
total++;
|
|
141
|
+
if (total <= offset || page.length >= limit || truncatedBySize)
|
|
142
|
+
continue;
|
|
143
|
+
const line = formatRow(row);
|
|
144
|
+
if (page.length > 0 && pageChars + line.length > MAX_PAGE_CHARS) {
|
|
145
|
+
truncatedBySize = true;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
page.push(line);
|
|
149
|
+
pageChars += line.length + 1;
|
|
150
|
+
}
|
|
151
|
+
const shownTo = offset + page.length;
|
|
152
|
+
const lines = [
|
|
153
|
+
`Filters: ${filters}`,
|
|
154
|
+
`Matching changes: ${total}`,
|
|
155
|
+
`Showing: ${page.length ? `${offset + 1}–${shownTo}` : 'none'}`,
|
|
156
|
+
'',
|
|
157
|
+
'Date (UTC) | User | Section | Change',
|
|
158
|
+
...page,
|
|
159
|
+
];
|
|
160
|
+
if (shownTo < total) {
|
|
161
|
+
lines.push('', `More rows available${truncatedBySize ? ' (page cut short to limit output size)' : ''}. ` +
|
|
162
|
+
`nextOffset: ${shownTo}`);
|
|
163
|
+
}
|
|
164
|
+
return toolResponse(lines.join('\n'));
|
|
165
|
+
}
|
|
166
|
+
const sections = new Map();
|
|
167
|
+
const users = new Map();
|
|
168
|
+
const days = new Map();
|
|
169
|
+
let total = 0;
|
|
170
|
+
let first = '';
|
|
171
|
+
let last = '';
|
|
172
|
+
for await (const row of readAuditTrailCsv(filePath)) {
|
|
173
|
+
if (!matches(row))
|
|
174
|
+
continue;
|
|
175
|
+
total++;
|
|
176
|
+
countInto(sections, row.Section);
|
|
177
|
+
countInto(users, row.Username);
|
|
178
|
+
countInto(days, row.CreatedDate.slice(0, 10));
|
|
179
|
+
if (!first || row.CreatedDate < first)
|
|
180
|
+
first = row.CreatedDate;
|
|
181
|
+
if (!last || row.CreatedDate > last)
|
|
182
|
+
last = row.CreatedDate;
|
|
183
|
+
}
|
|
184
|
+
const lines = [`Filters: ${filters}`, `Matching changes: ${total}`];
|
|
185
|
+
if (total > 0) {
|
|
186
|
+
lines.push(`First change: ${first}`, `Last change: ${last}`, '', 'By section:', ...formatTopCounts(sections, 25), '', 'By user:', ...formatTopCounts(users, 10), '', 'By day (UTC):', ...[...days.entries()].sort((a, b) => a[0].localeCompare(b[0])).map(([day, count]) => ` ${day}: ${count}`), '', `Next step: call again with mode "rows" (and optional section/text filters) to list individual changes.`);
|
|
187
|
+
}
|
|
188
|
+
else if ((args.user ?? defaultUser(args)) !== '*') {
|
|
189
|
+
lines.push('', `No changes matched. Try user "*" to see which usernames appear in the file.`);
|
|
190
|
+
}
|
|
191
|
+
return toolResponse(lines.join('\n'));
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
return toolResponse(`Failed to search Setup Audit Trail: ${error.message}`, true);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export const auditTrailSearchSchema = {
|
|
198
|
+
filePath: z.string().describe('Path to the CSV returned by salesforce_audit_trail_download.'),
|
|
199
|
+
user: z.string().describe('Case-insensitive substring matched against the username or full name. Defaults to "acquis" ("*" in "users" mode). Use "*" for all users.').optional(),
|
|
200
|
+
startDate: z.string().describe('Only include changes on or after this date (YYYY-MM-DD or ISO 8601 datetime, UTC).').optional(),
|
|
201
|
+
endDate: z.string().describe('Only include changes on or before this date, inclusive (YYYY-MM-DD or ISO 8601 datetime, UTC).').optional(),
|
|
202
|
+
section: z.string().describe('Case-insensitive substring of the Setup section (e.g. "Customize Accounts", "Apex Class", "Manage Users").').optional(),
|
|
203
|
+
text: z.string().describe('Case-insensitive substring matched against the change description (Display) or Action.').optional(),
|
|
204
|
+
mode: z.enum(['users', 'summary', 'rows']).describe('"users" groups changes by user; "summary" (default) returns counts only; "rows" returns a page of matching changes.').optional(),
|
|
205
|
+
limit: z.number().describe('Rows per page in "rows" mode (default 50, max 200).').optional(),
|
|
206
|
+
offset: z.number().describe('Number of matching rows to skip in "rows" mode (default 0). Use nextOffset from the previous page.').optional(),
|
|
207
|
+
};
|
|
208
|
+
export const auditTrailSearchDescriptor = {
|
|
209
|
+
name: 'salesforce_audit_trail_search',
|
|
210
|
+
description: auditTrailSearchTool.description,
|
|
211
|
+
schema: auditTrailSearchSchema,
|
|
212
|
+
handler: handleAuditTrailSearch,
|
|
213
|
+
noConnection: true,
|
|
214
|
+
};
|
|
215
|
+
//# sourceMappingURL=auditTrailSearch.js.map
|
|
@@ -0,0 +1 @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AAC,QAAQ,CAAC,4GAA4G,CAAC,CAAC,QAAQ,EAAE;IACrJ,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wFAAwF,CAAC,CAAC,QAAQ,EAAE;IAC9H,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,qHAAqH,CAAC,CAAC,QAAQ,EAAE;IACrL,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,qDAAqD,CAAC,CAAC,QAAQ,EAAE;IAC5F,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oGAAoG,CAAC,CAAC,QAAQ,EAAE;CAC7I,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,IAAI,EAAE,+BAA+B;IACrC,WAAW,EAAE,oBAAoB,CAAC,WAAW;IAC7C,MAAM,EAAE,sBAAsB;IAC9B,OAAO,EAAE,sBAAsB;IAC/B,YAAY,EAAE,IAAI;CACnB,CAAC"}
|
|
@@ -24,6 +24,54 @@ export const bulkExportResultsTool = {
|
|
|
24
24
|
required: ['jobId'],
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Fetches every Bulk API v2 result page for a job directly (bypassing jsforce's
|
|
29
|
+
* bulk2 stream/pipe machinery, which drops/duplicates data across locator pages)
|
|
30
|
+
* and appends raw bytes to disk, stripping the repeated header row from every
|
|
31
|
+
* page after the first and ensuring a newline separates each page's rows.
|
|
32
|
+
*/
|
|
33
|
+
async function downloadResultPages(conn, jobId, filePath) {
|
|
34
|
+
const fileHandle = await fs.promises.open(filePath, 'w');
|
|
35
|
+
try {
|
|
36
|
+
let locator;
|
|
37
|
+
let isFirstPage = true;
|
|
38
|
+
let endsWithNewline = true;
|
|
39
|
+
do {
|
|
40
|
+
const url = `${conn.instanceUrl}/services/data/v${conn.version}/jobs/query/${jobId}/results` +
|
|
41
|
+
(locator ? `?locator=${encodeURIComponent(locator)}` : '');
|
|
42
|
+
const response = await fetch(url, {
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${conn.accessToken}`,
|
|
45
|
+
Accept: 'text/csv',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
if (!response.ok) {
|
|
49
|
+
throw new Error(`Failed to fetch result page (HTTP ${response.status} ${response.statusText})`);
|
|
50
|
+
}
|
|
51
|
+
const page = Buffer.from(await response.arrayBuffer());
|
|
52
|
+
let toWrite;
|
|
53
|
+
if (isFirstPage) {
|
|
54
|
+
toWrite = page;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
const headerEnd = page.indexOf(0x0a); // '\n'
|
|
58
|
+
toWrite = headerEnd === -1 ? Buffer.alloc(0) : page.subarray(headerEnd + 1);
|
|
59
|
+
if (toWrite.length > 0 && !endsWithNewline) {
|
|
60
|
+
await fileHandle.write(Buffer.from('\n'));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (toWrite.length > 0) {
|
|
64
|
+
await fileHandle.write(toWrite);
|
|
65
|
+
endsWithNewline = toWrite[toWrite.length - 1] === 0x0a;
|
|
66
|
+
}
|
|
67
|
+
isFirstPage = false;
|
|
68
|
+
locator = response.headers.get('sforce-locator') ?? undefined;
|
|
69
|
+
} while (locator && locator !== 'null');
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
await fileHandle.close();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
27
75
|
export async function handleBulkExportResults(conn, args) {
|
|
28
76
|
const { jobId, outputDir, fileName } = args;
|
|
29
77
|
try {
|
|
@@ -40,16 +88,7 @@ export async function handleBulkExportResults(conn, args) {
|
|
|
40
88
|
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
41
89
|
const name = fileName || `${info.object}_${timestamp}.csv`;
|
|
42
90
|
const filePath = path.join(dir, name);
|
|
43
|
-
|
|
44
|
-
const writeStream = fs.createWriteStream(filePath);
|
|
45
|
-
await new Promise((resolve, reject) => {
|
|
46
|
-
resultStream
|
|
47
|
-
.stream()
|
|
48
|
-
.pipe(writeStream)
|
|
49
|
-
.on('finish', resolve)
|
|
50
|
-
.on('error', reject);
|
|
51
|
-
resultStream.on('error', reject);
|
|
52
|
-
});
|
|
91
|
+
await downloadResultPages(conn, jobId, filePath);
|
|
53
92
|
const stats = fs.statSync(filePath);
|
|
54
93
|
const fileSizeMB = (stats.size / (1024 * 1024)).toFixed(2);
|
|
55
94
|
return toolResponse(`Bulk export results downloaded successfully.\n\n` +
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bulkExportResults.js","sourceRoot":"","sources":["../../src/tools/bulkExportResults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,gCAAgC;IACtC,WAAW,EACT,gLAAgL;IAClL,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wDAAwD;aACtE;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yGAAyG;aACvH;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,yEAAyE;aACvF;SACF;QACD,QAAQ,EAAE,CAAC,OAAO,CAAC;KACpB;CACF,CAAC;AAQF,
|
|
1
|
+
{"version":3,"file":"bulkExportResults.js","sourceRoot":"","sources":["../../src/tools/bulkExportResults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EA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AAQ,CAAC,QAAQ,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAE3D,OAAO,YAAY,CACjB,kDAAkD;YAClD,SAAS,QAAQ,IAAI;YACrB,WAAW,IAAI,CAAC,MAAM,IAAI;YAC1B,sBAAsB,IAAI,CAAC,sBAAsB,IAAI,KAAK,IAAI;YAC9D,cAAc,UAAU,KAAK,CAC9B,CAAC;IACJ,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,OAAO,YAAY,CAAC,2CAA2C,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;IACxF,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wDAAwD,CAAC;IACpF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yGAAyG,CAAC,CAAC,QAAQ,EAAE;IACpJ,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yEAAyE,CAAC,CAAC,QAAQ,EAAE;CACpH,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,IAAI,EAAE,gCAAgC;IACtC,WAAW,EAAE,qBAAqB,CAAC,WAAW;IAC9C,MAAM,EAAE,uBAAuB;IAC/B,OAAO,EAAE,uBAAuB;CACjC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Connection } from 'jsforce';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const bulkImportAbortTool: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
jobId: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
required: string[];
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export interface BulkImportAbortArgs {
|
|
18
|
+
jobId: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function handleBulkImportAbort(conn: Connection, args: BulkImportAbortArgs): Promise<{
|
|
21
|
+
content: {
|
|
22
|
+
type: "text";
|
|
23
|
+
text: string;
|
|
24
|
+
}[];
|
|
25
|
+
isError: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const bulkImportAbortSchema: {
|
|
28
|
+
jobId: z.ZodString;
|
|
29
|
+
};
|
|
30
|
+
export declare const bulkImportAbortDescriptor: {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
schema: {
|
|
34
|
+
jobId: z.ZodString;
|
|
35
|
+
};
|
|
36
|
+
handler: typeof handleBulkImportAbort;
|
|
37
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { toolResponse } from '../utils/index.js';
|
|
3
|
+
const ABORTABLE_STATES = ['Open', 'UploadComplete', 'InProgress'];
|
|
4
|
+
export const bulkImportAbortTool = {
|
|
5
|
+
name: 'salesforce_bulk_import_abort',
|
|
6
|
+
description: 'Abort a bulk import job that is in Open, UploadComplete, or InProgress state. Records already committed before the abort are not rolled back.',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
jobId: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The bulk import job ID to abort.',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
required: ['jobId'],
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export async function handleBulkImportAbort(conn, args) {
|
|
19
|
+
const { jobId } = args;
|
|
20
|
+
try {
|
|
21
|
+
const job = conn.bulk2.job('ingest', { id: jobId });
|
|
22
|
+
const info = await job.check();
|
|
23
|
+
if (!ABORTABLE_STATES.includes(info.state)) {
|
|
24
|
+
return toolResponse(`Cannot abort job in state "${info.state}". Only Open, UploadComplete, or InProgress jobs can be aborted.`, true);
|
|
25
|
+
}
|
|
26
|
+
await job.abort();
|
|
27
|
+
return toolResponse(`Bulk import job aborted successfully.\n\n` +
|
|
28
|
+
`Job ID: ${jobId}\n` +
|
|
29
|
+
`Previous State: ${info.state}\n` +
|
|
30
|
+
`Current State: Aborted\n\n` +
|
|
31
|
+
`Records already processed are not rolled back. Use salesforce_bulk_import_results to see what was committed.`);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return toolResponse(`Failed to abort bulk import job: ${error.message}`, true);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export const bulkImportAbortSchema = {
|
|
38
|
+
jobId: z.string().describe('The bulk import job ID to abort.'),
|
|
39
|
+
};
|
|
40
|
+
export const bulkImportAbortDescriptor = {
|
|
41
|
+
name: 'salesforce_bulk_import_abort',
|
|
42
|
+
description: bulkImportAbortTool.description,
|
|
43
|
+
schema: bulkImportAbortSchema,
|
|
44
|
+
handler: handleBulkImportAbort,
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=bulkImportAbort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulkImportAbort.js","sourceRoot":"","sources":["../../src/tools/bulkImportAbort.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,YAAY,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,8BAA8B;IACpC,WAAW,EACT,+IAA+I;IACjJ,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE;g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
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Connection } from 'jsforce';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const bulkImportResultsTool: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
jobId: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
outputDir: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
fileNamePrefix: {
|
|
18
|
+
type: string;
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
required: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export interface BulkImportResultsArgs {
|
|
26
|
+
jobId: string;
|
|
27
|
+
outputDir?: string;
|
|
28
|
+
fileNamePrefix?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function handleBulkImportResults(conn: Connection, args: BulkImportResultsArgs): Promise<{
|
|
31
|
+
content: {
|
|
32
|
+
type: "text";
|
|
33
|
+
text: string;
|
|
34
|
+
}[];
|
|
35
|
+
isError: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const bulkImportResultsSchema: {
|
|
38
|
+
jobId: z.ZodString;
|
|
39
|
+
outputDir: z.ZodOptional<z.ZodString>;
|
|
40
|
+
fileNamePrefix: z.ZodOptional<z.ZodString>;
|
|
41
|
+
};
|
|
42
|
+
export declare const bulkImportResultsDescriptor: {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
schema: {
|
|
46
|
+
jobId: z.ZodString;
|
|
47
|
+
outputDir: z.ZodOptional<z.ZodString>;
|
|
48
|
+
fileNamePrefix: z.ZodOptional<z.ZodString>;
|
|
49
|
+
};
|
|
50
|
+
handler: typeof handleBulkImportResults;
|
|
51
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { toolResponse } from '../utils/index.js';
|
|
3
|
+
import * as fs from 'node:fs';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
const TERMINAL_STATES = ['JobComplete', 'Failed', 'Aborted'];
|
|
6
|
+
const ERROR_PREVIEW_LIMIT = 5;
|
|
7
|
+
const DELIMITER_CHARS = {
|
|
8
|
+
BACKQUOTE: '`',
|
|
9
|
+
CARET: '^',
|
|
10
|
+
COMMA: ',',
|
|
11
|
+
PIPE: '|',
|
|
12
|
+
SEMICOLON: ';',
|
|
13
|
+
TAB: '\t',
|
|
14
|
+
};
|
|
15
|
+
const RESULT_KINDS = [
|
|
16
|
+
{ key: 'success', endpoint: 'successfulResults', label: 'Successful' },
|
|
17
|
+
{ key: 'failed', endpoint: 'failedResults', label: 'Failed' },
|
|
18
|
+
{ key: 'unprocessed', endpoint: 'unprocessedrecords', label: 'Unprocessed' },
|
|
19
|
+
];
|
|
20
|
+
export const bulkImportResultsTool = {
|
|
21
|
+
name: 'salesforce_bulk_import_results',
|
|
22
|
+
description: 'Download the results of a finished bulk import job (JobComplete, Failed, or Aborted) as CSV files: successful records (with sf__Id/sf__Created), failed records (with sf__Error), and unprocessed records. Returns file paths, row counts, and a preview of the first error messages.',
|
|
23
|
+
inputSchema: {
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
jobId: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: 'The bulk import job ID (must be in JobComplete, Failed, or Aborted state).',
|
|
29
|
+
},
|
|
30
|
+
outputDir: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Directory to save the CSV files. Defaults to SALESFORCE_EXPORT_DIR env var or current working directory.',
|
|
33
|
+
},
|
|
34
|
+
fileNamePrefix: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
description: 'Custom prefix for the CSV file names. Defaults to {ObjectName}_{jobId}. Files are named {prefix}_{success|failed|unprocessed}.csv.',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['jobId'],
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
/** Minimal RFC 4180 parser — handles quoted fields with embedded delimiters, quotes, and newlines. */
|
|
43
|
+
function parseCsv(text, delimiter) {
|
|
44
|
+
const rows = [];
|
|
45
|
+
let row = [];
|
|
46
|
+
let field = '';
|
|
47
|
+
let inQuotes = false;
|
|
48
|
+
for (let i = 0; i < text.length; i++) {
|
|
49
|
+
const ch = text[i];
|
|
50
|
+
if (inQuotes) {
|
|
51
|
+
if (ch === '"') {
|
|
52
|
+
if (text[i + 1] === '"') {
|
|
53
|
+
field += '"';
|
|
54
|
+
i++;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
inQuotes = false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
field += ch;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (ch === '"') {
|
|
65
|
+
inQuotes = true;
|
|
66
|
+
}
|
|
67
|
+
else if (ch === delimiter) {
|
|
68
|
+
row.push(field);
|
|
69
|
+
field = '';
|
|
70
|
+
}
|
|
71
|
+
else if (ch === '\n' || ch === '\r') {
|
|
72
|
+
if (ch === '\r' && text[i + 1] === '\n')
|
|
73
|
+
i++;
|
|
74
|
+
row.push(field);
|
|
75
|
+
rows.push(row);
|
|
76
|
+
row = [];
|
|
77
|
+
field = '';
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
field += ch;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (field !== '' || row.length > 0) {
|
|
84
|
+
row.push(field);
|
|
85
|
+
rows.push(row);
|
|
86
|
+
}
|
|
87
|
+
return rows;
|
|
88
|
+
}
|
|
89
|
+
async function fetchResult(conn, jobId, endpoint) {
|
|
90
|
+
const url = `${conn.instanceUrl}/services/data/v${conn.version}/jobs/ingest/${jobId}/${endpoint}`;
|
|
91
|
+
const response = await fetch(url, {
|
|
92
|
+
headers: {
|
|
93
|
+
Authorization: `Bearer ${conn.accessToken}`,
|
|
94
|
+
Accept: 'text/csv',
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
throw new Error(`Failed to fetch ${endpoint} (HTTP ${response.status} ${response.statusText})`);
|
|
99
|
+
}
|
|
100
|
+
return response.text();
|
|
101
|
+
}
|
|
102
|
+
export async function handleBulkImportResults(conn, args) {
|
|
103
|
+
const { jobId, outputDir, fileNamePrefix } = args;
|
|
104
|
+
try {
|
|
105
|
+
const job = conn.bulk2.job('ingest', { id: jobId });
|
|
106
|
+
const info = await job.check();
|
|
107
|
+
if (!TERMINAL_STATES.includes(info.state)) {
|
|
108
|
+
return toolResponse(`Job has not finished. Current state: ${info.state}.\n` +
|
|
109
|
+
`Use salesforce_bulk_import_status to check progress before downloading results.`, true);
|
|
110
|
+
}
|
|
111
|
+
const dir = outputDir || process.env.SALESFORCE_EXPORT_DIR || process.cwd();
|
|
112
|
+
if (!fs.existsSync(dir)) {
|
|
113
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
114
|
+
}
|
|
115
|
+
const delimiter = DELIMITER_CHARS[info.columnDelimiter] ?? ',';
|
|
116
|
+
const prefix = fileNamePrefix || `${info.object}_${jobId}`;
|
|
117
|
+
const lines = [
|
|
118
|
+
`Bulk import results for job ${jobId}.`,
|
|
119
|
+
'',
|
|
120
|
+
`Object: ${info.object}`,
|
|
121
|
+
`Operation: ${info.operation}`,
|
|
122
|
+
`State: ${info.state}`,
|
|
123
|
+
];
|
|
124
|
+
if (info.errorMessage)
|
|
125
|
+
lines.push(`Job Error: ${info.errorMessage}`);
|
|
126
|
+
lines.push('');
|
|
127
|
+
const errorPreview = [];
|
|
128
|
+
for (const kind of RESULT_KINDS) {
|
|
129
|
+
const csv = await fetchResult(conn, jobId, kind.endpoint);
|
|
130
|
+
const rows = parseCsv(csv, delimiter).filter((r) => !(r.length === 1 && r[0] === ''));
|
|
131
|
+
const dataRows = rows.length > 0 ? rows.length - 1 : 0;
|
|
132
|
+
if (dataRows === 0) {
|
|
133
|
+
lines.push(`${kind.label}: 0 records (no file written)`);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const filePath = path.join(dir, `${prefix}_${kind.key}.csv`);
|
|
137
|
+
await fs.promises.writeFile(filePath, csv);
|
|
138
|
+
lines.push(`${kind.label}: ${dataRows} record(s) → ${filePath}`);
|
|
139
|
+
if (kind.key === 'failed') {
|
|
140
|
+
const errorCol = rows[0].indexOf('sf__Error');
|
|
141
|
+
if (errorCol !== -1) {
|
|
142
|
+
for (const row of rows.slice(1, 1 + ERROR_PREVIEW_LIMIT)) {
|
|
143
|
+
errorPreview.push(` - ${row[errorCol]}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (errorPreview.length > 0) {
|
|
149
|
+
lines.push('', `First ${errorPreview.length} error(s):`, ...errorPreview);
|
|
150
|
+
}
|
|
151
|
+
return toolResponse(lines.join('\n'));
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
return toolResponse(`Failed to download bulk import results: ${error.message}`, true);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
export const bulkImportResultsSchema = {
|
|
158
|
+
jobId: z.string().describe('The bulk import job ID (must be in JobComplete, Failed, or Aborted state).'),
|
|
159
|
+
outputDir: z.string().describe('Directory to save the CSV files. Defaults to SALESFORCE_EXPORT_DIR env var or current working directory.').optional(),
|
|
160
|
+
fileNamePrefix: z.string().describe('Custom prefix for the CSV file names. Defaults to {ObjectName}_{jobId}. Files are named {prefix}_{success|failed|unprocessed}.csv.').optional(),
|
|
161
|
+
};
|
|
162
|
+
export const bulkImportResultsDescriptor = {
|
|
163
|
+
name: 'salesforce_bulk_import_results',
|
|
164
|
+
description: bulkImportResultsTool.description,
|
|
165
|
+
schema: bulkImportResultsSchema,
|
|
166
|
+
handler: handleBulkImportResults,
|
|
167
|
+
};
|
|
168
|
+
//# sourceMappingURL=bulkImportResults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bulkImportResults.js","sourceRoot":"","sources":["../../src/tools/bulkImportResults.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,MAAM,eAAe,GAAG,CAAC,aAAa,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAC7D,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,MAAM,eAAe,GAA2B;IAC9C,SAAS,EAAE,GAAG;IACd,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,IAAI,EAAE,GAAG;IACT,SAAS,EAAE,GAAG;IACd,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,KAAK,EAAE,YAAY,EAAE;IACtE,EAAE,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE;IAC7D,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,oBAAoB,EAAE,KAAK,EAAE,aAAa,EAAE;CACpE,CAAC;AAEX,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,IAAI,EAAE,gCAAgC;IACtC,WAAW,EACT,uRAAuR;IACzR,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,4EAA4E;aAC1F;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,0GAA0G;aACxH;YACD,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