Skip to content

Commit bf5aa6d

Browse files
committed
update measurement schema
1 parent 2c57530 commit bf5aa6d

File tree

2 files changed

+108
-16
lines changed

2 files changed

+108
-16
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
"@hypercerts-org/lexicon": minor
3+
---
4+
5+
Refactor measurement lexicon schema: add unit field, date ranges, and locations array
6+
7+
**Breaking Changes:**
8+
9+
- **Measurement lexicon (`org.hypercerts.claim.measurement`):**
10+
- Changed required fields: removed `measurers` from required, added `unit` as required
11+
- Added `unit` field (required, string, maxLength: 50): The unit of the measured value (e.g. kg CO₂e, hectares, %, index score)
12+
- Added `startDate` field (optional, datetime): The start date and time when the measurement began
13+
- Added `endDate` field (optional, datetime): The end date and time when the measurement ended
14+
- Changed `location` (single strongRef) to `locations` (array of strongRefs, maxLength: 100)
15+
- Moved `measurers` from required to optional field
16+
- Added `comment` field (optional, string): Short comment suitable for previews and list views
17+
- Added `commentFacets` field (optional, array): Rich text annotations for `comment` (mentions, URLs, hashtags, etc.)
18+
- Updated field descriptions for `metric` and `value` with more detailed examples
19+
20+
**Migration:**
21+
22+
**Required fields:** Update measurement records to include the new required `unit` field:
23+
24+
```json
25+
// Before
26+
{
27+
"$type": "org.hypercerts.claim.measurement",
28+
"measurers": [...],
29+
"metric": "CO₂ sequestered",
30+
"value": "1000",
31+
"createdAt": "..."
32+
}
33+
34+
// After
35+
{
36+
"$type": "org.hypercerts.claim.measurement",
37+
"metric": "CO₂ sequestered",
38+
"unit": "kg CO₂e",
39+
"value": "1000",
40+
"measurers": [...], // Now optional
41+
"createdAt": "..."
42+
}
43+
```
44+
45+
**Location field:** Convert from single location to locations array:
46+
47+
```json
48+
// Before
49+
{
50+
"location": { "uri": "...", "cid": "..." }
51+
}
52+
53+
// After
54+
{
55+
"locations": [{ "uri": "...", "cid": "..." }]
56+
}
57+
```
58+
59+
**Date ranges:** Optionally add `startDate` and `endDate` to specify when measurements were taken.

lexicons/org/hypercerts/claim/measurement.json

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,47 @@
88
"key": "tid",
99
"record": {
1010
"type": "object",
11-
"required": ["measurers", "metric", "value", "createdAt"],
11+
"required": ["metric", "unit", "value", "createdAt"],
1212
"properties": {
1313
"subject": {
1414
"type": "ref",
1515
"ref": "com.atproto.repo.strongRef",
1616
"description": "A strong reference to the record this measurement refers to (e.g. an activity, project, or claim)."
1717
},
18-
"measurers": {
19-
"type": "array",
20-
"description": "DIDs of the entity (or entities) that measured this data",
21-
"items": {
22-
"type": "ref",
23-
"ref": "app.certified.defs#did"
24-
},
25-
"maxLength": 100
26-
},
2718
"metric": {
2819
"type": "string",
29-
"description": "The metric being measured",
20+
"description": "The metric being measured, e.g. forest area restored, number of users, etc.",
3021
"maxLength": 500
3122
},
23+
"unit": {
24+
"type": "string",
25+
"description": "The unit of the measured value (e.g. kg CO₂e, hectares, %, index score).",
26+
"maxLength": 50
27+
},
3228
"value": {
3329
"type": "string",
34-
"description": "The measured value",
30+
"description": "The measured numeric value.",
3531
"maxLength": 500
3632
},
33+
"startDate": {
34+
"type": "string",
35+
"format": "datetime",
36+
"description": "The start date and time when the measurement began."
37+
},
38+
"endDate": {
39+
"type": "string",
40+
"format": "datetime",
41+
"description": "The end date and time when the measurement ended. If it was a one time measurement, the endDate should be equal to the startDate."
42+
},
43+
"locations": {
44+
"type": "array",
45+
"description": "Optional geographic references related to where the measurement was taken. Each referenced record must conform with the app.certified.location lexicon.",
46+
"items": {
47+
"type": "ref",
48+
"ref": "com.atproto.repo.strongRef"
49+
},
50+
"maxLength": 100
51+
},
3752
"methodType": {
3853
"type": "string",
3954
"description": "Short identifier for the measurement methodology",
@@ -53,10 +68,28 @@
5368
},
5469
"maxLength": 50
5570
},
56-
"location": {
57-
"type": "ref",
58-
"ref": "com.atproto.repo.strongRef",
59-
"description": "A strong reference to the location where the measurement was taken. The record referenced must conform with the lexicon app.certified.location"
71+
"measurers": {
72+
"type": "array",
73+
"description": "DIDs of the entity (or entities) that measured this data",
74+
"items": {
75+
"type": "ref",
76+
"ref": "app.certified.defs#did"
77+
},
78+
"maxLength": 100
79+
},
80+
"comment": {
81+
"type": "string",
82+
"description": "Short comment of this measurement, suitable for previews and list views. Rich text annotations may be provided via `commentFacets`.",
83+
"maxLength": 3000,
84+
"maxGraphemes": 300
85+
},
86+
"commentFacets": {
87+
"type": "array",
88+
"description": "Rich text annotations for `comment` (mentions, URLs, hashtags, etc).",
89+
"items": {
90+
"type": "ref",
91+
"ref": "app.bsky.richtext.facet"
92+
}
6093
},
6194
"createdAt": {
6295
"type": "string",

0 commit comments

Comments
 (0)