diff --git a/openapi.yaml b/openapi.yaml index 4a2da86..e62865e 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -13298,6 +13298,269 @@ paths: $ref: '#/components/responses/NotFound' "422": $ref: '#/components/responses/UnprocessableEntity' + /requirement_sets: + get: + tags: [Reports] + summary: List an organisation's Requirement Sets + operationId: listRequirementSets + description: | + A Requirement Set holds a funder's reporting requirements for a programme (one or more + albums and/or projects), and the metrics that answer each. Each Requirement is one thing + the funder asks for, e.g. "KPI 3: number of young people completing the programme"; one + with no metrics linked is "Not covered". Requires someone who can see Report Templates in + the organisation; another organisation is a 404. + security: [{tokenAuth: []}] + parameters: + - name: charity_id + in: query + required: true + schema: + type: integer + example: 42 + description: The organisation + - name: recipient + in: query + required: false + schema: + type: string + example: Comic Relief + description: Only sets for this recipient, whatever its case and surrounding spaces + - name: project_id + in: query + required: false + schema: + type: integer + description: Only sets covering this project, directly or through an album holding it + - name: album_id + in: query + required: false + schema: + type: integer + description: Only sets covering this album + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + - $ref: '#/components/parameters/LastSyncDatetime' + responses: + "200": + description: The organisation's Requirement Sets + content: + application/json: + schema: + $ref: '#/components/schemas/PaginatedRequirementSets' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + post: + tags: [Reports] + summary: Create a Requirement Set + operationId: createRequirementSet + description: | + Creates a Requirement Set, as **Add reporting requirements** does. The scope is + `project_ids` and/or `album_ids` (at least one), all the organisation's and ones you can + view. `requirements` are saved in the order given. Each requirement's `metrics` are + `{type, id}` with type `Change`, `Indicator`, `CohortTracker`, `WorkflowTracker`, + `FormulaTracker` or `FilteredMetric`, all the organisation's. `answer_shape` is one of + `count`, `sum`, `average`, `ratio`, `share_meeting_threshold`, `change_over_time`, + `breakdown` or `quote`. Errors name the requirement, e.g. + `KPI 2: Answer shape is not included in the list`. + security: [{tokenAuth: []}] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RequirementSetInput' + example: + charity_id: 42 + name: Comic Relief 2027 grant + recipient: Comic Relief + source_name: Grant agreement + source_url: https://example.org/grant-agreement.pdf + album_ids: [15] + requirements: + - reference: KPI 1 + wording: Number of young people completing the programme + answer_shape: count + answer_format: makerble_data + answer_preset: target_vs_actual + metrics: + - type: CohortTracker + id: 4 + - reference: KPI 2 + wording: A story of change from a young person + answer_shape: quote + answer_format: narrative + word_limit: 250 + responses: + "201": + description: The new Requirement Set + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/RequirementSet' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/Forbidden' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /requirement_sets/{id}: + get: + tags: [Reports] + summary: Get a Requirement Set + operationId: getRequirementSet + description: One Requirement Set with its requirements in order and the metrics answering each. A set you can't see is a 404. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + schema: + type: integer + example: 9 + responses: + "200": + description: The Requirement Set + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/RequirementSet' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + patch: + tags: [Reports] + summary: Change a Requirement Set + operationId: updateRequirementSet + description: | + Changes a Requirement Set. Fields left out stay as they are. Giving `project_ids` or + `album_ids` replaces the whole scope. `requirements`, when given, is the full list in order: + give an existing requirement's `id` to keep and change it; any left out are removed. A + requirement's `metrics`, when given, replaces its links. Requires the set's creator or an + Organisation Admin; otherwise 403. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + schema: + type: integer + example: 9 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RequirementSetInput' + example: + requirements: + - id: 31 + reference: KPI 1 + wording: Number of young people completing the programme + metrics: + - type: CohortTracker + id: 4 + - type: FilteredMetric + id: 12 + responses: + "200": + description: The changed Requirement Set + content: + application/json: + schema: + type: object + properties: + data: + $ref: '#/components/schemas/RequirementSet' + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/Forbidden' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + delete: + tags: [Reports] + summary: Delete a Requirement Set + operationId: deleteRequirementSet + description: Deletes a Requirement Set with its requirements and metric links. Requires the set's creator or an Organisation Admin; otherwise 403. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + schema: + type: integer + example: 9 + responses: + "204": + description: Deleted + "401": + $ref: '#/components/responses/Unauthorized' + "403": + $ref: '#/components/responses/Forbidden' + "404": + $ref: '#/components/responses/NotFound' + /reports/{report_id}/requirements: + get: + tags: [Reports] + summary: Get the reporting requirements for a Report + operationId: getReportRequirements + description: | + The Requirement Sets that apply to a Report: sets for the Report's recipient (whatever its + case and spacing) whose albums and projects overlap the Report's. `match` says how they were + chosen: `exact` (a set scoped to exactly the Report's albums and projects), `narrowest` (the + narrowest set containing all of them), `candidates` (sets that only partly overlap, offered + rather than chosen) or `none`. `conflicting` is true when two or more sets qualify equally; + all are returned, and none is picked. A Report you can't see is a 404. + security: [{tokenAuth: []}] + parameters: + - name: report_id + in: path + required: true + schema: + type: integer + example: 120 + responses: + "200": + description: The Requirement Sets for the Report + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + recipient: + type: string + nullable: true + match: + type: string + enum: [exact, narrowest, candidates, none] + conflicting: + type: boolean + requirement_sets: + type: array + items: + $ref: '#/components/schemas/RequirementSet' + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' /reports/{report_id}/contents: get: tags: [Reports] @@ -26730,6 +26993,166 @@ components: type: array items: $ref: '#/components/schemas/ReportTemplate' + RequirementSet: + type: object + description: A funder's reporting requirements for a programme, and the metrics that answer each + properties: + id: + type: integer + charity_id: + type: integer + name: + type: string + recipient: + type: string + description: Who the requirements are for, e.g. Comic Relief + source_name: + type: string + nullable: true + source_url: + type: string + nullable: true + description: Link to the original + reporting_cycle_id: + type: integer + nullable: true + project_ids: + type: array + items: + type: integer + album_ids: + type: array + items: + type: integer + requirements_count: + type: integer + covered_count: + type: integer + description: Requirements with at least one metric linked + updated_at: + type: string + format: date-time + requirements: + type: array + items: + $ref: '#/components/schemas/Requirement' + Requirement: + type: object + properties: + id: + type: integer + position: + type: integer + reference: + type: string + nullable: true + example: KPI 3 + wording: + type: string + answer_shape: + type: string + nullable: true + enum: [count, sum, average, ratio, share_meeting_threshold, change_over_time, breakdown, quote, null] + answer_format: + type: string + nullable: true + enum: [narrative, number, table, makerble_data, null] + answer_preset: + type: string + nullable: true + description: The Makerble data preset, for makerble_data + recommended_source: + type: object + description: e.g. {"kind":"preset","preset":"target_vs_actual"} or {"kind":"tool","tool":"GetSessionsAndAttendance"} + word_limit: + type: integer + nullable: true + covered: + type: boolean + description: false means Not covered + metrics: + type: array + items: + type: object + properties: + type: + type: string + enum: [Change, Indicator, CohortTracker, WorkflowTracker, FormulaTracker, FilteredMetric] + id: + type: integer + name: + type: string + RequirementSetInput: + type: object + properties: + charity_id: + type: integer + description: The organisation, when creating + name: + type: string + recipient: + type: string + source_name: + type: string + source_url: + type: string + reporting_cycle_id: + type: integer + project_ids: + type: array + items: + type: integer + album_ids: + type: array + items: + type: integer + requirements: + type: array + items: + type: object + required: [wording] + properties: + id: + type: integer + reference: + type: string + wording: + type: string + answer_shape: + type: string + answer_format: + type: string + answer_preset: + type: string + recommended_source: + type: object + word_limit: + type: integer + metrics: + type: array + items: + type: object + required: [type, id] + properties: + type: + type: string + id: + type: integer + PaginatedRequirementSets: + type: object + properties: + page: + type: integer + page_size: + type: integer + page_count: + type: integer + total_count: + type: integer + data: + type: array + items: + $ref: '#/components/schemas/RequirementSet' ReportContent: type: object description: A Report's answer to one question of its Report Template diff --git a/server.js b/server.js index c35e6ac..426ca75 100644 --- a/server.js +++ b/server.js @@ -954,6 +954,7 @@ function buildDocsPage() { GETLibrary GETExplore Surveys GETReport Templates + GETRequirement Sets GETReport answers GETExplore Report Templates GETExplore Forms @@ -3314,6 +3315,73 @@ function buildDocsPage() { + +
+
Reporting
+

Requirement Sets

+
+

A Requirement Set holds a funder's reporting requirements for a programme: one recipient (e.g. Comic Relief) and one or more albums and/or projects. Each Requirement is one thing the funder asks for, e.g. "KPI 3: number of young people completing the programme", linked to the metrics (trackers) that answer it. A Requirement with no metrics is Not covered.

+

A metric is {type, id} with type Change, Indicator, CohortTracker, WorkflowTracker, FormulaTracker or FilteredMetric. answer_shape is one of count, sum, average, ratio, share_meeting_threshold, change_over_time, breakdown or quote.

+
+
+ ${endpointCard("GET", "/requirement_sets", "List an organisation's Requirement Sets", true, [ + { name: "charity_id", type: "integer", required: true, desc: "The organisation" }, + { name: "recipient", type: "string", required: false, desc: "Only sets for this recipient, whatever its case and spacing" }, + { name: "project_id", type: "integer", required: false, desc: "Only sets covering this project, directly or through an album" }, + { name: "album_id", type: "integer", required: false, desc: "Only sets covering this album" }, + { name: "page", type: "integer", required: false, desc: "Page number" }, + { name: "per_page", type: "integer", required: false, desc: "Sets per page (default 10, max 200)" }, + { name: "last_synced_datetime", type: "string", required: false, desc: "ISO 8601 — only sets updated after this" } + ], [ + { code: "200", cls: "response-2xx", desc: "Each set's id, name, recipient, source_name, source_url, reporting_cycle_id, project_ids, album_ids, requirements_count, covered_count and requirements (id, reference, wording, answer_shape, answer_format, answer_preset, recommended_source, word_limit, covered, metrics)" }, + { code: "404", cls: "response-4xx", desc: "An organisation you can't see Report Templates in" }, + { code: "422", cls: "response-4xx", desc: "No charity_id" } + ])} + ${endpointCard("GET", "/requirement_sets/{id}", "Get a Requirement Set", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Requirement Set" } + ], [ + { code: "200", cls: "response-2xx", desc: "The set as above, in data" }, + { code: "404", cls: "response-4xx", desc: "Not found, or one you can't see" } + ])} + ${endpointCard("POST", "/requirement_sets", "Create a Requirement Set", true, [ + { name: "charity_id", in: "body", type: "integer", required: true, desc: "The organisation" }, + { name: "name", in: "body", type: "string", required: true, desc: "e.g. Comic Relief 2027 grant" }, + { name: "recipient", in: "body", type: "string", required: true, desc: "Who the requirements are for" }, + { name: "source_name", in: "body", type: "string", required: false, desc: "The document they came from" }, + { name: "source_url", in: "body", type: "string", required: false, desc: "Link to the original (http or https)" }, + { name: "project_ids", in: "body", type: "array", required: false, desc: "Projects covered; with album_ids, at least one" }, + { name: "album_ids", in: "body", type: "array", required: false, desc: "Albums covered" }, + { name: "requirements", in: "body", type: "array", required: false, desc: "In order, each with reference, wording, answer_shape, answer_format, answer_preset, recommended_source, word_limit and metrics" } + ], [ + { code: "201", cls: "response-2xx", desc: "The new set, in data" }, + { code: "404", cls: "response-4xx", desc: "An organisation you can't create sets in" }, + { code: "422", cls: "response-4xx", desc: "errors naming the requirement, e.g. KPI 2: Answer shape is not included in the list" } + ])} + ${endpointCard("PATCH", "/requirement_sets/{id}", "Change a Requirement Set", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Requirement Set" }, + { name: "requirements", in: "body", type: "array", required: false, desc: "The full list in order: give an existing requirement's id to keep it; any left out are removed" } + ], [ + { code: "200", cls: "response-2xx", desc: "The changed set, in data" }, + { code: "403", cls: "response-4xx", desc: "Not its creator or an Organisation Admin" }, + { code: "404", cls: "response-4xx", desc: "Not found, or one you can't see" }, + { code: "422", cls: "response-4xx", desc: "errors" } + ], "Fields left out stay as they are. Giving project_ids or album_ids replaces the whole scope.")} + ${endpointCard("DELETE", "/requirement_sets/{id}", "Delete a Requirement Set", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Requirement Set" } + ], [ + { code: "204", cls: "response-2xx", desc: "Deleted, with its requirements and links" }, + { code: "403", cls: "response-4xx", desc: "Not its creator or an Organisation Admin" }, + { code: "404", cls: "response-4xx", desc: "Not found, or one you can't see" } + ])} + ${endpointCard("GET", "/reports/{report_id}/requirements", "Get the reporting requirements for a Report", true, [ + { name: "report_id", in: "path", type: "integer", required: true, desc: "The Report" } + ], [ + { code: "200", cls: "response-2xx", desc: "recipient, match (exact, narrowest, candidates or none), conflicting (two or more sets qualify equally; none is picked) and requirement_sets" }, + { code: "404", cls: "response-4xx", desc: "Not found, or a Report you can't see" } + ])} +
+
+
Reporting