diff --git a/openapi.yaml b/openapi.yaml index fea4f34..8c14435 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -11019,6 +11019,172 @@ paths: "422": $ref: '#/components/responses/UnprocessableEntity' + /impact_frameworks/{id}/additions: + get: + tags: [Library] + summary: List where an Impact Framework has been added + operationId: listImpactFrameworkAdditions + description: | + The Projects and other Impact Frameworks this Impact Framework (Template) has been added to, by + whom and when, as recorded by **Add to projects** and by **Add metrics from another project or + framework** on Edit metrics. Only Projects and frameworks of your organisations, and frameworks + you made, are listed. + + `project` is null when the receiving framework isn't a Project's Theory of Change. `added_by` is + null for additions made before Makerble recorded who added them. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + description: The id of the Impact Framework (Template) + schema: + type: integer + example: 7174 + - $ref: '#/components/parameters/Page' + - $ref: '#/components/parameters/PerPage' + - $ref: '#/components/parameters/LastSyncDatetime' + responses: + "200": + description: Where the framework has been added + content: + application/json: + schema: + type: object + properties: + page: {type: integer} + page_size: {type: integer} + page_count: {type: integer} + total_count: {type: integer} + data: + type: array + items: + type: object + properties: + id: {type: integer} + impact_framework_id: {type: integer} + receiving_framework: + type: object + properties: + id: {type: integer} + name: {type: string} + project: + type: object + nullable: true + properties: + id: {type: integer} + name: {type: string} + added_by: + type: object + nullable: true + properties: + id: {type: integer} + name: {type: string} + added_at: {type: string, format: date-time} + updated_at: {type: string, format: date-time} + example: + page: 1 + page_size: 1 + page_count: 1 + total_count: 1 + data: + - id: 31 + impact_framework_id: 7174 + receiving_framework: {id: 5549, name: Youth Club Theory of Change} + project: {id: 5427, name: Youth Club} + added_by: {id: 812, name: Sam Patel} + added_at: "2026-11-18T09:12:44.000Z" + updated_at: "2026-11-18T09:12:44.000Z" + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + post: + tags: [Library] + summary: Add an Impact Framework to projects or frameworks + operationId: addImpactFramework + description: | + Adds an Impact Framework's (Template's) metrics to Projects and to other Impact Frameworks, as the + **Add to projects** page and the **Add metrics from another project or framework** box on Edit + metrics do. Adding to a Project adds the metrics to that Project's own Theory of Change. + + The framework isn't copied: each metric goes into the same stage, a metric already there in that + stage is skipped, and the addition is recorded (see List where an Impact Framework has been added). + Adding the same framework again only adds metrics it has gained since. + + You must be able to edit each Project's or framework's metrics. One you can't edit, or that doesn't + exist, is listed in `refused` and the rest are still added. Give `project_ids`, `framework_ids` or both. + security: [{tokenAuth: []}] + parameters: + - name: id + in: path + required: true + description: The id of the Impact Framework (Template) whose metrics to add + schema: + type: integer + example: 7174 + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + project_ids: + type: array + items: {type: integer} + description: Projects to add the metrics to + framework_ids: + type: array + items: {type: integer} + description: Other Impact Frameworks (Templates) to add the metrics to + example: + project_ids: [5427, 5428] + framework_ids: [1460] + responses: + "201": + description: What was added and what was refused + content: + application/json: + schema: + type: object + properties: + data: + type: object + properties: + impact_framework_id: {type: integer} + added: + type: array + items: + type: object + properties: + receiving_framework_id: {type: integer} + project_id: {type: integer, nullable: true} + refused: + type: array + items: + type: object + properties: + project_id: {type: integer} + framework_id: {type: integer} + error: + type: string + enum: [forbidden, not-found, same_framework, not_saved] + example: + data: + impact_framework_id: 7174 + added: + - {receiving_framework_id: 5549, project_id: 5427} + - {receiving_framework_id: 1460, project_id: null} + refused: + - {project_id: 5428, error: forbidden} + "401": + $ref: '#/components/responses/Unauthorized' + "404": + $ref: '#/components/responses/NotFound' + "422": + $ref: '#/components/responses/UnprocessableEntity' + /referral_submissions: post: tags: [Signup Pages] diff --git a/server.js b/server.js index 994afd4..4285c26 100644 --- a/server.js +++ b/server.js @@ -2652,6 +2652,26 @@ function buildDocsPage() { { code: "404", cls: "response-4xx", desc: "No Impact Framework with that id that you may copy" }, { code: "422", cls: "response-4xx", desc: "The copy could not be saved; the error says why. Nothing is created" } ], "The same as Copy on the Manage Impact Frameworks page: the stages and metrics are copied, the projects are not.")} + ${endpointCard("POST", "/impact_frameworks/{id}/additions", "Add an Impact Framework to projects or frameworks", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Impact Framework (Template) whose metrics to add" }, + { name: "project_ids", in: "body", type: "array", required: false, desc: "Projects to add the metrics to, in each Project's own Theory of Change" }, + { name: "framework_ids", in: "body", type: "array", required: false, desc: "Other Impact Frameworks (Templates) to add the metrics to. Give project_ids, framework_ids or both" } + ], [ + { code: "201", cls: "response-2xx", desc: "data: impact_framework_id, added (each with receiving_framework_id and project_id) and refused (each with project_id or framework_id and error: forbidden, not-found or same_framework)" }, + { code: "401", cls: "response-4xx", desc: "Missing or invalid token" }, + { code: "404", cls: "response-4xx", desc: "No Impact Framework with that id" }, + { code: "422", cls: "response-4xx", desc: "Neither project_ids nor framework_ids given" } + ], "The same as Add to projects and Add metrics from another project or framework on Edit metrics: the metrics are added stage by stage, ones already there are skipped, and the addition is recorded. Projects and frameworks you can't edit are refused, the rest are added.")} + ${endpointCard("GET", "/impact_frameworks/{id}/additions", "List where an Impact Framework has been added", true, [ + { name: "id", in: "path", type: "integer", required: true, desc: "The Impact Framework (Template)" }, + { name: "page", type: "integer", required: false, desc: "Page number" }, + { name: "per_page", type: "integer", required: false, desc: "Results per page (default 10, max 200)" }, + { name: "last_synced_datetime", type: "string", required: false, desc: "ISO 8601 — only additions changed after this" } + ], [ + { code: "200", cls: "response-2xx", desc: "Each with id, impact_framework_id, receiving_framework {id, name}, project {id, name} (null for a framework that isn't a Project's), added_by {id, name} (null before Makerble recorded it), added_at and updated_at" }, + { code: "401", cls: "response-4xx", desc: "Missing or invalid token" }, + { code: "404", cls: "response-4xx", desc: "No Impact Framework with that id" } + ], "Only Projects and frameworks of your organisations, and frameworks you made, are listed.")} ${endpointCard("GET", "/impact_frameworks/{id}/missing_metrics", "List an Impact Framework's metrics a Results Canvas can't show", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "The Impact Framework (Template): one the Results Canvas's Metrics dropdown offers you" }, { name: "project_id", in: "query", type: "integer", required: false, desc: "The project whose Results Canvas to check (give this or album_id)" },