@@ -80,18 +80,22 @@ export async function insertUnassignedStewardships(
8080 return parseInt ( result . count , 10 )
8181}
8282
83+ function toIso ( v : unknown ) : string {
84+ return v instanceof Date ? v . toISOString ( ) : String ( v )
85+ }
86+
8387function mapStewardshipRow ( row : Record < string , unknown > ) : StewardshipRecord {
8488 return {
8589 id : String ( row . id ) ,
8690 packageId : String ( row . package_id ) ,
8791 status : row . status as string ,
8892 origin : row . origin as string ,
8993 version : Number ( row . version ) ,
90- openedAt : row . opened_at ? String ( row . opened_at ) : null ,
91- lastStatusAt : row . last_status_at ? String ( row . last_status_at ) : null ,
94+ openedAt : row . opened_at ? toIso ( row . opened_at ) : null ,
95+ lastStatusAt : row . last_status_at ? toIso ( row . last_status_at ) : null ,
9296 inactiveReason : row . inactive_reason ? String ( row . inactive_reason ) : null ,
93- createdAt : String ( row . created_at ) ,
94- updatedAt : String ( row . updated_at ) ,
97+ createdAt : toIso ( row . created_at ) ,
98+ updatedAt : toIso ( row . updated_at ) ,
9599 }
96100}
97101
@@ -159,7 +163,8 @@ export async function openStewardshipByPurl(
159163/**
160164 * Assigns a steward to a stewardship. Soft-deletes any existing active entry
161165 * for the same user (allowing role changes). Logs a steward_added activity.
162- * Returns the updated stewardship row and the full active stewards list.
166+ * Returns the stewardship row (unchanged by this operation) and the full
167+ * active stewards list as of the end of the transaction.
163168 */
164169export async function assignSteward (
165170 qx : QueryExecutor ,
@@ -213,7 +218,7 @@ export async function assignSteward(
213218 stewardshipId : String ( s . stewardship_id ) ,
214219 userId : String ( s . user_id ) ,
215220 role : String ( s . role ) ,
216- assignedAt : String ( s . assigned_at ) ,
221+ assignedAt : toIso ( s . assigned_at ) ,
217222 assignedBy : s . assigned_by ? String ( s . assigned_by ) : null ,
218223 } ) ) ,
219224 }
@@ -300,11 +305,14 @@ export async function updateStewardshipStatus(
300305 stewardshipId : number ,
301306 data : {
302307 status : UpdatableStewardshipStatus
303- inactiveReason ?: string
308+ inactiveReason ?: InactiveReason
304309 notes ?: string
305310 actorUserId : string
306311 } ,
307312) : Promise < StewardshipRecord | null > {
313+ if ( data . status === 'inactive' && ! data . inactiveReason ) {
314+ throw new Error ( 'inactiveReason is required when setting status to inactive' )
315+ }
308316 const row : Record < string , unknown > | null = await qx . selectOneOrNone (
309317 `
310318 WITH upd AS (
0 commit comments