toga-ai 1.0.314 → 1.0.315

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.
@@ -6,7 +6,7 @@ project: Library
6
6
  client: elite
7
7
  type: client-feature
8
8
  status: active
9
- updated: 2026-06-15
9
+ updated: 2026-07-10
10
10
  owners: ["snaredla"]
11
11
  files:
12
12
  - library/app/api/toga2.php
@@ -165,5 +165,49 @@ Pass `true` for the dedup GET — errors must not silently empty the dedup array
165
165
  Each ticket sync is wrapped in `try/catch` — exceptions are sent to Sentry and the run
166
166
  continues with the next ticket. A single bad ticket does not abort the whole sync.
167
167
 
168
+ ## Elite-specific sync behaviour
169
+
170
+ ### Department assignment (TOGaDesk → TOGA 2)
171
+ Elite tickets use `c_togadeskDepartmentId` on `Client_Elite.TicketTeams` to reverse-lookup the correct Toga2 team from TOGaDesk's actual `departmentid`. CF84 (custom field storing team name) is **never** updated when an agent manually transfers a ticket between TOGaDesk departments via the UI — so it cannot be used as the sync source for team.
172
+
173
+ Lookup in `syncTogaDesk1TicketIntoToga2Ticket`:
174
+ ```php
175
+ $eliteTeamLookupOptions = [
176
+ 'where' => ['and' => [['c_togadeskDepartmentId' => ['=' => (int) $togadeskTicket->departmentid]]]]
177
+ ];
178
+ $eliteTeamResult = App_Api_Toga2::send(..., 'GET', '/ticket-teams', null, $eliteTeamLookupOptions, ...);
179
+ if ($eliteTeamResult->meta->totalRecordCount == 1) {
180
+ $payload['ticketTeam'] = ['uuid' => $eliteTeamResult->data->ticketTeams[0]->uuid];
181
+ }
182
+ ```
183
+
184
+ **Pending DB migration** — `c_togadeskDepartmentId INT NULL` must be added to `Client_Elite.TicketTeams` with team→dept mappings before this lookup works.
185
+
186
+ ### Timestamp guard (prevents overwriting Freshservice changes)
187
+ Before pushing any field update (priority, status, category, group, type) to Freshservice, the sync compares timestamps:
188
+ ```php
189
+ $eliteOriginalUpdatedAt = ... strtotime($eliteTicket->updated_at) ...; // captured BEFORE reply POSTs
190
+ $togadeskUpdatedAt = strtotime($togadeskLastModified);
191
+ $togadeskUpdateIsMoreRecent = ($togadeskUpdatedAt > $eliteOriginalUpdatedAt);
192
+ ```
193
+ Nothing is written to Freshservice unless TOGaDesk is strictly newer. Safe to reset `TOGA_LAST_TICKET_INTEGRATION_DATETIME` for re-sync — Freshservice changes are protected.
194
+
195
+ ### Reply status badge mapping
196
+ `tickets_replies.newStatus` is set from `$ticketNote->ticketStage->code` when a reply is synced in. Elite code → TOGaDesk status:
197
+
198
+ | Freshservice code | TOGaDesk status |
199
+ |---|---|
200
+ | 2 | Open |
201
+ | 3 | Awaiting User |
202
+ | 6 | In Progress |
203
+ | 4 | Resolved |
204
+ | 5 | Closed |
205
+
206
+ **Gotcha:** `case 2` was previously mapped to `STATUS__NEW_TICKET` (wrong) — fixed 2026-07-10. Replies from Freshservice with status "Open" were showing "New Ticket" badge in TOGaDesk.
207
+
208
+ ### Variable name pollution gotcha
209
+ The Elite team lookup block inside `syncTogaDesk1TicketIntoToga2Ticket` must use its own dedicated options variable (`$eliteTeamLookupOptions`) — never reuse `$method`, `$route`, `$payload`, or `$options`. Those shared variables are consumed by the `send()` call immediately after the block. Reusing them causes the wrong endpoint to be called, resulting in a Sentry crash: `Undefined property: stdClass::$tickets`.
210
+
168
211
  ## Change history
169
212
  - 2026-06-10 — Documented `App_Api_Toga2::syncWithTogadesk` orchestration (bidirectional TOGA 2 ↔ TOGaDesk ticket/note/file sync, watermarks, `ticketNoteFiles` gotcha). (snaredla)
213
+ - 2026-07-10 — Added Elite-specific section: department reverse-lookup via `c_togadeskDepartmentId`, timestamp guard, reply status badge mapping fix (`case 2` → Open), variable pollution gotcha. (snaredla)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toga-ai",
3
- "version": "1.0.314",
3
+ "version": "1.0.315",
4
4
  "description": "TOGA Technology Team Claude Knowledge System — shared AI coding harness with skills, knowledge base CLI, and project installer for Claude Code.",
5
5
  "keywords": [
6
6
  "claude",