@cxtms/cx-schema 1.9.28 → 1.9.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cxtms/cx-schema",
3
- "version": "1.9.28",
3
+ "version": "1.9.30",
4
4
  "description": "Schema validation package for CXTMS YAML modules",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -5515,6 +5515,10 @@ type commodity {
5515
5515
  allTagNames: [String!]! @cost(weight: "10")
5516
5516
  "Gets only the tags directly assigned to this commodity"
5517
5517
  directTagNames: [String!]! @cost(weight: "10")
5518
+ lastTrackingEvent(
5519
+ eventDefinitionName: String
5520
+ orderBy: String
5521
+ ): trackingEvent @cost(weight: "10")
5518
5522
  }
5519
5523
 
5520
5524
  type commodityStatus {
@@ -119,6 +119,7 @@ Field names as used in workflow expressions: `{{ entity.description }}`, `{{ ent
119
119
  | `getRelatedOrder(filter)` | `Order` | First related order |
120
120
  | `getCommodityTrackingNumber(idPropertyName)` | `TrackingNumber` | Lookup |
121
121
  | `getCommodityAttachments(filter)` | `[Attachment]` | |
122
+ | `lastTrackingEvent(eventDefinitionName, orderBy?)` | `TrackingEvent` | Most recent (or earliest) tracking event, resolved via batched DataLoader. `orderBy` is **honoured**: omit or prefix with `-` for DESC (latest event: `COALESCE(EventDate, Created) DESC, TrackingEventId DESC`); no prefix for ASC (earliest event: same columns ASC). Default is DESC. |
122
123
  | `changeHistory(startDate, endDate, maxResults)` | `[ChangeHistory]` | Audit trail |
123
124
 
124
125
  ## Container/Child Pattern (Self-Referencing)
@@ -108,7 +108,7 @@ These are virtual fields that filter `orderEntities` by type:
108
108
  | `getCharge(chargeDescription)` | `Charge` | Single charge by description |
109
109
  | `getChargesByChargeType(chargeType)` | `[Charge]` | Charges filtered by type |
110
110
  | `getOrderSummary(weightUnit, volumeUnit, dimensionsUnit)` | `OrderSummary` | |
111
- | `lastTrackingEvent(eventDefinitionName)` | `TrackingEvent` | Most recent |
111
+ | `lastTrackingEvent(eventDefinitionName, orderBy?)` | `TrackingEvent` | Most recent (or earliest) tracking event, resolved via batched DataLoader. `orderBy` is **honoured**: omit or prefix with `-` for DESC (latest event: `COALESCE(EventDate, Created) DESC, TrackingEventId DESC`); no prefix for ASC (earliest event: same columns ASC). Default is DESC. |
112
112
  | `businessDays(path: String!)` | `int?` | Business days from the date at `path` to today, using the org's business calendar. `path` is a dot-separated property path on the order (e.g. `"customValues.leg.pickup.scheduledAt"`). Returns `null` if path doesn't resolve or value isn't a parseable date. |
113
113
  | `attachmentsSummary` | `OrderAttachmentSummaryGqlDto` | `.totalCount` (int), `.hasAny` (bool) — batched DataLoader, backed by DB view |
114
114
  | `notesSummary` | `OrderNoteSummaryGqlDto` | `.totalCount` (int), `.hasAny` (bool) — batched DataLoader, backed by DB view |
@@ -97,6 +97,25 @@ orderBy: "customValues.fieldName" # Custom field sort
97
97
  orderBy: "orderNumber~ToInt32" # Type conversion during sort
98
98
  ```
99
99
 
100
+ ### `lastTrackingEvent` synthetic sort path (Order / Commodity)
101
+
102
+ Sort the result list by the winning tracking event of each order or commodity. The "winner" is selected using `COALESCE(EventDate, Created) DESC/ASC, TrackingEventId DESC/ASC` — identical to the DataLoader logic — so SQL-level ordering and per-row resolution are always consistent.
103
+
104
+ ```
105
+ orderBy: "-lastTrackingEvent.eventDate" # Latest event first (DESC)
106
+ orderBy: "lastTrackingEvent.eventDate" # Earliest event first (ASC)
107
+ ```
108
+
109
+ Filter to a specific event type using bracket notation before sorting:
110
+
111
+ ```
112
+ orderBy: "-lastTrackingEvent[eventDefinition.eventName:Departed].eventDate"
113
+ ```
114
+
115
+ - The bracket predicate (`[path:value]`) filters the `TrackingEvents` collection before the winner is picked.
116
+ - Only `.eventDate` is supported as the sub-path. The expression resolves to `COALESCE(winner.EventDate, winner.Created)`, so null `EventDate` values fall back to `Created`.
117
+ - Works on both `orders` and `commodities` top-level queries.
118
+
100
119
  ## Pagination
101
120
 
102
121
  ```graphql