@@ -359,17 +359,16 @@ export interface IAdminForth {
359359 tr ( msg : string , category : string , lang : string , params : any , pluralizationNumber ?: number ) : Promise < string > ;
360360
361361 createResourceRecord (
362- params : { resource : AdminForthResource , record : any , response : IAdminForthHttpResponse , adminUser : AdminUser , extra ?: HttpExtra }
363- ) : Promise < { error ?: string , createdRecord ?: any , newRecordId ?: any } > ;
362+ params : CreateResourceRecordParams ,
363+ ) : Promise < CreateResourceRecordResult > ;
364364
365365 updateResourceRecord (
366- params : { resource : AdminForthResource , recordId : any , record : any , oldRecord : any , adminUser : AdminUser , response : IAdminForthHttpResponse , extra ?: HttpExtra , updates ?: never }
367- | { resource : AdminForthResource , recordId : any , record ?: never , oldRecord : any , adminUser : AdminUser , response : IAdminForthHttpResponse , extra ?: HttpExtra , updates : any }
368- ) : Promise < { error ?: string } > ;
366+ params : UpdateResourceRecordParams ,
367+ ) : Promise < UpdateResourceRecordResult > ;
369368
370369 deleteResourceRecord (
371- params : { resource : AdminForthResource , recordId : string , adminUser : AdminUser , record : any , response : IAdminForthHttpResponse , extra ?: HttpExtra }
372- ) : Promise < { error ?: string } > ;
370+ params : DeleteResourceRecordParams ,
371+ ) : Promise < DeleteResourceRecordResult > ;
373372
374373 auth : IAdminForthAuth ;
375374
@@ -534,7 +533,205 @@ export interface HttpExtra {
534533 cookies : Record < string , string > ,
535534 requestUrl : string ,
536535 meta ?: any ,
536+ response : IAdminForthHttpResponse
537537}
538+
539+ /**
540+ * Result of {@link IAdminForth.createResourceRecord}.
541+ */
542+ export type CreateResourceRecordResult = {
543+ /** Optional error message if creation failed. */
544+ error ?: string ;
545+
546+ /** Created record as returned from the connector. */
547+ createdRecord ?: any ;
548+
549+ /**
550+ * Optional id of an existing record to redirect to
551+ * (used when a beforeSave hook aborts creation and supplies newRecordId).
552+ */
553+ newRecordId ?: any ;
554+ } ;
555+
556+ /**
557+ * Parameters for {@link IAdminForth.createResourceRecord}.
558+ */
559+ export type CreateResourceRecordParams = {
560+ /**
561+ * Resource configuration used to create a record.
562+ */
563+ resource : AdminForthResource ;
564+
565+ /**
566+ * Record data to create.
567+ */
568+ record : any ;
569+
570+ /**
571+ * Admin user performing the action.
572+ */
573+ adminUser : AdminUser ;
574+
575+ /**
576+ * HTTP response object.
577+ *
578+ * @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
579+ */
580+ response : IAdminForthHttpResponse ;
581+
582+ /**
583+ * Extra HTTP information. Prefer using extra.response over the top-level response field.
584+ */
585+ extra ?: HttpExtra ;
586+ } ;
587+
588+ /**
589+ * Parameters for {@link IAdminForth.updateResourceRecord}.
590+ */
591+ export type UpdateResourceRecordParams =
592+ | {
593+ /**
594+ * Resource configuration used to update a record.
595+ */
596+ resource : AdminForthResource ;
597+
598+ /**
599+ * Primary key value of the record to update.
600+ */
601+ recordId : any ;
602+
603+ /**
604+ * Full record data with applied changes.
605+ *
606+ * @deprecated Since 1.2.9. Will be removed in 2.0.0. Use updates instead.
607+ */
608+ record : any ;
609+
610+ /**
611+ * Record data before update.
612+ */
613+ oldRecord : any ;
614+
615+ /**
616+ * Admin user performing the action.
617+ */
618+ adminUser : AdminUser ;
619+
620+ /**
621+ * HTTP response object.
622+ *
623+ * @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
624+ */
625+ response : IAdminForthHttpResponse ;
626+
627+ /**
628+ * Extra HTTP information. Prefer using extra.response over the top-level response field.
629+ */
630+ extra ?: HttpExtra ;
631+
632+ /**
633+ * Partial record data with only changed fields. Mutually exclusive with record.
634+ */
635+ updates ?: never ;
636+ }
637+ | {
638+ /**
639+ * Resource configuration used to update a record.
640+ */
641+ resource : AdminForthResource ;
642+
643+ /**
644+ * Primary key value of the record to update.
645+ */
646+ recordId : any ;
647+
648+ /**
649+ * Full record data with applied changes.
650+ *
651+ * @deprecated Since 1.2.9. Will be removed in 2.0.0. Use updates instead.
652+ */
653+ record ?: never ;
654+
655+ /**
656+ * Record data before update.
657+ */
658+ oldRecord : any ;
659+
660+ /**
661+ * Admin user performing the action.
662+ */
663+ adminUser : AdminUser ;
664+
665+ /**
666+ * HTTP response object.
667+ *
668+ * @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
669+ */
670+ response : IAdminForthHttpResponse ;
671+
672+ /**
673+ * Extra HTTP information. Prefer using extra.response over the top-level response field.
674+ */
675+ extra ?: HttpExtra ;
676+
677+ /**
678+ * Partial record data with only changed fields. Mutually exclusive with record.
679+ */
680+ updates : any ;
681+ } ;
682+
683+ /**
684+ * Parameters for {@link IAdminForth.deleteResourceRecord}.
685+ */
686+ export type DeleteResourceRecordParams = {
687+ /**
688+ * Resource configuration used to delete a record.
689+ */
690+ resource : AdminForthResource ;
691+
692+ /**
693+ * Primary key value of the record to delete.
694+ */
695+ recordId : string ;
696+
697+ /**
698+ * Admin user performing the action.
699+ */
700+ adminUser : AdminUser ;
701+
702+ /**
703+ * Record data before deletion.
704+ */
705+ record : any ;
706+
707+ /**
708+ * HTTP response object.
709+ *
710+ * @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
711+ */
712+ response : IAdminForthHttpResponse ;
713+
714+ /**
715+ * Extra HTTP information. Prefer using extra.response over the top-level response field.
716+ */
717+ extra ?: HttpExtra ;
718+ } ;
719+
720+ /**
721+ * Result of {@link IAdminForth.updateResourceRecord}.
722+ */
723+ export type UpdateResourceRecordResult = {
724+ /** Optional error message if update failed. */
725+ error ?: string ;
726+ } ;
727+
728+ /**
729+ * Result of {@link IAdminForth.deleteResourceRecord}.
730+ */
731+ export type DeleteResourceRecordResult = {
732+ /** Optional error message if delete failed. */
733+ error ?: string ;
734+ } ;
538735/**
539736 * Modify record to change how data is saved to database.
540737 * Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
0 commit comments