diff --git a/openapi.yaml b/openapi.yaml index 5d63abf..86a8d64 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -692,6 +692,11 @@ paths: properties: default_project_story_privacy: $ref: '#/components/schemas/DefaultProjectStoryPrivacy' + participant_pass_sign_in_enabled: + type: boolean + description: >- + "Enable contacts to sign in using a participant pass". When false, a Contact's profile + hides the Participating As tab unless the Contact is already linked to a user. example: default_project_story_privacy: only_project_colleagues responses: @@ -4297,6 +4302,51 @@ paths: "401": $ref: '#/components/responses/Unauthorized' + /project_story_categories/{id}: + parameters: + - name: id + in: path + required: true + schema: {type: integer} + description: The Survey Campaign (Project Story Category) ID + patch: + tags: [Project Story Categories] + summary: Change a Survey Campaign's settings + description: | + Turns "Force colleagues to select an interval" on or off, as the Survey Campaign + Settings page does. When on and the Survey Campaign has intervals (Waves), every story, + survey invitation, shared link and automation for it must name an interval. Requires + Project Editor (Project Manager) or Organisation Editor (Organisation Admin) access. + operationId: updateProjectStoryCategory + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + type: object + required: [force_interval] + properties: + force_interval: {type: boolean} + example: {force_interval: true} + responses: + "200": + description: The updated Survey Campaign + content: + application/json: + schema: {$ref: '#/components/schemas/ProjectStoryCategory'} + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: The user may not change this Survey Campaign + content: + application/json: + schema: {$ref: '#/components/schemas/Error'} + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /project_story_categories/{id}/survey_links: parameters: - name: id @@ -4344,7 +4394,9 @@ paths: description: Email addresses, matched to or creating Contacts. No email is sent. send_survey_wave_id: type: integer - description: Optional Wave, from GET /project_story_categories/{id}/survey_waves + description: >- + Wave, from GET /project_story_categories/{id}/survey_waves. Required when the + Survey Campaign's force_interval is true and it has Waves; otherwise optional. link_expiry: type: string enum: [use_once, evergreen] @@ -9868,9 +9920,11 @@ paths: choice for it, e.g. "Any relationship" (`criteria: {any: true}`). Criteria values are strings: IDs, or pairs such as `project_states` ":", `project_event_categories` ":", `relationship_sides` - ":parent|child", and `survey_waves` ":". The "for a relative" types take `relatives: [{relationship_side, - beneficiary_category_ids | survey_waves}]`. + ":parent|child", and `survey_waves`, one of: ":" (that Survey Campaign in its Project); "survey:" (a survey made with that Survey in any Project); or "shared::" (a survey tagged to that Shared Wave (Shared Interval) of the Survey, in any Project). The "for a + relative" types take `relatives: [{relationship_side, beneficiary_category_ids | survey_waves}]`. operationId: listChecklistActionTypes security: [{tokenAuth: []}] responses: @@ -10161,6 +10215,75 @@ paths: "404": description: The Checklist or Project wasn't found, or the user can't edit the Project + /checklists/{id}/summary: + get: + tags: [Checklists] + operationId: getChecklistSummary + summary: Checklist Summary across the projects you oversee + description: > + The Checklist Summary (the Summary tab of the Focus page) for one Checklist: one row for each + project (Workspace) you oversee that uses the Checklist, with its Project Managers ("Managed by"), + its other Workspace colleagues (reporters and observers), and for each step of the Checklist how + many of the project's contacts with the Checklist have done that step, as a count and a percentage. + Only Organisation Admins (every open project of their organisation), Team Leaders (open projects + where someone in a Team they lead is a colleague) and Album Editors (open projects in organisation + Albums they edit) may call it; anyone else gets 403. A Checklist that none of your projects uses + returns 404. Only contacts you may see, that aren't deleted and are still active in the project, + are counted. Rows are sorted before pagination; the sort is not remembered. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + description: Checklist id + schema: {type: integer} + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + - name: sort + in: query + description: "project (default), managed_by, colleagues, or step_ (1 = first step)" + schema: {type: string, example: step_1} + - name: direction + in: query + schema: {type: string, enum: [asc, desc], default: asc} + responses: + "200": + description: One page of projects + content: + application/json: + example: + checklist_id: 12 + checklist_name: Intake + sort: project + direction: asc + steps: + - {id: 31, number: 1, action_type: create_task, title: Consent form} + - {id: 32, number: 2, action_type: add_role, title: Enrol} + page: 1 + page_size: 1 + page_count: 1 + total_count: 1 + data: + - project_id: 7 + project_name: Youth Club + managed_by: [Ama Ng] + workspace_colleagues: [Obi Eze] + contacts_count: 2 + steps: + - {action_id: 31, number: 1, done_count: 1, percent: 50} + - {action_id: 32, number: 2, done_count: 0, percent: 0} + "401": + $ref: '#/components/responses/Unauthorized' + "403": + description: Not an Organisation Admin, Team Leader or Album Editor + content: + application/json: + example: {error: forbidden} + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /checklists/{id}/progress: get: tags: [Checklists] @@ -10229,8 +10352,6 @@ paths: $ref: '#/components/responses/NotFound' "422": $ref: '#/components/responses/UnprocessableEntity' - "422": - $ref: '#/components/responses/UnprocessableEntity' /checklists/{id}/progress/contacts: get: @@ -17663,6 +17784,12 @@ components: example: "Greenfield Community Trust" default_project_story_privacy: $ref: '#/components/schemas/DefaultProjectStoryPrivacy' + participant_pass_sign_in_enabled: + type: boolean + description: >- + "Enable contacts to sign in using a participant pass" (Charity Preferences, Contacts). Off + by default. + example: false DefaultProjectStoryPrivacy: type: string @@ -19306,6 +19433,14 @@ components: type: boolean display_respondent_name: type: boolean + force_interval: + type: boolean + description: >- + "Force colleagues to select an interval". When true and the Survey Campaign has + intervals (Waves), colleagues must choose one when they add a story, send the survey, + share its link or set up an automation that sends it, and POST + /project_story_categories/{id}/survey_links requires send_survey_wave_id. + On by default for new Survey Campaigns. StoryCategoryResponse: allOf: diff --git a/server.js b/server.js index aa9fe3b..be288cd 100644 --- a/server.js +++ b/server.js @@ -1176,19 +1176,20 @@ function buildDocsPage() { ${endpointCard("GET", "/charities/{id}", "Get a single Organisation", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Organisation ID" } ], [ - { code: "200", cls: "response-2xx", desc: "Charity record with id, name, timestamps and default_project_story_privacy: the Story Privacy Level each new project in the Organisation starts with" }, + { code: "200", cls: "response-2xx", desc: "Charity record with id, name, timestamps, default_project_story_privacy: the Story Privacy Level each new project in the Organisation starts with, and participant_pass_sign_in_enabled" }, { code: "401", cls: "response-4xx", desc: "Not authenticated" }, { code: "404", cls: "response-4xx", desc: "Not found" } ])} ${endpointCard("PATCH", "/charities/{id}", "Change an Organisation's settings", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Organisation ID" }, - { name: "default_project_story_privacy", in: "body", type: "string", required: false, desc: "Default story level privacy setting on each project: the Story Privacy Level each new project starts with. One of only_project_colleagues (Project colleagues only), only_charity_colleagues (Organisation colleagues only), charity_plus_network (Network & organisation colleagues only) or everyone. Existing projects keep their own level." } + { name: "default_project_story_privacy", in: "body", type: "string", required: false, desc: "Default story level privacy setting on each project: the Story Privacy Level each new project starts with. One of only_project_colleagues (Project colleagues only), only_charity_colleagues (Organisation colleagues only), charity_plus_network (Network & organisation colleagues only) or everyone. Existing projects keep their own level." }, + { name: "participant_pass_sign_in_enabled", in: "body", type: "boolean", required: false, desc: "Enable contacts to sign in using a participant pass. When false, a Contact's profile hides the Participating As tab unless the Contact is already linked to a user." } ], [ { code: "200", cls: "response-2xx", desc: "The Organisation, with the setting changed" }, { code: "401", cls: "response-4xx", desc: "Not authenticated" }, { code: "403", cls: "response-4xx", desc: "Not an Organisation Admin of this Organisation" }, { code: "404", cls: "response-4xx", desc: "Not found, or not one of your Organisations" }, - { code: "422", cls: "response-4xx", desc: "default_project_story_privacy isn't one of the four levels" } + { code: "422", cls: "response-4xx", desc: "default_project_story_privacy isn't one of the four levels, or participant_pass_sign_in_enabled isn't true or false" } ], "Only an Organisation Admin can change these settings, the same people who can use Charity Preferences. Only the settings sent are changed.")} @@ -1938,6 +1939,15 @@ function buildDocsPage() { { name: "page", type: "integer", required: false, desc: "Page number" }, { name: "per_page", type: "integer", required: false, desc: "Records per page" } ], [{ code: "200", cls: "response-2xx", desc: "Surveys deployed to specific Projects" }])} + ${endpointCard("PATCH", "/project_story_categories/{id}", "Change a Survey Campaign's settings", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Survey Campaign (Project Story Category) ID" }, + { name: "force_interval", in: "body", type: "boolean", required: true, desc: "\"Force colleagues to select an interval\": when true and the campaign has Waves, every story, survey invitation, shared link and automation for it must name an interval" } + ], [ + { code: "200", cls: "response-2xx", desc: "The updated Survey Campaign, with force_interval" }, + { code: "403", cls: "response-4xx", desc: "Not a Project Editor or Organisation Editor" }, + { code: "404", cls: "response-4xx", desc: "Survey Campaign not found, or another organisation's" }, + { code: "422", cls: "response-4xx", desc: "force_interval missing or not true/false" } + ], "New Survey Campaigns have force_interval: true; existing ones were left at false.")} ${endpointCard("GET", "/project_story_categories/{id}/survey_waves", "List the Waves of a Survey Campaign", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Survey Campaign (Project Story Category) ID" }, { name: "page", type: "integer", required: false, desc: "Page number" }, @@ -1950,14 +1960,14 @@ function buildDocsPage() { { name: "id", in: "path", type: "integer", required: true, desc: "Survey Campaign (Project Story Category) ID" }, { name: "beneficiary_ids", in: "body", type: "integer[]", required: false, desc: "Contacts in the Survey Campaign's Project" }, { name: "emails", in: "body", type: "string[]", required: false, desc: "Email addresses, matched to an existing Contact of the organisation or creating one. No email is sent." }, - { name: "send_survey_wave_id", in: "body", type: "integer", required: false, desc: "Wave, from the Waves endpoint" }, + { name: "send_survey_wave_id", in: "body", type: "integer", required: false, desc: "Wave, from the Waves endpoint. Required when the Survey Campaign's force_interval is true and it has Waves" }, { name: "link_expiry", in: "body", type: "string", required: false, desc: "use_once (default) or evergreen" }, { name: "is_anonymised", in: "body", type: "boolean", required: false, desc: "Default false" } ], [ { code: "201", cls: "response-2xx", desc: "send_survey_id and data: one link per Contact with survey_url, survey_token, link_expiry, expired" }, { code: "403", cls: "response-4xx", desc: "Not a Project Editor or Organisation Editor" }, { code: "404", cls: "response-4xx", desc: "Survey Campaign not found" }, - { code: "422", cls: "response-4xx", desc: "Contacts outside the Project (invalid_beneficiary_ids, split into beneficiary_ids_not_in_project: in the organisation but not the Project, add them with POST /project_beneficiaries first; and beneficiary_ids_not_found: not Contacts of the organisation), over 200 recipients, no recipients, or an unavailable Wave" } + { code: "422", cls: "response-4xx", desc: "Contacts outside the Project (invalid_beneficiary_ids, split into beneficiary_ids_not_in_project: in the organisation but not the Project, add them with POST /project_beneficiaries first; and beneficiary_ids_not_found: not Contacts of the organisation), over 200 recipients, no recipients, an unavailable Wave, or no Wave when the Survey Campaign forces one (errors: [\"Select an interval for this survey.\"])" } ], "Generates the same personal links as the Send Survey page, but sends nothing: share the returned survey_url yourself. At most 200 contacts and email addresses per request. A use_once link stops working after one response; an evergreen link stays active.")} ${endpointCard("GET", "/project_story_categories/{id}/survey_links", "List personal survey links", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "Survey Campaign (Project Story Category) ID" }, @@ -2804,7 +2814,7 @@ function buildDocsPage() { ])} ${endpointCard("GET", "/checklists/action_types", "List the actions a Checklist can contain", true, [], [ { code: "200", cls: "response-2xx", desc: "{data: [{action_type, name, criteria_keys, any_name, project_scopable}]}; any_name names the \"Any\" choice, e.g. \"Any relationship\" (criteria: {any: true}); project_scopable types can take only_this_project" } - ], "Criteria values are strings: IDs, or pairs such as project_states \"<project_id>:<state_id>\", project_event_categories \"<project_id>:<event_category_id>\", relationship_sides \"<category_id>:parent|child\" and survey_waves \"<Survey Campaign id>:<Wave id, or 0>\".")} + ], "Criteria values are strings: IDs, or pairs such as project_states \"<project_id>:<state_id>\", project_event_categories \"<project_id>:<event_category_id>\", relationship_sides \"<category_id>:parent|child\" and survey_waves: \"<Survey Campaign id>:<Wave id, or 0>\" for that Survey Campaign, \"survey:<Survey id>\" for that Survey in any Project, or \"shared:<Survey id>:<Shared Wave id>\" for that Shared Interval of the Survey in any Project.")} ${endpointCard("GET", "/checklists/owner_options", "List the choices for who is responsible for an action", true, [ { name: "charity_id", type: "integer", required: true, desc: "The Organisation ID" } ], [ @@ -2825,6 +2835,18 @@ function buildDocsPage() { { code: "200", cls: "response-2xx", desc: "The Checklist with stages (id, name, icon, position, colour), actions (each with stage_id, due_within_days, video_url, its owner fields and owner_description; action_name is \"Not set yet\" while no type is chosen), projects and contacts_count" }, { code: "404", cls: "response-4xx", desc: "Not found, or another Organisation's" } ])} + ${endpointCard("GET", "/checklists/{id}/summary", "Get a Checklist Summary across the projects you oversee", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "Checklist ID" }, + { name: "page", type: "integer", required: false, desc: "Page number" }, + { name: "per_page", type: "integer", required: false, desc: "Projects per page (default 10, max 200)" }, + { name: "sort", type: "string", required: false, desc: "project (default), managed_by, colleagues or step_<number>" }, + { name: "direction", type: "string", required: false, desc: "asc (default) or desc" } + ], [ + { code: "200", cls: "response-2xx", desc: "{checklist_id, checklist_name, sort, direction, steps: [{id, number, action_type, title}], page, page_size, page_count, total_count, data: [{project_id, project_name, managed_by, workspace_colleagues, contacts_count, steps: [{action_id, number, done_count, percent}]}]}" }, + { code: "403", cls: "response-4xx", desc: "Not an Organisation Admin, Team Leader or Album Editor" }, + { code: "404", cls: "response-4xx", desc: "None of your projects uses this Checklist" }, + { code: "422", cls: "response-4xx", desc: "An unknown sort or direction" } + ], "The Summary tab of the Focus page: a row per project (Workspace) you oversee that uses the Checklist, with its Project Managers (\"Managed by\"), its reporters and observers (\"Workspace colleagues\"), and for each step how many of the project's contacts with the Checklist have done it. Only contacts you may see, not deleted and still active in the project, are counted.")} ${endpointCard("POST", "/checklists", "Create a Checklist", true, [], [ { code: "201", cls: "response-2xx", desc: "The new Checklist" }, { code: "403", cls: "response-4xx", desc: "Not an editor or reporter of the Organisation" },