BeefreeSDK / beefree-sdk-npm-official

Official NPM package of Beefree SDK
https://developers.beefree.io
Apache License 2.0
19 stars 7 forks source link

chore: added custom attributes type #159

Closed davidesamp closed 1 month ago

davidesamp commented 1 month ago

Description

Motivation and Context

Align typing with documentation https://docs.beefree.io/beefree-sdk/other-customizations/advanced-options/custom-attributes

Usage examples

import BeefreeSDK from '@beefree.io/sdk'
import { CustomAttributes, IBeeConfig, IEntityContentJson } from '@beefree.io/sdk/dist/types/bee'

const customAttributes: CustomAttributes = {
 //You can also add only enableOpenFields option to basic use
 //enableOpenFields: true,
  attributes: [ 
    {
      key: "data-country",
      value: ['us', 'italy', 'france', 'germany'],
      target: "link"
    },
    {
      key: "Deeplink",
      value: true,
      target: "link"
    },
    {
      key: "data-segment",
      value: ['travel', 'luxury'],
      target: "link"
    },
    {
      key: "data-descriptor",
      value: "",
      target: "link"
    },
    {
      key: "data-campaign",
      value: ['ua001', 'ua002'],
      target: "link"
    },
    {
      key: "class",
      target: "tag"
    }
  ]
}

const beeConfig :IBeeConfig = {
 uid: 'test1-clientside',
 container: 'bee-plugin-container',
 customAttributes,
....
}

const yourTemplate: IEntityContentJson = {...}
const sdk = new BeefreeSDK()
sdk.getToken('your-client-id', 'your-client-secrets').then(() => {
   sdk.start(beeConfig, yourTemplate, )
})

Types of changes

github-actions[bot] commented 1 month ago

Code Coverage Report

Coverage after merging type/customAttributes into master

81.94%
Coverage Report
FileBranchesFuncsLinesUncovered Lines
src
   index.ts60%5.88%57.95%..., 85, 95, 96, 99
src/services
   api.ts100%50%100%
   axios.ts100%100%100%
src/types
   bee.ts100%100%100%
src/utils
   Constants.ts100%100%100%
   utils.ts0%0%73.33%..., 8, 8, 8, 8