projectionslisted
Install: claude install-skill diegosouzapw/awesome-omni-skill
# Projections Skill
## Core Principle
**State is derived from TES events. Projections are the queryable current truth.**
---
## Projection Types
| Projection | Purpose | Key |
|------------|---------|-----|
| ItemCurrentState | Current state of an item | item canonical_id |
| ListingCurrentState | Current listing status | listing canonical_id |
| ParticipantInventory | What a user owns | participant canonical_id |
| CampaignState | Campaign metrics | campaign canonical_id |
---
## Durable Object Pattern
```javascript
// workers/projections/ItemProjection.js
export class ItemProjection {
constructor(state, env) {
this.state = state;
this.env = env;
}
async fetch(request) {
const url = new URL(request.url);
if (request.method === "GET") {
const currentState = await this.state.storage.get("state");
return Response.json(currentState || { error: "Not found" });
}
if (request.method === "POST" && url.pathname === "/apply-event") {
const event = await request.json();
return this.applyEvent(event);
}
}
async applyEvent(event) {
// Idempotency check
const processedEvents = await this.state.storage.get("processed") || [];
if (processedEvents.includes(event.id)) {
return Response.json({ status: "already_processed" });
}
// Get current state
let state = await this.state.storage.get("state") || this.initialState();
// Apply event
state = this.reduce(state, event);
state.l