@contentful/ecommerce-app-base
- AdditionalDataRenderer
- AdditionalDataRendererProps
- Config
- DeleteFn
- DisabledPredicateFn
- Integration
- MakeCTAFn
- MakeSaveBtnTextFn
- OpenDialogFn
- Pagination
- ParameterDefinition
- Product
- ProductCardVersion
- ProductPreviewsFn
- ProductsFn
- RenderDialogFn
- SKUType
- ValidateParametersFn
Ƭ AdditionalDataRenderer<P
>: (props
: AdditionalDataRendererProps
<P
>) => ReactNode
Name | Type |
---|---|
P |
extends Product = Product |
▸ (props
): ReactNode
Name | Type |
---|---|
props |
AdditionalDataRendererProps <P > |
ReactNode
Ƭ AdditionalDataRendererProps<P
>: Object
Name | Type |
---|---|
P |
extends Product = Product |
Name | Type |
---|---|
product |
P |
Ƭ Config: Record
<string
, unknown
>
Object containing all information configured on the app configuration page.
Ƭ DeleteFn: (index
: number
) => void
▸ (index
): void
Name | Type |
---|---|
index |
number |
void
Ƭ DisabledPredicateFn: (currentValue
: string
[], config
: Config
) => boolean
▸ (currentValue
, config
): boolean
Function that should return true when the button should be disabled.
Name | Type | Description |
---|---|---|
currentValue |
string [] |
Currently selected skus |
config |
Config |
App configuration |
boolean
true, if the button in the field location should be disabled. false, if the button should be enabled
Ƭ Integration<P
>: Object
Name | Type |
---|---|
P |
extends Product = Product |
Name | Type | Description |
---|---|---|
additionalDataRenderer? |
AdditionalDataRenderer <P > |
render additional data with for Product Card version "v2" |
color |
string |
The app's primary color |
description |
string |
Short description of the app |
fetchProductPreviews |
ProductPreviewsFn <P > |
Function that returns a list for a given list of skus. The returned value is used to render a product preview. Param List of skus Param App configuration |
isDisabled |
DisabledPredicateFn |
Function that should return true when the button should be disabled. Param Currently selected assets Param App configuration |
isInOrchestrationEAP? |
boolean |
- |
logo |
string |
Path to the app's logo |
makeCTA |
MakeCTAFn |
Returns the text that is displayed on the button in the field location. Param Type of the field the app is used for. |
name |
string |
Name of the app |
openDialog |
OpenDialogFn |
Function that gets called when app wants to open a dialog. Should return an updated list of skus as a Promise. You probably want to call sdk.openCurrentApp . Example javascript async function openDialog(sdk, currentValue, config) { return await sdk.dialogs.openCurrentApp({ parameters: { config, currentValue }, }); } Param FieldExtensionSDK Param Array of currently selected skus Param App configuration |
parameterDefinitions |
ParameterDefinition [] |
Parameter definition which can be customized on the app configuration page and used in the callback functions. |
productCardVersion? |
ProductCardVersion |
Opt-in to the new Product Card component |
renderDialog |
RenderDialogFn |
Function that gets called within the Iframe when the app is rendered in a dialog location. Example javascript function renderDialog(sdk) { const config = sdk.parameters.invocation; const container = document.createElement('div'); container.innerHTML = `<iframe src="https://example.com/dam?folder=${config.folder}" width="400" height="650" style="border:none;"/>`; document.body.appendChild(container); } Param DialogExtensionSDK |
skuTypes? |
SKUType [] |
If your app supports multiple sku types (for example - product, product variant, category...) you can provide a list here. This configuration will be stored under the skuTypes key in your installation parameters. |
validateParameters |
ValidateParametersFn |
Custom code that validates installation parameters that is run before saving. Param Object containing the entered parameters. |
Ƭ MakeCTAFn: (fieldType
: string
, skuType?
: string
) => string
▸ (fieldType
, skuType?
): string
Returns the text that is displayed on the button in the field location.
Name | Type | Description |
---|---|---|
fieldType |
string |
Type of the field the app is used for. |
skuType? |
string |
SKU type of the current field. Undefined if only a single SKU type is supported by the app. |
string
Text that should be displayed on the button
Ƭ MakeSaveBtnTextFn: (selectedSKUs
: string
[], skuType?
: string
) => string
▸ (selectedSKUs
, skuType?
): string
Returns the text that is used for confirming the dialog selection.
Name | Type | Description |
---|---|---|
selectedSKUs |
string [] |
An array of SKUs chosen. |
skuType? |
string |
- |
string
Text that should be displayed on the button
Ƭ OpenDialogFn: (sdk
: FieldAppSDK
, currentValue
: string
[] | string
, config
: Config
) => Promise
<string
[]>
▸ (sdk
, currentValue
, config
): Promise
<string
[]>
Function that gets called when app wants to open a dialog. Should return an updated list of skus as a Promise.
You probably want to call sdk.openCurrentApp
.
Name | Type | Description |
---|---|---|
sdk |
FieldAppSDK |
FieldExtensionSDK |
currentValue |
string [] | string |
List of currently selected akus |
config |
Config |
App configuration |
Promise
<string
[]>
Promise containing a list of selected skus
Example
async function openDialog(sdk, currentValue, config) {
return await sdk.dialogs.openCurrentApp({
parameters: { config, currentValue },
});
}
Ƭ Pagination: Object
Name | Type |
---|---|
count |
number |
hasNextPage? |
boolean |
limit |
number |
offset |
number |
total |
number |
Ƭ ParameterDefinition: Object
Definition of app configuration parameters
Name | Type | Description |
---|---|---|
default? |
unknown |
Default value |
description |
string |
Short description/explanation |
id |
string |
Unique id. Used as key in Config object. |
name |
string |
Name / Label |
required |
boolean |
Whether it is possible without providing a value. |
type |
"Symbol" | "List" | "Number" |
Parameter type - Symbol: Text - List: List of texts - Number: Integer |
Ƭ Product: Object
Name | Type |
---|---|
category? |
string |
description? |
string |
displaySKU? |
string |
externalLink? |
string |
id |
string |
image |
string |
name |
string |
sku |
string |
Ƭ ProductCardVersion: "v1"
| "v2"
Ƭ ProductPreviewsFn<P
>: (skus
: string
[], config
: Config
, skuType?
: string
) => Promise
<P
[]>
Name | Type |
---|---|
P |
extends Product = Product |
▸ (skus
, config
, skuType?
): Promise
<P
[]>
Function that returns a list for a given list of skus. The returned value is used to render a product preview.
Name | Type | Description |
---|---|---|
skus |
string [] |
List of skus |
config |
Config |
App configuration |
skuType? |
string |
SKU type of the current field. Undefined if only a single SKU type is supported by the app. |
Promise
<P
[]>
List of Products which is used to render a preview.
Ƭ ProductsFn<P
>: (search
: string
, pagination?
: Partial
<Pagination
>) => Promise
<ProductsFnResponse
<P
>>
Name | Type |
---|---|
P |
extends Product = Product |
▸ (search
, pagination?
): Promise
<ProductsFnResponse
<P
>>
Name | Type |
---|---|
search |
string |
pagination? |
Partial <Pagination > |
Promise
<ProductsFnResponse
<P
>>
Ƭ RenderDialogFn: (sdk
: DialogAppSDK
) => void
▸ (sdk
): void
Function that gets called within the Iframe when the app is rendered in a dialog location.
Name | Type | Description |
---|---|---|
sdk |
DialogAppSDK |
DialogExtensionSDK |
void
Example
function renderDialog(sdk) {
const config = sdk.parameters.invocation;
const container = document.createElement('div');
container.innerHTML = `<iframe src="https://example.com/dam?folder=${config.folder}" width="400" height="650" style="border:none;"/>`;
document.body.appendChild(container);
}
Ƭ SKUType: Object
Name | Type |
---|---|
default? |
boolean |
id |
string |
name |
string |
Ƭ ValidateParametersFn: (parameters
: Record
<string
, string
>) => string
| null
▸ (parameters
): string
| null
Custom code that validates installation parameters that is run before saving.
Name | Type | Description |
---|---|---|
parameters |
Record <string , string > |
Object containg the entered parameters. |
string
| null
string
containing an error message. null
if the parameters are valid.
▸ LinkDataItemRenderer(props
, context?
): null
| ReactElement
<any
, any
>
Name | Type |
---|---|
props |
PropsWithChildren <Props > |
context? |
any |
null
| ReactElement
<any
, any
>
▸ MetaDataRenderer(props
, context?
): null
| ReactElement
<any
, any
>
Name | Type |
---|---|
props |
PropsWithChildren <MetaDataProps > |
context? |
any |
null
| ReactElement
<any
, any
>
▸ RawDataRenderer(props
, context?
): null
| ReactElement
<any
, any
>
Name | Type |
---|---|
props |
PropsWithChildren <Props > |
context? |
any |
null
| ReactElement
<any
, any
>
▸ renderSkuPicker(elementId
, «destructured»
): void
Name | Type |
---|---|
elementId |
string |
«destructured» |
Props |
void
▸ setup<P
>(integration
): void
Name | Type |
---|---|
P |
extends Product = Product |
Name | Type |
---|---|
integration |
Integration <P > |
void