sfdx-hardis 6.9.1-alpha202510270024.0 → 6.9.1-alpha202510270034.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.
@@ -132,12 +132,13 @@
132
132
  "clear:cache:hardis"
133
133
  ]
134
134
  },
135
- "hardis:config:get": {
135
+ "hardis:auth:login": {
136
136
  "aliases": [],
137
137
  "args": {},
138
- "description": "\n## Command Behavior\n\n**Retrieves and displays the sfdx-hardis configuration for a specified level.**\n\nThis command allows you to inspect the configuration that is currently in effect for your project, which is useful for debugging and understanding how sfdx-hardis will behave.\n\n- **Configuration levels:** It can retrieve configuration from three different levels:\n - **Project:** The configuration defined in the project's `.sfdx-hardis.yml` file.\n - **Branch:** The configuration defined in a branch-specific configuration file (e.g., `.sfdx-hardis.production.yml`).\n - **User:** The global user-level configuration.\n\n## Technical explanations\n\nThe command's logic is straightforward:\n\n- **`getConfig` function:** It calls the `getConfig` utility function, passing the desired configuration level as an argument.\n- **Configuration loading:** The `getConfig` function is responsible for finding the appropriate configuration file, reading its contents, and parsing it as YAML or JSON.\n- **Output:** The retrieved configuration is then displayed to the user as a JSON string.\n",
138
+ "description": "\n## Command Behavior\n\n**Authenticates to a Salesforce org, primarily designed for CI/CD workflows.**\n\nThis command facilitates secure and automated logins to Salesforce organizations within continuous integration and continuous delivery pipelines. It leverages pre-configured authentication details, ensuring that CI/CD processes can interact with Salesforce without manual intervention.\n\nKey aspects:\n\n- **Configuration-Driven:** It relies on authentication variables and files set up by dedicated configuration commands:\n - For CI/CD repositories: [Configure Org CI Authentication](https://sfdx-hardis.cloudity.com/hardis/project/configure/auth/)\n - For Monitoring repositories: [Configure Org Monitoring](https://sfdx-hardis.cloudity.com/hardis/org/configure/monitoring/)\n- **Technical Org Support:** Supports authentication to a 'technical org' (e.g., for calling Agentforce from another org) by utilizing the `SFDX_AUTH_URL_TECHNICAL_ORG` environment variable. If this variable is set, the command authenticates to this org with the alias `TECHNICAL_ORG`.\n\nTo obtain the `SFDX_AUTH_URL_TECHNICAL_ORG` value, you can run `sf org display --verbose --json` and copy the `sfdxAuthUrl` field from the output.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical flow involves:\n\n- **Flag Parsing:** It parses command-line flags such as `instanceurl`, `devhub`, `scratchorg`, and `debug` to determine the authentication context.\n- **Authentication Hook:** It triggers an internal authentication hook (`this.config.runHook('auth', ...`)) which is responsible for executing the actual authentication logic based on the provided flags (e.g., whether it's a Dev Hub or a scratch org).\n- **Environment Variable Check:** It checks for the presence of `SFDX_AUTH_URL_TECHNICAL_ORG` or `TECHNICAL_ORG_ALIAS` environment variables.\n- **`authOrg` Utility:** If a technical org is configured, it calls the `authOrg` utility function to perform the authentication for that specific org, ensuring it's connected and available for subsequent operations.\n- **Salesforce CLI Integration:** It integrates with the Salesforce CLI's authentication mechanisms to establish and manage org connections.\n</details>\n",
139
139
  "examples": [
140
- "$ sf hardis:project:deploy:sources:metadata"
140
+ "$ sf hardis:auth:login",
141
+ "CI=true CI_COMMIT_REF_NAME=monitoring_myclient sf hardis:auth:login"
141
142
  ],
142
143
  "flags": {
143
144
  "json": {
@@ -155,20 +156,28 @@
155
156
  "multiple": false,
156
157
  "type": "option"
157
158
  },
158
- "level": {
159
- "char": "l",
160
- "description": "project,branch or user",
161
- "name": "level",
162
- "default": "project",
159
+ "instanceurl": {
160
+ "char": "r",
161
+ "description": "URL of org instance",
162
+ "name": "instanceurl",
163
163
  "hasDynamicHelp": false,
164
164
  "multiple": false,
165
- "options": [
166
- "project",
167
- "branch",
168
- "user"
169
- ],
170
165
  "type": "option"
171
166
  },
167
+ "devhub": {
168
+ "char": "h",
169
+ "description": "Also connect associated DevHub",
170
+ "name": "devhub",
171
+ "allowNo": false,
172
+ "type": "boolean"
173
+ },
174
+ "scratchorg": {
175
+ "char": "s",
176
+ "description": "Scratch org",
177
+ "name": "scratchorg",
178
+ "allowNo": false,
179
+ "type": "boolean"
180
+ },
172
181
  "debug": {
173
182
  "char": "d",
174
183
  "description": "Activate debug mode (more logs)",
@@ -192,39 +201,38 @@
192
201
  },
193
202
  "hasDynamicHelp": false,
194
203
  "hiddenAliases": [],
195
- "id": "hardis:config:get",
204
+ "id": "hardis:auth:login",
196
205
  "pluginAlias": "sfdx-hardis",
197
206
  "pluginName": "sfdx-hardis",
198
207
  "pluginType": "core",
199
208
  "strict": true,
200
209
  "enableJsonFlag": true,
201
- "title": "Deploy metadata sources to org",
210
+ "title": "Login",
202
211
  "requiresProject": false,
203
212
  "isESM": true,
204
213
  "relativePath": [
205
214
  "lib",
206
215
  "commands",
207
216
  "hardis",
208
- "config",
209
- "get.js"
217
+ "auth",
218
+ "login.js"
210
219
  ],
211
220
  "aliasPermutations": [],
212
221
  "permutations": [
213
- "hardis:config:get",
214
- "config:hardis:get",
215
- "config:get:hardis",
216
- "hardis:get:config",
217
- "get:hardis:config",
218
- "get:config:hardis"
222
+ "hardis:auth:login",
223
+ "auth:hardis:login",
224
+ "auth:login:hardis",
225
+ "hardis:login:auth",
226
+ "login:hardis:auth",
227
+ "login:auth:hardis"
219
228
  ]
220
229
  },
221
- "hardis:auth:login": {
230
+ "hardis:config:get": {
222
231
  "aliases": [],
223
232
  "args": {},
224
- "description": "\n## Command Behavior\n\n**Authenticates to a Salesforce org, primarily designed for CI/CD workflows.**\n\nThis command facilitates secure and automated logins to Salesforce organizations within continuous integration and continuous delivery pipelines. It leverages pre-configured authentication details, ensuring that CI/CD processes can interact with Salesforce without manual intervention.\n\nKey aspects:\n\n- **Configuration-Driven:** It relies on authentication variables and files set up by dedicated configuration commands:\n - For CI/CD repositories: [Configure Org CI Authentication](https://sfdx-hardis.cloudity.com/hardis/project/configure/auth/)\n - For Monitoring repositories: [Configure Org Monitoring](https://sfdx-hardis.cloudity.com/hardis/org/configure/monitoring/)\n- **Technical Org Support:** Supports authentication to a 'technical org' (e.g., for calling Agentforce from another org) by utilizing the `SFDX_AUTH_URL_TECHNICAL_ORG` environment variable. If this variable is set, the command authenticates to this org with the alias `TECHNICAL_ORG`.\n\nTo obtain the `SFDX_AUTH_URL_TECHNICAL_ORG` value, you can run `sf org display --verbose --json` and copy the `sfdxAuthUrl` field from the output.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical flow involves:\n\n- **Flag Parsing:** It parses command-line flags such as `instanceurl`, `devhub`, `scratchorg`, and `debug` to determine the authentication context.\n- **Authentication Hook:** It triggers an internal authentication hook (`this.config.runHook('auth', ...`)) which is responsible for executing the actual authentication logic based on the provided flags (e.g., whether it's a Dev Hub or a scratch org).\n- **Environment Variable Check:** It checks for the presence of `SFDX_AUTH_URL_TECHNICAL_ORG` or `TECHNICAL_ORG_ALIAS` environment variables.\n- **`authOrg` Utility:** If a technical org is configured, it calls the `authOrg` utility function to perform the authentication for that specific org, ensuring it's connected and available for subsequent operations.\n- **Salesforce CLI Integration:** It integrates with the Salesforce CLI's authentication mechanisms to establish and manage org connections.\n</details>\n",
233
+ "description": "\n## Command Behavior\n\n**Retrieves and displays the sfdx-hardis configuration for a specified level.**\n\nThis command allows you to inspect the configuration that is currently in effect for your project, which is useful for debugging and understanding how sfdx-hardis will behave.\n\n- **Configuration levels:** It can retrieve configuration from three different levels:\n - **Project:** The configuration defined in the project's `.sfdx-hardis.yml` file.\n - **Branch:** The configuration defined in a branch-specific configuration file (e.g., `.sfdx-hardis.production.yml`).\n - **User:** The global user-level configuration.\n\n## Technical explanations\n\nThe command's logic is straightforward:\n\n- **`getConfig` function:** It calls the `getConfig` utility function, passing the desired configuration level as an argument.\n- **Configuration loading:** The `getConfig` function is responsible for finding the appropriate configuration file, reading its contents, and parsing it as YAML or JSON.\n- **Output:** The retrieved configuration is then displayed to the user as a JSON string.\n",
225
234
  "examples": [
226
- "$ sf hardis:auth:login",
227
- "CI=true CI_COMMIT_REF_NAME=monitoring_myclient sf hardis:auth:login"
235
+ "$ sf hardis:project:deploy:sources:metadata"
228
236
  ],
229
237
  "flags": {
230
238
  "json": {
@@ -242,28 +250,20 @@
242
250
  "multiple": false,
243
251
  "type": "option"
244
252
  },
245
- "instanceurl": {
246
- "char": "r",
247
- "description": "URL of org instance",
248
- "name": "instanceurl",
253
+ "level": {
254
+ "char": "l",
255
+ "description": "project,branch or user",
256
+ "name": "level",
257
+ "default": "project",
249
258
  "hasDynamicHelp": false,
250
259
  "multiple": false,
260
+ "options": [
261
+ "project",
262
+ "branch",
263
+ "user"
264
+ ],
251
265
  "type": "option"
252
266
  },
253
- "devhub": {
254
- "char": "h",
255
- "description": "Also connect associated DevHub",
256
- "name": "devhub",
257
- "allowNo": false,
258
- "type": "boolean"
259
- },
260
- "scratchorg": {
261
- "char": "s",
262
- "description": "Scratch org",
263
- "name": "scratchorg",
264
- "allowNo": false,
265
- "type": "boolean"
266
- },
267
267
  "debug": {
268
268
  "char": "d",
269
269
  "description": "Activate debug mode (more logs)",
@@ -287,30 +287,30 @@
287
287
  },
288
288
  "hasDynamicHelp": false,
289
289
  "hiddenAliases": [],
290
- "id": "hardis:auth:login",
290
+ "id": "hardis:config:get",
291
291
  "pluginAlias": "sfdx-hardis",
292
292
  "pluginName": "sfdx-hardis",
293
293
  "pluginType": "core",
294
294
  "strict": true,
295
295
  "enableJsonFlag": true,
296
- "title": "Login",
296
+ "title": "Deploy metadata sources to org",
297
297
  "requiresProject": false,
298
298
  "isESM": true,
299
299
  "relativePath": [
300
300
  "lib",
301
301
  "commands",
302
302
  "hardis",
303
- "auth",
304
- "login.js"
303
+ "config",
304
+ "get.js"
305
305
  ],
306
306
  "aliasPermutations": [],
307
307
  "permutations": [
308
- "hardis:auth:login",
309
- "auth:hardis:login",
310
- "auth:login:hardis",
311
- "hardis:login:auth",
312
- "login:hardis:auth",
313
- "login:auth:hardis"
308
+ "hardis:config:get",
309
+ "config:hardis:get",
310
+ "config:get:hardis",
311
+ "hardis:get:config",
312
+ "get:hardis:config",
313
+ "get:config:hardis"
314
314
  ]
315
315
  },
316
316
  "hardis:doc:fieldusage": {
@@ -5539,12 +5539,15 @@
5539
5539
  "import:data:org:hardis"
5540
5540
  ]
5541
5541
  },
5542
- "hardis:org:files:export": {
5542
+ "hardis:org:diagnose:audittrail": {
5543
5543
  "aliases": [],
5544
5544
  "args": {},
5545
- "description": "\n## Command Behavior\n\n**Exports file attachments (ContentVersion, Attachment) from a Salesforce org based on a predefined configuration.**\n\nThis command enables the mass download of files associated with Salesforce records, providing a robust solution for backing up files, migrating them to other systems, or integrating them with external document management solutions.\n\nKey functionalities:\n\n- **Configuration-Driven Export:** Relies on an `export.json` file within a designated file export project to define the export criteria, including the SOQL query for parent records, file types to export, output naming conventions, and file size filtering.\n- **File Size Filtering:** Supports minimum file size filtering via the `fileSizeMin` configuration parameter (in KB). Files smaller than the specified size will be skipped during export.\n- **File Validation:** After downloading each file, validates the integrity by:\n - **Checksum Validation:** For ContentVersion files, compares MD5 checksum with Salesforce's stored checksum\n - **Size Validation:** For both ContentVersion and Attachment files, verifies actual file size matches expected size\n - **Status Tracking:** Files are categorized with specific statuses: `success` (valid files), `failed` (download errors), `skipped` (filtered files), `invalid` (downloaded but failed validation)\n - All validation results are logged in the CSV export log for audit purposes\n- **Resume/Restart Capability:** \n - **Resume Mode:** When `--resume` flag is used (default in CI environments), checks existing downloaded files for validity. Valid files are skipped, invalid files are re-downloaded.\n - **Restart Mode:** When resume is disabled, clears the output folder and starts a fresh export.\n - **Interactive Mode:** When existing files are found and `--resume` is not explicitly specified (non-CI environments), prompts the user to choose between resume or restart.\n- **Interactive Project Selection:** If the file export project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Configurable Export Options:** Allows overriding default export settings such as `chunksize` (number of records processed in a batch), `polltimeout` (timeout for Bulk API calls), and `startchunknumber` (to resume a failed export).\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for a practical example:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesExporter Class:** The core logic is encapsulated within the `FilesExporter` class, which orchestrates the entire export process.\n- **SOQL Queries (Bulk API):** It uses Salesforce Bulk API queries to efficiently retrieve large volumes of parent record IDs and file metadata, including checksums and file sizes.\n- **File Download:** Downloads the actual file content from Salesforce.\n- **File Validation:** After each successful download, validates file integrity by comparing checksums (ContentVersion) and file sizes (both ContentVersion and Attachment) against Salesforce metadata.\n- **Resume Logic:** In resume mode, checks for existing files before downloading, validates their integrity, and only re-downloads invalid or missing files. This enables efficient recovery from interrupted exports.\n- **File System Operations:** Writes the downloaded files to the local file system, organizing them into folders based on the configured naming conventions.\n- **Configuration Loading:** Reads the `export.json` file to get the export configuration. It also allows for interactive overriding of these settings.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file export project, `promptFilesExportConfiguration` for customizing export options, and prompts for resume/restart choice when existing files are found.\n- **Error Handling:** Includes mechanisms to handle potential errors during the export process, such as network issues, API limits, and file validation failures. Each file is assigned a specific status (`success`, `failed`, `skipped`, `invalid`) for comprehensive tracking and troubleshooting.\n</details>\n",
5545
+ "description": "Export Audit trail into a CSV file with selected criteria, and highlight suspect actions\n\nAlso detects updates of Custom Settings values (disable by defining `SKIP_AUDIT_TRAIL_CUSTOM_SETTINGS=true`)\n\nRegular setup actions performed in major orgs are filtered.\n\n- \"\"\n - createScratchOrg\n - changedsenderemail\n - deleteScratchOrg\n - loginasgrantedtopartnerbt\n- Certificate and Key Management\n - insertCertificate\n- Custom App Licenses\n - addeduserpackagelicense\n - granteduserpackagelicense\n - revokeduserpackagelicense\n- Customer Portal\n - createdcustomersuccessuser\n - CSPUserDisabled\n- Currency\n - updateddatedexchrate\n- Data Management\n - queueMembership\n- Email Administration\n - dkimRotationPreparationSuccessful\n - dkimRotationSuccessful\n- External Objects\n - xdsEncryptedFieldChange\n- Groups\n - groupMembership\n- Holidays\n - holiday_insert\n- Inbox mobile and legacy desktop apps\n - enableSIQUserNonEAC\n - siqUserAcceptedTOS\n- Manage Users\n - activateduser\n - createduser\n - changedcommunitynickname\n - changedemail\n - changedfederationid\n - changedpassword\n - changedinteractionuseroffon\n - changedinteractionuseronoff\n - changedmarketinguseroffon\n - changedmarketinguseronoff\n - changedofflineuseroffon\n - changedprofileforuserstdtostd\n - changedprofileforuser\n - changedprofileforusercusttostd\n - changedprofileforuserstdtocust\n - changedroleforusertonone\n - changedroleforuser\n - changedroleforuserfromnone\n - changedUserAdminVerifiedStatusVerified\n - changedUserEmailVerifiedStatusUnverified\n - changedUserEmailVerifiedStatusVerified\n - changedknowledgeuseroffon\n - changedsfcontentuseroffon\n - changedsupportuseroffon\n - changedusername\n - changedUserPhoneNumber\n - changedUserPhoneVerifiedStatusUnverified\n - changedUserPhoneVerifiedStatusVerified\n - deactivateduser\n - deleteAuthenticatorPairing\n - deleteTwoFactorInfo2\n - deleteTwoFactorTempCode\n - frozeuser\n - insertAuthenticatorPairing\n - insertTwoFactorInfo2\n - insertTwoFactorTempCode\n - lightningloginenroll\n - PermSetAssign\n - PermSetGroupAssign\n - PermSetGroupUnassign\n - PermSetLicenseAssign\n - PermSetUnassign\n - PermSetLicenseUnassign\n - registeredUserPhoneNumber\n - resetpassword\n - suNetworkAdminLogin\n - suNetworkAdminLogout\n - suOrgAdminLogin\n - suOrgAdminLogout\n - unfrozeuser\n - useremailchangesent\n- Mobile Administration\n - assigneduserstomobileconfig\n- Reporting Snapshots\n - createdReportJob\n - deletedReportJob\n- Sandboxes\n - DeleteSandbox\n\nBy default, deployment user defined in .sfdx-hardis.yml targetUsername property will be excluded.\n\nYou can define additional users to exclude in .sfdx-hardis.yml **monitoringExcludeUsernames** property.\n\nYou can also add more sections / actions considered as not suspect using property **monitoringAllowedSectionsActions**\n\nExample:\n\n```yaml\nmonitoringExcludeUsernames:\n - deploymentuser@cloudity.com\n - marketingcloud@cloudity.com\n - integration-user@cloudity.com\n\nmonitoringAllowedSectionsActions:\n \"Some section\": [] // Will ignore all actions from such section\n \"Some other section\": [\"actionType1\",\"actionType2\",\"actionType3\"] // Will ignore only those 3 actions from section \"Some other section\". Other actions in the same section will be considered as suspect.\n```\n\n## Excel output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-excel.jpg)\n\n## Local output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-local.jpg)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-suspect-audit-trail/) and can output Grafana, Slack and MsTeams Notifications.\n",
5546
5546
  "examples": [
5547
- "$ sf hardis:org:files:export"
5547
+ "$ sf hardis:org:diagnose:audittrail",
5548
+ "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com",
5549
+ "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com,bertrand@titi.com",
5550
+ "$ sf hardis:org:diagnose:audittrail --lastndays 5"
5548
5551
  ],
5549
5552
  "flags": {
5550
5553
  "json": {
@@ -5562,48 +5565,30 @@
5562
5565
  "multiple": false,
5563
5566
  "type": "option"
5564
5567
  },
5565
- "path": {
5566
- "char": "p",
5567
- "description": "Path to the file export project",
5568
- "name": "path",
5569
- "hasDynamicHelp": false,
5570
- "multiple": false,
5571
- "type": "option"
5572
- },
5573
- "chunksize": {
5574
- "char": "c",
5575
- "description": "Number of records to add in a chunk before it is processed",
5576
- "name": "chunksize",
5577
- "default": 1000,
5568
+ "excludeusers": {
5569
+ "char": "e",
5570
+ "description": "Comma-separated list of usernames to exclude",
5571
+ "name": "excludeusers",
5578
5572
  "hasDynamicHelp": false,
5579
5573
  "multiple": false,
5580
5574
  "type": "option"
5581
5575
  },
5582
- "polltimeout": {
5576
+ "lastndays": {
5583
5577
  "char": "t",
5584
- "description": "Timeout in MS for Bulk API calls",
5585
- "name": "polltimeout",
5586
- "default": 300000,
5578
+ "description": "Number of days to extract from today (included)",
5579
+ "name": "lastndays",
5587
5580
  "hasDynamicHelp": false,
5588
5581
  "multiple": false,
5589
5582
  "type": "option"
5590
5583
  },
5591
- "startchunknumber": {
5592
- "char": "s",
5593
- "description": "Chunk number to start from",
5594
- "name": "startchunknumber",
5595
- "default": 0,
5584
+ "outputfile": {
5585
+ "char": "f",
5586
+ "description": "Force the path and name of output report file. Must end with .csv",
5587
+ "name": "outputfile",
5596
5588
  "hasDynamicHelp": false,
5597
5589
  "multiple": false,
5598
5590
  "type": "option"
5599
5591
  },
5600
- "resume": {
5601
- "char": "r",
5602
- "description": "Resume previous export by checking existing files (default in CI)",
5603
- "name": "resume",
5604
- "allowNo": false,
5605
- "type": "boolean"
5606
- },
5607
5592
  "debug": {
5608
5593
  "char": "d",
5609
5594
  "description": "Activate debug mode (more logs)",
@@ -5642,13 +5627,13 @@
5642
5627
  },
5643
5628
  "hasDynamicHelp": true,
5644
5629
  "hiddenAliases": [],
5645
- "id": "hardis:org:files:export",
5630
+ "id": "hardis:org:diagnose:audittrail",
5646
5631
  "pluginAlias": "sfdx-hardis",
5647
5632
  "pluginName": "sfdx-hardis",
5648
5633
  "pluginType": "core",
5649
5634
  "strict": true,
5650
5635
  "enableJsonFlag": true,
5651
- "title": "Export files",
5636
+ "title": "Diagnose content of Setup Audit Trail",
5652
5637
  "requiresProject": false,
5653
5638
  "isESM": true,
5654
5639
  "relativePath": [
@@ -5656,43 +5641,43 @@
5656
5641
  "commands",
5657
5642
  "hardis",
5658
5643
  "org",
5659
- "files",
5660
- "export.js"
5644
+ "diagnose",
5645
+ "audittrail.js"
5661
5646
  ],
5662
5647
  "aliasPermutations": [],
5663
5648
  "permutations": [
5664
- "hardis:org:files:export",
5665
- "org:hardis:files:export",
5666
- "org:files:hardis:export",
5667
- "org:files:export:hardis",
5668
- "hardis:files:org:export",
5669
- "files:hardis:org:export",
5670
- "files:org:hardis:export",
5671
- "files:org:export:hardis",
5672
- "hardis:files:export:org",
5673
- "files:hardis:export:org",
5674
- "files:export:hardis:org",
5675
- "files:export:org:hardis",
5676
- "hardis:org:export:files",
5677
- "org:hardis:export:files",
5678
- "org:export:hardis:files",
5679
- "org:export:files:hardis",
5680
- "hardis:export:org:files",
5681
- "export:hardis:org:files",
5682
- "export:org:hardis:files",
5683
- "export:org:files:hardis",
5684
- "hardis:export:files:org",
5685
- "export:hardis:files:org",
5686
- "export:files:hardis:org",
5687
- "export:files:org:hardis"
5649
+ "hardis:org:diagnose:audittrail",
5650
+ "org:hardis:diagnose:audittrail",
5651
+ "org:diagnose:hardis:audittrail",
5652
+ "org:diagnose:audittrail:hardis",
5653
+ "hardis:diagnose:org:audittrail",
5654
+ "diagnose:hardis:org:audittrail",
5655
+ "diagnose:org:hardis:audittrail",
5656
+ "diagnose:org:audittrail:hardis",
5657
+ "hardis:diagnose:audittrail:org",
5658
+ "diagnose:hardis:audittrail:org",
5659
+ "diagnose:audittrail:hardis:org",
5660
+ "diagnose:audittrail:org:hardis",
5661
+ "hardis:org:audittrail:diagnose",
5662
+ "org:hardis:audittrail:diagnose",
5663
+ "org:audittrail:hardis:diagnose",
5664
+ "org:audittrail:diagnose:hardis",
5665
+ "hardis:audittrail:org:diagnose",
5666
+ "audittrail:hardis:org:diagnose",
5667
+ "audittrail:org:hardis:diagnose",
5668
+ "audittrail:org:diagnose:hardis",
5669
+ "hardis:audittrail:diagnose:org",
5670
+ "audittrail:hardis:diagnose:org",
5671
+ "audittrail:diagnose:hardis:org",
5672
+ "audittrail:diagnose:org:hardis"
5688
5673
  ]
5689
5674
  },
5690
- "hardis:org:files:import": {
5675
+ "hardis:org:diagnose:instanceupgrade": {
5691
5676
  "aliases": [],
5692
5677
  "args": {},
5693
- "description": "\nThis command facilitates the mass upload of files into Salesforce, allowing you to populate records with associated documents, images, or other file types. It's a crucial tool for data migration, content seeding, or synchronizing external file repositories with Salesforce.\n\nKey functionalities:\n\n- **Configuration-Driven Import:** Relies on an `export.json` file within a designated file export project (created using `sf hardis:org:configure:files`) to determine which files to import and how they should be associated with Salesforce records.\n- **Interactive Project Selection:** If the file import project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Overwrite Option:** The `--overwrite` flag allows you to replace existing files in Salesforce with local versions that have the same name. Be aware that this option doubles the number of API calls used.\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for how to export files, which is often a prerequisite for importing:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesImporter Class:** The core logic is encapsulated within the `FilesImporter` class, which orchestrates the entire import process.\n- **File System Scan:** Scans the local file system within the configured project directory to identify files for import.\n- **Salesforce API Interaction:** Uses Salesforce APIs (e.g., ContentVersion, Attachment) to upload files and associate them with records.\n- **Configuration Loading:** Reads the `export.json` file to get the import configuration, including SOQL queries to identify parent records for file association.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file import project and `prompts` for confirming the overwrite behavior.\n- **Error Handling:** Includes mechanisms to handle potential errors during the import process, such as API limits or file upload failures.\n</details>\n",
5678
+ "description": "\n## Command Behavior\n\n**Retrieves and displays the scheduled upgrade date for a Salesforce org's instance.**\n\nThis command provides crucial information about when your Salesforce instance will be upgraded to the next major release (Spring, Summer, or Winter). This is vital for release planning, testing, and ensuring compatibility with upcoming Salesforce features.\n\nKey functionalities:\n\n- **Instance Identification:** Determines the Salesforce instance name of your target org.\n- **Upgrade Date Retrieval:** Fetches the planned start time of the next major core service upgrade for that instance from the Salesforce Status API.\n- **Days Until Upgrade:** Calculates and displays the number of days remaining until the next major upgrade.\n- **Severity-Based Logging:** Adjusts the log severity (info, warning) based on the proximity of the upgrade date, providing a visual cue for urgency.\n- **Notifications:** Sends notifications to configured channels (e.g., Slack, MS Teams, Grafana) with the upgrade information, making it suitable for automated monitoring.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Query:** It first queries the `Organization` object in Salesforce to get the `InstanceName` of the target org.\n- **Salesforce Status API Integration:** It makes an HTTP GET request to the Salesforce Status API (`https://api.status.salesforce.com/v1/instances/{instanceName}/status`) to retrieve detailed information about the instance, including scheduled maintenances.\n- **Data Parsing:** It parses the JSON response from the Status API to extract the relevant major release upgrade information.\n- **Date Calculation:** Uses the `moment` library to calculate the difference in days between the current date and the planned upgrade date.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including the instance name, upgrade date, and days remaining, along with relevant metrics for monitoring dashboards.\n- **User Feedback:** Provides clear messages to the user about the upgrade status and proximity.\n</details>\n",
5694
5679
  "examples": [
5695
- "$ sf hardis:org:files:import"
5680
+ "$ sf hardis:org:diagnose:instanceupgrade"
5696
5681
  ],
5697
5682
  "flags": {
5698
5683
  "json": {
@@ -5710,21 +5695,6 @@
5710
5695
  "multiple": false,
5711
5696
  "type": "option"
5712
5697
  },
5713
- "path": {
5714
- "char": "p",
5715
- "description": "Path to the file export project",
5716
- "name": "path",
5717
- "hasDynamicHelp": false,
5718
- "multiple": false,
5719
- "type": "option"
5720
- },
5721
- "overwrite": {
5722
- "char": "f",
5723
- "description": "Override existing files (doubles the number of API calls)",
5724
- "name": "overwrite",
5725
- "allowNo": false,
5726
- "type": "boolean"
5727
- },
5728
5698
  "debug": {
5729
5699
  "char": "d",
5730
5700
  "description": "Activate debug mode (more logs)",
@@ -5763,13 +5733,13 @@
5763
5733
  },
5764
5734
  "hasDynamicHelp": true,
5765
5735
  "hiddenAliases": [],
5766
- "id": "hardis:org:files:import",
5736
+ "id": "hardis:org:diagnose:instanceupgrade",
5767
5737
  "pluginAlias": "sfdx-hardis",
5768
5738
  "pluginName": "sfdx-hardis",
5769
5739
  "pluginType": "core",
5770
5740
  "strict": true,
5771
5741
  "enableJsonFlag": true,
5772
- "title": "Import files",
5742
+ "title": "Get Instance Upgrade date",
5773
5743
  "requiresProject": false,
5774
5744
  "isESM": true,
5775
5745
  "relativePath": [
@@ -5777,44 +5747,46 @@
5777
5747
  "commands",
5778
5748
  "hardis",
5779
5749
  "org",
5780
- "files",
5781
- "import.js"
5750
+ "diagnose",
5751
+ "instanceupgrade.js"
5782
5752
  ],
5783
5753
  "aliasPermutations": [],
5784
5754
  "permutations": [
5785
- "hardis:org:files:import",
5786
- "org:hardis:files:import",
5787
- "org:files:hardis:import",
5788
- "org:files:import:hardis",
5789
- "hardis:files:org:import",
5790
- "files:hardis:org:import",
5791
- "files:org:hardis:import",
5792
- "files:org:import:hardis",
5793
- "hardis:files:import:org",
5794
- "files:hardis:import:org",
5795
- "files:import:hardis:org",
5796
- "files:import:org:hardis",
5797
- "hardis:org:import:files",
5798
- "org:hardis:import:files",
5799
- "org:import:hardis:files",
5800
- "org:import:files:hardis",
5801
- "hardis:import:org:files",
5802
- "import:hardis:org:files",
5803
- "import:org:hardis:files",
5804
- "import:org:files:hardis",
5805
- "hardis:import:files:org",
5806
- "import:hardis:files:org",
5807
- "import:files:hardis:org",
5808
- "import:files:org:hardis"
5755
+ "hardis:org:diagnose:instanceupgrade",
5756
+ "org:hardis:diagnose:instanceupgrade",
5757
+ "org:diagnose:hardis:instanceupgrade",
5758
+ "org:diagnose:instanceupgrade:hardis",
5759
+ "hardis:diagnose:org:instanceupgrade",
5760
+ "diagnose:hardis:org:instanceupgrade",
5761
+ "diagnose:org:hardis:instanceupgrade",
5762
+ "diagnose:org:instanceupgrade:hardis",
5763
+ "hardis:diagnose:instanceupgrade:org",
5764
+ "diagnose:hardis:instanceupgrade:org",
5765
+ "diagnose:instanceupgrade:hardis:org",
5766
+ "diagnose:instanceupgrade:org:hardis",
5767
+ "hardis:org:instanceupgrade:diagnose",
5768
+ "org:hardis:instanceupgrade:diagnose",
5769
+ "org:instanceupgrade:hardis:diagnose",
5770
+ "org:instanceupgrade:diagnose:hardis",
5771
+ "hardis:instanceupgrade:org:diagnose",
5772
+ "instanceupgrade:hardis:org:diagnose",
5773
+ "instanceupgrade:org:hardis:diagnose",
5774
+ "instanceupgrade:org:diagnose:hardis",
5775
+ "hardis:instanceupgrade:diagnose:org",
5776
+ "instanceupgrade:hardis:diagnose:org",
5777
+ "instanceupgrade:diagnose:hardis:org",
5778
+ "instanceupgrade:diagnose:org:hardis"
5809
5779
  ]
5810
5780
  },
5811
- "hardis:org:fix:listviewmine": {
5781
+ "hardis:org:diagnose:legacyapi": {
5812
5782
  "aliases": [],
5813
5783
  "args": {},
5814
- "description": "Fix listviews whose scope Mine has been replaced by Everything\n\n[![Invalid scope:Mine, not allowed ? Deploy your ListViews anyway !](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-invalid-scope-mine.jpg)](https://nicolas.vuillamy.fr/invalid-scope-mine-not-allowed-deploy-your-listviews-anyway-443aceca8ac7)\n\nList of ListViews can be:\n\n- read from .sfdx-hardis.yml file in property **listViewsToSetToMine**\n- sent in argument listviews\n\nNote: property **listViewsToSetToMine** can be auto-generated by command hardis:work:save if .sfdx-hardis.yml contains the following configuration\n\n```yaml\nautoCleanTypes:\n - listViewsMine\n```\n\n- Example of sfdx-hardis.yml property `listViewsToSetToMine`:\n\n```yaml\nlistViewsToSetToMine:\n - \"force-app/main/default/objects/Operation__c/listViews/MyCurrentOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Operation__c/listViews/MyFinalizedOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/Default_Opportunity_Pipeline.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MyCurrentSubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MySubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Account/listViews/MyActivePartners.listView-meta.xml\"\n```\n\n- If manually written, this could also be:\n\n```yaml\nlistViewsToSetToMine:\n - \"Operation__c:MyCurrentOperations\"\n - \"Operation__c:MyFinalizedOperations\"\n - \"Opportunity:Default_Opportunity_Pipeline\"\n - \"Opportunity:MyCurrentSubscriptions\"\n - \"Opportunity:MySubscriptions\"\n - \"Account:MyActivePartners\"\n```\n\nTroubleshooting: if you need to run this command from an alpine-linux based docker image, use this workaround in your dockerfile:\n\n```dockerfile\n# Do not use puppeteer embedded chromium\nRUN apk add --update --no-cache chromium\nENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=\"true\"\nENV CHROMIUM_PATH=\"/usr/bin/chromium-browser\"\nENV PUPPETEER_EXECUTABLE_PATH=\"$\\{CHROMIUM_PATH}\" // remove \\ before {\n```\n",
5784
+ "description": "Checks if an org uses retired or someday retired API version\n\n\nSee article below\n\n[![Handle Salesforce API versions Deprecation like a pro](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deprecated-api.jpg)](https://nicolas.vuillamy.fr/handle-salesforce-api-versions-deprecation-like-a-pro-335065f52238)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-deprecated-api-calls/) and can output Grafana, Slack and MsTeams Notifications.\n",
5815
5785
  "examples": [
5816
- "$ sf hardis:org:fix:listviewmine",
5817
- "$ sf hardis:org:fix:listviewmine --listviews Opportunity:MySubscriptions,Account:MyActivePartners"
5786
+ "$ sf hardis:org:diagnose:legacyapi",
5787
+ "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com",
5788
+ "$ sf hardis:org:diagnose:legacyapi --outputfile 'c:/path/to/folder/legacyapi.csv'",
5789
+ "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com --outputfile ./tmp/legacyapi.csv"
5818
5790
  ],
5819
5791
  "flags": {
5820
5792
  "json": {
@@ -5832,10 +5804,28 @@
5832
5804
  "multiple": false,
5833
5805
  "type": "option"
5834
5806
  },
5835
- "listviews": {
5807
+ "eventtype": {
5808
+ "char": "e",
5809
+ "description": "Type of EventLogFile event to analyze",
5810
+ "name": "eventtype",
5811
+ "default": "ApiTotalUsage",
5812
+ "hasDynamicHelp": false,
5813
+ "multiple": false,
5814
+ "type": "option"
5815
+ },
5816
+ "limit": {
5836
5817
  "char": "l",
5837
- "description": "Comma-separated list of listviews following format Object:ListViewName\nExample: Contact:MyContacts,Contact:MyActiveContacts,Opportunity:MYClosedOpportunities",
5838
- "name": "listviews",
5818
+ "description": "Number of latest EventLogFile events to analyze",
5819
+ "name": "limit",
5820
+ "default": 999,
5821
+ "hasDynamicHelp": false,
5822
+ "multiple": false,
5823
+ "type": "option"
5824
+ },
5825
+ "outputfile": {
5826
+ "char": "f",
5827
+ "description": "Force the path and name of output report file. Must end with .csv",
5828
+ "name": "outputfile",
5839
5829
  "hasDynamicHelp": false,
5840
5830
  "multiple": false,
5841
5831
  "type": "option"
@@ -5878,59 +5868,57 @@
5878
5868
  },
5879
5869
  "hasDynamicHelp": true,
5880
5870
  "hiddenAliases": [],
5881
- "id": "hardis:org:fix:listviewmine",
5871
+ "id": "hardis:org:diagnose:legacyapi",
5882
5872
  "pluginAlias": "sfdx-hardis",
5883
5873
  "pluginName": "sfdx-hardis",
5884
5874
  "pluginType": "core",
5885
5875
  "strict": true,
5886
5876
  "enableJsonFlag": true,
5887
- "title": "Fix listviews with ",
5888
- "requiresProject": true,
5877
+ "title": "Check for legacy API use",
5878
+ "requiresProject": false,
5889
5879
  "isESM": true,
5890
5880
  "relativePath": [
5891
5881
  "lib",
5892
5882
  "commands",
5893
5883
  "hardis",
5894
5884
  "org",
5895
- "fix",
5896
- "listviewmine.js"
5885
+ "diagnose",
5886
+ "legacyapi.js"
5897
5887
  ],
5898
5888
  "aliasPermutations": [],
5899
5889
  "permutations": [
5900
- "hardis:org:fix:listviewmine",
5901
- "org:hardis:fix:listviewmine",
5902
- "org:fix:hardis:listviewmine",
5903
- "org:fix:listviewmine:hardis",
5904
- "hardis:fix:org:listviewmine",
5905
- "fix:hardis:org:listviewmine",
5906
- "fix:org:hardis:listviewmine",
5907
- "fix:org:listviewmine:hardis",
5908
- "hardis:fix:listviewmine:org",
5909
- "fix:hardis:listviewmine:org",
5910
- "fix:listviewmine:hardis:org",
5911
- "fix:listviewmine:org:hardis",
5912
- "hardis:org:listviewmine:fix",
5913
- "org:hardis:listviewmine:fix",
5914
- "org:listviewmine:hardis:fix",
5915
- "org:listviewmine:fix:hardis",
5916
- "hardis:listviewmine:org:fix",
5917
- "listviewmine:hardis:org:fix",
5918
- "listviewmine:org:hardis:fix",
5919
- "listviewmine:org:fix:hardis",
5920
- "hardis:listviewmine:fix:org",
5921
- "listviewmine:hardis:fix:org",
5922
- "listviewmine:fix:hardis:org",
5923
- "listviewmine:fix:org:hardis"
5890
+ "hardis:org:diagnose:legacyapi",
5891
+ "org:hardis:diagnose:legacyapi",
5892
+ "org:diagnose:hardis:legacyapi",
5893
+ "org:diagnose:legacyapi:hardis",
5894
+ "hardis:diagnose:org:legacyapi",
5895
+ "diagnose:hardis:org:legacyapi",
5896
+ "diagnose:org:hardis:legacyapi",
5897
+ "diagnose:org:legacyapi:hardis",
5898
+ "hardis:diagnose:legacyapi:org",
5899
+ "diagnose:hardis:legacyapi:org",
5900
+ "diagnose:legacyapi:hardis:org",
5901
+ "diagnose:legacyapi:org:hardis",
5902
+ "hardis:org:legacyapi:diagnose",
5903
+ "org:hardis:legacyapi:diagnose",
5904
+ "org:legacyapi:hardis:diagnose",
5905
+ "org:legacyapi:diagnose:hardis",
5906
+ "hardis:legacyapi:org:diagnose",
5907
+ "legacyapi:hardis:org:diagnose",
5908
+ "legacyapi:org:hardis:diagnose",
5909
+ "legacyapi:org:diagnose:hardis",
5910
+ "hardis:legacyapi:diagnose:org",
5911
+ "legacyapi:hardis:diagnose:org",
5912
+ "legacyapi:diagnose:hardis:org",
5913
+ "legacyapi:diagnose:org:hardis"
5924
5914
  ]
5925
5915
  },
5926
- "hardis:org:generate:packagexmlfull": {
5916
+ "hardis:org:diagnose:licenses": {
5927
5917
  "aliases": [],
5928
5918
  "args": {},
5929
- "description": "\n## Command Behavior\n\n**Generates a comprehensive `package.xml` file for a Salesforce org, including all metadata components, even managed ones.**\n\nThis command is essential for various Salesforce development and administration tasks, especially when you need a complete snapshot of an org's metadata. It goes beyond typical source tracking by including managed package components, which is crucial for understanding the full metadata footprint of an org.\n\nKey functionalities:\n\n- **Full Org Metadata Retrieval:** Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a complete list of all metadata types and their members.\n- **Managed Package Inclusion:** Unlike standard source retrieval, this command explicitly includes metadata from managed packages, providing a truly comprehensive `package.xml`.\n- **Customizable Output:** Allows you to specify the output file path for the generated `package.xml`.\n- **Interactive Org Selection:** If no target org is specified, it interactively prompts the user to choose an org. (or use --no-prompt to skip this step)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce Metadata API Interaction:** It leverages the Salesforce Metadata API to list all available metadata types and then retrieve all components for each type.\n- **`buildOrgManifest` Utility:** The core logic for querying the org's metadata and constructing the `package.xml` is encapsulated within the `buildOrgManifest` utility function.\n- **XML Generation:** It dynamically builds the XML structure of the `package.xml` file, including the `types` and `members` elements for all retrieved metadata.\n- **File System Operations:** It writes the generated `package.xml` file to the specified output path.\n- **Interactive Prompts:** Uses `promptOrgUsernameDefault` to guide the user in selecting the target Salesforce org.\n</details>\n",
5919
+ "description": "\n**Lists and analyzes User Licenses and Permission Set Licenses subscribed and used in a Salesforce org.**\n\nThis command provides a comprehensive overview of your Salesforce license consumption. It's particularly useful for:\n\n- **License Management:** Understanding which licenses are active, how many are available, and how many are being used.\n- **Cost Optimization:** Identifying unused or underutilized licenses that could be reallocated or decommissioned.\n- **Compliance:** Ensuring that your organization is compliant with Salesforce licensing agreements.\n- **Monitoring:** Tracking license usage trends over time.\n\nKey functionalities:\n\n- **User License Details:** Retrieves information about standard and custom User Licenses, including `MasterLabel`, `Name`, `TotalLicenses`, and `UsedLicenses`.\n- **Permission Set License Details:** Retrieves information about Permission Set Licenses, including `MasterLabel`, `PermissionSetLicenseKey`, `TotalLicenses`, and `UsedLicenses`.\n- **Used Licenses Filter:** The `--usedonly` flag allows you to filter the report to show only licenses that have at least one `UsedLicenses` count greater than zero.\n- **CSV Report Generation:** Generates a CSV file containing all the retrieved license information, suitable for detailed analysis.\n- **Notifications:** Sends notifications to configured channels (e.g., Grafana, Slack, MS Teams) with a summary of license usage, including lists of active and used licenses.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It executes SOQL queries against the `UserLicense` and `PermissionSetLicense` objects in Salesforce to retrieve license data.\n- **Data Transformation:** It processes the query results, reformatting the data to be more readable and consistent for reporting purposes (e.g., removing `Id` and `attributes`, renaming `PermissionSetLicenseKey` to `Name`).\n- **Data Aggregation:** It aggregates license information, creating a `licensesByKey` object for quick lookups and a `usedLicenses` array for a concise list of actively used licenses.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of license data.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Feedback:** Provides clear messages to the user about the license extraction process and the used licenses.\n</details>\n",
5930
5920
  "examples": [
5931
- "$ sf hardis:org:generate:packagexmlfull",
5932
- "$ sf hardis:org:generate:packagexmlfull --outputfile /tmp/packagexmlfull.xml",
5933
- "$ sf hardis:org:generate:packagexmlfull --target-org nico@example.com"
5921
+ "$ sf hardis:org:diagnose:licenses"
5934
5922
  ],
5935
5923
  "flags": {
5936
5924
  "json": {
@@ -5949,12 +5937,20 @@
5949
5937
  "type": "option"
5950
5938
  },
5951
5939
  "outputfile": {
5952
- "description": "Output package.xml file",
5940
+ "char": "f",
5941
+ "description": "Force the path and name of output report file. Must end with .csv",
5953
5942
  "name": "outputfile",
5954
5943
  "hasDynamicHelp": false,
5955
5944
  "multiple": false,
5956
5945
  "type": "option"
5957
5946
  },
5947
+ "usedonly": {
5948
+ "char": "u",
5949
+ "description": "Filter to have only used licenses",
5950
+ "name": "usedonly",
5951
+ "allowNo": false,
5952
+ "type": "boolean"
5953
+ },
5958
5954
  "debug": {
5959
5955
  "char": "d",
5960
5956
  "description": "Activate debug mode (more logs)",
@@ -5962,13 +5958,6 @@
5962
5958
  "allowNo": false,
5963
5959
  "type": "boolean"
5964
5960
  },
5965
- "no-prompt": {
5966
- "char": "n",
5967
- "description": "Do not prompt for org username, use the default one",
5968
- "name": "no-prompt",
5969
- "allowNo": false,
5970
- "type": "boolean"
5971
- },
5972
5961
  "websocket": {
5973
5962
  "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
5974
5963
  "name": "websocket",
@@ -6000,13 +5989,13 @@
6000
5989
  },
6001
5990
  "hasDynamicHelp": true,
6002
5991
  "hiddenAliases": [],
6003
- "id": "hardis:org:generate:packagexmlfull",
5992
+ "id": "hardis:org:diagnose:licenses",
6004
5993
  "pluginAlias": "sfdx-hardis",
6005
5994
  "pluginName": "sfdx-hardis",
6006
5995
  "pluginType": "core",
6007
5996
  "strict": true,
6008
5997
  "enableJsonFlag": true,
6009
- "title": "Generate Full Org package.xml",
5998
+ "title": "List licenses subscribed and used in a Salesforce org",
6010
5999
  "requiresProject": false,
6011
6000
  "isESM": true,
6012
6001
  "relativePath": [
@@ -6014,43 +6003,43 @@
6014
6003
  "commands",
6015
6004
  "hardis",
6016
6005
  "org",
6017
- "generate",
6018
- "packagexmlfull.js"
6006
+ "diagnose",
6007
+ "licenses.js"
6019
6008
  ],
6020
6009
  "aliasPermutations": [],
6021
6010
  "permutations": [
6022
- "hardis:org:generate:packagexmlfull",
6023
- "org:hardis:generate:packagexmlfull",
6024
- "org:generate:hardis:packagexmlfull",
6025
- "org:generate:packagexmlfull:hardis",
6026
- "hardis:generate:org:packagexmlfull",
6027
- "generate:hardis:org:packagexmlfull",
6028
- "generate:org:hardis:packagexmlfull",
6029
- "generate:org:packagexmlfull:hardis",
6030
- "hardis:generate:packagexmlfull:org",
6031
- "generate:hardis:packagexmlfull:org",
6032
- "generate:packagexmlfull:hardis:org",
6033
- "generate:packagexmlfull:org:hardis",
6034
- "hardis:org:packagexmlfull:generate",
6035
- "org:hardis:packagexmlfull:generate",
6036
- "org:packagexmlfull:hardis:generate",
6037
- "org:packagexmlfull:generate:hardis",
6038
- "hardis:packagexmlfull:org:generate",
6039
- "packagexmlfull:hardis:org:generate",
6040
- "packagexmlfull:org:hardis:generate",
6041
- "packagexmlfull:org:generate:hardis",
6042
- "hardis:packagexmlfull:generate:org",
6043
- "packagexmlfull:hardis:generate:org",
6044
- "packagexmlfull:generate:hardis:org",
6045
- "packagexmlfull:generate:org:hardis"
6011
+ "hardis:org:diagnose:licenses",
6012
+ "org:hardis:diagnose:licenses",
6013
+ "org:diagnose:hardis:licenses",
6014
+ "org:diagnose:licenses:hardis",
6015
+ "hardis:diagnose:org:licenses",
6016
+ "diagnose:hardis:org:licenses",
6017
+ "diagnose:org:hardis:licenses",
6018
+ "diagnose:org:licenses:hardis",
6019
+ "hardis:diagnose:licenses:org",
6020
+ "diagnose:hardis:licenses:org",
6021
+ "diagnose:licenses:hardis:org",
6022
+ "diagnose:licenses:org:hardis",
6023
+ "hardis:org:licenses:diagnose",
6024
+ "org:hardis:licenses:diagnose",
6025
+ "org:licenses:hardis:diagnose",
6026
+ "org:licenses:diagnose:hardis",
6027
+ "hardis:licenses:org:diagnose",
6028
+ "licenses:hardis:org:diagnose",
6029
+ "licenses:org:hardis:diagnose",
6030
+ "licenses:org:diagnose:hardis",
6031
+ "hardis:licenses:diagnose:org",
6032
+ "licenses:hardis:diagnose:org",
6033
+ "licenses:diagnose:hardis:org",
6034
+ "licenses:diagnose:org:hardis"
6046
6035
  ]
6047
6036
  },
6048
- "hardis:org:monitor:all": {
6037
+ "hardis:org:diagnose:releaseupdates": {
6049
6038
  "aliases": [],
6050
6039
  "args": {},
6051
- "description": "Monitor org, generate reports and sends notifications\n\nYou can disable some commands defining either a **monitoringDisable** property in `.sfdx-hardis.yml`, or a comma separated list in env variable **MONITORING_DISABLE**\n\nExample in .sfdx-hardis.yml:\n \n```yaml\nmonitoringDisable:\n - METADATA_STATUS\n - MISSING_ATTRIBUTES\n - UNUSED_METADATAS\n```\n \nExample in env var:\n\n```sh\nMONITORING_DISABLE=METADATA_STATUS,MISSING_ATTRIBUTES,UNUSED_METADATAS\n```\n\nA [default list of monitoring commands](https://sfdx-hardis.cloudity.com/salesforce-monitoring-home/#monitoring-commands) is used, if you want to override it you can define property **monitoringCommands** in your .sfdx-hardis.yml file\n\nExample:\n\n```yaml\nmonitoringCommands:\n - title: My Custom command\n command: sf my:custom:command\n - title: My Custom command 2\n command: sf my:other:custom:command\n```\n\nYou can force the daily run of all commands by defining env var `MONITORING_IGNORE_FREQUENCY=true`\n\nThe default list of commands is the following:\n\n| Key | Description | Command | Frequency |\n| :---: | :---- | :---- | :-----: |\n| [AUDIT_TRAIL](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/audittrail) | Detect suspect setup actions in major org | [sf hardis:org:diagnose:audittrail](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/audittrail) | daily |\n| [LEGACY_API](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/legacyapi) | Detect calls to deprecated API versions | [sf hardis:org:diagnose:legacyapi](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/legacyapi) | daily |\n| [ORG_LIMITS](https://sfdx-hardis.cloudity.com/hardis/org/monitor/limits) | Detect if org limits are close to be reached | [sf hardis:org:monitor:limits](https://sfdx-hardis.cloudity.com/hardis/org/monitor/limits) | daily |\n| [UNSECURED_CONNECTED_APPS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unsecure-connected-apps) | Detect unsecured Connected Apps in an org | [sf hardis:org:diagnose:unsecure-connected-apps](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unsecure-connected-apps) | daily |\n| [LICENSES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/licenses) | Extract licenses information | [sf hardis:org:diagnose:licenses](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/licenses) | weekly |\n| [LINT_ACCESS](https://sfdx-hardis.cloudity.com/hardis/lint/access) | Detect custom elements with no access rights defined in permission sets | [sf hardis:lint:access](https://sfdx-hardis.cloudity.com/hardis/lint/access) | weekly |\n| [UNUSED_LICENSES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedlicenses) | Detect permission set licenses that are assigned to users that do not need them | [sf hardis:org:diagnose:unusedlicenses](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedlicenses) | weekly |\n| [UNUSED_USERS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | Detect active users without recent logins | [sf hardis:org:diagnose:unusedusers](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | weekly |\n| [ACTIVE_USERS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | Detect active users with recent logins | [sf hardis:org:diagnose:unusedusers --returnactiveusers](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | weekly |\n| [ORG_INFO](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/instanceupgrade) | Get org info + SF instance info + next major upgrade date | [sf hardis:org:diagnose:instanceupgrade](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/instanceupgrade) | weekly |\n| [RELEASE_UPDATES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/releaseupdates) | Gather warnings about incoming and overdue Release Updates | [sf hardis:org:diagnose:releaseupdates](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/releaseupdates) | weekly |\n| [UNUSED_METADATAS](https://sfdx-hardis.cloudity.com/hardis/lint/unusedmetadatas) | Detect custom labels and custom permissions that are not in use | [sf hardis:lint:unusedmetadatas](https://sfdx-hardis.cloudity.com/hardis/lint/unusedmetadatas) | weekly |\n| [UNUSED_APEX_CLASSES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-apex-classes) | Detect unused Apex classes in an org | [sf hardis:org:diagnose:unused-apex-classes](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-apex-classes) | weekly |\n| [CONNECTED_APPS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-connected-apps) | Detect unused Connected Apps in an org | [sf hardis:org:diagnose:unused-connected-apps](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-connected-apps) | weekly |\n| [METADATA_STATUS](https://sfdx-hardis.cloudity.com/hardis/lint/metadatastatus) | Detect inactive metadata | [sf hardis:lint:metadatastatus](https://sfdx-hardis.cloudity.com/hardis/lint/metadatastatus) | weekly |\n| [MISSING_ATTRIBUTES](https://sfdx-hardis.cloudity.com/hardis/lint/missingattributes) | Detect missing description on custom field | [sf hardis:lint:missingattributes](https://sfdx-hardis.cloudity.com/hardis/lint/missingattributes) | weekly |\n\n",
6040
+ "description": "Export Release Updates into a CSV file with selected criteria, and highlight Release Updates that should be checked.\n\nBefore publishing **Breaking Changes** ❌, Salesforce announce them in the setup menu [**Release Updates**](https://help.salesforce.com/s/articleView?id=sf.release_updates.htm&type=5)\n\n⚠️ Some of them are very important, because if you don't make the related upgrades in time (ex: before Winter 25) , your production org can crash !\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-release-updates/) and can output Grafana, Slack and MsTeams Notifications.\n",
6052
6041
  "examples": [
6053
- "$ sf hardis:org:monitor:all"
6042
+ "$ sf hardis:org:diagnose:releaseupdates"
6054
6043
  ],
6055
6044
  "flags": {
6056
6045
  "json": {
@@ -6068,6 +6057,14 @@
6068
6057
  "multiple": false,
6069
6058
  "type": "option"
6070
6059
  },
6060
+ "outputfile": {
6061
+ "char": "f",
6062
+ "description": "Force the path and name of output report file. Must end with .csv",
6063
+ "name": "outputfile",
6064
+ "hasDynamicHelp": false,
6065
+ "multiple": false,
6066
+ "type": "option"
6067
+ },
6071
6068
  "debug": {
6072
6069
  "char": "d",
6073
6070
  "description": "Activate debug mode (more logs)",
@@ -6106,159 +6103,57 @@
6106
6103
  },
6107
6104
  "hasDynamicHelp": true,
6108
6105
  "hiddenAliases": [],
6109
- "id": "hardis:org:monitor:all",
6106
+ "id": "hardis:org:diagnose:releaseupdates",
6110
6107
  "pluginAlias": "sfdx-hardis",
6111
6108
  "pluginName": "sfdx-hardis",
6112
6109
  "pluginType": "core",
6113
6110
  "strict": true,
6114
6111
  "enableJsonFlag": true,
6115
- "title": "Monitor org",
6116
- "monitoringCommandsDefault": [
6117
- {
6118
- "key": "AUDIT_TRAIL",
6119
- "title": "Detect suspect setup actions in major org",
6120
- "command": "sf hardis:org:diagnose:audittrail",
6121
- "frequency": "daily"
6122
- },
6123
- {
6124
- "key": "LEGACY_API",
6125
- "title": "Detect calls to deprecated API versions",
6126
- "command": "sf hardis:org:diagnose:legacyapi",
6127
- "frequency": "daily"
6128
- },
6129
- {
6130
- "key": "ORG_LIMITS",
6131
- "title": "Detect if org limits are close to be reached",
6132
- "command": "sf hardis:org:monitor:limits",
6133
- "frequency": "daily"
6134
- },
6135
- {
6136
- "key": "UNSECURED_CONNECTED_APPS",
6137
- "title": "Detect unsecured Connected Apps in an org",
6138
- "command": "sf hardis:org:diagnose:unsecure-connected-apps",
6139
- "frequency": "daily"
6140
- },
6141
- {
6142
- "key": "LICENSES",
6143
- "title": "Extract licenses information",
6144
- "command": "sf hardis:org:diagnose:licenses",
6145
- "frequency": "weekly"
6146
- },
6147
- {
6148
- "key": "LINT_ACCESS",
6149
- "title": "Detect custom elements with no access rights defined in permission sets",
6150
- "command": "sf hardis:lint:access",
6151
- "frequency": "weekly"
6152
- },
6153
- {
6154
- "key": "UNUSED_LICENSES",
6155
- "title": "Detect permission set licenses that are assigned to users that do not need them",
6156
- "command": "sf hardis:org:diagnose:unusedlicenses",
6157
- "frequency": "weekly"
6158
- },
6159
- {
6160
- "key": "UNUSED_USERS",
6161
- "title": "Detect active users without recent logins",
6162
- "command": "sf hardis:org:diagnose:unusedusers",
6163
- "frequency": "weekly"
6164
- },
6165
- {
6166
- "key": "ACTIVE_USERS",
6167
- "title": "Detect active users with recent logins",
6168
- "command": "sf hardis:org:diagnose:unusedusers --returnactiveusers",
6169
- "frequency": "weekly"
6170
- },
6171
- {
6172
- "key": "ORG_INFO",
6173
- "title": "Get org info + SF instance info + next major upgrade date",
6174
- "command": "sf hardis:org:diagnose:instanceupgrade",
6175
- "frequency": "weekly"
6176
- },
6177
- {
6178
- "key": "RELEASE_UPDATES",
6179
- "title": "Gather warnings about incoming and overdue Release Updates",
6180
- "command": "sf hardis:org:diagnose:releaseupdates",
6181
- "frequency": "weekly"
6182
- },
6183
- {
6184
- "key": "UNUSED_METADATAS",
6185
- "title": "Detect custom labels and custom permissions that are not in use",
6186
- "command": "sf hardis:lint:unusedmetadatas",
6187
- "frequency": "weekly"
6188
- },
6189
- {
6190
- "key": "UNUSED_APEX_CLASSES",
6191
- "title": "Detect unused Apex classes in an org",
6192
- "command": "sf hardis:org:diagnose:unused-apex-classes",
6193
- "frequency": "weekly"
6194
- },
6195
- {
6196
- "key": "CONNECTED_APPS",
6197
- "title": "Detect unused Connected Apps in an org",
6198
- "command": "sf hardis:org:diagnose:unused-connected-apps",
6199
- "frequency": "weekly"
6200
- },
6201
- {
6202
- "key": "METADATA_STATUS",
6203
- "title": "Detect inactive metadata",
6204
- "command": "sf hardis:lint:metadatastatus",
6205
- "frequency": "weekly"
6206
- },
6207
- {
6208
- "key": "MISSING_ATTRIBUTES",
6209
- "title": "Detect missing description on custom field",
6210
- "command": "sf hardis:lint:missingattributes",
6211
- "frequency": "weekly"
6212
- }
6213
- ],
6214
- "requiresProject": true,
6215
- "triggerNotification": true,
6112
+ "title": "Check Release Updates of an org",
6113
+ "requiresProject": false,
6216
6114
  "isESM": true,
6217
6115
  "relativePath": [
6218
6116
  "lib",
6219
6117
  "commands",
6220
6118
  "hardis",
6221
6119
  "org",
6222
- "monitor",
6223
- "all.js"
6120
+ "diagnose",
6121
+ "releaseupdates.js"
6224
6122
  ],
6225
6123
  "aliasPermutations": [],
6226
6124
  "permutations": [
6227
- "hardis:org:monitor:all",
6228
- "org:hardis:monitor:all",
6229
- "org:monitor:hardis:all",
6230
- "org:monitor:all:hardis",
6231
- "hardis:monitor:org:all",
6232
- "monitor:hardis:org:all",
6233
- "monitor:org:hardis:all",
6234
- "monitor:org:all:hardis",
6235
- "hardis:monitor:all:org",
6236
- "monitor:hardis:all:org",
6237
- "monitor:all:hardis:org",
6238
- "monitor:all:org:hardis",
6239
- "hardis:org:all:monitor",
6240
- "org:hardis:all:monitor",
6241
- "org:all:hardis:monitor",
6242
- "org:all:monitor:hardis",
6243
- "hardis:all:org:monitor",
6244
- "all:hardis:org:monitor",
6245
- "all:org:hardis:monitor",
6246
- "all:org:monitor:hardis",
6247
- "hardis:all:monitor:org",
6248
- "all:hardis:monitor:org",
6249
- "all:monitor:hardis:org",
6250
- "all:monitor:org:hardis"
6125
+ "hardis:org:diagnose:releaseupdates",
6126
+ "org:hardis:diagnose:releaseupdates",
6127
+ "org:diagnose:hardis:releaseupdates",
6128
+ "org:diagnose:releaseupdates:hardis",
6129
+ "hardis:diagnose:org:releaseupdates",
6130
+ "diagnose:hardis:org:releaseupdates",
6131
+ "diagnose:org:hardis:releaseupdates",
6132
+ "diagnose:org:releaseupdates:hardis",
6133
+ "hardis:diagnose:releaseupdates:org",
6134
+ "diagnose:hardis:releaseupdates:org",
6135
+ "diagnose:releaseupdates:hardis:org",
6136
+ "diagnose:releaseupdates:org:hardis",
6137
+ "hardis:org:releaseupdates:diagnose",
6138
+ "org:hardis:releaseupdates:diagnose",
6139
+ "org:releaseupdates:hardis:diagnose",
6140
+ "org:releaseupdates:diagnose:hardis",
6141
+ "hardis:releaseupdates:org:diagnose",
6142
+ "releaseupdates:hardis:org:diagnose",
6143
+ "releaseupdates:org:hardis:diagnose",
6144
+ "releaseupdates:org:diagnose:hardis",
6145
+ "hardis:releaseupdates:diagnose:org",
6146
+ "releaseupdates:hardis:diagnose:org",
6147
+ "releaseupdates:diagnose:hardis:org",
6148
+ "releaseupdates:diagnose:org:hardis"
6251
6149
  ]
6252
6150
  },
6253
- "hardis:org:monitor:backup": {
6151
+ "hardis:org:diagnose:unsecure-connected-apps": {
6254
6152
  "aliases": [],
6255
6153
  "args": {},
6256
- "description": "Retrieve sfdx sources in the context of a monitoring backup\n\nThe command exists in 2 modes: filtered(default & recommended) and full.\n\n## Filtered mode (default, better performances)\n\nAutomatically skips metadatas from installed packages with namespace. \n\nYou can remove more metadata types from backup, especially in case you have too many metadatas and that provokes a crash, using:\n\n- Manual update of `manifest/package-skip-items.xml` config file (then commit & push in the same branch)\n\n - Works with full wildcard (`<members>*</members>`) , named metadata (`<members>Account.Name</members>`) or partial wildcards names (`<members>pi__*</members>` , `<members>*__dlm</members>` , or `<members>prefix*suffix</members>`)\n\n- Environment variable MONITORING_BACKUP_SKIP_METADATA_TYPES (example: `MONITORING_BACKUP_SKIP_METADATA_TYPES=CustomLabel,StaticResource,Translation`): that will be applied to all monitoring branches.\n\n## Full mode\n\nActivate it with **--full** parameter, or variable MONITORING_BACKUP_MODE_FULL=true\n\nIgnores filters (namespaces items & manifest/package-skip-items.xml) to retrieve ALL metadatas, including those you might not care about (reports, translations...)\n\nAs we can retrieve only 10000 files by call, the list of all metadatas will be chunked to make multiple calls (and take more time than filtered mode)\n\n- if you use `--full-apply-filters` , manifest/package-skip-items.xml and MONITORING_BACKUP_SKIP_METADATA_TYPES filters will be applied anyway\n- if you use `--exclude-namespaces` , namespaced items will be ignored\n\n_With those both options, it's like if you are not using --full, but with chunked metadata download_\n\n## In CI/CD\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-metadata-backup/) and can output Grafana, Slack and MsTeams Notifications.\n\n## Troubleshooting\n\nIf you have unknown errors (it happens !), you can investigate using the full command with smaller chunks.\n\nExample: `sf hardis:org:monitor:backup --full --exclude-namespaces --full-apply-filters --max-by-chunk 500`\n\nIt will allow you the identify the responsible metadata and ignore it using package-skip-items.xml or MONITORING_BACKUP_SKIP_METADATA_TYPES env variable.\n\n## Documentation\n\n[Doc generation (including visual flows)](https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/) is triggered at the end of the command.\n\nIf you want to also upload HTML Documentation on your Salesforce Org as static resource, use variable **SFDX_HARDIS_DOC_DEPLOY_TO_ORG=\"true\"**\n\nIf you want to also upload HTML Documentation on Cloudflare, use variable **SFDX_HARDIS_DOC_DEPLOY_TO_CLOUDFLARE=\"true\"**\n\n- If you want to generate the documentation in multiple languages, define variable SFDX_DOC_LANGUAGES (ex: SFDX_DOC_LANGUAGES=en,fr,de)\n- You can define one Cloudflare site by language, for example with the following variables:\n - CLOUDFLARE_PROJECT_NAME_EN=cloudity-demo-english\n - CLOUDFLARE_PROJECT_NAME_FR=cloudity-demo-french\n - CLOUDFLARE_PROJECT_NAME_DE=cloudity-demo-german\n\nIf Flow history doc always display a single state, you probably need to update your workflow configuration:\n\n- on Gitlab: Env variable [`GIT_FETCH_EXTRA_FLAGS: --depth 10000`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/.gitlab-ci.yml#L11)\n- on GitHub: [`fetch-depth: 0`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/.github/workflows/org-monitoring.yml#L58)\n- on Azure: [`fetchDepth: \"0\"`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/azure-pipelines.yml#L39)\n- on Bitbucket: [`step: clone: depth: full`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/bitbucket-pipelines.yml#L18)\n",
6154
+ "description": "\n## Command Behavior\n\n**Detects unsecured Connected Apps in a Salesforce org and generates detailed reports for security analysis.**\n\nThis command is a critical security diagnostic tool that helps administrators identify Connected Apps that may pose security risks due to improper configuration. It provides comprehensive analysis of OAuth tokens and Connected App security settings to ensure proper access control.\n\nKey functionalities:\n\n- **OAuth Token Analysis:** Queries all OAuth tokens in the org using SOQL to retrieve comprehensive token information including app names, users, authorization status, and usage statistics.\n- **Security Status Assessment:** Evaluates each Connected App's security configuration by checking the `IsUsingAdminAuthorization` flag to determine if admin pre-approval is required.\n- **Unsecured App Detection:** Identifies Connected Apps that allow users to authorize themselves without admin approval, which can pose security risks.\n- **Detailed Reporting:** Generates two comprehensive CSV reports:\n - **OAuth Tokens Report:** Lists all OAuth tokens with security status, user information, and usage data\n - **Connected Apps Summary:** Aggregates unsecured Connected Apps with counts of associated OAuth tokens\n- **Visual Indicators:** Uses status icons (❌ for unsecured, for secured) to provide immediate visual feedback on security status.\n- **Security Recommendations:** Provides actionable guidance on how to secure Connected Apps through proper configuration.\n- **Notifications:** Sends alerts to configured channels (Grafana, Slack, MS Teams) with security findings and attached reports.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-org-security/) and can output Grafana, Slack and MsTeams Notifications.\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/jHv8yrSK8Dg\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query Execution:** Executes a comprehensive SOQL query on the `OauthToken` object, joining with `AppMenuItem` and `User` objects to gather complete security context.\n- **Security Analysis Logic:** Analyzes the `AppMenuItem.IsUsingAdminAuthorization` field to determine if a Connected App requires admin pre-approval for user authorization.\n- **Data Transformation:** Processes raw SOQL results to add security status indicators and reorganize data for optimal reporting and analysis.\n- **Aggregation Processing:** Groups OAuth tokens by Connected App name to provide summary statistics and identify the most problematic applications.\n- **Report Generation:** Uses `generateCsvFile` to create structured CSV reports with proper formatting and metadata for easy analysis and sharing.\n- **Notification Integration:** Integrates with the `NotifProvider` to send security alerts with detailed metrics, including the number of unsecured Connected Apps and associated OAuth tokens.\n- **File Management:** Generates multiple output formats (CSV, XLSX) and manages file paths using `generateReportPath` for consistent report organization.\n- **Connection Management:** Uses `setConnectionVariables` to ensure proper authentication context for notification providers that require org connection details.\n</details>\n",
6257
6155
  "examples": [
6258
- "$ sf hardis:org:monitor:backup",
6259
- "$ sf hardis:org:monitor:backup --full",
6260
- "$ sf hardis:org:monitor:backup --full --exclude-namespaces",
6261
- "$ sf hardis:org:monitor:backup --full --exclude-namespaces --full-apply-filters"
6156
+ "$ sf hardis:org:diagnose:unsecure-connected-apps"
6262
6157
  ],
6263
6158
  "flags": {
6264
6159
  "json": {
@@ -6276,49 +6171,6 @@
6276
6171
  "multiple": false,
6277
6172
  "type": "option"
6278
6173
  },
6279
- "full": {
6280
- "description": "Dot not take in account filtering using package-skip-items.xml and MONITORING_BACKUP_SKIP_METADATA_TYPES. Efficient but much much slower !",
6281
- "name": "full",
6282
- "allowNo": false,
6283
- "type": "boolean"
6284
- },
6285
- "max-by-chunk": {
6286
- "char": "m",
6287
- "description": "If mode --full is activated, maximum number of metadatas in a package.xml chunk",
6288
- "name": "max-by-chunk",
6289
- "default": 3000,
6290
- "hasDynamicHelp": false,
6291
- "multiple": false,
6292
- "type": "option"
6293
- },
6294
- "exclude-namespaces": {
6295
- "char": "e",
6296
- "description": "If mode --full is activated, exclude namespaced metadatas",
6297
- "name": "exclude-namespaces",
6298
- "allowNo": false,
6299
- "type": "boolean"
6300
- },
6301
- "full-apply-filters": {
6302
- "char": "z",
6303
- "description": "If mode --full is activated, apply filters of manifest/package-skip-items.xml and MONITORING_BACKUP_SKIP_METADATA_TYPES anyway",
6304
- "name": "full-apply-filters",
6305
- "allowNo": false,
6306
- "type": "boolean"
6307
- },
6308
- "start-chunk": {
6309
- "description": "Use this parameter to troubleshoot a specific chunk. It will be used as the first chunk to retrieve",
6310
- "name": "start-chunk",
6311
- "default": 1,
6312
- "hasDynamicHelp": false,
6313
- "multiple": false,
6314
- "type": "option"
6315
- },
6316
- "skip-doc": {
6317
- "description": "Skip the generation of project documentation at the end of the command",
6318
- "name": "skip-doc",
6319
- "allowNo": false,
6320
- "type": "boolean"
6321
- },
6322
6174
  "outputfile": {
6323
6175
  "char": "f",
6324
6176
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6365,58 +6217,58 @@
6365
6217
  },
6366
6218
  "hasDynamicHelp": true,
6367
6219
  "hiddenAliases": [],
6368
- "id": "hardis:org:monitor:backup",
6220
+ "id": "hardis:org:diagnose:unsecure-connected-apps",
6369
6221
  "pluginAlias": "sfdx-hardis",
6370
6222
  "pluginName": "sfdx-hardis",
6371
6223
  "pluginType": "core",
6372
6224
  "strict": true,
6373
6225
  "enableJsonFlag": true,
6374
- "title": "Backup DX sources",
6375
- "requiresProject": true,
6376
- "triggerNotification": true,
6226
+ "title": "Detect Unsecured Connected Apps",
6227
+ "requiresProject": false,
6377
6228
  "isESM": true,
6378
6229
  "relativePath": [
6379
6230
  "lib",
6380
6231
  "commands",
6381
6232
  "hardis",
6382
6233
  "org",
6383
- "monitor",
6384
- "backup.js"
6234
+ "diagnose",
6235
+ "unsecure-connected-apps.js"
6385
6236
  ],
6386
6237
  "aliasPermutations": [],
6387
6238
  "permutations": [
6388
- "hardis:org:monitor:backup",
6389
- "org:hardis:monitor:backup",
6390
- "org:monitor:hardis:backup",
6391
- "org:monitor:backup:hardis",
6392
- "hardis:monitor:org:backup",
6393
- "monitor:hardis:org:backup",
6394
- "monitor:org:hardis:backup",
6395
- "monitor:org:backup:hardis",
6396
- "hardis:monitor:backup:org",
6397
- "monitor:hardis:backup:org",
6398
- "monitor:backup:hardis:org",
6399
- "monitor:backup:org:hardis",
6400
- "hardis:org:backup:monitor",
6401
- "org:hardis:backup:monitor",
6402
- "org:backup:hardis:monitor",
6403
- "org:backup:monitor:hardis",
6404
- "hardis:backup:org:monitor",
6405
- "backup:hardis:org:monitor",
6406
- "backup:org:hardis:monitor",
6407
- "backup:org:monitor:hardis",
6408
- "hardis:backup:monitor:org",
6409
- "backup:hardis:monitor:org",
6410
- "backup:monitor:hardis:org",
6411
- "backup:monitor:org:hardis"
6239
+ "hardis:org:diagnose:unsecure-connected-apps",
6240
+ "org:hardis:diagnose:unsecure-connected-apps",
6241
+ "org:diagnose:hardis:unsecure-connected-apps",
6242
+ "org:diagnose:unsecure-connected-apps:hardis",
6243
+ "hardis:diagnose:org:unsecure-connected-apps",
6244
+ "diagnose:hardis:org:unsecure-connected-apps",
6245
+ "diagnose:org:hardis:unsecure-connected-apps",
6246
+ "diagnose:org:unsecure-connected-apps:hardis",
6247
+ "hardis:diagnose:unsecure-connected-apps:org",
6248
+ "diagnose:hardis:unsecure-connected-apps:org",
6249
+ "diagnose:unsecure-connected-apps:hardis:org",
6250
+ "diagnose:unsecure-connected-apps:org:hardis",
6251
+ "hardis:org:unsecure-connected-apps:diagnose",
6252
+ "org:hardis:unsecure-connected-apps:diagnose",
6253
+ "org:unsecure-connected-apps:hardis:diagnose",
6254
+ "org:unsecure-connected-apps:diagnose:hardis",
6255
+ "hardis:unsecure-connected-apps:org:diagnose",
6256
+ "unsecure-connected-apps:hardis:org:diagnose",
6257
+ "unsecure-connected-apps:org:hardis:diagnose",
6258
+ "unsecure-connected-apps:org:diagnose:hardis",
6259
+ "hardis:unsecure-connected-apps:diagnose:org",
6260
+ "unsecure-connected-apps:hardis:diagnose:org",
6261
+ "unsecure-connected-apps:diagnose:hardis:org",
6262
+ "unsecure-connected-apps:diagnose:org:hardis"
6412
6263
  ]
6413
6264
  },
6414
- "hardis:org:monitor:limits": {
6265
+ "hardis:org:diagnose:unused-apex-classes": {
6415
6266
  "aliases": [],
6416
6267
  "args": {},
6417
- "description": "\n## Command Behavior\n\n**Checks the current usage of various Salesforce org limits and sends notifications if thresholds are exceeded.**\n\nThis command is a critical component of proactive Salesforce org management, helping administrators and developers monitor resource consumption and prevent hitting critical limits that could impact performance or functionality. It provides early warnings when limits are approaching their capacity.\n\nKey functionalities:\n\n- **Limit Retrieval:** Fetches a comprehensive list of all Salesforce org limits using the Salesforce CLI.\n- **Usage Calculation:** Calculates the percentage of each limit that is currently being used.\n- **Threshold-Based Alerting:** Assigns a severity (success, warning, or error) to each limit based on configurable thresholds:\n - **Warning:** If usage exceeds 50% (configurable via `LIMIT_THRESHOLD_WARNING` environment variable).\n - **Error:** If usage exceeds 75% (configurable via `LIMIT_THRESHOLD_ERROR` environment variable).\n- **CSV Report Generation:** Generates a CSV file containing all org limits, their current usage, maximum allowed, and calculated percentage used, along with the assigned severity.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of limits that have exceeded the warning or error thresholds.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-org-limits/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce CLI Integration:** It executes the `sf org limits list` command to retrieve the current org limits. It parses the JSON output of this command.\n- **Data Processing:** It iterates through the retrieved limits, calculates the `used` and `percentUsed` values, and assigns a `severity` (success, warning, error) based on the configured thresholds.\n- **Environment Variable Configuration:** Reads `LIMIT_THRESHOLD_WARNING` and `LIMIT_THRESHOLD_ERROR` environment variables to set the warning and error thresholds for limit usage.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of org limits.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and detailed metrics for each limit, which can be consumed by monitoring dashboards like Grafana.\n- **Exit Code Management:** Sets the process exit code to 1 if any limit is in an 'error' state, indicating a critical issue.\n</details>\n",
6268
+ "description": "List all async Apex classes (Batch,Queueable,Schedulable) that has not been called for more than 365 days.\n \nThe result class list probably can be removed from the project, and that will improve your test classes performances 😊\n\nThe number of unused day is overridable using --days option. \n\nThe command uses queries on AsyncApexJob and CronTrigger technical tables to build the result.\n\nApex Classes CreatedBy and CreatedOn fields are calculated from MIN(date from git, date from org)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-apex-classes/) and can output Grafana, Slack and MsTeams Notifications.\n\n![](https://sfdx-hardis.cloudity.com/assets/images/screenshot-monitoring-unused-apex-grafana.jpg)\n",
6418
6269
  "examples": [
6419
- "$ sf hardis:org:monitor:limits"
6270
+ "$ sf hardis:org:diagnose:unused-apex-classes",
6271
+ "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
6420
6272
  ],
6421
6273
  "flags": {
6422
6274
  "json": {
@@ -6442,6 +6294,14 @@
6442
6294
  "multiple": false,
6443
6295
  "type": "option"
6444
6296
  },
6297
+ "days": {
6298
+ "char": "t",
6299
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
6300
+ "name": "days",
6301
+ "hasDynamicHelp": false,
6302
+ "multiple": false,
6303
+ "type": "option"
6304
+ },
6445
6305
  "debug": {
6446
6306
  "char": "d",
6447
6307
  "description": "Activate debug mode (more logs)",
@@ -6480,61 +6340,57 @@
6480
6340
  },
6481
6341
  "hasDynamicHelp": true,
6482
6342
  "hiddenAliases": [],
6483
- "id": "hardis:org:monitor:limits",
6343
+ "id": "hardis:org:diagnose:unused-apex-classes",
6484
6344
  "pluginAlias": "sfdx-hardis",
6485
6345
  "pluginName": "sfdx-hardis",
6486
6346
  "pluginType": "core",
6487
6347
  "strict": true,
6488
6348
  "enableJsonFlag": true,
6489
- "title": "Check org limits",
6490
- "requiresProject": true,
6491
- "triggerNotification": true,
6492
- "isESM": true,
6349
+ "title": "Detect unused Apex classes in an org",
6350
+ "requiresProject": false,
6351
+ "isESM": true,
6493
6352
  "relativePath": [
6494
6353
  "lib",
6495
6354
  "commands",
6496
6355
  "hardis",
6497
6356
  "org",
6498
- "monitor",
6499
- "limits.js"
6357
+ "diagnose",
6358
+ "unused-apex-classes.js"
6500
6359
  ],
6501
6360
  "aliasPermutations": [],
6502
6361
  "permutations": [
6503
- "hardis:org:monitor:limits",
6504
- "org:hardis:monitor:limits",
6505
- "org:monitor:hardis:limits",
6506
- "org:monitor:limits:hardis",
6507
- "hardis:monitor:org:limits",
6508
- "monitor:hardis:org:limits",
6509
- "monitor:org:hardis:limits",
6510
- "monitor:org:limits:hardis",
6511
- "hardis:monitor:limits:org",
6512
- "monitor:hardis:limits:org",
6513
- "monitor:limits:hardis:org",
6514
- "monitor:limits:org:hardis",
6515
- "hardis:org:limits:monitor",
6516
- "org:hardis:limits:monitor",
6517
- "org:limits:hardis:monitor",
6518
- "org:limits:monitor:hardis",
6519
- "hardis:limits:org:monitor",
6520
- "limits:hardis:org:monitor",
6521
- "limits:org:hardis:monitor",
6522
- "limits:org:monitor:hardis",
6523
- "hardis:limits:monitor:org",
6524
- "limits:hardis:monitor:org",
6525
- "limits:monitor:hardis:org",
6526
- "limits:monitor:org:hardis"
6362
+ "hardis:org:diagnose:unused-apex-classes",
6363
+ "org:hardis:diagnose:unused-apex-classes",
6364
+ "org:diagnose:hardis:unused-apex-classes",
6365
+ "org:diagnose:unused-apex-classes:hardis",
6366
+ "hardis:diagnose:org:unused-apex-classes",
6367
+ "diagnose:hardis:org:unused-apex-classes",
6368
+ "diagnose:org:hardis:unused-apex-classes",
6369
+ "diagnose:org:unused-apex-classes:hardis",
6370
+ "hardis:diagnose:unused-apex-classes:org",
6371
+ "diagnose:hardis:unused-apex-classes:org",
6372
+ "diagnose:unused-apex-classes:hardis:org",
6373
+ "diagnose:unused-apex-classes:org:hardis",
6374
+ "hardis:org:unused-apex-classes:diagnose",
6375
+ "org:hardis:unused-apex-classes:diagnose",
6376
+ "org:unused-apex-classes:hardis:diagnose",
6377
+ "org:unused-apex-classes:diagnose:hardis",
6378
+ "hardis:unused-apex-classes:org:diagnose",
6379
+ "unused-apex-classes:hardis:org:diagnose",
6380
+ "unused-apex-classes:org:hardis:diagnose",
6381
+ "unused-apex-classes:org:diagnose:hardis",
6382
+ "hardis:unused-apex-classes:diagnose:org",
6383
+ "unused-apex-classes:hardis:diagnose:org",
6384
+ "unused-apex-classes:diagnose:hardis:org",
6385
+ "unused-apex-classes:diagnose:org:hardis"
6527
6386
  ]
6528
6387
  },
6529
- "hardis:org:diagnose:audittrail": {
6388
+ "hardis:org:diagnose:unused-connected-apps": {
6530
6389
  "aliases": [],
6531
6390
  "args": {},
6532
- "description": "Export Audit trail into a CSV file with selected criteria, and highlight suspect actions\n\nAlso detects updates of Custom Settings values (disable by defining `SKIP_AUDIT_TRAIL_CUSTOM_SETTINGS=true`)\n\nRegular setup actions performed in major orgs are filtered.\n\n- \"\"\n - createScratchOrg\n - changedsenderemail\n - deleteScratchOrg\n - loginasgrantedtopartnerbt\n- Certificate and Key Management\n - insertCertificate\n- Custom App Licenses\n - addeduserpackagelicense\n - granteduserpackagelicense\n - revokeduserpackagelicense\n- Customer Portal\n - createdcustomersuccessuser\n - CSPUserDisabled\n- Currency\n - updateddatedexchrate\n- Data Management\n - queueMembership\n- Email Administration\n - dkimRotationPreparationSuccessful\n - dkimRotationSuccessful\n- External Objects\n - xdsEncryptedFieldChange\n- Groups\n - groupMembership\n- Holidays\n - holiday_insert\n- Inbox mobile and legacy desktop apps\n - enableSIQUserNonEAC\n - siqUserAcceptedTOS\n- Manage Users\n - activateduser\n - createduser\n - changedcommunitynickname\n - changedemail\n - changedfederationid\n - changedpassword\n - changedinteractionuseroffon\n - changedinteractionuseronoff\n - changedmarketinguseroffon\n - changedmarketinguseronoff\n - changedofflineuseroffon\n - changedprofileforuserstdtostd\n - changedprofileforuser\n - changedprofileforusercusttostd\n - changedprofileforuserstdtocust\n - changedroleforusertonone\n - changedroleforuser\n - changedroleforuserfromnone\n - changedUserAdminVerifiedStatusVerified\n - changedUserEmailVerifiedStatusUnverified\n - changedUserEmailVerifiedStatusVerified\n - changedknowledgeuseroffon\n - changedsfcontentuseroffon\n - changedsupportuseroffon\n - changedusername\n - changedUserPhoneNumber\n - changedUserPhoneVerifiedStatusUnverified\n - changedUserPhoneVerifiedStatusVerified\n - deactivateduser\n - deleteAuthenticatorPairing\n - deleteTwoFactorInfo2\n - deleteTwoFactorTempCode\n - frozeuser\n - insertAuthenticatorPairing\n - insertTwoFactorInfo2\n - insertTwoFactorTempCode\n - lightningloginenroll\n - PermSetAssign\n - PermSetGroupAssign\n - PermSetGroupUnassign\n - PermSetLicenseAssign\n - PermSetUnassign\n - PermSetLicenseUnassign\n - registeredUserPhoneNumber\n - resetpassword\n - suNetworkAdminLogin\n - suNetworkAdminLogout\n - suOrgAdminLogin\n - suOrgAdminLogout\n - unfrozeuser\n - useremailchangesent\n- Mobile Administration\n - assigneduserstomobileconfig\n- Reporting Snapshots\n - createdReportJob\n - deletedReportJob\n- Sandboxes\n - DeleteSandbox\n\nBy default, deployment user defined in .sfdx-hardis.yml targetUsername property will be excluded.\n\nYou can define additional users to exclude in .sfdx-hardis.yml **monitoringExcludeUsernames** property.\n\nYou can also add more sections / actions considered as not suspect using property **monitoringAllowedSectionsActions**\n\nExample:\n\n```yaml\nmonitoringExcludeUsernames:\n - deploymentuser@cloudity.com\n - marketingcloud@cloudity.com\n - integration-user@cloudity.com\n\nmonitoringAllowedSectionsActions:\n \"Some section\": [] // Will ignore all actions from such section\n \"Some other section\": [\"actionType1\",\"actionType2\",\"actionType3\"] // Will ignore only those 3 actions from section \"Some other section\". Other actions in the same section will be considered as suspect.\n```\n\n## Excel output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-excel.jpg)\n\n## Local output example\n\n![](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/screenshot-monitoring-audittrail-local.jpg)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-suspect-audit-trail/) and can output Grafana, Slack and MsTeams Notifications.\n",
6391
+ "description": "\n## Command Behavior\n\n**Identifies and reports on potentially unused Connected Apps in a Salesforce org, suggesting candidates for deletion or deactivation.**\n\nThis command helps improve org security and reduce technical debt by pinpointing Connected Apps that are no longer actively used. Connected Apps can pose security risks if left unmonitored, and cleaning them up contributes to a healthier Salesforce environment.\n\nKey functionalities:\n\n- **Connected App Data Collection:** Gathers information about all Connected Apps in the org, including creation and last modified dates, and associated users.\n- **Usage Analysis:** Analyzes `LoginHistory` and `OAuthToken` records to determine the last usage date of each Connected App.\n- **Inactivity Detection:** Flags Connected Apps as potentially unused if they have no recent login history or OAuth token usage.\n- **Accessibility Check:** Examines Connected App metadata to identify if they are accessible (e.g., if they require admin approval and have no profiles or permission sets assigned).\n- **Ignored Apps:** Automatically ignores a predefined list of common Salesforce Connected Apps (e.g., `Salesforce CLI`, `Salesforce Mobile Dashboards`). You can extend this list by defining the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n- **CSV Report Generation:** Generates a CSV file containing details of all analyzed Connected Apps, including their usage status, last usage date, and reasons for being flagged as potentially unused.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of potentially unused Connected Apps.\n\n**Default Ignored Connected Apps:**\n\n- Ant Migration Tool\n- Chatter Desktop\n- Chatter Mobile for BlackBerry\n- Force.com IDE\n- OIQ_Integration\n- Salesforce CLI\n- Salesforce Files\n- Salesforce Mobile Dashboards\n- Salesforce Touch\n- Salesforce for Outlook\n- SalesforceA\n- SalesforceA for Android\n- SalesforceA for iOS\n- SalesforceDX Namespace Registry\n- SalesforceIQ\n\nYou can add more ignored apps by defining a comma-separated list of names in the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n\n_Example: \nALLOWED_INACTIVE_CONNECTED_APPS=My App 1,My App 2, My App 3_\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-connected-apps/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It performs SOQL queries against `ConnectedApplication`, `LoginHistory`, and `OAuthToken` objects to gather comprehensive data about Connected Apps and their usage.\n- **Temporary SFDX Project:** It creates a temporary SFDX project to retrieve Connected App metadata, allowing for local parsing and analysis of their XML files.\n- **Metadata Parsing:** It parses the `connectedApp-meta.xml` files to check for `isAdminApproved` and the presence of `profileName` or `permissionsetName` to determine accessibility.\n- **Data Correlation:** It correlates data from various Salesforce objects to build a complete picture of each Connected App's usage and status.\n- **Date Calculation:** Uses `moment` to calculate the time since the last OAuth token usage.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused Connected Apps.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **File System Operations:** Uses `fs-extra` for creating and removing temporary directories and files.\n- **Environment Variable Reading:** Reads the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable to customize the list of ignored Connected Apps.\n</details>\n",
6533
6392
  "examples": [
6534
- "$ sf hardis:org:diagnose:audittrail",
6535
- "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com",
6536
- "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com,bertrand@titi.com",
6537
- "$ sf hardis:org:diagnose:audittrail --lastndays 5"
6393
+ "$ sf hardis:org:diagnose:unused-connected-apps"
6538
6394
  ],
6539
6395
  "flags": {
6540
6396
  "json": {
@@ -6552,22 +6408,6 @@
6552
6408
  "multiple": false,
6553
6409
  "type": "option"
6554
6410
  },
6555
- "excludeusers": {
6556
- "char": "e",
6557
- "description": "Comma-separated list of usernames to exclude",
6558
- "name": "excludeusers",
6559
- "hasDynamicHelp": false,
6560
- "multiple": false,
6561
- "type": "option"
6562
- },
6563
- "lastndays": {
6564
- "char": "t",
6565
- "description": "Number of days to extract from today (included)",
6566
- "name": "lastndays",
6567
- "hasDynamicHelp": false,
6568
- "multiple": false,
6569
- "type": "option"
6570
- },
6571
6411
  "outputfile": {
6572
6412
  "char": "f",
6573
6413
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6614,13 +6454,30 @@
6614
6454
  },
6615
6455
  "hasDynamicHelp": true,
6616
6456
  "hiddenAliases": [],
6617
- "id": "hardis:org:diagnose:audittrail",
6457
+ "id": "hardis:org:diagnose:unused-connected-apps",
6618
6458
  "pluginAlias": "sfdx-hardis",
6619
6459
  "pluginName": "sfdx-hardis",
6620
6460
  "pluginType": "core",
6621
6461
  "strict": true,
6622
6462
  "enableJsonFlag": true,
6623
- "title": "Diagnose content of Setup Audit Trail",
6463
+ "title": "Unused Connected Apps in an org",
6464
+ "allowedInactiveConnectedApps": [
6465
+ "Ant Migration Tool",
6466
+ "Chatter Desktop",
6467
+ "Chatter Mobile for BlackBerry",
6468
+ "Force.com IDE",
6469
+ "OIQ_Integration",
6470
+ "Salesforce CLI",
6471
+ "Salesforce Files",
6472
+ "Salesforce Mobile Dashboards",
6473
+ "Salesforce Touch",
6474
+ "Salesforce for Outlook",
6475
+ "SalesforceA",
6476
+ "SalesforceA for Android",
6477
+ "SalesforceA for iOS",
6478
+ "SalesforceDX Namespace Registry",
6479
+ "SalesforceIQ"
6480
+ ],
6624
6481
  "requiresProject": false,
6625
6482
  "isESM": true,
6626
6483
  "relativePath": [
@@ -6629,42 +6486,43 @@
6629
6486
  "hardis",
6630
6487
  "org",
6631
6488
  "diagnose",
6632
- "audittrail.js"
6489
+ "unused-connected-apps.js"
6633
6490
  ],
6634
6491
  "aliasPermutations": [],
6635
6492
  "permutations": [
6636
- "hardis:org:diagnose:audittrail",
6637
- "org:hardis:diagnose:audittrail",
6638
- "org:diagnose:hardis:audittrail",
6639
- "org:diagnose:audittrail:hardis",
6640
- "hardis:diagnose:org:audittrail",
6641
- "diagnose:hardis:org:audittrail",
6642
- "diagnose:org:hardis:audittrail",
6643
- "diagnose:org:audittrail:hardis",
6644
- "hardis:diagnose:audittrail:org",
6645
- "diagnose:hardis:audittrail:org",
6646
- "diagnose:audittrail:hardis:org",
6647
- "diagnose:audittrail:org:hardis",
6648
- "hardis:org:audittrail:diagnose",
6649
- "org:hardis:audittrail:diagnose",
6650
- "org:audittrail:hardis:diagnose",
6651
- "org:audittrail:diagnose:hardis",
6652
- "hardis:audittrail:org:diagnose",
6653
- "audittrail:hardis:org:diagnose",
6654
- "audittrail:org:hardis:diagnose",
6655
- "audittrail:org:diagnose:hardis",
6656
- "hardis:audittrail:diagnose:org",
6657
- "audittrail:hardis:diagnose:org",
6658
- "audittrail:diagnose:hardis:org",
6659
- "audittrail:diagnose:org:hardis"
6493
+ "hardis:org:diagnose:unused-connected-apps",
6494
+ "org:hardis:diagnose:unused-connected-apps",
6495
+ "org:diagnose:hardis:unused-connected-apps",
6496
+ "org:diagnose:unused-connected-apps:hardis",
6497
+ "hardis:diagnose:org:unused-connected-apps",
6498
+ "diagnose:hardis:org:unused-connected-apps",
6499
+ "diagnose:org:hardis:unused-connected-apps",
6500
+ "diagnose:org:unused-connected-apps:hardis",
6501
+ "hardis:diagnose:unused-connected-apps:org",
6502
+ "diagnose:hardis:unused-connected-apps:org",
6503
+ "diagnose:unused-connected-apps:hardis:org",
6504
+ "diagnose:unused-connected-apps:org:hardis",
6505
+ "hardis:org:unused-connected-apps:diagnose",
6506
+ "org:hardis:unused-connected-apps:diagnose",
6507
+ "org:unused-connected-apps:hardis:diagnose",
6508
+ "org:unused-connected-apps:diagnose:hardis",
6509
+ "hardis:unused-connected-apps:org:diagnose",
6510
+ "unused-connected-apps:hardis:org:diagnose",
6511
+ "unused-connected-apps:org:hardis:diagnose",
6512
+ "unused-connected-apps:org:diagnose:hardis",
6513
+ "hardis:unused-connected-apps:diagnose:org",
6514
+ "unused-connected-apps:hardis:diagnose:org",
6515
+ "unused-connected-apps:diagnose:hardis:org",
6516
+ "unused-connected-apps:diagnose:org:hardis"
6660
6517
  ]
6661
6518
  },
6662
- "hardis:org:diagnose:instanceupgrade": {
6519
+ "hardis:org:diagnose:unusedlicenses": {
6663
6520
  "aliases": [],
6664
6521
  "args": {},
6665
- "description": "\n## Command Behavior\n\n**Retrieves and displays the scheduled upgrade date for a Salesforce org's instance.**\n\nThis command provides crucial information about when your Salesforce instance will be upgraded to the next major release (Spring, Summer, or Winter). This is vital for release planning, testing, and ensuring compatibility with upcoming Salesforce features.\n\nKey functionalities:\n\n- **Instance Identification:** Determines the Salesforce instance name of your target org.\n- **Upgrade Date Retrieval:** Fetches the planned start time of the next major core service upgrade for that instance from the Salesforce Status API.\n- **Days Until Upgrade:** Calculates and displays the number of days remaining until the next major upgrade.\n- **Severity-Based Logging:** Adjusts the log severity (info, warning) based on the proximity of the upgrade date, providing a visual cue for urgency.\n- **Notifications:** Sends notifications to configured channels (e.g., Slack, MS Teams, Grafana) with the upgrade information, making it suitable for automated monitoring.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Query:** It first queries the `Organization` object in Salesforce to get the `InstanceName` of the target org.\n- **Salesforce Status API Integration:** It makes an HTTP GET request to the Salesforce Status API (`https://api.status.salesforce.com/v1/instances/{instanceName}/status`) to retrieve detailed information about the instance, including scheduled maintenances.\n- **Data Parsing:** It parses the JSON response from the Status API to extract the relevant major release upgrade information.\n- **Date Calculation:** Uses the `moment` library to calculate the difference in days between the current date and the planned upgrade date.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including the instance name, upgrade date, and days remaining, along with relevant metrics for monitoring dashboards.\n- **User Feedback:** Provides clear messages to the user about the upgrade status and proximity.\n</details>\n",
6522
+ "description": "\n## Command Behavior\n\n**Detects and suggests the deletion of unused Permission Set License Assignments in a Salesforce org.**\n\nWhen a Permission Set (PS) linked to a Permission Set License (PSL) is assigned to a user, a Permission Set License Assignment (PSLA) is automatically created. However, when that PS is unassigned from the user, the PSLA is *not* automatically deleted. This can lead to organizations being charged for unused PSLAs, representing a hidden cost and technical debt.\n\nThis command identifies such useless PSLAs and provides options to delete them, helping to optimize license usage and reduce unnecessary expenses.\n\nKey functionalities:\n\n- **PSLA Detection:** Queries the Salesforce org to find all active PSLAs.\n- **Usage Verification:** Correlates PSLAs with actual Permission Set Assignments and Permission Set Group Assignments to determine if the underlying Permission Sets are still assigned to the user.\n- **Special Case Handling:** Accounts for specific scenarios where profiles might implicitly assign PSLAs (e.g., `Salesforce API Only` profile assigning `SalesforceAPIIntegrationPsl`) and allows for always excluding certain PSLAs from the unused check.\n- **Reporting:** Generates a CSV report of all identified unused PSLAs, including the user and the associated Permission Set License.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of unused PSLAs.\n- **Interactive Deletion:** In non-CI environments, it offers an interactive prompt to bulk delete the identified unused PSLAs.\n\nMany thanks to [Vincent Finet](https://www.linkedin.com/in/vincentfinet/) for the inspiration during his great speaker session at [French Touch Dreamin '23](https://frenchtouchdreamin.com/), and his kind agreement for reusing such inspiration in this command 😊\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-licenses/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves extensive querying of Salesforce objects and data correlation:\n\n- **SOQL Queries (Bulk API):** It uses `bulkQuery` and `bulkQueryChunksIn` to efficiently retrieve large volumes of data from `PermissionSetLicenseAssign`, `PermissionSetLicense`, `PermissionSet`, `PermissionSetGroupComponent`, and `PermissionSetAssignment` objects.\n- **Data Correlation:** It meticulously correlates data across these objects to determine if a `PermissionSetLicenseAssign` record has a corresponding active assignment to a Permission Set or Permission Set Group for the same user.\n- **Filtering Logic:** It applies complex filtering logic to exclude PSLAs that are genuinely in use or are part of predefined exceptions (e.g., `alwaysExcludeForActiveUsersPermissionSetLicenses`).\n- **Bulk Deletion:** If the user opts to delete unused PSLAs, it uses `bulkUpdate` with the `delete` operation to efficiently remove multiple records.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused PSLAs.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Interaction:** Uses `prompts` for interactive confirmation before performing deletion operations.\n</details>\n",
6666
6523
  "examples": [
6667
- "$ sf hardis:org:diagnose:instanceupgrade"
6524
+ "$ sf hardis:org:diagnose:unusedlicenses",
6525
+ "$ sf hardis:org:diagnose:unusedlicenses --fix"
6668
6526
  ],
6669
6527
  "flags": {
6670
6528
  "json": {
@@ -6682,6 +6540,14 @@
6682
6540
  "multiple": false,
6683
6541
  "type": "option"
6684
6542
  },
6543
+ "outputfile": {
6544
+ "char": "f",
6545
+ "description": "Force the path and name of output report file. Must end with .csv",
6546
+ "name": "outputfile",
6547
+ "hasDynamicHelp": false,
6548
+ "multiple": false,
6549
+ "type": "option"
6550
+ },
6685
6551
  "debug": {
6686
6552
  "char": "d",
6687
6553
  "description": "Activate debug mode (more logs)",
@@ -6720,14 +6586,32 @@
6720
6586
  },
6721
6587
  "hasDynamicHelp": true,
6722
6588
  "hiddenAliases": [],
6723
- "id": "hardis:org:diagnose:instanceupgrade",
6589
+ "id": "hardis:org:diagnose:unusedlicenses",
6724
6590
  "pluginAlias": "sfdx-hardis",
6725
6591
  "pluginName": "sfdx-hardis",
6726
6592
  "pluginType": "core",
6727
6593
  "strict": true,
6728
6594
  "enableJsonFlag": true,
6729
- "title": "Get Instance Upgrade date",
6595
+ "title": "Detect unused Permission Set Licenses (beta)",
6730
6596
  "requiresProject": false,
6597
+ "additionalPermissionSetsToAlwaysGet": [
6598
+ "Sales_User"
6599
+ ],
6600
+ "permSetsPermSetLicenses": [
6601
+ {
6602
+ "permSet": "Sales_User",
6603
+ "permSetLicense": "SalesUserPsl"
6604
+ }
6605
+ ],
6606
+ "profilesPermissionSetLicenses": [
6607
+ {
6608
+ "profile": "Salesforce API Only",
6609
+ "permSetLicense": "SalesforceAPIIntegrationPsl"
6610
+ }
6611
+ ],
6612
+ "alwaysExcludeForActiveUsersPermissionSetLicenses": [
6613
+ "IdentityConnect"
6614
+ ],
6731
6615
  "isESM": true,
6732
6616
  "relativePath": [
6733
6617
  "lib",
@@ -6735,45 +6619,46 @@
6735
6619
  "hardis",
6736
6620
  "org",
6737
6621
  "diagnose",
6738
- "instanceupgrade.js"
6622
+ "unusedlicenses.js"
6739
6623
  ],
6740
6624
  "aliasPermutations": [],
6741
6625
  "permutations": [
6742
- "hardis:org:diagnose:instanceupgrade",
6743
- "org:hardis:diagnose:instanceupgrade",
6744
- "org:diagnose:hardis:instanceupgrade",
6745
- "org:diagnose:instanceupgrade:hardis",
6746
- "hardis:diagnose:org:instanceupgrade",
6747
- "diagnose:hardis:org:instanceupgrade",
6748
- "diagnose:org:hardis:instanceupgrade",
6749
- "diagnose:org:instanceupgrade:hardis",
6750
- "hardis:diagnose:instanceupgrade:org",
6751
- "diagnose:hardis:instanceupgrade:org",
6752
- "diagnose:instanceupgrade:hardis:org",
6753
- "diagnose:instanceupgrade:org:hardis",
6754
- "hardis:org:instanceupgrade:diagnose",
6755
- "org:hardis:instanceupgrade:diagnose",
6756
- "org:instanceupgrade:hardis:diagnose",
6757
- "org:instanceupgrade:diagnose:hardis",
6758
- "hardis:instanceupgrade:org:diagnose",
6759
- "instanceupgrade:hardis:org:diagnose",
6760
- "instanceupgrade:org:hardis:diagnose",
6761
- "instanceupgrade:org:diagnose:hardis",
6762
- "hardis:instanceupgrade:diagnose:org",
6763
- "instanceupgrade:hardis:diagnose:org",
6764
- "instanceupgrade:diagnose:hardis:org",
6765
- "instanceupgrade:diagnose:org:hardis"
6626
+ "hardis:org:diagnose:unusedlicenses",
6627
+ "org:hardis:diagnose:unusedlicenses",
6628
+ "org:diagnose:hardis:unusedlicenses",
6629
+ "org:diagnose:unusedlicenses:hardis",
6630
+ "hardis:diagnose:org:unusedlicenses",
6631
+ "diagnose:hardis:org:unusedlicenses",
6632
+ "diagnose:org:hardis:unusedlicenses",
6633
+ "diagnose:org:unusedlicenses:hardis",
6634
+ "hardis:diagnose:unusedlicenses:org",
6635
+ "diagnose:hardis:unusedlicenses:org",
6636
+ "diagnose:unusedlicenses:hardis:org",
6637
+ "diagnose:unusedlicenses:org:hardis",
6638
+ "hardis:org:unusedlicenses:diagnose",
6639
+ "org:hardis:unusedlicenses:diagnose",
6640
+ "org:unusedlicenses:hardis:diagnose",
6641
+ "org:unusedlicenses:diagnose:hardis",
6642
+ "hardis:unusedlicenses:org:diagnose",
6643
+ "unusedlicenses:hardis:org:diagnose",
6644
+ "unusedlicenses:org:hardis:diagnose",
6645
+ "unusedlicenses:org:diagnose:hardis",
6646
+ "hardis:unusedlicenses:diagnose:org",
6647
+ "unusedlicenses:hardis:diagnose:org",
6648
+ "unusedlicenses:diagnose:hardis:org",
6649
+ "unusedlicenses:diagnose:org:hardis"
6766
6650
  ]
6767
6651
  },
6768
- "hardis:org:diagnose:legacyapi": {
6652
+ "hardis:org:diagnose:unusedusers": {
6769
6653
  "aliases": [],
6770
6654
  "args": {},
6771
- "description": "Checks if an org uses retired or someday retired API version\n\n\nSee article below\n\n[![Handle Salesforce API versions Deprecation like a pro](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-deprecated-api.jpg)](https://nicolas.vuillamy.fr/handle-salesforce-api-versions-deprecation-like-a-pro-335065f52238)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-deprecated-api-calls/) and can output Grafana, Slack and MsTeams Notifications.\n",
6655
+ "description": "\n## Command Behavior\n\n**Detects and reports on inactive or unused Salesforce user accounts, helping to optimize license usage and enhance security.**\n\nEfficient user management is vital in Salesforce to ensure resources are optimized and costs are controlled. However, inactive or unused user accounts can often go unnoticed, leading to wasted licenses and potential security risks. This tool addresses this challenge by enabling administrators to identify users who haven't logged in within a specified period.\n\nBy analyzing user login activity and last login timestamps, this feature highlights inactive user accounts, allowing administrators to take appropriate action. Whether it's deactivating dormant accounts, freeing up licenses, or ensuring compliance with security policies, this functionality empowers administrators to maintain a lean and secure Salesforce environment.\n\nKey functionalities:\n\n- **Inactivity Detection:** Identifies users who have not logged in for a specified number of days (`--days` flag, default 180 days in CI, 365 days otherwise).\n- **License Type Filtering:** Allows filtering users by license type using `--licensetypes` (e.g., `all-crm`, `all-paying`) or specific license identifiers using `--licenseidentifiers`.\n - `all-crm`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT` licenses.\n - `all-paying`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT`, `PID_Customer_Community`, `PID_Customer_Community_Login`, `PID_Partner_Community`, `PID_Partner_Community_Login` licenses.\n - Note: You can see the full list of available license identifiers in [Salesforce Documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/sfdx_cli_reference/sforce_api_objects_userlicense.htm).\n- **Active User Retrieval:** The `--returnactiveusers` flag inverts the command, allowing you to retrieve active users who *have* logged in during the specified period.\n- **CSV Report Generation:** Generates a CSV file containing details of all identified users (inactive or active), including their last login date, profile, and license information.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of inactive or active users.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-inactive-users/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query (Bulk API):** It uses `bulkQuery` to efficiently retrieve user records from the Salesforce `User` object. The SOQL query dynamically constructs its WHERE clause based on the `--days`, `--licensetypes`, `--licenseidentifiers`, and `--returnactiveusers` flags.\n- **Interactive Prompts:** Uses `prompts` to interactively ask the user for the number of inactive days and license types if not provided via flags.\n- **License Mapping:** Internally maps common license type aliases (e.g., `all-crm`) to their corresponding Salesforce `LicenseDefinitionKey` values.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of users.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Feedback:** Provides a summary of the findings in the console, indicating the number of inactive or active users found.\n</details>",
6772
6656
  "examples": [
6773
- "$ sf hardis:org:diagnose:legacyapi",
6774
- "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com",
6775
- "$ sf hardis:org:diagnose:legacyapi --outputfile 'c:/path/to/folder/legacyapi.csv'",
6776
- "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com --outputfile ./tmp/legacyapi.csv"
6657
+ "$ sf hardis:org:diagnose:unusedusers",
6658
+ "$ sf hardis:org:diagnose:unusedusers --days 365",
6659
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm",
6660
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licenseidentifiers SFDC,AUL,AUL1",
6661
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm --returnactiveusers"
6777
6662
  ],
6778
6663
  "flags": {
6779
6664
  "json": {
@@ -6791,32 +6676,49 @@
6791
6676
  "multiple": false,
6792
6677
  "type": "option"
6793
6678
  },
6794
- "eventtype": {
6795
- "char": "e",
6796
- "description": "Type of EventLogFile event to analyze",
6797
- "name": "eventtype",
6798
- "default": "ApiTotalUsage",
6679
+ "outputfile": {
6680
+ "char": "f",
6681
+ "description": "Force the path and name of output report file. Must end with .csv",
6682
+ "name": "outputfile",
6799
6683
  "hasDynamicHelp": false,
6800
6684
  "multiple": false,
6801
6685
  "type": "option"
6802
6686
  },
6803
- "limit": {
6687
+ "days": {
6688
+ "char": "t",
6689
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
6690
+ "name": "days",
6691
+ "hasDynamicHelp": false,
6692
+ "multiple": false,
6693
+ "type": "option"
6694
+ },
6695
+ "licensetypes": {
6804
6696
  "char": "l",
6805
- "description": "Number of latest EventLogFile events to analyze",
6806
- "name": "limit",
6807
- "default": 999,
6697
+ "description": "Type of licenses to check. If set, do not use licenseidentifiers option. In CI, default is all-crm",
6698
+ "name": "licensetypes",
6808
6699
  "hasDynamicHelp": false,
6809
6700
  "multiple": false,
6701
+ "options": [
6702
+ "all",
6703
+ "all-crm",
6704
+ "all-paying"
6705
+ ],
6810
6706
  "type": "option"
6811
6707
  },
6812
- "outputfile": {
6813
- "char": "f",
6814
- "description": "Force the path and name of output report file. Must end with .csv",
6815
- "name": "outputfile",
6708
+ "licenseidentifiers": {
6709
+ "char": "i",
6710
+ "description": "Comma-separated list of license identifiers, in case licensetypes is not used.. Identifiers available at https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userlicense.htm",
6711
+ "name": "licenseidentifiers",
6816
6712
  "hasDynamicHelp": false,
6817
6713
  "multiple": false,
6818
6714
  "type": "option"
6819
6715
  },
6716
+ "returnactiveusers": {
6717
+ "description": "Inverts the command by returning the active users",
6718
+ "name": "returnactiveusers",
6719
+ "allowNo": false,
6720
+ "type": "boolean"
6721
+ },
6820
6722
  "debug": {
6821
6723
  "char": "d",
6822
6724
  "description": "Activate debug mode (more logs)",
@@ -6855,13 +6757,13 @@
6855
6757
  },
6856
6758
  "hasDynamicHelp": true,
6857
6759
  "hiddenAliases": [],
6858
- "id": "hardis:org:diagnose:legacyapi",
6760
+ "id": "hardis:org:diagnose:unusedusers",
6859
6761
  "pluginAlias": "sfdx-hardis",
6860
6762
  "pluginName": "sfdx-hardis",
6861
6763
  "pluginType": "core",
6862
6764
  "strict": true,
6863
6765
  "enableJsonFlag": true,
6864
- "title": "Check for legacy API use",
6766
+ "title": "Detect unused Users in Salesforce",
6865
6767
  "requiresProject": false,
6866
6768
  "isESM": true,
6867
6769
  "relativePath": [
@@ -6870,42 +6772,42 @@
6870
6772
  "hardis",
6871
6773
  "org",
6872
6774
  "diagnose",
6873
- "legacyapi.js"
6775
+ "unusedusers.js"
6874
6776
  ],
6875
6777
  "aliasPermutations": [],
6876
6778
  "permutations": [
6877
- "hardis:org:diagnose:legacyapi",
6878
- "org:hardis:diagnose:legacyapi",
6879
- "org:diagnose:hardis:legacyapi",
6880
- "org:diagnose:legacyapi:hardis",
6881
- "hardis:diagnose:org:legacyapi",
6882
- "diagnose:hardis:org:legacyapi",
6883
- "diagnose:org:hardis:legacyapi",
6884
- "diagnose:org:legacyapi:hardis",
6885
- "hardis:diagnose:legacyapi:org",
6886
- "diagnose:hardis:legacyapi:org",
6887
- "diagnose:legacyapi:hardis:org",
6888
- "diagnose:legacyapi:org:hardis",
6889
- "hardis:org:legacyapi:diagnose",
6890
- "org:hardis:legacyapi:diagnose",
6891
- "org:legacyapi:hardis:diagnose",
6892
- "org:legacyapi:diagnose:hardis",
6893
- "hardis:legacyapi:org:diagnose",
6894
- "legacyapi:hardis:org:diagnose",
6895
- "legacyapi:org:hardis:diagnose",
6896
- "legacyapi:org:diagnose:hardis",
6897
- "hardis:legacyapi:diagnose:org",
6898
- "legacyapi:hardis:diagnose:org",
6899
- "legacyapi:diagnose:hardis:org",
6900
- "legacyapi:diagnose:org:hardis"
6779
+ "hardis:org:diagnose:unusedusers",
6780
+ "org:hardis:diagnose:unusedusers",
6781
+ "org:diagnose:hardis:unusedusers",
6782
+ "org:diagnose:unusedusers:hardis",
6783
+ "hardis:diagnose:org:unusedusers",
6784
+ "diagnose:hardis:org:unusedusers",
6785
+ "diagnose:org:hardis:unusedusers",
6786
+ "diagnose:org:unusedusers:hardis",
6787
+ "hardis:diagnose:unusedusers:org",
6788
+ "diagnose:hardis:unusedusers:org",
6789
+ "diagnose:unusedusers:hardis:org",
6790
+ "diagnose:unusedusers:org:hardis",
6791
+ "hardis:org:unusedusers:diagnose",
6792
+ "org:hardis:unusedusers:diagnose",
6793
+ "org:unusedusers:hardis:diagnose",
6794
+ "org:unusedusers:diagnose:hardis",
6795
+ "hardis:unusedusers:org:diagnose",
6796
+ "unusedusers:hardis:org:diagnose",
6797
+ "unusedusers:org:hardis:diagnose",
6798
+ "unusedusers:org:diagnose:hardis",
6799
+ "hardis:unusedusers:diagnose:org",
6800
+ "unusedusers:hardis:diagnose:org",
6801
+ "unusedusers:diagnose:hardis:org",
6802
+ "unusedusers:diagnose:org:hardis"
6901
6803
  ]
6902
6804
  },
6903
- "hardis:org:diagnose:licenses": {
6805
+ "hardis:org:files:export": {
6904
6806
  "aliases": [],
6905
6807
  "args": {},
6906
- "description": "\n**Lists and analyzes User Licenses and Permission Set Licenses subscribed and used in a Salesforce org.**\n\nThis command provides a comprehensive overview of your Salesforce license consumption. It's particularly useful for:\n\n- **License Management:** Understanding which licenses are active, how many are available, and how many are being used.\n- **Cost Optimization:** Identifying unused or underutilized licenses that could be reallocated or decommissioned.\n- **Compliance:** Ensuring that your organization is compliant with Salesforce licensing agreements.\n- **Monitoring:** Tracking license usage trends over time.\n\nKey functionalities:\n\n- **User License Details:** Retrieves information about standard and custom User Licenses, including `MasterLabel`, `Name`, `TotalLicenses`, and `UsedLicenses`.\n- **Permission Set License Details:** Retrieves information about Permission Set Licenses, including `MasterLabel`, `PermissionSetLicenseKey`, `TotalLicenses`, and `UsedLicenses`.\n- **Used Licenses Filter:** The `--usedonly` flag allows you to filter the report to show only licenses that have at least one `UsedLicenses` count greater than zero.\n- **CSV Report Generation:** Generates a CSV file containing all the retrieved license information, suitable for detailed analysis.\n- **Notifications:** Sends notifications to configured channels (e.g., Grafana, Slack, MS Teams) with a summary of license usage, including lists of active and used licenses.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It executes SOQL queries against the `UserLicense` and `PermissionSetLicense` objects in Salesforce to retrieve license data.\n- **Data Transformation:** It processes the query results, reformatting the data to be more readable and consistent for reporting purposes (e.g., removing `Id` and `attributes`, renaming `PermissionSetLicenseKey` to `Name`).\n- **Data Aggregation:** It aggregates license information, creating a `licensesByKey` object for quick lookups and a `usedLicenses` array for a concise list of actively used licenses.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of license data.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Feedback:** Provides clear messages to the user about the license extraction process and the used licenses.\n</details>\n",
6808
+ "description": "\n## Command Behavior\n\n**Exports file attachments (ContentVersion, Attachment) from a Salesforce org based on a predefined configuration.**\n\nThis command enables the mass download of files associated with Salesforce records, providing a robust solution for backing up files, migrating them to other systems, or integrating them with external document management solutions.\n\nKey functionalities:\n\n- **Configuration-Driven Export:** Relies on an `export.json` file within a designated file export project to define the export criteria, including the SOQL query for parent records, file types to export, output naming conventions, and file size filtering.\n- **File Size Filtering:** Supports minimum file size filtering via the `fileSizeMin` configuration parameter (in KB). Files smaller than the specified size will be skipped during export.\n- **File Validation:** After downloading each file, validates the integrity by:\n - **Checksum Validation:** For ContentVersion files, compares MD5 checksum with Salesforce's stored checksum\n - **Size Validation:** For both ContentVersion and Attachment files, verifies actual file size matches expected size\n - **Status Tracking:** Files are categorized with specific statuses: `success` (valid files), `failed` (download errors), `skipped` (filtered files), `invalid` (downloaded but failed validation)\n - All validation results are logged in the CSV export log for audit purposes\n- **Resume/Restart Capability:** \n - **Resume Mode:** When `--resume` flag is used (default in CI environments), checks existing downloaded files for validity. Valid files are skipped, invalid files are re-downloaded.\n - **Restart Mode:** When resume is disabled, clears the output folder and starts a fresh export.\n - **Interactive Mode:** When existing files are found and `--resume` is not explicitly specified (non-CI environments), prompts the user to choose between resume or restart.\n- **Interactive Project Selection:** If the file export project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Configurable Export Options:** Allows overriding default export settings such as `chunksize` (number of records processed in a batch), `polltimeout` (timeout for Bulk API calls), and `startchunknumber` (to resume a failed export).\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for a practical example:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesExporter Class:** The core logic is encapsulated within the `FilesExporter` class, which orchestrates the entire export process.\n- **SOQL Queries (Bulk API):** It uses Salesforce Bulk API queries to efficiently retrieve large volumes of parent record IDs and file metadata, including checksums and file sizes.\n- **File Download:** Downloads the actual file content from Salesforce.\n- **File Validation:** After each successful download, validates file integrity by comparing checksums (ContentVersion) and file sizes (both ContentVersion and Attachment) against Salesforce metadata.\n- **Resume Logic:** In resume mode, checks for existing files before downloading, validates their integrity, and only re-downloads invalid or missing files. This enables efficient recovery from interrupted exports.\n- **File System Operations:** Writes the downloaded files to the local file system, organizing them into folders based on the configured naming conventions.\n- **Configuration Loading:** Reads the `export.json` file to get the export configuration. It also allows for interactive overriding of these settings.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file export project, `promptFilesExportConfiguration` for customizing export options, and prompts for resume/restart choice when existing files are found.\n- **Error Handling:** Includes mechanisms to handle potential errors during the export process, such as network issues, API limits, and file validation failures. Each file is assigned a specific status (`success`, `failed`, `skipped`, `invalid`) for comprehensive tracking and troubleshooting.\n</details>\n",
6907
6809
  "examples": [
6908
- "$ sf hardis:org:diagnose:licenses"
6810
+ "$ sf hardis:org:files:export"
6909
6811
  ],
6910
6812
  "flags": {
6911
6813
  "json": {
@@ -6923,18 +6825,45 @@
6923
6825
  "multiple": false,
6924
6826
  "type": "option"
6925
6827
  },
6926
- "outputfile": {
6927
- "char": "f",
6928
- "description": "Force the path and name of output report file. Must end with .csv",
6929
- "name": "outputfile",
6828
+ "path": {
6829
+ "char": "p",
6830
+ "description": "Path to the file export project",
6831
+ "name": "path",
6930
6832
  "hasDynamicHelp": false,
6931
6833
  "multiple": false,
6932
6834
  "type": "option"
6933
6835
  },
6934
- "usedonly": {
6935
- "char": "u",
6936
- "description": "Filter to have only used licenses",
6937
- "name": "usedonly",
6836
+ "chunksize": {
6837
+ "char": "c",
6838
+ "description": "Number of records to add in a chunk before it is processed",
6839
+ "name": "chunksize",
6840
+ "default": 1000,
6841
+ "hasDynamicHelp": false,
6842
+ "multiple": false,
6843
+ "type": "option"
6844
+ },
6845
+ "polltimeout": {
6846
+ "char": "t",
6847
+ "description": "Timeout in MS for Bulk API calls",
6848
+ "name": "polltimeout",
6849
+ "default": 300000,
6850
+ "hasDynamicHelp": false,
6851
+ "multiple": false,
6852
+ "type": "option"
6853
+ },
6854
+ "startchunknumber": {
6855
+ "char": "s",
6856
+ "description": "Chunk number to start from",
6857
+ "name": "startchunknumber",
6858
+ "default": 0,
6859
+ "hasDynamicHelp": false,
6860
+ "multiple": false,
6861
+ "type": "option"
6862
+ },
6863
+ "resume": {
6864
+ "char": "r",
6865
+ "description": "Resume previous export by checking existing files (default in CI)",
6866
+ "name": "resume",
6938
6867
  "allowNo": false,
6939
6868
  "type": "boolean"
6940
6869
  },
@@ -6976,13 +6905,13 @@
6976
6905
  },
6977
6906
  "hasDynamicHelp": true,
6978
6907
  "hiddenAliases": [],
6979
- "id": "hardis:org:diagnose:licenses",
6908
+ "id": "hardis:org:files:export",
6980
6909
  "pluginAlias": "sfdx-hardis",
6981
6910
  "pluginName": "sfdx-hardis",
6982
6911
  "pluginType": "core",
6983
6912
  "strict": true,
6984
6913
  "enableJsonFlag": true,
6985
- "title": "List licenses subscribed and used in a Salesforce org",
6914
+ "title": "Export files",
6986
6915
  "requiresProject": false,
6987
6916
  "isESM": true,
6988
6917
  "relativePath": [
@@ -6990,43 +6919,43 @@
6990
6919
  "commands",
6991
6920
  "hardis",
6992
6921
  "org",
6993
- "diagnose",
6994
- "licenses.js"
6922
+ "files",
6923
+ "export.js"
6995
6924
  ],
6996
6925
  "aliasPermutations": [],
6997
6926
  "permutations": [
6998
- "hardis:org:diagnose:licenses",
6999
- "org:hardis:diagnose:licenses",
7000
- "org:diagnose:hardis:licenses",
7001
- "org:diagnose:licenses:hardis",
7002
- "hardis:diagnose:org:licenses",
7003
- "diagnose:hardis:org:licenses",
7004
- "diagnose:org:hardis:licenses",
7005
- "diagnose:org:licenses:hardis",
7006
- "hardis:diagnose:licenses:org",
7007
- "diagnose:hardis:licenses:org",
7008
- "diagnose:licenses:hardis:org",
7009
- "diagnose:licenses:org:hardis",
7010
- "hardis:org:licenses:diagnose",
7011
- "org:hardis:licenses:diagnose",
7012
- "org:licenses:hardis:diagnose",
7013
- "org:licenses:diagnose:hardis",
7014
- "hardis:licenses:org:diagnose",
7015
- "licenses:hardis:org:diagnose",
7016
- "licenses:org:hardis:diagnose",
7017
- "licenses:org:diagnose:hardis",
7018
- "hardis:licenses:diagnose:org",
7019
- "licenses:hardis:diagnose:org",
7020
- "licenses:diagnose:hardis:org",
7021
- "licenses:diagnose:org:hardis"
6927
+ "hardis:org:files:export",
6928
+ "org:hardis:files:export",
6929
+ "org:files:hardis:export",
6930
+ "org:files:export:hardis",
6931
+ "hardis:files:org:export",
6932
+ "files:hardis:org:export",
6933
+ "files:org:hardis:export",
6934
+ "files:org:export:hardis",
6935
+ "hardis:files:export:org",
6936
+ "files:hardis:export:org",
6937
+ "files:export:hardis:org",
6938
+ "files:export:org:hardis",
6939
+ "hardis:org:export:files",
6940
+ "org:hardis:export:files",
6941
+ "org:export:hardis:files",
6942
+ "org:export:files:hardis",
6943
+ "hardis:export:org:files",
6944
+ "export:hardis:org:files",
6945
+ "export:org:hardis:files",
6946
+ "export:org:files:hardis",
6947
+ "hardis:export:files:org",
6948
+ "export:hardis:files:org",
6949
+ "export:files:hardis:org",
6950
+ "export:files:org:hardis"
7022
6951
  ]
7023
6952
  },
7024
- "hardis:org:diagnose:releaseupdates": {
6953
+ "hardis:org:files:import": {
7025
6954
  "aliases": [],
7026
6955
  "args": {},
7027
- "description": "Export Release Updates into a CSV file with selected criteria, and highlight Release Updates that should be checked.\n\nBefore publishing **Breaking Changes** ❌, Salesforce announce them in the setup menu [**Release Updates**](https://help.salesforce.com/s/articleView?id=sf.release_updates.htm&type=5)\n\n⚠️ Some of them are very important, because if you don't make the related upgrades in time (ex: before Winter 25) , your production org can crash !\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-release-updates/) and can output Grafana, Slack and MsTeams Notifications.\n",
6956
+ "description": "\nThis command facilitates the mass upload of files into Salesforce, allowing you to populate records with associated documents, images, or other file types. It's a crucial tool for data migration, content seeding, or synchronizing external file repositories with Salesforce.\n\nKey functionalities:\n\n- **Configuration-Driven Import:** Relies on an `export.json` file within a designated file export project (created using `sf hardis:org:configure:files`) to determine which files to import and how they should be associated with Salesforce records.\n- **Interactive Project Selection:** If the file import project path is not provided via the `--path` flag, it interactively prompts the user to select one.\n- **Overwrite Option:** The `--overwrite` flag allows you to replace existing files in Salesforce with local versions that have the same name. Be aware that this option doubles the number of API calls used.\n- **Support for ContentVersion and Attachment:** Handles both modern Salesforce Files (ContentVersion) and older Attachments.\n\nSee this article for how to export files, which is often a prerequisite for importing:\n\n[![How to mass download notes and attachments files from a Salesforce org](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-mass-download.jpg)](https://nicolas.vuillamy.fr/how-to-mass-download-notes-and-attachments-files-from-a-salesforce-org-83a028824afd)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **FilesImporter Class:** The core logic is encapsulated within the `FilesImporter` class, which orchestrates the entire import process.\n- **File System Scan:** Scans the local file system within the configured project directory to identify files for import.\n- **Salesforce API Interaction:** Uses Salesforce APIs (e.g., ContentVersion, Attachment) to upload files and associate them with records.\n- **Configuration Loading:** Reads the `export.json` file to get the import configuration, including SOQL queries to identify parent records for file association.\n- **Interactive Prompts:** Uses `selectFilesWorkspace` to allow the user to choose a file import project and `prompts` for confirming the overwrite behavior.\n- **Error Handling:** Includes mechanisms to handle potential errors during the import process, such as API limits or file upload failures.\n</details>\n",
7028
6957
  "examples": [
7029
- "$ sf hardis:org:diagnose:releaseupdates"
6958
+ "$ sf hardis:org:files:import"
7030
6959
  ],
7031
6960
  "flags": {
7032
6961
  "json": {
@@ -7044,14 +6973,21 @@
7044
6973
  "multiple": false,
7045
6974
  "type": "option"
7046
6975
  },
7047
- "outputfile": {
7048
- "char": "f",
7049
- "description": "Force the path and name of output report file. Must end with .csv",
7050
- "name": "outputfile",
6976
+ "path": {
6977
+ "char": "p",
6978
+ "description": "Path to the file export project",
6979
+ "name": "path",
7051
6980
  "hasDynamicHelp": false,
7052
6981
  "multiple": false,
7053
6982
  "type": "option"
7054
6983
  },
6984
+ "overwrite": {
6985
+ "char": "f",
6986
+ "description": "Override existing files (doubles the number of API calls)",
6987
+ "name": "overwrite",
6988
+ "allowNo": false,
6989
+ "type": "boolean"
6990
+ },
7055
6991
  "debug": {
7056
6992
  "char": "d",
7057
6993
  "description": "Activate debug mode (more logs)",
@@ -7090,13 +7026,13 @@
7090
7026
  },
7091
7027
  "hasDynamicHelp": true,
7092
7028
  "hiddenAliases": [],
7093
- "id": "hardis:org:diagnose:releaseupdates",
7029
+ "id": "hardis:org:files:import",
7094
7030
  "pluginAlias": "sfdx-hardis",
7095
7031
  "pluginName": "sfdx-hardis",
7096
7032
  "pluginType": "core",
7097
7033
  "strict": true,
7098
7034
  "enableJsonFlag": true,
7099
- "title": "Check Release Updates of an org",
7035
+ "title": "Import files",
7100
7036
  "requiresProject": false,
7101
7037
  "isESM": true,
7102
7038
  "relativePath": [
@@ -7104,43 +7040,44 @@
7104
7040
  "commands",
7105
7041
  "hardis",
7106
7042
  "org",
7107
- "diagnose",
7108
- "releaseupdates.js"
7043
+ "files",
7044
+ "import.js"
7109
7045
  ],
7110
7046
  "aliasPermutations": [],
7111
7047
  "permutations": [
7112
- "hardis:org:diagnose:releaseupdates",
7113
- "org:hardis:diagnose:releaseupdates",
7114
- "org:diagnose:hardis:releaseupdates",
7115
- "org:diagnose:releaseupdates:hardis",
7116
- "hardis:diagnose:org:releaseupdates",
7117
- "diagnose:hardis:org:releaseupdates",
7118
- "diagnose:org:hardis:releaseupdates",
7119
- "diagnose:org:releaseupdates:hardis",
7120
- "hardis:diagnose:releaseupdates:org",
7121
- "diagnose:hardis:releaseupdates:org",
7122
- "diagnose:releaseupdates:hardis:org",
7123
- "diagnose:releaseupdates:org:hardis",
7124
- "hardis:org:releaseupdates:diagnose",
7125
- "org:hardis:releaseupdates:diagnose",
7126
- "org:releaseupdates:hardis:diagnose",
7127
- "org:releaseupdates:diagnose:hardis",
7128
- "hardis:releaseupdates:org:diagnose",
7129
- "releaseupdates:hardis:org:diagnose",
7130
- "releaseupdates:org:hardis:diagnose",
7131
- "releaseupdates:org:diagnose:hardis",
7132
- "hardis:releaseupdates:diagnose:org",
7133
- "releaseupdates:hardis:diagnose:org",
7134
- "releaseupdates:diagnose:hardis:org",
7135
- "releaseupdates:diagnose:org:hardis"
7136
- ]
7137
- },
7138
- "hardis:org:diagnose:unsecure-connected-apps": {
7139
- "aliases": [],
7140
- "args": {},
7141
- "description": "\n## Command Behavior\n\n**Detects unsecured Connected Apps in a Salesforce org and generates detailed reports for security analysis.**\n\nThis command is a critical security diagnostic tool that helps administrators identify Connected Apps that may pose security risks due to improper configuration. It provides comprehensive analysis of OAuth tokens and Connected App security settings to ensure proper access control.\n\nKey functionalities:\n\n- **OAuth Token Analysis:** Queries all OAuth tokens in the org using SOQL to retrieve comprehensive token information including app names, users, authorization status, and usage statistics.\n- **Security Status Assessment:** Evaluates each Connected App's security configuration by checking the `IsUsingAdminAuthorization` flag to determine if admin pre-approval is required.\n- **Unsecured App Detection:** Identifies Connected Apps that allow users to authorize themselves without admin approval, which can pose security risks.\n- **Detailed Reporting:** Generates two comprehensive CSV reports:\n - **OAuth Tokens Report:** Lists all OAuth tokens with security status, user information, and usage data\n - **Connected Apps Summary:** Aggregates unsecured Connected Apps with counts of associated OAuth tokens\n- **Visual Indicators:** Uses status icons (❌ for unsecured, ✅ for secured) to provide immediate visual feedback on security status.\n- **Security Recommendations:** Provides actionable guidance on how to secure Connected Apps through proper configuration.\n- **Notifications:** Sends alerts to configured channels (Grafana, Slack, MS Teams) with security findings and attached reports.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-org-security/) and can output Grafana, Slack and MsTeams Notifications.\n\n<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/jHv8yrSK8Dg\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query Execution:** Executes a comprehensive SOQL query on the `OauthToken` object, joining with `AppMenuItem` and `User` objects to gather complete security context.\n- **Security Analysis Logic:** Analyzes the `AppMenuItem.IsUsingAdminAuthorization` field to determine if a Connected App requires admin pre-approval for user authorization.\n- **Data Transformation:** Processes raw SOQL results to add security status indicators and reorganize data for optimal reporting and analysis.\n- **Aggregation Processing:** Groups OAuth tokens by Connected App name to provide summary statistics and identify the most problematic applications.\n- **Report Generation:** Uses `generateCsvFile` to create structured CSV reports with proper formatting and metadata for easy analysis and sharing.\n- **Notification Integration:** Integrates with the `NotifProvider` to send security alerts with detailed metrics, including the number of unsecured Connected Apps and associated OAuth tokens.\n- **File Management:** Generates multiple output formats (CSV, XLSX) and manages file paths using `generateReportPath` for consistent report organization.\n- **Connection Management:** Uses `setConnectionVariables` to ensure proper authentication context for notification providers that require org connection details.\n</details>\n",
7048
+ "hardis:org:files:import",
7049
+ "org:hardis:files:import",
7050
+ "org:files:hardis:import",
7051
+ "org:files:import:hardis",
7052
+ "hardis:files:org:import",
7053
+ "files:hardis:org:import",
7054
+ "files:org:hardis:import",
7055
+ "files:org:import:hardis",
7056
+ "hardis:files:import:org",
7057
+ "files:hardis:import:org",
7058
+ "files:import:hardis:org",
7059
+ "files:import:org:hardis",
7060
+ "hardis:org:import:files",
7061
+ "org:hardis:import:files",
7062
+ "org:import:hardis:files",
7063
+ "org:import:files:hardis",
7064
+ "hardis:import:org:files",
7065
+ "import:hardis:org:files",
7066
+ "import:org:hardis:files",
7067
+ "import:org:files:hardis",
7068
+ "hardis:import:files:org",
7069
+ "import:hardis:files:org",
7070
+ "import:files:hardis:org",
7071
+ "import:files:org:hardis"
7072
+ ]
7073
+ },
7074
+ "hardis:org:fix:listviewmine": {
7075
+ "aliases": [],
7076
+ "args": {},
7077
+ "description": "Fix listviews whose scope Mine has been replaced by Everything\n\n[![Invalid scope:Mine, not allowed ? Deploy your ListViews anyway !](https://github.com/hardisgroupcom/sfdx-hardis/raw/main/docs/assets/images/article-invalid-scope-mine.jpg)](https://nicolas.vuillamy.fr/invalid-scope-mine-not-allowed-deploy-your-listviews-anyway-443aceca8ac7)\n\nList of ListViews can be:\n\n- read from .sfdx-hardis.yml file in property **listViewsToSetToMine**\n- sent in argument listviews\n\nNote: property **listViewsToSetToMine** can be auto-generated by command hardis:work:save if .sfdx-hardis.yml contains the following configuration\n\n```yaml\nautoCleanTypes:\n - listViewsMine\n```\n\n- Example of sfdx-hardis.yml property `listViewsToSetToMine`:\n\n```yaml\nlistViewsToSetToMine:\n - \"force-app/main/default/objects/Operation__c/listViews/MyCurrentOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Operation__c/listViews/MyFinalizedOperations.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/Default_Opportunity_Pipeline.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MyCurrentSubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Opportunity/listViews/MySubscriptions.listView-meta.xml\"\n - \"force-app/main/default/objects/Account/listViews/MyActivePartners.listView-meta.xml\"\n```\n\n- If manually written, this could also be:\n\n```yaml\nlistViewsToSetToMine:\n - \"Operation__c:MyCurrentOperations\"\n - \"Operation__c:MyFinalizedOperations\"\n - \"Opportunity:Default_Opportunity_Pipeline\"\n - \"Opportunity:MyCurrentSubscriptions\"\n - \"Opportunity:MySubscriptions\"\n - \"Account:MyActivePartners\"\n```\n\nTroubleshooting: if you need to run this command from an alpine-linux based docker image, use this workaround in your dockerfile:\n\n```dockerfile\n# Do not use puppeteer embedded chromium\nRUN apk add --update --no-cache chromium\nENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=\"true\"\nENV CHROMIUM_PATH=\"/usr/bin/chromium-browser\"\nENV PUPPETEER_EXECUTABLE_PATH=\"$\\{CHROMIUM_PATH}\" // remove \\ before {\n```\n",
7142
7078
  "examples": [
7143
- "$ sf hardis:org:diagnose:unsecure-connected-apps"
7079
+ "$ sf hardis:org:fix:listviewmine",
7080
+ "$ sf hardis:org:fix:listviewmine --listviews Opportunity:MySubscriptions,Account:MyActivePartners"
7144
7081
  ],
7145
7082
  "flags": {
7146
7083
  "json": {
@@ -7158,10 +7095,10 @@
7158
7095
  "multiple": false,
7159
7096
  "type": "option"
7160
7097
  },
7161
- "outputfile": {
7162
- "char": "f",
7163
- "description": "Force the path and name of output report file. Must end with .csv",
7164
- "name": "outputfile",
7098
+ "listviews": {
7099
+ "char": "l",
7100
+ "description": "Comma-separated list of listviews following format Object:ListViewName\nExample: Contact:MyContacts,Contact:MyActiveContacts,Opportunity:MYClosedOpportunities",
7101
+ "name": "listviews",
7165
7102
  "hasDynamicHelp": false,
7166
7103
  "multiple": false,
7167
7104
  "type": "option"
@@ -7204,58 +7141,59 @@
7204
7141
  },
7205
7142
  "hasDynamicHelp": true,
7206
7143
  "hiddenAliases": [],
7207
- "id": "hardis:org:diagnose:unsecure-connected-apps",
7144
+ "id": "hardis:org:fix:listviewmine",
7208
7145
  "pluginAlias": "sfdx-hardis",
7209
7146
  "pluginName": "sfdx-hardis",
7210
7147
  "pluginType": "core",
7211
7148
  "strict": true,
7212
7149
  "enableJsonFlag": true,
7213
- "title": "Detect Unsecured Connected Apps",
7214
- "requiresProject": false,
7150
+ "title": "Fix listviews with ",
7151
+ "requiresProject": true,
7215
7152
  "isESM": true,
7216
7153
  "relativePath": [
7217
7154
  "lib",
7218
7155
  "commands",
7219
7156
  "hardis",
7220
7157
  "org",
7221
- "diagnose",
7222
- "unsecure-connected-apps.js"
7158
+ "fix",
7159
+ "listviewmine.js"
7223
7160
  ],
7224
7161
  "aliasPermutations": [],
7225
7162
  "permutations": [
7226
- "hardis:org:diagnose:unsecure-connected-apps",
7227
- "org:hardis:diagnose:unsecure-connected-apps",
7228
- "org:diagnose:hardis:unsecure-connected-apps",
7229
- "org:diagnose:unsecure-connected-apps:hardis",
7230
- "hardis:diagnose:org:unsecure-connected-apps",
7231
- "diagnose:hardis:org:unsecure-connected-apps",
7232
- "diagnose:org:hardis:unsecure-connected-apps",
7233
- "diagnose:org:unsecure-connected-apps:hardis",
7234
- "hardis:diagnose:unsecure-connected-apps:org",
7235
- "diagnose:hardis:unsecure-connected-apps:org",
7236
- "diagnose:unsecure-connected-apps:hardis:org",
7237
- "diagnose:unsecure-connected-apps:org:hardis",
7238
- "hardis:org:unsecure-connected-apps:diagnose",
7239
- "org:hardis:unsecure-connected-apps:diagnose",
7240
- "org:unsecure-connected-apps:hardis:diagnose",
7241
- "org:unsecure-connected-apps:diagnose:hardis",
7242
- "hardis:unsecure-connected-apps:org:diagnose",
7243
- "unsecure-connected-apps:hardis:org:diagnose",
7244
- "unsecure-connected-apps:org:hardis:diagnose",
7245
- "unsecure-connected-apps:org:diagnose:hardis",
7246
- "hardis:unsecure-connected-apps:diagnose:org",
7247
- "unsecure-connected-apps:hardis:diagnose:org",
7248
- "unsecure-connected-apps:diagnose:hardis:org",
7249
- "unsecure-connected-apps:diagnose:org:hardis"
7163
+ "hardis:org:fix:listviewmine",
7164
+ "org:hardis:fix:listviewmine",
7165
+ "org:fix:hardis:listviewmine",
7166
+ "org:fix:listviewmine:hardis",
7167
+ "hardis:fix:org:listviewmine",
7168
+ "fix:hardis:org:listviewmine",
7169
+ "fix:org:hardis:listviewmine",
7170
+ "fix:org:listviewmine:hardis",
7171
+ "hardis:fix:listviewmine:org",
7172
+ "fix:hardis:listviewmine:org",
7173
+ "fix:listviewmine:hardis:org",
7174
+ "fix:listviewmine:org:hardis",
7175
+ "hardis:org:listviewmine:fix",
7176
+ "org:hardis:listviewmine:fix",
7177
+ "org:listviewmine:hardis:fix",
7178
+ "org:listviewmine:fix:hardis",
7179
+ "hardis:listviewmine:org:fix",
7180
+ "listviewmine:hardis:org:fix",
7181
+ "listviewmine:org:hardis:fix",
7182
+ "listviewmine:org:fix:hardis",
7183
+ "hardis:listviewmine:fix:org",
7184
+ "listviewmine:hardis:fix:org",
7185
+ "listviewmine:fix:hardis:org",
7186
+ "listviewmine:fix:org:hardis"
7250
7187
  ]
7251
7188
  },
7252
- "hardis:org:diagnose:unused-apex-classes": {
7189
+ "hardis:org:generate:packagexmlfull": {
7253
7190
  "aliases": [],
7254
7191
  "args": {},
7255
- "description": "List all async Apex classes (Batch,Queueable,Schedulable) that has not been called for more than 365 days.\n \nThe result class list probably can be removed from the project, and that will improve your test classes performances 😊\n\nThe number of unused day is overridable using --days option. \n\nThe command uses queries on AsyncApexJob and CronTrigger technical tables to build the result.\n\nApex Classes CreatedBy and CreatedOn fields are calculated from MIN(date from git, date from org)\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-apex-classes/) and can output Grafana, Slack and MsTeams Notifications.\n\n![](https://sfdx-hardis.cloudity.com/assets/images/screenshot-monitoring-unused-apex-grafana.jpg)\n",
7192
+ "description": "\n## Command Behavior\n\n**Generates a comprehensive `package.xml` file for a Salesforce org, including all metadata components, even managed ones.**\n\nThis command is essential for various Salesforce development and administration tasks, especially when you need a complete snapshot of an org's metadata. It goes beyond typical source tracking by including managed package components, which is crucial for understanding the full metadata footprint of an org.\n\nKey functionalities:\n\n- **Full Org Metadata Retrieval:** Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a complete list of all metadata types and their members.\n- **Managed Package Inclusion:** Unlike standard source retrieval, this command explicitly includes metadata from managed packages, providing a truly comprehensive `package.xml`.\n- **Customizable Output:** Allows you to specify the output file path for the generated `package.xml`.\n- **Interactive Org Selection:** If no target org is specified, it interactively prompts the user to choose an org. (or use --no-prompt to skip this step)\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce Metadata API Interaction:** It leverages the Salesforce Metadata API to list all available metadata types and then retrieve all components for each type.\n- **`buildOrgManifest` Utility:** The core logic for querying the org's metadata and constructing the `package.xml` is encapsulated within the `buildOrgManifest` utility function.\n- **XML Generation:** It dynamically builds the XML structure of the `package.xml` file, including the `types` and `members` elements for all retrieved metadata.\n- **File System Operations:** It writes the generated `package.xml` file to the specified output path.\n- **Interactive Prompts:** Uses `promptOrgUsernameDefault` to guide the user in selecting the target Salesforce org.\n</details>\n",
7256
7193
  "examples": [
7257
- "$ sf hardis:org:diagnose:unused-apex-classes",
7258
- "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
7194
+ "$ sf hardis:org:generate:packagexmlfull",
7195
+ "$ sf hardis:org:generate:packagexmlfull --outputfile /tmp/packagexmlfull.xml",
7196
+ "$ sf hardis:org:generate:packagexmlfull --target-org nico@example.com"
7259
7197
  ],
7260
7198
  "flags": {
7261
7199
  "json": {
@@ -7274,21 +7212,12 @@
7274
7212
  "type": "option"
7275
7213
  },
7276
7214
  "outputfile": {
7277
- "char": "f",
7278
- "description": "Force the path and name of output report file. Must end with .csv",
7215
+ "description": "Output package.xml file",
7279
7216
  "name": "outputfile",
7280
7217
  "hasDynamicHelp": false,
7281
7218
  "multiple": false,
7282
7219
  "type": "option"
7283
7220
  },
7284
- "days": {
7285
- "char": "t",
7286
- "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7287
- "name": "days",
7288
- "hasDynamicHelp": false,
7289
- "multiple": false,
7290
- "type": "option"
7291
- },
7292
7221
  "debug": {
7293
7222
  "char": "d",
7294
7223
  "description": "Activate debug mode (more logs)",
@@ -7296,6 +7225,13 @@
7296
7225
  "allowNo": false,
7297
7226
  "type": "boolean"
7298
7227
  },
7228
+ "no-prompt": {
7229
+ "char": "n",
7230
+ "description": "Do not prompt for org username, use the default one",
7231
+ "name": "no-prompt",
7232
+ "allowNo": false,
7233
+ "type": "boolean"
7234
+ },
7299
7235
  "websocket": {
7300
7236
  "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
7301
7237
  "name": "websocket",
@@ -7327,13 +7263,13 @@
7327
7263
  },
7328
7264
  "hasDynamicHelp": true,
7329
7265
  "hiddenAliases": [],
7330
- "id": "hardis:org:diagnose:unused-apex-classes",
7266
+ "id": "hardis:org:generate:packagexmlfull",
7331
7267
  "pluginAlias": "sfdx-hardis",
7332
7268
  "pluginName": "sfdx-hardis",
7333
7269
  "pluginType": "core",
7334
7270
  "strict": true,
7335
7271
  "enableJsonFlag": true,
7336
- "title": "Detect unused Apex classes in an org",
7272
+ "title": "Generate Full Org package.xml",
7337
7273
  "requiresProject": false,
7338
7274
  "isESM": true,
7339
7275
  "relativePath": [
@@ -7341,43 +7277,43 @@
7341
7277
  "commands",
7342
7278
  "hardis",
7343
7279
  "org",
7344
- "diagnose",
7345
- "unused-apex-classes.js"
7280
+ "generate",
7281
+ "packagexmlfull.js"
7346
7282
  ],
7347
7283
  "aliasPermutations": [],
7348
7284
  "permutations": [
7349
- "hardis:org:diagnose:unused-apex-classes",
7350
- "org:hardis:diagnose:unused-apex-classes",
7351
- "org:diagnose:hardis:unused-apex-classes",
7352
- "org:diagnose:unused-apex-classes:hardis",
7353
- "hardis:diagnose:org:unused-apex-classes",
7354
- "diagnose:hardis:org:unused-apex-classes",
7355
- "diagnose:org:hardis:unused-apex-classes",
7356
- "diagnose:org:unused-apex-classes:hardis",
7357
- "hardis:diagnose:unused-apex-classes:org",
7358
- "diagnose:hardis:unused-apex-classes:org",
7359
- "diagnose:unused-apex-classes:hardis:org",
7360
- "diagnose:unused-apex-classes:org:hardis",
7361
- "hardis:org:unused-apex-classes:diagnose",
7362
- "org:hardis:unused-apex-classes:diagnose",
7363
- "org:unused-apex-classes:hardis:diagnose",
7364
- "org:unused-apex-classes:diagnose:hardis",
7365
- "hardis:unused-apex-classes:org:diagnose",
7366
- "unused-apex-classes:hardis:org:diagnose",
7367
- "unused-apex-classes:org:hardis:diagnose",
7368
- "unused-apex-classes:org:diagnose:hardis",
7369
- "hardis:unused-apex-classes:diagnose:org",
7370
- "unused-apex-classes:hardis:diagnose:org",
7371
- "unused-apex-classes:diagnose:hardis:org",
7372
- "unused-apex-classes:diagnose:org:hardis"
7285
+ "hardis:org:generate:packagexmlfull",
7286
+ "org:hardis:generate:packagexmlfull",
7287
+ "org:generate:hardis:packagexmlfull",
7288
+ "org:generate:packagexmlfull:hardis",
7289
+ "hardis:generate:org:packagexmlfull",
7290
+ "generate:hardis:org:packagexmlfull",
7291
+ "generate:org:hardis:packagexmlfull",
7292
+ "generate:org:packagexmlfull:hardis",
7293
+ "hardis:generate:packagexmlfull:org",
7294
+ "generate:hardis:packagexmlfull:org",
7295
+ "generate:packagexmlfull:hardis:org",
7296
+ "generate:packagexmlfull:org:hardis",
7297
+ "hardis:org:packagexmlfull:generate",
7298
+ "org:hardis:packagexmlfull:generate",
7299
+ "org:packagexmlfull:hardis:generate",
7300
+ "org:packagexmlfull:generate:hardis",
7301
+ "hardis:packagexmlfull:org:generate",
7302
+ "packagexmlfull:hardis:org:generate",
7303
+ "packagexmlfull:org:hardis:generate",
7304
+ "packagexmlfull:org:generate:hardis",
7305
+ "hardis:packagexmlfull:generate:org",
7306
+ "packagexmlfull:hardis:generate:org",
7307
+ "packagexmlfull:generate:hardis:org",
7308
+ "packagexmlfull:generate:org:hardis"
7373
7309
  ]
7374
7310
  },
7375
- "hardis:org:diagnose:unused-connected-apps": {
7311
+ "hardis:org:monitor:all": {
7376
7312
  "aliases": [],
7377
7313
  "args": {},
7378
- "description": "\n## Command Behavior\n\n**Identifies and reports on potentially unused Connected Apps in a Salesforce org, suggesting candidates for deletion or deactivation.**\n\nThis command helps improve org security and reduce technical debt by pinpointing Connected Apps that are no longer actively used. Connected Apps can pose security risks if left unmonitored, and cleaning them up contributes to a healthier Salesforce environment.\n\nKey functionalities:\n\n- **Connected App Data Collection:** Gathers information about all Connected Apps in the org, including creation and last modified dates, and associated users.\n- **Usage Analysis:** Analyzes `LoginHistory` and `OAuthToken` records to determine the last usage date of each Connected App.\n- **Inactivity Detection:** Flags Connected Apps as potentially unused if they have no recent login history or OAuth token usage.\n- **Accessibility Check:** Examines Connected App metadata to identify if they are accessible (e.g., if they require admin approval and have no profiles or permission sets assigned).\n- **Ignored Apps:** Automatically ignores a predefined list of common Salesforce Connected Apps (e.g., `Salesforce CLI`, `Salesforce Mobile Dashboards`). You can extend this list by defining the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n- **CSV Report Generation:** Generates a CSV file containing details of all analyzed Connected Apps, including their usage status, last usage date, and reasons for being flagged as potentially unused.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of potentially unused Connected Apps.\n\n**Default Ignored Connected Apps:**\n\n- Ant Migration Tool\n- Chatter Desktop\n- Chatter Mobile for BlackBerry\n- Force.com IDE\n- OIQ_Integration\n- Salesforce CLI\n- Salesforce Files\n- Salesforce Mobile Dashboards\n- Salesforce Touch\n- Salesforce for Outlook\n- SalesforceA\n- SalesforceA for Android\n- SalesforceA for iOS\n- SalesforceDX Namespace Registry\n- SalesforceIQ\n\nYou can add more ignored apps by defining a comma-separated list of names in the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable.\n\n_Example: \nALLOWED_INACTIVE_CONNECTED_APPS=My App 1,My App 2, My App 3_\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-connected-apps/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce SOQL Queries:** It performs SOQL queries against `ConnectedApplication`, `LoginHistory`, and `OAuthToken` objects to gather comprehensive data about Connected Apps and their usage.\n- **Temporary SFDX Project:** It creates a temporary SFDX project to retrieve Connected App metadata, allowing for local parsing and analysis of their XML files.\n- **Metadata Parsing:** It parses the `connectedApp-meta.xml` files to check for `isAdminApproved` and the presence of `profileName` or `permissionsetName` to determine accessibility.\n- **Data Correlation:** It correlates data from various Salesforce objects to build a complete picture of each Connected App's usage and status.\n- **Date Calculation:** Uses `moment` to calculate the time since the last OAuth token usage.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused Connected Apps.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **File System Operations:** Uses `fs-extra` for creating and removing temporary directories and files.\n- **Environment Variable Reading:** Reads the `ALLOWED_INACTIVE_CONNECTED_APPS` environment variable to customize the list of ignored Connected Apps.\n</details>\n",
7314
+ "description": "Monitor org, generate reports and sends notifications\n\nYou can disable some commands defining either a **monitoringDisable** property in `.sfdx-hardis.yml`, or a comma separated list in env variable **MONITORING_DISABLE**\n\nExample in .sfdx-hardis.yml:\n \n```yaml\nmonitoringDisable:\n - METADATA_STATUS\n - MISSING_ATTRIBUTES\n - UNUSED_METADATAS\n```\n \nExample in env var:\n\n```sh\nMONITORING_DISABLE=METADATA_STATUS,MISSING_ATTRIBUTES,UNUSED_METADATAS\n```\n\nA [default list of monitoring commands](https://sfdx-hardis.cloudity.com/salesforce-monitoring-home/#monitoring-commands) is used, if you want to override it you can define property **monitoringCommands** in your .sfdx-hardis.yml file\n\nExample:\n\n```yaml\nmonitoringCommands:\n - title: My Custom command\n command: sf my:custom:command\n - title: My Custom command 2\n command: sf my:other:custom:command\n```\n\nYou can force the daily run of all commands by defining env var `MONITORING_IGNORE_FREQUENCY=true`\n\nThe default list of commands is the following:\n\n| Key | Description | Command | Frequency |\n| :---: | :---- | :---- | :-----: |\n| [AUDIT_TRAIL](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/audittrail) | Detect suspect setup actions in major org | [sf hardis:org:diagnose:audittrail](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/audittrail) | daily |\n| [LEGACY_API](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/legacyapi) | Detect calls to deprecated API versions | [sf hardis:org:diagnose:legacyapi](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/legacyapi) | daily |\n| [ORG_LIMITS](https://sfdx-hardis.cloudity.com/hardis/org/monitor/limits) | Detect if org limits are close to be reached | [sf hardis:org:monitor:limits](https://sfdx-hardis.cloudity.com/hardis/org/monitor/limits) | daily |\n| [UNSECURED_CONNECTED_APPS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unsecure-connected-apps) | Detect unsecured Connected Apps in an org | [sf hardis:org:diagnose:unsecure-connected-apps](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unsecure-connected-apps) | daily |\n| [LICENSES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/licenses) | Extract licenses information | [sf hardis:org:diagnose:licenses](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/licenses) | weekly |\n| [LINT_ACCESS](https://sfdx-hardis.cloudity.com/hardis/lint/access) | Detect custom elements with no access rights defined in permission sets | [sf hardis:lint:access](https://sfdx-hardis.cloudity.com/hardis/lint/access) | weekly |\n| [UNUSED_LICENSES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedlicenses) | Detect permission set licenses that are assigned to users that do not need them | [sf hardis:org:diagnose:unusedlicenses](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedlicenses) | weekly |\n| [UNUSED_USERS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | Detect active users without recent logins | [sf hardis:org:diagnose:unusedusers](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | weekly |\n| [ACTIVE_USERS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | Detect active users with recent logins | [sf hardis:org:diagnose:unusedusers --returnactiveusers](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unusedusers) | weekly |\n| [ORG_INFO](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/instanceupgrade) | Get org info + SF instance info + next major upgrade date | [sf hardis:org:diagnose:instanceupgrade](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/instanceupgrade) | weekly |\n| [RELEASE_UPDATES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/releaseupdates) | Gather warnings about incoming and overdue Release Updates | [sf hardis:org:diagnose:releaseupdates](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/releaseupdates) | weekly |\n| [UNUSED_METADATAS](https://sfdx-hardis.cloudity.com/hardis/lint/unusedmetadatas) | Detect custom labels and custom permissions that are not in use | [sf hardis:lint:unusedmetadatas](https://sfdx-hardis.cloudity.com/hardis/lint/unusedmetadatas) | weekly |\n| [UNUSED_APEX_CLASSES](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-apex-classes) | Detect unused Apex classes in an org | [sf hardis:org:diagnose:unused-apex-classes](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-apex-classes) | weekly |\n| [CONNECTED_APPS](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-connected-apps) | Detect unused Connected Apps in an org | [sf hardis:org:diagnose:unused-connected-apps](https://sfdx-hardis.cloudity.com/hardis/org/diagnose/unused-connected-apps) | weekly |\n| [METADATA_STATUS](https://sfdx-hardis.cloudity.com/hardis/lint/metadatastatus) | Detect inactive metadata | [sf hardis:lint:metadatastatus](https://sfdx-hardis.cloudity.com/hardis/lint/metadatastatus) | weekly |\n| [MISSING_ATTRIBUTES](https://sfdx-hardis.cloudity.com/hardis/lint/missingattributes) | Detect missing description on custom field | [sf hardis:lint:missingattributes](https://sfdx-hardis.cloudity.com/hardis/lint/missingattributes) | weekly |\n\n",
7379
7315
  "examples": [
7380
- "$ sf hardis:org:diagnose:unused-connected-apps"
7316
+ "$ sf hardis:org:monitor:all"
7381
7317
  ],
7382
7318
  "flags": {
7383
7319
  "json": {
@@ -7395,14 +7331,6 @@
7395
7331
  "multiple": false,
7396
7332
  "type": "option"
7397
7333
  },
7398
- "outputfile": {
7399
- "char": "f",
7400
- "description": "Force the path and name of output report file. Must end with .csv",
7401
- "name": "outputfile",
7402
- "hasDynamicHelp": false,
7403
- "multiple": false,
7404
- "type": "option"
7405
- },
7406
7334
  "debug": {
7407
7335
  "char": "d",
7408
7336
  "description": "Activate debug mode (more logs)",
@@ -7441,75 +7369,159 @@
7441
7369
  },
7442
7370
  "hasDynamicHelp": true,
7443
7371
  "hiddenAliases": [],
7444
- "id": "hardis:org:diagnose:unused-connected-apps",
7372
+ "id": "hardis:org:monitor:all",
7445
7373
  "pluginAlias": "sfdx-hardis",
7446
7374
  "pluginName": "sfdx-hardis",
7447
7375
  "pluginType": "core",
7448
7376
  "strict": true,
7449
7377
  "enableJsonFlag": true,
7450
- "title": "Unused Connected Apps in an org",
7451
- "allowedInactiveConnectedApps": [
7452
- "Ant Migration Tool",
7453
- "Chatter Desktop",
7454
- "Chatter Mobile for BlackBerry",
7455
- "Force.com IDE",
7456
- "OIQ_Integration",
7457
- "Salesforce CLI",
7458
- "Salesforce Files",
7459
- "Salesforce Mobile Dashboards",
7460
- "Salesforce Touch",
7461
- "Salesforce for Outlook",
7462
- "SalesforceA",
7463
- "SalesforceA for Android",
7464
- "SalesforceA for iOS",
7465
- "SalesforceDX Namespace Registry",
7466
- "SalesforceIQ"
7378
+ "title": "Monitor org",
7379
+ "monitoringCommandsDefault": [
7380
+ {
7381
+ "key": "AUDIT_TRAIL",
7382
+ "title": "Detect suspect setup actions in major org",
7383
+ "command": "sf hardis:org:diagnose:audittrail",
7384
+ "frequency": "daily"
7385
+ },
7386
+ {
7387
+ "key": "LEGACY_API",
7388
+ "title": "Detect calls to deprecated API versions",
7389
+ "command": "sf hardis:org:diagnose:legacyapi",
7390
+ "frequency": "daily"
7391
+ },
7392
+ {
7393
+ "key": "ORG_LIMITS",
7394
+ "title": "Detect if org limits are close to be reached",
7395
+ "command": "sf hardis:org:monitor:limits",
7396
+ "frequency": "daily"
7397
+ },
7398
+ {
7399
+ "key": "UNSECURED_CONNECTED_APPS",
7400
+ "title": "Detect unsecured Connected Apps in an org",
7401
+ "command": "sf hardis:org:diagnose:unsecure-connected-apps",
7402
+ "frequency": "daily"
7403
+ },
7404
+ {
7405
+ "key": "LICENSES",
7406
+ "title": "Extract licenses information",
7407
+ "command": "sf hardis:org:diagnose:licenses",
7408
+ "frequency": "weekly"
7409
+ },
7410
+ {
7411
+ "key": "LINT_ACCESS",
7412
+ "title": "Detect custom elements with no access rights defined in permission sets",
7413
+ "command": "sf hardis:lint:access",
7414
+ "frequency": "weekly"
7415
+ },
7416
+ {
7417
+ "key": "UNUSED_LICENSES",
7418
+ "title": "Detect permission set licenses that are assigned to users that do not need them",
7419
+ "command": "sf hardis:org:diagnose:unusedlicenses",
7420
+ "frequency": "weekly"
7421
+ },
7422
+ {
7423
+ "key": "UNUSED_USERS",
7424
+ "title": "Detect active users without recent logins",
7425
+ "command": "sf hardis:org:diagnose:unusedusers",
7426
+ "frequency": "weekly"
7427
+ },
7428
+ {
7429
+ "key": "ACTIVE_USERS",
7430
+ "title": "Detect active users with recent logins",
7431
+ "command": "sf hardis:org:diagnose:unusedusers --returnactiveusers",
7432
+ "frequency": "weekly"
7433
+ },
7434
+ {
7435
+ "key": "ORG_INFO",
7436
+ "title": "Get org info + SF instance info + next major upgrade date",
7437
+ "command": "sf hardis:org:diagnose:instanceupgrade",
7438
+ "frequency": "weekly"
7439
+ },
7440
+ {
7441
+ "key": "RELEASE_UPDATES",
7442
+ "title": "Gather warnings about incoming and overdue Release Updates",
7443
+ "command": "sf hardis:org:diagnose:releaseupdates",
7444
+ "frequency": "weekly"
7445
+ },
7446
+ {
7447
+ "key": "UNUSED_METADATAS",
7448
+ "title": "Detect custom labels and custom permissions that are not in use",
7449
+ "command": "sf hardis:lint:unusedmetadatas",
7450
+ "frequency": "weekly"
7451
+ },
7452
+ {
7453
+ "key": "UNUSED_APEX_CLASSES",
7454
+ "title": "Detect unused Apex classes in an org",
7455
+ "command": "sf hardis:org:diagnose:unused-apex-classes",
7456
+ "frequency": "weekly"
7457
+ },
7458
+ {
7459
+ "key": "CONNECTED_APPS",
7460
+ "title": "Detect unused Connected Apps in an org",
7461
+ "command": "sf hardis:org:diagnose:unused-connected-apps",
7462
+ "frequency": "weekly"
7463
+ },
7464
+ {
7465
+ "key": "METADATA_STATUS",
7466
+ "title": "Detect inactive metadata",
7467
+ "command": "sf hardis:lint:metadatastatus",
7468
+ "frequency": "weekly"
7469
+ },
7470
+ {
7471
+ "key": "MISSING_ATTRIBUTES",
7472
+ "title": "Detect missing description on custom field",
7473
+ "command": "sf hardis:lint:missingattributes",
7474
+ "frequency": "weekly"
7475
+ }
7467
7476
  ],
7468
- "requiresProject": false,
7477
+ "requiresProject": true,
7478
+ "triggerNotification": true,
7469
7479
  "isESM": true,
7470
7480
  "relativePath": [
7471
7481
  "lib",
7472
7482
  "commands",
7473
7483
  "hardis",
7474
7484
  "org",
7475
- "diagnose",
7476
- "unused-connected-apps.js"
7485
+ "monitor",
7486
+ "all.js"
7477
7487
  ],
7478
7488
  "aliasPermutations": [],
7479
7489
  "permutations": [
7480
- "hardis:org:diagnose:unused-connected-apps",
7481
- "org:hardis:diagnose:unused-connected-apps",
7482
- "org:diagnose:hardis:unused-connected-apps",
7483
- "org:diagnose:unused-connected-apps:hardis",
7484
- "hardis:diagnose:org:unused-connected-apps",
7485
- "diagnose:hardis:org:unused-connected-apps",
7486
- "diagnose:org:hardis:unused-connected-apps",
7487
- "diagnose:org:unused-connected-apps:hardis",
7488
- "hardis:diagnose:unused-connected-apps:org",
7489
- "diagnose:hardis:unused-connected-apps:org",
7490
- "diagnose:unused-connected-apps:hardis:org",
7491
- "diagnose:unused-connected-apps:org:hardis",
7492
- "hardis:org:unused-connected-apps:diagnose",
7493
- "org:hardis:unused-connected-apps:diagnose",
7494
- "org:unused-connected-apps:hardis:diagnose",
7495
- "org:unused-connected-apps:diagnose:hardis",
7496
- "hardis:unused-connected-apps:org:diagnose",
7497
- "unused-connected-apps:hardis:org:diagnose",
7498
- "unused-connected-apps:org:hardis:diagnose",
7499
- "unused-connected-apps:org:diagnose:hardis",
7500
- "hardis:unused-connected-apps:diagnose:org",
7501
- "unused-connected-apps:hardis:diagnose:org",
7502
- "unused-connected-apps:diagnose:hardis:org",
7503
- "unused-connected-apps:diagnose:org:hardis"
7490
+ "hardis:org:monitor:all",
7491
+ "org:hardis:monitor:all",
7492
+ "org:monitor:hardis:all",
7493
+ "org:monitor:all:hardis",
7494
+ "hardis:monitor:org:all",
7495
+ "monitor:hardis:org:all",
7496
+ "monitor:org:hardis:all",
7497
+ "monitor:org:all:hardis",
7498
+ "hardis:monitor:all:org",
7499
+ "monitor:hardis:all:org",
7500
+ "monitor:all:hardis:org",
7501
+ "monitor:all:org:hardis",
7502
+ "hardis:org:all:monitor",
7503
+ "org:hardis:all:monitor",
7504
+ "org:all:hardis:monitor",
7505
+ "org:all:monitor:hardis",
7506
+ "hardis:all:org:monitor",
7507
+ "all:hardis:org:monitor",
7508
+ "all:org:hardis:monitor",
7509
+ "all:org:monitor:hardis",
7510
+ "hardis:all:monitor:org",
7511
+ "all:hardis:monitor:org",
7512
+ "all:monitor:hardis:org",
7513
+ "all:monitor:org:hardis"
7504
7514
  ]
7505
7515
  },
7506
- "hardis:org:diagnose:unusedlicenses": {
7516
+ "hardis:org:monitor:backup": {
7507
7517
  "aliases": [],
7508
7518
  "args": {},
7509
- "description": "\n## Command Behavior\n\n**Detects and suggests the deletion of unused Permission Set License Assignments in a Salesforce org.**\n\nWhen a Permission Set (PS) linked to a Permission Set License (PSL) is assigned to a user, a Permission Set License Assignment (PSLA) is automatically created. However, when that PS is unassigned from the user, the PSLA is *not* automatically deleted. This can lead to organizations being charged for unused PSLAs, representing a hidden cost and technical debt.\n\nThis command identifies such useless PSLAs and provides options to delete them, helping to optimize license usage and reduce unnecessary expenses.\n\nKey functionalities:\n\n- **PSLA Detection:** Queries the Salesforce org to find all active PSLAs.\n- **Usage Verification:** Correlates PSLAs with actual Permission Set Assignments and Permission Set Group Assignments to determine if the underlying Permission Sets are still assigned to the user.\n- **Special Case Handling:** Accounts for specific scenarios where profiles might implicitly assign PSLAs (e.g., `Salesforce API Only` profile assigning `SalesforceAPIIntegrationPsl`) and allows for always excluding certain PSLAs from the unused check.\n- **Reporting:** Generates a CSV report of all identified unused PSLAs, including the user and the associated Permission Set License.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of unused PSLAs.\n- **Interactive Deletion:** In non-CI environments, it offers an interactive prompt to bulk delete the identified unused PSLAs.\n\nMany thanks to [Vincent Finet](https://www.linkedin.com/in/vincentfinet/) for the inspiration during his great speaker session at [French Touch Dreamin '23](https://frenchtouchdreamin.com/), and his kind agreement for reusing such inspiration in this command 😊\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-unused-licenses/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves extensive querying of Salesforce objects and data correlation:\n\n- **SOQL Queries (Bulk API):** It uses `bulkQuery` and `bulkQueryChunksIn` to efficiently retrieve large volumes of data from `PermissionSetLicenseAssign`, `PermissionSetLicense`, `PermissionSet`, `PermissionSetGroupComponent`, and `PermissionSetAssignment` objects.\n- **Data Correlation:** It meticulously correlates data across these objects to determine if a `PermissionSetLicenseAssign` record has a corresponding active assignment to a Permission Set or Permission Set Group for the same user.\n- **Filtering Logic:** It applies complex filtering logic to exclude PSLAs that are genuinely in use or are part of predefined exceptions (e.g., `alwaysExcludeForActiveUsersPermissionSetLicenses`).\n- **Bulk Deletion:** If the user opts to delete unused PSLAs, it uses `bulkUpdate` with the `delete` operation to efficiently remove multiple records.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of unused PSLAs.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Interaction:** Uses `prompts` for interactive confirmation before performing deletion operations.\n</details>\n",
7519
+ "description": "Retrieve sfdx sources in the context of a monitoring backup\n\nThe command exists in 2 modes: filtered(default & recommended) and full.\n\n## Filtered mode (default, better performances)\n\nAutomatically skips metadatas from installed packages with namespace. \n\nYou can remove more metadata types from backup, especially in case you have too many metadatas and that provokes a crash, using:\n\n- Manual update of `manifest/package-skip-items.xml` config file (then commit & push in the same branch)\n\n - Works with full wildcard (`<members>*</members>`) , named metadata (`<members>Account.Name</members>`) or partial wildcards names (`<members>pi__*</members>` , `<members>*__dlm</members>` , or `<members>prefix*suffix</members>`)\n\n- Environment variable MONITORING_BACKUP_SKIP_METADATA_TYPES (example: `MONITORING_BACKUP_SKIP_METADATA_TYPES=CustomLabel,StaticResource,Translation`): that will be applied to all monitoring branches.\n\n## Full mode\n\nActivate it with **--full** parameter, or variable MONITORING_BACKUP_MODE_FULL=true\n\nIgnores filters (namespaces items & manifest/package-skip-items.xml) to retrieve ALL metadatas, including those you might not care about (reports, translations...)\n\nAs we can retrieve only 10000 files by call, the list of all metadatas will be chunked to make multiple calls (and take more time than filtered mode)\n\n- if you use `--full-apply-filters` , manifest/package-skip-items.xml and MONITORING_BACKUP_SKIP_METADATA_TYPES filters will be applied anyway\n- if you use `--exclude-namespaces` , namespaced items will be ignored\n\n_With those both options, it's like if you are not using --full, but with chunked metadata download_\n\n## In CI/CD\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-metadata-backup/) and can output Grafana, Slack and MsTeams Notifications.\n\n## Troubleshooting\n\nIf you have unknown errors (it happens !), you can investigate using the full command with smaller chunks.\n\nExample: `sf hardis:org:monitor:backup --full --exclude-namespaces --full-apply-filters --max-by-chunk 500`\n\nIt will allow you the identify the responsible metadata and ignore it using package-skip-items.xml or MONITORING_BACKUP_SKIP_METADATA_TYPES env variable.\n\n## Documentation\n\n[Doc generation (including visual flows)](https://sfdx-hardis.cloudity.com/hardis/doc/project2markdown/) is triggered at the end of the command.\n\nIf you want to also upload HTML Documentation on your Salesforce Org as static resource, use variable **SFDX_HARDIS_DOC_DEPLOY_TO_ORG=\"true\"**\n\nIf you want to also upload HTML Documentation on Cloudflare, use variable **SFDX_HARDIS_DOC_DEPLOY_TO_CLOUDFLARE=\"true\"**\n\n- If you want to generate the documentation in multiple languages, define variable SFDX_DOC_LANGUAGES (ex: SFDX_DOC_LANGUAGES=en,fr,de)\n- You can define one Cloudflare site by language, for example with the following variables:\n - CLOUDFLARE_PROJECT_NAME_EN=cloudity-demo-english\n - CLOUDFLARE_PROJECT_NAME_FR=cloudity-demo-french\n - CLOUDFLARE_PROJECT_NAME_DE=cloudity-demo-german\n\nIf Flow history doc always display a single state, you probably need to update your workflow configuration:\n\n- on Gitlab: Env variable [`GIT_FETCH_EXTRA_FLAGS: --depth 10000`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/.gitlab-ci.yml#L11)\n- on GitHub: [`fetch-depth: 0`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/.github/workflows/org-monitoring.yml#L58)\n- on Azure: [`fetchDepth: \"0\"`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/azure-pipelines.yml#L39)\n- on Bitbucket: [`step: clone: depth: full`](https://github.com/hardisgroupcom/sfdx-hardis/blob/main/defaults/monitoring/bitbucket-pipelines.yml#L18)\n",
7510
7520
  "examples": [
7511
- "$ sf hardis:org:diagnose:unusedlicenses",
7512
- "$ sf hardis:org:diagnose:unusedlicenses --fix"
7521
+ "$ sf hardis:org:monitor:backup",
7522
+ "$ sf hardis:org:monitor:backup --full",
7523
+ "$ sf hardis:org:monitor:backup --full --exclude-namespaces",
7524
+ "$ sf hardis:org:monitor:backup --full --exclude-namespaces --full-apply-filters"
7513
7525
  ],
7514
7526
  "flags": {
7515
7527
  "json": {
@@ -7527,6 +7539,49 @@
7527
7539
  "multiple": false,
7528
7540
  "type": "option"
7529
7541
  },
7542
+ "full": {
7543
+ "description": "Dot not take in account filtering using package-skip-items.xml and MONITORING_BACKUP_SKIP_METADATA_TYPES. Efficient but much much slower !",
7544
+ "name": "full",
7545
+ "allowNo": false,
7546
+ "type": "boolean"
7547
+ },
7548
+ "max-by-chunk": {
7549
+ "char": "m",
7550
+ "description": "If mode --full is activated, maximum number of metadatas in a package.xml chunk",
7551
+ "name": "max-by-chunk",
7552
+ "default": 3000,
7553
+ "hasDynamicHelp": false,
7554
+ "multiple": false,
7555
+ "type": "option"
7556
+ },
7557
+ "exclude-namespaces": {
7558
+ "char": "e",
7559
+ "description": "If mode --full is activated, exclude namespaced metadatas",
7560
+ "name": "exclude-namespaces",
7561
+ "allowNo": false,
7562
+ "type": "boolean"
7563
+ },
7564
+ "full-apply-filters": {
7565
+ "char": "z",
7566
+ "description": "If mode --full is activated, apply filters of manifest/package-skip-items.xml and MONITORING_BACKUP_SKIP_METADATA_TYPES anyway",
7567
+ "name": "full-apply-filters",
7568
+ "allowNo": false,
7569
+ "type": "boolean"
7570
+ },
7571
+ "start-chunk": {
7572
+ "description": "Use this parameter to troubleshoot a specific chunk. It will be used as the first chunk to retrieve",
7573
+ "name": "start-chunk",
7574
+ "default": 1,
7575
+ "hasDynamicHelp": false,
7576
+ "multiple": false,
7577
+ "type": "option"
7578
+ },
7579
+ "skip-doc": {
7580
+ "description": "Skip the generation of project documentation at the end of the command",
7581
+ "name": "skip-doc",
7582
+ "allowNo": false,
7583
+ "type": "boolean"
7584
+ },
7530
7585
  "outputfile": {
7531
7586
  "char": "f",
7532
7587
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -7573,79 +7628,58 @@
7573
7628
  },
7574
7629
  "hasDynamicHelp": true,
7575
7630
  "hiddenAliases": [],
7576
- "id": "hardis:org:diagnose:unusedlicenses",
7631
+ "id": "hardis:org:monitor:backup",
7577
7632
  "pluginAlias": "sfdx-hardis",
7578
7633
  "pluginName": "sfdx-hardis",
7579
7634
  "pluginType": "core",
7580
7635
  "strict": true,
7581
7636
  "enableJsonFlag": true,
7582
- "title": "Detect unused Permission Set Licenses (beta)",
7583
- "requiresProject": false,
7584
- "additionalPermissionSetsToAlwaysGet": [
7585
- "Sales_User"
7586
- ],
7587
- "permSetsPermSetLicenses": [
7588
- {
7589
- "permSet": "Sales_User",
7590
- "permSetLicense": "SalesUserPsl"
7591
- }
7592
- ],
7593
- "profilesPermissionSetLicenses": [
7594
- {
7595
- "profile": "Salesforce API Only",
7596
- "permSetLicense": "SalesforceAPIIntegrationPsl"
7597
- }
7598
- ],
7599
- "alwaysExcludeForActiveUsersPermissionSetLicenses": [
7600
- "IdentityConnect"
7601
- ],
7637
+ "title": "Backup DX sources",
7638
+ "requiresProject": true,
7639
+ "triggerNotification": true,
7602
7640
  "isESM": true,
7603
7641
  "relativePath": [
7604
7642
  "lib",
7605
7643
  "commands",
7606
7644
  "hardis",
7607
7645
  "org",
7608
- "diagnose",
7609
- "unusedlicenses.js"
7646
+ "monitor",
7647
+ "backup.js"
7610
7648
  ],
7611
7649
  "aliasPermutations": [],
7612
7650
  "permutations": [
7613
- "hardis:org:diagnose:unusedlicenses",
7614
- "org:hardis:diagnose:unusedlicenses",
7615
- "org:diagnose:hardis:unusedlicenses",
7616
- "org:diagnose:unusedlicenses:hardis",
7617
- "hardis:diagnose:org:unusedlicenses",
7618
- "diagnose:hardis:org:unusedlicenses",
7619
- "diagnose:org:hardis:unusedlicenses",
7620
- "diagnose:org:unusedlicenses:hardis",
7621
- "hardis:diagnose:unusedlicenses:org",
7622
- "diagnose:hardis:unusedlicenses:org",
7623
- "diagnose:unusedlicenses:hardis:org",
7624
- "diagnose:unusedlicenses:org:hardis",
7625
- "hardis:org:unusedlicenses:diagnose",
7626
- "org:hardis:unusedlicenses:diagnose",
7627
- "org:unusedlicenses:hardis:diagnose",
7628
- "org:unusedlicenses:diagnose:hardis",
7629
- "hardis:unusedlicenses:org:diagnose",
7630
- "unusedlicenses:hardis:org:diagnose",
7631
- "unusedlicenses:org:hardis:diagnose",
7632
- "unusedlicenses:org:diagnose:hardis",
7633
- "hardis:unusedlicenses:diagnose:org",
7634
- "unusedlicenses:hardis:diagnose:org",
7635
- "unusedlicenses:diagnose:hardis:org",
7636
- "unusedlicenses:diagnose:org:hardis"
7651
+ "hardis:org:monitor:backup",
7652
+ "org:hardis:monitor:backup",
7653
+ "org:monitor:hardis:backup",
7654
+ "org:monitor:backup:hardis",
7655
+ "hardis:monitor:org:backup",
7656
+ "monitor:hardis:org:backup",
7657
+ "monitor:org:hardis:backup",
7658
+ "monitor:org:backup:hardis",
7659
+ "hardis:monitor:backup:org",
7660
+ "monitor:hardis:backup:org",
7661
+ "monitor:backup:hardis:org",
7662
+ "monitor:backup:org:hardis",
7663
+ "hardis:org:backup:monitor",
7664
+ "org:hardis:backup:monitor",
7665
+ "org:backup:hardis:monitor",
7666
+ "org:backup:monitor:hardis",
7667
+ "hardis:backup:org:monitor",
7668
+ "backup:hardis:org:monitor",
7669
+ "backup:org:hardis:monitor",
7670
+ "backup:org:monitor:hardis",
7671
+ "hardis:backup:monitor:org",
7672
+ "backup:hardis:monitor:org",
7673
+ "backup:monitor:hardis:org",
7674
+ "backup:monitor:org:hardis"
7637
7675
  ]
7638
7676
  },
7639
- "hardis:org:diagnose:unusedusers": {
7677
+ "hardis:org:monitor:limits": {
7640
7678
  "aliases": [],
7641
7679
  "args": {},
7642
- "description": "\n## Command Behavior\n\n**Detects and reports on inactive or unused Salesforce user accounts, helping to optimize license usage and enhance security.**\n\nEfficient user management is vital in Salesforce to ensure resources are optimized and costs are controlled. However, inactive or unused user accounts can often go unnoticed, leading to wasted licenses and potential security risks. This tool addresses this challenge by enabling administrators to identify users who haven't logged in within a specified period.\n\nBy analyzing user login activity and last login timestamps, this feature highlights inactive user accounts, allowing administrators to take appropriate action. Whether it's deactivating dormant accounts, freeing up licenses, or ensuring compliance with security policies, this functionality empowers administrators to maintain a lean and secure Salesforce environment.\n\nKey functionalities:\n\n- **Inactivity Detection:** Identifies users who have not logged in for a specified number of days (`--days` flag, default 180 days in CI, 365 days otherwise).\n- **License Type Filtering:** Allows filtering users by license type using `--licensetypes` (e.g., `all-crm`, `all-paying`) or specific license identifiers using `--licenseidentifiers`.\n - `all-crm`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT` licenses.\n - `all-paying`: Includes `SFDC`, `AUL`, `AUL1`, `AULL_IGHT`, `PID_Customer_Community`, `PID_Customer_Community_Login`, `PID_Partner_Community`, `PID_Partner_Community_Login` licenses.\n - Note: You can see the full list of available license identifiers in [Salesforce Documentation](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/sfdx_cli_reference/sforce_api_objects_userlicense.htm).\n- **Active User Retrieval:** The `--returnactiveusers` flag inverts the command, allowing you to retrieve active users who *have* logged in during the specified period.\n- **CSV Report Generation:** Generates a CSV file containing details of all identified users (inactive or active), including their last login date, profile, and license information.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of inactive or active users.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-inactive-users/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query (Bulk API):** It uses `bulkQuery` to efficiently retrieve user records from the Salesforce `User` object. The SOQL query dynamically constructs its WHERE clause based on the `--days`, `--licensetypes`, `--licenseidentifiers`, and `--returnactiveusers` flags.\n- **Interactive Prompts:** Uses `prompts` to interactively ask the user for the number of inactive days and license types if not provided via flags.\n- **License Mapping:** Internally maps common license type aliases (e.g., `all-crm`) to their corresponding Salesforce `LicenseDefinitionKey` values.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of users.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and metrics for monitoring dashboards.\n- **User Feedback:** Provides a summary of the findings in the console, indicating the number of inactive or active users found.\n</details>",
7680
+ "description": "\n## Command Behavior\n\n**Checks the current usage of various Salesforce org limits and sends notifications if thresholds are exceeded.**\n\nThis command is a critical component of proactive Salesforce org management, helping administrators and developers monitor resource consumption and prevent hitting critical limits that could impact performance or functionality. It provides early warnings when limits are approaching their capacity.\n\nKey functionalities:\n\n- **Limit Retrieval:** Fetches a comprehensive list of all Salesforce org limits using the Salesforce CLI.\n- **Usage Calculation:** Calculates the percentage of each limit that is currently being used.\n- **Threshold-Based Alerting:** Assigns a severity (success, warning, or error) to each limit based on configurable thresholds:\n - **Warning:** If usage exceeds 50% (configurable via `LIMIT_THRESHOLD_WARNING` environment variable).\n - **Error:** If usage exceeds 75% (configurable via `LIMIT_THRESHOLD_ERROR` environment variable).\n- **CSV Report Generation:** Generates a CSV file containing all org limits, their current usage, maximum allowed, and calculated percentage used, along with the assigned severity.\n- **Notifications:** Sends notifications to configured channels (Grafana, Slack, MS Teams) with a summary of limits that have exceeded the warning or error thresholds.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-org-limits/) and can output Grafana, Slack and MsTeams Notifications.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Salesforce CLI Integration:** It executes the `sf org limits list` command to retrieve the current org limits. It parses the JSON output of this command.\n- **Data Processing:** It iterates through the retrieved limits, calculates the `used` and `percentUsed` values, and assigns a `severity` (success, warning, error) based on the configured thresholds.\n- **Environment Variable Configuration:** Reads `LIMIT_THRESHOLD_WARNING` and `LIMIT_THRESHOLD_ERROR` environment variables to set the warning and error thresholds for limit usage.\n- **Report Generation:** It uses `generateCsvFile` to create the CSV report of org limits.\n- **Notification Integration:** It integrates with the `NotifProvider` to send notifications, including attachments of the generated CSV report and detailed metrics for each limit, which can be consumed by monitoring dashboards like Grafana.\n- **Exit Code Management:** Sets the process exit code to 1 if any limit is in an 'error' state, indicating a critical issue.\n</details>\n",
7643
7681
  "examples": [
7644
- "$ sf hardis:org:diagnose:unusedusers",
7645
- "$ sf hardis:org:diagnose:unusedusers --days 365",
7646
- "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm",
7647
- "$ sf hardis:org:diagnose:unusedusers --days 60 --licenseidentifiers SFDC,AUL,AUL1",
7648
- "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm --returnactiveusers"
7682
+ "$ sf hardis:org:monitor:limits"
7649
7683
  ],
7650
7684
  "flags": {
7651
7685
  "json": {
@@ -7671,41 +7705,6 @@
7671
7705
  "multiple": false,
7672
7706
  "type": "option"
7673
7707
  },
7674
- "days": {
7675
- "char": "t",
7676
- "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7677
- "name": "days",
7678
- "hasDynamicHelp": false,
7679
- "multiple": false,
7680
- "type": "option"
7681
- },
7682
- "licensetypes": {
7683
- "char": "l",
7684
- "description": "Type of licenses to check. If set, do not use licenseidentifiers option. In CI, default is all-crm",
7685
- "name": "licensetypes",
7686
- "hasDynamicHelp": false,
7687
- "multiple": false,
7688
- "options": [
7689
- "all",
7690
- "all-crm",
7691
- "all-paying"
7692
- ],
7693
- "type": "option"
7694
- },
7695
- "licenseidentifiers": {
7696
- "char": "i",
7697
- "description": "Comma-separated list of license identifiers, in case licensetypes is not used.. Identifiers available at https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_userlicense.htm",
7698
- "name": "licenseidentifiers",
7699
- "hasDynamicHelp": false,
7700
- "multiple": false,
7701
- "type": "option"
7702
- },
7703
- "returnactiveusers": {
7704
- "description": "Inverts the command by returning the active users",
7705
- "name": "returnactiveusers",
7706
- "allowNo": false,
7707
- "type": "boolean"
7708
- },
7709
7708
  "debug": {
7710
7709
  "char": "d",
7711
7710
  "description": "Activate debug mode (more logs)",
@@ -7744,49 +7743,50 @@
7744
7743
  },
7745
7744
  "hasDynamicHelp": true,
7746
7745
  "hiddenAliases": [],
7747
- "id": "hardis:org:diagnose:unusedusers",
7746
+ "id": "hardis:org:monitor:limits",
7748
7747
  "pluginAlias": "sfdx-hardis",
7749
7748
  "pluginName": "sfdx-hardis",
7750
7749
  "pluginType": "core",
7751
7750
  "strict": true,
7752
7751
  "enableJsonFlag": true,
7753
- "title": "Detect unused Users in Salesforce",
7754
- "requiresProject": false,
7752
+ "title": "Check org limits",
7753
+ "requiresProject": true,
7754
+ "triggerNotification": true,
7755
7755
  "isESM": true,
7756
7756
  "relativePath": [
7757
7757
  "lib",
7758
7758
  "commands",
7759
7759
  "hardis",
7760
7760
  "org",
7761
- "diagnose",
7762
- "unusedusers.js"
7761
+ "monitor",
7762
+ "limits.js"
7763
7763
  ],
7764
7764
  "aliasPermutations": [],
7765
7765
  "permutations": [
7766
- "hardis:org:diagnose:unusedusers",
7767
- "org:hardis:diagnose:unusedusers",
7768
- "org:diagnose:hardis:unusedusers",
7769
- "org:diagnose:unusedusers:hardis",
7770
- "hardis:diagnose:org:unusedusers",
7771
- "diagnose:hardis:org:unusedusers",
7772
- "diagnose:org:hardis:unusedusers",
7773
- "diagnose:org:unusedusers:hardis",
7774
- "hardis:diagnose:unusedusers:org",
7775
- "diagnose:hardis:unusedusers:org",
7776
- "diagnose:unusedusers:hardis:org",
7777
- "diagnose:unusedusers:org:hardis",
7778
- "hardis:org:unusedusers:diagnose",
7779
- "org:hardis:unusedusers:diagnose",
7780
- "org:unusedusers:hardis:diagnose",
7781
- "org:unusedusers:diagnose:hardis",
7782
- "hardis:unusedusers:org:diagnose",
7783
- "unusedusers:hardis:org:diagnose",
7784
- "unusedusers:org:hardis:diagnose",
7785
- "unusedusers:org:diagnose:hardis",
7786
- "hardis:unusedusers:diagnose:org",
7787
- "unusedusers:hardis:diagnose:org",
7788
- "unusedusers:diagnose:hardis:org",
7789
- "unusedusers:diagnose:org:hardis"
7766
+ "hardis:org:monitor:limits",
7767
+ "org:hardis:monitor:limits",
7768
+ "org:monitor:hardis:limits",
7769
+ "org:monitor:limits:hardis",
7770
+ "hardis:monitor:org:limits",
7771
+ "monitor:hardis:org:limits",
7772
+ "monitor:org:hardis:limits",
7773
+ "monitor:org:limits:hardis",
7774
+ "hardis:monitor:limits:org",
7775
+ "monitor:hardis:limits:org",
7776
+ "monitor:limits:hardis:org",
7777
+ "monitor:limits:org:hardis",
7778
+ "hardis:org:limits:monitor",
7779
+ "org:hardis:limits:monitor",
7780
+ "org:limits:hardis:monitor",
7781
+ "org:limits:monitor:hardis",
7782
+ "hardis:limits:org:monitor",
7783
+ "limits:hardis:org:monitor",
7784
+ "limits:org:hardis:monitor",
7785
+ "limits:org:monitor:hardis",
7786
+ "hardis:limits:monitor:org",
7787
+ "limits:hardis:monitor:org",
7788
+ "limits:monitor:hardis:org",
7789
+ "limits:monitor:org:hardis"
7790
7790
  ]
7791
7791
  },
7792
7792
  "hardis:org:purge:apexlog": {
@@ -15370,5 +15370,5 @@
15370
15370
  ]
15371
15371
  }
15372
15372
  },
15373
- "version": "6.9.1-alpha202510270024.0"
15373
+ "version": "6.9.1-alpha202510270034.0"
15374
15374
  }