@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.
Files changed (149) hide show
  1. package/LICENSE +177 -21
  2. package/README.md +16 -13
  3. package/TRADEMARKS.md +49 -0
  4. package/dist/nbt.js +398 -19
  5. package/package.json +5 -4
  6. package/stdlib/auth/README.md +83 -0
  7. package/stdlib/auth/migrations/20260424144652_initial/migration.nbt +48 -0
  8. package/stdlib/auth/migrations/20260424144652_initial/schema_snapshot.nbt +58 -0
  9. package/stdlib/auth/migrations/20260521191014_update_user/migration.nbt +3 -0
  10. package/stdlib/auth/migrations/20260521191014_update_user/schema_snapshot.nbt +59 -0
  11. package/stdlib/auth/schema.nbt +142 -0
  12. package/stdlib/calendar/adapters/gohighlevel/tests/fixtures/v2_calendar_pilot.json +12 -0
  13. package/stdlib/calendar/adapters/gohighlevel/tests/fixtures/webhooks/appointment_changed.json +70 -0
  14. package/stdlib/calendar/adapters/gohighlevel/tests/fixtures/webhooks/appointment_created.json +72 -0
  15. package/stdlib/calendar/migrations/20260501210107_initial/migration.nbt +60 -0
  16. package/stdlib/calendar/migrations/20260501210107_initial/schema_snapshot.nbt +66 -0
  17. package/stdlib/calendar/migrations/20260513151050_schema_update/migration.nbt +17 -0
  18. package/stdlib/calendar/migrations/20260513151050_schema_update/schema_snapshot.nbt +83 -0
  19. package/stdlib/calendar/schema.nbt +85 -0
  20. package/stdlib/chat/migrations/20260429222411_initial/migration.nbt +59 -0
  21. package/stdlib/chat/migrations/20260429222411_initial/schema_snapshot.nbt +71 -0
  22. package/stdlib/chat/migrations/20260430185225_add_messagereaction/migration.nbt +9 -0
  23. package/stdlib/chat/migrations/20260430185225_add_messagereaction/schema_snapshot.nbt +78 -0
  24. package/stdlib/chat/migrations/20260514202654_update_directmessageroom/migration.nbt +4 -0
  25. package/stdlib/chat/migrations/20260514202654_update_directmessageroom/schema_snapshot.nbt +80 -0
  26. package/stdlib/chat/migrations/20260518191152_update_message/migration.nbt +3 -0
  27. package/stdlib/chat/migrations/20260518191152_update_message/schema_snapshot.nbt +81 -0
  28. package/stdlib/chat/schema.nbt +130 -0
  29. package/stdlib/crm/adapters/gohighlevel/README.md +85 -0
  30. package/stdlib/crm/adapters/gohighlevel/tests/README.md +159 -0
  31. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_138fields.json +222 -0
  32. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_140fields.json +219 -0
  33. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_alt.json +212 -0
  34. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_changed.json +102 -0
  35. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_created.json +95 -0
  36. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_full.json +213 -0
  37. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_sparse.json +161 -0
  38. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_update_a.json +197 -0
  39. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/contact_update_b.json +197 -0
  40. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/opportunity_changed.json +85 -0
  41. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/opportunity_created.json +85 -0
  42. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_contact_pilot.json +43 -0
  43. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_contact_with_price_closed.json +7 -0
  44. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_contact_with_price_open.json +7 -0
  45. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_appointment_delete.json +1 -0
  46. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_calendar_update.json +1 -0
  47. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_contact_create.json +1 -0
  48. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_event_opp_status_update.json +1 -0
  49. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_opportunity_pilot.json +16 -0
  50. package/stdlib/crm/adapters/gohighlevel/tests/fixtures/webhooks/v2_pipelines_pilot.json +137 -0
  51. package/stdlib/crm/migrations/20260501210107_initial/migration.nbt +63 -0
  52. package/stdlib/crm/migrations/20260501210107_initial/schema_snapshot.nbt +73 -0
  53. package/stdlib/crm/migrations/20260513151050_schema_update/migration.nbt +13 -0
  54. package/stdlib/crm/migrations/20260513151050_schema_update/schema_snapshot.nbt +86 -0
  55. package/stdlib/crm/schema.nbt +146 -0
  56. package/stdlib/design/migrations/20260501210107_initial/migration.nbt +19 -0
  57. package/stdlib/design/migrations/20260501210107_initial/schema_snapshot.nbt +21 -0
  58. package/stdlib/design/migrations/20260610130000_design_system/migration.nbt +50 -0
  59. package/stdlib/design/migrations/20260610130000_design_system/schema_snapshot.nbt +80 -0
  60. package/stdlib/design/schema.nbt +140 -0
  61. package/stdlib/dns/migrations/20260501210107_initial/migration.nbt +32 -0
  62. package/stdlib/dns/migrations/20260501210107_initial/schema_snapshot.nbt +36 -0
  63. package/stdlib/dns/schema.nbt +68 -0
  64. package/stdlib/email/migrations/20260427235207_initial/migration.nbt +75 -0
  65. package/stdlib/email/migrations/20260427235207_initial/schema_snapshot.nbt +87 -0
  66. package/stdlib/email/schema.nbt +145 -0
  67. package/stdlib/ingest/README.md +29 -0
  68. package/stdlib/ingest/migrations/20260424144652_initial/migration.nbt +18 -0
  69. package/stdlib/ingest/migrations/20260424144652_initial/schema_snapshot.nbt +20 -0
  70. package/stdlib/ingest/migrations/20260429203747_schema_update/migration.nbt +3 -0
  71. package/stdlib/ingest/migrations/20260429203747_schema_update/schema_snapshot.nbt +21 -0
  72. package/stdlib/ingest/schema.nbt +37 -0
  73. package/stdlib/notifications/README.md +118 -0
  74. package/stdlib/notifications/migrations/20260430204408_initial/migration.nbt +42 -0
  75. package/stdlib/notifications/migrations/20260430204408_initial/schema_snapshot.nbt +46 -0
  76. package/stdlib/notifications/schema.nbt +67 -0
  77. package/stdlib/phone/migrations/20260605205722_initial/migration.nbt +50 -0
  78. package/stdlib/phone/migrations/20260605205722_initial/schema_snapshot.nbt +56 -0
  79. package/stdlib/phone/schema.nbt +95 -0
  80. package/stdlib/registry/migrations/20260602181932_initial/migration.nbt +8 -0
  81. package/stdlib/registry/migrations/20260602181932_initial/schema_snapshot.nbt +8 -0
  82. package/stdlib/registry/schema.nbt +20 -0
  83. package/stdlib/workflows/schema.nbt +43 -0
  84. package/vendor/linux-x64/cartridges/auth/migrations/20260424144652_initial/migration.nbt +48 -0
  85. package/vendor/linux-x64/cartridges/auth/migrations/20260424144652_initial/schema_snapshot.nbt +58 -0
  86. package/vendor/linux-x64/cartridges/auth/migrations/20260521191014_update_user/migration.nbt +3 -0
  87. package/vendor/linux-x64/cartridges/auth/migrations/20260521191014_update_user/schema_snapshot.nbt +59 -0
  88. package/vendor/linux-x64/cartridges/auth/schema.nbt +142 -0
  89. package/vendor/linux-x64/cartridges/calendar/migrations/20260501210107_initial/migration.nbt +60 -0
  90. package/vendor/linux-x64/cartridges/calendar/migrations/20260501210107_initial/schema_snapshot.nbt +66 -0
  91. package/vendor/linux-x64/cartridges/calendar/migrations/20260513151050_schema_update/migration.nbt +17 -0
  92. package/vendor/linux-x64/cartridges/calendar/migrations/20260513151050_schema_update/schema_snapshot.nbt +83 -0
  93. package/vendor/linux-x64/cartridges/calendar/schema.nbt +85 -0
  94. package/vendor/linux-x64/cartridges/chat/migrations/20260429222411_initial/migration.nbt +59 -0
  95. package/vendor/linux-x64/cartridges/chat/migrations/20260429222411_initial/schema_snapshot.nbt +71 -0
  96. package/vendor/linux-x64/cartridges/chat/migrations/20260430185225_add_messagereaction/migration.nbt +9 -0
  97. package/vendor/linux-x64/cartridges/chat/migrations/20260430185225_add_messagereaction/schema_snapshot.nbt +78 -0
  98. package/vendor/linux-x64/cartridges/chat/migrations/20260514202654_update_directmessageroom/migration.nbt +4 -0
  99. package/vendor/linux-x64/cartridges/chat/migrations/20260514202654_update_directmessageroom/schema_snapshot.nbt +80 -0
  100. package/vendor/linux-x64/cartridges/chat/migrations/20260518191152_update_message/migration.nbt +3 -0
  101. package/vendor/linux-x64/cartridges/chat/migrations/20260518191152_update_message/schema_snapshot.nbt +81 -0
  102. package/vendor/linux-x64/cartridges/chat/schema.nbt +130 -0
  103. package/vendor/linux-x64/cartridges/crm/migrations/20260501210107_initial/migration.nbt +63 -0
  104. package/vendor/linux-x64/cartridges/crm/migrations/20260501210107_initial/schema_snapshot.nbt +73 -0
  105. package/vendor/linux-x64/cartridges/crm/migrations/20260513151050_schema_update/migration.nbt +13 -0
  106. package/vendor/linux-x64/cartridges/crm/migrations/20260513151050_schema_update/schema_snapshot.nbt +86 -0
  107. package/vendor/linux-x64/cartridges/crm/schema.nbt +146 -0
  108. package/vendor/linux-x64/cartridges/design/migrations/20260501210107_initial/migration.nbt +19 -0
  109. package/vendor/linux-x64/cartridges/design/migrations/20260501210107_initial/schema_snapshot.nbt +21 -0
  110. package/vendor/linux-x64/cartridges/design/migrations/20260610130000_design_system/migration.nbt +50 -0
  111. package/vendor/linux-x64/cartridges/design/migrations/20260610130000_design_system/schema_snapshot.nbt +80 -0
  112. package/vendor/linux-x64/cartridges/design/schema.nbt +140 -0
  113. package/vendor/linux-x64/cartridges/dns/migrations/20260501210107_initial/migration.nbt +32 -0
  114. package/vendor/linux-x64/cartridges/dns/migrations/20260501210107_initial/schema_snapshot.nbt +36 -0
  115. package/vendor/linux-x64/cartridges/dns/schema.nbt +68 -0
  116. package/vendor/linux-x64/cartridges/email/migrations/20260427235207_initial/migration.nbt +75 -0
  117. package/vendor/linux-x64/cartridges/email/migrations/20260427235207_initial/schema_snapshot.nbt +87 -0
  118. package/vendor/linux-x64/cartridges/email/schema.nbt +145 -0
  119. package/vendor/linux-x64/cartridges/ingest/migrations/20260424144652_initial/migration.nbt +18 -0
  120. package/vendor/linux-x64/cartridges/ingest/migrations/20260424144652_initial/schema_snapshot.nbt +20 -0
  121. package/vendor/linux-x64/cartridges/ingest/migrations/20260429203747_schema_update/migration.nbt +3 -0
  122. package/vendor/linux-x64/cartridges/ingest/migrations/20260429203747_schema_update/schema_snapshot.nbt +21 -0
  123. package/vendor/linux-x64/cartridges/ingest/schema.nbt +37 -0
  124. package/vendor/linux-x64/cartridges/notifications/migrations/20260430204408_initial/migration.nbt +42 -0
  125. package/vendor/linux-x64/cartridges/notifications/migrations/20260430204408_initial/schema_snapshot.nbt +46 -0
  126. package/vendor/linux-x64/cartridges/notifications/schema.nbt +67 -0
  127. package/vendor/linux-x64/cartridges/phone/migrations/20260605205722_initial/migration.nbt +50 -0
  128. package/vendor/linux-x64/cartridges/phone/migrations/20260605205722_initial/schema_snapshot.nbt +56 -0
  129. package/vendor/linux-x64/cartridges/phone/schema.nbt +95 -0
  130. package/vendor/linux-x64/cartridges/registry/migrations/20260602181932_initial/migration.nbt +8 -0
  131. package/vendor/linux-x64/cartridges/registry/migrations/20260602181932_initial/schema_snapshot.nbt +8 -0
  132. package/vendor/linux-x64/cartridges/registry/schema.nbt +20 -0
  133. package/vendor/linux-x64/cartridges/workflows/schema.nbt +43 -0
  134. package/vendor/linux-x64/console +0 -0
  135. package/vendor/linux-x64/nbt +0 -0
  136. package/contracts/audit/.dist/contract.json +0 -56
  137. package/contracts/auth/.dist/contract.json +0 -252
  138. package/contracts/calendar/.dist/contract.json +0 -141
  139. package/contracts/chat/.dist/contract.json +0 -229
  140. package/contracts/crm/.dist/contract.json +0 -239
  141. package/contracts/design/.dist/contract.json +0 -85
  142. package/contracts/dns/.dist/contract.json +0 -123
  143. package/contracts/email/.dist/contract.json +0 -267
  144. package/contracts/embed/.dist/contract.json +0 -137
  145. package/contracts/ingest/.dist/contract.json +0 -86
  146. package/contracts/notifications/.dist/contract.json +0 -133
  147. package/contracts/phone/.dist/contract.json +0 -168
  148. package/contracts/registry/.dist/contract.json +0 -49
  149. package/contracts/workflows/.dist/contract.json +0 -106
@@ -0,0 +1,67 @@
1
+ # Notifications cartridge — durable user notification state plus browser push
2
+ # subscriptions. The portal owns browser permission prompts and service worker
3
+ # registration; this cartridge owns the resulting state.
4
+ #
5
+ # Behavior (the former main.nbt actions) lives in native/runtime.jai as regular
6
+ # Jai over the generated ORM — see notifications_register_extra_routes.
7
+
8
+
9
+ entity Notification {
10
+ id: ulid
11
+ createdAt: DateTime @default(now())
12
+ updatedAt: DateTime @updatedAt
13
+ userId: string
14
+ projectId?: string
15
+ sourceCart?: string
16
+ sourceId?: string
17
+ kind: string
18
+
19
+ title: string
20
+ body?: string
21
+ url?: string
22
+ payloadJson?: string
23
+
24
+ readAt?: DateTime
25
+ archivedAt?: DateTime
26
+
27
+ @@index([userId])
28
+ @@index([projectId])
29
+ @@index([sourceCart, sourceId])
30
+ }
31
+
32
+ entity NotificationDelivery {
33
+ id: ulid
34
+ createdAt: DateTime @default(now())
35
+ updatedAt: DateTime @updatedAt
36
+ notificationId: string
37
+ userId: string
38
+ channel: string # "browser_push", later "email", "sms", etc.
39
+ status: string # "pending" | "sent" | "failed" | "skipped"
40
+ attempts: u32
41
+ lastError?: string
42
+ providerMessageId?: string
43
+ lastAttemptAt?: DateTime
44
+ sentAt?: DateTime
45
+
46
+ @@index([notificationId])
47
+ @@index([userId])
48
+ @@index([channel, status])
49
+ }
50
+
51
+ entity BrowserPushSubscription {
52
+ id: ulid
53
+ createdAt: DateTime @default(now())
54
+ updatedAt: DateTime @updatedAt
55
+ userId: string
56
+ endpoint: string
57
+ p256dh: string
58
+ auth: string
59
+ expirationTimeMs?: u64
60
+ userAgent?: string
61
+ deviceLabel?: string
62
+ lastSeenAt: DateTime @default(now())
63
+ disabledAt?: DateTime
64
+
65
+ @@unique([endpoint])
66
+ @@index([userId])
67
+ }
@@ -0,0 +1,50 @@
1
+ migration initial {
2
+ add_entity TwilioAccount
3
+ add_field TwilioAccount name string default("")
4
+ add_field TwilioAccount subAccountSid string default("")
5
+ add_field TwilioAccount authToken string default("")
6
+ add_field TwilioAccount publicUrlBase string default("")
7
+ add_field TwilioAccount status string default("")
8
+ add_field TwilioAccount retentionDays s32 default(0)
9
+ add_index TwilioAccount [subAccountSid]
10
+ add_unique TwilioAccount [name]
11
+ add_entity PhoneNumber
12
+ add_field PhoneNumber accountId string default("")
13
+ add_field PhoneNumber phoneNumber string default("")
14
+ add_field PhoneNumber numberSid string default("")
15
+ add_field PhoneNumber friendlyName string default("")
16
+ add_field PhoneNumber capabilities string default("")
17
+ add_index PhoneNumber [accountId]
18
+ add_index PhoneNumber [numberSid]
19
+ add_unique PhoneNumber [phoneNumber]
20
+ add_entity SmsMessage
21
+ add_field SmsMessage accountId string default("")
22
+ add_field SmsMessage numberId string default("")
23
+ add_field SmsMessage direction string default("")
24
+ add_field SmsMessage fromE164 string default("")
25
+ add_field SmsMessage toE164 string default("")
26
+ add_field SmsMessage body string default("")
27
+ add_field SmsMessage twilioSid string default("")
28
+ add_field SmsMessage status string default("")
29
+ add_field SmsMessage errorCode s32 default(0)
30
+ add_field SmsMessage errorMessage string default("")
31
+ add_field SmsMessage priceMicros s64 default(0)
32
+ add_field SmsMessage priceCurrency string default("")
33
+ add_field SmsMessage numSegments s32 default(0)
34
+ add_field SmsMessage numMedia s32 default(0)
35
+ add_field SmsMessage mediaUrls string default("")
36
+ add_field SmsMessage senderUserId string default("")
37
+ add_field SmsMessage dateSentMs u64 default(0)
38
+ add_field SmsMessage dateDeliveredMs u64 default(0)
39
+ add_index SmsMessage [accountId]
40
+ add_index SmsMessage [numberId]
41
+ add_index SmsMessage [twilioSid]
42
+ add_entity PhoneUsageDaily
43
+ add_field PhoneUsageDaily accountId string default("")
44
+ add_field PhoneUsageDaily date string default("")
45
+ add_field PhoneUsageDaily smsCount s64 default(0)
46
+ add_field PhoneUsageDaily smsSegmentsTotal s64 default(0)
47
+ add_field PhoneUsageDaily smsPriceMicros s64 default(0)
48
+ add_index PhoneUsageDaily [accountId]
49
+ add_unique PhoneUsageDaily [accountId, date]
50
+ }
@@ -0,0 +1,56 @@
1
+ entity TwilioAccount {
2
+ name: string
3
+ subAccountSid: string
4
+ authToken: string
5
+ publicUrlBase: string
6
+ status: string
7
+ retentionDays: s32
8
+ @@unique([name])
9
+ @@index([subAccountSid])
10
+ }
11
+
12
+ entity PhoneNumber {
13
+ accountId: string
14
+ phoneNumber: string
15
+ numberSid: string
16
+ friendlyName: string
17
+ capabilities: string
18
+ @@index([accountId])
19
+ @@unique([phoneNumber])
20
+ @@index([numberSid])
21
+ }
22
+
23
+ entity SmsMessage {
24
+ accountId: string
25
+ numberId: string
26
+ direction: string
27
+ fromE164: string
28
+ toE164: string
29
+ body: string
30
+ twilioSid: string
31
+ status: string
32
+ errorCode: s32
33
+ errorMessage: string
34
+ priceMicros: s64
35
+ priceCurrency: string
36
+ numSegments: s32
37
+ numMedia: s32
38
+ mediaUrls: string
39
+ senderUserId: string
40
+ dateSentMs: u64
41
+ dateDeliveredMs: u64
42
+ @@index([accountId])
43
+ @@index([numberId])
44
+ @@index([twilioSid])
45
+ }
46
+
47
+ entity PhoneUsageDaily {
48
+ accountId: string
49
+ date: string
50
+ smsCount: s64
51
+ smsSegmentsTotal: s64
52
+ smsPriceMicros: s64
53
+ @@unique([accountId, date])
54
+ @@index([accountId])
55
+ }
56
+
@@ -0,0 +1,95 @@
1
+ # Phone cartridge — Twilio number management, SMS, click-to-call.
2
+ #
3
+ # Per-tenant model (see modules/twilio/module.jai for the rationale):
4
+ # - One master Twilio account owned by the platform (SID + auth token in
5
+ # env: TWILIO_MASTER_SID, TWILIO_MASTER_TOKEN).
6
+ # - Each tenant gets a TwilioAccount row with its own subaccount SID and
7
+ # auth token. All per-tenant API calls authenticate as the subaccount.
8
+ # - Webhooks are configured to URLs under the tenant's public base
9
+ # (TwilioAccount.publicUrlBase), which the gateway routes back to this
10
+ # cart. Signature verification uses the subaccount's auth token.
11
+
12
+ # Behavior (the former jai{} helper blocks + actions) lives in
13
+ # native/runtime.jai over the generated ORM — see phone_register_extra_routes,
14
+ # which registers the HTTP routes.
15
+
16
+ # Auth policy for the hand-written routes (formerly @public actions). The
17
+ # handlers live in native/runtime.jai; these keep the daemon's public-route
18
+ # manifest correct so the /api/* auth gate is bypassed for Twilio webhooks.
19
+ @public_route "/api/phone/webhook/sms"
20
+ @public_route "/api/phone/webhook/status"
21
+
22
+ entity TwilioAccount {
23
+ id: ulid
24
+ createdAt: DateTime @default(now())
25
+ updatedAt: DateTime @updatedAt
26
+ name: string # operator-facing label
27
+ subAccountSid: string # AC... — populated by provision()
28
+ authToken: string # subaccount auth token (TODO: encrypt at rest)
29
+ publicUrlBase: string # e.g. "https://acme.console.app"
30
+ status: string # PENDING | ACTIVE | SUSPENDED | CLOSED
31
+ retentionDays: s32 # 0 = keep message bodies forever; N = null body after N days
32
+
33
+ @@unique([name])
34
+ @@index([subAccountSid])
35
+ }
36
+
37
+ entity PhoneNumber {
38
+ id: ulid
39
+ createdAt: DateTime @default(now())
40
+ updatedAt: DateTime @updatedAt
41
+ accountId: string # FK TwilioAccount.id
42
+ phoneNumber: string # E.164 "+15551234567"
43
+ numberSid: string # PN...
44
+ friendlyName: string
45
+ capabilities: string # "sms"
46
+
47
+ @@index([accountId])
48
+ @@unique([phoneNumber])
49
+ @@index([numberSid])
50
+ }
51
+
52
+ entity SmsMessage {
53
+ id: ulid
54
+ createdAt: DateTime @default(now())
55
+ updatedAt: DateTime @updatedAt
56
+ accountId: string
57
+ numberId: string # FK PhoneNumber.id (empty on inbound if not matched)
58
+ direction: string # inbound | outbound
59
+ fromE164: string
60
+ toE164: string
61
+ body: string # nulled after retentionDays if TwilioAccount configured
62
+ twilioSid: string # SM...
63
+ status: string # queued | sent | delivered | failed | received
64
+ errorCode: s32
65
+ errorMessage: string # human-readable sibling of errorCode
66
+ priceMicros: s64 # negative = charged (Twilio convention); 0 until status callback
67
+ priceCurrency: string # "USD" / "CAD"
68
+ numSegments: s32
69
+ numMedia: s32
70
+ mediaUrls: string # JSON array of MMS media URLs
71
+ senderUserId: string # who triggered the send (empty for inbound)
72
+ dateSentMs: u64 # Twilio canonical timestamp (ms since epoch)
73
+ dateDeliveredMs: u64
74
+
75
+ @@index([accountId])
76
+ @@index([numberId])
77
+ @@index([twilioSid])
78
+ }
79
+
80
+ # Per-tenant per-day usage rollup. Written by the nightly rollup workflow;
81
+ # read by the portal to generate invoices.
82
+ entity PhoneUsageDaily {
83
+ id: ulid
84
+ createdAt: DateTime @default(now())
85
+ updatedAt: DateTime @updatedAt
86
+ accountId: string
87
+ date: string # "YYYY-MM-DD" in UTC
88
+ smsCount: s64
89
+ smsSegmentsTotal: s64
90
+ smsPriceMicros: s64
91
+
92
+ @@unique([accountId, date])
93
+ @@index([accountId])
94
+ }
95
+
@@ -0,0 +1,8 @@
1
+ migration initial {
2
+ add_entity InstalledCartridge
3
+ add_field InstalledCartridge tier string default("")
4
+ add_field InstalledCartridge source string default("")
5
+ add_field InstalledCartridge schemaChecksum string default("")
6
+ add_field InstalledCartridge installedAt u64 default(0)
7
+ add_field InstalledCartridge status string default("")
8
+ }
@@ -0,0 +1,8 @@
1
+ entity InstalledCartridge {
2
+ tier: string
3
+ source: string
4
+ schemaChecksum: string
5
+ installedAt: u64
6
+ status: string
7
+ }
8
+
@@ -0,0 +1,20 @@
1
+ # Installed-cartridge registry — the single source of truth for which tier-2
2
+ # (bundled) and customer cartridges are installed on this instance.
3
+ #
4
+ # Lives in replicated storage, so the install set is HA-safe and survives
5
+ # restarts: on boot the console re-activates every InstalledCartridge row.
6
+ #
7
+ # The console daemon is the SINGLE WRITER (cartridge_registry.jai writes rows
8
+ # through THIS cart's generated serializer — same code, no format drift). The
9
+ # generated CRUD routes are read-mostly, for the portal/client. The row id is
10
+ # the cartridge name.
11
+ entity InstalledCartridge {
12
+ id: string @id # the cartridge name (slug), NOT a ulid
13
+ createdAt: DateTime @default(now())
14
+ updatedAt: DateTime @updatedAt
15
+ tier: string # "bundled" | "customer"
16
+ source: string # "bundled" | "customer"
17
+ schemaChecksum: string # checksum of the installed schema (drift detection)
18
+ installedAt: u64 # ms epoch
19
+ status: string # "installed" | "failed"
20
+ }
@@ -0,0 +1,43 @@
1
+
2
+ # Question: How do we tie in cartridge metadata and workflow side effects into all this?
3
+
4
+ enum WorkerStatus {
5
+ WAITING
6
+ RUNNING
7
+ TERMINATED
8
+ }
9
+
10
+ entity Worker {
11
+ id: ulid
12
+ createdAt: DateTime @default(now())
13
+ updatedAt: DateTime @updatedAt
14
+ source: blob
15
+ contentHash: string
16
+ queue?: string
17
+ # TODO: We need some sort of termination options like a restart policy
18
+ }
19
+
20
+ # Stub — flesh out execution lifecycle fields later.
21
+ entity WorkflowExecution {
22
+ id: ulid
23
+ createdAt: DateTime @default(now())
24
+ updatedAt: DateTime @updatedAt
25
+ status: string
26
+ events: WorkflowExecutionEvent[]
27
+ }
28
+
29
+ # Do we want this to be a string?
30
+ enum WorkflowExecutionEventKind {
31
+ WORKFLOW_EXECUTION_STARTED
32
+ WORKFLOW_STEP_SCHEDULED
33
+ WORKFLOW_STEP_STARTED
34
+ WORKFLOW_STEP_COMPLETED
35
+ WORKFLOW_EXECUTION_COMPLETED
36
+ }
37
+
38
+ entity WorkflowExecutionEvent {
39
+ id: ulid
40
+ createdAt: DateTime @default(now())
41
+ updatedAt: DateTime @updatedAt
42
+ kind: WorkflowExecutionEventKind
43
+ }
Binary file
Binary file
@@ -1,56 +0,0 @@
1
- {
2
- "cartridge": "audit",
3
- "version": "0.1",
4
- "owns": {
5
- "AuditEvent": {
6
- "fields": [
7
- { "name": "id", "type": "ULID", "kind": "scalar" },
8
- { "name": "createdAt", "type": "DateTime", "kind": "scalar" },
9
- { "name": "updatedAt", "type": "DateTime", "kind": "scalar" },
10
- { "name": "seq", "type": "u64", "kind": "scalar" },
11
- { "name": "actor", "type": "string", "kind": "scalar" },
12
- { "name": "resource", "type": "string", "kind": "scalar" },
13
- { "name": "verb", "type": "string", "kind": "scalar" },
14
- { "name": "requestId", "type": "string", "kind": "scalar" },
15
- { "name": "cartridgeName", "type": "string", "optional": true, "kind": "scalar" },
16
- { "name": "outcome", "type": "string", "kind": "scalar" },
17
- { "name": "cap", "type": "string", "optional": true, "kind": "scalar" },
18
- { "name": "srcIp", "type": "string", "optional": true, "kind": "scalar" },
19
- { "name": "beforeHash", "type": "string", "optional": true, "kind": "scalar" },
20
- { "name": "afterHash", "type": "string", "optional": true, "kind": "scalar" },
21
- { "name": "prevHash", "type": "string", "kind": "scalar" },
22
- { "name": "detail", "type": "string", "optional": true, "kind": "scalar" },
23
- { "name": "ts", "type": "DateTime", "kind": "scalar" }
24
- ],
25
- "indices": [["seq"]],
26
- "searchFields": [],
27
- "methods": [
28
- { "name": "find_by_id", "inputs": [ { "name": "id", "type": "string" } ], "outputs": [ { "name": "out", "type": "AuditEvent" } ] },
29
- { "name": "list", "inputs": [], "outputs": [ { "name": "out", "type": "list<AuditEvent>" } ] },
30
- { "name": "delete", "inputs": [ { "name": "id", "type": "string" } ], "outputs": [] },
31
- { "name": "create", "inputs": [{ "name": "id", "type": "ULID" }, { "name": "seq", "type": "u64" }, { "name": "actor", "type": "string" }, { "name": "resource", "type": "string" }, { "name": "verb", "type": "string" }, { "name": "requestId", "type": "string" }, { "name": "outcome", "type": "string" }, { "name": "prevHash", "type": "string" }, { "name": "cartridgeName", "type": "string", "optional": true }, { "name": "cap", "type": "string", "optional": true }, { "name": "srcIp", "type": "string", "optional": true }, { "name": "beforeHash", "type": "string", "optional": true }, { "name": "afterHash", "type": "string", "optional": true }, { "name": "detail", "type": "string", "optional": true }], "outputs": [ { "name": "out", "type": "AuditEvent" } ] },
32
- { "name": "update", "inputs": [{ "name": "id", "type": "string" }, { "name": "id", "type": "ULID", "optional": true }, { "name": "seq", "type": "u64", "optional": true }, { "name": "actor", "type": "string", "optional": true }, { "name": "resource", "type": "string", "optional": true }, { "name": "verb", "type": "string", "optional": true }, { "name": "requestId", "type": "string", "optional": true }, { "name": "cartridgeName", "type": "string", "optional": true }, { "name": "outcome", "type": "string", "optional": true }, { "name": "cap", "type": "string", "optional": true }, { "name": "srcIp", "type": "string", "optional": true }, { "name": "beforeHash", "type": "string", "optional": true }, { "name": "afterHash", "type": "string", "optional": true }, { "name": "prevHash", "type": "string", "optional": true }, { "name": "detail", "type": "string", "optional": true }], "outputs": [ { "name": "out", "type": "AuditEvent" } ] },
33
- { "name": "find_by_seq", "inputs": [ { "name": "seq", "type": "u64" } ], "outputs": [ { "name": "out", "type": "list<AuditEvent>" } ] }
34
- ],
35
- "routes": [
36
- { "op": "list", "method": "GET", "path": "/api/audit/auditevent" },
37
- { "op": "create", "method": "POST", "path": "/api/audit/auditevent" },
38
- { "op": "count", "method": "GET", "path": "/api/audit/auditevent/count" },
39
- { "op": "batch_get", "method": "POST", "path": "/api/audit/auditevent/_batch" },
40
- { "op": "get", "method": "GET", "path": "/api/audit/auditevent/:id" }
41
- ],
42
- "exported": false
43
- }
44
- },
45
- "structs": [],
46
- "enums": [],
47
- "imports": {
48
- },
49
- "actions": [],
50
- "middleware": [],
51
- "workflows": [],
52
- "schedules": [],
53
- "tasks": [],
54
- "tools": [],
55
- "widgets": []
56
- }