@hypercerts-org/lexicon 0.10.0-beta.11 → 0.10.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +166 -0
- package/README.md +145 -1
- package/SCHEMAS.md +202 -94
- package/dist/exports.d.ts +138 -130
- package/dist/exports.d.ts.map +1 -1
- package/dist/generated/exports.d.ts +138 -130
- package/dist/generated/exports.d.ts.map +1 -1
- package/dist/generated/lexicons.d.ts +299 -283
- package/dist/generated/lexicons.d.ts.map +1 -1
- package/dist/generated/types/app/certified/location.d.ts +9 -1
- package/dist/generated/types/app/certified/location.d.ts.map +1 -1
- package/dist/generated/types/org/hypercerts/claim/activity.d.ts +3 -1
- package/dist/generated/types/org/hypercerts/claim/activity.d.ts.map +1 -1
- package/dist/generated/types/org/hypercerts/claim/attachment.d.ts +37 -0
- package/dist/generated/types/org/hypercerts/claim/attachment.d.ts.map +1 -0
- package/dist/generated/types/org/hypercerts/claim/measurement.d.ts +17 -5
- package/dist/generated/types/org/hypercerts/claim/measurement.d.ts.map +1 -1
- package/dist/generated/types/org/hypercerts/defs.d.ts +0 -44
- package/dist/generated/types/org/hypercerts/defs.d.ts.map +1 -1
- package/dist/index.cjs +409 -465
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +406 -462
- package/dist/index.mjs.map +1 -1
- package/dist/lexicons.cjs +155 -163
- package/dist/lexicons.cjs.map +1 -1
- package/dist/lexicons.d.ts +299 -283
- package/dist/lexicons.d.ts.map +1 -1
- package/dist/lexicons.mjs +155 -163
- package/dist/lexicons.mjs.map +1 -1
- package/dist/types/app/certified/location.d.ts +9 -1
- package/dist/types/app/certified/location.d.ts.map +1 -1
- package/dist/types/org/hypercerts/claim/activity.d.ts +3 -1
- package/dist/types/org/hypercerts/claim/activity.d.ts.map +1 -1
- package/dist/types/org/hypercerts/claim/attachment.d.ts +37 -0
- package/dist/types/org/hypercerts/claim/attachment.d.ts.map +1 -0
- package/dist/types/org/hypercerts/claim/measurement.d.ts +17 -5
- package/dist/types/org/hypercerts/claim/measurement.d.ts.map +1 -1
- package/dist/types/org/hypercerts/defs.d.ts +0 -44
- package/dist/types/org/hypercerts/defs.d.ts.map +1 -1
- package/lexicons/app/certified/location.json +16 -2
- package/lexicons/org/hypercerts/claim/activity.json +8 -7
- package/lexicons/org/hypercerts/claim/attachment.json +86 -0
- package/lexicons/org/hypercerts/claim/measurement.json +49 -16
- package/lexicons/org/hypercerts/defs.json +0 -88
- package/package.json +1 -1
- package/dist/generated/types/org/hypercerts/claim/evidence.d.ts +0 -29
- package/dist/generated/types/org/hypercerts/claim/evidence.d.ts.map +0 -1
- package/dist/types/org/hypercerts/claim/evidence.d.ts +0 -29
- package/dist/types/org/hypercerts/claim/evidence.d.ts.map +0 -1
- package/lexicons/org/hypercerts/claim/evidence.json +0 -57
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,171 @@
|
|
|
1
1
|
# @hypercerts-org/lexicon
|
|
2
2
|
|
|
3
|
+
## 0.10.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#131](https://github.com/hypercerts-org/hypercerts-lexicon/pull/131) [`7f42fad`](https://github.com/hypercerts-org/hypercerts-lexicon/commit/7f42fad517e191dad6db22fc67ec8346ec167f5c) Thanks [@aspiers](https://github.com/aspiers)! - Add inline string format to app.certified.location schema with documentation and examples
|
|
8
|
+
|
|
9
|
+
- [#118](https://github.com/hypercerts-org/hypercerts-lexicon/pull/118) [`8427780`](https://github.com/hypercerts-org/hypercerts-lexicon/commit/8427780888759ee749a683528f49e6b0da2b97c2) Thanks [@holkexyz](https://github.com/holkexyz)! - Rename evidence lexicon to attachment and refactor schema structure
|
|
10
|
+
|
|
11
|
+
**Breaking Changes:**
|
|
12
|
+
- **Lexicon ID change:**
|
|
13
|
+
- `org.hypercerts.claim.evidence` → `org.hypercerts.claim.attachment`
|
|
14
|
+
- All existing evidence records must be migrated to use the new lexicon ID
|
|
15
|
+
- **Schema structure changes (`org.hypercerts.claim.attachment`):**
|
|
16
|
+
- Changed `subject` (single strongRef) to `subjects` (array of strongRefs, maxLength: 100)
|
|
17
|
+
- Changed `content` from single union (uri/blob) to array of unions (maxLength: 100)
|
|
18
|
+
- Added `contentType` field (string, maxLength: 64) to specify attachment type
|
|
19
|
+
- Removed `relationType` field (previously used to indicate supports/challenges/clarifies)
|
|
20
|
+
- Removed `contributors` field
|
|
21
|
+
- Removed `locations` field
|
|
22
|
+
- Added rich text support: `shortDescriptionFacets` and `descriptionFacets` (arrays of `app.bsky.richtext.facet`)
|
|
23
|
+
- Updated required fields: `["title", "content", "createdAt"]` (content is now required)
|
|
24
|
+
- **Common definitions (`org.hypercerts.defs`):**
|
|
25
|
+
- Added `weightedContributor` def for contributor references with optional weights
|
|
26
|
+
- Added `contributorIdentity` def for string-based contributor identification
|
|
27
|
+
|
|
28
|
+
**Migration:**
|
|
29
|
+
|
|
30
|
+
**Lexicon ID:** Update all references from `org.hypercerts.claim.evidence` to `org.hypercerts.claim.attachment`.
|
|
31
|
+
|
|
32
|
+
**Schema migration:**
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
// Before (org.hypercerts.claim.evidence)
|
|
36
|
+
{
|
|
37
|
+
"$type": "org.hypercerts.claim.evidence",
|
|
38
|
+
"subject": { "uri": "...", "cid": "..." },
|
|
39
|
+
"content": { "uri": "https://..." },
|
|
40
|
+
"title": "Evidence Title",
|
|
41
|
+
"relationType": "supports",
|
|
42
|
+
"createdAt": "..."
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// After (org.hypercerts.claim.attachment)
|
|
46
|
+
{
|
|
47
|
+
"$type": "org.hypercerts.claim.attachment",
|
|
48
|
+
"subjects": [{ "uri": "...", "cid": "..." }],
|
|
49
|
+
"content": [{ "uri": "https://..." }],
|
|
50
|
+
"contentType": "evidence",
|
|
51
|
+
"title": "Evidence Title",
|
|
52
|
+
"createdAt": "..."
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Field mapping:**
|
|
57
|
+
- `subject` → `subjects` (wrap in array)
|
|
58
|
+
- `content` (single) → `content` (array, wrap existing value)
|
|
59
|
+
- `relationType` → remove (no direct replacement)
|
|
60
|
+
- `contributors` → remove (no direct replacement)
|
|
61
|
+
- `locations` → remove (no direct replacement)
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- [#118](https://github.com/hypercerts-org/hypercerts-lexicon/pull/118) [`8427780`](https://github.com/hypercerts-org/hypercerts-lexicon/commit/8427780888759ee749a683528f49e6b0da2b97c2) Thanks [@holkexyz](https://github.com/holkexyz)! - Add location property to attachment schema
|
|
66
|
+
|
|
67
|
+
**New Feature:**
|
|
68
|
+
- **`location` field** (`org.hypercerts.claim.attachment`):
|
|
69
|
+
- Added optional `location` property as a strong reference (`com.atproto.repo.strongRef`)
|
|
70
|
+
- Allows attachments to associate location metadata directly without using the sidecar pattern
|
|
71
|
+
- The referenced record must conform to the `app.certified.location` lexicon
|
|
72
|
+
|
|
73
|
+
**Usage:**
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"$type": "org.hypercerts.claim.attachment",
|
|
78
|
+
"subjects": [
|
|
79
|
+
{
|
|
80
|
+
"uri": "at://did:plc:.../org.hypercerts.claim.activity/...",
|
|
81
|
+
"cid": "..."
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"content": [{ "uri": "https://..." }],
|
|
85
|
+
"title": "Field Report",
|
|
86
|
+
"location": {
|
|
87
|
+
"uri": "at://did:plc:.../app.certified.location/abc123",
|
|
88
|
+
"cid": "..."
|
|
89
|
+
},
|
|
90
|
+
"createdAt": "..."
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This change aligns with the location property addition to collections (PR #123), providing a consistent pattern for associating location metadata across record types.
|
|
95
|
+
|
|
96
|
+
## 0.10.0-beta.12
|
|
97
|
+
|
|
98
|
+
### Minor Changes
|
|
99
|
+
|
|
100
|
+
- [#120](https://github.com/hypercerts-org/hypercerts-lexicon/pull/120) [`b2f7b68`](https://github.com/hypercerts-org/hypercerts-lexicon/commit/b2f7b683ac17f07a891a59ee8289d26717197ba3) Thanks [@holkexyz](https://github.com/holkexyz)! - Refactor measurement lexicon schema: add unit field, date ranges, and locations array
|
|
101
|
+
|
|
102
|
+
**Breaking Changes:**
|
|
103
|
+
- **Measurement lexicon (`org.hypercerts.claim.measurement`):**
|
|
104
|
+
- Changed required fields: removed `measurers` from required, added `unit` as required
|
|
105
|
+
- Added `unit` field (required, string, maxLength: 50): The unit of the measured value (e.g. kg CO₂e, hectares, %, index score)
|
|
106
|
+
- Added `startDate` field (optional, datetime): The start date and time when the measurement began
|
|
107
|
+
- Added `endDate` field (optional, datetime): The end date and time when the measurement ended
|
|
108
|
+
- Changed `location` (single strongRef) to `locations` (array of strongRefs, maxLength: 100)
|
|
109
|
+
- Moved `measurers` from required to optional field
|
|
110
|
+
- Added `comment` field (optional, string): Short comment suitable for previews and list views
|
|
111
|
+
- Added `commentFacets` field (optional, array): Rich text annotations for `comment` (mentions, URLs, hashtags, etc.)
|
|
112
|
+
- Updated field descriptions for `metric` and `value` with more detailed examples
|
|
113
|
+
|
|
114
|
+
**Migration:**
|
|
115
|
+
|
|
116
|
+
**Required fields:** Update measurement records to include the new required `unit` field:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
// Before
|
|
120
|
+
{
|
|
121
|
+
"$type": "org.hypercerts.claim.measurement",
|
|
122
|
+
"measurers": [...],
|
|
123
|
+
"metric": "CO₂ sequestered",
|
|
124
|
+
"value": "1000",
|
|
125
|
+
"createdAt": "..."
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// After
|
|
129
|
+
{
|
|
130
|
+
"$type": "org.hypercerts.claim.measurement",
|
|
131
|
+
"metric": "CO₂ sequestered",
|
|
132
|
+
"unit": "kg CO₂e",
|
|
133
|
+
"value": "1000",
|
|
134
|
+
"measurers": [...], // Now optional
|
|
135
|
+
"createdAt": "..."
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Location field:** Convert from single location to locations array:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
// Before
|
|
143
|
+
{
|
|
144
|
+
"location": { "uri": "...", "cid": "..." }
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// After
|
|
148
|
+
{
|
|
149
|
+
"locations": [{ "uri": "...", "cid": "..." }]
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Date ranges:** Optionally add `startDate` and `endDate` to specify when measurements were taken.
|
|
154
|
+
|
|
155
|
+
- [#125](https://github.com/hypercerts-org/hypercerts-lexicon/pull/125) [`771d142`](https://github.com/hypercerts-org/hypercerts-lexicon/commit/771d14269ced86ea686cb6dac3414a7a283c482a) Thanks [@s-adamantine](https://github.com/s-adamantine)! - Simplify workScope to union of strongRef and string
|
|
156
|
+
|
|
157
|
+
**Breaking Changes:**
|
|
158
|
+
- The `workScope` field in `org.hypercerts.claim.activity` is now a union of:
|
|
159
|
+
- `com.atproto.repo.strongRef`: A reference to a work-scope logic record for structured, nested work scope definitions
|
|
160
|
+
- `org.hypercerts.claim.activity#workScopeString`: A free-form string for simple or legacy scopes
|
|
161
|
+
- **Removed** from `org.hypercerts.defs`:
|
|
162
|
+
- `workScopeAll` (logical AND operator)
|
|
163
|
+
- `workScopeAny` (logical OR operator)
|
|
164
|
+
- `workScopeNot` (logical NOT operator)
|
|
165
|
+
- `workScopeAtom` (atomic scope reference)
|
|
166
|
+
|
|
167
|
+
This simplification allows work scope complexity to be managed via referenced records while still supporting simple string-based scopes for straightforward use cases.
|
|
168
|
+
|
|
3
169
|
## 0.10.0-beta.11
|
|
4
170
|
|
|
5
171
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -65,10 +65,12 @@ const activityRecord = {
|
|
|
65
65
|
$type: ACTIVITY_NSID,
|
|
66
66
|
title: "My Impact Work",
|
|
67
67
|
shortDescription: "Description here",
|
|
68
|
+
// workScope can be a strongRef to a work-scope record:
|
|
68
69
|
workScope: {
|
|
69
|
-
uri: "at://did:plc:alice/org.hypercerts.
|
|
70
|
+
uri: "at://did:plc:alice/org.hypercerts.helper.workScopeTag/abc123",
|
|
70
71
|
cid: "...",
|
|
71
72
|
},
|
|
73
|
+
// OR a simple string: workScope: "Environmental conservation",
|
|
72
74
|
startDate: "2023-01-01T00:00:00Z",
|
|
73
75
|
endDate: "2023-12-31T23:59:59Z",
|
|
74
76
|
createdAt: new Date().toISOString(),
|
|
@@ -87,6 +89,95 @@ await agent.api.com.atproto.repo.createRecord({
|
|
|
87
89
|
});
|
|
88
90
|
```
|
|
89
91
|
|
|
92
|
+
### Creating Location Records
|
|
93
|
+
|
|
94
|
+
Location records (`app.certified.location`) specify where work was performed
|
|
95
|
+
using geographic coordinates or other location formats. They can be referenced
|
|
96
|
+
by activities, collections, attachments, measurements, and evaluations.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
import { LOCATION_NSID } from "@hypercerts-org/lexicon";
|
|
100
|
+
|
|
101
|
+
const locationRecord = {
|
|
102
|
+
$type: LOCATION_NSID,
|
|
103
|
+
lpVersion: "1.0", // Location Protocol version
|
|
104
|
+
srs: "http://www.opengis.net/def/crs/OGC/1.3/CRS84", // Spatial Reference System
|
|
105
|
+
locationType: "coordinate-decimal", // or "geojson-point"
|
|
106
|
+
location: {
|
|
107
|
+
uri: "https://example.com/location-data.geojson",
|
|
108
|
+
},
|
|
109
|
+
// Optional fields
|
|
110
|
+
name: "Project Site A",
|
|
111
|
+
description: "Primary research facility in the Amazon rainforest",
|
|
112
|
+
createdAt: new Date().toISOString(),
|
|
113
|
+
};
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `lpVersion` (required): Version of the Location Protocol specification
|
|
117
|
+
- `srs` (required): Spatial Reference System URI defining the coordinate system
|
|
118
|
+
- `locationType` (required): Format identifier (e.g., "coordinate-decimal", "geojson-point")
|
|
119
|
+
- `location` (required): Location data as URI, blob, or string
|
|
120
|
+
- `name` (optional): Human-readable name for the location
|
|
121
|
+
- `description` (optional): Additional context about the location
|
|
122
|
+
- `createdAt` (required): Timestamp when the record was created
|
|
123
|
+
|
|
124
|
+
**Location data formats:**
|
|
125
|
+
|
|
126
|
+
The `location` field accepts three formats:
|
|
127
|
+
|
|
128
|
+
1. **URI reference**: `{ uri: "https://..." }` - Link to external location data
|
|
129
|
+
2. **Small blob**: Embedded location data (up to 10MB)
|
|
130
|
+
3. **Location string**: Inline string wrapped in an object, containing coordinates or GeoJSON
|
|
131
|
+
|
|
132
|
+
```typescript
|
|
133
|
+
// Example with embedded blob
|
|
134
|
+
const locationWithBlob = {
|
|
135
|
+
$type: LOCATION_NSID,
|
|
136
|
+
lpVersion: "1.0",
|
|
137
|
+
srs: "http://www.opengis.net/def/crs/OGC/1.3/CRS84",
|
|
138
|
+
locationType: "geojson-point",
|
|
139
|
+
location: {
|
|
140
|
+
blob: {
|
|
141
|
+
$type: "blob",
|
|
142
|
+
ref: {
|
|
143
|
+
$link: "bafyrei...", // CID of the uploaded blob
|
|
144
|
+
},
|
|
145
|
+
mimeType: "application/geo+json",
|
|
146
|
+
size: 123,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
name: "Amazon Research Station",
|
|
150
|
+
createdAt: new Date().toISOString(),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Example with inline string (coordinates)
|
|
154
|
+
const locationWithCoordinates = {
|
|
155
|
+
$type: LOCATION_NSID,
|
|
156
|
+
lpVersion: "1.0",
|
|
157
|
+
srs: "http://www.opengis.net/def/crs/OGC/1.3/CRS84",
|
|
158
|
+
locationType: "coordinate-decimal",
|
|
159
|
+
location: {
|
|
160
|
+
string: "-3.4653, -62.2159", // lat, lon
|
|
161
|
+
},
|
|
162
|
+
name: "Amazon Research Site",
|
|
163
|
+
description: "Field station coordinates",
|
|
164
|
+
createdAt: new Date().toISOString(),
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Example with inline GeoJSON string
|
|
168
|
+
const locationWithGeoJSON = {
|
|
169
|
+
$type: LOCATION_NSID,
|
|
170
|
+
lpVersion: "1.0",
|
|
171
|
+
srs: "http://www.opengis.net/def/crs/OGC/1.3/CRS84",
|
|
172
|
+
locationType: "geojson-point",
|
|
173
|
+
location: {
|
|
174
|
+
string: '{"type":"Point","coordinates":[-62.2159,-3.4653]}',
|
|
175
|
+
},
|
|
176
|
+
name: "Research Station Alpha",
|
|
177
|
+
createdAt: new Date().toISOString(),
|
|
178
|
+
};
|
|
179
|
+
```
|
|
180
|
+
|
|
90
181
|
### Accessing NSIDs (Lexicon IDs)
|
|
91
182
|
|
|
92
183
|
**Recommended**: Use individual NSID constants for cleaner, more readable code:
|
|
@@ -320,3 +411,56 @@ const collectionRecord = {
|
|
|
320
411
|
```
|
|
321
412
|
|
|
322
413
|
The `location` field is a strong reference to an `app.certified.location` record containing the same `uri` and `cid` fields as described above for activities.
|
|
414
|
+
|
|
415
|
+
### Creating Attachments
|
|
416
|
+
|
|
417
|
+
Attachments provide commentary, context, evidence, or documentary material
|
|
418
|
+
related to hypercert records. They can be linked to activities, evaluations,
|
|
419
|
+
measurements, or even other attachments:
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
import { ATTACHMENT_NSID } from "@hypercerts-org/lexicon";
|
|
423
|
+
|
|
424
|
+
const attachmentRecord = {
|
|
425
|
+
$type: ATTACHMENT_NSID,
|
|
426
|
+
title: "Field Survey Report",
|
|
427
|
+
subjects: [
|
|
428
|
+
{
|
|
429
|
+
uri: "at://did:plc:alice/org.hypercerts.claim.activity/abc123",
|
|
430
|
+
cid: "...",
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
contentType: "report",
|
|
434
|
+
content: [
|
|
435
|
+
{ uri: "https://example.com/reports/survey-2024.pdf" },
|
|
436
|
+
{ uri: "ipfs://Qm..." },
|
|
437
|
+
],
|
|
438
|
+
shortDescription: "Quarterly field survey documenting project progress",
|
|
439
|
+
createdAt: new Date().toISOString(),
|
|
440
|
+
};
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
**Key fields:**
|
|
444
|
+
|
|
445
|
+
- `title` (required): String title for the attachment
|
|
446
|
+
- `shortDescription`/`description`: Support rich text via facet annotations
|
|
447
|
+
- `subjects` (optional): Array of strong references to records this attachment relates to
|
|
448
|
+
- `contentType` (optional): Type descriptor (e.g., "report", "audit", "evidence", "testimonial")
|
|
449
|
+
- `content` (required): Array of URIs or blobs containing the attachment files
|
|
450
|
+
- `location` (optional): Strong reference to an `app.certified.location` record
|
|
451
|
+
- `createdAt` (required): Timestamp when the attachment was created
|
|
452
|
+
|
|
453
|
+
**Adding Location to Attachments:**
|
|
454
|
+
|
|
455
|
+
```typescript
|
|
456
|
+
const attachmentWithLocation = {
|
|
457
|
+
$type: ATTACHMENT_NSID,
|
|
458
|
+
title: "Site Inspection Photos",
|
|
459
|
+
content: [{ uri: "https://..." }],
|
|
460
|
+
location: {
|
|
461
|
+
uri: "at://did:plc:alice/app.certified.location/loc123",
|
|
462
|
+
cid: "...",
|
|
463
|
+
},
|
|
464
|
+
createdAt: new Date().toISOString(),
|
|
465
|
+
};
|
|
466
|
+
```
|