sfdx-hardis 6.9.1-alpha202510270024.0 → 6.9.1-alpha202510282151.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +1 -0
  2. package/lib/commands/hardis/doc/mkdocs-to-cf.js +38 -39
  3. package/lib/commands/hardis/doc/mkdocs-to-cf.js.map +1 -1
  4. package/lib/common/actionsProvider/actionsProvider.d.ts +5 -1
  5. package/lib/common/actionsProvider/actionsProvider.js +56 -2
  6. package/lib/common/actionsProvider/actionsProvider.js.map +1 -1
  7. package/lib/common/actionsProvider/apexAction.d.ts +1 -1
  8. package/lib/common/actionsProvider/apexAction.js +2 -2
  9. package/lib/common/actionsProvider/apexAction.js.map +1 -1
  10. package/lib/common/actionsProvider/commandAction.d.ts +1 -1
  11. package/lib/common/actionsProvider/commandAction.js +2 -1
  12. package/lib/common/actionsProvider/commandAction.js.map +1 -1
  13. package/lib/common/actionsProvider/dataAction.d.ts +1 -1
  14. package/lib/common/actionsProvider/dataAction.js +9 -2
  15. package/lib/common/actionsProvider/dataAction.js.map +1 -1
  16. package/lib/common/actionsProvider/manualAction.d.ts +1 -1
  17. package/lib/common/actionsProvider/manualAction.js +2 -2
  18. package/lib/common/actionsProvider/manualAction.js.map +1 -1
  19. package/lib/common/actionsProvider/publishCommunityAction.d.ts +1 -1
  20. package/lib/common/actionsProvider/publishCommunityAction.js +2 -2
  21. package/lib/common/actionsProvider/publishCommunityAction.js.map +1 -1
  22. package/lib/common/utils/authUtils.d.ts +15 -2
  23. package/lib/common/utils/authUtils.js +48 -29
  24. package/lib/common/utils/authUtils.js.map +1 -1
  25. package/lib/common/utils/orgUtils.d.ts +1 -0
  26. package/lib/common/utils/orgUtils.js +12 -0
  27. package/lib/common/utils/orgUtils.js.map +1 -1
  28. package/lib/common/utils/prePostCommandUtils.js +6 -4
  29. package/lib/common/utils/prePostCommandUtils.js.map +1 -1
  30. package/oclif.manifest.json +1070 -1070
  31. package/package.json +1 -1
@@ -509,7 +509,7 @@
509
509
  "hardis:doc:mkdocs-to-cf": {
510
510
  "aliases": [],
511
511
  "args": {},
512
- "description": "## Command Behavior**Generates MkDocs HTML pages and uploads them to Cloudflare as a static site, secured with Cloudflare Access.**This command automates the deployment of your project's documentation (built with MkDocs) to Cloudflare Pages, making it accessible and secure. It handles the entire process from HTML generation to Cloudflare configuration.Key operations performed:- **MkDocs HTML Generation:** Builds the MkDocs project into static HTML pages. It can use a locally installed `mkdocs-material` or a `mkdocs` Docker image.- **Cloudflare Pages Project Creation/Update:** Creates a new Cloudflare Pages project if one doesn't exist for your documentation, or updates an existing one.- **Cloudflare Access Policy Assignment:** Assigns a policy to restrict access to the deployed application, ensuring only authorized users can view your documentation.- **Cloudflare Access Application Setup:** Configures a Cloudflare Access application for the deployed site, integrating it with your Zero Trust policies.- **HTML Page Upload:** Deploys the generated HTML pages to Cloudflare Pages.- **Browser Opening (Non-CI):** Opens the newly deployed website in your default browser if the command is not run in a CI/CD environment.**Prerequisite:** The documentation must have been previously generated using `sf hardis:doc:project2markdown --with-history`.**Customization:** You can override default styles by customizing your `mkdocs.yml` file.More information can be found in the [Documentation section](https://sfdx-hardis.cloudity.com/salesforce-project-documentation/).**Environment Variables for Cloudflare Configuration:**| Variable | Description | Default || :---------------------------------------- | :----------------------------------------------------------------------- | :------------------------------------: || `CLOUDFLARE_EMAIL` | Cloudflare account email | _Required_ || `CLOUDFLARE_API_TOKEN` | Cloudflare API token | _Required_ || `CLOUDFLARE_ACCOUNT_ID` | Cloudflare account ID | _Required_ || `CLOUDFLARE_PROJECT_NAME` | Project name, also used for the site URL | Built from Git branch name || `CLOUDFLARE_DEFAULT_LOGIN_METHOD_TYPE` | Cloudflare default login method type | `onetimepin` || `CLOUDFLARE_DEFAULT_ACCESS_EMAIL_DOMAIN` | Cloudflare default access email domain | `@cloudity.com` || `CLOUDFLARE_EXTRA_ACCESS_POLICY_ID_LIST` | Comma-separated list of additional policy IDs to assign to the application | _Optional_ |<details markdown=\"1\">\n<summary>Technical explanations</summary>The command orchestrates interactions with MkDocs, Cloudflare APIs, and Git:- **MkDocs Integration:** It calls `generateMkDocsHTML()` to execute the MkDocs build process, which converts Markdown files into static HTML. It checks for the presence of `mkdocs.yml` to ensure it's a valid MkDocs project.- **Cloudflare API Interaction:** It uses the `cloudflare` npm package to interact with the Cloudflare API. This involves: - **Authentication:** Initializes the Cloudflare client using `CLOUDFLARE_EMAIL`, `CLOUDFLARE_API_TOKEN`, and `CLOUDFLARE_ACCOUNT_ID` environment variables. - **Pages Project Management:** Calls `client.pages.projects.get()` to check for an existing project and `client.pages.projects.create()` to create a new one if needed. - **Access Policy Management:** Lists existing access policies (`client.zeroTrust.access.policies.list()`) and creates a new one (`client.zeroTrust.access.policies.create()`) if the required policy doesn't exist. It configures the policy with email domain restrictions and a default login method. - **Access Application Management:** Lists existing access applications (`client.zeroTrust.access.applications.list()`) and creates a new one (`client.zeroTrust.access.applications.create()`) for the deployed site. It then updates the application to associate it with the created access policy.- **Git Integration:** Retrieves the current Git branch name using `getCurrentGitBranch()` to construct the Cloudflare project name and branch for deployment.- **Wrangler CLI:** Uses the `wrangler` CLI (Cloudflare's developer tool) to deploy the generated HTML pages to Cloudflare Pages via `wrangler pages deploy`.- **Environment Variable Management:** Reads various environment variables to configure Cloudflare settings and project names.- **Error Handling:** Includes checks for missing `mkdocs.yml` and Cloudflare environment variables, throwing `SfError` when necessary.</details>\n",
512
+ "description": "## Command Behavior\n\n**Generates MkDocs HTML pages and uploads them to Cloudflare as a static site, secured with Cloudflare Access.**\n\nThis command automates the deployment of your project's documentation (built with MkDocs) to Cloudflare Pages, making it accessible and secure. It handles the entire process from HTML generation to Cloudflare configuration.\n\nKey operations performed:\n\n- **MkDocs HTML Generation:** Builds the MkDocs project into static HTML pages. It can use a locally installed `mkdocs-material` or a `mkdocs` Docker image.\n- **Cloudflare Pages Project Creation/Update:** Creates a new Cloudflare Pages project if one doesn't exist for your documentation, or updates an existing one.\n- **Cloudflare Access Policy Assignment:** Assigns a policy to restrict access to the deployed application, ensuring only authorized users can view your documentation.\n- **Cloudflare Access Application Setup:** Configures a Cloudflare Access application for the deployed site, integrating it with your Zero Trust policies.\n- **HTML Page Upload:** Deploys the generated HTML pages to Cloudflare Pages.\n- **Browser Opening (Non-CI):** Opens the newly deployed website in your default browser if the command is not run in a CI/CD environment.\n\n**Prerequisite:** The documentation must have been previously generated using `sf hardis:doc:project2markdown --with-history`.\n\n**Customization:** You can override default styles by customizing your `mkdocs.yml` file.\n\nMore information can be found in the [Documentation section](https://sfdx-hardis.cloudity.com/salesforce-project-documentation/).\n\n**Environment Variables for Cloudflare Configuration:**\n\n| Variable | Description | Default || :---------------------------------------- | :----------------------------------------------------------------------- | :------------------------------------: || `CLOUDFLARE_EMAIL` | Cloudflare account email | _Required_ || `CLOUDFLARE_API_TOKEN` | Cloudflare API token | _Required_ || `CLOUDFLARE_ACCOUNT_ID` | Cloudflare account ID | _Required_ || `CLOUDFLARE_PROJECT_NAME` | Project name, also used for the site URL | Built from Git branch name || `CLOUDFLARE_DEFAULT_LOGIN_METHOD_TYPE` | Cloudflare default login method type | `onetimepin` || `CLOUDFLARE_DEFAULT_ACCESS_EMAIL_DOMAIN` | Cloudflare default access email domain | `@cloudity.com` || `CLOUDFLARE_EXTRA_ACCESS_POLICY_ID_LIST` | Comma-separated list of additional policy IDs to assign to the application | _Optional_ |\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command orchestrates interactions with MkDocs, Cloudflare APIs, and Git:\n\n- **MkDocs Integration:** It calls `generateMkDocsHTML()` to execute the MkDocs build process, which converts Markdown files into static HTML. It checks for the presence of `mkdocs.yml` to ensure it's a valid MkDocs project.\n- **Cloudflare API Interaction:** It uses the `cloudflare` npm package to interact with the Cloudflare API. This involves:\n - **Authentication:** Initializes the Cloudflare client using `CLOUDFLARE_EMAIL`, `CLOUDFLARE_API_TOKEN`, and `CLOUDFLARE_ACCOUNT_ID` environment variables.\n - **Pages Project Management:** Calls `client.pages.projects.get()` to check for an existing project and `client.pages.projects.create()` to create a new one if needed.\n - **Access Policy Management:** Lists existing access policies (`client.zeroTrust.access.policies.list()`) and creates a new one (`client.zeroTrust.access.policies.create()`) if the required policy doesn't exist. It configures the policy with email domain restrictions and a default login method.\n - **Access Application Management:** Lists existing access applications (`client.zeroTrust.access.applications.list()`) and creates a new one (`client.zeroTrust.access.applications.create()`) for the deployed site. It then updates the application to associate it with the created access policy.\n- **Git Integration:** Retrieves the current Git branch name using `getCurrentGitBranch()` to construct the Cloudflare project name and branch for deployment.\n- **Wrangler CLI:** Uses the `wrangler` CLI (Cloudflare's developer tool) to deploy the generated HTML pages to Cloudflare Pages via `wrangler pages deploy`.\n- **Environment Variable Management:** Reads various environment variables to configure Cloudflare settings and project names.\n- **Error Handling:** Includes checks for missing `mkdocs.yml` and Cloudflare environment variables, throwing `SfError` when necessary.\n</details>\n",
513
513
  "examples": [
514
514
  "$ sf hardis:doc:mkdocs-to-cf"
515
515
  ],
@@ -5923,14 +5923,15 @@
5923
5923
  "listviewmine:fix:org:hardis"
5924
5924
  ]
5925
5925
  },
5926
- "hardis:org:generate:packagexmlfull": {
5926
+ "hardis:org:diagnose:audittrail": {
5927
5927
  "aliases": [],
5928
5928
  "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",
5929
+ "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",
5930
5930
  "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"
5931
+ "$ sf hardis:org:diagnose:audittrail",
5932
+ "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com",
5933
+ "$ sf hardis:org:diagnose:audittrail --excludeusers baptiste@titi.com,bertrand@titi.com",
5934
+ "$ sf hardis:org:diagnose:audittrail --lastndays 5"
5934
5935
  ],
5935
5936
  "flags": {
5936
5937
  "json": {
@@ -5948,8 +5949,25 @@
5948
5949
  "multiple": false,
5949
5950
  "type": "option"
5950
5951
  },
5952
+ "excludeusers": {
5953
+ "char": "e",
5954
+ "description": "Comma-separated list of usernames to exclude",
5955
+ "name": "excludeusers",
5956
+ "hasDynamicHelp": false,
5957
+ "multiple": false,
5958
+ "type": "option"
5959
+ },
5960
+ "lastndays": {
5961
+ "char": "t",
5962
+ "description": "Number of days to extract from today (included)",
5963
+ "name": "lastndays",
5964
+ "hasDynamicHelp": false,
5965
+ "multiple": false,
5966
+ "type": "option"
5967
+ },
5951
5968
  "outputfile": {
5952
- "description": "Output package.xml file",
5969
+ "char": "f",
5970
+ "description": "Force the path and name of output report file. Must end with .csv",
5953
5971
  "name": "outputfile",
5954
5972
  "hasDynamicHelp": false,
5955
5973
  "multiple": false,
@@ -5962,13 +5980,6 @@
5962
5980
  "allowNo": false,
5963
5981
  "type": "boolean"
5964
5982
  },
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
5983
  "websocket": {
5973
5984
  "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
5974
5985
  "name": "websocket",
@@ -6000,13 +6011,13 @@
6000
6011
  },
6001
6012
  "hasDynamicHelp": true,
6002
6013
  "hiddenAliases": [],
6003
- "id": "hardis:org:generate:packagexmlfull",
6014
+ "id": "hardis:org:diagnose:audittrail",
6004
6015
  "pluginAlias": "sfdx-hardis",
6005
6016
  "pluginName": "sfdx-hardis",
6006
6017
  "pluginType": "core",
6007
6018
  "strict": true,
6008
6019
  "enableJsonFlag": true,
6009
- "title": "Generate Full Org package.xml",
6020
+ "title": "Diagnose content of Setup Audit Trail",
6010
6021
  "requiresProject": false,
6011
6022
  "isESM": true,
6012
6023
  "relativePath": [
@@ -6014,43 +6025,43 @@
6014
6025
  "commands",
6015
6026
  "hardis",
6016
6027
  "org",
6017
- "generate",
6018
- "packagexmlfull.js"
6028
+ "diagnose",
6029
+ "audittrail.js"
6019
6030
  ],
6020
6031
  "aliasPermutations": [],
6021
6032
  "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"
6033
+ "hardis:org:diagnose:audittrail",
6034
+ "org:hardis:diagnose:audittrail",
6035
+ "org:diagnose:hardis:audittrail",
6036
+ "org:diagnose:audittrail:hardis",
6037
+ "hardis:diagnose:org:audittrail",
6038
+ "diagnose:hardis:org:audittrail",
6039
+ "diagnose:org:hardis:audittrail",
6040
+ "diagnose:org:audittrail:hardis",
6041
+ "hardis:diagnose:audittrail:org",
6042
+ "diagnose:hardis:audittrail:org",
6043
+ "diagnose:audittrail:hardis:org",
6044
+ "diagnose:audittrail:org:hardis",
6045
+ "hardis:org:audittrail:diagnose",
6046
+ "org:hardis:audittrail:diagnose",
6047
+ "org:audittrail:hardis:diagnose",
6048
+ "org:audittrail:diagnose:hardis",
6049
+ "hardis:audittrail:org:diagnose",
6050
+ "audittrail:hardis:org:diagnose",
6051
+ "audittrail:org:hardis:diagnose",
6052
+ "audittrail:org:diagnose:hardis",
6053
+ "hardis:audittrail:diagnose:org",
6054
+ "audittrail:hardis:diagnose:org",
6055
+ "audittrail:diagnose:hardis:org",
6056
+ "audittrail:diagnose:org:hardis"
6046
6057
  ]
6047
6058
  },
6048
- "hardis:org:monitor:all": {
6059
+ "hardis:org:diagnose:instanceupgrade": {
6049
6060
  "aliases": [],
6050
6061
  "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",
6062
+ "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",
6052
6063
  "examples": [
6053
- "$ sf hardis:org:monitor:all"
6064
+ "$ sf hardis:org:diagnose:instanceupgrade"
6054
6065
  ],
6055
6066
  "flags": {
6056
6067
  "json": {
@@ -6106,159 +6117,60 @@
6106
6117
  },
6107
6118
  "hasDynamicHelp": true,
6108
6119
  "hiddenAliases": [],
6109
- "id": "hardis:org:monitor:all",
6120
+ "id": "hardis:org:diagnose:instanceupgrade",
6110
6121
  "pluginAlias": "sfdx-hardis",
6111
6122
  "pluginName": "sfdx-hardis",
6112
6123
  "pluginType": "core",
6113
6124
  "strict": true,
6114
6125
  "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,
6126
+ "title": "Get Instance Upgrade date",
6127
+ "requiresProject": false,
6216
6128
  "isESM": true,
6217
6129
  "relativePath": [
6218
6130
  "lib",
6219
6131
  "commands",
6220
6132
  "hardis",
6221
6133
  "org",
6222
- "monitor",
6223
- "all.js"
6134
+ "diagnose",
6135
+ "instanceupgrade.js"
6224
6136
  ],
6225
6137
  "aliasPermutations": [],
6226
6138
  "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"
6139
+ "hardis:org:diagnose:instanceupgrade",
6140
+ "org:hardis:diagnose:instanceupgrade",
6141
+ "org:diagnose:hardis:instanceupgrade",
6142
+ "org:diagnose:instanceupgrade:hardis",
6143
+ "hardis:diagnose:org:instanceupgrade",
6144
+ "diagnose:hardis:org:instanceupgrade",
6145
+ "diagnose:org:hardis:instanceupgrade",
6146
+ "diagnose:org:instanceupgrade:hardis",
6147
+ "hardis:diagnose:instanceupgrade:org",
6148
+ "diagnose:hardis:instanceupgrade:org",
6149
+ "diagnose:instanceupgrade:hardis:org",
6150
+ "diagnose:instanceupgrade:org:hardis",
6151
+ "hardis:org:instanceupgrade:diagnose",
6152
+ "org:hardis:instanceupgrade:diagnose",
6153
+ "org:instanceupgrade:hardis:diagnose",
6154
+ "org:instanceupgrade:diagnose:hardis",
6155
+ "hardis:instanceupgrade:org:diagnose",
6156
+ "instanceupgrade:hardis:org:diagnose",
6157
+ "instanceupgrade:org:hardis:diagnose",
6158
+ "instanceupgrade:org:diagnose:hardis",
6159
+ "hardis:instanceupgrade:diagnose:org",
6160
+ "instanceupgrade:hardis:diagnose:org",
6161
+ "instanceupgrade:diagnose:hardis:org",
6162
+ "instanceupgrade:diagnose:org:hardis"
6251
6163
  ]
6252
6164
  },
6253
- "hardis:org:monitor:backup": {
6165
+ "hardis:org:diagnose:legacyapi": {
6254
6166
  "aliases": [],
6255
6167
  "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",
6168
+ "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",
6257
6169
  "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"
6170
+ "$ sf hardis:org:diagnose:legacyapi",
6171
+ "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com",
6172
+ "$ sf hardis:org:diagnose:legacyapi --outputfile 'c:/path/to/folder/legacyapi.csv'",
6173
+ "$ sf hardis:org:diagnose:legacyapi -u hardis@myclient.com --outputfile ./tmp/legacyapi.csv"
6262
6174
  ],
6263
6175
  "flags": {
6264
6176
  "json": {
@@ -6276,49 +6188,24 @@
6276
6188
  "multiple": false,
6277
6189
  "type": "option"
6278
6190
  },
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,
6191
+ "eventtype": {
6192
+ "char": "e",
6193
+ "description": "Type of EventLogFile event to analyze",
6194
+ "name": "eventtype",
6195
+ "default": "ApiTotalUsage",
6290
6196
  "hasDynamicHelp": false,
6291
6197
  "multiple": false,
6292
6198
  "type": "option"
6293
6199
  },
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,
6200
+ "limit": {
6201
+ "char": "l",
6202
+ "description": "Number of latest EventLogFile events to analyze",
6203
+ "name": "limit",
6204
+ "default": 999,
6312
6205
  "hasDynamicHelp": false,
6313
6206
  "multiple": false,
6314
6207
  "type": "option"
6315
6208
  },
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
6209
  "outputfile": {
6323
6210
  "char": "f",
6324
6211
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6365,58 +6252,57 @@
6365
6252
  },
6366
6253
  "hasDynamicHelp": true,
6367
6254
  "hiddenAliases": [],
6368
- "id": "hardis:org:monitor:backup",
6255
+ "id": "hardis:org:diagnose:legacyapi",
6369
6256
  "pluginAlias": "sfdx-hardis",
6370
6257
  "pluginName": "sfdx-hardis",
6371
6258
  "pluginType": "core",
6372
6259
  "strict": true,
6373
6260
  "enableJsonFlag": true,
6374
- "title": "Backup DX sources",
6375
- "requiresProject": true,
6376
- "triggerNotification": true,
6261
+ "title": "Check for legacy API use",
6262
+ "requiresProject": false,
6377
6263
  "isESM": true,
6378
6264
  "relativePath": [
6379
6265
  "lib",
6380
6266
  "commands",
6381
6267
  "hardis",
6382
6268
  "org",
6383
- "monitor",
6384
- "backup.js"
6269
+ "diagnose",
6270
+ "legacyapi.js"
6385
6271
  ],
6386
6272
  "aliasPermutations": [],
6387
6273
  "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"
6274
+ "hardis:org:diagnose:legacyapi",
6275
+ "org:hardis:diagnose:legacyapi",
6276
+ "org:diagnose:hardis:legacyapi",
6277
+ "org:diagnose:legacyapi:hardis",
6278
+ "hardis:diagnose:org:legacyapi",
6279
+ "diagnose:hardis:org:legacyapi",
6280
+ "diagnose:org:hardis:legacyapi",
6281
+ "diagnose:org:legacyapi:hardis",
6282
+ "hardis:diagnose:legacyapi:org",
6283
+ "diagnose:hardis:legacyapi:org",
6284
+ "diagnose:legacyapi:hardis:org",
6285
+ "diagnose:legacyapi:org:hardis",
6286
+ "hardis:org:legacyapi:diagnose",
6287
+ "org:hardis:legacyapi:diagnose",
6288
+ "org:legacyapi:hardis:diagnose",
6289
+ "org:legacyapi:diagnose:hardis",
6290
+ "hardis:legacyapi:org:diagnose",
6291
+ "legacyapi:hardis:org:diagnose",
6292
+ "legacyapi:org:hardis:diagnose",
6293
+ "legacyapi:org:diagnose:hardis",
6294
+ "hardis:legacyapi:diagnose:org",
6295
+ "legacyapi:hardis:diagnose:org",
6296
+ "legacyapi:diagnose:hardis:org",
6297
+ "legacyapi:diagnose:org:hardis"
6412
6298
  ]
6413
6299
  },
6414
- "hardis:org:monitor:limits": {
6300
+ "hardis:org:diagnose:licenses": {
6415
6301
  "aliases": [],
6416
6302
  "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",
6303
+ "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",
6418
6304
  "examples": [
6419
- "$ sf hardis:org:monitor:limits"
6305
+ "$ sf hardis:org:diagnose:licenses"
6420
6306
  ],
6421
6307
  "flags": {
6422
6308
  "json": {
@@ -6442,6 +6328,13 @@
6442
6328
  "multiple": false,
6443
6329
  "type": "option"
6444
6330
  },
6331
+ "usedonly": {
6332
+ "char": "u",
6333
+ "description": "Filter to have only used licenses",
6334
+ "name": "usedonly",
6335
+ "allowNo": false,
6336
+ "type": "boolean"
6337
+ },
6445
6338
  "debug": {
6446
6339
  "char": "d",
6447
6340
  "description": "Activate debug mode (more logs)",
@@ -6480,61 +6373,57 @@
6480
6373
  },
6481
6374
  "hasDynamicHelp": true,
6482
6375
  "hiddenAliases": [],
6483
- "id": "hardis:org:monitor:limits",
6376
+ "id": "hardis:org:diagnose:licenses",
6484
6377
  "pluginAlias": "sfdx-hardis",
6485
6378
  "pluginName": "sfdx-hardis",
6486
6379
  "pluginType": "core",
6487
6380
  "strict": true,
6488
6381
  "enableJsonFlag": true,
6489
- "title": "Check org limits",
6490
- "requiresProject": true,
6491
- "triggerNotification": true,
6382
+ "title": "List licenses subscribed and used in a Salesforce org",
6383
+ "requiresProject": false,
6492
6384
  "isESM": true,
6493
6385
  "relativePath": [
6494
6386
  "lib",
6495
6387
  "commands",
6496
6388
  "hardis",
6497
6389
  "org",
6498
- "monitor",
6499
- "limits.js"
6390
+ "diagnose",
6391
+ "licenses.js"
6500
6392
  ],
6501
6393
  "aliasPermutations": [],
6502
6394
  "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"
6395
+ "hardis:org:diagnose:licenses",
6396
+ "org:hardis:diagnose:licenses",
6397
+ "org:diagnose:hardis:licenses",
6398
+ "org:diagnose:licenses:hardis",
6399
+ "hardis:diagnose:org:licenses",
6400
+ "diagnose:hardis:org:licenses",
6401
+ "diagnose:org:hardis:licenses",
6402
+ "diagnose:org:licenses:hardis",
6403
+ "hardis:diagnose:licenses:org",
6404
+ "diagnose:hardis:licenses:org",
6405
+ "diagnose:licenses:hardis:org",
6406
+ "diagnose:licenses:org:hardis",
6407
+ "hardis:org:licenses:diagnose",
6408
+ "org:hardis:licenses:diagnose",
6409
+ "org:licenses:hardis:diagnose",
6410
+ "org:licenses:diagnose:hardis",
6411
+ "hardis:licenses:org:diagnose",
6412
+ "licenses:hardis:org:diagnose",
6413
+ "licenses:org:hardis:diagnose",
6414
+ "licenses:org:diagnose:hardis",
6415
+ "hardis:licenses:diagnose:org",
6416
+ "licenses:hardis:diagnose:org",
6417
+ "licenses:diagnose:hardis:org",
6418
+ "licenses:diagnose:org:hardis"
6527
6419
  ]
6528
6420
  },
6529
- "hardis:org:diagnose:audittrail": {
6421
+ "hardis:org:diagnose:releaseupdates": {
6530
6422
  "aliases": [],
6531
6423
  "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",
6424
+ "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",
6533
6425
  "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"
6426
+ "$ sf hardis:org:diagnose:releaseupdates"
6538
6427
  ],
6539
6428
  "flags": {
6540
6429
  "json": {
@@ -6552,22 +6441,6 @@
6552
6441
  "multiple": false,
6553
6442
  "type": "option"
6554
6443
  },
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
6444
  "outputfile": {
6572
6445
  "char": "f",
6573
6446
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6614,13 +6487,13 @@
6614
6487
  },
6615
6488
  "hasDynamicHelp": true,
6616
6489
  "hiddenAliases": [],
6617
- "id": "hardis:org:diagnose:audittrail",
6490
+ "id": "hardis:org:diagnose:releaseupdates",
6618
6491
  "pluginAlias": "sfdx-hardis",
6619
6492
  "pluginName": "sfdx-hardis",
6620
6493
  "pluginType": "core",
6621
6494
  "strict": true,
6622
6495
  "enableJsonFlag": true,
6623
- "title": "Diagnose content of Setup Audit Trail",
6496
+ "title": "Check Release Updates of an org",
6624
6497
  "requiresProject": false,
6625
6498
  "isESM": true,
6626
6499
  "relativePath": [
@@ -6629,47 +6502,47 @@
6629
6502
  "hardis",
6630
6503
  "org",
6631
6504
  "diagnose",
6632
- "audittrail.js"
6505
+ "releaseupdates.js"
6633
6506
  ],
6634
6507
  "aliasPermutations": [],
6635
6508
  "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"
6660
- ]
6661
- },
6662
- "hardis:org:diagnose:instanceupgrade": {
6663
- "aliases": [],
6664
- "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",
6666
- "examples": [
6667
- "$ sf hardis:org:diagnose:instanceupgrade"
6668
- ],
6669
- "flags": {
6670
- "json": {
6671
- "description": "Format output as json.",
6672
- "helpGroup": "GLOBAL",
6509
+ "hardis:org:diagnose:releaseupdates",
6510
+ "org:hardis:diagnose:releaseupdates",
6511
+ "org:diagnose:hardis:releaseupdates",
6512
+ "org:diagnose:releaseupdates:hardis",
6513
+ "hardis:diagnose:org:releaseupdates",
6514
+ "diagnose:hardis:org:releaseupdates",
6515
+ "diagnose:org:hardis:releaseupdates",
6516
+ "diagnose:org:releaseupdates:hardis",
6517
+ "hardis:diagnose:releaseupdates:org",
6518
+ "diagnose:hardis:releaseupdates:org",
6519
+ "diagnose:releaseupdates:hardis:org",
6520
+ "diagnose:releaseupdates:org:hardis",
6521
+ "hardis:org:releaseupdates:diagnose",
6522
+ "org:hardis:releaseupdates:diagnose",
6523
+ "org:releaseupdates:hardis:diagnose",
6524
+ "org:releaseupdates:diagnose:hardis",
6525
+ "hardis:releaseupdates:org:diagnose",
6526
+ "releaseupdates:hardis:org:diagnose",
6527
+ "releaseupdates:org:hardis:diagnose",
6528
+ "releaseupdates:org:diagnose:hardis",
6529
+ "hardis:releaseupdates:diagnose:org",
6530
+ "releaseupdates:hardis:diagnose:org",
6531
+ "releaseupdates:diagnose:hardis:org",
6532
+ "releaseupdates:diagnose:org:hardis"
6533
+ ]
6534
+ },
6535
+ "hardis:org:diagnose:unsecure-connected-apps": {
6536
+ "aliases": [],
6537
+ "args": {},
6538
+ "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",
6539
+ "examples": [
6540
+ "$ sf hardis:org:diagnose:unsecure-connected-apps"
6541
+ ],
6542
+ "flags": {
6543
+ "json": {
6544
+ "description": "Format output as json.",
6545
+ "helpGroup": "GLOBAL",
6673
6546
  "name": "json",
6674
6547
  "allowNo": false,
6675
6548
  "type": "boolean"
@@ -6682,6 +6555,14 @@
6682
6555
  "multiple": false,
6683
6556
  "type": "option"
6684
6557
  },
6558
+ "outputfile": {
6559
+ "char": "f",
6560
+ "description": "Force the path and name of output report file. Must end with .csv",
6561
+ "name": "outputfile",
6562
+ "hasDynamicHelp": false,
6563
+ "multiple": false,
6564
+ "type": "option"
6565
+ },
6685
6566
  "debug": {
6686
6567
  "char": "d",
6687
6568
  "description": "Activate debug mode (more logs)",
@@ -6720,13 +6601,13 @@
6720
6601
  },
6721
6602
  "hasDynamicHelp": true,
6722
6603
  "hiddenAliases": [],
6723
- "id": "hardis:org:diagnose:instanceupgrade",
6604
+ "id": "hardis:org:diagnose:unsecure-connected-apps",
6724
6605
  "pluginAlias": "sfdx-hardis",
6725
6606
  "pluginName": "sfdx-hardis",
6726
6607
  "pluginType": "core",
6727
6608
  "strict": true,
6728
6609
  "enableJsonFlag": true,
6729
- "title": "Get Instance Upgrade date",
6610
+ "title": "Detect Unsecured Connected Apps",
6730
6611
  "requiresProject": false,
6731
6612
  "isESM": true,
6732
6613
  "relativePath": [
@@ -6735,45 +6616,43 @@
6735
6616
  "hardis",
6736
6617
  "org",
6737
6618
  "diagnose",
6738
- "instanceupgrade.js"
6619
+ "unsecure-connected-apps.js"
6739
6620
  ],
6740
6621
  "aliasPermutations": [],
6741
6622
  "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"
6623
+ "hardis:org:diagnose:unsecure-connected-apps",
6624
+ "org:hardis:diagnose:unsecure-connected-apps",
6625
+ "org:diagnose:hardis:unsecure-connected-apps",
6626
+ "org:diagnose:unsecure-connected-apps:hardis",
6627
+ "hardis:diagnose:org:unsecure-connected-apps",
6628
+ "diagnose:hardis:org:unsecure-connected-apps",
6629
+ "diagnose:org:hardis:unsecure-connected-apps",
6630
+ "diagnose:org:unsecure-connected-apps:hardis",
6631
+ "hardis:diagnose:unsecure-connected-apps:org",
6632
+ "diagnose:hardis:unsecure-connected-apps:org",
6633
+ "diagnose:unsecure-connected-apps:hardis:org",
6634
+ "diagnose:unsecure-connected-apps:org:hardis",
6635
+ "hardis:org:unsecure-connected-apps:diagnose",
6636
+ "org:hardis:unsecure-connected-apps:diagnose",
6637
+ "org:unsecure-connected-apps:hardis:diagnose",
6638
+ "org:unsecure-connected-apps:diagnose:hardis",
6639
+ "hardis:unsecure-connected-apps:org:diagnose",
6640
+ "unsecure-connected-apps:hardis:org:diagnose",
6641
+ "unsecure-connected-apps:org:hardis:diagnose",
6642
+ "unsecure-connected-apps:org:diagnose:hardis",
6643
+ "hardis:unsecure-connected-apps:diagnose:org",
6644
+ "unsecure-connected-apps:hardis:diagnose:org",
6645
+ "unsecure-connected-apps:diagnose:hardis:org",
6646
+ "unsecure-connected-apps:diagnose:org:hardis"
6766
6647
  ]
6767
6648
  },
6768
- "hardis:org:diagnose:legacyapi": {
6649
+ "hardis:org:diagnose:unused-apex-classes": {
6769
6650
  "aliases": [],
6770
6651
  "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",
6652
+ "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",
6772
6653
  "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"
6654
+ "$ sf hardis:org:diagnose:unused-apex-classes",
6655
+ "$ sf hardis:org:diagnose:unused-apex-classes --days 700"
6777
6656
  ],
6778
6657
  "flags": {
6779
6658
  "json": {
@@ -6791,24 +6670,6 @@
6791
6670
  "multiple": false,
6792
6671
  "type": "option"
6793
6672
  },
6794
- "eventtype": {
6795
- "char": "e",
6796
- "description": "Type of EventLogFile event to analyze",
6797
- "name": "eventtype",
6798
- "default": "ApiTotalUsage",
6799
- "hasDynamicHelp": false,
6800
- "multiple": false,
6801
- "type": "option"
6802
- },
6803
- "limit": {
6804
- "char": "l",
6805
- "description": "Number of latest EventLogFile events to analyze",
6806
- "name": "limit",
6807
- "default": 999,
6808
- "hasDynamicHelp": false,
6809
- "multiple": false,
6810
- "type": "option"
6811
- },
6812
6673
  "outputfile": {
6813
6674
  "char": "f",
6814
6675
  "description": "Force the path and name of output report file. Must end with .csv",
@@ -6817,6 +6678,14 @@
6817
6678
  "multiple": false,
6818
6679
  "type": "option"
6819
6680
  },
6681
+ "days": {
6682
+ "char": "t",
6683
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
6684
+ "name": "days",
6685
+ "hasDynamicHelp": false,
6686
+ "multiple": false,
6687
+ "type": "option"
6688
+ },
6820
6689
  "debug": {
6821
6690
  "char": "d",
6822
6691
  "description": "Activate debug mode (more logs)",
@@ -6855,13 +6724,13 @@
6855
6724
  },
6856
6725
  "hasDynamicHelp": true,
6857
6726
  "hiddenAliases": [],
6858
- "id": "hardis:org:diagnose:legacyapi",
6727
+ "id": "hardis:org:diagnose:unused-apex-classes",
6859
6728
  "pluginAlias": "sfdx-hardis",
6860
6729
  "pluginName": "sfdx-hardis",
6861
6730
  "pluginType": "core",
6862
6731
  "strict": true,
6863
6732
  "enableJsonFlag": true,
6864
- "title": "Check for legacy API use",
6733
+ "title": "Detect unused Apex classes in an org",
6865
6734
  "requiresProject": false,
6866
6735
  "isESM": true,
6867
6736
  "relativePath": [
@@ -6870,42 +6739,42 @@
6870
6739
  "hardis",
6871
6740
  "org",
6872
6741
  "diagnose",
6873
- "legacyapi.js"
6742
+ "unused-apex-classes.js"
6874
6743
  ],
6875
6744
  "aliasPermutations": [],
6876
6745
  "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"
6746
+ "hardis:org:diagnose:unused-apex-classes",
6747
+ "org:hardis:diagnose:unused-apex-classes",
6748
+ "org:diagnose:hardis:unused-apex-classes",
6749
+ "org:diagnose:unused-apex-classes:hardis",
6750
+ "hardis:diagnose:org:unused-apex-classes",
6751
+ "diagnose:hardis:org:unused-apex-classes",
6752
+ "diagnose:org:hardis:unused-apex-classes",
6753
+ "diagnose:org:unused-apex-classes:hardis",
6754
+ "hardis:diagnose:unused-apex-classes:org",
6755
+ "diagnose:hardis:unused-apex-classes:org",
6756
+ "diagnose:unused-apex-classes:hardis:org",
6757
+ "diagnose:unused-apex-classes:org:hardis",
6758
+ "hardis:org:unused-apex-classes:diagnose",
6759
+ "org:hardis:unused-apex-classes:diagnose",
6760
+ "org:unused-apex-classes:hardis:diagnose",
6761
+ "org:unused-apex-classes:diagnose:hardis",
6762
+ "hardis:unused-apex-classes:org:diagnose",
6763
+ "unused-apex-classes:hardis:org:diagnose",
6764
+ "unused-apex-classes:org:hardis:diagnose",
6765
+ "unused-apex-classes:org:diagnose:hardis",
6766
+ "hardis:unused-apex-classes:diagnose:org",
6767
+ "unused-apex-classes:hardis:diagnose:org",
6768
+ "unused-apex-classes:diagnose:hardis:org",
6769
+ "unused-apex-classes:diagnose:org:hardis"
6901
6770
  ]
6902
6771
  },
6903
- "hardis:org:diagnose:licenses": {
6772
+ "hardis:org:diagnose:unused-connected-apps": {
6904
6773
  "aliases": [],
6905
6774
  "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",
6775
+ "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",
6907
6776
  "examples": [
6908
- "$ sf hardis:org:diagnose:licenses"
6777
+ "$ sf hardis:org:diagnose:unused-connected-apps"
6909
6778
  ],
6910
6779
  "flags": {
6911
6780
  "json": {
@@ -6931,13 +6800,6 @@
6931
6800
  "multiple": false,
6932
6801
  "type": "option"
6933
6802
  },
6934
- "usedonly": {
6935
- "char": "u",
6936
- "description": "Filter to have only used licenses",
6937
- "name": "usedonly",
6938
- "allowNo": false,
6939
- "type": "boolean"
6940
- },
6941
6803
  "debug": {
6942
6804
  "char": "d",
6943
6805
  "description": "Activate debug mode (more logs)",
@@ -6976,13 +6838,30 @@
6976
6838
  },
6977
6839
  "hasDynamicHelp": true,
6978
6840
  "hiddenAliases": [],
6979
- "id": "hardis:org:diagnose:licenses",
6841
+ "id": "hardis:org:diagnose:unused-connected-apps",
6980
6842
  "pluginAlias": "sfdx-hardis",
6981
6843
  "pluginName": "sfdx-hardis",
6982
6844
  "pluginType": "core",
6983
6845
  "strict": true,
6984
6846
  "enableJsonFlag": true,
6985
- "title": "List licenses subscribed and used in a Salesforce org",
6847
+ "title": "Unused Connected Apps in an org",
6848
+ "allowedInactiveConnectedApps": [
6849
+ "Ant Migration Tool",
6850
+ "Chatter Desktop",
6851
+ "Chatter Mobile for BlackBerry",
6852
+ "Force.com IDE",
6853
+ "OIQ_Integration",
6854
+ "Salesforce CLI",
6855
+ "Salesforce Files",
6856
+ "Salesforce Mobile Dashboards",
6857
+ "Salesforce Touch",
6858
+ "Salesforce for Outlook",
6859
+ "SalesforceA",
6860
+ "SalesforceA for Android",
6861
+ "SalesforceA for iOS",
6862
+ "SalesforceDX Namespace Registry",
6863
+ "SalesforceIQ"
6864
+ ],
6986
6865
  "requiresProject": false,
6987
6866
  "isESM": true,
6988
6867
  "relativePath": [
@@ -6991,42 +6870,43 @@
6991
6870
  "hardis",
6992
6871
  "org",
6993
6872
  "diagnose",
6994
- "licenses.js"
6873
+ "unused-connected-apps.js"
6995
6874
  ],
6996
6875
  "aliasPermutations": [],
6997
6876
  "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"
7022
- ]
7023
- },
7024
- "hardis:org:diagnose:releaseupdates": {
7025
- "aliases": [],
7026
- "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",
7028
- "examples": [
7029
- "$ sf hardis:org:diagnose:releaseupdates"
6877
+ "hardis:org:diagnose:unused-connected-apps",
6878
+ "org:hardis:diagnose:unused-connected-apps",
6879
+ "org:diagnose:hardis:unused-connected-apps",
6880
+ "org:diagnose:unused-connected-apps:hardis",
6881
+ "hardis:diagnose:org:unused-connected-apps",
6882
+ "diagnose:hardis:org:unused-connected-apps",
6883
+ "diagnose:org:hardis:unused-connected-apps",
6884
+ "diagnose:org:unused-connected-apps:hardis",
6885
+ "hardis:diagnose:unused-connected-apps:org",
6886
+ "diagnose:hardis:unused-connected-apps:org",
6887
+ "diagnose:unused-connected-apps:hardis:org",
6888
+ "diagnose:unused-connected-apps:org:hardis",
6889
+ "hardis:org:unused-connected-apps:diagnose",
6890
+ "org:hardis:unused-connected-apps:diagnose",
6891
+ "org:unused-connected-apps:hardis:diagnose",
6892
+ "org:unused-connected-apps:diagnose:hardis",
6893
+ "hardis:unused-connected-apps:org:diagnose",
6894
+ "unused-connected-apps:hardis:org:diagnose",
6895
+ "unused-connected-apps:org:hardis:diagnose",
6896
+ "unused-connected-apps:org:diagnose:hardis",
6897
+ "hardis:unused-connected-apps:diagnose:org",
6898
+ "unused-connected-apps:hardis:diagnose:org",
6899
+ "unused-connected-apps:diagnose:hardis:org",
6900
+ "unused-connected-apps:diagnose:org:hardis"
6901
+ ]
6902
+ },
6903
+ "hardis:org:diagnose:unusedlicenses": {
6904
+ "aliases": [],
6905
+ "args": {},
6906
+ "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",
6907
+ "examples": [
6908
+ "$ sf hardis:org:diagnose:unusedlicenses",
6909
+ "$ sf hardis:org:diagnose:unusedlicenses --fix"
7030
6910
  ],
7031
6911
  "flags": {
7032
6912
  "json": {
@@ -7090,14 +6970,32 @@
7090
6970
  },
7091
6971
  "hasDynamicHelp": true,
7092
6972
  "hiddenAliases": [],
7093
- "id": "hardis:org:diagnose:releaseupdates",
6973
+ "id": "hardis:org:diagnose:unusedlicenses",
7094
6974
  "pluginAlias": "sfdx-hardis",
7095
6975
  "pluginName": "sfdx-hardis",
7096
6976
  "pluginType": "core",
7097
6977
  "strict": true,
7098
6978
  "enableJsonFlag": true,
7099
- "title": "Check Release Updates of an org",
6979
+ "title": "Detect unused Permission Set Licenses (beta)",
7100
6980
  "requiresProject": false,
6981
+ "additionalPermissionSetsToAlwaysGet": [
6982
+ "Sales_User"
6983
+ ],
6984
+ "permSetsPermSetLicenses": [
6985
+ {
6986
+ "permSet": "Sales_User",
6987
+ "permSetLicense": "SalesUserPsl"
6988
+ }
6989
+ ],
6990
+ "profilesPermissionSetLicenses": [
6991
+ {
6992
+ "profile": "Salesforce API Only",
6993
+ "permSetLicense": "SalesforceAPIIntegrationPsl"
6994
+ }
6995
+ ],
6996
+ "alwaysExcludeForActiveUsersPermissionSetLicenses": [
6997
+ "IdentityConnect"
6998
+ ],
7101
6999
  "isESM": true,
7102
7000
  "relativePath": [
7103
7001
  "lib",
@@ -7105,42 +7003,46 @@
7105
7003
  "hardis",
7106
7004
  "org",
7107
7005
  "diagnose",
7108
- "releaseupdates.js"
7006
+ "unusedlicenses.js"
7109
7007
  ],
7110
7008
  "aliasPermutations": [],
7111
7009
  "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"
7010
+ "hardis:org:diagnose:unusedlicenses",
7011
+ "org:hardis:diagnose:unusedlicenses",
7012
+ "org:diagnose:hardis:unusedlicenses",
7013
+ "org:diagnose:unusedlicenses:hardis",
7014
+ "hardis:diagnose:org:unusedlicenses",
7015
+ "diagnose:hardis:org:unusedlicenses",
7016
+ "diagnose:org:hardis:unusedlicenses",
7017
+ "diagnose:org:unusedlicenses:hardis",
7018
+ "hardis:diagnose:unusedlicenses:org",
7019
+ "diagnose:hardis:unusedlicenses:org",
7020
+ "diagnose:unusedlicenses:hardis:org",
7021
+ "diagnose:unusedlicenses:org:hardis",
7022
+ "hardis:org:unusedlicenses:diagnose",
7023
+ "org:hardis:unusedlicenses:diagnose",
7024
+ "org:unusedlicenses:hardis:diagnose",
7025
+ "org:unusedlicenses:diagnose:hardis",
7026
+ "hardis:unusedlicenses:org:diagnose",
7027
+ "unusedlicenses:hardis:org:diagnose",
7028
+ "unusedlicenses:org:hardis:diagnose",
7029
+ "unusedlicenses:org:diagnose:hardis",
7030
+ "hardis:unusedlicenses:diagnose:org",
7031
+ "unusedlicenses:hardis:diagnose:org",
7032
+ "unusedlicenses:diagnose:hardis:org",
7033
+ "unusedlicenses:diagnose:org:hardis"
7136
7034
  ]
7137
7035
  },
7138
- "hardis:org:diagnose:unsecure-connected-apps": {
7036
+ "hardis:org:diagnose:unusedusers": {
7139
7037
  "aliases": [],
7140
7038
  "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",
7039
+ "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>",
7142
7040
  "examples": [
7143
- "$ sf hardis:org:diagnose:unsecure-connected-apps"
7041
+ "$ sf hardis:org:diagnose:unusedusers",
7042
+ "$ sf hardis:org:diagnose:unusedusers --days 365",
7043
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm",
7044
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licenseidentifiers SFDC,AUL,AUL1",
7045
+ "$ sf hardis:org:diagnose:unusedusers --days 60 --licensetypes all-crm --returnactiveusers"
7144
7046
  ],
7145
7047
  "flags": {
7146
7048
  "json": {
@@ -7166,6 +7068,41 @@
7166
7068
  "multiple": false,
7167
7069
  "type": "option"
7168
7070
  },
7071
+ "days": {
7072
+ "char": "t",
7073
+ "description": "Extracts the users that have been inactive for the amount of days specified. In CI, default is 180 days",
7074
+ "name": "days",
7075
+ "hasDynamicHelp": false,
7076
+ "multiple": false,
7077
+ "type": "option"
7078
+ },
7079
+ "licensetypes": {
7080
+ "char": "l",
7081
+ "description": "Type of licenses to check. If set, do not use licenseidentifiers option. In CI, default is all-crm",
7082
+ "name": "licensetypes",
7083
+ "hasDynamicHelp": false,
7084
+ "multiple": false,
7085
+ "options": [
7086
+ "all",
7087
+ "all-crm",
7088
+ "all-paying"
7089
+ ],
7090
+ "type": "option"
7091
+ },
7092
+ "licenseidentifiers": {
7093
+ "char": "i",
7094
+ "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",
7095
+ "name": "licenseidentifiers",
7096
+ "hasDynamicHelp": false,
7097
+ "multiple": false,
7098
+ "type": "option"
7099
+ },
7100
+ "returnactiveusers": {
7101
+ "description": "Inverts the command by returning the active users",
7102
+ "name": "returnactiveusers",
7103
+ "allowNo": false,
7104
+ "type": "boolean"
7105
+ },
7169
7106
  "debug": {
7170
7107
  "char": "d",
7171
7108
  "description": "Activate debug mode (more logs)",
@@ -7204,13 +7141,13 @@
7204
7141
  },
7205
7142
  "hasDynamicHelp": true,
7206
7143
  "hiddenAliases": [],
7207
- "id": "hardis:org:diagnose:unsecure-connected-apps",
7144
+ "id": "hardis:org:diagnose:unusedusers",
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",
7150
+ "title": "Detect unused Users in Salesforce",
7214
7151
  "requiresProject": false,
7215
7152
  "isESM": true,
7216
7153
  "relativePath": [
@@ -7219,43 +7156,44 @@
7219
7156
  "hardis",
7220
7157
  "org",
7221
7158
  "diagnose",
7222
- "unsecure-connected-apps.js"
7159
+ "unusedusers.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:diagnose:unusedusers",
7164
+ "org:hardis:diagnose:unusedusers",
7165
+ "org:diagnose:hardis:unusedusers",
7166
+ "org:diagnose:unusedusers:hardis",
7167
+ "hardis:diagnose:org:unusedusers",
7168
+ "diagnose:hardis:org:unusedusers",
7169
+ "diagnose:org:hardis:unusedusers",
7170
+ "diagnose:org:unusedusers:hardis",
7171
+ "hardis:diagnose:unusedusers:org",
7172
+ "diagnose:hardis:unusedusers:org",
7173
+ "diagnose:unusedusers:hardis:org",
7174
+ "diagnose:unusedusers:org:hardis",
7175
+ "hardis:org:unusedusers:diagnose",
7176
+ "org:hardis:unusedusers:diagnose",
7177
+ "org:unusedusers:hardis:diagnose",
7178
+ "org:unusedusers:diagnose:hardis",
7179
+ "hardis:unusedusers:org:diagnose",
7180
+ "unusedusers:hardis:org:diagnose",
7181
+ "unusedusers:org:hardis:diagnose",
7182
+ "unusedusers:org:diagnose:hardis",
7183
+ "hardis:unusedusers:diagnose:org",
7184
+ "unusedusers:hardis:diagnose:org",
7185
+ "unusedusers:diagnose:hardis:org",
7186
+ "unusedusers:diagnose: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,211 +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"
7467
- ],
7468
- "requiresProject": false,
7469
- "isESM": true,
7470
- "relativePath": [
7471
- "lib",
7472
- "commands",
7473
- "hardis",
7474
- "org",
7475
- "diagnose",
7476
- "unused-connected-apps.js"
7477
- ],
7478
- "aliasPermutations": [],
7479
- "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"
7504
- ]
7505
- },
7506
- "hardis:org:diagnose:unusedlicenses": {
7507
- "aliases": [],
7508
- "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",
7510
- "examples": [
7511
- "$ sf hardis:org:diagnose:unusedlicenses",
7512
- "$ sf hardis:org:diagnose:unusedlicenses --fix"
7513
- ],
7514
- "flags": {
7515
- "json": {
7516
- "description": "Format output as json.",
7517
- "helpGroup": "GLOBAL",
7518
- "name": "json",
7519
- "allowNo": false,
7520
- "type": "boolean"
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"
7521
7385
  },
7522
- "flags-dir": {
7523
- "helpGroup": "GLOBAL",
7524
- "name": "flags-dir",
7525
- "summary": "Import flag values from a directory.",
7526
- "hasDynamicHelp": false,
7527
- "multiple": false,
7528
- "type": "option"
7386
+ {
7387
+ "key": "LEGACY_API",
7388
+ "title": "Detect calls to deprecated API versions",
7389
+ "command": "sf hardis:org:diagnose:legacyapi",
7390
+ "frequency": "daily"
7529
7391
  },
7530
- "outputfile": {
7531
- "char": "f",
7532
- "description": "Force the path and name of output report file. Must end with .csv",
7533
- "name": "outputfile",
7534
- "hasDynamicHelp": false,
7535
- "multiple": false,
7536
- "type": "option"
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"
7537
7397
  },
7538
- "debug": {
7539
- "char": "d",
7540
- "description": "Activate debug mode (more logs)",
7541
- "name": "debug",
7542
- "allowNo": false,
7543
- "type": "boolean"
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"
7544
7403
  },
7545
- "websocket": {
7546
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
7547
- "name": "websocket",
7548
- "hasDynamicHelp": false,
7549
- "multiple": false,
7550
- "type": "option"
7404
+ {
7405
+ "key": "LICENSES",
7406
+ "title": "Extract licenses information",
7407
+ "command": "sf hardis:org:diagnose:licenses",
7408
+ "frequency": "weekly"
7551
7409
  },
7552
- "skipauth": {
7553
- "description": "Skip authentication check when a default username is required",
7554
- "name": "skipauth",
7555
- "allowNo": false,
7556
- "type": "boolean"
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"
7557
7415
  },
7558
- "target-org": {
7559
- "aliases": [
7560
- "targetusername",
7561
- "u"
7562
- ],
7563
- "char": "o",
7564
- "deprecateAliases": true,
7565
- "name": "target-org",
7566
- "noCacheDefault": true,
7567
- "required": true,
7568
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
7569
- "hasDynamicHelp": true,
7570
- "multiple": false,
7571
- "type": "option"
7572
- }
7573
- },
7574
- "hasDynamicHelp": true,
7575
- "hiddenAliases": [],
7576
- "id": "hardis:org:diagnose:unusedlicenses",
7577
- "pluginAlias": "sfdx-hardis",
7578
- "pluginName": "sfdx-hardis",
7579
- "pluginType": "core",
7580
- "strict": true,
7581
- "enableJsonFlag": true,
7582
- "title": "Detect unused Permission Set Licenses (beta)",
7583
- "requiresProject": false,
7584
- "additionalPermissionSetsToAlwaysGet": [
7585
- "Sales_User"
7586
- ],
7587
- "permSetsPermSetLicenses": [
7588
7416
  {
7589
- "permSet": "Sales_User",
7590
- "permSetLicense": "SalesUserPsl"
7591
- }
7592
- ],
7593
- "profilesPermissionSetLicenses": [
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
+ },
7594
7422
  {
7595
- "profile": "Salesforce API Only",
7596
- "permSetLicense": "SalesforceAPIIntegrationPsl"
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"
7597
7475
  }
7598
7476
  ],
7599
- "alwaysExcludeForActiveUsersPermissionSetLicenses": [
7600
- "IdentityConnect"
7601
- ],
7477
+ "requiresProject": true,
7478
+ "triggerNotification": true,
7602
7479
  "isESM": true,
7603
7480
  "relativePath": [
7604
7481
  "lib",
7605
7482
  "commands",
7606
7483
  "hardis",
7607
7484
  "org",
7608
- "diagnose",
7609
- "unusedlicenses.js"
7485
+ "monitor",
7486
+ "all.js"
7610
7487
  ],
7611
7488
  "aliasPermutations": [],
7612
7489
  "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"
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"
7637
7514
  ]
7638
7515
  },
7639
- "hardis:org:diagnose:unusedusers": {
7516
+ "hardis:org:monitor:backup": {
7640
7517
  "aliases": [],
7641
7518
  "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>",
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",
7643
7520
  "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"
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"
7649
7525
  ],
7650
7526
  "flags": {
7651
7527
  "json": {
@@ -7663,163 +7539,57 @@
7663
7539
  "multiple": false,
7664
7540
  "type": "option"
7665
7541
  },
7666
- "outputfile": {
7667
- "char": "f",
7668
- "description": "Force the path and name of output report file. Must end with .csv",
7669
- "name": "outputfile",
7670
- "hasDynamicHelp": false,
7671
- "multiple": false,
7672
- "type": "option"
7673
- },
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"
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"
7694
7547
  },
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",
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,
7699
7553
  "hasDynamicHelp": false,
7700
7554
  "multiple": false,
7701
7555
  "type": "option"
7702
7556
  },
7703
- "returnactiveusers": {
7704
- "description": "Inverts the command by returning the active users",
7705
- "name": "returnactiveusers",
7557
+ "exclude-namespaces": {
7558
+ "char": "e",
7559
+ "description": "If mode --full is activated, exclude namespaced metadatas",
7560
+ "name": "exclude-namespaces",
7706
7561
  "allowNo": false,
7707
7562
  "type": "boolean"
7708
7563
  },
7709
- "debug": {
7710
- "char": "d",
7711
- "description": "Activate debug mode (more logs)",
7712
- "name": "debug",
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",
7713
7568
  "allowNo": false,
7714
7569
  "type": "boolean"
7715
7570
  },
7716
- "websocket": {
7717
- "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
7718
- "name": "websocket",
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,
7719
7575
  "hasDynamicHelp": false,
7720
7576
  "multiple": false,
7721
7577
  "type": "option"
7722
7578
  },
7723
- "skipauth": {
7724
- "description": "Skip authentication check when a default username is required",
7725
- "name": "skipauth",
7726
- "allowNo": false,
7727
- "type": "boolean"
7728
- },
7729
- "target-org": {
7730
- "aliases": [
7731
- "targetusername",
7732
- "u"
7733
- ],
7734
- "char": "o",
7735
- "deprecateAliases": true,
7736
- "name": "target-org",
7737
- "noCacheDefault": true,
7738
- "required": true,
7739
- "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
7740
- "hasDynamicHelp": true,
7741
- "multiple": false,
7742
- "type": "option"
7743
- }
7744
- },
7745
- "hasDynamicHelp": true,
7746
- "hiddenAliases": [],
7747
- "id": "hardis:org:diagnose:unusedusers",
7748
- "pluginAlias": "sfdx-hardis",
7749
- "pluginName": "sfdx-hardis",
7750
- "pluginType": "core",
7751
- "strict": true,
7752
- "enableJsonFlag": true,
7753
- "title": "Detect unused Users in Salesforce",
7754
- "requiresProject": false,
7755
- "isESM": true,
7756
- "relativePath": [
7757
- "lib",
7758
- "commands",
7759
- "hardis",
7760
- "org",
7761
- "diagnose",
7762
- "unusedusers.js"
7763
- ],
7764
- "aliasPermutations": [],
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"
7790
- ]
7791
- },
7792
- "hardis:org:purge:apexlog": {
7793
- "aliases": [],
7794
- "args": {},
7795
- "description": "\n**Purges Apex debug logs from a Salesforce org.**\n\nThis command provides a quick and efficient way to clear out accumulated Apex debug logs from your Salesforce environment. This is particularly useful for:\n\n- **Storage Management:** Freeing up valuable data storage space in your Salesforce org.\n- **Performance Optimization:** Reducing the overhead associated with large volumes of debug logs.\n- **Troubleshooting:** Ensuring that new debug logs are generated cleanly without interference from old, irrelevant logs.\n\nKey functionalities:\n\n- **Log Identification:** Queries the `ApexLog` object to identify all existing debug logs.\n- **Confirmation Prompt:** Before deletion, it prompts for user confirmation, displaying the number of Apex logs that will be deleted.\n- **Bulk Deletion:** Uses the Salesforce Bulk API to efficiently delete a large number of Apex logs.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query:** It executes a SOQL query (`SELECT Id FROM ApexLog LIMIT 50000`) to retrieve the IDs of Apex logs to be deleted. The limit is set to 50,000 to handle large volumes of logs.\n- **CSV Export:** The retrieved log IDs are temporarily exported to a CSV file (`ApexLogsToDelete_*.csv`) in the `./tmp` directory.\n- **User Confirmation:** It uses the `prompts` library to ask for user confirmation before proceeding with the deletion, displaying the count of logs to be purged.\n- **Bulk API Deletion:** It then uses the Salesforce CLI's `sf data delete bulk` command, pointing to the generated CSV file, to perform the mass deletion of Apex logs.\n- **File System Operations:** It uses `fs-extra` to create the temporary directory and manage the CSV file.\n- **Error Handling:** Includes error handling for the query and deletion operations.\n</details>\n",
7796
- "examples": [
7797
- "$ sf hardis:org:purge:apexlog",
7798
- "$ sf hardis:org:purge:apexlog --target-org nicolas.vuillamy@gmail.com"
7799
- ],
7800
- "flags": {
7801
- "json": {
7802
- "description": "Format output as json.",
7803
- "helpGroup": "GLOBAL",
7804
- "name": "json",
7579
+ "skip-doc": {
7580
+ "description": "Skip the generation of project documentation at the end of the command",
7581
+ "name": "skip-doc",
7805
7582
  "allowNo": false,
7806
7583
  "type": "boolean"
7807
7584
  },
7808
- "flags-dir": {
7809
- "helpGroup": "GLOBAL",
7810
- "name": "flags-dir",
7811
- "summary": "Import flag values from a directory.",
7585
+ "outputfile": {
7586
+ "char": "f",
7587
+ "description": "Force the path and name of output report file. Must end with .csv",
7588
+ "name": "outputfile",
7812
7589
  "hasDynamicHelp": false,
7813
7590
  "multiple": false,
7814
7591
  "type": "option"
7815
7592
  },
7816
- "prompt": {
7817
- "char": "z",
7818
- "description": "Prompt for confirmation (true by default, use --no-prompt to skip)",
7819
- "name": "prompt",
7820
- "allowNo": true,
7821
- "type": "boolean"
7822
- },
7823
7593
  "debug": {
7824
7594
  "char": "d",
7825
7595
  "description": "Activate debug mode (more logs)",
@@ -7858,59 +7628,58 @@
7858
7628
  },
7859
7629
  "hasDynamicHelp": true,
7860
7630
  "hiddenAliases": [],
7861
- "id": "hardis:org:purge:apexlog",
7631
+ "id": "hardis:org:monitor:backup",
7862
7632
  "pluginAlias": "sfdx-hardis",
7863
7633
  "pluginName": "sfdx-hardis",
7864
7634
  "pluginType": "core",
7865
7635
  "strict": true,
7866
7636
  "enableJsonFlag": true,
7867
- "title": "Purge Apex Logs",
7868
- "requiresProject": false,
7637
+ "title": "Backup DX sources",
7638
+ "requiresProject": true,
7639
+ "triggerNotification": true,
7869
7640
  "isESM": true,
7870
7641
  "relativePath": [
7871
7642
  "lib",
7872
7643
  "commands",
7873
7644
  "hardis",
7874
7645
  "org",
7875
- "purge",
7876
- "apexlog.js"
7646
+ "monitor",
7647
+ "backup.js"
7877
7648
  ],
7878
7649
  "aliasPermutations": [],
7879
7650
  "permutations": [
7880
- "hardis:org:purge:apexlog",
7881
- "org:hardis:purge:apexlog",
7882
- "org:purge:hardis:apexlog",
7883
- "org:purge:apexlog:hardis",
7884
- "hardis:purge:org:apexlog",
7885
- "purge:hardis:org:apexlog",
7886
- "purge:org:hardis:apexlog",
7887
- "purge:org:apexlog:hardis",
7888
- "hardis:purge:apexlog:org",
7889
- "purge:hardis:apexlog:org",
7890
- "purge:apexlog:hardis:org",
7891
- "purge:apexlog:org:hardis",
7892
- "hardis:org:apexlog:purge",
7893
- "org:hardis:apexlog:purge",
7894
- "org:apexlog:hardis:purge",
7895
- "org:apexlog:purge:hardis",
7896
- "hardis:apexlog:org:purge",
7897
- "apexlog:hardis:org:purge",
7898
- "apexlog:org:hardis:purge",
7899
- "apexlog:org:purge:hardis",
7900
- "hardis:apexlog:purge:org",
7901
- "apexlog:hardis:purge:org",
7902
- "apexlog:purge:hardis:org",
7903
- "apexlog:purge: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"
7904
7675
  ]
7905
7676
  },
7906
- "hardis:org:purge:flow": {
7677
+ "hardis:org:monitor:limits": {
7907
7678
  "aliases": [],
7908
7679
  "args": {},
7909
- "description": "\n**Purges old or unwanted Flow versions from a Salesforce org, with an option to delete related Flow Interviews.**\n\nThis command helps maintain a clean and performant Salesforce org by removing obsolete Flow versions. Over time, multiple versions of Flows can accumulate, consuming storage and potentially impacting performance. This tool provides a controlled way to clean up these versions.\n\nKey functionalities:\n\n- **Targeted Flow Selection:** Allows you to filter Flow versions to delete by name (`--name`) and status (`--status`, e.g., `Obsolete`, `Draft`, `Inactive`).\n- **Flow Interview Deletion:** If a Flow version cannot be deleted due to active Flow Interviews, the `--delete-flow-interviews` flag (or interactive prompt) allows you to delete these interviews first, then retry the Flow version deletion.\n- **Confirmation Prompt:** In interactive mode, it prompts for confirmation before proceeding with the deletion of Flow versions and Flow Interviews.\n- **Partial Success Handling:** The `--allowpurgefailure` flag (default `true`) allows the command to continue even if some deletions fail, reporting the errors.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Queries (Tooling API):** It queries the `Flow` object (using the Tooling API) to list Flow versions based on the provided filters (name, status, manageable state).\n- **Bulk Deletion (Tooling API):** It uses `bulkDeleteTooling` to perform mass deletions of Flow versions. If deletion fails due to active interviews, it extracts the interview IDs.\n- **Flow Interview Management:** If `delete-flow-interviews` is enabled, it queries `FlowInterview` objects, performs bulk deletion of the identified interviews using `bulkDelete`, and then retries the Flow version deletion.\n- **Interactive Prompts:** Uses the `prompts` library to interact with the user for selecting Flows, statuses, and confirming deletion actions.\n- **Error Reporting:** Logs detailed error messages for failed deletions, including the specific reasons.\n- **Command-Line Execution:** Uses `execSfdxJson` to execute Salesforce CLI commands for querying Flow data.\n</details>\n",
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",
7910
7681
  "examples": [
7911
- "$ sf hardis:org:purge:flow",
7912
- "$ sf hardis:org:purge:flow --target-org nicolas.vuillamy@gmail.com --no-prompt --delete-flow-interviews",
7913
- "$ sf hardis:org:purge:flow --target-org nicolas.vuillamy@gmail.com --status \"Obsolete,Draft,InvalidDraft\" --name TestFlow"
7682
+ "$ sf hardis:org:monitor:limits"
7914
7683
  ],
7915
7684
  "flags": {
7916
7685
  "json": {
@@ -7920,56 +7689,18 @@
7920
7689
  "allowNo": false,
7921
7690
  "type": "boolean"
7922
7691
  },
7923
- "flags-dir": {
7924
- "helpGroup": "GLOBAL",
7925
- "name": "flags-dir",
7926
- "summary": "Import flag values from a directory.",
7927
- "hasDynamicHelp": false,
7928
- "multiple": false,
7929
- "type": "option"
7930
- },
7931
- "prompt": {
7932
- "char": "z",
7933
- "description": "Prompt for confirmation (true by default, use --no-prompt to skip)",
7934
- "name": "prompt",
7935
- "allowNo": true,
7936
- "type": "boolean"
7937
- },
7938
- "name": {
7939
- "char": "n",
7940
- "description": "Filter according to Name criteria",
7941
- "name": "name",
7942
- "hasDynamicHelp": false,
7943
- "multiple": false,
7944
- "type": "option"
7945
- },
7946
- "status": {
7947
- "char": "s",
7948
- "description": "Filter according to Status criteria",
7949
- "name": "status",
7692
+ "flags-dir": {
7693
+ "helpGroup": "GLOBAL",
7694
+ "name": "flags-dir",
7695
+ "summary": "Import flag values from a directory.",
7950
7696
  "hasDynamicHelp": false,
7951
7697
  "multiple": false,
7952
7698
  "type": "option"
7953
7699
  },
7954
- "delete-flow-interviews": {
7955
- "char": "w",
7956
- "description": "If the presence of Flow interviews prevent to delete flows versions, delete them before retrying to delete flow versions",
7957
- "name": "delete-flow-interviews",
7958
- "allowNo": false,
7959
- "type": "boolean"
7960
- },
7961
- "allowpurgefailure": {
7700
+ "outputfile": {
7962
7701
  "char": "f",
7963
- "description": "Allows purges to fail without exiting with 1. Use --no-allowpurgefailure to disable",
7964
- "name": "allowpurgefailure",
7965
- "allowNo": true,
7966
- "type": "boolean"
7967
- },
7968
- "instanceurl": {
7969
- "char": "r",
7970
- "description": "URL of org instance",
7971
- "name": "instanceurl",
7972
- "default": "https://login.salesforce.com",
7702
+ "description": "Force the path and name of output report file. Must end with .csv",
7703
+ "name": "outputfile",
7973
7704
  "hasDynamicHelp": false,
7974
7705
  "multiple": false,
7975
7706
  "type": "option"
@@ -8012,49 +7743,50 @@
8012
7743
  },
8013
7744
  "hasDynamicHelp": true,
8014
7745
  "hiddenAliases": [],
8015
- "id": "hardis:org:purge:flow",
7746
+ "id": "hardis:org:monitor:limits",
8016
7747
  "pluginAlias": "sfdx-hardis",
8017
7748
  "pluginName": "sfdx-hardis",
8018
7749
  "pluginType": "core",
8019
7750
  "strict": true,
8020
7751
  "enableJsonFlag": true,
8021
- "title": "Purge Flow versions",
8022
- "requiresProject": false,
7752
+ "title": "Check org limits",
7753
+ "requiresProject": true,
7754
+ "triggerNotification": true,
8023
7755
  "isESM": true,
8024
7756
  "relativePath": [
8025
7757
  "lib",
8026
7758
  "commands",
8027
7759
  "hardis",
8028
7760
  "org",
8029
- "purge",
8030
- "flow.js"
7761
+ "monitor",
7762
+ "limits.js"
8031
7763
  ],
8032
7764
  "aliasPermutations": [],
8033
7765
  "permutations": [
8034
- "hardis:org:purge:flow",
8035
- "org:hardis:purge:flow",
8036
- "org:purge:hardis:flow",
8037
- "org:purge:flow:hardis",
8038
- "hardis:purge:org:flow",
8039
- "purge:hardis:org:flow",
8040
- "purge:org:hardis:flow",
8041
- "purge:org:flow:hardis",
8042
- "hardis:purge:flow:org",
8043
- "purge:hardis:flow:org",
8044
- "purge:flow:hardis:org",
8045
- "purge:flow:org:hardis",
8046
- "hardis:org:flow:purge",
8047
- "org:hardis:flow:purge",
8048
- "org:flow:hardis:purge",
8049
- "org:flow:purge:hardis",
8050
- "hardis:flow:org:purge",
8051
- "flow:hardis:org:purge",
8052
- "flow:org:hardis:purge",
8053
- "flow:org:purge:hardis",
8054
- "hardis:flow:purge:org",
8055
- "flow:hardis:purge:org",
8056
- "flow:purge:hardis:org",
8057
- "flow:purge: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"
8058
7790
  ]
8059
7791
  },
8060
7792
  "hardis:org:refresh:after-refresh": {
@@ -8296,13 +8028,128 @@
8296
8028
  "before-refresh:refresh:org:hardis"
8297
8029
  ]
8298
8030
  },
8299
- "hardis:org:retrieve:packageconfig": {
8031
+ "hardis:org:purge:apexlog": {
8300
8032
  "aliases": [],
8301
8033
  "args": {},
8302
- "description": "\n**Retrieves the installed package configuration from a Salesforce org and optionally updates the local project configuration.**\n\nThis command is useful for maintaining an accurate record of installed packages within your Salesforce project, which is crucial for managing dependencies and ensuring consistent deployments across environments.\n\nKey functionalities:\n\n- **Package Listing:** Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a list of all installed packages.\n- **Configuration Update:** Offers the option to update your local project's configuration with the retrieved list of installed packages. This can be beneficial for automating package installations during environment setup or CI/CD processes.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Org Connection:** It establishes a connection to the target Salesforce org using the provided or prompted username.\n- **Metadata Retrieval:** It utilizes `MetadataUtils.listInstalledPackages` to query the Salesforce org and obtain details about the installed packages.\n- **Interactive Prompt:** It uses the `prompts` library to ask the user whether they want to update their local project configuration with the retrieved package list.\n- **Configuration Management:** If the user confirms, it calls `managePackageConfig` to update the project's configuration file (likely `.sfdx-hardis.yml`) with the new package information.\n- **User Feedback:** Provides clear messages to the user about the success of the package retrieval and configuration update.\n</details>\n",
8034
+ "description": "\n**Purges Apex debug logs from a Salesforce org.**\n\nThis command provides a quick and efficient way to clear out accumulated Apex debug logs from your Salesforce environment. This is particularly useful for:\n\n- **Storage Management:** Freeing up valuable data storage space in your Salesforce org.\n- **Performance Optimization:** Reducing the overhead associated with large volumes of debug logs.\n- **Troubleshooting:** Ensuring that new debug logs are generated cleanly without interference from old, irrelevant logs.\n\nKey functionalities:\n\n- **Log Identification:** Queries the `ApexLog` object to identify all existing debug logs.\n- **Confirmation Prompt:** Before deletion, it prompts for user confirmation, displaying the number of Apex logs that will be deleted.\n- **Bulk Deletion:** Uses the Salesforce Bulk API to efficiently delete a large number of Apex logs.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Query:** It executes a SOQL query (`SELECT Id FROM ApexLog LIMIT 50000`) to retrieve the IDs of Apex logs to be deleted. The limit is set to 50,000 to handle large volumes of logs.\n- **CSV Export:** The retrieved log IDs are temporarily exported to a CSV file (`ApexLogsToDelete_*.csv`) in the `./tmp` directory.\n- **User Confirmation:** It uses the `prompts` library to ask for user confirmation before proceeding with the deletion, displaying the count of logs to be purged.\n- **Bulk API Deletion:** It then uses the Salesforce CLI's `sf data delete bulk` command, pointing to the generated CSV file, to perform the mass deletion of Apex logs.\n- **File System Operations:** It uses `fs-extra` to create the temporary directory and manage the CSV file.\n- **Error Handling:** Includes error handling for the query and deletion operations.\n</details>\n",
8303
8035
  "examples": [
8304
- "$ sf hardis:org:retrieve:packageconfig",
8305
- "sf hardis:org:retrieve:packageconfig -u myOrg"
8036
+ "$ sf hardis:org:purge:apexlog",
8037
+ "$ sf hardis:org:purge:apexlog --target-org nicolas.vuillamy@gmail.com"
8038
+ ],
8039
+ "flags": {
8040
+ "json": {
8041
+ "description": "Format output as json.",
8042
+ "helpGroup": "GLOBAL",
8043
+ "name": "json",
8044
+ "allowNo": false,
8045
+ "type": "boolean"
8046
+ },
8047
+ "flags-dir": {
8048
+ "helpGroup": "GLOBAL",
8049
+ "name": "flags-dir",
8050
+ "summary": "Import flag values from a directory.",
8051
+ "hasDynamicHelp": false,
8052
+ "multiple": false,
8053
+ "type": "option"
8054
+ },
8055
+ "prompt": {
8056
+ "char": "z",
8057
+ "description": "Prompt for confirmation (true by default, use --no-prompt to skip)",
8058
+ "name": "prompt",
8059
+ "allowNo": true,
8060
+ "type": "boolean"
8061
+ },
8062
+ "debug": {
8063
+ "char": "d",
8064
+ "description": "Activate debug mode (more logs)",
8065
+ "name": "debug",
8066
+ "allowNo": false,
8067
+ "type": "boolean"
8068
+ },
8069
+ "websocket": {
8070
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
8071
+ "name": "websocket",
8072
+ "hasDynamicHelp": false,
8073
+ "multiple": false,
8074
+ "type": "option"
8075
+ },
8076
+ "skipauth": {
8077
+ "description": "Skip authentication check when a default username is required",
8078
+ "name": "skipauth",
8079
+ "allowNo": false,
8080
+ "type": "boolean"
8081
+ },
8082
+ "target-org": {
8083
+ "aliases": [
8084
+ "targetusername",
8085
+ "u"
8086
+ ],
8087
+ "char": "o",
8088
+ "deprecateAliases": true,
8089
+ "name": "target-org",
8090
+ "noCacheDefault": true,
8091
+ "required": true,
8092
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
8093
+ "hasDynamicHelp": true,
8094
+ "multiple": false,
8095
+ "type": "option"
8096
+ }
8097
+ },
8098
+ "hasDynamicHelp": true,
8099
+ "hiddenAliases": [],
8100
+ "id": "hardis:org:purge:apexlog",
8101
+ "pluginAlias": "sfdx-hardis",
8102
+ "pluginName": "sfdx-hardis",
8103
+ "pluginType": "core",
8104
+ "strict": true,
8105
+ "enableJsonFlag": true,
8106
+ "title": "Purge Apex Logs",
8107
+ "requiresProject": false,
8108
+ "isESM": true,
8109
+ "relativePath": [
8110
+ "lib",
8111
+ "commands",
8112
+ "hardis",
8113
+ "org",
8114
+ "purge",
8115
+ "apexlog.js"
8116
+ ],
8117
+ "aliasPermutations": [],
8118
+ "permutations": [
8119
+ "hardis:org:purge:apexlog",
8120
+ "org:hardis:purge:apexlog",
8121
+ "org:purge:hardis:apexlog",
8122
+ "org:purge:apexlog:hardis",
8123
+ "hardis:purge:org:apexlog",
8124
+ "purge:hardis:org:apexlog",
8125
+ "purge:org:hardis:apexlog",
8126
+ "purge:org:apexlog:hardis",
8127
+ "hardis:purge:apexlog:org",
8128
+ "purge:hardis:apexlog:org",
8129
+ "purge:apexlog:hardis:org",
8130
+ "purge:apexlog:org:hardis",
8131
+ "hardis:org:apexlog:purge",
8132
+ "org:hardis:apexlog:purge",
8133
+ "org:apexlog:hardis:purge",
8134
+ "org:apexlog:purge:hardis",
8135
+ "hardis:apexlog:org:purge",
8136
+ "apexlog:hardis:org:purge",
8137
+ "apexlog:org:hardis:purge",
8138
+ "apexlog:org:purge:hardis",
8139
+ "hardis:apexlog:purge:org",
8140
+ "apexlog:hardis:purge:org",
8141
+ "apexlog:purge:hardis:org",
8142
+ "apexlog:purge:org:hardis"
8143
+ ]
8144
+ },
8145
+ "hardis:org:purge:flow": {
8146
+ "aliases": [],
8147
+ "args": {},
8148
+ "description": "\n**Purges old or unwanted Flow versions from a Salesforce org, with an option to delete related Flow Interviews.**\n\nThis command helps maintain a clean and performant Salesforce org by removing obsolete Flow versions. Over time, multiple versions of Flows can accumulate, consuming storage and potentially impacting performance. This tool provides a controlled way to clean up these versions.\n\nKey functionalities:\n\n- **Targeted Flow Selection:** Allows you to filter Flow versions to delete by name (`--name`) and status (`--status`, e.g., `Obsolete`, `Draft`, `Inactive`).\n- **Flow Interview Deletion:** If a Flow version cannot be deleted due to active Flow Interviews, the `--delete-flow-interviews` flag (or interactive prompt) allows you to delete these interviews first, then retry the Flow version deletion.\n- **Confirmation Prompt:** In interactive mode, it prompts for confirmation before proceeding with the deletion of Flow versions and Flow Interviews.\n- **Partial Success Handling:** The `--allowpurgefailure` flag (default `true`) allows the command to continue even if some deletions fail, reporting the errors.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **SOQL Queries (Tooling API):** It queries the `Flow` object (using the Tooling API) to list Flow versions based on the provided filters (name, status, manageable state).\n- **Bulk Deletion (Tooling API):** It uses `bulkDeleteTooling` to perform mass deletions of Flow versions. If deletion fails due to active interviews, it extracts the interview IDs.\n- **Flow Interview Management:** If `delete-flow-interviews` is enabled, it queries `FlowInterview` objects, performs bulk deletion of the identified interviews using `bulkDelete`, and then retries the Flow version deletion.\n- **Interactive Prompts:** Uses the `prompts` library to interact with the user for selecting Flows, statuses, and confirming deletion actions.\n- **Error Reporting:** Logs detailed error messages for failed deletions, including the specific reasons.\n- **Command-Line Execution:** Uses `execSfdxJson` to execute Salesforce CLI commands for querying Flow data.\n</details>\n",
8149
+ "examples": [
8150
+ "$ sf hardis:org:purge:flow",
8151
+ "$ sf hardis:org:purge:flow --target-org nicolas.vuillamy@gmail.com --no-prompt --delete-flow-interviews",
8152
+ "$ sf hardis:org:purge:flow --target-org nicolas.vuillamy@gmail.com --status \"Obsolete,Draft,InvalidDraft\" --name TestFlow"
8306
8153
  ],
8307
8154
  "flags": {
8308
8155
  "json": {
@@ -8320,6 +8167,52 @@
8320
8167
  "multiple": false,
8321
8168
  "type": "option"
8322
8169
  },
8170
+ "prompt": {
8171
+ "char": "z",
8172
+ "description": "Prompt for confirmation (true by default, use --no-prompt to skip)",
8173
+ "name": "prompt",
8174
+ "allowNo": true,
8175
+ "type": "boolean"
8176
+ },
8177
+ "name": {
8178
+ "char": "n",
8179
+ "description": "Filter according to Name criteria",
8180
+ "name": "name",
8181
+ "hasDynamicHelp": false,
8182
+ "multiple": false,
8183
+ "type": "option"
8184
+ },
8185
+ "status": {
8186
+ "char": "s",
8187
+ "description": "Filter according to Status criteria",
8188
+ "name": "status",
8189
+ "hasDynamicHelp": false,
8190
+ "multiple": false,
8191
+ "type": "option"
8192
+ },
8193
+ "delete-flow-interviews": {
8194
+ "char": "w",
8195
+ "description": "If the presence of Flow interviews prevent to delete flows versions, delete them before retrying to delete flow versions",
8196
+ "name": "delete-flow-interviews",
8197
+ "allowNo": false,
8198
+ "type": "boolean"
8199
+ },
8200
+ "allowpurgefailure": {
8201
+ "char": "f",
8202
+ "description": "Allows purges to fail without exiting with 1. Use --no-allowpurgefailure to disable",
8203
+ "name": "allowpurgefailure",
8204
+ "allowNo": true,
8205
+ "type": "boolean"
8206
+ },
8207
+ "instanceurl": {
8208
+ "char": "r",
8209
+ "description": "URL of org instance",
8210
+ "name": "instanceurl",
8211
+ "default": "https://login.salesforce.com",
8212
+ "hasDynamicHelp": false,
8213
+ "multiple": false,
8214
+ "type": "option"
8215
+ },
8323
8216
  "debug": {
8324
8217
  "char": "d",
8325
8218
  "description": "Activate debug mode (more logs)",
@@ -8358,13 +8251,13 @@
8358
8251
  },
8359
8252
  "hasDynamicHelp": true,
8360
8253
  "hiddenAliases": [],
8361
- "id": "hardis:org:retrieve:packageconfig",
8254
+ "id": "hardis:org:purge:flow",
8362
8255
  "pluginAlias": "sfdx-hardis",
8363
8256
  "pluginName": "sfdx-hardis",
8364
8257
  "pluginType": "core",
8365
8258
  "strict": true,
8366
8259
  "enableJsonFlag": true,
8367
- "title": "Retrieve package configuration from an org",
8260
+ "title": "Purge Flow versions",
8368
8261
  "requiresProject": false,
8369
8262
  "isESM": true,
8370
8263
  "relativePath": [
@@ -8372,43 +8265,44 @@
8372
8265
  "commands",
8373
8266
  "hardis",
8374
8267
  "org",
8375
- "retrieve",
8376
- "packageconfig.js"
8268
+ "purge",
8269
+ "flow.js"
8377
8270
  ],
8378
8271
  "aliasPermutations": [],
8379
8272
  "permutations": [
8380
- "hardis:org:retrieve:packageconfig",
8381
- "org:hardis:retrieve:packageconfig",
8382
- "org:retrieve:hardis:packageconfig",
8383
- "org:retrieve:packageconfig:hardis",
8384
- "hardis:retrieve:org:packageconfig",
8385
- "retrieve:hardis:org:packageconfig",
8386
- "retrieve:org:hardis:packageconfig",
8387
- "retrieve:org:packageconfig:hardis",
8388
- "hardis:retrieve:packageconfig:org",
8389
- "retrieve:hardis:packageconfig:org",
8390
- "retrieve:packageconfig:hardis:org",
8391
- "retrieve:packageconfig:org:hardis",
8392
- "hardis:org:packageconfig:retrieve",
8393
- "org:hardis:packageconfig:retrieve",
8394
- "org:packageconfig:hardis:retrieve",
8395
- "org:packageconfig:retrieve:hardis",
8396
- "hardis:packageconfig:org:retrieve",
8397
- "packageconfig:hardis:org:retrieve",
8398
- "packageconfig:org:hardis:retrieve",
8399
- "packageconfig:org:retrieve:hardis",
8400
- "hardis:packageconfig:retrieve:org",
8401
- "packageconfig:hardis:retrieve:org",
8402
- "packageconfig:retrieve:hardis:org",
8403
- "packageconfig:retrieve:org:hardis"
8273
+ "hardis:org:purge:flow",
8274
+ "org:hardis:purge:flow",
8275
+ "org:purge:hardis:flow",
8276
+ "org:purge:flow:hardis",
8277
+ "hardis:purge:org:flow",
8278
+ "purge:hardis:org:flow",
8279
+ "purge:org:hardis:flow",
8280
+ "purge:org:flow:hardis",
8281
+ "hardis:purge:flow:org",
8282
+ "purge:hardis:flow:org",
8283
+ "purge:flow:hardis:org",
8284
+ "purge:flow:org:hardis",
8285
+ "hardis:org:flow:purge",
8286
+ "org:hardis:flow:purge",
8287
+ "org:flow:hardis:purge",
8288
+ "org:flow:purge:hardis",
8289
+ "hardis:flow:org:purge",
8290
+ "flow:hardis:org:purge",
8291
+ "flow:org:hardis:purge",
8292
+ "flow:org:purge:hardis",
8293
+ "hardis:flow:purge:org",
8294
+ "flow:hardis:purge:org",
8295
+ "flow:purge:hardis:org",
8296
+ "flow:purge:org:hardis"
8404
8297
  ]
8405
8298
  },
8406
- "hardis:org:test:apex": {
8299
+ "hardis:org:retrieve:packageconfig": {
8407
8300
  "aliases": [],
8408
8301
  "args": {},
8409
- "description": "Run apex tests in Salesforce org\n\nIf following configuration is defined, it will fail if apex coverage target is not reached:\n\n- Env `APEX_TESTS_MIN_COVERAGE_ORG_WIDE` or `.sfdx-hardis` property `apexTestsMinCoverageOrgWide`\n- Env `APEX_TESTS_MIN_COVERAGE_ORG_WIDE` or `.sfdx-hardis` property `apexTestsMinCoverageOrgWide`\n\nYou can override env var SFDX_TEST_WAIT_MINUTES to wait more than 120 minutes.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-apex-tests/) and can output Grafana, Slack and MsTeams Notifications.\n",
8302
+ "description": "\n**Retrieves the installed package configuration from a Salesforce org and optionally updates the local project configuration.**\n\nThis command is useful for maintaining an accurate record of installed packages within your Salesforce project, which is crucial for managing dependencies and ensuring consistent deployments across environments.\n\nKey functionalities:\n\n- **Package Listing:** Connects to a specified Salesforce org (or prompts for one if not provided) and retrieves a list of all installed packages.\n- **Configuration Update:** Offers the option to update your local project's configuration with the retrieved list of installed packages. This can be beneficial for automating package installations during environment setup or CI/CD processes.\n\n<details markdown=\"1\">\n<summary>Technical explanations</summary>\n\nThe command's technical implementation involves:\n\n- **Org Connection:** It establishes a connection to the target Salesforce org using the provided or prompted username.\n- **Metadata Retrieval:** It utilizes `MetadataUtils.listInstalledPackages` to query the Salesforce org and obtain details about the installed packages.\n- **Interactive Prompt:** It uses the `prompts` library to ask the user whether they want to update their local project configuration with the retrieved package list.\n- **Configuration Management:** If the user confirms, it calls `managePackageConfig` to update the project's configuration file (likely `.sfdx-hardis.yml`) with the new package information.\n- **User Feedback:** Provides clear messages to the user about the success of the package retrieval and configuration update.\n</details>\n",
8410
8303
  "examples": [
8411
- "$ sf hardis:org:test:apex"
8304
+ "$ sf hardis:org:retrieve:packageconfig",
8305
+ "sf hardis:org:retrieve:packageconfig -u myOrg"
8412
8306
  ],
8413
8307
  "flags": {
8414
8308
  "json": {
@@ -8426,21 +8320,6 @@
8426
8320
  "multiple": false,
8427
8321
  "type": "option"
8428
8322
  },
8429
- "testlevel": {
8430
- "char": "l",
8431
- "description": "Level of tests to apply to validate deployment",
8432
- "name": "testlevel",
8433
- "default": "RunLocalTests",
8434
- "hasDynamicHelp": false,
8435
- "multiple": false,
8436
- "options": [
8437
- "NoTestRun",
8438
- "RunSpecifiedTests",
8439
- "RunLocalTests",
8440
- "RunAllTestsInOrg"
8441
- ],
8442
- "type": "option"
8443
- },
8444
8323
  "debug": {
8445
8324
  "char": "d",
8446
8325
  "description": "Activate debug mode (more logs)",
@@ -8479,48 +8358,49 @@
8479
8358
  },
8480
8359
  "hasDynamicHelp": true,
8481
8360
  "hiddenAliases": [],
8482
- "id": "hardis:org:test:apex",
8361
+ "id": "hardis:org:retrieve:packageconfig",
8483
8362
  "pluginAlias": "sfdx-hardis",
8484
8363
  "pluginName": "sfdx-hardis",
8485
8364
  "pluginType": "core",
8486
8365
  "strict": true,
8487
8366
  "enableJsonFlag": true,
8488
- "title": "Run apex tests",
8367
+ "title": "Retrieve package configuration from an org",
8368
+ "requiresProject": false,
8489
8369
  "isESM": true,
8490
8370
  "relativePath": [
8491
8371
  "lib",
8492
8372
  "commands",
8493
8373
  "hardis",
8494
8374
  "org",
8495
- "test",
8496
- "apex.js"
8375
+ "retrieve",
8376
+ "packageconfig.js"
8497
8377
  ],
8498
8378
  "aliasPermutations": [],
8499
8379
  "permutations": [
8500
- "hardis:org:test:apex",
8501
- "org:hardis:test:apex",
8502
- "org:test:hardis:apex",
8503
- "org:test:apex:hardis",
8504
- "hardis:test:org:apex",
8505
- "test:hardis:org:apex",
8506
- "test:org:hardis:apex",
8507
- "test:org:apex:hardis",
8508
- "hardis:test:apex:org",
8509
- "test:hardis:apex:org",
8510
- "test:apex:hardis:org",
8511
- "test:apex:org:hardis",
8512
- "hardis:org:apex:test",
8513
- "org:hardis:apex:test",
8514
- "org:apex:hardis:test",
8515
- "org:apex:test:hardis",
8516
- "hardis:apex:org:test",
8517
- "apex:hardis:org:test",
8518
- "apex:org:hardis:test",
8519
- "apex:org:test:hardis",
8520
- "hardis:apex:test:org",
8521
- "apex:hardis:test:org",
8522
- "apex:test:hardis:org",
8523
- "apex:test:org:hardis"
8380
+ "hardis:org:retrieve:packageconfig",
8381
+ "org:hardis:retrieve:packageconfig",
8382
+ "org:retrieve:hardis:packageconfig",
8383
+ "org:retrieve:packageconfig:hardis",
8384
+ "hardis:retrieve:org:packageconfig",
8385
+ "retrieve:hardis:org:packageconfig",
8386
+ "retrieve:org:hardis:packageconfig",
8387
+ "retrieve:org:packageconfig:hardis",
8388
+ "hardis:retrieve:packageconfig:org",
8389
+ "retrieve:hardis:packageconfig:org",
8390
+ "retrieve:packageconfig:hardis:org",
8391
+ "retrieve:packageconfig:org:hardis",
8392
+ "hardis:org:packageconfig:retrieve",
8393
+ "org:hardis:packageconfig:retrieve",
8394
+ "org:packageconfig:hardis:retrieve",
8395
+ "org:packageconfig:retrieve:hardis",
8396
+ "hardis:packageconfig:org:retrieve",
8397
+ "packageconfig:hardis:org:retrieve",
8398
+ "packageconfig:org:hardis:retrieve",
8399
+ "packageconfig:org:retrieve:hardis",
8400
+ "hardis:packageconfig:retrieve:org",
8401
+ "packageconfig:hardis:retrieve:org",
8402
+ "packageconfig:retrieve:hardis:org",
8403
+ "packageconfig:retrieve:org:hardis"
8524
8404
  ]
8525
8405
  },
8526
8406
  "hardis:org:user:activateinvalid": {
@@ -8923,6 +8803,126 @@
8923
8803
  "unfreeze:user:org:hardis"
8924
8804
  ]
8925
8805
  },
8806
+ "hardis:org:test:apex": {
8807
+ "aliases": [],
8808
+ "args": {},
8809
+ "description": "Run apex tests in Salesforce org\n\nIf following configuration is defined, it will fail if apex coverage target is not reached:\n\n- Env `APEX_TESTS_MIN_COVERAGE_ORG_WIDE` or `.sfdx-hardis` property `apexTestsMinCoverageOrgWide`\n- Env `APEX_TESTS_MIN_COVERAGE_ORG_WIDE` or `.sfdx-hardis` property `apexTestsMinCoverageOrgWide`\n\nYou can override env var SFDX_TEST_WAIT_MINUTES to wait more than 120 minutes.\n\nThis command is part of [sfdx-hardis Monitoring](https://sfdx-hardis.cloudity.com/salesforce-monitoring-apex-tests/) and can output Grafana, Slack and MsTeams Notifications.\n",
8810
+ "examples": [
8811
+ "$ sf hardis:org:test:apex"
8812
+ ],
8813
+ "flags": {
8814
+ "json": {
8815
+ "description": "Format output as json.",
8816
+ "helpGroup": "GLOBAL",
8817
+ "name": "json",
8818
+ "allowNo": false,
8819
+ "type": "boolean"
8820
+ },
8821
+ "flags-dir": {
8822
+ "helpGroup": "GLOBAL",
8823
+ "name": "flags-dir",
8824
+ "summary": "Import flag values from a directory.",
8825
+ "hasDynamicHelp": false,
8826
+ "multiple": false,
8827
+ "type": "option"
8828
+ },
8829
+ "testlevel": {
8830
+ "char": "l",
8831
+ "description": "Level of tests to apply to validate deployment",
8832
+ "name": "testlevel",
8833
+ "default": "RunLocalTests",
8834
+ "hasDynamicHelp": false,
8835
+ "multiple": false,
8836
+ "options": [
8837
+ "NoTestRun",
8838
+ "RunSpecifiedTests",
8839
+ "RunLocalTests",
8840
+ "RunAllTestsInOrg"
8841
+ ],
8842
+ "type": "option"
8843
+ },
8844
+ "debug": {
8845
+ "char": "d",
8846
+ "description": "Activate debug mode (more logs)",
8847
+ "name": "debug",
8848
+ "allowNo": false,
8849
+ "type": "boolean"
8850
+ },
8851
+ "websocket": {
8852
+ "description": "Websocket host:port for VsCode SFDX Hardis UI integration",
8853
+ "name": "websocket",
8854
+ "hasDynamicHelp": false,
8855
+ "multiple": false,
8856
+ "type": "option"
8857
+ },
8858
+ "skipauth": {
8859
+ "description": "Skip authentication check when a default username is required",
8860
+ "name": "skipauth",
8861
+ "allowNo": false,
8862
+ "type": "boolean"
8863
+ },
8864
+ "target-org": {
8865
+ "aliases": [
8866
+ "targetusername",
8867
+ "u"
8868
+ ],
8869
+ "char": "o",
8870
+ "deprecateAliases": true,
8871
+ "name": "target-org",
8872
+ "noCacheDefault": true,
8873
+ "required": true,
8874
+ "summary": "Username or alias of the target org. Not required if the `target-org` configuration variable is already set.",
8875
+ "hasDynamicHelp": true,
8876
+ "multiple": false,
8877
+ "type": "option"
8878
+ }
8879
+ },
8880
+ "hasDynamicHelp": true,
8881
+ "hiddenAliases": [],
8882
+ "id": "hardis:org:test:apex",
8883
+ "pluginAlias": "sfdx-hardis",
8884
+ "pluginName": "sfdx-hardis",
8885
+ "pluginType": "core",
8886
+ "strict": true,
8887
+ "enableJsonFlag": true,
8888
+ "title": "Run apex tests",
8889
+ "isESM": true,
8890
+ "relativePath": [
8891
+ "lib",
8892
+ "commands",
8893
+ "hardis",
8894
+ "org",
8895
+ "test",
8896
+ "apex.js"
8897
+ ],
8898
+ "aliasPermutations": [],
8899
+ "permutations": [
8900
+ "hardis:org:test:apex",
8901
+ "org:hardis:test:apex",
8902
+ "org:test:hardis:apex",
8903
+ "org:test:apex:hardis",
8904
+ "hardis:test:org:apex",
8905
+ "test:hardis:org:apex",
8906
+ "test:org:hardis:apex",
8907
+ "test:org:apex:hardis",
8908
+ "hardis:test:apex:org",
8909
+ "test:hardis:apex:org",
8910
+ "test:apex:hardis:org",
8911
+ "test:apex:org:hardis",
8912
+ "hardis:org:apex:test",
8913
+ "org:hardis:apex:test",
8914
+ "org:apex:hardis:test",
8915
+ "org:apex:test:hardis",
8916
+ "hardis:apex:org:test",
8917
+ "apex:hardis:org:test",
8918
+ "apex:org:hardis:test",
8919
+ "apex:org:test:hardis",
8920
+ "hardis:apex:test:org",
8921
+ "apex:hardis:test:org",
8922
+ "apex:test:hardis:org",
8923
+ "apex:test:org:hardis"
8924
+ ]
8925
+ },
8926
8926
  "hardis:package:version:create": {
8927
8927
  "aliases": [],
8928
8928
  "args": {},
@@ -15370,5 +15370,5 @@
15370
15370
  ]
15371
15371
  }
15372
15372
  },
15373
- "version": "6.9.1-alpha202510270024.0"
15373
+ "version": "6.9.1-alpha202510282151.0"
15374
15374
  }