Skip to content

Commit fa67a0e

Browse files
committed
docs: enhance documentation for Before and After save functions, deprecate response field in favor of extra.response
1 parent 8ded8ec commit fa67a0e

File tree

1 file changed

+184
-1
lines changed

1 file changed

+184
-1
lines changed

adminforth/types/Back.ts

Lines changed: 184 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,45 +737,143 @@ export type DeleteResourceRecordResult = {
737737
* Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
738738
*/
739739
export type BeforeDeleteSaveFunction = (params: {
740+
/**
741+
* Resource info.
742+
*/
740743
resource: AdminForthResource,
744+
/**
745+
* Primary key value of the record to delete.
746+
*/
741747
recordId: any,
742-
adminUser: AdminUser,
748+
/**
749+
* Admin user performing the action.
750+
*/
751+
adminUser: AdminUser,
752+
/**
753+
* Record data before deletion.
754+
*/
743755
record: any,
756+
/**
757+
* Adminforth instance.
758+
*/
744759
adminforth: IAdminForth,
760+
/**
761+
* HTTP response object.
762+
*
763+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
764+
*/
745765
response?: IAdminForthHttpResponse,
766+
/**
767+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
768+
*/
746769
extra?: HttpExtra,
747770
}) => Promise<{ok: boolean, error?: string}>;
748771

749772

750773
export type BeforeEditSaveFunction = (params: {
774+
/**
775+
* Resource info.
776+
*/
751777
resource: AdminForthResource,
778+
/**
779+
* Primary key value of the record to delete.
780+
*/
752781
recordId: any,
782+
/**
783+
* Admin user performing the action.
784+
*/
753785
adminUser: AdminUser,
786+
/*
787+
* Fields to update in record.
788+
*/
754789
updates: any,
790+
/**
791+
* Record with updates
792+
*
793+
* @deprecated. Will be removed in 2.0.0. Use updates instead.
794+
*/
755795
record: any, // legacy, 'updates' should be used instead
796+
/**
797+
* Record data before update.
798+
*/
756799
oldRecord: any,
800+
/**
801+
* Adminforth instance.
802+
*/
757803
adminforth: IAdminForth,
804+
/**
805+
* HTTP response object.
806+
*
807+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
808+
*/
758809
response: IAdminForthHttpResponse,
810+
/**
811+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
812+
*/
759813
extra?: HttpExtra,
760814
}) => Promise<{ok: boolean, error?: string | null}>;
761815

762816
export type BeforeCreateSaveFunction = (params: {
817+
/**
818+
* Resource info.
819+
*/
763820
resource: AdminForthResource,
821+
/**
822+
* Admin user performing the action.
823+
*/
764824
adminUser: AdminUser,
825+
/**
826+
* Record data to create.
827+
*/
765828
record: any,
829+
/**
830+
* Adminforth instance.
831+
*/
766832
adminforth: IAdminForth,
833+
/**
834+
* HTTP response object.
835+
*
836+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
837+
*/
767838
response: IAdminForthHttpResponse,
839+
768840
extra?: HttpExtra,
769841
}) => Promise<{ok: boolean, error?: string | null, newRecordId?: string}>;
770842

771843
export type AfterCreateSaveFunction = (params: {
844+
/**
845+
* Resource info.
846+
*/
772847
resource: AdminForthResource,
848+
/**
849+
* Primary key value of the record to delete.
850+
*/
773851
recordId: any,
852+
/**
853+
* Admin user performing the action.
854+
*/
774855
adminUser: AdminUser,
856+
/**
857+
* Record data after creation.
858+
*/
775859
record: any,
860+
/**
861+
* Adminforth instance.
862+
*/
776863
adminforth: IAdminForth,
864+
/**
865+
* Record with virtual columns after creation.
866+
*/
777867
recordWithVirtualColumns?: any,
868+
/**
869+
* HTTP response object.
870+
*
871+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
872+
*/
778873
response: IAdminForthHttpResponse,
874+
/**
875+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
876+
*/
779877
extra?: HttpExtra,
780878
}) => Promise<{ok: boolean, error?: string}>;
781879

@@ -784,36 +882,107 @@ export type AfterCreateSaveFunction = (params: {
784882
* Return ok: false and error: string to stop execution and show error message to user. Return ok: true to continue execution.
785883
*/
786884
export type AfterDeleteSaveFunction = (params: {
885+
/**
886+
* Resource info.
887+
*/
787888
resource: AdminForthResource,
889+
/**
890+
* Primary key value of the record to delete.
891+
*/
788892
recordId: any,
893+
/**
894+
* Admin user performing the action.
895+
*/
789896
adminUser: AdminUser,
897+
/**
898+
* Record data, that was deleted.
899+
*/
790900
record: any,
901+
/**
902+
* Adminforth instance.
903+
*/
791904
adminforth: IAdminForth,
905+
/**
906+
* HTTP response object.
907+
*
908+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
909+
*/
792910
response: IAdminForthHttpResponse,
911+
/**
912+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
913+
*/
793914
extra?: HttpExtra,
794915
}) => Promise<{ok: boolean, error?: string}>;
795916

796917

797918
export type AfterEditSaveFunction = (params: {
919+
/**
920+
* Resource info.
921+
*/
798922
resource: AdminForthResource,
923+
/**
924+
* Primary key value of the record to delete.
925+
*/
799926
recordId: any,
927+
/**
928+
* Admin user performing the action.
929+
*/
800930
adminUser: AdminUser,
931+
/**
932+
* Record updates.
933+
*/
801934
updates: any,
935+
/**
936+
* Record after update.
937+
*
938+
* @deprecated. Will be removed in 2.0.0. Use updates instead.
939+
*/
802940
record: any, // legacy, 'updates' should be used instead
941+
/**
942+
* Record data before update.
943+
*/
803944
oldRecord: any,
945+
/**
946+
* Adminforth instance.
947+
*/
804948
adminforth: IAdminForth,
949+
/**
950+
* HTTP response object.
951+
*
952+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
953+
*/
805954
response: IAdminForthHttpResponse,
955+
/**
956+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
957+
*/
806958
extra?: HttpExtra,
807959
}) => Promise<{ok: boolean, error?: string}>;
808960

809961
/**
810962
* Allow to get user data before login confirmation, will triger when user try to login.
811963
*/
812964
export type BeforeLoginConfirmationFunction = (params?: {
965+
/**
966+
* Admin user performing the action.
967+
*/
813968
adminUser: AdminUser,
969+
/**
970+
* HTTP response object.
971+
*
972+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
973+
*/
814974
response: IAdminForthHttpResponse,
975+
/**
976+
* Adminforth instance.
977+
*/
815978
adminforth: IAdminForth,
979+
/**
980+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
981+
*/
816982
extra?: HttpExtra,
983+
/**
984+
* Duration of session in format "1s", "1m", "1h", or "1d" (e.g., "30d" for 30 days)
985+
*/
817986
sessionDuration?: string,
818987
}) => Promise<{
819988
error?: string,
@@ -827,9 +996,23 @@ export type BeforeLoginConfirmationFunction = (params?: {
827996
* Allow to make extra authorization
828997
*/
829998
export type AdminUserAuthorizeFunction = ((params?: {
999+
/**
1000+
* Admin user performing the action.
1001+
*/
8301002
adminUser: AdminUser,
1003+
/**
1004+
* HTTP response object.
1005+
*
1006+
* @deprecated Since 1.2.9. Will be removed in 2.0.0. Use extra.response instead.
1007+
*/
8311008
response: IAdminForthHttpResponse,
1009+
/**
1010+
* Adminforth instance.
1011+
*/
8321012
adminforth: IAdminForth,
1013+
/**
1014+
* Extra HTTP information. Prefer using extra.response over the top-level response field.
1015+
*/
8331016
extra?: HttpExtra,
8341017
}) => Promise<{
8351018
error?: string,

0 commit comments

Comments
 (0)