-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample-usage.js
More file actions
61 lines (52 loc) · 1.99 KB
/
example-usage.js
File metadata and controls
61 lines (52 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Example: How to use the AI-accessible event data
// Import the AI reference functions
import {
getEventByKind,
searchEventsByUsage,
getEventsByCategory,
getAllImplementationNotes,
getAllCommonGotchas
} from './src/data/ai-event-reference.ts';
import {
getEventImplementationGuide,
validateEventStructure,
searchEventsByUsagePattern
} from './src/lib/eventData.ts';
// 1. Get complete info about a specific event kind
const profileEvent = getEventByKind(0);
console.log("Profile Event Summary:", profileEvent.summary);
console.log("Use Cases:", profileEvent.useCases);
console.log("Implementation Notes:", profileEvent.implementationNotes);
console.log("Common Gotchas:", profileEvent.commonGotchas);
console.log("Basic Example:", profileEvent.basicExample.code);
// 2. Search events by use case
const messagingEvents = searchEventsByUsage("direct message");
console.log("Events for messaging:", messagingEvents.map(e => `${e.kind}: ${e.name}`));
// 3. Get events by category
const replaceableEvents = getEventsByCategory('replaceable');
console.log("Replaceable events:", replaceableEvents.map(e => `${e.kind}: ${e.name}`));
// 4. Get complete implementation guide
const guide = getEventImplementationGuide(1); // Text notes
console.log("Complete guide for text notes:", {
eventKind: guide.eventKind?.name,
aiReference: guide.aiReference?.summary,
exampleCount: guide.examples.length,
relatedEvents: guide.relatedEvents.length
});
// 5. Validate an event before publishing
const testEvent = {
id: "abc123",
pubkey: "def456",
created_at: Math.floor(Date.now() / 1000),
kind: 7,
tags: [["e", "target123"], ["p", "author456"]],
content: "+",
sig: "signature"
};
const validation = validateEventStructure(testEvent);
console.log("Event validation:", validation);
// 6. Get all implementation wisdom
const allNotes = getAllImplementationNotes();
const allGotchas = getAllCommonGotchas();
console.log("All implementation notes:", allNotes);
console.log("All common gotchas:", allGotchas);