@acquis-consulting/asm 1.0.5
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/README.md +0 -0
- package/dist/apps/gitDiffReview/gitDiffParser.d.ts +6 -0
- package/dist/apps/gitDiffReview/gitDiffParser.js +1 -0
- package/dist/apps/gitDiffReview/packageXml.d.ts +8 -0
- package/dist/apps/gitDiffReview/packageXml.js +1 -0
- package/dist/apps/gitDiffReview/tools.d.ts +42 -0
- package/dist/apps/gitDiffReview/tools.js +1 -0
- package/dist/apps/gitDiffReview/types.d.ts +19 -0
- package/dist/apps/gitDiffReview/types.js +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +193 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata-diff.html +98 -0
- package/dist/tools/aggregateQuery.d.ts +85 -0
- package/dist/tools/aggregateQuery.js +110 -0
- package/dist/tools/aggregateQuery.js.map +1 -0
- package/dist/tools/bulkExportAbort.d.ts +37 -0
- package/dist/tools/bulkExportAbort.js +44 -0
- package/dist/tools/bulkExportAbort.js.map +1 -0
- package/dist/tools/bulkExportResults.d.ts +51 -0
- package/dist/tools/bulkExportResults.js +76 -0
- package/dist/tools/bulkExportResults.js.map +1 -0
- package/dist/tools/bulkExportStart.d.ts +61 -0
- package/dist/tools/bulkExportStart.js +68 -0
- package/dist/tools/bulkExportStart.js.map +1 -0
- package/dist/tools/bulkExportStatus.d.ts +37 -0
- package/dist/tools/bulkExportStatus.js +54 -0
- package/dist/tools/bulkExportStatus.js.map +1 -0
- package/dist/tools/crossObjectSearch.d.ts +155 -0
- package/dist/tools/crossObjectSearch.js +145 -0
- package/dist/tools/crossObjectSearch.js.map +1 -0
- package/dist/tools/debugLogs.d.ts +106 -0
- package/dist/tools/debugLogs.js +189 -0
- package/dist/tools/debugLogs.js.map +1 -0
- package/dist/tools/deployMetadata.d.ts +60 -0
- package/dist/tools/deployMetadata.js +106 -0
- package/dist/tools/deployMetadata.js.map +1 -0
- package/dist/tools/deployPackage.d.ts +49 -0
- package/dist/tools/deployPackage.js +1 -0
- package/dist/tools/dml.d.ts +70 -0
- package/dist/tools/dml.js +105 -0
- package/dist/tools/dml.js.map +1 -0
- package/dist/tools/dmlDelete.d.ts +51 -0
- package/dist/tools/dmlDelete.js +71 -0
- package/dist/tools/dmlDelete.js.map +1 -0
- package/dist/tools/executeAnonymous.d.ts +63 -0
- package/dist/tools/executeAnonymous.js +77 -0
- package/dist/tools/executeAnonymous.js.map +1 -0
- package/dist/tools/fieldManagement.d.ts +222 -0
- package/dist/tools/fieldManagement.js +234 -0
- package/dist/tools/fieldManagement.js.map +1 -0
- package/dist/tools/fieldPermissions.d.ts +94 -0
- package/dist/tools/fieldPermissions.js +191 -0
- package/dist/tools/fieldPermissions.js.map +1 -0
- package/dist/tools/getDependencies.d.ts +58 -0
- package/dist/tools/getDependencies.js +105 -0
- package/dist/tools/getDependencies.js.map +1 -0
- package/dist/tools/listUserPermissions.d.ts +36 -0
- package/dist/tools/listUserPermissions.js +59 -0
- package/dist/tools/listUserPermissions.js.map +1 -0
- package/dist/tools/metadataDescribe.d.ts +37 -0
- package/dist/tools/metadataDescribe.js +35 -0
- package/dist/tools/metadataDescribe.js.map +1 -0
- package/dist/tools/metadataDiff.d.ts +66 -0
- package/dist/tools/metadataDiff.js +215 -0
- package/dist/tools/metadataDiff.js.map +1 -0
- package/dist/tools/metadataDiffFileDetail.d.ts +44 -0
- package/dist/tools/metadataDiffFileDetail.js +84 -0
- package/dist/tools/metadataDiffFileDetail.js.map +1 -0
- package/dist/tools/metadataDiffFiles.d.ts +37 -0
- package/dist/tools/metadataDiffFiles.js +72 -0
- package/dist/tools/metadataDiffFiles.js.map +1 -0
- package/dist/tools/metadataDiffGeneratePackage.d.ts +73 -0
- package/dist/tools/metadataDiffGeneratePackage.js +122 -0
- package/dist/tools/metadataDiffGeneratePackage.js.map +1 -0
- package/dist/tools/metadataImport.d.ts +63 -0
- package/dist/tools/metadataImport.js +122 -0
- package/dist/tools/metadataImport.js.map +1 -0
- package/dist/tools/metadataJobStatus.d.ts +44 -0
- package/dist/tools/metadataJobStatus.js +101 -0
- package/dist/tools/metadataJobStatus.js.map +1 -0
- package/dist/tools/metadataList.d.ts +44 -0
- package/dist/tools/metadataList.js +49 -0
- package/dist/tools/metadataList.js.map +1 -0
- package/dist/tools/metadataRead.d.ts +47 -0
- package/dist/tools/metadataRead.js +52 -0
- package/dist/tools/metadataRead.js.map +1 -0
- package/dist/tools/metadataTypeSchema.d.ts +44 -0
- package/dist/tools/metadataTypeSchema.js +101 -0
- package/dist/tools/metadataTypeSchema.js.map +1 -0
- package/dist/tools/metadataWsdl.d.ts +19 -0
- package/dist/tools/metadataWsdl.js +1 -0
- package/dist/tools/objectManagement.d.ts +107 -0
- package/dist/tools/objectManagement.js +123 -0
- package/dist/tools/objectManagement.js.map +1 -0
- package/dist/tools/objectPermissions.d.ts +101 -0
- package/dist/tools/objectPermissions.js +157 -0
- package/dist/tools/objectPermissions.js.map +1 -0
- package/dist/tools/objectSchema.d.ts +37 -0
- package/dist/tools/objectSchema.js +66 -0
- package/dist/tools/objectSchema.js.map +1 -0
- package/dist/tools/objectSearch.d.ts +37 -0
- package/dist/tools/objectSearch.js +44 -0
- package/dist/tools/objectSearch.js.map +1 -0
- package/dist/tools/packageStatus.d.ts +24 -0
- package/dist/tools/packageStatus.js +1 -0
- package/dist/tools/permissionSetAssignment.d.ts +39 -0
- package/dist/tools/permissionSetAssignment.js +1 -0
- package/dist/tools/readApexClasses.d.ts +50 -0
- package/dist/tools/readApexClasses.js +83 -0
- package/dist/tools/readApexClasses.js.map +1 -0
- package/dist/tools/readApexTriggers.d.ts +50 -0
- package/dist/tools/readApexTriggers.js +82 -0
- package/dist/tools/readApexTriggers.js.map +1 -0
- package/dist/tools/recordPicker.d.ts +48 -0
- package/dist/tools/recordPicker.js +1 -0
- package/dist/tools/recordQuery.d.ts +68 -0
- package/dist/tools/recordQuery.js +131 -0
- package/dist/tools/recordQuery.js.map +1 -0
- package/dist/tools/retrieveJobStatus.d.ts +51 -0
- package/dist/tools/retrieveJobStatus.js +192 -0
- package/dist/tools/retrieveJobStatus.js.map +1 -0
- package/dist/tools/retrieveMetadata.d.ts +79 -0
- package/dist/tools/retrieveMetadata.js +225 -0
- package/dist/tools/retrieveMetadata.js.map +1 -0
- package/dist/tools/retrievePackage.d.ts +37 -0
- package/dist/tools/retrievePackage.js +1 -0
- package/dist/tools/salesforceLogin.d.ts +36 -0
- package/dist/tools/salesforceLogin.js +75 -0
- package/dist/tools/salesforceLogin.js.map +1 -0
- package/dist/tools/selectOrg.d.ts +25 -0
- package/dist/tools/selectOrg.js +91 -0
- package/dist/tools/selectOrg.js.map +1 -0
- package/dist/tools/toolingQuery.d.ts +37 -0
- package/dist/tools/toolingQuery.js +54 -0
- package/dist/tools/toolingQuery.js.map +1 -0
- package/dist/tools/userPermissions.d.ts +76 -0
- package/dist/tools/userPermissions.js +130 -0
- package/dist/tools/userPermissions.js.map +1 -0
- package/dist/tools/versionMetadataComplete.d.ts +45 -0
- package/dist/tools/versionMetadataComplete.js +1 -0
- package/dist/tools/versionMetadataStart.d.ts +25 -0
- package/dist/tools/versionMetadataStart.js +1 -0
- package/dist/tools/versionMetadataStatus.d.ts +25 -0
- package/dist/tools/versionMetadataStatus.js +1 -0
- package/dist/tools/writeApexClasses.d.ts +64 -0
- package/dist/tools/writeApexClasses.js +79 -0
- package/dist/tools/writeApexClasses.js.map +1 -0
- package/dist/tools/writeApexTriggers.d.ts +71 -0
- package/dist/tools/writeApexTriggers.js +96 -0
- package/dist/tools/writeApexTriggers.js.map +1 -0
- package/dist/types/connection.d.ts +20 -0
- package/dist/types/connection.js +9 -0
- package/dist/types/connection.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/metadata.d.ts +44 -0
- package/dist/types/metadata.js +2 -0
- package/dist/types/metadata.js.map +1 -0
- package/dist/types/salesforce.d.ts +38 -0
- package/dist/types/salesforce.js +2 -0
- package/dist/types/salesforce.js.map +1 -0
- package/dist/utils/apexContainer.d.ts +18 -0
- package/dist/utils/apexContainer.js +79 -0
- package/dist/utils/apexContainer.js.map +1 -0
- package/dist/utils/connection.d.ts +3 -0
- package/dist/utils/connection.js +135 -0
- package/dist/utils/connection.js.map +1 -0
- package/dist/utils/decomposePermissions.d.ts +16 -0
- package/dist/utils/decomposePermissions.js +188 -0
- package/dist/utils/decomposePermissions.js.map +1 -0
- package/dist/utils/dxPathMapper.d.ts +16 -0
- package/dist/utils/dxPathMapper.js +217 -0
- package/dist/utils/dxPathMapper.js.map +1 -0
- package/dist/utils/errors.d.ts +8 -0
- package/dist/utils/errors.js +40 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/oauthWebFlow.d.ts +8 -0
- package/dist/utils/oauthWebFlow.js +172 -0
- package/dist/utils/oauthWebFlow.js.map +1 -0
- package/dist/utils/packageJobs.d.ts +17 -0
- package/dist/utils/packageJobs.js +1 -0
- package/dist/utils/packageXml.d.ts +18 -0
- package/dist/utils/packageXml.js +1 -0
- package/dist/utils/permissionSetResolver.d.ts +14 -0
- package/dist/utils/permissionSetResolver.js +1 -0
- package/dist/utils/preSelectMatcher.d.ts +18 -0
- package/dist/utils/preSelectMatcher.js +1 -0
- package/dist/utils/profileCleanup.d.ts +18 -0
- package/dist/utils/profileCleanup.js +1 -0
- package/dist/utils/retrieveStore.d.ts +12 -0
- package/dist/utils/retrieveStore.js +1 -0
- package/dist/utils/sfCli.d.ts +18 -0
- package/dist/utils/sfCli.js +130 -0
- package/dist/utils/sfCli.js.map +1 -0
- package/dist/utils/tokenBroker.d.ts +13 -0
- package/dist/utils/tokenBroker.js +73 -0
- package/dist/utils/tokenBroker.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Connection } from 'jsforce';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const deployMetadataTool: {
|
|
4
|
+
name: "salesforce_deploy_metadata";
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
sourceDir: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
dryRun: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
testLevel: {
|
|
18
|
+
type: string;
|
|
19
|
+
enum: string[];
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
required: string[];
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
export interface DeployMetadataArgs {
|
|
27
|
+
sourceDir: string;
|
|
28
|
+
dryRun?: boolean;
|
|
29
|
+
testLevel?: 'NoTestRun' | 'RunLocalTests' | 'RunAllTestsInOrg';
|
|
30
|
+
}
|
|
31
|
+
export declare function handleDeployMetadata(conn: Connection, args: DeployMetadataArgs): Promise<{
|
|
32
|
+
content: {
|
|
33
|
+
type: "text";
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
isError: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const deployMetadataSchema: {
|
|
39
|
+
sourceDir: z.ZodString;
|
|
40
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
testLevel: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
NoTestRun: "NoTestRun";
|
|
43
|
+
RunLocalTests: "RunLocalTests";
|
|
44
|
+
RunAllTestsInOrg: "RunAllTestsInOrg";
|
|
45
|
+
}>>;
|
|
46
|
+
};
|
|
47
|
+
export declare const deployMetadataDescriptor: {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
schema: {
|
|
51
|
+
sourceDir: z.ZodString;
|
|
52
|
+
dryRun: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
testLevel: z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
NoTestRun: "NoTestRun";
|
|
55
|
+
RunLocalTests: "RunLocalTests";
|
|
56
|
+
RunAllTestsInOrg: "RunAllTestsInOrg";
|
|
57
|
+
}>>;
|
|
58
|
+
};
|
|
59
|
+
handler: typeof handleDeployMetadata;
|
|
60
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { existsSync, statSync } from 'fs';
|
|
3
|
+
import { toolResponse } from '../utils/index.js';
|
|
4
|
+
import { authenticateOrg, runSfCli, ensureSfCli, createSfdxProjectJson, resolveBaseOutputDir, createJobDir } from '../utils/sfCli.js';
|
|
5
|
+
export const deployMetadataTool = {
|
|
6
|
+
name: 'salesforce_deploy_metadata',
|
|
7
|
+
description: 'Deploy Salesforce metadata from a local DX source directory using the sf CLI (async). ' +
|
|
8
|
+
'Returns a job ID immediately — use salesforce_deploy_job_status to poll progress and get results. ' +
|
|
9
|
+
'Use after retrieving and modifying metadata with salesforce_retrieve_metadata. ' +
|
|
10
|
+
'Requires the Salesforce CLI (sf) to be installed.',
|
|
11
|
+
inputSchema: {
|
|
12
|
+
type: 'object',
|
|
13
|
+
properties: {
|
|
14
|
+
sourceDir: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'Path to the DX source directory to deploy (from a previous retrieve)',
|
|
17
|
+
},
|
|
18
|
+
dryRun: {
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
description: 'If true, performs validation-only deploy without making changes (default: false)',
|
|
21
|
+
},
|
|
22
|
+
testLevel: {
|
|
23
|
+
type: 'string',
|
|
24
|
+
enum: ['NoTestRun', 'RunLocalTests', 'RunAllTestsInOrg'],
|
|
25
|
+
description: 'Test level for the deployment (default: NoTestRun)',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ['sourceDir'],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export async function handleDeployMetadata(conn, args) {
|
|
32
|
+
try {
|
|
33
|
+
await ensureSfCli();
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
return toolResponse(err.message, true);
|
|
37
|
+
}
|
|
38
|
+
const { sourceDir, dryRun = false, testLevel = 'NoTestRun' } = args;
|
|
39
|
+
// Validate sourceDir
|
|
40
|
+
if (!existsSync(sourceDir)) {
|
|
41
|
+
return toolResponse(`Source directory does not exist: ${sourceDir}`, true);
|
|
42
|
+
}
|
|
43
|
+
if (!statSync(sourceDir).isDirectory()) {
|
|
44
|
+
return toolResponse(`Path is not a directory: ${sourceDir}`, true);
|
|
45
|
+
}
|
|
46
|
+
// Authenticate the org
|
|
47
|
+
let alias;
|
|
48
|
+
try {
|
|
49
|
+
alias = await authenticateOrg(conn);
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
return toolResponse(`Authentication failed: ${err.message}`, true);
|
|
53
|
+
}
|
|
54
|
+
// Create a temp project context for sf CLI
|
|
55
|
+
let projectDir;
|
|
56
|
+
try {
|
|
57
|
+
projectDir = createJobDir(resolveBaseOutputDir());
|
|
58
|
+
createSfdxProjectJson(projectDir);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
return toolResponse(`Failed to create project directory: ${err.message}`, true);
|
|
62
|
+
}
|
|
63
|
+
// Build deploy command (async mode)
|
|
64
|
+
const cliArgs = [
|
|
65
|
+
'project', 'deploy', 'start',
|
|
66
|
+
'--source-dir', sourceDir,
|
|
67
|
+
'--target-org', alias,
|
|
68
|
+
'--test-level', testLevel,
|
|
69
|
+
'--async',
|
|
70
|
+
'--json',
|
|
71
|
+
];
|
|
72
|
+
if (dryRun) {
|
|
73
|
+
cliArgs.push('--dry-run');
|
|
74
|
+
}
|
|
75
|
+
const result = await runSfCli(cliArgs, { timeout: 60 * 1000, cwd: projectDir });
|
|
76
|
+
if (result.exitCode !== 0) {
|
|
77
|
+
const msg = result.jsonOutput?.message || result.stderr || 'Unknown error';
|
|
78
|
+
return toolResponse(`Deploy failed (exit ${result.exitCode}): ${msg}`, true);
|
|
79
|
+
}
|
|
80
|
+
const jobId = result.jsonOutput?.result?.id;
|
|
81
|
+
if (!jobId) {
|
|
82
|
+
return toolResponse('Deploy started but no job ID was returned. Raw output: ' + result.stdout, true);
|
|
83
|
+
}
|
|
84
|
+
const summary = [
|
|
85
|
+
`Deploy started (async).`,
|
|
86
|
+
`Job ID: ${jobId}`,
|
|
87
|
+
`Project directory: ${projectDir}`,
|
|
88
|
+
'',
|
|
89
|
+
'Use salesforce_deploy_job_status every 5 seconds with:',
|
|
90
|
+
` jobId: "${jobId}"`,
|
|
91
|
+
` projectDir: "${projectDir}"`,
|
|
92
|
+
].join('\n');
|
|
93
|
+
return toolResponse(summary);
|
|
94
|
+
}
|
|
95
|
+
export const deployMetadataSchema = {
|
|
96
|
+
sourceDir: z.string().describe('Path to the DX source directory to deploy (from a previous retrieve)'),
|
|
97
|
+
dryRun: z.boolean().describe('If true, performs validation-only deploy without making changes (default: false)').optional(),
|
|
98
|
+
testLevel: z.enum(['NoTestRun', 'RunLocalTests', 'RunAllTestsInOrg']).describe('Test level for the deployment (default: NoTestRun)').optional(),
|
|
99
|
+
};
|
|
100
|
+
export const deployMetadataDescriptor = {
|
|
101
|
+
name: 'salesforce_deploy_metadata',
|
|
102
|
+
description: deployMetadataTool.description,
|
|
103
|
+
schema: deployMetadataSchema,
|
|
104
|
+
handler: handleDeployMetadata,
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=deployMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployMetadata.js","sourceRoot":"","sources":["../../src/tools/deployMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MA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EAAE,EAAE,IAAI,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,YAAY,CAAC,yDAAyD,GAAG,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACvG,CAAC;IAED,MAAM,OAAO,GAAG;QACd,yBAAyB;QACzB,WAAW,KAAK,EAAE;QAClB,sBAAsB,UAAU,EAAE;QAClC,EAAE;QACF,wDAAwD;QACxD,aAAa,KAAK,GAAG;QACrB,kBAAkB,UAAU,GAAG;KAChC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAEb,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sEAAsE,CAAC;IACtG,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,kFAAkF,CAAC,CAAC,QAAQ,EAAE;IAC3H,SAAS,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,eAAe,EAAE,kBAAkB,CAAC,CAAC,CAAC,QAAQ,CAAC,oDAAoD,CAAC,CAAC,QAAQ,EAAE;CAChJ,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,IAAI,EAAE,4BAA4B;IAClC,WAAW,EAAE,kBAAkB,CAAC,WAAW;IAC3C,MAAM,EAAE,oBAAoB;IAC5B,OAAO,EAAE,oBAAoB;CAC9B,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Connection } from 'jsforce';
|
|
2
|
+
export declare const deployPackageTool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: "object";
|
|
7
|
+
properties: {
|
|
8
|
+
packageDirectory: {
|
|
9
|
+
type: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
checkOnly: {
|
|
13
|
+
type: string;
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
testLevel: {
|
|
17
|
+
type: string;
|
|
18
|
+
enum: string[];
|
|
19
|
+
description: string;
|
|
20
|
+
};
|
|
21
|
+
runTests: {
|
|
22
|
+
type: string;
|
|
23
|
+
items: {
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
description: string;
|
|
27
|
+
};
|
|
28
|
+
rollbackOnError: {
|
|
29
|
+
type: string;
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
required: string[];
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export interface DeployPackageArgs {
|
|
37
|
+
packageDirectory: string;
|
|
38
|
+
checkOnly?: boolean;
|
|
39
|
+
testLevel?: 'NoTestRun' | 'RunSpecifiedTests' | 'RunLocalTests' | 'RunAllTestsInOrg';
|
|
40
|
+
runTests?: string[];
|
|
41
|
+
rollbackOnError?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare function handleDeployPackage(conn: Connection, args: DeployPackageArgs): Promise<{
|
|
44
|
+
content: {
|
|
45
|
+
type: "text";
|
|
46
|
+
text: string;
|
|
47
|
+
}[];
|
|
48
|
+
isError: boolean;
|
|
49
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir as e,readFile as t,stat as a}from"node:fs/promises";import{join as o,relative as n}from"node:path";import{toolResponse as s}from"../utils/index.js";import{registerJob as r}from"../utils/packageJobs.js";export const deployPackageTool={name:"salesforce_deploy_package",description:"Start an asynchronous metadata deploy from a local directory containing package.xml and metadata files. Returns a job ID immediately — use salesforce_package_status to poll for completion. Defaults to checkOnly (validation-only) for safety. Switch orgs via salesforce_select_org before deploying to a different org.",inputSchema:{type:"object",properties:{packageDirectory:{type:"string",description:"Absolute path to the directory containing package.xml and metadata files."},checkOnly:{type:"boolean",description:"If true (default), performs a validation-only deploy without committing changes. Set to false for an actual deploy."},testLevel:{type:"string",enum:["NoTestRun","RunSpecifiedTests","RunLocalTests","RunAllTestsInOrg"],description:"Test level for the deployment. Default varies by org type."},runTests:{type:"array",items:{type:"string"},description:"Specific test class names to run (only used with testLevel: RunSpecifiedTests)."},rollbackOnError:{type:"boolean",description:"If true (default), rolls back all components on any error."}},required:["packageDirectory"]}};async function i(a,s,r){const l=await e(s,{withFileTypes:!0});for(const e of l){const l=o(s,e.name),c=n(r,l);if(e.isDirectory())await i(a,l,r);else{const e=await t(l);a.file(c,e)}}}export async function handleDeployPackage(e,t){const{packageDirectory:n,checkOnly:l=!0,testLevel:c,runTests:p,rollbackOnError:d=!0}=t;try{const t=o(n,"package.xml");try{await a(t)}catch{return s(`package.xml not found in ${n}. The directory must contain a valid package.xml file.`,!0)}const y=new(0,(await import("jszip")).default);await i(y,n,n);const f=await y.generateAsync({type:"nodebuffer"}),u={checkOnly:l,rollbackOnError:d,singlePackage:!0};c&&(u.testLevel=c),p&&p.length>0&&(u.runTests=p);const m=(await e.metadata.deploy(f,u)).id;return m?(r({type:"deploy",id:m,conn:e,startedAt:Date.now()}),s(`Metadata deploy started.\n\nJob ID: ${m}\nMode: ${l?"Validation only (checkOnly)":"ACTUAL DEPLOY"}\nSource: ${n}\nRollback on error: ${d}\n`+(c?`Test level: ${c}\n`:"")+(p?.length?`Run tests: ${p.join(", ")}\n`:"")+`\nNext step: Use salesforce_package_status with jobId "${m}" to check progress.`)):s("Deploy request did not return a job ID.",!0)}catch(e){return s(`Failed to start metadata deploy: ${e.message}`,!0)}}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Connection } from 'jsforce';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const dmlTool: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
operation: {
|
|
10
|
+
type: string;
|
|
11
|
+
enum: string[];
|
|
12
|
+
description: string;
|
|
13
|
+
};
|
|
14
|
+
objectName: {
|
|
15
|
+
type: string;
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
records: {
|
|
19
|
+
type: string;
|
|
20
|
+
items: {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
externalIdField: {
|
|
26
|
+
type: string;
|
|
27
|
+
description: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
required: string[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
export interface DmlArgs {
|
|
34
|
+
operation: 'insert' | 'update' | 'upsert';
|
|
35
|
+
objectName: string;
|
|
36
|
+
records: Record<string, any>[];
|
|
37
|
+
externalIdField?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function handleDml(conn: Connection, args: DmlArgs): Promise<{
|
|
40
|
+
content: {
|
|
41
|
+
type: "text";
|
|
42
|
+
text: string;
|
|
43
|
+
}[];
|
|
44
|
+
isError: boolean;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const dmlSchema: {
|
|
47
|
+
operation: z.ZodEnum<{
|
|
48
|
+
insert: "insert";
|
|
49
|
+
update: "update";
|
|
50
|
+
upsert: "upsert";
|
|
51
|
+
}>;
|
|
52
|
+
objectName: z.ZodString;
|
|
53
|
+
records: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
54
|
+
externalIdField: z.ZodOptional<z.ZodString>;
|
|
55
|
+
};
|
|
56
|
+
export declare const dmlDescriptor: {
|
|
57
|
+
name: string;
|
|
58
|
+
description: string;
|
|
59
|
+
schema: {
|
|
60
|
+
operation: z.ZodEnum<{
|
|
61
|
+
insert: "insert";
|
|
62
|
+
update: "update";
|
|
63
|
+
upsert: "upsert";
|
|
64
|
+
}>;
|
|
65
|
+
objectName: z.ZodString;
|
|
66
|
+
records: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
67
|
+
externalIdField: z.ZodOptional<z.ZodString>;
|
|
68
|
+
};
|
|
69
|
+
handler: typeof handleDml;
|
|
70
|
+
};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { toolResponse } from '../utils/index.js';
|
|
3
|
+
export const dmlTool = {
|
|
4
|
+
name: 'salesforce_dml',
|
|
5
|
+
description: 'Insert, update, or upsert Salesforce records. For upsert, provide the externalIdField parameter.',
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
operation: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
enum: ['insert', 'update', 'upsert'],
|
|
12
|
+
description: 'The DML operation to perform.',
|
|
13
|
+
},
|
|
14
|
+
objectName: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
description: 'The Salesforce object API name.',
|
|
17
|
+
},
|
|
18
|
+
records: {
|
|
19
|
+
type: 'array',
|
|
20
|
+
items: { type: 'object' },
|
|
21
|
+
description: 'Array of record objects. For update, include "Id" field. For upsert, include the external ID field.',
|
|
22
|
+
},
|
|
23
|
+
externalIdField: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'Required for upsert. The external ID field API name.',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
required: ['operation', 'objectName', 'records'],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
function formatDmlResults(results, operation) {
|
|
32
|
+
const resultArray = Array.isArray(results) ? results : [results];
|
|
33
|
+
let successCount = 0;
|
|
34
|
+
let failureCount = 0;
|
|
35
|
+
const errors = [];
|
|
36
|
+
for (let i = 0; i < resultArray.length; i++) {
|
|
37
|
+
const r = resultArray[i];
|
|
38
|
+
if (r.success) {
|
|
39
|
+
successCount++;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
failureCount++;
|
|
43
|
+
const errList = Array.isArray(r.errors) ? r.errors : [r.errors];
|
|
44
|
+
for (const err of errList) {
|
|
45
|
+
if (err) {
|
|
46
|
+
const fields = err.fields ? ` (fields: ${Array.isArray(err.fields) ? err.fields.join(', ') : err.fields})` : '';
|
|
47
|
+
errors.push(`Record ${i + 1}: [${err.statusCode || 'ERROR'}] ${err.message}${fields}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
let msg = `${operation} results: ${successCount} succeeded, ${failureCount} failed`;
|
|
53
|
+
if (operation === 'insert' || operation === 'upsert') {
|
|
54
|
+
const ids = resultArray.filter(r => r.success && r.id).map(r => r.id);
|
|
55
|
+
if (ids.length > 0)
|
|
56
|
+
msg += `\nCreated/Updated IDs: ${ids.join(', ')}`;
|
|
57
|
+
}
|
|
58
|
+
if (errors.length > 0) {
|
|
59
|
+
msg += `\n\nErrors:\n${errors.join('\n')}`;
|
|
60
|
+
}
|
|
61
|
+
return msg;
|
|
62
|
+
}
|
|
63
|
+
export async function handleDml(conn, args) {
|
|
64
|
+
const { operation, objectName, records, externalIdField } = args;
|
|
65
|
+
if (records.length === 0) {
|
|
66
|
+
return toolResponse('No records provided.', true);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
let results;
|
|
70
|
+
const sobj = conn.sobject(objectName);
|
|
71
|
+
switch (operation) {
|
|
72
|
+
case 'insert':
|
|
73
|
+
results = await sobj.create(records);
|
|
74
|
+
break;
|
|
75
|
+
case 'update':
|
|
76
|
+
results = await sobj.update(records);
|
|
77
|
+
break;
|
|
78
|
+
case 'upsert':
|
|
79
|
+
if (!externalIdField) {
|
|
80
|
+
return toolResponse('Upsert requires "externalIdField" parameter.', true);
|
|
81
|
+
}
|
|
82
|
+
results = await sobj.upsert(records, externalIdField);
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
const msg = formatDmlResults(results, operation);
|
|
86
|
+
const hasFailures = msg.includes('Errors:');
|
|
87
|
+
return toolResponse(msg, hasFailures);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
return toolResponse(`DML ${operation} failed: ${error.message}`, true);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
export const dmlSchema = {
|
|
94
|
+
operation: z.enum(['insert', 'update', 'upsert']).describe('The DML operation to perform.'),
|
|
95
|
+
objectName: z.string().describe('The Salesforce object API name.'),
|
|
96
|
+
records: z.array(z.record(z.string(), z.any())).describe('Array of record objects. For update, include "Id" field. For upsert, include the external ID field.'),
|
|
97
|
+
externalIdField: z.string().describe('Required for upsert. The external ID field API name.').optional(),
|
|
98
|
+
};
|
|
99
|
+
export const dmlDescriptor = {
|
|
100
|
+
name: 'salesforce_dml',
|
|
101
|
+
description: dmlTool.description,
|
|
102
|
+
schema: dmlSchema,
|
|
103
|
+
handler: handleDml,
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=dml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dml.js","sourceRoot":"","sources":["../../src/tools/dml.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,kGAAkG;IAC/G,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;gBACpC,WAAW,EAAE,+BAA+B;aAC7C;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,iCAAiC;aAC/C;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,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sDAAsD,CAAC,CAAC,QAAQ,EAAE;CACxG,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,OAAO,CAAC,WAAW;IAChC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;CACnB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Connection } from 'jsforce';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const dmlDeleteTool: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
annotations: {
|
|
7
|
+
destructiveHint: boolean;
|
|
8
|
+
readOnlyHint: boolean;
|
|
9
|
+
};
|
|
10
|
+
inputSchema: {
|
|
11
|
+
type: "object";
|
|
12
|
+
properties: {
|
|
13
|
+
objectName: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
recordIds: {
|
|
18
|
+
type: string;
|
|
19
|
+
items: {
|
|
20
|
+
type: string;
|
|
21
|
+
};
|
|
22
|
+
description: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
required: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export interface DmlDeleteArgs {
|
|
29
|
+
objectName: string;
|
|
30
|
+
recordIds: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare function handleDmlDelete(conn: Connection, args: DmlDeleteArgs): Promise<{
|
|
33
|
+
content: {
|
|
34
|
+
type: "text";
|
|
35
|
+
text: string;
|
|
36
|
+
}[];
|
|
37
|
+
isError: boolean;
|
|
38
|
+
}>;
|
|
39
|
+
export declare const dmlDeleteSchema: {
|
|
40
|
+
objectName: z.ZodString;
|
|
41
|
+
recordIds: z.ZodArray<z.ZodString>;
|
|
42
|
+
};
|
|
43
|
+
export declare const dmlDeleteDescriptor: {
|
|
44
|
+
name: string;
|
|
45
|
+
description: string;
|
|
46
|
+
schema: {
|
|
47
|
+
objectName: z.ZodString;
|
|
48
|
+
recordIds: z.ZodArray<z.ZodString>;
|
|
49
|
+
};
|
|
50
|
+
handler: typeof handleDmlDelete;
|
|
51
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import { toolResponse } from '../utils/index.js';
|
|
3
|
+
export const dmlDeleteTool = {
|
|
4
|
+
name: 'salesforce_delete_records',
|
|
5
|
+
description: 'Delete Salesforce records by their IDs. This is a destructive operation.',
|
|
6
|
+
annotations: { destructiveHint: true, readOnlyHint: false },
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
objectName: {
|
|
11
|
+
type: 'string',
|
|
12
|
+
description: 'The Salesforce object API name.',
|
|
13
|
+
},
|
|
14
|
+
recordIds: {
|
|
15
|
+
type: 'array',
|
|
16
|
+
items: { type: 'string' },
|
|
17
|
+
description: 'Array of record IDs to delete.',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
required: ['objectName', 'recordIds'],
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
export async function handleDmlDelete(conn, args) {
|
|
24
|
+
const { objectName, recordIds } = args;
|
|
25
|
+
if (recordIds.length === 0) {
|
|
26
|
+
return toolResponse('No record IDs provided.', true);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const results = await conn.sobject(objectName).destroy(recordIds);
|
|
30
|
+
const resultArray = Array.isArray(results) ? results : [results];
|
|
31
|
+
let successCount = 0;
|
|
32
|
+
let failureCount = 0;
|
|
33
|
+
const errors = [];
|
|
34
|
+
for (let i = 0; i < resultArray.length; i++) {
|
|
35
|
+
const r = resultArray[i];
|
|
36
|
+
if (r.success) {
|
|
37
|
+
successCount++;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
failureCount++;
|
|
41
|
+
const errList = Array.isArray(r.errors) ? r.errors : [r.errors];
|
|
42
|
+
for (const err of errList) {
|
|
43
|
+
if (err) {
|
|
44
|
+
const fields = err.fields ? ` (fields: ${Array.isArray(err.fields) ? err.fields.join(', ') : err.fields})` : '';
|
|
45
|
+
errors.push(`Record ${i + 1}: [${err.statusCode || 'ERROR'}] ${err.message}${fields}`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let msg = `delete results: ${successCount} succeeded, ${failureCount} failed`;
|
|
51
|
+
if (errors.length > 0) {
|
|
52
|
+
msg += `\n\nErrors:\n${errors.join('\n')}`;
|
|
53
|
+
}
|
|
54
|
+
const hasFailures = errors.length > 0;
|
|
55
|
+
return toolResponse(msg, hasFailures);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
return toolResponse(`DML delete failed: ${error.message}`, true);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export const dmlDeleteSchema = {
|
|
62
|
+
objectName: z.string().describe('The Salesforce object API name.'),
|
|
63
|
+
recordIds: z.array(z.string()).describe('Array of record IDs to delete.'),
|
|
64
|
+
};
|
|
65
|
+
export const dmlDeleteDescriptor = {
|
|
66
|
+
name: 'salesforce_delete_records',
|
|
67
|
+
description: dmlDeleteTool.description,
|
|
68
|
+
schema: dmlDeleteSchema,
|
|
69
|
+
handler: handleDmlDelete,
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=dmlDelete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dmlDelete.js","sourceRoot":"","sources":["../../src/tools/dmlDelete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,0EAA0E;IACvF,WAAW,EAAE,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE;IAC3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C;IAClE,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,gCAAgC,CAAC;CAC1E,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,IAAI,EAAE,2BAA2B;IACjC,WAAW,EAAE,aAAa,CAAC,WAAW;IACtC,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,eAAe;CACzB,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Connection } from 'jsforce';
|
|
2
|
+
import { z } from 'zod/v4';
|
|
3
|
+
export declare const executeAnonymousTool: {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: "object";
|
|
8
|
+
properties: {
|
|
9
|
+
apexCode: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
logLevel: {
|
|
14
|
+
type: string;
|
|
15
|
+
enum: string[];
|
|
16
|
+
description: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
required: string[];
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export interface ExecuteAnonymousArgs {
|
|
23
|
+
apexCode: string;
|
|
24
|
+
logLevel?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function handleExecuteAnonymous(conn: Connection, args: ExecuteAnonymousArgs): Promise<{
|
|
27
|
+
content: {
|
|
28
|
+
type: "text";
|
|
29
|
+
text: string;
|
|
30
|
+
}[];
|
|
31
|
+
isError: boolean;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const executeAnonymousSchema: {
|
|
34
|
+
apexCode: z.ZodString;
|
|
35
|
+
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
36
|
+
ERROR: "ERROR";
|
|
37
|
+
NONE: "NONE";
|
|
38
|
+
WARN: "WARN";
|
|
39
|
+
INFO: "INFO";
|
|
40
|
+
DEBUG: "DEBUG";
|
|
41
|
+
FINE: "FINE";
|
|
42
|
+
FINER: "FINER";
|
|
43
|
+
FINEST: "FINEST";
|
|
44
|
+
}>>;
|
|
45
|
+
};
|
|
46
|
+
export declare const executeAnonymousDescriptor: {
|
|
47
|
+
name: string;
|
|
48
|
+
description: string;
|
|
49
|
+
schema: {
|
|
50
|
+
apexCode: z.ZodString;
|
|
51
|
+
logLevel: z.ZodOptional<z.ZodEnum<{
|
|
52
|
+
ERROR: "ERROR";
|
|
53
|
+
NONE: "NONE";
|
|
54
|
+
WARN: "WARN";
|
|
55
|
+
INFO: "INFO";
|
|
56
|
+
DEBUG: "DEBUG";
|
|
57
|
+
FINE: "FINE";
|
|
58
|
+
FINER: "FINER";
|
|
59
|
+
FINEST: "FINEST";
|
|
60
|
+
}>>;
|
|
61
|
+
};
|
|
62
|
+
handler: typeof handleExecuteAnonymous;
|
|
63
|
+
};
|