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
45 changes: 45 additions & 0 deletions .changeset/add-collection-item-weights.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
"@hypercerts-org/lexicon": minor
---

Refactor collection items structure to support optional weights and remove activityWeight from activity schema

**Breaking Changes:**

- **Activity lexicon (`org.hypercerts.claim.activity`):**
- Removed `org.hypercerts.claim.activity#activityWeight` def
- Activity records no longer include activity weight information

- **Collection lexicon (`org.hypercerts.claim.collection`):**
- Changed `org.hypercerts.claim.collection#items` from array of strongRefs to array of item objects
- Added `org.hypercerts.claim.collection#item` def with:
- `itemIdentifier` (required): strongRef to an item (activity or collection)
- `itemWeight` (optional): positive numeric value stored as string
- Supports recursive collection nesting (items can reference activities or other collections)

**Migration:**

**Collection items:** Convert from array of strongRefs to array of item objects:

```json
// Before
"items": [strongRef1, strongRef2]

// After
"items": [
{ "itemIdentifier": strongRef1, "itemWeight": "1.5" },
{ "itemIdentifier": strongRef2 }
]
```

**Activity weights:** Migrate existing `org.hypercerts.claim.activity#activityWeight` data to collection `org.hypercerts.claim.collection#item.itemWeight`:

```json
// Old (removed from activity)
{ "activity": { "uri": "...", "cid": "..." }, "weight": "1.5" }

// New (in collection items)
{ "itemIdentifier": { "uri": "...", "cid": "..." }, "itemWeight": "1.5" }
```

Update collections that reference activities to include weights in `org.hypercerts.claim.collection#item.itemWeight`. Weights can be dropped if not needed.
5 changes: 0 additions & 5 deletions .changeset/refactor-collection-items-array.md

This file was deleted.

36 changes: 19 additions & 17 deletions SCHEMAS.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ Hypercerts-specific lexicons for tracking impact work and claims.
| `weight` | `string` | ❌ | The relative weight/importance of this contribution (stored as a string to avoid float precision issues). Must be a positive numeric value. Weights do not need to sum to a specific total; normalization can be performed by the consuming application as needed. |
| `contributionDetails` | `union` | ❌ | Contribution details as a string or strong reference to org.hypercerts.claim.contributionDetails#main. |

##### activityWeight

| Property | Type | Required | Description |
| ---------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `activity` | `ref` | ✅ | A strong reference to a hypercert activity record. This activity must conform to the lexicon org.hypercerts.claim.activity |
| `weight` | `string` | ✅ | The relative weight/importance of this hypercert activity (stored as a string to avoid float precision issues). Weights can be any positive numeric values and do not need to sum to a specific total; normalization can be performed by the consuming application as needed. |

---

### `org.hypercerts.claim.evaluation`
Expand Down Expand Up @@ -131,16 +124,25 @@ Hypercerts-specific lexicons for tracking impact work and claims.

#### Properties

| Property | Type | Required | Description | Comments |
| ------------------ | -------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| `type` | `string` | ❌ | The type of this collection. Possible fields can be 'favorites', 'project', or any other type of collection. | |
| `title` | `string` | ✅ | The title of this collection | maxLength: 800, maxGraphemes: 80 |
| `shortDescription` | `string` | ❌ | Short summary of this collection, suitable for previews and list views | maxLength: 3000, maxGraphemes: 300 |
| `description` | `ref` | ❌ | Rich-text description, represented as a Leaflet linear document. | |
| `avatar` | `union` | ❌ | The collection's avatar/profile image as a URI or image blob. | |
| `banner` | `union` | ❌ | Larger horizontal image to display behind the collection view. | |
| `items` | `ref` | ✅ | Array of strong references to items in this collection. Items can be activities (org.hypercerts.claim.activity) and/or other collections (org.hypercerts.claim.collection). | |
| `createdAt` | `string` | ✅ | Client-declared timestamp when this record was originally created | |
| Property | Type | Required | Description | Comments |
| ------------------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------ | ---------------------------------- |
| `type` | `string` | ❌ | The type of this collection. Possible fields can be 'favorites', 'project', or any other type of collection. | |
| `title` | `string` | ✅ | The title of this collection | maxLength: 800, maxGraphemes: 80 |
| `shortDescription` | `string` | ❌ | Short summary of this collection, suitable for previews and list views | maxLength: 3000, maxGraphemes: 300 |
| `description` | `ref` | ❌ | Rich-text description, represented as a Leaflet linear document. | |
| `avatar` | `union` | ❌ | The collection's avatar/profile image as a URI or image blob. | |
| `banner` | `union` | ❌ | Larger horizontal image to display behind the collection view. | |
| `items` | `ref` | ✅ | Array of items in this collection with optional weights. | |
| `createdAt` | `string` | ✅ | Client-declared timestamp when this record was originally created | |

#### Defs

##### item

| Property | Type | Required | Description |
| ---------------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `itemIdentifier` | `ref` | ✅ | Strong reference to an item in this collection. Items can be activities (org.hypercerts.claim.activity) and/or other collections (org.hypercerts.claim.collection). |
| `itemWeight` | `string` | ❌ | Optional weight for this item (positive numeric value stored as string). Weights do not need to sum to a specific total; normalization can be performed by the consuming application as needed. |

---

Expand Down
15 changes: 0 additions & 15 deletions lexicons/org/hypercerts/claim/activity.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,21 +124,6 @@
"description": "Contribution details as a string.",
"maxLength": 10000,
"maxGraphemes": 1000
},
"activityWeight": {
"type": "object",
"required": ["activity", "weight"],
"properties": {
"activity": {
"type": "ref",
"ref": "com.atproto.repo.strongRef",
"description": "A strong reference to a hypercert activity record. This activity must conform to the lexicon org.hypercerts.claim.activity"
},
"weight": {
"type": "string",
"description": "The relative weight/importance of this hypercert activity (stored as a string to avoid float precision issues). Weights can be any positive numeric values and do not need to sum to a specific total; normalization can be performed by the consuming application as needed."
}
}
}
}
}
19 changes: 17 additions & 2 deletions lexicons/org/hypercerts/claim/collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@
},
"items": {
"type": "array",
"description": "Array of strong references to items in this collection. Items can be activities (org.hypercerts.claim.activity) and/or other collections (org.hypercerts.claim.collection).",
"description": "Array of items in this collection with optional weights.",
"items": {
"type": "ref",
"ref": "com.atproto.repo.strongRef"
"ref": "#item"
}
},
"createdAt": {
Expand All @@ -62,6 +62,21 @@
}
}
}
},
"item": {
"type": "object",
"required": ["itemIdentifier"],
"properties": {
"itemIdentifier": {
"type": "ref",
"ref": "com.atproto.repo.strongRef",
"description": "Strong reference to an item in this collection. Items can be activities (org.hypercerts.claim.activity) and/or other collections (org.hypercerts.claim.collection)."
},
"itemWeight": {
"type": "string",
"description": "Optional weight for this item (positive numeric value stored as string). Weights do not need to sum to a specific total; normalization can be performed by the consuming application as needed."
}
}
}
}
}