Skip to main content

IConfigurationModuleService Reference

This section of the documentation provides a reference to the IConfigurationModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Configuration 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 Configuration Module.

Methods


createConfigurationRules

This section provides a reference to the createConfigurationRules method. This belongs to the Configuration Module.

createConfigurationRules(data, sharedContext?): Promise<ConfigurationRuleDTO[]>

This method creates configuration rules.

Example

const rules = await configurationModuleService.createConfigurationRules([
  {
    rule_type: "require_product_approval",
    is_enabled: true,
  },
  {
    rule_type: "product_import_enabled",
    is_enabled: false,
  },
])

Parameters

data
CreateConfigurationRuleDTO[]
required
The configuration rules to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<ConfigurationRuleDTO[]>
The created configuration rules.

createConfigurationRules(data, sharedContext?): Promise<ConfigurationRuleDTO>

This method creates a configuration rule.

Example

const rule = await configurationModuleService.createConfigurationRules({
  rule_type: "require_product_approval",
  is_enabled: true,
})

Parameters

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

Returns

Promise
Promise<ConfigurationRuleDTO>
The created configuration rule.

updateConfigurationRules

This section provides a reference to the updateConfigurationRules method. This belongs to the Configuration Module.

updateConfigurationRules(id, data, sharedContext?): Promise<ConfigurationRuleDTO>

This method updates an existing configuration rule.

Example

const rule = await configurationModuleService.updateConfigurationRules("conf_123", {
  is_enabled: false,
})

Parameters

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

Returns

Promise
Promise<ConfigurationRuleDTO>
The updated configuration rule.

deleteConfigurationRules

This section provides a reference to the deleteConfigurationRules method. This belongs to the Configuration Module.

deleteConfigurationRules(ids, sharedContext?): Promise<void>

This method deletes configuration rules by their IDs.

Example

await configurationModuleService.deleteConfigurationRules(["conf_123", "conf_321"])

Parameters

ids
string[]
required
The IDs of the configuration rules.
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 configuration rules are deleted successfully.

deleteConfigurationRules(id, sharedContext?): Promise<void>

This method deletes a configuration rule by its ID.

Example

await configurationModuleService.deleteConfigurationRules("conf_123")

Parameters

id
string
required
The ID of the configuration rule.
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 configuration rule is deleted successfully.

retrieveConfigurationRule

This section provides a reference to the retrieveConfigurationRule method. This belongs to the Configuration Module. This method retrieves a configuration rule by its ID.

Example

const rule = await configurationModuleService.retrieveConfigurationRule("conf_123")

Parameters

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

Returns

Promise
Promise<ConfigurationRuleDTO>
The retrieved configuration rule.

listConfigurationRules

This section provides a reference to the listConfigurationRules method. This belongs to the Configuration Module. This method retrieves a paginated list of configuration rules based on optional filters and configuration.

Example

To retrieve a list of configuration rules using their IDs:
const rules = await configurationModuleService.listConfigurationRules({
  id: ["conf_123", "conf_321"],
})
To retrieve enabled rules:
const rules = await configurationModuleService.listConfigurationRules({
  is_enabled: true,
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const rules = await configurationModuleService.listConfigurationRules(
  {
    rule_type: "require_product_approval",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableConfigurationRuleProps
The filters to apply on the retrieved configuration rules.
config
FindConfig<ConfigurationRuleDTO>
The configurations determining how the configuration rule is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<ConfigurationRuleDTO[]>
The list of configuration rules.

listAndCountConfigurationRules

This section provides a reference to the listAndCountConfigurationRules method. This belongs to the Configuration Module. This method retrieves a paginated list of configuration rules along with the total count of available configuration rules satisfying the provided filters.

Example

To retrieve a list of configuration rules using their IDs:
const [rules, count] = await configurationModuleService.listAndCountConfigurationRules({
  id: ["conf_123", "conf_321"],
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const [rules, count] = await configurationModuleService.listAndCountConfigurationRules(
  {
    is_enabled: true,
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableConfigurationRuleProps
The filters to apply on the retrieved configuration rules.
config
FindConfig<ConfigurationRuleDTO>
The configurations determining how the configuration rule is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[ConfigurationRuleDTO[], number]>
The list of configuration rules along with their total count.

softDeleteConfigurationRules

This section provides a reference to the softDeleteConfigurationRules method. This belongs to the Configuration Module. This method soft deletes configuration rules by their IDs.

Example

await configurationModuleService.softDeleteConfigurationRules([
  "conf_123",
  "conf_321",
])

Parameters

configurationRuleIds
string[]
required
The IDs of the configuration rules.
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.

restoreConfigurationRules

This section provides a reference to the restoreConfigurationRules method. This belongs to the Configuration Module. This method restores soft deleted configuration rules by their IDs.

Example

await configurationModuleService.restoreConfigurationRules(["conf_123", "conf_321"])

Parameters

configurationRuleIds
string[]
required
The IDs of the configuration rules.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the configuration rule.
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.

isRuleEnabled

This section provides a reference to the isRuleEnabled method. This belongs to the Configuration Module. This method checks whether a specific configuration rule is enabled. If the rule doesn’t exist in the database, it returns the default value for that rule type.

Example

const isEnabled = await configurationModuleService.isRuleEnabled("require_product_approval")

Parameters

type
ConfigurationRuleType
required
The type of the configuration rule to check. Can be global_product_catalog, require_product_approval, product_request_enabled, or product_import_enabled.

Returns

Promise
Promise<boolean>
A boolean indicating whether the configuration rule is enabled.