Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .changeset/add-location-to-attachment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
"@hypercerts-org/lexicon": patch
---

Add location property to attachment schema

**New Feature:**

- **`location` field** (`org.hypercerts.claim.attachment`):
- Added optional `location` property as a strong reference (`com.atproto.repo.strongRef`)
- Allows attachments to associate location metadata directly without using the sidecar pattern
- The referenced record must conform to the `app.certified.location` lexicon

**Usage:**

```json
{
"$type": "org.hypercerts.claim.attachment",
"subjects": [
{
"uri": "at://did:plc:.../org.hypercerts.claim.activity/...",
"cid": "..."
}
],
"content": [{ "uri": "https://..." }],
"title": "Field Report",
"location": {
"uri": "at://did:plc:.../app.certified.location/abc123",
"cid": "..."
},
"createdAt": "..."
}
```

This change aligns with the location property addition to collections (PR #123), providing a consistent pattern for associating location metadata across record types.
61 changes: 61 additions & 0 deletions .changeset/rename-evidence-to-attachment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
"@hypercerts-org/lexicon": minor
---

Rename evidence lexicon to attachment and refactor schema structure

**Breaking Changes:**

- **Lexicon ID change:**
- `org.hypercerts.claim.evidence` → `org.hypercerts.claim.attachment`
- All existing evidence records must be migrated to use the new lexicon ID

- **Schema structure changes (`org.hypercerts.claim.attachment`):**
- Changed `subject` (single strongRef) to `subjects` (array of strongRefs, maxLength: 100)
- Changed `content` from single union (uri/blob) to array of unions (maxLength: 100)
- Added `contentType` field (string, maxLength: 64) to specify attachment type
- Removed `relationType` field (previously used to indicate supports/challenges/clarifies)
- Removed `contributors` field
- Removed `locations` field
- Added rich text support: `shortDescriptionFacets` and `descriptionFacets` (arrays of `app.bsky.richtext.facet`)
- Updated required fields: `["title", "content", "createdAt"]` (content is now required)

- **Common definitions (`org.hypercerts.defs`):**
- Added `weightedContributor` def for contributor references with optional weights
- Added `contributorIdentity` def for string-based contributor identification

Comment thread
coderabbitai[bot] marked this conversation as resolved.
**Migration:**

**Lexicon ID:** Update all references from `org.hypercerts.claim.evidence` to `org.hypercerts.claim.attachment`.

**Schema migration:**

```json
// Before (org.hypercerts.claim.evidence)
{
"$type": "org.hypercerts.claim.evidence",
"subject": { "uri": "...", "cid": "..." },
"content": { "uri": "https://..." },
"title": "Evidence Title",
"relationType": "supports",
"createdAt": "..."
}

// After (org.hypercerts.claim.attachment)
{
"$type": "org.hypercerts.claim.attachment",
"subjects": [{ "uri": "...", "cid": "..." }],
"content": [{ "uri": "https://..." }],
"contentType": "evidence",
"title": "Evidence Title",
"createdAt": "..."
}
```

**Field mapping:**

- `subject` → `subjects` (wrap in array)
- `content` (single) → `content` (array, wrap existing value)
- `relationType` → remove (no direct replacement)
- `contributors` → remove (no direct replacement)
- `locations` → remove (no direct replacement)
22 changes: 12 additions & 10 deletions ERD.puml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,16 @@ dataclass activity <<largeBold>> #B4E5D0 {
!endif
}

' org.hypercerts.claim.evidence
dataclass evidence {
' org.hypercerts.claim.attachment
dataclass attachment {
!if (SHOW_FIELDS == "true")
subject?
content
subjects[]?
contentType?
content[]
title
shortDescription?
description?
relationType?
location?
createdAt
!endif
}
Expand Down Expand Up @@ -238,20 +239,20 @@ protocol token <<largeBold>> #FFB6C1 {
}

' layout hints
'evaluation --d[hidden]-> evidence
'evaluation --d[hidden]-> attachment
'evaluation --d[hidden]-> measurement
'measurement -d[hidden]-> activity
'evidence -r[hidden]-> measurement
'attachment -r[hidden]-> measurement
'activity -r[hidden]-> token
'evidence -d[hidden]-> activity
'attachment -d[hidden]-> activity
'collection -d[hidden]-> activity
'activity -u[hidden]-> contributor
'activity -u[hidden]-> location
'activity -d[hidden]-> rights
'contribution -r[hidden]-> contributor
'fundingReceipt -[hidden]-> contributor

evaluation::subject --> evidence
evaluation::subject --> attachment
evaluation::measurements --> measurement
evaluation::subject --> activity

Expand All @@ -275,7 +276,8 @@ hiddenLocation1 -[hidden]-> activity
'evaluation -d[norank]--> location
!endif

evidence::subject --> activity
attachment::subjects --> activity
attachment::location --> location

measurement::subject --> activity

Expand Down
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,56 @@ const collectionRecord = {
```

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.

### Creating Attachments

Attachments provide commentary, context, evidence, or documentary material
related to hypercert records. They can be linked to activities, evaluations,
measurements, or even other attachments:

```typescript
import { ATTACHMENT_NSID } from "@hypercerts-org/lexicon";

const attachmentRecord = {
$type: ATTACHMENT_NSID,
title: "Field Survey Report",
subjects: [
{
uri: "at://did:plc:alice/org.hypercerts.claim.activity/abc123",
cid: "...",
},
],
contentType: "report",
content: [
{ uri: "https://example.com/reports/survey-2024.pdf" },
{ uri: "ipfs://Qm..." },
],
shortDescription: "Quarterly field survey documenting project progress",
createdAt: new Date().toISOString(),
};
```

**Key fields:**

- `title` (required): String title for the attachment
- `shortDescription`/`description`: Support rich text via facet annotations
- `subjects` (optional): Array of strong references to records this attachment relates to
- `contentType` (optional): Type descriptor (e.g., "report", "audit", "evidence", "testimonial")
- `content` (required): Array of URIs or blobs containing the attachment files
- `location` (optional): Strong reference to an `app.certified.location` record
- `createdAt` (required): Timestamp when the attachment was created

Comment thread
coderabbitai[bot] marked this conversation as resolved.
**Adding Location to Attachments:**

```typescript
const attachmentWithLocation = {
$type: ATTACHMENT_NSID,
title: "Site Inspection Photos",
content: [{ uri: "https://..." }],
location: {
uri: "at://did:plc:alice/app.certified.location/loc123",
cid: "...",
},
createdAt: new Date().toISOString(),
};
```
Loading