IRequestModuleService Reference
This section of the documentation provides a reference to the IRequestModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Request Module.
You should only use the methods in this reference when implementing complex customizations. For common cases, check out available workflows instead.
The main service interface for the Request Module.
Methods
createRequests
This section provides a reference to the createRequests method. This belongs to the Request Module.
createRequests(data, sharedContext?): Promise<RequestDTO[]>
This method creates requests.
Example
const requests = await requestModuleService . createRequests ([
{
type: "product" ,
submitter_id: "mem_123" ,
data: {
title: "New Product" ,
description: "Product description" ,
},
status: "pending" ,
},
{
type: "product_category" ,
submitter_id: "mem_123" ,
data: {
name: "Electronics" ,
parent_category_id: null ,
},
},
])
Parameters
data
CreateRequestDTO[]
required
The requests to be created. The type of the request. Can be product, product_collection, product_type, product_category, product_tag, or review_remove.
The ID of the seller member who submitted the request.
The request payload containing the proposed entity data.
status
"pending" | "accepted" | "rejected" | "draft"
The status of the request.
The ID of the admin user who reviewed the request.
The admin’s note explaining their decision.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
createRequests(data, sharedContext?): Promise<RequestDTO>
This method creates a request.
Example
const request = await requestModuleService . createRequests ({
type: "product" ,
submitter_id: "mem_123" ,
data: {
title: "New Product" ,
description: "Product description" ,
},
status: "pending" ,
})
Parameters
The request to be created. The type of the request. Can be product, product_collection, product_type, product_category, product_tag, or review_remove.
The ID of the seller member who submitted the request.
The request payload containing the proposed entity data.
status
"pending" | "accepted" | "rejected" | "draft"
The status of the request.
The ID of the admin user who reviewed the request.
The admin’s note explaining their decision.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
updateRequests
This section provides a reference to the updateRequests method. This belongs to the Request Module.
updateRequests(id, data, sharedContext?): Promise<RequestDTO>
This method updates an existing request.
Example
Accepting a request:
const request = await requestModuleService . updateRequests ( "req_123" , {
reviewer_id: "user_123" ,
reviewer_note: "Looks good, approved" ,
status: "accepted" ,
})
Rejecting a request:
const request = await requestModuleService . updateRequests ( "req_123" , {
reviewer_id: "user_123" ,
reviewer_note: "Duplicate product" ,
status: "rejected" ,
})
Parameters
The attributes to update in the request. The ID of the admin user who reviewed the request.
The admin’s note explaining their decision.
status
"pending" | "accepted" | "rejected" | "draft"
required
The status of the request.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
The updated request. The request payload containing the proposed entity data.
The ID of the seller member who submitted the request.
The ID of the admin user who reviewed the request.
The admin’s note explaining their decision.
status
"pending" | "accepted" | "rejected"
The status of the request.
The created date of the request.
The updated date of the request.
deleteRequests
This section provides a reference to the deleteRequests method. This belongs to the Request Module.
deleteRequests(ids, sharedContext?): Promise<void>
This method deletes requests by their IDs.
Example
await requestModuleService . deleteRequests ([ "req_123" , "req_321" ])
Parameters
A context used to share resources, such as transaction manager, between the application and the module.
Returns
Resolves when the requests are deleted successfully.
deleteRequests(id, sharedContext?): Promise<void>
This method deletes a request by its ID.
Example
await requestModuleService . deleteRequests ( "req_123" )
Parameters
A context used to share resources, such as transaction manager, between the application and the module.
Returns
Resolves when the request is deleted successfully.
retrieveRequest
This section provides a reference to the retrieveRequest method. This belongs to the Request Module.
This method retrieves a request by its ID.
Example
const request = await requestModuleService . retrieveRequest ( "req_123" )
Parameters
The configurations determining how the request is retrieved. An array of strings, each being attribute names of the entity to retrieve in the result.
A number indicating the number of records to skip before retrieving the results.
A number indicating the number of records to return in the result.
An array of strings, each being relation names of the entity to retrieve in the result. Use Query to retrieve linked submitter or reviewer data.
order
Record<string, "ASC" | "DESC">
An object used to specify how to sort the returned records.
A boolean indicating whether deleted records should also be retrieved as part of the result.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
The retrieved request. The request payload containing the proposed entity data.
The ID of the seller member who submitted the request.
The ID of the admin user who reviewed the request.
The admin’s note explaining their decision.
status
"pending" | "accepted" | "rejected"
The status of the request.
The created date of the request.
The updated date of the request.
listRequests
This section provides a reference to the listRequests method. This belongs to the Request Module.
This method retrieves a paginated list of requests based on optional filters and configuration.
Example
To retrieve pending requests:
const requests = await requestModuleService . listRequests ({
status: "pending" ,
})
To retrieve requests by type:
const requests = await requestModuleService . listRequests ({
type: "product" ,
})
To retrieve requests from a specific seller:
const requests = await requestModuleService . listRequests ({
submitter_id: "mem_123" ,
})
By default, only the first 15 records are retrieved. You can control pagination:
const requests = await requestModuleService . listRequests (
{
status: "pending" ,
},
{
take: 20 ,
skip: 2 ,
}
)
Parameters
The filters to apply on the retrieved requests. The IDs to filter the requests by.
Filter requests by their types.
Filter requests by their submitter IDs.
Filter requests by their reviewer IDs.
Filter requests by their status.
The configurations determining how the request is retrieved. An array of strings, each being attribute names of the entity to retrieve in the result.
A number indicating the number of records to skip before retrieving the results.
A number indicating the number of records to return in the result.
An array of strings, each being relation names of the entity to retrieve in the result.
order
Record<string, "ASC" | "DESC">
An object used to specify how to sort the returned records.
A boolean indicating whether deleted records should also be retrieved as part of the result.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
listAndCountRequests
This section provides a reference to the listAndCountRequests method. This belongs to the Request Module.
This method retrieves a paginated list of requests along with the total count of available requests satisfying the provided filters.
Example
To retrieve pending requests with count:
const [ requests , count ] = await requestModuleService . listAndCountRequests ({
status: "pending" ,
})
By default, only the first 15 records are retrieved. You can control pagination:
const [ requests , count ] = await requestModuleService . listAndCountRequests (
{
type: "product" ,
status: "pending" ,
},
{
take: 20 ,
skip: 2 ,
}
)
Parameters
The filters to apply on the retrieved requests. The IDs to filter the requests by.
Filter requests by their types.
Filter requests by their submitter IDs.
Filter requests by their reviewer IDs.
Filter requests by their status.
The configurations determining how the request is retrieved. An array of strings, each being attribute names of the entity to retrieve in the result.
A number indicating the number of records to skip before retrieving the results.
A number indicating the number of records to return in the result.
An array of strings, each being relation names of the entity to retrieve in the result.
order
Record<string, "ASC" | "DESC">
An object used to specify how to sort the returned records.
A boolean indicating whether deleted records should also be retrieved as part of the result.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
Promise
Promise<[RequestDTO[], number]>
The list of requests along with their total count.
softDeleteRequests
This section provides a reference to the softDeleteRequests method. This belongs to the Request Module.
This method soft deletes requests by their IDs.
Example
await requestModuleService . softDeleteRequests ([
"req_123" ,
"req_321" ,
])
Parameters
config
SoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity’s related entities that should be soft-deleted when the main entity is soft-deleted.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.
restoreRequests
This section provides a reference to the restoreRequests method. This belongs to the Request Module.
This method restores soft deleted requests by their IDs.
Example
await requestModuleService . restoreRequests ([ "req_123" , "req_321" ])
Parameters
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the request.
A context used to share resources, such as transaction manager, between the application and the module.
Returns
Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.