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
21 changes: 11 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ GRC-20 is designed for encoding, decoding, and synchronizing graph data across d

## Features

- **Property Graph Model** — Entities, relations, and typed properties with 12 data types
- **Property Graph Model** — Entities, relations, and typed properties with 13 data types
- **Event Sourced** — All state changes expressed as append-only operations
- **Binary Optimized** — Dictionary interning and zstd compression for minimal wire size
- **Deterministic** — Canonical encoding for content addressing and signatures
Expand Down Expand Up @@ -56,8 +56,8 @@ import { EditBuilder, encodeEdit, decodeEdit, properties } from '@geoprotocol/gr

// Create an edit
const edit = new EditBuilder(editId)
.name('My Edit')
.author(authorId)
.setName('My Edit')
.addAuthor(authorId)
.createEntity(entityId, (e) => e.text(properties.name(), 'Hello'))
.build();

Expand All @@ -78,11 +78,12 @@ const decoded = decodeEdit(bytes);
| `DECIMAL` | Arbitrary-precision decimal (with optional unit) |
| `TEXT` | UTF-8 string (with optional language) |
| `BYTES` | Opaque byte array |
| `DATE` | ISO 8601 date (year, month, or day precision) |
| `TIME` | ISO 8601 time (HH:MM:SS with optional timezone) |
| `DATETIME` | ISO 8601 date-time with timezone |
| `SCHEDULE` | Recurring schedule (cron-like) |
| `POINT` | WGS84 coordinates (lat, lon) |
| `DATE` | Calendar date with timezone |
| `TIME` | Time of day with timezone |
| `DATETIME` | Timestamp with timezone |
| `SCHEDULE` | RFC 5545/7953 iCalendar schedule |
| `POINT` | WGS84 coordinates (lat, lon, optional alt) |
| `RECT` | Axis-aligned bounding box |
| `EMBEDDING` | Dense vectors for semantic search |

## Operations
Expand All @@ -107,7 +108,7 @@ Value references allow creating referenceable values that can be used as relatio

```typescript
// Create a value ref that can be targeted by relations
.createValueRef(valueRefId, entityId, propId, value)
.addOp({ type: 'createValueRef', id: valueRefId, entity: entityId, property: propId })
```

### Multi-Language Support
Expand All @@ -120,7 +121,7 @@ e.text(nameProp, "Hello", languages.english())
e.text(nameProp, "Hola", languages.spanish())

// Unset specific language variant
u.unsetText(nameProp, languages.english())
u.unsetLanguage(nameProp, languages.english())
```

### Relation Features
Expand Down
9 changes: 4 additions & 5 deletions rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ assert_eq!(edit.id, decoded.id);

### Data Types

All 12 GRC-20 data types are supported:
All 13 GRC-20 data types are supported:

| Type | Rust Representation | Wire Size |
|------|---------------------|-----------|
Expand All @@ -75,8 +75,9 @@ All 12 GRC-20 data types are supported:
| DATE | `Value::Date(Cow<str>)` | 6 bytes |
| TIME | `Value::Time(Cow<str>)` | 8 bytes |
| DATETIME | `Value::Datetime(Cow<str>)` | 10 bytes |
| SCHEDULE | `Value::Schedule(String)` | variable |
| POINT | `Value::Point { lon, lat, alt }` | 17-25 bytes |
| SCHEDULE | `Value::Schedule(Cow<str>)` | variable |
| POINT | `Value::Point { lat, lon, alt }` | 17-25 bytes |
| RECT | `Value::Rect { min_lat, min_lon, max_lat, max_lon }` | 32 bytes |
| EMBEDDING | `Value::Embedding { sub_type, dims, data }` | variable |

**Temporal types use RFC 3339 strings in the API:**
Expand Down Expand Up @@ -184,7 +185,6 @@ let edit = decode_edit_borrowed(&bytes)?;
// Strings borrow from input buffer - no allocation
assert!(matches!(edit.name, Cow::Borrowed(_)));
```
- `CreateValueRef` — Create a referenceable ID for a value slot

### Compression

Expand Down Expand Up @@ -213,7 +213,6 @@ let description_prop = properties::description();

// Core types
let person_type = types::person();
let organization_type = types::organization();

// Core relation types
let types_rel = relation_types::types();
Expand Down
16 changes: 7 additions & 9 deletions typescript/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ const edit = new EditBuilder(editId)
.updateEntity(entityId, u => u
.setText(propId, "new value", undefined)
.setInt64(propId, 100n, undefined)
.unsetText(propId, languageId) // Unset specific language
.unsetAll(propId) // Unset all values for property
.unsetLanguage(propId, languageId) // Unset specific language
.unsetAll(propId) // Unset all values for property
)
.deleteEntity(entityId)
.restoreEntity(entityId)
Expand All @@ -139,10 +139,7 @@ const edit = new EditBuilder(editId)
)
.deleteRelation(relationId)
.restoreRelation(relationId)
.createValueRef(valueRefId, entityId, propId, {
type: "text",
value: "Referenceable value"
})
.addOp({ type: 'createValueRef', id: valueRefId, entity: entityId, property: propId })
.build();
```

Expand Down Expand Up @@ -301,9 +298,10 @@ if (!posResult.valid) {
| `DATE` | `{ type: "date", value: string }` (RFC 3339, e.g. `"2024-01-15Z"`) |
| `TIME` | `{ type: "time", value: string }` (RFC 3339, e.g. `"14:30:00Z"`) |
| `DATETIME` | `{ type: "datetime", value: string }` (RFC 3339, e.g. `"2024-01-15T14:30:00Z"`) |
| `SCHEDULE` | `{ type: "schedule", value: string }` (cron-like) |
| `POINT` | `{ type: "point", lat: number, lon: number }` |
| `EMBEDDING` | `{ type: "embedding", subType: EmbeddingSubType.Float32 \| EmbeddingSubType.Int8 \| EmbeddingSubType.Binary, data: number[] }` |
| `SCHEDULE` | `{ type: "schedule", value: string }` (RFC 5545/7953 iCalendar) |
| `POINT` | `{ type: "point", lat: number, lon: number, alt?: number }` |
| `RECT` | `{ type: "rect", minLat: number, minLon: number, maxLat: number, maxLon: number }` |
| `EMBEDDING` | `{ type: "embedding", subType: EmbeddingSubType, dims: number, data: Uint8Array }` |

### Genesis IDs

Expand Down