From c1b48fe4c52243024734fce06d65fd0a82ec30fd Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Fri, 1 May 2026 11:53:22 -0500 Subject: [PATCH 1/2] feat(#10341): remove `chtPermissionsSettings` param from permission check functions --- content/en/building/reference/_partial_cht_api.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/content/en/building/reference/_partial_cht_api.md b/content/en/building/reference/_partial_cht_api.md index 5cd1e2114..4f00b507a 100644 --- a/content/en/building/reference/_partial_cht_api.md +++ b/content/en/building/reference/_partial_cht_api.md @@ -12,12 +12,12 @@ Introduced in v3.12.0 Provides CHT Core Framework's functions to contact summary, targets and tasks. The API is available in the `cht` reserved variable under the `v1` version. -| Function | Arguments | Description | -| -------- | --------- |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| hasPermissions(permissions, userRoles, chtPermissionsSettings) | `permissions`: String or array of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user.
`chtPermissionsSettings`: (Optional) Object of configured permissions in CHT-Core's settings. Default to the current instance's configured permissions. | Returns true if the user has the permission(s), otherwise returns false. | -| hasAnyPermission(permissionsGroups, userRoles, chtPermissionsSettings) | `permissionsGroups`: Array of groups of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user.
`chtPermissionsSettings`: (Optional) Object of configured permissions in CHT-Core's settings. Default to the current instance's configured permissions. | Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. | -| getExtensionLib(name) | `name`: String of script name | Returns an executable function identified by the given name configured as [extension-libs](/building/reference/extension-libs). -| analytics.getTargetDocs() | | Returns three [target](/technical-overview/data/db-schema#targets) documents of the contact, calculated for the last three reporting intervals, including the current one. When viewing one of the current logged in user's associated facilities, returns the target documents for the contact associated with the current logged in user. Returns an empty array if no target documents are found (for example when viewing a contact that does not upload targets). _Introduced in v4.11.0_ | +| Function | Arguments | Description | +|------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| hasPermissions(permissions, userRoles) | `permissions`: String or array of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user. | Returns true if the user has the permission(s), otherwise returns false. | +| hasAnyPermission(permissionsGroups, userRoles) | `permissionsGroups`: Array of groups of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user.
| Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. | +| getExtensionLib(name) | `name`: String of script name | Returns an executable function identified by the given name configured as [extension-libs](/building/reference/extension-libs). | +| analytics.getTargetDocs() | | Returns three [target](/technical-overview/data/db-schema#targets) documents of the contact, calculated for the last three reporting intervals, including the current one. When viewing one of the current logged in user's associated facilities, returns the target documents for the contact associated with the current logged in user. Returns an empty array if no target documents are found (for example when viewing a contact that does not upload targets). _Introduced in v4.11.0_ | ### CHT API's code samples From d6aa6a8745c43c027b92284e6c280e565806d268 Mon Sep 17 00:00:00 2001 From: Joshua Kuestersteffen Date: Mon, 11 May 2026 14:55:57 -0500 Subject: [PATCH 2/2] Add dedicated CHT API docs for purging --- content/en/building/reference/_partial_cht_api.md | 12 ++++++------ .../data/performance/purging.md | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/content/en/building/reference/_partial_cht_api.md b/content/en/building/reference/_partial_cht_api.md index 4f00b507a..c41fcfc2b 100644 --- a/content/en/building/reference/_partial_cht_api.md +++ b/content/en/building/reference/_partial_cht_api.md @@ -12,12 +12,12 @@ Introduced in v3.12.0 Provides CHT Core Framework's functions to contact summary, targets and tasks. The API is available in the `cht` reserved variable under the `v1` version. -| Function | Arguments | Description | -|------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| hasPermissions(permissions, userRoles) | `permissions`: String or array of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user. | Returns true if the user has the permission(s), otherwise returns false. | -| hasAnyPermission(permissionsGroups, userRoles) | `permissionsGroups`: Array of groups of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user.
| Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. | -| getExtensionLib(name) | `name`: String of script name | Returns an executable function identified by the given name configured as [extension-libs](/building/reference/extension-libs). | -| analytics.getTargetDocs() | | Returns three [target](/technical-overview/data/db-schema#targets) documents of the contact, calculated for the last three reporting intervals, including the current one. When viewing one of the current logged in user's associated facilities, returns the target documents for the contact associated with the current logged in user. Returns an empty array if no target documents are found (for example when viewing a contact that does not upload targets). _Introduced in v4.11.0_ | +| Function | Arguments | Description | +|------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| hasPermissions(permissions, userRoles) | `permissions`: String or array of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user. | Returns true if the user has the permission(s), otherwise returns false. | +| hasAnyPermission(permissionsGroups, userRoles) | `permissionsGroups`: Array of groups of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user. | Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. | +| getExtensionLib(name) | `name`: String of script name | Returns an executable function identified by the given name configured as [extension-libs](/building/reference/extension-libs). | +| analytics.getTargetDocs() | | Returns three [target](/technical-overview/data/db-schema#targets) documents of the contact, calculated for the last three reporting intervals, including the current one. When viewing one of the current logged in user's associated facilities, returns the target documents for the contact associated with the current logged in user. Returns an empty array if no target documents are found (for example when viewing a contact that does not upload targets). _Introduced in v4.11.0_ | ### CHT API's code samples diff --git a/content/en/technical-overview/data/performance/purging.md b/content/en/technical-overview/data/performance/purging.md index 51b906423..3c404380d 100644 --- a/content/en/technical-overview/data/performance/purging.md +++ b/content/en/technical-overview/data/performance/purging.md @@ -115,7 +115,7 @@ This function takes six parameters: - `contact`, the contact document of a patient or other contact who has reports about them. - `reports`, an array of all reports for that subject that are present on the server. - `messages`, an array of sms messages that the contact has sent or received. -- `chtScriptApi` (Optional) the CHT API that provides CHT-Core Framework's functions to other parts of the app. More info on the API can be found [here](/building/reference/_partial_cht_api). Added in 4.3.0. +- `chtScriptApi` (Optional) the CHT API that provides CHT-Core Framework's functions to other parts of the app. More info on the API can be found [below](#cht-api). Added in 4.3.0. - `permissions` (Optional) string or array of permissions that the user has. More info on permissions can be found [here](/building/reference/app-settings/user-permissions). Added in 4.3.0. And should return an array of `_id` values for docs you would like to be purged (or `undefined` / nothing if you don't wish to purge anything). `Only ids of docs that were passed to the function are valid for purging: you are not allowed to purge other documents. @@ -125,6 +125,19 @@ In the cases of reports that do not have subjects or their subjects are not foun As of **3.9.0**, `task` documents that are in a terminal state (`Cancelled`, `Completed`, `Failed`) are purged if their `end_date` is more than 60 days ago (relative to server date). As of **3.9.0**, `target` documents are purged if their reporting period is more than 6 months ago (relative to server date). Purging `task` and `target` documents happens automatically on every purge run. The intervals and required states are not configurable. +#### CHT API + +{{< callout type="info" >}} +This API for the purge configuration includes a _subset_ of the functions available in the [CHT API for the webapp](/building/reference/_partial_cht_api/) (used by client-side configurations such as contact-summary or tasks). +{{< /callout >}} + +Provides functions for checking permissions for the user in context. The API is available in the `cht` reserved variable under the `v1` version. + +| Function | Arguments | Description | +|------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------| +| hasPermissions(permissions, userRoles) | `permissions`: String or array of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user.
`chtPermissionsSettings`: (Optional as of `5.2.0`) Object of configured permissions in CHT-Core's settings. Default is the current instance's configured permissions. | Returns true if the user has the permission(s), otherwise returns false. | +| hasAnyPermission(permissionsGroups, userRoles) | `permissionsGroups`: Array of groups of permission name(s).
`userRoles`: (Optional) Array of user roles. Default to the current logged in user.
`chtPermissionsSettings`: (Optional as of `5.2.0`) Object of configured permissions in CHT-Core's settings. Default is the current instance's configured permissions. | Returns true if the user has all the permissions of any of the provided groups, otherwise returns false. | + ### Schedule configuration You must set a schedule for purging to run server-side.