Skip to main content

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.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<RequestDTO[]>
The created requests.

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

data
CreateRequestDTO
required
The request to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<RequestDTO>
The created request.

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

id
string
required
The ID of the request.
data
UpdateRequestDTO
required
The attributes to update in the request.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<RequestDTO>
The updated 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

ids
string[]
required
The IDs of the requests.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
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

id
string
required
The ID of the request.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
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

id
string
required
The ID of the request.
config
FindConfig<RequestDTO>
The configurations determining how the request is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<RequestDTO>
The retrieved 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

filters
FilterableRequestProps
The filters to apply on the retrieved requests.
config
FindConfig<RequestDTO>
The configurations determining how the request is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<RequestDTO[]>
The list of requests.

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

filters
FilterableRequestProps
The filters to apply on the retrieved requests.
config
FindConfig<RequestDTO>
The configurations determining how the request is retrieved.
sharedContext
Context
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

requestIds
string[]
required
The IDs of the requests.
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.
sharedContext
Context
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

requestIds
string[]
required
The IDs of the requests.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the request.
sharedContext
Context
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.