@d19n/youfibre-odin-sdk 2.0.116 → 2.0.117

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.
@@ -107,6 +107,20 @@ export declare type KciDispatchDecision = {
107
107
  dateFrom: string;
108
108
  timeBlockFrom: string;
109
109
  supplierReferenceFrom: string;
110
+ /**
111
+ * Optional co-effect — when present, the caller must ALSO apply a
112
+ * PROPERTY_WRITE on the named entity + properties after the
113
+ * schedule-appointment dispatch succeeds. Used by REAPPOINTED /
114
+ * AMENDED rows whose dto carries a new `provideServiceOrder.committedDate`
115
+ * for the rebooked appointment — without this co-effect the Order's
116
+ * CommittedDate would stay frozen at the ORIGINAL committed date and
117
+ * downstream consumers (Supply→Active cron, customer-facing dashboards)
118
+ * make decisions on stale data.
119
+ */
120
+ propertyWrite?: {
121
+ entityKey: YfKciTargetEntity;
122
+ properties: ReadonlyArray<string>;
123
+ };
110
124
  } | {
111
125
  kind: 'PROPERTY_WRITE';
112
126
  row: KciEffectRow;
@@ -193,12 +193,22 @@ exports.KCI_EFFECT_ROWS = [
193
193
  timeBlockFrom: 'provideServiceOrder.appointmentTimeslot.classification',
194
194
  supplierReferenceFrom: 'provideServiceOrder.appointmentReservationReference',
195
195
  },
196
+ // Co-effect: REAPPOINTED's dto also carries an updated
197
+ // `provideServiceOrder.committedDate` for the rebooked appointment.
198
+ // Update Order.CommittedDate atomically with the schedule-appointment
199
+ // dispatch so downstream consumers (Supply→Active cron, dashboards)
200
+ // see the new supplier-committed date rather than the original.
201
+ propertyWrite: {
202
+ entityKey: 'OrderModule:Order',
203
+ properties: ['CommittedDate'],
204
+ },
196
205
  notes: 'Supplier-confirmed reschedule. Bundled effect: WO Pending→Scheduled + ' +
197
- 'set appointment date + stamp supplier reservation reference. Single ' +
198
- 'scheduleAppointment service call handles all three (skipSupplierBooking=true ' +
199
- 'because KCI is the commit, not a request). Target WO resolved from ' +
200
- 'dto.tenantWorkOrderReference; field-service picks the right Scheduled-stage ' +
201
- 'key per WO type.',
206
+ 'set appointment date + stamp supplier reservation reference + write the ' +
207
+ 'new Order.CommittedDate. Single scheduleAppointment service call handles ' +
208
+ 'the WO transition + appointment write (skipSupplierBooking=true because ' +
209
+ 'KCI is the commit, not a request); a follow-on PATCH on the Order writes ' +
210
+ 'CommittedDate. Target WO resolved from dto.tenantWorkOrderReference; ' +
211
+ 'field-service picks the right Scheduled-stage key per WO type.',
202
212
  },
203
213
  logAgainstOrder: true,
204
214
  },
@@ -400,11 +410,23 @@ exports.KCI_EFFECT_ROWS = [
400
410
  timeBlockFrom: 'provideServiceOrder.appointmentTimeslot.classification',
401
411
  supplierReferenceFrom: 'provideServiceOrder.appointmentReservationReference',
402
412
  },
413
+ // Co-effect: AMENDED's dto carries the updated
414
+ // `provideServiceOrder.committedDate` reflecting the new appointment.
415
+ // Update Order.CommittedDate atomically with the WO transition so the
416
+ // YF Order tracks the supplier-committed date for the rebooked slot
417
+ // (same reason as REAPPOINTED — keeps downstream cron / dashboard
418
+ // decisions aligned with the supplier's current commitment).
419
+ propertyWrite: {
420
+ entityKey: 'OrderModule:Order',
421
+ properties: ['CommittedDate'],
422
+ },
403
423
  notes: 'Supplier-confirmed amendment — new appointment locked in. Bundled ' +
404
424
  'effect: WO Pending→Scheduled + set appointment date + stamp supplier ' +
405
- 'reservation reference. Single scheduleAppointment service call handles ' +
406
- 'all three (skipSupplierBooking=true because NET has already accepted ' +
407
- 'the amendment server-side). Target WO resolved from ' +
425
+ 'reservation reference + write the new Order.CommittedDate. The ' +
426
+ 'scheduleAppointment service call handles the WO transition + ' +
427
+ 'appointment write (skipSupplierBooking=true because NET has already ' +
428
+ 'accepted the amendment server-side); a follow-on PATCH on the Order ' +
429
+ 'writes CommittedDate. Target WO resolved from ' +
408
430
  'dto.tenantWorkOrderReference; field-service picks the right ' +
409
431
  'Scheduled-stage key per WO type. ' +
410
432
  'AMENDED is the canonical "supplier has accepted an amendment with new ' +
@@ -499,13 +521,14 @@ function decideKciDispatch(dto) {
499
521
  if (!row.yfEffect.scheduleAppointment) {
500
522
  throw new Error(`bridge invariant: WO_SCHEDULE_APPOINTMENT row ${row.id} missing scheduleAppointment`);
501
523
  }
502
- return {
503
- kind: 'WO_SCHEDULE_APPOINTMENT',
504
- row,
505
- dateFrom: row.yfEffect.scheduleAppointment.dateFrom,
506
- timeBlockFrom: row.yfEffect.scheduleAppointment.timeBlockFrom,
507
- supplierReferenceFrom: row.yfEffect.scheduleAppointment.supplierReferenceFrom,
508
- };
524
+ return Object.assign({ kind: 'WO_SCHEDULE_APPOINTMENT', row, dateFrom: row.yfEffect.scheduleAppointment.dateFrom, timeBlockFrom: row.yfEffect.scheduleAppointment.timeBlockFrom, supplierReferenceFrom: row.yfEffect.scheduleAppointment.supplierReferenceFrom }, (row.yfEffect.propertyWrite
525
+ ? {
526
+ propertyWrite: {
527
+ entityKey: row.yfEffect.propertyWrite.entityKey,
528
+ properties: row.yfEffect.propertyWrite.properties,
529
+ },
530
+ }
531
+ : {}));
509
532
  case 'PROPERTY_WRITE':
510
533
  if (!row.yfEffect.propertyWrite) {
511
534
  throw new Error(`bridge invariant: PROPERTY_WRITE row ${row.id} missing propertyWrite`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d19n/youfibre-odin-sdk",
3
- "version": "2.0.116",
3
+ "version": "2.0.117",
4
4
  "description": "",
5
5
  "author": "@d19n",
6
6
  "license": "UNLICENSED",