@ingenx-io/valets-schema-mcp-server 0.2.3 → 0.2.5

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 (76) hide show
  1. package/README.md +26 -0
  2. package/data/docs/collections/firestore-paths.md +32 -20
  3. package/data/docs/enums/app-status.md +24 -0
  4. package/data/docs/enums/attention-status.md +2 -2
  5. package/data/docs/enums/booking-status.md +2 -2
  6. package/data/docs/enums/customer-payment-status.md +2 -2
  7. package/data/docs/enums/customer-payment-target-type.md +2 -2
  8. package/data/docs/enums/delivery-type.md +2 -2
  9. package/data/docs/enums/deployment-link-type.md +2 -2
  10. package/data/docs/enums/event-status.md +2 -2
  11. package/data/docs/enums/fulfillment-status.md +2 -2
  12. package/data/docs/enums/loyalty-transaction-type.md +2 -2
  13. package/data/docs/enums/notification-channel.md +2 -2
  14. package/data/docs/enums/notification-entity-type.md +2 -2
  15. package/data/docs/enums/notification-status.md +2 -2
  16. package/data/docs/enums/order-status.md +2 -2
  17. package/data/docs/enums/outbound-message-format.md +2 -2
  18. package/data/docs/enums/outbound-message-purpose.md +2 -2
  19. package/data/docs/enums/outbound-message-status.md +2 -2
  20. package/data/docs/enums/payment-method.md +2 -2
  21. package/data/docs/enums/payment-proof-status.md +2 -2
  22. package/data/docs/enums/payment-status.md +2 -2
  23. package/data/docs/enums/pending-issue.md +2 -2
  24. package/data/docs/enums/return-status.md +2 -2
  25. package/data/docs/enums/session-status.md +2 -2
  26. package/data/docs/enums/site-status.md +2 -2
  27. package/data/docs/enums/stocktake-frequency.md +2 -2
  28. package/data/docs/enums/stocktake-item-status.md +2 -2
  29. package/data/docs/enums/stocktake-status.md +2 -2
  30. package/data/docs/enums/ticket-status.md +2 -2
  31. package/data/docs/enums/waba-label.md +2 -2
  32. package/data/docs/enums/whatsapp-button-sub-type.md +2 -2
  33. package/data/docs/enums/whatsapp-template-component.md +2 -2
  34. package/data/docs/enums/whatsapp-template-status.md +2 -2
  35. package/data/docs/index.md +9 -5
  36. package/data/docs/models/allowed-user.md +7 -7
  37. package/data/docs/models/analytics-backfill.md +7 -7
  38. package/data/docs/models/analytics-daily.md +6 -6
  39. package/data/docs/models/analytics-event.md +7 -7
  40. package/data/docs/models/analytics-hourly.md +6 -6
  41. package/data/docs/models/app-payment.md +200 -0
  42. package/data/docs/models/app.md +561 -0
  43. package/data/docs/models/booking-version.md +2 -2
  44. package/data/docs/models/booking.md +127 -127
  45. package/data/docs/models/customer-payment-allocation.md +20 -20
  46. package/data/docs/models/customer-payment.md +23 -23
  47. package/data/docs/models/customer.md +11 -11
  48. package/data/docs/models/event.md +22 -22
  49. package/data/docs/models/loyalty-config.md +4 -4
  50. package/data/docs/models/loyalty-reward.md +3 -3
  51. package/data/docs/models/loyalty-status.md +6 -6
  52. package/data/docs/models/loyalty-transaction.md +2 -2
  53. package/data/docs/models/magic-link-request.md +9 -9
  54. package/data/docs/models/metrics-current.md +169 -37
  55. package/data/docs/models/metrics-daily.md +172 -40
  56. package/data/docs/models/metrics-monthly.md +172 -40
  57. package/data/docs/models/notification-record.md +3 -3
  58. package/data/docs/models/order-item.md +6 -6
  59. package/data/docs/models/order.md +78 -78
  60. package/data/docs/models/sale.md +18 -18
  61. package/data/docs/models/site-payment.md +2 -2
  62. package/data/docs/models/site.md +2 -2
  63. package/data/docs/models/stocktake-item.md +4 -4
  64. package/data/docs/models/stocktake.md +5 -5
  65. package/data/docs/models/ticket.md +3 -3
  66. package/data/docs/models/user.md +249 -0
  67. package/data/docs/models/whatsapp-inbound-message.md +2 -2
  68. package/data/docs/models/whatsapp-outbound-lifecycle-event.md +2 -2
  69. package/data/docs/models/whatsapp-outbound-message.md +6 -6
  70. package/data/docs/models/whatsapp-template.md +2 -2
  71. package/data/static/cookbook.json +150 -0
  72. package/data/static/llms.txt +179 -33
  73. package/data/static/openapi.yaml +626 -60
  74. package/data/static/schemas.json +680 -69
  75. package/index.js +32 -0
  76. package/package.json +1 -1
@@ -0,0 +1,249 @@
1
+ ---
2
+ title: "User"
3
+ sidebar_label: "User"
4
+ sidebar_position: 31
5
+ ---
6
+
7
+ # User
8
+
9
+ <details>
10
+ <summary>Example JSON</summary>
11
+
12
+ ```json
13
+ {
14
+ "id": null,
15
+ "displayName": null,
16
+ "email": null,
17
+ "phoneE164": null,
18
+ "companyId": null,
19
+ "role": null,
20
+ "isActive": null,
21
+ "createdAt": "createdAt",
22
+ "updatedAt": "updatedAt"
23
+ }
24
+ ```
25
+
26
+ </details>
27
+
28
+
29
+ - [1. Property `id`](#id)
30
+ - [2. Property `displayName`](#displayName)
31
+ - [3. Property `email`](#email)
32
+ - [4. Property `phoneE164`](#phoneE164)
33
+ - [5. Property `companyId`](#companyId)
34
+ - [6. Property `role`](#role)
35
+ - [7. Property `isActive`](#isActive)
36
+ - [8. Property `createdAt`](#createdAt)
37
+ - [8.1. Property `firestore-timestamp`](#createdAt_anyOf_i0)
38
+ - [8.1.1. Property `_seconds`](#createdAt_anyOf_i0__seconds)
39
+ - [8.1.2. Property `_nanoseconds`](#createdAt_anyOf_i0__nanoseconds)
40
+ - [8.2. Property `item 1`](#createdAt_anyOf_i1)
41
+ - [9. Property `updatedAt`](#updatedAt)
42
+ - [9.1. Property `firestore-timestamp`](#updatedAt_anyOf_i0)
43
+ - [9.2. Property `item 1`](#updatedAt_anyOf_i1)
44
+
45
+ | | |
46
+ | ------------------------- | ------------------ |
47
+ | **Type** | `object` |
48
+ | **Required** | No |
49
+ | **Additional properties** | Not allowed |
50
+ | **Defined in** | #/definitions/user |
51
+
52
+ **Description:** User / staff account. Collection: users/\{uid\}. Document ID is always the Firebase Auth UID (decision #27). phoneE164 is the canonical E.164 phone field for OTP lookup. Legacy phone-keyed documents must be migrated to uid-keyed docs with phoneE164 set.
53
+
54
+ | Property | Pattern | Type | Deprecated | Definition | Title/Description |
55
+ | ------------------------------ | ------- | --------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------ |
56
+ | - [id](#id ) | No | string or null | No | - | (Read-only) Firebase Auth UID. Matches the Firestore document ID. |
57
+ | - [displayName](#displayName ) | No | string or null | No | - | User display name from Firebase Auth or manually set. |
58
+ | - [email](#email ) | No | string or null | No | - | Email address. Present for email/Google auth users. |
59
+ | - [phoneE164](#phoneE164 ) | No | string or null | No | - | E.164-normalized phone number (e.g. +2250777471485). Canonical phone identity field; used for WhatsApp OTP lookup via indexed query. |
60
+ | - [companyId](#companyId ) | No | string or null | No | - | (Immutable) FK → Company document ID. Present for staff accounts scoped to a company. |
61
+ | - [role](#role ) | No | string or null | No | - | Staff role within the company (e.g. admin, manager, staff). Application-defined. |
62
+ | - [isActive](#isActive ) | No | boolean or null | No | - | Whether this user account is active. Inactive accounts are denied access. |
63
+ | - [createdAt](#createdAt ) | No | Combination | No | - | (Read-only) When the user document was created. |
64
+ | - [updatedAt](#updatedAt ) | No | Combination | No | - | (Read-only) When the user document was last updated. |
65
+
66
+ ## <a name="id"></a>1. Property `id`
67
+
68
+ | | |
69
+ | ------------ | ---------------- |
70
+ | **Type** | `string or null` |
71
+ | **Required** | No |
72
+
73
+ **Description:** (Read-only) Firebase Auth UID. Matches the Firestore document ID.
74
+
75
+ :::warning Server-set
76
+ Do not include in write requests. This field is set exclusively by the server (Firestore trigger or Admin SDK). Clients that send it will have the value silently ignored or may receive a validation error.
77
+ :::
78
+
79
+ ## <a name="displayName"></a>2. Property `displayName`
80
+
81
+ | | |
82
+ | ------------ | ---------------- |
83
+ | **Type** | `string or null` |
84
+ | **Required** | No |
85
+
86
+ **Description:** User display name from Firebase Auth or manually set.
87
+
88
+ ## <a name="email"></a>3. Property `email`
89
+
90
+ | | |
91
+ | ------------ | ---------------- |
92
+ | **Type** | `string or null` |
93
+ | **Required** | No |
94
+
95
+ **Description:** Email address. Present for email/Google auth users.
96
+
97
+ ## <a name="phoneE164"></a>4. Property `phoneE164`
98
+
99
+ | | |
100
+ | ------------ | ---------------- |
101
+ | **Type** | `string or null` |
102
+ | **Required** | No |
103
+
104
+ **Description:** E.164-normalized phone number (e.g. +2250777471485). Canonical phone identity field; used for WhatsApp OTP lookup via indexed query.
105
+
106
+ :::note
107
+ E.164 format with leading + (e.g. +2250777471485). Canonical phone identity field (decision #27). Distinct from wa_id (Meta conversation key). Server must normalize at write time: 8-digit CI local → prepend +225.
108
+ :::
109
+
110
+ :::tip When to set
111
+ Set when the user authenticated via phone (WhatsApp OTP) or when a staff member's phone is known. Required for WhatsApp OTP lookup — add a Firestore composite index on phoneE164.
112
+ :::
113
+
114
+ ## <a name="companyId"></a>5. Property `companyId`
115
+
116
+ | | |
117
+ | ------------ | ---------------- |
118
+ | **Type** | `string or null` |
119
+ | **Required** | No |
120
+
121
+ **Description:** (Immutable) FK → Company document ID. Present for staff accounts scoped to a company.
122
+
123
+ :::info Immutable
124
+ Set at creation only. This field cannot be modified after the document is created. Include it in CREATE payloads; omit it (or leave unchanged) in UPDATE payloads.
125
+ :::
126
+
127
+ ## <a name="role"></a>6. Property `role`
128
+
129
+ | | |
130
+ | ------------ | ---------------- |
131
+ | **Type** | `string or null` |
132
+ | **Required** | No |
133
+
134
+ **Description:** Staff role within the company (e.g. admin, manager, staff). Application-defined.
135
+
136
+ ## <a name="isActive"></a>7. Property `isActive`
137
+
138
+ | | |
139
+ | ------------ | ----------------- |
140
+ | **Type** | `boolean or null` |
141
+ | **Required** | No |
142
+
143
+ **Description:** Whether this user account is active. Inactive accounts are denied access.
144
+
145
+ ## <a name="createdAt"></a>8. Property `createdAt`
146
+
147
+ | | |
148
+ | ------------------------- | ---------------- |
149
+ | **Type** | `combining` |
150
+ | **Required** | No |
151
+ | **Additional properties** | Any type allowed |
152
+
153
+ **Description:** (Read-only) When the user document was created.
154
+
155
+ | Any of(Option) |
156
+ | ------------------------------------------ |
157
+ | [firestore-timestamp](#createdAt_anyOf_i0) |
158
+ | [item 1](#createdAt_anyOf_i1) |
159
+
160
+ ### <a name="createdAt_anyOf_i0"></a>8.1. Property `firestore-timestamp`
161
+
162
+ | | |
163
+ | ------------------------- | --------------------------------- |
164
+ | **Type** | `object` |
165
+ | **Required** | No |
166
+ | **Additional properties** | Not allowed |
167
+ | **Defined in** | #/definitions/firestore-timestamp |
168
+
169
+ **Description:** Firestore Timestamp — Admin SDK form: \{ _seconds, _nanoseconds \}. See types/firestore.ts for REST API v1 and client SDK serialization notes (#10).
170
+
171
+ | Property | Pattern | Type | Deprecated | Definition | Title/Description |
172
+ | --------------------------------------------------- | ------- | ------- | ---------- | ---------- | ----------------- |
173
+ | + [_seconds](#createdAt_anyOf_i0__seconds ) | No | integer | No | - | - |
174
+ | + [_nanoseconds](#createdAt_anyOf_i0__nanoseconds ) | No | integer | No | - | - |
175
+
176
+ #### <a name="createdAt_anyOf_i0__seconds"></a>8.1.1. Property `_seconds`
177
+
178
+ | | |
179
+ | ------------ | --------- |
180
+ | **Type** | `integer` |
181
+ | **Required** | Yes |
182
+
183
+ | Restrictions | |
184
+ | ------------ | ---------------------- |
185
+ | **Minimum** | &ge; -9007199254740991 |
186
+ | **Maximum** | &le; 9007199254740991 |
187
+
188
+ #### <a name="createdAt_anyOf_i0__nanoseconds"></a>8.1.2. Property `_nanoseconds`
189
+
190
+ | | |
191
+ | ------------ | --------- |
192
+ | **Type** | `integer` |
193
+ | **Required** | Yes |
194
+
195
+ | Restrictions | |
196
+ | ------------ | ---------------------- |
197
+ | **Minimum** | &ge; -9007199254740991 |
198
+ | **Maximum** | &le; 9007199254740991 |
199
+
200
+ ### <a name="createdAt_anyOf_i1"></a>8.2. Property `item 1`
201
+
202
+ | | |
203
+ | ------------ | ------ |
204
+ | **Type** | `null` |
205
+ | **Required** | No |
206
+
207
+ :::warning Server-set
208
+ Do not include in write requests. This field is set exclusively by the server (Firestore trigger or Admin SDK). Clients that send it will have the value silently ignored or may receive a validation error.
209
+ :::
210
+
211
+ ## <a name="updatedAt"></a>9. Property `updatedAt`
212
+
213
+ | | |
214
+ | ------------------------- | ---------------- |
215
+ | **Type** | `combining` |
216
+ | **Required** | No |
217
+ | **Additional properties** | Any type allowed |
218
+
219
+ **Description:** (Read-only) When the user document was last updated.
220
+
221
+ | Any of(Option) |
222
+ | ------------------------------------------ |
223
+ | [firestore-timestamp](#updatedAt_anyOf_i0) |
224
+ | [item 1](#updatedAt_anyOf_i1) |
225
+
226
+ ### <a name="updatedAt_anyOf_i0"></a>9.1. Property `firestore-timestamp`
227
+
228
+ | | |
229
+ | ------------------------- | ----------------------------------------- |
230
+ | **Type** | `object` |
231
+ | **Required** | No |
232
+ | **Additional properties** | Not allowed |
233
+ | **Same definition as** | [createdAt_anyOf_i0](#createdAt_anyOf_i0) |
234
+
235
+ **Description:** Firestore Timestamp — Admin SDK form: \{ _seconds, _nanoseconds \}. See types/firestore.ts for REST API v1 and client SDK serialization notes (#10).
236
+
237
+ ### <a name="updatedAt_anyOf_i1"></a>9.2. Property `item 1`
238
+
239
+ | | |
240
+ | ------------ | ------ |
241
+ | **Type** | `null` |
242
+ | **Required** | No |
243
+
244
+ ----------------------------------------------------------------------------------------------------------------------------
245
+ Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-30 at 12:42:51 +0000
246
+
247
+ :::warning Server-set
248
+ Do not include in write requests. This field is set exclusively by the server (Firestore trigger or Admin SDK). Clients that send it will have the value silently ignored or may receive a validation error.
249
+ :::
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: "WhatsappInboundMessage"
3
3
  sidebar_label: "WhatsappInboundMessage"
4
- sidebar_position: 29
4
+ sidebar_position: 32
5
5
  ---
6
6
 
7
7
  # WhatsappInboundMessage
@@ -366,4 +366,4 @@ Do not include in write requests. This field is set exclusively by the server (F
366
366
  Specific value: `true`
367
367
 
368
368
  ----------------------------------------------------------------------------------------------------------------------------
369
- Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-27 at 15:51:05 +0000
369
+ Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-30 at 12:42:51 +0000
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: "WhatsappOutboundLifecycleEvent"
3
3
  sidebar_label: "WhatsappOutboundLifecycleEvent"
4
- sidebar_position: 30
4
+ sidebar_position: 33
5
5
  ---
6
6
 
7
7
  # WhatsappOutboundLifecycleEvent
@@ -303,7 +303,7 @@ Do not include in write requests. This field is set exclusively by the server (F
303
303
  **Description:** (Read-only) Raw Meta error object(s).
304
304
 
305
305
  ----------------------------------------------------------------------------------------------------------------------------
306
- Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-27 at 15:51:06 +0000
306
+ Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-30 at 12:42:51 +0000
307
307
 
308
308
  :::warning Server-set
309
309
  Do not include in write requests. This field is set exclusively by the server (Firestore trigger or Admin SDK). Clients that send it will have the value silently ignored or may receive a validation error.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: "WhatsappOutboundMessage"
3
3
  sidebar_label: "WhatsappOutboundMessage"
4
- sidebar_position: 31
4
+ sidebar_position: 34
5
5
  ---
6
6
 
7
7
  # WhatsappOutboundMessage
@@ -461,7 +461,7 @@ Do not include in write requests. This field is set exclusively by the server (F
461
461
  | **Additional properties** | Not allowed |
462
462
  | **Same definition as** | [createdAt](#createdAt) |
463
463
 
464
- **Description:** Firestore Timestamp serialized representation
464
+ **Description:** Firestore Timestamp Admin SDK form: \{ _seconds, _nanoseconds \}. See types/firestore.ts for REST API v1 and client SDK serialization notes (#10).
465
465
 
466
466
  ### <a name="sentAt_anyOf_i1"></a>15.2. Property `item 1`
467
467
 
@@ -498,7 +498,7 @@ Do not include in write requests. This field is set exclusively by the server (F
498
498
  | **Additional properties** | Not allowed |
499
499
  | **Same definition as** | [createdAt](#createdAt) |
500
500
 
501
- **Description:** Firestore Timestamp serialized representation
501
+ **Description:** Firestore Timestamp Admin SDK form: \{ _seconds, _nanoseconds \}. See types/firestore.ts for REST API v1 and client SDK serialization notes (#10).
502
502
 
503
503
  ### <a name="deliveredAt_anyOf_i1"></a>16.2. Property `item 1`
504
504
 
@@ -535,7 +535,7 @@ Do not include in write requests. This field is set exclusively by the server (F
535
535
  | **Additional properties** | Not allowed |
536
536
  | **Same definition as** | [createdAt](#createdAt) |
537
537
 
538
- **Description:** Firestore Timestamp serialized representation
538
+ **Description:** Firestore Timestamp Admin SDK form: \{ _seconds, _nanoseconds \}. See types/firestore.ts for REST API v1 and client SDK serialization notes (#10).
539
539
 
540
540
  ### <a name="readAt_anyOf_i1"></a>17.2. Property `item 1`
541
541
 
@@ -572,7 +572,7 @@ Do not include in write requests. This field is set exclusively by the server (F
572
572
  | **Additional properties** | Not allowed |
573
573
  | **Same definition as** | [createdAt](#createdAt) |
574
574
 
575
- **Description:** Firestore Timestamp serialized representation
575
+ **Description:** Firestore Timestamp Admin SDK form: \{ _seconds, _nanoseconds \}. See types/firestore.ts for REST API v1 and client SDK serialization notes (#10).
576
576
 
577
577
  ### <a name="failedAt_anyOf_i1"></a>18.2. Property `item 1`
578
578
 
@@ -582,7 +582,7 @@ Do not include in write requests. This field is set exclusively by the server (F
582
582
  | **Required** | No |
583
583
 
584
584
  ----------------------------------------------------------------------------------------------------------------------------
585
- Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-27 at 15:51:06 +0000
585
+ Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-30 at 12:42:51 +0000
586
586
 
587
587
  :::warning Server-set
588
588
  Do not include in write requests. This field is set exclusively by the server (Firestore trigger or Admin SDK). Clients that send it will have the value silently ignored or may receive a validation error.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  title: "WhatsappTemplate"
3
3
  sidebar_label: "WhatsappTemplate"
4
- sidebar_position: 32
4
+ sidebar_position: 35
5
5
  ---
6
6
 
7
7
  # WhatsappTemplate
@@ -287,7 +287,7 @@ Do not include in write requests. This field is set exclusively by the server (F
287
287
  **Description:** (Read-only) Rendered preview text for display in the dashboard picker.
288
288
 
289
289
  ----------------------------------------------------------------------------------------------------------------------------
290
- Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-27 at 15:51:06 +0000
290
+ Generated using [json-schema-for-humans](https://github.com/coveooss/json-schema-for-humans) on 2026-05-30 at 12:42:51 +0000
291
291
 
292
292
  :::warning Server-set
293
293
  Do not include in write requests. This field is set exclusively by the server (Firestore trigger or Admin SDK). Clients that send it will have the value silently ignored or may receive a validation error.
@@ -0,0 +1,150 @@
1
+ {
2
+ "version": "1",
3
+ "recipes": [
4
+ {
5
+ "slug": "write-model-code",
6
+ "title": "Writing code that touches a model",
7
+ "summary": "How to look up a model's schema, identify field constraints, and avoid writing to server-set or immutable fields.",
8
+ "steps": [
9
+ {
10
+ "step": 1,
11
+ "tool": "schema_overview",
12
+ "args": {},
13
+ "note": "Start here to see all available models and enums. Identify the model(s) your code will read or write."
14
+ },
15
+ {
16
+ "step": 2,
17
+ "tool": "get_schema",
18
+ "args": { "name": "<model-name>" },
19
+ "note": "Fetch the full JSON Schema for the model. Inspect each field for constraint extensions: readOnly, x-immutable, deprecated, x-note, x-when."
20
+ },
21
+ {
22
+ "step": 3,
23
+ "tool": "get_openapi",
24
+ "args": { "component": "<ModelCreate>" },
25
+ "note": "Use the Create variant (PascalCase + 'Create', e.g. 'OrderCreate') to determine the correct write shape. readOnly and deprecated fields are excluded from required[] here."
26
+ },
27
+ {
28
+ "step": 4,
29
+ "tool": "get_openapi",
30
+ "args": { "component": "<ModelUpdate>" },
31
+ "note": "For PATCH operations use the Update variant. All fields become optional and readOnly / x-immutable fields are excluded entirely."
32
+ },
33
+ {
34
+ "step": 5,
35
+ "tool": "get_doc",
36
+ "args": { "slug": "models/<model-name>" },
37
+ "note": "Read the human-readable doc page for callout blocks: server-set warnings, immutable notices, deprecation alerts, and implementation tips."
38
+ }
39
+ ],
40
+ "field_constraint_cheatsheet": {
41
+ "readOnly: true": "Set by Firestore trigger or Admin SDK only — never write from client or backend application code.",
42
+ "x-immutable: true": "Set exactly once at document creation. Any subsequent write to this field is a bug.",
43
+ "deprecated: true": "Do not write in new code. Check x-replaced-by for the replacement field.",
44
+ "x-internal: true": "Backend-only collection — consumers must not depend on this model's shape."
45
+ },
46
+ "tips": [
47
+ "Field descriptions often contain '(GH#N)' or '(D-id)' references — use get_decision to trace rationale.",
48
+ "If a field is absent from ModelCreate, it is either readOnly (server-sets it) or deprecated.",
49
+ "Run get_schema on related enums (e.g. 'payment-status') to understand the allowed values for enum fields."
50
+ ]
51
+ },
52
+ {
53
+ "slug": "field-history",
54
+ "title": "Understanding a field's history or rationale",
55
+ "summary": "How to trace why a field exists, what decision or issue drove it, and whether it has been migrated or superseded.",
56
+ "steps": [
57
+ {
58
+ "step": 1,
59
+ "tool": "search_docs",
60
+ "args": { "query": "<fieldName>" },
61
+ "note": "Find every doc page that mentions the field. This surfaces the model page, any decision pages, and migration docs."
62
+ },
63
+ {
64
+ "step": 2,
65
+ "tool": "get_schema",
66
+ "args": { "name": "<model-name>" },
67
+ "note": "Read the field's 'description' value directly. It typically includes a GH# issue reference or a D-id decision reference."
68
+ },
69
+ {
70
+ "step": 3,
71
+ "tool": "list_decisions",
72
+ "args": {},
73
+ "note": "Scan all decisions for ones related to the model or field. Look at 'status': accepted decisions are live; superseded ones have been replaced."
74
+ },
75
+ {
76
+ "step": 4,
77
+ "tool": "get_decision",
78
+ "args": { "id": "<D-id>" },
79
+ "note": "Get full context: rationale, migration path, affected models, and implementation status."
80
+ },
81
+ {
82
+ "step": 5,
83
+ "tool": "get_doc",
84
+ "args": { "slug": "decisions/migrations" },
85
+ "note": "Check the migrations page for a changelog of field-level changes and the order in which they must be applied."
86
+ }
87
+ ],
88
+ "tips": [
89
+ "If a field has 'x-replaced-by', check that replacement field's schema and the decision that drove the change.",
90
+ "A decision with status 'pending' means the change is not yet live — do not depend on the new shape yet.",
91
+ "search_docs with the GH# (e.g. 'GH#48') will surface all docs that reference that issue."
92
+ ]
93
+ },
94
+ {
95
+ "slug": "whatsapp-conversation-display",
96
+ "title": "Displaying WhatsApp conversation history for an order",
97
+ "summary": "Current workaround for rendering a per-order WhatsApp thread using NotificationRecord documents. There is no dedicated WhatsApp conversation model yet; outbound messages are reconstructed from the notification audit log.",
98
+ "workaround_notice": "This is a temporary workaround (GH#48). NotificationRecord captures outbound messages only. Inbound customer replies are not stored in Firestore. A proper WhatsApp conversation model is a future concern.",
99
+ "steps": [
100
+ {
101
+ "step": 1,
102
+ "tool": "get_schema",
103
+ "args": { "name": "notification-record" },
104
+ "note": "Understand the full NotificationRecord shape. Note: every field is readOnly — this is a backend-written audit log, consumers read only."
105
+ },
106
+ {
107
+ "step": 2,
108
+ "tool": "get_doc",
109
+ "args": { "slug": "collections/firestore-paths" },
110
+ "note": "Review the two notification collection paths: company-wide (always written) and order-scoped (dual-write when relatedEntity.type === 'order')."
111
+ },
112
+ {
113
+ "step": 3,
114
+ "action": "query",
115
+ "collection": "companies/{companyId}/orders/{orderId}/notifications",
116
+ "filter": "type == 'whatsapp'",
117
+ "sort": "sentAt ASC",
118
+ "note": "Use the order-scoped subcollection for O(1) per-order lookup. Filter to type='whatsapp' to exclude email/sms/push records."
119
+ },
120
+ {
121
+ "step": 4,
122
+ "action": "render",
123
+ "fields": {
124
+ "message_content": "templateParams — filled-in template variable values at send time; reconstruct the message text without calling the Meta API.",
125
+ "delivery_status": "status — 'sent' | 'failed' | 'pending'",
126
+ "failure_reason": "error — present only when status === 'failed'",
127
+ "timestamp": "sentAt — Firestore Timestamp; convert to local time for display",
128
+ "meta_message_id": "wamid — WhatsApp message ID from Meta; use for deduplication if querying both collection paths"
129
+ },
130
+ "note": "All display fields are reconstructable from the NotificationRecord alone — no Meta API call needed."
131
+ },
132
+ {
133
+ "step": 5,
134
+ "action": "deduplicate",
135
+ "note": "If you query both companies/{cid}/notifications (filtered by relatedEntity.id === orderId) AND the order-scoped subcollection, deduplicate by 'id' — both paths write the same document ID."
136
+ }
137
+ ],
138
+ "related_models": {
139
+ "notification-record": "GH#48 — the model used in this workaround",
140
+ "whatsapp-outbound-message": "GH#43 — dashboard-initiated WhatsApp sends. Separate from backend-automated NotificationRecords but both appear in the conversation thread. Query this collection too for a complete view."
141
+ },
142
+ "tips": [
143
+ "notification-record covers ALL channels (email, whatsapp, sms, push). Always filter by type='whatsapp'.",
144
+ "metadata field may contain 'templateName', 'senderPhoneId', 'orderNumber' — useful for display headers.",
145
+ "The order-scoped subcollection only exists if at least one notification with relatedEntity.type='order' was sent. Check for its absence gracefully.",
146
+ "For a company-wide WhatsApp audit (not order-scoped), query companies/{cid}/notifications filtered by type='whatsapp'."
147
+ ]
148
+ }
149
+ ]
150
+ }