diff --git a/openapi.yaml b/openapi.yaml index b213fee..8aa886c 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -17079,8 +17079,23 @@ paths: them, so projects using it don't get Metrics they don't need. For a new Outcome, they are linked to it as they are, not copied. An id you can't see, or that isn't one of the reused Outcome's Metrics, answers `404` and creates nothing. - - At most 50 entries and new Metrics together. Near-identical names of new items get `409` + - `cohort_tracker_id` or `new_cohort_tracker`, `workflow_tracker_id` or `new_workflow_tracker`, + `formula_tracker_id` or `new_formula_tracker` (Cohort, Workflow and Formula Trackers), in any + of the five stages. A reused tracker must be your organisation's; another organisation's id + answers `404`. A new tracker takes the same fields as its own create endpoint and is made in + your organisation. A new Formula Tracker's formula can use another entry of this draft by its + number, with the token `{"kind": "tracker", "entry": 2}`, so a percentage of two new trackers + is made in one go. That entry must be an Activity tracker or a tracker (an Outcome has no + number of its own), and a formula that uses itself, directly or through other entries, is + refused with `422`. + + With `project_id` (one of your organisation's projects, whose metrics you can edit), the + framework is also added to that project, and `filtered_versions` are made there: filtered + versions of a metric (an Activity tracker entry, the nth new Metric of an Outcome entry, or a + Change or Indicator by `parent_type` and `parent_id`) for a subset of Contacts or responses, such + as "Girls under 16". `project_id` is needed only with `filtered_versions`. + + At most 50 entries, new Metrics and filtered versions together. Near-identical names of new items get `409` with the matches, each with its `entry`, unless you send `force: true`. Nothing is created unless everything is, and an error names the entry. It stays private to your organisation unless you are Makerble staff and send `approved: true`. @@ -17118,6 +17133,13 @@ paths: maxItems: 50 items: $ref: '#/components/schemas/ImpactFrameworkDraftEntry' + project_id: + type: integer + description: Needed with filtered_versions. The project the framework is added to, where the filtered versions are made + filtered_versions: + type: array + items: + $ref: '#/components/schemas/ImpactFrameworkDraftFilteredVersion' example: organisation_id: 913 name: "Youth employment" @@ -17136,6 +17158,31 @@ paths: - stage: Long-term outcomes new_outcome: title: "In sustained work" + - stage: Participation outputs + new_cohort_tracker: + name: "Contacts attending 80% of sessions" + criteria: + attendance_rate: {change_id: "412", from: "80", to: "100"} + - stage: Participation outputs + new_cohort_tracker: + name: "Contacts enrolled" + membership: currently_enrolled + criteria: {} + - stage: Short-term outcomes + new_formula_tracker: + name: "Share attending 80% of sessions" + display_format: percentage + expression: + - {kind: tracker, entry: 4} + - {kind: operator, value: "/"} + - {kind: tracker, entry: 5} + project_id: 4410 + filtered_versions: + - entry: 1 + display_name: "Workshops delivered to girls under 16" + contact_criteria: + sub_ratio_ids: ["881"] + age_to: {year: "15", month: "11", day: "30"} responses: "201": $ref: '#/components/responses/LibraryItemCreated' @@ -29948,7 +29995,7 @@ components: ImpactFrameworkDraftEntry: type: object - description: One entry. Give a stage and exactly one of activity_tracker_id, new_activity_tracker, outcome_id or new_outcome. + description: One entry. Give a stage and exactly one of activity_tracker_id, new_activity_tracker, outcome_id, new_outcome, cohort_tracker_id, new_cohort_tracker, workflow_tracker_id, new_workflow_tracker, formula_tracker_id or new_formula_tracker. required: [stage] properties: stage: @@ -30018,6 +30065,77 @@ components: enum: [top to bottom, bottom to top, none] description: type: string + cohort_tracker_id: + type: integer + description: One of your organisation's Cohort Trackers + new_cohort_tracker: + type: object + required: [name] + description: The fields of a new Cohort Tracker, as in Create a Cohort Tracker (without charity_id) + additionalProperties: true + properties: + name: + type: string + description: + type: string + membership: + type: string + enum: [ever_enrolled, currently_enrolled] + criteria: + type: object + result_type: + type: string + enum: [number, percentage] + denominator: + type: string + enum: [members, enough_data, filtered] + denominator_criteria: + type: object + workflow_tracker_id: + type: integer + description: One of your organisation's Workflow Trackers + new_workflow_tracker: + description: The fields of a new Workflow Tracker, as in Create a Workflow Tracker (without charity_id) + allOf: + - $ref: '#/components/schemas/WorkflowTrackerAttributes' + formula_tracker_id: + type: integer + description: One of your organisation's Formula Trackers + new_formula_tracker: + description: | + The fields of a new Formula Tracker, as in Create a Formula Tracker (without charity_id). A + tracker token may give `entry` (another entry's number in this draft) instead of `type` and `id`. + allOf: + - $ref: '#/components/schemas/FormulaTrackerAttributes' + + ImpactFrameworkDraftFilteredVersion: + type: object + required: [display_name] + description: | + A filtered version made on the draft's project. Name the metric it filters with `entry` (an + Activity tracker entry, or with `new_metric` the nth new Metric of an Outcome entry), or with + `parent_type` and `parent_id`. + properties: + display_name: + type: string + entry: + type: integer + description: The number of an entry in this draft, counting from 1 + new_metric: + type: integer + description: With entry, the nth of that Outcome entry's new_metrics, counting from 1 + parent_type: + type: string + enum: [Change, Indicator] + parent_id: + type: integer + column: + type: string + enum: [activities, engagement, potential, behaviour, growth] + response_criteria: + type: object + contact_criteria: + type: object LibraryItem: type: object diff --git a/server.js b/server.js index b7605a1..7a04251 100644 --- a/server.js +++ b/server.js @@ -3213,7 +3213,9 @@ function buildDocsPage() { ${endpointCard("POST", "/impact_frameworks", "Create an Impact Framework with its entries", true, [ { name: "organisation_id", in: "body", type: "integer", required: true, desc: "The organisation (Charity) that will own it; you must be one of its editors" }, { name: "name", in: "body", type: "string", required: true, desc: "e.g. Youth employment" }, - { name: "entries", in: "body", type: "array", required: true, desc: "In order. Each has a stage and exactly one of activity_tracker_id or new_activity_tracker {name, category} (Activity or Participation outputs), or outcome_id or new_outcome {title} (Short-, Medium- or Long-term outcomes). An Outcome entry can add new_metrics, and indicator_ids of existing Metrics: only those of a reused Outcome's Metrics are taken, or they are linked to a new Outcome without being copied. At most 50 entries and new Metrics together" }, + { name: "entries", in: "body", type: "array", required: true, desc: "In order. Each has a stage and exactly one of activity_tracker_id or new_activity_tracker {name, category} (Activity or Participation outputs), or outcome_id or new_outcome {title} (Short-, Medium- or Long-term outcomes). An Outcome entry can add new_metrics, and indicator_ids of existing Metrics: only those of a reused Outcome's Metrics are taken, or they are linked to a new Outcome without being copied. Any stage can also take cohort_tracker_id, workflow_tracker_id or formula_tracker_id (your organisation's own), or new_cohort_tracker, new_workflow_tracker or new_formula_tracker with the fields of its create endpoint. A new formula can use another entry by number, {kind: \"tracker\", entry: 2}; a formula that uses itself is refused. At most 50 entries, new Metrics and filtered versions together" }, + { name: "project_id", in: "body", type: "integer", required: false, desc: "With filtered_versions: one of the organisation's projects whose metrics you can edit. The framework is added to it" }, + { name: "filtered_versions", in: "body", type: "array", required: false, desc: "Filtered versions made on that project, each with display_name, response_criteria and contact_criteria, and the metric it filters: entry (an Activity tracker entry, or with new_metric the nth new Metric of an Outcome entry), or parent_type and parent_id" }, { name: "description / color / causes / department", in: "body", type: "string", required: false, desc: "Shown with the framework and used by the Explore filters" }, { name: "approved", in: "body", type: "boolean", required: false, desc: "Makerble staff only: share it in the public library and approve its new items" }, { name: "force", in: "body", type: "boolean", required: false, desc: "true to create new items even though near-identical ones exist (see 409)" } @@ -3223,7 +3225,7 @@ function buildDocsPage() { { code: "403", cls: "response-4xx", desc: "You may not create Impact Frameworks, trackers, Outcomes or Metrics, as in the Makerble app" }, { code: "404", cls: "response-4xx", desc: "The organisation, or an id in an entry, isn't one you can use; the error names the entry" }, { code: "409", cls: "response-4xx", desc: "Nothing created: duplicates lists items you can reuse instead of the new ones, each with its entry" }, - { code: "422", cls: "response-4xx", desc: "Invalid input (e.g. an Outcome in an Activity stage); nothing is created and the error names the entry" } + { code: "422", cls: "response-4xx", desc: "Invalid input (e.g. an Outcome in an Activity stage, or a formula that uses itself); nothing is created and the error names the entry or filtered version" } ], "An Impact Framework (Template). Reuse trackers and Outcomes by id, and define only what's missing.")} ${endpointCard("POST", "/impact_frameworks/{id}/copy", "Copy an Impact Framework", true, [ { name: "id", in: "path", type: "integer", required: true, desc: "The Impact Framework (Template) to copy: your own, one of an organisation you belong to, the Theory of Change of a project you edit, or an approved ImpactStore framework" }