@capillarytech/creatives-library 8.0.153 → 8.0.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/config/app.js CHANGED
@@ -20,7 +20,7 @@ const config = {
20
20
  accountConfig: (strs, accountId) => `${window.location.origin}/org/config/AccountAdd?q=a&channelId=2&accountId=${accountId}&edit=1`,
21
21
  },
22
22
  development: {
23
- api_endpoint: 'http://localhost:2022/arya/api/v1/creatives',
23
+ api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/creatives',
24
24
  campaigns_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/campaigns',
25
25
  campaigns_api_org_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/org/campaign',
26
26
  auth_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/auth',
package/index.js CHANGED
@@ -103,13 +103,7 @@ import Rcs from './v2Containers/Rcs';
103
103
  import rcsReducer from './v2Containers/Rcs/reducer';
104
104
  import rcsSaga from './v2Containers/Rcs/sagas';
105
105
 
106
- // Utils
107
- import {
108
- convertMediaTagsToUrls,
109
- convertUrlsToMediaTags,
110
- } from './utils/transformTemplateConfig';
111
-
112
- //API Imports
106
+ //API Imports
113
107
  import { updateMetaConfig } from './services/api';
114
108
 
115
109
  export {default as Ebill} from './v2Containers/Ebill';
@@ -190,7 +184,5 @@ export { CapContainer,
190
184
  RcsContainer,
191
185
  ZaloContainer,
192
186
  InAppContainer,
193
- convertMediaTagsToUrls,
194
- convertUrlsToMediaTags,
195
187
  updateMetaConfig,
196
188
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.153",
4
+ "version": "8.0.155",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -55,4 +55,4 @@
55
55
  "webpack-bugsnag-plugins": "^1.4.3",
56
56
  "whatwg-fetch": "3.0.0"
57
57
  }
58
- }
58
+ }
package/services/api.js CHANGED
@@ -329,11 +329,6 @@ export const getTemplateDetails = async ({id, channel}) => {
329
329
  return { ...compressedTemplatesData, response: decompressData};
330
330
  };
331
331
 
332
- export const getMediaDetails = async ({ id }) => {
333
- const url = `${API_ENDPOINT}/media/${id}`;
334
- return request(url, getAPICallObject('GET'));
335
- };
336
-
337
332
  export const getAllTemplates = async ({channel, queryParams = {}}) => {
338
333
  const url = getUrlWithQueryParams({
339
334
  url: `${API_ENDPOINT}/templates/v1/${channel}?`,
@@ -391,12 +386,13 @@ export const uploadFile = ({
391
386
  data.append('appSecret', wechatParams.appSecret);
392
387
  }
393
388
  if (whatsappParams) {
394
- const { source, wabaId, accessToken, access_token, phoneId, hostName } = whatsappParams;
389
+ const { source, wabaId, accessToken, access_token, phoneId, hostName, baseUrl } = whatsappParams;
395
390
  data.append('source', source);
396
391
  data.append('wabaId', wabaId);
397
392
  data.append('accessToken', accessToken || access_token);
398
393
  data.append('phoneId', phoneId);
399
394
  data.append('hostName', hostName);
395
+ data.append('baseUrl', baseUrl);
400
396
  }
401
397
  const url = `${API_ENDPOINT}/assets/${assetType}`;
402
398
  // return API.post(url, data, true);
@@ -24,7 +24,6 @@ import {
24
24
  createTestMessageMeta,
25
25
  updateTestMessageMeta,
26
26
  updateMetaConfig,
27
- getMediaDetails,
28
27
  } from '../api';
29
28
  import { mockData } from './mockData';
30
29
  import getSchema from '../getSchema';
@@ -70,6 +69,7 @@ describe('uploadFile -- whatsapp image upload', () => {
70
69
  wabaId: '107499611940863',
71
70
  accessToken: 'Bearer gDwEuRIm9icV6phixociSw==',
72
71
  hostName: 'karixwhatsappbulk',
72
+ baseUrl: 'https://api.whatsapp.com/v1',
73
73
  },
74
74
  }),
75
75
  ).toEqual(Promise.resolve()));
@@ -823,28 +823,3 @@ describe('updateMetaConfig', () => {
823
823
  });
824
824
  });
825
825
  });
826
-
827
- describe('getMediaDetails', () => {
828
- it('should return correct response on success', async () => {
829
- global.fetch.mockReturnValue(Promise.resolve({
830
- status: 200,
831
- json: () => Promise.resolve({
832
- status: 200,
833
- response: 'test media details',
834
- }),
835
- }));
836
- const result = await getMediaDetails({ id: 'testId' });
837
- expect(result).toEqual({
838
- status: 200,
839
- response: 'test media details',
840
- });
841
- });
842
-
843
- it('should handle fetch failure', async () => {
844
- global.fetch.mockRejectedValue({ error: 'Network error' });
845
- const result = await getMediaDetails({ id: 'testId' });
846
- expect(result).toEqual({
847
- error: 'Network error',
848
- });
849
- });
850
- });
@@ -18,6 +18,7 @@ describe('HAPTIC API Integration Tests', () => {
18
18
  access_token: 'haptic-token',
19
19
  phoneId: 'phone-456',
20
20
  hostName: 'hapticwhatsappbulk',
21
+ baseUrl: 'https://api.whatsapp.com/v1',
21
22
  };
22
23
 
23
24
  // Mock successful response
@@ -55,6 +56,7 @@ describe('HAPTIC API Integration Tests', () => {
55
56
  expect(formData.get('accessToken')).toBe('haptic-token'); // Note: API converts access_token to accessToken
56
57
  expect(formData.get('phoneId')).toBe('phone-456');
57
58
  expect(formData.get('hostName')).toBe('hapticwhatsappbulk');
59
+ expect(formData.get('baseUrl')).toBe('https://api.whatsapp.com/v1');
58
60
  });
59
61
 
60
62
  it('should handle missing HAPTIC parameters gracefully', () => {
@@ -83,6 +85,7 @@ describe('HAPTIC API Integration Tests', () => {
83
85
  expect(formData.get('accessToken')).toBe('undefined');
84
86
  expect(formData.get('phoneId')).toBe('undefined');
85
87
  expect(formData.get('hostName')).toBe('undefined');
88
+ expect(formData.get('baseUrl')).toBe('undefined');
86
89
  });
87
90
 
88
91
  it('should handle undefined whatsappParams', () => {
@@ -109,6 +112,7 @@ describe('HAPTIC API Integration Tests', () => {
109
112
  expect(formData.get('accessToken')).toBeNull();
110
113
  expect(formData.get('phoneId')).toBeNull();
111
114
  expect(formData.get('hostName')).toBeNull();
115
+ expect(formData.get('baseUrl')).toBeNull();
112
116
  });
113
117
 
114
118
  it('should handle empty string parameters', () => {
@@ -119,6 +123,7 @@ describe('HAPTIC API Integration Tests', () => {
119
123
  access_token: '',
120
124
  phoneId: '',
121
125
  hostName: '',
126
+ baseUrl: '',
122
127
  };
123
128
 
124
129
  fetch.mockResolvedValueOnce({
@@ -139,6 +144,7 @@ describe('HAPTIC API Integration Tests', () => {
139
144
  expect(formData.get('accessToken')).toBe('');
140
145
  expect(formData.get('phoneId')).toBe('');
141
146
  expect(formData.get('hostName')).toBe('');
147
+ expect(formData.get('baseUrl')).toBe('');
142
148
  });
143
149
 
144
150
  it('should handle null parameters', () => {
@@ -149,6 +155,7 @@ describe('HAPTIC API Integration Tests', () => {
149
155
  access_token: null,
150
156
  phoneId: null,
151
157
  hostName: null,
158
+ baseUrl: null,
152
159
  };
153
160
 
154
161
  fetch.mockResolvedValueOnce({
@@ -37,6 +37,7 @@ export const mockData = {
37
37
  accountId: '2000222347',
38
38
  accessToken: 'DTpZEh4VK',
39
39
  hostName: 'gupshupwhatsappbulk',
40
+ baseUrl: 'https://api.gupshup.io/whatsapp/v1',
40
41
  },
41
42
  },
42
43
  },
@@ -81,7 +81,7 @@ const SlideBoxWrapper = styled.div`
81
81
  export class Creatives extends React.Component {
82
82
  constructor(props) {
83
83
  super(props);
84
-
84
+
85
85
  const initialSlidBoxContent = this.getSlideBoxContent({ mode: props.creativesMode, templateData: props.templateData, isFullMode: props.isFullMode });
86
86
 
87
87
  this.state = {
@@ -954,7 +954,6 @@ export class Creatives extends React.Component {
954
954
  default:
955
955
  break;
956
956
  }
957
-
958
957
  templateData = {
959
958
  channel,
960
959
  accountId,
@@ -962,7 +961,7 @@ export class Creatives extends React.Component {
962
961
  accountName: accountDetails?.name || '',
963
962
  messageBody: languages[0].content,
964
963
  templateConfigs: {
965
- id: template?._id,
964
+ id: template?.value?.name,
966
965
  name: template?.value?.name,
967
966
  template: templateEditor,
968
967
  varMapped,
@@ -81,6 +81,7 @@ export const senderDetailsWhatsapp = {
81
81
  wabaId: "testSourceAccount",
82
82
  userid: "testSourceAccount",
83
83
  sourceAccountIdentifier: "testSourceAccount",
84
+ baseUrl: "https://api.whatsapp.com/v1",
84
85
  },
85
86
  hostname: "testWhatsappHost",
86
87
  },
@@ -39,6 +39,7 @@ import {
39
39
  CAP_WHITE,
40
40
  } from '@capillarytech/cap-ui-library/styled/variables';
41
41
  import { makeSelectWhatsapp, makeSelectAccount } from './selectors';
42
+ import { makeSelectTemplates } from '../Templates/selectors';
42
43
  import {
43
44
  isLoadingMetaEntities,
44
45
  makeSelectMetaEntities,
@@ -135,6 +136,23 @@ let editContent = {};
135
136
  let tagValidationResponse = {};
136
137
  let headerTagValidationResponse = {};
137
138
 
139
+ // Function to extract baseUrl from domainProperties
140
+ export const extractBaseUrlFromDomainProperties = (selectedSourceAccountIdentifier, domainPropertiesData = []) => {
141
+ if (!selectedSourceAccountIdentifier || isEmpty(domainPropertiesData)) {
142
+ return '';
143
+ }
144
+
145
+ // Handle both API response structure and processed Redux state
146
+ const whatsappDomainProperties = domainPropertiesData?.entity?.WHATSAPP || domainPropertiesData;
147
+
148
+ const domainProperty = whatsappDomainProperties?.find(({ domainProperties }) => {
149
+ const { connectionProperties: { sourceAccountIdentifier } = {} } = domainProperties || {};
150
+ return sourceAccountIdentifier === selectedSourceAccountIdentifier;
151
+ });
152
+
153
+ return domainProperty?.domainProperties?.connectionProperties?.baseUrl || '';
154
+ };
155
+
138
156
  export const Whatsapp = (props) => {
139
157
  const {
140
158
  intl,
@@ -184,6 +202,7 @@ export const Whatsapp = (props) => {
184
202
  const [accessToken, setAccessToken] = useState('');
185
203
  const [accountName, setAccountName] = useState('');
186
204
  const [host, setHost] = useState('');
205
+ const [baseUrl, setBaseUrl] = useState('');
187
206
  const [spin, setSpin] = useState(false);
188
207
  const [unsubscribeRequired, setUnsubscribeRequired] = useState(false);
189
208
  const [securityWarningReqd, setSecurityWarningReqd] = useState(false);
@@ -276,8 +295,14 @@ export const Whatsapp = (props) => {
276
295
  setAccessToken(configs.accessToken || '');
277
296
  setAccountName(name);
278
297
  setHost(hostName);
298
+
299
+ // Extract baseUrl from domainProperties
300
+ const { senderDetails = {} } = props.Templates || {};
301
+ const { domainProperties = [] } = senderDetails;
302
+ const extractedBaseUrl = extractBaseUrlFromDomainProperties(sourceAccountIdentifier, domainProperties);
303
+ setBaseUrl(extractedBaseUrl);
279
304
  }
280
- }, [accountData.selectedWhatsappAccount]);
305
+ }, [accountData.selectedWhatsappAccount, props.Templates?.senderDetails]);
281
306
 
282
307
  //gets template details
283
308
  const paramObj = params || {};
@@ -1073,6 +1098,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1073
1098
  wabaId: accountId,
1074
1099
  phoneId,
1075
1100
  hostName: host,
1101
+ baseUrl: baseUrl,
1076
1102
  };
1077
1103
 
1078
1104
  // Add the correct access token field based on host
@@ -1613,6 +1639,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
1613
1639
  accessToken,
1614
1640
  }),
1615
1641
  hostName: host,
1642
+ baseUrl: baseUrl,
1616
1643
  ...(isBtnTypeQuickReply && {
1617
1644
  buttonType,
1618
1645
  buttons: getQuickReplyData(),
@@ -2981,6 +3008,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2981
3008
  const mapStateToProps = createStructuredSelector({
2982
3009
  editData: makeSelectWhatsapp(),
2983
3010
  accountData: makeSelectAccount(),
3011
+ Templates: makeSelectTemplates(),
2984
3012
  metaEntities: makeSelectMetaEntities(),
2985
3013
  loadingTags: isLoadingMetaEntities(),
2986
3014
  injectedTags: setInjectedTags(),