@salesforce/plugin-org 5.9.74 → 5.9.75
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
CHANGED
|
@@ -99,6 +99,7 @@ the [SandboxNuts](https://github.com/salesforcecli/plugin-org/actions/workflows/
|
|
|
99
99
|
|
|
100
100
|
<!-- commands -->
|
|
101
101
|
|
|
102
|
+
- [`sf org create agent-user`](#sf-org-create-agent-user)
|
|
102
103
|
- [`sf org create sandbox`](#sf-org-create-sandbox)
|
|
103
104
|
- [`sf org create scratch`](#sf-org-create-scratch)
|
|
104
105
|
- [`sf org delete sandbox`](#sf-org-delete-sandbox)
|
|
@@ -116,6 +117,84 @@ the [SandboxNuts](https://github.com/salesforcecli/plugin-org/actions/workflows/
|
|
|
116
117
|
- [`sf org resume sandbox`](#sf-org-resume-sandbox)
|
|
117
118
|
- [`sf org resume scratch`](#sf-org-resume-scratch)
|
|
118
119
|
|
|
120
|
+
## `sf org create agent-user`
|
|
121
|
+
|
|
122
|
+
Create the default Salesforce user that is used to run an agent.
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
USAGE
|
|
126
|
+
$ sf org create agent-user -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--base-username <value>]
|
|
127
|
+
[--first-name <value>] [--last-name <value>]
|
|
128
|
+
|
|
129
|
+
FLAGS
|
|
130
|
+
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
|
|
131
|
+
configuration variable is already set.
|
|
132
|
+
--api-version=<value> Override the api version used for api requests made by this command
|
|
133
|
+
--base-username=<value> Base username pattern. A unique ID is appended to ensure global uniqueness of the
|
|
134
|
+
usename.
|
|
135
|
+
--first-name=<value> [default: Agent] First name for the agent user.
|
|
136
|
+
--last-name=<value> [default: User] Last name for the agent user.
|
|
137
|
+
|
|
138
|
+
GLOBAL FLAGS
|
|
139
|
+
--flags-dir=<value> Import flag values from a directory.
|
|
140
|
+
--json Format output as json.
|
|
141
|
+
|
|
142
|
+
DESCRIPTION
|
|
143
|
+
Create the default Salesforce user that is used to run an agent.
|
|
144
|
+
|
|
145
|
+
You specify this user in the agent's Agent Script file using the "default_agent_user" parameter in the "config" block.
|
|
146
|
+
|
|
147
|
+
By default, this command:
|
|
148
|
+
|
|
149
|
+
- Generates a user called "Agent User" with a globally unique username. Use flags to change these default names.
|
|
150
|
+
- Sets the user's email to the new username.
|
|
151
|
+
- Assigns the user the "Einstein Agent User" profile.
|
|
152
|
+
- Assigns the user these required permission sets: AgentforceServiceAgentBase, AgentforceServiceAgentUser,
|
|
153
|
+
EinsteinGPTPromptTemplateUser
|
|
154
|
+
- Checks that the user licenses required by the profile and permission sets are available in your org.
|
|
155
|
+
|
|
156
|
+
The generated user doesn't have a password. You can’t log into Salesforce using the agent user's username. Only
|
|
157
|
+
Salesforce users with admin permissions can view or edit an agent user in Setup.
|
|
158
|
+
|
|
159
|
+
To assign additional permission sets or licenses after the user was created, use the "org assign permset" or "org
|
|
160
|
+
assign
|
|
161
|
+
permsetlicense" commands.
|
|
162
|
+
|
|
163
|
+
When the command completes, it displays a summary of what it did, including the new agent user's username and ID, the
|
|
164
|
+
available licenses associated with the Einstein Agent User profile, and the profile and permission sets assigned to
|
|
165
|
+
the
|
|
166
|
+
agent user.
|
|
167
|
+
|
|
168
|
+
EXAMPLES
|
|
169
|
+
Create an agent user with an auto-generated username; create the user in the org with alias "myorg":
|
|
170
|
+
|
|
171
|
+
$ sf org create agent-user --target-org myorg
|
|
172
|
+
|
|
173
|
+
Create an agent user by specifying a base username pattern; to make the username unique, the command appends a unique
|
|
174
|
+
identifier:
|
|
175
|
+
$ sf org create agent-user --base-username service-agent@corp.com --target-org myorg
|
|
176
|
+
|
|
177
|
+
Create an agent user with an auto-generated username but the custom name "Service Agent"; create the user in your
|
|
178
|
+
default org:
|
|
179
|
+
$ sf org create agent-user --first-name Service --last-name Agent
|
|
180
|
+
|
|
181
|
+
FLAG DESCRIPTIONS
|
|
182
|
+
--base-username=<value> Base username pattern. A unique ID is appended to ensure global uniqueness of the usename.
|
|
183
|
+
|
|
184
|
+
Specify a base username in email format, such as "service-agent@corp.com". The command then appends a 12-character
|
|
185
|
+
globally unique ID (GUID) to the name before the "@" sign, which ensures that the username is globally unique across
|
|
186
|
+
all
|
|
187
|
+
Salesforce orgs and sandboxes.
|
|
188
|
+
|
|
189
|
+
For example, if you specify "service-agent@corp.com", then the username might be
|
|
190
|
+
"service-agent.a1b2c3d4e5f6@corp.com".
|
|
191
|
+
|
|
192
|
+
If not specified, the command auto-generates the username using this pattern:
|
|
193
|
+
"agent.user.<GUID>@your-org-domain.com".
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
_See code: [src/commands/org/create/agent-user.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/create/agent-user.ts)_
|
|
197
|
+
|
|
119
198
|
## `sf org create sandbox`
|
|
120
199
|
|
|
121
200
|
Create a sandbox org.
|
|
@@ -248,7 +327,7 @@ FLAG DESCRIPTIONS
|
|
|
248
327
|
You can specify either --source-sandbox-name or --source-id when cloning an existing sandbox, but not both.
|
|
249
328
|
```
|
|
250
329
|
|
|
251
|
-
_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
330
|
+
_See code: [src/commands/org/create/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/create/sandbox.ts)_
|
|
252
331
|
|
|
253
332
|
## `sf org create scratch`
|
|
254
333
|
|
|
@@ -430,7 +509,7 @@ FLAG DESCRIPTIONS
|
|
|
430
509
|
Omit this flag to have Salesforce generate a unique username for your org.
|
|
431
510
|
```
|
|
432
511
|
|
|
433
|
-
_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
512
|
+
_See code: [src/commands/org/create/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/create/scratch.ts)_
|
|
434
513
|
|
|
435
514
|
## `sf org delete sandbox`
|
|
436
515
|
|
|
@@ -476,7 +555,7 @@ EXAMPLES
|
|
|
476
555
|
$ sf org delete sandbox --target-org my-sandbox --no-prompt
|
|
477
556
|
```
|
|
478
557
|
|
|
479
|
-
_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
558
|
+
_See code: [src/commands/org/delete/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/delete/sandbox.ts)_
|
|
480
559
|
|
|
481
560
|
## `sf org delete scratch`
|
|
482
561
|
|
|
@@ -520,7 +599,7 @@ EXAMPLES
|
|
|
520
599
|
$ sf org delete scratch --target-org my-scratch-org --no-prompt
|
|
521
600
|
```
|
|
522
601
|
|
|
523
|
-
_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
602
|
+
_See code: [src/commands/org/delete/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/delete/scratch.ts)_
|
|
524
603
|
|
|
525
604
|
## `sf org disable tracking`
|
|
526
605
|
|
|
@@ -559,7 +638,7 @@ EXAMPLES
|
|
|
559
638
|
$ sf org disable tracking
|
|
560
639
|
```
|
|
561
640
|
|
|
562
|
-
_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
641
|
+
_See code: [src/commands/org/disable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/disable/tracking.ts)_
|
|
563
642
|
|
|
564
643
|
## `sf org display`
|
|
565
644
|
|
|
@@ -604,7 +683,7 @@ EXAMPLES
|
|
|
604
683
|
$ sf org display --target-org TestOrg1 --verbose
|
|
605
684
|
```
|
|
606
685
|
|
|
607
|
-
_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
686
|
+
_See code: [src/commands/org/display.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/display.ts)_
|
|
608
687
|
|
|
609
688
|
## `sf org enable tracking`
|
|
610
689
|
|
|
@@ -646,7 +725,7 @@ EXAMPLES
|
|
|
646
725
|
$ sf org enable tracking
|
|
647
726
|
```
|
|
648
727
|
|
|
649
|
-
_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
728
|
+
_See code: [src/commands/org/enable/tracking.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/enable/tracking.ts)_
|
|
650
729
|
|
|
651
730
|
## `sf org list`
|
|
652
731
|
|
|
@@ -685,7 +764,7 @@ EXAMPLES
|
|
|
685
764
|
$ sf org list --clean
|
|
686
765
|
```
|
|
687
766
|
|
|
688
|
-
_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
767
|
+
_See code: [src/commands/org/list.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/list.ts)_
|
|
689
768
|
|
|
690
769
|
## `sf org list metadata`
|
|
691
770
|
|
|
@@ -752,7 +831,7 @@ FLAG DESCRIPTIONS
|
|
|
752
831
|
Examples of metadata types that use folders are Dashboard, Document, EmailTemplate, and Report.
|
|
753
832
|
```
|
|
754
833
|
|
|
755
|
-
_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
834
|
+
_See code: [src/commands/org/list/metadata.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/list/metadata.ts)_
|
|
756
835
|
|
|
757
836
|
## `sf org list metadata-types`
|
|
758
837
|
|
|
@@ -807,7 +886,7 @@ FLAG DESCRIPTIONS
|
|
|
807
886
|
Override the api version used for api requests made by this command
|
|
808
887
|
```
|
|
809
888
|
|
|
810
|
-
_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
889
|
+
_See code: [src/commands/org/list/metadata-types.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/list/metadata-types.ts)_
|
|
811
890
|
|
|
812
891
|
## `sf org open`
|
|
813
892
|
|
|
@@ -883,7 +962,7 @@ EXAMPLES
|
|
|
883
962
|
$ sf org open --source-file force-app/main/default/bots/Coral_Cloud_Agent/Coral_Cloud_Agent.bot-meta.xml
|
|
884
963
|
```
|
|
885
964
|
|
|
886
|
-
_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
965
|
+
_See code: [src/commands/org/open.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/open.ts)_
|
|
887
966
|
|
|
888
967
|
## `sf org open agent`
|
|
889
968
|
|
|
@@ -934,7 +1013,7 @@ EXAMPLES
|
|
|
934
1013
|
$ sf org open agent --target-org MyTestOrg1 --browser firefox --api-name Coral_Cloud_Agent
|
|
935
1014
|
```
|
|
936
1015
|
|
|
937
|
-
_See code: [src/commands/org/open/agent.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
1016
|
+
_See code: [src/commands/org/open/agent.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/open/agent.ts)_
|
|
938
1017
|
|
|
939
1018
|
## `sf org open authoring-bundle`
|
|
940
1019
|
|
|
@@ -980,7 +1059,7 @@ EXAMPLES
|
|
|
980
1059
|
$ sf org open authoring-bundle --target-org MyTestOrg1 --browser firefox
|
|
981
1060
|
```
|
|
982
1061
|
|
|
983
|
-
_See code: [src/commands/org/open/authoring-bundle.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
1062
|
+
_See code: [src/commands/org/open/authoring-bundle.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/open/authoring-bundle.ts)_
|
|
984
1063
|
|
|
985
1064
|
## `sf org refresh sandbox`
|
|
986
1065
|
|
|
@@ -1083,7 +1162,7 @@ FLAG DESCRIPTIONS
|
|
|
1083
1162
|
You can specify either --source-sandbox-name or --source-id when refreshing an existing sandbox, but not both.
|
|
1084
1163
|
```
|
|
1085
1164
|
|
|
1086
|
-
_See code: [src/commands/org/refresh/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
1165
|
+
_See code: [src/commands/org/refresh/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/refresh/sandbox.ts)_
|
|
1087
1166
|
|
|
1088
1167
|
## `sf org resume sandbox`
|
|
1089
1168
|
|
|
@@ -1146,7 +1225,7 @@ FLAG DESCRIPTIONS
|
|
|
1146
1225
|
returns the job ID. To resume checking the sandbox creation, rerun this command.
|
|
1147
1226
|
```
|
|
1148
1227
|
|
|
1149
|
-
_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
1228
|
+
_See code: [src/commands/org/resume/sandbox.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/resume/sandbox.ts)_
|
|
1150
1229
|
|
|
1151
1230
|
## `sf org resume scratch`
|
|
1152
1231
|
|
|
@@ -1199,6 +1278,6 @@ FLAG DESCRIPTIONS
|
|
|
1199
1278
|
returns the job ID. To resume checking the scratch creation, rerun this command.
|
|
1200
1279
|
```
|
|
1201
1280
|
|
|
1202
|
-
_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.
|
|
1281
|
+
_See code: [src/commands/org/resume/scratch.ts](https://github.com/salesforcecli/plugin-org/blob/5.9.75/src/commands/org/resume/scratch.ts)_
|
|
1203
1282
|
|
|
1204
1283
|
<!-- commandsstop -->
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { SfCommand } from '@salesforce/sf-plugins-core';
|
|
2
|
+
export type AgentUserCreateResponse = {
|
|
3
|
+
userId: string;
|
|
4
|
+
username: string;
|
|
5
|
+
profileId: string;
|
|
6
|
+
permissionSetsAssigned: string[];
|
|
7
|
+
permissionSetErrors: Array<{
|
|
8
|
+
permissionSet: string;
|
|
9
|
+
error: string;
|
|
10
|
+
}>;
|
|
11
|
+
};
|
|
12
|
+
export default class OrgCreateAgentUser extends SfCommand<AgentUserCreateResponse> {
|
|
13
|
+
static readonly summary: string;
|
|
14
|
+
static readonly description: string;
|
|
15
|
+
static readonly examples: string[];
|
|
16
|
+
static readonly flags: {
|
|
17
|
+
'target-org': import("@oclif/core/interfaces").OptionFlag<import("@salesforce/core").Org, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
'api-version': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
'base-username': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
20
|
+
'first-name': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
21
|
+
'last-name': import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
};
|
|
23
|
+
run(): Promise<AgentUserCreateResponse>;
|
|
24
|
+
private generateUsername;
|
|
25
|
+
private checkAgentUserLicenses;
|
|
26
|
+
private getProfileId;
|
|
27
|
+
private createAgentUser;
|
|
28
|
+
private assignPermissionSets;
|
|
29
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 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 { randomUUID } from 'node:crypto';
|
|
17
|
+
import { Messages, SfError } from '@salesforce/core';
|
|
18
|
+
import { Flags, SfCommand } from '@salesforce/sf-plugins-core';
|
|
19
|
+
Messages.importMessagesDirectoryFromMetaUrl(import.meta.url);
|
|
20
|
+
const messages = Messages.loadMessages('@salesforce/plugin-org', 'create_agent_user');
|
|
21
|
+
export default class OrgCreateAgentUser extends SfCommand {
|
|
22
|
+
static summary = messages.getMessage('summary');
|
|
23
|
+
static description = messages.getMessage('description');
|
|
24
|
+
static examples = messages.getMessages('examples');
|
|
25
|
+
static flags = {
|
|
26
|
+
'target-org': Flags.requiredOrg(),
|
|
27
|
+
'api-version': Flags.orgApiVersion(),
|
|
28
|
+
'base-username': Flags.string({
|
|
29
|
+
summary: messages.getMessage('flags.base-username.summary'),
|
|
30
|
+
description: messages.getMessage('flags.base-username.description'),
|
|
31
|
+
}),
|
|
32
|
+
'first-name': Flags.string({
|
|
33
|
+
summary: messages.getMessage('flags.first-name.summary'),
|
|
34
|
+
default: 'Agent',
|
|
35
|
+
}),
|
|
36
|
+
'last-name': Flags.string({
|
|
37
|
+
summary: messages.getMessage('flags.last-name.summary'),
|
|
38
|
+
default: 'User',
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
async run() {
|
|
42
|
+
const { flags } = await this.parse(OrgCreateAgentUser);
|
|
43
|
+
const connection = flags['target-org'].getConnection(flags['api-version']);
|
|
44
|
+
// Generate username
|
|
45
|
+
const username = this.generateUsername(connection, flags['base-username']);
|
|
46
|
+
this.log(`Generated username: ${username}`);
|
|
47
|
+
// Always check for available agent user licenses
|
|
48
|
+
await this.checkAgentUserLicenses(connection);
|
|
49
|
+
// Always use Einstein Agent User profile
|
|
50
|
+
const profileId = await this.getProfileId(connection);
|
|
51
|
+
this.log('Using profile: Einstein Agent User');
|
|
52
|
+
// Create the agent user
|
|
53
|
+
const userId = await this.createAgentUser(connection, username, profileId, {
|
|
54
|
+
firstName: flags['first-name'],
|
|
55
|
+
lastName: flags['last-name'],
|
|
56
|
+
});
|
|
57
|
+
this.log(`Agent user created successfully: ${userId}`);
|
|
58
|
+
// Always assign the required permission sets
|
|
59
|
+
const requiredPermissionSets = [
|
|
60
|
+
'AgentforceServiceAgentBase',
|
|
61
|
+
'AgentforceServiceAgentUser',
|
|
62
|
+
'EinsteinGPTPromptTemplateUser',
|
|
63
|
+
];
|
|
64
|
+
// Assign permission sets
|
|
65
|
+
const { assigned, errors } = await this.assignPermissionSets(connection, userId, requiredPermissionSets);
|
|
66
|
+
// Fail if any required permission sets could not be assigned
|
|
67
|
+
if (errors.length > 0) {
|
|
68
|
+
const errorDetails = errors.map(({ permissionSet, error }) => ` - ${permissionSet}: ${error}`).join('\n');
|
|
69
|
+
throw new SfError(`Agent user created but failed to assign required permission sets:\n${errorDetails}\n\nThe user may not function correctly without these permission sets.`, 'PermissionSetAssignmentError', [
|
|
70
|
+
'Verify that the permission sets exist in your org',
|
|
71
|
+
'Check that you have permission to assign permission sets',
|
|
72
|
+
'Ensure Agentforce is properly configured in your org',
|
|
73
|
+
`Manually assign the missing permission sets to user ${username}`,
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
this.logSuccess(`Agent user created successfully with username: ${username}`);
|
|
77
|
+
return {
|
|
78
|
+
userId,
|
|
79
|
+
username,
|
|
80
|
+
profileId,
|
|
81
|
+
permissionSetsAssigned: assigned,
|
|
82
|
+
permissionSetErrors: errors,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// eslint-disable-next-line class-methods-use-this
|
|
86
|
+
generateUsername(connection, baseUsername) {
|
|
87
|
+
// Generate username with GUID
|
|
88
|
+
const guid = randomUUID().replace(/-/g, '').substring(0, 12);
|
|
89
|
+
if (baseUsername) {
|
|
90
|
+
// Validate base username format
|
|
91
|
+
if (!baseUsername.includes('@')) {
|
|
92
|
+
throw new SfError(`Invalid base username format: "${baseUsername}". Must include @ symbol.`, 'InvalidBaseUsernameError', ['Provide a base username in email format, e.g., service-agent@corp.com']);
|
|
93
|
+
}
|
|
94
|
+
const [localPart, domain] = baseUsername.split('@');
|
|
95
|
+
return `${localPart}.${guid}@${domain}`;
|
|
96
|
+
}
|
|
97
|
+
// Default: auto-generate based on org domain
|
|
98
|
+
const orgIdentity = connection.getAuthInfoFields();
|
|
99
|
+
const orgUsername = orgIdentity.username;
|
|
100
|
+
if (!orgUsername) {
|
|
101
|
+
throw new SfError('Unable to determine org username for generating agent user username', 'OrgUsernameError', [
|
|
102
|
+
'Specify a --base-username',
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
const domain = orgUsername.split('@')[1];
|
|
106
|
+
return `agent.user.${guid}@${domain}`;
|
|
107
|
+
}
|
|
108
|
+
async checkAgentUserLicenses(connection) {
|
|
109
|
+
// Query the Einstein Agent User profile to get its associated license
|
|
110
|
+
const profileResult = await connection.query(`
|
|
111
|
+
SELECT UserLicense.Id, UserLicense.Name, UserLicense.MasterLabel,
|
|
112
|
+
UserLicense.TotalLicenses, UserLicense.UsedLicenses
|
|
113
|
+
FROM Profile
|
|
114
|
+
WHERE Name = 'Einstein Agent User'
|
|
115
|
+
`);
|
|
116
|
+
if (profileResult.totalSize === 0) {
|
|
117
|
+
throw new SfError('Einstein Agent User profile not found in this org. This profile is required for agent users.', 'ProfileNotFoundError', [
|
|
118
|
+
'Verify that Agentforce is enabled for your org',
|
|
119
|
+
'Contact your Salesforce account team to enable Agentforce features',
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
const license = profileResult.records[0].UserLicense;
|
|
123
|
+
if (!license) {
|
|
124
|
+
throw new SfError('No license information found for Einstein Agent User profile. This may indicate an org configuration issue.', 'NoAgentLicensesError', ['Contact your Salesforce account team', 'Verify that Agentforce is properly configured in your org']);
|
|
125
|
+
}
|
|
126
|
+
// Check if licenses are available
|
|
127
|
+
const availableLicenses = license.TotalLicenses - license.UsedLicenses;
|
|
128
|
+
if (license.TotalLicenses === 0) {
|
|
129
|
+
throw new SfError(`No ${license.MasterLabel} licenses are provisioned in this org. These licenses are required to create agent users.`, 'NoAgentLicensesError', [
|
|
130
|
+
`Contact your Salesforce account team to add ${license.MasterLabel} licenses to your org`,
|
|
131
|
+
'Verify that Agentforce is enabled for your org',
|
|
132
|
+
]);
|
|
133
|
+
}
|
|
134
|
+
if (availableLicenses <= 0) {
|
|
135
|
+
throw new SfError(`No available ${license.MasterLabel} licenses in this org. License usage: ${license.UsedLicenses}/${license.TotalLicenses} used`, 'NoAvailableAgentLicensesError', [
|
|
136
|
+
'Remove an existing agent user to free up a license',
|
|
137
|
+
`Contact your Salesforce account team to add more ${license.MasterLabel} licenses`,
|
|
138
|
+
]);
|
|
139
|
+
}
|
|
140
|
+
// Log license availability
|
|
141
|
+
this.log(`${license.MasterLabel}: ${availableLicenses} of ${license.TotalLicenses} licenses available`);
|
|
142
|
+
}
|
|
143
|
+
// eslint-disable-next-line class-methods-use-this
|
|
144
|
+
async getProfileId(connection) {
|
|
145
|
+
try {
|
|
146
|
+
// Use the Einstein Agent User profile which is specifically designed for agent users
|
|
147
|
+
const profileResult = await connection.singleRecordQuery("SELECT Id FROM Profile WHERE Name='Einstein Agent User'");
|
|
148
|
+
return profileResult.Id;
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
152
|
+
throw new SfError(`Failed to query for "Einstein Agent User" profile: ${errorMessage}. This profile is required for agent users.`, 'ProfileQueryError', [
|
|
153
|
+
'Ensure Agentforce is enabled in your org',
|
|
154
|
+
'Verify that the Einstein Agent User profile exists',
|
|
155
|
+
'Check that you have permission to query Profile records',
|
|
156
|
+
'Contact your Salesforce administrator to enable Agentforce features',
|
|
157
|
+
]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// eslint-disable-next-line class-methods-use-this
|
|
161
|
+
async createAgentUser(connection, username, profileId, nameFields) {
|
|
162
|
+
// Generate alias from username (max 8 chars)
|
|
163
|
+
// Take first part before @ or first 8 chars of username
|
|
164
|
+
const alias = username
|
|
165
|
+
.split('@')[0]
|
|
166
|
+
.replace(/[^a-zA-Z0-9]/g, '')
|
|
167
|
+
.substring(0, 8);
|
|
168
|
+
const userRecord = await connection.sobject('User').create({
|
|
169
|
+
FirstName: nameFields.firstName,
|
|
170
|
+
LastName: nameFields.lastName,
|
|
171
|
+
Alias: alias,
|
|
172
|
+
Email: username,
|
|
173
|
+
Username: username,
|
|
174
|
+
ProfileId: profileId,
|
|
175
|
+
TimeZoneSidKey: 'America/Los_Angeles',
|
|
176
|
+
LocaleSidKey: 'en_US',
|
|
177
|
+
EmailEncodingKey: 'UTF-8',
|
|
178
|
+
LanguageLocaleKey: 'en_US',
|
|
179
|
+
});
|
|
180
|
+
if (!userRecord.success || !userRecord.id) {
|
|
181
|
+
const errorMessages = userRecord.errors?.map((e) => e.message).join(', ') ?? 'Unknown error';
|
|
182
|
+
throw new SfError(`Failed to create agent user: ${errorMessages}`, 'UserCreationError', [
|
|
183
|
+
'Verify that the username is globally unique',
|
|
184
|
+
'Ensure the Einstein Agent User profile exists in your org',
|
|
185
|
+
'Check that Agentforce is enabled for your org',
|
|
186
|
+
'Verify you have permission to create User records',
|
|
187
|
+
]);
|
|
188
|
+
}
|
|
189
|
+
return userRecord.id;
|
|
190
|
+
}
|
|
191
|
+
async assignPermissionSets(connection, userId, permissionSets) {
|
|
192
|
+
const assigned = [];
|
|
193
|
+
const errors = [];
|
|
194
|
+
for (const permissionSetName of permissionSets) {
|
|
195
|
+
try {
|
|
196
|
+
// Look up the permission set
|
|
197
|
+
// eslint-disable-next-line no-await-in-loop
|
|
198
|
+
const psResult = await connection.query(`SELECT Id FROM PermissionSet WHERE Name = '${permissionSetName}' LIMIT 1`);
|
|
199
|
+
if (psResult.totalSize === 0) {
|
|
200
|
+
errors.push({
|
|
201
|
+
permissionSet: permissionSetName,
|
|
202
|
+
error: 'Permission set not found in org',
|
|
203
|
+
});
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const permissionSetId = psResult.records[0].Id;
|
|
207
|
+
// Assign the permission set
|
|
208
|
+
// eslint-disable-next-line no-await-in-loop
|
|
209
|
+
const assignmentResult = await connection.sobject('PermissionSetAssignment').create({
|
|
210
|
+
PermissionSetId: permissionSetId,
|
|
211
|
+
AssigneeId: userId,
|
|
212
|
+
});
|
|
213
|
+
if (!assignmentResult.success) {
|
|
214
|
+
const errorMessages = assignmentResult.errors?.map((e) => e.message).join(', ') ?? 'Unknown error';
|
|
215
|
+
errors.push({
|
|
216
|
+
permissionSet: permissionSetName,
|
|
217
|
+
error: errorMessages,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
assigned.push(permissionSetName);
|
|
222
|
+
this.log(`Assigned permission set: ${permissionSetName}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
errors.push({
|
|
227
|
+
permissionSet: permissionSetName,
|
|
228
|
+
error: error instanceof Error ? error.message : String(error),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return { assigned, errors };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=agent-user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-user.js","sourceRoot":"","sources":["../../../../src/commands/org/create/agent-user.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAc,QAAQ,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,SAAS,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,wBAAwB,EAAE,mBAAmB,CAAC,CAAC;AAUtF,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,SA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CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,eAAe,CAAC;oBACnG,MAAM,CAAC,IAAI,CAAC;wBACV,aAAa,EAAE,iBAAiB;wBAChC,KAAK,EAAE,aAAa;qBACrB,CAAC,CAAC;gBACL,CAAC;qBAAM,CAAC;oBACN,QAAQ,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;oBACjC,IAAI,CAAC,GAAG,CAAC,4BAA4B,iBAAiB,EAAE,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,CAAC;oBACV,aAAa,EAAE,iBAAiB;oBAChC,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Create the default Salesforce user that is used to run an agent.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
You specify this user in the agent's Agent Script file using the "default_agent_user" parameter in the "config" block.
|
|
8
|
+
|
|
9
|
+
By default, this command:
|
|
10
|
+
|
|
11
|
+
- Generates a user called "Agent User" with a globally unique username. Use flags to change these default names.
|
|
12
|
+
- Sets the user's email to the new username.
|
|
13
|
+
- Assigns the user the "Einstein Agent User" profile.
|
|
14
|
+
- Assigns the user these required permission sets: AgentforceServiceAgentBase, AgentforceServiceAgentUser,
|
|
15
|
+
EinsteinGPTPromptTemplateUser
|
|
16
|
+
- Checks that the user licenses required by the profile and permission sets are available in your org.
|
|
17
|
+
|
|
18
|
+
The generated user doesn't have a password. You can’t log into Salesforce using the agent user's username. Only
|
|
19
|
+
Salesforce users with admin permissions can view or edit an agent user in Setup.
|
|
20
|
+
|
|
21
|
+
To assign additional permission sets or licenses after the user was created, use the "org assign permset" or "org assign
|
|
22
|
+
permsetlicense" commands.
|
|
23
|
+
|
|
24
|
+
When the command completes, it displays a summary of what it did, including the new agent user's username and ID, the
|
|
25
|
+
available licenses associated with the Einstein Agent User profile, and the profile and permission sets assigned to the
|
|
26
|
+
agent user.
|
|
27
|
+
|
|
28
|
+
# examples
|
|
29
|
+
|
|
30
|
+
- Create an agent user with an auto-generated username; create the user in the org with alias "myorg":
|
|
31
|
+
|
|
32
|
+
<%= config.bin %> <%= command.id %> --target-org myorg
|
|
33
|
+
|
|
34
|
+
- Create an agent user by specifying a base username pattern; to make the username unique, the command appends a unique
|
|
35
|
+
identifier:
|
|
36
|
+
|
|
37
|
+
<%= config.bin %> <%= command.id %> --base-username service-agent@corp.com --target-org myorg
|
|
38
|
+
|
|
39
|
+
- Create an agent user with an auto-generated username but the custom name "Service Agent"; create the user in your
|
|
40
|
+
default org:
|
|
41
|
+
|
|
42
|
+
<%= config.bin %> <%= command.id %> --first-name Service --last-name Agent
|
|
43
|
+
|
|
44
|
+
# flags.target-org.summary
|
|
45
|
+
|
|
46
|
+
Username or alias of the target org where the agent user will be created.
|
|
47
|
+
|
|
48
|
+
# flags.base-username.summary
|
|
49
|
+
|
|
50
|
+
Base username pattern. A unique ID is appended to ensure global uniqueness of the usename.
|
|
51
|
+
|
|
52
|
+
# flags.base-username.description
|
|
53
|
+
|
|
54
|
+
Specify a base username in email format, such as "service-agent@corp.com". The command then appends a 12-character
|
|
55
|
+
globally unique ID (GUID) to the name before the "@" sign, which ensures that the username is globally unique across all
|
|
56
|
+
Salesforce orgs and sandboxes.
|
|
57
|
+
|
|
58
|
+
For example, if you specify "service-agent@corp.com", then the username might be "service-agent.a1b2c3d4e5f6@corp.com".
|
|
59
|
+
|
|
60
|
+
If not specified, the command auto-generates the username using this pattern: "agent.user.<GUID>@your-org-domain.com".
|
|
61
|
+
|
|
62
|
+
# flags.first-name.summary
|
|
63
|
+
|
|
64
|
+
First name for the agent user.
|
|
65
|
+
|
|
66
|
+
# flags.last-name.summary
|
|
67
|
+
|
|
68
|
+
Last name for the agent user.
|
package/oclif.manifest.json
CHANGED
|
@@ -385,6 +385,100 @@
|
|
|
385
385
|
"open:org"
|
|
386
386
|
]
|
|
387
387
|
},
|
|
388
|
+
"org:create:agent-user": {
|
|
389
|
+
"aliases": [],
|
|
390
|
+
"args": {},
|
|
391
|
+
"description": "You specify this user in the agent's Agent Script file using the \"default_agent_user\" parameter in the \"config\" block.\n\nBy default, this command:\n\n- Generates a user called \"Agent User\" with a globally unique username. Use flags to change these default names.\n- Sets the user's email to the new username.\n- Assigns the user the \"Einstein Agent User\" profile.\n- Assigns the user these required permission sets: AgentforceServiceAgentBase, AgentforceServiceAgentUser,\n EinsteinGPTPromptTemplateUser\n- Checks that the user licenses required by the profile and permission sets are available in your org.\n\nThe generated user doesn't have a password. You can’t log into Salesforce using the agent user's username. Only\nSalesforce users with admin permissions can view or edit an agent user in Setup.\n\nTo assign additional permission sets or licenses after the user was created, use the \"org assign permset\" or \"org assign\npermsetlicense\" commands.\n\nWhen the command completes, it displays a summary of what it did, including the new agent user's username and ID, the\navailable licenses associated with the Einstein Agent User profile, and the profile and permission sets assigned to the\nagent user.",
|
|
392
|
+
"examples": [
|
|
393
|
+
"Create an agent user with an auto-generated username; create the user in the org with alias \"myorg\":\n<%= config.bin %> <%= command.id %> --target-org myorg",
|
|
394
|
+
"Create an agent user by specifying a base username pattern; to make the username unique, the command appends a unique\nidentifier:\n<%= config.bin %> <%= command.id %> --base-username service-agent@corp.com --target-org myorg",
|
|
395
|
+
"Create an agent user with an auto-generated username but the custom name \"Service Agent\"; create the user in your\ndefault org:\n<%= config.bin %> <%= command.id %> --first-name Service --last-name Agent"
|
|
396
|
+
],
|
|
397
|
+
"flags": {
|
|
398
|
+
"json": {
|
|
399
|
+
"description": "Format output as json.",
|
|
400
|
+
"helpGroup": "GLOBAL",
|
|
401
|
+
"name": "json",
|
|
402
|
+
"allowNo": false,
|
|
403
|
+
"type": "boolean"
|
|
404
|
+
},
|
|
405
|
+
"flags-dir": {
|
|
406
|
+
"helpGroup": "GLOBAL",
|
|
407
|
+
"name": "flags-dir",
|
|
408
|
+
"summary": "Import flag values from a directory.",
|
|
409
|
+
"hasDynamicHelp": false,
|
|
410
|
+
"multiple": false,
|
|
411
|
+
"type": "option"
|
|
412
|
+
},
|
|
413
|
+
"target-org": {
|
|
414
|
+
"char": "o",
|
|
415
|
+
"name": "target-org",
|
|
416
|
+
"noCacheDefault": true,
|
|
417
|
+
"required": true,
|
|
418
|
+
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
|
|
419
|
+
"hasDynamicHelp": true,
|
|
420
|
+
"multiple": false,
|
|
421
|
+
"type": "option"
|
|
422
|
+
},
|
|
423
|
+
"api-version": {
|
|
424
|
+
"description": "Override the api version used for api requests made by this command",
|
|
425
|
+
"name": "api-version",
|
|
426
|
+
"hasDynamicHelp": false,
|
|
427
|
+
"multiple": false,
|
|
428
|
+
"type": "option"
|
|
429
|
+
},
|
|
430
|
+
"base-username": {
|
|
431
|
+
"description": "Specify a base username in email format, such as \"service-agent@corp.com\". The command then appends a 12-character\nglobally unique ID (GUID) to the name before the \"@\" sign, which ensures that the username is globally unique across all\nSalesforce orgs and sandboxes.\n\nFor example, if you specify \"service-agent@corp.com\", then the username might be \"service-agent.a1b2c3d4e5f6@corp.com\".\n\nIf not specified, the command auto-generates the username using this pattern: \"agent.user.<GUID>@your-org-domain.com\".",
|
|
432
|
+
"name": "base-username",
|
|
433
|
+
"summary": "Base username pattern. A unique ID is appended to ensure global uniqueness of the usename.",
|
|
434
|
+
"hasDynamicHelp": false,
|
|
435
|
+
"multiple": false,
|
|
436
|
+
"type": "option"
|
|
437
|
+
},
|
|
438
|
+
"first-name": {
|
|
439
|
+
"name": "first-name",
|
|
440
|
+
"summary": "First name for the agent user.",
|
|
441
|
+
"default": "Agent",
|
|
442
|
+
"hasDynamicHelp": false,
|
|
443
|
+
"multiple": false,
|
|
444
|
+
"type": "option"
|
|
445
|
+
},
|
|
446
|
+
"last-name": {
|
|
447
|
+
"name": "last-name",
|
|
448
|
+
"summary": "Last name for the agent user.",
|
|
449
|
+
"default": "User",
|
|
450
|
+
"hasDynamicHelp": false,
|
|
451
|
+
"multiple": false,
|
|
452
|
+
"type": "option"
|
|
453
|
+
}
|
|
454
|
+
},
|
|
455
|
+
"hasDynamicHelp": true,
|
|
456
|
+
"hiddenAliases": [],
|
|
457
|
+
"id": "org:create:agent-user",
|
|
458
|
+
"pluginAlias": "@salesforce/plugin-org",
|
|
459
|
+
"pluginName": "@salesforce/plugin-org",
|
|
460
|
+
"pluginType": "core",
|
|
461
|
+
"strict": true,
|
|
462
|
+
"summary": "Create the default Salesforce user that is used to run an agent.",
|
|
463
|
+
"enableJsonFlag": true,
|
|
464
|
+
"isESM": true,
|
|
465
|
+
"relativePath": [
|
|
466
|
+
"lib",
|
|
467
|
+
"commands",
|
|
468
|
+
"org",
|
|
469
|
+
"create",
|
|
470
|
+
"agent-user.js"
|
|
471
|
+
],
|
|
472
|
+
"aliasPermutations": [],
|
|
473
|
+
"permutations": [
|
|
474
|
+
"org:create:agent-user",
|
|
475
|
+
"create:org:agent-user",
|
|
476
|
+
"create:agent-user:org",
|
|
477
|
+
"org:agent-user:create",
|
|
478
|
+
"agent-user:org:create",
|
|
479
|
+
"agent-user:create:org"
|
|
480
|
+
]
|
|
481
|
+
},
|
|
388
482
|
"org:create:sandbox": {
|
|
389
483
|
"aliases": [
|
|
390
484
|
"env:create:sandbox"
|
|
@@ -851,6 +945,69 @@
|
|
|
851
945
|
"scratch:create:org"
|
|
852
946
|
]
|
|
853
947
|
},
|
|
948
|
+
"org:disable:tracking": {
|
|
949
|
+
"aliases": [],
|
|
950
|
+
"args": {},
|
|
951
|
+
"description": "Disabling source tracking has no direct effect on the org, it affects only your local environment. Specifically, Salesforce CLI stores the setting in the org's local configuration file so that no source tracking operations are executed when working with the org.",
|
|
952
|
+
"examples": [
|
|
953
|
+
"Disable source tracking for an org with alias \"myscratch\":\n<%= config.bin %> <%= command.id %> --target-org myscratch",
|
|
954
|
+
"Disable source tracking for an org using a username:\n<%= config.bin %> <%= command.id %> --target-org you@example.com",
|
|
955
|
+
"Disable source tracking for your default org:\n<%= config.bin %> <%= command.id %>"
|
|
956
|
+
],
|
|
957
|
+
"flags": {
|
|
958
|
+
"json": {
|
|
959
|
+
"description": "Format output as json.",
|
|
960
|
+
"helpGroup": "GLOBAL",
|
|
961
|
+
"name": "json",
|
|
962
|
+
"allowNo": false,
|
|
963
|
+
"type": "boolean"
|
|
964
|
+
},
|
|
965
|
+
"flags-dir": {
|
|
966
|
+
"helpGroup": "GLOBAL",
|
|
967
|
+
"name": "flags-dir",
|
|
968
|
+
"summary": "Import flag values from a directory.",
|
|
969
|
+
"hasDynamicHelp": false,
|
|
970
|
+
"multiple": false,
|
|
971
|
+
"type": "option"
|
|
972
|
+
},
|
|
973
|
+
"target-org": {
|
|
974
|
+
"char": "o",
|
|
975
|
+
"name": "target-org",
|
|
976
|
+
"noCacheDefault": true,
|
|
977
|
+
"required": true,
|
|
978
|
+
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
|
|
979
|
+
"hasDynamicHelp": true,
|
|
980
|
+
"multiple": false,
|
|
981
|
+
"type": "option"
|
|
982
|
+
}
|
|
983
|
+
},
|
|
984
|
+
"hasDynamicHelp": true,
|
|
985
|
+
"hiddenAliases": [],
|
|
986
|
+
"id": "org:disable:tracking",
|
|
987
|
+
"pluginAlias": "@salesforce/plugin-org",
|
|
988
|
+
"pluginName": "@salesforce/plugin-org",
|
|
989
|
+
"pluginType": "core",
|
|
990
|
+
"strict": true,
|
|
991
|
+
"summary": "Prevent Salesforce CLI from tracking changes in your source files between your project and an org.",
|
|
992
|
+
"enableJsonFlag": true,
|
|
993
|
+
"isESM": true,
|
|
994
|
+
"relativePath": [
|
|
995
|
+
"lib",
|
|
996
|
+
"commands",
|
|
997
|
+
"org",
|
|
998
|
+
"disable",
|
|
999
|
+
"tracking.js"
|
|
1000
|
+
],
|
|
1001
|
+
"aliasPermutations": [],
|
|
1002
|
+
"permutations": [
|
|
1003
|
+
"org:disable:tracking",
|
|
1004
|
+
"disable:org:tracking",
|
|
1005
|
+
"disable:tracking:org",
|
|
1006
|
+
"org:tracking:disable",
|
|
1007
|
+
"tracking:org:disable",
|
|
1008
|
+
"tracking:disable:org"
|
|
1009
|
+
]
|
|
1010
|
+
},
|
|
854
1011
|
"org:delete:sandbox": {
|
|
855
1012
|
"aliases": [
|
|
856
1013
|
"env:delete:sandbox"
|
|
@@ -1019,69 +1176,6 @@
|
|
|
1019
1176
|
"scratch:delete:org"
|
|
1020
1177
|
]
|
|
1021
1178
|
},
|
|
1022
|
-
"org:disable:tracking": {
|
|
1023
|
-
"aliases": [],
|
|
1024
|
-
"args": {},
|
|
1025
|
-
"description": "Disabling source tracking has no direct effect on the org, it affects only your local environment. Specifically, Salesforce CLI stores the setting in the org's local configuration file so that no source tracking operations are executed when working with the org.",
|
|
1026
|
-
"examples": [
|
|
1027
|
-
"Disable source tracking for an org with alias \"myscratch\":\n<%= config.bin %> <%= command.id %> --target-org myscratch",
|
|
1028
|
-
"Disable source tracking for an org using a username:\n<%= config.bin %> <%= command.id %> --target-org you@example.com",
|
|
1029
|
-
"Disable source tracking for your default org:\n<%= config.bin %> <%= command.id %>"
|
|
1030
|
-
],
|
|
1031
|
-
"flags": {
|
|
1032
|
-
"json": {
|
|
1033
|
-
"description": "Format output as json.",
|
|
1034
|
-
"helpGroup": "GLOBAL",
|
|
1035
|
-
"name": "json",
|
|
1036
|
-
"allowNo": false,
|
|
1037
|
-
"type": "boolean"
|
|
1038
|
-
},
|
|
1039
|
-
"flags-dir": {
|
|
1040
|
-
"helpGroup": "GLOBAL",
|
|
1041
|
-
"name": "flags-dir",
|
|
1042
|
-
"summary": "Import flag values from a directory.",
|
|
1043
|
-
"hasDynamicHelp": false,
|
|
1044
|
-
"multiple": false,
|
|
1045
|
-
"type": "option"
|
|
1046
|
-
},
|
|
1047
|
-
"target-org": {
|
|
1048
|
-
"char": "o",
|
|
1049
|
-
"name": "target-org",
|
|
1050
|
-
"noCacheDefault": true,
|
|
1051
|
-
"required": true,
|
|
1052
|
-
"summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
|
|
1053
|
-
"hasDynamicHelp": true,
|
|
1054
|
-
"multiple": false,
|
|
1055
|
-
"type": "option"
|
|
1056
|
-
}
|
|
1057
|
-
},
|
|
1058
|
-
"hasDynamicHelp": true,
|
|
1059
|
-
"hiddenAliases": [],
|
|
1060
|
-
"id": "org:disable:tracking",
|
|
1061
|
-
"pluginAlias": "@salesforce/plugin-org",
|
|
1062
|
-
"pluginName": "@salesforce/plugin-org",
|
|
1063
|
-
"pluginType": "core",
|
|
1064
|
-
"strict": true,
|
|
1065
|
-
"summary": "Prevent Salesforce CLI from tracking changes in your source files between your project and an org.",
|
|
1066
|
-
"enableJsonFlag": true,
|
|
1067
|
-
"isESM": true,
|
|
1068
|
-
"relativePath": [
|
|
1069
|
-
"lib",
|
|
1070
|
-
"commands",
|
|
1071
|
-
"org",
|
|
1072
|
-
"disable",
|
|
1073
|
-
"tracking.js"
|
|
1074
|
-
],
|
|
1075
|
-
"aliasPermutations": [],
|
|
1076
|
-
"permutations": [
|
|
1077
|
-
"org:disable:tracking",
|
|
1078
|
-
"disable:org:tracking",
|
|
1079
|
-
"disable:tracking:org",
|
|
1080
|
-
"org:tracking:disable",
|
|
1081
|
-
"tracking:org:disable",
|
|
1082
|
-
"tracking:disable:org"
|
|
1083
|
-
]
|
|
1084
|
-
},
|
|
1085
1179
|
"org:enable:tracking": {
|
|
1086
1180
|
"aliases": [],
|
|
1087
1181
|
"args": {},
|
|
@@ -1983,5 +2077,5 @@
|
|
|
1983
2077
|
]
|
|
1984
2078
|
}
|
|
1985
2079
|
},
|
|
1986
|
-
"version": "5.9.
|
|
2080
|
+
"version": "5.9.75"
|
|
1987
2081
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/plugin-org",
|
|
3
3
|
"description": "Commands to interact with Salesforce orgs",
|
|
4
|
-
"version": "5.9.
|
|
4
|
+
"version": "5.9.75",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bugs": "https://github.com/forcedotcom/cli/issues",
|
|
7
7
|
"enableO11y": true,
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"terminal-link": "^3.0.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@oclif/plugin-command-snapshot": "^5.3.
|
|
24
|
+
"@oclif/plugin-command-snapshot": "^5.3.13",
|
|
25
25
|
"@salesforce/cli-plugins-testkit": "^5.3.41",
|
|
26
26
|
"@salesforce/dev-scripts": "^11.0.4",
|
|
27
27
|
"@salesforce/plugin-command-reference": "^3.1.82",
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
"exports": "./lib/index.js",
|
|
231
231
|
"type": "module",
|
|
232
232
|
"sfdx": {
|
|
233
|
-
"publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.9.
|
|
234
|
-
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.9.
|
|
233
|
+
"publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.9.75.crt",
|
|
234
|
+
"signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@salesforce/plugin-org/5.9.75.sig"
|
|
235
235
|
}
|
|
236
236
|
}
|