When you generate a service plugin extension, the CLI adds the following files to your project:
<your-service-plugin>.extension.ts: Builds the service plugin.<your-service-plugin>.ts: Defines the service plugin handler logic.The <your-service-plugin>.extension.ts file contains the service plugin builder configuration. This file provides all required configuration for your plugin.
The service plugin builder is defined using the following schema, shown here as a TypeScript type:
Here's an example builder definition for an eCommerce Shipping Rates service plugin:
The following fields are commonly used in the configuration object:
| Field | Type | Description |
|---|---|---|
id | string | Service plugin ID as a (GUID). The ID is automatically generated and must be unique across all extensions in the project. |
name | string | The service plugin name. |
description | string | A short description of what the service plugin does. |
source | string | Path to the service plugin handler file that contains the plugin logic. |
Additional fields may be required or optional depending on the specific service plugin type. You can find the details for each field by locating your service plugin in this table and clicking on the link to view its documentation.
The <your-service-plugin>.ts file contains the service plugin handler logic.
This file contains:
The generated <your-service-plugin>.ts file will contain example code with empty placeholders for each of the functions.
The <your-service-plugin>.ts file must be in the following format:
Here's an example my-service-plugin.ts file for the eCommerce Shipping Rates service plugin:
Your custom logic should be placed inside each handler function. To find out what your function receives in the parameters and what it must return, see the documentation for your specific service plugin. Locate your service plugin in this table and click on the link to view its documentation, then navigate to the specific function in the menu.