From 0015a19b00a6e0b163e63a0ac8aad099d37c45b9 Mon Sep 17 00:00:00 2001 From: Marcus Aurelius Date: Mon, 13 Jan 2025 13:54:20 -0500 Subject: [PATCH] Additional fields for DCI --- carbon-projects/lib/sectors.ts | 1 + carbon-projects/schemas/assessor.ts | 47 ++++++++++ carbon-projects/schemas/developer.ts | 44 +++++++++ carbon-projects/schemas/index.ts | 6 ++ carbon-projects/schemas/methodology.ts | 9 +- carbon-projects/schemas/objects/hostedFile.ts | 9 +- carbon-projects/schemas/project.ts | 89 +++++++++++++++++-- carbon-projects/schemas/standard.ts | 36 ++++++++ 8 files changed, 227 insertions(+), 14 deletions(-) create mode 100644 carbon-projects/lib/sectors.ts create mode 100644 carbon-projects/schemas/assessor.ts create mode 100644 carbon-projects/schemas/developer.ts create mode 100644 carbon-projects/schemas/standard.ts diff --git a/carbon-projects/lib/sectors.ts b/carbon-projects/lib/sectors.ts new file mode 100644 index 0000000000..942a78cd98 --- /dev/null +++ b/carbon-projects/lib/sectors.ts @@ -0,0 +1 @@ +[{ title: "Waste handling and disposal", value: "waste-h-d" }]; diff --git a/carbon-projects/schemas/assessor.ts b/carbon-projects/schemas/assessor.ts new file mode 100644 index 0000000000..f5c78ba5e3 --- /dev/null +++ b/carbon-projects/schemas/assessor.ts @@ -0,0 +1,47 @@ +import { defineType } from "sanity"; + +export default defineType({ + name: "assessor", + title: "Assessor", + description: "Information about an organization that assesses projects", + description: + "A profile containing information about an entity including name, avatar, and link", + type: "document", + preview: { + select: { + name: "name", + }, + prepare(selection) { + return { + title: selection.name || "", + }; + }, + }, + fields: [ + { + type: "string", + title: "Name", + name: "name", + validation: (r) => r.required(), + }, + { + type: "string", + title: "Link", + name: "link", + }, + { + type: "image", + title: "Avatar", + name: "avatar", + }, + { + type: "array", + title: "Accreditations", + name: "accreditations", + of: [ + { type: "string", name: "name" }, + { type: "string", name: "link" }, + ], + }, + ], +}); diff --git a/carbon-projects/schemas/developer.ts b/carbon-projects/schemas/developer.ts new file mode 100644 index 0000000000..055efe1603 --- /dev/null +++ b/carbon-projects/schemas/developer.ts @@ -0,0 +1,44 @@ +import { defineType } from "sanity"; + +export default defineType({ + name: "developer", + title: "Developer", + description: "Information about an organization that develops projects", + description: + "A profile containing information about an entity including name, avatar, and link", + type: "document", + preview: { + select: { + name: "name", + }, + prepare(selection) { + return { + title: selection.name || "", + }; + }, + }, + fields: [ + { + type: "string", + title: "Name", + name: "name", + validation: (r) => r.required(), + }, + { + type: "string", + title: "Link", + name: "link", + }, + { + type: "image", + title: "Avatar", + name: "avatar", + }, + { + type: "array", + title: "Carbonmark Handles", + name: "handles", + of: [{ type: "string" }], + }, + ], +}); diff --git a/carbon-projects/schemas/index.ts b/carbon-projects/schemas/index.ts index d5bd05d104..88c2294fde 100644 --- a/carbon-projects/schemas/index.ts +++ b/carbon-projects/schemas/index.ts @@ -1,4 +1,6 @@ +import assessor from "./assessor"; import country from "./country"; +import developer from "./developer"; import indexContent from "./indexContent"; import methodology from "./methodology"; import captionImage from "./objects/captionImage"; @@ -6,6 +8,7 @@ import externalFile from "./objects/externalFile"; import hostedFile from "./objects/hostedFile"; import project from "./project"; import projectContent from "./projectContent"; +import standard from "./standard"; export const schemaTypes = [ project, methodology, @@ -15,4 +18,7 @@ export const schemaTypes = [ captionImage, country, indexContent, + assessor, + developer, + standard, ]; diff --git a/carbon-projects/schemas/methodology.ts b/carbon-projects/schemas/methodology.ts index 8783dcea3b..4ba78a9a1d 100644 --- a/carbon-projects/schemas/methodology.ts +++ b/carbon-projects/schemas/methodology.ts @@ -1,12 +1,12 @@ import { defineField, defineType } from "sanity"; import { categories } from "../lib/categories"; +import { sectors } from "../lib/sectors"; export default defineType({ name: "methodology", title: "Methodology", description: "Methodology definition", type: "document", - groups: [{ name: "location" }], preview: { select: { slug: "id", @@ -43,6 +43,13 @@ export default defineType({ }, validation: (r) => r.required(), }), + defineField({ + name: "sector", + type: "string", + options: { + list: sectors, + }, + }), defineField({ name: "link", type: "string", diff --git a/carbon-projects/schemas/objects/hostedFile.ts b/carbon-projects/schemas/objects/hostedFile.ts index 797e1844bb..3c25ec15df 100644 --- a/carbon-projects/schemas/objects/hostedFile.ts +++ b/carbon-projects/schemas/objects/hostedFile.ts @@ -4,7 +4,8 @@ export default defineType({ name: "hostedFile", type: "file", title: "Hosted file", - description: "A file whose content is hosted directly in the Sanity CMS, with associated metadata", + description: + "A file whose content is hosted directly in the Sanity CMS, with associated metadata", fields: [ { type: "string", @@ -24,12 +25,12 @@ export default defineType({ { type: "string", title: "File category", - name: "category" + name: "category", }, { type: "number", title: "File size", - name: "size" - } + name: "size", + }, ], }); diff --git a/carbon-projects/schemas/project.ts b/carbon-projects/schemas/project.ts index b798ac4ec8..83e38b7232 100644 --- a/carbon-projects/schemas/project.ts +++ b/carbon-projects/schemas/project.ts @@ -11,6 +11,16 @@ const ccbs = [ { title: "CCB Community Gold", value: "CCB-Community Gold" }, ]; +const registries = [ + { title: "Verra", value: "VCS" }, + { title: "Gold Standard", value: "GS" }, + { title: "EcoRegistry", value: "ECO" }, + { title: "International Carbon Registry", value: "ICR" }, + { title: "Puro", value: "PUR" }, + { title: "J-Credit", value: "JCS" }, + { title: "Carbonmark Direct Issuance", value: "CMARK" }, +]; + const subcategories = [ { title: "Solar Energy", value: "solar" }, { title: "Wind Energy", value: "wind" }, @@ -21,6 +31,20 @@ const subcategories = [ { title: "Mangrove Restoration", value: "mangroves" }, ]; +const statuses = [ + { title: "Registered", value: "registered" }, + { title: "Validated", value: "validated" }, + { title: "Verified", value: "verified" }, + { title: "Withdrawn", value: "withdrawn" } +]; + +const types = [ + { title: "Avoidance", value: "avoidance" }, + { title: "Reduction", value: "reduction" }, + { title: "Removal", value: "removal" }, + { title: "Hybrid", value: "hybrid" }, +]; + export default defineType({ name: "project", title: "Project", @@ -71,14 +95,7 @@ export default defineType({ placeholder: "VCS", type: "string", options: { - list: [ - { title: "Verra", value: "VCS" }, - { title: "Gold Standard", value: "GS" }, - { title: "EcoRegistry", value: "ECO" }, - { title: "International Carbon Registry", value: "ICR" }, - { title: "Puro", value: "PUR" }, - { title: "J-Credit", value: "JCS" }, - ], + list: registries, }, validation: (r) => r.required(), }, @@ -117,6 +134,52 @@ export default defineType({ return true; }), }), + defineField({ + type: "reference", + name: "developer", + to: [{ type: "developer" }], + description: "The developer of this project", + group: "info", + }), + defineField({ + type: "reference", + name: "assessor", + to: [{ type: "assessor" }], + description: "The assessor of this project", + group: "info", + }), + defineField({ + type: "array", + name: "standards", + of: [ + { + type: "reference", + to: [{ type: "standard" }], + }, + ], + description: "Standards with which the project conforms", + group: "info", + }), + { + name: "status", + description: + "Project status. Indicates where a project is in its lifecycle from registration to verification and issuance", + group: "info", + type: "string", + options: { + list: statuses, + }, + }, + { + name: "type", + description: + "Project type. Indicates whether a project avoids or removes emissions, or both.", + group: "info", + type: "string", + options: { + list: types, + }, + }, defineField({ type: "array", name: "methodologies", @@ -146,11 +209,18 @@ export default defineType({ defineField({ name: "subcategory", description: "From our predefined ontology of subcategories", + group: "info", type: "string", options: { list: subcategories, }, }), + defineField({ + name: "estAnnualMitigations", + description: "Estimated tonnes of carbon emissions mitigated per annum", + group: "info", + type: "number", + }), { name: "region", description: "Region where the project was implemented", @@ -252,7 +322,8 @@ export default defineType({ }), defineField({ name: "hostedDocuments", - description: "PDF documents hosted in this CMS associated with this project", + description: + "PDF documents hosted in this CMS associated with this project", group: "media", type: "array", of: [{ type: "hostedFile" }], diff --git a/carbon-projects/schemas/standard.ts b/carbon-projects/schemas/standard.ts new file mode 100644 index 0000000000..9a9692e6d4 --- /dev/null +++ b/carbon-projects/schemas/standard.ts @@ -0,0 +1,36 @@ +import { defineType } from "sanity"; + +export default defineType({ + name: "standard", + title: "Standard", + description: "Information about a standard that applies to projects", + type: "document", + preview: { + select: { + name: "name", + }, + prepare(selection) { + return { + title: selection.name || "", + }; + }, + }, + fields: [ + { + type: "string", + title: "Name", + name: "name", + validation: (r) => r.required(), + }, + { + type: "string", + title: "Link", + name: "link", + }, + { + type: "image", + title: "Logo", + name: "logo", + }, + ], +});