@simplysf/simply-apex 1.0.0
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/lib/commands/simply/apex/execute.d.ts +23 -0
- package/lib/commands/simply/apex/execute.js +73 -0
- package/lib/commands/simply/apex/execute.js.map +1 -0
- package/lib/commands/simply/apex/logs/purge.d.ts +18 -0
- package/lib/commands/simply/apex/logs/purge.js +89 -0
- package/lib/commands/simply/apex/logs/purge.js.map +1 -0
- package/lib/commands/simply/apex/trace/setup.d.ts +18 -0
- package/lib/commands/simply/apex/trace/setup.js +102 -0
- package/lib/commands/simply/apex/trace/setup.js.map +1 -0
- package/lib/commands/simply/apex/trace/silence.d.ts +19 -0
- package/lib/commands/simply/apex/trace/silence.js +152 -0
- package/lib/commands/simply/apex/trace/silence.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +17 -0
- package/lib/index.js.map +1 -0
- package/lib/schemas/silence/classesToSilence.d.ts +5 -0
- package/lib/schemas/silence/classesToSilence.js +20 -0
- package/lib/schemas/silence/classesToSilence.js.map +1 -0
- package/messages/simply.apex.execute.md +35 -0
- package/messages/simply.apex.logs.purge.md +45 -0
- package/messages/simply.apex.trace.setup.md +43 -0
- package/messages/simply.apex.trace.silence.md +69 -0
- package/package.json +209 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type ApexExecuteResult = {
|
|
3
|
+
success: boolean;
|
|
4
|
+
compiled: boolean;
|
|
5
|
+
compileProblem: string;
|
|
6
|
+
exceptionMessage: string;
|
|
7
|
+
exceptionStackTrace: string;
|
|
8
|
+
line: number;
|
|
9
|
+
column: number;
|
|
10
|
+
logs?: string;
|
|
11
|
+
};
|
|
12
|
+
export default class ApexExecute extends SfCommand<ApexExecuteResult> {
|
|
13
|
+
static readonly summary: string;
|
|
14
|
+
static readonly description: string;
|
|
15
|
+
static readonly examples: string[];
|
|
16
|
+
static readonly flags: {
|
|
17
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
};
|
|
22
|
+
run(): Promise<ApexExecuteResult>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import path from 'node:path';
|
|
17
|
+
import { ExecuteService } from '@salesforce/apex-node';
|
|
18
|
+
import { Messages } from '@salesforce/core';
|
|
19
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
20
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
21
|
+
const messages = Messages.loadMessages('@simplysf/simply-apex', 'simply.apex.execute');
|
|
22
|
+
export default class ApexExecute extends SfCommand {
|
|
23
|
+
static summary = messages.getMessage('summary');
|
|
24
|
+
static description = messages.getMessage('description');
|
|
25
|
+
static examples = messages.getMessages('examples');
|
|
26
|
+
static flags = {
|
|
27
|
+
...SfCommand.baseFlags,
|
|
28
|
+
'api-version': Flags.orgApiVersion(),
|
|
29
|
+
file: Flags.file({
|
|
30
|
+
summary: messages.getMessage('flags.file.summary'),
|
|
31
|
+
description: messages.getMessage('flags.file.description'),
|
|
32
|
+
char: 'f',
|
|
33
|
+
exists: true,
|
|
34
|
+
required: true,
|
|
35
|
+
}),
|
|
36
|
+
'target-org': Flags.requiredOrg(),
|
|
37
|
+
};
|
|
38
|
+
async run() {
|
|
39
|
+
const { flags } = await this.parse(ApexExecute);
|
|
40
|
+
const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
|
|
41
|
+
if (!targetOrgConnection) {
|
|
42
|
+
throw messages.createError('error.targetOrgConnectionFailed');
|
|
43
|
+
}
|
|
44
|
+
this.spinner.start(`Executing ${path.parse(flags.file).name}`);
|
|
45
|
+
const executeService = new ExecuteService(targetOrgConnection);
|
|
46
|
+
const response = await executeService.executeAnonymous({ apexFilePath: flags.file });
|
|
47
|
+
const diagnostic = response.diagnostic?.[0];
|
|
48
|
+
const result = {
|
|
49
|
+
success: response.success,
|
|
50
|
+
compiled: response.compiled,
|
|
51
|
+
compileProblem: diagnostic?.compileProblem ?? '',
|
|
52
|
+
exceptionMessage: diagnostic?.exceptionMessage ?? '',
|
|
53
|
+
exceptionStackTrace: diagnostic?.exceptionStackTrace ?? '',
|
|
54
|
+
line: diagnostic?.lineNumber ?? -1,
|
|
55
|
+
column: diagnostic?.columnNumber ?? -1,
|
|
56
|
+
logs: response.logs,
|
|
57
|
+
};
|
|
58
|
+
if (!response.compiled) {
|
|
59
|
+
this.spinner.stop(messages.getMessage('info.failed'));
|
|
60
|
+
throw messages.createError('error.compileFailed', [result.line, result.column, result.compileProblem]);
|
|
61
|
+
}
|
|
62
|
+
if (!response.success) {
|
|
63
|
+
this.spinner.stop(messages.getMessage('info.failed'));
|
|
64
|
+
throw messages.createError('error.executeFailed', [result.exceptionMessage]);
|
|
65
|
+
}
|
|
66
|
+
this.spinner.stop();
|
|
67
|
+
if (result.logs) {
|
|
68
|
+
this.log(result.logs);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=execute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execute.js","sourceRoot":"","sources":["../../../../src/commands/simply/apex/execute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,uBAAuB,EAAE,qBAAqB,CAAC,CAAC;AAavF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,SAA4B;IAC5D,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,GAAG,SAAS,CAAC,SAAS;QACtB,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE;QACpC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;YACf,OAAO,EAAE,QAAQ,CAAC,UAAU,CAAC,oBAAoB,CAAC;YAClD,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,wBAA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AQ,CAAC,IAAI;SACpB,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;YACtD,MAAM,QAAQ,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC;QACzG,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC;YACtD,MAAM,QAAQ,CAAC,WAAW,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAC/E,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YAChB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type ApexLogsPurgeResult = {
|
|
3
|
+
Id: string;
|
|
4
|
+
Success: boolean;
|
|
5
|
+
Error?: string;
|
|
6
|
+
};
|
|
7
|
+
export default class ApexLogsPurge extends SfCommand<ApexLogsPurgeResult[]> {
|
|
8
|
+
static readonly summary: string;
|
|
9
|
+
static readonly description: string;
|
|
10
|
+
static readonly examples: string[];
|
|
11
|
+
static readonly flags: {
|
|
12
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
where: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<ApexLogsPurgeResult[]>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
19
|
+
const messages = Messages.loadMessages('@simplysf/simply-apex', 'simply.apex.logs.purge');
|
|
20
|
+
const CHUNK_SIZE = 200;
|
|
21
|
+
export default class ApexLogsPurge extends SfCommand {
|
|
22
|
+
static summary = messages.getMessage('summary');
|
|
23
|
+
static description = messages.getMessage('description');
|
|
24
|
+
static examples = messages.getMessages('examples');
|
|
25
|
+
static flags = {
|
|
26
|
+
...SfCommand.baseFlags,
|
|
27
|
+
'api-version': Flags.orgApiVersion(),
|
|
28
|
+
'target-org': Flags.requiredOrg(),
|
|
29
|
+
where: Flags.string({
|
|
30
|
+
summary: messages.getMessage('flags.where.summary'),
|
|
31
|
+
description: messages.getMessage('flags.where.description'),
|
|
32
|
+
char: 'w',
|
|
33
|
+
}),
|
|
34
|
+
};
|
|
35
|
+
async run() {
|
|
36
|
+
const { flags } = await this.parse(ApexLogsPurge);
|
|
37
|
+
const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
|
|
38
|
+
if (!targetOrgConnection) {
|
|
39
|
+
throw messages.createError('error.targetOrgConnectionFailed');
|
|
40
|
+
}
|
|
41
|
+
let query = 'SELECT Id FROM ApexLog';
|
|
42
|
+
if (flags.where) {
|
|
43
|
+
query += ` WHERE ${flags.where}`;
|
|
44
|
+
}
|
|
45
|
+
this.spinner.start(messages.getMessage('info.queryingLogs'));
|
|
46
|
+
const queryResult = await targetOrgConnection.tooling.query(query);
|
|
47
|
+
this.spinner.stop();
|
|
48
|
+
if (queryResult.records.length === 0) {
|
|
49
|
+
this.info(messages.getMessage('info.noLogsToPurge'));
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
const logIds = queryResult.records.map((record) => record.Id);
|
|
53
|
+
const results = [];
|
|
54
|
+
this.spinner.start(messages.getMessage('info.purgingLogs', [logIds.length]));
|
|
55
|
+
for (let i = 0; i < logIds.length; i += CHUNK_SIZE) {
|
|
56
|
+
const chunk = logIds.slice(i, i + CHUNK_SIZE);
|
|
57
|
+
this.spinner.status = `${Math.min(i + chunk.length, logIds.length)}/${logIds.length}`;
|
|
58
|
+
// eslint-disable-next-line no-await-in-loop
|
|
59
|
+
const deleteResults = await targetOrgConnection.tooling.delete('ApexLog', chunk);
|
|
60
|
+
const deleteResultsArray = Array.isArray(deleteResults) ? deleteResults : [deleteResults];
|
|
61
|
+
deleteResultsArray.forEach((deleteResult) => {
|
|
62
|
+
results.push({
|
|
63
|
+
Id: deleteResult.id ?? 'unknown',
|
|
64
|
+
Success: deleteResult.success,
|
|
65
|
+
Error: deleteResult.success ? undefined : deleteResult.errors.map((e) => e.message).join(', '),
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
this.spinner.stop();
|
|
70
|
+
const successCount = results.filter((result) => result.Success).length;
|
|
71
|
+
const failureCount = results.length - successCount;
|
|
72
|
+
if (failureCount > 0) {
|
|
73
|
+
this.warn(messages.getMessage('warning.someFailed', [successCount, failureCount]));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
this.info(messages.getMessage('info.allPurged', [successCount]));
|
|
77
|
+
}
|
|
78
|
+
this.table({
|
|
79
|
+
data: results,
|
|
80
|
+
columns: [
|
|
81
|
+
{ key: 'Id', name: 'ID' },
|
|
82
|
+
{ key: 'Success', name: 'SUCCESS' },
|
|
83
|
+
{ key: 'Error', name: 'ERROR' },
|
|
84
|
+
],
|
|
85
|
+
});
|
|
86
|
+
return results;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=purge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purge.js","sourceRoot":"","sources":["../../../../../src/commands/simply/apex/logs/purge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,uBAAuB,EAAE,wBAAwB,CAAC,CAAC;AAQ1F,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAgC;IAClE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,C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SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBAC/F,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;QACvE,MAAM,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC;QAEnD,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,oBAAoB,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;QACrF,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE;gBACzB,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;gBACnC,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;aAChC;SACF,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type ApexTraceSetupResult = {
|
|
3
|
+
userId: string;
|
|
4
|
+
debugLevelId: string;
|
|
5
|
+
traceFlagId: string;
|
|
6
|
+
expirationDate: string;
|
|
7
|
+
};
|
|
8
|
+
export default class ApexTraceSetup extends SfCommand<ApexTraceSetupResult> {
|
|
9
|
+
static readonly summary: string;
|
|
10
|
+
static readonly description: string;
|
|
11
|
+
static readonly examples: string[];
|
|
12
|
+
static readonly flags: {
|
|
13
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
};
|
|
17
|
+
run(): Promise<ApexTraceSetupResult>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { Messages } from '@salesforce/core';
|
|
17
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
18
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
19
|
+
const messages = Messages.loadMessages('@simplysf/simply-apex', 'simply.apex.trace.setup');
|
|
20
|
+
const DEBUG_LEVEL_NAME = 'ReplayDebuggerLevels';
|
|
21
|
+
const TRACE_DURATION_MS = 24 * 60 * 60 * 1000;
|
|
22
|
+
export default class ApexTraceSetup extends SfCommand {
|
|
23
|
+
static summary = messages.getMessage('summary');
|
|
24
|
+
static description = messages.getMessage('description');
|
|
25
|
+
static examples = messages.getMessages('examples');
|
|
26
|
+
static flags = {
|
|
27
|
+
...SfCommand.baseFlags,
|
|
28
|
+
'api-version': Flags.orgApiVersion(),
|
|
29
|
+
'target-org': Flags.requiredOrg(),
|
|
30
|
+
};
|
|
31
|
+
async run() {
|
|
32
|
+
const { flags } = await this.parse(ApexTraceSetup);
|
|
33
|
+
const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
|
|
34
|
+
if (!targetOrgConnection) {
|
|
35
|
+
throw messages.createError('error.targetOrgConnectionFailed');
|
|
36
|
+
}
|
|
37
|
+
this.spinner.start(messages.getMessage('info.findingUser'));
|
|
38
|
+
const username = targetOrgConnection.getUsername() ?? '';
|
|
39
|
+
const userQueryResult = await targetOrgConnection.query(`SELECT Id FROM User WHERE Username = '${username}'`);
|
|
40
|
+
if (userQueryResult.records.length === 0) {
|
|
41
|
+
throw messages.createError('error.userNotFound', [username]);
|
|
42
|
+
}
|
|
43
|
+
const userId = userQueryResult.records[0].Id;
|
|
44
|
+
this.spinner.stop();
|
|
45
|
+
this.spinner.start(messages.getMessage('info.checkingDebugLevel'));
|
|
46
|
+
const debugLevelResult = await targetOrgConnection.tooling.query(`SELECT Id FROM DebugLevel WHERE DeveloperName = '${DEBUG_LEVEL_NAME}'`);
|
|
47
|
+
let debugLevelId;
|
|
48
|
+
if (debugLevelResult.records.length > 0) {
|
|
49
|
+
debugLevelId = debugLevelResult.records[0].Id;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const createResult = await targetOrgConnection.tooling.sobject('DebugLevel').create({
|
|
53
|
+
DeveloperName: DEBUG_LEVEL_NAME,
|
|
54
|
+
MasterLabel: DEBUG_LEVEL_NAME,
|
|
55
|
+
ApexCode: 'FINEST',
|
|
56
|
+
Visualforce: 'FINER',
|
|
57
|
+
});
|
|
58
|
+
if (!createResult.success) {
|
|
59
|
+
throw messages.createError('error.debugLevelCreateFailed', [
|
|
60
|
+
createResult.errors.map((e) => e.message).join(', '),
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
debugLevelId = createResult.id;
|
|
64
|
+
}
|
|
65
|
+
this.spinner.stop();
|
|
66
|
+
this.spinner.start(messages.getMessage('info.configuringTraceFlag'));
|
|
67
|
+
const traceFlagResult = await targetOrgConnection.tooling.query(`SELECT Id FROM TraceFlag WHERE LogType = 'DEVELOPER_LOG' AND TracedEntityId = '${userId}'`);
|
|
68
|
+
const now = new Date();
|
|
69
|
+
const expiration = new Date(now.getTime() + TRACE_DURATION_MS);
|
|
70
|
+
const startDate = now.toISOString();
|
|
71
|
+
const expirationDate = expiration.toISOString();
|
|
72
|
+
let traceFlagId;
|
|
73
|
+
if (traceFlagResult.records.length > 0) {
|
|
74
|
+
traceFlagId = traceFlagResult.records[0].Id;
|
|
75
|
+
await targetOrgConnection.tooling.sobject('TraceFlag').update({
|
|
76
|
+
Id: traceFlagId,
|
|
77
|
+
DebugLevelId: debugLevelId,
|
|
78
|
+
StartDate: startDate,
|
|
79
|
+
ExpirationDate: expirationDate,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
const createResult = await targetOrgConnection.tooling.sobject('TraceFlag').create({
|
|
84
|
+
TracedEntityId: userId,
|
|
85
|
+
LogType: 'DEVELOPER_LOG',
|
|
86
|
+
DebugLevelId: debugLevelId,
|
|
87
|
+
StartDate: startDate,
|
|
88
|
+
ExpirationDate: expirationDate,
|
|
89
|
+
});
|
|
90
|
+
if (!createResult.success) {
|
|
91
|
+
throw messages.createError('error.traceFlagCreateFailed', [
|
|
92
|
+
createResult.errors.map((e) => e.message).join(', '),
|
|
93
|
+
]);
|
|
94
|
+
}
|
|
95
|
+
traceFlagId = createResult.id;
|
|
96
|
+
}
|
|
97
|
+
this.spinner.stop();
|
|
98
|
+
this.info(messages.getMessage('info.complete', [expirationDate]));
|
|
99
|
+
return { userId, debugLevelId, traceFlagId, expirationDate };
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../../../src/commands/simply/apex/trace/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAE/D,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,uBAAuB,EAAE,yBAAyB,CAAC,CAAC;AAE3F,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAChD,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAS9C,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,SAA+B;IAClE,MAAM,CAAU,OAAO,GAAG,QAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;IACzD,MAAM,CAAU,WAAW,GAAG,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACjE,MAAM,CAAU,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAE5D,MAAM,CAAU,KAAK,GAAG;QAC7B,GAAG,SAAS,CAAC,SAAS;QACtB,aAAa,EAAE,KAAK,CAAC,aAAa,EAAE;QACpC,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE;KAClC,CAAC;IAEK,KAAK,CAAC,GAAG;QACd,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;Q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,YAAY,EAAE,YAAY;gBAC1B,SAAS,EAAE,SAAS;gBACpB,cAAc,EAAE,cAAc;aAC/B,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,MAAM,YAAY,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC;gBACjF,cAAc,EAAE,MAAM;gBACtB,OAAO,EAAE,eAAe;gBACxB,YAAY,EAAE,YAAY;gBAC1B,SAAS,EAAE,SAAS;gBACpB,cAAc,EAAE,cAAc;aAC/B,CAAC,CAAC;YAEH,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC1B,MAAM,QAAQ,CAAC,WAAW,CAAC,6BAA6B,EAAE;oBACxD,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;iBACrD,CAAC,CAAC;YACL,CAAC;YAED,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC;QAChC,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QAElE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;IAC/D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type ApexTraceSilenceResult = {
|
|
3
|
+
class: string;
|
|
4
|
+
classId: string;
|
|
5
|
+
traceFlagId: string;
|
|
6
|
+
};
|
|
7
|
+
export default class ApexTraceSilence extends SfCommand<ApexTraceSilenceResult[]> {
|
|
8
|
+
static readonly summary: string;
|
|
9
|
+
static readonly description: string;
|
|
10
|
+
static readonly examples: string[];
|
|
11
|
+
static readonly flags: {
|
|
12
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
classes: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
'classes-file': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
'flags-dir': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
};
|
|
18
|
+
run(): Promise<ApexTraceSilenceResult[]>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import fs from 'node:fs';
|
|
17
|
+
import { Messages } from '@salesforce/core';
|
|
18
|
+
import { SfCommand, Flags } from '@salesforce/sf-plugins-core';
|
|
19
|
+
import { ClassesToSilenceSchema } from '../../../../schemas/silence/classesToSilence.js';
|
|
20
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
21
|
+
const messages = Messages.loadMessages('@simplysf/simply-apex', 'simply.apex.trace.silence');
|
|
22
|
+
const DEBUG_LEVEL_NAME = 'Silence';
|
|
23
|
+
const TRACE_DURATION_MS = 24 * 60 * 60 * 1000;
|
|
24
|
+
function resolveClasses(classesFlag, classesFileFlag) {
|
|
25
|
+
if (classesFlag) {
|
|
26
|
+
return classesFlag
|
|
27
|
+
.split(',')
|
|
28
|
+
.map((className) => className.trim())
|
|
29
|
+
.filter(Boolean);
|
|
30
|
+
}
|
|
31
|
+
if (classesFileFlag) {
|
|
32
|
+
const fileContent = fs.readFileSync(classesFileFlag, 'utf-8');
|
|
33
|
+
const parsed = ClassesToSilenceSchema.safeParse(JSON.parse(fileContent));
|
|
34
|
+
if (!parsed.success) {
|
|
35
|
+
throw messages.createError('error.invalidClassesFile', [parsed.error.message]);
|
|
36
|
+
}
|
|
37
|
+
return parsed.data.classes;
|
|
38
|
+
}
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
export default class ApexTraceSilence extends SfCommand {
|
|
42
|
+
static summary = messages.getMessage('summary');
|
|
43
|
+
static description = messages.getMessage('description');
|
|
44
|
+
static examples = messages.getMessages('examples');
|
|
45
|
+
static flags = {
|
|
46
|
+
...SfCommand.baseFlags,
|
|
47
|
+
'api-version': Flags.orgApiVersion(),
|
|
48
|
+
classes: Flags.string({
|
|
49
|
+
summary: messages.getMessage('flags.classes.summary'),
|
|
50
|
+
description: messages.getMessage('flags.classes.description'),
|
|
51
|
+
char: 'c',
|
|
52
|
+
exclusive: ['classes-file'],
|
|
53
|
+
}),
|
|
54
|
+
'classes-file': Flags.file({
|
|
55
|
+
summary: messages.getMessage('flags.classes-file.summary'),
|
|
56
|
+
description: messages.getMessage('flags.classes-file.description'),
|
|
57
|
+
exists: true,
|
|
58
|
+
exclusive: ['classes'],
|
|
59
|
+
}),
|
|
60
|
+
'target-org': Flags.requiredOrg(),
|
|
61
|
+
};
|
|
62
|
+
async run() {
|
|
63
|
+
const { flags } = await this.parse(ApexTraceSilence);
|
|
64
|
+
const targetOrgConnection = flags['target-org']?.getConnection(flags['api-version']);
|
|
65
|
+
if (!targetOrgConnection) {
|
|
66
|
+
throw messages.createError('error.targetOrgConnectionFailed');
|
|
67
|
+
}
|
|
68
|
+
const classes = resolveClasses(flags.classes, flags['classes-file']);
|
|
69
|
+
if (classes.length === 0) {
|
|
70
|
+
throw messages.createError('error.noClassesSpecified');
|
|
71
|
+
}
|
|
72
|
+
this.spinner.start(messages.getMessage('info.checkingDebugLevel'));
|
|
73
|
+
const debugLevelResult = await targetOrgConnection.tooling.query(`SELECT Id FROM DebugLevel WHERE DeveloperName = '${DEBUG_LEVEL_NAME}'`);
|
|
74
|
+
let debugLevelId;
|
|
75
|
+
if (debugLevelResult.records.length > 0) {
|
|
76
|
+
debugLevelId = debugLevelResult.records[0].Id;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
const createResult = await targetOrgConnection.tooling.sobject('DebugLevel').create({
|
|
80
|
+
DeveloperName: DEBUG_LEVEL_NAME,
|
|
81
|
+
MasterLabel: DEBUG_LEVEL_NAME,
|
|
82
|
+
ApexCode: 'NONE',
|
|
83
|
+
ApexProfiling: 'NONE',
|
|
84
|
+
Callout: 'NONE',
|
|
85
|
+
Database: 'NONE',
|
|
86
|
+
System: 'NONE',
|
|
87
|
+
Validation: 'NONE',
|
|
88
|
+
Visualforce: 'NONE',
|
|
89
|
+
Workflow: 'NONE',
|
|
90
|
+
});
|
|
91
|
+
if (!createResult.success) {
|
|
92
|
+
throw messages.createError('error.debugLevelCreateFailed', [
|
|
93
|
+
createResult.errors.map((e) => e.message).join(', '),
|
|
94
|
+
]);
|
|
95
|
+
}
|
|
96
|
+
debugLevelId = createResult.id;
|
|
97
|
+
}
|
|
98
|
+
this.spinner.stop();
|
|
99
|
+
this.spinner.start(messages.getMessage('info.findingClasses'));
|
|
100
|
+
const classesClause = classes.map((className) => `'${className}'`).join(',');
|
|
101
|
+
const classResult = await targetOrgConnection.tooling.query(`SELECT Id, Name FROM ApexClass WHERE Name IN (${classesClause})`);
|
|
102
|
+
this.spinner.stop();
|
|
103
|
+
if (classResult.records.length === 0) {
|
|
104
|
+
this.warn(messages.getMessage('warning.noClassesFound'));
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
const foundNames = new Set(classResult.records.map((record) => record.Name));
|
|
108
|
+
const missingNames = classes.filter((className) => !foundNames.has(className));
|
|
109
|
+
if (missingNames.length > 0) {
|
|
110
|
+
this.warn(messages.getMessage('warning.someClassesNotFound', [missingNames.join(', ')]));
|
|
111
|
+
}
|
|
112
|
+
const now = new Date();
|
|
113
|
+
const expiration = new Date(now.getTime() + TRACE_DURATION_MS);
|
|
114
|
+
const startDate = now.toISOString();
|
|
115
|
+
const expirationDate = expiration.toISOString();
|
|
116
|
+
const results = [];
|
|
117
|
+
this.spinner.start(messages.getMessage('info.creatingTraceFlags'));
|
|
118
|
+
for (const classRecord of classResult.records) {
|
|
119
|
+
// eslint-disable-next-line no-await-in-loop
|
|
120
|
+
const createResult = await targetOrgConnection.tooling.sobject('TraceFlag').create({
|
|
121
|
+
StartDate: startDate,
|
|
122
|
+
ExpirationDate: expirationDate,
|
|
123
|
+
DebugLevelId: debugLevelId,
|
|
124
|
+
TracedEntityId: classRecord.Id,
|
|
125
|
+
LogType: 'CLASS_TRACING',
|
|
126
|
+
});
|
|
127
|
+
if (!createResult.success) {
|
|
128
|
+
this.warn(messages.getMessage('warning.traceFlagCreateFailed', [
|
|
129
|
+
classRecord.Name,
|
|
130
|
+
createResult.errors.map((e) => e.message).join(', '),
|
|
131
|
+
]));
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
results.push({
|
|
135
|
+
class: classRecord.Name,
|
|
136
|
+
classId: classRecord.Id,
|
|
137
|
+
traceFlagId: createResult.id,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
this.spinner.stop();
|
|
141
|
+
this.table({
|
|
142
|
+
data: results,
|
|
143
|
+
columns: [
|
|
144
|
+
{ key: 'class', name: 'CLASS' },
|
|
145
|
+
{ key: 'classId', name: 'CLASS ID' },
|
|
146
|
+
{ key: 'traceFlagId', name: 'TRACE FLAG ID' },
|
|
147
|
+
],
|
|
148
|
+
});
|
|
149
|
+
return results;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=silence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"silence.js","sourceRoot":"","sources":["../../../../../src/commands/simply/apex/trace/silence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AAEzF,QAAQ,CAAC,kCAAkC,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC7D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,uBAAuB,EAAE,2BAA2B,CAAC,CAAC;AAE7F,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,iBAAiB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAQ9C,SAAS,cAAc,CAAC,WAA+B,EAAE,eAAmC;IAC1F,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,WAAW;aACf,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;aACpC,MAAM,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;IAED,IAAI,eAAe,EAAE,CAAC;QACpB,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,sBAAsB,CAAC,SAAS,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CAAC,CACH,CAAC;gBACF,SAAS;YACX,CAAC;YAED,OAAO,CAAC,IAAI,CAAC;gBACX,KAAK,EAAE,WAAW,CAAC,IAAI;gBACvB,OAAO,EAAE,WAAW,CAAC,EAAE;gBACvB,WAAW,EAAE,YAAY,CAAC,EAAE;aAC7B,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAEpB,IAAI,CAAC,KAAK,CAAC;YACT,IAAI,EAAE,OAAO;YACb,OAAO,EAAE;gBACP,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;gBAC/B,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE;gBACpC,EAAE,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,eAAe,EAAE;aAC9C;SACF,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export default {};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, Clay Chipps; Copyright (c) 2026 Salesforce, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
export const ClassesToSilenceSchema = z.object({
|
|
18
|
+
classes: z.array(z.string()).min(1),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=classesToSilence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"classesToSilence.js","sourceRoot":"","sources":["../../../src/schemas/silence/classesToSilence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7C,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Execute anonymous Apex code.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Executes an anonymous block of Apex code from a local .apex file against a target org and reports the compile and execution results, including any debug logs produced.
|
|
8
|
+
|
|
9
|
+
# flags.file.summary
|
|
10
|
+
|
|
11
|
+
Path to Apex file
|
|
12
|
+
|
|
13
|
+
# flags.file.description
|
|
14
|
+
|
|
15
|
+
The path to the local .apex file containing the anonymous Apex code to execute.
|
|
16
|
+
|
|
17
|
+
# examples
|
|
18
|
+
|
|
19
|
+
- <%= config.bin %> <%= command.id %> --target-org myOrg --file scripts/apex/data-fix.apex
|
|
20
|
+
|
|
21
|
+
# error.targetOrgConnectionFailed
|
|
22
|
+
|
|
23
|
+
Unable to establish connection to the org.
|
|
24
|
+
|
|
25
|
+
# error.compileFailed
|
|
26
|
+
|
|
27
|
+
Compilation failed at line %s, column %s with the error: %s
|
|
28
|
+
|
|
29
|
+
# error.executeFailed
|
|
30
|
+
|
|
31
|
+
Execution failed with the error: %s
|
|
32
|
+
|
|
33
|
+
# info.failed
|
|
34
|
+
|
|
35
|
+
Failed
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Purge Apex debug logs.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Deletes ApexLog records from the target org. By default all logs are purged; use --where to scope the deletion to a subset of logs.
|
|
8
|
+
|
|
9
|
+
# flags.where.summary
|
|
10
|
+
|
|
11
|
+
SOQL WHERE clause
|
|
12
|
+
|
|
13
|
+
# flags.where.description
|
|
14
|
+
|
|
15
|
+
A WHERE clause used to filter which ApexLog records are purged (e.g. "Status = 'Success'").
|
|
16
|
+
|
|
17
|
+
# examples
|
|
18
|
+
|
|
19
|
+
- <%= config.bin %> <%= command.id %> --target-org myOrg
|
|
20
|
+
|
|
21
|
+
- <%= config.bin %> <%= command.id %> --target-org myOrg --where "Status = 'Success'"
|
|
22
|
+
|
|
23
|
+
# error.targetOrgConnectionFailed
|
|
24
|
+
|
|
25
|
+
Unable to establish connection to the org.
|
|
26
|
+
|
|
27
|
+
# info.queryingLogs
|
|
28
|
+
|
|
29
|
+
Querying Apex logs...
|
|
30
|
+
|
|
31
|
+
# info.noLogsToPurge
|
|
32
|
+
|
|
33
|
+
No logs to purge.
|
|
34
|
+
|
|
35
|
+
# info.purgingLogs
|
|
36
|
+
|
|
37
|
+
Purging %s Apex logs...
|
|
38
|
+
|
|
39
|
+
# info.allPurged
|
|
40
|
+
|
|
41
|
+
Successfully purged %s Apex logs.
|
|
42
|
+
|
|
43
|
+
# warning.someFailed
|
|
44
|
+
|
|
45
|
+
Successfully purged %s logs, but failed to delete %s logs. See the Error column for details.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Configure a debug log trace flag for the current user.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Creates or updates a 24-hour DEVELOPER_LOG trace flag for the user running the command, using a FINEST/FINER debug level suitable for the Apex Replay Debugger.
|
|
8
|
+
|
|
9
|
+
# examples
|
|
10
|
+
|
|
11
|
+
- <%= config.bin %> <%= command.id %> --target-org myOrg
|
|
12
|
+
|
|
13
|
+
# error.targetOrgConnectionFailed
|
|
14
|
+
|
|
15
|
+
Unable to establish connection to the org.
|
|
16
|
+
|
|
17
|
+
# error.userNotFound
|
|
18
|
+
|
|
19
|
+
User not found for username: %s
|
|
20
|
+
|
|
21
|
+
# error.debugLevelCreateFailed
|
|
22
|
+
|
|
23
|
+
Failed to create the debug level: %s
|
|
24
|
+
|
|
25
|
+
# error.traceFlagCreateFailed
|
|
26
|
+
|
|
27
|
+
Failed to create the trace flag: %s
|
|
28
|
+
|
|
29
|
+
# info.findingUser
|
|
30
|
+
|
|
31
|
+
Finding current user...
|
|
32
|
+
|
|
33
|
+
# info.checkingDebugLevel
|
|
34
|
+
|
|
35
|
+
Checking debug level...
|
|
36
|
+
|
|
37
|
+
# info.configuringTraceFlag
|
|
38
|
+
|
|
39
|
+
Configuring trace flag...
|
|
40
|
+
|
|
41
|
+
# info.complete
|
|
42
|
+
|
|
43
|
+
Trace flag configured. Debug logs will be captured until %s.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Silence debug logs for specific Apex classes.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Creates a 24-hour CLASS_TRACING trace flag with a fully suppressed (NONE) debug level for each specified Apex class, preventing those classes from generating debug log output.
|
|
8
|
+
|
|
9
|
+
# flags.classes.summary
|
|
10
|
+
|
|
11
|
+
Comma-separated Apex class names
|
|
12
|
+
|
|
13
|
+
# flags.classes.description
|
|
14
|
+
|
|
15
|
+
A comma-separated list of Apex class names to silence.
|
|
16
|
+
|
|
17
|
+
# flags.classes-file.summary
|
|
18
|
+
|
|
19
|
+
Path to a JSON file listing classes to silence
|
|
20
|
+
|
|
21
|
+
# flags.classes-file.description
|
|
22
|
+
|
|
23
|
+
The path to a JSON file with the shape { "classes": ["ClassOne", "ClassTwo"] } listing the Apex class names to silence.
|
|
24
|
+
|
|
25
|
+
# examples
|
|
26
|
+
|
|
27
|
+
- <%= config.bin %> <%= command.id %> --target-org myOrg --classes NoisyClass,ChattyTrigger
|
|
28
|
+
|
|
29
|
+
- <%= config.bin %> <%= command.id %> --target-org myOrg --classes-file classesToSilence.json
|
|
30
|
+
|
|
31
|
+
# error.targetOrgConnectionFailed
|
|
32
|
+
|
|
33
|
+
Unable to establish connection to the org.
|
|
34
|
+
|
|
35
|
+
# error.noClassesSpecified
|
|
36
|
+
|
|
37
|
+
No Apex classes specified to silence. Use --classes or --classes-file.
|
|
38
|
+
|
|
39
|
+
# error.invalidClassesFile
|
|
40
|
+
|
|
41
|
+
The classes file is invalid: %s
|
|
42
|
+
|
|
43
|
+
# error.debugLevelCreateFailed
|
|
44
|
+
|
|
45
|
+
Failed to create the debug level: %s
|
|
46
|
+
|
|
47
|
+
# info.checkingDebugLevel
|
|
48
|
+
|
|
49
|
+
Checking debug level...
|
|
50
|
+
|
|
51
|
+
# info.findingClasses
|
|
52
|
+
|
|
53
|
+
Finding Apex classes...
|
|
54
|
+
|
|
55
|
+
# info.creatingTraceFlags
|
|
56
|
+
|
|
57
|
+
Creating trace flags...
|
|
58
|
+
|
|
59
|
+
# warning.noClassesFound
|
|
60
|
+
|
|
61
|
+
No Apex classes found matching the provided names.
|
|
62
|
+
|
|
63
|
+
# warning.someClassesNotFound
|
|
64
|
+
|
|
65
|
+
The following classes were not found and were skipped: %s
|
|
66
|
+
|
|
67
|
+
# warning.traceFlagCreateFailed
|
|
68
|
+
|
|
69
|
+
Failed to create a trace flag for class %s: %s
|
package/package.json
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@simplysf/simply-apex",
|
|
3
|
+
"description": "Utilities for working with Apex",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"author": "@ClayChipps",
|
|
6
|
+
"homepage": "https://github.com/SimplySF/simply",
|
|
7
|
+
"bugs": "https://github.com/SimplySF/simply/issues",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/SimplySF/simply",
|
|
11
|
+
"directory": "packages/simply-apex"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22.0.0"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"/lib",
|
|
18
|
+
"/messages",
|
|
19
|
+
"/npm-shrinkwrap.json",
|
|
20
|
+
"/oclif.lock",
|
|
21
|
+
"/oclif.manifest.json"
|
|
22
|
+
],
|
|
23
|
+
"keywords": [
|
|
24
|
+
"force",
|
|
25
|
+
"salesforce",
|
|
26
|
+
"sfdx",
|
|
27
|
+
"salesforcedx",
|
|
28
|
+
"sfdx-plugin",
|
|
29
|
+
"sf-plugin",
|
|
30
|
+
"sf"
|
|
31
|
+
],
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"exports": "./lib/index.js",
|
|
34
|
+
"type": "module",
|
|
35
|
+
"oclif": {
|
|
36
|
+
"bin": "sf",
|
|
37
|
+
"commands": "./lib/commands",
|
|
38
|
+
"devPlugins": [
|
|
39
|
+
"@oclif/plugin-command-snapshot",
|
|
40
|
+
"@oclif/plugin-help",
|
|
41
|
+
"@salesforce/plugin-command-reference"
|
|
42
|
+
],
|
|
43
|
+
"flexibleTaxonomy": true,
|
|
44
|
+
"plugins": [],
|
|
45
|
+
"repositoryPrefix": "<%- repo %>/blob/@simplysf/simply-apex@<%- version %>/packages/simply-apex/<%- commandPath %>",
|
|
46
|
+
"topics": {
|
|
47
|
+
"simply": {
|
|
48
|
+
"description": "Commands for simplifying Salesforce",
|
|
49
|
+
"subtopics": {
|
|
50
|
+
"apex": {
|
|
51
|
+
"description": "Commands for working with Apex",
|
|
52
|
+
"subtopics": {
|
|
53
|
+
"logs": {
|
|
54
|
+
"description": "Commands for working with Apex logs"
|
|
55
|
+
},
|
|
56
|
+
"trace": {
|
|
57
|
+
"description": "Commands for working with Apex trace flags"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"topicSeparator": " "
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@oclif/core": "^4.11.2",
|
|
68
|
+
"@salesforce/apex-node": "^8.4.39",
|
|
69
|
+
"@salesforce/core": "^8.30.0",
|
|
70
|
+
"@salesforce/kit": "^3.2.6",
|
|
71
|
+
"@salesforce/sf-plugins-core": "^12.2.16",
|
|
72
|
+
"zod": "^4.1.12"
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@oclif/plugin-command-snapshot": "^5.3.19",
|
|
76
|
+
"@salesforce/plugin-command-reference": "^3.1.99"
|
|
77
|
+
},
|
|
78
|
+
"publishConfig": {
|
|
79
|
+
"access": "public"
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "wireit",
|
|
83
|
+
"compile": "wireit",
|
|
84
|
+
"fix-license": "eslint src test --fix --rule \"header/header: [2]\"",
|
|
85
|
+
"format": "wireit",
|
|
86
|
+
"link-check": "wireit",
|
|
87
|
+
"lint": "wireit",
|
|
88
|
+
"readme": "oclif readme --no-aliases",
|
|
89
|
+
"test": "wireit",
|
|
90
|
+
"test:nuts": "nyc mocha \"**/*.nut.ts\" --slow 4500 --timeout 1200000 --parallel --jobs 5",
|
|
91
|
+
"test:only": "wireit",
|
|
92
|
+
"test:watch": "mocha --watch \"./test/**/*.test.ts\""
|
|
93
|
+
},
|
|
94
|
+
"wireit": {
|
|
95
|
+
"build": {
|
|
96
|
+
"dependencies": [
|
|
97
|
+
"compile",
|
|
98
|
+
"lint"
|
|
99
|
+
]
|
|
100
|
+
},
|
|
101
|
+
"compile": {
|
|
102
|
+
"command": "tsc -p . --pretty --incremental",
|
|
103
|
+
"files": [
|
|
104
|
+
"src/**/*.ts",
|
|
105
|
+
"**/tsconfig.json",
|
|
106
|
+
"messages/**"
|
|
107
|
+
],
|
|
108
|
+
"output": [
|
|
109
|
+
"lib/**",
|
|
110
|
+
"*.tsbuildinfo"
|
|
111
|
+
],
|
|
112
|
+
"clean": "if-file-deleted"
|
|
113
|
+
},
|
|
114
|
+
"format": {
|
|
115
|
+
"command": "prettier --write \"+(src|test|schemas)/**/*.+(ts|js|json)|command-snapshot.json\"",
|
|
116
|
+
"files": [
|
|
117
|
+
"src/**/*.ts",
|
|
118
|
+
"test/**/*.ts",
|
|
119
|
+
"schemas/**/*.json",
|
|
120
|
+
"command-snapshot.json",
|
|
121
|
+
".prettier*"
|
|
122
|
+
],
|
|
123
|
+
"output": []
|
|
124
|
+
},
|
|
125
|
+
"lint": {
|
|
126
|
+
"command": "eslint src test --color --cache --cache-location .eslintcache",
|
|
127
|
+
"files": [
|
|
128
|
+
"src/**/*.ts",
|
|
129
|
+
"test/**/*.ts",
|
|
130
|
+
"messages/**",
|
|
131
|
+
"**/.eslint*",
|
|
132
|
+
"**/tsconfig.json"
|
|
133
|
+
],
|
|
134
|
+
"output": []
|
|
135
|
+
},
|
|
136
|
+
"test": {
|
|
137
|
+
"dependencies": [
|
|
138
|
+
"test:compile",
|
|
139
|
+
"test:only",
|
|
140
|
+
"test:command-reference",
|
|
141
|
+
"test:deprecation-policy",
|
|
142
|
+
"lint",
|
|
143
|
+
"test:json-schema",
|
|
144
|
+
"link-check"
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
"test:command-reference": {
|
|
148
|
+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" commandreference:generate --erroronwarnings",
|
|
149
|
+
"files": [
|
|
150
|
+
"src/**/*.ts",
|
|
151
|
+
"messages/**",
|
|
152
|
+
"package.json"
|
|
153
|
+
],
|
|
154
|
+
"output": [
|
|
155
|
+
"tmp/root"
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"test:deprecation-policy": {
|
|
159
|
+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" snapshot:compare",
|
|
160
|
+
"files": [
|
|
161
|
+
"src/**/*.ts"
|
|
162
|
+
],
|
|
163
|
+
"output": [],
|
|
164
|
+
"dependencies": [
|
|
165
|
+
"compile"
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
"test:json-schema": {
|
|
169
|
+
"command": "node --loader ts-node/esm --no-warnings=ExperimentalWarning \"./bin/dev.js\" schema:compare",
|
|
170
|
+
"files": [
|
|
171
|
+
"src/**/*.ts",
|
|
172
|
+
"schemas"
|
|
173
|
+
],
|
|
174
|
+
"output": []
|
|
175
|
+
},
|
|
176
|
+
"test:compile": {
|
|
177
|
+
"command": "tsc -p \"./test\" --pretty",
|
|
178
|
+
"files": [
|
|
179
|
+
"test/**/*.ts",
|
|
180
|
+
"**/tsconfig.json"
|
|
181
|
+
],
|
|
182
|
+
"output": []
|
|
183
|
+
},
|
|
184
|
+
"test:only": {
|
|
185
|
+
"command": "nyc mocha \"test/**/*.test.ts\"",
|
|
186
|
+
"env": {
|
|
187
|
+
"FORCE_COLOR": "2"
|
|
188
|
+
},
|
|
189
|
+
"files": [
|
|
190
|
+
"test/**/*.ts",
|
|
191
|
+
"src/**/*.ts",
|
|
192
|
+
"**/tsconfig.json",
|
|
193
|
+
".mocha*",
|
|
194
|
+
"!*.nut.ts",
|
|
195
|
+
".nycrc"
|
|
196
|
+
],
|
|
197
|
+
"output": []
|
|
198
|
+
},
|
|
199
|
+
"link-check": {
|
|
200
|
+
"command": "node -e \"process.exit(process.env.CI ? 0 : 1)\" || linkinator \"**/*.md\" --skip \"CHANGELOG.md|node_modules|test/|confluence.internal.salesforce.com|my.salesforce.com|localhost|blob/.*/lib/|%s\" --markdown --retry --directory-listing --verbosity error",
|
|
201
|
+
"files": [
|
|
202
|
+
"./*.md",
|
|
203
|
+
"./!(CHANGELOG).md",
|
|
204
|
+
"messages/**/*.md"
|
|
205
|
+
],
|
|
206
|
+
"output": []
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|