@nbt-dev/nbt 0.0.1 → 0.0.3
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/LICENSE +177 -21
- package/README.md +16 -13
- package/TRADEMARKS.md +49 -0
- package/dist/nbt.js +398 -19
- package/package.json +5 -4
- package/stdlib/auth/README.md +83 -0
- package/stdlib/auth/migrations/20260424144652_initial/migration.nbt +48 -0
- package/stdlib/auth/migrations/20260424144652_initial/schema_snapshot.nbt +58 -0
- package/stdlib/auth/migrations/20260521191014_update_user/migration.nbt +3 -0
- package/stdlib/auth/migrations/20260521191014_update_user/schema_snapshot.nbt +59 -0
- package/stdlib/auth/schema.nbt +142 -0
- package/stdlib/calendar/adapters/gohighlevel/tests/fixtures/v2_calendar_pilot.json +12 -0
- package/stdlib/calendar/adapters/gohighlevel/tests/fixtures/webhooks/appointment_changed.json +70 -0
- package/stdlib/calendar/adapters/gohighlevel/tests/fixtures/webhooks/appointment_created.json +72 -0
- package/stdlib/calendar/migrations/20260501210107_initial/migration.nbt +60 -0
- package/stdlib/calendar/migrations/20260501210107_initial/schema_snapshot.nbt +66 -0
- package/stdlib/calendar/migrations/20260513151050_schema_update/migration.nbt +17 -0
- package/stdlib/calendar/migrations/20260513151050_schema_update/schema_snapshot.nbt +83 -0
- package/stdlib/calendar/schema.nbt +85 -0
- package/stdlib/chat/migrations/20260429222411_initial/migration.nbt +59 -0
- package/stdlib/chat/migrations/20260429222411_initial/schema_snapshot.nbt +71 -0
- package/stdlib/chat/migrations/20260430185225_add_messagereaction/migration.nbt +9 -0
- package/stdlib/chat/migrations/20260430185225_add_messagereaction/schema_snapshot.nbt +78 -0
- package/stdlib/chat/migrations/20260514202654_update_directmessageroom/migration.nbt +4 -0
- package/stdlib/chat/migrations/20260514202654_update_directmessageroom/schema_snapshot.nbt +80 -0
- package/stdlib/chat/migrations/20260518191152_update_message/migration.nbt +3 -0
- package/stdlib/chat/migrations/20260518191152_update_message/schema_snapshot.nbt +81 -0
- package/stdlib/chat/schema.nbt +130 -0
- package/stdlib/crm/adapters/gohighlevel/README.md +85 -0
- package/stdlib/crm/adapters/gohighlevel/tests/README.md +159 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_138fields.json +222 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_140fields.json +219 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_alt.json +212 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_changed.json +102 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_created.json +95 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_full.json +213 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_sparse.json +161 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_update_a.json +197 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_update_b.json +197 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/opportunity_changed.json +85 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/opportunity_created.json +85 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_contact_pilot.json +43 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_contact_with_price_closed.json +7 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_contact_with_price_open.json +7 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_appointment_delete.json +1 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_calendar_update.json +1 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_contact_create.json +1 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_opp_status_update.json +1 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_opportunity_pilot.json +16 -0
- package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_pipelines_pilot.json +137 -0
- package/stdlib/crm/migrations/20260501210107_initial/migration.nbt +63 -0
- package/stdlib/crm/migrations/20260501210107_initial/schema_snapshot.nbt +73 -0
- package/stdlib/crm/migrations/20260513151050_schema_update/migration.nbt +13 -0
- package/stdlib/crm/migrations/20260513151050_schema_update/schema_snapshot.nbt +86 -0
- package/stdlib/crm/schema.nbt +146 -0
- package/stdlib/design/migrations/20260501210107_initial/migration.nbt +19 -0
- package/stdlib/design/migrations/20260501210107_initial/schema_snapshot.nbt +21 -0
- package/stdlib/design/migrations/20260610130000_design_system/migration.nbt +50 -0
- package/stdlib/design/migrations/20260610130000_design_system/schema_snapshot.nbt +80 -0
- package/stdlib/design/schema.nbt +140 -0
- package/stdlib/dns/migrations/20260501210107_initial/migration.nbt +32 -0
- package/stdlib/dns/migrations/20260501210107_initial/schema_snapshot.nbt +36 -0
- package/stdlib/dns/schema.nbt +68 -0
- package/stdlib/email/migrations/20260427235207_initial/migration.nbt +75 -0
- package/stdlib/email/migrations/20260427235207_initial/schema_snapshot.nbt +87 -0
- package/stdlib/email/schema.nbt +145 -0
- package/stdlib/ingest/README.md +29 -0
- package/stdlib/ingest/migrations/20260424144652_initial/migration.nbt +18 -0
- package/stdlib/ingest/migrations/20260424144652_initial/schema_snapshot.nbt +20 -0
- package/stdlib/ingest/migrations/20260429203747_schema_update/migration.nbt +3 -0
- package/stdlib/ingest/migrations/20260429203747_schema_update/schema_snapshot.nbt +21 -0
- package/stdlib/ingest/schema.nbt +37 -0
- package/stdlib/notifications/README.md +118 -0
- package/stdlib/notifications/migrations/20260430204408_initial/migration.nbt +42 -0
- package/stdlib/notifications/migrations/20260430204408_initial/schema_snapshot.nbt +46 -0
- package/stdlib/notifications/schema.nbt +67 -0
- package/stdlib/phone/migrations/20260605205722_initial/migration.nbt +50 -0
- package/stdlib/phone/migrations/20260605205722_initial/schema_snapshot.nbt +56 -0
- package/stdlib/phone/schema.nbt +95 -0
- package/stdlib/registry/migrations/20260602181932_initial/migration.nbt +8 -0
- package/stdlib/registry/migrations/20260602181932_initial/schema_snapshot.nbt +8 -0
- package/stdlib/registry/schema.nbt +20 -0
- package/stdlib/workflows/schema.nbt +43 -0
- package/vendor/linux-x64/cartridges/auth/migrations/20260424144652_initial/migration.nbt +48 -0
- package/vendor/linux-x64/cartridges/auth/migrations/20260424144652_initial/schema_snapshot.nbt +58 -0
- package/vendor/linux-x64/cartridges/auth/migrations/20260521191014_update_user/migration.nbt +3 -0
- package/vendor/linux-x64/cartridges/auth/migrations/20260521191014_update_user/schema_snapshot.nbt +59 -0
- package/vendor/linux-x64/cartridges/auth/schema.nbt +142 -0
- package/vendor/linux-x64/cartridges/calendar/migrations/20260501210107_initial/migration.nbt +60 -0
- package/vendor/linux-x64/cartridges/calendar/migrations/20260501210107_initial/schema_snapshot.nbt +66 -0
- package/vendor/linux-x64/cartridges/calendar/migrations/20260513151050_schema_update/migration.nbt +17 -0
- package/vendor/linux-x64/cartridges/calendar/migrations/20260513151050_schema_update/schema_snapshot.nbt +83 -0
- package/vendor/linux-x64/cartridges/calendar/schema.nbt +85 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260429222411_initial/migration.nbt +59 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260429222411_initial/schema_snapshot.nbt +71 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260430185225_add_messagereaction/migration.nbt +9 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260430185225_add_messagereaction/schema_snapshot.nbt +78 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260514202654_update_directmessageroom/migration.nbt +4 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260514202654_update_directmessageroom/schema_snapshot.nbt +80 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260518191152_update_message/migration.nbt +3 -0
- package/vendor/linux-x64/cartridges/chat/migrations/20260518191152_update_message/schema_snapshot.nbt +81 -0
- package/vendor/linux-x64/cartridges/chat/schema.nbt +130 -0
- package/vendor/linux-x64/cartridges/crm/migrations/20260501210107_initial/migration.nbt +63 -0
- package/vendor/linux-x64/cartridges/crm/migrations/20260501210107_initial/schema_snapshot.nbt +73 -0
- package/vendor/linux-x64/cartridges/crm/migrations/20260513151050_schema_update/migration.nbt +13 -0
- package/vendor/linux-x64/cartridges/crm/migrations/20260513151050_schema_update/schema_snapshot.nbt +86 -0
- package/vendor/linux-x64/cartridges/crm/schema.nbt +146 -0
- package/vendor/linux-x64/cartridges/design/migrations/20260501210107_initial/migration.nbt +19 -0
- package/vendor/linux-x64/cartridges/design/migrations/20260501210107_initial/schema_snapshot.nbt +21 -0
- package/vendor/linux-x64/cartridges/design/migrations/20260610130000_design_system/migration.nbt +50 -0
- package/vendor/linux-x64/cartridges/design/migrations/20260610130000_design_system/schema_snapshot.nbt +80 -0
- package/vendor/linux-x64/cartridges/design/schema.nbt +140 -0
- package/vendor/linux-x64/cartridges/dns/migrations/20260501210107_initial/migration.nbt +32 -0
- package/vendor/linux-x64/cartridges/dns/migrations/20260501210107_initial/schema_snapshot.nbt +36 -0
- package/vendor/linux-x64/cartridges/dns/schema.nbt +68 -0
- package/vendor/linux-x64/cartridges/email/migrations/20260427235207_initial/migration.nbt +75 -0
- package/vendor/linux-x64/cartridges/email/migrations/20260427235207_initial/schema_snapshot.nbt +87 -0
- package/vendor/linux-x64/cartridges/email/schema.nbt +145 -0
- package/vendor/linux-x64/cartridges/ingest/migrations/20260424144652_initial/migration.nbt +18 -0
- package/vendor/linux-x64/cartridges/ingest/migrations/20260424144652_initial/schema_snapshot.nbt +20 -0
- package/vendor/linux-x64/cartridges/ingest/migrations/20260429203747_schema_update/migration.nbt +3 -0
- package/vendor/linux-x64/cartridges/ingest/migrations/20260429203747_schema_update/schema_snapshot.nbt +21 -0
- package/vendor/linux-x64/cartridges/ingest/schema.nbt +37 -0
- package/vendor/linux-x64/cartridges/notifications/migrations/20260430204408_initial/migration.nbt +42 -0
- package/vendor/linux-x64/cartridges/notifications/migrations/20260430204408_initial/schema_snapshot.nbt +46 -0
- package/vendor/linux-x64/cartridges/notifications/schema.nbt +67 -0
- package/vendor/linux-x64/cartridges/phone/migrations/20260605205722_initial/migration.nbt +50 -0
- package/vendor/linux-x64/cartridges/phone/migrations/20260605205722_initial/schema_snapshot.nbt +56 -0
- package/vendor/linux-x64/cartridges/phone/schema.nbt +95 -0
- package/vendor/linux-x64/cartridges/registry/migrations/20260602181932_initial/migration.nbt +8 -0
- package/vendor/linux-x64/cartridges/registry/migrations/20260602181932_initial/schema_snapshot.nbt +8 -0
- package/vendor/linux-x64/cartridges/registry/schema.nbt +20 -0
- package/vendor/linux-x64/cartridges/workflows/schema.nbt +43 -0
- package/vendor/linux-x64/console +0 -0
- package/vendor/linux-x64/nbt +0 -0
- package/contracts/audit/.dist/contract.json +0 -56
- package/contracts/auth/.dist/contract.json +0 -252
- package/contracts/calendar/.dist/contract.json +0 -141
- package/contracts/chat/.dist/contract.json +0 -229
- package/contracts/crm/.dist/contract.json +0 -239
- package/contracts/design/.dist/contract.json +0 -85
- package/contracts/dns/.dist/contract.json +0 -123
- package/contracts/email/.dist/contract.json +0 -267
- package/contracts/embed/.dist/contract.json +0 -137
- package/contracts/ingest/.dist/contract.json +0 -86
- package/contracts/notifications/.dist/contract.json +0 -133
- package/contracts/phone/.dist/contract.json +0 -168
- package/contracts/registry/.dist/contract.json +0 -49
- package/contracts/workflows/.dist/contract.json +0 -106
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
entity Calendar {
|
|
2
|
+
name: string
|
|
3
|
+
description?: string
|
|
4
|
+
timezone?: string
|
|
5
|
+
slotDuration?: u32
|
|
6
|
+
slotInterval?: u32
|
|
7
|
+
isActive: bool
|
|
8
|
+
source?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
entity Appointment {
|
|
12
|
+
calendar: Calendar
|
|
13
|
+
contact: Contact
|
|
14
|
+
title?: string
|
|
15
|
+
address?: string
|
|
16
|
+
notes?: string
|
|
17
|
+
startTime: DateTime
|
|
18
|
+
endTime: DateTime
|
|
19
|
+
timezone?: string
|
|
20
|
+
status: string
|
|
21
|
+
source?: string
|
|
22
|
+
assignedUser?: User
|
|
23
|
+
isRescheduled: bool
|
|
24
|
+
originalStartTime?: DateTime
|
|
25
|
+
originalEndTime?: DateTime
|
|
26
|
+
state?: string
|
|
27
|
+
outcomeClass?: string
|
|
28
|
+
embedText?: string
|
|
29
|
+
@@index([contactId])
|
|
30
|
+
@@index([calendarId])
|
|
31
|
+
@@index([state])
|
|
32
|
+
@@index([outcomeClass])
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
entity AppointmentParticipant {
|
|
36
|
+
appointment: Appointment
|
|
37
|
+
user: User
|
|
38
|
+
role: string
|
|
39
|
+
assignedAt: DateTime
|
|
40
|
+
assignedBy?: User
|
|
41
|
+
notes?: string
|
|
42
|
+
@@unique([appointmentId, role, userId])
|
|
43
|
+
@@index([appointmentId])
|
|
44
|
+
@@index([userId, role])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
entity Contact {
|
|
48
|
+
firstName?: string
|
|
49
|
+
lastName?: string
|
|
50
|
+
fullName?: string
|
|
51
|
+
phone?: string
|
|
52
|
+
mobile?: string
|
|
53
|
+
email?: string
|
|
54
|
+
address?: string
|
|
55
|
+
fullAddress?: string
|
|
56
|
+
postalCode?: string
|
|
57
|
+
city?: string
|
|
58
|
+
stateOrProvince?: string
|
|
59
|
+
country?: string
|
|
60
|
+
timezone?: string
|
|
61
|
+
lat?: float
|
|
62
|
+
lon?: float
|
|
63
|
+
company?: string
|
|
64
|
+
website?: string
|
|
65
|
+
title?: string
|
|
66
|
+
industry?: string
|
|
67
|
+
source?: string
|
|
68
|
+
notes?: string
|
|
69
|
+
data: document
|
|
70
|
+
customData: document
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
entity User {
|
|
74
|
+
name: string
|
|
75
|
+
username?: string
|
|
76
|
+
email?: string
|
|
77
|
+
emailVerified: bool
|
|
78
|
+
externalId?: string
|
|
79
|
+
capsVersion: u32
|
|
80
|
+
@@index([email])
|
|
81
|
+
@@index([externalId])
|
|
82
|
+
}
|
|
83
|
+
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {Contact} from "crm";
|
|
2
|
+
import {User} from "auth";
|
|
3
|
+
|
|
4
|
+
entity Calendar {
|
|
5
|
+
id: ulid
|
|
6
|
+
createdAt: DateTime @default(now())
|
|
7
|
+
updatedAt: DateTime @updatedAt
|
|
8
|
+
name: string
|
|
9
|
+
description?: string
|
|
10
|
+
timezone?: string
|
|
11
|
+
slotDuration?: u32
|
|
12
|
+
slotInterval?: u32
|
|
13
|
+
isActive: bool
|
|
14
|
+
source?: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export entity Appointment {
|
|
18
|
+
id: ulid
|
|
19
|
+
createdAt: DateTime @default(now())
|
|
20
|
+
updatedAt: DateTime @updatedAt
|
|
21
|
+
calendar: Calendar
|
|
22
|
+
contact: Contact
|
|
23
|
+
title?: string
|
|
24
|
+
address?: string
|
|
25
|
+
notes?: string
|
|
26
|
+
startTime: DateTime
|
|
27
|
+
endTime: DateTime
|
|
28
|
+
timezone?: string
|
|
29
|
+
status: string
|
|
30
|
+
source?: string
|
|
31
|
+
assignedUser?: User
|
|
32
|
+
isRescheduled: bool
|
|
33
|
+
originalStartTime?: DateTime
|
|
34
|
+
originalEndTime?: DateTime
|
|
35
|
+
|
|
36
|
+
# Geographic state (e.g. "CA", "TX") parsed from `address` at ingest. Indexed
|
|
37
|
+
# so customers can filter assignment candidates by state cheaply.
|
|
38
|
+
state?: string
|
|
39
|
+
|
|
40
|
+
# Generic outcome label for similarity-weighted aggregation. Customer fills
|
|
41
|
+
# via their domain's lifecycle hook ("won" for MyLocalPro, "positive" for
|
|
42
|
+
# therapy). Indexed for `Appointment.find_by_outcomeClass("won")` lookups.
|
|
43
|
+
outcomeClass?: string
|
|
44
|
+
|
|
45
|
+
# Rendered embedding-template text. Persisted alongside the Appointment so
|
|
46
|
+
# similarity search can score (target_text, candidate_text) pairs without
|
|
47
|
+
# re-rendering the customer's @embed template on every query. Populated at
|
|
48
|
+
# ingest by the customer's @embed binding
|
|
49
|
+
# (D09.10c). Generic surface — every customer composing similarity search
|
|
50
|
+
# over Appointments needs it; the *content* of the text is customer policy.
|
|
51
|
+
embedText?: string
|
|
52
|
+
|
|
53
|
+
@@index([contactId])
|
|
54
|
+
@@index([calendarId])
|
|
55
|
+
@@index([state])
|
|
56
|
+
@@index([outcomeClass])
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Many-to-many linkage between Appointment and User with a client-defined
|
|
60
|
+
# role label. Lets a deployment encode any participant taxonomy without
|
|
61
|
+
# adding new columns to Appointment:
|
|
62
|
+
#
|
|
63
|
+
# MyLocalPro: role = "setter" | "closer" | "shadower"
|
|
64
|
+
# Therapy: role = "therapist" | "supervisor"
|
|
65
|
+
# Field service: role = "primary" | "backup" | "trainee"
|
|
66
|
+
#
|
|
67
|
+
# `Appointment.assignedUser` stays as the conventional "primary owner"
|
|
68
|
+
# pointer (single value, indexed) for clients that don't need multi-role.
|
|
69
|
+
# AppointmentParticipant is additive — clients pick the row when they
|
|
70
|
+
# want richer linkage.
|
|
71
|
+
export entity AppointmentParticipant {
|
|
72
|
+
id: ulid
|
|
73
|
+
createdAt: DateTime @default(now())
|
|
74
|
+
updatedAt: DateTime @updatedAt
|
|
75
|
+
appointment: Appointment
|
|
76
|
+
user: User
|
|
77
|
+
role: string # client-defined (e.g. "setter", "closer")
|
|
78
|
+
assignedAt: DateTime @default(now())
|
|
79
|
+
assignedBy?: User # who recorded this assignment (for audit)
|
|
80
|
+
notes?: string
|
|
81
|
+
|
|
82
|
+
@@unique([appointmentId, role, userId])
|
|
83
|
+
@@index([appointmentId])
|
|
84
|
+
@@index([userId, role])
|
|
85
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
migration initial {
|
|
2
|
+
add_entity Channel
|
|
3
|
+
add_field Channel name string default("")
|
|
4
|
+
add_field Channel description string default("")
|
|
5
|
+
add_field Channel creatorId string default("")
|
|
6
|
+
add_field Channel isPrivate bool default(false)
|
|
7
|
+
add_field Channel isArchived bool default(false)
|
|
8
|
+
add_field Channel lastActivityAt DateTime default(0)
|
|
9
|
+
add_unique Channel [name]
|
|
10
|
+
add_entity ChannelMember
|
|
11
|
+
add_field ChannelMember channelId string default("")
|
|
12
|
+
add_field ChannelMember userId string default("")
|
|
13
|
+
add_field ChannelMember joinedAt DateTime default(0)
|
|
14
|
+
add_index ChannelMember [userId]
|
|
15
|
+
add_index ChannelMember [channelId]
|
|
16
|
+
add_unique ChannelMember [channelId, userId]
|
|
17
|
+
add_entity DirectMessageRoom
|
|
18
|
+
add_field DirectMessageRoom participantA string default("")
|
|
19
|
+
add_field DirectMessageRoom participantAType string default("USER")
|
|
20
|
+
add_field DirectMessageRoom participantB string default("")
|
|
21
|
+
add_field DirectMessageRoom participantBType string default("USER")
|
|
22
|
+
add_field DirectMessageRoom lastActivityAt DateTime default(0)
|
|
23
|
+
add_index DirectMessageRoom [participantA]
|
|
24
|
+
add_index DirectMessageRoom [participantB]
|
|
25
|
+
add_unique DirectMessageRoom [participantA, participantB]
|
|
26
|
+
add_entity Message
|
|
27
|
+
add_field Message channelId string default("")
|
|
28
|
+
add_field Message dmRoomId string default("")
|
|
29
|
+
add_field Message parentMessageId string default("")
|
|
30
|
+
add_field Message senderType string default("")
|
|
31
|
+
add_field Message senderId string default("")
|
|
32
|
+
add_field Message content string default("")
|
|
33
|
+
add_field Message editedAt DateTime default(0)
|
|
34
|
+
add_field Message deletedAt DateTime default(0)
|
|
35
|
+
add_field Message replyCount u32 default(0)
|
|
36
|
+
add_index Message [channelId]
|
|
37
|
+
add_index Message [dmRoomId]
|
|
38
|
+
add_index Message [parentMessageId]
|
|
39
|
+
add_index Message [senderId]
|
|
40
|
+
add_entity ChatReadState
|
|
41
|
+
add_field ChatReadState userId string default("")
|
|
42
|
+
add_field ChatReadState scopeKey string default("")
|
|
43
|
+
add_field ChatReadState scopeType string default("")
|
|
44
|
+
add_field ChatReadState scopeId string default("")
|
|
45
|
+
add_field ChatReadState lastReadMessageId string default("")
|
|
46
|
+
add_field ChatReadState lastReadAt DateTime default(0)
|
|
47
|
+
add_index ChatReadState [userId]
|
|
48
|
+
add_index ChatReadState [scopeKey]
|
|
49
|
+
add_unique ChatReadState [userId, scopeKey]
|
|
50
|
+
add_entity User
|
|
51
|
+
add_field User name string default("")
|
|
52
|
+
add_field User username string default("")
|
|
53
|
+
add_field User email string default("")
|
|
54
|
+
add_field User emailVerified bool default(false)
|
|
55
|
+
add_field User externalId string default("")
|
|
56
|
+
add_field User capsVersion u32 default(0)
|
|
57
|
+
add_index User [email]
|
|
58
|
+
add_index User [externalId]
|
|
59
|
+
}
|
package/vendor/linux-x64/cartridges/chat/migrations/20260429222411_initial/schema_snapshot.nbt
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
entity Channel {
|
|
2
|
+
name: string
|
|
3
|
+
description?: string
|
|
4
|
+
creatorId: string
|
|
5
|
+
isPrivate: bool
|
|
6
|
+
isArchived: bool
|
|
7
|
+
lastActivityAt?: DateTime
|
|
8
|
+
@@unique([name])
|
|
9
|
+
@@collaborative([])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
entity ChannelMember {
|
|
13
|
+
channelId: string
|
|
14
|
+
userId: string
|
|
15
|
+
joinedAt: DateTime
|
|
16
|
+
@@unique([channelId, userId])
|
|
17
|
+
@@index([userId])
|
|
18
|
+
@@index([channelId])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
entity DirectMessageRoom {
|
|
22
|
+
participantA: string
|
|
23
|
+
participantAType: string
|
|
24
|
+
participantB: string
|
|
25
|
+
participantBType: string
|
|
26
|
+
lastActivityAt?: DateTime
|
|
27
|
+
@@unique([participantA, participantB])
|
|
28
|
+
@@index([participantA])
|
|
29
|
+
@@index([participantB])
|
|
30
|
+
@@collaborative([])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
entity Message {
|
|
34
|
+
channelId?: string
|
|
35
|
+
dmRoomId?: string
|
|
36
|
+
parentMessageId?: string
|
|
37
|
+
senderType: string
|
|
38
|
+
senderId: string
|
|
39
|
+
content: string
|
|
40
|
+
editedAt?: DateTime
|
|
41
|
+
deletedAt?: DateTime
|
|
42
|
+
replyCount: u32
|
|
43
|
+
@@index([channelId])
|
|
44
|
+
@@index([dmRoomId])
|
|
45
|
+
@@index([parentMessageId])
|
|
46
|
+
@@index([senderId])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
entity ChatReadState {
|
|
50
|
+
userId: string
|
|
51
|
+
scopeKey: string
|
|
52
|
+
scopeType: string
|
|
53
|
+
scopeId: string
|
|
54
|
+
lastReadMessageId: string
|
|
55
|
+
lastReadAt: DateTime
|
|
56
|
+
@@unique([userId, scopeKey])
|
|
57
|
+
@@index([userId])
|
|
58
|
+
@@index([scopeKey])
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
entity User {
|
|
62
|
+
name: string
|
|
63
|
+
username?: string
|
|
64
|
+
email?: string
|
|
65
|
+
emailVerified: bool
|
|
66
|
+
externalId?: string
|
|
67
|
+
capsVersion: u32
|
|
68
|
+
@@index([email])
|
|
69
|
+
@@index([externalId])
|
|
70
|
+
}
|
|
71
|
+
|
package/vendor/linux-x64/cartridges/chat/migrations/20260430185225_add_messagereaction/migration.nbt
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
migration add_messagereaction {
|
|
2
|
+
add_entity MessageReaction
|
|
3
|
+
add_field MessageReaction messageId string default("")
|
|
4
|
+
add_field MessageReaction emoji string default("")
|
|
5
|
+
add_field MessageReaction userId string default("")
|
|
6
|
+
add_index MessageReaction [messageId]
|
|
7
|
+
add_index MessageReaction [userId]
|
|
8
|
+
add_unique MessageReaction [messageId, emoji, userId]
|
|
9
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
entity Channel {
|
|
2
|
+
name: string
|
|
3
|
+
description?: string
|
|
4
|
+
creatorId: string
|
|
5
|
+
isPrivate: bool
|
|
6
|
+
isArchived: bool
|
|
7
|
+
lastActivityAt?: DateTime
|
|
8
|
+
@@unique([name])
|
|
9
|
+
@@collaborative([])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
entity ChannelMember {
|
|
13
|
+
channelId: string
|
|
14
|
+
userId: string
|
|
15
|
+
joinedAt: DateTime
|
|
16
|
+
@@unique([channelId, userId])
|
|
17
|
+
@@index([userId])
|
|
18
|
+
@@index([channelId])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
entity DirectMessageRoom {
|
|
22
|
+
participantA: string
|
|
23
|
+
participantB: string
|
|
24
|
+
lastActivityAt?: DateTime
|
|
25
|
+
@@unique([participantA, participantB])
|
|
26
|
+
@@index([participantA])
|
|
27
|
+
@@index([participantB])
|
|
28
|
+
@@collaborative([])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
entity Message {
|
|
32
|
+
channelId?: string
|
|
33
|
+
dmRoomId?: string
|
|
34
|
+
parentMessageId?: string
|
|
35
|
+
senderType: string
|
|
36
|
+
senderId: string
|
|
37
|
+
content: string
|
|
38
|
+
editedAt?: DateTime
|
|
39
|
+
deletedAt?: DateTime
|
|
40
|
+
replyCount: u32
|
|
41
|
+
@@index([channelId])
|
|
42
|
+
@@index([dmRoomId])
|
|
43
|
+
@@index([parentMessageId])
|
|
44
|
+
@@index([senderId])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
entity MessageReaction {
|
|
48
|
+
messageId: string
|
|
49
|
+
emoji: string
|
|
50
|
+
userId: string
|
|
51
|
+
@@unique([messageId, emoji, userId])
|
|
52
|
+
@@index([messageId])
|
|
53
|
+
@@index([userId])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
entity ChatReadState {
|
|
57
|
+
userId: string
|
|
58
|
+
scopeKey: string
|
|
59
|
+
scopeType: string
|
|
60
|
+
scopeId: string
|
|
61
|
+
lastReadMessageId: string
|
|
62
|
+
lastReadAt: DateTime
|
|
63
|
+
@@unique([userId, scopeKey])
|
|
64
|
+
@@index([userId])
|
|
65
|
+
@@index([scopeKey])
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
entity User {
|
|
69
|
+
name: string
|
|
70
|
+
username?: string
|
|
71
|
+
email?: string
|
|
72
|
+
emailVerified: bool
|
|
73
|
+
externalId?: string
|
|
74
|
+
capsVersion: u32
|
|
75
|
+
@@index([email])
|
|
76
|
+
@@index([externalId])
|
|
77
|
+
}
|
|
78
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
entity Channel {
|
|
2
|
+
name: string
|
|
3
|
+
description?: string
|
|
4
|
+
creatorId: string
|
|
5
|
+
isPrivate: bool
|
|
6
|
+
isArchived: bool
|
|
7
|
+
lastActivityAt?: DateTime
|
|
8
|
+
@@unique([name])
|
|
9
|
+
@@collaborative([])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
entity ChannelMember {
|
|
13
|
+
channelId: string
|
|
14
|
+
userId: string
|
|
15
|
+
joinedAt: DateTime
|
|
16
|
+
@@unique([channelId, userId])
|
|
17
|
+
@@index([userId])
|
|
18
|
+
@@index([channelId])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
entity DirectMessageRoom {
|
|
22
|
+
participantA: string
|
|
23
|
+
participantAType: string
|
|
24
|
+
participantB: string
|
|
25
|
+
participantBType: string
|
|
26
|
+
lastActivityAt?: DateTime
|
|
27
|
+
@@unique([participantA, participantB])
|
|
28
|
+
@@index([participantA])
|
|
29
|
+
@@index([participantB])
|
|
30
|
+
@@collaborative([])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
entity Message {
|
|
34
|
+
channelId?: string
|
|
35
|
+
dmRoomId?: string
|
|
36
|
+
parentMessageId?: string
|
|
37
|
+
senderType: string
|
|
38
|
+
senderId: string
|
|
39
|
+
content: string
|
|
40
|
+
editedAt?: DateTime
|
|
41
|
+
deletedAt?: DateTime
|
|
42
|
+
replyCount: u32
|
|
43
|
+
@@index([channelId])
|
|
44
|
+
@@index([dmRoomId])
|
|
45
|
+
@@index([parentMessageId])
|
|
46
|
+
@@index([senderId])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
entity MessageReaction {
|
|
50
|
+
messageId: string
|
|
51
|
+
emoji: string
|
|
52
|
+
userId: string
|
|
53
|
+
@@unique([messageId, emoji, userId])
|
|
54
|
+
@@index([messageId])
|
|
55
|
+
@@index([userId])
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
entity ChatReadState {
|
|
59
|
+
userId: string
|
|
60
|
+
scopeKey: string
|
|
61
|
+
scopeType: string
|
|
62
|
+
scopeId: string
|
|
63
|
+
lastReadMessageId: string
|
|
64
|
+
lastReadAt: DateTime
|
|
65
|
+
@@unique([userId, scopeKey])
|
|
66
|
+
@@index([userId])
|
|
67
|
+
@@index([scopeKey])
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
entity User {
|
|
71
|
+
name: string
|
|
72
|
+
username?: string
|
|
73
|
+
email?: string
|
|
74
|
+
emailVerified: bool
|
|
75
|
+
externalId?: string
|
|
76
|
+
capsVersion: u32
|
|
77
|
+
@@index([email])
|
|
78
|
+
@@index([externalId])
|
|
79
|
+
}
|
|
80
|
+
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
entity Channel {
|
|
2
|
+
name: string
|
|
3
|
+
description?: string
|
|
4
|
+
creatorId: string
|
|
5
|
+
isPrivate: bool
|
|
6
|
+
isArchived: bool
|
|
7
|
+
lastActivityAt?: DateTime
|
|
8
|
+
@@unique([name])
|
|
9
|
+
@@collaborative([])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
entity ChannelMember {
|
|
13
|
+
channelId: string
|
|
14
|
+
userId: string
|
|
15
|
+
joinedAt: DateTime
|
|
16
|
+
@@unique([channelId, userId])
|
|
17
|
+
@@index([userId])
|
|
18
|
+
@@index([channelId])
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
entity DirectMessageRoom {
|
|
22
|
+
participantA: string
|
|
23
|
+
participantAType: string
|
|
24
|
+
participantB: string
|
|
25
|
+
participantBType: string
|
|
26
|
+
lastActivityAt?: DateTime
|
|
27
|
+
@@unique([participantA, participantB])
|
|
28
|
+
@@index([participantA])
|
|
29
|
+
@@index([participantB])
|
|
30
|
+
@@collaborative([])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
entity Message {
|
|
34
|
+
channelId?: string
|
|
35
|
+
dmRoomId?: string
|
|
36
|
+
parentMessageId?: string
|
|
37
|
+
senderType: string
|
|
38
|
+
senderId: string
|
|
39
|
+
content: string
|
|
40
|
+
editedAt?: DateTime
|
|
41
|
+
deletedAt?: DateTime
|
|
42
|
+
replyCount: u32
|
|
43
|
+
@@index([channelId])
|
|
44
|
+
@@index([dmRoomId])
|
|
45
|
+
@@index([parentMessageId])
|
|
46
|
+
@@index([senderId])
|
|
47
|
+
@@search([content])
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
entity MessageReaction {
|
|
51
|
+
messageId: string
|
|
52
|
+
emoji: string
|
|
53
|
+
userId: string
|
|
54
|
+
@@unique([messageId, emoji, userId])
|
|
55
|
+
@@index([messageId])
|
|
56
|
+
@@index([userId])
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
entity ChatReadState {
|
|
60
|
+
userId: string
|
|
61
|
+
scopeKey: string
|
|
62
|
+
scopeType: string
|
|
63
|
+
scopeId: string
|
|
64
|
+
lastReadMessageId: string
|
|
65
|
+
lastReadAt: DateTime
|
|
66
|
+
@@unique([userId, scopeKey])
|
|
67
|
+
@@index([userId])
|
|
68
|
+
@@index([scopeKey])
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
entity User {
|
|
72
|
+
name: string
|
|
73
|
+
username?: string
|
|
74
|
+
email?: string
|
|
75
|
+
emailVerified: bool
|
|
76
|
+
externalId?: string
|
|
77
|
+
capsVersion: u32
|
|
78
|
+
@@index([email])
|
|
79
|
+
@@index([externalId])
|
|
80
|
+
}
|
|
81
|
+
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Chat cart — channels, DMs, threaded messages.
|
|
2
|
+
|
|
3
|
+
import {User} from "auth";
|
|
4
|
+
|
|
5
|
+
entity Channel {
|
|
6
|
+
id: ulid
|
|
7
|
+
createdAt: DateTime @default(now())
|
|
8
|
+
updatedAt: DateTime @updatedAt
|
|
9
|
+
name: string
|
|
10
|
+
description?: string
|
|
11
|
+
creatorId: string
|
|
12
|
+
isPrivate: bool
|
|
13
|
+
isArchived: bool
|
|
14
|
+
lastActivityAt?: DateTime
|
|
15
|
+
|
|
16
|
+
@@unique([name])
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
# Membership table for private channels. Public channels skip this — any
|
|
20
|
+
# authed user can post. Membership = read+post; admin gates write metadata.
|
|
21
|
+
entity ChannelMember {
|
|
22
|
+
id: ulid
|
|
23
|
+
createdAt: DateTime @default(now())
|
|
24
|
+
updatedAt: DateTime @updatedAt
|
|
25
|
+
channelId: string
|
|
26
|
+
userId: string
|
|
27
|
+
joinedAt: DateTime @default(now())
|
|
28
|
+
|
|
29
|
+
@@unique([channelId, userId])
|
|
30
|
+
@@index([userId])
|
|
31
|
+
@@index([channelId])
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# 1:1 DM room. Pair canonicalized in handler: participantA = lexicographic
|
|
35
|
+
# min(ULID), participantB = max. Lookups normalize both args before hitting
|
|
36
|
+
# the unique index.
|
|
37
|
+
#
|
|
38
|
+
# participantAType / participantBType ∈ "USER" | "AGENT". Required so DM
|
|
39
|
+
# triggers (`on dm(<agent>)`) can identify the peer at message send time
|
|
40
|
+
# without a cross-cart lookup. Existing rows default to USER/USER.
|
|
41
|
+
entity DirectMessageRoom {
|
|
42
|
+
id: ulid
|
|
43
|
+
createdAt: DateTime @default(now())
|
|
44
|
+
updatedAt: DateTime @updatedAt
|
|
45
|
+
participantA: string
|
|
46
|
+
participantAType: string
|
|
47
|
+
participantB: string
|
|
48
|
+
participantBType: string
|
|
49
|
+
lastActivityAt?: DateTime
|
|
50
|
+
|
|
51
|
+
@@unique([participantA, participantB])
|
|
52
|
+
@@index([participantA])
|
|
53
|
+
@@index([participantB])
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# Single Message entity for both channel + DM scopes. Exactly one of
|
|
57
|
+
# channelId / dmRoomId is non-empty per row. parentMessageId set => thread
|
|
58
|
+
# reply (Google-Chat-style inline replies; only one level deep — replies
|
|
59
|
+
# of replies coalesce to the top-level parent).
|
|
60
|
+
#
|
|
61
|
+
# senderType ∈ "USER" | "AGENT" | "SYSTEM". senderId points at the
|
|
62
|
+
# corresponding entity in the appropriate cart (User/Agent/System). UI
|
|
63
|
+
# renders a bot badge for non-USER senders. No fake User rows for bots.
|
|
64
|
+
entity Message {
|
|
65
|
+
id: ulid
|
|
66
|
+
createdAt: DateTime @default(now())
|
|
67
|
+
updatedAt: DateTime @updatedAt
|
|
68
|
+
channelId?: string
|
|
69
|
+
dmRoomId?: string
|
|
70
|
+
parentMessageId?: string
|
|
71
|
+
|
|
72
|
+
senderType: string
|
|
73
|
+
senderId: string
|
|
74
|
+
|
|
75
|
+
content: string
|
|
76
|
+
|
|
77
|
+
editedAt?: DateTime
|
|
78
|
+
deletedAt?: DateTime
|
|
79
|
+
|
|
80
|
+
# Denormalized — bumped by send_message handler when a reply is created.
|
|
81
|
+
# Keeps the parent row paginatable without a per-message COUNT scan.
|
|
82
|
+
replyCount: u32
|
|
83
|
+
|
|
84
|
+
@@index([channelId])
|
|
85
|
+
@@index([dmRoomId])
|
|
86
|
+
@@index([parentMessageId])
|
|
87
|
+
@@index([senderId])
|
|
88
|
+
@@search([content])
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Per-user emoji reaction on a message. Discord-style counts are computed from
|
|
92
|
+
# these rows at read time; one user can react once per emoji per message.
|
|
93
|
+
entity MessageReaction {
|
|
94
|
+
id: ulid
|
|
95
|
+
createdAt: DateTime @default(now())
|
|
96
|
+
updatedAt: DateTime @updatedAt
|
|
97
|
+
messageId: string
|
|
98
|
+
emoji: string
|
|
99
|
+
userId: string
|
|
100
|
+
|
|
101
|
+
@@unique([messageId, emoji, userId])
|
|
102
|
+
@@index([messageId])
|
|
103
|
+
@@index([userId])
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Per-(user, scope) read pointer.
|
|
107
|
+
#
|
|
108
|
+
# scopeKey is "channel:<channel_id>" or "dm:<dm_room_id>" — collapses the two
|
|
109
|
+
# parallel scope fields into a single composite-uniqueable key. Two parallel
|
|
110
|
+
# @@unique constraints on nullable cols aren't currently exercised by NBT
|
|
111
|
+
# codegen, so this is the safe shape.
|
|
112
|
+
#
|
|
113
|
+
# lastReadMessageId is a ULID; ULIDs sort lexicographically by creation time
|
|
114
|
+
# so "msg.id > lastReadMessageId" (string compare) cleanly answers "unread?".
|
|
115
|
+
entity ChatReadState {
|
|
116
|
+
id: ulid
|
|
117
|
+
createdAt: DateTime @default(now())
|
|
118
|
+
updatedAt: DateTime @updatedAt
|
|
119
|
+
userId: string
|
|
120
|
+
scopeKey: string
|
|
121
|
+
scopeType: string
|
|
122
|
+
scopeId: string
|
|
123
|
+
|
|
124
|
+
lastReadMessageId: string
|
|
125
|
+
lastReadAt: DateTime @default(now())
|
|
126
|
+
|
|
127
|
+
@@unique([userId, scopeKey])
|
|
128
|
+
@@index([userId])
|
|
129
|
+
@@index([scopeKey])
|
|
130
|
+
}
|