oneie 3.6.27 → 3.6.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/agents/agent-builder.md +88 -0
- package/.claude/agents/agent-clone.md +2 -0
- package/.claude/agents/agent-frontend.md +87 -0
- package/.claude/agents/agent-writer.md +722 -0
- package/.claude/commands/create.md +26 -1
- package/.claude/commands/one.md +70 -8
- package/.claude/commands/push.md +42 -24
- package/.claude/commands/server.md +97 -48
- package/.claude/commands/start.md +182 -0
- package/.claude/hooks/.last-news-context +1 -0
- package/.claude/hooks/README-news-generation.md +364 -0
- package/.claude/hooks/push.sh +64 -12
- package/.claude/hooks/write-news.sh +194 -0
- package/CLAUDE.md +150 -1057
- package/one/knowledge/ontology-cheatsheet.md +78 -70
- package/one/knowledge/ontology-developer-guide.md +94 -87
- package/one/knowledge/ontology-index.md +51 -26
- package/one/knowledge/ontology-quickstart.md +58 -50
- package/one/knowledge/ontology-tutorial.md +27 -24
- package/one/knowledge/ontology-video-script.md +90 -59
- package/one/things/plans/multi-ontology-architecture.md +8 -8
- package/one/things/plans/ontology-compliance-audit.md +36 -9
- package/one/things/plans/video-backend.md +638 -0
- package/one/things/plans/video-frontend.md +432 -0
- package/one/things/plans/video-old-archived.md +656 -0
- package/package.json +1 -1
|
@@ -11,15 +11,15 @@ version: 1.0.0
|
|
|
11
11
|
ai_context: |
|
|
12
12
|
This document is part of the knowledge dimension in the ontology-tutorial.md category.
|
|
13
13
|
Location: one/knowledge/ontology-tutorial.md
|
|
14
|
-
Purpose: Documents
|
|
14
|
+
Purpose: Documents ONE Ontology architecture: interactive tutorial
|
|
15
15
|
Related dimensions: connections, events, groups, people, things
|
|
16
16
|
For AI agents: Read this to understand ontology tutorial.
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# ONE Ontology Architecture: Interactive Tutorial
|
|
20
20
|
|
|
21
21
|
**Version:** 1.0.0
|
|
22
|
-
**Purpose:** Learn the
|
|
22
|
+
**Purpose:** Learn the ONE Ontology system from basics to advanced patterns
|
|
23
23
|
**Audience:** Developers, AI agents, platform builders
|
|
24
24
|
|
|
25
25
|
---
|
|
@@ -134,8 +134,8 @@ connectionTypes:
|
|
|
134
134
|
|
|
135
135
|
- name: authored
|
|
136
136
|
description: "Creator authored post"
|
|
137
|
-
fromType: creator
|
|
138
|
-
toType: blog_post
|
|
137
|
+
fromType: creator # From core ontology
|
|
138
|
+
toType: blog_post # From this feature
|
|
139
139
|
|
|
140
140
|
eventTypes:
|
|
141
141
|
- name: post_published
|
|
@@ -165,18 +165,21 @@ Let's create a **newsletter** feature step-by-step.
|
|
|
165
165
|
Before writing YAML, answer these questions:
|
|
166
166
|
|
|
167
167
|
**What entities do we need?** (Things)
|
|
168
|
+
|
|
168
169
|
- `newsletter` - The newsletter publication
|
|
169
170
|
- `newsletter_issue` - Individual issues/editions
|
|
170
171
|
- `subscriber` - Someone subscribed to newsletter
|
|
171
172
|
- `newsletter_campaign` - Email campaign sending issues
|
|
172
173
|
|
|
173
174
|
**How do they relate?** (Connections)
|
|
175
|
+
|
|
174
176
|
- `creator` → `newsletter` (owns)
|
|
175
177
|
- `newsletter` → `newsletter_issue` (part_of)
|
|
176
178
|
- `subscriber` → `newsletter` (subscribed_to)
|
|
177
179
|
- `newsletter_campaign` → `newsletter_issue` (sends)
|
|
178
180
|
|
|
179
181
|
**What actions happen?** (Events)
|
|
182
|
+
|
|
180
183
|
- `newsletter_created` - New newsletter created
|
|
181
184
|
- `newsletter_subscribed` - Someone subscribed
|
|
182
185
|
- `newsletter_unsubscribed` - Someone unsubscribed
|
|
@@ -208,7 +211,7 @@ thingTypes:
|
|
|
208
211
|
title: string
|
|
209
212
|
description: string
|
|
210
213
|
slug: string
|
|
211
|
-
schedule: string
|
|
214
|
+
schedule: string # daily, weekly, monthly
|
|
212
215
|
subscriberCount: number
|
|
213
216
|
issueCount: number
|
|
214
217
|
|
|
@@ -217,12 +220,12 @@ thingTypes:
|
|
|
217
220
|
description: "Individual newsletter edition"
|
|
218
221
|
properties:
|
|
219
222
|
title: string
|
|
220
|
-
content: string
|
|
223
|
+
content: string # HTML or Markdown
|
|
221
224
|
slug: string
|
|
222
|
-
publishedAt: number
|
|
223
|
-
sentAt: number
|
|
224
|
-
openRate: number
|
|
225
|
-
clickRate: number
|
|
225
|
+
publishedAt: number # Timestamp
|
|
226
|
+
sentAt: number # When sent to subscribers
|
|
227
|
+
openRate: number # Percentage
|
|
228
|
+
clickRate: number # Percentage
|
|
226
229
|
|
|
227
230
|
# Newsletter subscriber
|
|
228
231
|
- name: subscriber
|
|
@@ -232,9 +235,9 @@ thingTypes:
|
|
|
232
235
|
firstName: string
|
|
233
236
|
lastName: string
|
|
234
237
|
subscribedAt: number
|
|
235
|
-
source: string
|
|
236
|
-
tags: string[]
|
|
237
|
-
active: boolean
|
|
238
|
+
source: string # Where they signed up
|
|
239
|
+
tags: string[] # Subscriber tags/segments
|
|
240
|
+
active: boolean # Active subscription
|
|
238
241
|
|
|
239
242
|
# Email campaign for sending issues
|
|
240
243
|
- name: newsletter_campaign
|
|
@@ -244,13 +247,13 @@ thingTypes:
|
|
|
244
247
|
previewText: string
|
|
245
248
|
fromName: string
|
|
246
249
|
fromEmail: string
|
|
247
|
-
scheduledFor: number
|
|
248
|
-
sentAt: number
|
|
250
|
+
scheduledFor: number # When to send
|
|
251
|
+
sentAt: number # When actually sent
|
|
249
252
|
recipientCount: number
|
|
250
253
|
deliveredCount: number
|
|
251
254
|
openCount: number
|
|
252
255
|
clickCount: number
|
|
253
|
-
status: string
|
|
256
|
+
status: string # draft, scheduled, sending, sent
|
|
254
257
|
|
|
255
258
|
# ============================================================================
|
|
256
259
|
# Connection Types - How things relate
|
|
@@ -260,11 +263,11 @@ connectionTypes:
|
|
|
260
263
|
# Creator owns newsletter
|
|
261
264
|
- name: owns_newsletter
|
|
262
265
|
description: "Creator owns newsletter publication"
|
|
263
|
-
fromType: creator
|
|
266
|
+
fromType: creator # From core ontology
|
|
264
267
|
toType: newsletter
|
|
265
268
|
metadata:
|
|
266
|
-
role: string
|
|
267
|
-
permissions: string[]
|
|
269
|
+
role: string # owner, editor, contributor
|
|
270
|
+
permissions: string[] # What they can do
|
|
268
271
|
|
|
269
272
|
# Newsletter contains issues
|
|
270
273
|
- name: part_of_newsletter
|
|
@@ -272,7 +275,7 @@ connectionTypes:
|
|
|
272
275
|
fromType: newsletter_issue
|
|
273
276
|
toType: newsletter
|
|
274
277
|
metadata:
|
|
275
|
-
issueNumber: number
|
|
278
|
+
issueNumber: number # Sequential issue number
|
|
276
279
|
|
|
277
280
|
# Subscriber subscribed to newsletter
|
|
278
281
|
- name: subscribed_to
|
|
@@ -281,9 +284,9 @@ connectionTypes:
|
|
|
281
284
|
toType: newsletter
|
|
282
285
|
metadata:
|
|
283
286
|
subscribedAt: number
|
|
284
|
-
source: string
|
|
285
|
-
doubleOptIn: boolean
|
|
286
|
-
preferences: object
|
|
287
|
+
source: string # Where they subscribed
|
|
288
|
+
doubleOptIn: boolean # Confirmed subscription
|
|
289
|
+
preferences: object # Email preferences
|
|
287
290
|
|
|
288
291
|
# Campaign sends issue
|
|
289
292
|
- name: sends
|
|
@@ -11,20 +11,20 @@ version: 1.0.0
|
|
|
11
11
|
ai_context: |
|
|
12
12
|
This document is part of the knowledge dimension in the ontology-video-script.md category.
|
|
13
13
|
Location: one/knowledge/ontology-video-script.md
|
|
14
|
-
Purpose: Documents
|
|
14
|
+
Purpose: Documents ONE Ontology tutorial video script
|
|
15
15
|
Related dimensions: connections, events, groups, people, things
|
|
16
16
|
For AI agents: Read this to understand ontology video script.
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
#
|
|
19
|
+
# ONE Ontology Tutorial Video Script
|
|
20
20
|
|
|
21
|
-
**Purpose:** Educational video series explaining the
|
|
21
|
+
**Purpose:** Educational video series explaining the ONE Ontology architecture
|
|
22
22
|
**Target Audience:** Developers building on ONE Platform
|
|
23
23
|
**Total Duration:** ~35 minutes (3 videos)
|
|
24
24
|
|
|
25
25
|
---
|
|
26
26
|
|
|
27
|
-
## Video 1: Introduction to
|
|
27
|
+
## Video 1: Introduction to ONE Ontology Architecture (5 minutes)
|
|
28
28
|
|
|
29
29
|
### [0:00-0:30] Hook
|
|
30
30
|
|
|
@@ -36,9 +36,10 @@ ai_context: |
|
|
|
36
36
|
|
|
37
37
|
What if adding a blog, newsletter, or course system was as simple as enabling a feature flag?
|
|
38
38
|
|
|
39
|
-
Welcome to the
|
|
39
|
+
Welcome to the ONE Ontology Architecture."
|
|
40
40
|
|
|
41
41
|
**ON-SCREEN TEXT:**
|
|
42
|
+
|
|
42
43
|
- No schema migrations
|
|
43
44
|
- Type-safe by default
|
|
44
45
|
- Infinite extensibility
|
|
@@ -58,6 +59,7 @@ Want to add a shop? Create tables for products, orders, inventory, shipping...
|
|
|
58
59
|
Before long, you have 50 tables, 200 columns, and a maintenance nightmare.
|
|
59
60
|
|
|
60
61
|
Every new feature requires:
|
|
62
|
+
|
|
61
63
|
- Database migrations
|
|
62
64
|
- Schema updates
|
|
63
65
|
- Breaking changes
|
|
@@ -67,11 +69,13 @@ There's a better way."
|
|
|
67
69
|
|
|
68
70
|
**ON-SCREEN TEXT:**
|
|
69
71
|
Traditional:
|
|
72
|
+
|
|
70
73
|
- 50+ tables
|
|
71
74
|
- Schema migrations
|
|
72
75
|
- Breaking changes
|
|
73
76
|
|
|
74
77
|
ONE:
|
|
78
|
+
|
|
75
79
|
- 6 dimensions
|
|
76
80
|
- YAML definitions
|
|
77
81
|
- Zero downtime
|
|
@@ -82,7 +86,7 @@ ONE:
|
|
|
82
86
|
|
|
83
87
|
**SCRIPT:**
|
|
84
88
|
|
|
85
|
-
"The
|
|
89
|
+
"The ONE Ontology Architecture solves this with 6 universal dimensions:
|
|
86
90
|
|
|
87
91
|
1. **Groups** - Who belongs where (organizations, teams, communities)
|
|
88
92
|
2. **People** - Who can do what (roles, permissions)
|
|
@@ -119,6 +123,7 @@ All type-safe. All auto-generated. Zero schema migrations."
|
|
|
119
123
|
**Video 3:** Advanced patterns - Multi-feature interactions, performance optimization, and production deployment. 20 minutes.
|
|
120
124
|
|
|
121
125
|
By the end, you'll be able to:
|
|
126
|
+
|
|
122
127
|
- Create custom features in minutes
|
|
123
128
|
- Compose features together
|
|
124
129
|
- Deploy with confidence
|
|
@@ -127,6 +132,7 @@ By the end, you'll be able to:
|
|
|
127
132
|
Let's get started."
|
|
128
133
|
|
|
129
134
|
**ON-SCREEN TEXT:**
|
|
135
|
+
|
|
130
136
|
- 3 videos, 35 minutes
|
|
131
137
|
- Build a real feature
|
|
132
138
|
- Production-ready patterns
|
|
@@ -144,6 +150,7 @@ Let's get started."
|
|
|
144
150
|
"Welcome back! In this video, we're building a complete newsletter feature from scratch.
|
|
145
151
|
|
|
146
152
|
We'll create:
|
|
153
|
+
|
|
147
154
|
- Newsletter publications
|
|
148
155
|
- Subscriber management
|
|
149
156
|
- Email campaigns
|
|
@@ -162,18 +169,21 @@ Let's dive in."
|
|
|
162
169
|
"Before writing any code, let's plan our data model.
|
|
163
170
|
|
|
164
171
|
**What entities do we need?** (Things)
|
|
172
|
+
|
|
165
173
|
- Newsletter - The publication
|
|
166
174
|
- Newsletter Issue - Individual editions
|
|
167
175
|
- Subscriber - People subscribed
|
|
168
176
|
- Campaign - Email delivery system
|
|
169
177
|
|
|
170
178
|
**How do they relate?** (Connections)
|
|
179
|
+
|
|
171
180
|
- Creator owns Newsletter
|
|
172
181
|
- Issue belongs to Newsletter
|
|
173
182
|
- Subscriber subscribes to Newsletter
|
|
174
183
|
- Campaign sends Issue
|
|
175
184
|
|
|
176
185
|
**What actions happen?** (Events)
|
|
186
|
+
|
|
177
187
|
- Newsletter created
|
|
178
188
|
- User subscribed
|
|
179
189
|
- Issue published
|
|
@@ -183,6 +193,7 @@ Let's dive in."
|
|
|
183
193
|
This maps perfectly to our 6-dimension ontology."
|
|
184
194
|
|
|
185
195
|
**ON-SCREEN DIAGRAM:**
|
|
196
|
+
|
|
186
197
|
```
|
|
187
198
|
Creator --owns--> Newsletter --contains--> Issue
|
|
188
199
|
^ |
|
|
@@ -240,10 +251,11 @@ eventTypes:
|
|
|
240
251
|
That's it. Our ontology is defined."
|
|
241
252
|
|
|
242
253
|
**ON-SCREEN TEXT:**
|
|
254
|
+
|
|
243
255
|
- 4 thing types
|
|
244
256
|
- 5 connection types
|
|
245
257
|
- 12 event types
|
|
246
|
-
= Complete feature
|
|
258
|
+
= Complete feature
|
|
247
259
|
|
|
248
260
|
### [4:00-5:30] Generating TypeScript Types
|
|
249
261
|
|
|
@@ -258,12 +270,14 @@ PUBLIC_FEATURES='newsletter' bun run generate-ontology-types.ts
|
|
|
258
270
|
```
|
|
259
271
|
|
|
260
272
|
Watch as it:
|
|
273
|
+
|
|
261
274
|
1. Loads the core ontology
|
|
262
275
|
2. Loads your newsletter ontology
|
|
263
276
|
3. Composes them together
|
|
264
277
|
4. Generates TypeScript types
|
|
265
278
|
|
|
266
279
|
Output:
|
|
280
|
+
|
|
267
281
|
- 70 thing types (core + newsletter)
|
|
268
282
|
- 30 connection types
|
|
269
283
|
- 79 event types
|
|
@@ -271,6 +285,7 @@ Output:
|
|
|
271
285
|
All type-safe. All auto-complete. Zero manual typing."
|
|
272
286
|
|
|
273
287
|
**ON-SCREEN OUTPUT:**
|
|
288
|
+
|
|
274
289
|
```
|
|
275
290
|
✅ Ontologies loaded successfully!
|
|
276
291
|
- Features: core, newsletter
|
|
@@ -292,8 +307,7 @@ All type-safe. All auto-complete. Zero manual typing."
|
|
|
292
307
|
Import the generated types:
|
|
293
308
|
|
|
294
309
|
```typescript
|
|
295
|
-
import type { ThingType, ConnectionType, EventType }
|
|
296
|
-
from '../types/ontology';
|
|
310
|
+
import type { ThingType, ConnectionType, EventType } from "../types/ontology";
|
|
297
311
|
```
|
|
298
312
|
|
|
299
313
|
Create the mutation:
|
|
@@ -301,28 +315,30 @@ Create the mutation:
|
|
|
301
315
|
```typescript
|
|
302
316
|
export const create = mutation({
|
|
303
317
|
args: {
|
|
304
|
-
groupId: v.id(
|
|
318
|
+
groupId: v.id("groups"),
|
|
305
319
|
title: v.string(),
|
|
306
320
|
schedule: v.string(),
|
|
307
321
|
},
|
|
308
322
|
handler: async (ctx, args) => {
|
|
309
323
|
// 1. Create newsletter entity
|
|
310
|
-
const newsletterId = await ctx.db.insert(
|
|
311
|
-
type:
|
|
324
|
+
const newsletterId = await ctx.db.insert("entities", {
|
|
325
|
+
type: "newsletter" as ThingType,
|
|
312
326
|
name: args.title,
|
|
313
|
-
properties: {
|
|
327
|
+
properties: {
|
|
328
|
+
/* ... */
|
|
329
|
+
},
|
|
314
330
|
});
|
|
315
331
|
|
|
316
332
|
// 2. Create ownership connection
|
|
317
|
-
await ctx.db.insert(
|
|
318
|
-
relationshipType:
|
|
333
|
+
await ctx.db.insert("connections", {
|
|
334
|
+
relationshipType: "owns" as ConnectionType,
|
|
319
335
|
fromEntityId: userId,
|
|
320
336
|
toEntityId: newsletterId,
|
|
321
337
|
});
|
|
322
338
|
|
|
323
339
|
// 3. Log creation event
|
|
324
|
-
await ctx.db.insert(
|
|
325
|
-
type:
|
|
340
|
+
await ctx.db.insert("events", {
|
|
341
|
+
type: "newsletter_created" as EventType,
|
|
326
342
|
actorId: userId,
|
|
327
343
|
targetId: newsletterId,
|
|
328
344
|
});
|
|
@@ -336,6 +352,7 @@ Three steps. Create, connect, log. Every time."
|
|
|
336
352
|
|
|
337
353
|
**ON-SCREEN TEXT:**
|
|
338
354
|
Pattern:
|
|
355
|
+
|
|
339
356
|
1. Create entity
|
|
340
357
|
2. Create connection
|
|
341
358
|
3. Log event
|
|
@@ -350,13 +367,12 @@ Pattern:
|
|
|
350
367
|
|
|
351
368
|
```typescript
|
|
352
369
|
export const list = query({
|
|
353
|
-
args: { groupId: v.id(
|
|
370
|
+
args: { groupId: v.id("groups") },
|
|
354
371
|
handler: async (ctx, args) => {
|
|
355
372
|
return await ctx.db
|
|
356
|
-
.query(
|
|
357
|
-
.withIndex(
|
|
358
|
-
q.eq(
|
|
359
|
-
.eq('type', 'newsletter')
|
|
373
|
+
.query("entities")
|
|
374
|
+
.withIndex("group_type", (q) =>
|
|
375
|
+
q.eq("groupId", args.groupId).eq("type", "newsletter")
|
|
360
376
|
)
|
|
361
377
|
.collect();
|
|
362
378
|
},
|
|
@@ -364,6 +380,7 @@ export const list = query({
|
|
|
364
380
|
```
|
|
365
381
|
|
|
366
382
|
This automatically:
|
|
383
|
+
|
|
367
384
|
- Filters by group (multi-tenant)
|
|
368
385
|
- Filters by type
|
|
369
386
|
- Returns real-time results
|
|
@@ -381,10 +398,10 @@ That's the power of Convex."
|
|
|
381
398
|
"Write tests to validate:
|
|
382
399
|
|
|
383
400
|
```typescript
|
|
384
|
-
it(
|
|
401
|
+
it("should create newsletter", async () => {
|
|
385
402
|
const id = await t.mutation(api.newsletter.create, {
|
|
386
|
-
groupId:
|
|
387
|
-
title:
|
|
403
|
+
groupId: "test",
|
|
404
|
+
title: "Test Newsletter",
|
|
388
405
|
});
|
|
389
406
|
|
|
390
407
|
expect(id).toBeDefined();
|
|
@@ -392,6 +409,7 @@ it('should create newsletter', async () => {
|
|
|
392
409
|
```
|
|
393
410
|
|
|
394
411
|
Run tests:
|
|
412
|
+
|
|
395
413
|
```bash
|
|
396
414
|
bun test newsletter.test.ts
|
|
397
415
|
```
|
|
@@ -421,6 +439,7 @@ See you there!"
|
|
|
421
439
|
You've learned the basics. Now let's level up.
|
|
422
440
|
|
|
423
441
|
We'll cover:
|
|
442
|
+
|
|
424
443
|
- Multi-feature interactions
|
|
425
444
|
- Performance optimization
|
|
426
445
|
- Production deployment
|
|
@@ -454,7 +473,7 @@ Now define a connection:
|
|
|
454
473
|
```yaml
|
|
455
474
|
connectionTypes:
|
|
456
475
|
- name: featured_in
|
|
457
|
-
fromType: blog_post
|
|
476
|
+
fromType: blog_post # From blog feature
|
|
458
477
|
toType: newsletter_issue # From newsletter feature
|
|
459
478
|
```
|
|
460
479
|
|
|
@@ -474,8 +493,8 @@ export const sendPostToNewsletter = mutation({
|
|
|
474
493
|
const post = await ctx.db.get(args.postId);
|
|
475
494
|
|
|
476
495
|
// Create newsletter issue from post
|
|
477
|
-
const issueId = await ctx.db.insert(
|
|
478
|
-
type:
|
|
496
|
+
const issueId = await ctx.db.insert("entities", {
|
|
497
|
+
type: "newsletter_issue",
|
|
479
498
|
properties: {
|
|
480
499
|
title: post.properties.title,
|
|
481
500
|
content: post.properties.content,
|
|
@@ -483,15 +502,15 @@ export const sendPostToNewsletter = mutation({
|
|
|
483
502
|
});
|
|
484
503
|
|
|
485
504
|
// Link post to issue
|
|
486
|
-
await ctx.db.insert(
|
|
487
|
-
relationshipType:
|
|
505
|
+
await ctx.db.insert("connections", {
|
|
506
|
+
relationshipType: "featured_in",
|
|
488
507
|
fromEntityId: args.postId,
|
|
489
508
|
toEntityId: issueId,
|
|
490
509
|
});
|
|
491
510
|
|
|
492
511
|
// Log event
|
|
493
|
-
await ctx.db.insert(
|
|
494
|
-
type:
|
|
512
|
+
await ctx.db.insert("events", {
|
|
513
|
+
type: "post_emailed",
|
|
495
514
|
actorId: args.postId,
|
|
496
515
|
targetId: issueId,
|
|
497
516
|
});
|
|
@@ -505,6 +524,7 @@ Features compose beautifully."
|
|
|
505
524
|
|
|
506
525
|
**ON-SCREEN TEXT:**
|
|
507
526
|
Compose Features:
|
|
527
|
+
|
|
508
528
|
- Extend multiple
|
|
509
529
|
- Cross-reference types
|
|
510
530
|
- Share connections
|
|
@@ -521,14 +541,14 @@ Compose Features:
|
|
|
521
541
|
Check enabled features:
|
|
522
542
|
|
|
523
543
|
```typescript
|
|
524
|
-
import { ONTOLOGY_METADATA } from
|
|
544
|
+
import { ONTOLOGY_METADATA } from "../types/ontology";
|
|
525
545
|
|
|
526
546
|
export const getFeatures = query({
|
|
527
547
|
handler: async () => {
|
|
528
548
|
return {
|
|
529
549
|
enabled: ONTOLOGY_METADATA.features,
|
|
530
|
-
hasBlog: ONTOLOGY_METADATA.features.includes(
|
|
531
|
-
hasShop: ONTOLOGY_METADATA.features.includes(
|
|
550
|
+
hasBlog: ONTOLOGY_METADATA.features.includes("blog"),
|
|
551
|
+
hasShop: ONTOLOGY_METADATA.features.includes("shop"),
|
|
532
552
|
};
|
|
533
553
|
},
|
|
534
554
|
});
|
|
@@ -541,8 +561,8 @@ export const createContent = mutation({
|
|
|
541
561
|
handler: async (ctx, args) => {
|
|
542
562
|
const features = ONTOLOGY_METADATA.features;
|
|
543
563
|
|
|
544
|
-
if (args.type ===
|
|
545
|
-
throw new Error(
|
|
564
|
+
if (args.type === "blog_post" && !features.includes("blog")) {
|
|
565
|
+
throw new Error("Blog feature not enabled");
|
|
546
566
|
}
|
|
547
567
|
|
|
548
568
|
// Create entity...
|
|
@@ -551,6 +571,7 @@ export const createContent = mutation({
|
|
|
551
571
|
```
|
|
552
572
|
|
|
553
573
|
This enables:
|
|
574
|
+
|
|
554
575
|
- Feature flags
|
|
555
576
|
- A/B testing
|
|
556
577
|
- Gradual rollouts
|
|
@@ -562,6 +583,7 @@ One platform. Infinite configurations."
|
|
|
562
583
|
|
|
563
584
|
**ON-SCREEN TEXT:**
|
|
564
585
|
Runtime Features:
|
|
586
|
+
|
|
565
587
|
- Feature flags
|
|
566
588
|
- A/B testing
|
|
567
589
|
- Gradual rollout
|
|
@@ -580,6 +602,7 @@ Runtime Features:
|
|
|
580
602
|
Type validation can be slow with linear search.
|
|
581
603
|
|
|
582
604
|
Before:
|
|
605
|
+
|
|
583
606
|
```typescript
|
|
584
607
|
function isValid(type: string) {
|
|
585
608
|
return THING_TYPES.includes(type); // O(n)
|
|
@@ -587,6 +610,7 @@ function isValid(type: string) {
|
|
|
587
610
|
```
|
|
588
611
|
|
|
589
612
|
After:
|
|
613
|
+
|
|
590
614
|
```typescript
|
|
591
615
|
const THING_TYPE_SET = new Set(THING_TYPES);
|
|
592
616
|
|
|
@@ -608,9 +632,7 @@ for (const item of items) {
|
|
|
608
632
|
}
|
|
609
633
|
|
|
610
634
|
// Good: Batch with Promise.all
|
|
611
|
-
const results = await Promise.all(
|
|
612
|
-
items.map(item => create(item))
|
|
613
|
-
);
|
|
635
|
+
const results = await Promise.all(items.map((item) => create(item)));
|
|
614
636
|
```
|
|
615
637
|
|
|
616
638
|
10x faster for bulk operations.
|
|
@@ -621,13 +643,13 @@ Always use indexes:
|
|
|
621
643
|
|
|
622
644
|
```typescript
|
|
623
645
|
// Bad: No index
|
|
624
|
-
await ctx.db.query(
|
|
646
|
+
await ctx.db.query("entities").collect();
|
|
625
647
|
|
|
626
648
|
// Good: Use index
|
|
627
649
|
await ctx.db
|
|
628
|
-
.query(
|
|
629
|
-
.withIndex(
|
|
630
|
-
q.eq(
|
|
650
|
+
.query("entities")
|
|
651
|
+
.withIndex("group_type", (q) =>
|
|
652
|
+
q.eq("groupId", groupId).eq("type", "newsletter")
|
|
631
653
|
)
|
|
632
654
|
.collect();
|
|
633
655
|
```
|
|
@@ -640,15 +662,16 @@ Always paginate:
|
|
|
640
662
|
|
|
641
663
|
```typescript
|
|
642
664
|
// Bad: Unbounded
|
|
643
|
-
await ctx.db.query(
|
|
665
|
+
await ctx.db.query("entities").collect();
|
|
644
666
|
|
|
645
667
|
// Good: Limited
|
|
646
|
-
await ctx.db.query(
|
|
668
|
+
await ctx.db.query("entities").take(50);
|
|
647
669
|
```
|
|
648
670
|
|
|
649
671
|
Prevents memory issues at scale."
|
|
650
672
|
|
|
651
673
|
**ON-SCREEN METRICS:**
|
|
674
|
+
|
|
652
675
|
- Type checks: 100x faster
|
|
653
676
|
- Batch ops: 10x faster
|
|
654
677
|
- Indexed queries: 1000x faster
|
|
@@ -670,19 +693,17 @@ Every action creates an event. Query events for insights.
|
|
|
670
693
|
export const getAnalytics = query({
|
|
671
694
|
handler: async (ctx, args) => {
|
|
672
695
|
const events = await ctx.db
|
|
673
|
-
.query(
|
|
674
|
-
.withIndex(
|
|
675
|
-
q.eq(
|
|
676
|
-
.gte('timestamp', thirtyDaysAgo)
|
|
696
|
+
.query("events")
|
|
697
|
+
.withIndex("target_time", (q) =>
|
|
698
|
+
q.eq("targetId", newsletterId).gte("timestamp", thirtyDaysAgo)
|
|
677
699
|
)
|
|
678
700
|
.collect();
|
|
679
701
|
|
|
680
702
|
return {
|
|
681
|
-
subscriptions: events.filter(e =>
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
e.type === 'newsletter_unsubscribed'
|
|
703
|
+
subscriptions: events.filter((e) => e.type === "newsletter_subscribed")
|
|
704
|
+
.length,
|
|
705
|
+
unsubscriptions: events.filter(
|
|
706
|
+
(e) => e.type === "newsletter_unsubscribed"
|
|
686
707
|
).length,
|
|
687
708
|
};
|
|
688
709
|
},
|
|
@@ -702,9 +723,7 @@ const cohorts = subscribers.reduce((acc, sub) => {
|
|
|
702
723
|
|
|
703
724
|
// Calculate retention for each cohort
|
|
704
725
|
const retention = Object.entries(cohorts).map(([week, subs]) => {
|
|
705
|
-
const stillActive = subs.filter(s =>
|
|
706
|
-
s.properties.active
|
|
707
|
-
).length;
|
|
726
|
+
const stillActive = subs.filter((s) => s.properties.active).length;
|
|
708
727
|
|
|
709
728
|
return {
|
|
710
729
|
week,
|
|
@@ -719,6 +738,7 @@ Events enable any analytics without changing schema."
|
|
|
719
738
|
|
|
720
739
|
**ON-SCREEN TEXT:**
|
|
721
740
|
Event-Driven Analytics:
|
|
741
|
+
|
|
722
742
|
- No schema changes
|
|
723
743
|
- Real-time metrics
|
|
724
744
|
- Infinite dimensions
|
|
@@ -781,6 +801,7 @@ Back to previous version in seconds.
|
|
|
781
801
|
**Step 5: Monitor**
|
|
782
802
|
|
|
783
803
|
Watch real-time metrics:
|
|
804
|
+
|
|
784
805
|
- Event throughput
|
|
785
806
|
- Query latency
|
|
786
807
|
- Error rates
|
|
@@ -809,6 +830,7 @@ Production Checklist:
|
|
|
809
830
|
The ONE Platform uses this exact architecture.
|
|
810
831
|
|
|
811
832
|
Features enabled:
|
|
833
|
+
|
|
812
834
|
- blog (content publishing)
|
|
813
835
|
- newsletter (email marketing)
|
|
814
836
|
- courses (education)
|
|
@@ -816,12 +838,14 @@ Features enabled:
|
|
|
816
838
|
- tokens (creator economy)
|
|
817
839
|
|
|
818
840
|
**By the numbers:**
|
|
841
|
+
|
|
819
842
|
- 66 thing types
|
|
820
843
|
- 31 connection types
|
|
821
844
|
- 93 event types
|
|
822
845
|
- 1 schema migration ever (the initial one)
|
|
823
846
|
|
|
824
847
|
**Adding a new feature:**
|
|
848
|
+
|
|
825
849
|
- Write YAML: 10 minutes
|
|
826
850
|
- Generate types: 5 seconds
|
|
827
851
|
- Write mutations: 20 minutes
|
|
@@ -834,6 +858,7 @@ Total: ~1 hour from idea to production.
|
|
|
834
858
|
Traditional approach: 2-4 weeks.
|
|
835
859
|
|
|
836
860
|
**Metrics:**
|
|
861
|
+
|
|
837
862
|
- 98% less context for AI
|
|
838
863
|
- 100x faster feature development
|
|
839
864
|
- Zero schema migrations
|
|
@@ -843,6 +868,7 @@ This is the power of ontology-driven development."
|
|
|
843
868
|
|
|
844
869
|
**ON-SCREEN STATS:**
|
|
845
870
|
ONE Platform:
|
|
871
|
+
|
|
846
872
|
- 66 thing types
|
|
847
873
|
- 31 connections
|
|
848
874
|
- 93 events
|
|
@@ -855,9 +881,10 @@ ONE Platform:
|
|
|
855
881
|
|
|
856
882
|
**SCRIPT:**
|
|
857
883
|
|
|
858
|
-
"Congratulations! You've mastered the
|
|
884
|
+
"Congratulations! You've mastered the ONE Ontology Architecture.
|
|
859
885
|
|
|
860
886
|
You learned:
|
|
887
|
+
|
|
861
888
|
1. The 6-dimension foundation
|
|
862
889
|
2. How to create features
|
|
863
890
|
3. Advanced composition patterns
|
|
@@ -872,6 +899,7 @@ You learned:
|
|
|
872
899
|
4. Deploy to production
|
|
873
900
|
|
|
874
901
|
**Resources:**
|
|
902
|
+
|
|
875
903
|
- Documentation: /one/knowledge/
|
|
876
904
|
- Examples: /backend/examples/
|
|
877
905
|
- Community: Discord link
|
|
@@ -885,6 +913,7 @@ Happy coding!"
|
|
|
885
913
|
You Did It! 🎉
|
|
886
914
|
|
|
887
915
|
Next Steps:
|
|
916
|
+
|
|
888
917
|
1. Build your feature
|
|
889
918
|
2. Join Discord
|
|
890
919
|
3. Read docs
|
|
@@ -895,11 +924,13 @@ Next Steps:
|
|
|
895
924
|
**END OF VIDEO SERIES**
|
|
896
925
|
|
|
897
926
|
Total Duration: ~35 minutes
|
|
927
|
+
|
|
898
928
|
- Video 1: 5 minutes (Introduction)
|
|
899
929
|
- Video 2: 10 minutes (First Feature)
|
|
900
930
|
- Video 3: 20 minutes (Advanced Patterns)
|
|
901
931
|
|
|
902
932
|
**Production Notes:**
|
|
933
|
+
|
|
903
934
|
- Use screen recording for code
|
|
904
935
|
- Use animations for concepts
|
|
905
936
|
- Add captions for accessibility
|